Lines Matching refs:v8
1 // Copyright 2011 the V8 project authors. All rights reserved.
5 #include "v8.h"
11 #include "../include/v8-profiler.h"
55 static const v8::HeapGraphNode* GetGlobalObject(
56 const v8::HeapSnapshot* snapshot) {
58 const v8::HeapGraphNode* global_obj =
66 static const v8::HeapGraphNode* GetProperty(const v8::HeapGraphNode* node,
67 v8::HeapGraphEdge::Type type,
70 const v8::HeapGraphEdge* prop = node->GetChild(i);
71 v8::String::AsciiValue prop_name(prop->GetName());
79 static bool HasString(const v8::HeapGraphNode* node, const char* contents) {
81 const v8::HeapGraphEdge* prop = node->GetChild(i);
82 const v8::HeapGraphNode* node = prop->GetToNode();
83 if (node->GetType() == v8::HeapGraphNode::kString) {
84 v8::String::AsciiValue node_name(node->GetName());
93 v8::HandleScope scope;
103 const v8::HeapSnapshot* snapshot_env2 =
104 v8::HeapProfiler::TakeSnapshot(v8_str("env2"));
108 const v8::HeapGraphNode* global_env2 = GetGlobalObject(snapshot_env2);
111 const v8::HeapGraphNode* a2_node =
112 GetProperty(global_env2, v8::HeapGraphEdge::kShortcut, "a2");
115 NULL, GetProperty(global_env2, v8::HeapGraphEdge::kShortcut, "b2_1"));
117 NULL, GetProperty(global_env2, v8::HeapGraphEdge::kShortcut, "b2_2"));
118 CHECK_NE(NULL, GetProperty(global_env2, v8::HeapGraphEdge::kShortcut, "c2"));
132 v8::HandleScope scope;
141 const v8::HeapSnapshot* snapshot =
142 v8::HeapProfiler::TakeSnapshot(v8_str("sizes"));
143 const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
144 const v8::HeapGraphNode* x =
145 GetProperty(global, v8::HeapGraphEdge::kShortcut, "x");
147 const v8::HeapGraphNode* x1 =
148 GetProperty(x, v8::HeapGraphEdge::kProperty, "a");
150 const v8::HeapGraphNode* x2 =
151 GetProperty(x, v8::HeapGraphEdge::kProperty, "b");
162 v8::HandleScope scope;
168 const v8::HeapSnapshot* snapshot =
169 v8::HeapProfiler::TakeSnapshot(v8_str("sizes"));
170 const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
171 const v8::HeapGraphNode* f =
172 GetProperty(global, v8::HeapGraphEdge::kShortcut, "boundFunction");
174 CHECK_EQ(v8::String::New("native_bind"), f->GetName());
175 const v8::HeapGraphNode* bindings =
176 GetProperty(f, v8::HeapGraphEdge::kInternal, "bindings");
178 CHECK_EQ(v8::HeapGraphNode::kArray, bindings->GetType());
181 const v8::HeapGraphNode* bound_this = GetProperty(
182 f, v8::HeapGraphEdge::kShortcut, "bound_this");
184 CHECK_EQ(v8::HeapGraphNode::kObject, bound_this->GetType());
186 const v8::HeapGraphNode* bound_function = GetProperty(
187 f, v8::HeapGraphEdge::kShortcut, "bound_function");
189 CHECK_EQ(v8::HeapGraphNode::kClosure, bound_function->GetType());
191 const v8::HeapGraphNode* bound_argument = GetProperty(
192 f, v8::HeapGraphEdge::kShortcut, "bound_argument_1");
194 CHECK_EQ(v8::HeapGraphNode::kObject, bound_argument->GetType());
199 v8::HandleScope scope;
205 const v8::HeapSnapshot* snapshot =
206 v8::HeapProfiler::TakeSnapshot(v8_str("children"));
207 const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
209 const v8::HeapGraphEdge* prop = global->GetChild(i);
212 const v8::HeapGraphNode* a =
213 GetProperty(global, v8::HeapGraphEdge::kProperty, "a");
216 const v8::HeapGraphEdge* prop = a->GetChild(i);
223 v8::HandleScope scope;
231 const v8::HeapSnapshot* snapshot =
232 v8::HeapProfiler::TakeSnapshot(v8_str("code"));
234 const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
235 const v8::HeapGraphNode* compiled =
236 GetProperty(global, v8::HeapGraphEdge::kShortcut, "compiled");
238 CHECK_EQ(v8::HeapGraphNode::kClosure, compiled->GetType());
239 const v8::HeapGraphNode* lazy =
240 GetProperty(global, v8::HeapGraphEdge::kShortcut, "lazy");
242 CHECK_EQ(v8::HeapGraphNode::kClosure, lazy->GetType());
243 const v8::HeapGraphNode* anonymous =
244 GetProperty(global, v8::HeapGraphEdge::kShortcut, "anonymous");
246 CHECK_EQ(v8::HeapGraphNode::kClosure, anonymous->GetType());
247 v8::String::AsciiValue anonymous_name(anonymous->GetName());
251 const v8::HeapGraphNode* compiled_code =
252 GetProperty(compiled, v8::HeapGraphEdge::kInternal, "shared");
254 const v8::HeapGraphNode* lazy_code =
255 GetProperty(lazy, v8::HeapGraphEdge::kInternal, "shared");
263 const v8::HeapGraphEdge* prop = compiled_code->GetChild(i);
264 const v8::HeapGraphNode* node = prop->GetToNode();
265 if (node->GetType() == v8::HeapGraphNode::kArray) {
273 const v8::HeapGraphEdge* prop = lazy_code->GetChild(i);
274 const v8::HeapGraphNode* node = prop->GetToNode();
275 if (node->GetType() == v8::HeapGraphNode::kArray) {
288 v8::HandleScope scope;
293 const v8::HeapSnapshot* snapshot =
294 v8::HeapProfiler::TakeSnapshot(v8_str("numbers"));
295 const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
296 CHECK_EQ(NULL, GetProperty(global, v8::HeapGraphEdge::kShortcut, "a"));
297 const v8::HeapGraphNode* b =
298 GetProperty(global, v8::HeapGraphEdge::kShortcut, "b");
300 CHECK_EQ(v8::HeapGraphNode::kHeapNumber, b->GetType());
304 v8::HandleScope scope;
312 const v8::HeapSnapshot* snapshot =
313 v8::HeapProfiler::TakeSnapshot(v8_str("strings"));
314 const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
315 const v8::HeapGraphNode* parent_string =
316 GetProperty(global, v8::HeapGraphEdge::kShortcut, "parent_string");
318 const v8::HeapGraphNode* child_string =
319 GetProperty(global, v8::HeapGraphEdge::kShortcut, "child_string");
321 const v8::HeapGraphNode* parent =
322 GetProperty(child_string, v8::HeapGraphEdge::kInternal, "parent");
327 v8::HandleScope scope;
328 v8::Local<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New();
331 v8::Handle<v8::Object> global_proxy = env->Global();
332 v8::Handle<v8::Object> global = global_proxy->GetPrototype().As<v8::Object>();
334 v8::Local<v8::Object> obj = v8::Object::New();
337 const v8::HeapSnapshot* snapshot =
338 v8::HeapProfiler::TakeSnapshot(v8_str("internals"));
339 const v8::HeapGraphNode* global_node = GetGlobalObject(snapshot);
341 CHECK_EQ(NULL, GetProperty(global_node, v8::HeapGraphEdge::kInternal, "0"));
343 CHECK_NE(NULL, GetProperty(global_node, v8::HeapGraphEdge::kInternal, "1"));
356 v8::HandleScope scope;
367 const v8::HeapSnapshot* snapshot1 =
368 v8::HeapProfiler::TakeSnapshot(v8_str("s1"));
376 const v8::HeapSnapshot* snapshot2 =
377 v8::HeapProfiler::TakeSnapshot(v8_str("s2"));
379 const v8::HeapGraphNode* global1 = GetGlobalObject(snapshot1);
380 const v8::HeapGraphNode* global2 = GetGlobalObject(snapshot2);
384 const v8::HeapGraphNode* a1 =
385 GetProperty(global1, v8::HeapGraphEdge::kProperty, "a");
387 const v8::HeapGraphNode* e1 =
388 GetProperty(a1, v8::HeapGraphEdge::kHidden, "1");
390 const v8::HeapGraphNode* k1 =
391 GetProperty(e1, v8::HeapGraphEdge::kInternal, "elements");
393 const v8::HeapGraphNode* a2 =
394 GetProperty(global2, v8::HeapGraphEdge::kProperty, "a");
396 const v8::HeapGraphNode* e2 =
397 GetProperty(a2, v8::HeapGraphEdge::kHidden, "1");
399 const v8::HeapGraphNode* k2 =
400 GetProperty(e2, v8::HeapGraphEdge::kInternal, "elements");
409 v8::HandleScope scope;
417 const v8::HeapSnapshot* snapshot1 =
418 v8::HeapProfiler::TakeSnapshot(v8_str("s1"));
422 const v8::HeapSnapshot* snapshot2 =
423 v8::HeapProfiler::TakeSnapshot(v8_str("s2"));
425 const v8::HeapGraphNode* global1 = GetGlobalObject(snapshot1);
426 const v8::HeapGraphNode* global2 = GetGlobalObject(snapshot2);
429 const v8::HeapGraphNode* A1 =
430 GetProperty(global1, v8::HeapGraphEdge::kProperty, "A");
432 const v8::HeapGraphNode* A2 =
433 GetProperty(global2, v8::HeapGraphEdge::kProperty, "A");
437 const v8::HeapGraphNode* B1 =
438 GetProperty(global1, v8::HeapGraphEdge::kProperty, "B");
440 const v8::HeapGraphNode* B2 =
441 GetProperty(global2, v8::HeapGraphEdge::kProperty, "B");
445 const v8::HeapGraphNode* a1 =
446 GetProperty(global1, v8::HeapGraphEdge::kProperty, "a");
448 const v8::HeapGraphNode* a2 =
449 GetProperty(global2, v8::HeapGraphEdge::kProperty, "a");
453 const v8::HeapGraphNode* b1 =
454 GetProperty(global1, v8::HeapGraphEdge::kProperty, "b");
456 const v8::HeapGraphNode* b2 =
457 GetProperty(global2, v8::HeapGraphEdge::kProperty, "b");
465 v8::HandleScope scope;
467 const v8::HeapSnapshot* snapshot =
468 v8::HeapProfiler::TakeSnapshot(v8_str("s"));
469 const v8::HeapGraphNode* root1 = snapshot->GetRoot();
472 const v8::HeapGraphNode* root2 = snapshot->GetRoot();
492 v8::HandleScope scope;
505 const v8::HeapSnapshot* snapshot =
506 v8::HeapProfiler::TakeSnapshot(v8_str("dominators"));
508 const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
510 const v8::HeapGraphNode* node6 =
511 GetProperty(global, v8::HeapGraphEdge::kShortcut, "node6");
513 const v8::HeapGraphNode* node5 =
514 GetProperty(node6, v8::HeapGraphEdge::kProperty, "a");
516 const v8::HeapGraphNode* node4 =
517 GetProperty(node6, v8::HeapGraphEdge::kProperty, "b");
519 const v8::HeapGraphNode* node3 =
520 GetProperty(node4, v8::HeapGraphEdge::kProperty, "b");
522 const v8::HeapGraphNode* node2 =
523 GetProperty(node4, v8::HeapGraphEdge::kProperty, "a");
525 const v8::HeapGraphNode* node1 =
526 GetProperty(node5, v8::HeapGraphEdge::kProperty, "a");
539 class TestJSONStream : public v8::OutputStream {
563 class AsciiResource: public v8::String::ExternalAsciiStringResource {
578 v8::HandleScope scope;
588 const v8::HeapSnapshot* snapshot =
589 v8::HeapProfiler::TakeSnapshot(v8_str("json"));
591 snapshot->Serialize(&stream, v8::HeapSnapshot::kJSON);
599 v8::Local<v8::String> json_string = v8::String::NewExternal(&json_res);
601 v8::Local<v8::Value> snapshot_parse_result = CompileRun(
606 v8::Local<v8::Object> parsed_snapshot =
613 v8::Local<v8::Value> meta_analysis_result = CompileRun(
650 v8::Local<v8::Value> string_obj_pos_val = CompileRun(
661 v8::Local<v8::Object> nodes_array =
666 v8::Local<v8::Object> strings_array =
668 v8::Local<v8::String> string = strings_array->Get(string_index)->ToString();
669 v8::Local<v8::String> ref_string =
672 CHECK_EQ(*v8::String::Utf8Value(ref_string),
673 *v8::String::Utf8Value(string));
678 v8::HandleScope scope;
680 const v8::HeapSnapshot* snapshot =
681 v8::HeapProfiler::TakeSnapshot(v8_str("abort"));
683 snapshot->Serialize(&stream, v8::HeapSnapshot::kJSON);
689 static void CheckChildrenIds(const v8::HeapSnapshot* snapshot,
690 const v8::HeapGraphNode* node,
695 const v8::HeapGraphEdge* prop = node->GetChild(i);
696 const v8::HeapGraphNode* child =
706 v8::HandleScope scope;
709 const v8::HeapSnapshot* snapshot =
710 v8::HeapProfiler::TakeSnapshot(v8_str("id"));
711 const v8::HeapGraphNode* root = snapshot->GetRoot();
720 class TestActivityControl : public v8::ActivityControl {
740 v8::HandleScope scope;
743 const int snapshots_count = v8::HeapProfiler::GetSnapshotsCount();
745 const v8::HeapSnapshot* no_snapshot =
746 v8::HeapProfiler::TakeSnapshot(v8_str("abort"),
747 v8::HeapSnapshot::kFull,
750 CHECK_EQ(snapshots_count, v8::HeapProfiler::GetSnapshotsCount());
754 const v8::HeapSnapshot* snapshot =
755 v8::HeapProfiler::TakeSnapshot(v8_str("full"),
756 v8::HeapSnapshot::kFull,
759 CHECK_EQ(snapshots_count + 1, v8::HeapProfiler::GetSnapshotsCount());
767 class TestRetainedObjectInfo : public v8::RetainedObjectInfo {
797 static v8::RetainedObjectInfo* WrapperInfoCallback(
798 uint16_t class_id, v8::Handle<v8::Value> wrapper) {
801 v8::String::AsciiValue ascii(wrapper);
809 v8::String::AsciiValue ascii(wrapper);
835 static const v8::HeapGraphNode* GetNode(const v8::HeapGraphNode* parent,
836 v8::HeapGraphNode::Type type,
839 const v8::HeapGraphNode* node = parent->GetChild(i)->GetToNode();
851 v8::HandleScope scope;
854 v8::HeapProfiler::DefineWrapperClass(
856 v8::HeapProfiler::DefineWrapperClass(
858 v8::Persistent<v8::String> p_AAA =
859 v8::Persistent<v8::String>::New(v8_str("AAA"));
861 v8::Persistent<v8::String> p_BBB =
862 v8::Persistent<v8::String>::New(v8_str("BBB"));
864 v8::Persistent<v8::String> p_CCC =
865 v8::Persistent<v8::String>::New(v8_str("CCC"));
868 const v8::HeapSnapshot* snapshot =
869 v8::HeapProfiler::TakeSnapshot(v8_str("retained"));
877 const v8::HeapGraphNode* native_group_aaa = GetNode(
878 snapshot->GetRoot(), v8::HeapGraphNode::kSynthetic, "aaa-group");
881 const v8::HeapGraphNode* aaa = GetNode(
882 native_group_aaa, v8::HeapGraphNode::kNative, "aaa / 100 entries");
886 const v8::HeapGraphNode* native_group_ccc = GetNode(
887 snapshot->GetRoot(), v8::HeapGraphNode::kSynthetic, "ccc-group");
888 const v8::HeapGraphNode* ccc = GetNode(
889 native_group_ccc, v8::HeapGraphNode::kNative, "ccc");
892 const v8::HeapGraphNode* n_AAA = GetNode(
893 aaa, v8::HeapGraphNode::kString, "AAA");
895 const v8::HeapGraphNode* n_BBB = GetNode(
896 aaa, v8::HeapGraphNode::kString, "BBB");
899 const v8::HeapGraphNode* n_CCC = GetNode(
900 ccc, v8::HeapGraphNode::kString, "CCC");
903 CHECK_EQ(aaa, GetProperty(n_AAA, v8::HeapGraphEdge::kInternal, "native"));
904 CHECK_EQ(aaa, GetProperty(n_BBB, v8::HeapGraphEdge::kInternal, "native"));
905 CHECK_EQ(ccc, GetProperty(n_CCC, v8::HeapGraphEdge::kInternal, "native"));
916 objects_[i] = v8::Persistent<v8::Object>::New(v8::Object::New());
931 v8::V8::AddImplicitReferences(
932 v8::Persistent<v8::Object>::Cast(objects_[0]), &objects_[1], 1);
934 v8::V8::AddImplicitReferences(
935 v8::Persistent<v8::Object>::Cast(objects_[1]), &objects_[2], 2);
938 v8::Persistent<v8::Value> objects_[kObjectsCount];
946 v8::HandleScope scope;
950 v8::V8::SetGlobalGCPrologueCallback(&GraphWithImplicitRefs::gcPrologue);
952 const v8::HeapSnapshot* snapshot =
953 v8::HeapProfiler::TakeSnapshot(v8_str("implicit_refs"));
955 const v8::HeapGraphNode* global_object = GetGlobalObject(snapshot);
957 const v8::HeapGraphNode* obj0 = GetProperty(
958 global_object, v8::HeapGraphEdge::kShortcut, "root_object");
960 CHECK_EQ(v8::HeapGraphNode::kObject, obj0->GetType());
961 const v8::HeapGraphNode* obj1 = GetProperty(
962 obj0, v8::HeapGraphEdge::kInternal, "native");
966 const v8::HeapGraphEdge* prop = obj1->GetChild(i);
967 v8::String::AsciiValue prop_name(prop->GetName());
968 if (prop->GetType() == v8::HeapGraphEdge::kInternal &&
974 v8::V8::SetGlobalGCPrologueCallback(NULL);
979 v8::HandleScope scope;
982 CHECK_EQ(0, v8::HeapProfiler::GetSnapshotsCount());
983 v8::HeapProfiler::DeleteAllSnapshots();
984 CHECK_EQ(0, v8::HeapProfiler::GetSnapshotsCount());
985 CHECK_NE(NULL, v8::HeapProfiler::TakeSnapshot(v8_str("1")));
986 CHECK_EQ(1, v8::HeapProfiler::GetSnapshotsCount());
987 v8::HeapProfiler::DeleteAllSnapshots();
988 CHECK_EQ(0, v8::HeapProfiler::GetSnapshotsCount());
989 CHECK_NE(NULL, v8::HeapProfiler::TakeSnapshot(v8_str("1")));
990 CHECK_NE(NULL, v8::HeapProfiler::TakeSnapshot(v8_str("2")));
991 CHECK_EQ(2, v8::HeapProfiler::GetSnapshotsCount());
992 v8::HeapProfiler::DeleteAllSnapshots();
993 CHECK_EQ(0, v8::HeapProfiler::GetSnapshotsCount());
998 v8::HandleScope scope;
1001 CHECK_EQ(0, v8::HeapProfiler::GetSnapshotsCount());
1002 const v8::HeapSnapshot* s1 =
1003 v8::HeapProfiler::TakeSnapshot(v8_str("1"));
1005 CHECK_EQ(1, v8::HeapProfiler::GetSnapshotsCount());
1007 CHECK_EQ(s1, v8::HeapProfiler::FindSnapshot(uid1));
1008 const_cast<v8::HeapSnapshot*>(s1)->Delete();
1009 CHECK_EQ(0, v8::HeapProfiler::GetSnapshotsCount());
1010 CHECK_EQ(NULL, v8::HeapProfiler::FindSnapshot(uid1));
1012 const v8::HeapSnapshot* s2 =
1013 v8::HeapProfiler::TakeSnapshot(v8_str("2"));
1015 CHECK_EQ(1, v8::HeapProfiler::GetSnapshotsCount());
1018 CHECK_EQ(s2, v8::HeapProfiler::FindSnapshot(uid2));
1019 const v8::HeapSnapshot* s3 =
1020 v8::HeapProfiler::TakeSnapshot(v8_str("3"));
1022 CHECK_EQ(2, v8::HeapProfiler::GetSnapshotsCount());
1025 CHECK_EQ(s3, v8::HeapProfiler::FindSnapshot(uid3));
1026 const_cast<v8::HeapSnapshot*>(s2)->Delete();
1027 CHECK_EQ(1, v8::HeapProfiler::GetSnapshotsCount());
1028 CHECK_EQ(NULL, v8::HeapProfiler::FindSnapshot(uid2));
1029 CHECK_EQ(s3, v8::HeapProfiler::FindSnapshot(uid3));
1030 const_cast<v8::HeapSnapshot*>(s3)->Delete();
1031 CHECK_EQ(0, v8::HeapProfiler::GetSnapshotsCount());
1032 CHECK_EQ(NULL, v8::HeapProfiler::FindSnapshot(uid3));
1037 v8::HandleScope scope;
1042 const v8::HeapSnapshot* snapshot =
1043 v8::HeapProfiler::TakeSnapshot(v8_str("document"));
1044 const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
1053 v8::HandleScope scope;
1058 const v8::HeapSnapshot* snapshot =
1059 v8::HeapProfiler::TakeSnapshot(v8_str("document"));
1060 const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
1069 v8::HandleScope scope;
1076 const v8::HeapSnapshot* snapshot =
1077 v8::HeapProfiler::TakeSnapshot(v8_str("document"));
1078 const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
1087 v8::HandleScope scope;
1092 v8::Handle<v8::String> name(v8_str("leakz"));
1094 v8::HeapProfiler::TakeSnapshot(name);
1101 v8::HandleScope scope;
1103 const v8::HeapSnapshot* snapshot =
1104 v8::HeapProfiler::TakeSnapshot(v8_str("iteration"));
1105 const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
1119 v8::HandleScope scope;
1123 const v8::HeapSnapshot* snapshot =
1124 v8::HeapProfiler::TakeSnapshot(v8_str("value"));
1125 const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
1127 v8::Local<v8::Object> js_global =
1128 env->Global()->GetPrototype().As<v8::Object>();
1130 const v8::HeapGraphNode* obj = GetProperty(
1131 global, v8::HeapGraphEdge::kShortcut, "a");
1133 v8::Local<v8::Object> js_obj = js_global->Get(v8_str("a")).As<v8::Object>();
1135 const v8::HeapGraphNode* s_prop =
1136 GetProperty(obj, v8::HeapGraphEdge::kProperty, "s_prop");
1137 v8::Local<v8::String> js_s_prop =
1138 js_obj->Get(v8_str("s_prop")).As<v8::String>();
1140 const v8::HeapGraphNode* n_prop =
1141 GetProperty(obj, v8::HeapGraphEdge::kProperty, "n_prop");
1142 v8::Local<v8::Number> js_n_prop =
1143 js_obj->Get(v8_str("n_prop")).As<v8::Number>();
1149 v8::HandleScope scope;
1156 const v8::HeapSnapshot* snapshot =
1157 v8::HeapProfiler::TakeSnapshot(v8_str("snapshot"));
1158 const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
1159 const v8::HeapGraphNode* obj = GetProperty(
1160 global, v8::HeapGraphEdge::kShortcut, "a");
1161 const v8::HeapGraphNode* prop = GetProperty(
1162 obj, v8::HeapGraphEdge::kProperty, "p");
1166 v8::HandleScope scope;
1184 v8::HandleScope scope;
1201 v8::Local<v8::Object> js_global =
1202 env->Global()->GetPrototype().As<v8::Object>();
1203 v8::Local<v8::Object> obj1 = js_global->Get(v8_str("obj1")).As<v8::Object>();
1204 i::Handle<i::JSObject> js_obj1 = v8::Utils::OpenHandle(*obj1);
1207 v8::Local<v8::Object> obj2 = js_global->Get(v8_str("obj2")).As<v8::Object>();
1208 i::Handle<i::JSObject> js_obj2 = v8::Utils::OpenHandle(*obj2);
1211 v8::Local<v8::Object> obj3 = js_global->Get(v8_str("obj3")).As<v8::Object>();
1212 i::Handle<i::JSObject> js_obj3 = v8::Utils::OpenHandle(*obj3);
1215 v8::Local<v8::Object> obj4 = js_global->Get(v8_str("obj4")).As<v8::Object>();
1216 i::Handle<i::JSObject> js_obj4 = v8::Utils::OpenHandle(*obj4);
1219 v8::Local<v8::Object> obj5 = js_global->Get(v8_str("obj5")).As<v8::Object>();
1220 i::Handle<i::JSObject> js_obj5 = v8::Utils::OpenHandle(*obj5);
1223 v8::Local<v8::Object> obj6 = js_global->Get(v8_str("obj6")).As<v8::Object>();
1224 i::Handle<i::JSObject> js_obj6 = v8::Utils::OpenHandle(*obj6);
1231 v8::HandleScope scope;
1241 const v8::HeapSnapshot* snapshot =
1242 v8::HeapProfiler::TakeSnapshot(v8_str("fastCaseGetter"));
1244 const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
1246 const v8::HeapGraphNode* obj1 =
1247 GetProperty(global, v8::HeapGraphEdge::kShortcut, "obj1");
1249 const v8::HeapGraphNode* getterFunction =
1250 GetProperty(obj1, v8::HeapGraphEdge::kProperty, "get-propWithGetter");
1252 const v8::HeapGraphNode* setterFunction =
1253 GetProperty(obj1, v8::HeapGraphEdge::kProperty, "set-propWithSetter");
1258 bool HasWeakEdge(const v8::HeapGraphNode* node) {
1260 const v8::HeapGraphEdge* handle_edge = node->GetChild(i);
1261 if (handle_edge->GetType() == v8::HeapGraphEdge::kWeak) return true;
1268 const v8::HeapSnapshot* snapshot =
1269 v8::HeapProfiler::TakeSnapshot(v8_str("weaks"));
1270 const v8::HeapGraphNode* gc_roots = GetNode(
1271 snapshot->GetRoot(), v8::HeapGraphNode::kObject, "(GC roots)");
1273 const v8::HeapGraphNode* global_handles = GetNode(
1274 gc_roots, v8::HeapGraphNode::kObject, "(Global handles)");
1280 static void PersistentHandleCallback(v8::Persistent<v8::Value> handle, void*) {
1286 v8::HandleScope scope;
1291 v8::Persistent<v8::Object> handle =
1292 v8::Persistent<v8::Object>::New(v8::Object::New());
1300 v8::HandleScope scope;
1303 const v8::HeapSnapshot* snapshot =
1304 v8::HeapProfiler::TakeSnapshot(v8_str("weaks"));
1305 const v8::HeapGraphNode* gc_roots = GetNode(
1306 snapshot->GetRoot(), v8::HeapGraphNode::kObject, "(GC roots)");
1308 const v8::HeapGraphNode* global_handles = GetNode(
1309 gc_roots, v8::HeapGraphNode::kObject, "(Global handles)");
1311 const v8::HeapGraphNode* global_context = GetNode(
1312 global_handles, v8::HeapGraphNode::kHidden, "system / GlobalContext");
1319 v8::HandleScope scope;
1324 const v8::HeapSnapshot* snapshot =
1325 v8::HeapProfiler::TakeSnapshot(v8_str("fun"));
1326 const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
1328 const v8::HeapGraphNode* fun =
1329 GetProperty(global, v8::HeapGraphEdge::kShortcut, "fun");
1331 const v8::HeapGraphNode* shared =
1332 GetProperty(fun, v8::HeapGraphEdge::kInternal, "shared");
1338 v8::HandleScope scope;
1341 // V8 also uses global handles internally, so we can't test for an absolute
1343 int global_handle_count = v8::HeapProfiler::GetPersistentHandleCount();
1346 v8::Persistent<v8::String> p_AAA =
1347 v8::Persistent<v8::String>::New(v8_str("AAA"));
1349 v8::HeapProfiler::GetPersistentHandleCount());
1350 v8::Persistent<v8::String> p_BBB =
1351 v8::Persistent<v8::String>::New(v8_str("BBB"));
1353 v8::HeapProfiler::GetPersistentHandleCount());
1354 v8::Persistent<v8::String> p_CCC =
1355 v8::Persistent<v8::String>::New(v8_str("CCC"));
1357 v8::HeapProfiler::GetPersistentHandleCount());
1362 v8::HeapProfiler::GetPersistentHandleCount());
1365 v8::HeapProfiler::GetPersistentHandleCount());
1367 CHECK_EQ(global_handle_count, v8::HeapProfiler::GetPersistentHandleCount());