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

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: Minor tweak. 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
« src/profile-generator.cc ('K') | « 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.nodes[0];\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 = parsed.nodes.slice(1);\n"
mnaganov (inactive) 2012/04/10 22:28:09 Why is this needed?
alexeif 2012/04/11 12:49:57 it's not needed anymore. I removed the meta node f
633 "parsed.nodes.concat(0, 0, 0, 0, 0, 0, parsed.edges.length);");
638 CHECK(!meta_analysis_result.IsEmpty()); 634 CHECK(!meta_analysis_result.IsEmpty());
639 635
640 // A helper function for processing encoded nodes. 636 // A helper function for processing encoded nodes.
641 CompileRun( 637 CompileRun(
642 "function GetChildPosByProperty(pos, prop_name, prop_type) {\n" 638 "function GetChildPosByProperty(pos, prop_name, prop_type) {\n"
643 " var nodes = parsed.nodes;\n" 639 " var nodes = parsed.nodes;\n"
640 " var edges = parsed.edges;\n"
644 " var strings = parsed.strings;\n" 641 " var strings = parsed.strings;\n"
645 " for (var i = 0,\n" 642 " for (var i = nodes[pos + edges_index_offset],\n"
646 " count = nodes[pos + children_count_offset] * child_fields_count;\n" 643 " count = nodes[pos + node_fields_count + edges_index_offset];\n"
647 " i < count; i += child_fields_count) {\n" 644 " i < count; i += edge_fields_count) {\n"
648 " var child_pos = pos + children_offset + i;\n" 645 " if (edges[i + edge_type_offset] === prop_type\n"
649 " if (nodes[child_pos + child_type_offset] === prop_type\n" 646 " && strings[edges[i + edge_name_offset]] === prop_name)\n"
650 " && strings[nodes[child_pos + child_name_offset]] === prop_name)\n" 647 " return edges[i + edge_to_node_offset];\n"
651 " return nodes[child_pos + child_to_node_offset];\n"
652 " }\n" 648 " }\n"
653 " return null;\n" 649 " return null;\n"
654 "}\n"); 650 "}\n");
655 // Get the string index using the path: <root> -> <global>.b.x.s 651 // Get the string index using the path: <root> -> <global>.b.x.s
656 v8::Local<v8::Value> string_obj_pos_val = CompileRun( 652 v8::Local<v8::Value> string_obj_pos_val = CompileRun(
657 "GetChildPosByProperty(\n" 653 "GetChildPosByProperty(\n"
658 " GetChildPosByProperty(\n" 654 " GetChildPosByProperty(\n"
659 " GetChildPosByProperty(" 655 " GetChildPosByProperty("
660 " parsed.nodes[1 + children_offset + child_to_node_offset]," 656 " parsed.edges[parsed.nodes[edges_index_offset]"
661 " \"b\",shortcut_type),\n" 657 " + edge_to_node_offset],"
658 " \"b\", shortcut_type),\n"
662 " \"x\", property_type)," 659 " \"x\", property_type),"
663 " \"s\", property_type)"); 660 " \"s\", property_type)");
664 CHECK(!string_obj_pos_val.IsEmpty()); 661 CHECK(!string_obj_pos_val.IsEmpty());
665 int string_obj_pos = 662 int string_obj_pos =
666 static_cast<int>(string_obj_pos_val->ToNumber()->Value()); 663 static_cast<int>(string_obj_pos_val->ToNumber()->Value());
667 v8::Local<v8::Object> nodes_array = 664 v8::Local<v8::Object> nodes_array =
668 parsed_snapshot->Get(v8_str("nodes"))->ToObject(); 665 parsed_snapshot->Get(v8_str("nodes"))->ToObject();
669 int string_index = static_cast<int>( 666 int string_index = static_cast<int>(
670 nodes_array->Get(string_obj_pos + 1)->ToNumber()->Value()); 667 nodes_array->Get(string_obj_pos + 1)->ToNumber()->Value());
671 CHECK_GT(string_index, 0); 668 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. 1362 // Dipose the persistent handles in a different order.
1366 p_AAA.Dispose(); 1363 p_AAA.Dispose();
1367 CHECK_EQ(global_handle_count + 2, 1364 CHECK_EQ(global_handle_count + 2,
1368 v8::HeapProfiler::GetPersistentHandleCount()); 1365 v8::HeapProfiler::GetPersistentHandleCount());
1369 p_CCC.Dispose(); 1366 p_CCC.Dispose();
1370 CHECK_EQ(global_handle_count + 1, 1367 CHECK_EQ(global_handle_count + 1,
1371 v8::HeapProfiler::GetPersistentHandleCount()); 1368 v8::HeapProfiler::GetPersistentHandleCount());
1372 p_BBB.Dispose(); 1369 p_BBB.Dispose();
1373 CHECK_EQ(global_handle_count, v8::HeapProfiler::GetPersistentHandleCount()); 1370 CHECK_EQ(global_handle_count, v8::HeapProfiler::GetPersistentHandleCount());
1374 } 1371 }
OLDNEW
« src/profile-generator.cc ('K') | « src/profile-generator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698