summaryrefslogtreecommitdiff
path: root/libguile/vm-engine.h
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2008-10-09 14:44:43 +0200
committerAndy Wingo <wingo@pobox.com>2008-10-09 14:44:43 +0200
commit66db076ae17e1a6b5225fabaaeb6958115cc9b4c (patch)
treea2390479cac342ab6de5d38aa9492648afe74f16 /libguile/vm-engine.h
parent0570c3f197f910cc136969d6a2ed2ad0792b3501 (diff)
downloadguile-66db076ae17e1a6b5225fabaaeb6958115cc9b4c.tar.gz
NULLSTACK fixes for nonlocal exits in reentrant pre-wind handlers
* libguile/vm-i-system.c (goto/cc): Add some asserts here. * libguile/vm.c (capture_vm_cont): Add some asserts here too. (reinstate_vm_cont): Null the correct number of bytes. Add a FIXME. (vm_reset_stack): Make the code a bit clearer. Null the correct number of bytes. * libguile/vm-engine.h (NULLSTACK_FOR_NONLOCAL_EXIT): New macro, handles a very tricky case that took me days to find! Amply commented. Expands to nothing in the normal case. * libguile/vm-i-system.c (call, goto/args, mv-call): Call NULLSTACK_FOR_NONLOCAL_EXIT in the right places. Fixes continuations.test.
Diffstat (limited to 'libguile/vm-engine.h')
-rw-r--r--libguile/vm-engine.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/libguile/vm-engine.h b/libguile/vm-engine.h
index 2c15b9d63..22a7ef5e4 100644
--- a/libguile/vm-engine.h
+++ b/libguile/vm-engine.h
@@ -247,10 +247,17 @@
# define CHECK_STACK_LEAKN(_n) ASSERT (!sp[_n]);
# define CHECK_STACK_LEAK() CHECK_STACK_LEAKN(1)
# define NULLSTACK(_n) { int __x = _n; CHECK_STACK_LEAKN (_n+1); while (__x > 0) sp[__x--] = NULL; }
+/* If you have a nonlocal exit in a pre-wind proc while invoking a continuation
+ inside a dynwind (phew!), the stack is fully rewound but vm_reset_stack for
+ that continuation doesn't have a chance to run. It's not important on a
+ semantic level, but it does mess up our stack nulling -- so this macro is to
+ fix that. */
+# define NULLSTACK_FOR_NONLOCAL_EXIT() if (vp->sp > sp) NULLSTACK (vp->sp - sp);
#else
# define CHECK_STACK_LEAKN(_n)
# define CHECK_STACK_LEAK()
# define NULLSTACK(_n)
+# define NULLSTACK_FOR_NONLOCAL_EXIT()
#endif
#define CHECK_OVERFLOW() \