summaryrefslogtreecommitdiffhomepage
path: root/src/vm.c
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2020-11-03 14:58:44 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2020-11-03 14:58:44 +0900
commitb7e8406f6cf7f8f83fe9594d06c0861e4068241b (patch)
treebfed217bbb86a7d04aabe7e8ca88a99323fd6bfa /src/vm.c
parent0be5b266b668a6219b440c80bfcff692e02d2097 (diff)
downloadmruby-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.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/vm.c b/src/vm.c
index bcb78c0c9..1d6f82249 100644
--- a/src/vm.c
+++ b/src/vm.c
@@ -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);
}