diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2018-08-25 09:49:20 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2018-08-25 09:49:20 +0900 |
| commit | d79dbd92f9104712c6cf41ab3c029dec318a757d (patch) | |
| tree | 9312f33cbc3facb0ce381d62fc97803501f3997f /mrbgems/mruby-compiler/core | |
| parent | 49d1b168221221b7e810f001d88e16ebc94378fd (diff) | |
| download | mruby-d79dbd92f9104712c6cf41ab3c029dec318a757d.tar.gz mruby-d79dbd92f9104712c6cf41ab3c029dec318a757d.zip | |
fixup! New bytecode implementation of mruby VM.
Diffstat (limited to 'mrbgems/mruby-compiler/core')
| -rw-r--r-- | mrbgems/mruby-compiler/core/codegen.c | 100 |
1 files changed, 0 insertions, 100 deletions
diff --git a/mrbgems/mruby-compiler/core/codegen.c b/mrbgems/mruby-compiler/core/codegen.c index bf5cc14b0..075945b3b 100644 --- a/mrbgems/mruby-compiler/core/codegen.c +++ b/mrbgems/mruby-compiler/core/codegen.c @@ -445,108 +445,8 @@ gen_move(codegen_scope *s, uint16_t dst, uint16_t src, int nopeep) break; default: goto normal; -======= -struct mrb_insn_data { - uint8_t insn; - uint16_t a; - uint16_t b; - uint8_t c; -}; - -struct mrb_insn_data -mrb_decode_insn(codegen_scope *s, mrb_code *pc) -{ - struct mrb_insn_data data = { 0 }; - mrb_code insn = READ_B(); - uint16_t a = 0; - uint16_t b = 0; - uint8_t c = 0; - - switch (insn) { -#define FETCH_Z() /* empty */ -#define OPCODE(i,x) case OP_ ## i: FETCH_ ## x (); break; -#include "mruby/ops.h" -#undef OPCODE - } - switch (insn) { - case OP_EXT1: - insn = READ_B(); - switch (insn) { -#define OPCODE(i,x) case OP_ ## i: FETCH_ ## x ## _1 (); break; -#include "mruby/ops.h" -#undef OPCODE - } - break; - case OP_EXT2: - insn = READ_B(); - switch (insn) { -#define OPCODE(i,x) case OP_ ## i: FETCH_ ## x ## _2 (); break; -#include "mruby/ops.h" -#undef OPCODE - } - break; - case OP_EXT3: - insn = READ_B(); - switch (insn) { -#define OPCODE(i,x) case OP_ ## i: FETCH_ ## x ## _3 (); break; -#include "mruby/ops.h" -#undef OPCODE - } - break; - default: - break; - } - data.insn = insn; - data.a = a; - data.b = b; - data.c = c; - return data; -} - -struct mrb_insn_data -mrb_last_insn(codegen_scope *s) -{ - if (s->pc == s->lastpc) { - struct mrb_insn_data data; - - data.insn = OP_NOP; - return data; - } - return mrb_decode_insn(s, &s->iseq[s->lastpc]); -} - -static mrb_bool -no_peephole(codegen_scope *s) -{ - return no_optimize(s) || s->lastlabel == s->pc || s->pc == 0 || s->pc == s->lastpc; -} - -static uint16_t -genjmp(codegen_scope *s, mrb_code i, uint16_t pc) -{ - uint16_t pos; - - s->lastpc = s->pc; - gen_B(s, i); - pos = s->pc; - gen_S(s, pc); - return pos; -} - -static uint16_t -genjmp2(codegen_scope *s, mrb_code i, uint16_t a, int pc, int val) -{ - uint16_t pos; - - if (!no_peephole(s) && !val) { - struct mrb_insn_data data = mrb_last_insn(s); - - if (data.insn == OP_MOVE && data.a == a) { - s->pc = s->lastpc; - a = data.b; } } - return genop(s, i); } static void |
