mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
[INFER] Constant fold 'x ==/!= null' comparisons with a known result, bug 654705.
This commit is contained in:
parent
30f0c2d28b
commit
bdd6f8267a
@ -1724,21 +1724,8 @@ mjit::Compiler::generateMethod()
|
||||
} else {
|
||||
if (fused == JSOP_IFEQ)
|
||||
result = !result;
|
||||
|
||||
if (result) {
|
||||
if (!frame.syncForBranch(target, Uses(0)))
|
||||
return Compile_Error;
|
||||
Jump j = masm.jump();
|
||||
if (!jumpAndTrace(j, target))
|
||||
return Compile_Error;
|
||||
} else {
|
||||
/*
|
||||
* Branch is never taken, but clean up any loop
|
||||
* if this is a backedge.
|
||||
*/
|
||||
if (target < PC && !finishLoop(target))
|
||||
return Compile_Error;
|
||||
}
|
||||
if (!constantFoldBranch(target, result))
|
||||
return Compile_Error;
|
||||
}
|
||||
} else {
|
||||
if (!emitStubCmpOp(stub, target, fused))
|
||||
@ -4035,6 +4022,26 @@ mjit::Compiler::compareTwoValues(JSContext *cx, JSOp op, const Value &lhs, const
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
mjit::Compiler::constantFoldBranch(jsbytecode *target, bool taken)
|
||||
{
|
||||
if (taken) {
|
||||
if (!frame.syncForBranch(target, Uses(0)))
|
||||
return false;
|
||||
Jump j = masm.jump();
|
||||
if (!jumpAndTrace(j, target))
|
||||
return false;
|
||||
} else {
|
||||
/*
|
||||
* Branch is never taken, but clean up any loop
|
||||
* if this is a backedge.
|
||||
*/
|
||||
if (target < PC && !finishLoop(target))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
mjit::Compiler::emitStubCmpOp(BoolStub stub, jsbytecode *target, JSOp fused)
|
||||
{
|
||||
|
@ -572,6 +572,7 @@ class Compiler : public BaseCompiler
|
||||
bool canUseApplyTricks();
|
||||
|
||||
/* Emitting helpers. */
|
||||
bool constantFoldBranch(jsbytecode *target, bool taken);
|
||||
bool emitStubCmpOp(BoolStub stub, jsbytecode *target, JSOp fused);
|
||||
bool iter(uintN flags);
|
||||
void iterNext();
|
||||
|
@ -414,8 +414,18 @@ mjit::Compiler::jsop_equality(JSOp op, BoolStub stub, jsbytecode *target, JSOp f
|
||||
/* What's the other mask? */
|
||||
FrameEntry *test = lhsTest ? rhs : lhs;
|
||||
|
||||
if (test->isTypeKnown())
|
||||
if (test->isType(JSVAL_TYPE_NULL) || test->isType(JSVAL_TYPE_UNDEFINED)) {
|
||||
return emitStubCmpOp(stub, target, fused);
|
||||
} else if (test->isTypeKnown()) {
|
||||
/* The test will not succeed, constant fold the compare. */
|
||||
bool result = GetCompareCondition(op, fused) == Assembler::NotEqual;
|
||||
frame.pop();
|
||||
frame.pop();
|
||||
if (target)
|
||||
return constantFoldBranch(target, result);
|
||||
frame.push(BooleanValue(result));
|
||||
return true;
|
||||
}
|
||||
|
||||
/* The other side must be null or undefined. */
|
||||
RegisterID reg = frame.ownRegForType(test);
|
||||
|
Loading…
Reference in New Issue
Block a user