summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/runtime/GCActivityCallbackBlackBerry.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/JavaScriptCore/runtime/GCActivityCallbackBlackBerry.cpp')
-rw-r--r--Source/JavaScriptCore/runtime/GCActivityCallbackBlackBerry.cpp19
1 files changed, 10 insertions, 9 deletions
diff --git a/Source/JavaScriptCore/runtime/GCActivityCallbackBlackBerry.cpp b/Source/JavaScriptCore/runtime/GCActivityCallbackBlackBerry.cpp
index 3b0b5a751..d9f96fa1e 100644
--- a/Source/JavaScriptCore/runtime/GCActivityCallbackBlackBerry.cpp
+++ b/Source/JavaScriptCore/runtime/GCActivityCallbackBlackBerry.cpp
@@ -20,39 +20,40 @@
#include "GCActivityCallback.h"
#include "Heap.h"
+#include "JSGlobalData.h"
#include <BlackBerryPlatformMemory.h>
namespace JSC {
+static const size_t bytesWorthGC = 4 * 1024 * 1024;
+
DefaultGCActivityCallback::DefaultGCActivityCallback(Heap* heap)
: GCActivityCallback(heap->globalData())
{
}
-DefaultGCActivityCallback::doWork()
+void DefaultGCActivityCallback::doWork()
{
+ m_globalData->heap.collect(Heap::DoNotSweep);
}
void DefaultGCActivityCallback::didAllocate(size_t bytesAllocated)
{
- if (!BlackBerry::Platform::isMemoryLow())
- return;
-
- if (bytesAllocated < 1 * 1024 * 1024)
+ if (bytesAllocated < bytesWorthGC || m_timer.started())
return;
- if (m_globalData->heap.isBusy() || !m_globalData->heap.isSafeToCollect())
- return;
-
- m_globalData->heap.collect(Heap::DoNotSweep);
+ // Try using ~5% CPU time.
+ m_timer.start(m_globalData->heap.lastGCLength() * 20);
}
void DefaultGCActivityCallback::willCollect()
{
+ cancel();
}
void DefaultGCActivityCallback::cancel()
{
+ m_timer.stop();
}
}