Title: [120502] trunk/Source/_javascript_Core
Revision
120502
Author
[email protected]
Date
2012-06-15 15:24:21 -0700 (Fri, 15 Jun 2012)

Log Message

[BlackBerry] Put platform-specific GC policy in GCActivityCallback
https://bugs.webkit.org/show_bug.cgi?id=89236

Patch by Yong Li <[email protected]> on 2012-06-15
Reviewed by Rob Buis.

Add GCActivityCallbackBlackBerry.cpp and implement platform-specific
low memory GC policy there.

* PlatformBlackBerry.cmake:
* heap/Heap.h:
(JSC::Heap::isSafeToCollect): Added.
* runtime/GCActivityCallbackBlackBerry.cpp: Added.
(JSC):
(JSC::DefaultGCActivityCallbackPlatformData::DefaultGCActivityCallbackPlatformData):
(DefaultGCActivityCallbackPlatformData):
(JSC::DefaultGCActivityCallback::DefaultGCActivityCallback):
(JSC::DefaultGCActivityCallback::~DefaultGCActivityCallback):
(JSC::DefaultGCActivityCallback::didAllocate):
(JSC::DefaultGCActivityCallback::willCollect):
(JSC::DefaultGCActivityCallback::synchronize):
(JSC::DefaultGCActivityCallback::cancel):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (120501 => 120502)


--- trunk/Source/_javascript_Core/ChangeLog	2012-06-15 22:24:05 UTC (rev 120501)
+++ trunk/Source/_javascript_Core/ChangeLog	2012-06-15 22:24:21 UTC (rev 120502)
@@ -1,3 +1,27 @@
+2012-06-15  Yong Li  <[email protected]>
+
+        [BlackBerry] Put platform-specific GC policy in GCActivityCallback
+        https://bugs.webkit.org/show_bug.cgi?id=89236
+
+        Reviewed by Rob Buis.
+
+        Add GCActivityCallbackBlackBerry.cpp and implement platform-specific
+        low memory GC policy there.
+
+        * PlatformBlackBerry.cmake:
+        * heap/Heap.h:
+        (JSC::Heap::isSafeToCollect): Added.
+        * runtime/GCActivityCallbackBlackBerry.cpp: Added.
+        (JSC):
+        (JSC::DefaultGCActivityCallbackPlatformData::DefaultGCActivityCallbackPlatformData):
+        (DefaultGCActivityCallbackPlatformData):
+        (JSC::DefaultGCActivityCallback::DefaultGCActivityCallback):
+        (JSC::DefaultGCActivityCallback::~DefaultGCActivityCallback):
+        (JSC::DefaultGCActivityCallback::didAllocate):
+        (JSC::DefaultGCActivityCallback::willCollect):
+        (JSC::DefaultGCActivityCallback::synchronize):
+        (JSC::DefaultGCActivityCallback::cancel):
+
 2012-06-15  Filip Pizlo  <[email protected]>
 
         DFG should be able to set watchpoints on structure transitions in the

Modified: trunk/Source/_javascript_Core/PlatformBlackBerry.cmake (120501 => 120502)


--- trunk/Source/_javascript_Core/PlatformBlackBerry.cmake	2012-06-15 22:24:05 UTC (rev 120501)
+++ trunk/Source/_javascript_Core/PlatformBlackBerry.cmake	2012-06-15 22:24:21 UTC (rev 120502)
@@ -2,4 +2,12 @@
     "${BLACKBERRY_THIRD_PARTY_DIR}/icu"
 )
 
+LIST(REMOVE_ITEM _javascript_Core_SOURCES
+    runtime/GCActivityCallback.cpp
+)
+
+LIST(APPEND _javascript_Core_SOURCES
+    runtime/GCActivityCallbackBlackBerry.cpp
+)
+
 INSTALL(FILES "wtf/Forward.h" DESTINATION usr/include/browser/webkit/wtf)

Modified: trunk/Source/_javascript_Core/heap/Heap.h (120501 => 120502)


--- trunk/Source/_javascript_Core/heap/Heap.h	2012-06-15 22:24:05 UTC (rev 120501)
+++ trunk/Source/_javascript_Core/heap/Heap.h	2012-06-15 22:24:21 UTC (rev 120502)
@@ -119,6 +119,7 @@
         void addCompiledCode(ExecutableBase*);
 
         void notifyIsSafeToCollect() { m_isSafeToCollect = true; }
+        bool isSafeToCollect() const { return m_isSafeToCollect; }
 
         JS_EXPORT_PRIVATE void collectAllGarbage();
         enum SweepToggle { DoNotSweep, DoSweep };

Added: trunk/Source/_javascript_Core/runtime/GCActivityCallbackBlackBerry.cpp (0 => 120502)


--- trunk/Source/_javascript_Core/runtime/GCActivityCallbackBlackBerry.cpp	                        (rev 0)
+++ trunk/Source/_javascript_Core/runtime/GCActivityCallbackBlackBerry.cpp	2012-06-15 22:24:21 UTC (rev 120502)
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include "config.h"
+#include "GCActivityCallback.h"
+
+#include "Heap.h"
+#include <BlackBerryPlatformMemory.h>
+
+namespace JSC {
+
+struct DefaultGCActivityCallbackPlatformData {
+    explicit DefaultGCActivityCallbackPlatformData(Heap* heap) : m_heap(heap) { }
+    Heap* m_heap;
+};
+
+DefaultGCActivityCallback::DefaultGCActivityCallback(Heap* heap)
+    : d(adoptPtr(new DefaultGCActivityCallbackPlatformData(heap)))
+{
+}
+
+DefaultGCActivityCallback::~DefaultGCActivityCallback()
+{
+}
+
+void DefaultGCActivityCallback::didAllocate(size_t bytesAllocated)
+{
+    if (!BlackBerry::Platform::isMemoryLow())
+        return;
+
+    if (bytesAllocated < 1 * 1024 * 1024)
+        return;
+
+    if (d->m_heap->isBusy() || !d->m_heap->isSafeToCollect())
+        return;
+
+    d->m_heap->collect(Heap::DoNotSweep);
+}
+
+void DefaultGCActivityCallback::willCollect()
+{
+}
+
+void DefaultGCActivityCallback::synchronize()
+{
+}
+
+void DefaultGCActivityCallback::cancel()
+{
+}
+
+}
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to