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

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

Issue 17881005: Heap snapshot: Update user roots definition. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix a typo 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 | « src/heap-snapshot-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 // 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 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 "var property_type =" 652 "var property_type ="
652 " meta.edge_types[edge_type_offset].indexOf('property');\n" 653 " meta.edge_types[edge_type_offset].indexOf('property');\n"
653 "var shortcut_type =" 654 "var shortcut_type ="
654 " meta.edge_types[edge_type_offset].indexOf('shortcut');\n" 655 " meta.edge_types[edge_type_offset].indexOf('shortcut');\n"
655 "var node_count = parsed.nodes.length / node_fields_count;\n" 656 "var node_count = parsed.nodes.length / node_fields_count;\n"
656 "var first_edge_indexes = parsed.first_edge_indexes = [];\n" 657 "var first_edge_indexes = parsed.first_edge_indexes = [];\n"
657 "for (var i = 0, first_edge_index = 0; i < node_count; ++i) {\n" 658 "for (var i = 0, first_edge_index = 0; i < node_count; ++i) {\n"
658 " first_edge_indexes[i] = first_edge_index;\n" 659 " first_edge_indexes[i] = first_edge_index;\n"
659 " first_edge_index += edge_fields_count *\n" 660 " first_edge_index += edge_fields_count *\n"
660 " parsed.nodes[i * node_fields_count + edge_count_offset];\n" 661 " parsed.nodes[i * node_fields_count + edge_count_offset];\n"
661 "}\n"); 662 "}\n"
663 "first_edge_indexes[node_count] = first_edge_index;\n");
662 CHECK(!meta_analysis_result.IsEmpty()); 664 CHECK(!meta_analysis_result.IsEmpty());
663 665
664 // A helper function for processing encoded nodes. 666 // A helper function for processing encoded nodes.
665 CompileRun( 667 CompileRun(
666 "function GetChildPosByProperty(pos, prop_name, prop_type) {\n" 668 "function GetChildPosByProperty(pos, prop_name, prop_type) {\n"
667 " var nodes = parsed.nodes;\n" 669 " var nodes = parsed.nodes;\n"
668 " var edges = parsed.edges;\n" 670 " var edges = parsed.edges;\n"
669 " var strings = parsed.strings;\n" 671 " var strings = parsed.strings;\n"
670 " var node_ordinal = pos / node_fields_count;\n" 672 " var node_ordinal = pos / node_fields_count;\n"
671 " for (var i = parsed.first_edge_indexes[node_ordinal],\n" 673 " for (var i = parsed.first_edge_indexes[node_ordinal],\n"
672 " count = parsed.first_edge_indexes[node_ordinal + 1];\n" 674 " count = parsed.first_edge_indexes[node_ordinal + 1];\n"
673 " i < count; i += edge_fields_count) {\n" 675 " i < count; i += edge_fields_count) {\n"
674 " if (edges[i + edge_type_offset] === prop_type\n" 676 " if (edges[i + edge_type_offset] === prop_type\n"
675 " && strings[edges[i + edge_name_offset]] === prop_name)\n" 677 " && strings[edges[i + edge_name_offset]] === prop_name)\n"
676 " return edges[i + edge_to_node_offset];\n" 678 " return edges[i + edge_to_node_offset];\n"
677 " }\n" 679 " }\n"
678 " return null;\n" 680 " return null;\n"
679 "}\n"); 681 "}\n");
680 // Get the string index using the path: <root> -> <global>.b.x.s 682 // Get the string index using the path: <root> -> <global>.b.x.s
681 v8::Local<v8::Value> string_obj_pos_val = CompileRun( 683 v8::Local<v8::Value> string_obj_pos_val = CompileRun(
682 "GetChildPosByProperty(\n" 684 "GetChildPosByProperty(\n"
683 " GetChildPosByProperty(\n" 685 " GetChildPosByProperty(\n"
684 " GetChildPosByProperty(" 686 " GetChildPosByProperty("
685 " parsed.edges[edge_to_node_offset]," 687 " parsed.edges[edge_fields_count + edge_to_node_offset],"
686 " \"b\", property_type),\n" 688 " \"b\", property_type),\n"
687 " \"x\", property_type)," 689 " \"x\", property_type),"
688 " \"s\", property_type)"); 690 " \"s\", property_type)");
689 CHECK(!string_obj_pos_val.IsEmpty()); 691 CHECK(!string_obj_pos_val.IsEmpty());
690 int string_obj_pos = 692 int string_obj_pos =
691 static_cast<int>(string_obj_pos_val->ToNumber()->Value()); 693 static_cast<int>(string_obj_pos_val->ToNumber()->Value());
692 v8::Local<v8::Object> nodes_array = 694 v8::Local<v8::Object> nodes_array =
693 parsed_snapshot->Get(v8_str("nodes"))->ToObject(); 695 parsed_snapshot->Get(v8_str("nodes"))->ToObject();
694 int string_index = static_cast<int>( 696 int string_index = static_cast<int>(
695 nodes_array->Get(string_obj_pos + 1)->ToNumber()->Value()); 697 nodes_array->Get(string_obj_pos + 1)->ToNumber()->Value());
(...skipping 1121 matching lines...) Expand 10 before | Expand all | Expand 10 after
1817 // Check all the objects have got their names. 1819 // Check all the objects have got their names.
1818 // ... well check just every 8th because otherwise it's too slow in debug. 1820 // ... well check just every 8th because otherwise it's too slow in debug.
1819 for (int i = 0; i < num_objects - 1; i += 8) { 1821 for (int i = 0; i < num_objects - 1; i += 8) {
1820 i::EmbeddedVector<char, 100> var_name; 1822 i::EmbeddedVector<char, 100> var_name;
1821 i::OS::SNPrintF(var_name, "f_%d", i); 1823 i::OS::SNPrintF(var_name, "f_%d", i);
1822 const v8::HeapGraphNode* f_object = GetProperty( 1824 const v8::HeapGraphNode* f_object = GetProperty(
1823 context_object, v8::HeapGraphEdge::kContextVariable, var_name.start()); 1825 context_object, v8::HeapGraphEdge::kContextVariable, var_name.start());
1824 CHECK_NE(NULL, f_object); 1826 CHECK_NE(NULL, f_object);
1825 } 1827 }
1826 } 1828 }
OLDNEW
« no previous file with comments | « src/heap-snapshot-generator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698