OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 1894 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1905 | 1905 |
1906 | 1906 |
1907 void V8HeapExplorer::ExtractJSObjectReferences( | 1907 void V8HeapExplorer::ExtractJSObjectReferences( |
1908 int entry, JSObject* js_obj) { | 1908 int entry, JSObject* js_obj) { |
1909 HeapObject* obj = js_obj; | 1909 HeapObject* obj = js_obj; |
1910 ExtractClosureReferences(js_obj, entry); | 1910 ExtractClosureReferences(js_obj, entry); |
1911 ExtractPropertyReferences(js_obj, entry); | 1911 ExtractPropertyReferences(js_obj, entry); |
1912 ExtractElementReferences(js_obj, entry); | 1912 ExtractElementReferences(js_obj, entry); |
1913 ExtractInternalReferences(js_obj, entry); | 1913 ExtractInternalReferences(js_obj, entry); |
1914 SetPropertyReference( | 1914 SetPropertyReference( |
1915 obj, entry, heap_->Proto_symbol(), js_obj->GetPrototype()); | 1915 obj, entry, heap_->proto_string(), js_obj->GetPrototype()); |
1916 if (obj->IsJSFunction()) { | 1916 if (obj->IsJSFunction()) { |
1917 JSFunction* js_fun = JSFunction::cast(js_obj); | 1917 JSFunction* js_fun = JSFunction::cast(js_obj); |
1918 Object* proto_or_map = js_fun->prototype_or_initial_map(); | 1918 Object* proto_or_map = js_fun->prototype_or_initial_map(); |
1919 if (!proto_or_map->IsTheHole()) { | 1919 if (!proto_or_map->IsTheHole()) { |
1920 if (!proto_or_map->IsMap()) { | 1920 if (!proto_or_map->IsMap()) { |
1921 SetPropertyReference( | 1921 SetPropertyReference( |
1922 obj, entry, | 1922 obj, entry, |
1923 heap_->prototype_symbol(), proto_or_map, | 1923 heap_->prototype_string(), proto_or_map, |
1924 NULL, | 1924 NULL, |
1925 JSFunction::kPrototypeOrInitialMapOffset); | 1925 JSFunction::kPrototypeOrInitialMapOffset); |
1926 } else { | 1926 } else { |
1927 SetPropertyReference( | 1927 SetPropertyReference( |
1928 obj, entry, | 1928 obj, entry, |
1929 heap_->prototype_symbol(), js_fun->prototype()); | 1929 heap_->prototype_string(), js_fun->prototype()); |
1930 } | 1930 } |
1931 } | 1931 } |
1932 SharedFunctionInfo* shared_info = js_fun->shared(); | 1932 SharedFunctionInfo* shared_info = js_fun->shared(); |
1933 // JSFunction has either bindings or literals and never both. | 1933 // JSFunction has either bindings or literals and never both. |
1934 bool bound = shared_info->bound(); | 1934 bool bound = shared_info->bound(); |
1935 TagObject(js_fun->literals_or_bindings(), | 1935 TagObject(js_fun->literals_or_bindings(), |
1936 bound ? "(function bindings)" : "(function literals)"); | 1936 bound ? "(function bindings)" : "(function literals)"); |
1937 SetInternalReference(js_fun, entry, | 1937 SetInternalReference(js_fun, entry, |
1938 bound ? "bindings" : "literals", | 1938 bound ? "bindings" : "literals", |
1939 js_fun->literals_or_bindings(), | 1939 js_fun->literals_or_bindings(), |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2209 int real_size = js_obj->map()->NumberOfOwnDescriptors(); | 2209 int real_size = js_obj->map()->NumberOfOwnDescriptors(); |
2210 for (int i = 0; i < descs->number_of_descriptors(); i++) { | 2210 for (int i = 0; i < descs->number_of_descriptors(); i++) { |
2211 if (descs->GetDetails(i).descriptor_index() > real_size) continue; | 2211 if (descs->GetDetails(i).descriptor_index() > real_size) continue; |
2212 switch (descs->GetType(i)) { | 2212 switch (descs->GetType(i)) { |
2213 case FIELD: { | 2213 case FIELD: { |
2214 int index = descs->GetFieldIndex(i); | 2214 int index = descs->GetFieldIndex(i); |
2215 | 2215 |
2216 String* k = descs->GetKey(i); | 2216 String* k = descs->GetKey(i); |
2217 if (index < js_obj->map()->inobject_properties()) { | 2217 if (index < js_obj->map()->inobject_properties()) { |
2218 Object* value = js_obj->InObjectPropertyAt(index); | 2218 Object* value = js_obj->InObjectPropertyAt(index); |
2219 if (k != heap_->hidden_symbol()) { | 2219 if (k != heap_->hidden_string()) { |
2220 SetPropertyReference( | 2220 SetPropertyReference( |
2221 js_obj, entry, | 2221 js_obj, entry, |
2222 k, value, | 2222 k, value, |
2223 NULL, | 2223 NULL, |
2224 js_obj->GetInObjectPropertyOffset(index)); | 2224 js_obj->GetInObjectPropertyOffset(index)); |
2225 } else { | 2225 } else { |
2226 TagObject(value, "(hidden properties)"); | 2226 TagObject(value, "(hidden properties)"); |
2227 SetInternalReference( | 2227 SetInternalReference( |
2228 js_obj, entry, | 2228 js_obj, entry, |
2229 "hidden_properties", value, | 2229 "hidden_properties", value, |
2230 js_obj->GetInObjectPropertyOffset(index)); | 2230 js_obj->GetInObjectPropertyOffset(index)); |
2231 } | 2231 } |
2232 } else { | 2232 } else { |
2233 Object* value = js_obj->FastPropertyAt(index); | 2233 Object* value = js_obj->FastPropertyAt(index); |
2234 if (k != heap_->hidden_symbol()) { | 2234 if (k != heap_->hidden_string()) { |
2235 SetPropertyReference(js_obj, entry, k, value); | 2235 SetPropertyReference(js_obj, entry, k, value); |
2236 } else { | 2236 } else { |
2237 TagObject(value, "(hidden properties)"); | 2237 TagObject(value, "(hidden properties)"); |
2238 SetInternalReference(js_obj, entry, "hidden_properties", value); | 2238 SetInternalReference(js_obj, entry, "hidden_properties", value); |
2239 } | 2239 } |
2240 } | 2240 } |
2241 break; | 2241 break; |
2242 } | 2242 } |
2243 case CONSTANT_FUNCTION: | 2243 case CONSTANT_FUNCTION: |
2244 SetPropertyReference( | 2244 SetPropertyReference( |
(...skipping 29 matching lines...) Expand all Loading... |
2274 StringDictionary* dictionary = js_obj->property_dictionary(); | 2274 StringDictionary* dictionary = js_obj->property_dictionary(); |
2275 int length = dictionary->Capacity(); | 2275 int length = dictionary->Capacity(); |
2276 for (int i = 0; i < length; ++i) { | 2276 for (int i = 0; i < length; ++i) { |
2277 Object* k = dictionary->KeyAt(i); | 2277 Object* k = dictionary->KeyAt(i); |
2278 if (dictionary->IsKey(k)) { | 2278 if (dictionary->IsKey(k)) { |
2279 Object* target = dictionary->ValueAt(i); | 2279 Object* target = dictionary->ValueAt(i); |
2280 // We assume that global objects can only have slow properties. | 2280 // We assume that global objects can only have slow properties. |
2281 Object* value = target->IsJSGlobalPropertyCell() | 2281 Object* value = target->IsJSGlobalPropertyCell() |
2282 ? JSGlobalPropertyCell::cast(target)->value() | 2282 ? JSGlobalPropertyCell::cast(target)->value() |
2283 : target; | 2283 : target; |
2284 if (k != heap_->hidden_symbol()) { | 2284 if (k != heap_->hidden_string()) { |
2285 SetPropertyReference(js_obj, entry, String::cast(k), value); | 2285 SetPropertyReference(js_obj, entry, String::cast(k), value); |
2286 } else { | 2286 } else { |
2287 TagObject(value, "(hidden properties)"); | 2287 TagObject(value, "(hidden properties)"); |
2288 SetInternalReference(js_obj, entry, "hidden_properties", value); | 2288 SetInternalReference(js_obj, entry, "hidden_properties", value); |
2289 } | 2289 } |
2290 } | 2290 } |
2291 } | 2291 } |
2292 } | 2292 } |
2293 } | 2293 } |
2294 | 2294 |
(...skipping 29 matching lines...) Expand all Loading... |
2324 for (int i = 0; i < length; ++i) { | 2324 for (int i = 0; i < length; ++i) { |
2325 Object* o = js_obj->GetInternalField(i); | 2325 Object* o = js_obj->GetInternalField(i); |
2326 SetInternalReference( | 2326 SetInternalReference( |
2327 js_obj, entry, i, o, js_obj->GetInternalFieldOffset(i)); | 2327 js_obj, entry, i, o, js_obj->GetInternalFieldOffset(i)); |
2328 } | 2328 } |
2329 } | 2329 } |
2330 | 2330 |
2331 | 2331 |
2332 String* V8HeapExplorer::GetConstructorName(JSObject* object) { | 2332 String* V8HeapExplorer::GetConstructorName(JSObject* object) { |
2333 Heap* heap = object->GetHeap(); | 2333 Heap* heap = object->GetHeap(); |
2334 if (object->IsJSFunction()) return heap->closure_symbol(); | 2334 if (object->IsJSFunction()) return heap->closure_string(); |
2335 String* constructor_name = object->constructor_name(); | 2335 String* constructor_name = object->constructor_name(); |
2336 if (constructor_name == heap->Object_symbol()) { | 2336 if (constructor_name == heap->Object_string()) { |
2337 // Look up an immediate "constructor" property, if it is a function, | 2337 // Look up an immediate "constructor" property, if it is a function, |
2338 // return its name. This is for instances of binding objects, which | 2338 // return its name. This is for instances of binding objects, which |
2339 // have prototype constructor type "Object". | 2339 // have prototype constructor type "Object". |
2340 Object* constructor_prop = NULL; | 2340 Object* constructor_prop = NULL; |
2341 LookupResult result(heap->isolate()); | 2341 LookupResult result(heap->isolate()); |
2342 object->LocalLookupRealNamedProperty(heap->constructor_symbol(), &result); | 2342 object->LocalLookupRealNamedProperty(heap->constructor_string(), &result); |
2343 if (!result.IsFound()) return object->constructor_name(); | 2343 if (!result.IsFound()) return object->constructor_name(); |
2344 | 2344 |
2345 constructor_prop = result.GetLazyValue(); | 2345 constructor_prop = result.GetLazyValue(); |
2346 if (constructor_prop->IsJSFunction()) { | 2346 if (constructor_prop->IsJSFunction()) { |
2347 Object* maybe_name = | 2347 Object* maybe_name = |
2348 JSFunction::cast(constructor_prop)->shared()->name(); | 2348 JSFunction::cast(constructor_prop)->shared()->name(); |
2349 if (maybe_name->IsString()) { | 2349 if (maybe_name->IsString()) { |
2350 String* name = String::cast(maybe_name); | 2350 String* name = String::cast(maybe_name); |
2351 if (name->length() > 0) return name; | 2351 if (name->length() > 0) return name; |
2352 } | 2352 } |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2654 | 2654 |
2655 const char* V8HeapExplorer::GetStrongGcSubrootName(Object* object) { | 2655 const char* V8HeapExplorer::GetStrongGcSubrootName(Object* object) { |
2656 if (strong_gc_subroot_names_.is_empty()) { | 2656 if (strong_gc_subroot_names_.is_empty()) { |
2657 #define NAME_ENTRY(name) strong_gc_subroot_names_.SetTag(heap_->name(), #name); | 2657 #define NAME_ENTRY(name) strong_gc_subroot_names_.SetTag(heap_->name(), #name); |
2658 #define ROOT_NAME(type, name, camel_name) NAME_ENTRY(name) | 2658 #define ROOT_NAME(type, name, camel_name) NAME_ENTRY(name) |
2659 STRONG_ROOT_LIST(ROOT_NAME) | 2659 STRONG_ROOT_LIST(ROOT_NAME) |
2660 #undef ROOT_NAME | 2660 #undef ROOT_NAME |
2661 #define STRUCT_MAP_NAME(NAME, Name, name) NAME_ENTRY(name##_map) | 2661 #define STRUCT_MAP_NAME(NAME, Name, name) NAME_ENTRY(name##_map) |
2662 STRUCT_LIST(STRUCT_MAP_NAME) | 2662 STRUCT_LIST(STRUCT_MAP_NAME) |
2663 #undef STRUCT_MAP_NAME | 2663 #undef STRUCT_MAP_NAME |
2664 #define SYMBOL_NAME(name, str) NAME_ENTRY(name) | 2664 #define STRING_NAME(name, str) NAME_ENTRY(name) |
2665 SYMBOL_LIST(SYMBOL_NAME) | 2665 INTERNALIZED_STRING_LIST(STRING_NAME) |
2666 #undef SYMBOL_NAME | 2666 #undef STRING_NAME |
2667 #undef NAME_ENTRY | 2667 #undef NAME_ENTRY |
2668 CHECK(!strong_gc_subroot_names_.is_empty()); | 2668 CHECK(!strong_gc_subroot_names_.is_empty()); |
2669 } | 2669 } |
2670 return strong_gc_subroot_names_.GetTag(object); | 2670 return strong_gc_subroot_names_.GetTag(object); |
2671 } | 2671 } |
2672 | 2672 |
2673 | 2673 |
2674 void V8HeapExplorer::TagObject(Object* obj, const char* tag) { | 2674 void V8HeapExplorer::TagObject(Object* obj, const char* tag) { |
2675 if (IsEssentialObject(obj)) { | 2675 if (IsEssentialObject(obj)) { |
2676 HeapEntry* entry = GetEntry(obj); | 2676 HeapEntry* entry = GetEntry(obj); |
(...skipping 908 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3585 | 3585 |
3586 | 3586 |
3587 void HeapSnapshotJSONSerializer::SortHashMap( | 3587 void HeapSnapshotJSONSerializer::SortHashMap( |
3588 HashMap* map, List<HashMap::Entry*>* sorted_entries) { | 3588 HashMap* map, List<HashMap::Entry*>* sorted_entries) { |
3589 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) | 3589 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) |
3590 sorted_entries->Add(p); | 3590 sorted_entries->Add(p); |
3591 sorted_entries->Sort(SortUsingEntryValue); | 3591 sorted_entries->Sort(SortUsingEntryValue); |
3592 } | 3592 } |
3593 | 3593 |
3594 } } // namespace v8::internal | 3594 } } // namespace v8::internal |
OLD | NEW |