summaryrefslogtreecommitdiff
path: root/src/lj_opt_mem.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lj_opt_mem.c')
-rw-r--r--src/lj_opt_mem.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/lj_opt_mem.c b/src/lj_opt_mem.c
index 57948311..042d6081 100644
--- a/src/lj_opt_mem.c
+++ b/src/lj_opt_mem.c
@@ -21,6 +21,7 @@
21/* Some local macros to save typing. Undef'd at the end. */ 21/* Some local macros to save typing. Undef'd at the end. */
22#define IR(ref) (&J->cur.ir[(ref)]) 22#define IR(ref) (&J->cur.ir[(ref)])
23#define fins (&J->fold.ins) 23#define fins (&J->fold.ins)
24#define fright (&J->fold.right)
24 25
25/* 26/*
26** Caveat #1: return value is not always a TRef -- only use with tref_ref(). 27** Caveat #1: return value is not always a TRef -- only use with tref_ref().
@@ -220,6 +221,34 @@ TRef LJ_FASTCALL lj_opt_fwd_hload(jit_State *J)
220 return EMITFOLD; 221 return EMITFOLD;
221} 222}
222 223
224/* Check whether HREF of TNEW/TDUP can be folded to niltv. */
225int LJ_FASTCALL lj_opt_fwd_href_nokey(jit_State *J)
226{
227 IRRef lim = fins->op1; /* Search limit. */
228 IRRef ref;
229
230 /* The key for an ASTORE may end up in the hash part after a NEWREF. */
231 if (irt_isnum(fright->t) && J->chain[IR_NEWREF] > lim) {
232 ref = J->chain[IR_ASTORE];
233 while (ref > lim) {
234 if (ref < J->chain[IR_NEWREF])
235 return 0; /* Conflict. */
236 ref = IR(ref)->prev;
237 }
238 }
239
240 /* Search for conflicting stores. */
241 ref = J->chain[IR_HSTORE];
242 while (ref > lim) {
243 IRIns *store = IR(ref);
244 if (aa_ahref(J, fins, IR(store->op1)) != ALIAS_NO)
245 return 0; /* Conflict. */
246 ref = store->prev;
247 }
248
249 return 1; /* No conflict. Can fold to niltv. */
250}
251
223/* ASTORE/HSTORE elimination. */ 252/* ASTORE/HSTORE elimination. */
224TRef LJ_FASTCALL lj_opt_dse_ahstore(jit_State *J) 253TRef LJ_FASTCALL lj_opt_dse_ahstore(jit_State *J)
225{ 254{
@@ -530,5 +559,6 @@ int lj_opt_fwd_wasnonnil(jit_State *J, IROpT loadop, IRRef xref)
530 559
531#undef IR 560#undef IR
532#undef fins 561#undef fins
562#undef fright
533 563
534#endif 564#endif