aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Pall <mike>2020-10-12 15:40:28 +0200
committerMike Pall <mike>2020-10-12 15:40:28 +0200
commitde6b1a11dd1a3349179084578c5d533be1c30234 (patch)
treef82129c93cef707f410be068c782dcedee98419d /src
parente8ec6fe996cf48ef23755581dafe372eb71ad75c (diff)
downloadluajit-de6b1a11dd1a3349179084578c5d533be1c30234.tar.gz
luajit-de6b1a11dd1a3349179084578c5d533be1c30234.tar.bz2
luajit-de6b1a11dd1a3349179084578c5d533be1c30234.zip
Ensure full init of IR_NOP instructions.
Diffstat (limited to 'src')
-rw-r--r--src/lj_asm.c2
-rw-r--r--src/lj_ir.h8
-rw-r--r--src/lj_opt_dce.c5
-rw-r--r--src/lj_opt_mem.c25
4 files changed, 15 insertions, 25 deletions
diff --git a/src/lj_asm.c b/src/lj_asm.c
index 9b17421e..60be4337 100644
--- a/src/lj_asm.c
+++ b/src/lj_asm.c
@@ -1833,7 +1833,7 @@ void lj_asm_trace(jit_State *J, GCtrace *T)
1833 1833
1834 /* Ensure an initialized instruction beyond the last one for HIOP checks. */ 1834 /* Ensure an initialized instruction beyond the last one for HIOP checks. */
1835 J->cur.nins = lj_ir_nextins(J); 1835 J->cur.nins = lj_ir_nextins(J);
1836 J->cur.ir[J->cur.nins].o = IR_NOP; 1836 lj_ir_nop(&J->cur.ir[J->cur.nins]);
1837 1837
1838 /* Setup initial state. Copy some fields to reduce indirections. */ 1838 /* Setup initial state. Copy some fields to reduce indirections. */
1839 as->J = J; 1839 as->J = J;
diff --git a/src/lj_ir.h b/src/lj_ir.h
index 3a154a05..ac51dc79 100644
--- a/src/lj_ir.h
+++ b/src/lj_ir.h
@@ -548,4 +548,12 @@ static LJ_AINLINE int ir_sideeff(IRIns *ir)
548 548
549LJ_STATIC_ASSERT((int)IRT_GUARD == (int)IRM_W); 549LJ_STATIC_ASSERT((int)IRT_GUARD == (int)IRM_W);
550 550
551/* Replace IR instruction with NOP. */
552static LJ_AINLINE void lj_ir_nop(IRIns *ir)
553{
554 ir->ot = IRT(IR_NOP, IRT_NIL);
555 ir->op1 = ir->op2 = 0;
556 ir->prev = 0;
557}
558
551#endif 559#endif
diff --git a/src/lj_opt_dce.c b/src/lj_opt_dce.c
index a1df91dd..31e5badd 100644
--- a/src/lj_opt_dce.c
+++ b/src/lj_opt_dce.c
@@ -47,10 +47,7 @@ static void dce_propagate(jit_State *J)
47 pchain[ir->o] = &ir->prev; 47 pchain[ir->o] = &ir->prev;
48 } else if (!ir_sideeff(ir)) { 48 } else if (!ir_sideeff(ir)) {
49 *pchain[ir->o] = ir->prev; /* Reroute original instruction chain. */ 49 *pchain[ir->o] = ir->prev; /* Reroute original instruction chain. */
50 ir->t.irt = IRT_NIL; 50 lj_ir_nop(ir);
51 ir->o = IR_NOP; /* Replace instruction with NOP. */
52 ir->op1 = ir->op2 = 0;
53 ir->prev = 0;
54 continue; 51 continue;
55 } 52 }
56 if (ir->op1 >= REF_FIRST) irt_setmark(IR(ir->op1)->t); 53 if (ir->op1 >= REF_FIRST) irt_setmark(IR(ir->op1)->t);
diff --git a/src/lj_opt_mem.c b/src/lj_opt_mem.c
index 281f29ad..5659a056 100644
--- a/src/lj_opt_mem.c
+++ b/src/lj_opt_mem.c
@@ -352,10 +352,7 @@ TRef LJ_FASTCALL lj_opt_dse_ahstore(jit_State *J)
352 goto doemit; /* No elimination possible. */ 352 goto doemit; /* No elimination possible. */
353 /* Remove redundant store from chain and replace with NOP. */ 353 /* Remove redundant store from chain and replace with NOP. */
354 *refp = store->prev; 354 *refp = store->prev;
355 store->o = IR_NOP; 355 lj_ir_nop(store);
356 store->t.irt = IRT_NIL;
357 store->op1 = store->op2 = 0;
358 store->prev = 0;
359 /* Now emit the new store instead. */ 356 /* Now emit the new store instead. */
360 } 357 }
361 goto doemit; 358 goto doemit;
@@ -456,10 +453,7 @@ TRef LJ_FASTCALL lj_opt_dse_ustore(jit_State *J)
456 goto doemit; /* No elimination possible. */ 453 goto doemit; /* No elimination possible. */
457 /* Remove redundant store from chain and replace with NOP. */ 454 /* Remove redundant store from chain and replace with NOP. */
458 *refp = store->prev; 455 *refp = store->prev;
459 store->o = IR_NOP; 456 lj_ir_nop(store);
460 store->t.irt = IRT_NIL;
461 store->op1 = store->op2 = 0;
462 store->prev = 0;
463 if (ref+1 < J->cur.nins && 457 if (ref+1 < J->cur.nins &&
464 store[1].o == IR_OBAR && store[1].op1 == xref) { 458 store[1].o == IR_OBAR && store[1].op1 == xref) {
465 IRRef1 *bp = &J->chain[IR_OBAR]; 459 IRRef1 *bp = &J->chain[IR_OBAR];
@@ -468,10 +462,7 @@ TRef LJ_FASTCALL lj_opt_dse_ustore(jit_State *J)
468 bp = &obar->prev; 462 bp = &obar->prev;
469 /* Remove OBAR, too. */ 463 /* Remove OBAR, too. */
470 *bp = obar->prev; 464 *bp = obar->prev;
471 obar->o = IR_NOP; 465 lj_ir_nop(obar);
472 obar->t.irt = IRT_NIL;
473 obar->op1 = obar->op2 = 0;
474 obar->prev = 0;
475 } 466 }
476 /* Now emit the new store instead. */ 467 /* Now emit the new store instead. */
477 } 468 }
@@ -562,10 +553,7 @@ TRef LJ_FASTCALL lj_opt_dse_fstore(jit_State *J)
562 goto doemit; /* No elimination possible. */ 553 goto doemit; /* No elimination possible. */
563 /* Remove redundant store from chain and replace with NOP. */ 554 /* Remove redundant store from chain and replace with NOP. */
564 *refp = store->prev; 555 *refp = store->prev;
565 store->o = IR_NOP; 556 lj_ir_nop(store);
566 store->t.irt = IRT_NIL;
567 store->op1 = store->op2 = 0;
568 store->prev = 0;
569 /* Now emit the new store instead. */ 557 /* Now emit the new store instead. */
570 } 558 }
571 goto doemit; 559 goto doemit;
@@ -816,10 +804,7 @@ TRef LJ_FASTCALL lj_opt_dse_xstore(jit_State *J)
816 goto doemit; /* No elimination possible. */ 804 goto doemit; /* No elimination possible. */
817 /* Remove redundant store from chain and replace with NOP. */ 805 /* Remove redundant store from chain and replace with NOP. */
818 *refp = store->prev; 806 *refp = store->prev;
819 store->o = IR_NOP; 807 lj_ir_nop(store);
820 store->t.irt = IRT_NIL;
821 store->op1 = store->op2 = 0;
822 store->prev = 0;
823 /* Now emit the new store instead. */ 808 /* Now emit the new store instead. */
824 } 809 }
825 goto doemit; 810 goto doemit;