Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Side by Side Diff: test/cctest/test-heap-profiler.cc

Issue 7082012: Heap profiler: fetch document.URL of global objects. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Style fix Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« src/profile-generator.cc ('K') | « src/profile-generator.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #ifdef ENABLE_LOGGING_AND_PROFILING 5 #ifdef ENABLE_LOGGING_AND_PROFILING
6 6
7 #include "v8.h" 7 #include "v8.h"
8 8
9 #include "cctest.h" 9 #include "cctest.h"
10 #include "heap-profiler.h" 10 #include "heap-profiler.h"
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 }; 409 };
410 410
411 } // namespace 411 } // namespace
412 412
413 413
414 static const v8::HeapGraphNode* GetGlobalObject( 414 static const v8::HeapGraphNode* GetGlobalObject(
415 const v8::HeapSnapshot* snapshot) { 415 const v8::HeapSnapshot* snapshot) {
416 CHECK_EQ(2, snapshot->GetRoot()->GetChildrenCount()); 416 CHECK_EQ(2, snapshot->GetRoot()->GetChildrenCount());
417 const v8::HeapGraphNode* global_obj = 417 const v8::HeapGraphNode* global_obj =
418 snapshot->GetRoot()->GetChild(0)->GetToNode(); 418 snapshot->GetRoot()->GetChild(0)->GetToNode();
419 CHECK_EQ("Object", const_cast<i::HeapEntry*>( 419 CHECK_EQ(0, strncmp("Object", const_cast<i::HeapEntry*>(
420 reinterpret_cast<const i::HeapEntry*>(global_obj))->name()); 420 reinterpret_cast<const i::HeapEntry*>(global_obj))->name(), 6));
421 return global_obj; 421 return global_obj;
422 } 422 }
423 423
424 424
425 static const v8::HeapGraphNode* GetProperty(const v8::HeapGraphNode* node, 425 static const v8::HeapGraphNode* GetProperty(const v8::HeapGraphNode* node,
426 v8::HeapGraphEdge::Type type, 426 v8::HeapGraphEdge::Type type,
427 const char* name) { 427 const char* name) {
428 for (int i = 0, count = node->GetChildrenCount(); i < count; ++i) { 428 for (int i = 0, count = node->GetChildrenCount(); i < count; ++i) {
429 const v8::HeapGraphEdge* prop = node->GetChild(i); 429 const v8::HeapGraphEdge* prop = node->GetChild(i);
430 v8::String::AsciiValue prop_name(prop->GetName()); 430 v8::String::AsciiValue prop_name(prop->GetName());
(...skipping 884 matching lines...) Expand 10 before | Expand all | Expand 10 after
1315 CHECK_EQ(s3, v8::HeapProfiler::FindSnapshot(uid3)); 1315 CHECK_EQ(s3, v8::HeapProfiler::FindSnapshot(uid3));
1316 const_cast<v8::HeapSnapshot*>(s2)->Delete(); 1316 const_cast<v8::HeapSnapshot*>(s2)->Delete();
1317 CHECK_EQ(1, v8::HeapProfiler::GetSnapshotsCount()); 1317 CHECK_EQ(1, v8::HeapProfiler::GetSnapshotsCount());
1318 CHECK_EQ(NULL, v8::HeapProfiler::FindSnapshot(uid2)); 1318 CHECK_EQ(NULL, v8::HeapProfiler::FindSnapshot(uid2));
1319 CHECK_EQ(s3, v8::HeapProfiler::FindSnapshot(uid3)); 1319 CHECK_EQ(s3, v8::HeapProfiler::FindSnapshot(uid3));
1320 const_cast<v8::HeapSnapshot*>(s3)->Delete(); 1320 const_cast<v8::HeapSnapshot*>(s3)->Delete();
1321 CHECK_EQ(0, v8::HeapProfiler::GetSnapshotsCount()); 1321 CHECK_EQ(0, v8::HeapProfiler::GetSnapshotsCount());
1322 CHECK_EQ(NULL, v8::HeapProfiler::FindSnapshot(uid3)); 1322 CHECK_EQ(NULL, v8::HeapProfiler::FindSnapshot(uid3));
1323 } 1323 }
1324 1324
1325
1326 TEST(DocumentURL) {
Vitaly Repeshko 2011/05/29 23:01:34 Please add a test where "document" and/or "URL" th
mnaganov (inactive) 2011/05/30 14:20:42 Done.
1327 v8::HandleScope scope;
1328 LocalContext env;
1329
1330 CompileRun("document = { URL:\"abcdefgh\" };");
1331
1332 const v8::HeapSnapshot* snapshot =
1333 v8::HeapProfiler::TakeSnapshot(v8::String::New("document"));
1334 const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
1335 CHECK_NE(NULL, global);
1336 CHECK_EQ("Object / abcdefgh",
1337 const_cast<i::HeapEntry*>(
1338 reinterpret_cast<const i::HeapEntry*>(global))->name());
1339 }
1340
1325 #endif // ENABLE_LOGGING_AND_PROFILING 1341 #endif // ENABLE_LOGGING_AND_PROFILING
OLDNEW
« src/profile-generator.cc ('K') | « src/profile-generator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698