Unverified Commit c6071335 authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto Committed by GitHub

Merge pull request #5200 from dearblue/catchhandler32

Change the catch handler address to 32 bits
parents 6d07d9b3 b0cea30f
......@@ -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 */
......@@ -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*
......
......@@ -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 */
......
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment