1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-02 04:40:29 +02:00

Revert "Refactor hook dispatch in VM"

This reverts commit 593e2db1dd.  The goto
strategy works for hooks that run just before a "next"; it doesn't work
for ones that run at the beginning of opcodes.
This commit is contained in:
Andy Wingo 2018-06-27 20:19:40 +02:00
parent 593e2db1dd
commit b5dcdf2e25

View file

@ -110,19 +110,6 @@
#endif #endif
#if VM_USE_HOOKS #if VM_USE_HOOKS
#define GOTO_HOOK(h) \
do { \
if (SCM_UNLIKELY (VP->trace_level)) \
goto run_##h##_hook; \
} while (0)
#define HOOK_HANDLER(h) \
do { \
run_##h##_hook: \
SYNC_IP (); \
vm_dispatch_##h##_hook (thread); \
CACHE_SP (); \
CONTINUE; \
} while (0)
#define RUN_HOOK(exp) \ #define RUN_HOOK(exp) \
do { \ do { \
if (SCM_UNLIKELY (VP->trace_level)) \ if (SCM_UNLIKELY (VP->trace_level)) \
@ -134,18 +121,16 @@
} while (0) } while (0)
#else #else
#define RUN_HOOK(exp) #define RUN_HOOK(exp)
#define GOTO_HOOK(h)
#define HOOK_HANDLER(h)
#endif #endif
#define RUN_HOOK0(h) RUN_HOOK (vm_dispatch_##h##_hook (thread))
#define RUN_HOOK1(h, arg) RUN_HOOK (vm_dispatch_##h##_hook (thread, arg))
#define APPLY_HOOK() GOTO_HOOK (apply) #define APPLY_HOOK() RUN_HOOK0 (apply)
#define PUSH_CONTINUATION_HOOK() GOTO_HOOK (push_continuation) #define PUSH_CONTINUATION_HOOK() RUN_HOOK0 (push_continuation)
#define NEXT_HOOK() GOTO_HOOK (next) #define POP_CONTINUATION_HOOK(old_fp) RUN_HOOK1 (pop_continuation, old_fp)
#define ABORT_CONTINUATION_HOOK() GOTO_HOOK (abort) #define NEXT_HOOK() RUN_HOOK0 (next)
#define ABORT_CONTINUATION_HOOK() RUN_HOOK0 (abort)
/* The only hook that needs an arg, currently. */
#define POP_CONTINUATION_HOOK(old_fp) \
RUN_HOOK (vm_dispatch_pop_continuation_hook (thread, old_fp))
@ -228,13 +213,13 @@
#ifdef HAVE_LABELS_AS_VALUES #ifdef HAVE_LABELS_AS_VALUES
# define BEGIN_DISPATCH_SWITCH /* */ # define BEGIN_DISPATCH_SWITCH /* */
# define END_DISPATCH_SWITCH /* */ # define END_DISPATCH_SWITCH /* */
# define CONTINUE do { op = *ip; goto *jump_table[op & 0xff]; } while (0)
# define NEXT(n) \ # define NEXT(n) \
do \ do \
{ \ { \
ip += n; \ ip += n; \
NEXT_HOOK (); \ NEXT_HOOK (); \
CONTINUE; \ op = *ip; \
goto *jump_table[op & 0xff]; \
} \ } \
while (0) while (0)
# define VM_DEFINE_OP(opcode, tag, name, meta) \ # define VM_DEFINE_OP(opcode, tag, name, meta) \
@ -248,12 +233,11 @@
{ {
# define END_DISPATCH_SWITCH \ # define END_DISPATCH_SWITCH \
} }
# define CONTINUE do { goto vm_start; } while (0)
# define NEXT(n) \ # define NEXT(n) \
do \ do \
{ \ { \
ip += n; \ ip += n; \
CONTINUE; \ goto vm_start; \
} \ } \
while (0) while (0)
# define VM_DEFINE_OP(opcode, tag, name, meta) \ # define VM_DEFINE_OP(opcode, tag, name, meta) \
@ -379,11 +363,11 @@ VM_NAME (scm_thread *thread)
uint32_t proc, nlocals; uint32_t proc, nlocals;
union scm_vm_stack_element *old_fp; union scm_vm_stack_element *old_fp;
PUSH_CONTINUATION_HOOK ();
UNPACK_24 (op, proc); UNPACK_24 (op, proc);
UNPACK_24 (ip[1], nlocals); UNPACK_24 (ip[1], nlocals);
PUSH_CONTINUATION_HOOK ();
old_fp = VP->fp; old_fp = VP->fp;
VP->fp = SCM_FRAME_SLOT (old_fp, proc - 1); VP->fp = SCM_FRAME_SLOT (old_fp, proc - 1);
SCM_FRAME_SET_DYNAMIC_LINK (VP->fp, old_fp); SCM_FRAME_SET_DYNAMIC_LINK (VP->fp, old_fp);
@ -421,12 +405,12 @@ VM_NAME (scm_thread *thread)
int32_t label; int32_t label;
union scm_vm_stack_element *old_fp; union scm_vm_stack_element *old_fp;
PUSH_CONTINUATION_HOOK ();
UNPACK_24 (op, proc); UNPACK_24 (op, proc);
UNPACK_24 (ip[1], nlocals); UNPACK_24 (ip[1], nlocals);
label = ip[2]; label = ip[2];
PUSH_CONTINUATION_HOOK ();
old_fp = VP->fp; old_fp = VP->fp;
VP->fp = SCM_FRAME_SLOT (old_fp, proc - 1); VP->fp = SCM_FRAME_SLOT (old_fp, proc - 1);
SCM_FRAME_SET_DYNAMIC_LINK (VP->fp, old_fp); SCM_FRAME_SET_DYNAMIC_LINK (VP->fp, old_fp);
@ -3010,14 +2994,6 @@ VM_NAME (scm_thread *thread)
} }
END_DISPATCH_SWITCH; END_DISPATCH_SWITCH;
HOOK_HANDLER (apply);
HOOK_HANDLER (push_continuation);
HOOK_HANDLER (next);
HOOK_HANDLER (abort);
/* Unreachable. */
abort ();
} }
@ -3037,8 +3013,8 @@ VM_NAME (scm_thread *thread)
#undef POP_CONTINUATION_HOOK #undef POP_CONTINUATION_HOOK
#undef PUSH_CONTINUATION_HOOK #undef PUSH_CONTINUATION_HOOK
#undef RUN_HOOK #undef RUN_HOOK
#undef HOOK_HANDLER #undef RUN_HOOK0
#undef GOTO_HOOK #undef RUN_HOOK1
#undef SYNC_IP #undef SYNC_IP
#undef UNPACK_8_8_8 #undef UNPACK_8_8_8
#undef UNPACK_8_16 #undef UNPACK_8_16