Changeset 252502 in webkit


Ignore:
Timestamp:
Nov 15, 2019 2:10:07 PM (5 years ago)
Author:
mark.lam@apple.com
Message:

Rename InPlaceAbstractState's m_foundConstant to m_shouldTryConstantFolding.
https://bugs.webkit.org/show_bug.cgi?id=204244

Reviewed by Saam Barati.

m_shouldTryConstantFolding is a more accurate description of what this flag really
means i.e. that the AbstractInterpreter thinks that we may benefit from constant
folding, and therefore, should attempt it. It doesn't always mean that it found
constants to be folded. It also doesn't guarantee that the constant folding phase
will succeed in folding any constants.

  • dfg/DFGAbstractInterpreter.h:

(JSC::DFG::AbstractInterpreter::setConstant):

  • dfg/DFGAbstractInterpreterInlines.h:

(JSC::DFG::AbstractInterpreter<AbstractStateType>::executeEffects):

  • dfg/DFGAtTailAbstractState.h:

(JSC::DFG::AtTailAbstractState::setShouldTryConstantFolding):
(JSC::DFG::AtTailAbstractState::setFoundConstants): Deleted.

  • dfg/DFGBasicBlock.cpp:

(JSC::DFG::BasicBlock::BasicBlock):

  • dfg/DFGBasicBlock.h:
  • dfg/DFGConstantFoldingPhase.cpp:

(JSC::DFG::ConstantFoldingPhase::run):

  • dfg/DFGInPlaceAbstractState.cpp:

(JSC::DFG::InPlaceAbstractState::beginBasicBlock):
(JSC::DFG::InPlaceAbstractState::initialize):
(JSC::DFG::InPlaceAbstractState::endBasicBlock):

  • dfg/DFGInPlaceAbstractState.h:

(JSC::DFG::InPlaceAbstractState::setShouldTryConstantFolding):
(JSC::DFG::InPlaceAbstractState::setFoundConstants): Deleted.

