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:
UNUSED_PARAM(registerThread);
#if ENABLE(JSC_MULTIPLE_THREADS)
if (registerThread)
globalData->heap.machineStackMarker().registerThread();
globalData->heap.machineThreads().addCurrentThread();
#endif
m_globalData->heap.activityCallback()->synchronize();
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>
BUILD FIX for armv7 after r80969
......
......@@ -163,6 +163,7 @@ __ZN3JSC14JSGlobalObject3putEPNS_9ExecStateERKNS_10IdentifierENS_7JSValueERNS_15
__ZN3JSC14JSGlobalObject4initEPNS_8JSObjectE
__ZN3JSC14JSGlobalObjectD2Ev
__ZN3JSC14JSGlobalObjectnwEmPNS_12JSGlobalDataE
__ZN3JSC14MachineThreads16addCurrentThreadEv
__ZN3JSC14SamplingThread4stopEv
__ZN3JSC14SamplingThread5startEj
__ZN3JSC14TimeoutChecker10didTimeOutEPNS_9ExecStateE
......@@ -184,7 +185,6 @@ __ZN3JSC17PropertyNameArray3addEPN3WTF10StringImplE
__ZN3JSC17constructFunctionEPNS_9ExecStateERKNS_7ArgListERKNS_10IdentifierERKNS_7UStringEi
__ZN3JSC17createSyntaxErrorEPNS_9ExecStateERKNS_7UStringE
__ZN3JSC18DebuggerActivationC1ERNS_12JSGlobalDataEPNS_8JSObjectE
__ZN3JSC18MachineStackMarker14registerThreadEv
__ZN3JSC18PropertyDescriptor11setWritableEb
__ZN3JSC18PropertyDescriptor12setUndefinedEv
__ZN3JSC18PropertyDescriptor13setDescriptorENS_7JSValueEj
......
......@@ -277,7 +277,7 @@ EXPORTS
?randomNumber@WTF@@YANXZ
?recompileAllJSFunctions@Debugger@JSC@@QAEXPAVJSGlobalData@2@@Z
?regExpFlags@JSC@@YA?AW4RegExpFlags@1@ABVUString@1@@Z
?registerThread@MachineStackMarker@JSC@@QAEXXZ
?addCurrentThread@MachineThreads@JSC@@QAEXXZ
?reifyString@StringBuilder@WTF@@AAEXXZ
?releaseDecommitted@OSAllocator@WTF@@SAXPAXI@Z
?releaseStack@MarkStack@JSC@@CAXPAXI@Z
......
......@@ -35,18 +35,18 @@ inline bool isPointerAligned(void* p)
return !((intptr_t)(p) & (sizeof(char*) - 1));
}
void ConservativeSet::grow()
void ConservativeRoots::grow()
{
size_t newCapacity = m_capacity == inlineCapacity ? nonInlineCapacity : m_capacity * 2;
JSCell** newSet = static_cast<JSCell**>(OSAllocator::reserveAndCommit(newCapacity * sizeof(JSCell*)));
memcpy(newSet, m_set, m_size * sizeof(JSCell*));
if (m_set != m_inlineSet)
OSAllocator::decommitAndRelease(m_set, m_capacity * sizeof(JSCell*));
JSCell** newRoots = static_cast<JSCell**>(OSAllocator::reserveAndCommit(newCapacity * sizeof(JSCell*)));
memcpy(newRoots, m_roots, m_size * sizeof(JSCell*));
if (m_roots != m_inlineRoots)
OSAllocator::decommitAndRelease(m_roots, m_capacity * sizeof(JSCell*));
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((static_cast<char*>(end) - static_cast<char*>(begin)) < 0x1000000);
......@@ -60,7 +60,7 @@ void ConservativeSet::add(void* begin, void* end)
if (m_size == m_capacity)
grow();
m_set[m_size++] = reinterpret_cast<JSCell*>(*it);
m_roots[m_size++] = reinterpret_cast<JSCell*>(*it);
}
}
......
......@@ -23,8 +23,8 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef ConservativeSet_h
#define ConservativeSet_h
#ifndef ConservativeRoots_h
#define ConservativeRoots_h
#include <wtf/OSAllocator.h>
#include <wtf/Vector.h>
......@@ -36,15 +36,15 @@ class Heap;
// May contain duplicates.
class ConservativeSet {
class ConservativeRoots {
public:
ConservativeSet(Heap*);
~ConservativeSet();
ConservativeRoots(Heap*);
~ConservativeRoots();
void add(void* begin, void* end);
size_t size();
JSCell** set();
JSCell** roots();
private:
static const size_t inlineCapacity = 128;
......@@ -53,36 +53,36 @@ private:
void grow();
Heap* m_heap;
JSCell** m_set;
JSCell** m_roots;
size_t m_size;
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_set(m_inlineSet)
, m_roots(m_inlineRoots)
, m_size(0)
, m_capacity(inlineCapacity)
{
}
inline ConservativeSet::~ConservativeSet()
inline ConservativeRoots::~ConservativeRoots()
{
if (m_set != m_inlineSet)
OSAllocator::decommitAndRelease(m_set, m_capacity * sizeof(JSCell*));
if (m_roots != m_inlineRoots)
OSAllocator::decommitAndRelease(m_roots, m_capacity * sizeof(JSCell*));
}
inline size_t ConservativeSet::size()
inline size_t ConservativeRoots::size()
{
return m_size;
}
inline JSCell** ConservativeSet::set()
inline JSCell** ConservativeRoots::roots()
{
return m_set;
return m_roots;
}
} // namespace JSC
#endif // ConservativeSet_h
#endif // ConservativeRoots_h
......@@ -46,7 +46,7 @@ Heap::Heap(JSGlobalData* globalData)
, m_markListSet(0)
, m_activityCallback(DefaultGCActivityCallback::create(this))
, m_globalData(globalData)
, m_machineStackMarker(this)
, m_machineThreads(this)
, m_markStack(globalData->jsArrayVPtr)
, m_handleHeap(globalData)
, m_extraCost(0)
......@@ -208,14 +208,14 @@ void Heap::markRoots()
// We gather the conservative set before clearing mark bits, because
// conservative gathering uses the mark bits from our last mark pass to
// determine whether a reference is valid.
ConservativeSet conservativeSet(this);
m_machineStackMarker.markMachineStackConservatively(conservativeSet);
conservativeSet.add(registerFile().start(), registerFile().end());
ConservativeRoots conservativeRoots(this);
m_machineThreads.gatherConservativeRoots(conservativeRoots);
conservativeRoots.add(registerFile().start(), registerFile().end());
m_markedSpace.clearMarks();
MarkStack& markStack = m_markStack;
markStack.append(conservativeSet);
markStack.append(conservativeRoots);
markStack.drain();
// Mark explicitly registered roots.
......
......@@ -65,7 +65,7 @@ namespace JSC {
JSGlobalData* globalData() const { return m_globalData; }
MarkedSpace& markedSpace() { return m_markedSpace; }
MachineStackMarker& machineStackMarker() { return m_machineStackMarker; }
MachineThreads& machineThreads() { return m_machineThreads; }
GCActivityCallback* activityCallback();
void setActivityCallback(PassOwnPtr<GCActivityCallback>);
......@@ -129,7 +129,7 @@ namespace JSC {
JSGlobalData* m_globalData;
MachineStackMarker m_machineStackMarker;
MachineThreads m_machineThreads;
MarkStack m_markStack;
HandleHeap m_handleHeap;
......
......@@ -128,7 +128,7 @@ namespace JSC {
#if ENABLE(JSC_MULTIPLE_THREADS)
// Will start tracking threads that use the heap, which is resource-heavy.
void makeUsableFromMultipleThreads() { heap.machineStackMarker().makeUsableFromMultipleThreads(); }
void makeUsableFromMultipleThreads() { heap.machineThreads().makeUsableFromMultipleThreads(); }
#endif
GlobalDataType globalDataType;
......
......@@ -78,7 +78,7 @@
#if USE(PTHREADS) && !OS(WINDOWS) && !OS(DARWIN)
#include <signal.h>
#ifndef SA_RESTART
#error MachineStackMarker requires SA_RESTART
#error MachineThreads requires SA_RESTART
#endif
#endif
......@@ -117,7 +117,7 @@ static void pthreadSignalHandlerSuspendResume(int signo)
}
#endif
class MachineStackMarker::Thread {
class MachineThreads::Thread {
public:
Thread(pthread_t pthread, const PlatformThread& platThread, void* base)
: posixThread(pthread)
......@@ -146,20 +146,20 @@ public:
#endif
MachineStackMarker::MachineStackMarker(Heap* heap)
MachineThreads::MachineThreads(Heap* heap)
: m_heap(heap)
#if ENABLE(JSC_MULTIPLE_THREADS)
, m_registeredThreads(0)
, m_currentThreadRegistrar(0)
, m_threadSpecific(0)
#endif
{
}
MachineStackMarker::~MachineStackMarker()
MachineThreads::~MachineThreads()
{
#if ENABLE(JSC_MULTIPLE_THREADS)
if (m_currentThreadRegistrar) {
int error = pthread_key_delete(m_currentThreadRegistrar);
if (m_threadSpecific) {
int error = pthread_key_delete(m_threadSpecific);
ASSERT_UNUSED(error, !error);
}
......@@ -185,24 +185,24 @@ static inline PlatformThread getCurrentPlatformThread()
#endif
}
void MachineStackMarker::makeUsableFromMultipleThreads()
void MachineThreads::makeUsableFromMultipleThreads()
{
if (m_currentThreadRegistrar)
if (m_threadSpecific)
return;
int error = pthread_key_create(&m_currentThreadRegistrar, unregisterThread);
int error = pthread_key_create(&m_threadSpecific, removeThread);
if (error)
CRASH();
}
void MachineStackMarker::registerThread()
void MachineThreads::addCurrentThread()
{
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;
pthread_setspecific(m_currentThreadRegistrar, this);
pthread_setspecific(m_threadSpecific, this);
Thread* thread = new Thread(pthread_self(), getCurrentPlatformThread(), m_heap->globalData()->stack().origin());
MutexLocker lock(m_registeredThreadsMutex);
......@@ -211,13 +211,13 @@ void MachineStackMarker::registerThread()
m_registeredThreads = thread;
}
void MachineStackMarker::unregisterThread(void* p)
void MachineThreads::removeThread(void* p)
{
if (p)
static_cast<MachineStackMarker*>(p)->unregisterThread();
static_cast<MachineThreads*>(p)->removeCurrentThread();
}
void MachineStackMarker::unregisterThread()
void MachineThreads::removeCurrentThread()
{
pthread_t currentPosixThread = pthread_self();
......@@ -244,12 +244,12 @@ void MachineStackMarker::unregisterThread()
#endif
void NEVER_INLINE MachineStackMarker::markCurrentThreadConservativelyInternal(ConservativeSet& conservativeSet)
void NEVER_INLINE MachineThreads::gatherFromCurrentThreadInternal(ConservativeRoots& conservativeRoots)
{
void* begin = m_heap->globalData()->stack().current();
void* end = m_heap->globalData()->stack().origin();
swapIfBackwards(begin, end);
conservativeSet.add(begin, end);
conservativeRoots.add(begin, end);
}
#if COMPILER(GCC)
......@@ -258,7 +258,7 @@ void NEVER_INLINE MachineStackMarker::markCurrentThreadConservativelyInternal(Co
#define REGISTER_BUFFER_ALIGNMENT
#endif
void MachineStackMarker::markCurrentThreadConservatively(ConservativeSet& conservativeSet)
void MachineThreads::gatherFromCurrentThread(ConservativeRoots& conservativeRoots)
{
// setjmp forces volatile registers onto the stack
jmp_buf registers REGISTER_BUFFER_ALIGNMENT;
......@@ -271,7 +271,7 @@ void MachineStackMarker::markCurrentThreadConservatively(ConservativeSet& conser
#pragma warning(pop)
#endif
markCurrentThreadConservativelyInternal(conservativeSet);
gatherFromCurrentThreadInternal(conservativeRoots);
}
#if ENABLE(JSC_MULTIPLE_THREADS)
......@@ -435,20 +435,19 @@ static void freePlatformThreadRegisters(PlatformThreadRegisters& regs)
#endif
}
void MachineStackMarker::markOtherThreadConservatively(ConservativeSet& conservativeSet, Thread* thread)
void MachineThreads::gatherFromOtherThread(ConservativeRoots& conservativeRoots, Thread* thread)
{
suspendThread(thread->platformThread);
PlatformThreadRegisters regs;
size_t regSize = getPlatformThreadRegisters(thread->platformThread, regs);
// mark the thread's registers
conservativeSet.add(static_cast<void*>(&regs), static_cast<void*>(reinterpret_cast<char*>(&regs) + regSize));
conservativeRoots.add(static_cast<void*>(&regs), static_cast<void*>(reinterpret_cast<char*>(&regs) + regSize));
void* stackPointer = otherThreadStackPointer(regs);
void* stackBase = thread->stackBase;
swapIfBackwards(stackPointer, stackBase);
conservativeSet.add(stackPointer, stackBase);
conservativeRoots.add(stackPointer, stackBase);
resumeThread(thread->platformThread);
......@@ -457,27 +456,27 @@ void MachineStackMarker::markOtherThreadConservatively(ConservativeSet& conserva
#endif
void MachineStackMarker::markMachineStackConservatively(ConservativeSet& conservativeSet)
void MachineThreads::gatherConservativeRoots(ConservativeRoots& conservativeRoots)
{
markCurrentThreadConservatively(conservativeSet);
gatherFromCurrentThread(conservativeRoots);
#if ENABLE(JSC_MULTIPLE_THREADS)
if (m_currentThreadRegistrar) {
if (m_threadSpecific) {
MutexLocker lock(m_registeredThreadsMutex);
#ifndef NDEBUG
// Forbid malloc during the mark phase. Marking a thread suspends it, so
// a malloc inside markChildren() would risk a deadlock with a thread that had been
// suspended while holding the malloc lock.
// Forbid malloc during the gather phase. The gather phase suspends
// threads, so a malloc during gather would risk a deadlock with a
// thread that had been suspended while holding the malloc lock.
fastMallocForbid();
#endif
// 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.
for (Thread* thread = m_registeredThreads; thread; thread = thread->next) {
if (!pthread_equal(thread->posixThread, pthread_self()))
markOtherThreadConservatively(conservativeSet, thread);
gatherFromOtherThread(conservativeRoots, thread);
}
#ifndef NDEBUG
fastMallocAllow();
......
......@@ -19,8 +19,8 @@
*
*/
#ifndef MachineStackMarker_h
#define MachineStackMarker_h
#ifndef MachineThreads_h
#define MachineThreads_h
#include <wtf/Noncopyable.h>
#include <wtf/ThreadingPrimitives.h>
......@@ -32,32 +32,32 @@
namespace JSC {
class Heap;
class ConservativeSet;
class ConservativeRoots;
class MachineStackMarker {
WTF_MAKE_NONCOPYABLE(MachineStackMarker);
class MachineThreads {
WTF_MAKE_NONCOPYABLE(MachineThreads);
public:
MachineStackMarker(Heap*);
~MachineStackMarker();
MachineThreads(Heap*);
~MachineThreads();
void markMachineStackConservatively(ConservativeSet&);
void gatherConservativeRoots(ConservativeRoots&);
#if ENABLE(JSC_MULTIPLE_THREADS)
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
private:
void markCurrentThreadConservatively(ConservativeSet&);
void markCurrentThreadConservativelyInternal(ConservativeSet&);
void gatherFromCurrentThread(ConservativeRoots&);
void gatherFromCurrentThreadInternal(ConservativeRoots&);
#if ENABLE(JSC_MULTIPLE_THREADS)
class Thread;
static void unregisterThread(void*);
static void removeThread(void*);
void removeCurrentThread();
void unregisterThread();
void markOtherThreadConservatively(ConservativeSet&, Thread*);
void gatherFromOtherThread(ConservativeRoots&, Thread*);
#endif
Heap* m_heap;
......@@ -65,10 +65,10 @@ namespace JSC {
#if ENABLE(JSC_MULTIPLE_THREADS)
Mutex m_registeredThreadsMutex;
Thread* m_registeredThreads;
pthread_key_t m_currentThreadRegistrar;
pthread_key_t m_threadSpecific;
#endif
};
} // namespace JSC
#endif // MachineStackMarker_h
#endif // MachineThreads_h
......@@ -72,12 +72,12 @@ namespace JSC {
m_markSets.append(MarkSet(values, values + count, properties));
}
void append(ConservativeSet& conservativeSet)
void append(ConservativeRoots& conservativeRoots)
{
JSCell** set = conservativeSet.set();
size_t size = conservativeSet.size();
JSCell** roots = conservativeRoots.roots();
size_t size = conservativeRoots.size();
for (size_t i = 0; i < size; ++i)
internalAppend(set[i]);
internalAppend(roots[i]);
}
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