diff options
author | Andy Wingo <wingo@pobox.com> | 2009-07-19 19:48:26 +0200 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2009-07-22 00:13:52 +0200 |
commit | 8d90b356560b9cf54300ff9eabf4675acb650e03 (patch) | |
tree | 2193d51f330ab4a827be3559cbf3ac3208b18b57 /libguile/vm-engine.h | |
parent | a5cfddd560ca21205c8b0417413253d94f3e9b93 (diff) | |
download | guile-8d90b356560b9cf54300ff9eabf4675acb650e03.tar.gz |
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.
Diffstat (limited to 'libguile/vm-engine.h')
-rw-r--r-- | libguile/vm-engine.h | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/libguile/vm-engine.h b/libguile/vm-engine.h index d6849799c..a2c1effd3 100644 --- a/libguile/vm-engine.h +++ b/libguile/vm-engine.h @@ -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 |