Let the callers of V8::ContextDisposedNoticication() know
authorkasperl@chromium.org <kasperl@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Mon, 8 Mar 2010 11:19:20 +0000 (11:19 +0000)
committerkasperl@chromium.org <kasperl@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Mon, 8 Mar 2010 11:19:20 +0000 (11:19 +0000)
how many pending context disposals there are.
Review URL: http://codereview.chromium.org/669266

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4049 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

include/v8.h
src/api.cc
src/heap.cc
src/heap.h

index 238dddd..882eedd 100644 (file)
@@ -2507,9 +2507,11 @@ class V8EXPORT V8 {
 
   /**
    * Optional notification that a context has been disposed. V8 uses
-   * these notifications to guide the garbage collection heuristic.
+   * 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.
    */
-  static void ContextDisposedNotification();
+  static int ContextDisposedNotification();
 
  private:
   V8();
index 13bb47e..14b518c 100644 (file)
@@ -2872,9 +2872,9 @@ void v8::V8::LowMemoryNotification() {
 }
 
 
-void v8::V8::ContextDisposedNotification() {
-  if (!i::V8::IsRunning()) return;
-  i::Heap::NotifyContextDisposed();
+int v8::V8::ContextDisposedNotification() {
+  if (!i::V8::IsRunning()) return 0;
+  return i::Heap::NotifyContextDisposed();
 }
 
 
index f25b1a5..94d7175 100644 (file)
@@ -372,11 +372,6 @@ void Heap::CollectAllGarbage(bool force_compaction) {
 }
 
 
-void Heap::NotifyContextDisposed() {
-  contexts_disposed_++;
-}
-
-
 bool Heap::CollectGarbage(int requested_size, AllocationSpace space) {
   // The VM is in the GC state until exiting this function.
   VMState state(GC);
index 9abfce3..5cb896c 100644 (file)
@@ -643,7 +643,7 @@ class Heap : public AllStatic {
   static void CollectAllGarbage(bool force_compaction);
 
   // Notify the heap that a context has been disposed.
-  static void NotifyContextDisposed();
+  static int NotifyContextDisposed() { return ++contexts_disposed_; }
 
   // Utility to invoke the scavenger. This is needed in test code to
   // ensure correct callback for weak global handles.