Enable the embedder to specify what kind of context was disposed
authorjochen <jochen@chromium.org>
Mon, 22 Dec 2014 14:27:19 +0000 (06:27 -0800)
committerCommit bot <commit-bot@chromium.org>
Mon, 22 Dec 2014 14:27:37 +0000 (14:27 +0000)
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
src/api.cc
src/heap/heap.cc
src/heap/heap.h
src/runtime/runtime-test.cc
test/cctest/test-heap.cc

index b7ccdbf..d35f2fc 100644 (file)
@@ -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
index 65777bc..61e565f 100644 (file)
@@ -6742,9 +6742,9 @@ void Isolate::LowMemoryNotification() {
 }
 
 
-int Isolate::ContextDisposedNotification() {
+int Isolate::ContextDisposedNotification(bool dependant_context) {
   i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
-  return isolate->heap()->NotifyContextDisposed();
+  return isolate->heap()->NotifyContextDisposed(dependant_context);
 }
 
 
index 56e9614..86d48a2 100644 (file)
@@ -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();
index f891bbd..3027131 100644 (file)
@@ -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_++;
index 7aa2809..9faa2dc 100644 (file)
@@ -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();
 }
 
index d9dcc90..f8a7df2 100644 (file)
@@ -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.