From 97d0874ff5dc878758f79ceef5509cc632779c53 Mon Sep 17 00:00:00 2001 From: Mike Pall Date: Mon, 7 Feb 2011 21:59:25 +0100 Subject: [PATCH] Add IR_XBAR, a barrier against XLOAD/XSTORE optimizations. --- src/lj_asm.c | 2 +- src/lj_ir.h | 3 ++- src/lj_opt_fold.c | 1 + src/lj_opt_mem.c | 2 ++ 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/lj_asm.c b/src/lj_asm.c index acad3b25..c349c990 100644 --- a/src/lj_asm.c +++ b/src/lj_asm.c @@ -3991,7 +3991,7 @@ static void asm_ir(ASMState *as, IRIns *ir) switch ((IROp)ir->o) { /* Miscellaneous ops. */ case IR_LOOP: asm_loop(as); break; - case IR_NOP: lua_assert(!ra_used(ir)); break; + case IR_NOP: case IR_XBAR: lua_assert(!ra_used(ir)); break; case IR_PHI: asm_phi(as, ir); break; case IR_HIOP: asm_hiop(as, ir); break; diff --git a/src/lj_ir.h b/src/lj_ir.h index ae533939..a29fca6f 100644 --- a/src/lj_ir.h +++ b/src/lj_ir.h @@ -115,9 +115,10 @@ _(CNEW, AW, ref, ref) \ _(CNEWI, NW, ref, ref) /* CSE is ok, not marked as A. */ \ \ - /* Write barriers. */ \ + /* Barriers. */ \ _(TBAR, S , ref, ___) \ _(OBAR, S , ref, ref) \ + _(XBAR, S , ___, ___) \ \ /* Type conversions. */ \ _(CONV, N , ref, lit) \ diff --git a/src/lj_opt_fold.c b/src/lj_opt_fold.c index f4872046..e5ed7ade 100644 --- a/src/lj_opt_fold.c +++ b/src/lj_opt_fold.c @@ -1895,6 +1895,7 @@ LJFOLD(NEWREF any any) /* Treated like a store. */ LJFOLD(CALLS any any) LJFOLD(CALLL any any) /* Safeguard fallback. */ LJFOLD(CALLXS any any) +LJFOLD(XBAR) LJFOLD(RETF any any) /* Modifies BASE. */ LJFOLD(TNEW any any) LJFOLD(TDUP any) diff --git a/src/lj_opt_mem.c b/src/lj_opt_mem.c index 211c329a..6062be70 100644 --- a/src/lj_opt_mem.c +++ b/src/lj_opt_mem.c @@ -676,6 +676,7 @@ TRef LJ_FASTCALL lj_opt_fwd_xload(jit_State *J) ref = J->chain[IR_XSTORE]; retry: if (J->chain[IR_CALLXS] > lim) lim = J->chain[IR_CALLXS]; + if (J->chain[IR_XBAR] > lim) lim = J->chain[IR_XBAR]; while (ref > lim) { IRIns *store = IR(ref); switch (aa_xref(J, xr, fins, store)) { @@ -738,6 +739,7 @@ TRef LJ_FASTCALL lj_opt_dse_xstore(jit_State *J) IRRef1 *refp = &J->chain[IR_XSTORE]; IRRef ref = *refp; if (J->chain[IR_CALLXS] > lim) lim = J->chain[IR_CALLXS]; + if (J->chain[IR_XBAR] > lim) lim = J->chain[IR_XBAR]; while (ref > lim) { /* Search for redundant or conflicting stores. */ IRIns *store = IR(ref); switch (aa_xref(J, xr, fins, store)) {