Ignore:
Timestamp:
Feb 25, 2013, 12:23:55 PM (12 years ago)
Author:
[email protected]
Message:

The DFG special case checks for isCreatedThisArgument are fragile
https://bugs.webkit.org/show_bug.cgi?id=110535

Reviewed by Oliver Hunt.

There may be many situations in which we want to force a variable to never be
unboxed. Capturing is one such case, and the created this argument is another.
Previously all code that dealt with this issue had to query both scenarios.

Now DFG::VariableAccessData knows these things. You just have to ask
VariableAccessData for whether a variable should be unboxed. Anyone wishing to
force a variable to never be unboxed just tells VariableAccessData.

  • dfg/DFGAbstractState.cpp:

(JSC::DFG::AbstractState::initialize):

  • dfg/DFGByteCodeParser.cpp:

(JSC::DFG::ByteCodeParser::parseBlock):
(DFG):

  • dfg/DFGCFGSimplificationPhase.cpp:

(CFGSimplificationPhase):

  • dfg/DFGFixupPhase.cpp:

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

  • dfg/DFGGraph.h:

(Graph):

  • dfg/DFGPredictionPropagationPhase.cpp:

(JSC::DFG::PredictionPropagationPhase::doRoundOfDoubleVoting):

  • dfg/DFGSpeculativeJIT.cpp:

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

  • dfg/DFGSpeculativeJIT32_64.cpp:

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

  • dfg/DFGSpeculativeJIT64.cpp:

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

  • dfg/DFGUnificationPhase.cpp:

(JSC::DFG::UnificationPhase::run):

  • dfg/DFGVariableAccessData.h:

(JSC::DFG::VariableAccessData::VariableAccessData):
(JSC::DFG::VariableAccessData::mergeIsCaptured):
(JSC::DFG::VariableAccessData::mergeShouldNeverUnbox):
(VariableAccessData):
(JSC::DFG::VariableAccessData::shouldNeverUnbox):
(JSC::DFG::VariableAccessData::shouldUnboxIfPossible):
(JSC::DFG::VariableAccessData::shouldUseDoubleFormat):
(JSC::DFG::VariableAccessData::tallyVotesForShouldUseDoubleFormat):

File:
1 edited

Legend:

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

    r142544 r143955  
    4747        , m_argumentAwarePrediction(SpecNone)
    4848        , m_flags(0)
    49         , m_doubleFormatState(EmptyDoubleFormatState)
    5049        , m_isCaptured(false)
     50        , m_shouldNeverUnbox(false)
    5151        , m_isArgumentsAlias(false)
    5252        , m_structureCheckHoistingFailed(false)
     53        , m_doubleFormatState(EmptyDoubleFormatState)
    5354    {
    5455        clearVotes();
     
    6061        , m_argumentAwarePrediction(SpecNone)
    6162        , m_flags(0)
    62         , m_doubleFormatState(EmptyDoubleFormatState)
    6363        , m_isCaptured(isCaptured)
     64        , m_shouldNeverUnbox(isCaptured)
    6465        , m_isArgumentsAlias(false)
    6566        , m_structureCheckHoistingFailed(false)
     67        , m_doubleFormatState(EmptyDoubleFormatState)
    6668    {
    6769        clearVotes();
     
    8183    bool mergeIsCaptured(bool isCaptured)
    8284    {
     85        m_shouldNeverUnbox |= isCaptured;
    8386        bool newIsCaptured = m_isCaptured | isCaptured;
    8487        if (newIsCaptured == m_isCaptured)
     
    9194    {
    9295        return m_isCaptured;
     96    }
     97   
     98    bool mergeShouldNeverUnbox(bool shouldNeverUnbox)
     99    {
     100        bool newShouldNeverUnbox = m_shouldNeverUnbox | shouldNeverUnbox;
     101        if (newShouldNeverUnbox == m_shouldNeverUnbox)
     102            return false;
     103        m_shouldNeverUnbox = newShouldNeverUnbox;
     104        return true;
     105    }
     106   
     107    // Returns true if it would be unsound to store the value in an unboxed fashion.
     108    // If this returns false, it simply means that it is sound to unbox; it doesn't
     109    // mean that we have actually done so.
     110    bool shouldNeverUnbox()
     111    {
     112        ASSERT(!(m_isCaptured && !m_shouldNeverUnbox));
     113        return m_shouldNeverUnbox;
     114    }
     115   
     116    // Returns true if we should be unboxing the value provided that the predictions
     117    // and double format vote say so. This may return false even if shouldNeverUnbox()
     118    // returns false, since this incorporates heuristics of profitability.
     119    bool shouldUnboxIfPossible()
     120    {
     121        return !shouldNeverUnbox();
    93122    }
    94123   
     
    211240    {
    212241        ASSERT(isRoot());
    213         return m_doubleFormatState == UsingDoubleFormat;
     242        bool result = m_doubleFormatState == UsingDoubleFormat;
     243        ASSERT(!(result && shouldNeverUnbox()));
     244        ASSERT(!(result && isCaptured()));
     245        return result;
    214246    }
    215247   
     
    217249    {
    218250        ASSERT(isRoot());
     251       
     252        if (operandIsArgument(local()) || shouldNeverUnbox())
     253            return DFG::mergeDoubleFormatState(m_doubleFormatState, NotUsingDoubleFormat);
    219254       
    220255        if (m_doubleFormatState == CantUseDoubleFormat)
     
    271306    NodeFlags m_flags;
    272307   
     308    bool m_isCaptured;
     309    bool m_shouldNeverUnbox;
     310    bool m_isArgumentsAlias;
     311    bool m_structureCheckHoistingFailed;
     312
    273313    float m_votes[2]; // Used primarily for double voting but may be reused for other purposes.
    274314    DoubleFormatState m_doubleFormatState;
    275    
    276     bool m_isCaptured;
    277     bool m_isArgumentsAlias;
    278     bool m_structureCheckHoistingFailed;
    279315};
    280316
Note: See TracChangeset for help on using the changeset viewer.