Commit 2318c7e7 authored by ggaren@apple.com's avatar ggaren@apple.com

A few Heap-related renames (sans file moves, which should come next)

https://bugs.webkit.org/show_bug.cgi?id=56283
        
Reviewed by Sam Weinig.

ConservativeSet => ConservativeRoots. "Set" was misleading, since items
are not uniqued. Also, "Roots" is more specific about what's in the set.
        
MachineStackMarker => MachineThreads. "Threads" is more descriptive of
the fact that this class maintains a set of all threads using JSC.
"Stack" was misleading, since this class traverses stacks and registers.
"Mark" was misleading, since this class doesn't mark anything anymore.
        
registerThread => addCurrentThread. "Current" is more specific.
unregisterThread => removeCurrentThread. "Current" is more specific.
        
"currentThreadRegistrar" => threadSpecific. The only point of this data
structure is to register a thread-specific destructor with a pointer to
this.
        
"mark...Conservatively" => "gather". "Mark" is not true, since these
functions don't mark anything. "Conservatively" is redundant, since they
take "ConservativeRoots" as an argument.

* API/APIShims.h:
(JSC::APIEntryShimWithoutLock::APIEntryShimWithoutLock):
* JavaScriptCore.exp:
* runtime/ConservativeSet.cpp:
(JSC::ConservativeRoots::grow):
(JSC::ConservativeRoots::add):
* runtime/ConservativeSet.h:
(JSC::ConservativeRoots::ConservativeRoots):
(JSC::ConservativeRoots::~ConservativeRoots):
(JSC::ConservativeRoots::size):
(JSC::ConservativeRoots::roots):
* runtime/Heap.cpp:
(JSC::Heap::Heap):
(JSC::Heap::markRoots):
* runtime/Heap.h:
(JSC::Heap::machineThreads):
* runtime/JSGlobalData.h:
(JSC::JSGlobalData::makeUsableFromMultipleThreads):
* runtime/MachineStackMarker.cpp:
(JSC::MachineThreads::MachineThreads):
(JSC::MachineThreads::~MachineThreads):
(JSC::MachineThreads::makeUsableFromMultipleThreads):
(JSC::MachineThreads::addCurrentThread):
(JSC::MachineThreads::removeThread):
(JSC::MachineThreads::removeCurrentThread):
(JSC::MachineThreads::gatherFromCurrentThreadInternal):
(JSC::MachineThreads::gatherFromCurrentThread):
(JSC::MachineThreads::gatherFromOtherThread):
(JSC::MachineThreads::gatherConservativeRoots):
* runtime/MachineStackMarker.h:
* runtime/MarkStack.h:
(JSC::MarkStack::append):



