OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "v8.h" | 5 #include "v8.h" |
6 | 6 |
7 #include "heap-snapshot-generator-inl.h" | 7 #include "heap-snapshot-generator-inl.h" |
8 | 8 |
9 #include "allocation-tracker.h" | 9 #include "allocation-tracker.h" |
10 #include "code-stubs.h" | 10 #include "code-stubs.h" |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 case kClosure: return "/closure/"; | 148 case kClosure: return "/closure/"; |
149 case kString: return "/string/"; | 149 case kString: return "/string/"; |
150 case kCode: return "/code/"; | 150 case kCode: return "/code/"; |
151 case kArray: return "/array/"; | 151 case kArray: return "/array/"; |
152 case kRegExp: return "/regexp/"; | 152 case kRegExp: return "/regexp/"; |
153 case kHeapNumber: return "/number/"; | 153 case kHeapNumber: return "/number/"; |
154 case kNative: return "/native/"; | 154 case kNative: return "/native/"; |
155 case kSynthetic: return "/synthetic/"; | 155 case kSynthetic: return "/synthetic/"; |
156 case kConsString: return "/concatenated string/"; | 156 case kConsString: return "/concatenated string/"; |
157 case kSlicedString: return "/sliced string/"; | 157 case kSlicedString: return "/sliced string/"; |
| 158 case kSymbol: return "/symbol/"; |
158 default: return "???"; | 159 default: return "???"; |
159 } | 160 } |
160 } | 161 } |
161 | 162 |
162 | 163 |
163 // It is very important to keep objects that form a heap snapshot | 164 // It is very important to keep objects that form a heap snapshot |
164 // as small as possible. | 165 // as small as possible. |
165 namespace { // Avoid littering the global namespace. | 166 namespace { // Avoid littering the global namespace. |
166 | 167 |
167 template <size_t ptr_size> struct SnapshotSizeConstants; | 168 template <size_t ptr_size> struct SnapshotSizeConstants; |
(...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
844 return AddEntry(object, | 845 return AddEntry(object, |
845 HeapEntry::kConsString, | 846 HeapEntry::kConsString, |
846 "(concatenated string)"); | 847 "(concatenated string)"); |
847 if (string->IsSlicedString()) | 848 if (string->IsSlicedString()) |
848 return AddEntry(object, | 849 return AddEntry(object, |
849 HeapEntry::kSlicedString, | 850 HeapEntry::kSlicedString, |
850 "(sliced string)"); | 851 "(sliced string)"); |
851 return AddEntry(object, | 852 return AddEntry(object, |
852 HeapEntry::kString, | 853 HeapEntry::kString, |
853 names_->GetName(String::cast(object))); | 854 names_->GetName(String::cast(object))); |
| 855 } else if (object->IsSymbol()) { |
| 856 return AddEntry(object, HeapEntry::kSymbol, "symbol"); |
854 } else if (object->IsCode()) { | 857 } else if (object->IsCode()) { |
855 return AddEntry(object, HeapEntry::kCode, ""); | 858 return AddEntry(object, HeapEntry::kCode, ""); |
856 } else if (object->IsSharedFunctionInfo()) { | 859 } else if (object->IsSharedFunctionInfo()) { |
857 String* name = String::cast(SharedFunctionInfo::cast(object)->name()); | 860 String* name = String::cast(SharedFunctionInfo::cast(object)->name()); |
858 return AddEntry(object, | 861 return AddEntry(object, |
859 HeapEntry::kCode, | 862 HeapEntry::kCode, |
860 names_->GetName(name)); | 863 names_->GetName(name)); |
861 } else if (object->IsScript()) { | 864 } else if (object->IsScript()) { |
862 Object* name = Script::cast(object)->name(); | 865 Object* name = Script::cast(object)->name(); |
863 return AddEntry(object, | 866 return AddEntry(object, |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1091 if (obj->IsFixedArray()) return false; // FixedArrays are processed on pass 2 | 1094 if (obj->IsFixedArray()) return false; // FixedArrays are processed on pass 2 |
1092 | 1095 |
1093 if (obj->IsJSGlobalProxy()) { | 1096 if (obj->IsJSGlobalProxy()) { |
1094 ExtractJSGlobalProxyReferences(entry, JSGlobalProxy::cast(obj)); | 1097 ExtractJSGlobalProxyReferences(entry, JSGlobalProxy::cast(obj)); |
1095 } else if (obj->IsJSArrayBuffer()) { | 1098 } else if (obj->IsJSArrayBuffer()) { |
1096 ExtractJSArrayBufferReferences(entry, JSArrayBuffer::cast(obj)); | 1099 ExtractJSArrayBufferReferences(entry, JSArrayBuffer::cast(obj)); |
1097 } else if (obj->IsJSObject()) { | 1100 } else if (obj->IsJSObject()) { |
1098 ExtractJSObjectReferences(entry, JSObject::cast(obj)); | 1101 ExtractJSObjectReferences(entry, JSObject::cast(obj)); |
1099 } else if (obj->IsString()) { | 1102 } else if (obj->IsString()) { |
1100 ExtractStringReferences(entry, String::cast(obj)); | 1103 ExtractStringReferences(entry, String::cast(obj)); |
| 1104 } else if (obj->IsSymbol()) { |
| 1105 ExtractSymbolReferences(entry, Symbol::cast(obj)); |
1101 } else if (obj->IsMap()) { | 1106 } else if (obj->IsMap()) { |
1102 ExtractMapReferences(entry, Map::cast(obj)); | 1107 ExtractMapReferences(entry, Map::cast(obj)); |
1103 } else if (obj->IsSharedFunctionInfo()) { | 1108 } else if (obj->IsSharedFunctionInfo()) { |
1104 ExtractSharedFunctionInfoReferences(entry, SharedFunctionInfo::cast(obj)); | 1109 ExtractSharedFunctionInfoReferences(entry, SharedFunctionInfo::cast(obj)); |
1105 } else if (obj->IsScript()) { | 1110 } else if (obj->IsScript()) { |
1106 ExtractScriptReferences(entry, Script::cast(obj)); | 1111 ExtractScriptReferences(entry, Script::cast(obj)); |
1107 } else if (obj->IsAccessorPair()) { | 1112 } else if (obj->IsAccessorPair()) { |
1108 ExtractAccessorPairReferences(entry, AccessorPair::cast(obj)); | 1113 ExtractAccessorPairReferences(entry, AccessorPair::cast(obj)); |
1109 } else if (obj->IsCodeCache()) { | 1114 } else if (obj->IsCodeCache()) { |
1110 ExtractCodeCacheReferences(entry, CodeCache::cast(obj)); | 1115 ExtractCodeCacheReferences(entry, CodeCache::cast(obj)); |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1237 SetInternalReference(cs, entry, "second", cs->second(), | 1242 SetInternalReference(cs, entry, "second", cs->second(), |
1238 ConsString::kSecondOffset); | 1243 ConsString::kSecondOffset); |
1239 } else if (string->IsSlicedString()) { | 1244 } else if (string->IsSlicedString()) { |
1240 SlicedString* ss = SlicedString::cast(string); | 1245 SlicedString* ss = SlicedString::cast(string); |
1241 SetInternalReference(ss, entry, "parent", ss->parent(), | 1246 SetInternalReference(ss, entry, "parent", ss->parent(), |
1242 SlicedString::kParentOffset); | 1247 SlicedString::kParentOffset); |
1243 } | 1248 } |
1244 } | 1249 } |
1245 | 1250 |
1246 | 1251 |
| 1252 void V8HeapExplorer::ExtractSymbolReferences(int entry, Symbol* symbol) { |
| 1253 SetInternalReference(symbol, entry, |
| 1254 "name", symbol->name(), |
| 1255 Symbol::kNameOffset); |
| 1256 } |
| 1257 |
| 1258 |
1247 void V8HeapExplorer::ExtractContextReferences(int entry, Context* context) { | 1259 void V8HeapExplorer::ExtractContextReferences(int entry, Context* context) { |
1248 if (context == context->declaration_context()) { | 1260 if (context == context->declaration_context()) { |
1249 ScopeInfo* scope_info = context->closure()->shared()->scope_info(); | 1261 ScopeInfo* scope_info = context->closure()->shared()->scope_info(); |
1250 // Add context allocated locals. | 1262 // Add context allocated locals. |
1251 int context_locals = scope_info->ContextLocalCount(); | 1263 int context_locals = scope_info->ContextLocalCount(); |
1252 for (int i = 0; i < context_locals; ++i) { | 1264 for (int i = 0; i < context_locals; ++i) { |
1253 String* local_name = scope_info->ContextLocalName(i); | 1265 String* local_name = scope_info->ContextLocalName(i); |
1254 int idx = Context::MIN_CONTEXT_SLOTS + i; | 1266 int idx = Context::MIN_CONTEXT_SLOTS + i; |
1255 SetContextReference(context, entry, local_name, context->get(idx), | 1267 SetContextReference(context, entry, local_name, context->get(idx), |
1256 Context::OffsetOfElementAt(idx)); | 1268 Context::OffsetOfElementAt(idx)); |
(...skipping 1892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3149 writer_->AddString("\"<dummy>\""); | 3161 writer_->AddString("\"<dummy>\""); |
3150 for (int i = 1; i < sorted_strings.length(); ++i) { | 3162 for (int i = 1; i < sorted_strings.length(); ++i) { |
3151 writer_->AddCharacter(','); | 3163 writer_->AddCharacter(','); |
3152 SerializeString(sorted_strings[i]); | 3164 SerializeString(sorted_strings[i]); |
3153 if (writer_->aborted()) return; | 3165 if (writer_->aborted()) return; |
3154 } | 3166 } |
3155 } | 3167 } |
3156 | 3168 |
3157 | 3169 |
3158 } } // namespace v8::internal | 3170 } } // namespace v8::internal |
OLD | NEW |