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

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

Issue 10025014: Revert "External references should not affect dominance relation." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: 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-inl.h ('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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 "var c2 = new C2(a2);"); 102 "var c2 = new C2(a2);");
103 const v8::HeapSnapshot* snapshot_env2 = 103 const v8::HeapSnapshot* snapshot_env2 =
104 v8::HeapProfiler::TakeSnapshot(v8_str("env2")); 104 v8::HeapProfiler::TakeSnapshot(v8_str("env2"));
105 i::HeapSnapshot* i_snapshot_env2 = 105 i::HeapSnapshot* i_snapshot_env2 =
106 const_cast<i::HeapSnapshot*>( 106 const_cast<i::HeapSnapshot*>(
107 reinterpret_cast<const i::HeapSnapshot*>(snapshot_env2)); 107 reinterpret_cast<const i::HeapSnapshot*>(snapshot_env2));
108 const v8::HeapGraphNode* global_env2 = GetGlobalObject(snapshot_env2); 108 const v8::HeapGraphNode* global_env2 = GetGlobalObject(snapshot_env2);
109 109
110 // Verify, that JS global object of env2 has '..2' properties. 110 // Verify, that JS global object of env2 has '..2' properties.
111 const v8::HeapGraphNode* a2_node = 111 const v8::HeapGraphNode* a2_node =
112 GetProperty(global_env2, v8::HeapGraphEdge::kProperty, "a2"); 112 GetProperty(global_env2, v8::HeapGraphEdge::kShortcut, "a2");
113 CHECK_NE(NULL, a2_node); 113 CHECK_NE(NULL, a2_node);
114 CHECK_NE( 114 CHECK_NE(
115 NULL, GetProperty(global_env2, v8::HeapGraphEdge::kProperty, "b2_1")); 115 NULL, GetProperty(global_env2, v8::HeapGraphEdge::kShortcut, "b2_1"));
116 CHECK_NE( 116 CHECK_NE(
117 NULL, GetProperty(global_env2, v8::HeapGraphEdge::kProperty, "b2_2")); 117 NULL, GetProperty(global_env2, v8::HeapGraphEdge::kShortcut, "b2_2"));
118 CHECK_NE(NULL, GetProperty(global_env2, v8::HeapGraphEdge::kProperty, "c2")); 118 CHECK_NE(NULL, GetProperty(global_env2, v8::HeapGraphEdge::kShortcut, "c2"));
119 119
120 // Paint all nodes reachable from global object. 120 // Paint all nodes reachable from global object.
121 NamedEntriesDetector det; 121 NamedEntriesDetector det;
122 i_snapshot_env2->ClearPaint(); 122 i_snapshot_env2->ClearPaint();
123 det.CheckAllReachables(const_cast<i::HeapEntry*>( 123 det.CheckAllReachables(const_cast<i::HeapEntry*>(
124 reinterpret_cast<const i::HeapEntry*>(global_env2))); 124 reinterpret_cast<const i::HeapEntry*>(global_env2)));
125 CHECK(det.has_A2); 125 CHECK(det.has_A2);
126 CHECK(det.has_B2); 126 CHECK(det.has_B2);
127 CHECK(det.has_C2); 127 CHECK(det.has_C2);
128 } 128 }
129 129
130 130
131 TEST(HeapSnapshotObjectSizes) { 131 TEST(HeapSnapshotObjectSizes) {
132 v8::HandleScope scope; 132 v8::HandleScope scope;
133 LocalContext env; 133 LocalContext env;
134 134
135 // -a-> X1 --a 135 // -a-> X1 --a
136 // x -b-> X2 <-| 136 // x -b-> X2 <-|
137 CompileRun( 137 CompileRun(
138 "function X(a, b) { this.a = a; this.b = b; }\n" 138 "function X(a, b) { this.a = a; this.b = b; }\n"
139 "x = new X(new X(), new X());\n" 139 "x = new X(new X(), new X());\n"
140 "(function() { x.a.a = x.b; })();"); 140 "(function() { x.a.a = x.b; })();");
141 const v8::HeapSnapshot* snapshot = 141 const v8::HeapSnapshot* snapshot =
142 v8::HeapProfiler::TakeSnapshot(v8_str("sizes")); 142 v8::HeapProfiler::TakeSnapshot(v8_str("sizes"));
143 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); 143 const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
144 const v8::HeapGraphNode* x = 144 const v8::HeapGraphNode* x =
145 GetProperty(global, v8::HeapGraphEdge::kProperty, "x"); 145 GetProperty(global, v8::HeapGraphEdge::kShortcut, "x");
146 CHECK_NE(NULL, x); 146 CHECK_NE(NULL, x);
147 const v8::HeapGraphNode* x1 = 147 const v8::HeapGraphNode* x1 =
148 GetProperty(x, v8::HeapGraphEdge::kProperty, "a"); 148 GetProperty(x, v8::HeapGraphEdge::kProperty, "a");
149 CHECK_NE(NULL, x1); 149 CHECK_NE(NULL, x1);
150 const v8::HeapGraphNode* x2 = 150 const v8::HeapGraphNode* x2 =
151 GetProperty(x, v8::HeapGraphEdge::kProperty, "b"); 151 GetProperty(x, v8::HeapGraphEdge::kProperty, "b");
152 CHECK_NE(NULL, x2); 152 CHECK_NE(NULL, x2);
153 153
154 // Test sizes. 154 // Test sizes.
155 CHECK_EQ(x->GetSelfSize() * 3, x->GetRetainedSize()); 155 CHECK_EQ(x->GetSelfSize() * 3, x->GetRetainedSize());
156 CHECK_EQ(x1->GetSelfSize(), x1->GetRetainedSize()); 156 CHECK_EQ(x1->GetSelfSize(), x1->GetRetainedSize());
157 CHECK_EQ(x2->GetSelfSize(), x2->GetRetainedSize()); 157 CHECK_EQ(x2->GetSelfSize(), x2->GetRetainedSize());
158 } 158 }
159 159
160 160
161 TEST(BoundFunctionInSnapshot) { 161 TEST(BoundFunctionInSnapshot) {
162 v8::HandleScope scope; 162 v8::HandleScope scope;
163 LocalContext env; 163 LocalContext env;
164 CompileRun( 164 CompileRun(
165 "function myFunction(a, b) { this.a = a; this.b = b; }\n" 165 "function myFunction(a, b) { this.a = a; this.b = b; }\n"
166 "function AAAAA() {}\n" 166 "function AAAAA() {}\n"
167 "boundFunction = myFunction.bind(new AAAAA(), 20, new Number(12)); \n"); 167 "boundFunction = myFunction.bind(new AAAAA(), 20, new Number(12)); \n");
168 const v8::HeapSnapshot* snapshot = 168 const v8::HeapSnapshot* snapshot =
169 v8::HeapProfiler::TakeSnapshot(v8_str("sizes")); 169 v8::HeapProfiler::TakeSnapshot(v8_str("sizes"));
170 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); 170 const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
171 const v8::HeapGraphNode* f = 171 const v8::HeapGraphNode* f =
172 GetProperty(global, v8::HeapGraphEdge::kProperty, "boundFunction"); 172 GetProperty(global, v8::HeapGraphEdge::kShortcut, "boundFunction");
173 CHECK(f); 173 CHECK(f);
174 CHECK_EQ(v8::String::New("native_bind"), f->GetName()); 174 CHECK_EQ(v8::String::New("native_bind"), f->GetName());
175 const v8::HeapGraphNode* bindings = 175 const v8::HeapGraphNode* bindings =
176 GetProperty(f, v8::HeapGraphEdge::kInternal, "bindings"); 176 GetProperty(f, v8::HeapGraphEdge::kInternal, "bindings");
177 CHECK_NE(NULL, bindings); 177 CHECK_NE(NULL, bindings);
178 CHECK_EQ(v8::HeapGraphNode::kArray, bindings->GetType()); 178 CHECK_EQ(v8::HeapGraphNode::kArray, bindings->GetType());
179 CHECK_EQ(4, bindings->GetChildrenCount()); 179 CHECK_EQ(4, bindings->GetChildrenCount());
180 180
181 const v8::HeapGraphNode* bound_this = GetProperty( 181 const v8::HeapGraphNode* bound_this = GetProperty(
182 f, v8::HeapGraphEdge::kShortcut, "bound_this"); 182 f, v8::HeapGraphEdge::kShortcut, "bound_this");
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 CompileRun( 226 CompileRun(
227 "function lazy(x) { return x - 1; }\n" 227 "function lazy(x) { return x - 1; }\n"
228 "function compiled(x) { return x + 1; }\n" 228 "function compiled(x) { return x + 1; }\n"
229 "var anonymous = (function() { return function() { return 0; } })();\n" 229 "var anonymous = (function() { return function() { return 0; } })();\n"
230 "compiled(1)"); 230 "compiled(1)");
231 const v8::HeapSnapshot* snapshot = 231 const v8::HeapSnapshot* snapshot =
232 v8::HeapProfiler::TakeSnapshot(v8_str("code")); 232 v8::HeapProfiler::TakeSnapshot(v8_str("code"));
233 233
234 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); 234 const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
235 const v8::HeapGraphNode* compiled = 235 const v8::HeapGraphNode* compiled =
236 GetProperty(global, v8::HeapGraphEdge::kProperty, "compiled"); 236 GetProperty(global, v8::HeapGraphEdge::kShortcut, "compiled");
237 CHECK_NE(NULL, compiled); 237 CHECK_NE(NULL, compiled);
238 CHECK_EQ(v8::HeapGraphNode::kClosure, compiled->GetType()); 238 CHECK_EQ(v8::HeapGraphNode::kClosure, compiled->GetType());
239 const v8::HeapGraphNode* lazy = 239 const v8::HeapGraphNode* lazy =
240 GetProperty(global, v8::HeapGraphEdge::kProperty, "lazy"); 240 GetProperty(global, v8::HeapGraphEdge::kShortcut, "lazy");
241 CHECK_NE(NULL, lazy); 241 CHECK_NE(NULL, lazy);
242 CHECK_EQ(v8::HeapGraphNode::kClosure, lazy->GetType()); 242 CHECK_EQ(v8::HeapGraphNode::kClosure, lazy->GetType());
243 const v8::HeapGraphNode* anonymous = 243 const v8::HeapGraphNode* anonymous =
244 GetProperty(global, v8::HeapGraphEdge::kProperty, "anonymous"); 244 GetProperty(global, v8::HeapGraphEdge::kShortcut, "anonymous");
245 CHECK_NE(NULL, anonymous); 245 CHECK_NE(NULL, anonymous);
246 CHECK_EQ(v8::HeapGraphNode::kClosure, anonymous->GetType()); 246 CHECK_EQ(v8::HeapGraphNode::kClosure, anonymous->GetType());
247 v8::String::AsciiValue anonymous_name(anonymous->GetName()); 247 v8::String::AsciiValue anonymous_name(anonymous->GetName());
248 CHECK_EQ("", *anonymous_name); 248 CHECK_EQ("", *anonymous_name);
249 249
250 // Find references to code. 250 // Find references to code.
251 const v8::HeapGraphNode* compiled_code = 251 const v8::HeapGraphNode* compiled_code =
252 GetProperty(compiled, v8::HeapGraphEdge::kInternal, "shared"); 252 GetProperty(compiled, v8::HeapGraphEdge::kInternal, "shared");
253 CHECK_NE(NULL, compiled_code); 253 CHECK_NE(NULL, compiled_code);
254 const v8::HeapGraphNode* lazy_code = 254 const v8::HeapGraphNode* lazy_code =
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 286
287 TEST(HeapSnapshotHeapNumbers) { 287 TEST(HeapSnapshotHeapNumbers) {
288 v8::HandleScope scope; 288 v8::HandleScope scope;
289 LocalContext env; 289 LocalContext env;
290 CompileRun( 290 CompileRun(
291 "a = 1; // a is Smi\n" 291 "a = 1; // a is Smi\n"
292 "b = 2.5; // b is HeapNumber"); 292 "b = 2.5; // b is HeapNumber");
293 const v8::HeapSnapshot* snapshot = 293 const v8::HeapSnapshot* snapshot =
294 v8::HeapProfiler::TakeSnapshot(v8_str("numbers")); 294 v8::HeapProfiler::TakeSnapshot(v8_str("numbers"));
295 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); 295 const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
296 CHECK_EQ(NULL, GetProperty(global, v8::HeapGraphEdge::kProperty, "a")); 296 CHECK_EQ(NULL, GetProperty(global, v8::HeapGraphEdge::kShortcut, "a"));
297 const v8::HeapGraphNode* b = 297 const v8::HeapGraphNode* b =
298 GetProperty(global, v8::HeapGraphEdge::kProperty, "b"); 298 GetProperty(global, v8::HeapGraphEdge::kShortcut, "b");
299 CHECK_NE(NULL, b); 299 CHECK_NE(NULL, b);
300 CHECK_EQ(v8::HeapGraphNode::kHeapNumber, b->GetType()); 300 CHECK_EQ(v8::HeapGraphNode::kHeapNumber, b->GetType());
301 } 301 }
302 302
303 TEST(HeapSnapshotSlicedString) { 303 TEST(HeapSnapshotSlicedString) {
304 v8::HandleScope scope; 304 v8::HandleScope scope;
305 LocalContext env; 305 LocalContext env;
306 CompileRun( 306 CompileRun(
307 "parent_string = \"123456789.123456789.123456789.123456789.123456789." 307 "parent_string = \"123456789.123456789.123456789.123456789.123456789."
308 "123456789.123456789.123456789.123456789.123456789." 308 "123456789.123456789.123456789.123456789.123456789."
309 "123456789.123456789.123456789.123456789.123456789." 309 "123456789.123456789.123456789.123456789.123456789."
310 "123456789.123456789.123456789.123456789.123456789.\";" 310 "123456789.123456789.123456789.123456789.123456789.\";"
311 "child_string = parent_string.slice(100);"); 311 "child_string = parent_string.slice(100);");
312 const v8::HeapSnapshot* snapshot = 312 const v8::HeapSnapshot* snapshot =
313 v8::HeapProfiler::TakeSnapshot(v8_str("strings")); 313 v8::HeapProfiler::TakeSnapshot(v8_str("strings"));
314 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); 314 const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
315 const v8::HeapGraphNode* parent_string = 315 const v8::HeapGraphNode* parent_string =
316 GetProperty(global, v8::HeapGraphEdge::kProperty, "parent_string"); 316 GetProperty(global, v8::HeapGraphEdge::kShortcut, "parent_string");
317 CHECK_NE(NULL, parent_string); 317 CHECK_NE(NULL, parent_string);
318 const v8::HeapGraphNode* child_string = 318 const v8::HeapGraphNode* child_string =
319 GetProperty(global, v8::HeapGraphEdge::kProperty, "child_string"); 319 GetProperty(global, v8::HeapGraphEdge::kShortcut, "child_string");
320 CHECK_NE(NULL, child_string); 320 CHECK_NE(NULL, child_string);
321 const v8::HeapGraphNode* parent = 321 const v8::HeapGraphNode* parent =
322 GetProperty(child_string, v8::HeapGraphEdge::kInternal, "parent"); 322 GetProperty(child_string, v8::HeapGraphEdge::kInternal, "parent");
323 CHECK_EQ(parent_string, parent); 323 CHECK_EQ(parent_string, parent);
324 } 324 }
325 325
326 TEST(HeapSnapshotInternalReferences) { 326 TEST(HeapSnapshotInternalReferences) {
327 v8::HandleScope scope; 327 v8::HandleScope scope;
328 v8::Local<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); 328 v8::Local<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New();
329 global_template->SetInternalFieldCount(2); 329 global_template->SetInternalFieldCount(2);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 v8::HeapProfiler::TakeSnapshot(v8_str("s2")); 377 v8::HeapProfiler::TakeSnapshot(v8_str("s2"));
378 378
379 const v8::HeapGraphNode* global1 = GetGlobalObject(snapshot1); 379 const v8::HeapGraphNode* global1 = GetGlobalObject(snapshot1);
380 const v8::HeapGraphNode* global2 = GetGlobalObject(snapshot2); 380 const v8::HeapGraphNode* global2 = GetGlobalObject(snapshot2);
381 CHECK_NE_SNAPSHOT_OBJECT_ID(0, global1->GetId()); 381 CHECK_NE_SNAPSHOT_OBJECT_ID(0, global1->GetId());
382 CHECK_EQ_SNAPSHOT_OBJECT_ID(global1->GetId(), global2->GetId()); 382 CHECK_EQ_SNAPSHOT_OBJECT_ID(global1->GetId(), global2->GetId());
383 383
384 const v8::HeapGraphNode* a1 = 384 const v8::HeapGraphNode* a1 =
385 GetProperty(global1, v8::HeapGraphEdge::kProperty, "a"); 385 GetProperty(global1, v8::HeapGraphEdge::kProperty, "a");
386 CHECK_NE(NULL, a1); 386 CHECK_NE(NULL, a1);
387 const v8::HeapGraphNode* e1 =
388 GetProperty(a1, v8::HeapGraphEdge::kHidden, "1");
389 CHECK_NE(NULL, e1);
387 const v8::HeapGraphNode* k1 = 390 const v8::HeapGraphNode* k1 =
388 GetProperty(a1, v8::HeapGraphEdge::kInternal, "elements"); 391 GetProperty(e1, v8::HeapGraphEdge::kInternal, "elements");
389 CHECK_NE(NULL, k1); 392 CHECK_NE(NULL, k1);
390 const v8::HeapGraphNode* a2 = 393 const v8::HeapGraphNode* a2 =
391 GetProperty(global2, v8::HeapGraphEdge::kProperty, "a"); 394 GetProperty(global2, v8::HeapGraphEdge::kProperty, "a");
392 CHECK_NE(NULL, a2); 395 CHECK_NE(NULL, a2);
396 const v8::HeapGraphNode* e2 =
397 GetProperty(a2, v8::HeapGraphEdge::kHidden, "1");
398 CHECK_NE(NULL, e2);
393 const v8::HeapGraphNode* k2 = 399 const v8::HeapGraphNode* k2 =
394 GetProperty(a2, v8::HeapGraphEdge::kInternal, "elements"); 400 GetProperty(e2, v8::HeapGraphEdge::kInternal, "elements");
395 CHECK_NE(NULL, k2); 401 CHECK_NE(NULL, k2);
396 402
397 CHECK_EQ_SNAPSHOT_OBJECT_ID(a1->GetId(), a2->GetId()); 403 CHECK_EQ_SNAPSHOT_OBJECT_ID(a1->GetId(), a2->GetId());
404 CHECK_EQ_SNAPSHOT_OBJECT_ID(e1->GetId(), e2->GetId());
398 CHECK_EQ_SNAPSHOT_OBJECT_ID(k1->GetId(), k2->GetId()); 405 CHECK_EQ_SNAPSHOT_OBJECT_ID(k1->GetId(), k2->GetId());
399 } 406 }
400 407
401 TEST(HeapEntryIdsAndGC) { 408 TEST(HeapEntryIdsAndGC) {
402 v8::HandleScope scope; 409 v8::HandleScope scope;
403 LocalContext env; 410 LocalContext env;
404 411
405 CompileRun( 412 CompileRun(
406 "function A() {}\n" 413 "function A() {}\n"
407 "function B(x) { this.x = x; }\n" 414 "function B(x) { this.x = x; }\n"
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 "node6.b.a.b = node6.b.b; // node2 -> node3\n" 507 "node6.b.a.b = node6.b.b; // node2 -> node3\n"
501 "node6.b.b.a = node6.b.a; // node3 -> node2\n" 508 "node6.b.b.a = node6.b.a; // node3 -> node2\n"
502 "})();"); 509 "})();");
503 510
504 const v8::HeapSnapshot* snapshot = 511 const v8::HeapSnapshot* snapshot =
505 v8::HeapProfiler::TakeSnapshot(v8_str("dominators")); 512 v8::HeapProfiler::TakeSnapshot(v8_str("dominators"));
506 513
507 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); 514 const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
508 CHECK_NE(NULL, global); 515 CHECK_NE(NULL, global);
509 const v8::HeapGraphNode* node6 = 516 const v8::HeapGraphNode* node6 =
510 GetProperty(global, v8::HeapGraphEdge::kProperty, "node6"); 517 GetProperty(global, v8::HeapGraphEdge::kShortcut, "node6");
511 CHECK_NE(NULL, node6); 518 CHECK_NE(NULL, node6);
512 const v8::HeapGraphNode* node5 = 519 const v8::HeapGraphNode* node5 =
513 GetProperty(node6, v8::HeapGraphEdge::kProperty, "a"); 520 GetProperty(node6, v8::HeapGraphEdge::kProperty, "a");
514 CHECK_NE(NULL, node5); 521 CHECK_NE(NULL, node5);
515 const v8::HeapGraphNode* node4 = 522 const v8::HeapGraphNode* node4 =
516 GetProperty(node6, v8::HeapGraphEdge::kProperty, "b"); 523 GetProperty(node6, v8::HeapGraphEdge::kProperty, "b");
517 CHECK_NE(NULL, node4); 524 CHECK_NE(NULL, node4);
518 const v8::HeapGraphNode* node3 = 525 const v8::HeapGraphNode* node3 =
519 GetProperty(node4, v8::HeapGraphEdge::kProperty, "b"); 526 GetProperty(node4, v8::HeapGraphEdge::kProperty, "b");
520 CHECK_NE(NULL, node3); 527 CHECK_NE(NULL, node3);
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 " return nodes[child_pos + child_to_node_offset];\n" 651 " return nodes[child_pos + child_to_node_offset];\n"
645 " }\n" 652 " }\n"
646 " return null;\n" 653 " return null;\n"
647 "}\n"); 654 "}\n");
648 // Get the string index using the path: <root> -> <global>.b.x.s 655 // Get the string index using the path: <root> -> <global>.b.x.s
649 v8::Local<v8::Value> string_obj_pos_val = CompileRun( 656 v8::Local<v8::Value> string_obj_pos_val = CompileRun(
650 "GetChildPosByProperty(\n" 657 "GetChildPosByProperty(\n"
651 " GetChildPosByProperty(\n" 658 " GetChildPosByProperty(\n"
652 " GetChildPosByProperty(" 659 " GetChildPosByProperty("
653 " parsed.nodes[1 + children_offset + child_to_node_offset]," 660 " parsed.nodes[1 + children_offset + child_to_node_offset],"
654 " \"b\", property_type),\n" 661 " \"b\",shortcut_type),\n"
655 " \"x\", property_type)," 662 " \"x\", property_type),"
656 " \"s\", property_type)"); 663 " \"s\", property_type)");
657 CHECK(!string_obj_pos_val.IsEmpty()); 664 CHECK(!string_obj_pos_val.IsEmpty());
658 int string_obj_pos = 665 int string_obj_pos =
659 static_cast<int>(string_obj_pos_val->ToNumber()->Value()); 666 static_cast<int>(string_obj_pos_val->ToNumber()->Value());
660 v8::Local<v8::Object> nodes_array = 667 v8::Local<v8::Object> nodes_array =
661 parsed_snapshot->Get(v8_str("nodes"))->ToObject(); 668 parsed_snapshot->Get(v8_str("nodes"))->ToObject();
662 int string_index = static_cast<int>( 669 int string_index = static_cast<int>(
663 nodes_array->Get(string_obj_pos + 1)->ToNumber()->Value()); 670 nodes_array->Get(string_obj_pos + 1)->ToNumber()->Value());
664 CHECK_GT(string_index, 0); 671 CHECK_GT(string_index, 0);
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
945 v8::HandleScope scope; 952 v8::HandleScope scope;
946 LocalContext env; 953 LocalContext env;
947 954
948 GraphWithImplicitRefs graph(&env); 955 GraphWithImplicitRefs graph(&env);
949 v8::V8::SetGlobalGCPrologueCallback(&GraphWithImplicitRefs::gcPrologue); 956 v8::V8::SetGlobalGCPrologueCallback(&GraphWithImplicitRefs::gcPrologue);
950 957
951 const v8::HeapSnapshot* snapshot = 958 const v8::HeapSnapshot* snapshot =
952 v8::HeapProfiler::TakeSnapshot(v8_str("implicit_refs")); 959 v8::HeapProfiler::TakeSnapshot(v8_str("implicit_refs"));
953 960
954 const v8::HeapGraphNode* global_object = GetGlobalObject(snapshot); 961 const v8::HeapGraphNode* global_object = GetGlobalObject(snapshot);
962 // Use kShortcut type to skip intermediate JSGlobalPropertyCell
955 const v8::HeapGraphNode* obj0 = GetProperty( 963 const v8::HeapGraphNode* obj0 = GetProperty(
956 global_object, v8::HeapGraphEdge::kProperty, "root_object"); 964 global_object, v8::HeapGraphEdge::kShortcut, "root_object");
957 CHECK(obj0); 965 CHECK(obj0);
958 CHECK_EQ(v8::HeapGraphNode::kObject, obj0->GetType()); 966 CHECK_EQ(v8::HeapGraphNode::kObject, obj0->GetType());
959 const v8::HeapGraphNode* obj1 = GetProperty( 967 const v8::HeapGraphNode* obj1 = GetProperty(
960 obj0, v8::HeapGraphEdge::kInternal, "native"); 968 obj0, v8::HeapGraphEdge::kInternal, "native");
961 CHECK(obj1); 969 CHECK(obj1);
962 int implicit_targets_count = 0; 970 int implicit_targets_count = 0;
963 for (int i = 0, count = obj1->GetChildrenCount(); i < count; ++i) { 971 for (int i = 0, count = obj1->GetChildrenCount(); i < count; ++i) {
964 const v8::HeapGraphEdge* prop = obj1->GetChild(i); 972 const v8::HeapGraphEdge* prop = obj1->GetChild(i);
965 v8::String::AsciiValue prop_name(prop->GetName()); 973 v8::String::AsciiValue prop_name(prop->GetName());
966 if (prop->GetType() == v8::HeapGraphEdge::kInternal && 974 if (prop->GetType() == v8::HeapGraphEdge::kInternal &&
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
1119 1127
1120 CompileRun("a = { s_prop: \'value\', n_prop: 0.1 };"); 1128 CompileRun("a = { s_prop: \'value\', n_prop: 0.1 };");
1121 const v8::HeapSnapshot* snapshot = 1129 const v8::HeapSnapshot* snapshot =
1122 v8::HeapProfiler::TakeSnapshot(v8_str("value")); 1130 v8::HeapProfiler::TakeSnapshot(v8_str("value"));
1123 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); 1131 const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
1124 CHECK(global->GetHeapValue()->IsObject()); 1132 CHECK(global->GetHeapValue()->IsObject());
1125 v8::Local<v8::Object> js_global = 1133 v8::Local<v8::Object> js_global =
1126 env->Global()->GetPrototype().As<v8::Object>(); 1134 env->Global()->GetPrototype().As<v8::Object>();
1127 CHECK(js_global == global->GetHeapValue()); 1135 CHECK(js_global == global->GetHeapValue());
1128 const v8::HeapGraphNode* obj = GetProperty( 1136 const v8::HeapGraphNode* obj = GetProperty(
1129 global, v8::HeapGraphEdge::kProperty, "a"); 1137 global, v8::HeapGraphEdge::kShortcut, "a");
1130 CHECK(obj->GetHeapValue()->IsObject()); 1138 CHECK(obj->GetHeapValue()->IsObject());
1131 v8::Local<v8::Object> js_obj = js_global->Get(v8_str("a")).As<v8::Object>(); 1139 v8::Local<v8::Object> js_obj = js_global->Get(v8_str("a")).As<v8::Object>();
1132 CHECK(js_obj == obj->GetHeapValue()); 1140 CHECK(js_obj == obj->GetHeapValue());
1133 const v8::HeapGraphNode* s_prop = 1141 const v8::HeapGraphNode* s_prop =
1134 GetProperty(obj, v8::HeapGraphEdge::kProperty, "s_prop"); 1142 GetProperty(obj, v8::HeapGraphEdge::kProperty, "s_prop");
1135 v8::Local<v8::String> js_s_prop = 1143 v8::Local<v8::String> js_s_prop =
1136 js_obj->Get(v8_str("s_prop")).As<v8::String>(); 1144 js_obj->Get(v8_str("s_prop")).As<v8::String>();
1137 CHECK(js_s_prop == s_prop->GetHeapValue()); 1145 CHECK(js_s_prop == s_prop->GetHeapValue());
1138 const v8::HeapGraphNode* n_prop = 1146 const v8::HeapGraphNode* n_prop =
1139 GetProperty(obj, v8::HeapGraphEdge::kProperty, "n_prop"); 1147 GetProperty(obj, v8::HeapGraphEdge::kProperty, "n_prop");
1140 v8::Local<v8::Number> js_n_prop = 1148 v8::Local<v8::Number> js_n_prop =
1141 js_obj->Get(v8_str("n_prop")).As<v8::Number>(); 1149 js_obj->Get(v8_str("n_prop")).As<v8::Number>();
1142 CHECK(js_n_prop == n_prop->GetHeapValue()); 1150 CHECK(js_n_prop == n_prop->GetHeapValue());
1143 } 1151 }
1144 1152
1145 1153
1146 TEST(GetHeapValueForDeletedObject) { 1154 TEST(GetHeapValueForDeletedObject) {
1147 v8::HandleScope scope; 1155 v8::HandleScope scope;
1148 LocalContext env; 1156 LocalContext env;
1149 1157
1150 // It is impossible to delete a global property, so we are about to delete a 1158 // It is impossible to delete a global property, so we are about to delete a
1151 // property of the "a" object. Also, the "p" object can't be an empty one 1159 // property of the "a" object. Also, the "p" object can't be an empty one
1152 // because the empty object is static and isn't actually deleted. 1160 // because the empty object is static and isn't actually deleted.
1153 CompileRun("a = { p: { r: {} } };"); 1161 CompileRun("a = { p: { r: {} } };");
1154 const v8::HeapSnapshot* snapshot = 1162 const v8::HeapSnapshot* snapshot =
1155 v8::HeapProfiler::TakeSnapshot(v8_str("snapshot")); 1163 v8::HeapProfiler::TakeSnapshot(v8_str("snapshot"));
1156 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); 1164 const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
1157 const v8::HeapGraphNode* obj = GetProperty( 1165 const v8::HeapGraphNode* obj = GetProperty(
1158 global, v8::HeapGraphEdge::kProperty, "a"); 1166 global, v8::HeapGraphEdge::kShortcut, "a");
1159 const v8::HeapGraphNode* prop = GetProperty( 1167 const v8::HeapGraphNode* prop = GetProperty(
1160 obj, v8::HeapGraphEdge::kProperty, "p"); 1168 obj, v8::HeapGraphEdge::kProperty, "p");
1161 { 1169 {
1162 // Perform the check inside a nested local scope to avoid creating a 1170 // Perform the check inside a nested local scope to avoid creating a
1163 // reference to the object we are deleting. 1171 // reference to the object we are deleting.
1164 v8::HandleScope scope; 1172 v8::HandleScope scope;
1165 CHECK(prop->GetHeapValue()->IsObject()); 1173 CHECK(prop->GetHeapValue()->IsObject());
1166 } 1174 }
1167 CompileRun("delete a.p;"); 1175 CompileRun("delete a.p;");
1168 CHECK(prop->GetHeapValue()->IsUndefined()); 1176 CHECK(prop->GetHeapValue()->IsUndefined());
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1235 "});\n" 1243 "});\n"
1236 "obj1.__defineSetter__('propWithSetter', function Z(value) {\n" 1244 "obj1.__defineSetter__('propWithSetter', function Z(value) {\n"
1237 " return this.value_ = value;\n" 1245 " return this.value_ = value;\n"
1238 "});\n"); 1246 "});\n");
1239 const v8::HeapSnapshot* snapshot = 1247 const v8::HeapSnapshot* snapshot =
1240 v8::HeapProfiler::TakeSnapshot(v8_str("fastCaseGetter")); 1248 v8::HeapProfiler::TakeSnapshot(v8_str("fastCaseGetter"));
1241 1249
1242 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); 1250 const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
1243 CHECK_NE(NULL, global); 1251 CHECK_NE(NULL, global);
1244 const v8::HeapGraphNode* obj1 = 1252 const v8::HeapGraphNode* obj1 =
1245 GetProperty(global, v8::HeapGraphEdge::kProperty, "obj1"); 1253 GetProperty(global, v8::HeapGraphEdge::kShortcut, "obj1");
1246 CHECK_NE(NULL, obj1); 1254 CHECK_NE(NULL, obj1);
1247 const v8::HeapGraphNode* getterFunction = 1255 const v8::HeapGraphNode* getterFunction =
1248 GetProperty(obj1, v8::HeapGraphEdge::kProperty, "get-propWithGetter"); 1256 GetProperty(obj1, v8::HeapGraphEdge::kProperty, "get-propWithGetter");
1249 CHECK_NE(NULL, getterFunction); 1257 CHECK_NE(NULL, getterFunction);
1250 const v8::HeapGraphNode* setterFunction = 1258 const v8::HeapGraphNode* setterFunction =
1251 GetProperty(obj1, v8::HeapGraphEdge::kProperty, "set-propWithSetter"); 1259 GetProperty(obj1, v8::HeapGraphEdge::kProperty, "set-propWithSetter");
1252 CHECK_NE(NULL, setterFunction); 1260 CHECK_NE(NULL, setterFunction);
1253 } 1261 }
1254 1262
1255 1263
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1317 v8::HandleScope scope; 1325 v8::HandleScope scope;
1318 LocalContext env; 1326 LocalContext env;
1319 1327
1320 CompileRun( 1328 CompileRun(
1321 "fun = (function (x) { return function () { return x + 1; } })(1);"); 1329 "fun = (function (x) { return function () { return x + 1; } })(1);");
1322 const v8::HeapSnapshot* snapshot = 1330 const v8::HeapSnapshot* snapshot =
1323 v8::HeapProfiler::TakeSnapshot(v8_str("fun")); 1331 v8::HeapProfiler::TakeSnapshot(v8_str("fun"));
1324 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); 1332 const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
1325 CHECK_NE(NULL, global); 1333 CHECK_NE(NULL, global);
1326 const v8::HeapGraphNode* fun = 1334 const v8::HeapGraphNode* fun =
1327 GetProperty(global, v8::HeapGraphEdge::kProperty, "fun"); 1335 GetProperty(global, v8::HeapGraphEdge::kShortcut, "fun");
1328 CHECK(HasWeakEdge(fun)); 1336 CHECK(HasWeakEdge(fun));
1329 const v8::HeapGraphNode* shared = 1337 const v8::HeapGraphNode* shared =
1330 GetProperty(fun, v8::HeapGraphEdge::kInternal, "shared"); 1338 GetProperty(fun, v8::HeapGraphEdge::kInternal, "shared");
1331 CHECK(HasWeakEdge(shared)); 1339 CHECK(HasWeakEdge(shared));
1332 } 1340 }
1333 1341
1334 1342
1335 TEST(PersistentHandleCount) { 1343 TEST(PersistentHandleCount) {
1336 v8::HandleScope scope; 1344 v8::HandleScope scope;
1337 LocalContext env; 1345 LocalContext env;
(...skipping 19 matching lines...) Expand all
1357 // Dipose the persistent handles in a different order. 1365 // Dipose the persistent handles in a different order.
1358 p_AAA.Dispose(); 1366 p_AAA.Dispose();
1359 CHECK_EQ(global_handle_count + 2, 1367 CHECK_EQ(global_handle_count + 2,
1360 v8::HeapProfiler::GetPersistentHandleCount()); 1368 v8::HeapProfiler::GetPersistentHandleCount());
1361 p_CCC.Dispose(); 1369 p_CCC.Dispose();
1362 CHECK_EQ(global_handle_count + 1, 1370 CHECK_EQ(global_handle_count + 1,
1363 v8::HeapProfiler::GetPersistentHandleCount()); 1371 v8::HeapProfiler::GetPersistentHandleCount());
1364 p_BBB.Dispose(); 1372 p_BBB.Dispose();
1365 CHECK_EQ(global_handle_count, v8::HeapProfiler::GetPersistentHandleCount()); 1373 CHECK_EQ(global_handle_count, v8::HeapProfiler::GetPersistentHandleCount());
1366 } 1374 }
OLDNEW
« no previous file with comments | « src/profile-generator-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698