Tweak the context disposal GC heuristic: If the garbage collector
authorkasperl@chromium.org <kasperl@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Thu, 5 Mar 2009 07:44:13 +0000 (07:44 +0000)
committerkasperl@chromium.org <kasperl@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Thu, 5 Mar 2009 07:44:13 +0000 (07:44 +0000)
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.
Review URL: http://codereview.chromium.org/40154

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

src/heap.cc

index d088463..3a6f301 100644 (file)
@@ -295,11 +295,15 @@ void Heap::CollectAllGarbage() {
 
 
 void Heap::CollectAllGarbageIfContextDisposed() {
-  if (context_disposed_pending_) {
+  // 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_) {
     StatsRateScope scope(&Counters::gc_context);
     CollectAllGarbage();
-    context_disposed_pending_ = false;
   }
+  context_disposed_pending_ = false;
 }