Revision: 3985
Author: [email protected]
Date: Mon Mar  1 01:46:28 2010
Log: Merge r3971 and r3984 to trunk forming V8 version 2.1.2.4. This adds
the new context disposal notification API.
Review URL: http://codereview.chromium.org/660268
http://code.google.com/p/v8/source/detail?r=3985

Modified:
 /trunk/include/v8.h
 /trunk/src/api.cc
 /trunk/src/heap.cc
 /trunk/src/heap.h
 /trunk/src/version.cc

=======================================
--- /trunk/include/v8.h Fri Feb 19 00:53:10 2010
+++ /trunk/include/v8.h Mon Mar  1 01:46:28 2010
@@ -2473,6 +2473,12 @@
    */
   static void LowMemoryNotification();

+  /**
+   * Optional notification that a context has been disposed. V8 uses
+   * these notifications to guide the garbage collection heuristic.
+   */
+  static void ContextDisposedNotification();
+
  private:
   V8();

=======================================
--- /trunk/src/api.cc   Fri Feb 19 00:53:10 2010
+++ /trunk/src/api.cc   Mon Mar  1 01:46:28 2010
@@ -438,7 +438,7 @@
 void V8::DisposeGlobal(i::Object** obj) {
   LOG_API("DisposeGlobal");
   if (!i::V8::IsRunning()) return;
-  if ((*obj)->IsGlobalContext()) i::Heap::NotifyContextDisposed();
+ if ((*obj)->IsGlobalContext()) i::Heap::NotifyContextDisposedDeprecated();
   i::GlobalHandles::Destroy(obj);
 }

@@ -2819,6 +2819,12 @@
   if (!i::V8::IsRunning()) return;
   i::Heap::CollectAllGarbage(true);
 }
+
+
+void v8::V8::ContextDisposedNotification() {
+  if (!i::V8::IsRunning()) return;
+  i::Heap::NotifyContextDisposed();
+}


 const char* v8::V8::GetVersion() {
@@ -2857,7 +2863,7 @@
     // decide when should make a full GC.
 #else
     // Give the heap a chance to cleanup if we've disposed contexts.
-    i::Heap::CollectAllGarbageIfContextDisposed();
+    i::Heap::CollectAllGarbageIfContextDisposedDeprecated();
 #endif
     v8::Handle<ObjectTemplate> proxy_template = global_template;
     i::Handle<i::FunctionTemplateInfo> proxy_constructor;
=======================================
--- /trunk/src/heap.cc  Tue Feb 23 02:34:29 2010
+++ /trunk/src/heap.cc  Mon Mar  1 01:46:28 2010
@@ -115,7 +115,10 @@

 int Heap::always_allocate_scope_depth_ = 0;
 int Heap::linear_allocation_scope_depth_ = 0;
-bool Heap::context_disposed_pending_ = false;
+
+int Heap::contexts_disposed_ = 0;
+bool Heap::context_disposed_use_deprecated_heuristic_ = true;
+bool Heap::context_disposed_deprecated_pending_ = false;

 #ifdef DEBUG
 bool Heap::allocation_allowed_ = true;
@@ -371,21 +374,29 @@
 }


-void Heap::CollectAllGarbageIfContextDisposed() {
+void Heap::CollectAllGarbageIfContextDisposedDeprecated() {
+  if (!context_disposed_use_deprecated_heuristic_) return;
   // If the garbage collector interface is exposed through the global
   // gc() function, we avoid being clever about forcing GCs when
   // contexts are disposed and leave it to the embedder to make
   // informed decisions about when to force a collection.
-  if (!FLAG_expose_gc && context_disposed_pending_) {
+  if (!FLAG_expose_gc && context_disposed_deprecated_pending_) {
     HistogramTimerScope scope(&Counters::gc_context);
     CollectAllGarbage(false);
   }
-  context_disposed_pending_ = false;
+  context_disposed_deprecated_pending_ = false;
 }


 void Heap::NotifyContextDisposed() {
-  context_disposed_pending_ = true;
+  context_disposed_use_deprecated_heuristic_ = false;
+  contexts_disposed_++;
+}
+
+
+void Heap::NotifyContextDisposedDeprecated() {
+  if (!context_disposed_use_deprecated_heuristic_) return;
+  context_disposed_deprecated_pending_ = true;
 }


@@ -620,7 +631,9 @@
   Shrink();

   Counters::objs_since_last_full.Set(0);
-  context_disposed_pending_ = false;
+
+  contexts_disposed_ = 0;
+  context_disposed_deprecated_pending_ = false;
 }


@@ -3072,6 +3085,13 @@
   static int number_idle_notifications = 0;
   static int last_gc_count = gc_count_;

+  if (!FLAG_expose_gc && (contexts_disposed_ > 0)) {
+    HistogramTimerScope scope(&Counters::gc_context);
+    CollectAllGarbage(false);
+    ASSERT(contexts_disposed_ == 0);
+    return false;
+  }
+
   bool finished = false;

   if (last_gc_count == gc_count_) {
=======================================
--- /trunk/src/heap.h   Tue Feb 23 02:34:29 2010
+++ /trunk/src/heap.h   Mon Mar  1 01:46:28 2010
@@ -634,10 +634,11 @@

   // Performs a full garbage collection if a context has been disposed
   // since the last time the check was performed.
-  static void CollectAllGarbageIfContextDisposed();
+  static void CollectAllGarbageIfContextDisposedDeprecated();

   // Notify the heap that a context has been disposed.
   static void NotifyContextDisposed();
+  static void NotifyContextDisposedDeprecated();

   // Utility to invoke the scavenger. This is needed in test code to
   // ensure correct callback for weak global handles.
@@ -908,7 +909,11 @@

   static int always_allocate_scope_depth_;
   static int linear_allocation_scope_depth_;
-  static bool context_disposed_pending_;
+
+  // For keeping track of context disposals.
+  static int contexts_disposed_;
+  static bool context_disposed_use_deprecated_heuristic_;
+  static bool context_disposed_deprecated_pending_;

 #if defined(V8_TARGET_ARCH_X64)
   static const int kMaxObjectSizeInNewSpace = 512*KB;
=======================================
--- /trunk/src/version.cc       Fri Feb 26 03:42:58 2010
+++ /trunk/src/version.cc       Mon Mar  1 01:46:28 2010
@@ -35,7 +35,7 @@
 #define MAJOR_VERSION     2
 #define MINOR_VERSION     1
 #define BUILD_NUMBER      2
-#define PATCH_LEVEL       3
+#define PATCH_LEVEL       4
 #define CANDIDATE_VERSION false

 // Define SONAME to have the SCons build the put a specific SONAME into the

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to