Ignore:
Timestamp:
Dec 9, 2013, 7:24:31 PM (11 years ago)
Author:
[email protected]
Message:

Reveal array bounds checks in DFG IR
https://bugs.webkit.org/show_bug.cgi?id=125253

Reviewed by Oliver Hunt and Mark Hahnenberg.

In SSA mode, this reveals array bounds checks and the load of array length in DFG IR,
making this a candidate for LICM.

This also fixes a long-standing performance bug where the JSObject slow paths would
always create contiguous storage, rather than type-specialized storage, when doing a
"storage creating" storage, like:

var o = {};
o[0] = 42;

  • CMakeLists.txt:
  • GNUmakefile.list.am:
  • JavaScriptCore.vcxproj/JavaScriptCore.vcxproj:
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • bytecode/ExitKind.cpp:

(JSC::exitKindToString):
(JSC::exitKindIsCountable):

  • bytecode/ExitKind.h:
  • dfg/DFGAbstractInterpreterInlines.h:

(JSC::DFG::::executeEffects):

  • dfg/DFGArrayMode.cpp:

(JSC::DFG::permitsBoundsCheckLowering):
(JSC::DFG::ArrayMode::permitsBoundsCheckLowering):

  • dfg/DFGArrayMode.h:

(JSC::DFG::ArrayMode::lengthNeedsStorage):

  • dfg/DFGClobberize.h:

(JSC::DFG::clobberize):

  • dfg/DFGConstantFoldingPhase.cpp:

(JSC::DFG::ConstantFoldingPhase::foldConstants):

  • dfg/DFGFixupPhase.cpp:

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

  • dfg/DFGNodeType.h:
  • dfg/DFGPlan.cpp:

(JSC::DFG::Plan::compileInThreadImpl):

  • dfg/DFGPredictionPropagationPhase.cpp:

(JSC::DFG::PredictionPropagationPhase::propagate):

  • dfg/DFGSSALoweringPhase.cpp: Added.

(JSC::DFG::SSALoweringPhase::SSALoweringPhase):
(JSC::DFG::SSALoweringPhase::run):
(JSC::DFG::SSALoweringPhase::handleNode):
(JSC::DFG::SSALoweringPhase::lowerBoundsCheck):
(JSC::DFG::performSSALowering):

  • dfg/DFGSSALoweringPhase.h: Added.
  • dfg/DFGSafeToExecute.h:

(JSC::DFG::safeToExecute):

  • dfg/DFGSpeculativeJIT.cpp:

(JSC::DFG::SpeculativeJIT::compileDoublePutByVal):

  • dfg/DFGSpeculativeJIT32_64.cpp:

(JSC::DFG::SpeculativeJIT::compileContiguousPutByVal):
(JSC::DFG::SpeculativeJIT::compile):

  • dfg/DFGSpeculativeJIT64.cpp:

(JSC::DFG::SpeculativeJIT::compile):

  • ftl/FTLCapabilities.cpp:

(JSC::FTL::canCompile):

  • ftl/FTLLowerDFGToLLVM.cpp:

(JSC::FTL::LowerDFGToLLVM::compileNode):
(JSC::FTL::LowerDFGToLLVM::compileCheckInBounds):
(JSC::FTL::LowerDFGToLLVM::compileGetByVal):
(JSC::FTL::LowerDFGToLLVM::compilePutByVal):
(JSC::FTL::LowerDFGToLLVM::contiguousPutByValOutOfBounds):

  • runtime/JSObject.cpp:

(JSC::JSObject::convertUndecidedForValue):
(JSC::JSObject::createInitialForValueAndSet):
(JSC::JSObject::putByIndexBeyondVectorLength):
(JSC::JSObject::putDirectIndexBeyondVectorLength):

  • runtime/JSObject.h:
  • tests/stress/float32array-out-of-bounds.js: Added.

(make):
(foo):
(test):

  • tests/stress/int32-object-out-of-bounds.js: Added.

(make):
(foo):
(test):

  • tests/stress/int32-out-of-bounds.js: Added.

(foo):
(test):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/dfg/DFGArrayMode.cpp

    r156047 r160347  
    549549}
    550550
     551bool permitsBoundsCheckLowering(Array::Type type)
     552{
     553    switch (type) {
     554    case Array::Int32:
     555    case Array::Double:
     556    case Array::Contiguous:
     557    case Array::Int8Array:
     558    case Array::Int16Array:
     559    case Array::Int32Array:
     560    case Array::Uint8Array:
     561    case Array::Uint8ClampedArray:
     562    case Array::Uint16Array:
     563    case Array::Uint32Array:
     564    case Array::Float32Array:
     565    case Array::Float64Array:
     566        return true;
     567    default:
     568        // These don't allow for bounds check lowering either because the bounds
     569        // check involves something other than GetArrayLength (like ArrayStorage),
     570        // or because the bounds check isn't a speculation (like String, sort of),
     571        // or because the type implies an impure access.
     572        return false;
     573    }
     574}
     575
     576bool ArrayMode::permitsBoundsCheckLowering() const
     577{
     578    return DFG::permitsBoundsCheckLowering(type()) && isInBounds();
     579}
     580
    551581void ArrayMode::dump(PrintStream& out) const
    552582{
Note: See TracChangeset for help on using the changeset viewer.