Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: src/heap-snapshot-generator.cc

Issue 145353003: Allow arbitrary names for weak references in heap snapshots. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/heap-snapshot-generator.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 1096 matching lines...) Expand 10 before | Expand all | Expand 10 after
1107 js_fun->literals_or_bindings(), 1107 js_fun->literals_or_bindings(),
1108 JSFunction::kLiteralsOffset); 1108 JSFunction::kLiteralsOffset);
1109 TagObject(shared_info, "(shared function info)"); 1109 TagObject(shared_info, "(shared function info)");
1110 SetInternalReference(js_fun, entry, 1110 SetInternalReference(js_fun, entry,
1111 "shared", shared_info, 1111 "shared", shared_info,
1112 JSFunction::kSharedFunctionInfoOffset); 1112 JSFunction::kSharedFunctionInfoOffset);
1113 TagObject(js_fun->context(), "(context)"); 1113 TagObject(js_fun->context(), "(context)");
1114 SetInternalReference(js_fun, entry, 1114 SetInternalReference(js_fun, entry,
1115 "context", js_fun->context(), 1115 "context", js_fun->context(),
1116 JSFunction::kContextOffset); 1116 JSFunction::kContextOffset);
1117 for (int i = JSFunction::kNonWeakFieldsEndOffset; 1117 SetWeakReference(js_fun, entry,
1118 i < JSFunction::kSize; 1118 "next_function_link", js_fun->next_function_link(),
1119 i += kPointerSize) { 1119 JSFunction::kNextFunctionLinkOffset);
1120 SetWeakReference(js_fun, entry, i, *HeapObject::RawField(js_fun, i), i);
yurys 2014/01/24 14:02:55 Please add STATIC_CHECK that there are no other we
1121 }
1122 } else if (obj->IsGlobalObject()) { 1120 } else if (obj->IsGlobalObject()) {
1123 GlobalObject* global_obj = GlobalObject::cast(obj); 1121 GlobalObject* global_obj = GlobalObject::cast(obj);
1124 SetInternalReference(global_obj, entry, 1122 SetInternalReference(global_obj, entry,
1125 "builtins", global_obj->builtins(), 1123 "builtins", global_obj->builtins(),
1126 GlobalObject::kBuiltinsOffset); 1124 GlobalObject::kBuiltinsOffset);
1127 SetInternalReference(global_obj, entry, 1125 SetInternalReference(global_obj, entry,
1128 "native_context", global_obj->native_context(), 1126 "native_context", global_obj->native_context(),
1129 GlobalObject::kNativeContextOffset); 1127 GlobalObject::kNativeContextOffset);
1130 SetInternalReference(global_obj, entry, 1128 SetInternalReference(global_obj, entry,
1131 "global_receiver", global_obj->global_receiver(), 1129 "global_receiver", global_obj->global_receiver(),
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1173 VariableMode mode; 1171 VariableMode mode;
1174 int idx = scope_info->FunctionContextSlotIndex(name, &mode); 1172 int idx = scope_info->FunctionContextSlotIndex(name, &mode);
1175 if (idx >= 0) { 1173 if (idx >= 0) {
1176 SetContextReference(context, entry, name, context->get(idx), 1174 SetContextReference(context, entry, name, context->get(idx),
1177 Context::OffsetOfElementAt(idx)); 1175 Context::OffsetOfElementAt(idx));
1178 } 1176 }
1179 } 1177 }
1180 } 1178 }
1181 1179
1182 #define EXTRACT_CONTEXT_FIELD(index, type, name) \ 1180 #define EXTRACT_CONTEXT_FIELD(index, type, name) \
1183 SetInternalReference(context, entry, #name, context->get(Context::index), \ 1181 if (Context::index < Context::FIRST_WEAK_SLOT) { \
1184 FixedArray::OffsetOfElementAt(Context::index)); 1182 SetInternalReference(context, entry, #name, context->get(Context::index), \
1183 FixedArray::OffsetOfElementAt(Context::index)); \
1184 } else { \
1185 SetWeakReference(context, entry, #name, context->get(Context::index), \
1186 FixedArray::OffsetOfElementAt(Context::index)); \
1187 }
1185 EXTRACT_CONTEXT_FIELD(CLOSURE_INDEX, JSFunction, closure); 1188 EXTRACT_CONTEXT_FIELD(CLOSURE_INDEX, JSFunction, closure);
1186 EXTRACT_CONTEXT_FIELD(PREVIOUS_INDEX, Context, previous); 1189 EXTRACT_CONTEXT_FIELD(PREVIOUS_INDEX, Context, previous);
1187 EXTRACT_CONTEXT_FIELD(EXTENSION_INDEX, Object, extension); 1190 EXTRACT_CONTEXT_FIELD(EXTENSION_INDEX, Object, extension);
1188 EXTRACT_CONTEXT_FIELD(GLOBAL_OBJECT_INDEX, GlobalObject, global); 1191 EXTRACT_CONTEXT_FIELD(GLOBAL_OBJECT_INDEX, GlobalObject, global);
1189 if (context->IsNativeContext()) { 1192 if (context->IsNativeContext()) {
1190 TagObject(context->jsfunction_result_caches(), 1193 TagObject(context->jsfunction_result_caches(),
1191 "(context func. result caches)"); 1194 "(context func. result caches)");
1192 TagObject(context->normalized_map_cache(), "(context norm. map cache)"); 1195 TagObject(context->normalized_map_cache(), "(context norm. map cache)");
1193 TagObject(context->runtime_context(), "(runtime context)"); 1196 TagObject(context->runtime_context(), "(runtime context)");
1194 TagObject(context->embedder_data(), "(context data)"); 1197 TagObject(context->embedder_data(), "(context data)");
1195 NATIVE_CONTEXT_FIELDS(EXTRACT_CONTEXT_FIELD); 1198 NATIVE_CONTEXT_FIELDS(EXTRACT_CONTEXT_FIELD);
1199 EXTRACT_CONTEXT_FIELD(OPTIMIZED_FUNCTIONS_LIST, , optimized_functions_list);
1200 EXTRACT_CONTEXT_FIELD(OPTIMIZED_CODE_LIST, , optimized_code_list);
1201 EXTRACT_CONTEXT_FIELD(DEOPTIMIZED_CODE_LIST, , deoptimized_code_list);
1202 EXTRACT_CONTEXT_FIELD(NEXT_CONTEXT_LINK, , next_context_link);
1196 #undef EXTRACT_CONTEXT_FIELD 1203 #undef EXTRACT_CONTEXT_FIELD
1197 for (int i = Context::FIRST_WEAK_SLOT; 1204 STATIC_CHECK(Context::OPTIMIZED_FUNCTIONS_LIST == Context::FIRST_WEAK_SLOT);
1198 i < Context::NATIVE_CONTEXT_SLOTS; 1205 STATIC_CHECK(Context::NEXT_CONTEXT_LINK + 1
1199 ++i) { 1206 == Context::NATIVE_CONTEXT_SLOTS);
1200 SetWeakReference(context, entry, i, context->get(i),
1201 FixedArray::OffsetOfElementAt(i));
1202 }
1203 } 1207 }
1204 } 1208 }
1205 1209
1206 1210
1207 void V8HeapExplorer::ExtractMapReferences(int entry, Map* map) { 1211 void V8HeapExplorer::ExtractMapReferences(int entry, Map* map) {
1208 if (map->HasTransitionArray()) { 1212 if (map->HasTransitionArray()) {
1209 TransitionArray* transitions = map->transitions(); 1213 TransitionArray* transitions = map->transitions();
1210 int transitions_entry = GetEntry(transitions)->index(); 1214 int transitions_entry = GetEntry(transitions)->index();
1211 Object* back_pointer = transitions->back_pointer_storage(); 1215 Object* back_pointer = transitions->back_pointer_storage();
1212 TagObject(back_pointer, "(back pointer)"); 1216 TagObject(back_pointer, "(back pointer)");
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
1286 SetInternalReference(obj, entry, 1290 SetInternalReference(obj, entry,
1287 "debug_info", shared->debug_info(), 1291 "debug_info", shared->debug_info(),
1288 SharedFunctionInfo::kDebugInfoOffset); 1292 SharedFunctionInfo::kDebugInfoOffset);
1289 SetInternalReference(obj, entry, 1293 SetInternalReference(obj, entry,
1290 "inferred_name", shared->inferred_name(), 1294 "inferred_name", shared->inferred_name(),
1291 SharedFunctionInfo::kInferredNameOffset); 1295 SharedFunctionInfo::kInferredNameOffset);
1292 SetInternalReference(obj, entry, 1296 SetInternalReference(obj, entry,
1293 "optimized_code_map", shared->optimized_code_map(), 1297 "optimized_code_map", shared->optimized_code_map(),
1294 SharedFunctionInfo::kOptimizedCodeMapOffset); 1298 SharedFunctionInfo::kOptimizedCodeMapOffset);
1295 SetWeakReference(obj, entry, 1299 SetWeakReference(obj, entry,
1296 1, shared->initial_map(), 1300 "initial_map", shared->initial_map(),
1297 SharedFunctionInfo::kInitialMapOffset); 1301 SharedFunctionInfo::kInitialMapOffset);
1298 } 1302 }
1299 1303
1300 1304
1301 void V8HeapExplorer::ExtractScriptReferences(int entry, Script* script) { 1305 void V8HeapExplorer::ExtractScriptReferences(int entry, Script* script) {
1302 HeapObject* obj = script; 1306 HeapObject* obj = script;
1303 SetInternalReference(obj, entry, 1307 SetInternalReference(obj, entry,
1304 "source", script->source(), 1308 "source", script->source(),
1305 Script::kSourceOffset); 1309 Script::kSourceOffset);
1306 SetInternalReference(obj, entry, 1310 SetInternalReference(obj, entry,
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
1816 filler_->SetIndexedReference(HeapGraphEdge::kHidden, 1820 filler_->SetIndexedReference(HeapGraphEdge::kHidden,
1817 parent_entry, 1821 parent_entry,
1818 index, 1822 index,
1819 child_entry); 1823 child_entry);
1820 } 1824 }
1821 } 1825 }
1822 1826
1823 1827
1824 void V8HeapExplorer::SetWeakReference(HeapObject* parent_obj, 1828 void V8HeapExplorer::SetWeakReference(HeapObject* parent_obj,
1825 int parent_entry, 1829 int parent_entry,
1826 int index, 1830 const char* reference_name,
1827 Object* child_obj, 1831 Object* child_obj,
1828 int field_offset) { 1832 int field_offset) {
1829 ASSERT(parent_entry == GetEntry(parent_obj)->index()); 1833 ASSERT(parent_entry == GetEntry(parent_obj)->index());
1830 HeapEntry* child_entry = GetEntry(child_obj); 1834 HeapEntry* child_entry = GetEntry(child_obj);
1831 if (child_entry == NULL) return; 1835 if (child_entry == NULL) return;
1832 if (IsEssentialObject(child_obj)) { 1836 if (IsEssentialObject(child_obj)) {
1833 filler_->SetIndexedReference(HeapGraphEdge::kWeak, 1837 filler_->SetNamedReference(HeapGraphEdge::kWeak,
1834 parent_entry, 1838 parent_entry,
1835 index, 1839 reference_name,
1836 child_entry); 1840 child_entry);
1837 } 1841 }
1838 IndexedReferencesExtractor::MarkVisitedField(parent_obj, field_offset); 1842 IndexedReferencesExtractor::MarkVisitedField(parent_obj, field_offset);
1839 } 1843 }
1840 1844
1841 1845
1842 void V8HeapExplorer::SetPropertyReference(HeapObject* parent_obj, 1846 void V8HeapExplorer::SetPropertyReference(HeapObject* parent_obj,
1843 int parent_entry, 1847 int parent_entry,
1844 Name* reference_name, 1848 Name* reference_name,
1845 Object* child_obj, 1849 Object* child_obj,
1846 const char* name_format_string, 1850 const char* name_format_string,
(...skipping 1107 matching lines...) Expand 10 before | Expand all | Expand 10 after
2954 writer_->AddString("\"<dummy>\""); 2958 writer_->AddString("\"<dummy>\"");
2955 for (int i = 1; i < sorted_strings.length(); ++i) { 2959 for (int i = 1; i < sorted_strings.length(); ++i) {
2956 writer_->AddCharacter(','); 2960 writer_->AddCharacter(',');
2957 SerializeString(sorted_strings[i]); 2961 SerializeString(sorted_strings[i]);
2958 if (writer_->aborted()) return; 2962 if (writer_->aborted()) return;
2959 } 2963 }
2960 } 2964 }
2961 2965
2962 2966
2963 } } // namespace v8::internal 2967 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap-snapshot-generator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698