OLD | NEW |
---|---|
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 2046 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2057 } | 2057 } |
2058 } | 2058 } |
2059 | 2059 |
2060 | 2060 |
2061 void V8HeapExplorer::ExtractClosureReferences(JSObject* js_obj, | 2061 void V8HeapExplorer::ExtractClosureReferences(JSObject* js_obj, |
2062 HeapEntry* entry) { | 2062 HeapEntry* entry) { |
2063 if (js_obj->IsJSFunction()) { | 2063 if (js_obj->IsJSFunction()) { |
2064 HandleScope hs; | 2064 HandleScope hs; |
2065 JSFunction* func = JSFunction::cast(js_obj); | 2065 JSFunction* func = JSFunction::cast(js_obj); |
2066 Context* context = func->context(); | 2066 Context* context = func->context(); |
2067 ZoneScope zscope(Isolate::Current(), DELETE_ON_EXIT); | 2067 ScopeInfo* scope_info = context->closure()->shared()->scope_info(); |
2068 SerializedScopeInfo* serialized_scope_info = | 2068 |
2069 context->closure()->shared()->scope_info(); | 2069 // Add context allocated locals. |
2070 ScopeInfo<ZoneListAllocationPolicy> zone_scope_info(serialized_scope_info); | 2070 int context_locals = scope_info->num_context_locals(); |
2071 int locals_number = zone_scope_info.NumberOfLocals(); | 2071 for (int i = 0; i < context_locals; ++i) { |
2072 for (int i = 0; i < locals_number; ++i) { | 2072 String* local_name = *scope_info->context_local_name(i); |
Kevin Millikin (Chromium)
2011/11/02 16:31:19
Not your code, but while you're cleaning this up I
Steven
2011/11/02 18:52:59
Done. However AFAICS this is the only HandleScope
| |
2073 String* local_name = *zone_scope_info.LocalName(i); | 2073 int idx = Context::MIN_CONTEXT_SLOTS + i; |
2074 int idx = serialized_scope_info->ContextSlotIndex(local_name, NULL); | 2074 SetClosureReference(js_obj, entry, local_name, context->get(idx)); |
2075 if (idx >= 0 && idx < context->length()) { | 2075 } |
2076 SetClosureReference(js_obj, entry, local_name, context->get(idx)); | 2076 |
2077 } | 2077 // Add function variable. |
2078 if (scope_info->HasFunctionName()) { | |
2079 String* name = *scope_info->function_name(); | |
2080 int idx = Context::MIN_CONTEXT_SLOTS + context_locals; | |
2081 ASSERT(idx == scope_info->FunctionContextSlotIndex(name, NULL)); | |
2082 SetClosureReference(js_obj, entry, name, context->get(idx)); | |
2078 } | 2083 } |
2079 } | 2084 } |
2080 } | 2085 } |
2081 | 2086 |
2082 | 2087 |
2083 void V8HeapExplorer::ExtractPropertyReferences(JSObject* js_obj, | 2088 void V8HeapExplorer::ExtractPropertyReferences(JSObject* js_obj, |
2084 HeapEntry* entry) { | 2089 HeapEntry* entry) { |
2085 if (js_obj->HasFastProperties()) { | 2090 if (js_obj->HasFastProperties()) { |
2086 DescriptorArray* descs = js_obj->map()->instance_descriptors(); | 2091 DescriptorArray* descs = js_obj->map()->instance_descriptors(); |
2087 for (int i = 0; i < descs->number_of_descriptors(); i++) { | 2092 for (int i = 0; i < descs->number_of_descriptors(); i++) { |
(...skipping 1312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3400 | 3405 |
3401 | 3406 |
3402 void HeapSnapshotJSONSerializer::SortHashMap( | 3407 void HeapSnapshotJSONSerializer::SortHashMap( |
3403 HashMap* map, List<HashMap::Entry*>* sorted_entries) { | 3408 HashMap* map, List<HashMap::Entry*>* sorted_entries) { |
3404 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) | 3409 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) |
3405 sorted_entries->Add(p); | 3410 sorted_entries->Add(p); |
3406 sorted_entries->Sort(SortUsingEntryValue); | 3411 sorted_entries->Sort(SortUsingEntryValue); |
3407 } | 3412 } |
3408 | 3413 |
3409 } } // namespace v8::internal | 3414 } } // namespace v8::internal |
OLD | NEW |