| 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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 if (len == -1) { | 147 if (len == -1) { |
| 148 DeleteArray(str.start()); | 148 DeleteArray(str.start()); |
| 149 return format; | 149 return format; |
| 150 } | 150 } |
| 151 uint32_t hash = StringHasher::HashSequentialString( | 151 uint32_t hash = StringHasher::HashSequentialString( |
| 152 str.start(), len, HEAP->HashSeed()); | 152 str.start(), len, HEAP->HashSeed()); |
| 153 return AddOrDisposeString(str.start(), hash); | 153 return AddOrDisposeString(str.start(), hash); |
| 154 } | 154 } |
| 155 | 155 |
| 156 | 156 |
| 157 const char* StringsStorage::GetName(String* name) { | 157 const char* StringsStorage::GetName(Name* name) { |
| 158 if (name->IsString()) { | 158 if (name->IsString()) { |
| 159 int length = Min(kMaxNameSize, name->length()); | 159 String* str = String::cast(name); |
| 160 int length = Min(kMaxNameSize, str->length()); |
| 160 SmartArrayPointer<char> data = | 161 SmartArrayPointer<char> data = |
| 161 name->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL, 0, length); | 162 str->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL, 0, length); |
| 162 uint32_t hash = StringHasher::HashSequentialString( | 163 uint32_t hash = StringHasher::HashSequentialString( |
| 163 *data, length, name->GetHeap()->HashSeed()); | 164 *data, length, name->GetHeap()->HashSeed()); |
| 164 return AddOrDisposeString(data.Detach(), hash); | 165 return AddOrDisposeString(data.Detach(), hash); |
| 166 } else if (name->IsSymbol()) { |
| 167 return "<symbol>"; |
| 165 } | 168 } |
| 166 return ""; | 169 return ""; |
| 167 } | 170 } |
| 168 | 171 |
| 169 | 172 |
| 170 const char* StringsStorage::GetName(int index) { | 173 const char* StringsStorage::GetName(int index) { |
| 171 return GetFormatted("%d", index); | 174 return GetFormatted("%d", index); |
| 172 } | 175 } |
| 173 | 176 |
| 174 | 177 |
| (...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 776 for (int i = 0; i < current_count; ++i) { | 779 for (int i = 0; i < current_count; ++i) { |
| 777 if (list->at(i) == NULL) { | 780 if (list->at(i) == NULL) { |
| 778 (*list)[i] = unabridged_list->at(i)->FilteredClone(security_token_id); | 781 (*list)[i] = unabridged_list->at(i)->FilteredClone(security_token_id); |
| 779 } | 782 } |
| 780 } | 783 } |
| 781 return list; | 784 return list; |
| 782 } | 785 } |
| 783 | 786 |
| 784 | 787 |
| 785 CodeEntry* CpuProfilesCollection::NewCodeEntry(Logger::LogEventsAndTags tag, | 788 CodeEntry* CpuProfilesCollection::NewCodeEntry(Logger::LogEventsAndTags tag, |
| 786 String* name, | 789 Name* name, |
| 787 String* resource_name, | 790 String* resource_name, |
| 788 int line_number) { | 791 int line_number) { |
| 789 CodeEntry* entry = new CodeEntry(tag, | 792 CodeEntry* entry = new CodeEntry(tag, |
| 790 CodeEntry::kEmptyNamePrefix, | 793 CodeEntry::kEmptyNamePrefix, |
| 791 GetFunctionName(name), | 794 GetFunctionName(name), |
| 792 GetName(resource_name), | 795 GetName(resource_name), |
| 793 line_number, | 796 line_number, |
| 794 TokenEnumerator::kNoSecurityToken); | 797 TokenEnumerator::kNoSecurityToken); |
| 795 code_entries_.Add(entry); | 798 code_entries_.Add(entry); |
| 796 return entry; | 799 return entry; |
| 797 } | 800 } |
| 798 | 801 |
| 799 | 802 |
| 800 CodeEntry* CpuProfilesCollection::NewCodeEntry(Logger::LogEventsAndTags tag, | 803 CodeEntry* CpuProfilesCollection::NewCodeEntry(Logger::LogEventsAndTags tag, |
| 801 const char* name) { | 804 const char* name) { |
| 802 CodeEntry* entry = new CodeEntry(tag, | 805 CodeEntry* entry = new CodeEntry(tag, |
| 803 CodeEntry::kEmptyNamePrefix, | 806 CodeEntry::kEmptyNamePrefix, |
| 804 GetFunctionName(name), | 807 GetFunctionName(name), |
| 805 "", | 808 "", |
| 806 v8::CpuProfileNode::kNoLineNumberInfo, | 809 v8::CpuProfileNode::kNoLineNumberInfo, |
| 807 TokenEnumerator::kNoSecurityToken); | 810 TokenEnumerator::kNoSecurityToken); |
| 808 code_entries_.Add(entry); | 811 code_entries_.Add(entry); |
| 809 return entry; | 812 return entry; |
| 810 } | 813 } |
| 811 | 814 |
| 812 | 815 |
| 813 CodeEntry* CpuProfilesCollection::NewCodeEntry(Logger::LogEventsAndTags tag, | 816 CodeEntry* CpuProfilesCollection::NewCodeEntry(Logger::LogEventsAndTags tag, |
| 814 const char* name_prefix, | 817 const char* name_prefix, |
| 815 String* name) { | 818 Name* name) { |
| 816 CodeEntry* entry = new CodeEntry(tag, | 819 CodeEntry* entry = new CodeEntry(tag, |
| 817 name_prefix, | 820 name_prefix, |
| 818 GetName(name), | 821 GetName(name), |
| 819 "", | 822 "", |
| 820 v8::CpuProfileNode::kNoLineNumberInfo, | 823 v8::CpuProfileNode::kNoLineNumberInfo, |
| 821 TokenEnumerator::kInheritsSecurityToken); | 824 TokenEnumerator::kInheritsSecurityToken); |
| 822 code_entries_.Add(entry); | 825 code_entries_.Add(entry); |
| 823 return entry; | 826 return entry; |
| 824 } | 827 } |
| 825 | 828 |
| (...skipping 1380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2206 void V8HeapExplorer::ExtractPropertyReferences(JSObject* js_obj, int entry) { | 2209 void V8HeapExplorer::ExtractPropertyReferences(JSObject* js_obj, int entry) { |
| 2207 if (js_obj->HasFastProperties()) { | 2210 if (js_obj->HasFastProperties()) { |
| 2208 DescriptorArray* descs = js_obj->map()->instance_descriptors(); | 2211 DescriptorArray* descs = js_obj->map()->instance_descriptors(); |
| 2209 int real_size = js_obj->map()->NumberOfOwnDescriptors(); | 2212 int real_size = js_obj->map()->NumberOfOwnDescriptors(); |
| 2210 for (int i = 0; i < descs->number_of_descriptors(); i++) { | 2213 for (int i = 0; i < descs->number_of_descriptors(); i++) { |
| 2211 if (descs->GetDetails(i).descriptor_index() > real_size) continue; | 2214 if (descs->GetDetails(i).descriptor_index() > real_size) continue; |
| 2212 switch (descs->GetType(i)) { | 2215 switch (descs->GetType(i)) { |
| 2213 case FIELD: { | 2216 case FIELD: { |
| 2214 int index = descs->GetFieldIndex(i); | 2217 int index = descs->GetFieldIndex(i); |
| 2215 | 2218 |
| 2216 String* k = descs->GetKey(i); | 2219 Name* k = descs->GetKey(i); |
| 2217 if (index < js_obj->map()->inobject_properties()) { | 2220 if (index < js_obj->map()->inobject_properties()) { |
| 2218 Object* value = js_obj->InObjectPropertyAt(index); | 2221 Object* value = js_obj->InObjectPropertyAt(index); |
| 2219 if (k != heap_->hidden_string()) { | 2222 if (k != heap_->hidden_string()) { |
| 2220 SetPropertyReference( | 2223 SetPropertyReference( |
| 2221 js_obj, entry, | 2224 js_obj, entry, |
| 2222 k, value, | 2225 k, value, |
| 2223 NULL, | 2226 NULL, |
| 2224 js_obj->GetInObjectPropertyOffset(index)); | 2227 js_obj->GetInObjectPropertyOffset(index)); |
| 2225 } else { | 2228 } else { |
| 2226 TagObject(value, "(hidden properties)"); | 2229 TagObject(value, "(hidden properties)"); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2264 case HANDLER: // only in lookup results, not in descriptors | 2267 case HANDLER: // only in lookup results, not in descriptors |
| 2265 case INTERCEPTOR: // only in lookup results, not in descriptors | 2268 case INTERCEPTOR: // only in lookup results, not in descriptors |
| 2266 break; | 2269 break; |
| 2267 case TRANSITION: | 2270 case TRANSITION: |
| 2268 case NONEXISTENT: | 2271 case NONEXISTENT: |
| 2269 UNREACHABLE(); | 2272 UNREACHABLE(); |
| 2270 break; | 2273 break; |
| 2271 } | 2274 } |
| 2272 } | 2275 } |
| 2273 } else { | 2276 } else { |
| 2274 StringDictionary* dictionary = js_obj->property_dictionary(); | 2277 NameDictionary* dictionary = js_obj->property_dictionary(); |
| 2275 int length = dictionary->Capacity(); | 2278 int length = dictionary->Capacity(); |
| 2276 for (int i = 0; i < length; ++i) { | 2279 for (int i = 0; i < length; ++i) { |
| 2277 Object* k = dictionary->KeyAt(i); | 2280 Object* k = dictionary->KeyAt(i); |
| 2278 if (dictionary->IsKey(k)) { | 2281 if (dictionary->IsKey(k)) { |
| 2279 Object* target = dictionary->ValueAt(i); | 2282 Object* target = dictionary->ValueAt(i); |
| 2280 // We assume that global objects can only have slow properties. | 2283 // We assume that global objects can only have slow properties. |
| 2281 Object* value = target->IsJSGlobalPropertyCell() | 2284 Object* value = target->IsJSGlobalPropertyCell() |
| 2282 ? JSGlobalPropertyCell::cast(target)->value() | 2285 ? JSGlobalPropertyCell::cast(target)->value() |
| 2283 : target; | 2286 : target; |
| 2284 if (k != heap_->hidden_string()) { | 2287 if (k != heap_->hidden_string()) { |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2574 parent_entry, | 2577 parent_entry, |
| 2575 index, | 2578 index, |
| 2576 child_entry); | 2579 child_entry); |
| 2577 IndexedReferencesExtractor::MarkVisitedField(parent_obj, field_offset); | 2580 IndexedReferencesExtractor::MarkVisitedField(parent_obj, field_offset); |
| 2578 } | 2581 } |
| 2579 } | 2582 } |
| 2580 | 2583 |
| 2581 | 2584 |
| 2582 void V8HeapExplorer::SetPropertyReference(HeapObject* parent_obj, | 2585 void V8HeapExplorer::SetPropertyReference(HeapObject* parent_obj, |
| 2583 int parent_entry, | 2586 int parent_entry, |
| 2584 String* reference_name, | 2587 Name* reference_name, |
| 2585 Object* child_obj, | 2588 Object* child_obj, |
| 2586 const char* name_format_string, | 2589 const char* name_format_string, |
| 2587 int field_offset) { | 2590 int field_offset) { |
| 2588 HeapEntry* child_entry = GetEntry(child_obj); | 2591 HeapEntry* child_entry = GetEntry(child_obj); |
| 2589 if (child_entry != NULL) { | 2592 if (child_entry != NULL) { |
| 2590 HeapGraphEdge::Type type = reference_name->length() > 0 ? | 2593 HeapGraphEdge::Type type = |
| 2591 HeapGraphEdge::kProperty : HeapGraphEdge::kInternal; | 2594 reference_name->IsSymbol() || String::cast(reference_name)->length() > 0 |
| 2592 const char* name = name_format_string != NULL ? | 2595 ? HeapGraphEdge::kProperty : HeapGraphEdge::kInternal; |
| 2593 collection_->names()->GetFormatted( | 2596 const char* name = name_format_string != NULL && reference_name->IsString() |
| 2594 name_format_string, | 2597 ? collection_->names()->GetFormatted( |
| 2595 *reference_name->ToCString(DISALLOW_NULLS, | 2598 name_format_string, |
| 2596 ROBUST_STRING_TRAVERSAL)) : | 2599 *String::cast(reference_name)->ToCString( |
| 2597 collection_->names()->GetName(reference_name); | 2600 DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL)) |
| 2601 : collection_->names()->GetName(reference_name); |
| 2598 | 2602 |
| 2599 filler_->SetNamedReference(type, | 2603 filler_->SetNamedReference(type, |
| 2600 parent_entry, | 2604 parent_entry, |
| 2601 name, | 2605 name, |
| 2602 child_entry); | 2606 child_entry); |
| 2603 IndexedReferencesExtractor::MarkVisitedField(parent_obj, field_offset); | 2607 IndexedReferencesExtractor::MarkVisitedField(parent_obj, field_offset); |
| 2604 } | 2608 } |
| 2605 } | 2609 } |
| 2606 | 2610 |
| 2607 | 2611 |
| (...skipping 977 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3585 | 3589 |
| 3586 | 3590 |
| 3587 void HeapSnapshotJSONSerializer::SortHashMap( | 3591 void HeapSnapshotJSONSerializer::SortHashMap( |
| 3588 HashMap* map, List<HashMap::Entry*>* sorted_entries) { | 3592 HashMap* map, List<HashMap::Entry*>* sorted_entries) { |
| 3589 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) | 3593 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) |
| 3590 sorted_entries->Add(p); | 3594 sorted_entries->Add(p); |
| 3591 sorted_entries->Sort(SortUsingEntryValue); | 3595 sorted_entries->Sort(SortUsingEntryValue); |
| 3592 } | 3596 } |
| 3593 | 3597 |
| 3594 } } // namespace v8::internal | 3598 } } // namespace v8::internal |
| OLD | NEW |