1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-01 12:20:26 +02:00

attempt to clear stale references on VM C stack

* libguile/vm-engine.h (DEAD): New macro, nulls out a value.

* libguile/vm-i-system.c:
* libguile/vm-i-loader.c:
* libguile/vm-i-scheme.c: Use DEAD when variables become dead.

Later we can #ifdef this out, but I want to give the buildbots a try
with this patch to make sure it's correct.
This commit is contained in:
Andy Wingo 2012-01-27 19:04:46 +01:00
parent c0e4449908
commit 04b2d77354
4 changed files with 229 additions and 10 deletions

View file

@ -1,4 +1,4 @@
/* Copyright (C) 2001, 2009, 2010, 2011 Free Software Foundation, Inc. /* Copyright (C) 2001, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License * modify it under the terms of the GNU Lesser General Public License
@ -152,6 +152,8 @@
#define ASSERT_BOUND(x) #define ASSERT_BOUND(x)
#endif #endif
#define DEAD(v) v = SCM_UNDEFINED
#if VM_CHECK_OBJECT #if VM_CHECK_OBJECT
#define SET_OBJECT_COUNT(n) object_count = n #define SET_OBJECT_COUNT(n) object_count = n
#else #else
@ -325,6 +327,7 @@ do \
CONS (l, x, l); \ CONS (l, x, l); \
} \ } \
PUSH (l); \ PUSH (l); \
DEAD (l); \
} while (0) } while (0)
/* The opposite: push all of the elements in L onto the list. */ /* The opposite: push all of the elements in L onto the list. */
@ -350,7 +353,9 @@ do { \
CONS (l, o, l); \ CONS (l, o, l); \
POP (o); \ POP (o); \
} \ } \
DEAD (o); \
PUSH (l); \ PUSH (l); \
DEAD (l); \
} while (0) } while (0)
#define POP_CONS_MARK() \ #define POP_CONS_MARK() \
@ -363,7 +368,9 @@ do { \
CONS (l, o, l); \ CONS (l, o, l); \
POP (o); \ POP (o); \
} \ } \
DEAD (o); \
PUSH (l); \ PUSH (l); \
DEAD (l); \
} while (0) } while (0)

View file

