diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2021-02-01 16:07:48 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2021-02-01 16:20:58 +0900 |
| commit | d759a73525f2bff367433454e4d2851f7c193693 (patch) | |
| tree | 8b6007bb9a1d90e0a46a0b21cb124147f9eddfec /include | |
| parent | bd6b48fa3b352bbcb97463dcb95e30db37bff2e4 (diff) | |
| download | mruby-d759a73525f2bff367433454e4d2851f7c193693.tar.gz mruby-d759a73525f2bff367433454e4d2851f7c193693.zip | |
Allow more than 256 child `irep`; fix #5310
We have introduced following new instructions.
* `OP_LAMBDA16`
* `OP_BLOCK16`
* `OP_METHOD16`
* `OP_EXEC16`
Each instruction uses 16 bits operand for `reps` index. Since new
instructions are added, `mruby/c` VM should be updated.
Due to new instructions, dump format compatibility is lost, we have
increased `RITE_BINARY_MAJOR_VER`.
In addition, we have decreased the size of `refcnt` in `mrb_irep` from
`uint32_t` to `uint16_t`, which is reasonably big enough.
Diffstat (limited to 'include')
| -rw-r--r-- | include/mruby/dump.h | 2 | ||||
| -rw-r--r-- | include/mruby/irep.h | 4 | ||||
| -rw-r--r-- | include/mruby/ops.h | 4 |
3 files changed, 7 insertions, 3 deletions
diff --git a/include/mruby/dump.h b/include/mruby/dump.h index 0eefa00ce..ed0c64b1a 100644 --- a/include/mruby/dump.h +++ b/include/mruby/dump.h @@ -51,7 +51,7 @@ MRB_API mrb_irep *mrb_read_irep_buf(mrb_state*, const void*, size_t); /* Binary Format Version Major:Minor */ /* Major: Incompatible to prior versions */ /* Minor: Upper-compatible to prior versions */ -#define RITE_BINARY_MAJOR_VER "01" +#define RITE_BINARY_MAJOR_VER "02" #define RITE_BINARY_MINOR_VER "00" #define RITE_BINARY_FORMAT_VER RITE_BINARY_MAJOR_VER RITE_BINARY_MINOR_VER #define RITE_COMPILER_NAME "MATZ" diff --git a/include/mruby/irep.h b/include/mruby/irep.h index 12d81d0d3..8d1648e13 100644 --- a/include/mruby/irep.h +++ b/include/mruby/irep.h @@ -75,8 +75,8 @@ typedef struct mrb_irep { uint32_t ilen; uint16_t plen, slen; - uint8_t rlen; - uint32_t refcnt; + uint16_t rlen; + uint16_t refcnt; } mrb_irep; #define MRB_ISEQ_NO_FREE 1 diff --git a/include/mruby/ops.h b/include/mruby/ops.h index b006ae94f..d5d8fb077 100644 --- a/include/mruby/ops.h +++ b/include/mruby/ops.h @@ -100,14 +100,18 @@ OPCODE(HASH, BB) /* R(a) = hash_new(R(a),R(a+1)..R(a+b*2-1)) */ OPCODE(HASHADD, BB) /* R(a) = hash_push(R(a),R(a+1)..R(a+b*2)) */ OPCODE(HASHCAT, B) /* R(a) = hash_cat(R(a),R(a+1)) */ OPCODE(LAMBDA, BB) /* R(a) = lambda(SEQ[b],L_LAMBDA) */ +OPCODE(LAMBDA16, BS) /* R(a) = lambda(SEQ[b],L_LAMBDA) */ OPCODE(BLOCK, BB) /* R(a) = lambda(SEQ[b],L_BLOCK) */ +OPCODE(BLOCK16, BS) /* R(a) = lambda(SEQ[b],L_BLOCK) */ OPCODE(METHOD, BB) /* R(a) = lambda(SEQ[b],L_METHOD) */ +OPCODE(METHOD16, BS) /* R(a) = lambda(SEQ[b],L_METHOD) */ OPCODE(RANGE_INC, B) /* R(a) = range_new(R(a),R(a+1),FALSE) */ OPCODE(RANGE_EXC, B) /* R(a) = range_new(R(a),R(a+1),TRUE) */ OPCODE(OCLASS, B) /* R(a) = ::Object */ OPCODE(CLASS, BB) /* R(a) = newclass(R(a),Syms(b),R(a+1)) */ OPCODE(MODULE, BB) /* R(a) = newmodule(R(a),Syms(b)) */ OPCODE(EXEC, BB) /* R(a) = blockexec(R(a),SEQ[b]) */ +OPCODE(EXEC16, BS) /* R(a) = blockexec(R(a),SEQ[b]) */ OPCODE(DEF, BB) /* R(a).newmethod(Syms(b),R(a+1)) */ OPCODE(ALIAS, BB) /* alias_method(target_class,Syms(a),Syms(b)) */ OPCODE(UNDEF, B) /* undef_method(target_class,Syms(a)) */ |
