Ignore:
Timestamp:
Mar 4, 2014, 5:03:55 PM (11 years ago)
Author:
[email protected]
Message:

DFG and FTL should specialize for and support CompareStrictEq over Misc (i.e. boolean, undefined, or null)
https://bugs.webkit.org/show_bug.cgi?id=129563

Source/JavaScriptCore:

Reviewed by Geoffrey Garen.

This adds a specialization of CompareStrictEq over Misc. I noticed the need for this
when I saw that we didn't support CompareStrictEq(Untyped) in FTL but that the main
user of this was EarleyBoyer, and in that benchmark what it was really doing was
comparing undefined, null, and booleans to each other.

This also adds support for miscellaneous things that I needed to make my various test
cases work. This includes comparison over booleans and the various Throw-related node
types.

This also improves constant folding of CompareStrictEq and CompareEq.

Also found a bug where we were claiming that GetByVals on typed arrays are OutOfBounds
based on profiling, which caused some downstream badness. We don't actually support
compiling OutOfBounds GetByVals on typed arrays. The DFG would ignore the flag and just
emit a bounds check, but in the FTL path, the SSA lowering phase would assume that it
shouldn't factor out the bounds check since the access is not InBounds but then the
backend would ignore the flag and assume that the bounds check was already emitted.
This showed up on an existing test but I added a test for this explicitly to have more
certain coverage. The fix is to not mark something as OutOfBounds if the semantics are
that we'll have a bounds check anyway.

This is a 1% speed-up on Octane mostly because of raytrace, but also because of just
general progressions across the board. No speed-up yet on EarleyBoyer, since there is
still a lot more coverage work to be done there.

  • bytecode/SpeculatedType.cpp:

(JSC::speculationToAbbreviatedString):
(JSC::leastUpperBoundOfStrictlyEquivalentSpeculations):
(JSC::valuesCouldBeEqual):

  • bytecode/SpeculatedType.h:

(JSC::isMiscSpeculation):

  • dfg/DFGAbstractInterpreterInlines.h:

(JSC::DFG::AbstractInterpreter<AbstractStateType>::executeEffects):

  • dfg/DFGFixupPhase.cpp:

(JSC::DFG::FixupPhase::fixupNode):

  • dfg/DFGNode.h:

(JSC::DFG::Node::shouldSpeculateMisc):

  • dfg/DFGSafeToExecute.h:

(JSC::DFG::SafeToExecuteEdge::operator()):

  • dfg/DFGSpeculativeJIT.cpp:

(JSC::DFG::SpeculativeJIT::compileStrictEq):
(JSC::DFG::SpeculativeJIT::speculateMisc):
(JSC::DFG::SpeculativeJIT::speculate):

  • dfg/DFGSpeculativeJIT.h:
  • dfg/DFGSpeculativeJIT32_64.cpp:

(JSC::DFG::SpeculativeJIT::compileMiscStrictEq):

  • dfg/DFGSpeculativeJIT64.cpp:

(JSC::DFG::SpeculativeJIT::compileMiscStrictEq):

  • dfg/DFGUseKind.cpp:

(WTF::printInternal):

  • dfg/DFGUseKind.h:

(JSC::DFG::typeFilterFor):

  • ftl/FTLCapabilities.cpp:

(JSC::FTL::canCompile):

  • ftl/FTLLowerDFGToLLVM.cpp:

(JSC::FTL::LowerDFGToLLVM::compileNode):
(JSC::FTL::LowerDFGToLLVM::compileCompareEq):
(JSC::FTL::LowerDFGToLLVM::compileCompareStrictEq):
(JSC::FTL::LowerDFGToLLVM::compileThrow):
(JSC::FTL::LowerDFGToLLVM::isNotMisc):
(JSC::FTL::LowerDFGToLLVM::isMisc):
(JSC::FTL::LowerDFGToLLVM::speculate):
(JSC::FTL::LowerDFGToLLVM::speculateMisc):

  • tests/stress/float32-array-out-of-bounds.js: Added.
  • tests/stress/weird-equality-folding-cases.js: Added.

LayoutTests:

Reviewed by Geoffrey Garen.

  • js/regress/fold-strict-eq-expected.txt: Added.
  • js/regress/fold-strict-eq.html: Added.
  • js/regress/misc-strict-eq-expected.txt: Added.
  • js/regress/misc-strict-eq.html: Added.
  • js/regress/script-tests/fold-strict-eq.js: Added.

(foo):
(test):

  • js/regress/script-tests/misc-strict-eq.js: Added.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h

    r164620 r165085  
    918918            SpeculatedType leftType = forNode(node->child1()).m_type;
    919919            SpeculatedType rightType = forNode(node->child2()).m_type;
    920             if ((isInt32Speculation(leftType) && isOtherSpeculation(rightType))
    921                 || (isOtherSpeculation(leftType) && isInt32Speculation(rightType))) {
     920            if (!valuesCouldBeEqual(leftType, rightType)) {
    922921                setConstant(node, jsBoolean(false));
    923922                break;
     
    944943        JSValue right = forNode(rightNode).value();
    945944        if (left && right) {
    946             if (left.isNumber() && right.isNumber()) {
    947                 setConstant(node, jsBoolean(left.asNumber() == right.asNumber()));
    948                 break;
    949             }
    950945            if (left.isString() && right.isString()) {
     946                // We need this case because JSValue::strictEqual is otherwise too racy for
     947                // string comparisons.
    951948                const StringImpl* a = asString(left)->tryGetValueImpl();
    952949                const StringImpl* b = asString(right)->tryGetValueImpl();
     
    955952                    break;
    956953                }
    957             }
    958         }
     954            } else {
     955                setConstant(node, jsBoolean(JSValue::strictEqual(0, left, right)));
     956                break;
     957            }
     958        }
     959       
     960        SpeculatedType leftLUB = leastUpperBoundOfStrictlyEquivalentSpeculations(forNode(leftNode).m_type);
     961        SpeculatedType rightLUB = leastUpperBoundOfStrictlyEquivalentSpeculations(forNode(rightNode).m_type);
     962        if (!(leftLUB & rightLUB)) {
     963            setConstant(node, jsBoolean(false));
     964            break;
     965        }
     966       
    959967        forNode(node).setType(SpecBoolean);
    960968        node->setCanExit(true); // This is overly conservative.
Note: See TracChangeset for help on using the changeset viewer.