summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2010-04-01 09:05:59 +0200
committerAndy Wingo <wingo@pobox.com>2010-04-01 09:05:59 +0200
commit7b702b5391fb54114307636934e4d28101655093 (patch)
treefbec1b841f8d612d67cabef6da8b902df4c5872e
parenta587d6a97338a0fd62173e60581ff07f55ec2042 (diff)
fix vector-ref and vector-set opcodes for weak vectors
* libguile/vectors.h (SCM_I_IS_NONWEAK_VECTOR): New internal predicate. * libguile/vm-i-scheme.c (vector-ref, vector-set): Only inline access to nonweak vectors.
-rw-r--r--libguile/vectors.h1
-rw-r--r--libguile/vm-i-scheme.c4
2 files changed, 3 insertions, 2 deletions
diff --git a/libguile/vectors.h b/libguile/vectors.h
index 7f7451945..3746e9026 100644
--- a/libguile/vectors.h
+++ b/libguile/vectors.h
@@ -68,6 +68,7 @@ SCM_API SCM *scm_vector_writable_elements (SCM vec,
#define SCM_I_VECTOR_HEADER_SIZE 2U
#define SCM_I_IS_VECTOR(x) (!SCM_IMP(x) && (SCM_TYP7S(x)==scm_tc7_vector))
+#define SCM_I_IS_NONWEAK_VECTOR(x) (!SCM_IMP(x) && (SCM_TYP7(x)==scm_tc7_vector))
#define SCM_I_VECTOR_ELTS(x) ((const SCM *) SCM_I_VECTOR_WELTS (x))
#define SCM_I_VECTOR_WELTS(x) (SCM_CELL_OBJECT_LOC (x, SCM_I_VECTOR_HEADER_SIZE))
#define SCM_I_VECTOR_LENGTH(x) (((size_t) SCM_CELL_WORD_0 (x)) >> 8)
diff --git a/libguile/vm-i-scheme.c b/libguile/vm-i-scheme.c
index df3181050..af052af1c 100644
--- a/libguile/vm-i-scheme.c
+++ b/libguile/vm-i-scheme.c
@@ -346,7 +346,7 @@ VM_DEFINE_FUNCTION (161, vector_ref, "vector-ref", 2)
{
long i = 0;
ARGS2 (vect, idx);
- if (SCM_LIKELY (SCM_I_IS_VECTOR (vect)
+ if (SCM_LIKELY (SCM_I_IS_NONWEAK_VECTOR (vect)
&& SCM_I_INUMP (idx)
&& ((i = SCM_I_INUM (idx)) >= 0)
&& i < SCM_I_VECTOR_LENGTH (vect)))
@@ -363,7 +363,7 @@ VM_DEFINE_INSTRUCTION (162, vector_set, "vector-set", 0, 3, 0)
long i = 0;
SCM vect, idx, val;
POP (val); POP (idx); POP (vect);
- if (SCM_LIKELY (SCM_I_IS_VECTOR (vect)
+ if (SCM_LIKELY (SCM_I_IS_NONWEAK_VECTOR (vect)
&& SCM_I_INUMP (idx)
&& ((i = SCM_I_INUM (idx)) >= 0)
&& i < SCM_I_VECTOR_LENGTH (vect)))