summaryrefslogtreecommitdiff
path: root/libguile/vm-i-loader.c
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2008-10-03 16:00:30 +0200
committerAndy Wingo <wingo@pobox.com>2008-10-03 16:00:30 +0200
commit11ea1aba9eb99756e72b6447a93da8d901558299 (patch)
tree882323910c897b6b727288a683f29f25bd61a73e /libguile/vm-i-loader.c
parentedb1d1d78da289ffe9170ffe21e120cb31e463b5 (diff)
downloadguile-11ea1aba9eb99756e72b6447a93da8d901558299.tar.gz
precise stack marking, fix some missed references, still imperfect
* libguile/vm-engine.h (CHECK_STACK_LEAK, NULLSTACK): Add a new mode, VM_ENABLE_STACK_NULLING, that tries to ensure that all stack data past the top of the stack is NULL. This helps to verify the VM's consistency. If VM_ENABLE_STACK_NULLING is not defined, there is no overhead. (DROP, DROPN): Hook into NULLSTACK. (POP_LIST): Hoo, fix a good bug: if CONS triggered a GC, the elements of the list that had not yet been consed would not be marked, because the sp was already below them. (NEXT): Hook into CHECK_STACK_LEAK. (INIT_ARGS): Add a note that consing the rest arg can cause GC. (NEW_FRAME): Cons up the external data after initializing the frame, so that if GC is triggered, the precise marker sees a well-formed frame. * libguile/vm-i-loader.c (load-program): In the four-integers case, use the POP macro so that we can hook into NULLSTACK (if necessary). * libguile/vm-i-scheme.c (ARGS2, ARGS3): Hook into NULLSTACK. * libguile/vm-i-system.c (halt): Null the nvalues. Rework some asserts into using ASSERT, and null the stack when we free the frame. (variable-set): Use DROPN instead of sp -= 2. (BR): Hook into NULLSTACK. (goto/args): Hook into NULLSTACK. In the non-self case, delay updating the frame until after INIT_ARGS so that GC sees a well-formed frame. Delay consing the externals until after the frame is set up, as in NEW_FRAME. (call/cc): Add some asserts. (return): Rework some asserts into ASSERT, and hook into NULLSTACK. (return/values): Hook into NULLSTACK, and use ASSERT. (return/values*) Use ASSERT. * libguile/vm.c (VM_ENABLE_ASSERTIONS, VM_ENABLE_STACK_NULLING): These are the variables that control assertions and nulling. Perhaps we can do these per-engine when we start compiling the debug engine separate from a speedy engine. (vm_mark_stack): Add a precise stack marker. Yay! (vm_cont_mark): Mark the continuation stack precisely. (capture_vm_cont): Record the difference from the vp's stack_base too, so that we can translate the dynamic links when marking the continuation stack. Memset the stack to NULL if we are doing nulling. (reinstate_vm_cont): If we are nulling, null out the relevant part of the stack. (vm_reset_stack): When resetting sp due to a nonlocal exit, null out the stack too. (vm_mark): If we are nulling, assert that there are no extra values on the stack. Mark the stack precisely.
Diffstat (limited to 'libguile/vm-i-loader.c')
-rw-r--r--libguile/vm-i-loader.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/libguile/vm-i-loader.c b/libguile/vm-i-loader.c
index 72436f0d5..778163f0f 100644
--- a/libguile/vm-i-loader.c
+++ b/libguile/vm-i-loader.c
@@ -152,11 +152,10 @@ VM_DEFINE_LOADER (load_program, "load-program")
{
/* Other cases */
/* x is #f, and already popped off */
- p->nargs = SCM_I_INUM (sp[-3]);
- p->nrest = SCM_I_INUM (sp[-2]);
- p->nlocs = SCM_I_INUM (sp[-1]);
- p->nexts = SCM_I_INUM (sp[0]);
- sp -= 4;
+ POP (x); p->nexts = scm_to_unsigned_integer (x, 0, 255);
+ POP (x); p->nlocs = scm_to_unsigned_integer (x, 0, 255);
+ POP (x); p->nrest = scm_to_unsigned_integer (x, 0, 1);
+ POP (x); p->nargs = scm_to_unsigned_integer (x, 0, 255);
}
PUSH (prog);