diff --git a/doc/guides/mrbconf.md b/doc/guides/mrbconf.md index 771922a4b..291b7c767 100644 --- a/doc/guides/mrbconf.md +++ b/doc/guides/mrbconf.md @@ -247,6 +247,6 @@ largest value of required alignment. - Make it available `Symbol.all_symbols` in `mrbgems/mruby-symbol-ext` - Increase heap memory usage. -`MRB_NO_DIRECT_THREADING` +`MRB_USE_VM_SWITCH_DISPATCH` -- Turn off direct threading optimization in VM loop +- Turn on switch dispatch in VM loop diff --git a/include/mrbconf.h b/include/mrbconf.h index 1629a5c45..122eb2b0e 100644 --- a/include/mrbconf.h +++ b/include/mrbconf.h @@ -176,8 +176,8 @@ #if defined(DISABLE_STDIO) || defined(MRB_DISABLE_STDIO) # define MRB_NO_STDIO #endif -#ifdef MRB_DISABLE_DIRECT_THREADING -# define MRB_NO_DIRECT_THREADING +#if defined(MRB_DISABLE_DIRECT_THREADING) || defined(MRB_NO_DIRECT_THREADING) +# define MRB_USE_VM_SWITCH_DISPATCH #endif #if defined(ENABLE_DEBUG) || defined(MRB_ENABLE_DEBUG_HOOK) # define MRB_USE_DEBUG_HOOK diff --git a/src/vm.c b/src/vm.c index 6b7308799..ac7d3b908 100644 --- a/src/vm.c +++ b/src/vm.c @@ -1251,13 +1251,13 @@ prepare_tagged_break(mrb_state *mrb, uint32_t tag, const struct RProc *proc, mrb #define BYTECODE_DECODER(x) (x) #endif -#ifndef MRB_NO_DIRECT_THREADING -#if defined __GNUC__ || defined __clang__ || defined __INTEL_COMPILER -#define DIRECT_THREADED +#ifndef MRB_USE_VM_SWITCH_DISPATCH +#if !defined __GNUC__ && !defined __clang__ && !defined __INTEL_COMPILER +#define MRB_USE_VM_SWITCH_DISPATCH #endif -#endif /* ifndef MRB_NO_DIRECT_THREADING */ +#endif /* ifndef MRB_USE_VM_SWITCH_DISPATCH */ -#ifndef DIRECT_THREADED +#ifdef MRB_USE_VM_SWITCH_DISPATCH #define INIT_DISPATCH for (;;) { insn = BYTECODE_DECODER(*pc); CODE_FETCH_HOOK(mrb, irep, pc, regs); switch (insn) { #define CASE(insn,ops) case insn: pc++; FETCH_ ## ops (); mrb->c->ci->pc = pc; L_ ## insn ## _BODY: @@ -1364,7 +1364,7 @@ mrb_vm_exec(mrb_state *mrb, const struct RProc *proc, const mrb_code *pc) mrb_sym mid; const struct mrb_irep_catch_handler *ch; -#ifdef DIRECT_THREADED +#ifndef MRB_USE_VM_SWITCH_DISPATCH static const void * const optable[] = { #define OPCODE(x,_) &&L_OP_ ## x, #include "mruby/ops.h"