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 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 v8::Local<v8::String> s2_str = v8_str("s2"); | 418 v8::Local<v8::String> s2_str = v8_str("s2"); |
419 const v8::HeapSnapshot* snapshot1 = | 419 const v8::HeapSnapshot* snapshot1 = |
420 v8::HeapProfiler::TakeSnapshot(s1_str); | 420 v8::HeapProfiler::TakeSnapshot(s1_str); |
421 | 421 |
422 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 422 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
423 | 423 |
424 const v8::HeapSnapshot* snapshot2 = | 424 const v8::HeapSnapshot* snapshot2 = |
425 v8::HeapProfiler::TakeSnapshot(s2_str); | 425 v8::HeapProfiler::TakeSnapshot(s2_str); |
426 | 426 |
427 // Second snapshot has one more string, it is it's name 's2'. | 427 // Second snapshot has one more string, it is it's name 's2'. |
428 CHECK_EQ_SNAPSHOT_OBJECT_ID( | 428 CHECK( |
429 snapshot1->GetMaxSnapshotJSObjectId(), | 429 snapshot1->GetMaxSnapshotJSObjectId() <= |
430 snapshot2->GetMaxSnapshotJSObjectId()); | 430 snapshot2->GetMaxSnapshotJSObjectId() && |
| 431 snapshot2->GetMaxSnapshotJSObjectId() <= |
| 432 snapshot1->GetMaxSnapshotJSObjectId() + i::HeapObjectsMap::kObjectIdStep); |
431 | 433 |
432 const v8::HeapGraphNode* global1 = GetGlobalObject(snapshot1); | 434 const v8::HeapGraphNode* global1 = GetGlobalObject(snapshot1); |
433 const v8::HeapGraphNode* global2 = GetGlobalObject(snapshot2); | 435 const v8::HeapGraphNode* global2 = GetGlobalObject(snapshot2); |
434 CHECK_NE_SNAPSHOT_OBJECT_ID(0, global1->GetId()); | 436 CHECK_NE_SNAPSHOT_OBJECT_ID(0, global1->GetId()); |
435 CHECK_EQ_SNAPSHOT_OBJECT_ID(global1->GetId(), global2->GetId()); | 437 CHECK_EQ_SNAPSHOT_OBJECT_ID(global1->GetId(), global2->GetId()); |
436 const v8::HeapGraphNode* A1 = | 438 const v8::HeapGraphNode* A1 = |
437 GetProperty(global1, v8::HeapGraphEdge::kProperty, "A"); | 439 GetProperty(global1, v8::HeapGraphEdge::kProperty, "A"); |
438 CHECK_NE(NULL, A1); | 440 CHECK_NE(NULL, A1); |
439 const v8::HeapGraphNode* A2 = | 441 const v8::HeapGraphNode* A2 = |
440 GetProperty(global2, v8::HeapGraphEdge::kProperty, "A"); | 442 GetProperty(global2, v8::HeapGraphEdge::kProperty, "A"); |
(...skipping 925 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1366 // Dipose the persistent handles in a different order. | 1368 // Dipose the persistent handles in a different order. |
1367 p_AAA.Dispose(); | 1369 p_AAA.Dispose(); |
1368 CHECK_EQ(global_handle_count + 2, | 1370 CHECK_EQ(global_handle_count + 2, |
1369 v8::HeapProfiler::GetPersistentHandleCount()); | 1371 v8::HeapProfiler::GetPersistentHandleCount()); |
1370 p_CCC.Dispose(); | 1372 p_CCC.Dispose(); |
1371 CHECK_EQ(global_handle_count + 1, | 1373 CHECK_EQ(global_handle_count + 1, |
1372 v8::HeapProfiler::GetPersistentHandleCount()); | 1374 v8::HeapProfiler::GetPersistentHandleCount()); |
1373 p_BBB.Dispose(); | 1375 p_BBB.Dispose(); |
1374 CHECK_EQ(global_handle_count, v8::HeapProfiler::GetPersistentHandleCount()); | 1376 CHECK_EQ(global_handle_count, v8::HeapProfiler::GetPersistentHandleCount()); |
1375 } | 1377 } |
OLD | NEW |