diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2020-11-03 14:58:44 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2020-11-03 14:58:44 +0900 |
| commit | b7e8406f6cf7f8f83fe9594d06c0861e4068241b (patch) | |
| tree | bfed217bbb86a7d04aabe7e8ca88a99323fd6bfa /src/vm.c | |
| parent | 0be5b266b668a6219b440c80bfcff692e02d2097 (diff) | |
| download | mruby-b7e8406f6cf7f8f83fe9594d06c0861e4068241b.tar.gz mruby-b7e8406f6cf7f8f83fe9594d06c0861e4068241b.zip | |
Add new instructions to handle symbols/literals >255; fix #5109
New instructions:
* OP_LOADL16
* OP_LOADSYM16
* OP_STRING16
Size of pools, symbols are `int16_t` but offset representation in the
bytecode was 8 bits. Size of child `irep` array is `int16_t`, too but
this change does not address it.
Diffstat (limited to 'src/vm.c')
| -rw-r--r-- | src/vm.c | 17 |
1 files changed, 16 insertions, 1 deletions
@@ -1069,7 +1069,12 @@ RETRY_TRY_BLOCK: NEXT; } + + CASE(OP_LOADL16, BS) { + goto op_loadl; + } CASE(OP_LOADL, BB) { + op_loadl: switch (pool[b].tt) { /* number */ case IREP_TT_INT32: regs[a] = mrb_int_value(mrb, (mrb_int)pool[b].u.i32); @@ -1138,6 +1143,11 @@ RETRY_TRY_BLOCK: NEXT; } + CASE(OP_LOADSYM16, BS) { + SET_SYM_VALUE(regs[a], syms[b]); + NEXT; + } + CASE(OP_LOADNIL, B) { SET_NIL_VALUE(regs[a]); NEXT; @@ -2575,8 +2585,13 @@ RETRY_TRY_BLOCK: NEXT; } + CASE(OP_STRING16, BS) { + goto op_string; + } CASE(OP_STRING, BB) { - size_t len = pool[b].tt >> 2; + size_t len; + op_string: + len = pool[b].tt >> 2; if (pool[b].tt & IREP_TT_SFLAG) { regs[a] = mrb_str_new_static(mrb, pool[b].u.str, len); } |
