diff options
author | Andy Wingo <wingo@pobox.com> | 2021-04-26 09:36:56 +0200 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2021-04-26 09:48:52 +0200 |
commit | 83023160b18ec92ba4a80bd2a27b4d45e3878699 (patch) | |
tree | 77c8c188d008c4a0db5bfa300fc0b9bd992b6650 /libguile/vm-engine.c | |
parent | 976433d667e2502c25f8f6ac8eef04b7d472df6d (diff) | |
download | guile-83023160b18ec92ba4a80bd2a27b4d45e3878699.tar.gz |
Simplify module variable lookup slow-path
* libguile/intrinsics.h:
* libguile/intrinsics.c (lookup_bound_public, lookup_bound_private): Two
new intrinsics.
(scm_bootstrap_intrinsics): Wire them up.
* libguile/jit.c (compile_call_scm_from_scmn_scmn):
(compile_call_scm_from_scmn_scmn_slow):
(COMPILE_X8_S24__N32__N32__C32): Add JIT support for new instruction
kind.
* libguile/vm-engine.c (call-scm<-scmn-scmn): New instruction, takes
arguments as non-immediate offsets, to avoid needless loads and register
pressure.
* module/language/cps/effects-analysis.scm: Add cases for new
primcalls.
* module/language/cps/compile-bytecode.scm (compile-function): Add new
primcalls.
* module/language/cps/reify-primitives.scm (cached-module-box): If the
variable is bound, call lookup-bound-public / lookup-bound-private as
appropriate instead of separately resolving the module, name, and doing
the bound check.
* module/language/tree-il/compile-bytecode.scm (emit-cached-module-box):
Use new instructions.
* module/system/vm/assembler.scm (define-scm<-scmn-scmn-intrinsic):
(lookup-bound-public, lookup-bound-private): Add assembler support.
Diffstat (limited to 'libguile/vm-engine.c')
-rw-r--r-- | libguile/vm-engine.c | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/libguile/vm-engine.c b/libguile/vm-engine.c index bf646847c..510563ce4 100644 --- a/libguile/vm-engine.c +++ b/libguile/vm-engine.c @@ -1,4 +1,4 @@ -/* Copyright 2001,2009-2015,2017-2020 +/* Copyright 2001,2009-2015,2017-2021 Free Software Foundation, Inc. This file is part of Guile. @@ -3437,7 +3437,47 @@ VM_NAME (scm_thread *thread) NEXT (1); } - VM_DEFINE_OP (166, unused_166, NULL, NOP) + /* call-scm<-scmn-scmn dst:24 a:32 b:32 idx:32 + * + * Call the SCM-returning instrinsic with index IDX, passing the SCM + * values A and B as arguments. A and B are non-immediates, located + * at a constant offset from the instruction. Place the SCM result in + * DST. + */ + VM_DEFINE_OP (166, call_scm_from_scmn_scmn, "call-scm<-scmn-scmn", DOP4 (X8_S24, N32, N32, C32)) + { + uint32_t dst; + SCM a, b; + scm_t_scm_from_scmn_scmn_intrinsic intrinsic; + + UNPACK_24 (op, dst); + + { + int32_t offset = ip[1]; + uint32_t* loc = ip + offset; + scm_t_bits unpacked = (scm_t_bits) loc; + VM_ASSERT (!(unpacked & 0x7), abort()); + a = SCM_PACK (unpacked); + } + + { + int32_t offset = ip[2]; + uint32_t* loc = ip + offset; + scm_t_bits unpacked = (scm_t_bits) loc; + VM_ASSERT (!(unpacked & 0x7), abort()); + b = SCM_PACK (unpacked); + } + + intrinsic = intrinsics[ip[3]]; + + SYNC_IP (); + SCM res = intrinsic (a, b); + CACHE_SP (); + SP_SET (dst, res); + + NEXT (4); + } + VM_DEFINE_OP (167, unused_167, NULL, NOP) VM_DEFINE_OP (168, unused_168, NULL, NOP) VM_DEFINE_OP (169, unused_169, NULL, NOP) |