1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-14 15:40:19 +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:
Andy Wingo 2014-05-04 14:09:42 +02:00
parent 7c080187bc
commit f5cb70e94a
2 changed files with 28 additions and 20 deletions

View file

@ -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