-
-
Save mraleph/7dcfbef44a02ec72712e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/lj_opt_mem.c b/src/lj_opt_mem.c | |
index e04a622..0cc420e 100644 | |
--- a/src/lj_opt_mem.c | |
+++ b/src/lj_opt_mem.c | |
@@ -135,6 +135,31 @@ static TRef fwd_ahload(jit_State *J, IRRef xref) | |
IRRef lim = xref; /* Search limit. */ | |
IRRef ref; | |
+ /* Key is a newly allocated table. Walk the chain of stores up to the | |
+ ** key allocation itself and see it is ever potentially used to create | |
+ ** a reference (by checking if it aliases any of the keys). If it does | |
+ ** not we can drop the load. | |
+ */ | |
+ if (xr->o == IR_HREF && | |
+ (IR(xr->op2)->o == IR_TNEW || IR(xr->op2)->o == IR_TDUP)) { | |
+ int found = 0; | |
+ IRRef tab = xr->op2; | |
+ ref = J->chain[fins->o+IRDELTA_L2S]; | |
+ while (ref > tab) { | |
+ IRIns *store = IR(ref); | |
+ IRIns *refb = IR(store->op1); | |
+ if ((refb->o == IR_HREF || refb->o == IR_NEWREF) && | |
+ aa_table(J, tab, refb->op2) != ALIAS_NO) { | |
+ found = 1; | |
+ break; | |
+ } | |
+ ref = store->prev; | |
+ } | |
+ if (!found) { | |
+ return TREF_NIL; | |
+ } | |
+ } | |
+ | |
/* Search for conflicting stores. */ | |
ref = J->chain[fins->o+IRDELTA_L2S]; | |
while (ref > xref) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment