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/DFGSpeculativeJIT.cpp

    r164764 r165085  
    38033803    }
    38043804       
     3805    case MiscUse: {
     3806        compileMiscStrictEq(node);
     3807        return false;
     3808    }
     3809       
    38053810    case UntypedUse: {
    38063811        return nonSpeculativeStrictEq(node);
     
    48314836}
    48324837
     4838void SpeculativeJIT::speculateMisc(Edge edge, JSValueRegs regs)
     4839{
     4840#if USE(JSVALUE64)
     4841    typeCheck(
     4842        regs, edge, SpecMisc,
     4843        m_jit.branch64(MacroAssembler::Above, regs.gpr(), MacroAssembler::TrustedImm64(TagBitTypeOther | TagBitBool | TagBitUndefined)));
     4844#else
     4845    typeCheck(
     4846        regs, edge, SpecMisc | SpecInt32,
     4847        m_jit.branch32(MacroAssembler::Equal, regs.tagGPR(), MacroAssembler::TrustedImm32(JSValue::Int32Tag)));
     4848    typeCheck(
     4849        regs, edge, SpecMisc,
     4850        m_jit.branch32(MacroAssembler::Below, regs.tagGPR(), MacroAssembler::TrustedImm32(JSValue::UndefinedTag)));
     4851#endif
     4852}
     4853
     4854void SpeculativeJIT::speculateMisc(Edge edge)
     4855{
     4856    if (!needsTypeCheck(edge, SpecMisc))
     4857        return;
     4858   
     4859    JSValueOperand operand(this, edge, ManualOperandSpeculation);
     4860    speculateMisc(edge, operand.jsValueRegs());
     4861}
     4862
    48334863void SpeculativeJIT::speculate(Node*, Edge edge)
    48344864{
     
    48924922    case OtherUse:
    48934923        speculateOther(edge);
     4924        break;
     4925    case MiscUse:
     4926        speculateMisc(edge);
    48944927        break;
    48954928    default:
Note: See TracChangeset for help on using the changeset viewer.