diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2020-11-26 10:34:31 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2020-11-26 10:34:31 +0900 |
| commit | 7150c6753933f12a2ba63769fb7b3a44cfcddd3d (patch) | |
| tree | cddfd89197039d98cac827837e58bd3041d88a2a /src/codedump.c | |
| parent | 6dedd6a940194881c3b66124ff277c4cb14d08bd (diff) | |
| download | mruby-7150c6753933f12a2ba63769fb7b3a44cfcddd3d.tar.gz mruby-7150c6753933f12a2ba63769fb7b3a44cfcddd3d.zip | |
Make `OP_JMP*` operand address to be relative.
Jump target address is `operand (16bit)` + `address of next instruction`.
In addition, `ilen` was made `uint32_t` so that `iseq` length limitation
of 65536 is removed. Only jump target address should be within signed
16bit (-32768 .. 32767).
Diffstat (limited to 'src/codedump.c')
| -rw-r--r-- | src/codedump.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/codedump.c b/src/codedump.c index 4f793b753..94d4f24c0 100644 --- a/src/codedump.c +++ b/src/codedump.c @@ -271,21 +271,26 @@ codedump(mrb_state *mrb, const mrb_irep *irep) print_lv_a(mrb, irep, a); break; CASE(OP_JMP, S); - printf("OP_JMP\t\t%03d\n", a); + i = pc - irep->iseq; + printf("OP_JMP\t\t%03d\n", (int)i+(int16_t)a); break; CASE(OP_JMPUW, S); - printf("OP_JMPUW\t\t%03d\n", a); + i = pc - irep->iseq; + printf("OP_JMPUW\t\t%03d\n", (int)i+(int16_t)a); break; CASE(OP_JMPIF, BS); - printf("OP_JMPIF\tR%d\t%03d\t", a, b); + i = pc - irep->iseq; + printf("OP_JMPIF\tR%d\t%03d\t", a, (int)i+(int16_t)b); print_lv_a(mrb, irep, a); break; CASE(OP_JMPNOT, BS); - printf("OP_JMPNOT\tR%d\t%03d\t", a, b); + i = pc - irep->iseq; + printf("OP_JMPNOT\tR%d\t%03d\t", a, (int)i+(int16_t)b); print_lv_a(mrb, irep, a); break; CASE(OP_JMPNIL, BS); - printf("OP_JMPNIL\tR%d\t%03d\t", a, b); + i = pc - irep->iseq; + printf("OP_JMPNIL\tR%d\t%03d\t", a, (int)i+(int16_t)b); print_lv_a(mrb, irep, a); break; CASE(OP_SENDV, BB); |
