From 99d153bef9725db226614558d01df829afafee3c Mon Sep 17 00:00:00 2001 From: Mike Pall Date: Sat, 9 Jan 2010 23:59:43 +0100 Subject: Improve alias analysis of upvalues using a disambiguation hash value. All upvalue objects hold a disambiguation hash value now. It's built from the parent prototype and the slot number. Different hash values imply the upvalues cannot alias. Same hash values don't imply anything (collision or different closures). Upvalue disambiguation makes use of a reduced hash due to IR contraints. --- src/lj_opt_mem.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'src/lj_opt_mem.c') diff --git a/src/lj_opt_mem.c b/src/lj_opt_mem.c index 521c8590..57948311 100644 --- a/src/lj_opt_mem.c +++ b/src/lj_opt_mem.c @@ -277,12 +277,17 @@ static AliasRet aa_uref(IRIns *refa, IRIns *refb) { if (refa->o != refb->o) return ALIAS_NO; /* Different UREFx type. */ - if (refa->op1 != refb->op1) - return ALIAS_MAY; /* Different function. */ - else if (refa->op2 == refb->op2) - return ALIAS_MUST; /* Same function, same upvalue idx. */ - else - return ALIAS_NO; /* Same function, different upvalue idx. */ + if (refa->op1 == refb->op1) { /* Same function. */ + if (refa->op2 == refb->op2) + return ALIAS_MUST; /* Same function, same upvalue idx. */ + else + return ALIAS_NO; /* Same function, different upvalue idx. */ + } else { /* Different functions, check disambiguation hash values. */ + if (((refa->op2 ^ refb->op2) & 0xff)) + return ALIAS_NO; /* Upvalues with different hash values cannot alias. */ + else + return ALIAS_MAY; /* No conclusion can be drawn for same hash value. */ + } } /* ULOAD forwarding. */ -- cgit v1.2.3-55-g6feb