Skip to content

Commit

Permalink
Merge pull request #5902 from dearblue/threadedcode
Browse files Browse the repository at this point in the history
Replace `MRB_NO_DIRECT_THREADING` with `MRB_USE_VM_SWITCH_DISPATCH`
  • Loading branch information
matz committed Mar 18, 2023
2 parents db11e07 + f6c9191 commit 1c765dc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions doc/guides/mrbconf.md
Expand Up @@ -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
4 changes: 2 additions & 2 deletions include/mrbconf.h
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions src/vm.c
Expand Up @@ -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:
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 1c765dc

Please sign in to comment.