| 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 "src/profiler/heap-snapshot-generator.h" | 5 #include "src/profiler/heap-snapshot-generator.h" | 
| 6 | 6 | 
| 7 #include "src/code-stubs.h" | 7 #include "src/code-stubs.h" | 
| 8 #include "src/conversions.h" | 8 #include "src/conversions.h" | 
| 9 #include "src/debug/debug.h" | 9 #include "src/debug/debug.h" | 
| 10 #include "src/objects-body-descriptors.h" | 10 #include "src/objects-body-descriptors.h" | 
| (...skipping 1114 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1125     SetInternalReference(js_fun, entry, "literals", js_fun->literals(), | 1125     SetInternalReference(js_fun, entry, "literals", js_fun->literals(), | 
| 1126                          JSFunction::kLiteralsOffset); | 1126                          JSFunction::kLiteralsOffset); | 
| 1127     TagObject(shared_info, "(shared function info)"); | 1127     TagObject(shared_info, "(shared function info)"); | 
| 1128     SetInternalReference(js_fun, entry, | 1128     SetInternalReference(js_fun, entry, | 
| 1129                          "shared", shared_info, | 1129                          "shared", shared_info, | 
| 1130                          JSFunction::kSharedFunctionInfoOffset); | 1130                          JSFunction::kSharedFunctionInfoOffset); | 
| 1131     TagObject(js_fun->context(), "(context)"); | 1131     TagObject(js_fun->context(), "(context)"); | 
| 1132     SetInternalReference(js_fun, entry, | 1132     SetInternalReference(js_fun, entry, | 
| 1133                          "context", js_fun->context(), | 1133                          "context", js_fun->context(), | 
| 1134                          JSFunction::kContextOffset); | 1134                          JSFunction::kContextOffset); | 
| 1135     SetWeakReference(js_fun, entry, |  | 
| 1136                      "next_function_link", js_fun->next_function_link(), |  | 
| 1137                      JSFunction::kNextFunctionLinkOffset); |  | 
| 1138     // Ensure no new weak references appeared in JSFunction. | 1135     // Ensure no new weak references appeared in JSFunction. | 
| 1139     STATIC_ASSERT(JSFunction::kCodeEntryOffset == | 1136     STATIC_ASSERT(JSFunction::kCodeEntryOffset == | 
| 1140                   JSFunction::kNonWeakFieldsEndOffset); | 1137                   JSFunction::kNonWeakFieldsEndOffset); | 
| 1141     STATIC_ASSERT(JSFunction::kCodeEntryOffset + kPointerSize == | 1138     STATIC_ASSERT(JSFunction::kCodeEntryOffset + kPointerSize == | 
| 1142                   JSFunction::kNextFunctionLinkOffset); | 1139                   JSFunction::kNextFunctionLinkOffset); | 
| 1143     STATIC_ASSERT(JSFunction::kNextFunctionLinkOffset + kPointerSize | 1140     STATIC_ASSERT(JSFunction::kNextFunctionLinkOffset + kPointerSize | 
| 1144                  == JSFunction::kSize); | 1141                  == JSFunction::kSize); | 
| 1145   } else if (obj->IsJSGlobalObject()) { | 1142   } else if (obj->IsJSGlobalObject()) { | 
| 1146     JSGlobalObject* global_obj = JSGlobalObject::cast(obj); | 1143     JSGlobalObject* global_obj = JSGlobalObject::cast(obj); | 
| 1147     SetInternalReference(global_obj, entry, "native_context", | 1144     SetInternalReference(global_obj, entry, "native_context", | 
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1242   EXTRACT_CONTEXT_FIELD(EXTENSION_INDEX, HeapObject, extension); | 1239   EXTRACT_CONTEXT_FIELD(EXTENSION_INDEX, HeapObject, extension); | 
| 1243   EXTRACT_CONTEXT_FIELD(NATIVE_CONTEXT_INDEX, Context, native_context); | 1240   EXTRACT_CONTEXT_FIELD(NATIVE_CONTEXT_INDEX, Context, native_context); | 
| 1244   if (context->IsNativeContext()) { | 1241   if (context->IsNativeContext()) { | 
| 1245     TagObject(context->normalized_map_cache(), "(context norm. map cache)"); | 1242     TagObject(context->normalized_map_cache(), "(context norm. map cache)"); | 
| 1246     TagObject(context->embedder_data(), "(context data)"); | 1243     TagObject(context->embedder_data(), "(context data)"); | 
| 1247     NATIVE_CONTEXT_FIELDS(EXTRACT_CONTEXT_FIELD) | 1244     NATIVE_CONTEXT_FIELDS(EXTRACT_CONTEXT_FIELD) | 
| 1248     EXTRACT_CONTEXT_FIELD(OPTIMIZED_FUNCTIONS_LIST, unused, | 1245     EXTRACT_CONTEXT_FIELD(OPTIMIZED_FUNCTIONS_LIST, unused, | 
| 1249                           optimized_functions_list); | 1246                           optimized_functions_list); | 
| 1250     EXTRACT_CONTEXT_FIELD(OPTIMIZED_CODE_LIST, unused, optimized_code_list); | 1247     EXTRACT_CONTEXT_FIELD(OPTIMIZED_CODE_LIST, unused, optimized_code_list); | 
| 1251     EXTRACT_CONTEXT_FIELD(DEOPTIMIZED_CODE_LIST, unused, deoptimized_code_list); | 1248     EXTRACT_CONTEXT_FIELD(DEOPTIMIZED_CODE_LIST, unused, deoptimized_code_list); | 
| 1252     EXTRACT_CONTEXT_FIELD(NEXT_CONTEXT_LINK, unused, next_context_link); |  | 
| 1253 #undef EXTRACT_CONTEXT_FIELD | 1249 #undef EXTRACT_CONTEXT_FIELD | 
| 1254     STATIC_ASSERT(Context::OPTIMIZED_FUNCTIONS_LIST == | 1250     STATIC_ASSERT(Context::OPTIMIZED_FUNCTIONS_LIST == | 
| 1255                   Context::FIRST_WEAK_SLOT); | 1251                   Context::FIRST_WEAK_SLOT); | 
| 1256     STATIC_ASSERT(Context::NEXT_CONTEXT_LINK + 1 == | 1252     STATIC_ASSERT(Context::NEXT_CONTEXT_LINK + 1 == | 
| 1257                   Context::NATIVE_CONTEXT_SLOTS); | 1253                   Context::NATIVE_CONTEXT_SLOTS); | 
| 1258     STATIC_ASSERT(Context::FIRST_WEAK_SLOT + 4 == | 1254     STATIC_ASSERT(Context::FIRST_WEAK_SLOT + 4 == | 
| 1259                   Context::NATIVE_CONTEXT_SLOTS); | 1255                   Context::NATIVE_CONTEXT_SLOTS); | 
| 1260   } | 1256   } | 
| 1261 } | 1257 } | 
| 1262 | 1258 | 
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1448                        Code::kHandlerTableOffset); | 1444                        Code::kHandlerTableOffset); | 
| 1449   TagObject(code->deoptimization_data(), "(code deopt data)"); | 1445   TagObject(code->deoptimization_data(), "(code deopt data)"); | 
| 1450   SetInternalReference(code, entry, | 1446   SetInternalReference(code, entry, | 
| 1451                        "deoptimization_data", code->deoptimization_data(), | 1447                        "deoptimization_data", code->deoptimization_data(), | 
| 1452                        Code::kDeoptimizationDataOffset); | 1448                        Code::kDeoptimizationDataOffset); | 
| 1453   TagObject(code->source_position_table(), "(source position table)"); | 1449   TagObject(code->source_position_table(), "(source position table)"); | 
| 1454   SetInternalReference(code, entry, "source_position_table", | 1450   SetInternalReference(code, entry, "source_position_table", | 
| 1455                        code->source_position_table(), | 1451                        code->source_position_table(), | 
| 1456                        Code::kSourcePositionTableOffset); | 1452                        Code::kSourcePositionTableOffset); | 
| 1457   if (code->kind() == Code::FUNCTION) { | 1453   if (code->kind() == Code::FUNCTION) { | 
| 1458     SetInternalReference(code, entry, | 1454     SetInternalReference(code, entry, "type_feedback_info", | 
| 1459                          "type_feedback_info", code->type_feedback_info(), | 1455                          code->type_feedback_info(), | 
| 1460                          Code::kTypeFeedbackInfoOffset); | 1456                          Code::kTypeFeedbackInfoOffset); | 
| 1461   } | 1457   } | 
| 1462   SetInternalReference(code, entry, | 1458   SetInternalReference(code, entry, "gc_metadata", code->gc_metadata(), | 
| 1463                        "gc_metadata", code->gc_metadata(), |  | 
| 1464                        Code::kGCMetadataOffset); | 1459                        Code::kGCMetadataOffset); | 
| 1465   if (code->kind() == Code::OPTIMIZED_FUNCTION) { |  | 
| 1466     SetWeakReference(code, entry, |  | 
| 1467                      "next_code_link", code->next_code_link(), |  | 
| 1468                      Code::kNextCodeLinkOffset); |  | 
| 1469   } |  | 
| 1470 } | 1460 } | 
| 1471 | 1461 | 
| 1472 void V8HeapExplorer::ExtractBoxReferences(int entry, Box* box) { | 1462 void V8HeapExplorer::ExtractBoxReferences(int entry, Box* box) { | 
| 1473   SetInternalReference(box, entry, "value", box->value(), Box::kValueOffset); | 1463   SetInternalReference(box, entry, "value", box->value(), Box::kValueOffset); | 
| 1474 } | 1464 } | 
| 1475 | 1465 | 
| 1476 void V8HeapExplorer::ExtractCellReferences(int entry, Cell* cell) { | 1466 void V8HeapExplorer::ExtractCellReferences(int entry, Cell* cell) { | 
| 1477   SetInternalReference(cell, entry, "value", cell->value(), Cell::kValueOffset); | 1467   SetInternalReference(cell, entry, "value", cell->value(), Cell::kValueOffset); | 
| 1478 } | 1468 } | 
| 1479 | 1469 | 
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1834          object != heap_->free_space_map() && | 1824          object != heap_->free_space_map() && | 
| 1835          object != heap_->one_pointer_filler_map() && | 1825          object != heap_->one_pointer_filler_map() && | 
| 1836          object != heap_->two_pointer_filler_map(); | 1826          object != heap_->two_pointer_filler_map(); | 
| 1837 } | 1827 } | 
| 1838 | 1828 | 
| 1839 bool V8HeapExplorer::IsEssentialHiddenReference(Object* parent, | 1829 bool V8HeapExplorer::IsEssentialHiddenReference(Object* parent, | 
| 1840                                                 int field_offset) { | 1830                                                 int field_offset) { | 
| 1841   if (parent->IsAllocationSite() && | 1831   if (parent->IsAllocationSite() && | 
| 1842       field_offset == AllocationSite::kWeakNextOffset) | 1832       field_offset == AllocationSite::kWeakNextOffset) | 
| 1843     return false; | 1833     return false; | 
|  | 1834   if (parent->IsJSFunction() && | 
|  | 1835       field_offset == JSFunction::kNextFunctionLinkOffset) | 
|  | 1836     return false; | 
|  | 1837   if (parent->IsCode() && field_offset == Code::kNextCodeLinkOffset) | 
|  | 1838     return false; | 
|  | 1839   if (parent->IsContext() && | 
|  | 1840       field_offset == Context::OffsetOfElementAt(Context::NEXT_CONTEXT_LINK)) | 
|  | 1841     return false; | 
| 1844   if (parent->IsWeakCell() && field_offset == WeakCell::kNextOffset) | 1842   if (parent->IsWeakCell() && field_offset == WeakCell::kNextOffset) | 
| 1845     return false; | 1843     return false; | 
| 1846   // TODO(ulan): JSFunction, Code, and Context also have next weak link, which |  | 
| 1847   // is non-essential. Currently they are handled as normal weak links. |  | 
| 1848   // Move them here. |  | 
| 1849   return true; | 1844   return true; | 
| 1850 } | 1845 } | 
| 1851 | 1846 | 
| 1852 void V8HeapExplorer::SetContextReference(HeapObject* parent_obj, | 1847 void V8HeapExplorer::SetContextReference(HeapObject* parent_obj, | 
| 1853                                          int parent_entry, | 1848                                          int parent_entry, | 
| 1854                                          String* reference_name, | 1849                                          String* reference_name, | 
| 1855                                          Object* child_obj, | 1850                                          Object* child_obj, | 
| 1856                                          int field_offset) { | 1851                                          int field_offset) { | 
| 1857   DCHECK(parent_entry == GetEntry(parent_obj)->index()); | 1852   DCHECK(parent_entry == GetEntry(parent_obj)->index()); | 
| 1858   HeapEntry* child_entry = GetEntry(child_obj); | 1853   HeapEntry* child_entry = GetEntry(child_obj); | 
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1937                                child_entry); | 1932                                child_entry); | 
| 1938   } | 1933   } | 
| 1939   MarkVisitedField(parent_obj, field_offset); | 1934   MarkVisitedField(parent_obj, field_offset); | 
| 1940 } | 1935 } | 
| 1941 | 1936 | 
| 1942 void V8HeapExplorer::SetHiddenReference(HeapObject* parent_obj, | 1937 void V8HeapExplorer::SetHiddenReference(HeapObject* parent_obj, | 
| 1943                                         int parent_entry, int index, | 1938                                         int parent_entry, int index, | 
| 1944                                         Object* child_obj, int field_offset) { | 1939                                         Object* child_obj, int field_offset) { | 
| 1945   DCHECK(parent_entry == GetEntry(parent_obj)->index()); | 1940   DCHECK(parent_entry == GetEntry(parent_obj)->index()); | 
| 1946   HeapEntry* child_entry = GetEntry(child_obj); | 1941   HeapEntry* child_entry = GetEntry(child_obj); | 
| 1947   if (child_entry != NULL && IsEssentialObject(child_obj) && | 1942   if (child_entry != nullptr && IsEssentialObject(child_obj) && | 
| 1948       IsEssentialHiddenReference(parent_obj, field_offset)) { | 1943       IsEssentialHiddenReference(parent_obj, field_offset)) { | 
| 1949     filler_->SetIndexedReference(HeapGraphEdge::kHidden, | 1944     filler_->SetIndexedReference(HeapGraphEdge::kHidden, parent_entry, index, | 
| 1950                                  parent_entry, |  | 
| 1951                                  index, |  | 
| 1952                                  child_entry); | 1945                                  child_entry); | 
| 1953   } | 1946   } | 
| 1954 } | 1947 } | 
| 1955 | 1948 | 
| 1956 | 1949 | 
| 1957 void V8HeapExplorer::SetWeakReference(HeapObject* parent_obj, | 1950 void V8HeapExplorer::SetWeakReference(HeapObject* parent_obj, | 
| 1958                                       int parent_entry, | 1951                                       int parent_entry, | 
| 1959                                       const char* reference_name, | 1952                                       const char* reference_name, | 
| 1960                                       Object* child_obj, | 1953                                       Object* child_obj, | 
| 1961                                       int field_offset) { | 1954                                       int field_offset) { | 
| (...skipping 1158 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 3120   for (int i = 1; i < sorted_strings.length(); ++i) { | 3113   for (int i = 1; i < sorted_strings.length(); ++i) { | 
| 3121     writer_->AddCharacter(','); | 3114     writer_->AddCharacter(','); | 
| 3122     SerializeString(sorted_strings[i]); | 3115     SerializeString(sorted_strings[i]); | 
| 3123     if (writer_->aborted()) return; | 3116     if (writer_->aborted()) return; | 
| 3124   } | 3117   } | 
| 3125 } | 3118 } | 
| 3126 | 3119 | 
| 3127 | 3120 | 
| 3128 }  // namespace internal | 3121 }  // namespace internal | 
| 3129 }  // namespace v8 | 3122 }  // namespace v8 | 
| OLD | NEW | 
|---|