From 6d804376e94d17cf013a415c4bd98d632f7a91b9 Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Wed, 24 Feb 2010 16:56:05 +0100 Subject: [PATCH] record IP in partial continuations * libguile/control.c (reify_partial_continuation): Assert some invariants, and record the IP as the MVRA of the continuation. --- libguile/control.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/libguile/control.c b/libguile/control.c index 25c95047b..cffc00781 100644 --- a/libguile/control.c +++ b/libguile/control.c @@ -144,11 +144,20 @@ reify_partial_continuation (SCM vm, SCM prompt, SCM extwinds, if (cookie >= 0 && SCM_PROMPT_REGISTERS (prompt)->cookie == cookie) flags |= SCM_F_VM_CONT_REWINDABLE; - /* NULL RA and MVRA, as those get set when the cont is reinstated */ - vm_cont = scm_i_vm_capture_stack (SCM_PROMPT_REGISTERS (prompt)->sp, + /* Since non-escape continuations should begin with a thunk application, the + first bit of the stack should be a frame, with the saved fp equal to the fp + that was current when the prompt was made. */ + if ((SCM*)(SCM_PROMPT_REGISTERS (prompt)->sp[1]) + != SCM_PROMPT_REGISTERS (prompt)->fp) + abort (); + + /* Capture from the top of the thunk application frame up to the end. Set an + MVRA only, as the post-abort code is in an MV context. */ + vm_cont = scm_i_vm_capture_stack (SCM_PROMPT_REGISTERS (prompt)->sp + 4, SCM_VM_DATA (vm)->fp, SCM_VM_DATA (vm)->sp, - NULL, NULL, + NULL, + SCM_VM_DATA (vm)->ip, flags); ret = scm_make_program (cont_objcode,