Ignore:
Timestamp:
Aug 5, 2017, 9:43:37 PM (8 years ago)
Author:
[email protected]
Message:

REGRESSION (r219895-219897): Number of leaks on Open Source went from 9240 to 235983 and is now at 302372
https://bugs.webkit.org/show_bug.cgi?id=175083

Reviewed by Oliver Hunt.

Source/JavaScriptCore:

This fixes the leak by making MarkedBlock::specializedSweep call destructors when the block is empty,
even if we are using the pop path.

Also, this fixes HeapCellInlines.h to no longer include MarkedBlockInlines.h. That's pretty
important, since MarkedBlockInlines.h is the GC's internal guts - we don't want to have to recompile
the world just because we changed it.

Finally, this adds a new testing SPI for waiting for all VMs to finish destructing. This makes it
easier to debug leaks.

  • bytecode/AccessCase.cpp:
  • bytecode/PolymorphicAccess.cpp:
  • heap/HeapCell.cpp:

(JSC::HeapCell::isLive):

  • heap/HeapCellInlines.h:

(JSC::HeapCell::isLive): Deleted.

  • heap/MarkedAllocator.cpp:

(JSC::MarkedAllocator::tryAllocateWithoutCollecting):
(JSC::MarkedAllocator::endMarking):

  • heap/MarkedBlockInlines.h:

(JSC::MarkedBlock::Handle::specializedSweep):

  • jit/AssemblyHelpers.cpp:
  • jit/Repatch.cpp:
  • runtime/TestRunnerUtils.h:
  • runtime/VM.cpp:

(JSC::waitForVMDestruction):
(JSC::VM::~VM):

Source/WTF:

Adds a classic ReadWriteLock class. I wrote my own because I can never remember if the pthread one is
guaranted to bias in favor of writers or not.

  • WTF.xcodeproj/project.pbxproj:
  • wtf/Condition.h:

(WTF::ConditionBase::construct):
(WTF::Condition::Condition):

  • wtf/Lock.h:

(WTF::LockBase::construct):
(WTF::Lock::Lock):

  • wtf/ReadWriteLock.cpp: Added.

(WTF::ReadWriteLockBase::construct):
(WTF::ReadWriteLockBase::readLock):
(WTF::ReadWriteLockBase::readUnlock):
(WTF::ReadWriteLockBase::writeLock):
(WTF::ReadWriteLockBase::writeUnlock):

  • wtf/ReadWriteLock.h: Added.

(WTF::ReadWriteLockBase::ReadLock::tryLock):
(WTF::ReadWriteLockBase::ReadLock::lock):
(WTF::ReadWriteLockBase::ReadLock::unlock):
(WTF::ReadWriteLockBase::WriteLock::tryLock):
(WTF::ReadWriteLockBase::WriteLock::lock):
(WTF::ReadWriteLockBase::WriteLock::unlock):
(WTF::ReadWriteLockBase::read):
(WTF::ReadWriteLockBase::write):
(WTF::ReadWriteLock::ReadWriteLock):

Tools:

Leaks results are super confusing if leaks runs while some VMs are destructing. This calls a new SPI
to wait for VM destructions to finish before running the next test. This makes it easier to
understand leaks results from workers tests, and leads to fewer reported leaks.

  • DumpRenderTree/mac/DumpRenderTree.mm:

(runTest):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/runtime/VM.cpp

    r220291 r220322  
    102102#include "StrongInlines.h"
    103103#include "StructureInlines.h"
     104#include "TestRunnerUtils.h"
    104105#include "ThunkGenerators.h"
    105106#include "TypeProfiler.h"
     
    114115#include <wtf/CurrentTime.h>
    115116#include <wtf/ProcessID.h>
     117#include <wtf/ReadWriteLock.h>
    116118#include <wtf/SimpleStats.h>
    117119#include <wtf/StringPrintStream.h>
     
    342344}
    343345
     346static StaticReadWriteLock s_destructionLock;
     347
     348void waitForVMDestruction()
     349{
     350    auto locker = holdLock(s_destructionLock.write());
     351}
     352
    344353VM::~VM()
    345354{
     355    auto destructionLocker = holdLock(s_destructionLock.read());
     356   
    346357    Gigacage::removeDisableCallback(gigacageDisabledCallback, this);
    347358    promiseDeferredTimer->stopRunningTasks();
Note: See TracChangeset for help on using the changeset viewer.