1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-14 07:30:32 +02:00

Rework program->ip mapping in VM to always call intrinsic

* libguile/intrinsics.h:
* libguile/vm.c (get_callee_vcode): Rename from apply_non_program, and
  instead return the IP for the callee of a frame.
  (scm_call_n, scm_bootstrap_vm): Adapt to get_callee_vcode change.
* libguile/vm-engine.c (call, tail-call, call/cc): Use
  get_callee_vcode unconditionally.  JIT will do this to avoid so much
  code generation for calls.
This commit is contained in:
Andy Wingo 2018-08-08 15:22:28 +02:00
parent b7dbc7251f
commit 926b72f5ac
3 changed files with 19 additions and 42 deletions

View file

@ -379,16 +379,10 @@ VM_NAME (scm_thread *thread)
SCM_FRAME_SET_MACHINE_RETURN_ADDRESS (new_fp, 0);
VP->fp = new_fp;
SYNC_IP ();
RESET_FRAME (nlocals);
if (SCM_LIKELY (SCM_PROGRAM_P (FP_REF (0))))
ip = SCM_PROGRAM_CODE (FP_REF (0));
else
{
SYNC_IP ();
CALL_INTRINSIC (apply_non_program, (thread));
CACHE_REGISTER ();
}
ip = CALL_INTRINSIC (get_callee_vcode, (thread));
CACHE_SP ();
NEXT (0);
}
@ -435,15 +429,9 @@ VM_NAME (scm_thread *thread)
*/
VM_DEFINE_OP (3, tail_call, "tail-call", OP1 (X32))
{
if (SCM_LIKELY (SCM_PROGRAM_P (FP_REF (0))))
ip = SCM_PROGRAM_CODE (FP_REF (0));
else
{
SYNC_IP ();
CALL_INTRINSIC (apply_non_program, (thread));
CACHE_REGISTER ();
}
SYNC_IP ();
ip = CALL_INTRINSIC (get_callee_vcode, (thread));
CACHE_SP ();
NEXT (0);
}
@ -756,13 +744,8 @@ VM_NAME (scm_thread *thread)
SP_SET (1, SP_REF (0));
SP_SET (0, cont);
if (SCM_LIKELY (SCM_PROGRAM_P (SP_REF (1))))
ip = SCM_PROGRAM_CODE (SP_REF (1));
else
{
CALL_INTRINSIC (apply_non_program, (thread));
CACHE_REGISTER ();
}
ip = CALL_INTRINSIC (get_callee_vcode, (thread));
CACHE_SP ();
NEXT (0);
}