diff options
| author | dearblue <[email protected]> | 2020-11-28 14:44:34 +0900 |
|---|---|---|
| committer | dearblue <[email protected]> | 2020-11-29 13:48:45 +0900 |
| commit | b0cea30f3293d0d4d00fee6f8c7a461e64028890 (patch) | |
| tree | cde11dde7763c0c4b0dae7a5496165b6854b43cb | |
| parent | 6d07d9b3d7a64834bda8644ab6c4ed1fabe217a4 (diff) | |
| download | mruby-b0cea30f3293d0d4d00fee6f8c7a461e64028890.tar.gz mruby-b0cea30f3293d0d4d00fee6f8c7a461e64028890.zip | |
Change the catch handler address to 32 bits
Follow commit 7150c6753933f12a2ba63769fb7b3a44cfcddd3d .
| -rw-r--r-- | include/mruby/irep.h | 9 | ||||
| -rw-r--r-- | mrbgems/mruby-compiler/core/codegen.c | 6 | ||||
| -rw-r--r-- | src/dump.c | 2 | ||||
| -rw-r--r-- | src/load.c | 2 | ||||
| -rw-r--r-- | src/vm.c | 6 |
5 files changed, 14 insertions, 11 deletions
diff --git a/include/mruby/irep.h b/include/mruby/irep.h index 04ab54ee2..12d81d0d3 100644 --- a/include/mruby/irep.h +++ b/include/mruby/irep.h @@ -47,9 +47,9 @@ enum mrb_catch_type { struct mrb_irep_catch_handler { uint8_t type; /* enum mrb_catch_type */ - uint8_t begin[2]; /* The starting address to match the hander. Includes this. */ - uint8_t end[2]; /* The endpoint address that matches the hander. Not Includes this. */ - uint8_t target[2]; /* The address to jump to if a match is made. */ + uint8_t begin[4]; /* The starting address to match the hander. Includes this. */ + uint8_t end[4]; /* The endpoint address that matches the hander. Not Includes this. */ + uint8_t target[4]; /* The address to jump to if a match is made. */ }; /* Program data array struct */ @@ -139,6 +139,9 @@ mrb_irep_catch_handler_table(const struct mrb_irep *irep) } } +#define mrb_irep_catch_handler_pack(n, v) uint32_to_bin(n, v) +#define mrb_irep_catch_handler_unpack(v) bin_to_uint32(v) + MRB_END_DECL #endif /* MRUBY_IREP_H */ diff --git a/mrbgems/mruby-compiler/core/codegen.c b/mrbgems/mruby-compiler/core/codegen.c index 2e39e8930..3e2a98452 100644 --- a/mrbgems/mruby-compiler/core/codegen.c +++ b/mrbgems/mruby-compiler/core/codegen.c @@ -3229,9 +3229,9 @@ catch_handler_set(codegen_scope *s, int ent, enum mrb_catch_type type, uint32_t e = &s->catch_table[ent]; uint8_to_bin(type, &e->type); - uint16_to_bin(begin, e->begin); - uint16_to_bin(end, e->end); - uint16_to_bin(target, e->target); + mrb_irep_catch_handler_pack(begin, e->begin); + mrb_irep_catch_handler_pack(end, e->end); + mrb_irep_catch_handler_pack(target, e->target); } static struct RProc* diff --git a/src/dump.c b/src/dump.c index a79df597b..d6734e9bf 100644 --- a/src/dump.c +++ b/src/dump.c @@ -277,7 +277,7 @@ write_catch_table_block(mrb_state *mrb, const mrb_irep *irep, uint8_t *buf) { uint8_t *cur = buf; const struct mrb_irep_catch_handler *e = mrb_irep_catch_handler_table(irep); - mrb_static_assert1(sizeof(*e) == 7); + mrb_static_assert1(sizeof(*e) == 13); if (e == NULL) return 0; /* irep->clen has already been written before iseq block */ diff --git a/src/load.c b/src/load.c index 23e11d331..48496ba48 100644 --- a/src/load.c +++ b/src/load.c @@ -107,7 +107,7 @@ read_irep_record_1(mrb_state *mrb, const uint8_t *bin, size_t *len, uint8_t flag if (irep->ilen > 0) { size_t data_len = sizeof(mrb_code) * irep->ilen + sizeof(struct mrb_irep_catch_handler) * irep->clen; - mrb_static_assert1(sizeof(struct mrb_irep_catch_handler) == 7); + mrb_static_assert1(sizeof(struct mrb_irep_catch_handler) == 13); if (SIZE_ERROR_MUL(irep->ilen, sizeof(mrb_code))) { return NULL; } @@ -813,7 +813,7 @@ catch_handler_find(mrb_state *mrb, mrb_callinfo *ci, const mrb_code *pc, uint32_ e = mrb_irep_catch_handler_table(irep) + cnt - 1; for (; cnt > 0; cnt --, e --) { if (((UINT32_C(1) << e->type) & filter) && - catch_cover_p(xpc, bin_to_uint16(e->begin), bin_to_uint16(e->end))) { + catch_cover_p(xpc, mrb_irep_catch_handler_unpack(e->begin), mrb_irep_catch_handler_unpack(e->end))) { return e; } } @@ -1312,7 +1312,7 @@ RETRY_TRY_BLOCK: ch = catch_handler_find(mrb, mrb->c->ci, pc, MRB_CATCH_FILTER_ENSURE); if (ch) { /* avoiding a jump from a catch handler into the same handler */ - if (a < bin_to_uint16(ch->begin) || a >= bin_to_uint16(ch->end)) { + if (a < mrb_irep_catch_handler_unpack(ch->begin) || a >= mrb_irep_catch_handler_unpack(ch->end)) { THROW_TAGGED_BREAK(mrb, RBREAK_TAG_JUMP, proc, mrb_fixnum_value(a)); } } @@ -2009,7 +2009,7 @@ RETRY_TRY_BLOCK: mrb->c->stack = ci[1].stackent; } mrb_stack_extend(mrb, irep->nregs); - pc = irep->iseq + bin_to_uint16(ch->target); + pc = irep->iseq + mrb_irep_catch_handler_unpack(ch->target); } else { mrb_int acc; |
