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.
This commit is contained in:
@@ -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. */
|
||||
|
||||
Reference in New Issue
Block a user