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

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

Issue 10037004: Split nodes and edges into separate arrays in heap snapshot serialization. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Update to the snapshot structure desciption. Created 8 years, 8 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 "v8.h" 5 #include "v8.h"
6 6
7 #include "cctest.h" 7 #include "cctest.h"
8 #include "heap-profiler.h" 8 #include "heap-profiler.h"
9 #include "snapshot.h" 9 #include "snapshot.h"
10 #include "utils-inl.h" 10 #include "utils-inl.h"
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 env->Global()->Set(v8_str("json_snapshot"), json_string); 606 env->Global()->Set(v8_str("json_snapshot"), json_string);
607 v8::Local<v8::Value> snapshot_parse_result = CompileRun( 607 v8::Local<v8::Value> snapshot_parse_result = CompileRun(
608 "var parsed = JSON.parse(json_snapshot); true;"); 608 "var parsed = JSON.parse(json_snapshot); true;");
609 CHECK(!snapshot_parse_result.IsEmpty()); 609 CHECK(!snapshot_parse_result.IsEmpty());
610 610
611 // Verify that snapshot object has required fields. 611 // Verify that snapshot object has required fields.
612 v8::Local<v8::Object> parsed_snapshot = 612 v8::Local<v8::Object> parsed_snapshot =
613 env->Global()->Get(v8_str("parsed"))->ToObject(); 613 env->Global()->Get(v8_str("parsed"))->ToObject();
614 CHECK(parsed_snapshot->Has(v8_str("snapshot"))); 614 CHECK(parsed_snapshot->Has(v8_str("snapshot")));
615 CHECK(parsed_snapshot->Has(v8_str("nodes"))); 615 CHECK(parsed_snapshot->Has(v8_str("nodes")));
616 CHECK(parsed_snapshot->Has(v8_str("edges")));
616 CHECK(parsed_snapshot->Has(v8_str("strings"))); 617 CHECK(parsed_snapshot->Has(v8_str("strings")));
617 618
618 // Get node and edge "member" offsets. 619 // Get node and edge "member" offsets.
619 v8::Local<v8::Value> meta_analysis_result = CompileRun( 620 v8::Local<v8::Value> meta_analysis_result = CompileRun(
620 "var parsed_meta = parsed.nodes[0];\n" 621 "var meta = parsed.snapshot.meta;\n"
621 "var children_count_offset =" 622 "var edges_index_offset = meta.node_fields.indexOf('edges_index');\n"
622 " parsed_meta.fields.indexOf('children_count');\n" 623 "var node_fields_count = meta.node_fields.length;\n"
623 "var children_offset =" 624 "var edge_fields_count = meta.edge_fields.length;\n"
624 " parsed_meta.fields.indexOf('children');\n" 625 "var edge_type_offset = meta.edge_fields.indexOf('type');\n"
625 "var children_meta =" 626 "var edge_name_offset = meta.edge_fields.indexOf('name_or_index');\n"
626 " parsed_meta.types[children_offset];\n" 627 "var edge_to_node_offset = meta.edge_fields.indexOf('to_node');\n"
627 "var child_fields_count = children_meta.fields.length;\n"
628 "var child_type_offset ="
629 " children_meta.fields.indexOf('type');\n"
630 "var child_name_offset ="
631 " children_meta.fields.indexOf('name_or_index');\n"
632 "var child_to_node_offset ="
633 " children_meta.fields.indexOf('to_node');\n"
634 "var property_type =" 628 "var property_type ="
635 " children_meta.types[child_type_offset].indexOf('property');\n" 629 " meta.edge_types[edge_type_offset].indexOf('property');\n"
636 "var shortcut_type =" 630 "var shortcut_type ="
637 " children_meta.types[child_type_offset].indexOf('shortcut');"); 631 " meta.edge_types[edge_type_offset].indexOf('shortcut');\n"
632 "parsed.nodes.concat(0, 0, 0, 0, 0, 0, parsed.edges.length);");
638 CHECK(!meta_analysis_result.IsEmpty()); 633 CHECK(!meta_analysis_result.IsEmpty());
639 634
640 // A helper function for processing encoded nodes. 635 // A helper function for processing encoded nodes.
641 CompileRun( 636 CompileRun(
642 "function GetChildPosByProperty(pos, prop_name, prop_type) {\n" 637 "function GetChildPosByProperty(pos, prop_name, prop_type) {\n"
643 " var nodes = parsed.nodes;\n" 638 " var nodes = parsed.nodes;\n"
639 " var edges = parsed.edges;\n"
644 " var strings = parsed.strings;\n" 640 " var strings = parsed.strings;\n"
645 " for (var i = 0,\n" 641 " for (var i = nodes[pos + edges_index_offset],\n"
646 " count = nodes[pos + children_count_offset] * child_fields_count;\n" 642 " count = nodes[pos + node_fields_count + edges_index_offset];\n"
647 " i < count; i += child_fields_count) {\n" 643 " i < count; i += edge_fields_count) {\n"
648 " var child_pos = pos + children_offset + i;\n" 644 " if (edges[i + edge_type_offset] === prop_type\n"
649 " if (nodes[child_pos + child_type_offset] === prop_type\n" 645 " && strings[edges[i + edge_name_offset]] === prop_name)\n"
650 " && strings[nodes[child_pos + child_name_offset]] === prop_name)\n" 646 " return edges[i + edge_to_node_offset];\n"
651 " return nodes[child_pos + child_to_node_offset];\n"
652 " }\n" 647 " }\n"
653 " return null;\n" 648 " return null;\n"
654 "}\n"); 649 "}\n");
655 // Get the string index using the path: <root> -> <global>.b.x.s 650 // Get the string index using the path: <root> -> <global>.b.x.s
656 v8::Local<v8::Value> string_obj_pos_val = CompileRun( 651 v8::Local<v8::Value> string_obj_pos_val = CompileRun(
657 "GetChildPosByProperty(\n" 652 "GetChildPosByProperty(\n"
658 " GetChildPosByProperty(\n" 653 " GetChildPosByProperty(\n"
659 " GetChildPosByProperty(" 654 " GetChildPosByProperty("
660 " parsed.nodes[1 + children_offset + child_to_node_offset]," 655 " parsed.edges[parsed.nodes[edges_index_offset]"
661 " \"b\",shortcut_type),\n" 656 " + edge_to_node_offset],"
657 " \"b\", shortcut_type),\n"
662 " \"x\", property_type)," 658 " \"x\", property_type),"
663 " \"s\", property_type)"); 659 " \"s\", property_type)");
664 CHECK(!string_obj_pos_val.IsEmpty()); 660 CHECK(!string_obj_pos_val.IsEmpty());
665 int string_obj_pos = 661 int string_obj_pos =
666 static_cast<int>(string_obj_pos_val->ToNumber()->Value()); 662 static_cast<int>(string_obj_pos_val->ToNumber()->Value());
667 v8::Local<v8::Object> nodes_array = 663 v8::Local<v8::Object> nodes_array =
668 parsed_snapshot->Get(v8_str("nodes"))->ToObject(); 664 parsed_snapshot->Get(v8_str("nodes"))->ToObject();
669 int string_index = static_cast<int>( 665 int string_index = static_cast<int>(
670 nodes_array->Get(string_obj_pos + 1)->ToNumber()->Value()); 666 nodes_array->Get(string_obj_pos + 1)->ToNumber()->Value());
671 CHECK_GT(string_index, 0); 667 CHECK_GT(string_index, 0);
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after
1365 // Dipose the persistent handles in a different order. 1361 // Dipose the persistent handles in a different order.
1366 p_AAA.Dispose(); 1362 p_AAA.Dispose();
1367 CHECK_EQ(global_handle_count + 2, 1363 CHECK_EQ(global_handle_count + 2,
1368 v8::HeapProfiler::GetPersistentHandleCount()); 1364 v8::HeapProfiler::GetPersistentHandleCount());
1369 p_CCC.Dispose(); 1365 p_CCC.Dispose();
1370 CHECK_EQ(global_handle_count + 1, 1366 CHECK_EQ(global_handle_count + 1,
1371 v8::HeapProfiler::GetPersistentHandleCount()); 1367 v8::HeapProfiler::GetPersistentHandleCount());
1372 p_BBB.Dispose(); 1368 p_BBB.Dispose();
1373 CHECK_EQ(global_handle_count, v8::HeapProfiler::GetPersistentHandleCount()); 1369 CHECK_EQ(global_handle_count, v8::HeapProfiler::GetPersistentHandleCount());
1374 } 1370 }
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