| 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/profiler/allocation-tracker.h" | 10 #include "src/profiler/allocation-tracker.h" |
| (...skipping 977 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 988 class IndexedReferencesExtractor : public ObjectVisitor { | 988 class IndexedReferencesExtractor : public ObjectVisitor { |
| 989 public: | 989 public: |
| 990 IndexedReferencesExtractor(V8HeapExplorer* generator, | 990 IndexedReferencesExtractor(V8HeapExplorer* generator, |
| 991 HeapObject* parent_obj, | 991 HeapObject* parent_obj, |
| 992 int parent) | 992 int parent) |
| 993 : generator_(generator), | 993 : generator_(generator), |
| 994 parent_obj_(parent_obj), | 994 parent_obj_(parent_obj), |
| 995 parent_(parent), | 995 parent_(parent), |
| 996 next_index_(0) { | 996 next_index_(0) { |
| 997 } | 997 } |
| 998 void VisitCodeEntry(Address entry_address) { | 998 void VisitCodeEntry(Address entry_address) override { |
| 999 Code* code = Code::cast(Code::GetObjectFromEntryAddress(entry_address)); | 999 Code* code = Code::cast(Code::GetObjectFromEntryAddress(entry_address)); |
| 1000 generator_->SetInternalReference(parent_obj_, parent_, "code", code); | 1000 generator_->SetInternalReference(parent_obj_, parent_, "code", code); |
| 1001 generator_->TagCodeObject(code); | 1001 generator_->TagCodeObject(code); |
| 1002 } | 1002 } |
| 1003 void VisitPointers(Object** start, Object** end) { | 1003 void VisitPointers(Object** start, Object** end) override { |
| 1004 for (Object** p = start; p < end; p++) { | 1004 for (Object** p = start; p < end; p++) { |
| 1005 ++next_index_; | 1005 ++next_index_; |
| 1006 if (CheckVisitedAndUnmark(p)) continue; | 1006 if (CheckVisitedAndUnmark(p)) continue; |
| 1007 generator_->SetHiddenReference(parent_obj_, parent_, next_index_, *p); | 1007 generator_->SetHiddenReference(parent_obj_, parent_, next_index_, *p); |
| 1008 } | 1008 } |
| 1009 } | 1009 } |
| 1010 static void MarkVisitedField(HeapObject* obj, int offset) { | 1010 static void MarkVisitedField(HeapObject* obj, int offset) { |
| 1011 if (offset < 0) return; | 1011 if (offset < 0) return; |
| 1012 Address field = obj->address() + offset; | 1012 Address field = obj->address() + offset; |
| 1013 DCHECK(Memory::Object_at(field)->IsHeapObject()); | 1013 DCHECK(Memory::Object_at(field)->IsHeapObject()); |
| (...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1762 VisitorSynchronization::SyncTag tag; | 1762 VisitorSynchronization::SyncTag tag; |
| 1763 }; | 1763 }; |
| 1764 | 1764 |
| 1765 public: | 1765 public: |
| 1766 explicit RootsReferencesExtractor(Heap* heap) | 1766 explicit RootsReferencesExtractor(Heap* heap) |
| 1767 : collecting_all_references_(false), | 1767 : collecting_all_references_(false), |
| 1768 previous_reference_count_(0), | 1768 previous_reference_count_(0), |
| 1769 heap_(heap) { | 1769 heap_(heap) { |
| 1770 } | 1770 } |
| 1771 | 1771 |
| 1772 void VisitPointers(Object** start, Object** end) { | 1772 void VisitPointers(Object** start, Object** end) override { |
| 1773 if (collecting_all_references_) { | 1773 if (collecting_all_references_) { |
| 1774 for (Object** p = start; p < end; p++) all_references_.Add(*p); | 1774 for (Object** p = start; p < end; p++) all_references_.Add(*p); |
| 1775 } else { | 1775 } else { |
| 1776 for (Object** p = start; p < end; p++) strong_references_.Add(*p); | 1776 for (Object** p = start; p < end; p++) strong_references_.Add(*p); |
| 1777 } | 1777 } |
| 1778 } | 1778 } |
| 1779 | 1779 |
| 1780 void SetCollectingAllReferences() { collecting_all_references_ = true; } | 1780 void SetCollectingAllReferences() { collecting_all_references_ = true; } |
| 1781 | 1781 |
| 1782 void FillReferences(V8HeapExplorer* explorer) { | 1782 void FillReferences(V8HeapExplorer* explorer) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1795 explorer->TagBuiltinCodeObject( | 1795 explorer->TagBuiltinCodeObject( |
| 1796 Code::cast(all_references_[all_index]), | 1796 Code::cast(all_references_[all_index]), |
| 1797 builtins->name(builtin_index++)); | 1797 builtins->name(builtin_index++)); |
| 1798 } | 1798 } |
| 1799 ++all_index; | 1799 ++all_index; |
| 1800 if (is_strong) ++strong_index; | 1800 if (is_strong) ++strong_index; |
| 1801 if (reference_tags_[tags_index].index == all_index) ++tags_index; | 1801 if (reference_tags_[tags_index].index == all_index) ++tags_index; |
| 1802 } | 1802 } |
| 1803 } | 1803 } |
| 1804 | 1804 |
| 1805 void Synchronize(VisitorSynchronization::SyncTag tag) { | 1805 void Synchronize(VisitorSynchronization::SyncTag tag) override { |
| 1806 if (collecting_all_references_ && | 1806 if (collecting_all_references_ && |
| 1807 previous_reference_count_ != all_references_.length()) { | 1807 previous_reference_count_ != all_references_.length()) { |
| 1808 previous_reference_count_ = all_references_.length(); | 1808 previous_reference_count_ = all_references_.length(); |
| 1809 reference_tags_.Add(IndexTag(previous_reference_count_, tag)); | 1809 reference_tags_.Add(IndexTag(previous_reference_count_, tag)); |
| 1810 } | 1810 } |
| 1811 } | 1811 } |
| 1812 | 1812 |
| 1813 private: | 1813 private: |
| 1814 bool collecting_all_references_; | 1814 bool collecting_all_references_; |
| 1815 List<Object*> strong_references_; | 1815 List<Object*> strong_references_; |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2181 | 2181 |
| 2182 void V8HeapExplorer::MarkAsWeakContainer(Object* object) { | 2182 void V8HeapExplorer::MarkAsWeakContainer(Object* object) { |
| 2183 if (IsEssentialObject(object) && object->IsFixedArray()) { | 2183 if (IsEssentialObject(object) && object->IsFixedArray()) { |
| 2184 weak_containers_.Insert(object); | 2184 weak_containers_.Insert(object); |
| 2185 } | 2185 } |
| 2186 } | 2186 } |
| 2187 | 2187 |
| 2188 | 2188 |
| 2189 class GlobalObjectsEnumerator : public ObjectVisitor { | 2189 class GlobalObjectsEnumerator : public ObjectVisitor { |
| 2190 public: | 2190 public: |
| 2191 virtual void VisitPointers(Object** start, Object** end) { | 2191 void VisitPointers(Object** start, Object** end) override { |
| 2192 for (Object** p = start; p < end; p++) { | 2192 for (Object** p = start; p < end; p++) { |
| 2193 if ((*p)->IsNativeContext()) { | 2193 if ((*p)->IsNativeContext()) { |
| 2194 Context* context = Context::cast(*p); | 2194 Context* context = Context::cast(*p); |
| 2195 JSObject* proxy = context->global_proxy(); | 2195 JSObject* proxy = context->global_proxy(); |
| 2196 if (proxy->IsJSGlobalProxy()) { | 2196 if (proxy->IsJSGlobalProxy()) { |
| 2197 Object* global = proxy->map()->prototype(); | 2197 Object* global = proxy->map()->prototype(); |
| 2198 if (global->IsJSGlobalObject()) { | 2198 if (global->IsJSGlobalObject()) { |
| 2199 objects_.Add(Handle<JSGlobalObject>(JSGlobalObject::cast(global))); | 2199 objects_.Add(Handle<JSGlobalObject>(JSGlobalObject::cast(global))); |
| 2200 } | 2200 } |
| 2201 } | 2201 } |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2234 } | 2234 } |
| 2235 | 2235 |
| 2236 DeleteArray(urls); | 2236 DeleteArray(urls); |
| 2237 } | 2237 } |
| 2238 | 2238 |
| 2239 | 2239 |
| 2240 class GlobalHandlesExtractor : public ObjectVisitor { | 2240 class GlobalHandlesExtractor : public ObjectVisitor { |
| 2241 public: | 2241 public: |
| 2242 explicit GlobalHandlesExtractor(NativeObjectsExplorer* explorer) | 2242 explicit GlobalHandlesExtractor(NativeObjectsExplorer* explorer) |
| 2243 : explorer_(explorer) {} | 2243 : explorer_(explorer) {} |
| 2244 virtual ~GlobalHandlesExtractor() {} | 2244 ~GlobalHandlesExtractor() override {} |
| 2245 virtual void VisitPointers(Object** start, Object** end) { | 2245 void VisitPointers(Object** start, Object** end) override { UNREACHABLE(); } |
| 2246 UNREACHABLE(); | 2246 void VisitEmbedderReference(Object** p, uint16_t class_id) override { |
| 2247 } | |
| 2248 virtual void VisitEmbedderReference(Object** p, uint16_t class_id) { | |
| 2249 explorer_->VisitSubtreeWrapper(p, class_id); | 2247 explorer_->VisitSubtreeWrapper(p, class_id); |
| 2250 } | 2248 } |
| 2251 private: | 2249 private: |
| 2252 NativeObjectsExplorer* explorer_; | 2250 NativeObjectsExplorer* explorer_; |
| 2253 }; | 2251 }; |
| 2254 | 2252 |
| 2255 | 2253 |
| 2256 class BasicHeapEntriesAllocator : public HeapEntriesAllocator { | 2254 class BasicHeapEntriesAllocator : public HeapEntriesAllocator { |
| 2257 public: | 2255 public: |
| 2258 BasicHeapEntriesAllocator( | 2256 BasicHeapEntriesAllocator( |
| (...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3169 for (int i = 1; i < sorted_strings.length(); ++i) { | 3167 for (int i = 1; i < sorted_strings.length(); ++i) { |
| 3170 writer_->AddCharacter(','); | 3168 writer_->AddCharacter(','); |
| 3171 SerializeString(sorted_strings[i]); | 3169 SerializeString(sorted_strings[i]); |
| 3172 if (writer_->aborted()) return; | 3170 if (writer_->aborted()) return; |
| 3173 } | 3171 } |
| 3174 } | 3172 } |
| 3175 | 3173 |
| 3176 | 3174 |
| 3177 } // namespace internal | 3175 } // namespace internal |
| 3178 } // namespace v8 | 3176 } // namespace v8 |
| OLD | NEW |