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 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 | 407 |
408 TEST(HeapEntryIdsAndGC) { | 408 TEST(HeapEntryIdsAndGC) { |
409 v8::HandleScope scope; | 409 v8::HandleScope scope; |
410 LocalContext env; | 410 LocalContext env; |
411 | 411 |
412 CompileRun( | 412 CompileRun( |
413 "function A() {}\n" | 413 "function A() {}\n" |
414 "function B(x) { this.x = x; }\n" | 414 "function B(x) { this.x = x; }\n" |
415 "var a = new A();\n" | 415 "var a = new A();\n" |
416 "var b = new B(a);"); | 416 "var b = new B(a);"); |
| 417 v8::Local<v8::String> s1_str = v8_str("s1"); |
| 418 v8::Local<v8::String> s2_str = v8_str("s2"); |
417 const v8::HeapSnapshot* snapshot1 = | 419 const v8::HeapSnapshot* snapshot1 = |
418 v8::HeapProfiler::TakeSnapshot(v8_str("s1")); | 420 v8::HeapProfiler::TakeSnapshot(s1_str); |
419 | 421 |
420 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 422 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
421 | 423 |
422 const v8::HeapSnapshot* snapshot2 = | 424 const v8::HeapSnapshot* snapshot2 = |
423 v8::HeapProfiler::TakeSnapshot(v8_str("s2")); | 425 v8::HeapProfiler::TakeSnapshot(s2_str); |
| 426 |
| 427 // Second snapshot has one more string, it is it's name 's2'. |
| 428 CHECK_EQ_SNAPSHOT_OBJECT_ID( |
| 429 snapshot1->GetMaxSnapshotJSObjectId(), |
| 430 snapshot2->GetMaxSnapshotJSObjectId()); |
424 | 431 |
425 const v8::HeapGraphNode* global1 = GetGlobalObject(snapshot1); | 432 const v8::HeapGraphNode* global1 = GetGlobalObject(snapshot1); |
426 const v8::HeapGraphNode* global2 = GetGlobalObject(snapshot2); | 433 const v8::HeapGraphNode* global2 = GetGlobalObject(snapshot2); |
427 CHECK_NE_SNAPSHOT_OBJECT_ID(0, global1->GetId()); | 434 CHECK_NE_SNAPSHOT_OBJECT_ID(0, global1->GetId()); |
428 CHECK_EQ_SNAPSHOT_OBJECT_ID(global1->GetId(), global2->GetId()); | 435 CHECK_EQ_SNAPSHOT_OBJECT_ID(global1->GetId(), global2->GetId()); |
429 const v8::HeapGraphNode* A1 = | 436 const v8::HeapGraphNode* A1 = |
430 GetProperty(global1, v8::HeapGraphEdge::kProperty, "A"); | 437 GetProperty(global1, v8::HeapGraphEdge::kProperty, "A"); |
431 CHECK_NE(NULL, A1); | 438 CHECK_NE(NULL, A1); |
432 const v8::HeapGraphNode* A2 = | 439 const v8::HeapGraphNode* A2 = |
433 GetProperty(global2, v8::HeapGraphEdge::kProperty, "A"); | 440 GetProperty(global2, v8::HeapGraphEdge::kProperty, "A"); |
(...skipping 925 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1359 // Dipose the persistent handles in a different order. | 1366 // Dipose the persistent handles in a different order. |
1360 p_AAA.Dispose(); | 1367 p_AAA.Dispose(); |
1361 CHECK_EQ(global_handle_count + 2, | 1368 CHECK_EQ(global_handle_count + 2, |
1362 v8::HeapProfiler::GetPersistentHandleCount()); | 1369 v8::HeapProfiler::GetPersistentHandleCount()); |
1363 p_CCC.Dispose(); | 1370 p_CCC.Dispose(); |
1364 CHECK_EQ(global_handle_count + 1, | 1371 CHECK_EQ(global_handle_count + 1, |
1365 v8::HeapProfiler::GetPersistentHandleCount()); | 1372 v8::HeapProfiler::GetPersistentHandleCount()); |
1366 p_BBB.Dispose(); | 1373 p_BBB.Dispose(); |
1367 CHECK_EQ(global_handle_count, v8::HeapProfiler::GetPersistentHandleCount()); | 1374 CHECK_EQ(global_handle_count, v8::HeapProfiler::GetPersistentHandleCount()); |
1368 } | 1375 } |
OLD | NEW |