| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // | 2 // |
| 3 // Tests for heap profiler | 3 // Tests for heap profiler |
| 4 | 4 |
| 5 #include "v8.h" | 5 #include "v8.h" |
| 6 | 6 |
| 7 #include "cctest.h" | 7 #include "cctest.h" |
| 8 #include "heap-profiler.h" | 8 #include "heap-profiler.h" |
| 9 #include "snapshot.h" | 9 #include "snapshot.h" |
| 10 #include "utils-inl.h" | 10 #include "utils-inl.h" |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 LocalContext env; | 289 LocalContext env; |
| 290 | 290 |
| 291 CompileRun( | 291 CompileRun( |
| 292 "function A() {}\n" | 292 "function A() {}\n" |
| 293 "function B(x) { this.x = x; }\n" | 293 "function B(x) { this.x = x; }\n" |
| 294 "var a = new A();\n" | 294 "var a = new A();\n" |
| 295 "var b = new B(a);"); | 295 "var b = new B(a);"); |
| 296 const v8::HeapSnapshot* snapshot1 = | 296 const v8::HeapSnapshot* snapshot1 = |
| 297 v8::HeapProfiler::TakeSnapshot(v8::String::New("s1")); | 297 v8::HeapProfiler::TakeSnapshot(v8::String::New("s1")); |
| 298 | 298 |
| 299 HEAP->CollectAllGarbage(i::Heap::kForceCompactionMask); | 299 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 300 | 300 |
| 301 const v8::HeapSnapshot* snapshot2 = | 301 const v8::HeapSnapshot* snapshot2 = |
| 302 v8::HeapProfiler::TakeSnapshot(v8::String::New("s2")); | 302 v8::HeapProfiler::TakeSnapshot(v8::String::New("s2")); |
| 303 | 303 |
| 304 const v8::HeapGraphNode* global1 = GetGlobalObject(snapshot1); | 304 const v8::HeapGraphNode* global1 = GetGlobalObject(snapshot1); |
| 305 const v8::HeapGraphNode* global2 = GetGlobalObject(snapshot2); | 305 const v8::HeapGraphNode* global2 = GetGlobalObject(snapshot2); |
| 306 CHECK_NE_UINT64_T(0, global1->GetId()); | 306 CHECK_NE_UINT64_T(0, global1->GetId()); |
| 307 CHECK_EQ_UINT64_T(global1->GetId(), global2->GetId()); | 307 CHECK_EQ_UINT64_T(global1->GetId(), global2->GetId()); |
| 308 const v8::HeapGraphNode* A1 = | 308 const v8::HeapGraphNode* A1 = |
| 309 GetProperty(global1, v8::HeapGraphEdge::kProperty, "A"); | 309 GetProperty(global1, v8::HeapGraphEdge::kProperty, "A"); |
| (...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 884 CHECK_NE(NULL, global); | 884 CHECK_NE(NULL, global); |
| 885 // Verify that we can find this object by iteration. | 885 // Verify that we can find this object by iteration. |
| 886 const int nodes_count = snapshot->GetNodesCount(); | 886 const int nodes_count = snapshot->GetNodesCount(); |
| 887 int count = 0; | 887 int count = 0; |
| 888 for (int i = 0; i < nodes_count; ++i) { | 888 for (int i = 0; i < nodes_count; ++i) { |
| 889 if (snapshot->GetNode(i) == global) | 889 if (snapshot->GetNode(i) == global) |
| 890 ++count; | 890 ++count; |
| 891 } | 891 } |
| 892 CHECK_EQ(1, count); | 892 CHECK_EQ(1, count); |
| 893 } | 893 } |
| OLD | NEW |