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

Changeset 245667 in webkit


Ignore:
Timestamp:
May 22, 2019, 6:22:33 PM (7 years ago)
Author:
ysuzuki@apple.com
Message:

[JSC] ArrayAllocationProfile should not access to butterfly in concurrent compiler
https://bugs.webkit.org/show_bug.cgi?id=197809

Reviewed by Michael Saboff.

JSTests:

  • stress/array-allocation-profile-should-not-update-itself-in-concurrent-compiler.js: Added.

(foo):

Source/JavaScriptCore:

ArrayAllocationProfile assumes that Butterfly can be accessed concurrently. But this is not correct now
since LargeAllocation Butterfly can be realloced. In this patch, we switch profiling array allocations
only in the main thread. This allocation profiling is repeatedly called in the main thread's slow path,
and it is also called when updating the profiles in the main thread.

We also rename updateAllPredictionsAndCountLiveness to updateAllValueProfilePredictionsAndCountLiveness
since it only cares ValueProfiles.

  • bytecode/ArrayAllocationProfile.cpp:

(JSC::ArrayAllocationProfile::updateProfile):

  • bytecode/ArrayAllocationProfile.h:

(JSC::ArrayAllocationProfile::selectIndexingTypeConcurrently):
(JSC::ArrayAllocationProfile::selectIndexingType):
(JSC::ArrayAllocationProfile::vectorLengthHintConcurrently):
(JSC::ArrayAllocationProfile::vectorLengthHint):

  • bytecode/CodeBlock.cpp:

(JSC::CodeBlock::updateAllValueProfilePredictionsAndCountLiveness):
(JSC::CodeBlock::updateAllValueProfilePredictions):
(JSC::CodeBlock::shouldOptimizeNow):
(JSC::CodeBlock::updateAllPredictionsAndCountLiveness): Deleted.

  • bytecode/CodeBlock.h:
  • dfg/DFGByteCodeParser.cpp:

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

