Title: [114772] trunk/Source/_javascript_Core
- Revision
- 114772
- Author
- [email protected]
- Date
- 2012-04-20 12:55:21 -0700 (Fri, 20 Apr 2012)
Log Message
Heap should cancel GC timer at the start of the collection
https://bugs.webkit.org/show_bug.cgi?id=84477
Reviewed by Geoffrey Garen.
Currently the Heap cancels the GC timer at the conclusion of a collection.
We should change this to be at the beginning because something (e.g. a finalizer)
could call didAbandonObjectGraph(), which will schedule the timer, but then
we'll immediately unschedule the timer at the conclusion of the collection,
thus potentially preventing large swaths of memory from being reclaimed in a timely manner.
* API/JSBase.cpp:
(JSGarbageCollect): Remove outdated fix-me and remove check for whether the Heap is
busy or not, since we're just scheduling a timer to run a GC in the future.
* heap/Heap.cpp:
(JSC::Heap::collect): Rename didCollect to willCollect and move the call to the
top of Heap::collect.
* runtime/GCActivityCallback.cpp: Renamed didCollect to willCollect.
(JSC::DefaultGCActivityCallback::willCollect):
* runtime/GCActivityCallback.h: Ditto.
(JSC::GCActivityCallback::willCollect):
(DefaultGCActivityCallback):
* runtime/GCActivityCallbackCF.cpp: Ditto.
(JSC::DefaultGCActivityCallback::willCollect):
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/API/JSBase.cpp (114771 => 114772)
--- trunk/Source/_javascript_Core/API/JSBase.cpp 2012-04-20 19:36:13 UTC (rev 114771)
+++ trunk/Source/_javascript_Core/API/JSBase.cpp 2012-04-20 19:55:21 UTC (rev 114772)
@@ -100,13 +100,7 @@
ExecState* exec = toJS(ctx);
APIEntryShim entryShim(exec, false);
- JSGlobalData& globalData = exec->globalData();
- if (!globalData.heap.isBusy())
- globalData.heap.activityCallback()->didAbandonObjectGraph();
-
- // FIXME: Perhaps we should trigger a second mark and sweep
- // once the garbage collector is done if this is called when
- // the collector is busy.
+ exec->globalData().heap.activityCallback()->didAbandonObjectGraph();
}
void JSReportExtraMemoryCost(JSContextRef ctx, size_t size)
Modified: trunk/Source/_javascript_Core/ChangeLog (114771 => 114772)
--- trunk/Source/_javascript_Core/ChangeLog 2012-04-20 19:36:13 UTC (rev 114771)
+++ trunk/Source/_javascript_Core/ChangeLog 2012-04-20 19:55:21 UTC (rev 114772)
@@ -1,5 +1,32 @@
2012-04-20 Mark Hahnenberg <[email protected]>
+ Heap should cancel GC timer at the start of the collection
+ https://bugs.webkit.org/show_bug.cgi?id=84477
+
+ Reviewed by Geoffrey Garen.
+
+ Currently the Heap cancels the GC timer at the conclusion of a collection.
+ We should change this to be at the beginning because something (e.g. a finalizer)
+ could call didAbandonObjectGraph(), which will schedule the timer, but then
+ we'll immediately unschedule the timer at the conclusion of the collection,
+ thus potentially preventing large swaths of memory from being reclaimed in a timely manner.
+
+ * API/JSBase.cpp:
+ (JSGarbageCollect): Remove outdated fix-me and remove check for whether the Heap is
+ busy or not, since we're just scheduling a timer to run a GC in the future.
+ * heap/Heap.cpp:
+ (JSC::Heap::collect): Rename didCollect to willCollect and move the call to the
+ top of Heap::collect.
+ * runtime/GCActivityCallback.cpp: Renamed didCollect to willCollect.
+ (JSC::DefaultGCActivityCallback::willCollect):
+ * runtime/GCActivityCallback.h: Ditto.
+ (JSC::GCActivityCallback::willCollect):
+ (DefaultGCActivityCallback):
+ * runtime/GCActivityCallbackCF.cpp: Ditto.
+ (JSC::DefaultGCActivityCallback::willCollect):
+
+2012-04-20 Mark Hahnenberg <[email protected]>
+
JSGarbageCollect should not call collectAllGarbage()
https://bugs.webkit.org/show_bug.cgi?id=84476
Modified: trunk/Source/_javascript_Core/heap/Heap.cpp (114771 => 114772)
--- trunk/Source/_javascript_Core/heap/Heap.cpp 2012-04-20 19:36:13 UTC (rev 114771)
+++ trunk/Source/_javascript_Core/heap/Heap.cpp 2012-04-20 19:55:21 UTC (rev 114772)
@@ -801,6 +801,8 @@
ASSERT(m_isSafeToCollect);
_javascript_CORE_GC_BEGIN();
+ m_activityCallback->willCollect();
+
double lastGCStartTime = WTF::currentTime();
if (lastGCStartTime - m_lastCodeDiscardTime > minute) {
discardAllCompiledCode();
@@ -865,8 +867,6 @@
double lastGCEndTime = WTF::currentTime();
m_lastGCLength = lastGCEndTime - lastGCStartTime;
_javascript_CORE_GC_END();
-
- m_activityCallback->didCollect();
}
void Heap::canonicalizeCellLivenessData()
Modified: trunk/Source/_javascript_Core/runtime/GCActivityCallback.cpp (114771 => 114772)
--- trunk/Source/_javascript_Core/runtime/GCActivityCallback.cpp 2012-04-20 19:36:13 UTC (rev 114771)
+++ trunk/Source/_javascript_Core/runtime/GCActivityCallback.cpp 2012-04-20 19:55:21 UTC (rev 114772)
@@ -46,7 +46,7 @@
{
}
-void DefaultGCActivityCallback::didCollect()
+void DefaultGCActivityCallback::willCollect()
{
}
Modified: trunk/Source/_javascript_Core/runtime/GCActivityCallback.h (114771 => 114772)
--- trunk/Source/_javascript_Core/runtime/GCActivityCallback.h 2012-04-20 19:36:13 UTC (rev 114771)
+++ trunk/Source/_javascript_Core/runtime/GCActivityCallback.h 2012-04-20 19:55:21 UTC (rev 114772)
@@ -44,7 +44,7 @@
public:
virtual ~GCActivityCallback() { }
virtual void didAllocate(size_t) { }
- virtual void didCollect() { }
+ virtual void willCollect() { }
virtual void didAbandonObjectGraph() { }
virtual void synchronize() { }
@@ -62,7 +62,7 @@
virtual ~DefaultGCActivityCallback();
virtual void didAllocate(size_t);
- virtual void didCollect();
+ virtual void willCollect();
virtual void didAbandonObjectGraph();
virtual void synchronize();
Modified: trunk/Source/_javascript_Core/runtime/GCActivityCallbackCF.cpp (114771 => 114772)
--- trunk/Source/_javascript_Core/runtime/GCActivityCallbackCF.cpp 2012-04-20 19:36:13 UTC (rev 114771)
+++ trunk/Source/_javascript_Core/runtime/GCActivityCallbackCF.cpp 2012-04-20 19:55:21 UTC (rev 114772)
@@ -121,7 +121,7 @@
scheduleTimer(d.get());
}
-void DefaultGCActivityCallback::didCollect()
+void DefaultGCActivityCallback::willCollect()
{
cancelTimer(d.get());
}
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes