1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-14 15:40:19 +02:00

vm support for display closures

* libguile/vm-i-system.c (box, empty-box): Boxing values and storing
  them in local variables.
  (local-boxed-ref, local-boxed-set): A combination of local-ref then
  variable-ref/set.
  (make-closure2, closure-ref, closure-boxed-ref, closure-boxed-set):
  New ops. The idea is to migrate Guile over to using flat dispay
  closures. See the paper "Three Implementation Models for Scheme" by
  Kent Dybvig for more details; this is the "stack-based" model.

* libguile/vm-engine.c:
* libguile/vm-engine.h: Add the necessary infrastructure to keep track
  of a "closure" variable, like our "externals" in semantics, but
  minimal, flat, and O(1) in implementation.
This commit is contained in:
Andy Wingo 2009-07-19 19:48:26 +02:00
parent a5cfddd560
commit 8d90b35656
3 changed files with 130 additions and 1 deletions

View file

@ -117,6 +117,16 @@
vp->fp = fp; \
}
/* FIXME */
#define ASSERT_VARIABLE(x) \
do { if (!SCM_VARIABLEP (x)) { SYNC_REGISTER (); abort(); } \
} while (0)
#define ASSERT_BOUND_VARIABLE(x) \
do { ASSERT_VARIABLE (x); \
if (SCM_VARIABLE_REF (x) == SCM_UNDEFINED) \
{ SYNC_REGISTER (); abort(); } \
} while (0)
#ifdef VM_ENABLE_PARANOID_ASSERTIONS
#define CHECK_IP() \
do { if (ip < bp->base || ip - bp->base > bp->len) abort (); } while (0)
@ -145,6 +155,19 @@
object_count = 0; \
} \
} \
{ \
SCM c = SCM_PROGRAM_EXTERNALS (program); \
if (SCM_I_IS_VECTOR (c)) \
{ \
closure = SCM_I_VECTOR_WELTS (c); \
closure_count = SCM_I_VECTOR_LENGTH (c); \
} \
else \
{ \
closure = NULL; \
closure_count = 0; \
} \
} \
}
#define SYNC_BEFORE_GC() \
@ -178,6 +201,13 @@
#define CHECK_OBJECT(_num)
#endif
#if VM_CHECK_CLOSURE
#define CHECK_CLOSURE(_num) \
do { if (SCM_UNLIKELY ((_num) >= closure_count)) goto vm_error_closure; } while (0)
#else
#define CHECK_CLOSURE(_num)
#endif
/*
* Hooks