Commit 99cc9d93 authored by ggaren@apple.com's avatar ggaren@apple.com

2011-05-26 Geoffrey Garen <ggaren@apple.com>

        Reviewed by Geoffrey Garen.

        Factored out some Heap ASSERTs
        https://bugs.webkit.org/show_bug.cgi?id=61565

        * JavaScriptCore.exp:
        * heap/Heap.cpp:
        (JSC::isValidSharedInstanceThreadState):
        (JSC::isValidThreadState):
        (JSC::Heap::markRoots):
        (JSC::Heap::isValidAllocation):
        * heap/Heap.h:
        * runtime/JSCell.h:
        (JSC::JSCell::Heap::allocate):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@87434 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 3ae9394a
2011-05-26 Geoffrey Garen <ggaren@apple.com>
Reviewed by Geoffrey Garen.
Factored out some Heap ASSERTs
https://bugs.webkit.org/show_bug.cgi?id=61565
* JavaScriptCore.exp:
* heap/Heap.cpp:
(JSC::isValidSharedInstanceThreadState):
(JSC::isValidThreadState):
(JSC::Heap::markRoots):
(JSC::Heap::isValidAllocation):
* heap/Heap.h:
* runtime/JSCell.h:
(JSC::JSCell::Heap::allocate):
2011-05-26 Gavin Barraclough <barraclough@apple.com>
Reviewed by Geoff Garen.
......
......@@ -227,6 +227,7 @@ __ZN3JSC4Heap16allocateSlowCaseEm
__ZN3JSC4Heap16objectTypeCountsEv
__ZN3JSC4Heap17collectAllGarbageEv
__ZN3JSC4Heap17globalObjectCountEv
__ZN3JSC4Heap17isValidAllocationEm
__ZN3JSC4Heap19setActivityCallbackEN3WTF10PassOwnPtrINS_18GCActivityCallbackEEE
__ZN3JSC4Heap20protectedObjectCountEv
__ZN3JSC4Heap25protectedObjectTypeCountsEv
......
......@@ -41,6 +41,28 @@ namespace JSC {
const size_t minBytesPerCycle = 512 * 1024;
static inline bool isValidSharedInstanceThreadState()
{
if (!JSLock::lockCount())
return false;
if (!JSLock::currentThreadIsHoldingLock())
return false;
return true;
}
static inline bool isValidThreadState(JSGlobalData* globalData)
{
if (globalData->identifierTable != wtfThreadData().currentIdentifierTable())
return false;
if (globalData->isSharedInstance() && !isValidSharedInstanceThreadState())
return false;
return true;
}
Heap::Heap(JSGlobalData* globalData)
: m_operationInProgress(NoOperation)
, m_markedSpace(globalData)
......@@ -193,27 +215,18 @@ inline RegisterFile& Heap::registerFile()
void Heap::markRoots()
{
#ifndef NDEBUG
if (m_globalData->isSharedInstance()) {
ASSERT(JSLock::lockCount() > 0);
ASSERT(JSLock::currentThreadIsHoldingLock());
}
#endif
void* dummy;
ASSERT(m_operationInProgress == NoOperation);
ASSERT(isValidThreadState(m_globalData));
if (m_operationInProgress != NoOperation)
CRASH();
m_operationInProgress = Collection;
void* dummy;
MarkStack& visitor = m_markStack;
HeapRootVisitor heapRootMarker(visitor);
// We gather conservative roots before clearing mark bits because
// conservative gathering uses the mark bits from our last mark pass to
// determine whether a reference is valid.
// We gather conservative roots before clearing mark bits because conservative
// gathering uses the mark bits to determine whether a reference is valid.
ConservativeRoots machineThreadRoots(this);
m_machineThreads.gatherConservativeRoots(machineThreadRoots, &dummy);
......@@ -432,4 +445,18 @@ GCActivityCallback* Heap::activityCallback()
return m_activityCallback.get();
}
bool Heap::isValidAllocation(size_t bytes)
{
if (!isValidThreadState(m_globalData))
return false;
if (bytes > MarkedSpace::maxCellSize)
return false;
if (m_operationInProgress != NoOperation)
return false;
return true;
}
} // namespace JSC
......@@ -116,6 +116,7 @@ namespace JSC {
static const size_t minExtraCost = 256;
static const size_t maxExtraCost = 1024 * 1024;
bool isValidAllocation(size_t);
void* allocateSlowCase(size_t);
void reportExtraMemoryCostSlowCase(size_t);
......
......@@ -395,11 +395,7 @@ namespace JSC {
inline void* Heap::allocate(size_t bytes)
{
ASSERT(globalData()->identifierTable == wtfThreadData().currentIdentifierTable());
ASSERT(JSLock::lockCount() > 0);
ASSERT(JSLock::currentThreadIsHoldingLock());
ASSERT(bytes <= MarkedSpace::maxCellSize);
ASSERT(m_operationInProgress == NoOperation);
ASSERT(isValidAllocation(bytes));
m_operationInProgress = Allocation;
void* result = m_markedSpace.allocate(bytes);
......
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