| 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 2050 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2061 if (obj->IsConsString()) { | 2061 if (obj->IsConsString()) { |
| 2062 ConsString* cs = ConsString::cast(obj); | 2062 ConsString* cs = ConsString::cast(obj); |
| 2063 SetInternalReference(obj, entry, 1, cs->first()); | 2063 SetInternalReference(obj, entry, 1, cs->first()); |
| 2064 SetInternalReference(obj, entry, 2, cs->second()); | 2064 SetInternalReference(obj, entry, 2, cs->second()); |
| 2065 } | 2065 } |
| 2066 if (obj->IsSlicedString()) { | 2066 if (obj->IsSlicedString()) { |
| 2067 SlicedString* ss = SlicedString::cast(obj); | 2067 SlicedString* ss = SlicedString::cast(obj); |
| 2068 SetInternalReference(obj, entry, "parent", ss->parent()); | 2068 SetInternalReference(obj, entry, "parent", ss->parent()); |
| 2069 } | 2069 } |
| 2070 extract_indexed_refs = false; | 2070 extract_indexed_refs = false; |
| 2071 } else if (obj->IsGlobalContext()) { | 2071 } else if (obj->IsContext()) { |
| 2072 Context* context = Context::cast(obj); | 2072 Context* context = Context::cast(obj); |
| 2073 TagObject(context->jsfunction_result_caches(), | 2073 #define EXTRACT_CONTEXT_FIELD(index, type, name) \ |
| 2074 "(context func. result caches)"); | 2074 SetInternalReference(context, entry, #name, context->get(Context::index), \ |
| 2075 TagObject(context->normalized_map_cache(), "(context norm. map cache)"); | 2075 FixedArray::OffsetOfElementAt(Context::index)); |
| 2076 TagObject(context->runtime_context(), "(runtime context)"); | 2076 EXTRACT_CONTEXT_FIELD(CLOSURE_INDEX, JSFunction, closure); |
| 2077 TagObject(context->data(), "(context data)"); | 2077 EXTRACT_CONTEXT_FIELD(PREVIOUS_INDEX, Context, previous); |
| 2078 for (int i = Context::FIRST_WEAK_SLOT; | 2078 EXTRACT_CONTEXT_FIELD(EXTENSION_INDEX, Object, extension); |
| 2079 i < Context::GLOBAL_CONTEXT_SLOTS; | 2079 EXTRACT_CONTEXT_FIELD(GLOBAL_INDEX, GlobalObject, global); |
| 2080 ++i) { | 2080 if (obj->IsGlobalContext()) { |
| 2081 SetWeakReference(obj, entry, | 2081 TagObject(context->jsfunction_result_caches(), |
| 2082 i, context->get(i), | 2082 "(context func. result caches)"); |
| 2083 FixedArray::OffsetOfElementAt(i)); | 2083 TagObject(context->normalized_map_cache(), "(context norm. map cache)"); |
| 2084 TagObject(context->runtime_context(), "(runtime context)"); |
| 2085 TagObject(context->data(), "(context data)"); |
| 2086 GLOBAL_CONTEXT_FIELDS(EXTRACT_CONTEXT_FIELD); |
| 2087 #undef EXTRACT_CONTEXT_FIELD |
| 2088 for (int i = Context::FIRST_WEAK_SLOT; |
| 2089 i < Context::GLOBAL_CONTEXT_SLOTS; |
| 2090 ++i) { |
| 2091 SetWeakReference(obj, entry, |
| 2092 i, context->get(i), |
| 2093 FixedArray::OffsetOfElementAt(i)); |
| 2094 } |
| 2084 } | 2095 } |
| 2085 } else if (obj->IsMap()) { | 2096 } else if (obj->IsMap()) { |
| 2086 Map* map = Map::cast(obj); | 2097 Map* map = Map::cast(obj); |
| 2087 SetInternalReference(obj, entry, | 2098 SetInternalReference(obj, entry, |
| 2088 "prototype", map->prototype(), Map::kPrototypeOffset); | 2099 "prototype", map->prototype(), Map::kPrototypeOffset); |
| 2089 SetInternalReference(obj, entry, | 2100 SetInternalReference(obj, entry, |
| 2090 "constructor", map->constructor(), | 2101 "constructor", map->constructor(), |
| 2091 Map::kConstructorOffset); | 2102 Map::kConstructorOffset); |
| 2092 if (!map->instance_descriptors()->IsEmpty()) { | 2103 if (!map->instance_descriptors()->IsEmpty()) { |
| 2093 TagObject(map->instance_descriptors(), "(map descriptors)"); | 2104 TagObject(map->instance_descriptors(), "(map descriptors)"); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2180 obj->Iterate(&refs_extractor); | 2191 obj->Iterate(&refs_extractor); |
| 2181 } | 2192 } |
| 2182 } | 2193 } |
| 2183 | 2194 |
| 2184 | 2195 |
| 2185 void V8HeapExplorer::ExtractClosureReferences(JSObject* js_obj, | 2196 void V8HeapExplorer::ExtractClosureReferences(JSObject* js_obj, |
| 2186 HeapEntry* entry) { | 2197 HeapEntry* entry) { |
| 2187 if (!js_obj->IsJSFunction()) return; | 2198 if (!js_obj->IsJSFunction()) return; |
| 2188 | 2199 |
| 2189 JSFunction* func = JSFunction::cast(js_obj); | 2200 JSFunction* func = JSFunction::cast(js_obj); |
| 2190 Context* context = func->context()->declaration_context(); | |
| 2191 ScopeInfo* scope_info = context->closure()->shared()->scope_info(); | |
| 2192 | |
| 2193 if (func->shared()->bound()) { | 2201 if (func->shared()->bound()) { |
| 2194 FixedArray* bindings = func->function_bindings(); | 2202 FixedArray* bindings = func->function_bindings(); |
| 2195 SetNativeBindReference(js_obj, entry, "bound_this", | 2203 SetNativeBindReference(js_obj, entry, "bound_this", |
| 2196 bindings->get(JSFunction::kBoundThisIndex)); | 2204 bindings->get(JSFunction::kBoundThisIndex)); |
| 2197 SetNativeBindReference(js_obj, entry, "bound_function", | 2205 SetNativeBindReference(js_obj, entry, "bound_function", |
| 2198 bindings->get(JSFunction::kBoundFunctionIndex)); | 2206 bindings->get(JSFunction::kBoundFunctionIndex)); |
| 2199 for (int i = JSFunction::kBoundArgumentsStartIndex; | 2207 for (int i = JSFunction::kBoundArgumentsStartIndex; |
| 2200 i < bindings->length(); i++) { | 2208 i < bindings->length(); i++) { |
| 2201 const char* reference_name = collection_->names()->GetFormatted( | 2209 const char* reference_name = collection_->names()->GetFormatted( |
| 2202 "bound_argument_%d", | 2210 "bound_argument_%d", |
| 2203 i - JSFunction::kBoundArgumentsStartIndex); | 2211 i - JSFunction::kBoundArgumentsStartIndex); |
| 2204 SetNativeBindReference(js_obj, entry, reference_name, | 2212 SetNativeBindReference(js_obj, entry, reference_name, |
| 2205 bindings->get(i)); | 2213 bindings->get(i)); |
| 2206 } | 2214 } |
| 2207 } else { | 2215 } else { |
| 2216 Context* context = func->context()->declaration_context(); |
| 2217 ScopeInfo* scope_info = context->closure()->shared()->scope_info(); |
| 2208 // Add context allocated locals. | 2218 // Add context allocated locals. |
| 2209 int context_locals = scope_info->ContextLocalCount(); | 2219 int context_locals = scope_info->ContextLocalCount(); |
| 2210 for (int i = 0; i < context_locals; ++i) { | 2220 for (int i = 0; i < context_locals; ++i) { |
| 2211 String* local_name = scope_info->ContextLocalName(i); | 2221 String* local_name = scope_info->ContextLocalName(i); |
| 2212 int idx = Context::MIN_CONTEXT_SLOTS + i; | 2222 int idx = Context::MIN_CONTEXT_SLOTS + i; |
| 2213 SetClosureReference(js_obj, entry, local_name, context->get(idx)); | 2223 SetClosureReference(js_obj, entry, local_name, context->get(idx)); |
| 2214 } | 2224 } |
| 2215 | 2225 |
| 2216 // Add function variable. | 2226 // Add function variable. |
| 2217 if (scope_info->HasFunctionName()) { | 2227 if (scope_info->HasFunctionName()) { |
| (...skipping 1750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3968 | 3978 |
| 3969 | 3979 |
| 3970 void HeapSnapshotJSONSerializer::SortHashMap( | 3980 void HeapSnapshotJSONSerializer::SortHashMap( |
| 3971 HashMap* map, List<HashMap::Entry*>* sorted_entries) { | 3981 HashMap* map, List<HashMap::Entry*>* sorted_entries) { |
| 3972 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) | 3982 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) |
| 3973 sorted_entries->Add(p); | 3983 sorted_entries->Add(p); |
| 3974 sorted_entries->Sort(SortUsingEntryValue); | 3984 sorted_entries->Sort(SortUsingEntryValue); |
| 3975 } | 3985 } |
| 3976 | 3986 |
| 3977 } } // namespace v8::internal | 3987 } } // namespace v8::internal |
| OLD | NEW |