summaryrefslogtreecommitdiff
path: root/libguile/vm-engine.c
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2018-08-08 15:22:28 +0200
committerAndy Wingo <wingo@pobox.com>2018-08-08 15:22:28 +0200
commit926b72f5acb058cadd95bd60c4a89efb2977fe6b (patch)
tree0b382144a5caaa894e80c399db1aa32885cf83d9 /libguile/vm-engine.c
parentb7dbc7251f4cf58dbaeb8cff9229f325680690fd (diff)
downloadguile-926b72f5acb058cadd95bd60c4a89efb2977fe6b.tar.gz
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.
Diffstat (limited to 'libguile/vm-engine.c')
-rw-r--r--libguile/vm-engine.c33
1 files changed, 8 insertions, 25 deletions
diff --git a/libguile/vm-engine.c b/libguile/vm-engine.c
index 65342b6b3..eaaa2858a 100644
--- a/libguile/vm-engine.c
+++ b/libguile/vm-engine.c
@@ -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);
}