Add table.clear().

This commit is contained in:
Mike Pall
2013-11-25 15:18:31 +01:00
parent c378f7dbb8
commit 4593fb5e29
8 changed files with 62 additions and 2 deletions

View File

@@ -17,6 +17,7 @@
#include "lj_ir.h"
#include "lj_jit.h"
#include "lj_iropt.h"
#include "lj_ircall.h"
/* Some local macros to save typing. Undef'd at the end. */
#define IR(ref) (&J->cur.ir[(ref)])
@@ -308,7 +309,7 @@ int LJ_FASTCALL lj_opt_fwd_href_nokey(jit_State *J)
return 1; /* No conflict. Can fold to niltv. */
}
/* Check whether there's no aliasing NEWREF for the left operand. */
/* Check whether there's no aliasing NEWREF/table.clear for the left operand. */
int LJ_FASTCALL lj_opt_fwd_tptr(jit_State *J, IRRef lim)
{
IRRef ta = fins->op1;
@@ -319,6 +320,14 @@ int LJ_FASTCALL lj_opt_fwd_tptr(jit_State *J, IRRef lim)
return 0; /* Conflict. */
ref = newref->prev;
}
ref = J->chain[IR_CALLS];
while (ref > lim) {
IRIns *calls = IR(ref);
if (calls->op2 == IRCALL_lj_tab_clear &&
(ta == calls->op1 || aa_table(J, ta, calls->op1) != ALIAS_NO))
return 0; /* Conflict. */
ref = calls->prev;
}
return 1; /* No conflict. Can safely FOLD/CSE. */
}