diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2018-07-31 17:28:42 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2018-07-31 17:28:42 +0900 |
| commit | beb6e5c299bb411a7f2a9e355e6eeca3aa785c74 (patch) | |
| tree | 706d4a1cffc4f85367f08079a6e3da1332ab8ffd | |
| parent | 889f0f5f36212606056af4fbb7865f900c2b8af1 (diff) | |
| download | mruby-beb6e5c299bb411a7f2a9e355e6eeca3aa785c74.tar.gz mruby-beb6e5c299bb411a7f2a9e355e6eeca3aa785c74.zip | |
Bytecode support for `mrdb`.
| -rw-r--r-- | include/mruby/irep.h | 9 | ||||
| -rw-r--r-- | mrbgems/mruby-bin-debugger/tools/mrdb/mrdb.c | 8 | ||||
| -rw-r--r-- | mrbgems/mruby-compiler/core/codegen.c | 13 |
3 files changed, 17 insertions, 13 deletions
diff --git a/include/mruby/irep.h b/include/mruby/irep.h index c98d008db..7dcf33735 100644 --- a/include/mruby/irep.h +++ b/include/mruby/irep.h @@ -58,6 +58,15 @@ void mrb_irep_decref(mrb_state*, struct mrb_irep*); void mrb_irep_cutref(mrb_state*, struct mrb_irep*); void mrb_irep_remove_lv(mrb_state *mrb, mrb_irep *irep); +struct mrb_insn_data { + uint8_t insn; + uint16_t a; + uint16_t b; + uint8_t c; +}; + +struct mrb_insn_data mrb_decode_insn(mrb_code *pc); + MRB_END_DECL #endif /* MRUBY_IREP_H */ diff --git a/mrbgems/mruby-bin-debugger/tools/mrdb/mrdb.c b/mrbgems/mruby-bin-debugger/tools/mrdb/mrdb.c index 1b17128fd..05a6f3622 100644 --- a/mrbgems/mruby-bin-debugger/tools/mrdb/mrdb.c +++ b/mrbgems/mruby-bin-debugger/tools/mrdb/mrdb.c @@ -510,6 +510,7 @@ check_method_breakpoint(mrb_state *mrb, mrb_irep *irep, mrb_code *pc, mrb_value mrb_sym sym; int32_t bpno; mrb_bool isCfunc; + struct mrb_insn_data insn; mrb_debug_context *dbg = mrb_debug_context_get(mrb); @@ -517,11 +518,12 @@ check_method_breakpoint(mrb_state *mrb, mrb_irep *irep, mrb_code *pc, mrb_value bpno = dbg->method_bpno; dbg->method_bpno = 0; - switch(*pc) { + insn = mrb_decode_insn(pc); + switch(insn.insn) { case OP_SEND: case OP_SENDB: - c = mrb_class(mrb, regs[GETARG_A(*pc)]); - sym = irep->syms[GETARG_B(*pc)]; + c = mrb_class(mrb, regs[insn.a]); + sym = irep->syms[insn.b]; break; case OP_SUPER: c = mrb->c->ci->target_class->super; diff --git a/mrbgems/mruby-compiler/core/codegen.c b/mrbgems/mruby-compiler/core/codegen.c index 070aaac51..b8caba3a0 100644 --- a/mrbgems/mruby-compiler/core/codegen.c +++ b/mrbgems/mruby-compiler/core/codegen.c @@ -296,15 +296,8 @@ on_eval(codegen_scope *s) return FALSE; } -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) +mrb_decode_insn(mrb_code *pc) { struct mrb_insn_data data = { 0 }; mrb_code insn = READ_B(); @@ -353,7 +346,7 @@ mrb_decode_insn(codegen_scope *s, mrb_code *pc) return data; } -struct mrb_insn_data +static struct mrb_insn_data mrb_last_insn(codegen_scope *s) { if (s->pc == s->lastpc) { @@ -362,7 +355,7 @@ mrb_last_insn(codegen_scope *s) data.insn = OP_NOP; return data; } - return mrb_decode_insn(s, &s->iseq[s->lastpc]); + return mrb_decode_insn(&s->iseq[s->lastpc]); } static mrb_bool |
