summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--V8Binding/v8/include/v8.h8
-rw-r--r--V8Binding/v8/src/api.cc6
-rw-r--r--WebCore/bindings/v8/ScriptController.cpp5
-rw-r--r--WebKit/android/jni/WebCoreFrameBridge.cpp3
4 files changed, 21 insertions, 1 deletions
diff --git a/V8Binding/v8/include/v8.h b/V8Binding/v8/include/v8.h
index 83d5bed..6815ec9 100644
--- a/V8Binding/v8/include/v8.h
+++ b/V8Binding/v8/include/v8.h
@@ -2184,6 +2184,14 @@ class V8EXPORT V8 {
*/
static int GetLogLines(int from_pos, char* dest_buf, int max_size);
+#if defined(ANDROID)
+ /**
+ * Android system sends the browser low memory signal, and it is good to
+ * collect JS heap, which can free some DOM nodes.
+ * This function should ONLY be used by the browser in low memory condition.
+ */
+ static void CollectAllGarbage();
+#endif
/**
* Releases any resources used by v8 and stops any utility threads
diff --git a/V8Binding/v8/src/api.cc b/V8Binding/v8/src/api.cc
index 4222353..3eb6d60 100644
--- a/V8Binding/v8/src/api.cc
+++ b/V8Binding/v8/src/api.cc
@@ -3298,6 +3298,12 @@ int V8::GetLogLines(int from_pos, char* dest_buf, int max_size) {
return 0;
}
+
+void V8::CollectAllGarbage() {
+ i::Heap::CollectAllGarbage();
+}
+
+
String::Utf8Value::Utf8Value(v8::Handle<v8::Value> obj) {
EnsureInitialized("v8::String::Utf8Value::Utf8Value()");
if (obj.IsEmpty()) {
diff --git a/WebCore/bindings/v8/ScriptController.cpp b/WebCore/bindings/v8/ScriptController.cpp
index eecff45..674de43 100644
--- a/WebCore/bindings/v8/ScriptController.cpp
+++ b/WebCore/bindings/v8/ScriptController.cpp
@@ -251,8 +251,11 @@ void ScriptController::collectGarbage()
return;
v8::Context::Scope scope(context);
-
+#if PLATFORM(ANDROID)
+ v8::V8::CollectAllGarbage();
+#else
m_proxy->evaluate(ScriptSourceCode("if (window.gc) void(gc());"), 0);
+#endif
}
bool ScriptController::haveInterpreter() const
diff --git a/WebKit/android/jni/WebCoreFrameBridge.cpp b/WebKit/android/jni/WebCoreFrameBridge.cpp
index f47603b..4672427 100644
--- a/WebKit/android/jni/WebCoreFrameBridge.cpp
+++ b/WebKit/android/jni/WebCoreFrameBridge.cpp
@@ -1136,6 +1136,9 @@ static void ClearCache(JNIEnv *env, jobject obj)
#if USE(JSC)
// force JavaScript to GC when clear cache
WebCore::gcController().garbageCollectSoon();
+#elif USE(V8)
+ WebCore::Frame* pFrame = GET_NATIVE_FRAME(env, obj);
+ pFrame->script()->collectGarbage();
#endif // USE(JSC)
}