diff options
author | Andy Wingo <wingo@pobox.com> | 2018-07-29 15:36:07 +0200 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2018-07-29 15:47:07 +0200 |
commit | b8a9a666f140282fc3928f1027f235f01bad1ade (patch) | |
tree | 508dd64aae9dd247cf2b7fcd5b14adb380b01cce /libguile/gsubr.h | |
parent | 5077e6737128b04e840b96775627b000e29c63f1 (diff) | |
download | guile-b8a9a666f140282fc3928f1027f235f01bad1ade.tar.gz |
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.
Diffstat (limited to 'libguile/gsubr.h')
-rw-r--r-- | libguile/gsubr.h | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/libguile/gsubr.h b/libguile/gsubr.h index 8407ae5b3..b62e21140 100644 --- a/libguile/gsubr.h +++ b/libguile/gsubr.h @@ -38,14 +38,11 @@ #define SCM_PRIMITIVE_GENERIC_P(x) (SCM_PROGRAM_P (x) && SCM_PROGRAM_IS_PRIMITIVE_GENERIC (x)) -#define SCM_SUBRF(x) \ - ((SCM (*) (void)) \ - SCM_POINTER_VALUE (SCM_PROGRAM_FREE_VARIABLE_REF (x, 0))) - -#define SCM_SUBR_NAME(x) (SCM_PROGRAM_FREE_VARIABLE_REF (x, 1)) +#define SCM_SUBRF(x) scm_subr_function (x) +#define SCM_SUBR_NAME(x) scm_subr_name (x) #define SCM_SUBR_GENERIC(x) \ - ((SCM *) SCM_POINTER_VALUE (SCM_PROGRAM_FREE_VARIABLE_REF (x, 2))) + ((SCM *) SCM_POINTER_VALUE (SCM_PROGRAM_FREE_VARIABLE_REF (x, 0))) #define SCM_SET_SUBR_GENERIC(x, g) \ (*SCM_SUBR_GENERIC (x) = (g)) @@ -54,9 +51,13 @@ SCM_INTERNAL int scm_i_primitive_code_p (const uint32_t *code); SCM_INTERNAL uintptr_t scm_i_primitive_call_ip (SCM subr); +SCM_INTERNAL SCM scm_i_primitive_name (const uint32_t *code); + +SCM_API scm_t_subr scm_subr_function (SCM subr); +SCM_API SCM scm_subr_name (SCM subr); SCM_INTERNAL SCM scm_apply_subr (union scm_vm_stack_element *sp, - ptrdiff_t nargs); + uint32_t subr_idx, ptrdiff_t nargs); SCM_API SCM scm_c_make_gsubr (const char *name, int req, int opt, int rst, scm_t_subr fcn); |