diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2015-05-20 09:56:07 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2015-05-20 09:56:07 +0000 |
commit | 41386e9cb918eed93b3f13648cbef387e371e451 (patch) | |
tree | a97f9d7bd1d9d091833286085f72da9d83fd0606 /Source/JavaScriptCore/heap/GCThreadSharedData.cpp | |
parent | e15dd966d523731101f70ccf768bba12435a0208 (diff) | |
download | WebKitGtk-tarball-41386e9cb918eed93b3f13648cbef387e371e451.tar.gz |
webkitgtk-2.4.9webkitgtk-2.4.9
Diffstat (limited to 'Source/JavaScriptCore/heap/GCThreadSharedData.cpp')
-rw-r--r-- | Source/JavaScriptCore/heap/GCThreadSharedData.cpp | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/Source/JavaScriptCore/heap/GCThreadSharedData.cpp b/Source/JavaScriptCore/heap/GCThreadSharedData.cpp index 3fad8734b..09143a15f 100644 --- a/Source/JavaScriptCore/heap/GCThreadSharedData.cpp +++ b/Source/JavaScriptCore/heap/GCThreadSharedData.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009, 2011, 2015 Apple Inc. All rights reserved. + * Copyright (C) 2009, 2011 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -29,11 +29,10 @@ #include "CopyVisitor.h" #include "CopyVisitorInlines.h" #include "GCThread.h" +#include "VM.h" #include "MarkStack.h" -#include "JSCInlines.h" #include "SlotVisitor.h" #include "SlotVisitorInlines.h" -#include "VM.h" namespace JSC { @@ -73,7 +72,7 @@ GCThreadSharedData::GCThreadSharedData(VM* vm) : m_vm(vm) , m_copiedSpace(&vm->heap.m_storageSpace) , m_shouldHashCons(false) - , m_sharedMarkStack() + , m_sharedMarkStack(vm->heap.blockAllocator()) , m_numberOfActiveParallelMarkers(0) , m_parallelMarkersShouldExit(false) , m_copyIndex(0) @@ -81,12 +80,15 @@ GCThreadSharedData::GCThreadSharedData(VM* vm) , m_gcThreadsShouldWait(false) , m_currentPhase(NoPhase) { + m_copyLock.Init(); #if ENABLE(PARALLEL_GC) // Grab the lock so the new GC threads can be properly initialized before they start running. - std::unique_lock<Lock> lock(m_phaseMutex); + std::unique_lock<std::mutex> lock(m_phaseMutex); for (unsigned i = 1; i < Options::numberOfGCMarkers(); ++i) { m_numberOfActiveGCThreads++; - GCThread* newThread = new GCThread(*this, std::make_unique<SlotVisitor>(*this), std::make_unique<CopyVisitor>(*this)); + SlotVisitor* slotVisitor = new SlotVisitor(*this); + CopyVisitor* copyVisitor = new CopyVisitor(*this); + GCThread* newThread = new GCThread(*this, slotVisitor, copyVisitor); ThreadIdentifier threadID = createThread(GCThread::gcThreadStartFunc, newThread, "JavaScriptCore::Marking"); newThread->initializeThreadID(threadID); m_gcThreads.append(newThread); @@ -102,13 +104,13 @@ GCThreadSharedData::~GCThreadSharedData() #if ENABLE(PARALLEL_GC) // Destroy our marking threads. { - std::lock_guard<Lock> markingLock(m_markingMutex); - std::lock_guard<Lock> phaseLock(m_phaseMutex); + std::lock_guard<std::mutex> markingLock(m_markingMutex); + std::lock_guard<std::mutex> phaseLock(m_phaseMutex); ASSERT(m_currentPhase == NoPhase); m_parallelMarkersShouldExit = true; m_gcThreadsShouldWait = false; m_currentPhase = Exit; - m_phaseConditionVariable.notifyAll(); + m_phaseConditionVariable.notify_all(); } for (unsigned i = 0; i < m_gcThreads.size(); ++i) { waitForThreadCompletion(m_gcThreads[i]->threadID()); @@ -116,11 +118,16 @@ GCThreadSharedData::~GCThreadSharedData() } #endif } - + void GCThreadSharedData::reset() { ASSERT(m_sharedMarkStack.isEmpty()); +#if ENABLE(PARALLEL_GC) + m_opaqueRoots.clear(); +#else + ASSERT(m_opaqueRoots.isEmpty()); +#endif m_weakReferenceHarvesters.removeAll(); if (m_shouldHashCons) { @@ -131,34 +138,27 @@ void GCThreadSharedData::reset() void GCThreadSharedData::startNextPhase(GCPhase phase) { - std::lock_guard<Lock> lock(m_phaseMutex); + std::lock_guard<std::mutex> lock(m_phaseMutex); ASSERT(!m_gcThreadsShouldWait); ASSERT(m_currentPhase == NoPhase); m_gcThreadsShouldWait = true; m_currentPhase = phase; - m_phaseConditionVariable.notifyAll(); + m_phaseConditionVariable.notify_all(); } void GCThreadSharedData::endCurrentPhase() { ASSERT(m_gcThreadsShouldWait); - std::unique_lock<Lock> lock(m_phaseMutex); + std::unique_lock<std::mutex> lock(m_phaseMutex); m_currentPhase = NoPhase; m_gcThreadsShouldWait = false; - m_phaseConditionVariable.notifyAll(); + m_phaseConditionVariable.notify_all(); m_activityConditionVariable.wait(lock, [this] { return !m_numberOfActiveGCThreads; }); } void GCThreadSharedData::didStartMarking() { - if (m_vm->heap.operationInProgress() == FullCollection) { -#if ENABLE(PARALLEL_GC) - m_opaqueRoots.clear(); -#else - ASSERT(m_opaqueRoots.isEmpty()); -#endif -} - std::lock_guard<Lock> lock(m_markingMutex); + std::lock_guard<std::mutex> lock(m_markingMutex); m_parallelMarkersShouldExit = false; startNextPhase(Mark); } @@ -166,9 +166,9 @@ void GCThreadSharedData::didStartMarking() void GCThreadSharedData::didFinishMarking() { { - std::lock_guard<Lock> lock(m_markingMutex); + std::lock_guard<std::mutex> lock(m_markingMutex); m_parallelMarkersShouldExit = true; - m_markingConditionVariable.notifyAll(); + m_markingConditionVariable.notify_all(); } ASSERT(m_currentPhase == Mark); @@ -178,7 +178,7 @@ void GCThreadSharedData::didFinishMarking() void GCThreadSharedData::didStartCopying() { { - LockHolder locker(&m_copyLock); + SpinLockHolder locker(&m_copyLock); if (m_vm->heap.operationInProgress() == EdenCollection) { // Reset the vector to be empty, but don't throw away the backing store. m_blocksToCopy.shrink(0); |