From 18b1e6d353501a30a750ac12da68bdc0f93b923e Mon Sep 17 00:00:00 2001 From: jochen Date: Mon, 22 Dec 2014 06:27:19 -0800 Subject: [PATCH] Enable the embedder to specify what kind of context was disposed This API is used by Blink to inform V8 about HTML frames being disposed. Using the optional parameter, Blink can tell V8 whether the disposed frame was a main frame. In that case, we might want to reset GC parameters BUG=none R=hpayer@chromium.org LOG=y Review URL: https://codereview.chromium.org/823583003 Cr-Commit-Position: refs/heads/master@{#25926} --- include/v8.h | 5 ++++- src/api.cc | 4 ++-- src/heap/heap.cc | 3 ++- src/heap/heap.h | 2 +- src/runtime/runtime-test.cc | 2 +- test/cctest/test-heap.cc | 2 +- 6 files changed, 11 insertions(+), 7 deletions(-) diff --git a/include/v8.h b/include/v8.h index b7ccdbf61..d35f2fcb2 100644 --- a/include/v8.h +++ b/include/v8.h @@ -5180,8 +5180,11 @@ class V8_EXPORT Isolate { * these notifications to guide the GC heuristic. Returns the number * of context disposals - including this one - since the last time * V8 had a chance to clean up. + * + * The optional parameter |dependant_context| specifies whether the disposed + * context was depending on state from other contexts or not. */ - int ContextDisposedNotification(); + int ContextDisposedNotification(bool dependant_context = true); /** * Allows the host application to provide the address of a function that is diff --git a/src/api.cc b/src/api.cc index 65777bc0f..61e565f97 100644 --- a/src/api.cc +++ b/src/api.cc @@ -6742,9 +6742,9 @@ void Isolate::LowMemoryNotification() { } -int Isolate::ContextDisposedNotification() { +int Isolate::ContextDisposedNotification(bool dependant_context) { i::Isolate* isolate = reinterpret_cast(this); - return isolate->heap()->NotifyContextDisposed(); + return isolate->heap()->NotifyContextDisposed(dependant_context); } diff --git a/src/heap/heap.cc b/src/heap/heap.cc index 56e961445..86d48a243 100644 --- a/src/heap/heap.cc +++ b/src/heap/heap.cc @@ -863,7 +863,8 @@ bool Heap::CollectGarbage(GarbageCollector collector, const char* gc_reason, } -int Heap::NotifyContextDisposed() { +int Heap::NotifyContextDisposed(bool dependant_context) { + // TODO(hpayer): Reset heap shrinking if dependant_context is false. if (isolate()->concurrent_recompilation_enabled()) { // Flush the queued recompilation tasks. isolate()->optimizing_compiler_thread()->Flush(); diff --git a/src/heap/heap.h b/src/heap/heap.h index f891bbddc..30271313e 100644 --- a/src/heap/heap.h +++ b/src/heap/heap.h @@ -767,7 +767,7 @@ class Heap { bool IsHeapIterable(); // Notify the heap that a context has been disposed. - int NotifyContextDisposed(); + int NotifyContextDisposed(bool dependant_context); inline void increment_scan_on_scavenge_pages() { scan_on_scavenge_pages_++; diff --git a/src/runtime/runtime-test.cc b/src/runtime/runtime-test.cc index 7aa280917..9faa2dc69 100644 --- a/src/runtime/runtime-test.cc +++ b/src/runtime/runtime-test.cc @@ -170,7 +170,7 @@ RUNTIME_FUNCTION(Runtime_ClearFunctionTypeFeedback) { RUNTIME_FUNCTION(Runtime_NotifyContextDisposed) { HandleScope scope(isolate); DCHECK(args.length() == 0); - isolate->heap()->NotifyContextDisposed(); + isolate->heap()->NotifyContextDisposed(true); return isolate->heap()->undefined_value(); } diff --git a/test/cctest/test-heap.cc b/test/cctest/test-heap.cc index d9dcc9040..f8a7df20c 100644 --- a/test/cctest/test-heap.cc +++ b/test/cctest/test-heap.cc @@ -1579,7 +1579,7 @@ TEST(TestInternalWeakLists) { } // Force compilation cache cleanup. - CcTest::heap()->NotifyContextDisposed(); + CcTest::heap()->NotifyContextDisposed(true); CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); // Dispose the native contexts one by one. -- 2.34.1