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

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

Issue 10534008: Serialize edge counts instead of indexes in heap snapshot. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressing comment. Created 8 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
« no previous file with comments | « 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 #include <ctype.h> 5 #include <ctype.h>
6 6
7 #include "v8.h" 7 #include "v8.h"
8 8
9 #include "cctest.h" 9 #include "cctest.h"
10 #include "hashmap.h" 10 #include "hashmap.h"
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 v8::Local<v8::Object> parsed_snapshot = 558 v8::Local<v8::Object> parsed_snapshot =
559 env->Global()->Get(v8_str("parsed"))->ToObject(); 559 env->Global()->Get(v8_str("parsed"))->ToObject();
560 CHECK(parsed_snapshot->Has(v8_str("snapshot"))); 560 CHECK(parsed_snapshot->Has(v8_str("snapshot")));
561 CHECK(parsed_snapshot->Has(v8_str("nodes"))); 561 CHECK(parsed_snapshot->Has(v8_str("nodes")));
562 CHECK(parsed_snapshot->Has(v8_str("edges"))); 562 CHECK(parsed_snapshot->Has(v8_str("edges")));
563 CHECK(parsed_snapshot->Has(v8_str("strings"))); 563 CHECK(parsed_snapshot->Has(v8_str("strings")));
564 564
565 // Get node and edge "member" offsets. 565 // Get node and edge "member" offsets.
566 v8::Local<v8::Value> meta_analysis_result = CompileRun( 566 v8::Local<v8::Value> meta_analysis_result = CompileRun(
567 "var meta = parsed.snapshot.meta;\n" 567 "var meta = parsed.snapshot.meta;\n"
568 "var edges_index_offset = meta.node_fields.indexOf('edges_index');\n" 568 "var edge_count_offset = meta.node_fields.indexOf('edge_count');\n"
569 "var node_fields_count = meta.node_fields.length;\n" 569 "var node_fields_count = meta.node_fields.length;\n"
570 "var edge_fields_count = meta.edge_fields.length;\n" 570 "var edge_fields_count = meta.edge_fields.length;\n"
571 "var edge_type_offset = meta.edge_fields.indexOf('type');\n" 571 "var edge_type_offset = meta.edge_fields.indexOf('type');\n"
572 "var edge_name_offset = meta.edge_fields.indexOf('name_or_index');\n" 572 "var edge_name_offset = meta.edge_fields.indexOf('name_or_index');\n"
573 "var edge_to_node_offset = meta.edge_fields.indexOf('to_node');\n" 573 "var edge_to_node_offset = meta.edge_fields.indexOf('to_node');\n"
574 "var property_type =" 574 "var property_type ="
575 " meta.edge_types[edge_type_offset].indexOf('property');\n" 575 " meta.edge_types[edge_type_offset].indexOf('property');\n"
576 "var shortcut_type =" 576 "var shortcut_type ="
577 " meta.edge_types[edge_type_offset].indexOf('shortcut');\n" 577 " meta.edge_types[edge_type_offset].indexOf('shortcut');\n"
578 "parsed.nodes.concat(0, 0, 0, 0, 0, 0, parsed.edges.length);"); 578 "var node_count = parsed.nodes.length / node_fields_count;\n"
579 "var first_edge_indexes = parsed.first_edge_indexes = [];\n"
580 "for (var i = 0, first_edge_index = 0; i < node_count; ++i) {\n"
581 " first_edge_indexes[i] = first_edge_index;\n"
582 " first_edge_index += edge_fields_count *\n"
583 " parsed.nodes[i * node_fields_count + edge_count_offset];\n"
584 "}\n");
579 CHECK(!meta_analysis_result.IsEmpty()); 585 CHECK(!meta_analysis_result.IsEmpty());
580 586
581 // A helper function for processing encoded nodes. 587 // A helper function for processing encoded nodes.
582 CompileRun( 588 CompileRun(
583 "function GetChildPosByProperty(pos, prop_name, prop_type) {\n" 589 "function GetChildPosByProperty(pos, prop_name, prop_type) {\n"
584 " var nodes = parsed.nodes;\n" 590 " var nodes = parsed.nodes;\n"
585 " var edges = parsed.edges;\n" 591 " var edges = parsed.edges;\n"
586 " var strings = parsed.strings;\n" 592 " var strings = parsed.strings;\n"
587 " for (var i = nodes[pos + edges_index_offset],\n" 593 " var node_ordinal = pos / node_fields_count;\n"
588 " count = nodes[pos + node_fields_count + edges_index_offset];\n" 594 " for (var i = parsed.first_edge_indexes[node_ordinal],\n"
595 " count = parsed.first_edge_indexes[node_ordinal + 1];\n"
589 " i < count; i += edge_fields_count) {\n" 596 " i < count; i += edge_fields_count) {\n"
590 " if (edges[i + edge_type_offset] === prop_type\n" 597 " if (edges[i + edge_type_offset] === prop_type\n"
591 " && strings[edges[i + edge_name_offset]] === prop_name)\n" 598 " && strings[edges[i + edge_name_offset]] === prop_name)\n"
592 " return edges[i + edge_to_node_offset];\n" 599 " return edges[i + edge_to_node_offset];\n"
593 " }\n" 600 " }\n"
594 " return null;\n" 601 " return null;\n"
595 "}\n"); 602 "}\n");
596 // Get the string index using the path: <root> -> <global>.b.x.s 603 // Get the string index using the path: <root> -> <global>.b.x.s
597 v8::Local<v8::Value> string_obj_pos_val = CompileRun( 604 v8::Local<v8::Value> string_obj_pos_val = CompileRun(
598 "GetChildPosByProperty(\n" 605 "GetChildPosByProperty(\n"
599 " GetChildPosByProperty(\n" 606 " GetChildPosByProperty(\n"
600 " GetChildPosByProperty(" 607 " GetChildPosByProperty("
601 " parsed.edges[parsed.nodes[edges_index_offset]" 608 " parsed.edges[edge_to_node_offset],"
602 " + edge_to_node_offset],"
603 " \"b\", property_type),\n" 609 " \"b\", property_type),\n"
604 " \"x\", property_type)," 610 " \"x\", property_type),"
605 " \"s\", property_type)"); 611 " \"s\", property_type)");
606 CHECK(!string_obj_pos_val.IsEmpty()); 612 CHECK(!string_obj_pos_val.IsEmpty());
607 int string_obj_pos = 613 int string_obj_pos =
608 static_cast<int>(string_obj_pos_val->ToNumber()->Value()); 614 static_cast<int>(string_obj_pos_val->ToNumber()->Value());
609 v8::Local<v8::Object> nodes_array = 615 v8::Local<v8::Object> nodes_array =
610 parsed_snapshot->Get(v8_str("nodes"))->ToObject(); 616 parsed_snapshot->Get(v8_str("nodes"))->ToObject();
611 int string_index = static_cast<int>( 617 int string_index = static_cast<int>(
612 nodes_array->Get(string_obj_pos + 1)->ToNumber()->Value()); 618 nodes_array->Get(string_obj_pos + 1)->ToNumber()->Value());
(...skipping 1000 matching lines...) Expand 10 before | Expand all | Expand 10 after
1613 const v8::HeapGraphNode* global_object = 1619 const v8::HeapGraphNode* global_object =
1614 GetProperty(global, v8::HeapGraphEdge::kProperty, "global_object"); 1620 GetProperty(global, v8::HeapGraphEdge::kProperty, "global_object");
1615 CHECK_NE(NULL, global_object); 1621 CHECK_NE(NULL, global_object);
1616 const v8::HeapGraphNode* properties = 1622 const v8::HeapGraphNode* properties =
1617 GetProperty(global_object, v8::HeapGraphEdge::kInternal, "properties"); 1623 GetProperty(global_object, v8::HeapGraphEdge::kInternal, "properties");
1618 CHECK_EQ(NULL, properties); 1624 CHECK_EQ(NULL, properties);
1619 const v8::HeapGraphNode* elements = 1625 const v8::HeapGraphNode* elements =
1620 GetProperty(global_object, v8::HeapGraphEdge::kInternal, "elements"); 1626 GetProperty(global_object, v8::HeapGraphEdge::kInternal, "elements");
1621 CHECK_EQ(NULL, elements); 1627 CHECK_EQ(NULL, elements);
1622 } 1628 }
OLDNEW
« no previous file with comments | « src/profile-generator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698