Location:
trunk
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r245655 r245667  
     12019-05-22  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] ArrayAllocationProfile should not access to butterfly in concurrent compiler
     4        https://bugs.webkit.org/show_bug.cgi?id=197809
     5
     6        Reviewed by Michael Saboff.
     7
     8        * stress/array-allocation-profile-should-not-update-itself-in-concurrent-compiler.js: Added.
     9        (foo):
     10
    1112019-05-22  Ross Kirsling  <ross.kirsling@sony.com>
    212
  • trunk/Source/JavaScriptCore/ChangeLog

    r245658 r245667  
     12019-05-22  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] ArrayAllocationProfile should not access to butterfly in concurrent compiler
     4        https://bugs.webkit.org/show_bug.cgi?id=197809
     5
     6        Reviewed by Michael Saboff.
     7
     8        ArrayAllocationProfile assumes that Butterfly can be accessed concurrently. But this is not correct now
     9        since LargeAllocation Butterfly can be realloced. In this patch, we switch profiling array allocations
     10        only in the main thread. This allocation profiling is repeatedly called in the main thread's slow path,
     11        and it is also called when updating the profiles in the main thread.
     12
     13        We also rename updateAllPredictionsAndCountLiveness to updateAllValueProfilePredictionsAndCountLiveness
     14        since it only cares ValueProfiles.
     15
     16        * bytecode/ArrayAllocationProfile.cpp:
     17        (JSC::ArrayAllocationProfile::updateProfile):
     18        * bytecode/ArrayAllocationProfile.h:
     19        (JSC::ArrayAllocationProfile::selectIndexingTypeConcurrently):
     20        (JSC::ArrayAllocationProfile::selectIndexingType):
     21        (JSC::ArrayAllocationProfile::vectorLengthHintConcurrently):
     22        (JSC::ArrayAllocationProfile::vectorLengthHint):
     23        * bytecode/CodeBlock.cpp:
     24        (JSC::CodeBlock::updateAllValueProfilePredictionsAndCountLiveness):
     25        (JSC::CodeBlock::updateAllValueProfilePredictions):
     26        (JSC::CodeBlock::shouldOptimizeNow):
     27        (JSC::CodeBlock::updateAllPredictionsAndCountLiveness): Deleted.
     28        * bytecode/CodeBlock.h:
     29        * dfg/DFGByteCodeParser.cpp:
     30        (JSC::DFG::ByteCodeParser::parseBlock):
     31
    1322019-05-22  Yusuke Suzuki  <ysuzuki@apple.com>
    233
  • trunk/Source/JavaScriptCore/bytecode/ArrayAllocationProfile.cpp

    r232070 r245667  
    4848    //   be freed, since we require the GC to wait until all concurrent JITing
    4949    //   finishes.
     50    //
     51    // But one exception is vector length. We access vector length to get the vector
     52    // length hint. However vector length can be accessible only from the main
     53    // thread because large butterfly can be realloced in the main thread.
     54    // So for now, we update the allocation profile only from the main thread.
    5055   
     56    ASSERT(!isCompilationThread());
    5157    JSArray* lastArray = m_lastArray;
    5258    if (!lastArray)
  • trunk/Source/JavaScriptCore/bytecode/ArrayAllocationProfile.h

    r237547 r245667  
    4040    }
    4141
     42    IndexingType selectIndexingTypeConcurrently()
     43    {
     44        return m_currentIndexingType;
     45    }
     46
    4247    IndexingType selectIndexingType()
    4348    {
     49        ASSERT(!isCompilationThread());
    4450        JSArray* lastArray = m_lastArray;
    4551        if (lastArray && UNLIKELY(lastArray->indexingType() != m_currentIndexingType))
     
    4955
    5056    // vector length hint becomes [0, BASE_CONTIGUOUS_VECTOR_LEN_MAX].
     57    unsigned vectorLengthHintConcurrently()
     58    {
     59        return m_largestSeenVectorLength;
     60    }
     61
    5162    unsigned vectorLengthHint()
    5263    {
     64        ASSERT(!isCompilationThread());
    5365        JSArray* lastArray = m_lastArray;
    5466        if (lastArray && (m_largestSeenVectorLength != BASE_CONTIGUOUS_VECTOR_LEN_MAX) && UNLIKELY(lastArray->getVectorLength() > m_largestSeenVectorLength))
  • trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp

    r245658 r245667  
    26272627#endif // ENABLE(DFG_JIT)
    26282628
    2629 void CodeBlock::updateAllPredictionsAndCountLiveness(unsigned& numberOfLiveNonArgumentValueProfiles, unsigned& numberOfSamplesInProfiles)
     2629void CodeBlock::updateAllValueProfilePredictionsAndCountLiveness(unsigned& numberOfLiveNonArgumentValueProfiles, unsigned& numberOfSamplesInProfiles)
    26302630{
    26312631    ConcurrentJSLocker locker(m_lock);
     
    26652665{
    26662666    unsigned ignoredValue1, ignoredValue2;
    2667     updateAllPredictionsAndCountLiveness(ignoredValue1, ignoredValue2);
     2667    updateAllValueProfilePredictionsAndCountLiveness(ignoredValue1, ignoredValue2);
    26682668}
    26692669
     
    26992699    unsigned numberOfLiveNonArgumentValueProfiles;
    27002700    unsigned numberOfSamplesInProfiles;
    2701     updateAllPredictionsAndCountLiveness(numberOfLiveNonArgumentValueProfiles, numberOfSamplesInProfiles);
     2701    updateAllValueProfilePredictionsAndCountLiveness(numberOfLiveNonArgumentValueProfiles, numberOfSamplesInProfiles);
    27022702
    27032703    if (Options::verboseOSR()) {
  • trunk/Source/JavaScriptCore/bytecode/CodeBlock.h

    r245658 r245667  
    907907    double optimizationThresholdScalingFactor();
    908908
    909     void updateAllPredictionsAndCountLiveness(unsigned& numberOfLiveNonArgumentValueProfiles, unsigned& numberOfSamplesInProfiles);
     909    void updateAllValueProfilePredictionsAndCountLiveness(unsigned& numberOfLiveNonArgumentValueProfiles, unsigned& numberOfSamplesInProfiles);
    910910
    911911    void setConstantIdentifierSetRegisters(VM&, const Vector<ConstantIdentifierSetEntry>& constants);
  • trunk/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp

    r245658 r245667  
    48864886            for (int operandIdx = startOperand; operandIdx > startOperand - numOperands; --operandIdx)
    48874887                addVarArgChild(get(VirtualRegister(operandIdx)));
    4888             unsigned vectorLengthHint = std::max<unsigned>(profile.vectorLengthHint(), numOperands);
    4889             set(bytecode.m_dst, addToGraph(Node::VarArg, NewArray, OpInfo(profile.selectIndexingType()), OpInfo(vectorLengthHint)));
     4888            unsigned vectorLengthHint = std::max<unsigned>(profile.vectorLengthHintConcurrently(), numOperands);
     4889            set(bytecode.m_dst, addToGraph(Node::VarArg, NewArray, OpInfo(profile.selectIndexingTypeConcurrently()), OpInfo(vectorLengthHint)));
    48904890            NEXT_OPCODE(op_new_array);
    48914891        }
     
    49174917            auto bytecode = currentInstruction->as<OpNewArrayWithSize>();
    49184918            ArrayAllocationProfile& profile = bytecode.metadata(codeBlock).m_arrayAllocationProfile;
    4919             set(bytecode.m_dst, addToGraph(NewArrayWithSize, OpInfo(profile.selectIndexingType()), get(bytecode.m_length)));
     4919            set(bytecode.m_dst, addToGraph(NewArrayWithSize, OpInfo(profile.selectIndexingTypeConcurrently()), get(bytecode.m_length)));
    49204920            NEXT_OPCODE(op_new_array_with_size);
    49214921        }
Note: See TracChangeset for help on using the changeset viewer.