@ -1,4 +1,4 @@
/* Copyright (C) 2001,2008,2009,2010,2011 Free Software Foundation, Inc. /* Copyright (C) 2001,2008,2009,2010,2011,2012 Free Software Foundation, Inc.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License * modify it under the terms of the GNU Lesser General Public License
@ -73,6 +73,9 @@ VM_DEFINE_LOADER (104, load_program, "load-program")
PUSH (scm_make_program (objcode, objs, SCM_BOOL_F)); PUSH (scm_make_program (objcode, objs, SCM_BOOL_F));
DEAD (objs);
DEAD (objcode);
ip += len; ip += len;
NEXT; NEXT;
@ -84,6 +87,7 @@ VM_DEFINE_INSTRUCTION (105, link_now, "link-now", 0, 1, 1)
POP (what); POP (what);
SYNC_REGISTER (); SYNC_REGISTER ();
PUSH (resolve_variable (what, scm_current_module ())); PUSH (resolve_variable (what, scm_current_module ()));
DEAD (what);
NEXT; NEXT;
} }
@ -95,6 +99,8 @@ VM_DEFINE_LOADER (106, load_array, "load-array")
POP2 (shape, type); POP2 (shape, type);
SYNC_REGISTER (); SYNC_REGISTER ();
PUSH (scm_from_contiguous_typed_array (type, shape, ip, len)); PUSH (scm_from_contiguous_typed_array (type, shape, ip, len));
DEAD (type);
DEAD (shape);
ip += len; ip += len;
NEXT; NEXT;
} }

View file

@ -33,6 +33,7 @@ VM_DEFINE_FUNCTION (128, not, "not", 1)
{ {
ARGS1 (x); ARGS1 (x);
RETURN (scm_from_bool (scm_is_false (x))); RETURN (scm_from_bool (scm_is_false (x)));
DEAD (x);
NEXT; NEXT;
} }
@ -40,6 +41,7 @@ VM_DEFINE_FUNCTION (129, not_not, "not-not", 1)
{ {
ARGS1 (x); ARGS1 (x);
RETURN (scm_from_bool (!scm_is_false (x))); RETURN (scm_from_bool (!scm_is_false (x)));
DEAD (x);
NEXT; NEXT;
} }
@ -47,6 +49,8 @@ VM_DEFINE_FUNCTION (130, eq, "eq?", 2)
{ {
ARGS2 (x, y); ARGS2 (x, y);
RETURN (scm_from_bool (scm_is_eq (x, y))); RETURN (scm_from_bool (scm_is_eq (x, y)));
DEAD (x);
DEAD (y);
NEXT; NEXT;
} }
@ -54,6 +58,8 @@ VM_DEFINE_FUNCTION (131, not_eq, "not-eq?", 2)
{ {
ARGS2 (x, y); ARGS2 (x, y);
RETURN (scm_from_bool (!scm_is_eq (x, y))); RETURN (scm_from_bool (!scm_is_eq (x, y)));
DEAD (x);
DEAD (y);
NEXT; NEXT;
} }
@ -61,6 +67,7 @@ VM_DEFINE_FUNCTION (132, nullp, "null?", 1)
{ {
ARGS1 (x); ARGS1 (x);
RETURN (scm_from_bool (scm_is_null (x))); RETURN (scm_from_bool (scm_is_null (x)));
DEAD (x);
NEXT; NEXT;
} }
@ -68,6 +75,7 @@ VM_DEFINE_FUNCTION (133, not_nullp, "not-null?", 1)
{ {
ARGS1 (x); ARGS1 (x);
RETURN (scm_from_bool (!scm_is_null (x))); RETURN (scm_from_bool (!scm_is_null (x)));
DEAD (x);
NEXT; NEXT;
} }
@ -83,6 +91,8 @@ VM_DEFINE_FUNCTION (134, eqv, "eqv?", 2)
SYNC_REGISTER (); SYNC_REGISTER ();
RETURN (scm_eqv_p (x, y)); RETURN (scm_eqv_p (x, y));
} }
DEAD (x);
DEAD (y);
NEXT; NEXT;
} }
@ -98,6 +108,8 @@ VM_DEFINE_FUNCTION (135, equal, "equal?", 2)
SYNC_REGISTER (); SYNC_REGISTER ();
RETURN (scm_equal_p (x, y)); RETURN (scm_equal_p (x, y));
} }
DEAD (x);
DEAD (y);
NEXT; NEXT;
} }
@ -105,6 +117,7 @@ VM_DEFINE_FUNCTION (136, pairp, "pair?", 1)
{ {
ARGS1 (x); ARGS1 (x);
RETURN (scm_from_bool (scm_is_pair (x))); RETURN (scm_from_bool (scm_is_pair (x)));
DEAD (x);
NEXT; NEXT;
} }
@ -112,6 +125,7 @@ VM_DEFINE_FUNCTION (137, listp, "list?", 1)
{ {
ARGS1 (x); ARGS1 (x);
RETURN (scm_from_bool (scm_ilength (x) >= 0)); RETURN (scm_from_bool (scm_ilength (x) >= 0));
DEAD (x);
NEXT; NEXT;
} }
@ -119,6 +133,7 @@ VM_DEFINE_FUNCTION (138, symbolp, "symbol?", 1)
{ {
ARGS1 (x); ARGS1 (x);
RETURN (scm_from_bool (scm_is_symbol (x))); RETURN (scm_from_bool (scm_is_symbol (x)));
DEAD (x);
NEXT; NEXT;
} }
@ -126,6 +141,7 @@ VM_DEFINE_FUNCTION (139, vectorp, "vector?", 1)
{ {
ARGS1 (x); ARGS1 (x);
RETURN (scm_from_bool (SCM_I_IS_VECTOR (x))); RETURN (scm_from_bool (SCM_I_IS_VECTOR (x)));
DEAD (x);
NEXT; NEXT;
} }
@ -139,6 +155,8 @@ VM_DEFINE_FUNCTION (140, cons, "cons", 2)
ARGS2 (x, y); ARGS2 (x, y);
CONS (x, x, y); CONS (x, x, y);
RETURN (x); RETURN (x);
DEAD (x);
DEAD (y);
NEXT; NEXT;
} }
@ -155,6 +173,7 @@ VM_DEFINE_FUNCTION (141, car, "car", 1)
ARGS1 (x); ARGS1 (x);
VM_VALIDATE_CONS (x, "car"); VM_VALIDATE_CONS (x, "car");
RETURN (SCM_CAR (x)); RETURN (SCM_CAR (x));
DEAD (x);
NEXT; NEXT;
} }
@ -163,6 +182,7 @@ VM_DEFINE_FUNCTION (142, cdr, "cdr", 1)
ARGS1 (x); ARGS1 (x);
VM_VALIDATE_CONS (x, "cdr"); VM_VALIDATE_CONS (x, "cdr");
RETURN (SCM_CDR (x)); RETURN (SCM_CDR (x));
DEAD (x);
NEXT; NEXT;
} }
@ -172,6 +192,8 @@ VM_DEFINE_INSTRUCTION (143, set_car, "set-car!", 0, 2, 0)
POP2 (y, x); POP2 (y, x);
VM_VALIDATE_CONS (x, "set-car!"); VM_VALIDATE_CONS (x, "set-car!");
SCM_SETCAR (x, y); SCM_SETCAR (x, y);
DEAD (x);
DEAD (y);
NEXT; NEXT;
} }
@ -181,6 +203,8 @@ VM_DEFINE_INSTRUCTION (144, set_cdr, "set-cdr!", 0, 2, 0)
POP2 (y, x); POP2 (y, x);
VM_VALIDATE_CONS (x, "set-cdr!"); VM_VALIDATE_CONS (x, "set-cdr!");
SCM_SETCDR (x, y); SCM_SETCDR (x, y);
DEAD (x);
DEAD (y);
NEXT; NEXT;
} }
@ -201,6 +225,8 @@ VM_DEFINE_INSTRUCTION (144, set_cdr, "set-cdr!", 0, 2, 0)
SYNC_REGISTER (); \ SYNC_REGISTER (); \
RETURN (srel (x, y)); \ RETURN (srel (x, y)); \
} \ } \
DEAD (x); \
DEAD (y); \
NEXT; \ NEXT; \
} }
@ -250,11 +276,15 @@ VM_DEFINE_FUNCTION (149, ge, "ge?", 2)
if (SCM_FIXABLE (n)) \ if (SCM_FIXABLE (n)) \
{ \ { \
RETURN (SCM_I_MAKINUM (n)); \ RETURN (SCM_I_MAKINUM (n)); \
DEAD (x); \
DEAD (y); \
NEXT; \ NEXT; \
} \ } \
} \ } \
SYNC_REGISTER (); \ SYNC_REGISTER (); \
RETURN (SFUNC (x, y)); \ RETURN (SFUNC (x, y)); \
DEAD (x); \
DEAD (y); \
NEXT; \ NEXT; \
} }
@ -319,6 +349,8 @@ VM_DEFINE_FUNCTION (150, add, "add", 2)
ASM_ADD (x, y); ASM_ADD (x, y);
SYNC_REGISTER (); SYNC_REGISTER ();
RETURN (scm_sum (x, y)); RETURN (scm_sum (x, y));
DEAD (x);
DEAD (y);
NEXT; NEXT;
#endif #endif
} }
@ -340,12 +372,15 @@ VM_DEFINE_FUNCTION (151, add1, "add1", 1)
if (SCM_LIKELY (SCM_I_INUMP (result))) if (SCM_LIKELY (SCM_I_INUMP (result)))
{ {
RETURN (result); RETURN (result);
DEAD (result);
NEXT; NEXT;
} }
DEAD (result);
} }
SYNC_REGISTER (); SYNC_REGISTER ();
RETURN (scm_sum (x, SCM_I_MAKINUM (1))); RETURN (scm_sum (x, SCM_I_MAKINUM (1)));
DEAD (x);
NEXT; NEXT;
} }
@ -358,6 +393,8 @@ VM_DEFINE_FUNCTION (152, sub, "sub", 2)
ASM_SUB (x, y); ASM_SUB (x, y);
SYNC_REGISTER (); SYNC_REGISTER ();
RETURN (scm_difference (x, y)); RETURN (scm_difference (x, y));
DEAD (x);
DEAD (y);
NEXT; NEXT;
#endif #endif
} }
@ -379,12 +416,15 @@ VM_DEFINE_FUNCTION (153, sub1, "sub1", 1)
if (SCM_LIKELY (SCM_I_INUMP (result))) if (SCM_LIKELY (SCM_I_INUMP (result)))
{ {
RETURN (result); RETURN (result);
DEAD (result);
NEXT; NEXT;
} }
DEAD (result);
} }
SYNC_REGISTER (); SYNC_REGISTER ();
RETURN (scm_difference (x, SCM_I_MAKINUM (1))); RETURN (scm_difference (x, SCM_I_MAKINUM (1)));
DEAD (x);
NEXT; NEXT;
} }
@ -396,6 +436,8 @@ VM_DEFINE_FUNCTION (154, mul, "mul", 2)
ARGS2 (x, y); ARGS2 (x, y);
SYNC_REGISTER (); SYNC_REGISTER ();
RETURN (scm_product (x, y)); RETURN (scm_product (x, y));
DEAD (x);
DEAD (y);
NEXT; NEXT;
} }
@ -404,6 +446,8 @@ VM_DEFINE_FUNCTION (155, div, "div", 2)
ARGS2 (x, y); ARGS2 (x, y);
SYNC_REGISTER (); SYNC_REGISTER ();
RETURN (scm_divide (x, y)); RETURN (scm_divide (x, y));
DEAD (x);
DEAD (y);
NEXT; NEXT;
} }
@ -412,6 +456,8 @@ VM_DEFINE_FUNCTION (156, quo, "quo", 2)
ARGS2 (x, y); ARGS2 (x, y);
SYNC_REGISTER (); SYNC_REGISTER ();
RETURN (scm_quotient (x, y)); RETURN (scm_quotient (x, y));
DEAD (x);
DEAD (y);
NEXT; NEXT;
} }
@ -420,6 +466,8 @@ VM_DEFINE_FUNCTION (157, rem, "rem", 2)
ARGS2 (x, y); ARGS2 (x, y);
SYNC_REGISTER (); SYNC_REGISTER ();
RETURN (scm_remainder (x, y)); RETURN (scm_remainder (x, y));
DEAD (x);
DEAD (y);
NEXT; NEXT;
} }
@ -428,6 +476,8 @@ VM_DEFINE_FUNCTION (158, mod, "mod", 2)
ARGS2 (x, y); ARGS2 (x, y);
SYNC_REGISTER (); SYNC_REGISTER ();
RETURN (scm_modulo (x, y)); RETURN (scm_modulo (x, y));
DEAD (x);
DEAD (y);
NEXT; NEXT;
} }
@ -440,6 +490,8 @@ VM_DEFINE_FUNCTION (159, ash, "ash", 2)
/* Right shift, will be a fixnum. */ /* Right shift, will be a fixnum. */
{ {
RETURN (SCM_I_MAKINUM (SCM_I_INUM (x) >> -SCM_I_INUM (y))); RETURN (SCM_I_MAKINUM (SCM_I_INUM (x) >> -SCM_I_INUM (y)));
DEAD (x);
DEAD (y);
NEXT; NEXT;
} }
else else
@ -455,6 +507,8 @@ VM_DEFINE_FUNCTION (159, ash, "ash", 2)
(SCM_SRS (nn, (SCM_I_FIXNUM_BIT-1 - bits_to_shift)) + 1) (SCM_SRS (nn, (SCM_I_FIXNUM_BIT-1 - bits_to_shift)) + 1)
<= 1)) <= 1))
{ {
DEAD (x);
DEAD (y);
RETURN (SCM_I_MAKINUM (nn << bits_to_shift)); RETURN (SCM_I_MAKINUM (nn << bits_to_shift));
NEXT; NEXT;
} }
@ -464,6 +518,8 @@ VM_DEFINE_FUNCTION (159, ash, "ash", 2)
} }
SYNC_REGISTER (); SYNC_REGISTER ();
RETURN (scm_ash (x, y)); RETURN (scm_ash (x, y));
DEAD (x);
DEAD (y);
NEXT; NEXT;
} }
@ -477,6 +533,8 @@ VM_DEFINE_FUNCTION (160, logand, "logand", 2)
SYNC_REGISTER (); SYNC_REGISTER ();
RETURN (scm_logand (x, y)); RETURN (scm_logand (x, y));
} }
DEAD (x);
DEAD (y);
NEXT; NEXT;
} }
@ -490,6 +548,8 @@ VM_DEFINE_FUNCTION (161, logior, "logior", 2)
SYNC_REGISTER (); SYNC_REGISTER ();
RETURN (scm_logior (x, y)); RETURN (scm_logior (x, y));
} }
DEAD (x);
DEAD (y);
NEXT; NEXT;
} }
@ -503,6 +563,8 @@ VM_DEFINE_FUNCTION (162, logxor, "logxor", 2)
SYNC_REGISTER (); SYNC_REGISTER ();
RETURN (scm_logxor (x, y)); RETURN (scm_logxor (x, y));
} }
DEAD (x);
DEAD (y);
NEXT; NEXT;
} }
@ -525,6 +587,8 @@ VM_DEFINE_FUNCTION (163, vector_ref, "vector-ref", 2)
SYNC_REGISTER (); SYNC_REGISTER ();
RETURN (scm_vector_ref (vect, idx)); RETURN (scm_vector_ref (vect, idx));
} }
DEAD (vect);
DEAD (idx);
NEXT; NEXT;
} }
@ -543,6 +607,9 @@ VM_DEFINE_INSTRUCTION (164, vector_set, "vector-set", 0, 3, 0)
SYNC_REGISTER (); SYNC_REGISTER ();
scm_vector_set_x (vect, idx, val); scm_vector_set_x (vect, idx, val);
} }
DEAD (vect);
DEAD (idx);
DEAD (val);
NEXT; NEXT;
} }
@ -558,8 +625,10 @@ VM_DEFINE_INSTRUCTION (165, make_array, "make-array", 3, -1, 1)
SYNC_REGISTER (); SYNC_REGISTER ();
PRE_CHECK_UNDERFLOW (len); PRE_CHECK_UNDERFLOW (len);
ret = scm_from_contiguous_array (shape, sp - len + 1, len); ret = scm_from_contiguous_array (shape, sp - len + 1, len);
DEAD (shape);
DROPN (len); DROPN (len);
PUSH (ret); PUSH (ret);
DEAD (ret);
NEXT; NEXT;
} }
@ -579,6 +648,7 @@ VM_DEFINE_FUNCTION (166, struct_p, "struct?", 1)
{ {
ARGS1 (obj); ARGS1 (obj);
RETURN (scm_from_bool (SCM_STRUCTP (obj))); RETURN (scm_from_bool (SCM_STRUCTP (obj)));
DEAD (obj);
NEXT; NEXT;
} }
@ -587,6 +657,7 @@ VM_DEFINE_FUNCTION (167, struct_vtable, "struct-vtable", 1)
ARGS1 (obj); ARGS1 (obj);
VM_VALIDATE_STRUCT (obj, "struct_vtable"); VM_VALIDATE_STRUCT (obj, "struct_vtable");
RETURN (SCM_STRUCT_VTABLE (obj)); RETURN (SCM_STRUCT_VTABLE (obj));
DEAD (obj);
NEXT; NEXT;
} }
@ -616,9 +687,11 @@ VM_DEFINE_INSTRUCTION (168, make_struct, "make-struct", 2, -1, 1)
} }
else else
ret = scm_c_make_structv (vtable, 0, n - 1, (scm_t_bits *) inits); ret = scm_c_make_structv (vtable, 0, n - 1, (scm_t_bits *) inits);
DEAD (vtable);
DROPN (n); DROPN (n);
PUSH (ret); PUSH (ret);
DEAD (ret);
NEXT; NEXT;
} }
@ -646,12 +719,16 @@ VM_DEFINE_FUNCTION (169, struct_ref, "struct-ref", 2)
{ {
scm_t_bits *data = SCM_STRUCT_DATA (obj); scm_t_bits *data = SCM_STRUCT_DATA (obj);
RETURN (SCM_PACK (data[index])); RETURN (SCM_PACK (data[index]));
DEAD (obj);
DEAD (pos);
NEXT; NEXT;
} }
} }
SYNC_REGISTER (); SYNC_REGISTER ();
RETURN (scm_struct_ref (obj, pos)); RETURN (scm_struct_ref (obj, pos));
DEAD (obj);
DEAD (pos);
NEXT; NEXT;
} }
@ -677,13 +754,20 @@ VM_DEFINE_FUNCTION (170, struct_set, "struct-set", 3)
{ {
scm_t_bits *data = SCM_STRUCT_DATA (obj); scm_t_bits *data = SCM_STRUCT_DATA (obj);
data[index] = SCM_UNPACK (val); data[index] = SCM_UNPACK (val);
/* FIXME: Shouldn't be returning anything, right? */
RETURN (val); RETURN (val);
DEAD (obj);
DEAD (pos);
DEAD (val);
NEXT; NEXT;
} }
} }
SYNC_REGISTER (); SYNC_REGISTER ();
RETURN (scm_struct_set_x (obj, pos, val)); RETURN (scm_struct_set_x (obj, pos, val));
DEAD (obj);
DEAD (pos);
DEAD (val);
NEXT; NEXT;
} }
@ -701,6 +785,7 @@ VM_DEFINE_FUNCTION (171, class_of, "class-of", 1)
SYNC_REGISTER (); SYNC_REGISTER ();
RETURN (scm_class_of (obj)); RETURN (scm_class_of (obj));
} }
DEAD (obj);
NEXT; NEXT;
} }
@ -710,7 +795,9 @@ VM_DEFINE_FUNCTION (172, slot_ref, "slot-ref", 2)
size_t slot; size_t slot;
ARGS2 (instance, idx); ARGS2 (instance, idx);
slot = SCM_I_INUM (idx); slot = SCM_I_INUM (idx);
DEAD (idx);
RETURN (SCM_PACK (SCM_STRUCT_DATA (instance) [slot])); RETURN (SCM_PACK (SCM_STRUCT_DATA (instance) [slot]));
DEAD (instance);
NEXT; NEXT;
} }
@ -721,7 +808,10 @@ VM_DEFINE_INSTRUCTION (173, slot_set, "slot-set", 0, 3, 0)
size_t slot; size_t slot;
POP3 (val, idx, instance); POP3 (val, idx, instance);
slot = SCM_I_INUM (idx); slot = SCM_I_INUM (idx);
DEAD (idx);
SCM_STRUCT_DATA (instance) [slot] = SCM_UNPACK (val); SCM_STRUCT_DATA (instance) [slot] = SCM_UNPACK (val);
DEAD (instance);
DEAD (val);
NEXT; NEXT;
} }
@ -746,11 +836,17 @@ VM_DEFINE_INSTRUCTION (173, slot_set, "slot-set", 0, 3, 0)
SCM endianness; \ SCM endianness; \
POP (endianness); \ POP (endianness); \
if (scm_is_eq (endianness, scm_i_native_endianness)) \ if (scm_is_eq (endianness, scm_i_native_endianness)) \
goto VM_LABEL (bv_##stem##_native_ref); \ { \
DEAD (endianness); \
goto VM_LABEL (bv_##stem##_native_ref); \
} \
{ \ { \
ARGS2 (bv, idx); \ ARGS2 (bv, idx); \
SYNC_REGISTER (); \ SYNC_REGISTER (); \
RETURN (scm_bytevector_##fn_stem##_ref (bv, idx, endianness)); \ RETURN (scm_bytevector_##fn_stem##_ref (bv, idx, endianness)); \
DEAD (bv); \
DEAD (idx); \
DEAD (endianness); \
NEXT; \ NEXT; \
} \ } \
} }
@ -798,6 +894,8 @@ BV_REF_WITH_ENDIANNESS (f64, ieee_double)
SYNC_REGISTER (); \ SYNC_REGISTER (); \
RETURN (scm_bytevector_ ## fn_stem ## _ref (bv, idx)); \ RETURN (scm_bytevector_ ## fn_stem ## _ref (bv, idx)); \
} \ } \
DEAD (bv); \
DEAD (idx); \
NEXT; \ NEXT; \
} }
@ -830,6 +928,8 @@ BV_REF_WITH_ENDIANNESS (f64, ieee_double)
SYNC_REGISTER (); \ SYNC_REGISTER (); \
RETURN (scm_bytevector_ ## stem ## _native_ref (bv, idx)); \ RETURN (scm_bytevector_ ## stem ## _native_ref (bv, idx)); \
} \ } \
DEAD (bv); \
DEAD (idx); \
NEXT; \ NEXT; \
} }
@ -851,6 +951,8 @@ BV_REF_WITH_ENDIANNESS (f64, ieee_double)
RETURN (scm_from_double (*float_ptr)); \ RETURN (scm_from_double (*float_ptr)); \
else \ else \
RETURN (scm_bytevector_ ## fn_stem ## _native_ref (bv, idx)); \ RETURN (scm_bytevector_ ## fn_stem ## _native_ref (bv, idx)); \
DEAD (bv); \
DEAD (idx); \
NEXT; \ NEXT; \
} }
@ -894,11 +996,18 @@ BV_FLOAT_REF (f64, ieee_double, double, 8)
SCM endianness; \ SCM endianness; \
POP (endianness); \ POP (endianness); \
if (scm_is_eq (endianness, scm_i_native_endianness)) \ if (scm_is_eq (endianness, scm_i_native_endianness)) \
goto VM_LABEL (bv_##stem##_native_set); \ { \
DEAD (endianness); \
goto VM_LABEL (bv_##stem##_native_set); \
} \
{ \ { \
SCM bv, idx, val; POP3 (val, idx, bv); \ SCM bv, idx, val; POP3 (val, idx, bv); \
SYNC_REGISTER (); \ SYNC_REGISTER (); \
scm_bytevector_##fn_stem##_set_x (bv, idx, val, endianness); \ scm_bytevector_##fn_stem##_set_x (bv, idx, val, endianness); \
DEAD (bv); \
DEAD (idx); \
DEAD (val); \
DEAD (endianness); \
NEXT; \ NEXT; \
} \ } \
} }
@ -946,6 +1055,9 @@ BV_SET_WITH_ENDIANNESS (f64, ieee_double)
SYNC_REGISTER (); \ SYNC_REGISTER (); \
scm_bytevector_ ## fn_stem ## _set_x (bv, idx, val); \ scm_bytevector_ ## fn_stem ## _set_x (bv, idx, val); \
} \ } \
DEAD (bv); \
DEAD (idx); \
DEAD (val); \
NEXT; \ NEXT; \
} }
@ -970,6 +1082,9 @@ BV_SET_WITH_ENDIANNESS (f64, ieee_double)
SYNC_REGISTER (); \ SYNC_REGISTER (); \
scm_bytevector_ ## stem ## _native_set_x (bv, idx, val); \ scm_bytevector_ ## stem ## _native_set_x (bv, idx, val); \
} \ } \
DEAD (bv); \
DEAD (idx); \
DEAD (val); \
NEXT; \ NEXT; \
} }
@ -994,6 +1109,9 @@ BV_SET_WITH_ENDIANNESS (f64, ieee_double)
SYNC_REGISTER (); \ SYNC_REGISTER (); \
scm_bytevector_ ## fn_stem ## _native_set_x (bv, idx, val); \ scm_bytevector_ ## fn_stem ## _native_set_x (bv, idx, val); \
} \ } \
DEAD (bv); \
DEAD (idx); \
DEAD (val); \
NEXT; \ NEXT; \
} }

