mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-10 05:50:26 +02:00
Refactorings to apply-hook and push-continuation-hook
* libguile/vm-engine.c (vm_engine): Always invoke the apply hook after the ip has been reset. Avoids problems in frame-bindings, which builds its bindings map based on the IP. Invoke push-continuation before linking the new frame, so that more locals are available to the frame inspector. * module/system/vm/traps.scm (trap-in-procedure): No need for a push-cont handler, as the apply handler will exit the frame.
This commit is contained in:
parent
7c080187bc
commit
f5cb70e94a
2 changed files with 28 additions and 20 deletions
|
@ -486,6 +486,9 @@ VM_NAME (scm_i_thread *thread, struct scm_vm *vp,
|
|||
|
||||
/* Let's go! */
|
||||
ip = SCM_PROGRAM_CODE (LOCAL_REF (0));
|
||||
|
||||
APPLY_HOOK ();
|
||||
|
||||
NEXT (0);
|
||||
|
||||
BEGIN_DISPATCH_SWITCH;
|
||||
|
@ -549,6 +552,8 @@ VM_NAME (scm_i_thread *thread, struct scm_vm *vp,
|
|||
|
||||
VM_HANDLE_INTERRUPTS;
|
||||
|
||||
PUSH_CONTINUATION_HOOK ();
|
||||
|
||||
old_fp = fp;
|
||||
fp = vp->fp = old_fp + proc;
|
||||
SCM_FRAME_SET_DYNAMIC_LINK (fp, old_fp);
|
||||
|
@ -556,13 +561,13 @@ VM_NAME (scm_i_thread *thread, struct scm_vm *vp,
|
|||
|
||||
RESET_FRAME (nlocals);
|
||||
|
||||
PUSH_CONTINUATION_HOOK ();
|
||||
APPLY_HOOK ();
|
||||
|
||||
if (SCM_UNLIKELY (!SCM_PROGRAM_P (LOCAL_REF (0))))
|
||||
goto apply;
|
||||
|
||||
ip = SCM_PROGRAM_CODE (LOCAL_REF (0));
|
||||
|
||||
APPLY_HOOK ();
|
||||
|
||||
NEXT (0);
|
||||
}
|
||||
|
||||
|
@ -588,6 +593,8 @@ VM_NAME (scm_i_thread *thread, struct scm_vm *vp,
|
|||
|
||||
VM_HANDLE_INTERRUPTS;
|
||||
|
||||
PUSH_CONTINUATION_HOOK ();
|
||||
|
||||
old_fp = fp;
|
||||
fp = vp->fp = old_fp + proc;
|
||||
SCM_FRAME_SET_DYNAMIC_LINK (fp, old_fp);
|
||||
|
@ -595,10 +602,11 @@ VM_NAME (scm_i_thread *thread, struct scm_vm *vp,
|
|||
|
||||
RESET_FRAME (nlocals);
|
||||
|
||||
PUSH_CONTINUATION_HOOK ();
|
||||
ip += label;
|
||||
|
||||
APPLY_HOOK ();
|
||||
|
||||
NEXT (label);
|
||||
NEXT (0);
|
||||
}
|
||||
|
||||
/* tail-call nlocals:24
|
||||
|
@ -617,12 +625,13 @@ VM_NAME (scm_i_thread *thread, struct scm_vm *vp,
|
|||
|
||||
RESET_FRAME (nlocals);
|
||||
|
||||
APPLY_HOOK ();
|
||||
|
||||
if (SCM_UNLIKELY (!SCM_PROGRAM_P (LOCAL_REF (0))))
|
||||
goto apply;
|
||||
|
||||
ip = SCM_PROGRAM_CODE (LOCAL_REF (0));
|
||||
|
||||
APPLY_HOOK ();
|
||||
|
||||
NEXT (0);
|
||||
}
|
||||
|
||||
|
@ -643,9 +652,11 @@ VM_NAME (scm_i_thread *thread, struct scm_vm *vp,
|
|||
|
||||
RESET_FRAME (nlocals);
|
||||
|
||||
ip += label;
|
||||
|
||||
APPLY_HOOK ();
|
||||
|
||||
NEXT (label);
|
||||
NEXT (0);
|
||||
}
|
||||
|
||||
/* tail-call/shuffle from:24
|
||||
|
@ -671,12 +682,13 @@ VM_NAME (scm_i_thread *thread, struct scm_vm *vp,
|
|||
|
||||
RESET_FRAME (n + 1);
|
||||
|
||||
APPLY_HOOK ();
|
||||
|
||||
if (SCM_UNLIKELY (!SCM_PROGRAM_P (LOCAL_REF (0))))
|
||||
goto apply;
|
||||
|
||||
ip = SCM_PROGRAM_CODE (LOCAL_REF (0));
|
||||
|
||||
APPLY_HOOK ();
|
||||
|
||||
NEXT (0);
|
||||
}
|
||||
|
||||
|
@ -960,12 +972,13 @@ VM_NAME (scm_i_thread *thread, struct scm_vm *vp,
|
|||
for (i = 0; i < list_len; i++, list = SCM_CDR (list))
|
||||
LOCAL_SET (list_idx - 1 + i, SCM_CAR (list));
|
||||
|
||||
APPLY_HOOK ();
|
||||
|
||||
if (SCM_UNLIKELY (!SCM_PROGRAM_P (LOCAL_REF (0))))
|
||||
goto apply;
|
||||
|
||||
ip = SCM_PROGRAM_CODE (LOCAL_REF (0));
|
||||
|
||||
APPLY_HOOK ();
|
||||
|
||||
NEXT (0);
|
||||
}
|
||||
|
||||
|
@ -1004,12 +1017,13 @@ VM_NAME (scm_i_thread *thread, struct scm_vm *vp,
|
|||
LOCAL_SET (1, cont);
|
||||
RESET_FRAME (2);
|
||||
|
||||
APPLY_HOOK ();
|
||||
|
||||
if (SCM_UNLIKELY (!SCM_PROGRAM_P (LOCAL_REF (0))))
|
||||
goto apply;
|
||||
|
||||
ip = SCM_PROGRAM_CODE (LOCAL_REF (0));
|
||||
|
||||
APPLY_HOOK ();
|
||||
|
||||
NEXT (0);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -186,10 +186,6 @@
|
|||
(if (our-frame? frame)
|
||||
(enter-proc frame)))
|
||||
|
||||
(define (push-cont-hook frame)
|
||||
(if in-proc?
|
||||
(exit-proc frame)))
|
||||
|
||||
(define (pop-cont-hook frame . values)
|
||||
(if in-proc?
|
||||
(exit-proc frame))
|
||||
|
@ -206,7 +202,6 @@
|
|||
current-frame
|
||||
(lambda (frame)
|
||||
(add-hook! (vm-apply-hook) apply-hook)
|
||||
(add-hook! (vm-push-continuation-hook) push-cont-hook)
|
||||
(add-hook! (vm-pop-continuation-hook) pop-cont-hook)
|
||||
(add-hook! (vm-abort-continuation-hook) abort-hook)
|
||||
(if (and frame (our-frame? frame))
|
||||
|
@ -215,7 +210,6 @@
|
|||
(if in-proc?
|
||||
(exit-proc frame))
|
||||
(remove-hook! (vm-apply-hook) apply-hook)
|
||||
(remove-hook! (vm-push-continuation-hook) push-cont-hook)
|
||||
(remove-hook! (vm-pop-continuation-hook) pop-cont-hook)
|
||||
(remove-hook! (vm-abort-continuation-hook) abort-hook)))))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue