Ignore:
Timestamp:
Feb 26, 2013, 5:45:28 PM (12 years ago)
Author:
[email protected]
Message:

The DFG backend's and OSR's decision to unbox a variable should be based on whether it's used in a typed context
https://bugs.webkit.org/show_bug.cgi?id=110433

Reviewed by Oliver Hunt and Mark Hahnenberg.

This introduces the equivalent of a liveness analysis, except for type checking.
A variable is said to be "profitable for unboxing" (i.e. live at a type check)
if there exists a type check on a GetLocal of that variable, and the type check
is consistent with the variable's prediction. Variables that are not profitable
for unboxing aren't unboxed. Previously they would have been.

This is a slight speed-up on some things but mostly neutral.

  • dfg/DFGArgumentPosition.h:

(JSC::DFG::ArgumentPosition::ArgumentPosition):
(JSC::DFG::ArgumentPosition::mergeShouldNeverUnbox):
(JSC::DFG::ArgumentPosition::mergeArgumentPredictionAwareness):
(JSC::DFG::ArgumentPosition::mergeArgumentUnboxingAwareness):
(ArgumentPosition):
(JSC::DFG::ArgumentPosition::isProfitableToUnbox):
(JSC::DFG::ArgumentPosition::shouldUseDoubleFormat):

  • dfg/DFGCommon.h:

(JSC::DFG::checkAndSet):
(DFG):

  • dfg/DFGFixupPhase.cpp:

(JSC::DFG::FixupPhase::run):
(JSC::DFG::FixupPhase::fixupNode):
(JSC::DFG::FixupPhase::fixupSetLocalsInBlock):
(FixupPhase):
(JSC::DFG::FixupPhase::alwaysUnboxSimplePrimitives):
(JSC::DFG::FixupPhase::setUseKindAndUnboxIfProfitable):

  • dfg/DFGPredictionPropagationPhase.cpp:

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

  • dfg/DFGSpeculativeJIT.cpp:

(JSC::DFG::SpeculativeJIT::checkArgumentTypes):

  • dfg/DFGVariableAccessData.h:

(JSC::DFG::VariableAccessData::VariableAccessData):
(JSC::DFG::VariableAccessData::mergeIsCaptured):
(JSC::DFG::VariableAccessData::mergeIsProfitableToUnbox):
(VariableAccessData):
(JSC::DFG::VariableAccessData::isProfitableToUnbox):
(JSC::DFG::VariableAccessData::shouldUnboxIfPossible):
(JSC::DFG::VariableAccessData::mergeStructureCheckHoistingFailed):
(JSC::DFG::VariableAccessData::mergeIsArgumentsAlias):
(JSC::DFG::VariableAccessData::shouldUseDoubleFormat):
(JSC::DFG::VariableAccessData::mergeFlags):

File:
1 edited

Legend:

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

    r143955 r144131  
    11/*
    2  * Copyright (C) 2011, 2012 Apple Inc. All rights reserved.
     2 * Copyright (C) 2011, 2012, 2013 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    5151        , m_isArgumentsAlias(false)
    5252        , m_structureCheckHoistingFailed(false)
     53        , m_isProfitableToUnbox(false)
    5354        , m_doubleFormatState(EmptyDoubleFormatState)
    5455    {
     
    6566        , m_isArgumentsAlias(false)
    6667        , m_structureCheckHoistingFailed(false)
     68        , m_isProfitableToUnbox(false)
    6769        , m_doubleFormatState(EmptyDoubleFormatState)
    6870    {
     
    8385    bool mergeIsCaptured(bool isCaptured)
    8486    {
    85         m_shouldNeverUnbox |= isCaptured;
    86         bool newIsCaptured = m_isCaptured | isCaptured;
    87         if (newIsCaptured == m_isCaptured)
    88             return false;
    89         m_isCaptured = newIsCaptured;
    90         return true;
     87        return checkAndSet(m_shouldNeverUnbox, m_shouldNeverUnbox | isCaptured)
     88            | checkAndSet(m_isCaptured, m_isCaptured | isCaptured);
    9189    }
    9290   
     
    9492    {
    9593        return m_isCaptured;
     94    }
     95   
     96    bool mergeIsProfitableToUnbox(bool isProfitableToUnbox)
     97    {
     98        return checkAndSet(m_isProfitableToUnbox, m_isProfitableToUnbox | isProfitableToUnbox);
     99    }
     100   
     101    bool isProfitableToUnbox()
     102    {
     103        return m_isProfitableToUnbox;
    96104    }
    97105   
     
    119127    bool shouldUnboxIfPossible()
    120128    {
    121         return !shouldNeverUnbox();
    122     }
    123    
     129        return !shouldNeverUnbox() && isProfitableToUnbox();
     130    }
     131
    124132    bool mergeStructureCheckHoistingFailed(bool failed)
    125133    {
    126         bool newFailed = m_structureCheckHoistingFailed | failed;
    127         if (newFailed == m_structureCheckHoistingFailed)
    128             return false;
    129         m_structureCheckHoistingFailed = newFailed;
    130         return true;
     134        return checkAndSet(m_structureCheckHoistingFailed, m_structureCheckHoistingFailed | failed);
    131135    }
    132136   
     
    138142    bool mergeIsArgumentsAlias(bool isArgumentsAlias)
    139143    {
    140         bool newIsArgumentsAlias = m_isArgumentsAlias | isArgumentsAlias;
    141         if (newIsArgumentsAlias == m_isArgumentsAlias)
    142             return false;
    143         m_isArgumentsAlias = newIsArgumentsAlias;
    144         return true;
     144        return checkAndSet(m_isArgumentsAlias, m_isArgumentsAlias | isArgumentsAlias);
    145145    }
    146146   
     
    240240    {
    241241        ASSERT(isRoot());
    242         bool result = m_doubleFormatState == UsingDoubleFormat;
    243         ASSERT(!(result && shouldNeverUnbox()));
    244         ASSERT(!(result && isCaptured()));
    245         return result;
     242        bool doubleState = m_doubleFormatState == UsingDoubleFormat;
     243        ASSERT(!(doubleState && shouldNeverUnbox()));
     244        ASSERT(!(doubleState && isCaptured()));
     245        return doubleState && isProfitableToUnbox();
    246246    }
    247247   
     
    288288    bool mergeFlags(NodeFlags newFlags)
    289289    {
    290         newFlags |= m_flags;
    291         if (newFlags == m_flags)
    292             return false;
    293         m_flags = newFlags;
    294         return true;
     290        return checkAndSet(m_flags, m_flags | newFlags);
    295291    }
    296292   
     
    305301    SpeculatedType m_argumentAwarePrediction;
    306302    NodeFlags m_flags;
    307    
     303
    308304    bool m_isCaptured;
    309305    bool m_shouldNeverUnbox;
    310306    bool m_isArgumentsAlias;
    311307    bool m_structureCheckHoistingFailed;
     308    bool m_isProfitableToUnbox;
    312309
    313310    float m_votes[2]; // Used primarily for double voting but may be reused for other purposes.
Note: See TracChangeset for help on using the changeset viewer.