From 7150c6753933f12a2ba63769fb7b3a44cfcddd3d Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Thu, 26 Nov 2020 10:34:31 +0900 Subject: 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). --- include/mruby/irep.h | 3 ++- include/mruby/ops.h | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/mruby/irep.h b/include/mruby/irep.h index 173f69037..04ab54ee2 100644 --- a/include/mruby/irep.h +++ b/include/mruby/irep.h @@ -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; diff --git a/include/mruby/ops.h b/include/mruby/ops.h index 02f227634..b006ae94f 100644 --- a/include/mruby/ops.h +++ b/include/mruby/ops.h @@ -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)) */ -- cgit v1.2.3