Chromium Code Reviews| 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 1261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1272 v8::HeapProfiler::TakeSnapshot(v8_str("fun")); | 1272 v8::HeapProfiler::TakeSnapshot(v8_str("fun")); |
| 1273 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); | 1273 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); |
| 1274 CHECK_NE(NULL, global); | 1274 CHECK_NE(NULL, global); |
| 1275 const v8::HeapGraphNode* fun = | 1275 const v8::HeapGraphNode* fun = |
| 1276 GetProperty(global, v8::HeapGraphEdge::kShortcut, "fun"); | 1276 GetProperty(global, v8::HeapGraphEdge::kShortcut, "fun"); |
| 1277 CHECK(HasWeakEdge(fun)); | 1277 CHECK(HasWeakEdge(fun)); |
| 1278 const v8::HeapGraphNode* shared = | 1278 const v8::HeapGraphNode* shared = |
| 1279 GetProperty(fun, v8::HeapGraphEdge::kInternal, "shared"); | 1279 GetProperty(fun, v8::HeapGraphEdge::kInternal, "shared"); |
| 1280 CHECK(HasWeakEdge(shared)); | 1280 CHECK(HasWeakEdge(shared)); |
| 1281 } | 1281 } |
| 1282 | |
|
Vyacheslav Egorov (Chromium)
2012/03/07 17:07:02
one more empty line
| |
| 1283 TEST(PersistentHandleCount) { | |
| 1284 v8::HandleScope scope; | |
| 1285 LocalContext env; | |
| 1286 | |
| 1287 // V8 also uses global handles internally, so we can't test for an absolute | |
| 1288 // number. | |
| 1289 int global_handle_count = v8::HeapProfiler::GetPersistentHandleCount(); | |
| 1290 | |
| 1291 // Create some persistent handles. | |
| 1292 v8::Persistent<v8::String> p_AAA = | |
| 1293 v8::Persistent<v8::String>::New(v8_str("AAA")); | |
| 1294 CHECK_EQ(global_handle_count + 1, | |
| 1295 v8::HeapProfiler::GetPersistentHandleCount()); | |
| 1296 v8::Persistent<v8::String> p_BBB = | |
| 1297 v8::Persistent<v8::String>::New(v8_str("BBB")); | |
| 1298 CHECK_EQ(global_handle_count + 2, | |
| 1299 v8::HeapProfiler::GetPersistentHandleCount()); | |
| 1300 v8::Persistent<v8::String> p_CCC = | |
| 1301 v8::Persistent<v8::String>::New(v8_str("CCC")); | |
| 1302 CHECK_EQ(global_handle_count + 3, | |
| 1303 v8::HeapProfiler::GetPersistentHandleCount()); | |
| 1304 | |
| 1305 // Dipose the persistent handles in a different order. | |
| 1306 p_AAA.Dispose(); | |
| 1307 CHECK_EQ(global_handle_count + 2, | |
| 1308 v8::HeapProfiler::GetPersistentHandleCount()); | |
| 1309 p_CCC.Dispose(); | |
| 1310 CHECK_EQ(global_handle_count + 1, | |
| 1311 v8::HeapProfiler::GetPersistentHandleCount()); | |
| 1312 p_BBB.Dispose(); | |
| 1313 CHECK_EQ(global_handle_count, v8::HeapProfiler::GetPersistentHandleCount()); | |
| 1314 } | |
| OLD | NEW |