Lines Matching refs:v8
68 v8::base::HashMap visited(AddressesMatch); in CheckAllReachables()
78 v8::base::HashMap::Entry* entry = visited.LookupOrInsert( in CheckAllReachables()
98 static const v8::HeapGraphNode* GetGlobalObject( in GetGlobalObject()
99 const v8::HeapSnapshot* snapshot) { in GetGlobalObject()
102 const v8::HeapGraphNode* global_obj = in GetGlobalObject()
110 static const v8::HeapGraphNode* GetProperty(const v8::HeapGraphNode* node, in GetProperty()
111 v8::HeapGraphEdge::Type type, in GetProperty()
114 const v8::HeapGraphEdge* prop = node->GetChild(i); in GetProperty()
115 v8::String::Utf8Value prop_name(prop->GetName()); in GetProperty()
123 static bool HasString(const v8::HeapGraphNode* node, const char* contents) { in HasString()
125 const v8::HeapGraphEdge* prop = node->GetChild(i); in HasString()
126 const v8::HeapGraphNode* node = prop->GetToNode(); in HasString()
127 if (node->GetType() == v8::HeapGraphNode::kString) { in HasString()
128 v8::String::Utf8Value node_name(node->GetName()); in HasString()
142 static bool ValidateSnapshot(const v8::HeapSnapshot* snapshot, int depth = 3) { in ValidateSnapshot()
146 v8::base::HashMap visited(AddressesMatch); in ValidateSnapshot()
149 v8::base::HashMap::Entry* entry = visited.LookupOrInsert( in ValidateSnapshot()
159 v8::base::HashMap::Entry* entry = visited.Lookup( in ValidateSnapshot()
173 v8::HandleScope scope(env2->GetIsolate()); in TEST()
174 v8::HeapProfiler* heap_profiler = env2->GetIsolate()->GetHeapProfiler(); in TEST()
183 const v8::HeapSnapshot* snapshot_env2 = heap_profiler->TakeHeapSnapshot(); in TEST()
185 const v8::HeapGraphNode* global_env2 = GetGlobalObject(snapshot_env2); in TEST()
188 const v8::HeapGraphNode* a2_node = in TEST()
189 GetProperty(global_env2, v8::HeapGraphEdge::kProperty, "a2"); in TEST()
191 CHECK(GetProperty(global_env2, v8::HeapGraphEdge::kProperty, "b2_1")); in TEST()
192 CHECK(GetProperty(global_env2, v8::HeapGraphEdge::kProperty, "b2_2")); in TEST()
193 CHECK(GetProperty(global_env2, v8::HeapGraphEdge::kProperty, "c2")); in TEST()
206 v8::HandleScope scope(env->GetIsolate()); in TEST()
207 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); in TEST()
216 const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot(); in TEST()
218 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); in TEST()
219 const v8::HeapGraphNode* x = in TEST()
220 GetProperty(global, v8::HeapGraphEdge::kProperty, "x"); in TEST()
222 const v8::HeapGraphNode* x1 = in TEST()
223 GetProperty(x, v8::HeapGraphEdge::kProperty, "a"); in TEST()
225 const v8::HeapGraphNode* x2 = in TEST()
226 GetProperty(x, v8::HeapGraphEdge::kProperty, "b"); in TEST()
238 v8::HandleScope scope(env->GetIsolate()); in TEST()
239 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); in TEST()
244 const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot(); in TEST()
246 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); in TEST()
247 const v8::HeapGraphNode* f = in TEST()
248 GetProperty(global, v8::HeapGraphEdge::kProperty, "boundFunction"); in TEST()
251 const v8::HeapGraphNode* bindings = in TEST()
252 GetProperty(f, v8::HeapGraphEdge::kInternal, "bindings"); in TEST()
254 CHECK_EQ(v8::HeapGraphNode::kArray, bindings->GetType()); in TEST()
257 const v8::HeapGraphNode* bound_this = GetProperty( in TEST()
258 f, v8::HeapGraphEdge::kShortcut, "bound_this"); in TEST()
260 CHECK_EQ(v8::HeapGraphNode::kObject, bound_this->GetType()); in TEST()
262 const v8::HeapGraphNode* bound_function = GetProperty( in TEST()
263 f, v8::HeapGraphEdge::kShortcut, "bound_function"); in TEST()
265 CHECK_EQ(v8::HeapGraphNode::kClosure, bound_function->GetType()); in TEST()
267 const v8::HeapGraphNode* bound_argument = GetProperty( in TEST()
268 f, v8::HeapGraphEdge::kShortcut, "bound_argument_1"); in TEST()
270 CHECK_EQ(v8::HeapGraphNode::kObject, bound_argument->GetType()); in TEST()
276 v8::HandleScope scope(env->GetIsolate()); in TEST()
277 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); in TEST()
282 const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot(); in TEST()
284 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); in TEST()
286 const v8::HeapGraphEdge* prop = global->GetChild(i); in TEST()
289 const v8::HeapGraphNode* a = in TEST()
290 GetProperty(global, v8::HeapGraphEdge::kProperty, "a"); in TEST()
293 const v8::HeapGraphEdge* prop = a->GetChild(i); in TEST()
301 v8::HandleScope scope(env->GetIsolate()); in TEST()
302 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); in TEST()
309 const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot(); in TEST()
312 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); in TEST()
313 const v8::HeapGraphNode* compiled = in TEST()
314 GetProperty(global, v8::HeapGraphEdge::kProperty, "compiled"); in TEST()
316 CHECK_EQ(v8::HeapGraphNode::kClosure, compiled->GetType()); in TEST()
317 const v8::HeapGraphNode* lazy = in TEST()
318 GetProperty(global, v8::HeapGraphEdge::kProperty, "lazy"); in TEST()
320 CHECK_EQ(v8::HeapGraphNode::kClosure, lazy->GetType()); in TEST()
321 const v8::HeapGraphNode* anonymous = in TEST()
322 GetProperty(global, v8::HeapGraphEdge::kProperty, "anonymous"); in TEST()
324 CHECK_EQ(v8::HeapGraphNode::kClosure, anonymous->GetType()); in TEST()
325 v8::String::Utf8Value anonymous_name(anonymous->GetName()); in TEST()
329 const v8::HeapGraphNode* compiled_code = in TEST()
330 GetProperty(compiled, v8::HeapGraphEdge::kInternal, "shared"); in TEST()
332 const v8::HeapGraphNode* lazy_code = in TEST()
333 GetProperty(lazy, v8::HeapGraphEdge::kInternal, "shared"); in TEST()
338 const v8::HeapGraphNode* code = in TEST()
339 GetProperty(compiled_code, v8::HeapGraphEdge::kInternal, "code"); in TEST()
341 const v8::HeapGraphNode* next_code_link = in TEST()
342 GetProperty(code, v8::HeapGraphEdge::kInternal, "code"); in TEST()
350 const v8::HeapGraphEdge* prop = compiled_code->GetChild(i); in TEST()
351 const v8::HeapGraphNode* node = prop->GetToNode(); in TEST()
352 if (node->GetType() == v8::HeapGraphNode::kArray) { in TEST()
360 const v8::HeapGraphEdge* prop = lazy_code->GetChild(i); in TEST()
361 const v8::HeapGraphNode* node = prop->GetToNode(); in TEST()
362 if (node->GetType() == v8::HeapGraphNode::kArray) { in TEST()
378 v8::HandleScope scope(env->GetIsolate()); in TEST()
379 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); in TEST()
383 const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot(); in TEST()
385 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); in TEST()
386 CHECK(!GetProperty(global, v8::HeapGraphEdge::kProperty, "a")); in TEST()
387 const v8::HeapGraphNode* b = in TEST()
388 GetProperty(global, v8::HeapGraphEdge::kProperty, "b"); in TEST()
390 CHECK_EQ(v8::HeapGraphNode::kHeapNumber, b->GetType()); in TEST()
396 v8::HandleScope scope(env->GetIsolate()); in TEST()
397 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); in TEST()
408 const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot(); in TEST()
410 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); in TEST()
411 const v8::HeapGraphNode* parent_string = in TEST()
412 GetProperty(global, v8::HeapGraphEdge::kProperty, "parent_string"); in TEST()
414 const v8::HeapGraphNode* child_string = in TEST()
415 GetProperty(global, v8::HeapGraphEdge::kProperty, "child_string"); in TEST()
417 CHECK_EQ(v8::HeapGraphNode::kSlicedString, child_string->GetType()); in TEST()
418 const v8::HeapGraphNode* parent = in TEST()
419 GetProperty(child_string, v8::HeapGraphEdge::kInternal, "parent"); in TEST()
426 v8::Isolate* isolate = CcTest::isolate(); in TEST()
427 v8::HandleScope scope(isolate); in TEST()
428 v8::Local<v8::ObjectTemplate> global_template = in TEST()
429 v8::ObjectTemplate::New(isolate); in TEST()
432 v8::Local<v8::Object> global_proxy = env->Global(); in TEST()
433 v8::Local<v8::Object> global = global_proxy->GetPrototype().As<v8::Object>(); in TEST()
442 global->SetInternalField(0, v8::ToApiHandle<v8::String>(cons_string)); in TEST()
444 v8::HeapProfiler* heap_profiler = isolate->GetHeapProfiler(); in TEST()
445 const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot(); in TEST()
447 const v8::HeapGraphNode* global_node = GetGlobalObject(snapshot); in TEST()
449 const v8::HeapGraphNode* string_node = in TEST()
450 GetProperty(global_node, v8::HeapGraphEdge::kInternal, "0"); in TEST()
452 CHECK_EQ(v8::HeapGraphNode::kConsString, string_node->GetType()); in TEST()
454 const v8::HeapGraphNode* first_node = in TEST()
455 GetProperty(string_node, v8::HeapGraphEdge::kInternal, "first"); in TEST()
456 CHECK_EQ(v8::HeapGraphNode::kString, first_node->GetType()); in TEST()
458 const v8::HeapGraphNode* second_node = in TEST()
459 GetProperty(string_node, v8::HeapGraphEdge::kInternal, "second"); in TEST()
460 CHECK_EQ(v8::HeapGraphNode::kString, second_node->GetType()); in TEST()
468 v8::HandleScope scope(env->GetIsolate()); in TEST()
469 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); in TEST()
472 const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot(); in TEST()
474 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); in TEST()
475 const v8::HeapGraphNode* a = in TEST()
476 GetProperty(global, v8::HeapGraphEdge::kProperty, "a"); in TEST()
478 CHECK_EQ(a->GetType(), v8::HeapGraphNode::kSymbol); in TEST()
480 const v8::HeapGraphNode* name = in TEST()
481 GetProperty(a, v8::HeapGraphEdge::kInternal, "name"); in TEST()
490 v8::HandleScope scope(env->GetIsolate()); in CheckSimdSnapshot()
491 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); in CheckSimdSnapshot()
494 const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot(); in CheckSimdSnapshot()
496 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); in CheckSimdSnapshot()
497 const v8::HeapGraphNode* var = in CheckSimdSnapshot()
498 GetProperty(global, v8::HeapGraphEdge::kProperty, var_name); in CheckSimdSnapshot()
500 CHECK_EQ(var->GetType(), v8::HeapGraphNode::kSimdValue); in CheckSimdSnapshot()
520 v8::HandleScope scope(env->GetIsolate()); in TEST()
521 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); in TEST()
527 const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot(); in TEST()
529 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); in TEST()
530 const v8::HeapGraphNode* k = in TEST()
531 GetProperty(global, v8::HeapGraphEdge::kProperty, "k"); in TEST()
533 const v8::HeapGraphNode* v = in TEST()
534 GetProperty(global, v8::HeapGraphEdge::kProperty, "v"); in TEST()
536 const v8::HeapGraphNode* s = in TEST()
537 GetProperty(global, v8::HeapGraphEdge::kProperty, "s"); in TEST()
540 const v8::HeapGraphNode* ws = in TEST()
541 GetProperty(global, v8::HeapGraphEdge::kProperty, "ws"); in TEST()
543 CHECK_EQ(v8::HeapGraphNode::kObject, ws->GetType()); in TEST()
546 const v8::HeapGraphNode* ws_table = in TEST()
547 GetProperty(ws, v8::HeapGraphEdge::kInternal, "table"); in TEST()
548 CHECK_EQ(v8::HeapGraphNode::kArray, ws_table->GetType()); in TEST()
552 const v8::HeapGraphEdge* prop = ws_table->GetChild(i); in TEST()
553 if (prop->GetType() != v8::HeapGraphEdge::kWeak) continue; in TEST()
559 const v8::HeapGraphNode* ws_s = in TEST()
560 GetProperty(ws, v8::HeapGraphEdge::kProperty, "str"); in TEST()
564 const v8::HeapGraphNode* wm = in TEST()
565 GetProperty(global, v8::HeapGraphEdge::kProperty, "wm"); in TEST()
567 CHECK_EQ(v8::HeapGraphNode::kObject, wm->GetType()); in TEST()
570 const v8::HeapGraphNode* wm_table = in TEST()
571 GetProperty(wm, v8::HeapGraphEdge::kInternal, "table"); in TEST()
572 CHECK_EQ(v8::HeapGraphNode::kArray, wm_table->GetType()); in TEST()
576 const v8::HeapGraphEdge* prop = wm_table->GetChild(i); in TEST()
577 if (prop->GetType() != v8::HeapGraphEdge::kWeak) continue; in TEST()
578 const v8::SnapshotObjectId to_node_id = prop->GetToNode()->GetId(); in TEST()
584 const v8::HeapGraphNode* wm_s = in TEST()
585 GetProperty(wm, v8::HeapGraphEdge::kProperty, "str"); in TEST()
593 v8::HandleScope scope(env->GetIsolate()); in TEST()
594 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); in TEST()
600 const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot(); in TEST()
602 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); in TEST()
603 const v8::HeapGraphNode* k = in TEST()
604 GetProperty(global, v8::HeapGraphEdge::kProperty, "k"); in TEST()
606 const v8::HeapGraphNode* v = in TEST()
607 GetProperty(global, v8::HeapGraphEdge::kProperty, "v"); in TEST()
609 const v8::HeapGraphNode* s = in TEST()
610 GetProperty(global, v8::HeapGraphEdge::kProperty, "s"); in TEST()
613 const v8::HeapGraphNode* set = in TEST()
614 GetProperty(global, v8::HeapGraphEdge::kProperty, "set"); in TEST()
616 CHECK_EQ(v8::HeapGraphNode::kObject, set->GetType()); in TEST()
619 const v8::HeapGraphNode* set_table = in TEST()
620 GetProperty(set, v8::HeapGraphEdge::kInternal, "table"); in TEST()
621 CHECK_EQ(v8::HeapGraphNode::kArray, set_table->GetType()); in TEST()
625 const v8::HeapGraphEdge* prop = set_table->GetChild(i); in TEST()
626 const v8::SnapshotObjectId to_node_id = prop->GetToNode()->GetId(); in TEST()
632 const v8::HeapGraphNode* set_s = in TEST()
633 GetProperty(set, v8::HeapGraphEdge::kProperty, "str"); in TEST()
637 const v8::HeapGraphNode* map = in TEST()
638 GetProperty(global, v8::HeapGraphEdge::kProperty, "map"); in TEST()
640 CHECK_EQ(v8::HeapGraphNode::kObject, map->GetType()); in TEST()
643 const v8::HeapGraphNode* map_table = in TEST()
644 GetProperty(map, v8::HeapGraphEdge::kInternal, "table"); in TEST()
645 CHECK_EQ(v8::HeapGraphNode::kArray, map_table->GetType()); in TEST()
649 const v8::HeapGraphEdge* prop = map_table->GetChild(i); in TEST()
650 const v8::SnapshotObjectId to_node_id = prop->GetToNode()->GetId(); in TEST()
656 const v8::HeapGraphNode* map_s = in TEST()
657 GetProperty(map, v8::HeapGraphEdge::kProperty, "str"); in TEST()
664 v8::Isolate* isolate = CcTest::isolate(); in TEST()
665 v8::HandleScope scope(isolate); in TEST()
666 v8::Local<v8::ObjectTemplate> global_template = in TEST()
667 v8::ObjectTemplate::New(isolate); in TEST()
670 v8::Local<v8::Object> global_proxy = env->Global(); in TEST()
671 v8::Local<v8::Object> global = global_proxy->GetPrototype().As<v8::Object>(); in TEST()
673 v8::Local<v8::Object> obj = v8::Object::New(isolate); in TEST()
676 v8::HeapProfiler* heap_profiler = isolate->GetHeapProfiler(); in TEST()
677 const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot(); in TEST()
679 const v8::HeapGraphNode* global_node = GetGlobalObject(snapshot); in TEST()
681 CHECK(!GetProperty(global_node, v8::HeapGraphEdge::kInternal, "0")); in TEST()
683 CHECK(GetProperty(global_node, v8::HeapGraphEdge::kInternal, "1")); in TEST()
689 v8::HandleScope scope(env->GetIsolate()); in TEST()
690 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); in TEST()
697 const v8::HeapSnapshot* snapshot1 = heap_profiler->TakeHeapSnapshot(); in TEST()
699 v8::SnapshotObjectId maxId1 = snapshot1->GetMaxSnapshotJSObjectId(); in TEST()
706 const v8::HeapSnapshot* snapshot2 = heap_profiler->TakeHeapSnapshot(); in TEST()
708 const v8::HeapGraphNode* global2 = GetGlobalObject(snapshot2); in TEST()
710 const v8::HeapGraphNode* array_node = in TEST()
711 GetProperty(global2, v8::HeapGraphEdge::kProperty, "a"); in TEST()
715 const v8::HeapGraphEdge* prop = array_node->GetChild(i); in TEST()
716 if (prop->GetType() != v8::HeapGraphEdge::kElement) in TEST()
718 v8::SnapshotObjectId id = prop->GetToNode()->GetId(); in TEST()
728 v8::HandleScope scope(env->GetIsolate()); in TEST()
729 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); in TEST()
739 const v8::HeapSnapshot* snapshot1 = heap_profiler->TakeHeapSnapshot(); in TEST()
748 const v8::HeapSnapshot* snapshot2 = heap_profiler->TakeHeapSnapshot(); in TEST()
751 const v8::HeapGraphNode* global1 = GetGlobalObject(snapshot1); in TEST()
752 const v8::HeapGraphNode* global2 = GetGlobalObject(snapshot2); in TEST()
756 const v8::HeapGraphNode* a1 = in TEST()
757 GetProperty(global1, v8::HeapGraphEdge::kProperty, "a"); in TEST()
759 const v8::HeapGraphNode* k1 = in TEST()
760 GetProperty(a1, v8::HeapGraphEdge::kInternal, "elements"); in TEST()
762 const v8::HeapGraphNode* a2 = in TEST()
763 GetProperty(global2, v8::HeapGraphEdge::kProperty, "a"); in TEST()
765 const v8::HeapGraphNode* k2 = in TEST()
766 GetProperty(a2, v8::HeapGraphEdge::kInternal, "elements"); in TEST()
776 v8::HandleScope scope(env->GetIsolate()); in TEST()
777 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); in TEST()
784 const v8::HeapSnapshot* snapshot1 = heap_profiler->TakeHeapSnapshot(); in TEST()
789 const v8::HeapSnapshot* snapshot2 = heap_profiler->TakeHeapSnapshot(); in TEST()
796 const v8::HeapGraphNode* global1 = GetGlobalObject(snapshot1); in TEST()
797 const v8::HeapGraphNode* global2 = GetGlobalObject(snapshot2); in TEST()
800 const v8::HeapGraphNode* A1 = in TEST()
801 GetProperty(global1, v8::HeapGraphEdge::kProperty, "A"); in TEST()
803 const v8::HeapGraphNode* A2 = in TEST()
804 GetProperty(global2, v8::HeapGraphEdge::kProperty, "A"); in TEST()
808 const v8::HeapGraphNode* B1 = in TEST()
809 GetProperty(global1, v8::HeapGraphEdge::kProperty, "B"); in TEST()
811 const v8::HeapGraphNode* B2 = in TEST()
812 GetProperty(global2, v8::HeapGraphEdge::kProperty, "B"); in TEST()
816 const v8::HeapGraphNode* a1 = in TEST()
817 GetProperty(global1, v8::HeapGraphEdge::kProperty, "a"); in TEST()
819 const v8::HeapGraphNode* a2 = in TEST()
820 GetProperty(global2, v8::HeapGraphEdge::kProperty, "a"); in TEST()
824 const v8::HeapGraphNode* b1 = in TEST()
825 GetProperty(global1, v8::HeapGraphEdge::kProperty, "b"); in TEST()
827 const v8::HeapGraphNode* b2 = in TEST()
828 GetProperty(global2, v8::HeapGraphEdge::kProperty, "b"); in TEST()
837 v8::HandleScope scope(env->GetIsolate()); in TEST()
838 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); in TEST()
839 const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot(); in TEST()
841 const v8::HeapGraphNode* root1 = snapshot->GetRoot(); in TEST()
844 const v8::HeapGraphNode* root2 = snapshot->GetRoot(); in TEST()
851 class TestJSONStream : public v8::OutputStream {
880 class OneByteResource : public v8::String::ExternalOneByteStringResource {
895 v8::Isolate* isolate = CcTest::isolate(); in TEST()
897 v8::HandleScope scope(isolate); in TEST()
898 v8::HeapProfiler* heap_profiler = isolate->GetHeapProfiler(); in TEST()
907 const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot(); in TEST()
911 snapshot->Serialize(&stream, v8::HeapSnapshot::kJSON); in TEST()
919 v8::Local<v8::String> json_string = in TEST()
920 v8::String::NewExternalOneByte(env->GetIsolate(), json_res) in TEST()
925 v8::Local<v8::Value> snapshot_parse_result = CompileRun( in TEST()
930 v8::Local<v8::Object> parsed_snapshot = in TEST()
942 v8::Local<v8::Value> meta_analysis_result = CompileRun( in TEST()
981 v8::Local<v8::Value> string_obj_pos_val = CompileRun( in TEST()
992 v8::Local<v8::Object> nodes_array = in TEST()
1004 v8::Local<v8::Object> strings_array = in TEST()
1009 v8::Local<v8::String> string = strings_array->Get(env.local(), string_index) in TEST()
1013 v8::Local<v8::String> ref_string = CompileRun(STRING_LITERAL_FOR_TEST) in TEST()
1017 CHECK_EQ(0, strcmp(*v8::String::Utf8Value(ref_string), in TEST()
1018 *v8::String::Utf8Value(string))); in TEST()
1024 v8::HandleScope scope(env->GetIsolate()); in TEST()
1025 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); in TEST()
1026 const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot(); in TEST()
1029 snapshot->Serialize(&stream, v8::HeapSnapshot::kJSON); in TEST()
1036 class TestStatsStream : public v8::OutputStream {
1046 : v8::OutputStream(stream), in TestStatsStream()
1059 virtual WriteResult WriteHeapStatsChunk(v8::HeapStatsUpdate* buffer, in WriteHeapStatsChunk()
1093 v8::HeapProfiler* heap_profiler, in GetHeapStatsUpdate()
1094 v8::SnapshotObjectId* object_id = NULL) { in GetHeapStatsUpdate()
1097 v8::SnapshotObjectId last_seen_id = in GetHeapStatsUpdate()
1109 v8::HandleScope scope(env->GetIsolate()); in TEST()
1110 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); in TEST()
1119 v8::SnapshotObjectId initial_id; in TEST()
1131 v8::SnapshotObjectId same_id; in TEST()
1136 v8::SnapshotObjectId additional_string_id; in TEST()
1137 v8::HandleScope inner_scope_1(env->GetIsolate()); in TEST()
1152 v8::SnapshotObjectId last_id; in TEST()
1157 v8::HandleScope inner_scope_2(env->GetIsolate()); in TEST()
1162 v8::HandleScope inner_scope_3(env->GetIsolate()); in TEST()
1211 v8::Local<v8::Array> array = v8::Array::New(env->GetIsolate()); in TEST()
1249 v8::Isolate* isolate = env->GetIsolate(); in TEST()
1250 v8::HandleScope scope(isolate); in TEST()
1251 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); in TEST()
1254 v8::Local<v8::Object> objects[kLength]; in TEST()
1255 v8::SnapshotObjectId ids[kLength]; in TEST()
1260 objects[i] = v8::Object::New(isolate); in TEST()
1265 v8::SnapshotObjectId id = heap_profiler->GetObjectId(objects[i]); in TEST()
1266 CHECK_NE(v8::HeapProfiler::kUnknownObjectId, id); in TEST()
1274 v8::SnapshotObjectId id = heap_profiler->GetObjectId(objects[i]); in TEST()
1276 v8::Local<v8::Value> obj = heap_profiler->FindObjectById(ids[i]); in TEST()
1282 v8::SnapshotObjectId id = heap_profiler->GetObjectId(objects[i]); in TEST()
1283 CHECK_EQ(v8::HeapProfiler::kUnknownObjectId, id); in TEST()
1284 v8::Local<v8::Value> obj = heap_profiler->FindObjectById(ids[i]); in TEST()
1290 static void CheckChildrenIds(const v8::HeapSnapshot* snapshot, in CheckChildrenIds()
1291 const v8::HeapGraphNode* node, in CheckChildrenIds()
1296 const v8::HeapGraphEdge* prop = node->GetChild(i); in CheckChildrenIds()
1297 const v8::HeapGraphNode* child = in CheckChildrenIds()
1308 v8::HandleScope scope(env->GetIsolate()); in TEST()
1309 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); in TEST()
1311 const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot(); in TEST()
1313 const v8::HeapGraphNode* root = snapshot->GetRoot(); in TEST()
1322 v8::HandleScope scope(env->GetIsolate()); in TEST()
1323 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); in TEST()
1325 const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot(); in TEST()
1327 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); in TEST()
1328 const v8::HeapGraphNode* global_object = in TEST()
1329 GetProperty(global, v8::HeapGraphEdge::kProperty, "globalObject"); in TEST()
1332 v8::Local<v8::Value> globalObjectHandle = in TEST()
1337 v8::SnapshotObjectId id = heap_profiler->GetObjectId(globalObjectHandle); in TEST()
1338 CHECK_NE(v8::HeapProfiler::kUnknownObjectId, id); in TEST()
1345 v8::HandleScope scope(env->GetIsolate()); in TEST()
1346 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); in TEST()
1348 const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot(); in TEST()
1350 const v8::HeapGraphNode* node = in TEST()
1351 snapshot->GetNodeById(v8::HeapProfiler::kUnknownObjectId); in TEST()
1358 class TestActivityControl : public v8::ActivityControl {
1381 v8::HandleScope scope(env->GetIsolate()); in TEST()
1383 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); in TEST()
1386 const v8::HeapSnapshot* no_snapshot = in TEST()
1393 const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot(&control); in TEST()
1405 class TestRetainedObjectInfo : public v8::RetainedObjectInfo {
1435 static v8::RetainedObjectInfo* WrapperInfoCallback( in WrapperInfoCallback()
1436 uint16_t class_id, v8::Local<v8::Value> wrapper) { in WrapperInfoCallback()
1439 v8::String::Utf8Value utf8(wrapper); in WrapperInfoCallback()
1447 v8::String::Utf8Value utf8(wrapper); in WrapperInfoCallback()
1473 static const v8::HeapGraphNode* GetNode(const v8::HeapGraphNode* parent, in GetNode()
1474 v8::HeapGraphNode::Type type, in GetNode()
1477 const v8::HeapGraphNode* node = parent->GetChild(i)->GetToNode(); in GetNode()
1490 v8::Isolate* isolate = env->GetIsolate(); in TEST()
1491 v8::HandleScope scope(isolate); in TEST()
1492 v8::HeapProfiler* heap_profiler = isolate->GetHeapProfiler(); in TEST()
1498 v8::Persistent<v8::String> p_AAA(isolate, v8_str("AAA")); in TEST()
1500 v8::Persistent<v8::String> p_BBB(isolate, v8_str("BBB")); in TEST()
1502 v8::Persistent<v8::String> p_CCC(isolate, v8_str("CCC")); in TEST()
1505 const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot(); in TEST()
1514 const v8::HeapGraphNode* native_group_aaa = GetNode( in TEST()
1515 snapshot->GetRoot(), v8::HeapGraphNode::kSynthetic, "aaa-group"); in TEST()
1518 const v8::HeapGraphNode* aaa = GetNode( in TEST()
1519 native_group_aaa, v8::HeapGraphNode::kNative, "aaa / 100 entries"); in TEST()
1523 const v8::HeapGraphNode* native_group_ccc = GetNode( in TEST()
1524 snapshot->GetRoot(), v8::HeapGraphNode::kSynthetic, "ccc-group"); in TEST()
1525 const v8::HeapGraphNode* ccc = GetNode( in TEST()
1526 native_group_ccc, v8::HeapGraphNode::kNative, "ccc"); in TEST()
1529 const v8::HeapGraphNode* n_AAA = GetNode( in TEST()
1530 aaa, v8::HeapGraphNode::kString, "AAA"); in TEST()
1532 const v8::HeapGraphNode* n_BBB = GetNode( in TEST()
1533 aaa, v8::HeapGraphNode::kString, "BBB"); in TEST()
1536 const v8::HeapGraphNode* n_CCC = GetNode( in TEST()
1537 ccc, v8::HeapGraphNode::kString, "CCC"); in TEST()
1540 CHECK_EQ(aaa, GetProperty(n_AAA, v8::HeapGraphEdge::kInternal, "native")); in TEST()
1541 CHECK_EQ(aaa, GetProperty(n_BBB, v8::HeapGraphEdge::kInternal, "native")); in TEST()
1542 CHECK_EQ(ccc, GetProperty(n_CCC, v8::HeapGraphEdge::kInternal, "native")); in TEST()
1554 objects_[i].Reset(isolate_, v8::Object::New(isolate_)); in GraphWithImplicitRefs()
1559 v8::Local<v8::Value>::New(isolate_, objects_[0])) in GraphWithImplicitRefs()
1566 static void gcPrologue(v8::Isolate* isolate, v8::GCType type, in gcPrologue()
1567 v8::GCCallbackFlags flags) { in gcPrologue()
1575 v8::UniqueId(1)); in AddImplicitReferences()
1577 v8::UniqueId(1), objects_[1]); in AddImplicitReferences()
1579 isolate_->SetReference(objects_[1].As<v8::Object>(), in AddImplicitReferences()
1581 isolate_->SetReference(objects_[1].As<v8::Object>(), in AddImplicitReferences()
1585 v8::Persistent<v8::Value> objects_[kObjectsCount];
1587 v8::Isolate* isolate_;
1595 v8::HandleScope scope(env->GetIsolate()); in TEST()
1596 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); in TEST()
1601 const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot(); in TEST()
1604 const v8::HeapGraphNode* global_object = GetGlobalObject(snapshot); in TEST()
1605 const v8::HeapGraphNode* obj0 = GetProperty( in TEST()
1606 global_object, v8::HeapGraphEdge::kProperty, "root_object"); in TEST()
1608 CHECK_EQ(v8::HeapGraphNode::kObject, obj0->GetType()); in TEST()
1609 const v8::HeapGraphNode* obj1 = GetProperty( in TEST()
1610 obj0, v8::HeapGraphEdge::kInternal, "native"); in TEST()
1614 const v8::HeapGraphEdge* prop = obj1->GetChild(i); in TEST()
1615 v8::String::Utf8Value prop_name(prop->GetName()); in TEST()
1616 if (prop->GetType() == v8::HeapGraphEdge::kInternal && in TEST()
1629 v8::HandleScope scope(env->GetIsolate()); in TEST()
1630 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); in TEST()
1647 static bool FindHeapSnapshot(v8::HeapProfiler* profiler, in FindHeapSnapshot()
1648 const v8::HeapSnapshot* snapshot) { in FindHeapSnapshot()
1659 v8::HandleScope scope(env->GetIsolate()); in TEST()
1660 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); in TEST()
1663 const v8::HeapSnapshot* s1 = heap_profiler->TakeHeapSnapshot(); in TEST()
1668 const_cast<v8::HeapSnapshot*>(s1)->Delete(); in TEST()
1672 const v8::HeapSnapshot* s2 = heap_profiler->TakeHeapSnapshot(); in TEST()
1676 const v8::HeapSnapshot* s3 = heap_profiler->TakeHeapSnapshot(); in TEST()
1681 const_cast<v8::HeapSnapshot*>(s2)->Delete(); in TEST()
1685 const_cast<v8::HeapSnapshot*>(s3)->Delete(); in TEST()
1691 class NameResolver : public v8::HeapProfiler::ObjectNameResolver {
1693 virtual const char* GetName(v8::Local<v8::Object> object) { in GetName()
1701 v8::HandleScope scope(env->GetIsolate()); in TEST()
1702 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); in TEST()
1707 const v8::HeapSnapshot* snapshot = in TEST()
1710 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); in TEST()
1721 v8::HandleScope scope(env->GetIsolate()); in TEST()
1722 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); in TEST()
1724 const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot(); in TEST()
1726 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); in TEST()
1727 const v8::HeapGraphNode* native_context = in TEST()
1728 GetProperty(global, v8::HeapGraphEdge::kInternal, "native_context"); in TEST()
1730 const v8::HeapGraphNode* global_proxy = in TEST()
1731 GetProperty(global, v8::HeapGraphEdge::kInternal, "global_proxy"); in TEST()
1738 v8::HandleScope scope(env->GetIsolate()); in TEST()
1739 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); in TEST()
1753 v8::HandleScope scope(env->GetIsolate()); in TEST()
1754 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); in TEST()
1755 const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot(); in TEST()
1757 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); in TEST()
1772 v8::HandleScope scope(env->GetIsolate()); in TEST()
1773 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); in TEST()
1776 const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot(); in TEST()
1778 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); in TEST()
1780 v8::Local<v8::Object> js_global = in TEST()
1781 env->Global()->GetPrototype().As<v8::Object>(); in TEST()
1783 const v8::HeapGraphNode* obj = GetProperty( in TEST()
1784 global, v8::HeapGraphEdge::kProperty, "a"); in TEST()
1786 v8::Local<v8::Object> js_obj = js_global->Get(env.local(), v8_str("a")) in TEST()
1788 .As<v8::Object>(); in TEST()
1790 const v8::HeapGraphNode* s_prop = in TEST()
1791 GetProperty(obj, v8::HeapGraphEdge::kProperty, "s_prop"); in TEST()
1792 v8::Local<v8::String> js_s_prop = js_obj->Get(env.local(), v8_str("s_prop")) in TEST()
1794 .As<v8::String>(); in TEST()
1796 const v8::HeapGraphNode* n_prop = in TEST()
1797 GetProperty(obj, v8::HeapGraphEdge::kProperty, "n_prop"); in TEST()
1798 v8::Local<v8::String> js_n_prop = js_obj->Get(env.local(), v8_str("n_prop")) in TEST()
1800 .As<v8::String>(); in TEST()
1807 v8::HandleScope scope(env->GetIsolate()); in TEST()
1808 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); in TEST()
1814 const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot(); in TEST()
1816 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); in TEST()
1817 const v8::HeapGraphNode* obj = GetProperty( in TEST()
1818 global, v8::HeapGraphEdge::kProperty, "a"); in TEST()
1819 const v8::HeapGraphNode* prop = GetProperty( in TEST()
1820 obj, v8::HeapGraphEdge::kProperty, "p"); in TEST()
1824 v8::HandleScope scope(env->GetIsolate()); in TEST()
1833 v8::base::SmartArrayPointer<char> s_act = act->ToCString(); in StringCmp()
1843 v8::HandleScope scope(env->GetIsolate()); in TEST()
1859 v8::Local<v8::Object> js_global = in TEST()
1860 env->Global()->GetPrototype().As<v8::Object>(); in TEST()
1861 v8::Local<v8::Object> obj1 = js_global->Get(env.local(), v8_str("obj1")) in TEST()
1863 .As<v8::Object>(); in TEST()
1865 i::Handle<i::JSObject>::cast(v8::Utils::OpenHandle(*obj1)); in TEST()
1868 v8::Local<v8::Object> obj2 = js_global->Get(env.local(), v8_str("obj2")) in TEST()
1870 .As<v8::Object>(); in TEST()
1872 i::Handle<i::JSObject>::cast(v8::Utils::OpenHandle(*obj2)); in TEST()
1875 v8::Local<v8::Object> obj3 = js_global->Get(env.local(), v8_str("obj3")) in TEST()
1877 .As<v8::Object>(); in TEST()
1879 i::Handle<i::JSObject>::cast(v8::Utils::OpenHandle(*obj3)); in TEST()
1882 v8::Local<v8::Object> obj4 = js_global->Get(env.local(), v8_str("obj4")) in TEST()
1884 .As<v8::Object>(); in TEST()
1886 i::Handle<i::JSObject>::cast(v8::Utils::OpenHandle(*obj4)); in TEST()
1889 v8::Local<v8::Object> obj5 = js_global->Get(env.local(), v8_str("obj5")) in TEST()
1891 .As<v8::Object>(); in TEST()
1893 i::Handle<i::JSObject>::cast(v8::Utils::OpenHandle(*obj5)); in TEST()
1896 v8::Local<v8::Object> obj6 = js_global->Get(env.local(), v8_str("obj6")) in TEST()
1898 .As<v8::Object>(); in TEST()
1900 i::Handle<i::JSObject>::cast(v8::Utils::OpenHandle(*obj6)); in TEST()
1908 v8::HandleScope scope(env->GetIsolate()); in TEST()
1909 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); in TEST()
1918 const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot(); in TEST()
1921 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); in TEST()
1923 const v8::HeapGraphNode* obj1 = in TEST()
1924 GetProperty(global, v8::HeapGraphEdge::kProperty, "obj1"); in TEST()
1926 const v8::HeapGraphNode* func; in TEST()
1927 func = GetProperty(obj1, v8::HeapGraphEdge::kProperty, "get propWithGetter"); in TEST()
1929 func = GetProperty(obj1, v8::HeapGraphEdge::kProperty, "set propWithGetter"); in TEST()
1931 func = GetProperty(obj1, v8::HeapGraphEdge::kProperty, "set propWithSetter"); in TEST()
1933 func = GetProperty(obj1, v8::HeapGraphEdge::kProperty, "get propWithSetter"); in TEST()
1940 v8::HandleScope scope(env->GetIsolate()); in TEST()
1941 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); in TEST()
1957 v8::Local<v8::Object> js_global = in TEST()
1958 env->Global()->GetPrototype().As<v8::Object>(); in TEST()
1960 v8::Utils::OpenHandle(*js_global->Get(env.local(), v8_str("obj1")) in TEST()
1962 .As<v8::Object>()); in TEST()
1965 const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot(); in TEST()
1967 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); in TEST()
1969 const v8::HeapGraphNode* obj1 = in TEST()
1970 GetProperty(global, v8::HeapGraphEdge::kProperty, "obj1"); in TEST()
1972 const v8::HeapGraphNode* func; in TEST()
1973 func = GetProperty(obj1, v8::HeapGraphEdge::kProperty, "get prop"); in TEST()
1975 func = GetProperty(obj1, v8::HeapGraphEdge::kProperty, "set prop"); in TEST()
1982 v8::HandleScope scope(env->GetIsolate()); in TEST()
1983 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); in TEST()
1993 const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot(); in TEST()
1996 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); in TEST()
1998 const v8::HeapGraphNode* obj1 = in TEST()
1999 GetProperty(global, v8::HeapGraphEdge::kProperty, "obj1"); in TEST()
2001 const v8::HeapGraphNode* func; in TEST()
2002 func = GetProperty(obj1, v8::HeapGraphEdge::kProperty, "get propWithGetter"); in TEST()
2004 func = GetProperty(obj1, v8::HeapGraphEdge::kProperty, "set propWithGetter"); in TEST()
2006 func = GetProperty(obj1, v8::HeapGraphEdge::kProperty, "set propWithSetter"); in TEST()
2008 func = GetProperty(obj1, v8::HeapGraphEdge::kProperty, "get propWithSetter"); in TEST()
2014 v8::Isolate* isolate = CcTest::isolate(); in TEST()
2016 v8::HandleScope scope(isolate); in TEST()
2017 v8::HeapProfiler* heap_profiler = isolate->GetHeapProfiler(); in TEST()
2022 const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot(); in TEST()
2024 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); in TEST()
2025 const v8::HeapGraphNode* c = in TEST()
2026 GetProperty(global, v8::HeapGraphEdge::kProperty, "c"); in TEST()
2028 const v8::HeapGraphNode* hidden_props = in TEST()
2029 GetProperty(c, v8::HeapGraphEdge::kProperty, "<symbol>"); in TEST()
2032 v8::Local<v8::Value> cHandle = in TEST()
2038 v8::Private::ForApi(env->GetIsolate(), v8_str("key")), in TEST()
2045 c = GetProperty(global, v8::HeapGraphEdge::kProperty, "c"); in TEST()
2047 hidden_props = GetProperty(c, v8::HeapGraphEdge::kProperty, "<symbol>"); in TEST()
2054 v8::HandleScope scope(env->GetIsolate()); in TEST()
2055 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); in TEST()
2058 const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot(); in TEST()
2060 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); in TEST()
2061 const v8::HeapGraphNode* foo = in TEST()
2062 GetProperty(global, v8::HeapGraphEdge::kProperty, "foo"); in TEST()
2064 const v8::HeapGraphNode* map = in TEST()
2065 GetProperty(foo, v8::HeapGraphEdge::kInternal, "map"); in TEST()
2067 const v8::HeapGraphNode* descriptors = in TEST()
2068 GetProperty(map, v8::HeapGraphEdge::kInternal, "descriptors"); in TEST()
2070 const v8::HeapGraphNode* length_name = in TEST()
2071 GetProperty(descriptors, v8::HeapGraphEdge::kInternal, "2"); in TEST()
2073 CHECK_EQ(0, strcmp("length", *v8::String::Utf8Value(length_name->GetName()))); in TEST()
2074 const v8::HeapGraphNode* length_accessor = in TEST()
2075 GetProperty(descriptors, v8::HeapGraphEdge::kInternal, "4"); in TEST()
2078 *v8::String::Utf8Value(length_accessor->GetName()))); in TEST()
2079 const v8::HeapGraphNode* name = in TEST()
2080 GetProperty(length_accessor, v8::HeapGraphEdge::kInternal, "name"); in TEST()
2082 const v8::HeapGraphNode* getter = in TEST()
2083 GetProperty(length_accessor, v8::HeapGraphEdge::kInternal, "getter"); in TEST()
2085 const v8::HeapGraphNode* setter = in TEST()
2086 GetProperty(length_accessor, v8::HeapGraphEdge::kInternal, "setter"); in TEST()
2091 bool HasWeakEdge(const v8::HeapGraphNode* node) { in HasWeakEdge()
2093 const v8::HeapGraphEdge* handle_edge = node->GetChild(i); in HasWeakEdge()
2094 if (handle_edge->GetType() == v8::HeapGraphEdge::kWeak) return true; in HasWeakEdge()
2101 v8::Isolate* isolate = CcTest::isolate(); in HasWeakGlobalHandle()
2102 v8::HeapProfiler* heap_profiler = isolate->GetHeapProfiler(); in HasWeakGlobalHandle()
2103 const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot(); in HasWeakGlobalHandle()
2105 const v8::HeapGraphNode* gc_roots = GetNode( in HasWeakGlobalHandle()
2106 snapshot->GetRoot(), v8::HeapGraphNode::kSynthetic, "(GC roots)"); in HasWeakGlobalHandle()
2108 const v8::HeapGraphNode* global_handles = GetNode( in HasWeakGlobalHandle()
2109 gc_roots, v8::HeapGraphNode::kSynthetic, "(Global handles)"); in HasWeakGlobalHandle()
2116 const v8::WeakCallbackInfo<v8::Persistent<v8::Object> >& data) { in PersistentHandleCallback()
2123 v8::HandleScope scope(env->GetIsolate()); in TEST()
2127 v8::Persistent<v8::Object> handle(env->GetIsolate(), in TEST()
2128 v8::Object::New(env->GetIsolate())); in TEST()
2130 v8::WeakCallbackType::kParameter); in TEST()
2138 v8::HandleScope scope(env->GetIsolate()); in TEST()
2139 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); in TEST()
2143 const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot(); in TEST()
2145 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); in TEST()
2147 const v8::HeapGraphNode* fun = in TEST()
2148 GetProperty(global, v8::HeapGraphEdge::kProperty, "fun"); in TEST()
2150 const v8::HeapGraphNode* shared = in TEST()
2151 GetProperty(fun, v8::HeapGraphEdge::kInternal, "shared"); in TEST()
2158 v8::HandleScope scope(env->GetIsolate()); in TEST()
2159 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); in TEST()
2163 const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot(); in TEST()
2165 const v8::HeapGraphNode* root = snapshot->GetRoot(); in TEST()
2168 const v8::HeapGraphEdge* edge = root->GetChild(i); in TEST()
2169 if (edge->GetType() == v8::HeapGraphEdge::kShortcut) { in TEST()
2171 const v8::HeapGraphNode* global = edge->GetToNode(); in TEST()
2172 const v8::HeapGraphNode* foo = in TEST()
2173 GetProperty(global, v8::HeapGraphEdge::kProperty, "foo"); in TEST()
2183 v8::HandleScope scope(env->GetIsolate()); in TEST()
2184 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); in TEST()
2187 const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot(); in TEST()
2189 const v8::HeapGraphNode* gc_roots = GetNode( in TEST()
2190 snapshot->GetRoot(), v8::HeapGraphNode::kSynthetic, "(GC roots)"); in TEST()
2192 const v8::HeapGraphNode* strong_roots = GetNode( in TEST()
2193 gc_roots, v8::HeapGraphNode::kSynthetic, "(Strong roots)"); in TEST()
2196 const v8::HeapGraphEdge* edge = strong_roots->GetChild(i); in TEST()
2197 CHECK_EQ(v8::HeapGraphEdge::kInternal, edge->GetType()); in TEST()
2198 v8::String::Utf8Value name(edge->GetName()); in TEST()
2206 v8::HandleScope scope(env->GetIsolate()); in TEST()
2207 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); in TEST()
2209 const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot(); in TEST()
2211 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); in TEST()
2212 const v8::HeapGraphNode* global_object = in TEST()
2213 GetProperty(global, v8::HeapGraphEdge::kProperty, "global_object"); in TEST()
2215 const v8::HeapGraphNode* properties = in TEST()
2216 GetProperty(global_object, v8::HeapGraphEdge::kInternal, "properties"); in TEST()
2218 const v8::HeapGraphNode* elements = in TEST()
2219 GetProperty(global_object, v8::HeapGraphEdge::kInternal, "elements"); in TEST()
2226 v8::HandleScope scope(env->GetIsolate()); in TEST()
2227 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); in TEST()
2229 const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot(); in TEST()
2231 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); in TEST()
2232 const v8::HeapGraphNode* global_object = in TEST()
2233 GetProperty(global, v8::HeapGraphEdge::kProperty, "obj"); in TEST()
2236 const v8::HeapGraphNode* map = in TEST()
2237 GetProperty(global_object, v8::HeapGraphEdge::kInternal, "map"); in TEST()
2239 const v8::HeapGraphNode* own_descriptors = GetProperty( in TEST()
2240 map, v8::HeapGraphEdge::kInternal, "descriptors"); in TEST()
2242 const v8::HeapGraphNode* own_transitions = GetProperty( in TEST()
2243 map, v8::HeapGraphEdge::kInternal, "transitions"); in TEST()
2250 v8::HandleScope scope(env->GetIsolate()); in TEST()
2251 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); in TEST()
2267 const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot(); in TEST()
2270 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); in TEST()
2272 const v8::HeapGraphNode* ok_object = in TEST()
2273 GetProperty(global, v8::HeapGraphEdge::kProperty, "ok"); in TEST()
2275 const v8::HeapGraphNode* context_object = in TEST()
2276 GetProperty(ok_object, v8::HeapGraphEdge::kInternal, "context"); in TEST()
2279 CHECK_EQ(v8::internal::Context::MIN_CONTEXT_SLOTS + num_objects - 1, in TEST()
2286 const v8::HeapGraphNode* f_object = GetProperty( in TEST()
2287 context_object, v8::HeapGraphEdge::kContextVariable, var_name.start()); in TEST()
2295 v8::Isolate* isolate = env->GetIsolate(); in TEST()
2296 v8::HandleScope scope(isolate); in TEST()
2297 v8::HeapProfiler* heap_profiler = isolate->GetHeapProfiler(); in TEST()
2301 const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot(); in TEST()
2304 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); in TEST()
2306 const v8::HeapGraphNode* fun_code = in TEST()
2307 GetProperty(global, v8::HeapGraphEdge::kProperty, "fun"); in TEST()
2309 const v8::HeapGraphNode* literals = in TEST()
2310 GetProperty(fun_code, v8::HeapGraphEdge::kInternal, "literals"); in TEST()
2312 CHECK_EQ(v8::HeapGraphNode::kArray, literals->GetType()); in TEST()
2317 const v8::HeapGraphEdge* prop = literals->GetChild(0); in TEST()
2318 const v8::HeapGraphNode* allocation_site = prop->GetToNode(); in TEST()
2319 v8::String::Utf8Value name(allocation_site->GetName()); in TEST()
2321 const v8::HeapGraphNode* transition_info = in TEST()
2322 GetProperty(allocation_site, v8::HeapGraphEdge::kInternal, in TEST()
2326 const v8::HeapGraphNode* elements = in TEST()
2327 GetProperty(transition_info, v8::HeapGraphEdge::kInternal, in TEST()
2330 CHECK_EQ(v8::HeapGraphNode::kArray, elements->GetType()); in TEST()
2331 CHECK_EQ(v8::internal::FixedArray::SizeFor(3), in TEST()
2334 v8::Local<v8::Value> array_val = in TEST()
2337 v8::Local<v8::Array> array = v8::Local<v8::Array>::Cast(array_val); in TEST()
2340 CHECK(v8::Integer::New(isolate, 3) in TEST()
2342 array->Get(env.local(), v8::Integer::New(isolate, 0)) in TEST()
2345 CHECK(v8::Integer::New(isolate, 2) in TEST()
2347 array->Get(env.local(), v8::Integer::New(isolate, 1)) in TEST()
2350 CHECK(v8::Integer::New(isolate, 1) in TEST()
2352 array->Get(env.local(), v8::Integer::New(isolate, 2)) in TEST()
2360 v8::HandleScope scope(env->GetIsolate()); in TEST()
2361 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); in TEST()
2363 const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot(); in TEST()
2365 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); in TEST()
2366 const v8::HeapGraphNode* foo_func = in TEST()
2367 GetProperty(global, v8::HeapGraphEdge::kProperty, "foo"); in TEST()
2369 const v8::HeapGraphNode* code = in TEST()
2370 GetProperty(foo_func, v8::HeapGraphEdge::kInternal, "code"); in TEST()
2375 static const v8::HeapGraphNode* GetNodeByPath(const v8::HeapSnapshot* snapshot, in GetNodeByPath()
2378 const v8::HeapGraphNode* node = snapshot->GetRoot(); in GetNodeByPath()
2382 const v8::HeapGraphEdge* edge = node->GetChild(i); in GetNodeByPath()
2383 const v8::HeapGraphNode* to_node = edge->GetToNode(); in GetNodeByPath()
2384 v8::String::Utf8Value edge_name(edge->GetName()); in GetNodeByPath()
2385 v8::String::Utf8Value node_name(to_node->GetName()); in GetNodeByPath()
2401 v8::HandleScope scope(env->GetIsolate()); in TEST()
2402 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); in TEST()
2404 const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot(); in TEST()
2413 const v8::HeapGraphNode* node = GetNodeByPath(snapshot, in TEST()
2426 v8::String::Utf8Value node_name(node->GetName()); in TEST()
2496 v8::HandleScope scope(env->GetIsolate()); in TEST()
2497 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); in TEST()
2525 v8::HandleScope scope(v8::Isolate::GetCurrent()); in TEST()
2528 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); in TEST()
2572 v8::HandleScope scope(v8::Isolate::GetCurrent()); in TEST()
2575 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); in TEST()
2627 v8::HandleScope scope(v8::Isolate::GetCurrent()); in TEST()
2630 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); in TEST()
2634 v8::Local<v8::Object> o1 = v8::Object::New(env->GetIsolate()); in TEST()
2655 v8::HandleScope scope(env->GetIsolate()); in TEST()
2656 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); in TEST()
2658 const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot(); in TEST()
2660 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); in TEST()
2661 const v8::HeapGraphNode* arr1_obj = in TEST()
2662 GetProperty(global, v8::HeapGraphEdge::kProperty, "arr1"); in TEST()
2664 const v8::HeapGraphNode* arr1_buffer = in TEST()
2665 GetProperty(arr1_obj, v8::HeapGraphEdge::kInternal, "buffer"); in TEST()
2667 const v8::HeapGraphNode* backing_store = in TEST()
2668 GetProperty(arr1_buffer, v8::HeapGraphEdge::kInternal, "backing_store"); in TEST()
2674 static int GetRetainersCount(const v8::HeapSnapshot* snapshot, in GetRetainersCount()
2675 const v8::HeapGraphNode* node) { in GetRetainersCount()
2678 const v8::HeapGraphNode* parent = snapshot->GetNode(i); in GetRetainersCount()
2691 v8::Isolate* isolate = env->GetIsolate(); in TEST()
2692 v8::HandleScope handle_scope(isolate); in TEST()
2693 v8::HeapProfiler* heap_profiler = isolate->GetHeapProfiler(); in TEST()
2695 v8::Local<v8::ArrayBuffer> ab = v8::ArrayBuffer::New(isolate, 1024); in TEST()
2698 v8::ArrayBuffer::Contents ab_contents = ab->Externalize(); in TEST()
2704 v8::Local<v8::ArrayBuffer> ab2 = in TEST()
2705 v8::ArrayBuffer::New(isolate, data, ab_contents.ByteLength()); in TEST()
2710 v8::Local<v8::Value> result = CompileRun("ab2.byteLength"); in TEST()
2713 const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot(); in TEST()
2715 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); in TEST()
2716 const v8::HeapGraphNode* ab1_node = in TEST()
2717 GetProperty(global, v8::HeapGraphEdge::kProperty, "ab1"); in TEST()
2719 const v8::HeapGraphNode* ab1_data = in TEST()
2720 GetProperty(ab1_node, v8::HeapGraphEdge::kInternal, "backing_store"); in TEST()
2722 const v8::HeapGraphNode* ab2_node = in TEST()
2723 GetProperty(global, v8::HeapGraphEdge::kProperty, "ab2"); in TEST()
2725 const v8::HeapGraphNode* ab2_data = in TEST()
2726 GetProperty(ab2_node, v8::HeapGraphEdge::kInternal, "backing_store"); in TEST()
2735 v8::Isolate* isolate = CcTest::isolate(); in TEST()
2736 v8::HandleScope scope(isolate); in TEST()
2738 v8::Local<v8::Object> global_proxy = env->Global(); in TEST()
2739 v8::Local<v8::Object> global = global_proxy->GetPrototype().As<v8::Object>(); in TEST()
2744 global->Set(env.local(), 0, v8::ToApiHandle<v8::Object>(box)).FromJust(); in TEST()
2746 v8::HeapProfiler* heap_profiler = isolate->GetHeapProfiler(); in TEST()
2747 const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot(); in TEST()
2749 const v8::HeapGraphNode* global_node = GetGlobalObject(snapshot); in TEST()
2750 const v8::HeapGraphNode* box_node = in TEST()
2751 GetProperty(global_node, v8::HeapGraphEdge::kElement, "0"); in TEST()
2753 v8::String::Utf8Value box_node_name(box_node->GetName()); in TEST()
2755 const v8::HeapGraphNode* box_value = in TEST()
2756 GetProperty(box_node, v8::HeapGraphEdge::kInternal, "value"); in TEST()
2764 v8::HandleScope scope(env->GetIsolate()); in TEST()
2766 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); in TEST()
2774 const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot(); in TEST()
2776 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); in TEST()
2777 const v8::HeapGraphNode* obj = in TEST()
2778 GetProperty(global, v8::HeapGraphEdge::kProperty, "obj"); in TEST()
2780 const v8::HeapGraphNode* map = in TEST()
2781 GetProperty(obj, v8::HeapGraphEdge::kInternal, "map"); in TEST()
2783 const v8::HeapGraphNode* dependent_code = in TEST()
2784 GetProperty(map, v8::HeapGraphEdge::kInternal, "dependent_code"); in TEST()
2789 const v8::HeapGraphEdge* prop = dependent_code->GetChild(i); in TEST()
2790 CHECK_EQ(v8::HeapGraphEdge::kWeak, prop->GetType()); in TEST()
2855 static const v8::AllocationProfile::Node* FindAllocationProfileNode( in FindAllocationProfileNode()
2856 v8::AllocationProfile& profile, const Vector<const char*>& names) { in FindAllocationProfileNode()
2857 v8::AllocationProfile::Node* node = profile.GetRootNode(); in FindAllocationProfileNode()
2862 for (v8::AllocationProfile::Node* child : children) { in FindAllocationProfileNode()
2863 v8::String::Utf8Value child_name(child->name); in FindAllocationProfileNode()
2873 static void CheckNoZeroCountNodes(v8::AllocationProfile::Node* node) { in CheckNoZeroCountNodes()
2883 v8::HandleScope scope(v8::Isolate::GetCurrent()); in TEST()
2885 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); in TEST()
2889 v8::internal::FLAG_always_opt = false; in TEST()
2892 v8::internal::FLAG_sampling_heap_profiler_suppress_randomness = true; in TEST()
2906 v8::AllocationProfile* profile = heap_profiler->GetAllocationProfile(); in TEST()
2915 v8::base::SmartPointer<v8::AllocationProfile> profile( in TEST()
2933 v8::AllocationProfile* profile = heap_profiler->GetAllocationProfile(); in TEST()
2942 v8::base::SmartPointer<v8::AllocationProfile> profile( in TEST()
2976 v8::base::SmartPointer<v8::AllocationProfile> profile( in TEST()
3001 v8::base::SmartPointer<v8::AllocationProfile> profile( in TEST()
3013 v8::HandleScope scope(v8::Isolate::GetCurrent()); in TEST()
3015 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); in TEST()
3018 v8::internal::FLAG_sampling_heap_profiler_suppress_randomness = true; in TEST()
3022 for (int i = 0; i < 8 * 1024; ++i) v8::Object::New(env->GetIsolate()); in TEST()
3024 v8::base::SmartPointer<v8::AllocationProfile> profile( in TEST()
3035 v8::HandleScope scope(v8::Isolate::GetCurrent()); in TEST()
3037 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); in TEST()
3040 v8::internal::FLAG_sampling_heap_profiler_suppress_randomness = true; in TEST()
3053 CcTest::heap()->CollectGarbage(v8::internal::NEW_SPACE); in TEST()