mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Restore the variable pc after longjmp()
Changes made after `setjmp()` are destroyed and need reassignment. This problem is now caused by the addition of the `OP_JUW` instruction. When actually building on FreeBSD 12.1 with `clang10 -fsanitize=address`, mrbtest "NameError#name [15.2.31.2.1]" is failed. However, qualifying `pc` with `volatile` slows down significantly and increases the object code. Suppress them by qualifying only the variables that restore `pc`.
This commit is contained in:
committed by
Yukihiro "Matz" Matsumoto
parent
c1f112c49a
commit
bfb7b491cc
@@ -966,7 +966,7 @@ prepare_tagged_break(mrb_state *mrb, uint32_t tag, struct RProc *proc, mrb_value
|
||||
#ifndef DIRECT_THREADED
|
||||
|
||||
#define INIT_DISPATCH for (;;) { insn = BYTECODE_DECODER(*pc); CODE_FETCH_HOOK(mrb, irep, pc, regs); switch (insn) {
|
||||
#define CASE(insn,ops) case insn: pc0=pc++; FETCH_ ## ops ();
|
||||
#define CASE(insn,ops) case insn: pc0=pc++; FETCH_ ## ops (); pc_save = pc;
|
||||
#define NEXT break
|
||||
#define JUMP NEXT
|
||||
#define END_DISPATCH }}
|
||||
@@ -974,7 +974,7 @@ prepare_tagged_break(mrb_state *mrb, uint32_t tag, struct RProc *proc, mrb_value
|
||||
#else
|
||||
|
||||
#define INIT_DISPATCH JUMP; return mrb_nil_value();
|
||||
#define CASE(insn,ops) L_ ## insn: pc0=pc++; FETCH_ ## ops ();
|
||||
#define CASE(insn,ops) L_ ## insn: pc0=pc++; FETCH_ ## ops (); pc_save = pc;
|
||||
#define NEXT insn=BYTECODE_DECODER(*pc); CODE_FETCH_HOOK(mrb, irep, pc, regs); goto *optable[insn]
|
||||
#define JUMP NEXT
|
||||
|
||||
@@ -1030,6 +1030,7 @@ mrb_vm_exec(mrb_state *mrb, const struct RProc *proc, const mrb_code *pc)
|
||||
{
|
||||
/* mrb_assert(MRB_PROC_CFUNC_P(proc)) */
|
||||
const mrb_code *pc0 = pc;
|
||||
const mrb_code *volatile pc_save = pc;
|
||||
const mrb_irep *irep = proc->body.irep;
|
||||
const mrb_pool_value *pool = irep->pool;
|
||||
const mrb_sym *syms = irep->syms;
|
||||
@@ -2834,6 +2835,7 @@ RETRY_TRY_BLOCK:
|
||||
ci = cipop(mrb);
|
||||
}
|
||||
exc_catched = TRUE;
|
||||
pc = pc_save;
|
||||
goto RETRY_TRY_BLOCK;
|
||||
}
|
||||
MRB_END_EXC(&c_jmp);
|
||||
|
||||
Reference in New Issue
Block a user