1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-02 04:40:29 +02:00

add `nil?' primitive

* libguile/boolean.c (scm_nil_p): New function.

* libguile/vm-i-scheme.c (nilp, not_nilp):
* libguile/vm-i-system.c (br_if_nil, br_if_not_nil): New instructions.
  Renumber other ops.

* libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION): Increment.

* module/language/assembly/compile-bytecode.scm (compile-bytecode): Add
  support for writing `br-if-nil' and `br-if-not-nil' instructions.

* module/language/assembly/disassemble.scm (code-annotation): Add
  `br-if-nil' and `br-if-not-nil' to the list of branch instructions.

* module/language/tree-il/compile-glil.scm: Add `nil?' to
  `*primcall-ops*'.
  (flatten): Use the new branch instructions for `nil?' conditionals.

* module/language/tree-il/primitives.scm: Add `nil?' to
  `*interesting-primitive-names*', `*effect-free-primitives', and
  `*effect+exception-free-primitives*'.
This commit is contained in:
BT Templeton 2011-06-15 20:21:28 -04:00
parent 6937c7aa8b
commit 9348168ed5
8 changed files with 180 additions and 132 deletions

View file

@ -206,7 +206,7 @@
/* Major and minor versions must be single characters. */ /* Major and minor versions must be single characters. */
#define SCM_OBJCODE_MAJOR_VERSION 2 #define SCM_OBJCODE_MAJOR_VERSION 2
#define SCM_OBJCODE_MINOR_VERSION 0 #define SCM_OBJCODE_MINOR_VERSION 1
#define SCM_OBJCODE_MAJOR_VERSION_STRING \ #define SCM_OBJCODE_MAJOR_VERSION_STRING \
SCM_CPP_STRINGIFY(SCM_OBJCODE_MAJOR_VERSION) SCM_CPP_STRINGIFY(SCM_OBJCODE_MAJOR_VERSION)
#define SCM_OBJCODE_MINOR_VERSION_STRING \ #define SCM_OBJCODE_MINOR_VERSION_STRING \

View file

@ -62,6 +62,14 @@ SCM_DEFINE (scm_not, "not", 1, 0, 0,
} }
#undef FUNC_NAME #undef FUNC_NAME
SCM_DEFINE (scm_nil_p, "nil?", 1, 0, 0,
(SCM x),
"Return @code{#t} iff @var{x} is nil, else return @code{#f}.")
#define FUNC_NAME s_scm_nil_p
{
return scm_from_bool (scm_is_lisp_false (x));
}
#undef FUNC_NAME
SCM_DEFINE (scm_boolean_p, "boolean?", 1, 0, 0, SCM_DEFINE (scm_boolean_p, "boolean?", 1, 0, 0,
(SCM obj), (SCM obj),

View file

@ -65,7 +65,19 @@ VM_DEFINE_FUNCTION (133, not_nullp, "not-null?", 1)
RETURN (scm_from_bool (!scm_is_null (x))); RETURN (scm_from_bool (!scm_is_null (x)));
} }
VM_DEFINE_FUNCTION (134, eqv, "eqv?", 2) VM_DEFINE_FUNCTION (134, nilp, "nil?", 1)
{
ARGS1 (x);
RETURN (scm_from_bool (scm_is_lisp_false (x)));
}
VM_DEFINE_FUNCTION (135, not_nilp, "not-nil?", 1)
{
ARGS1 (x);
RETURN (scm_from_bool (!scm_is_lisp_false (x)));
}
VM_DEFINE_FUNCTION (136, eqv, "eqv?", 2)
{ {
ARGS2 (x, y); ARGS2 (x, y);
if (scm_is_eq (x, y)) if (scm_is_eq (x, y))
@ -76,7 +88,7 @@ VM_DEFINE_FUNCTION (134, eqv, "eqv?", 2)
RETURN (scm_eqv_p (x, y)); RETURN (scm_eqv_p (x, y));
} }
VM_DEFINE_FUNCTION (135, equal, "equal?", 2) VM_DEFINE_FUNCTION (137, equal, "equal?", 2)
{ {
ARGS2 (x, y); ARGS2 (x, y);
if (scm_is_eq (x, y)) if (scm_is_eq (x, y))
@ -87,25 +99,25 @@ VM_DEFINE_FUNCTION (135, equal, "equal?", 2)
RETURN (scm_equal_p (x, y)); RETURN (scm_equal_p (x, y));
} }
VM_DEFINE_FUNCTION (136, pairp, "pair?", 1) VM_DEFINE_FUNCTION (138, pairp, "pair?", 1)
{ {
ARGS1 (x); ARGS1 (x);
RETURN (scm_from_bool (scm_is_pair (x))); RETURN (scm_from_bool (scm_is_pair (x)));
} }
VM_DEFINE_FUNCTION (137, listp, "list?", 1) VM_DEFINE_FUNCTION (139, listp, "list?", 1)
{ {
ARGS1 (x); ARGS1 (x);
RETURN (scm_from_bool (scm_ilength (x) >= 0)); RETURN (scm_from_bool (scm_ilength (x) >= 0));
} }
VM_DEFINE_FUNCTION (138, symbolp, "symbol?", 1) VM_DEFINE_FUNCTION (140, symbolp, "symbol?", 1)
{ {
ARGS1 (x); ARGS1 (x);
RETURN (scm_from_bool (scm_is_symbol (x))); RETURN (scm_from_bool (scm_is_symbol (x)));
} }
VM_DEFINE_FUNCTION (139, vectorp, "vector?", 1) VM_DEFINE_FUNCTION (141, 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)));
@ -116,7 +128,7 @@ VM_DEFINE_FUNCTION (139, vectorp, "vector?", 1)
* Basic data * Basic data
*/ */
VM_DEFINE_FUNCTION (140, cons, "cons", 2) VM_DEFINE_FUNCTION (142, cons, "cons", 2)
{ {
ARGS2 (x, y); ARGS2 (x, y);
CONS (x, x, y); CONS (x, x, y);
@ -130,21 +142,21 @@ VM_DEFINE_FUNCTION (140, cons, "cons", 2)
goto vm_error_not_a_pair; \ goto vm_error_not_a_pair; \
} }
VM_DEFINE_FUNCTION (141, car, "car", 1) VM_DEFINE_FUNCTION (143, 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));
} }
VM_DEFINE_FUNCTION (142, cdr, "cdr", 1) VM_DEFINE_FUNCTION (144, 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));
} }
VM_DEFINE_INSTRUCTION (143, set_car, "set-car!", 0, 2, 0) VM_DEFINE_INSTRUCTION (145, set_car, "set-car!", 0, 2, 0)
{ {
SCM x, y; SCM x, y;
POP2 (y, x); POP2 (y, x);
@ -153,7 +165,7 @@ VM_DEFINE_INSTRUCTION (143, set_car, "set-car!", 0, 2, 0)
NEXT; NEXT;
} }
VM_DEFINE_INSTRUCTION (144, set_cdr, "set-cdr!", 0, 2, 0) VM_DEFINE_INSTRUCTION (146, set_cdr, "set-cdr!", 0, 2, 0)
{ {
SCM x, y; SCM x, y;
POP2 (y, x); POP2 (y, x);
@ -178,27 +190,27 @@ VM_DEFINE_INSTRUCTION (144, set_cdr, "set-cdr!", 0, 2, 0)
RETURN (srel (x, y)); \ RETURN (srel (x, y)); \
} }
VM_DEFINE_FUNCTION (145, ee, "ee?", 2) VM_DEFINE_FUNCTION (147, ee, "ee?", 2)
{ {
REL (==, scm_num_eq_p); REL (==, scm_num_eq_p);
} }
VM_DEFINE_FUNCTION (146, lt, "lt?", 2) VM_DEFINE_FUNCTION (148, lt, "lt?", 2)
{ {
REL (<, scm_less_p); REL (<, scm_less_p);
} }
VM_DEFINE_FUNCTION (147, le, "le?", 2) VM_DEFINE_FUNCTION (149, le, "le?", 2)
{ {
REL (<=, scm_leq_p); REL (<=, scm_leq_p);
} }
VM_DEFINE_FUNCTION (148, gt, "gt?", 2) VM_DEFINE_FUNCTION (150, gt, "gt?", 2)
{ {
REL (>, scm_gr_p); REL (>, scm_gr_p);
} }
VM_DEFINE_FUNCTION (149, ge, "ge?", 2) VM_DEFINE_FUNCTION (151, ge, "ge?", 2)
{ {
REL (>=, scm_geq_p); REL (>=, scm_geq_p);
} }
@ -280,7 +292,7 @@ VM_DEFINE_FUNCTION (149, ge, "ge?", 2)
#endif #endif
VM_DEFINE_FUNCTION (150, add, "add", 2) VM_DEFINE_FUNCTION (152, add, "add", 2)
{ {
#ifndef ASM_ADD #ifndef ASM_ADD
FUNC2 (+, scm_sum); FUNC2 (+, scm_sum);
@ -292,7 +304,7 @@ VM_DEFINE_FUNCTION (150, add, "add", 2)
#endif #endif
} }
VM_DEFINE_FUNCTION (151, add1, "add1", 1) VM_DEFINE_FUNCTION (153, add1, "add1", 1)
{ {
ARGS1 (x); ARGS1 (x);
@ -314,7 +326,7 @@ VM_DEFINE_FUNCTION (151, add1, "add1", 1)
RETURN (scm_sum (x, SCM_I_MAKINUM (1))); RETURN (scm_sum (x, SCM_I_MAKINUM (1)));
} }
VM_DEFINE_FUNCTION (152, sub, "sub", 2) VM_DEFINE_FUNCTION (154, sub, "sub", 2)
{ {
#ifndef ASM_SUB #ifndef ASM_SUB
FUNC2 (-, scm_difference); FUNC2 (-, scm_difference);
@ -326,7 +338,7 @@ VM_DEFINE_FUNCTION (152, sub, "sub", 2)
#endif #endif
} }
VM_DEFINE_FUNCTION (153, sub1, "sub1", 1) VM_DEFINE_FUNCTION (155, sub1, "sub1", 1)
{ {
ARGS1 (x); ARGS1 (x);
@ -351,42 +363,42 @@ VM_DEFINE_FUNCTION (153, sub1, "sub1", 1)
# undef ASM_ADD # undef ASM_ADD
# undef ASM_SUB # undef ASM_SUB
VM_DEFINE_FUNCTION (154, mul, "mul", 2) VM_DEFINE_FUNCTION (156, mul, "mul", 2)
{ {
ARGS2 (x, y); ARGS2 (x, y);
SYNC_REGISTER (); SYNC_REGISTER ();
RETURN (scm_product (x, y)); RETURN (scm_product (x, y));
} }
VM_DEFINE_FUNCTION (155, div, "div", 2) VM_DEFINE_FUNCTION (157, div, "div", 2)
{ {
ARGS2 (x, y); ARGS2 (x, y);
SYNC_REGISTER (); SYNC_REGISTER ();
RETURN (scm_divide (x, y)); RETURN (scm_divide (x, y));
} }
VM_DEFINE_FUNCTION (156, quo, "quo", 2) VM_DEFINE_FUNCTION (158, quo, "quo", 2)
{ {
ARGS2 (x, y); ARGS2 (x, y);
SYNC_REGISTER (); SYNC_REGISTER ();
RETURN (scm_quotient (x, y)); RETURN (scm_quotient (x, y));
} }
VM_DEFINE_FUNCTION (157, rem, "rem", 2) VM_DEFINE_FUNCTION (159, rem, "rem", 2)
{ {
ARGS2 (x, y); ARGS2 (x, y);
SYNC_REGISTER (); SYNC_REGISTER ();
RETURN (scm_remainder (x, y)); RETURN (scm_remainder (x, y));
} }
VM_DEFINE_FUNCTION (158, mod, "mod", 2) VM_DEFINE_FUNCTION (160, mod, "mod", 2)
{ {
ARGS2 (x, y); ARGS2 (x, y);
SYNC_REGISTER (); SYNC_REGISTER ();
RETURN (scm_modulo (x, y)); RETURN (scm_modulo (x, y));
} }
VM_DEFINE_FUNCTION (159, ash, "ash", 2) VM_DEFINE_FUNCTION (161, ash, "ash", 2)
{ {
ARGS2 (x, y); ARGS2 (x, y);
if (SCM_I_INUMP (x) && SCM_I_INUMP (y)) if (SCM_I_INUMP (x) && SCM_I_INUMP (y))
@ -415,7 +427,7 @@ VM_DEFINE_FUNCTION (159, ash, "ash", 2)
RETURN (scm_ash (x, y)); RETURN (scm_ash (x, y));
} }
VM_DEFINE_FUNCTION (160, logand, "logand", 2) VM_DEFINE_FUNCTION (162, logand, "logand", 2)
{ {
ARGS2 (x, y); ARGS2 (x, y);
if (SCM_I_INUMP (x) && SCM_I_INUMP (y)) if (SCM_I_INUMP (x) && SCM_I_INUMP (y))
@ -424,7 +436,7 @@ VM_DEFINE_FUNCTION (160, logand, "logand", 2)
RETURN (scm_logand (x, y)); RETURN (scm_logand (x, y));
} }
VM_DEFINE_FUNCTION (161, logior, "logior", 2) VM_DEFINE_FUNCTION (163, logior, "logior", 2)
{ {
ARGS2 (x, y); ARGS2 (x, y);
if (SCM_I_INUMP (x) && SCM_I_INUMP (y)) if (SCM_I_INUMP (x) && SCM_I_INUMP (y))
@ -433,7 +445,7 @@ VM_DEFINE_FUNCTION (161, logior, "logior", 2)
RETURN (scm_logior (x, y)); RETURN (scm_logior (x, y));
} }
VM_DEFINE_FUNCTION (162, logxor, "logxor", 2) VM_DEFINE_FUNCTION (164, logxor, "logxor", 2)
{ {
ARGS2 (x, y); ARGS2 (x, y);
if (SCM_I_INUMP (x) && SCM_I_INUMP (y)) if (SCM_I_INUMP (x) && SCM_I_INUMP (y))
@ -447,7 +459,7 @@ VM_DEFINE_FUNCTION (162, logxor, "logxor", 2)
* Vectors and arrays * Vectors and arrays
*/ */
VM_DEFINE_FUNCTION (163, vector_ref, "vector-ref", 2) VM_DEFINE_FUNCTION (165, vector_ref, "vector-ref", 2)
{ {
scm_t_signed_bits i = 0; scm_t_signed_bits i = 0;
ARGS2 (vect, idx); ARGS2 (vect, idx);
@ -463,7 +475,7 @@ VM_DEFINE_FUNCTION (163, vector_ref, "vector-ref", 2)
} }
} }
VM_DEFINE_INSTRUCTION (164, vector_set, "vector-set", 0, 3, 0) VM_DEFINE_INSTRUCTION (166, vector_set, "vector-set", 0, 3, 0)
{ {
scm_t_signed_bits i = 0; scm_t_signed_bits i = 0;
SCM vect, idx, val; SCM vect, idx, val;
@ -481,7 +493,7 @@ VM_DEFINE_INSTRUCTION (164, vector_set, "vector-set", 0, 3, 0)
NEXT; NEXT;
} }
VM_DEFINE_INSTRUCTION (165, make_array, "make-array", 3, -1, 1) VM_DEFINE_INSTRUCTION (167, make_array, "make-array", 3, -1, 1)
{ {
scm_t_uint32 len; scm_t_uint32 len;
SCM shape, ret; SCM shape, ret;
@ -510,20 +522,20 @@ VM_DEFINE_INSTRUCTION (165, make_array, "make-array", 3, -1, 1)
goto vm_error_not_a_struct; \ goto vm_error_not_a_struct; \
} }
VM_DEFINE_FUNCTION (166, struct_p, "struct?", 1) VM_DEFINE_FUNCTION (168, struct_p, "struct?", 1)
{ {
ARGS1 (obj); ARGS1 (obj);
RETURN (scm_from_bool (SCM_STRUCTP (obj))); RETURN (scm_from_bool (SCM_STRUCTP (obj)));
} }
VM_DEFINE_FUNCTION (167, struct_vtable, "struct-vtable", 1) VM_DEFINE_FUNCTION (169, 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));
} }
VM_DEFINE_INSTRUCTION (168, make_struct, "make-struct", 2, -1, 1) VM_DEFINE_INSTRUCTION (170, make_struct, "make-struct", 2, -1, 1)
{ {
unsigned h = FETCH (); unsigned h = FETCH ();
unsigned l = FETCH (); unsigned l = FETCH ();
@ -556,7 +568,7 @@ VM_DEFINE_INSTRUCTION (168, make_struct, "make-struct", 2, -1, 1)
NEXT; NEXT;
} }
VM_DEFINE_FUNCTION (169, struct_ref, "struct-ref", 2) VM_DEFINE_FUNCTION (171, struct_ref, "struct-ref", 2)
{ {
ARGS2 (obj, pos); ARGS2 (obj, pos);
@ -586,7 +598,7 @@ VM_DEFINE_FUNCTION (169, struct_ref, "struct-ref", 2)
RETURN (scm_struct_ref (obj, pos)); RETURN (scm_struct_ref (obj, pos));
} }
VM_DEFINE_FUNCTION (170, struct_set, "struct-set", 3) VM_DEFINE_FUNCTION (172, struct_set, "struct-set", 3)
{ {
ARGS3 (obj, pos, val); ARGS3 (obj, pos, val);
@ -620,7 +632,7 @@ VM_DEFINE_FUNCTION (170, struct_set, "struct-set", 3)
/* /*
* GOOPS support * GOOPS support
*/ */
VM_DEFINE_FUNCTION (171, class_of, "class-of", 1) VM_DEFINE_FUNCTION (173, class_of, "class-of", 1)
{ {
ARGS1 (obj); ARGS1 (obj);
if (SCM_INSTANCEP (obj)) if (SCM_INSTANCEP (obj))
@ -630,7 +642,7 @@ VM_DEFINE_FUNCTION (171, class_of, "class-of", 1)
} }
/* FIXME: No checking whatsoever. */ /* FIXME: No checking whatsoever. */
VM_DEFINE_FUNCTION (172, slot_ref, "slot-ref", 2) VM_DEFINE_FUNCTION (174, slot_ref, "slot-ref", 2)
{ {
size_t slot; size_t slot;
ARGS2 (instance, idx); ARGS2 (instance, idx);
@ -639,7 +651,7 @@ VM_DEFINE_FUNCTION (172, slot_ref, "slot-ref", 2)
} }
/* FIXME: No checking whatsoever. */ /* FIXME: No checking whatsoever. */
VM_DEFINE_INSTRUCTION (173, slot_set, "slot-set", 0, 3, 0) VM_DEFINE_INSTRUCTION (175, slot_set, "slot-set", 0, 3, 0)
{ {
SCM instance, idx, val; SCM instance, idx, val;
size_t slot; size_t slot;
@ -682,21 +694,21 @@ VM_DEFINE_INSTRUCTION (173, slot_set, "slot-set", 0, 3, 0)
#define ALIGNED_P(ptr, type) \ #define ALIGNED_P(ptr, type) \
((scm_t_uintptr) (ptr) % alignof (type) == 0) ((scm_t_uintptr) (ptr) % alignof (type) == 0)
VM_DEFINE_FUNCTION (174, bv_u16_ref, "bv-u16-ref", 3) VM_DEFINE_FUNCTION (176, bv_u16_ref, "bv-u16-ref", 3)
BV_REF_WITH_ENDIANNESS (u16, u16) BV_REF_WITH_ENDIANNESS (u16, u16)
VM_DEFINE_FUNCTION (175, bv_s16_ref, "bv-s16-ref", 3) VM_DEFINE_FUNCTION (177, bv_s16_ref, "bv-s16-ref", 3)
BV_REF_WITH_ENDIANNESS (s16, s16) BV_REF_WITH_ENDIANNESS (s16, s16)
VM_DEFINE_FUNCTION (176, bv_u32_ref, "bv-u32-ref", 3) VM_DEFINE_FUNCTION (178, bv_u32_ref, "bv-u32-ref", 3)
BV_REF_WITH_ENDIANNESS (u32, u32) BV_REF_WITH_ENDIANNESS (u32, u32)
VM_DEFINE_FUNCTION (177, bv_s32_ref, "bv-s32-ref", 3) VM_DEFINE_FUNCTION (179, bv_s32_ref, "bv-s32-ref", 3)
BV_REF_WITH_ENDIANNESS (s32, s32) BV_REF_WITH_ENDIANNESS (s32, s32)
VM_DEFINE_FUNCTION (178, bv_u64_ref, "bv-u64-ref", 3) VM_DEFINE_FUNCTION (180, bv_u64_ref, "bv-u64-ref", 3)
BV_REF_WITH_ENDIANNESS (u64, u64) BV_REF_WITH_ENDIANNESS (u64, u64)
VM_DEFINE_FUNCTION (179, bv_s64_ref, "bv-s64-ref", 3) VM_DEFINE_FUNCTION (181, bv_s64_ref, "bv-s64-ref", 3)
BV_REF_WITH_ENDIANNESS (s64, s64) BV_REF_WITH_ENDIANNESS (s64, s64)
VM_DEFINE_FUNCTION (180, bv_f32_ref, "bv-f32-ref", 3) VM_DEFINE_FUNCTION (182, bv_f32_ref, "bv-f32-ref", 3)
BV_REF_WITH_ENDIANNESS (f32, ieee_single) BV_REF_WITH_ENDIANNESS (f32, ieee_single)
VM_DEFINE_FUNCTION (181, bv_f64_ref, "bv-f64-ref", 3) VM_DEFINE_FUNCTION (183, bv_f64_ref, "bv-f64-ref", 3)
BV_REF_WITH_ENDIANNESS (f64, ieee_double) BV_REF_WITH_ENDIANNESS (f64, ieee_double)
#undef BV_REF_WITH_ENDIANNESS #undef BV_REF_WITH_ENDIANNESS
@ -774,33 +786,33 @@ BV_REF_WITH_ENDIANNESS (f64, ieee_double)
RETURN (scm_bytevector_ ## fn_stem ## _native_ref (bv, idx)); \ RETURN (scm_bytevector_ ## fn_stem ## _native_ref (bv, idx)); \
} }
VM_DEFINE_FUNCTION (182, bv_u8_ref, "bv-u8-ref", 2) VM_DEFINE_FUNCTION (184, bv_u8_ref, "bv-u8-ref", 2)
BV_FIXABLE_INT_REF (u8, u8, uint8, 1) BV_FIXABLE_INT_REF (u8, u8, uint8, 1)
VM_DEFINE_FUNCTION (183, bv_s8_ref, "bv-s8-ref", 2) VM_DEFINE_FUNCTION (185, bv_s8_ref, "bv-s8-ref", 2)
BV_FIXABLE_INT_REF (s8, s8, int8, 1) BV_FIXABLE_INT_REF (s8, s8, int8, 1)
VM_DEFINE_FUNCTION (184, bv_u16_native_ref, "bv-u16-native-ref", 2) VM_DEFINE_FUNCTION (186, bv_u16_native_ref, "bv-u16-native-ref", 2)
BV_FIXABLE_INT_REF (u16, u16_native, uint16, 2) BV_FIXABLE_INT_REF (u16, u16_native, uint16, 2)
VM_DEFINE_FUNCTION (185, bv_s16_native_ref, "bv-s16-native-ref", 2) VM_DEFINE_FUNCTION (187, bv_s16_native_ref, "bv-s16-native-ref", 2)
BV_FIXABLE_INT_REF (s16, s16_native, int16, 2) BV_FIXABLE_INT_REF (s16, s16_native, int16, 2)
VM_DEFINE_FUNCTION (186, bv_u32_native_ref, "bv-u32-native-ref", 2) VM_DEFINE_FUNCTION (188, bv_u32_native_ref, "bv-u32-native-ref", 2)
#if SIZEOF_VOID_P > 4 #if SIZEOF_VOID_P > 4
BV_FIXABLE_INT_REF (u32, u32_native, uint32, 4) BV_FIXABLE_INT_REF (u32, u32_native, uint32, 4)
#else #else
BV_INT_REF (u32, uint32, 4) BV_INT_REF (u32, uint32, 4)
#endif #endif
VM_DEFINE_FUNCTION (187, bv_s32_native_ref, "bv-s32-native-ref", 2) VM_DEFINE_FUNCTION (189, bv_s32_native_ref, "bv-s32-native-ref", 2)
#if SIZEOF_VOID_P > 4 #if SIZEOF_VOID_P > 4
BV_FIXABLE_INT_REF (s32, s32_native, int32, 4) BV_FIXABLE_INT_REF (s32, s32_native, int32, 4)
#else #else
BV_INT_REF (s32, int32, 4) BV_INT_REF (s32, int32, 4)
#endif #endif
VM_DEFINE_FUNCTION (188, bv_u64_native_ref, "bv-u64-native-ref", 2) VM_DEFINE_FUNCTION (190, bv_u64_native_ref, "bv-u64-native-ref", 2)
BV_INT_REF (u64, uint64, 8) BV_INT_REF (u64, uint64, 8)
VM_DEFINE_FUNCTION (189, bv_s64_native_ref, "bv-s64-native-ref", 2) VM_DEFINE_FUNCTION (191, bv_s64_native_ref, "bv-s64-native-ref", 2)
BV_INT_REF (s64, int64, 8) BV_INT_REF (s64, int64, 8)
VM_DEFINE_FUNCTION (190, bv_f32_native_ref, "bv-f32-native-ref", 2) VM_DEFINE_FUNCTION (192, bv_f32_native_ref, "bv-f32-native-ref", 2)
BV_FLOAT_REF (f32, ieee_single, float, 4) BV_FLOAT_REF (f32, ieee_single, float, 4)
VM_DEFINE_FUNCTION (191, bv_f64_native_ref, "bv-f64-native-ref", 2) VM_DEFINE_FUNCTION (193, bv_f64_native_ref, "bv-f64-native-ref", 2)
BV_FLOAT_REF (f64, ieee_double, double, 8) BV_FLOAT_REF (f64, ieee_double, double, 8)
#undef BV_FIXABLE_INT_REF #undef BV_FIXABLE_INT_REF
@ -823,21 +835,21 @@ BV_FLOAT_REF (f64, ieee_double, double, 8)
} \ } \
} }
VM_DEFINE_INSTRUCTION (192, bv_u16_set, "bv-u16-set", 0, 4, 0) VM_DEFINE_INSTRUCTION (194, bv_u16_set, "bv-u16-set", 0, 4, 0)
BV_SET_WITH_ENDIANNESS (u16, u16) BV_SET_WITH_ENDIANNESS (u16, u16)
VM_DEFINE_INSTRUCTION (193, bv_s16_set, "bv-s16-set", 0, 4, 0) VM_DEFINE_INSTRUCTION (195, bv_s16_set, "bv-s16-set", 0, 4, 0)
BV_SET_WITH_ENDIANNESS (s16, s16) BV_SET_WITH_ENDIANNESS (s16, s16)
VM_DEFINE_INSTRUCTION (194, bv_u32_set, "bv-u32-set", 0, 4, 0) VM_DEFINE_INSTRUCTION (196, bv_u32_set, "bv-u32-set", 0, 4, 0)
BV_SET_WITH_ENDIANNESS (u32, u32) BV_SET_WITH_ENDIANNESS (u32, u32)
VM_DEFINE_INSTRUCTION (195, bv_s32_set, "bv-s32-set", 0, 4, 0) VM_DEFINE_INSTRUCTION (197, bv_s32_set, "bv-s32-set", 0, 4, 0)
BV_SET_WITH_ENDIANNESS (s32, s32) BV_SET_WITH_ENDIANNESS (s32, s32)
VM_DEFINE_INSTRUCTION (196, bv_u64_set, "bv-u64-set", 0, 4, 0) VM_DEFINE_INSTRUCTION (198, bv_u64_set, "bv-u64-set", 0, 4, 0)
BV_SET_WITH_ENDIANNESS (u64, u64) BV_SET_WITH_ENDIANNESS (u64, u64)
VM_DEFINE_INSTRUCTION (197, bv_s64_set, "bv-s64-set", 0, 4, 0) VM_DEFINE_INSTRUCTION (199, bv_s64_set, "bv-s64-set", 0, 4, 0)
BV_SET_WITH_ENDIANNESS (s64, s64) BV_SET_WITH_ENDIANNESS (s64, s64)
VM_DEFINE_INSTRUCTION (198, bv_f32_set, "bv-f32-set", 0, 4, 0) VM_DEFINE_INSTRUCTION (200, bv_f32_set, "bv-f32-set", 0, 4, 0)
BV_SET_WITH_ENDIANNESS (f32, ieee_single) BV_SET_WITH_ENDIANNESS (f32, ieee_single)
VM_DEFINE_INSTRUCTION (199, bv_f64_set, "bv-f64-set", 0, 4, 0) VM_DEFINE_INSTRUCTION (201, bv_f64_set, "bv-f64-set", 0, 4, 0)
BV_SET_WITH_ENDIANNESS (f64, ieee_double) BV_SET_WITH_ENDIANNESS (f64, ieee_double)
#undef BV_SET_WITH_ENDIANNESS #undef BV_SET_WITH_ENDIANNESS
@ -917,33 +929,33 @@ BV_SET_WITH_ENDIANNESS (f64, ieee_double)
NEXT; \ NEXT; \
} }
VM_DEFINE_INSTRUCTION (200, bv_u8_set, "bv-u8-set", 0, 3, 0) VM_DEFINE_INSTRUCTION (202, bv_u8_set, "bv-u8-set", 0, 3, 0)
BV_FIXABLE_INT_SET (u8, u8, uint8, 0, SCM_T_UINT8_MAX, 1) BV_FIXABLE_INT_SET (u8, u8, uint8, 0, SCM_T_UINT8_MAX, 1)
VM_DEFINE_INSTRUCTION (201, bv_s8_set, "bv-s8-set", 0, 3, 0) VM_DEFINE_INSTRUCTION (203, bv_s8_set, "bv-s8-set", 0, 3, 0)
BV_FIXABLE_INT_SET (s8, s8, int8, SCM_T_INT8_MIN, SCM_T_INT8_MAX, 1) BV_FIXABLE_INT_SET (s8, s8, int8, SCM_T_INT8_MIN, SCM_T_INT8_MAX, 1)
VM_DEFINE_INSTRUCTION (202, bv_u16_native_set, "bv-u16-native-set", 0, 3, 0) VM_DEFINE_INSTRUCTION (204, bv_u16_native_set, "bv-u16-native-set", 0, 3, 0)
BV_FIXABLE_INT_SET (u16, u16_native, uint16, 0, SCM_T_UINT16_MAX, 2) BV_FIXABLE_INT_SET (u16, u16_native, uint16, 0, SCM_T_UINT16_MAX, 2)
VM_DEFINE_INSTRUCTION (203, bv_s16_native_set, "bv-s16-native-set", 0, 3, 0) VM_DEFINE_INSTRUCTION (205, bv_s16_native_set, "bv-s16-native-set", 0, 3, 0)
BV_FIXABLE_INT_SET (s16, s16_native, int16, SCM_T_INT16_MIN, SCM_T_INT16_MAX, 2) BV_FIXABLE_INT_SET (s16, s16_native, int16, SCM_T_INT16_MIN, SCM_T_INT16_MAX, 2)
VM_DEFINE_INSTRUCTION (204, bv_u32_native_set, "bv-u32-native-set", 0, 3, 0) VM_DEFINE_INSTRUCTION (206, bv_u32_native_set, "bv-u32-native-set", 0, 3, 0)
#if SIZEOF_VOID_P > 4 #if SIZEOF_VOID_P > 4
BV_FIXABLE_INT_SET (u32, u32_native, uint32, 0, SCM_T_UINT32_MAX, 4) BV_FIXABLE_INT_SET (u32, u32_native, uint32, 0, SCM_T_UINT32_MAX, 4)
#else #else
BV_INT_SET (u32, uint32, 4) BV_INT_SET (u32, uint32, 4)
#endif #endif
VM_DEFINE_INSTRUCTION (205, bv_s32_native_set, "bv-s32-native-set", 0, 3, 0) VM_DEFINE_INSTRUCTION (207, bv_s32_native_set, "bv-s32-native-set", 0, 3, 0)
#if SIZEOF_VOID_P > 4 #if SIZEOF_VOID_P > 4
BV_FIXABLE_INT_SET (s32, s32_native, int32, SCM_T_INT32_MIN, SCM_T_INT32_MAX, 4) BV_FIXABLE_INT_SET (s32, s32_native, int32, SCM_T_INT32_MIN, SCM_T_INT32_MAX, 4)
#else #else
BV_INT_SET (s32, int32, 4) BV_INT_SET (s32, int32, 4)
#endif #endif
VM_DEFINE_INSTRUCTION (206, bv_u64_native_set, "bv-u64-native-set", 0, 3, 0) VM_DEFINE_INSTRUCTION (208, bv_u64_native_set, "bv-u64-native-set", 0, 3, 0)
BV_INT_SET (u64, uint64, 8) BV_INT_SET (u64, uint64, 8)
VM_DEFINE_INSTRUCTION (207, bv_s64_native_set, "bv-s64-native-set", 0, 3, 0) VM_DEFINE_INSTRUCTION (209, bv_s64_native_set, "bv-s64-native-set", 0, 3, 0)
BV_INT_SET (s64, int64, 8) BV_INT_SET (s64, int64, 8)
VM_DEFINE_INSTRUCTION (208, bv_f32_native_set, "bv-f32-native-set", 0, 3, 0) VM_DEFINE_INSTRUCTION (210, bv_f32_native_set, "bv-f32-native-set", 0, 3, 0)
BV_FLOAT_SET (f32, ieee_single, float, 4) BV_FLOAT_SET (f32, ieee_single, float, 4)
VM_DEFINE_INSTRUCTION (209, bv_f64_native_set, "bv-f64-native-set", 0, 3, 0) VM_DEFINE_INSTRUCTION (211, bv_f64_native_set, "bv-f64-native-set", 0, 3, 0)
BV_FLOAT_SET (f64, ieee_double, double, 8) BV_FLOAT_SET (f64, ieee_double, double, 8)
#undef BV_FIXABLE_INT_SET #undef BV_FIXABLE_INT_SET

View file

@ -538,12 +538,25 @@ VM_DEFINE_INSTRUCTION (40, br_if_not_null, "br-if-not-null", 3, 0, 0)
BR (!scm_is_null (x)); BR (!scm_is_null (x));
} }
VM_DEFINE_INSTRUCTION (41, br_if_nil, "br-if-nil", 3, 0, 0)
{
SCM x;
POP (x);
BR (scm_is_lisp_false (x));
}
VM_DEFINE_INSTRUCTION (42, br_if_not_nil, "br-if-not-nil", 3, 0, 0)
{
SCM x;
POP (x);
BR (!scm_is_lisp_false (x));
}
/* /*
* Subprogram call * Subprogram call
*/ */
VM_DEFINE_INSTRUCTION (41, br_if_nargs_ne, "br-if-nargs-ne", 5, 0, 0) VM_DEFINE_INSTRUCTION (43, br_if_nargs_ne, "br-if-nargs-ne", 5, 0, 0)
{ {
scm_t_ptrdiff n; scm_t_ptrdiff n;
scm_t_int32 offset; scm_t_int32 offset;
@ -555,7 +568,7 @@ VM_DEFINE_INSTRUCTION (41, br_if_nargs_ne, "br-if-nargs-ne", 5, 0, 0)
NEXT; NEXT;
} }
VM_DEFINE_INSTRUCTION (42, br_if_nargs_lt, "br-if-nargs-lt", 5, 0, 0) VM_DEFINE_INSTRUCTION (44, br_if_nargs_lt, "br-if-nargs-lt", 5, 0, 0)
{ {
scm_t_ptrdiff n; scm_t_ptrdiff n;
scm_t_int32 offset; scm_t_int32 offset;
@ -567,7 +580,7 @@ VM_DEFINE_INSTRUCTION (42, br_if_nargs_lt, "br-if-nargs-lt", 5, 0, 0)
NEXT; NEXT;
} }
VM_DEFINE_INSTRUCTION (43, br_if_nargs_gt, "br-if-nargs-gt", 5, 0, 0) VM_DEFINE_INSTRUCTION (45, br_if_nargs_gt, "br-if-nargs-gt", 5, 0, 0)
{ {
scm_t_ptrdiff n; scm_t_ptrdiff n;
scm_t_int32 offset; scm_t_int32 offset;
@ -580,7 +593,7 @@ VM_DEFINE_INSTRUCTION (43, br_if_nargs_gt, "br-if-nargs-gt", 5, 0, 0)
NEXT; NEXT;
} }
VM_DEFINE_INSTRUCTION (44, assert_nargs_ee, "assert-nargs-ee", 2, 0, 0) VM_DEFINE_INSTRUCTION (46, assert_nargs_ee, "assert-nargs-ee", 2, 0, 0)
{ {
scm_t_ptrdiff n; scm_t_ptrdiff n;
n = FETCH () << 8; n = FETCH () << 8;
@ -590,7 +603,7 @@ VM_DEFINE_INSTRUCTION (44, assert_nargs_ee, "assert-nargs-ee", 2, 0, 0)
NEXT; NEXT;
} }
VM_DEFINE_INSTRUCTION (45, assert_nargs_ge, "assert-nargs-ge", 2, 0, 0) VM_DEFINE_INSTRUCTION (47, assert_nargs_ge, "assert-nargs-ge", 2, 0, 0)
{ {
scm_t_ptrdiff n; scm_t_ptrdiff n;
n = FETCH () << 8; n = FETCH () << 8;
@ -600,7 +613,7 @@ VM_DEFINE_INSTRUCTION (45, assert_nargs_ge, "assert-nargs-ge", 2, 0, 0)
NEXT; NEXT;
} }
VM_DEFINE_INSTRUCTION (46, bind_optionals, "bind-optionals", 2, -1, -1) VM_DEFINE_INSTRUCTION (48, bind_optionals, "bind-optionals", 2, -1, -1)
{ {
scm_t_ptrdiff n; scm_t_ptrdiff n;
n = FETCH () << 8; n = FETCH () << 8;
@ -610,7 +623,7 @@ VM_DEFINE_INSTRUCTION (46, bind_optionals, "bind-optionals", 2, -1, -1)
NEXT; NEXT;
} }
VM_DEFINE_INSTRUCTION (47, bind_optionals_shuffle, "bind-optionals/shuffle", 6, -1, -1) VM_DEFINE_INSTRUCTION (49, bind_optionals_shuffle, "bind-optionals/shuffle", 6, -1, -1)
{ {
SCM *walk; SCM *walk;
scm_t_ptrdiff nreq, nreq_and_opt, ntotal; scm_t_ptrdiff nreq, nreq_and_opt, ntotal;
@ -653,7 +666,7 @@ VM_DEFINE_INSTRUCTION (47, bind_optionals_shuffle, "bind-optionals/shuffle", 6,
#define F_ALLOW_OTHER_KEYS 1 #define F_ALLOW_OTHER_KEYS 1
#define F_REST 2 #define F_REST 2
VM_DEFINE_INSTRUCTION (48, bind_kwargs, "bind-kwargs", 5, 0, 0) VM_DEFINE_INSTRUCTION (50, bind_kwargs, "bind-kwargs", 5, 0, 0)
{ {
scm_t_uint16 idx; scm_t_uint16 idx;
scm_t_ptrdiff nkw; scm_t_ptrdiff nkw;
@ -706,7 +719,7 @@ VM_DEFINE_INSTRUCTION (48, bind_kwargs, "bind-kwargs", 5, 0, 0)
#undef F_REST #undef F_REST
VM_DEFINE_INSTRUCTION (49, push_rest, "push-rest", 2, -1, -1) VM_DEFINE_INSTRUCTION (51, push_rest, "push-rest", 2, -1, -1)
{ {
scm_t_ptrdiff n; scm_t_ptrdiff n;
SCM rest = SCM_EOL; SCM rest = SCM_EOL;
@ -719,7 +732,7 @@ VM_DEFINE_INSTRUCTION (49, push_rest, "push-rest", 2, -1, -1)
NEXT; NEXT;
} }
VM_DEFINE_INSTRUCTION (50, bind_rest, "bind-rest", 4, -1, -1) VM_DEFINE_INSTRUCTION (52, bind_rest, "bind-rest", 4, -1, -1)
{ {
scm_t_ptrdiff n; scm_t_ptrdiff n;
scm_t_uint32 i; scm_t_uint32 i;
@ -735,7 +748,7 @@ VM_DEFINE_INSTRUCTION (50, bind_rest, "bind-rest", 4, -1, -1)
NEXT; NEXT;
} }
VM_DEFINE_INSTRUCTION (51, reserve_locals, "reserve-locals", 2, -1, -1) VM_DEFINE_INSTRUCTION (53, reserve_locals, "reserve-locals", 2, -1, -1)
{ {
SCM *old_sp; SCM *old_sp;
scm_t_int32 n; scm_t_int32 n;
@ -756,7 +769,7 @@ VM_DEFINE_INSTRUCTION (51, reserve_locals, "reserve-locals", 2, -1, -1)
NEXT; NEXT;
} }
VM_DEFINE_INSTRUCTION (52, new_frame, "new-frame", 0, 0, 3) VM_DEFINE_INSTRUCTION (54, new_frame, "new-frame", 0, 0, 3)
{ {
/* NB: if you change this, see frames.c:vm-frame-num-locals */ /* NB: if you change this, see frames.c:vm-frame-num-locals */
/* and frames.h, vm-engine.c, etc of course */ /* and frames.h, vm-engine.c, etc of course */
@ -771,7 +784,7 @@ VM_DEFINE_INSTRUCTION (52, new_frame, "new-frame", 0, 0, 3)
NEXT; NEXT;
} }
VM_DEFINE_INSTRUCTION (53, call, "call", 1, -1, 1) VM_DEFINE_INSTRUCTION (55, call, "call", 1, -1, 1)
{ {
nargs = FETCH (); nargs = FETCH ();
@ -819,7 +832,7 @@ VM_DEFINE_INSTRUCTION (53, call, "call", 1, -1, 1)
NEXT; NEXT;
} }
VM_DEFINE_INSTRUCTION (54, tail_call, "tail-call", 1, -1, 1) VM_DEFINE_INSTRUCTION (56, tail_call, "tail-call", 1, -1, 1)
{ {
nargs = FETCH (); nargs = FETCH ();
@ -870,7 +883,7 @@ VM_DEFINE_INSTRUCTION (54, tail_call, "tail-call", 1, -1, 1)
} }
} }
VM_DEFINE_INSTRUCTION (55, subr_call, "subr-call", 1, -1, -1) VM_DEFINE_INSTRUCTION (57, subr_call, "subr-call", 1, -1, -1)
{ {
SCM pointer, ret; SCM pointer, ret;
SCM (*subr)(); SCM (*subr)();
@ -939,7 +952,7 @@ VM_DEFINE_INSTRUCTION (55, subr_call, "subr-call", 1, -1, -1)
} }
} }
VM_DEFINE_INSTRUCTION (56, smob_call, "smob-call", 1, -1, -1) VM_DEFINE_INSTRUCTION (58, smob_call, "smob-call", 1, -1, -1)
{ {
SCM smob, ret; SCM smob, ret;
SCM (*subr)(); SCM (*subr)();
@ -986,7 +999,7 @@ VM_DEFINE_INSTRUCTION (56, smob_call, "smob-call", 1, -1, -1)
} }
} }
VM_DEFINE_INSTRUCTION (57, foreign_call, "foreign-call", 1, -1, -1) VM_DEFINE_INSTRUCTION (59, foreign_call, "foreign-call", 1, -1, -1)
{ {
SCM foreign, ret; SCM foreign, ret;
nargs = FETCH (); nargs = FETCH ();
@ -1014,7 +1027,7 @@ VM_DEFINE_INSTRUCTION (57, foreign_call, "foreign-call", 1, -1, -1)
} }
} }
VM_DEFINE_INSTRUCTION (58, continuation_call, "continuation-call", 0, -1, 0) VM_DEFINE_INSTRUCTION (60, continuation_call, "continuation-call", 0, -1, 0)
{ {
SCM contregs; SCM contregs;
POP (contregs); POP (contregs);
@ -1030,7 +1043,7 @@ VM_DEFINE_INSTRUCTION (58, continuation_call, "continuation-call", 0, -1, 0)
abort (); abort ();
} }
VM_DEFINE_INSTRUCTION (59, partial_cont_call, "partial-cont-call", 0, -1, 0) VM_DEFINE_INSTRUCTION (61, partial_cont_call, "partial-cont-call", 0, -1, 0)
{ {
SCM vmcont, intwinds, prevwinds; SCM vmcont, intwinds, prevwinds;
POP2 (intwinds, vmcont); POP2 (intwinds, vmcont);
@ -1057,7 +1070,7 @@ VM_DEFINE_INSTRUCTION (59, partial_cont_call, "partial-cont-call", 0, -1, 0)
NEXT; NEXT;
} }
VM_DEFINE_INSTRUCTION (60, tail_call_nargs, "tail-call/nargs", 0, 0, 1) VM_DEFINE_INSTRUCTION (62, tail_call_nargs, "tail-call/nargs", 0, 0, 1)
{ {
SCM x; SCM x;
POP (x); POP (x);
@ -1066,7 +1079,7 @@ VM_DEFINE_INSTRUCTION (60, tail_call_nargs, "tail-call/nargs", 0, 0, 1)
goto vm_tail_call; goto vm_tail_call;
} }
VM_DEFINE_INSTRUCTION (61, call_nargs, "call/nargs", 0, 0, 1) VM_DEFINE_INSTRUCTION (63, call_nargs, "call/nargs", 0, 0, 1)
{ {
SCM x; SCM x;
POP (x); POP (x);
@ -1075,7 +1088,7 @@ VM_DEFINE_INSTRUCTION (61, call_nargs, "call/nargs", 0, 0, 1)
goto vm_call; goto vm_call;
} }
VM_DEFINE_INSTRUCTION (62, mv_call, "mv-call", 4, -1, 1) VM_DEFINE_INSTRUCTION (64, mv_call, "mv-call", 4, -1, 1)
{ {
scm_t_int32 offset; scm_t_int32 offset;
scm_t_uint8 *mvra; scm_t_uint8 *mvra;
@ -1128,7 +1141,7 @@ VM_DEFINE_INSTRUCTION (62, mv_call, "mv-call", 4, -1, 1)
NEXT; NEXT;
} }
VM_DEFINE_INSTRUCTION (63, apply, "apply", 1, -1, 1) VM_DEFINE_INSTRUCTION (65, apply, "apply", 1, -1, 1)
{ {
int len; int len;
SCM ls; SCM ls;
@ -1150,7 +1163,7 @@ VM_DEFINE_INSTRUCTION (63, apply, "apply", 1, -1, 1)
goto vm_call; goto vm_call;
} }
VM_DEFINE_INSTRUCTION (64, tail_apply, "tail-apply", 1, -1, 1) VM_DEFINE_INSTRUCTION (66, tail_apply, "tail-apply", 1, -1, 1)
{ {
int len; int len;
SCM ls; SCM ls;
@ -1172,7 +1185,7 @@ VM_DEFINE_INSTRUCTION (64, tail_apply, "tail-apply", 1, -1, 1)
goto vm_tail_call; goto vm_tail_call;
} }
VM_DEFINE_INSTRUCTION (65, call_cc, "call/cc", 0, 1, 1) VM_DEFINE_INSTRUCTION (67, call_cc, "call/cc", 0, 1, 1)
{ {
int first; int first;
SCM proc, vm_cont, cont; SCM proc, vm_cont, cont;
@ -1207,7 +1220,7 @@ VM_DEFINE_INSTRUCTION (65, call_cc, "call/cc", 0, 1, 1)
} }
} }
VM_DEFINE_INSTRUCTION (66, tail_call_cc, "tail-call/cc", 0, 1, 1) VM_DEFINE_INSTRUCTION (68, tail_call_cc, "tail-call/cc", 0, 1, 1)
{ {
int first; int first;
SCM proc, vm_cont, cont; SCM proc, vm_cont, cont;
@ -1247,7 +1260,7 @@ VM_DEFINE_INSTRUCTION (66, tail_call_cc, "tail-call/cc", 0, 1, 1)
} }
} }
VM_DEFINE_INSTRUCTION (67, return, "return", 0, 1, 1) VM_DEFINE_INSTRUCTION (69, return, "return", 0, 1, 1)
{ {
vm_return: vm_return:
POP_CONTINUATION_HOOK (1); POP_CONTINUATION_HOOK (1);
@ -1283,7 +1296,7 @@ VM_DEFINE_INSTRUCTION (67, return, "return", 0, 1, 1)
NEXT; NEXT;
} }
VM_DEFINE_INSTRUCTION (68, return_values, "return/values", 1, -1, -1) VM_DEFINE_INSTRUCTION (70, return_values, "return/values", 1, -1, -1)
{ {
/* nvalues declared at top level, because for some reason gcc seems to think /* nvalues declared at top level, because for some reason gcc seems to think
that perhaps it might be used without declaration. Fooey to that, I say. */ that perhaps it might be used without declaration. Fooey to that, I say. */
@ -1339,7 +1352,7 @@ VM_DEFINE_INSTRUCTION (68, return_values, "return/values", 1, -1, -1)
NEXT; NEXT;
} }
VM_DEFINE_INSTRUCTION (69, return_values_star, "return/values*", 1, -1, -1) VM_DEFINE_INSTRUCTION (71, return_values_star, "return/values*", 1, -1, -1)
{ {
SCM l; SCM l;
@ -1362,7 +1375,7 @@ VM_DEFINE_INSTRUCTION (69, return_values_star, "return/values*", 1, -1, -1)
goto vm_return_values; goto vm_return_values;
} }
VM_DEFINE_INSTRUCTION (70, return_nvalues, "return/nvalues", 0, 1, -1) VM_DEFINE_INSTRUCTION (72, return_nvalues, "return/nvalues", 0, 1, -1)
{ {
SCM n; SCM n;
POP (n); POP (n);
@ -1371,7 +1384,7 @@ VM_DEFINE_INSTRUCTION (70, return_nvalues, "return/nvalues", 0, 1, -1)
goto vm_return_values; goto vm_return_values;
} }
VM_DEFINE_INSTRUCTION (71, truncate_values, "truncate-values", 2, -1, -1) VM_DEFINE_INSTRUCTION (73, truncate_values, "truncate-values", 2, -1, -1)
{ {
SCM x; SCM x;
int nbinds, rest; int nbinds, rest;
@ -1394,7 +1407,7 @@ VM_DEFINE_INSTRUCTION (71, truncate_values, "truncate-values", 2, -1, -1)
NEXT; NEXT;
} }
VM_DEFINE_INSTRUCTION (72, box, "box", 1, 1, 0) VM_DEFINE_INSTRUCTION (74, box, "box", 1, 1, 0)
{ {
SCM val; SCM val;
POP (val); POP (val);
@ -1408,7 +1421,7 @@ VM_DEFINE_INSTRUCTION (72, box, "box", 1, 1, 0)
(set! a (lambda () (b ...))) (set! a (lambda () (b ...)))
...) ...)
*/ */
VM_DEFINE_INSTRUCTION (73, empty_box, "empty-box", 1, 0, 0) VM_DEFINE_INSTRUCTION (75, empty_box, "empty-box", 1, 0, 0)
{ {
SYNC_BEFORE_GC (); SYNC_BEFORE_GC ();
LOCAL_SET (FETCH (), LOCAL_SET (FETCH (),
@ -1416,7 +1429,7 @@ VM_DEFINE_INSTRUCTION (73, empty_box, "empty-box", 1, 0, 0)
NEXT; NEXT;
} }
VM_DEFINE_INSTRUCTION (74, local_boxed_ref, "local-boxed-ref", 1, 0, 1) VM_DEFINE_INSTRUCTION (76, 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);
@ -1424,7 +1437,7 @@ VM_DEFINE_INSTRUCTION (74, local_boxed_ref, "local-boxed-ref", 1, 0, 1)
NEXT; NEXT;
} }
VM_DEFINE_INSTRUCTION (75, local_boxed_set, "local-boxed-set", 1, 1, 0) VM_DEFINE_INSTRUCTION (77, local_boxed_set, "local-boxed-set", 1, 1, 0)
{ {
SCM v, val; SCM v, val;
v = LOCAL_REF (FETCH ()); v = LOCAL_REF (FETCH ());
@ -1434,7 +1447,7 @@ VM_DEFINE_INSTRUCTION (75, local_boxed_set, "local-boxed-set", 1, 1, 0)
NEXT; NEXT;
} }
VM_DEFINE_INSTRUCTION (76, free_ref, "free-ref", 1, 0, 1) VM_DEFINE_INSTRUCTION (78, free_ref, "free-ref", 1, 0, 1)
{ {
scm_t_uint8 idx = FETCH (); scm_t_uint8 idx = FETCH ();
@ -1445,7 +1458,7 @@ VM_DEFINE_INSTRUCTION (76, free_ref, "free-ref", 1, 0, 1)
/* no free-set -- if a var is assigned, it should be in a box */ /* no free-set -- if a var is assigned, it should be in a box */
VM_DEFINE_INSTRUCTION (77, free_boxed_ref, "free-boxed-ref", 1, 0, 1) VM_DEFINE_INSTRUCTION (79, free_boxed_ref, "free-boxed-ref", 1, 0, 1)
{ {
SCM v; SCM v;
scm_t_uint8 idx = FETCH (); scm_t_uint8 idx = FETCH ();
@ -1456,7 +1469,7 @@ VM_DEFINE_INSTRUCTION (77, free_boxed_ref, "free-boxed-ref", 1, 0, 1)
NEXT; NEXT;
} }
VM_DEFINE_INSTRUCTION (78, free_boxed_set, "free-boxed-set", 1, 1, 0) VM_DEFINE_INSTRUCTION (80, free_boxed_set, "free-boxed-set", 1, 1, 0)
{ {
SCM v, val; SCM v, val;
scm_t_uint8 idx = FETCH (); scm_t_uint8 idx = FETCH ();
@ -1468,7 +1481,7 @@ VM_DEFINE_INSTRUCTION (78, free_boxed_set, "free-boxed-set", 1, 1, 0)
NEXT; NEXT;
} }
VM_DEFINE_INSTRUCTION (79, make_closure, "make-closure", 2, -1, 1) VM_DEFINE_INSTRUCTION (81, make_closure, "make-closure", 2, -1, 1)
{ {
size_t n, len; size_t n, len;
SCM closure; SCM closure;
@ -1487,7 +1500,7 @@ VM_DEFINE_INSTRUCTION (79, make_closure, "make-closure", 2, -1, 1)
NEXT; NEXT;
} }
VM_DEFINE_INSTRUCTION (80, make_variable, "make-variable", 0, 0, 1) VM_DEFINE_INSTRUCTION (82, make_variable, "make-variable", 0, 0, 1)
{ {
SYNC_BEFORE_GC (); SYNC_BEFORE_GC ();
/* fixme underflow */ /* fixme underflow */
@ -1495,7 +1508,7 @@ VM_DEFINE_INSTRUCTION (80, make_variable, "make-variable", 0, 0, 1)
NEXT; NEXT;
} }
VM_DEFINE_INSTRUCTION (81, fix_closure, "fix-closure", 2, -1, 0) VM_DEFINE_INSTRUCTION (83, fix_closure, "fix-closure", 2, -1, 0)
{ {
SCM x; SCM x;
unsigned int i = FETCH (); unsigned int i = FETCH ();
@ -1512,7 +1525,7 @@ VM_DEFINE_INSTRUCTION (81, fix_closure, "fix-closure", 2, -1, 0)
NEXT; NEXT;
} }
VM_DEFINE_INSTRUCTION (82, define, "define", 0, 0, 2) VM_DEFINE_INSTRUCTION (84, define, "define", 0, 0, 2)
{ {
SCM sym, val; SCM sym, val;
POP2 (sym, val); POP2 (sym, val);
@ -1523,7 +1536,7 @@ VM_DEFINE_INSTRUCTION (82, define, "define", 0, 0, 2)
NEXT; NEXT;
} }
VM_DEFINE_INSTRUCTION (83, make_keyword, "make-keyword", 0, 1, 1) VM_DEFINE_INSTRUCTION (85, make_keyword, "make-keyword", 0, 1, 1)
{ {
CHECK_UNDERFLOW (); CHECK_UNDERFLOW ();
SYNC_REGISTER (); SYNC_REGISTER ();
@ -1531,7 +1544,7 @@ VM_DEFINE_INSTRUCTION (83, make_keyword, "make-keyword", 0, 1, 1)
NEXT; NEXT;
} }
VM_DEFINE_INSTRUCTION (84, make_symbol, "make-symbol", 0, 1, 1) VM_DEFINE_INSTRUCTION (86, make_symbol, "make-symbol", 0, 1, 1)
{ {
CHECK_UNDERFLOW (); CHECK_UNDERFLOW ();
SYNC_REGISTER (); SYNC_REGISTER ();
@ -1539,7 +1552,7 @@ VM_DEFINE_INSTRUCTION (84, make_symbol, "make-symbol", 0, 1, 1)
NEXT; NEXT;
} }
VM_DEFINE_INSTRUCTION (85, prompt, "prompt", 4, 2, 0) VM_DEFINE_INSTRUCTION (87, prompt, "prompt", 4, 2, 0)
{ {
scm_t_int32 offset; scm_t_int32 offset;
scm_t_uint8 escape_only_p; scm_t_uint8 escape_only_p;
@ -1577,7 +1590,7 @@ VM_DEFINE_INSTRUCTION (85, prompt, "prompt", 4, 2, 0)
NEXT; NEXT;
} }
VM_DEFINE_INSTRUCTION (86, wind, "wind", 0, 2, 0) VM_DEFINE_INSTRUCTION (88, wind, "wind", 0, 2, 0)
{ {
SCM wind, unwind; SCM wind, unwind;
POP2 (unwind, wind); POP2 (unwind, wind);
@ -1599,7 +1612,7 @@ VM_DEFINE_INSTRUCTION (86, wind, "wind", 0, 2, 0)
NEXT; NEXT;
} }
VM_DEFINE_INSTRUCTION (87, abort, "abort", 1, -1, -1) VM_DEFINE_INSTRUCTION (89, abort, "abort", 1, -1, -1)
{ {
unsigned n = FETCH (); unsigned n = FETCH ();
SYNC_REGISTER (); SYNC_REGISTER ();
@ -1610,7 +1623,7 @@ VM_DEFINE_INSTRUCTION (87, abort, "abort", 1, -1, -1)
abort (); abort ();
} }
VM_DEFINE_INSTRUCTION (88, unwind, "unwind", 0, 0, 0) VM_DEFINE_INSTRUCTION (90, unwind, "unwind", 0, 0, 0)
{ {
/* A normal exit from the dynamic extent of an expression. Pop the top entry /* A normal exit from the dynamic extent of an expression. Pop the top entry
off of the dynamic stack. */ off of the dynamic stack. */
@ -1618,7 +1631,7 @@ VM_DEFINE_INSTRUCTION (88, unwind, "unwind", 0, 0, 0)
NEXT; NEXT;
} }
VM_DEFINE_INSTRUCTION (89, wind_fluids, "wind-fluids", 1, -1, 0) VM_DEFINE_INSTRUCTION (91, wind_fluids, "wind-fluids", 1, -1, 0)
{ {
unsigned n = FETCH (); unsigned n = FETCH ();
SCM wf; SCM wf;
@ -1634,7 +1647,7 @@ VM_DEFINE_INSTRUCTION (89, wind_fluids, "wind-fluids", 1, -1, 0)
NEXT; NEXT;
} }
VM_DEFINE_INSTRUCTION (90, unwind_fluids, "unwind-fluids", 0, 0, 0) VM_DEFINE_INSTRUCTION (92, unwind_fluids, "unwind-fluids", 0, 0, 0)
{ {
SCM wf; SCM wf;
wf = scm_car (scm_i_dynwinds ()); wf = scm_car (scm_i_dynwinds ());
@ -1643,7 +1656,7 @@ VM_DEFINE_INSTRUCTION (90, unwind_fluids, "unwind-fluids", 0, 0, 0)
NEXT; NEXT;
} }
VM_DEFINE_INSTRUCTION (91, fluid_ref, "fluid-ref", 0, 1, 1) VM_DEFINE_INSTRUCTION (93, fluid_ref, "fluid-ref", 0, 1, 1)
{ {
size_t num; size_t num;
SCM fluids; SCM fluids;
@ -1671,7 +1684,7 @@ VM_DEFINE_INSTRUCTION (91, fluid_ref, "fluid-ref", 0, 1, 1)
NEXT; NEXT;
} }
VM_DEFINE_INSTRUCTION (92, fluid_set, "fluid-set", 0, 2, 0) VM_DEFINE_INSTRUCTION (94, fluid_set, "fluid-set", 0, 2, 0)
{ {
size_t num; size_t num;
SCM val, fluid, fluids; SCM val, fluid, fluids;
@ -1691,7 +1704,7 @@ VM_DEFINE_INSTRUCTION (92, fluid_set, "fluid-set", 0, 2, 0)
NEXT; NEXT;
} }
VM_DEFINE_INSTRUCTION (93, assert_nargs_ee_locals, "assert-nargs-ee/locals", 1, 0, 0) VM_DEFINE_INSTRUCTION (95, assert_nargs_ee_locals, "assert-nargs-ee/locals", 1, 0, 0)
{ {
scm_t_ptrdiff n; scm_t_ptrdiff n;
SCM *old_sp; SCM *old_sp;
@ -1711,7 +1724,6 @@ VM_DEFINE_INSTRUCTION (93, assert_nargs_ee_locals, "assert-nargs-ee/locals", 1,
NEXT; NEXT;
} }
/* /*
(defun renumber-ops () (defun renumber-ops ()
"start from top of buffer and renumber 'VM_DEFINE_FOO (\n' sequences" "start from top of buffer and renumber 'VM_DEFINE_FOO (\n' sequences"

View file

@ -133,6 +133,8 @@
((br-if-not-eq ,l) (write-break l)) ((br-if-not-eq ,l) (write-break l))
((br-if-null ,l) (write-break l)) ((br-if-null ,l) (write-break l))
((br-if-not-null ,l) (write-break l)) ((br-if-not-null ,l) (write-break l))
((br-if-nil ,l) (write-break l))
((br-if-not-nil ,l) (write-break l))
((br-if-nargs-ne ,hi ,lo ,l) (write-byte hi) (write-byte lo) (write-break l)) ((br-if-nargs-ne ,hi ,lo ,l) (write-byte hi) (write-byte lo) (write-break l))
((br-if-nargs-lt ,hi ,lo ,l) (write-byte hi) (write-byte lo) (write-break l)) ((br-if-nargs-lt ,hi ,lo ,l) (write-byte hi) (write-byte lo) (write-break l))
((br-if-nargs-gt ,hi ,lo ,l) (write-byte hi) (write-byte lo) (write-break l)) ((br-if-nargs-gt ,hi ,lo ,l) (write-byte hi) (write-byte lo) (write-break l))

View file

@ -125,7 +125,9 @@
(case inst (case inst
((list vector) ((list vector)
(list "~a element~:p" (apply make-int16 args))) (list "~a element~:p" (apply make-int16 args)))
((br br-if br-if-eq br-if-not br-if-not-eq br-if-not-null br-if-null) ((br
br-if br-if-eq br-if-not br-if-not-eq br-if-not-null br-if-null
br-if-nil br-if-not-nil)
(list "-> ~A" (assq-ref labels (car args)))) (list "-> ~A" (assq-ref labels (car args))))
((br-if-nargs-ne br-if-nargs-lt br-if-nargs-gt) ((br-if-nargs-ne br-if-nargs-lt br-if-nargs-gt)
(list "-> ~A" (assq-ref labels (caddr args)))) (list "-> ~A" (assq-ref labels (caddr args))))

View file

@ -110,6 +110,7 @@
((list? . 1) . list?) ((list? . 1) . list?)
((symbol? . 1) . symbol?) ((symbol? . 1) . symbol?)
((vector? . 1) . vector?) ((vector? . 1) . vector?)
((nil? . 1) . nil?)
(list . list) (list . list)
(vector . vector) (vector . vector)
((class-of . 1) . class-of) ((class-of . 1) . class-of)
@ -568,6 +569,10 @@
(comp-push (car args)) (comp-push (car args))
(emit-branch src 'br-if-not-null L1)) (emit-branch src 'br-if-not-null L1))
((and (eq? name 'nil?) (= len 1))
(comp-push (car args))
(emit-branch src 'br-if-not-nil L1))
((and (eq? name 'not) (= len 1)) ((and (eq? name 'not) (= len 1))
(let ((app (car args))) (let ((app (car args)))
(record-case app (record-case app
@ -586,6 +591,10 @@
(comp-push (car args)) (comp-push (car args))
(emit-branch src 'br-if-null L1)) (emit-branch src 'br-if-null L1))
((and (eq? name 'nil?) (= len 1))
(comp-push (car args))
(emit-branch src 'br-if-nil L1))
(else (else
(comp-push app) (comp-push app)
(emit-branch src 'br-if L1)))) (emit-branch src 'br-if L1))))

View file

@ -46,6 +46,7 @@
ash logand logior logxor ash logand logior logxor
not not
pair? null? list? symbol? vector? string? struct? pair? null? list? symbol? vector? string? struct?
nil?
acons cons cons* acons cons cons*
list vector list vector
@ -141,6 +142,7 @@
+ * - / 1- 1+ quotient remainder modulo + * - / 1- 1+ quotient remainder modulo
not not
pair? null? list? symbol? vector? struct? string? pair? null? list? symbol? vector? struct? string?
nil?
string-length string-length
;; These all should get expanded out by expand-primitives!. ;; These all should get expanded out by expand-primitives!.
caar cadr cdar cddr caar cadr cdar cddr
@ -168,6 +170,7 @@
ash logand logior logxor ash logand logior logxor
not not
pair? null? list? symbol? vector? acons cons cons* pair? null? list? symbol? vector? acons cons cons*
nil?
list vector list vector
car cdr car cdr
set-car! set-cdr! set-car! set-cdr!