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

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

Issue 6639024: Get rid of distinction between below- and above-watermark in page allocation.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/gc/
Patch Set: '' Created 9 years, 9 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
OLDNEW
1 // Copyright 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 #include "heap-profiler.h" 8 #include "heap-profiler.h"
9 #include "snapshot.h" 9 #include "snapshot.h"
10 #include "string-stream.h" 10 #include "string-stream.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 TEST(ConstructorProfile) { 52 TEST(ConstructorProfile) {
53 v8::HandleScope scope; 53 v8::HandleScope scope;
54 LocalContext env; 54 LocalContext env;
55 55
56 CompileRun( 56 CompileRun(
57 "function F() {} // A constructor\n" 57 "function F() {} // A constructor\n"
58 "var f1 = new F();\n" 58 "var f1 = new F();\n"
59 "var f2 = new F();\n"); 59 "var f2 = new F();\n");
60 60
61 ConstructorHeapProfileTestHelper cons_profile; 61 ConstructorHeapProfileTestHelper cons_profile;
62 i::HeapIterator iterator;
62 i::AssertNoAllocation no_alloc; 63 i::AssertNoAllocation no_alloc;
63 i::HeapIterator iterator; 64 for (i::HeapObject* obj = iterator.Next(); obj != NULL; obj = iterator.Next())
64 for (i::HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next())
65 cons_profile.CollectStats(obj); 65 cons_profile.CollectStats(obj);
66 CHECK_EQ(0, cons_profile.f_count()); 66 CHECK_EQ(0, cons_profile.f_count());
67 cons_profile.PrintStats(); 67 cons_profile.PrintStats();
68 CHECK_EQ(2, cons_profile.f_count()); 68 CHECK_EQ(2, cons_profile.f_count());
69 } 69 }
70 70
71 71
72 static JSObjectsCluster AddHeapObjectToTree(JSObjectsRetainerTree* tree, 72 static JSObjectsCluster AddHeapObjectToTree(JSObjectsRetainerTree* tree,
73 i::String* constructor, 73 i::String* constructor,
74 int instance, 74 int instance,
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 356
357 CompileRun( 357 CompileRun(
358 "function A() {}\n" 358 "function A() {}\n"
359 "function B(x) { this.x = x; }\n" 359 "function B(x) { this.x = x; }\n"
360 "function C(x) { this.x1 = x; this.x2 = x; }\n" 360 "function C(x) { this.x1 = x; this.x2 = x; }\n"
361 "var a = new A();\n" 361 "var a = new A();\n"
362 "var b1 = new B(a), b2 = new B(a);\n" 362 "var b1 = new B(a), b2 = new B(a);\n"
363 "var c = new C(a);"); 363 "var c = new C(a);");
364 364
365 RetainerHeapProfile ret_profile; 365 RetainerHeapProfile ret_profile;
366 i::HeapIterator iterator;
366 i::AssertNoAllocation no_alloc; 367 i::AssertNoAllocation no_alloc;
367 i::HeapIterator iterator; 368 for (i::HeapObject* obj = iterator.Next(); obj != NULL; obj = iterator.Next())
368 for (i::HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next())
369 ret_profile.CollectStats(obj); 369 ret_profile.CollectStats(obj);
370 ret_profile.CoarseAndAggregate(); 370 ret_profile.CoarseAndAggregate();
371 RetainerProfilePrinter printer; 371 RetainerProfilePrinter printer;
372 ret_profile.DebugPrintStats(&printer); 372 ret_profile.DebugPrintStats(&printer);
373 const char* retainers_of_a = printer.GetRetainers("A"); 373 const char* retainers_of_a = printer.GetRetainers("A");
374 // The order of retainers is unspecified, so we check string length, and 374 // The order of retainers is unspecified, so we check string length, and
375 // verify each retainer separately. 375 // verify each retainer separately.
376 CHECK_EQ(i::StrLength("(global property);1,B;2,C;2"), 376 CHECK_EQ(i::StrLength("(global property);1,B;2,C;2"),
377 i::StrLength(retainers_of_a)); 377 i::StrLength(retainers_of_a));
378 CHECK(strstr(retainers_of_a, "(global property);1") != NULL); 378 CHECK(strstr(retainers_of_a, "(global property);1") != NULL);
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 LocalContext env; 723 LocalContext env;
724 724
725 CompileRun( 725 CompileRun(
726 "function A() {}\n" 726 "function A() {}\n"
727 "function B(x) { this.x = x; }\n" 727 "function B(x) { this.x = x; }\n"
728 "var a = new A();\n" 728 "var a = new A();\n"
729 "var b = new B(a);"); 729 "var b = new B(a);");
730 const v8::HeapSnapshot* snapshot1 = 730 const v8::HeapSnapshot* snapshot1 =
731 v8::HeapProfiler::TakeSnapshot(v8::String::New("s1")); 731 v8::HeapProfiler::TakeSnapshot(v8::String::New("s1"));
732 732
733 i::Heap::CollectAllGarbage(true); // Enforce compaction. 733 i::Heap::CollectAllGarbage(i::Heap::kForceCompactionMask);
734 734
735 const v8::HeapSnapshot* snapshot2 = 735 const v8::HeapSnapshot* snapshot2 =
736 v8::HeapProfiler::TakeSnapshot(v8::String::New("s2")); 736 v8::HeapProfiler::TakeSnapshot(v8::String::New("s2"));
737 737
738 const v8::HeapGraphNode* global1 = GetGlobalObject(snapshot1); 738 const v8::HeapGraphNode* global1 = GetGlobalObject(snapshot1);
739 const v8::HeapGraphNode* global2 = GetGlobalObject(snapshot2); 739 const v8::HeapGraphNode* global2 = GetGlobalObject(snapshot2);
740 CHECK_NE_UINT64_T(0, global1->GetId()); 740 CHECK_NE_UINT64_T(0, global1->GetId());
741 CHECK_EQ_UINT64_T(global1->GetId(), global2->GetId()); 741 CHECK_EQ_UINT64_T(global1->GetId(), global2->GetId());
742 const v8::HeapGraphNode* A1 = 742 const v8::HeapGraphNode* A1 =
743 GetProperty(global1, v8::HeapGraphEdge::kProperty, "A"); 743 GetProperty(global1, v8::HeapGraphEdge::kProperty, "A");
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after
1389 const v8::HeapGraphNode* n_CCC = GetNode( 1389 const v8::HeapGraphNode* n_CCC = GetNode(
1390 ccc, v8::HeapGraphNode::kString, "CCC"); 1390 ccc, v8::HeapGraphNode::kString, "CCC");
1391 CHECK_NE(NULL, n_CCC); 1391 CHECK_NE(NULL, n_CCC);
1392 1392
1393 CHECK_EQ(aaa, GetProperty(n_AAA, v8::HeapGraphEdge::kInternal, "Native")); 1393 CHECK_EQ(aaa, GetProperty(n_AAA, v8::HeapGraphEdge::kInternal, "Native"));
1394 CHECK_EQ(aaa, GetProperty(n_BBB, v8::HeapGraphEdge::kInternal, "Native")); 1394 CHECK_EQ(aaa, GetProperty(n_BBB, v8::HeapGraphEdge::kInternal, "Native"));
1395 CHECK_EQ(ccc, GetProperty(n_CCC, v8::HeapGraphEdge::kInternal, "Native")); 1395 CHECK_EQ(ccc, GetProperty(n_CCC, v8::HeapGraphEdge::kInternal, "Native"));
1396 } 1396 }
1397 1397
1398 #endif // ENABLE_LOGGING_AND_PROFILING 1398 #endif // ENABLE_LOGGING_AND_PROFILING
OLDNEW
« src/spaces-inl.h ('K') | « test/cctest/test-heap.cc ('k') | test/cctest/test-log.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698