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

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

Issue 148503002: A64: Synchronize with r15545. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 11 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-heap.cc ('k') | test/cctest/test-javascript-a64.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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 bool has_B2; 85 bool has_B2;
86 bool has_C2; 86 bool has_C2;
87 }; 87 };
88 88
89 } // namespace 89 } // namespace
90 90
91 91
92 static const v8::HeapGraphNode* GetGlobalObject( 92 static const v8::HeapGraphNode* GetGlobalObject(
93 const v8::HeapSnapshot* snapshot) { 93 const v8::HeapSnapshot* snapshot) {
94 CHECK_EQ(2, snapshot->GetRoot()->GetChildrenCount()); 94 CHECK_EQ(2, snapshot->GetRoot()->GetChildrenCount());
95 // The 0th-child is (GC Roots), 1st is the user root.
95 const v8::HeapGraphNode* global_obj = 96 const v8::HeapGraphNode* global_obj =
96 snapshot->GetRoot()->GetChild(0)->GetToNode(); 97 snapshot->GetRoot()->GetChild(1)->GetToNode();
97 CHECK_EQ(0, strncmp("Object", const_cast<i::HeapEntry*>( 98 CHECK_EQ(0, strncmp("Object", const_cast<i::HeapEntry*>(
98 reinterpret_cast<const i::HeapEntry*>(global_obj))->name(), 6)); 99 reinterpret_cast<const i::HeapEntry*>(global_obj))->name(), 6));
99 return global_obj; 100 return global_obj;
100 } 101 }
101 102
102 103
103 static const v8::HeapGraphNode* GetProperty(const v8::HeapGraphNode* node, 104 static const v8::HeapGraphNode* GetProperty(const v8::HeapGraphNode* node,
104 v8::HeapGraphEdge::Type type, 105 v8::HeapGraphEdge::Type type,
105 const char* name) { 106 const char* name) {
106 for (int i = 0, count = node->GetChildrenCount(); i < count; ++i) { 107 for (int i = 0, count = node->GetChildrenCount(); i < count; ++i) {
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 const v8::HeapSnapshot* snapshot = 333 const v8::HeapSnapshot* snapshot =
333 heap_profiler->TakeHeapSnapshot(v8_str("numbers")); 334 heap_profiler->TakeHeapSnapshot(v8_str("numbers"));
334 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); 335 const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
335 CHECK_EQ(NULL, GetProperty(global, v8::HeapGraphEdge::kProperty, "a")); 336 CHECK_EQ(NULL, GetProperty(global, v8::HeapGraphEdge::kProperty, "a"));
336 const v8::HeapGraphNode* b = 337 const v8::HeapGraphNode* b =
337 GetProperty(global, v8::HeapGraphEdge::kProperty, "b"); 338 GetProperty(global, v8::HeapGraphEdge::kProperty, "b");
338 CHECK_NE(NULL, b); 339 CHECK_NE(NULL, b);
339 CHECK_EQ(v8::HeapGraphNode::kHeapNumber, b->GetType()); 340 CHECK_EQ(v8::HeapGraphNode::kHeapNumber, b->GetType());
340 } 341 }
341 342
343
342 TEST(HeapSnapshotSlicedString) { 344 TEST(HeapSnapshotSlicedString) {
343 LocalContext env; 345 LocalContext env;
344 v8::HandleScope scope(env->GetIsolate()); 346 v8::HandleScope scope(env->GetIsolate());
345 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); 347 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
346 CompileRun( 348 CompileRun(
347 "parent_string = \"123456789.123456789.123456789.123456789.123456789." 349 "parent_string = \"123456789.123456789.123456789.123456789.123456789."
348 "123456789.123456789.123456789.123456789.123456789." 350 "123456789.123456789.123456789.123456789.123456789."
349 "123456789.123456789.123456789.123456789.123456789." 351 "123456789.123456789.123456789.123456789.123456789."
350 "123456789.123456789.123456789.123456789.123456789.\";" 352 "123456789.123456789.123456789.123456789.123456789.\";"
351 "child_string = parent_string.slice(100);"); 353 "child_string = parent_string.slice(100);");
352 const v8::HeapSnapshot* snapshot = 354 const v8::HeapSnapshot* snapshot =
353 heap_profiler->TakeHeapSnapshot(v8_str("strings")); 355 heap_profiler->TakeHeapSnapshot(v8_str("strings"));
354 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); 356 const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
355 const v8::HeapGraphNode* parent_string = 357 const v8::HeapGraphNode* parent_string =
356 GetProperty(global, v8::HeapGraphEdge::kProperty, "parent_string"); 358 GetProperty(global, v8::HeapGraphEdge::kProperty, "parent_string");
357 CHECK_NE(NULL, parent_string); 359 CHECK_NE(NULL, parent_string);
358 const v8::HeapGraphNode* child_string = 360 const v8::HeapGraphNode* child_string =
359 GetProperty(global, v8::HeapGraphEdge::kProperty, "child_string"); 361 GetProperty(global, v8::HeapGraphEdge::kProperty, "child_string");
360 CHECK_NE(NULL, child_string); 362 CHECK_NE(NULL, child_string);
361 const v8::HeapGraphNode* parent = 363 const v8::HeapGraphNode* parent =
362 GetProperty(child_string, v8::HeapGraphEdge::kInternal, "parent"); 364 GetProperty(child_string, v8::HeapGraphEdge::kInternal, "parent");
363 CHECK_EQ(parent_string, parent); 365 CHECK_EQ(parent_string, parent);
364 } 366 }
365 367
368
366 TEST(HeapSnapshotInternalReferences) { 369 TEST(HeapSnapshotInternalReferences) {
367 v8::Isolate* isolate = v8::Isolate::GetCurrent(); 370 v8::Isolate* isolate = v8::Isolate::GetCurrent();
368 v8::HandleScope scope(isolate); 371 v8::HandleScope scope(isolate);
369 v8::Local<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); 372 v8::Local<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New();
370 global_template->SetInternalFieldCount(2); 373 global_template->SetInternalFieldCount(2);
371 LocalContext env(NULL, global_template); 374 LocalContext env(NULL, global_template);
372 v8::Handle<v8::Object> global_proxy = env->Global(); 375 v8::Handle<v8::Object> global_proxy = env->Global();
373 v8::Handle<v8::Object> global = global_proxy->GetPrototype().As<v8::Object>(); 376 v8::Handle<v8::Object> global = global_proxy->GetPrototype().As<v8::Object>();
374 CHECK_EQ(2, global->InternalFieldCount()); 377 CHECK_EQ(2, global->InternalFieldCount());
375 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
473 GetProperty(global2, v8::HeapGraphEdge::kProperty, "a"); 476 GetProperty(global2, v8::HeapGraphEdge::kProperty, "a");
474 CHECK_NE(NULL, a2); 477 CHECK_NE(NULL, a2);
475 const v8::HeapGraphNode* k2 = 478 const v8::HeapGraphNode* k2 =
476 GetProperty(a2, v8::HeapGraphEdge::kInternal, "elements"); 479 GetProperty(a2, v8::HeapGraphEdge::kInternal, "elements");
477 CHECK_NE(NULL, k2); 480 CHECK_NE(NULL, k2);
478 481
479 CHECK_EQ_SNAPSHOT_OBJECT_ID(a1->GetId(), a2->GetId()); 482 CHECK_EQ_SNAPSHOT_OBJECT_ID(a1->GetId(), a2->GetId());
480 CHECK_EQ_SNAPSHOT_OBJECT_ID(k1->GetId(), k2->GetId()); 483 CHECK_EQ_SNAPSHOT_OBJECT_ID(k1->GetId(), k2->GetId());
481 } 484 }
482 485
486
483 TEST(HeapEntryIdsAndGC) { 487 TEST(HeapEntryIdsAndGC) {
484 LocalContext env; 488 LocalContext env;
485 v8::HandleScope scope(env->GetIsolate()); 489 v8::HandleScope scope(env->GetIsolate());
486 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); 490 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
487 491
488 CompileRun( 492 CompileRun(
489 "function A() {}\n" 493 "function A() {}\n"
490 "function B(x) { this.x = x; }\n" 494 "function B(x) { this.x = x; }\n"
491 "var a = new A();\n" 495 "var a = new A();\n"
492 "var b = new B(a);"); 496 "var b = new B(a);");
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 "var property_type =" 655 "var property_type ="
652 " meta.edge_types[edge_type_offset].indexOf('property');\n" 656 " meta.edge_types[edge_type_offset].indexOf('property');\n"
653 "var shortcut_type =" 657 "var shortcut_type ="
654 " meta.edge_types[edge_type_offset].indexOf('shortcut');\n" 658 " meta.edge_types[edge_type_offset].indexOf('shortcut');\n"
655 "var node_count = parsed.nodes.length / node_fields_count;\n" 659 "var node_count = parsed.nodes.length / node_fields_count;\n"
656 "var first_edge_indexes = parsed.first_edge_indexes = [];\n" 660 "var first_edge_indexes = parsed.first_edge_indexes = [];\n"
657 "for (var i = 0, first_edge_index = 0; i < node_count; ++i) {\n" 661 "for (var i = 0, first_edge_index = 0; i < node_count; ++i) {\n"
658 " first_edge_indexes[i] = first_edge_index;\n" 662 " first_edge_indexes[i] = first_edge_index;\n"
659 " first_edge_index += edge_fields_count *\n" 663 " first_edge_index += edge_fields_count *\n"
660 " parsed.nodes[i * node_fields_count + edge_count_offset];\n" 664 " parsed.nodes[i * node_fields_count + edge_count_offset];\n"
661 "}\n"); 665 "}\n"
666 "first_edge_indexes[node_count] = first_edge_index;\n");
662 CHECK(!meta_analysis_result.IsEmpty()); 667 CHECK(!meta_analysis_result.IsEmpty());
663 668
664 // A helper function for processing encoded nodes. 669 // A helper function for processing encoded nodes.
665 CompileRun( 670 CompileRun(
666 "function GetChildPosByProperty(pos, prop_name, prop_type) {\n" 671 "function GetChildPosByProperty(pos, prop_name, prop_type) {\n"
667 " var nodes = parsed.nodes;\n" 672 " var nodes = parsed.nodes;\n"
668 " var edges = parsed.edges;\n" 673 " var edges = parsed.edges;\n"
669 " var strings = parsed.strings;\n" 674 " var strings = parsed.strings;\n"
670 " var node_ordinal = pos / node_fields_count;\n" 675 " var node_ordinal = pos / node_fields_count;\n"
671 " for (var i = parsed.first_edge_indexes[node_ordinal],\n" 676 " for (var i = parsed.first_edge_indexes[node_ordinal],\n"
672 " count = parsed.first_edge_indexes[node_ordinal + 1];\n" 677 " count = parsed.first_edge_indexes[node_ordinal + 1];\n"
673 " i < count; i += edge_fields_count) {\n" 678 " i < count; i += edge_fields_count) {\n"
674 " if (edges[i + edge_type_offset] === prop_type\n" 679 " if (edges[i + edge_type_offset] === prop_type\n"
675 " && strings[edges[i + edge_name_offset]] === prop_name)\n" 680 " && strings[edges[i + edge_name_offset]] === prop_name)\n"
676 " return edges[i + edge_to_node_offset];\n" 681 " return edges[i + edge_to_node_offset];\n"
677 " }\n" 682 " }\n"
678 " return null;\n" 683 " return null;\n"
679 "}\n"); 684 "}\n");
680 // Get the string index using the path: <root> -> <global>.b.x.s 685 // Get the string index using the path: <root> -> <global>.b.x.s
681 v8::Local<v8::Value> string_obj_pos_val = CompileRun( 686 v8::Local<v8::Value> string_obj_pos_val = CompileRun(
682 "GetChildPosByProperty(\n" 687 "GetChildPosByProperty(\n"
683 " GetChildPosByProperty(\n" 688 " GetChildPosByProperty(\n"
684 " GetChildPosByProperty(" 689 " GetChildPosByProperty("
685 " parsed.edges[edge_to_node_offset]," 690 " parsed.edges[edge_fields_count + edge_to_node_offset],"
686 " \"b\", property_type),\n" 691 " \"b\", property_type),\n"
687 " \"x\", property_type)," 692 " \"x\", property_type),"
688 " \"s\", property_type)"); 693 " \"s\", property_type)");
689 CHECK(!string_obj_pos_val.IsEmpty()); 694 CHECK(!string_obj_pos_val.IsEmpty());
690 int string_obj_pos = 695 int string_obj_pos =
691 static_cast<int>(string_obj_pos_val->ToNumber()->Value()); 696 static_cast<int>(string_obj_pos_val->ToNumber()->Value());
692 v8::Local<v8::Object> nodes_array = 697 v8::Local<v8::Object> nodes_array =
693 parsed_snapshot->Get(v8_str("nodes"))->ToObject(); 698 parsed_snapshot->Get(v8_str("nodes"))->ToObject();
694 int string_index = static_cast<int>( 699 int string_index = static_cast<int>(
695 nodes_array->Get(string_obj_pos + 1)->ToNumber()->Value()); 700 nodes_array->Get(string_obj_pos + 1)->ToNumber()->Value());
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
1008 int done() { return done_; } 1013 int done() { return done_; }
1009 int total() { return total_; } 1014 int total() { return total_; }
1010 1015
1011 private: 1016 private:
1012 int done_; 1017 int done_;
1013 int total_; 1018 int total_;
1014 int abort_count_; 1019 int abort_count_;
1015 }; 1020 };
1016 } 1021 }
1017 1022
1023
1018 TEST(TakeHeapSnapshotAborting) { 1024 TEST(TakeHeapSnapshotAborting) {
1019 LocalContext env; 1025 LocalContext env;
1020 v8::HandleScope scope(env->GetIsolate()); 1026 v8::HandleScope scope(env->GetIsolate());
1021 1027
1022 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); 1028 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
1023 const int snapshots_count = heap_profiler->GetSnapshotCount(); 1029 const int snapshots_count = heap_profiler->GetSnapshotCount();
1024 TestActivityControl aborting_control(1); 1030 TestActivityControl aborting_control(1);
1025 const v8::HeapSnapshot* no_snapshot = 1031 const v8::HeapSnapshot* no_snapshot =
1026 heap_profiler->TakeHeapSnapshot(v8_str("abort"), 1032 heap_profiler->TakeHeapSnapshot(v8_str("abort"),
1027 &aborting_control); 1033 &aborting_control);
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
1331 } 1337 }
1332 1338
1333 1339
1334 class NameResolver : public v8::HeapProfiler::ObjectNameResolver { 1340 class NameResolver : public v8::HeapProfiler::ObjectNameResolver {
1335 public: 1341 public:
1336 virtual const char* GetName(v8::Handle<v8::Object> object) { 1342 virtual const char* GetName(v8::Handle<v8::Object> object) {
1337 return "Global object name"; 1343 return "Global object name";
1338 } 1344 }
1339 }; 1345 };
1340 1346
1347
1341 TEST(GlobalObjectName) { 1348 TEST(GlobalObjectName) {
1342 LocalContext env; 1349 LocalContext env;
1343 v8::HandleScope scope(env->GetIsolate()); 1350 v8::HandleScope scope(env->GetIsolate());
1344 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); 1351 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
1345 1352
1346 CompileRun("document = { URL:\"abcdefgh\" };"); 1353 CompileRun("document = { URL:\"abcdefgh\" };");
1347 1354
1348 NameResolver name_resolver; 1355 NameResolver name_resolver;
1349 const v8::HeapSnapshot* snapshot = 1356 const v8::HeapSnapshot* snapshot =
1350 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
1597 snapshot = heap_profiler->TakeHeapSnapshot( 1604 snapshot = heap_profiler->TakeHeapSnapshot(
1598 v8_str("HiddenPropertiesFastCase2")); 1605 v8_str("HiddenPropertiesFastCase2"));
1599 global = GetGlobalObject(snapshot); 1606 global = GetGlobalObject(snapshot);
1600 c = GetProperty(global, v8::HeapGraphEdge::kProperty, "c"); 1607 c = GetProperty(global, v8::HeapGraphEdge::kProperty, "c");
1601 CHECK_NE(NULL, c); 1608 CHECK_NE(NULL, c);
1602 hidden_props = GetProperty(c, v8::HeapGraphEdge::kInternal, 1609 hidden_props = GetProperty(c, v8::HeapGraphEdge::kInternal,
1603 "hidden_properties"); 1610 "hidden_properties");
1604 CHECK_NE(NULL, hidden_props); 1611 CHECK_NE(NULL, hidden_props);
1605 } 1612 }
1606 1613
1614
1607 bool HasWeakEdge(const v8::HeapGraphNode* node) { 1615 bool HasWeakEdge(const v8::HeapGraphNode* node) {
1608 for (int i = 0; i < node->GetChildrenCount(); ++i) { 1616 for (int i = 0; i < node->GetChildrenCount(); ++i) {
1609 const v8::HeapGraphEdge* handle_edge = node->GetChild(i); 1617 const v8::HeapGraphEdge* handle_edge = node->GetChild(i);
1610 if (handle_edge->GetType() == v8::HeapGraphEdge::kWeak) return true; 1618 if (handle_edge->GetType() == v8::HeapGraphEdge::kWeak) return true;
1611 } 1619 }
1612 return false; 1620 return false;
1613 } 1621 }
1614 1622
1615 1623
1616 bool HasWeakGlobalHandle() { 1624 bool HasWeakGlobalHandle() {
1617 v8::Isolate* isolate = v8::Isolate::GetCurrent(); 1625 v8::Isolate* isolate = v8::Isolate::GetCurrent();
1618 v8::HeapProfiler* heap_profiler = isolate->GetHeapProfiler(); 1626 v8::HeapProfiler* heap_profiler = isolate->GetHeapProfiler();
1619 const v8::HeapSnapshot* snapshot = 1627 const v8::HeapSnapshot* snapshot =
1620 heap_profiler->TakeHeapSnapshot(v8_str("weaks")); 1628 heap_profiler->TakeHeapSnapshot(v8_str("weaks"));
1621 const v8::HeapGraphNode* gc_roots = GetNode( 1629 const v8::HeapGraphNode* gc_roots = GetNode(
1622 snapshot->GetRoot(), v8::HeapGraphNode::kObject, "(GC roots)"); 1630 snapshot->GetRoot(), v8::HeapGraphNode::kSynthetic, "(GC roots)");
1623 CHECK_NE(NULL, gc_roots); 1631 CHECK_NE(NULL, gc_roots);
1624 const v8::HeapGraphNode* global_handles = GetNode( 1632 const v8::HeapGraphNode* global_handles = GetNode(
1625 gc_roots, v8::HeapGraphNode::kObject, "(Global handles)"); 1633 gc_roots, v8::HeapGraphNode::kSynthetic, "(Global handles)");
1626 CHECK_NE(NULL, global_handles); 1634 CHECK_NE(NULL, global_handles);
1627 return HasWeakEdge(global_handles); 1635 return HasWeakEdge(global_handles);
1628 } 1636 }
1629 1637
1630 1638
1631 static void PersistentHandleCallback(v8::Isolate* isolate, 1639 static void PersistentHandleCallback(v8::Isolate* isolate,
1632 v8::Persistent<v8::Value>* handle, 1640 v8::Persistent<v8::Value>* handle,
1633 void*) { 1641 void*) {
1634 handle->Dispose(isolate); 1642 handle->Dispose(isolate);
1635 } 1643 }
(...skipping 13 matching lines...) Expand all
1649 1657
1650 1658
1651 TEST(WeakNativeContextRefs) { 1659 TEST(WeakNativeContextRefs) {
1652 LocalContext env; 1660 LocalContext env;
1653 v8::HandleScope scope(env->GetIsolate()); 1661 v8::HandleScope scope(env->GetIsolate());
1654 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); 1662 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
1655 1663
1656 const v8::HeapSnapshot* snapshot = 1664 const v8::HeapSnapshot* snapshot =
1657 heap_profiler->TakeHeapSnapshot(v8_str("weaks")); 1665 heap_profiler->TakeHeapSnapshot(v8_str("weaks"));
1658 const v8::HeapGraphNode* gc_roots = GetNode( 1666 const v8::HeapGraphNode* gc_roots = GetNode(
1659 snapshot->GetRoot(), v8::HeapGraphNode::kObject, "(GC roots)"); 1667 snapshot->GetRoot(), v8::HeapGraphNode::kSynthetic, "(GC roots)");
1660 CHECK_NE(NULL, gc_roots); 1668 CHECK_NE(NULL, gc_roots);
1661 const v8::HeapGraphNode* global_handles = GetNode( 1669 const v8::HeapGraphNode* global_handles = GetNode(
1662 gc_roots, v8::HeapGraphNode::kObject, "(Global handles)"); 1670 gc_roots, v8::HeapGraphNode::kSynthetic, "(Global handles)");
1663 CHECK_NE(NULL, global_handles); 1671 CHECK_NE(NULL, global_handles);
1664 const v8::HeapGraphNode* native_context = GetNode( 1672 const v8::HeapGraphNode* native_context = GetNode(
1665 global_handles, v8::HeapGraphNode::kHidden, "system / NativeContext"); 1673 global_handles, v8::HeapGraphNode::kHidden, "system / NativeContext");
1666 CHECK_NE(NULL, native_context); 1674 CHECK_NE(NULL, native_context);
1667 CHECK(HasWeakEdge(native_context)); 1675 CHECK(HasWeakEdge(native_context));
1668 } 1676 }
1669 1677
1670 1678
1671 TEST(SfiAndJsFunctionWeakRefs) { 1679 TEST(SfiAndJsFunctionWeakRefs) {
1672 LocalContext env; 1680 LocalContext env;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1717 1725
1718 TEST(AllStrongGcRootsHaveNames) { 1726 TEST(AllStrongGcRootsHaveNames) {
1719 LocalContext env; 1727 LocalContext env;
1720 v8::HandleScope scope(env->GetIsolate()); 1728 v8::HandleScope scope(env->GetIsolate());
1721 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); 1729 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
1722 1730
1723 CompileRun("foo = {};"); 1731 CompileRun("foo = {};");
1724 const v8::HeapSnapshot* snapshot = 1732 const v8::HeapSnapshot* snapshot =
1725 heap_profiler->TakeHeapSnapshot(v8_str("snapshot")); 1733 heap_profiler->TakeHeapSnapshot(v8_str("snapshot"));
1726 const v8::HeapGraphNode* gc_roots = GetNode( 1734 const v8::HeapGraphNode* gc_roots = GetNode(
1727 snapshot->GetRoot(), v8::HeapGraphNode::kObject, "(GC roots)"); 1735 snapshot->GetRoot(), v8::HeapGraphNode::kSynthetic, "(GC roots)");
1728 CHECK_NE(NULL, gc_roots); 1736 CHECK_NE(NULL, gc_roots);
1729 const v8::HeapGraphNode* strong_roots = GetNode( 1737 const v8::HeapGraphNode* strong_roots = GetNode(
1730 gc_roots, v8::HeapGraphNode::kObject, "(Strong roots)"); 1738 gc_roots, v8::HeapGraphNode::kSynthetic, "(Strong roots)");
1731 CHECK_NE(NULL, strong_roots); 1739 CHECK_NE(NULL, strong_roots);
1732 for (int i = 0; i < strong_roots->GetChildrenCount(); ++i) { 1740 for (int i = 0; i < strong_roots->GetChildrenCount(); ++i) {
1733 const v8::HeapGraphEdge* edge = strong_roots->GetChild(i); 1741 const v8::HeapGraphEdge* edge = strong_roots->GetChild(i);
1734 CHECK_EQ(v8::HeapGraphEdge::kInternal, edge->GetType()); 1742 CHECK_EQ(v8::HeapGraphEdge::kInternal, edge->GetType());
1735 v8::String::Utf8Value name(edge->GetName()); 1743 v8::String::Utf8Value name(edge->GetName());
1736 CHECK(isalpha(**name)); 1744 CHECK(isalpha(**name));
1737 } 1745 }
1738 } 1746 }
1739 1747
1740 1748
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
1817 // Check all the objects have got their names. 1825 // Check all the objects have got their names.
1818 // ... 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.
1819 for (int i = 0; i < num_objects - 1; i += 8) { 1827 for (int i = 0; i < num_objects - 1; i += 8) {
1820 i::EmbeddedVector<char, 100> var_name; 1828 i::EmbeddedVector<char, 100> var_name;
1821 i::OS::SNPrintF(var_name, "f_%d", i); 1829 i::OS::SNPrintF(var_name, "f_%d", i);
1822 const v8::HeapGraphNode* f_object = GetProperty( 1830 const v8::HeapGraphNode* f_object = GetProperty(
1823 context_object, v8::HeapGraphEdge::kContextVariable, var_name.start()); 1831 context_object, v8::HeapGraphEdge::kContextVariable, var_name.start());
1824 CHECK_NE(NULL, f_object); 1832 CHECK_NE(NULL, f_object);
1825 } 1833 }
1826 } 1834 }
OLDNEW
« no previous file with comments | « test/cctest/test-heap.cc ('k') | test/cctest/test-javascript-a64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698