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

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

Issue 18509003: Keep two empty lines between declarations for cpp files (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 7 years, 5 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
« no previous file with comments | « test/cctest/test-double.cc ('k') | test/cctest/test-list.cc » ('j') | 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 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 const v8::HeapSnapshot* snapshot = 333 const v8::HeapSnapshot* snapshot =
334 heap_profiler->TakeHeapSnapshot(v8_str("numbers")); 334 heap_profiler->TakeHeapSnapshot(v8_str("numbers"));
335 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); 335 const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
336 CHECK_EQ(NULL, GetProperty(global, v8::HeapGraphEdge::kProperty, "a")); 336 CHECK_EQ(NULL, GetProperty(global, v8::HeapGraphEdge::kProperty, "a"));
337 const v8::HeapGraphNode* b = 337 const v8::HeapGraphNode* b =
338 GetProperty(global, v8::HeapGraphEdge::kProperty, "b"); 338 GetProperty(global, v8::HeapGraphEdge::kProperty, "b");
339 CHECK_NE(NULL, b); 339 CHECK_NE(NULL, b);
340 CHECK_EQ(v8::HeapGraphNode::kHeapNumber, b->GetType()); 340 CHECK_EQ(v8::HeapGraphNode::kHeapNumber, b->GetType());
341 } 341 }
342 342
343
343 TEST(HeapSnapshotSlicedString) { 344 TEST(HeapSnapshotSlicedString) {
344 LocalContext env; 345 LocalContext env;
345 v8::HandleScope scope(env->GetIsolate()); 346 v8::HandleScope scope(env->GetIsolate());
346 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); 347 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
347 CompileRun( 348 CompileRun(
348 "parent_string = \"123456789.123456789.123456789.123456789.123456789." 349 "parent_string = \"123456789.123456789.123456789.123456789.123456789."
349 "123456789.123456789.123456789.123456789.123456789." 350 "123456789.123456789.123456789.123456789.123456789."
350 "123456789.123456789.123456789.123456789.123456789." 351 "123456789.123456789.123456789.123456789.123456789."
351 "123456789.123456789.123456789.123456789.123456789.\";" 352 "123456789.123456789.123456789.123456789.123456789.\";"
352 "child_string = parent_string.slice(100);"); 353 "child_string = parent_string.slice(100);");
353 const v8::HeapSnapshot* snapshot = 354 const v8::HeapSnapshot* snapshot =
354 heap_profiler->TakeHeapSnapshot(v8_str("strings")); 355 heap_profiler->TakeHeapSnapshot(v8_str("strings"));
355 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); 356 const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
356 const v8::HeapGraphNode* parent_string = 357 const v8::HeapGraphNode* parent_string =
357 GetProperty(global, v8::HeapGraphEdge::kProperty, "parent_string"); 358 GetProperty(global, v8::HeapGraphEdge::kProperty, "parent_string");
358 CHECK_NE(NULL, parent_string); 359 CHECK_NE(NULL, parent_string);
359 const v8::HeapGraphNode* child_string = 360 const v8::HeapGraphNode* child_string =
360 GetProperty(global, v8::HeapGraphEdge::kProperty, "child_string"); 361 GetProperty(global, v8::HeapGraphEdge::kProperty, "child_string");
361 CHECK_NE(NULL, child_string); 362 CHECK_NE(NULL, child_string);
362 const v8::HeapGraphNode* parent = 363 const v8::HeapGraphNode* parent =
363 GetProperty(child_string, v8::HeapGraphEdge::kInternal, "parent"); 364 GetProperty(child_string, v8::HeapGraphEdge::kInternal, "parent");
364 CHECK_EQ(parent_string, parent); 365 CHECK_EQ(parent_string, parent);
365 } 366 }
366 367
368
367 TEST(HeapSnapshotInternalReferences) { 369 TEST(HeapSnapshotInternalReferences) {
368 v8::Isolate* isolate = v8::Isolate::GetCurrent(); 370 v8::Isolate* isolate = v8::Isolate::GetCurrent();
369 v8::HandleScope scope(isolate); 371 v8::HandleScope scope(isolate);
370 v8::Local<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); 372 v8::Local<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New();
371 global_template->SetInternalFieldCount(2); 373 global_template->SetInternalFieldCount(2);
372 LocalContext env(NULL, global_template); 374 LocalContext env(NULL, global_template);
373 v8::Handle<v8::Object> global_proxy = env->Global(); 375 v8::Handle<v8::Object> global_proxy = env->Global();
374 v8::Handle<v8::Object> global = global_proxy->GetPrototype().As<v8::Object>(); 376 v8::Handle<v8::Object> global = global_proxy->GetPrototype().As<v8::Object>();
375 CHECK_EQ(2, global->InternalFieldCount()); 377 CHECK_EQ(2, global->InternalFieldCount());
376 v8::Local<v8::Object> obj = v8::Object::New(); 378 v8::Local<v8::Object> obj = v8::Object::New();
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 GetProperty(global2, v8::HeapGraphEdge::kProperty, "a"); 476 GetProperty(global2, v8::HeapGraphEdge::kProperty, "a");
475 CHECK_NE(NULL, a2); 477 CHECK_NE(NULL, a2);
476 const v8::HeapGraphNode* k2 = 478 const v8::HeapGraphNode* k2 =
477 GetProperty(a2, v8::HeapGraphEdge::kInternal, "elements"); 479 GetProperty(a2, v8::HeapGraphEdge::kInternal, "elements");
478 CHECK_NE(NULL, k2); 480 CHECK_NE(NULL, k2);
479 481
480 CHECK_EQ_SNAPSHOT_OBJECT_ID(a1->GetId(), a2->GetId()); 482 CHECK_EQ_SNAPSHOT_OBJECT_ID(a1->GetId(), a2->GetId());
481 CHECK_EQ_SNAPSHOT_OBJECT_ID(k1->GetId(), k2->GetId()); 483 CHECK_EQ_SNAPSHOT_OBJECT_ID(k1->GetId(), k2->GetId());
482 } 484 }
483 485
486
484 TEST(HeapEntryIdsAndGC) { 487 TEST(HeapEntryIdsAndGC) {
485 LocalContext env; 488 LocalContext env;
486 v8::HandleScope scope(env->GetIsolate()); 489 v8::HandleScope scope(env->GetIsolate());
487 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); 490 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
488 491
489 CompileRun( 492 CompileRun(
490 "function A() {}\n" 493 "function A() {}\n"
491 "function B(x) { this.x = x; }\n" 494 "function B(x) { this.x = x; }\n"
492 "var a = new A();\n" 495 "var a = new A();\n"
493 "var b = new B(a);"); 496 "var b = new B(a);");
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after
1010 int done() { return done_; } 1013 int done() { return done_; }
1011 int total() { return total_; } 1014 int total() { return total_; }
1012 1015
1013 private: 1016 private:
1014 int done_; 1017 int done_;
1015 int total_; 1018 int total_;
1016 int abort_count_; 1019 int abort_count_;
1017 }; 1020 };
1018 } 1021 }
1019 1022
1023
1020 TEST(TakeHeapSnapshotAborting) { 1024 TEST(TakeHeapSnapshotAborting) {
1021 LocalContext env; 1025 LocalContext env;
1022 v8::HandleScope scope(env->GetIsolate()); 1026 v8::HandleScope scope(env->GetIsolate());
1023 1027
1024 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); 1028 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
1025 const int snapshots_count = heap_profiler->GetSnapshotCount(); 1029 const int snapshots_count = heap_profiler->GetSnapshotCount();
1026 TestActivityControl aborting_control(1); 1030 TestActivityControl aborting_control(1);
1027 const v8::HeapSnapshot* no_snapshot = 1031 const v8::HeapSnapshot* no_snapshot =
1028 heap_profiler->TakeHeapSnapshot(v8_str("abort"), 1032 heap_profiler->TakeHeapSnapshot(v8_str("abort"),
1029 &aborting_control); 1033 &aborting_control);
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
1333 } 1337 }
1334 1338
1335 1339
1336 class NameResolver : public v8::HeapProfiler::ObjectNameResolver { 1340 class NameResolver : public v8::HeapProfiler::ObjectNameResolver {
1337 public: 1341 public:
1338 virtual const char* GetName(v8::Handle<v8::Object> object) { 1342 virtual const char* GetName(v8::Handle<v8::Object> object) {
1339 return "Global object name"; 1343 return "Global object name";
1340 } 1344 }
1341 }; 1345 };
1342 1346
1347
1343 TEST(GlobalObjectName) { 1348 TEST(GlobalObjectName) {
1344 LocalContext env; 1349 LocalContext env;
1345 v8::HandleScope scope(env->GetIsolate()); 1350 v8::HandleScope scope(env->GetIsolate());
1346 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); 1351 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
1347 1352
1348 CompileRun("document = { URL:\"abcdefgh\" };"); 1353 CompileRun("document = { URL:\"abcdefgh\" };");
1349 1354
1350 NameResolver name_resolver; 1355 NameResolver name_resolver;
1351 const v8::HeapSnapshot* snapshot = 1356 const v8::HeapSnapshot* snapshot =
1352 heap_profiler->TakeHeapSnapshot(v8_str("document"), 1357 heap_profiler->TakeHeapSnapshot(v8_str("document"),
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
1599 snapshot = heap_profiler->TakeHeapSnapshot( 1604 snapshot = heap_profiler->TakeHeapSnapshot(
1600 v8_str("HiddenPropertiesFastCase2")); 1605 v8_str("HiddenPropertiesFastCase2"));
1601 global = GetGlobalObject(snapshot); 1606 global = GetGlobalObject(snapshot);
1602 c = GetProperty(global, v8::HeapGraphEdge::kProperty, "c"); 1607 c = GetProperty(global, v8::HeapGraphEdge::kProperty, "c");
1603 CHECK_NE(NULL, c); 1608 CHECK_NE(NULL, c);
1604 hidden_props = GetProperty(c, v8::HeapGraphEdge::kInternal, 1609 hidden_props = GetProperty(c, v8::HeapGraphEdge::kInternal,
1605 "hidden_properties"); 1610 "hidden_properties");
1606 CHECK_NE(NULL, hidden_props); 1611 CHECK_NE(NULL, hidden_props);
1607 } 1612 }
1608 1613
1614
1609 bool HasWeakEdge(const v8::HeapGraphNode* node) { 1615 bool HasWeakEdge(const v8::HeapGraphNode* node) {
1610 for (int i = 0; i < node->GetChildrenCount(); ++i) { 1616 for (int i = 0; i < node->GetChildrenCount(); ++i) {
1611 const v8::HeapGraphEdge* handle_edge = node->GetChild(i); 1617 const v8::HeapGraphEdge* handle_edge = node->GetChild(i);
1612 if (handle_edge->GetType() == v8::HeapGraphEdge::kWeak) return true; 1618 if (handle_edge->GetType() == v8::HeapGraphEdge::kWeak) return true;
1613 } 1619 }
1614 return false; 1620 return false;
1615 } 1621 }
1616 1622
1617 1623
1618 bool HasWeakGlobalHandle() { 1624 bool HasWeakGlobalHandle() {
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
1819 // Check all the objects have got their names. 1825 // Check all the objects have got their names.
1820 // ... well check just every 8th because otherwise it's too slow in debug. 1826 // ... well check just every 8th because otherwise it's too slow in debug.
1821 for (int i = 0; i < num_objects - 1; i += 8) { 1827 for (int i = 0; i < num_objects - 1; i += 8) {
1822 i::EmbeddedVector<char, 100> var_name; 1828 i::EmbeddedVector<char, 100> var_name;
1823 i::OS::SNPrintF(var_name, "f_%d", i); 1829 i::OS::SNPrintF(var_name, "f_%d", i);
1824 const v8::HeapGraphNode* f_object = GetProperty( 1830 const v8::HeapGraphNode* f_object = GetProperty(
1825 context_object, v8::HeapGraphEdge::kContextVariable, var_name.start()); 1831 context_object, v8::HeapGraphEdge::kContextVariable, var_name.start());
1826 CHECK_NE(NULL, f_object); 1832 CHECK_NE(NULL, f_object);
1827 } 1833 }
1828 } 1834 }
OLDNEW
« no previous file with comments | « test/cctest/test-double.cc ('k') | test/cctest/test-list.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698