Revision: 4917
Author: [email protected]
Date: Tue Jun 22 07:58:08 2010
Log: Heap profiler: perform a GC round before taking a snapshot
to get rid of global object loaded from a snapshot. This
eliminates the "double global object" issue. Thanks to Mads
for suggesting this!

Review URL: http://codereview.chromium.org/2865013
http://code.google.com/p/v8/source/detail?r=4917

Modified:
 /branches/bleeding_edge/src/heap-profiler.cc
 /branches/bleeding_edge/test/cctest/test-heap-profiler.cc

=======================================
--- /branches/bleeding_edge/src/heap-profiler.cc        Wed Jun 16 12:53:24 2010
+++ /branches/bleeding_edge/src/heap-profiler.cc        Tue Jun 22 07:58:08 2010
@@ -360,6 +360,7 @@


 HeapSnapshot* HeapProfiler::TakeSnapshotImpl(const char* name) {
+  Heap::CollectAllGarbage(false);
HeapSnapshot* result = snapshots_->NewSnapshot(name, next_snapshot_uid_++);
   HeapSnapshotGenerator generator(result);
   generator.GenerateSnapshot();
=======================================
--- /branches/bleeding_edge/test/cctest/test-heap-profiler.cc Thu Jun 17 05:56:55 2010 +++ /branches/bleeding_edge/test/cctest/test-heap-profiler.cc Tue Jun 22 07:58:08 2010
@@ -431,21 +431,8 @@

 static const v8::HeapGraphNode* GetGlobalObject(
     const v8::HeapSnapshot* snapshot) {
-  if (i::Snapshot::IsEnabled()) {
-    // In case if snapshots are enabled, there will present a
-    // vanilla deserealized global object, without properties
-    // added by the test code.
-    CHECK_EQ(2, snapshot->GetHead()->GetChildrenCount());
-    // Choose the global object of a bigger size.
-    const v8::HeapGraphNode* node0 =
-        snapshot->GetHead()->GetChild(0)->GetToNode();
-    const v8::HeapGraphNode* node1 =
-        snapshot->GetHead()->GetChild(1)->GetToNode();
-    return node0->GetTotalSize() > node1->GetTotalSize() ? node0 : node1;
-  } else {
-    CHECK_EQ(1, snapshot->GetHead()->GetChildrenCount());
-    return snapshot->GetHead()->GetChild(0)->GetToNode();
-  }
+  CHECK_EQ(1, snapshot->GetHead()->GetChildrenCount());
+  return snapshot->GetHead()->GetChild(0)->GetToNode();
 }


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

Reply via email to