+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.
// 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;
}
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;
}
}
void Heap::collectAllGarbage()
+{
+ reset(DoSweep);
+}
+
+void Heap::reset(SweepToggle sweepToggle)
{
ASSERT(globalData()->identifierTable == wtfThreadData().currentIdentifierTable());
JAVASCRIPTCORE_GC_BEGIN();
JAVASCRIPTCORE_GC_MARKED();
m_markedSpace.reset();
- m_markedSpace.sweep();
m_extraCost = 0;
+ if (sweepToggle == DoSweep)
+ m_markedSpace.sweep();
+
JAVASCRIPTCORE_GC_END();
(*m_activityCallback)();
void updateWeakGCHandles();
WeakGCHandlePool* weakGCHandlePool(size_t index);
+
+ enum SweepToggle { DoNotSweep, DoSweep };
+ void reset(SweepToggle);
RegisterFile& registerFile();