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).
This commit is contained in:
Yukihiro "Matz" Matsumoto
2020-11-26 10:34:31 +09:00
parent 6dedd6a940
commit 7150c67539
6 changed files with 83 additions and 43 deletions
+2 -1
View File
@@ -73,7 +73,8 @@ typedef struct mrb_irep {
/* debug info */
struct mrb_irep_debug_info* debug_info;
uint16_t ilen, plen, slen;
uint32_t ilen;
uint16_t plen, slen;
uint8_t rlen;
uint32_t refcnt;
} mrb_irep;
+4 -4
View File
@@ -49,10 +49,10 @@ OPCODE(GETMCNST, BB) /* R(a) = R(a)::Syms(b) */
OPCODE(SETMCNST, BB) /* R(a+1)::Syms(b) = R(a) */
OPCODE(GETUPVAR, BBB) /* R(a) = uvget(b,c) */
OPCODE(SETUPVAR, BBB) /* uvset(b,c,R(a)) */
OPCODE(JMP, S) /* pc=a */
OPCODE(JMPIF, BS) /* if R(a) pc=b */
OPCODE(JMPNOT, BS) /* if !R(a) pc=b */
OPCODE(JMPNIL, BS) /* if R(a)==nil pc=b */
OPCODE(JMP, S) /* pc+=a */
OPCODE(JMPIF, BS) /* if R(a) pc+=b */
OPCODE(JMPNOT, BS) /* if !R(a) pc+=b */
OPCODE(JMPNIL, BS) /* if R(a)==nil pc+=b */
OPCODE(JMPUW, S) /* unwind_and_jump_to(a) */
OPCODE(EXCEPT, B) /* R(a) = exc */
OPCODE(RESCUE, BB) /* R(b) = R(a).isa?(R(b)) */