diff options
| author | dearblue <[email protected]> | 2020-07-26 11:45:24 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2020-10-12 16:21:33 +0900 |
| commit | bfb7b491cc13776cc4b44671d1605f8fb1da7514 (patch) | |
| tree | 0abda84ba7364e85b6310214dac0798f9637fa07 /src | |
| parent | c1f112c49a597da8478516261f0812bc073f6cd8 (diff) | |
| download | mruby-bfb7b491cc13776cc4b44671d1605f8fb1da7514.tar.gz mruby-bfb7b491cc13776cc4b44671d1605f8fb1da7514.zip | |
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`.
Diffstat (limited to 'src')
| -rw-r--r-- | src/vm.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -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); |