View file

@ -84,6 +84,7 @@ VM_DEFINE_INSTRUCTION (3, dup, "dup", 0, 0, 1)
{ {
SCM x = *sp; SCM x = *sp;
PUSH (x); PUSH (x);
DEAD (x);
NEXT; NEXT;
} }
@ -226,6 +227,7 @@ VM_DEFINE_INSTRUCTION (18, vector, "vector", 2, -1, 1)
memcpy (SCM_I_VECTOR_WELTS(vect), sp, sizeof(SCM) * len); memcpy (SCM_I_VECTOR_WELTS(vect), sp, sizeof(SCM) * len);
NULLSTACK (len); NULLSTACK (len);
*sp = vect; *sp = vect;
DEAD (vect);
NEXT; NEXT;
} }
@ -330,6 +332,7 @@ VM_DEFINE_INSTRUCTION (25, variable_ref, "variable-ref", 0, 1, 1)
{ {
SCM o = VARIABLE_REF (x); SCM o = VARIABLE_REF (x);
*sp = o; *sp = o;
DEAD (o);
} }
NEXT; NEXT;
@ -347,18 +350,20 @@ VM_DEFINE_INSTRUCTION (26, variable_bound, "variable-bound?", 0, 1, 1)
} }
else else
*sp = scm_from_bool (VARIABLE_BOUNDP (x)); *sp = scm_from_bool (VARIABLE_BOUNDP (x));
DEAD (x);
NEXT; NEXT;
} }
VM_DEFINE_INSTRUCTION (27, toplevel_ref, "toplevel-ref", 1, 0, 1) VM_DEFINE_INSTRUCTION (27, toplevel_ref, "toplevel-ref", 1, 0, 1)
{ {
unsigned objnum = FETCH (); unsigned objnum = FETCH ();
SCM what, resolved; SCM what;
CHECK_OBJECT (objnum); CHECK_OBJECT (objnum);
what = OBJECT_REF (objnum); what = OBJECT_REF (objnum);
if (!SCM_VARIABLEP (what)) if (!SCM_VARIABLEP (what))
{ {
SCM resolved;
SYNC_REGISTER (); SYNC_REGISTER ();
resolved = resolve_variable (what, scm_program_module (program)); resolved = resolve_variable (what, scm_program_module (program));
if (!VARIABLE_BOUNDP (resolved)) if (!VARIABLE_BOUNDP (resolved))
@ -367,16 +372,18 @@ VM_DEFINE_INSTRUCTION (27, toplevel_ref, "toplevel-ref", 1, 0, 1)
goto vm_error_unbound; goto vm_error_unbound;
} }
what = resolved; what = resolved;
DEAD (resolved);
OBJECT_SET (objnum, what); OBJECT_SET (objnum, what);
} }
PUSH (VARIABLE_REF (what)); PUSH (VARIABLE_REF (what));
DEAD (what);
NEXT; NEXT;
} }
VM_DEFINE_INSTRUCTION (28, long_toplevel_ref, "long-toplevel-ref", 2, 0, 1) VM_DEFINE_INSTRUCTION (28, long_toplevel_ref, "long-toplevel-ref", 2, 0, 1)
{ {
SCM what, resolved; SCM what;
unsigned int objnum = FETCH (); unsigned int objnum = FETCH ();
objnum <<= 8; objnum <<= 8;
objnum += FETCH (); objnum += FETCH ();
@ -385,6 +392,7 @@ VM_DEFINE_INSTRUCTION (28, long_toplevel_ref, "long-toplevel-ref", 2, 0, 1)
if (!SCM_VARIABLEP (what)) if (!SCM_VARIABLEP (what))
{ {
SCM resolved;
SYNC_REGISTER (); SYNC_REGISTER ();
resolved = resolve_variable (what, scm_program_module (program)); resolved = resolve_variable (what, scm_program_module (program));
if (!VARIABLE_BOUNDP (resolved)) if (!VARIABLE_BOUNDP (resolved))
@ -393,10 +401,12 @@ VM_DEFINE_INSTRUCTION (28, long_toplevel_ref, "long-toplevel-ref", 2, 0, 1)
goto vm_error_unbound; goto vm_error_unbound;
} }
what = resolved; what = resolved;
DEAD (resolved);
OBJECT_SET (objnum, what); OBJECT_SET (objnum, what);
} }
PUSH (VARIABLE_REF (what)); PUSH (VARIABLE_REF (what));
DEAD (what);
NEXT; NEXT;
} }
@ -407,6 +417,7 @@ VM_DEFINE_INSTRUCTION (29, local_set, "local-set", 1, 1, 0)
SCM x; SCM x;
POP (x); POP (x);
LOCAL_SET (FETCH (), x); LOCAL_SET (FETCH (), x);
DEAD (x);
NEXT; NEXT;
} }
@ -418,6 +429,7 @@ VM_DEFINE_INSTRUCTION (30, long_local_set, "long-local-set", 2, 1, 0)
i += FETCH (); i += FETCH ();
POP (x); POP (x);
LOCAL_SET (i, x); LOCAL_SET (i, x);
DEAD (x);
NEXT; NEXT;
} }
@ -449,6 +461,7 @@ VM_DEFINE_INSTRUCTION (32, toplevel_set, "toplevel-set", 1, 1, 0)
} }
VARIABLE_SET (what, *sp); VARIABLE_SET (what, *sp);
DEAD (what);
DROP (); DROP ();
NEXT; NEXT;
} }
@ -470,6 +483,7 @@ VM_DEFINE_INSTRUCTION (33, long_toplevel_set, "long-toplevel-set", 2, 1, 0)
} }
VARIABLE_SET (what, *sp); VARIABLE_SET (what, *sp);
DEAD (what);
DROP (); DROP ();
NEXT; NEXT;
} }
@ -496,7 +510,6 @@ VM_DEFINE_INSTRUCTION (33, long_toplevel_set, "long-toplevel-set", 2, 1, 0)
ip += offset; \ ip += offset; \
if (offset < 0) \ if (offset < 0) \
VM_HANDLE_INTERRUPTS; \ VM_HANDLE_INTERRUPTS; \
NEXT; \
} }
VM_DEFINE_INSTRUCTION (34, br, "br", 3, 0, 0) VM_DEFINE_INSTRUCTION (34, br, "br", 3, 0, 0)
@ -514,6 +527,8 @@ VM_DEFINE_INSTRUCTION (35, br_if, "br-if", 3, 0, 0)
SCM x; SCM x;
POP (x); POP (x);
BR (scm_is_true (x)); BR (scm_is_true (x));
DEAD (x);
NEXT;
} }
VM_DEFINE_INSTRUCTION (36, br_if_not, "br-if-not", 3, 0, 0) VM_DEFINE_INSTRUCTION (36, br_if_not, "br-if-not", 3, 0, 0)
@ -521,6 +536,8 @@ VM_DEFINE_INSTRUCTION (36, br_if_not, "br-if-not", 3, 0, 0)
SCM x; SCM x;
POP (x); POP (x);
BR (scm_is_false (x)); BR (scm_is_false (x));
DEAD (x);
NEXT;
} }
VM_DEFINE_INSTRUCTION (37, br_if_eq, "br-if-eq", 3, 0, 0) VM_DEFINE_INSTRUCTION (37, br_if_eq, "br-if-eq", 3, 0, 0)
@ -528,6 +545,9 @@ VM_DEFINE_INSTRUCTION (37, br_if_eq, "br-if-eq", 3, 0, 0)
SCM x, y; SCM x, y;
POP2 (y, x); POP2 (y, x);
BR (scm_is_eq (x, y)); BR (scm_is_eq (x, y));
DEAD (x);
DEAD (y);
NEXT;
} }
VM_DEFINE_INSTRUCTION (38, br_if_not_eq, "br-if-not-eq", 3, 0, 0) VM_DEFINE_INSTRUCTION (38, br_if_not_eq, "br-if-not-eq", 3, 0, 0)
@ -535,6 +555,9 @@ VM_DEFINE_INSTRUCTION (38, br_if_not_eq, "br-if-not-eq", 3, 0, 0)
SCM x, y; SCM x, y;
POP2 (y, x); POP2 (y, x);
BR (!scm_is_eq (x, y)); BR (!scm_is_eq (x, y));
DEAD (x);
DEAD (y);
NEXT;
} }
VM_DEFINE_INSTRUCTION (39, br_if_null, "br-if-null", 3, 0, 0) VM_DEFINE_INSTRUCTION (39, br_if_null, "br-if-null", 3, 0, 0)
@ -542,6 +565,8 @@ VM_DEFINE_INSTRUCTION (39, br_if_null, "br-if-null", 3, 0, 0)
SCM x; SCM x;
POP (x); POP (x);
BR (scm_is_null (x)); BR (scm_is_null (x));
DEAD (x);
NEXT;
} }
VM_DEFINE_INSTRUCTION (40, br_if_not_null, "br-if-not-null", 3, 0, 0) VM_DEFINE_INSTRUCTION (40, br_if_not_null, "br-if-not-null", 3, 0, 0)
@ -549,6 +574,8 @@ VM_DEFINE_INSTRUCTION (40, br_if_not_null, "br-if-not-null", 3, 0, 0)
SCM x; SCM x;
POP (x); POP (x);
BR (!scm_is_null (x)); BR (!scm_is_null (x));
DEAD (x);
NEXT;
} }
@ -712,6 +739,8 @@ VM_DEFINE_INSTRUCTION (48, bind_kwargs, "bind-kwargs", 5, 0, 0)
goto vm_error_kwargs_invalid_keyword; goto vm_error_kwargs_invalid_keyword;
} }
DEAD (kw);
NEXT; NEXT;
} }
@ -729,6 +758,7 @@ VM_DEFINE_INSTRUCTION (49, push_rest, "push-rest", 2, -1, -1)
/* No need to check for underflow. */ /* No need to check for underflow. */
CONS (rest, *sp--, rest); CONS (rest, *sp--, rest);
PUSH (rest); PUSH (rest);
DEAD (rest);
NEXT; NEXT;
} }
@ -745,6 +775,7 @@ VM_DEFINE_INSTRUCTION (50, bind_rest, "bind-rest", 4, -1, -1)
/* No need to check for underflow. */ /* No need to check for underflow. */
CONS (rest, *sp--, rest); CONS (rest, *sp--, rest);
LOCAL_SET (i, rest); LOCAL_SET (i, rest);
DEAD (rest);
NEXT; NEXT;
} }
@ -935,6 +966,7 @@ VM_DEFINE_INSTRUCTION (55, subr_call, "subr-call", 1, -1, -1)
abort (); abort ();
} }
DEAD (pointer);
NULLSTACK_FOR_NONLOCAL_EXIT (); NULLSTACK_FOR_NONLOCAL_EXIT ();
if (SCM_UNLIKELY (SCM_VALUESP (ret))) if (SCM_UNLIKELY (SCM_VALUESP (ret)))
@ -943,11 +975,13 @@ VM_DEFINE_INSTRUCTION (55, subr_call, "subr-call", 1, -1, -1)
ret = scm_struct_ref (ret, SCM_INUM0); ret = scm_struct_ref (ret, SCM_INUM0);
nvalues = scm_ilength (ret); nvalues = scm_ilength (ret);
PUSH_LIST (ret, scm_is_null); PUSH_LIST (ret, scm_is_null);
DEAD (ret);
goto vm_return_values; goto vm_return_values;
} }
else else
{ {
PUSH (ret); PUSH (ret);
DEAD (ret);
goto vm_return; goto vm_return;
} }
} }
@ -982,6 +1016,7 @@ VM_DEFINE_INSTRUCTION (56, smob_call, "smob-call", 1, -1, -1)
abort (); abort ();
} }
DEAD (smob);
NULLSTACK_FOR_NONLOCAL_EXIT (); NULLSTACK_FOR_NONLOCAL_EXIT ();
if (SCM_UNLIKELY (SCM_VALUESP (ret))) if (SCM_UNLIKELY (SCM_VALUESP (ret)))
@ -990,11 +1025,13 @@ VM_DEFINE_INSTRUCTION (56, smob_call, "smob-call", 1, -1, -1)
ret = scm_struct_ref (ret, SCM_INUM0); ret = scm_struct_ref (ret, SCM_INUM0);
nvalues = scm_ilength (ret); nvalues = scm_ilength (ret);
PUSH_LIST (ret, scm_is_null); PUSH_LIST (ret, scm_is_null);
DEAD (ret);
goto vm_return_values; goto vm_return_values;
} }
else else
{ {
PUSH (ret); PUSH (ret);
DEAD (ret);
goto vm_return; goto vm_return;
} }
} }
@ -1010,6 +1047,7 @@ VM_DEFINE_INSTRUCTION (57, foreign_call, "foreign-call", 1, -1, -1)
ret = scm_i_foreign_call (foreign, sp - nargs + 1); ret = scm_i_foreign_call (foreign, sp - nargs + 1);
DEAD (foreign);
NULLSTACK_FOR_NONLOCAL_EXIT (); NULLSTACK_FOR_NONLOCAL_EXIT ();
if (SCM_UNLIKELY (SCM_VALUESP (ret))) if (SCM_UNLIKELY (SCM_VALUESP (ret)))
@ -1018,11 +1056,13 @@ VM_DEFINE_INSTRUCTION (57, foreign_call, "foreign-call", 1, -1, -1)
ret = scm_struct_ref (ret, SCM_INUM0); ret = scm_struct_ref (ret, SCM_INUM0);
nvalues = scm_ilength (ret); nvalues = scm_ilength (ret);
PUSH_LIST (ret, scm_is_null); PUSH_LIST (ret, scm_is_null);
DEAD (ret);
goto vm_return_values; goto vm_return_values;
} }
else else
{ {
PUSH (ret); PUSH (ret);
DEAD (ret);
goto vm_return; goto vm_return;
} }
} }
@ -1039,7 +1079,7 @@ VM_DEFINE_INSTRUCTION (58, continuation_call, "continuation-call", 0, -1, 0)
sp - (fp - 1), fp); sp - (fp - 1), fp);
scm_i_reinstate_continuation (contregs); scm_i_reinstate_continuation (contregs);
/* no NEXT */ /* no DEAD, no NEXT */
abort (); abort ();
} }
@ -1049,12 +1089,15 @@ VM_DEFINE_INSTRUCTION (59, partial_cont_call, "partial-cont-call", 0, -1, 0)
POP2 (intwinds, vmcont); POP2 (intwinds, vmcont);
SYNC_REGISTER (); SYNC_REGISTER ();
if (SCM_UNLIKELY (!SCM_VM_CONT_REWINDABLE_P (vmcont))) if (SCM_UNLIKELY (!SCM_VM_CONT_REWINDABLE_P (vmcont)))
{ finish_args = vmcont; {
finish_args = vmcont;
goto vm_error_continuation_not_rewindable; goto vm_error_continuation_not_rewindable;
} }
prevwinds = scm_i_dynwinds (); prevwinds = scm_i_dynwinds ();
vm_reinstate_partial_continuation (vm, vmcont, intwinds, sp + 1 - fp, fp, vm_reinstate_partial_continuation (vm, vmcont, intwinds, sp + 1 - fp, fp,
vm_cookie); vm_cookie);
DEAD (vmcont);
DEAD (intwinds);
/* Rewind prompt jmpbuffers, if any. */ /* Rewind prompt jmpbuffers, if any. */
{ {
@ -1062,7 +1105,9 @@ VM_DEFINE_INSTRUCTION (59, partial_cont_call, "partial-cont-call", 0, -1, 0)
for (; !scm_is_eq (winds, prevwinds); winds = scm_cdr (winds)) for (; !scm_is_eq (winds, prevwinds); winds = scm_cdr (winds))
if (SCM_PROMPT_P (scm_car (winds)) && SCM_PROMPT_SETJMP (scm_car (winds))) if (SCM_PROMPT_P (scm_car (winds)) && SCM_PROMPT_SETJMP (scm_car (winds)))
break; break;
DEAD (winds);
} }
DEAD (prevwinds);
CACHE_REGISTER (); CACHE_REGISTER ();
program = SCM_FRAME_PROGRAM (fp); program = SCM_FRAME_PROGRAM (fp);
@ -1075,6 +1120,7 @@ VM_DEFINE_INSTRUCTION (60, tail_call_nargs, "tail-call/nargs", 0, 0, 1)
SCM x; SCM x;
POP (x); POP (x);
nargs = scm_to_int (x); nargs = scm_to_int (x);
DEAD (x);
/* FIXME: should truncate values? */ /* FIXME: should truncate values? */
goto vm_tail_call; goto vm_tail_call;
} }
@ -1084,6 +1130,7 @@ VM_DEFINE_INSTRUCTION (61, call_nargs, "call/nargs", 0, 0, 1)
SCM x; SCM x;
POP (x); POP (x);
nargs = scm_to_int (x); nargs = scm_to_int (x);
DEAD (x);
/* FIXME: should truncate values? */ /* FIXME: should truncate values? */
goto vm_call; goto vm_call;
} }
@ -1158,6 +1205,7 @@ VM_DEFINE_INSTRUCTION (63, apply, "apply", 1, -1, 1)
} }
PUSH_LIST (ls, SCM_NULL_OR_NIL_P); PUSH_LIST (ls, SCM_NULL_OR_NIL_P);
DEAD (ls);
nargs += len - 2; nargs += len - 2;
goto vm_call; goto vm_call;
@ -1180,6 +1228,7 @@ VM_DEFINE_INSTRUCTION (64, tail_apply, "tail-apply", 1, -1, 1)
} }
PUSH_LIST (ls, SCM_NULL_OR_NIL_P); PUSH_LIST (ls, SCM_NULL_OR_NIL_P);
DEAD (ls);
nargs += len - 2; nargs += len - 2;
goto vm_tail_call; goto vm_tail_call;
@ -1193,13 +1242,16 @@ VM_DEFINE_INSTRUCTION (65, call_cc, "call/cc", 0, 1, 1)
SYNC_ALL (); SYNC_ALL ();
vm_cont = scm_i_vm_capture_stack (vp->stack_base, fp, sp, ip, NULL, 0); vm_cont = scm_i_vm_capture_stack (vp->stack_base, fp, sp, ip, NULL, 0);
cont = scm_i_make_continuation (&first, vm, vm_cont); cont = scm_i_make_continuation (&first, vm, vm_cont);
DEAD (vm_cont);
if (first) if (first)
{ {
PUSH (SCM_PACK (0)); /* dynamic link */ PUSH (SCM_PACK (0)); /* dynamic link */
PUSH (SCM_PACK (0)); /* mvra */ PUSH (SCM_PACK (0)); /* mvra */
PUSH (SCM_PACK (0)); /* ra */ PUSH (SCM_PACK (0)); /* ra */
PUSH (proc); PUSH (proc);
DEAD (proc);
PUSH (cont); PUSH (cont);
DEAD (cont);
nargs = 1; nargs = 1;
goto vm_call; goto vm_call;
} }
@ -1212,6 +1264,8 @@ VM_DEFINE_INSTRUCTION (65, call_cc, "call/cc", 0, 1, 1)
So, pull our regs back down from the vp, and march on to the So, pull our regs back down from the vp, and march on to the
next instruction. */ next instruction. */
DEAD (proc);
DEAD (cont);
CACHE_REGISTER (); CACHE_REGISTER ();
program = SCM_FRAME_PROGRAM (fp); program = SCM_FRAME_PROGRAM (fp);
CACHE_PROGRAM (); CACHE_PROGRAM ();
@ -1235,15 +1289,20 @@ VM_DEFINE_INSTRUCTION (66, tail_call_cc, "tail-call/cc", 0, 1, 1)
SCM_FRAME_MV_RETURN_ADDRESS (fp), SCM_FRAME_MV_RETURN_ADDRESS (fp),
0); 0);
cont = scm_i_make_continuation (&first, vm, vm_cont); cont = scm_i_make_continuation (&first, vm, vm_cont);
DEAD (vm_cont);
if (first) if (first)
{ {
PUSH (proc); PUSH (proc);
DEAD (proc);
PUSH (cont); PUSH (cont);
DEAD (cont);
nargs = 1; nargs = 1;
goto vm_tail_call; goto vm_tail_call;
} }
else else
{ {
DEAD (proc);
DEAD (cont);
/* Otherwise, cache regs and NEXT, as above. Invoking the continuation /* Otherwise, cache regs and NEXT, as above. Invoking the continuation
does a return from the frame, either to the RA or does a return from the frame, either to the RA or
MVRA. */ MVRA. */
@ -1288,6 +1347,8 @@ VM_DEFINE_INSTRUCTION (67, return, "return", 0, 1, 1)
/* Set return value (sp is already pushed) */ /* Set return value (sp is already pushed) */
*sp = ret; *sp = ret;
DEAD (ret);
} }
/* Restore the last program */ /* Restore the last program */
@ -1375,6 +1436,7 @@ VM_DEFINE_INSTRUCTION (69, return_values_star, "return/values*", 1, -1, -1)
goto vm_error_improper_list; goto vm_error_improper_list;
} }
DEAD (l);
goto vm_return_values; goto vm_return_values;
} }
@ -1383,6 +1445,7 @@ VM_DEFINE_INSTRUCTION (70, return_nvalues, "return/nvalues", 0, 1, -1)
SCM n; SCM n;
POP (n); POP (n);
nvalues = scm_to_int (n); nvalues = scm_to_int (n);
DEAD (n);
ASSERT (nvalues >= 0); ASSERT (nvalues >= 0);
goto vm_return_values; goto vm_return_values;
} }
@ -1393,6 +1456,7 @@ VM_DEFINE_INSTRUCTION (71, truncate_values, "truncate-values", 2, -1, -1)
int nbinds, rest; int nbinds, rest;
POP (x); POP (x);
nvalues = scm_to_int (x); nvalues = scm_to_int (x);
DEAD (x);
nbinds = FETCH (); nbinds = FETCH ();
rest = FETCH (); rest = FETCH ();
@ -1416,6 +1480,7 @@ VM_DEFINE_INSTRUCTION (72, box, "box", 1, 1, 0)
POP (val); POP (val);
SYNC_BEFORE_GC (); SYNC_BEFORE_GC ();
LOCAL_SET (FETCH (), scm_cell (scm_tc7_variable, SCM_UNPACK (val))); LOCAL_SET (FETCH (), scm_cell (scm_tc7_variable, SCM_UNPACK (val)));
DEAD (val);
NEXT; NEXT;
} }
@ -1437,6 +1502,7 @@ VM_DEFINE_INSTRUCTION (74, local_boxed_ref, "local-boxed-ref", 1, 0, 1)
SCM v = LOCAL_REF (FETCH ()); SCM v = LOCAL_REF (FETCH ());
ASSERT_BOUND_VARIABLE (v); ASSERT_BOUND_VARIABLE (v);
PUSH (VARIABLE_REF (v)); PUSH (VARIABLE_REF (v));
DEAD (v);
NEXT; NEXT;
} }
@ -1447,6 +1513,8 @@ VM_DEFINE_INSTRUCTION (75, local_boxed_set, "local-boxed-set", 1, 1, 0)
POP (val); POP (val);
ASSERT_VARIABLE (v); ASSERT_VARIABLE (v);
VARIABLE_SET (v, val); VARIABLE_SET (v, val);
DEAD (v);
DEAD (val);
NEXT; NEXT;
} }
@ -1469,6 +1537,7 @@ VM_DEFINE_INSTRUCTION (77, free_boxed_ref, "free-boxed-ref", 1, 0, 1)
v = FREE_VARIABLE_REF (idx); v = FREE_VARIABLE_REF (idx);
ASSERT_BOUND_VARIABLE (v); ASSERT_BOUND_VARIABLE (v);
PUSH (VARIABLE_REF (v)); PUSH (VARIABLE_REF (v));
DEAD (v);
NEXT; NEXT;
} }
@ -1481,6 +1550,8 @@ VM_DEFINE_INSTRUCTION (78, free_boxed_set, "free-boxed-set", 1, 1, 0)
v = FREE_VARIABLE_REF (idx); v = FREE_VARIABLE_REF (idx);
ASSERT_BOUND_VARIABLE (v); ASSERT_BOUND_VARIABLE (v);
VARIABLE_SET (v, val); VARIABLE_SET (v, val);
DEAD (v);
DEAD (val);
NEXT; NEXT;
} }
@ -1499,6 +1570,7 @@ VM_DEFINE_INSTRUCTION (79, make_closure, "make-closure", 2, -1, 1)
sp[-len] = closure; sp[-len] = closure;
for (n = 0; n < len; n++) for (n = 0; n < len; n++)
SCM_PROGRAM_FREE_VARIABLE_SET (closure, n, sp[-len + 1 + n]); SCM_PROGRAM_FREE_VARIABLE_SET (closure, n, sp[-len + 1 + n]);
DEAD (closure);
DROPN (len); DROPN (len);
NEXT; NEXT;
} }
@ -1524,6 +1596,7 @@ VM_DEFINE_INSTRUCTION (81, fix_closure, "fix-closure", 2, -1, 0)
len = SCM_PROGRAM_NUM_FREE_VARIABLES (x); len = SCM_PROGRAM_NUM_FREE_VARIABLES (x);
for (n = 0; n < len; n++) for (n = 0; n < len; n++)
SCM_PROGRAM_FREE_VARIABLE_SET (x, n, sp[-len + 1 + n]); SCM_PROGRAM_FREE_VARIABLE_SET (x, n, sp[-len + 1 + n]);
DEAD (x);
DROPN (len); DROPN (len);
NEXT; NEXT;
} }
@ -1536,6 +1609,8 @@ VM_DEFINE_INSTRUCTION (82, define, "define", 0, 0, 2)
VARIABLE_SET (scm_sym2var (sym, scm_current_module_lookup_closure (), VARIABLE_SET (scm_sym2var (sym, scm_current_module_lookup_closure (),
SCM_BOOL_T), SCM_BOOL_T),
val); val);
DEAD (sym);
DEAD (val);
NEXT; NEXT;
} }
@ -1579,6 +1654,8 @@ VM_DEFINE_INSTRUCTION (85, prompt, "prompt", 4, 2, 0)
vm_engine that can be assigned *has* been assigned. So we need to pull vm_engine that can be assigned *has* been assigned. So we need to pull
all our state back from the ip/fp/sp. all our state back from the ip/fp/sp.
*/ */
DEAD (k);
DEAD (prompt);
CACHE_REGISTER (); CACHE_REGISTER ();
program = SCM_FRAME_PROGRAM (fp); program = SCM_FRAME_PROGRAM (fp);
CACHE_PROGRAM (); CACHE_PROGRAM ();
@ -1588,6 +1665,9 @@ VM_DEFINE_INSTRUCTION (85, prompt, "prompt", 4, 2, 0)
NEXT; NEXT;
} }
DEAD (k);
DEAD (prompt);
/* Otherwise setjmp returned for the first time, so we go to execute the /* Otherwise setjmp returned for the first time, so we go to execute the
prompt's body. */ prompt's body. */
NEXT; NEXT;
@ -1612,6 +1692,8 @@ VM_DEFINE_INSTRUCTION (86, wind, "wind", 0, 2, 0)
goto vm_error_not_a_thunk; goto vm_error_not_a_thunk;
} }
scm_i_set_dynwinds (scm_cons (scm_cons (wind, unwind), scm_i_dynwinds ())); scm_i_set_dynwinds (scm_cons (scm_cons (wind, unwind), scm_i_dynwinds ()));
DEAD (wind);
DEAD (unwind);
NEXT; NEXT;
} }
@ -1647,6 +1729,7 @@ VM_DEFINE_INSTRUCTION (89, wind_fluids, "wind-fluids", 1, -1, 0)
scm_i_swap_with_fluids (wf, current_thread->dynamic_state); scm_i_swap_with_fluids (wf, current_thread->dynamic_state);
scm_i_set_dynwinds (scm_cons (wf, scm_i_dynwinds ())); scm_i_set_dynwinds (scm_cons (wf, scm_i_dynwinds ()));
DEAD (wf);
NEXT; NEXT;
} }
@ -1656,6 +1739,7 @@ VM_DEFINE_INSTRUCTION (90, unwind_fluids, "unwind-fluids", 0, 0, 0)
wf = scm_car (scm_i_dynwinds ()); wf = scm_car (scm_i_dynwinds ());
scm_i_set_dynwinds (scm_cdr (scm_i_dynwinds ())); scm_i_set_dynwinds (scm_cdr (scm_i_dynwinds ()));
scm_i_swap_with_fluids (wf, current_thread->dynamic_state); scm_i_swap_with_fluids (wf, current_thread->dynamic_state);
DEAD (wf);
NEXT; NEXT;
} }
@ -1670,12 +1754,14 @@ VM_DEFINE_INSTRUCTION (91, fluid_ref, "fluid-ref", 0, 1, 1)
|| ((num = SCM_I_FLUID_NUM (*sp)) >= SCM_SIMPLE_VECTOR_LENGTH (fluids))) || ((num = SCM_I_FLUID_NUM (*sp)) >= SCM_SIMPLE_VECTOR_LENGTH (fluids)))
{ {
/* Punt dynstate expansion and error handling to the C proc. */ /* Punt dynstate expansion and error handling to the C proc. */
DEAD (fluids);
SYNC_REGISTER (); SYNC_REGISTER ();
*sp = scm_fluid_ref (*sp); *sp = scm_fluid_ref (*sp);
} }
else else
{ {
SCM val = SCM_SIMPLE_VECTOR_REF (fluids, num); SCM val = SCM_SIMPLE_VECTOR_REF (fluids, num);
DEAD (fluids);
if (scm_is_eq (val, SCM_UNDEFINED)) if (scm_is_eq (val, SCM_UNDEFINED))
val = SCM_I_FLUID_DEFAULT (*sp); val = SCM_I_FLUID_DEFAULT (*sp);
if (SCM_UNLIKELY (scm_is_eq (val, SCM_UNDEFINED))) if (SCM_UNLIKELY (scm_is_eq (val, SCM_UNDEFINED)))
@ -1705,7 +1791,9 @@ VM_DEFINE_INSTRUCTION (92, fluid_set, "fluid-set", 0, 2, 0)
} }
else else
SCM_SIMPLE_VECTOR_SET (fluids, num, val); SCM_SIMPLE_VECTOR_SET (fluids, num, val);
DEAD (fluids);
DEAD (fluid);
DEAD (val);
NEXT; NEXT;
} }