1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-14 15:40:19 +02:00

Rewrite subr implementation

* libguile/gsubr.c: Reimplement to store subr names and procedures in a
  side table, and to allocate fresh vcode for each subr.  This allows
  JIT of subrs, moves to a uniform all-code-starts-with-instrument-entry
  regime, and also allows statprof to distinguish between subrs based on
  IP.
* libguile/gsubr.h (SCM_SUBRF, SCM_SUBR_NAME): Call out to functions,
  now that these are in a side table.
  (scm_subr_function, scm_subr_name): New exports.
  (scm_i_primitive_name): New internal function, for looking up a
  primitive name based on IP.
  (scm_apply_subr): Take the subr index.
* libguile/vm-engine.c (subr-call):
* libguile/jit.c (compile_subr_call): Adapt to take index as arg.
* module/statprof.scm (sample-stack-procs, count-call):
  (stack-samples->procedure-data): Update to always record IP in stack
  samples and call counts.
* module/system/vm/frame.scm (frame-procedure-name): Simplify.
  (frame-instruction-pointer-or-primitive-procedure-name): Removed.
* libguile/programs.h:
* libguile/programs.c (scm_primitive_code_name): New function.
* module/system/vm/program.scm (primitive-code-name): New export.
This commit is contained in:
Andy Wingo 2018-07-29 15:36:07 +02:00
parent 5077e67371
commit b8a9a666f1
9 changed files with 363 additions and 272 deletions

View file

@ -595,19 +595,23 @@ VM_NAME (scm_thread *thread)
* Specialized call stubs
*/
/* subr-call _:24
/* subr-call idx:24
*
* Call a subr, passing all locals in this frame as arguments. Return
* from the calling frame. This instruction is part of the
* trampolines created in gsubr.c, and is not generated by the
* compiler.
*/
VM_DEFINE_OP (10, subr_call, "subr-call", OP1 (X32))
VM_DEFINE_OP (10, subr_call, "subr-call", OP1 (X8_C24))
{
SCM ret;
uint32_t idx;
UNPACK_24 (op, idx);
SYNC_IP ();
ret = scm_apply_subr (sp, FRAME_LOCALS_COUNT ());
ret = scm_apply_subr (sp, idx, FRAME_LOCALS_COUNT ());
CACHE_SP ();
if (SCM_UNLIKELY (scm_is_values (ret)))