diff options
author | Andy Wingo <wingo@pobox.com> | 2018-09-14 12:57:16 +0200 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2018-09-14 13:02:44 +0200 |
commit | 12b125f2ad6defe77de29cab6f54f367e07550c2 (patch) | |
tree | df8016189ad967aee3cb55d940ab7b752f96e49a /libguile/vm.h | |
parent | 8bb9ae3b51aa5f16b6b364f5212c0f3a82136a2f (diff) | |
download | guile-12b125f2ad6defe77de29cab6f54f367e07550c2.tar.gz |
Hook refactors
* libguile/vm.h (SCM_VM_NUM_HOOKS): Remove hook enumeration.
(struct scm_vm): Re-arrange members to be more dense and to use common
cache lines for commonly-used members. Declare hooks and their enabled
flags by name.
* libguile/vm-engine.c (RUN_HOOK): Refer to hooks by name.
* libguile/vm.c (FOR_EACH_HOOK): New helper.
(vm_hook_compute_enabled, vm_recompute_disable_mcode): New routines to
recompute when hooks are enabled, and whether to disable mcode because
hooks are active.
(set_vm_trace_level): New helper.
(invoke_hook): Take hook to invoke by value.
(DEFINE_INVOKE_HOOK): Refactor to use named hooks.
(scm_i_vm_prepare_stack): Init named hooks.
(VM_ADD_HOOK, VM_REMOVE_HOOK): Refactor to use named hooks, and also
recompute global disable_mcode flag.
(scm_set_vm_trace_level_x, scm_c_set_vm_engine_x): Use internal helper.
Diffstat (limited to 'libguile/vm.h')
-rw-r--r-- | libguile/vm.h | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/libguile/vm.h b/libguile/vm.h index 8f528f63c..5f1c63844 100644 --- a/libguile/vm.h +++ b/libguile/vm.h @@ -25,14 +25,6 @@ #include <libguile/gc.h> #include <libguile/programs.h> -enum { - SCM_VM_APPLY_HOOK, - SCM_VM_RETURN_HOOK, - SCM_VM_NEXT_HOOK, - SCM_VM_ABORT_HOOK, - SCM_VM_NUM_HOOKS, -}; - #define SCM_VM_REGULAR_ENGINE 0 #define SCM_VM_DEBUG_ENGINE 1 #define SCM_VM_NUM_ENGINES 2 @@ -48,19 +40,27 @@ struct scm_vm { uint32_t *ip; /* instruction pointer */ union scm_vm_stack_element *sp; /* stack pointer */ union scm_vm_stack_element *fp; /* frame pointer */ - uint8_t compare_result; /* flags register: a value from scm_compare */ - union scm_vm_stack_element *stack_limit; /* stack limit address */ - int trace_level; /* traces enabled if trace_level > 0 */ union scm_vm_stack_element *sp_min_since_gc; /* deepest sp since last gc */ + union scm_vm_stack_element *stack_limit; /* stack limit address */ + uint8_t compare_result; /* flags register: a value from scm_compare */ + uint8_t apply_hook_enabled; /* if apply hook is enabled */ + uint8_t return_hook_enabled; /* if return hook is enabled */ + uint8_t next_hook_enabled; /* if next hook is enabled */ + uint8_t abort_hook_enabled; /* if abort hook is enabled */ + uint8_t disable_mcode; /* if mcode is disabled (because debugging) */ + uint8_t engine; /* which vm engine we're using */ + uint8_t unused; /* padding */ size_t stack_size; /* stack size */ union scm_vm_stack_element *stack_bottom; /* lowest address in allocated stack */ + SCM apply_hook; /* apply hook */ + SCM return_hook; /* return hook */ + SCM next_hook; /* next hook */ + SCM abort_hook; /* abort hook */ union scm_vm_stack_element *stack_top; /* highest address in allocated stack */ SCM overflow_handler_stack; /* alist of max-stack-size -> thunk */ - SCM hooks[SCM_VM_NUM_HOOKS]; /* hooks */ - uint8_t hooks_enabled[SCM_VM_NUM_HOOKS]; /* if corresponding hook is enabled */ jmp_buf *registers; /* registers captured at latest vm entry */ uint8_t *mra_after_abort; /* mra to resume after nonlocal exit, or NULL */ - int engine; /* which vm engine we're using */ + int trace_level; /* traces enabled if trace_level > 0 */ }; SCM_API SCM scm_call_with_vm (SCM proc, SCM args); |