| 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 1693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1704 return AddEntry(object, | 1704 return AddEntry(object, |
| 1705 HeapEntry::kCode, | 1705 HeapEntry::kCode, |
| 1706 collection_->names()->GetName(name)); | 1706 collection_->names()->GetName(name)); |
| 1707 } else if (object->IsScript()) { | 1707 } else if (object->IsScript()) { |
| 1708 Object* name = Script::cast(object)->name(); | 1708 Object* name = Script::cast(object)->name(); |
| 1709 return AddEntry(object, | 1709 return AddEntry(object, |
| 1710 HeapEntry::kCode, | 1710 HeapEntry::kCode, |
| 1711 name->IsString() | 1711 name->IsString() |
| 1712 ? collection_->names()->GetName(String::cast(name)) | 1712 ? collection_->names()->GetName(String::cast(name)) |
| 1713 : ""); | 1713 : ""); |
| 1714 } else if (object->IsNativeContext()) { | 1714 } else if (object->IsGlobalContext()) { |
| 1715 return AddEntry(object, HeapEntry::kHidden, "system / NativeContext"); | 1715 return AddEntry(object, HeapEntry::kHidden, "system / GlobalContext"); |
| 1716 } else if (object->IsContext()) { | 1716 } else if (object->IsContext()) { |
| 1717 return AddEntry(object, HeapEntry::kHidden, "system / Context"); | 1717 return AddEntry(object, HeapEntry::kHidden, "system / Context"); |
| 1718 } else if (object->IsFixedArray() || | 1718 } else if (object->IsFixedArray() || |
| 1719 object->IsFixedDoubleArray() || | 1719 object->IsFixedDoubleArray() || |
| 1720 object->IsByteArray() || | 1720 object->IsByteArray() || |
| 1721 object->IsExternalArray()) { | 1721 object->IsExternalArray()) { |
| 1722 return AddEntry(object, HeapEntry::kArray, ""); | 1722 return AddEntry(object, HeapEntry::kArray, ""); |
| 1723 } else if (object->IsHeapNumber()) { | 1723 } else if (object->IsHeapNumber()) { |
| 1724 return AddEntry(object, HeapEntry::kHeapNumber, "number"); | 1724 return AddEntry(object, HeapEntry::kHeapNumber, "number"); |
| 1725 } | 1725 } |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1939 i < JSFunction::kSize; | 1939 i < JSFunction::kSize; |
| 1940 i += kPointerSize) { | 1940 i += kPointerSize) { |
| 1941 SetWeakReference(js_fun, entry, i, *HeapObject::RawField(js_fun, i), i); | 1941 SetWeakReference(js_fun, entry, i, *HeapObject::RawField(js_fun, i), i); |
| 1942 } | 1942 } |
| 1943 } else if (obj->IsGlobalObject()) { | 1943 } else if (obj->IsGlobalObject()) { |
| 1944 GlobalObject* global_obj = GlobalObject::cast(obj); | 1944 GlobalObject* global_obj = GlobalObject::cast(obj); |
| 1945 SetInternalReference(global_obj, entry, | 1945 SetInternalReference(global_obj, entry, |
| 1946 "builtins", global_obj->builtins(), | 1946 "builtins", global_obj->builtins(), |
| 1947 GlobalObject::kBuiltinsOffset); | 1947 GlobalObject::kBuiltinsOffset); |
| 1948 SetInternalReference(global_obj, entry, | 1948 SetInternalReference(global_obj, entry, |
| 1949 "native_context", global_obj->native_context(), | 1949 "global_context", global_obj->global_context(), |
| 1950 GlobalObject::kNativeContextOffset); | 1950 GlobalObject::kGlobalContextOffset); |
| 1951 SetInternalReference(global_obj, entry, | 1951 SetInternalReference(global_obj, entry, |
| 1952 "global_receiver", global_obj->global_receiver(), | 1952 "global_receiver", global_obj->global_receiver(), |
| 1953 GlobalObject::kGlobalReceiverOffset); | 1953 GlobalObject::kGlobalReceiverOffset); |
| 1954 } | 1954 } |
| 1955 TagObject(js_obj->properties(), "(object properties)"); | 1955 TagObject(js_obj->properties(), "(object properties)"); |
| 1956 SetInternalReference(obj, entry, | 1956 SetInternalReference(obj, entry, |
| 1957 "properties", js_obj->properties(), | 1957 "properties", js_obj->properties(), |
| 1958 JSObject::kPropertiesOffset); | 1958 JSObject::kPropertiesOffset); |
| 1959 TagObject(js_obj->elements(), "(object elements)"); | 1959 TagObject(js_obj->elements(), "(object elements)"); |
| 1960 SetInternalReference(obj, entry, | 1960 SetInternalReference(obj, entry, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1975 } | 1975 } |
| 1976 | 1976 |
| 1977 | 1977 |
| 1978 void V8HeapExplorer::ExtractContextReferences(int entry, Context* context) { | 1978 void V8HeapExplorer::ExtractContextReferences(int entry, Context* context) { |
| 1979 #define EXTRACT_CONTEXT_FIELD(index, type, name) \ | 1979 #define EXTRACT_CONTEXT_FIELD(index, type, name) \ |
| 1980 SetInternalReference(context, entry, #name, context->get(Context::index), \ | 1980 SetInternalReference(context, entry, #name, context->get(Context::index), \ |
| 1981 FixedArray::OffsetOfElementAt(Context::index)); | 1981 FixedArray::OffsetOfElementAt(Context::index)); |
| 1982 EXTRACT_CONTEXT_FIELD(CLOSURE_INDEX, JSFunction, closure); | 1982 EXTRACT_CONTEXT_FIELD(CLOSURE_INDEX, JSFunction, closure); |
| 1983 EXTRACT_CONTEXT_FIELD(PREVIOUS_INDEX, Context, previous); | 1983 EXTRACT_CONTEXT_FIELD(PREVIOUS_INDEX, Context, previous); |
| 1984 EXTRACT_CONTEXT_FIELD(EXTENSION_INDEX, Object, extension); | 1984 EXTRACT_CONTEXT_FIELD(EXTENSION_INDEX, Object, extension); |
| 1985 EXTRACT_CONTEXT_FIELD(GLOBAL_OBJECT_INDEX, GlobalObject, global); | 1985 EXTRACT_CONTEXT_FIELD(GLOBAL_INDEX, GlobalObject, global); |
| 1986 if (context->IsNativeContext()) { | 1986 if (context->IsGlobalContext()) { |
| 1987 TagObject(context->jsfunction_result_caches(), | 1987 TagObject(context->jsfunction_result_caches(), |
| 1988 "(context func. result caches)"); | 1988 "(context func. result caches)"); |
| 1989 TagObject(context->normalized_map_cache(), "(context norm. map cache)"); | 1989 TagObject(context->normalized_map_cache(), "(context norm. map cache)"); |
| 1990 TagObject(context->runtime_context(), "(runtime context)"); | 1990 TagObject(context->runtime_context(), "(runtime context)"); |
| 1991 TagObject(context->data(), "(context data)"); | 1991 TagObject(context->data(), "(context data)"); |
| 1992 NATIVE_CONTEXT_FIELDS(EXTRACT_CONTEXT_FIELD); | 1992 GLOBAL_CONTEXT_FIELDS(EXTRACT_CONTEXT_FIELD); |
| 1993 #undef EXTRACT_CONTEXT_FIELD | 1993 #undef EXTRACT_CONTEXT_FIELD |
| 1994 for (int i = Context::FIRST_WEAK_SLOT; | 1994 for (int i = Context::FIRST_WEAK_SLOT; |
| 1995 i < Context::NATIVE_CONTEXT_SLOTS; | 1995 i < Context::GLOBAL_CONTEXT_SLOTS; |
| 1996 ++i) { | 1996 ++i) { |
| 1997 SetWeakReference(context, entry, i, context->get(i), | 1997 SetWeakReference(context, entry, i, context->get(i), |
| 1998 FixedArray::OffsetOfElementAt(i)); | 1998 FixedArray::OffsetOfElementAt(i)); |
| 1999 } | 1999 } |
| 2000 } | 2000 } |
| 2001 } | 2001 } |
| 2002 | 2002 |
| 2003 | 2003 |
| 2004 void V8HeapExplorer::ExtractMapReferences(int entry, Map* map) { | 2004 void V8HeapExplorer::ExtractMapReferences(int entry, Map* map) { |
| 2005 SetInternalReference(map, entry, | 2005 SetInternalReference(map, entry, |
| (...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2665 entry->set_name(tag); | 2665 entry->set_name(tag); |
| 2666 } | 2666 } |
| 2667 } | 2667 } |
| 2668 } | 2668 } |
| 2669 | 2669 |
| 2670 | 2670 |
| 2671 class GlobalObjectsEnumerator : public ObjectVisitor { | 2671 class GlobalObjectsEnumerator : public ObjectVisitor { |
| 2672 public: | 2672 public: |
| 2673 virtual void VisitPointers(Object** start, Object** end) { | 2673 virtual void VisitPointers(Object** start, Object** end) { |
| 2674 for (Object** p = start; p < end; p++) { | 2674 for (Object** p = start; p < end; p++) { |
| 2675 if ((*p)->IsNativeContext()) { | 2675 if ((*p)->IsGlobalContext()) { |
| 2676 Context* context = Context::cast(*p); | 2676 Context* context = Context::cast(*p); |
| 2677 JSObject* proxy = context->global_proxy(); | 2677 JSObject* proxy = context->global_proxy(); |
| 2678 if (proxy->IsJSGlobalProxy()) { | 2678 if (proxy->IsJSGlobalProxy()) { |
| 2679 Object* global = proxy->map()->prototype(); | 2679 Object* global = proxy->map()->prototype(); |
| 2680 if (global->IsJSGlobalObject()) { | 2680 if (global->IsJSGlobalObject()) { |
| 2681 objects_.Add(Handle<JSGlobalObject>(JSGlobalObject::cast(global))); | 2681 objects_.Add(Handle<JSGlobalObject>(JSGlobalObject::cast(global))); |
| 2682 } | 2682 } |
| 2683 } | 2683 } |
| 2684 } | 2684 } |
| 2685 } | 2685 } |
| (...skipping 893 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3579 | 3579 |
| 3580 | 3580 |
| 3581 void HeapSnapshotJSONSerializer::SortHashMap( | 3581 void HeapSnapshotJSONSerializer::SortHashMap( |
| 3582 HashMap* map, List<HashMap::Entry*>* sorted_entries) { | 3582 HashMap* map, List<HashMap::Entry*>* sorted_entries) { |
| 3583 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) | 3583 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) |
| 3584 sorted_entries->Add(p); | 3584 sorted_entries->Add(p); |
| 3585 sorted_entries->Sort(SortUsingEntryValue); | 3585 sorted_entries->Sort(SortUsingEntryValue); |
| 3586 } | 3586 } |
| 3587 | 3587 |
| 3588 } } // namespace v8::internal | 3588 } } // namespace v8::internal |
| OLD | NEW |