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

Side by Side Diff: src/profile-generator.h

Issue 1013143003: CpuProfiler: push the collected information about deopts to cpu profiler (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: comments addressed Created 5 years, 9 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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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_PROFILE_GENERATOR_H_ 5 #ifndef V8_PROFILE_GENERATOR_H_
6 #define V8_PROFILE_GENERATOR_H_ 6 #define V8_PROFILE_GENERATOR_H_
7 7
8 #include <map> 8 #include <map>
9 #include "include/v8-profiler.h" 9 #include "include/v8-profiler.h"
10 #include "src/allocation.h" 10 #include "src/allocation.h"
(...skipping 18 matching lines...) Expand all
29 29
30 bool empty() const { return pc_offset_map_.empty(); } 30 bool empty() const { return pc_offset_map_.empty(); }
31 31
32 private: 32 private:
33 // pc_offset -> source line 33 // pc_offset -> source line
34 typedef std::map<int, int> PcOffsetMap; 34 typedef std::map<int, int> PcOffsetMap;
35 PcOffsetMap pc_offset_map_; 35 PcOffsetMap pc_offset_map_;
36 DISALLOW_COPY_AND_ASSIGN(JITLineInfoTable); 36 DISALLOW_COPY_AND_ASSIGN(JITLineInfoTable);
37 }; 37 };
38 38
39
40 struct DeoptInfo {
41 const char* deopt_reason;
42 struct Frame {
43 int script_id;
44 int position;
45 };
46 std::vector<Frame> stack;
47 };
48
49
39 class CodeEntry { 50 class CodeEntry {
40 public: 51 public:
41 // CodeEntry doesn't own name strings, just references them. 52 // CodeEntry doesn't own name strings, just references them.
42 inline CodeEntry(Logger::LogEventsAndTags tag, const char* name, 53 inline CodeEntry(Logger::LogEventsAndTags tag, const char* name,
43 const char* name_prefix = CodeEntry::kEmptyNamePrefix, 54 const char* name_prefix = CodeEntry::kEmptyNamePrefix,
44 const char* resource_name = CodeEntry::kEmptyResourceName, 55 const char* resource_name = CodeEntry::kEmptyResourceName,
45 int line_number = v8::CpuProfileNode::kNoLineNumberInfo, 56 int line_number = v8::CpuProfileNode::kNoLineNumberInfo,
46 int column_number = v8::CpuProfileNode::kNoColumnNumberInfo, 57 int column_number = v8::CpuProfileNode::kNoColumnNumberInfo,
47 JITLineInfoTable* line_info = NULL, 58 JITLineInfoTable* line_info = NULL,
48 Address instruction_start = NULL); 59 Address instruction_start = NULL);
(...skipping 16 matching lines...) Expand all
65 } 76 }
66 const char* bailout_reason() const { return bailout_reason_; } 77 const char* bailout_reason() const { return bailout_reason_; }
67 78
68 void set_deopt_info(const char* deopt_reason, SourcePosition position, 79 void set_deopt_info(const char* deopt_reason, SourcePosition position,
69 size_t pc_offset) { 80 size_t pc_offset) {
70 DCHECK(deopt_position_.IsUnknown()); 81 DCHECK(deopt_position_.IsUnknown());
71 deopt_reason_ = deopt_reason; 82 deopt_reason_ = deopt_reason;
72 deopt_position_ = position; 83 deopt_position_ = position;
73 pc_offset_ = pc_offset; 84 pc_offset_ = pc_offset;
74 } 85 }
86 DeoptInfo* GetDeoptInfo();
75 const char* deopt_reason() const { return deopt_reason_; } 87 const char* deopt_reason() const { return deopt_reason_; }
76 SourcePosition deopt_position() const { return deopt_position_; } 88 SourcePosition deopt_position() const { return deopt_position_; }
77 bool has_deopt_info() const { return !deopt_position_.IsUnknown(); } 89 bool has_deopt_info() const { return !deopt_position_.IsUnknown(); }
78 void clear_deopt_info() { 90 void clear_deopt_info() {
79 deopt_reason_ = kNoDeoptReason; 91 deopt_reason_ = kNoDeoptReason;
80 deopt_position_ = SourcePosition::Unknown(); 92 deopt_position_ = SourcePosition::Unknown();
81 } 93 }
82 94
83 void FillFunctionInfo(SharedFunctionInfo* shared); 95 void FillFunctionInfo(SharedFunctionInfo* shared);
84 96
85 static inline bool is_js_function_tag(Logger::LogEventsAndTags tag); 97 static inline bool is_js_function_tag(Logger::LogEventsAndTags tag);
86 98
87 List<OffsetRange>* no_frame_ranges() const { return no_frame_ranges_; } 99 List<OffsetRange>* no_frame_ranges() const { return no_frame_ranges_; }
88 void set_no_frame_ranges(List<OffsetRange>* ranges) { 100 void set_no_frame_ranges(List<OffsetRange>* ranges) {
89 no_frame_ranges_ = ranges; 101 no_frame_ranges_ = ranges;
90 } 102 }
103 void set_inlined_function_infos(std::vector<InlinedFunctionInfo>* infos) {
104 DCHECK(!inlined_function_infos_);
105 inlined_function_infos_ = infos;
106 }
107 std::vector<InlinedFunctionInfo>* ReleaseInlinedFunctionInfos() {
108 std::vector<InlinedFunctionInfo>* tmp = inlined_function_infos_;
109 inlined_function_infos_ = NULL;
110 return tmp;
111 }
91 112
92 void SetBuiltinId(Builtins::Name id); 113 void SetBuiltinId(Builtins::Name id);
93 Builtins::Name builtin_id() const { 114 Builtins::Name builtin_id() const {
94 return BuiltinIdField::decode(bit_field_); 115 return BuiltinIdField::decode(bit_field_);
95 } 116 }
96 117
97 uint32_t GetHash() const; 118 uint32_t GetHash() const;
98 bool IsSameFunctionAs(CodeEntry* entry) const; 119 bool IsSameFunctionAs(CodeEntry* entry) const;
99 120
100 int GetSourceLine(int pc_offset) const; 121 int GetSourceLine(int pc_offset) const;
(...skipping 19 matching lines...) Expand all
120 int script_id_; 141 int script_id_;
121 int position_; 142 int position_;
122 List<OffsetRange>* no_frame_ranges_; 143 List<OffsetRange>* no_frame_ranges_;
123 const char* bailout_reason_; 144 const char* bailout_reason_;
124 const char* deopt_reason_; 145 const char* deopt_reason_;
125 SourcePosition deopt_position_; 146 SourcePosition deopt_position_;
126 size_t pc_offset_; 147 size_t pc_offset_;
127 JITLineInfoTable* line_info_; 148 JITLineInfoTable* line_info_;
128 Address instruction_start_; 149 Address instruction_start_;
129 150
151 std::vector<InlinedFunctionInfo>* inlined_function_infos_;
152
130 DISALLOW_COPY_AND_ASSIGN(CodeEntry); 153 DISALLOW_COPY_AND_ASSIGN(CodeEntry);
131 }; 154 };
132 155
133 156
134 class ProfileTree; 157 class ProfileTree;
135 158
136 class ProfileNode { 159 class ProfileNode {
137 private:
138 struct DeoptInfo {
139 DeoptInfo(const char* deopt_reason, SourcePosition deopt_position)
140 : deopt_reason(deopt_reason), deopt_position(deopt_position) {}
141 DeoptInfo(const DeoptInfo& info)
142 : deopt_reason(info.deopt_reason),
143 deopt_position(info.deopt_position) {}
144 const char* deopt_reason;
145 SourcePosition deopt_position;
146 };
147
148 public: 160 public:
149 inline ProfileNode(ProfileTree* tree, CodeEntry* entry); 161 inline ProfileNode(ProfileTree* tree, CodeEntry* entry);
162 ~ProfileNode();
150 163
151 ProfileNode* FindChild(CodeEntry* entry); 164 ProfileNode* FindChild(CodeEntry* entry);
152 ProfileNode* FindOrAddChild(CodeEntry* entry); 165 ProfileNode* FindOrAddChild(CodeEntry* entry);
153 void IncrementSelfTicks() { ++self_ticks_; } 166 void IncrementSelfTicks() { ++self_ticks_; }
154 void IncreaseSelfTicks(unsigned amount) { self_ticks_ += amount; } 167 void IncreaseSelfTicks(unsigned amount) { self_ticks_ += amount; }
155 void IncrementLineTicks(int src_line); 168 void IncrementLineTicks(int src_line);
156 169
157 CodeEntry* entry() const { return entry_; } 170 CodeEntry* entry() const { return entry_; }
158 unsigned self_ticks() const { return self_ticks_; } 171 unsigned self_ticks() const { return self_ticks_; }
159 const List<ProfileNode*>* children() const { return &children_list_; } 172 const List<ProfileNode*>* children() const { return &children_list_; }
160 unsigned id() const { return id_; } 173 unsigned id() const { return id_; }
161 unsigned function_id() const; 174 unsigned function_id() const;
162 unsigned int GetHitLineCount() const { return line_ticks_.occupancy(); } 175 unsigned int GetHitLineCount() const { return line_ticks_.occupancy(); }
163 bool GetLineTicks(v8::CpuProfileNode::LineTick* entries, 176 bool GetLineTicks(v8::CpuProfileNode::LineTick* entries,
164 unsigned int length) const; 177 unsigned int length) const;
165 void CollectDeoptInfo(CodeEntry* entry); 178 void CollectDeoptInfo(CodeEntry* entry);
166 const List<DeoptInfo>& deopt_infos() const { return deopt_infos_; } 179 const std::vector<DeoptInfo*>& deopt_infos() const { return deopt_infos_; }
167 180
168 void Print(int indent); 181 void Print(int indent);
169 182
170 static bool CodeEntriesMatch(void* entry1, void* entry2) { 183 static bool CodeEntriesMatch(void* entry1, void* entry2) {
171 return reinterpret_cast<CodeEntry*>(entry1) 184 return reinterpret_cast<CodeEntry*>(entry1)
172 ->IsSameFunctionAs(reinterpret_cast<CodeEntry*>(entry2)); 185 ->IsSameFunctionAs(reinterpret_cast<CodeEntry*>(entry2));
173 } 186 }
174 187
175 private: 188 private:
176 static uint32_t CodeEntryHash(CodeEntry* entry) { return entry->GetHash(); } 189 static uint32_t CodeEntryHash(CodeEntry* entry) { return entry->GetHash(); }
177 190
178 static bool LineTickMatch(void* a, void* b) { return a == b; } 191 static bool LineTickMatch(void* a, void* b) { return a == b; }
179 192
180 ProfileTree* tree_; 193 ProfileTree* tree_;
181 CodeEntry* entry_; 194 CodeEntry* entry_;
182 unsigned self_ticks_; 195 unsigned self_ticks_;
183 // Mapping from CodeEntry* to ProfileNode* 196 // Mapping from CodeEntry* to ProfileNode*
184 HashMap children_; 197 HashMap children_;
185 List<ProfileNode*> children_list_; 198 List<ProfileNode*> children_list_;
186 unsigned id_; 199 unsigned id_;
187 HashMap line_ticks_; 200 HashMap line_ticks_;
188 201
189 List<DeoptInfo> deopt_infos_; 202 std::vector<DeoptInfo*> deopt_infos_;
203
190 DISALLOW_COPY_AND_ASSIGN(ProfileNode); 204 DISALLOW_COPY_AND_ASSIGN(ProfileNode);
191 }; 205 };
192 206
193 207
194 class ProfileTree { 208 class ProfileTree {
195 public: 209 public:
196 ProfileTree(); 210 ProfileTree();
197 ~ProfileTree(); 211 ~ProfileTree();
198 212
199 ProfileNode* AddPathFromEnd( 213 ProfileNode* AddPathFromEnd(
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 CodeEntry* gc_entry_; 392 CodeEntry* gc_entry_;
379 CodeEntry* unresolved_entry_; 393 CodeEntry* unresolved_entry_;
380 394
381 DISALLOW_COPY_AND_ASSIGN(ProfileGenerator); 395 DISALLOW_COPY_AND_ASSIGN(ProfileGenerator);
382 }; 396 };
383 397
384 398
385 } } // namespace v8::internal 399 } } // namespace v8::internal
386 400
387 #endif // V8_PROFILE_GENERATOR_H_ 401 #endif // V8_PROFILE_GENERATOR_H_
OLDNEW
« src/compiler.cc ('K') | « src/hydrogen.cc ('k') | src/profile-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698