Ignore:
Timestamp:
Sep 10, 2013, 8:24:09 PM (12 years ago)
Author:
[email protected]
Message:

Be explicit about backwards propagation properties that care about escaping to bytecode, as opposed to just escaping within DFG code.

Rubber stamped by Mark Hahnenberg.

We need to care about escaping to bytecode if we're doing a lossy optimization,
i.e. the optimization means we produce less information and so we can't rescue
ourselves during OSR exit.

We only need to care about escaping within the DFG code (and can ignore what
might happen in bytecode) if we're doing an optimization that is lossless, i.e.
we can always still reconstruct the values that bytecode wants.

Example #1:

Large int32 + int32 which overflows. We want to optimize away the overflow
check and just do a 32-bit add.


This is lossy; the result should have one extra bit but we simply throw
that bit away by doing a check-less 32-bit add. Hence we need to know that
even the bytecode wouldn't have cared about that bit. This is true in cases
like (a + b) | 0.


Example #2:

Larbe int32 + int32 which overflows. We want to optimize away the overflow
check by doing a 64-bit add.


This is lossless. We can always convert the resulting 64-bit int back to a
double if that's what bytecode wants. Hence we only need to know that the
DFG code won't want to do something to this value that would make 64-bit
ints either unprofitable or unsound.


The backwards propagator's notions of flags (NodeUsedAsValue, etc) are for lossy
optimizations and so should be named in a way that reflects this. This patch
calls then NodeBytecodeUsesAsValue, etc.

  • dfg/DFGAbstractInterpreterInlines.h:

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

  • dfg/DFGArrayMode.cpp:

(JSC::DFG::ArrayMode::refine):

  • dfg/DFGBackwardsPropagationPhase.cpp:

(JSC::DFG::BackwardsPropagationPhase::mergeDefaultFlags):
(JSC::DFG::BackwardsPropagationPhase::propagate):

  • dfg/DFGFixupPhase.cpp:

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

  • dfg/DFGGraph.h:

(JSC::DFG::Graph::addImmediateShouldSpeculateInt32):

  • dfg/DFGNode.h:

(JSC::DFG::Node::arithNodeFlags):

  • dfg/DFGNodeFlags.cpp:

(JSC::DFG::dumpNodeFlags):

  • dfg/DFGNodeFlags.h:

(JSC::DFG::bytecodeUsesAsNumber):
(JSC::DFG::bytecodeCanTruncateInteger):
(JSC::DFG::bytecodeCanIgnoreNegativeZero):
(JSC::DFG::nodeMayNegZero):
(JSC::DFG::nodeCanSpeculateInt32):

  • dfg/DFGPredictionPropagationPhase.cpp:

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

  • dfg/DFGSpeculativeJIT.cpp:

(JSC::DFG::SpeculativeJIT::compileDoubleAsInt32):
(JSC::DFG::SpeculativeJIT::compileAdd):
(JSC::DFG::SpeculativeJIT::compileArithSub):
(JSC::DFG::SpeculativeJIT::compileArithNegate):
(JSC::DFG::SpeculativeJIT::compileArithMul):
(JSC::DFG::SpeculativeJIT::compileArithDiv):
(JSC::DFG::SpeculativeJIT::compileArithMod):

  • dfg/DFGVariableAccessData.h:

(JSC::DFG::VariableAccessData::shouldUseDoubleFormatAccordingToVote):

  • ftl/FTLLowerDFGToLLVM.cpp:

(JSC::FTL::LowerDFGToLLVM::compileAdd):
(JSC::FTL::LowerDFGToLLVM::compileArithSub):
(JSC::FTL::LowerDFGToLLVM::compileArithMul):
(JSC::FTL::LowerDFGToLLVM::compileArithDiv):
(JSC::FTL::LowerDFGToLLVM::compileArithMod):
(JSC::FTL::LowerDFGToLLVM::compileArithNegate):

File:
1 edited

Legend:

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

    r153274 r155497  
    7878   
    7979    if (flags & NodeResultMask) {
    80         if (!(flags & NodeUsedAsNumber) && !(flags & NodeNeedsNegZero))
     80        if (!(flags & NodeBytecodeUsesAsNumber) && !(flags & NodeBytecodeNeedsNegZero))
    8181            out.print(comma, "PureInt");
    82         else if (!(flags & NodeUsedAsNumber))
     82        else if (!(flags & NodeBytecodeUsesAsNumber))
    8383            out.print(comma, "PureInt(w/ neg zero)");
    84         else if (!(flags & NodeNeedsNegZero))
     84        else if (!(flags & NodeBytecodeNeedsNegZero))
    8585            out.print(comma, "PureNum");
    86         if (flags & NodeUsedAsOther)
     86        if (flags & NodeBytecodeUsesAsOther)
    8787            out.print(comma, "UseAsOther");
    8888    }
     
    9494        out.print(comma, "MayNegZero");
    9595   
    96     if (flags & NodeUsedAsInt)
     96    if (flags & NodeBytecodeUsesAsInt)
    9797        out.print(comma, "UseAsInt");
    9898   
Note: See TracChangeset for help on using the changeset viewer.