| 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 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 697 return id << 1; | 697 return id << 1; |
| 698 } | 698 } |
| 699 | 699 |
| 700 | 700 |
| 701 size_t HeapObjectsMap::GetUsedMemorySize() const { | 701 size_t HeapObjectsMap::GetUsedMemorySize() const { |
| 702 return sizeof(*this) + | 702 return sizeof(*this) + |
| 703 sizeof(base::HashMap::Entry) * entries_map_.capacity() + | 703 sizeof(base::HashMap::Entry) * entries_map_.capacity() + |
| 704 GetMemoryUsedByList(entries_) + GetMemoryUsedByList(time_intervals_); | 704 GetMemoryUsedByList(entries_) + GetMemoryUsedByList(time_intervals_); |
| 705 } | 705 } |
| 706 | 706 |
| 707 HeapEntriesMap::HeapEntriesMap() : entries_(base::HashMap::PointersMatch) {} | 707 HeapEntriesMap::HeapEntriesMap() : entries_() {} |
| 708 | 708 |
| 709 int HeapEntriesMap::Map(HeapThing thing) { | 709 int HeapEntriesMap::Map(HeapThing thing) { |
| 710 base::HashMap::Entry* cache_entry = entries_.Lookup(thing, Hash(thing)); | 710 base::HashMap::Entry* cache_entry = entries_.Lookup(thing, Hash(thing)); |
| 711 if (cache_entry == NULL) return HeapEntry::kNoEntry; | 711 if (cache_entry == NULL) return HeapEntry::kNoEntry; |
| 712 return static_cast<int>(reinterpret_cast<intptr_t>(cache_entry->value)); | 712 return static_cast<int>(reinterpret_cast<intptr_t>(cache_entry->value)); |
| 713 } | 713 } |
| 714 | 714 |
| 715 | 715 |
| 716 void HeapEntriesMap::Pair(HeapThing thing, int entry) { | 716 void HeapEntriesMap::Pair(HeapThing thing, int entry) { |
| 717 base::HashMap::Entry* cache_entry = | 717 base::HashMap::Entry* cache_entry = |
| 718 entries_.LookupOrInsert(thing, Hash(thing)); | 718 entries_.LookupOrInsert(thing, Hash(thing)); |
| 719 DCHECK(cache_entry->value == NULL); | 719 DCHECK(cache_entry->value == NULL); |
| 720 cache_entry->value = reinterpret_cast<void*>(static_cast<intptr_t>(entry)); | 720 cache_entry->value = reinterpret_cast<void*>(static_cast<intptr_t>(entry)); |
| 721 } | 721 } |
| 722 | 722 |
| 723 HeapObjectsSet::HeapObjectsSet() : entries_(base::HashMap::PointersMatch) {} | 723 HeapObjectsSet::HeapObjectsSet() : entries_() {} |
| 724 | 724 |
| 725 void HeapObjectsSet::Clear() { | 725 void HeapObjectsSet::Clear() { |
| 726 entries_.Clear(); | 726 entries_.Clear(); |
| 727 } | 727 } |
| 728 | 728 |
| 729 | 729 |
| 730 bool HeapObjectsSet::Contains(Object* obj) { | 730 bool HeapObjectsSet::Contains(Object* obj) { |
| 731 if (!obj->IsHeapObject()) return false; | 731 if (!obj->IsHeapObject()) return false; |
| 732 HeapObject* object = HeapObject::cast(obj); | 732 HeapObject* object = HeapObject::cast(obj); |
| 733 return entries_.Lookup(object, HeapEntriesMap::Hash(object)) != NULL; | 733 return entries_.Lookup(object, HeapEntriesMap::Hash(object)) != NULL; |
| (...skipping 2388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3122 for (int i = 1; i < sorted_strings.length(); ++i) { | 3122 for (int i = 1; i < sorted_strings.length(); ++i) { |
| 3123 writer_->AddCharacter(','); | 3123 writer_->AddCharacter(','); |
| 3124 SerializeString(sorted_strings[i]); | 3124 SerializeString(sorted_strings[i]); |
| 3125 if (writer_->aborted()) return; | 3125 if (writer_->aborted()) return; |
| 3126 } | 3126 } |
| 3127 } | 3127 } |
| 3128 | 3128 |
| 3129 | 3129 |
| 3130 } // namespace internal | 3130 } // namespace internal |
| 3131 } // namespace v8 | 3131 } // namespace v8 |
| OLD | NEW |