Commit 7ddf61bc authored by ggaren@apple.com's avatar ggaren@apple.com

2011-01-30 Geoffrey Garen <ggaren@apple.com>

        Reviewed by Oliver Hunt.

        Filter all Heap collection through a common reset function, in
        preparation for adding features triggered by collection.
        https://bugs.webkit.org/show_bug.cgi?id=53396
        
        SunSpider reports no change.

        * runtime/Heap.cpp:
        (JSC::Heap::reportExtraMemoryCostSlowCase): When we're over the extraCost
        limit, just call collectAllGarbage() instead of rolling our own special
        way of resetting the heap. In theory, this may be slower in some cases,
        but it also fixes cases of pathological heap growth that we've seen,
        where the only objects being allocated are temporary and huge
        (<rdar://problem/8885843>).

        (JSC::Heap::allocate):
        (JSC::Heap::collectAllGarbage): Use the shared reset function.

        (JSC::Heap::reset):
        * runtime/Heap.h: Carved a new shared reset function out of the old
        collectAllGarbage.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@77094 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 9f33cba2
2011-01-30 Geoffrey Garen <ggaren@apple.com>
Reviewed by Oliver Hunt.
Filter all Heap collection through a common reset function, in
preparation for adding features triggered by collection.
https://bugs.webkit.org/show_bug.cgi?id=53396
SunSpider reports no change.
* runtime/Heap.cpp:
(JSC::Heap::reportExtraMemoryCostSlowCase): When we're over the extraCost
limit, just call collectAllGarbage() instead of rolling our own special
way of resetting the heap. In theory, this may be slower in some cases,
but it also fixes cases of pathological heap growth that we've seen,
where the only objects being allocated are temporary and huge
(<rdar://problem/8885843>).
(JSC::Heap::allocate):
(JSC::Heap::collectAllGarbage): Use the shared reset function.
(JSC::Heap::reset):
* runtime/Heap.h: Carved a new shared reset function out of the old
collectAllGarbage.
2011-01-30 Sheriff Bot <webkit.review.bot@gmail.com>
Unreviewed, rolling out r77025.
......
......@@ -90,20 +90,8 @@ void Heap::reportExtraMemoryCostSlowCase(size_t cost)
// if a large value survives one garbage collection, there is not much point to
// collecting more frequently as long as it stays alive.
if (m_extraCost > maxExtraCost && m_extraCost > m_markedSpace.capacity() / 2) {
JAVASCRIPTCORE_GC_BEGIN();
markRoots();
JAVASCRIPTCORE_GC_MARKED();
m_markedSpace.reset();
m_extraCost = 0;
JAVASCRIPTCORE_GC_END();
(*m_activityCallback)();
}
if (m_extraCost > maxExtraCost && m_extraCost > m_markedSpace.capacity() / 2)
collectAllGarbage();
m_extraCost += cost;
}
......@@ -123,25 +111,14 @@ void* Heap::allocate(size_t s)
m_operationInProgress = Allocation;
void* result = m_markedSpace.allocate(s);
m_operationInProgress = NoOperation;
if (!result) {
JAVASCRIPTCORE_GC_BEGIN();
markRoots();
JAVASCRIPTCORE_GC_MARKED();
m_markedSpace.reset();
m_extraCost = 0;
JAVASCRIPTCORE_GC_END();
(*m_activityCallback)();
reset(DoNotSweep);
m_operationInProgress = Allocation;
result = m_markedSpace.allocate(s);
m_operationInProgress = NoOperation;
}
ASSERT(result);
return result;
}
......@@ -388,6 +365,11 @@ bool Heap::isBusy()
}
void Heap::collectAllGarbage()
{
reset(DoSweep);
}
void Heap::reset(SweepToggle sweepToggle)
{
ASSERT(globalData()->identifierTable == wtfThreadData().currentIdentifierTable());
JAVASCRIPTCORE_GC_BEGIN();
......@@ -397,9 +379,11 @@ void Heap::collectAllGarbage()
JAVASCRIPTCORE_GC_MARKED();
m_markedSpace.reset();
m_markedSpace.sweep();
m_extraCost = 0;
if (sweepToggle == DoSweep)
m_markedSpace.sweep();
JAVASCRIPTCORE_GC_END();
(*m_activityCallback)();
......
......@@ -113,6 +113,9 @@ namespace JSC {
void updateWeakGCHandles();
WeakGCHandlePool* weakGCHandlePool(size_t index);
enum SweepToggle { DoNotSweep, DoSweep };
void reset(SweepToggle);
RegisterFile& registerFile();
......
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