⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 285167 in webkit


Ignore:
Timestamp:
Nov 2, 2021, 10:25:46 AM (5 years ago)
Author:
sbarati@apple.com
Message:

EnumeratorGetByVal for IndexedMode+OwnStructureMode doesn't always recover the property name
​https://bugs.webkit.org/show_bug.cgi?id=231321
<rdar://problem/84211697>

Reviewed by Yusuke Suzuki.

JSTests:

  • stress/enumerator-get-by-val-needs-to-recover-property-name.js: Added.

Source/JavaScriptCore:

When running an EnumeratorGetByVal in IndexedMode+OwnStructureMode, we may
go to the slow path. However, we were incorrectly going to the slow path
before recovering the actual property name. Instead, we were passing in
the integer index value to the get by val.

  • dfg/DFGSpeculativeJIT.cpp:

(JSC::DFG::SpeculativeJIT::compileEnumeratorGetByVal):

  • ftl/FTLLowerDFGToB3.cpp:

(JSC::FTL::DFG::LowerDFGToB3::compileCompareStrictEq):

Location:
trunk
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r285123 r285167  
     12021-11-02  Saam Barati  <sbarati@apple.com>
     2
     3        EnumeratorGetByVal for IndexedMode+OwnStructureMode doesn't always recover the property name
     4        https://bugs.webkit.org/show_bug.cgi?id=231321
     5        <rdar://problem/84211697>
     6
     7        Reviewed by Yusuke Suzuki.
     8
     9        * stress/enumerator-get-by-val-needs-to-recover-property-name.js: Added.
     10
    1112021-11-01  Saam Barati  <sbarati@apple.com>
    212
  • trunk/Source/JavaScriptCore/ChangeLog

    r285164 r285167  
     12021-11-02  Saam Barati  <sbarati@apple.com>
     2
     3        EnumeratorGetByVal for IndexedMode+OwnStructureMode doesn't always recover the property name
     4        https://bugs.webkit.org/show_bug.cgi?id=231321
     5        <rdar://problem/84211697>
     6
     7        Reviewed by Yusuke Suzuki.
     8
     9        When running an EnumeratorGetByVal in IndexedMode+OwnStructureMode, we may
     10        go to the slow path. However, we were incorrectly going to the slow path
     11        before recovering the actual property name. Instead, we were passing in
     12        the integer index value to the get by val.
     13
     14        * dfg/DFGSpeculativeJIT.cpp:
     15        (JSC::DFG::SpeculativeJIT::compileEnumeratorGetByVal):
     16        * ftl/FTLLowerDFGToB3.cpp:
     17        (JSC::FTL::DFG::LowerDFGToB3::compileCompareStrictEq):
     18
    1192021-11-02  Patrick Angle  <pangle@apple.com>
    220
  • trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp

    r285078 r285167  
    1587615876        GPRReg indexGPR;
    1587715877        GPRReg enumeratorGPR;
    15878         MacroAssembler::Jump badStructureSlowPath;
     15878        MacroAssembler::JumpList recoverGenericCase;
    1587915879
    1588015880        compileGetByVal(node, scopedLambda<std::tuple<JSValueRegs, DataFormat, CanUseFlush>(DataFormat)>([&] (DataFormat) {
    … …  
    1590515905
    1590615906            MacroAssembler::JumpList notFastNamedCases;
     15907            // FIXME: Maybe we should have a better way to represent IndexedMode+OwnStructureMode?
     15908            bool indexedAndOwnStructureMode = m_graph.varArgChild(node, 1).node() == m_graph.varArgChild(node, 3).node();
     15909            MacroAssembler::JumpList& genericOrRecoverCase = indexedAndOwnStructureMode ? recoverGenericCase : notFastNamedCases;
    1590715910
    1590815911            // FIXME: We shouldn't generate this code if we know base is not an object.
    … …  
    1591015913            {
    1591115914                if (!m_state.forNode(baseEdge).isType(SpecCell))
    15912                     notFastNamedCases.append(m_jit.branchIfNotCell(baseRegs));
     15915                    genericOrRecoverCase.append(m_jit.branchIfNotCell(baseRegs));
    1591315916
    1591415917                // Check the structure
    … …  
    1592115924                    MacroAssembler::Address(
    1592215925                        enumeratorGPR, JSPropertyNameEnumerator::cachedStructureIDOffset()));
    15923 
    15924                 // FIXME: Maybe we should have a better way to represent Indexed+Named?
    15925                 if (m_graph.varArgChild(node, 1).node() == m_graph.varArgChild(node, 3).node())
    15926                     badStructureSlowPath = badStructure;
    15927                 else
    15928                     notFastNamedCases.append(badStructure);
     15926                genericOrRecoverCase.append(badStructure);
    1592915927
    1593015928                // Compute the offset
    … …  
    1595815956        ASSERT(generationInfo(node).jsValueRegs() == resultRegs && generationInfo(node).registerFormat() == DataFormatJS);
    1595915957
    15960         if (badStructureSlowPath.isSet()) {
     15958        if (!recoverGenericCase.empty()) {
    1596115959            if (baseRegs.tagGPR() == InvalidGPRReg)
    15962                 addSlowPathGenerator(slowPathCall(badStructureSlowPath, this, operationEnumeratorRecoverNameAndGetByVal, resultRegs, TrustedImmPtr::weakPointer(m_graph, m_graph.globalObjectFor(node->origin.semantic)), CCallHelpers::CellValue(baseRegs.payloadGPR()), indexGPR, enumeratorGPR));
     15960                addSlowPathGenerator(slowPathCall(recoverGenericCase, this, operationEnumeratorRecoverNameAndGetByVal, resultRegs, TrustedImmPtr::weakPointer(m_graph, m_graph.globalObjectFor(node->origin.semantic)), CCallHelpers::CellValue(baseRegs.payloadGPR()), indexGPR, enumeratorGPR));
    1596315961            else
    15964                 addSlowPathGenerator(slowPathCall(badStructureSlowPath, this, operationEnumeratorRecoverNameAndGetByVal, resultRegs, TrustedImmPtr::weakPointer(m_graph, m_graph.globalObjectFor(node->origin.semantic)), baseRegs, indexGPR, enumeratorGPR));
     15962                addSlowPathGenerator(slowPathCall(recoverGenericCase, this, operationEnumeratorRecoverNameAndGetByVal, resultRegs, TrustedImmPtr::weakPointer(m_graph, m_graph.globalObjectFor(node->origin.semantic)), baseRegs, indexGPR, enumeratorGPR));
    1596515963        }
    1596615964
  • trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp

    r285078 r285167  
    1368213682        LBasicBlock genericICBlock = m_out.newBlock();
    1368313683        LBasicBlock continuation = m_out.newBlock();
     13684        LBasicBlock genericOrRecover;
     13685
     13686        // FIXME: This is not the cleanest way to say we're using IndexedMode+OwnStructureMode mode.
     13687        bool indexedAndOwnStructureMode = indexEdge.node() == propertyNameEdge.node();
     13688        if (indexedAndOwnStructureMode)
     13689            genericOrRecover = m_out.newBlock();
     13690        else
     13691            genericOrRecover = genericICBlock;
    1368413692
    1368513693        Vector<ValueFromBlock, 4> results;
    … …  
    1368913697
    1369013698        m_out.appendTo(checkIsCellBlock);
    13691         m_out.branch(isCell(base, provenType(baseEdge)), usually(checkStructureBlock), rarely(genericICBlock));
     13699        m_out.branch(isCell(base, provenType(baseEdge)), usually(checkStructureBlock), rarely(genericOrRecover));
    1369213700
    1369313701        m_out.appendTo(checkStructureBlock);
    … …  
    1370113709        LValue hasEnumeratorStructure = m_out.equal(structureID, m_out.load32(enumerator, m_heaps.JSPropertyNameEnumerator_cachedStructureID));
    1370213710
    13703         if (indexEdge.node() == propertyNameEdge.node()) {
    13704             JSGlobalObject* globalObject = m_graph.globalObjectFor(m_origin.semantic);
    13705             LBasicBlock badStructureSlowPath = m_out.newBlock();
    13706             m_out.branch(hasEnumeratorStructure, usually(checkInlineOrOutOfLineBlock), rarely(genericICBlock));
    13707 
    13708             m_out.appendTo(badStructureSlowPath);
    13709             results.append(m_out.anchor(vmCall(Int64, operationEnumeratorRecoverNameAndGetByVal, weakPointer(globalObject), base, index, enumerator)));
    13710         } else
    13711             m_out.branch(hasEnumeratorStructure, usually(checkInlineOrOutOfLineBlock), rarely(genericICBlock));
     13711        m_out.branch(hasEnumeratorStructure, usually(checkInlineOrOutOfLineBlock), rarely(genericOrRecover));
    1371213712
    1371313713        m_out.appendTo(checkInlineOrOutOfLineBlock);
    … …  
    1375313753        results.append(m_out.anchor(genericResult));
    1375413754        m_out.jump(continuation);
     13755
     13756        if (indexedAndOwnStructureMode) {
     13757            m_out.appendTo(genericOrRecover);
     13758            results.append(m_out.anchor(vmCall(Int64, operationEnumeratorRecoverNameAndGetByVal, weakPointer(m_graph.globalObjectFor(m_origin.semantic)), base, index, enumerator)));
     13759            m_out.jump(continuation);
     13760        }
    1375513761
    1375613762        m_out.appendTo(continuation);
Note: See TracChangeset for help on using the changeset viewer.