git-svn-id: svn://svn.chromium.org/blink/trunk@80995 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 2b164fe1
...@@ -42,7 +42,7 @@ protected: ...@@ -42,7 +42,7 @@ protected:
UNUSED_PARAM(registerThread); UNUSED_PARAM(registerThread);
#if ENABLE(JSC_MULTIPLE_THREADS) #if ENABLE(JSC_MULTIPLE_THREADS)
if (registerThread) if (registerThread)
globalData->heap.machineStackMarker().registerThread(); globalData->heap.machineThreads().addCurrentThread();
#endif #endif
m_globalData->heap.activityCallback()->synchronize(); m_globalData->heap.activityCallback()->synchronize();
m_globalData->timeoutChecker.start(); m_globalData->timeoutChecker.start();
......
2011-03-13 Geoffrey Garen <ggaren@apple.com>
Reviewed by Sam Weinig.
A few Heap-related renames (sans file moves, which should come next)
https://bugs.webkit.org/show_bug.cgi?id=56283
ConservativeSet => ConservativeRoots. "Set" was misleading, since items
are not uniqued. Also, "Roots" is more specific about what's in the set.
MachineStackMarker => MachineThreads. "Threads" is more descriptive of
the fact that this class maintains a set of all threads using JSC.
"Stack" was misleading, since this class traverses stacks and registers.
"Mark" was misleading, since this class doesn't mark anything anymore.
registerThread => addCurrentThread. "Current" is more specific.
unregisterThread => removeCurrentThread. "Current" is more specific.
"currentThreadRegistrar" => threadSpecific. The only point of this data
structure is to register a thread-specific destructor with a pointer to
this.
"mark...Conservatively" => "gather". "Mark" is not true, since these
functions don't mark anything. "Conservatively" is redundant, since they
take "ConservativeRoots" as an argument.
* API/APIShims.h:
(JSC::APIEntryShimWithoutLock::APIEntryShimWithoutLock):
* JavaScriptCore.exp:
* runtime/ConservativeSet.cpp:
(JSC::ConservativeRoots::grow):
(JSC::ConservativeRoots::add):
* runtime/ConservativeSet.h:
(JSC::ConservativeRoots::ConservativeRoots):
(JSC::ConservativeRoots::~ConservativeRoots):
(JSC::ConservativeRoots::size):
(JSC::ConservativeRoots::roots):
* runtime/Heap.cpp:
(JSC::Heap::Heap):
(JSC::Heap::markRoots):
* runtime/Heap.h:
(JSC::Heap::machineThreads):
* runtime/JSGlobalData.h:
(JSC::JSGlobalData::makeUsableFromMultipleThreads):
* runtime/MachineStackMarker.cpp:
(JSC::MachineThreads::MachineThreads):
(JSC::MachineThreads::~MachineThreads):
(JSC::MachineThreads::makeUsableFromMultipleThreads):
(JSC::MachineThreads::addCurrentThread):
(JSC::MachineThreads::removeThread):
(JSC::MachineThreads::removeCurrentThread):
(JSC::MachineThreads::gatherFromCurrentThreadInternal):
(JSC::MachineThreads::gatherFromCurrentThread):
(JSC::MachineThreads::gatherFromOtherThread):
(JSC::MachineThreads::gatherConservativeRoots):
* runtime/MachineStackMarker.h:
* runtime/MarkStack.h:
(JSC::MarkStack::append):
2011-03-13 David Kilzer <ddkilzer@apple.com> 2011-03-13 David Kilzer <ddkilzer@apple.com>
BUILD FIX for armv7 after r80969 BUILD FIX for armv7 after r80969
......
...@@ -163,6 +163,7 @@ __ZN3JSC14JSGlobalObject3putEPNS_9ExecStateERKNS_10IdentifierENS_7JSValueERNS_15 ...@@ -163,6 +163,7 @@ __ZN3JSC14JSGlobalObject3putEPNS_9ExecStateERKNS_10IdentifierENS_7JSValueERNS_15
__ZN3JSC14JSGlobalObject4initEPNS_8JSObjectE __ZN3JSC14JSGlobalObject4initEPNS_8JSObjectE
__ZN3JSC14JSGlobalObjectD2Ev __ZN3JSC14JSGlobalObjectD2Ev
__ZN3JSC14JSGlobalObjectnwEmPNS_12JSGlobalDataE __ZN3JSC14JSGlobalObjectnwEmPNS_12JSGlobalDataE
__ZN3JSC14MachineThreads16addCurrentThreadEv
__ZN3JSC14SamplingThread4stopEv __ZN3JSC14SamplingThread4stopEv
__ZN3JSC14SamplingThread5startEj __ZN3JSC14SamplingThread5startEj
__ZN3JSC14TimeoutChecker10didTimeOutEPNS_9ExecStateE __ZN3JSC14TimeoutChecker10didTimeOutEPNS_9ExecStateE
...@@ -184,7 +185,6 @@ __ZN3JSC17PropertyNameArray3addEPN3WTF10StringImplE ...@@ -184,7 +185,6 @@ __ZN3JSC17PropertyNameArray3addEPN3WTF10StringImplE
__ZN3JSC17constructFunctionEPNS_9ExecStateERKNS_7ArgListERKNS_10IdentifierERKNS_7UStringEi __ZN3JSC17constructFunctionEPNS_9ExecStateERKNS_7ArgListERKNS_10IdentifierERKNS_7UStringEi
__ZN3JSC17createSyntaxErrorEPNS_9ExecStateERKNS_7UStringE __ZN3JSC17createSyntaxErrorEPNS_9ExecStateERKNS_7UStringE
__ZN3JSC18DebuggerActivationC1ERNS_12JSGlobalDataEPNS_8JSObjectE __ZN3JSC18DebuggerActivationC1ERNS_12JSGlobalDataEPNS_8JSObjectE
__ZN3JSC18MachineStackMarker14registerThreadEv
__ZN3JSC18PropertyDescriptor11setWritableEb __ZN3JSC18PropertyDescriptor11setWritableEb
__ZN3JSC18PropertyDescriptor12setUndefinedEv __ZN3JSC18PropertyDescriptor12setUndefinedEv
__ZN3JSC18PropertyDescriptor13setDescriptorENS_7JSValueEj __ZN3JSC18PropertyDescriptor13setDescriptorENS_7JSValueEj
......
...@@ -277,7 +277,7 @@ EXPORTS ...@@ -277,7 +277,7 @@ EXPORTS
?randomNumber@WTF@@YANXZ ?randomNumber@WTF@@YANXZ
?recompileAllJSFunctions@Debugger@JSC@@QAEXPAVJSGlobalData@2@@Z ?recompileAllJSFunctions@Debugger@JSC@@QAEXPAVJSGlobalData@2@@Z
?regExpFlags@JSC@@YA?AW4RegExpFlags@1@ABVUString@1@@Z ?regExpFlags@JSC@@YA?AW4RegExpFlags@1@ABVUString@1@@Z
?registerThread@MachineStackMarker@JSC@@QAEXXZ ?addCurrentThread@MachineThreads@JSC@@QAEXXZ
?reifyString@StringBuilder@WTF@@AAEXXZ ?reifyString@StringBuilder@WTF@@AAEXXZ
?releaseDecommitted@OSAllocator@WTF@@SAXPAXI@Z ?releaseDecommitted@OSAllocator@WTF@@SAXPAXI@Z
?releaseStack@MarkStack@JSC@@CAXPAXI@Z ?releaseStack@MarkStack@JSC@@CAXPAXI@Z
......
...@@ -35,18 +35,18 @@ inline bool isPointerAligned(void* p) ...@@ -35,18 +35,18 @@ inline bool isPointerAligned(void* p)
return !((intptr_t)(p) & (sizeof(char*) - 1)); return !((intptr_t)(p) & (sizeof(char*) - 1));
} }
void ConservativeSet::grow() void ConservativeRoots::grow()
{ {
size_t newCapacity = m_capacity == inlineCapacity ? nonInlineCapacity : m_capacity * 2; size_t newCapacity = m_capacity == inlineCapacity ? nonInlineCapacity : m_capacity * 2;
JSCell** newSet = static_cast<JSCell**>(OSAllocator::reserveAndCommit(newCapacity * sizeof(JSCell*))); JSCell** newRoots = static_cast<JSCell**>(OSAllocator::reserveAndCommit(newCapacity * sizeof(JSCell*)));
memcpy(newSet, m_set, m_size * sizeof(JSCell*)); memcpy(newRoots, m_roots, m_size * sizeof(JSCell*));
if (m_set != m_inlineSet) if (m_roots != m_inlineRoots)
OSAllocator::decommitAndRelease(m_set, m_capacity * sizeof(JSCell*)); OSAllocator::decommitAndRelease(m_roots, m_capacity * sizeof(JSCell*));
m_capacity = newCapacity; m_capacity = newCapacity;
m_set = newSet; m_roots = newRoots;
} }
void ConservativeSet::add(void* begin, void* end) void ConservativeRoots::add(void* begin, void* end)
{ {
ASSERT(begin <= end); ASSERT(begin <= end);
ASSERT((static_cast<char*>(end) - static_cast<char*>(begin)) < 0x1000000); ASSERT((static_cast<char*>(end) - static_cast<char*>(begin)) < 0x1000000);
...@@ -60,7 +60,7 @@ void ConservativeSet::add(void* begin, void* end) ...@@ -60,7 +60,7 @@ void ConservativeSet::add(void* begin, void* end)
if (m_size == m_capacity) if (m_size == m_capacity)
grow(); grow();
m_set[m_size++] = reinterpret_cast<JSCell*>(*it); m_roots[m_size++] = reinterpret_cast<JSCell*>(*it);
} }
} }
......
...@@ -23,8 +23,8 @@ ...@@ -23,8 +23,8 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef ConservativeSet_h #ifndef ConservativeRoots_h
#define ConservativeSet_h #define ConservativeRoots_h
#include <wtf/OSAllocator.h> #include <wtf/OSAllocator.h>
#include <wtf/Vector.h> #include <wtf/Vector.h>
...@@ -36,15 +36,15 @@ class Heap; ...@@ -36,15 +36,15 @@ class Heap;
// May contain duplicates. // May contain duplicates.
class ConservativeSet { class ConservativeRoots {
public: public:
ConservativeSet(Heap*); ConservativeRoots(Heap*);
~ConservativeSet(); ~ConservativeRoots();
void add(void* begin, void* end); void add(void* begin, void* end);
size_t size(); size_t size();
JSCell** set(); JSCell** roots();
private: private:
static const size_t inlineCapacity = 128; static const size_t inlineCapacity = 128;
...@@ -53,36 +53,36 @@ private: ...@@ -53,36 +53,36 @@ private:
void grow(); void grow();
Heap* m_heap; Heap* m_heap;
JSCell** m_set; JSCell** m_roots;
size_t m_size; size_t m_size;
size_t m_capacity; size_t m_capacity;
JSCell* m_inlineSet[inlineCapacity]; JSCell* m_inlineRoots[inlineCapacity];
}; };
inline ConservativeSet::ConservativeSet(Heap* heap) inline ConservativeRoots::ConservativeRoots(Heap* heap)
: m_heap(heap) : m_heap(heap)
, m_set(m_inlineSet) , m_roots(m_inlineRoots)
, m_size(0) , m_size(0)
, m_capacity(inlineCapacity) , m_capacity(inlineCapacity)
{ {
} }
inline ConservativeSet::~ConservativeSet() inline ConservativeRoots::~ConservativeRoots()
{ {
if (m_set != m_inlineSet) if (m_roots != m_inlineRoots)
OSAllocator::decommitAndRelease(m_set, m_capacity * sizeof(JSCell*)); OSAllocator::decommitAndRelease(m_roots, m_capacity * sizeof(JSCell*));
} }
inline size_t ConservativeSet::size() inline size_t ConservativeRoots::size()
{ {
return m_size; return m_size;
} }
inline JSCell** ConservativeSet::set() inline JSCell** ConservativeRoots::roots()
{ {
return m_set; return m_roots;
} }
} // namespace JSC } // namespace JSC
#endif // ConservativeSet_h #endif // ConservativeRoots_h
...@@ -46,7 +46,7 @@ Heap::Heap(JSGlobalData* globalData) ...@@ -46,7 +46,7 @@ Heap::Heap(JSGlobalData* globalData)
, m_markListSet(0) , m_markListSet(0)
, m_activityCallback(DefaultGCActivityCallback::create(this)) , m_activityCallback(DefaultGCActivityCallback::create(this))
, m_globalData(globalData) , m_globalData(globalData)
, m_machineStackMarker(this) , m_machineThreads(this)
, m_markStack(globalData->jsArrayVPtr) , m_markStack(globalData->jsArrayVPtr)
, m_handleHeap(globalData) , m_handleHeap(globalData)
, m_extraCost(0) , m_extraCost(0)
...@@ -208,14 +208,14 @@ void Heap::markRoots() ...@@ -208,14 +208,14 @@ void Heap::markRoots()
// We gather the conservative set before clearing mark bits, because // We gather the conservative set before clearing mark bits, because
// conservative gathering uses the mark bits from our last mark pass to // conservative gathering uses the mark bits from our last mark pass to
// determine whether a reference is valid. // determine whether a reference is valid.
ConservativeSet conservativeSet(this); ConservativeRoots conservativeRoots(this);
m_machineStackMarker.markMachineStackConservatively(conservativeSet); m_machineThreads.gatherConservativeRoots(conservativeRoots);
conservativeSet.add(registerFile().start(), registerFile().end()); conservativeRoots.add(registerFile().start(), registerFile().end());
m_markedSpace.clearMarks(); m_markedSpace.clearMarks();
MarkStack& markStack = m_markStack; MarkStack& markStack = m_markStack;
markStack.append(conservativeSet); markStack.append(conservativeRoots);
markStack.drain(); markStack.drain();
// Mark explicitly registered roots. // Mark explicitly registered roots.
......
...@@ -65,7 +65,7 @@ namespace JSC { ...@@ -65,7 +65,7 @@ namespace JSC {
JSGlobalData* globalData() const { return m_globalData; } JSGlobalData* globalData() const { return m_globalData; }
MarkedSpace& markedSpace() { return m_markedSpace; } MarkedSpace& markedSpace() { return m_markedSpace; }
MachineStackMarker& machineStackMarker() { return m_machineStackMarker; } MachineThreads& machineThreads() { return m_machineThreads; }
GCActivityCallback* activityCallback(); GCActivityCallback* activityCallback();
void setActivityCallback(PassOwnPtr<GCActivityCallback>); void setActivityCallback(PassOwnPtr<GCActivityCallback>);
...@@ -129,7 +129,7 @@ namespace JSC { ...@@ -129,7 +129,7 @@ namespace JSC {
JSGlobalData* m_globalData; JSGlobalData* m_globalData;
MachineStackMarker m_machineStackMarker; MachineThreads m_machineThreads;
MarkStack m_markStack; MarkStack m_markStack;
HandleHeap m_handleHeap; HandleHeap m_handleHeap;
......
...@@ -128,7 +128,7 @@ namespace JSC { ...@@ -128,7 +128,7 @@ namespace JSC {
#if ENABLE(JSC_MULTIPLE_THREADS) #if ENABLE(JSC_MULTIPLE_THREADS)
// Will start tracking threads that use the heap, which is resource-heavy. // Will start tracking threads that use the heap, which is resource-heavy.
void makeUsableFromMultipleThreads() { heap.machineStackMarker().makeUsableFromMultipleThreads(); } void makeUsableFromMultipleThreads() { heap.machineThreads().makeUsableFromMultipleThreads(); }
#endif #endif
GlobalDataType globalDataType; GlobalDataType globalDataType;
......
...@@ -78,7 +78,7 @@ ...@@ -78,7 +78,7 @@
#if USE(PTHREADS) && !OS(WINDOWS) && !OS(DARWIN) #if USE(PTHREADS) && !OS(WINDOWS) && !OS(DARWIN)
#include <signal.h> #include <signal.h>
#ifndef SA_RESTART #ifndef SA_RESTART
#error MachineStackMarker requires SA_RESTART #error MachineThreads requires SA_RESTART
#endif #endif
#endif #endif
...@@ -117,7 +117,7 @@ static void pthreadSignalHandlerSuspendResume(int signo) ...@@ -117,7 +117,7 @@ static void pthreadSignalHandlerSuspendResume(int signo)
} }
#endif #endif
class MachineStackMarker::Thread { class MachineThreads::Thread {
public: public:
Thread(pthread_t pthread, const PlatformThread& platThread, void* base) Thread(pthread_t pthread, const PlatformThread& platThread, void* base)
: posixThread(pthread) : posixThread(pthread)
...@@ -146,20 +146,20 @@ public: ...@@ -146,20 +146,20 @@ public:
#endif #endif
MachineStackMarker::MachineStackMarker(Heap* heap) MachineThreads::MachineThreads(Heap* heap)
: m_heap(heap) : m_heap(heap)
#if ENABLE(JSC_MULTIPLE_THREADS) #if ENABLE(JSC_MULTIPLE_THREADS)
, m_registeredThreads(0) , m_registeredThreads(0)
, m_currentThreadRegistrar(0) , m_threadSpecific(0)
#endif #endif
{ {
} }
MachineStackMarker::~MachineStackMarker() MachineThreads::~MachineThreads()
{ {
#if ENABLE(JSC_MULTIPLE_THREADS) #if ENABLE(JSC_MULTIPLE_THREADS)
if (m_currentThreadRegistrar) { if (m_threadSpecific) {
int error = pthread_key_delete(m_currentThreadRegistrar); int error = pthread_key_delete(m_threadSpecific);
ASSERT_UNUSED(error, !error); ASSERT_UNUSED(error, !error);
} }
...@@ -185,24 +185,24 @@ static inline PlatformThread getCurrentPlatformThread() ...@@ -185,24 +185,24 @@ static inline PlatformThread getCurrentPlatformThread()
#endif #endif
} }
void MachineStackMarker::makeUsableFromMultipleThreads() void MachineThreads::makeUsableFromMultipleThreads()
{ {
if (m_currentThreadRegistrar) if (m_threadSpecific)
return; return;
int error = pthread_key_create(&m_currentThreadRegistrar, unregisterThread); int error = pthread_key_create(&m_threadSpecific, removeThread);
if (error) if (error)
CRASH(); CRASH();
} }
void MachineStackMarker::registerThread() void MachineThreads::addCurrentThread()
{ {
ASSERT(!m_heap->globalData()->exclusiveThread || m_heap->globalData()->exclusiveThread == currentThread()); ASSERT(!m_heap->globalData()->exclusiveThread || m_heap->globalData()->exclusiveThread == currentThread());
if (!m_currentThreadRegistrar || pthread_getspecific(m_currentThreadRegistrar)) if (!m_threadSpecific || pthread_getspecific(m_threadSpecific))
return; return;
pthread_setspecific(m_currentThreadRegistrar, this); pthread_setspecific(m_threadSpecific, this);
Thread* thread = new Thread(pthread_self(), getCurrentPlatformThread(), m_heap->globalData()->stack().origin()); Thread* thread = new Thread(pthread_self(), getCurrentPlatformThread(), m_heap->globalData()->stack().origin());
MutexLocker lock(m_registeredThreadsMutex); MutexLocker lock(m_registeredThreadsMutex);
...@@ -211,13 +211,13 @@ void MachineStackMarker::registerThread() ...@@ -211,13 +211,13 @@ void MachineStackMarker::registerThread()
m_registeredThreads = thread; m_registeredThreads = thread;
} }
void MachineStackMarker::unregisterThread(void* p) void MachineThreads::removeThread(void* p)
{ {
if (p) if (p)
static_cast<MachineStackMarker*>(p)->unregisterThread(); static_cast<MachineThreads*>(p)->removeCurrentThread();
} }
void MachineStackMarker::unregisterThread() void MachineThreads::removeCurrentThread()
{ {
pthread_t currentPosixThread = pthread_self(); pthread_t currentPosixThread = pthread_self();
...@@ -244,12 +244,12 @@ void MachineStackMarker::unregisterThread() ...@@ -244,12 +244,12 @@ void MachineStackMarker::unregisterThread()
#endif #endif
void NEVER_INLINE MachineStackMarker::markCurrentThreadConservativelyInternal(ConservativeSet& conservativeSet) void NEVER_INLINE MachineThreads::gatherFromCurrentThreadInternal(ConservativeRoots& conservativeRoots)
{ {
void* begin = m_heap->globalData()->stack().current(); void* begin = m_heap->globalData()->stack().current();
void* end = m_heap->globalData()->stack().origin(); void* end = m_heap->globalData()->stack().origin();
swapIfBackwards(begin, end); swapIfBackwards(begin, end);
conservativeSet.add(begin, end); conservativeRoots.add(begin, end);
} }
#if COMPILER(GCC) #if COMPILER(GCC)
...@@ -258,7 +258,7 @@ void NEVER_INLINE MachineStackMarker::markCurrentThreadConservativelyInternal(Co ...@@ -258,7 +258,7 @@ void NEVER_INLINE MachineStackMarker::markCurrentThreadConservativelyInternal(Co
#define REGISTER_BUFFER_ALIGNMENT #define REGISTER_BUFFER_ALIGNMENT
#endif #endif
void MachineStackMarker::markCurrentThreadConservatively(ConservativeSet& conservativeSet) void MachineThreads::gatherFromCurrentThread(ConservativeRoots& conservativeRoots)
{ {
// setjmp forces volatile registers onto the stack // setjmp forces volatile registers onto the stack
jmp_buf registers REGISTER_BUFFER_ALIGNMENT; jmp_buf registers REGISTER_BUFFER_ALIGNMENT;
...@@ -271,7 +271,7 @@ void MachineStackMarker::markCurrentThreadConservatively(ConservativeSet& conser ...@@ -271,7 +271,7 @@ void MachineStackMarker::markCurrentThreadConservatively(ConservativeSet& conser
#pragma warning(pop) #pragma warning(pop)
#endif #endif
markCurrentThreadConservativelyInternal(conservativeSet); gatherFromCurrentThreadInternal(conservativeRoots);
} }
#if ENABLE(JSC_MULTIPLE_THREADS) #if ENABLE(JSC_MULTIPLE_THREADS)
...@@ -435,20 +435,19 @@ static void freePlatformThreadRegisters(PlatformThreadRegisters& regs) ...@@ -435,20 +435,19 @@ static void freePlatformThreadRegisters(PlatformThreadRegisters& regs)
#endif #endif
} }
void MachineStackMarker::markOtherThreadConservatively(ConservativeSet& conservativeSet, Thread* thread) void MachineThreads::gatherFromOtherThread(ConservativeRoots& conservativeRoots, Thread* thread)
{ {
suspendThread(thread->platformThread); suspendThread(thread->platformThread);
PlatformThreadRegisters regs; PlatformThreadRegisters regs;
size_t regSize = getPlatformThreadRegisters(thread->platformThread, regs); size_t regSize = getPlatformThreadRegisters(thread->platformThread, regs);
// mark the thread's registers conservativeRoots.add(static_cast<void*>(&regs), static_cast<void*>(reinterpret_cast<char*>(&regs) + regSize));
conservativeSet.add(static_cast<void*>(&regs), static_cast<void*>(reinterpret_cast<char*>(&regs) + regSize));
void* stackPointer = otherThreadStackPointer(regs); void* stackPointer = otherThreadStackPointer(regs);
void* stackBase = thread->stackBase; void* stackBase = thread->stackBase;
swapIfBackwards(stackPointer, stackBase); swapIfBackwards(stackPointer, stackBase);
conservativeSet.add(stackPointer, stackBase); conservativeRoots.add(stackPointer, stackBase);
resumeThread(thread->platformThread); resumeThread(thread->platformThread);
...@@ -457,27 +456,27 @@ void MachineStackMarker::markOtherThreadConservatively(ConservativeSet& conserva ...@@ -457,27 +456,27 @@ void MachineStackMarker::markOtherThreadConservatively(ConservativeSet& conserva
#endif #endif
void MachineStackMarker::markMachineStackConservatively(ConservativeSet& conservativeSet) void MachineThreads::gatherConservativeRoots(ConservativeRoots& conservativeRoots)
{ {
markCurrentThreadConservatively(conservativeSet); gatherFromCurrentThread(conservativeRoots);
#if ENABLE(JSC_MULTIPLE_THREADS) #if ENABLE(JSC_MULTIPLE_THREADS)
if (m_currentThreadRegistrar) { if (m_threadSpecific) {
MutexLocker lock(m_registeredThreadsMutex); MutexLocker lock(m_registeredThreadsMutex);
#ifndef NDEBUG #ifndef NDEBUG
// Forbid malloc during the mark phase. Marking a thread suspends it, so // Forbid malloc during the gather phase. The gather phase suspends
// a malloc inside markChildren() would risk a deadlock with a thread that had been // threads, so a malloc during gather would risk a deadlock with a
// suspended while holding the malloc lock. // thread that had been suspended while holding the malloc lock.
fastMallocForbid(); fastMallocForbid();
#endif #endif
// It is safe to access the registeredThreads list, because we earlier asserted that locks are being held, // It is safe to access the registeredThreads list, because we earlier asserted that locks are being held,
// and since this is a shared heap, they are real locks. // and since this is a shared heap, they are real locks.
for (Thread* thread = m_registeredThreads; thread; thread = thread->next) { for (Thread* thread = m_registeredThreads; thread; thread = thread->next) {
if (!pthread_equal(thread->posixThread, pthread_self())) if (!pthread_equal(thread->posixThread, pthread_self()))
markOtherThreadConservatively(conservativeSet, thread); gatherFromOtherThread(conservativeRoots, thread);
} }
#ifndef NDEBUG #ifndef NDEBUG
fastMallocAllow(); fastMallocAllow();
......
...@@ -19,8 +19,8 @@ ...@@ -19,8 +19,8 @@
* *
*/ */
#ifndef MachineStackMarker_h #ifndef MachineThreads_h
#define MachineStackMarker_h #define MachineThreads_h
#include <wtf/Noncopyable.h> #include <wtf/Noncopyable.h>
#include <wtf/ThreadingPrimitives.h> #include <wtf/ThreadingPrimitives.h>
...@@ -32,32 +32,32 @@ ...@@ -32,32 +32,32 @@
namespace JSC { namespace JSC {
class Heap; class Heap;
class ConservativeSet; class ConservativeRoots;
class MachineStackMarker { class MachineThreads {
WTF_MAKE_NONCOPYABLE(MachineStackMarker); WTF_MAKE_NONCOPYABLE(MachineThreads);
public: public:
MachineStackMarker(Heap*); MachineThreads(Heap*);
~MachineStackMarker(); ~MachineThreads();
void markMachineStackConservatively(ConservativeSet&); void gatherConservativeRoots(ConservativeRoots&);
#if ENABLE(JSC_MULTIPLE_THREADS) #if ENABLE(JSC_MULTIPLE_THREADS)
void makeUsableFromMultipleThreads(); void makeUsableFromMultipleThreads();
void registerThread(); // Only needs to be called by clients that can use the same heap from multiple threads. void addCurrentThread(); // Only needs to be called by clients that can use the same heap from multiple threads.
#endif #endif
private: private:
void markCurrentThreadConservatively(ConservativeSet&); void gatherFromCurrentThread(ConservativeRoots&);
void markCurrentThreadConservativelyInternal(ConservativeSet&); void gatherFromCurrentThreadInternal(ConservativeRoots&);
#if ENABLE(JSC_MULTIPLE_THREADS) #if ENABLE(JSC_MULTIPLE_THREADS)
class Thread; class Thread;
static void unregisterThread(void*); static void removeThread(void*);
void removeCurrentThread();
void unregisterThread(); void gatherFromOtherThread(ConservativeRoots&, Thread*);
void markOtherThreadConservatively(ConservativeSet&, Thread*);
#endif #endif
Heap* m_heap; Heap* m_heap;
...@@ -65,10 +65,10 @@ namespace JSC { ...@@ -65,10 +65,10 @@ namespace JSC {
#if ENABLE(JSC_MULTIPLE_THREADS) #if ENABLE(JSC_MULTIPLE_THREADS)
Mutex m_registeredThreadsMutex; Mutex m_registeredThreadsMutex;
Thread* m_registeredThreads; Thread* m_registeredThreads;
pthread_key_t m_currentThreadRegistrar; pthread_key_t m_threadSpecific;
#endif #endif
}; };
} // namespace JSC } // namespace JSC
#endif // MachineStackMarker_h #endif // MachineThreads_h
...@@ -72,12 +72,12 @@ namespace JSC { ...@@ -72,12 +72,12 @@ namespace JSC {
m_markSets.append(MarkSet(values, values + count, properties)); m_markSets.append(MarkSet(values, values + count, properties));
} }
void append(ConservativeSet& conservativeSet) void append(ConservativeRoots& conservativeRoots)
{ {
JSCell** set = conservativeSet.set(); JSCell** roots = conservativeRoots.roots();
size_t size = conservativeSet.size(); size_t size = conservativeRoots.size();
for (size_t i = 0; i < size; ++i) for (size_t i = 0; i < size; ++i)
internalAppend(set[i]); internalAppend(roots[i]);
} }
inline void drain(); inline void drain();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment