Ignore:
Timestamp:
Oct 5, 2015, 4:31:53 PM (10 years ago)
Author:
[email protected]
Message:

Unreviewed, rolling back in r190450
https://bugs.webkit.org/show_bug.cgi?id=149727

The cause of the leak was VM shutdown, which happens in workers.

The fix is for CodeBlockSet to participate in lastChanceToFinalize,
since it's responsible for running CodeBlock destructors.

I ran the leaks tests locally and did not see any CodeBlock-related leaks.

Restored changesets:

"CodeBlock should be a GC object"
https://bugs.webkit.org/show_bug.cgi?id=149727
http://trac.webkit.org/changeset/190450

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/heap/Heap.cpp

    r190569 r190589  
    383383    RELEASE_ASSERT(m_operationInProgress == NoOperation);
    384384
     385    m_codeBlocks.lastChanceToFinalize();
    385386    m_objectSpace.lastChanceToFinalize();
    386387    releaseDelayedReleasedObjects();
     
    521522    ASSERT(isValidThreadState(m_vm));
    522523
    523     Vector<const JSCell*> rememberedSet(m_slotVisitor.markStack().size());
    524     m_slotVisitor.markStack().fillVector(rememberedSet);
    525 
    526 #if ENABLE(DFG_JIT)
    527     DFG::clearCodeBlockMarks(*m_vm);
    528 #endif
    529     if (m_operationInProgress == EdenCollection)
    530         m_codeBlocks.clearMarksForEdenCollection(rememberedSet);
    531     else
    532         m_codeBlocks.clearMarksForFullCollection();
    533 
    534524    // We gather conservative roots before clearing mark bits because conservative
    535525    // gathering uses the mark bits to determine whether a reference is valid.
     
    539529    gatherScratchBufferRoots(conservativeRoots);
    540530
     531#if ENABLE(DFG_JIT)
     532    DFG::rememberCodeBlocks(*m_vm);
     533#endif
     534
     535    if (m_operationInProgress == FullCollection) {
     536        m_opaqueRoots.clear();
     537        m_slotVisitor.clearMarkStack();
     538    }
     539
    541540    clearLivenessData();
    542 
    543     if (m_operationInProgress == FullCollection)
    544         m_opaqueRoots.clear();
    545541
    546542    m_parallelMarkersShouldExit = false;
     
    581577        ParallelModeEnabler enabler(m_slotVisitor);
    582578
     579        m_slotVisitor.donateAndDrain();
    583580        visitExternalRememberedSet();
    584581        visitSmallStrings();
     
    695692{
    696693    GCPHASE(ClearLivenessData);
     694    if (m_operationInProgress == FullCollection)
     695        m_codeBlocks.clearMarksForFullCollection();
     696
    697697    m_objectSpace.clearNewlyAllocated();
    698698    m_objectSpace.clearMarks();
     
    816816{
    817817    GCPHASE(TraceCodeBlocksAndJITStubRoutines);
    818     m_codeBlocks.traceMarked(m_slotVisitor);
    819818    m_jitStubRoutines.traceMarkedStubRoutines(m_slotVisitor);
    820819
     
    950949    // we'll end up returning to deleted code.
    951950    RELEASE_ASSERT(!m_vm->entryScope);
     951    ASSERT(m_operationInProgress == NoOperation);
    952952
    953953    completeAllDFGPlans();
    954954
    955     for (ExecutableBase* current : m_executables) {
    956         if (!current->isFunctionExecutable())
    957             continue;
    958         static_cast<FunctionExecutable*>(current)->clearCode();
    959     }
    960 
    961     ASSERT(m_operationInProgress == FullCollection || m_operationInProgress == NoOperation);
    962     m_codeBlocks.clearMarksForFullCollection();
    963     m_codeBlocks.deleteUnmarkedAndUnreferenced(FullCollection);
     955    for (ExecutableBase* executable : m_executables)
     956        executable->clearCode();
    964957}
    965958
     
    981974            continue;
    982975
    983         // We do this because executable memory is limited on some platforms and because
    984         // CodeBlock requires eager finalization.
    985         ExecutableBase::clearCodeVirtual(current);
     976        // Eagerly dereference the Executable's JITCode in order to run watchpoint
     977        // destructors. Otherwise, watchpoints might fire for deleted CodeBlocks.
     978        current->clearCode();
    986979        std::swap(m_executables[i], m_executables.last());
    987980        m_executables.removeLast();
     
    11041097    deleteSourceProviderCaches();
    11051098    notifyIncrementalSweeper();
    1106     rememberCurrentlyExecutingCodeBlocks();
     1099    writeBarrierCurrentlyExecutingCodeBlocks();
    11071100
    11081101    resetAllocators();
     
    11411134    if (shouldDoFullCollection(collectionType)) {
    11421135        m_operationInProgress = FullCollection;
    1143         m_slotVisitor.clearMarkStack();
    11441136        m_shouldDoFullCollection = false;
    11451137        if (Options::logGC())
     
    12581250}
    12591251
    1260 void Heap::rememberCurrentlyExecutingCodeBlocks()
    1261 {
    1262     GCPHASE(RememberCurrentlyExecutingCodeBlocks);
    1263     m_codeBlocks.rememberCurrentlyExecutingCodeBlocks(this);
     1252void Heap::writeBarrierCurrentlyExecutingCodeBlocks()
     1253{
     1254    GCPHASE(WriteBarrierCurrentlyExecutingCodeBlocks);
     1255    m_codeBlocks.writeBarrierCurrentlyExecutingCodeBlocks(this);
    12641256}
    12651257
Note: See TracChangeset for help on using the changeset viewer.