From 95964bd95fd7cf40e8b9d88671e45d1544cfe2ab Mon Sep 17 00:00:00 2001 From: "kasperl@chromium.org" Date: Mon, 8 Mar 2010 11:19:20 +0000 Subject: [PATCH] Let the callers of V8::ContextDisposedNoticication() know 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 | 6 ++++-- src/api.cc | 6 +++--- src/heap.cc | 5 ----- src/heap.h | 2 +- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/include/v8.h b/include/v8.h index 238dddd..882eedd 100644 --- a/include/v8.h +++ b/include/v8.h @@ -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(); diff --git a/src/api.cc b/src/api.cc index 13bb47e..14b518c 100644 --- a/src/api.cc +++ b/src/api.cc @@ -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(); } diff --git a/src/heap.cc b/src/heap.cc index f25b1a5..94d7175 100644 --- a/src/heap.cc +++ b/src/heap.cc @@ -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); diff --git a/src/heap.h b/src/heap.h index 9abfce3..5cb896c 100644 --- a/src/heap.h +++ b/src/heap.h @@ -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. -- 2.7.4