Location:
trunk/Source/JavaScriptCore
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r252479 r252502  
     12019-11-15  Mark Lam  <mark.lam@apple.com>
     2
     3        Rename InPlaceAbstractState's m_foundConstant to m_shouldTryConstantFolding.
     4        https://bugs.webkit.org/show_bug.cgi?id=204244
     5
     6        Reviewed by Saam Barati.
     7
     8        m_shouldTryConstantFolding is a more accurate description of what this flag really
     9        means i.e. that the AbstractInterpreter thinks that we may benefit from constant
     10        folding, and therefore, should attempt it.  It doesn't always mean that it found
     11        constants to be folded.  It also doesn't guarantee that the constant folding phase
     12        will succeed in folding any constants.
     13
     14        * dfg/DFGAbstractInterpreter.h:
     15        (JSC::DFG::AbstractInterpreter::setConstant):
     16        * dfg/DFGAbstractInterpreterInlines.h:
     17        (JSC::DFG::AbstractInterpreter<AbstractStateType>::executeEffects):
     18        * dfg/DFGAtTailAbstractState.h:
     19        (JSC::DFG::AtTailAbstractState::setShouldTryConstantFolding):
     20        (JSC::DFG::AtTailAbstractState::setFoundConstants): Deleted.
     21        * dfg/DFGBasicBlock.cpp:
     22        (JSC::DFG::BasicBlock::BasicBlock):
     23        * dfg/DFGBasicBlock.h:
     24        * dfg/DFGConstantFoldingPhase.cpp:
     25        (JSC::DFG::ConstantFoldingPhase::run):
     26        * dfg/DFGInPlaceAbstractState.cpp:
     27        (JSC::DFG::InPlaceAbstractState::beginBasicBlock):
     28        (JSC::DFG::InPlaceAbstractState::initialize):
     29        (JSC::DFG::InPlaceAbstractState::endBasicBlock):
     30        * dfg/DFGInPlaceAbstractState.h:
     31        (JSC::DFG::InPlaceAbstractState::setShouldTryConstantFolding):
     32        (JSC::DFG::InPlaceAbstractState::setFoundConstants): Deleted.
     33
    1342019-11-14  Saam Barati  <sbarati@apple.com>
    235
  • trunk/Source/JavaScriptCore/dfg/DFGAbstractInterpreter.h

    r248546 r252502  
    248248    {
    249249        setBuiltInConstant(node, value);
    250         m_state.setFoundConstants(true);
     250        m_state.setShouldTryConstantFolding(true);
    251251    }
    252252   
  • trunk/Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h

    r252416 r252502  
    370370        setForNode(node, forNode(node->child1()));
    371371        if (forNode(node).value())
    372             m_state.setFoundConstants(true);
     372            m_state.setShouldTryConstantFolding(true);
    373373        break;
    374374    }
     
    386386        DFG_ASSERT(m_graph, node, value.isType(typeFilterFor(variableAccessData->flushFormat())));
    387387        if (value.value())
    388             m_state.setFoundConstants(true);
     388            m_state.setShouldTryConstantFolding(true);
    389389        setForNode(node, value);
    390390        break;
     
    397397        DFG_ASSERT(m_graph, node, value.isType(typeFilterFor(data->format)));
    398398        if (value.value())
    399             m_state.setFoundConstants(true);
     399            m_state.setShouldTryConstantFolding(true);
    400400        setForNode(node, value);
    401401        break;
     
    598598        value = forNode(node->child1());
    599599        if (node->child1().useKind() == UntypedUse && !(value.m_type & ~SpecBoolean))
    600             m_state.setFoundConstants(true);
     600            m_state.setShouldTryConstantFolding(true);
    601601        if (value.m_type & SpecBoolean) {
    602602            value.merge(SpecBoolInt32);
     
    820820
    821821        if (numberOfRemovedChildren)
    822             m_state.setFoundConstants(true);
     822            m_state.setShouldTryConstantFolding(true);
    823823        setForNode(node, m_vm.stringStructure.get());
    824824        break;
     
    12721272        SpeculatedType typeMaybeNormalized = (SpecFullNumber & ~SpecInt32Only);
    12731273        if (!(forNode(node->child1()).m_type & typeMaybeNormalized)) {
    1274             m_state.setFoundConstants(true);
     1274            m_state.setShouldTryConstantFolding(true);
    12751275            forNode(node) = forNode(node->child1());
    12761276            break;
     
    19041904
    19051905            if (isNonStringCellConstant(left) || isNonStringCellConstant(right)) {
    1906                 m_state.setFoundConstants(true);
     1906                m_state.setShouldTryConstantFolding(true);
    19071907                setNonCellTypeForNode(node, SpecBoolean);
    19081908                break;
     
    23352335                        setForNode(node, m_state.operand(
    23362336                            virtualRegisterForArgument(argumentIndex + 1) + inlineCallFrame->stackOffset));
    2337                         m_state.setFoundConstants(true);
     2337                        m_state.setShouldTryConstantFolding(true);
    23382338                        break;
    23392339                    }
     
    23412341                    if (argumentIndex < m_state.numberOfArguments() - 1) {
    23422342                        setForNode(node, m_state.argument(argumentIndex + 1));
    2343                         m_state.setFoundConstants(true);
     2343                        m_state.setShouldTryConstantFolding(true);
    23442344                        break;
    23452345                    }
     
    23622362           
    23632363            if (result.value())
    2364                 m_state.setFoundConstants(true);
     2364                m_state.setShouldTryConstantFolding(true);
    23652365           
    23662366            setForNode(node, result);
     
    24802480       
    24812481        if (!(forNode(node->child1()).m_type & ~(SpecFullNumber | SpecBoolean | SpecString | SpecSymbol | SpecBigInt))) {
    2482             m_state.setFoundConstants(true);
     2482            m_state.setShouldTryConstantFolding(true);
    24832483            didFoldClobberWorld();
    24842484            setForNode(node, forNode(node->child1()));
     
    25032503
    25042504        if (!(forNode(node->child1()).m_type & ~SpecBytecodeNumber)) {
    2505             m_state.setFoundConstants(true);
     2505            m_state.setShouldTryConstantFolding(true);
    25062506            didFoldClobberWorld();
    25072507            setForNode(node, forNode(node->child1()));
     
    25412541            int32_t radix = radixValue.asInt32();
    25422542            if (2 <= radix && radix <= 36) {
    2543                 m_state.setFoundConstants(true);
     2543                m_state.setShouldTryConstantFolding(true);
    25442544                didFoldClobberWorld();
    25452545                setForNode(node, m_graph.m_vm.stringStructure.get());
     
    26422642        switch (result) {
    26432643        case ToThisResult::Identity:
    2644             m_state.setFoundConstants(true);
     2644            m_state.setShouldTryConstantFolding(true);
    26452645            destination = source;
    26462646            break;
     
    26492649            break;
    26502650        case ToThisResult::GlobalThis:
    2651             m_state.setFoundConstants(true);
     2651            m_state.setShouldTryConstantFolding(true);
    26522652            destination.setType(m_graph, SpecObject);
    26532653            break;
     
    26722672                            m_graph.freeze(rareData);
    26732673                            m_graph.watchpoints().addLazily(rareData->allocationProfileWatchpointSet());
    2674                             m_state.setFoundConstants(true);
     2674                            m_state.setShouldTryConstantFolding(true);
    26752675                            didFoldClobberWorld();
    26762676                            setForNode(node, structure);
     
    26902690        if (JSValue base = forNode(node->child1()).m_value) {
    26912691            if (base == (node->isInternalPromise() ? globalObject->internalPromiseConstructor() : globalObject->promiseConstructor())) {
    2692                 m_state.setFoundConstants(true);
     2692                m_state.setShouldTryConstantFolding(true);
    26932693                didFoldClobberWorld();
    26942694                setForNode(node, node->isInternalPromise() ? globalObject->internalPromiseStructure() : globalObject->promiseStructure());
     
    27052705                            m_graph.freeze(rareData);
    27062706                            m_graph.watchpoints().addLazily(rareData->allocationProfileWatchpointSet());
    2707                             m_state.setFoundConstants(true);
     2707                            m_state.setShouldTryConstantFolding(true);
    27082708                            didFoldClobberWorld();
    27092709                            setForNode(node, structure);
     
    27342734                                m_graph.freeze(rareData);
    27352735                                m_graph.watchpoints().addLazily(rareData->allocationProfileWatchpointSet());
    2736                                 m_state.setFoundConstants(true);
     2736                                m_state.setShouldTryConstantFolding(true);
    27372737                                didFoldClobberWorld();
    27382738                                setForNode(node, structure);
     
    27912791           
    27922792            if (structure) {
    2793                 m_state.setFoundConstants(true);
     2793                m_state.setShouldTryConstantFolding(true);
    27942794                if (node->child1().useKind() == UntypedUse)
    27952795                    didFoldClobberWorld();
     
    28122812                    if (!!rareData->cachedOwnKeysConcurrently()) {
    28132813                        if (m_graph.isWatchingHavingABadTimeWatchpoint(node)) {
    2814                             m_state.setFoundConstants(true);
     2814                            m_state.setShouldTryConstantFolding(true);
    28152815                            didFoldClobberWorld();
    28162816                            setTypeForNode(node, SpecArray);
     
    28332833
    28342834        if (!(source.m_type & ~SpecObject)) {
    2835             m_state.setFoundConstants(true);
     2835            m_state.setShouldTryConstantFolding(true);
    28362836            if (node->op() == ToObject)
    28372837                didFoldClobberWorld();
     
    30923092                }
    30933093           
    3094                 m_state.setFoundConstants(true);
     3094                m_state.setShouldTryConstantFolding(true);
    30953095                didFoldClobberWorld();
    30963096                forNode(node) = result;
     
    31453145       
    31463146        if (value.m_structure.isSubsetOf(set))
    3147             m_state.setFoundConstants(true);
     3147            m_state.setShouldTryConstantFolding(true);
    31483148
    31493149        SpeculatedType admittedTypes = SpecNone;
     
    31703170        bool mayBeEmpty = value.m_type & SpecEmpty;
    31713171        if (!mayBeEmpty)
    3172             m_state.setFoundConstants(true);
     3172            m_state.setShouldTryConstantFolding(true);
    31733173
    31743174        SpeculatedType admittedTypes = mayBeEmpty ? SpecEmpty : SpecNone;
     
    31873187            if (Structure* structure = jsDynamicCast<Structure*>(m_vm, value.value())) {
    31883188                if (set.contains(m_graph.registerStructure(structure))) {
    3189                     m_state.setFoundConstants(true);
     3189                    m_state.setShouldTryConstantFolding(true);
    31903190                    break;
    31913191                }
     
    32073207                });
    32083208            if (allGood) {
    3209                 m_state.setFoundConstants(true);
     3209                m_state.setShouldTryConstantFolding(true);
    32103210                break;
    32113211            }
     
    32253225            if (forNode(node->child1()).m_structure.onlyStructure() == node->transition()->next) {
    32263226                didFoldClobberStructures();
    3227                 m_state.setFoundConstants(true);
     3227                m_state.setShouldTryConstantFolding(true);
    32283228            } else {
    32293229                observeTransition(
     
    32503250        if (constant) {
    32513251            if (constant.isCell() && constant.asCell()->inherits(m_vm, node->classInfo())) {
    3252                 m_state.setFoundConstants(true);
     3252                m_state.setShouldTryConstantFolding(true);
    32533253                ASSERT(constant);
    32543254                break;
     
    32593259
    32603260        if (value.m_structure.isSubClassOf(node->classInfo()))
    3261             m_state.setFoundConstants(true);
     3261            m_state.setShouldTryConstantFolding(true);
    32623262
    32633263        filterClassInfo(value, node->classInfo());
     
    32843284    case CheckArray: {
    32853285        if (node->arrayMode().alreadyChecked(m_graph, node, forNode(node->child1()))) {
    3286             m_state.setFoundConstants(true);
     3286            m_state.setShouldTryConstantFolding(true);
    32873287            break;
    32883288        }
     
    33443344        if (node->arrayMode().alreadyChecked(m_graph, node, forNode(node->child1()))) {
    33453345            didFoldClobberStructures();
    3346             m_state.setFoundConstants(true);
     3346            m_state.setShouldTryConstantFolding(true);
    33473347            break;
    33483348        }
     
    33553355        AbstractValue& value = forNode(node->child1());
    33563356        if (value.m_structure.isSubsetOf(RegisteredStructureSet(node->structure())))
    3357             m_state.setFoundConstants(true);
     3357            m_state.setShouldTryConstantFolding(true);
    33583358        clobberStructures();
    33593359       
     
    33923392            forNode(node->child1()).m_value, node->arrayMode());
    33933393        if (view)
    3394             m_state.setFoundConstants(true);
     3394            m_state.setShouldTryConstantFolding(true);
    33953395        clearForNode(node);
    33963396        break;
     
    34833483        setForNode(node, value);
    34843484        if (value.m_value)
    3485             m_state.setFoundConstants(true);
     3485            m_state.setShouldTryConstantFolding(true);
    34863486        break;
    34873487    }
     
    35103510        // realize it. This is the case here.
    35113511       
    3512         // Ordinarily you have to be careful with calling setFoundConstants()
     3512        // Ordinarily you have to be careful with calling setShouldTryConstantFolding()
    35133513        // because of the effect on compile times, but this node is FTL-only.
    3514         m_state.setFoundConstants(true);
     3514        m_state.setShouldTryConstantFolding(true);
    35153515       
    35163516        AbstractValue base = forNode(node->child1());
     
    35563556        TransitionVector transitions;
    35573557       
    3558         // Ordinarily you have to be careful with calling setFoundConstants()
     3558        // Ordinarily you have to be careful with calling setShouldTryConstantFolding()
    35593559        // because of the effect on compile times, but this node is FTL-only.
    3560         m_state.setFoundConstants(true);
     3560        m_state.setShouldTryConstantFolding(true);
    35613561       
    35623562        AbstractValue base = forNode(node->child1());
     
    36203620        JSValue value = forNode(node->child1()).value();
    36213621        if (value == node->cellOperand()->value()) {
    3622             m_state.setFoundConstants(true);
     3622            m_state.setShouldTryConstantFolding(true);
    36233623            ASSERT(value);
    36243624            break;
     
    36323632        AbstractValue& value = forNode(node->child1());
    36333633        if (!(value.m_type & SpecEmpty)) {
    3634             m_state.setFoundConstants(true);
     3634            m_state.setShouldTryConstantFolding(true);
    36353635            break;
    36363636        }
     
    36493649            ASSERT(childConstant.isString());
    36503650            if (asString(childConstant)->tryGetValueImpl() == uid) {
    3651                 m_state.setFoundConstants(true);
     3651                m_state.setShouldTryConstantFolding(true);
    36523652                break;
    36533653            }
     
    36623662        JSValue right = forNode(node->child2()).value();
    36633663        if (left && right && left.isInt32() && right.isInt32() && static_cast<uint32_t>(left.asInt32()) < static_cast<uint32_t>(right.asInt32()))
    3664             m_state.setFoundConstants(true);
     3664            m_state.setShouldTryConstantFolding(true);
    36653665
    36663666        // We claim we result in Int32. It's not really important what our result is (though we
     
    37043704
    37053705                if (status.numVariants() == 1 || m_graph.m_plan.isFTL())
    3706                     m_state.setFoundConstants(true);
     3706                    m_state.setShouldTryConstantFolding(true);
    37073707               
    37083708                didFoldClobberWorld();
     
    37533753                const StringImpl* impl = string->tryGetValueImpl();
    37543754                if (impl && impl->isAtom())
    3755                     m_state.setFoundConstants(true);
     3755                    m_state.setShouldTryConstantFolding(true);
    37563756            }
    37573757        }
     
    38783878            RegisteredStructure structure = variant.structure;
    38793879            if (!base.contains(structure)) {
    3880                 m_state.setFoundConstants(true);
     3880                m_state.setShouldTryConstantFolding(true);
    38813881                continue;
    38823882            }
     
    39103910        // constant, in which case we'd like to know.
    39113911        if (forNode(node).m_value)
    3912             m_state.setFoundConstants(true);
     3912            m_state.setShouldTryConstantFolding(true);
    39133913        break;
    39143914       
     
    39883988        if (bits == ImplementsDefaultHasInstance) {
    39893989            if (abstractValue.m_type == SpecFunctionWithDefaultHasInstance) {
    3990                 m_state.setFoundConstants(true);
     3990                m_state.setShouldTryConstantFolding(true);
    39913991                break;
    39923992            }
     
    39993999                // object's lifetime.
    40004000                if ((value.asCell()->inlineTypeFlags() & bits) == bits) {
    4001                     m_state.setFoundConstants(true);
     4001                    m_state.setShouldTryConstantFolding(true);
    40024002                    break;
    40034003                }
     
    40114011            });
    40124012            if (ok) {
    4013                 m_state.setFoundConstants(true);
     4013                m_state.setShouldTryConstantFolding(true);
    40144014                break;
    40154015            }
     
    40304030            if (radix.isNumber()
    40314031                && (radix.asNumber() == 0 || radix.asNumber() == 10)) {
    4032                 m_state.setFoundConstants(true);
     4032                m_state.setShouldTryConstantFolding(true);
    40334033                if (node->child1().useKind() == UntypedUse)
    40344034                    didFoldClobberWorld();
     
    40624062                return;
    40634063            if (edge.isProved() || edge.willNotHaveCheck())
    4064                 m_state.setFoundConstants(true);
     4064                m_state.setShouldTryConstantFolding(true);
    40654065        });
    40664066        break;
  • trunk/Source/JavaScriptCore/dfg/DFGAtTailAbstractState.h

    r231607 r252502  
    166166    void setIsValid(bool isValid) { m_block->cfaDidFinish = isValid; }
    167167    void setBranchDirection(BranchDirection) { }
    168     void setFoundConstants(bool) { }
     168    void setShouldTryConstantFolding(bool) { }
    169169
    170170    void trustEdgeProofs() { m_trustEdgeProofs = true; }
  • trunk/Source/JavaScriptCore/dfg/DFGBasicBlock.cpp

    r251468 r252502  
    4141    , cfaHasVisited(false)
    4242    , cfaShouldRevisit(false)
    43     , cfaFoundConstants(false)
    4443    , cfaDidFinish(true)
    4544    , intersectionOfCFAHasVisited(true)
  • trunk/Source/JavaScriptCore/dfg/DFGBasicBlock.h

    r251468 r252502  
    188188    bool cfaHasVisited;
    189189    bool cfaShouldRevisit;
    190     bool cfaFoundConstants;
     190    bool cfaThinksShouldTryConstantFolding { false };
    191191    bool cfaDidFinish;
    192192    bool intersectionOfCFAHasVisited;
  • trunk/Source/JavaScriptCore/dfg/DFGConstantFoldingPhase.cpp

    r250630 r252502  
    5959
    6060        for (BasicBlock* block : m_graph.blocksInNaturalOrder()) {
    61             if (block->cfaFoundConstants)
     61            if (block->cfaThinksShouldTryConstantFolding)
    6262                changed |= foldConstants(block);
    6363        }
  • trunk/Source/JavaScriptCore/dfg/DFGInPlaceAbstractState.cpp

    r250005 r252502  
    8585    basicBlock->cfaHasVisited = true;
    8686    m_isValid = true;
    87     m_foundConstants = false;
     87    m_shouldTryConstantFolding = false;
    8888    m_branchDirection = InvalidBranchDirection;
    8989    m_structureClobberState = basicBlock->cfaStructureClobberStateAtHead;
     
    115115        entrypoint->cfaShouldRevisit = true;
    116116        entrypoint->cfaHasVisited = false;
    117         entrypoint->cfaFoundConstants = false;
     117        entrypoint->cfaThinksShouldTryConstantFolding = false;
    118118        entrypoint->cfaStructureClobberStateAtHead = StructuresAreWatched;
    119119        entrypoint->cfaStructureClobberStateAtTail = StructuresAreWatched;
     
    173173        block->cfaShouldRevisit = false;
    174174        block->cfaHasVisited = false;
    175         block->cfaFoundConstants = false;
     175        block->cfaThinksShouldTryConstantFolding = false;
    176176        block->cfaStructureClobberStateAtHead = StructuresAreWatched;
    177177        block->cfaStructureClobberStateAtTail = StructuresAreWatched;
     
    203203    BasicBlock* block = m_block; // Save the block for successor merging.
    204204   
    205     block->cfaFoundConstants = m_foundConstants;
     205    block->cfaThinksShouldTryConstantFolding = m_shouldTryConstantFolding;
    206206    block->cfaDidFinish = m_isValid;
    207207    block->cfaBranchDirection = m_branchDirection;
  • trunk/Source/JavaScriptCore/dfg/DFGInPlaceAbstractState.h

    r231660 r252502  
    258258    // https://bugs.webkit.org/show_bug.cgi?id=133947
    259259    // So, we should probably keep this method.
    260     void setFoundConstants(bool foundConstants) { m_foundConstants = foundConstants; }
     260    void setShouldTryConstantFolding(bool tryConstantFolding) { m_shouldTryConstantFolding = tryConstantFolding; }
    261261
    262262    void setProofStatus(Edge& edge, ProofStatus status)
     
    283283    FastBitVector m_activeVariables;
    284284    BasicBlock* m_block;
    285    
    286     bool m_foundConstants;
    287    
     285
     286    bool m_shouldTryConstantFolding;
     287
    288288    bool m_isValid;
    289289    AbstractInterpreterClobberState m_clobberState;
Note: See TracChangeset for help on using the changeset viewer.