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

Changeset 281029 in webkit


Ignore:
Timestamp:
Aug 13, 2021, 12:29:04 PM (5 years ago)
Author:
keith_miller@apple.com
Message:

EnumeratorNextUpdatePropertyName always needs to be able to handle IndexedMode
https://bugs.webkit.org/show_bug.cgi?id=229087

Reviewed by Filip Pizlo.

JSTests:

  • stress/for-in-own-structure-and-generic-with-late-add-indexed.js: Added.

(test):
(Foo):

Source/JavaScriptCore:

Right now, this operation incorrectly assumes that EnumeratorNextUpdateIndexAndMode will guarantee
the mode matches the seen mode set. But no speculation is guaranteed and adding such a guarantee
would require adding checkpoints, which is likely not worth it. Instead, this patch just makes
sure we always handle the allocation for IndexedMode.

  • dfg/DFGSpeculativeJIT.cpp:

(JSC::DFG::SpeculativeJIT::compileEnumeratorNextUpdatePropertyName):

  • ftl/FTLLowerDFGToB3.cpp:

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

Location:
trunk
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r280886 r281029  
     12021-08-13  Keith Miller  <keith_miller@apple.com>
     2
     3        EnumeratorNextUpdatePropertyName always needs to be able to handle IndexedMode
     4        https://bugs.webkit.org/show_bug.cgi?id=229087
     5
     6        Reviewed by Filip Pizlo.
     7
     8        * stress/for-in-own-structure-and-generic-with-late-add-indexed.js: Added.
     9        (test):
     10        (Foo):
     11
    1122021-08-11  Yusuke Suzuki  <ysuzuki@apple.com>
    213
  • trunk/Source/JavaScriptCore/ChangeLog

    r280996 r281029  
     12021-08-13  Keith Miller  <keith_miller@apple.com>
     2
     3        EnumeratorNextUpdatePropertyName always needs to be able to handle IndexedMode
     4        https://bugs.webkit.org/show_bug.cgi?id=229087
     5
     6        Reviewed by Filip Pizlo.
     7
     8        Right now, this operation incorrectly assumes that EnumeratorNextUpdateIndexAndMode will guarantee
     9        the mode matches the seen mode set. But no speculation is guaranteed and adding such a guarantee
     10        would require adding checkpoints, which is likely not worth it. Instead, this patch just makes
     11        sure we always handle the allocation for IndexedMode.
     12
     13        * dfg/DFGSpeculativeJIT.cpp:
     14        (JSC::DFG::SpeculativeJIT::compileEnumeratorNextUpdatePropertyName):
     15        * ftl/FTLLowerDFGToB3.cpp:
     16        (JSC::FTL::DFG::LowerDFGToB3::compileCompareStrictEq):
     17
    1182021-08-12  Mark Lam  <mark.lam@apple.com>
    219
  • trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp

    r280760 r281029  
    1359213592    MacroAssembler::Jump operationCall;
    1359313593
    13594     bool needsOperation = seenModes.contains(JSPropertyNameEnumerator::IndexedMode);
    13595 
    13596     // Make sure we flush on all code paths if we could call the operation.
    13597     if (needsOperation)
    13598         flushRegisters();
     13594    // Make sure we flush on all code paths if we will call the operation.
     13595    // Note: we can't omit the operation because we are not guaranteed EnumeratorUpdateIndexAndMode will speculate on the mode.
     13596    flushRegisters();
    1359913597
    1360013598    if (seenModes.containsAny({ JSPropertyNameEnumerator::OwnStructureMode, JSPropertyNameEnumerator::GenericMode })) {
    13601 
    13602         if (needsOperation)
    13603             operationCall = m_jit.branchTest32(MacroAssembler::NonZero, mode, TrustedImm32(JSPropertyNameEnumerator::IndexedMode));
     13599        operationCall = m_jit.branchTest32(MacroAssembler::NonZero, mode, TrustedImm32(JSPropertyNameEnumerator::IndexedMode));
    1360413600
    1360513601        auto outOfBounds = m_jit.branch32(MacroAssembler::AboveOrEqual, index, MacroAssembler::Address(enumerator, JSPropertyNameEnumerator::endGenericPropertyIndexOffset()));
     
    1361413610        outOfBounds.link(&m_jit);
    1361513611        m_jit.moveTrustedValue(jsNull(), resultRegs);
    13616     }
    13617 
    13618     if (needsOperation) {
    13619         if (operationCall.isSet()) {
    13620             doneCases.append(m_jit.jump());
    13621             operationCall.link(&m_jit);
    13622         }
    13623         callOperation(operationEnumeratorNextUpdatePropertyName, resultRegs, TrustedImmPtr::weakPointer(m_graph, m_graph.globalObjectFor(node->origin.semantic)), index, mode, enumerator);
    13624         m_jit.exceptionCheck();
    13625     }
     13612        doneCases.append(m_jit.jump());
     13613        operationCall.link(&m_jit);
     13614    }
     13615
     13616    callOperation(operationEnumeratorNextUpdatePropertyName, resultRegs, TrustedImmPtr::weakPointer(m_graph, m_graph.globalObjectFor(node->origin.semantic)), index, mode, enumerator);
     13617    m_jit.exceptionCheck();
    1362613618
    1362713619    doneCases.link(&m_jit);
  • trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp

    r280809 r281029  
    1313913139
    1314013140        if (seenModes.containsAny({ JSPropertyNameEnumerator::OwnStructureMode, JSPropertyNameEnumerator::GenericMode })) {
    13141             LBasicBlock checkIndex = nullptr;
     13141            LBasicBlock checkIndex = m_out.newBlock();
    1314213142            LBasicBlock outOfBoundsBlock = m_out.newBlock();
    1314313143            LBasicBlock loadPropertyNameBlock = m_out.newBlock();
    1314413144            continuation = m_out.newBlock();
    13145 
    13146             if (seenModes.contains(JSPropertyNameEnumerator::IndexedMode)) {
    13147                 checkIndex = m_out.newBlock();
    13148                 operationBlock = m_out.newBlock();
    13149                 m_out.branch(m_out.testIsZero32(mode, m_out.constInt32(JSPropertyNameEnumerator::IndexedMode)), unsure(checkIndex), unsure(operationBlock));
    13150             }
    13151 
     13145            operationBlock = m_out.newBlock();
     13146
     13147            m_out.branch(m_out.testIsZero32(mode, m_out.constInt32(JSPropertyNameEnumerator::IndexedMode)), unsure(checkIndex), unsure(operationBlock));
    1315213148            {
    13153                 if (checkIndex)
    13154                     m_out.appendTo(checkIndex);
     13149                m_out.appendTo(checkIndex);
    1315513150                LValue outOfBounds = m_out.aboveOrEqual(index, m_out.load32(enumerator, m_heaps.JSPropertyNameEnumerator_endGenericPropertyIndex));
    1315613151                m_out.branch(outOfBounds, unsure(outOfBoundsBlock), unsure(loadPropertyNameBlock));
     
    1317113166        }
    1317213167
    13173         if (seenModes.contains(JSPropertyNameEnumerator::IndexedMode)) {
    13174             if (operationBlock)
    13175                 m_out.appendTo(operationBlock);
    13176             results.append(m_out.anchor(vmCall(Int64, operationEnumeratorNextUpdatePropertyName, weakPointer(globalObject), index, mode, enumerator)));
    13177             if (continuation)
    13178                 m_out.jump(continuation);
    13179         }
    13180 
    13181         if (continuation)
     13168        if (operationBlock)
     13169            m_out.appendTo(operationBlock);
     13170        // Note: We can't omit the operation because we have no guarantee that the mode will match what we profiled.
     13171        results.append(m_out.anchor(vmCall(Int64, operationEnumeratorNextUpdatePropertyName, weakPointer(globalObject), index, mode, enumerator)));
     13172        if (continuation) {
     13173            m_out.jump(continuation);
    1318213174            m_out.appendTo(continuation);
     13175        }
    1318313176
    1318413177        ASSERT(results.size());
Note: See TracChangeset for help on using the changeset viewer.