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

Side by Side Diff: src/profiler/sampling-heap-profiler.h

Issue 1697903002: Sampling heap profiler data structure changes (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 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
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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 #ifndef V8_PROFILER_SAMPLING_HEAP_PROFILER_H_ 5 #ifndef V8_PROFILER_SAMPLING_HEAP_PROFILER_H_
6 #define V8_PROFILER_SAMPLING_HEAP_PROFILER_H_ 6 #define V8_PROFILER_SAMPLING_HEAP_PROFILER_H_
7 7
8 #include <deque> 8 #include <deque>
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 int get_script_id() const { return script_id_; } 62 int get_script_id() const { return script_id_; }
63 int get_start_position() const { return start_position_; } 63 int get_start_position() const { return start_position_; }
64 64
65 private: 65 private:
66 const char* const name_; 66 const char* const name_;
67 const char* script_name_; 67 const char* script_name_;
68 int script_id_; 68 int script_id_;
69 const int start_position_; 69 const int start_position_;
70 }; 70 };
71 71
72 class SampledAllocation { 72 class AllocationNode;
73
74 struct Sample {
75 size_t size;
76 AllocationNode* owner;
77 Global<Value>* global;
ofrobots 2016/02/14 23:57:42 It is more idiomatic to keep Globals (and Locals a
mattloring 2016/02/16 05:28:40 Globals are held by value now. How does DISALLOW_C
78 };
79
80 class AllocationNode {
73 public: 81 public:
74 SampledAllocation(SamplingHeapProfiler* sampling_heap_profiler, 82 explicit AllocationNode(FunctionInfo* info)
75 Isolate* isolate, Local<Value> local, size_t size, 83 : script_id_(info->get_script_id()),
76 int max_frames); 84 script_position_(info->get_start_position()),
77 ~SampledAllocation() { 85 name_(info->get_name()) {}
78 for (auto info : stack_) { 86 ~AllocationNode() {
79 delete info; 87 for (auto child : children_) {
88 delete child;
80 } 89 }
81 global_.Reset(); // drop the reference.
82 } 90 }
83 size_t get_size() const { return size_; }
84 const std::vector<FunctionInfo*>& get_stack() const { return stack_; }
85 91
86 private: 92 private:
87 static void OnWeakCallback(const WeakCallbackInfo<SampledAllocation>& data); 93 std::map<size_t, unsigned int> allocations_;
94 std::vector<AllocationNode*> children_;
95 int script_id_;
96 int script_position_;
97 const char* name_;
88 98
89 SamplingHeapProfiler* const sampling_heap_profiler_; 99 friend class SamplingHeapProfiler;
90 Global<Value> global_;
91 std::vector<FunctionInfo*> stack_;
92 const size_t size_;
93 100
94 DISALLOW_COPY_AND_ASSIGN(SampledAllocation); 101 DISALLOW_COPY_AND_ASSIGN(AllocationNode);
95 }; 102 };
96 103
97 private: 104 private:
98 Heap* heap() const { return heap_; } 105 Heap* heap() const { return heap_; }
99 106
100 void SampleObject(Address soon_object, size_t size); 107 void SampleObject(Address soon_object, size_t size);
101 108
109 static void OnWeakCallback(const WeakCallbackInfo<Sample>& data);
110
102 // Methods that construct v8::AllocationProfile. 111 // Methods that construct v8::AllocationProfile.
103 v8::AllocationProfile::Node* AddStack( 112 v8::AllocationProfile::Node* GenerateProfile(
104 AllocationProfile* profile, const std::map<int, Script*>& scripts, 113 AllocationProfile* profile, SamplingHeapProfiler::AllocationNode* node,
105 const std::vector<FunctionInfo*>& stack); 114 const std::map<int, Script*>& scripts);
106 v8::AllocationProfile::Node* FindOrAddChildNode( 115 AllocationNode* AddStack(const std::vector<FunctionInfo*>& stack);
107 AllocationProfile* profile, const std::map<int, Script*>& scripts, 116 std::vector<FunctionInfo*> CollectStack(int max_frames);
108 v8::AllocationProfile::Node* parent, FunctionInfo* function_info); 117 AllocationNode* FindOrAddChildNode(AllocationNode* parent,
109 v8::AllocationProfile::Node* AllocateNode( 118 FunctionInfo* function_info);
110 AllocationProfile* profile, const std::map<int, Script*>& scripts,
111 FunctionInfo* function_info);
112 119
113 Isolate* const isolate_; 120 Isolate* const isolate_;
114 Heap* const heap_; 121 Heap* const heap_;
115 base::SmartPointer<SamplingAllocationObserver> new_space_observer_; 122 base::SmartPointer<SamplingAllocationObserver> new_space_observer_;
116 base::SmartPointer<SamplingAllocationObserver> other_spaces_observer_; 123 base::SmartPointer<SamplingAllocationObserver> other_spaces_observer_;
117 StringsStorage* const names_; 124 StringsStorage* const names_;
118 std::set<SampledAllocation*> samples_; 125 AllocationNode* profile_root_;
119 const int stack_depth_; 126 const int stack_depth_;
120 127
121 friend class SamplingAllocationObserver; 128 friend class SamplingAllocationObserver;
122 }; 129 };
123 130
124 class SamplingAllocationObserver : public AllocationObserver { 131 class SamplingAllocationObserver : public AllocationObserver {
125 public: 132 public:
126 SamplingAllocationObserver(Heap* heap, intptr_t step_size, uint64_t rate, 133 SamplingAllocationObserver(Heap* heap, intptr_t step_size, uint64_t rate,
127 SamplingHeapProfiler* profiler, 134 SamplingHeapProfiler* profiler,
128 base::RandomNumberGenerator* random) 135 base::RandomNumberGenerator* random)
(...skipping 19 matching lines...) Expand all
148 SamplingHeapProfiler* const profiler_; 155 SamplingHeapProfiler* const profiler_;
149 Heap* const heap_; 156 Heap* const heap_;
150 base::RandomNumberGenerator* const random_; 157 base::RandomNumberGenerator* const random_;
151 uint64_t const rate_; 158 uint64_t const rate_;
152 }; 159 };
153 160
154 } // namespace internal 161 } // namespace internal
155 } // namespace v8 162 } // namespace v8
156 163
157 #endif // V8_PROFILER_SAMPLING_HEAP_PROFILER_H_ 164 #endif // V8_PROFILER_SAMPLING_HEAP_PROFILER_H_
OLDNEW
« no previous file with comments | « no previous file | src/profiler/sampling-heap-profiler.cc » ('j') | src/profiler/sampling-heap-profiler.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698