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

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(
104 const std::vector<InlinedFunctionInfo>& infos) {
105 inlined_function_infos_ = infos;
106 }
107 const std::vector<InlinedFunctionInfo> inlined_function_infos() {
108 return inlined_function_infos_;
109 }
91 110
92 void SetBuiltinId(Builtins::Name id); 111 void SetBuiltinId(Builtins::Name id);
93 Builtins::Name builtin_id() const { 112 Builtins::Name builtin_id() const {
94 return BuiltinIdField::decode(bit_field_); 113 return BuiltinIdField::decode(bit_field_);
95 } 114 }
96 115
97 uint32_t GetHash() const; 116 uint32_t GetHash() const;
98 bool IsSameFunctionAs(CodeEntry* entry) const; 117 bool IsSameFunctionAs(CodeEntry* entry) const;
99 118
100 int GetSourceLine(int pc_offset) const; 119 int GetSourceLine(int pc_offset) const;
(...skipping 19 matching lines...) Expand all
120 int script_id_; 139 int script_id_;
121 int position_; 140 int position_;
122 List<OffsetRange>* no_frame_ranges_; 141 List<OffsetRange>* no_frame_ranges_;
123 const char* bailout_reason_; 142 const char* bailout_reason_;
124 const char* deopt_reason_; 143 const char* deopt_reason_;
125 SourcePosition deopt_position_; 144 SourcePosition deopt_position_;
126 size_t pc_offset_; 145 size_t pc_offset_;
127 JITLineInfoTable* line_info_; 146 JITLineInfoTable* line_info_;
128 Address instruction_start_; 147 Address instruction_start_;
129 148
149 std::vector<InlinedFunctionInfo> inlined_function_infos_;
150
130 DISALLOW_COPY_AND_ASSIGN(CodeEntry); 151 DISALLOW_COPY_AND_ASSIGN(CodeEntry);
131 }; 152 };
132 153
133 154
134 class ProfileTree; 155 class ProfileTree;
135 156
136 class ProfileNode { 157 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: 158 public:
149 inline ProfileNode(ProfileTree* tree, CodeEntry* entry); 159 inline ProfileNode(ProfileTree* tree, CodeEntry* entry);
150 160
151 ProfileNode* FindChild(CodeEntry* entry); 161 ProfileNode* FindChild(CodeEntry* entry);
152 ProfileNode* FindOrAddChild(CodeEntry* entry); 162 ProfileNode* FindOrAddChild(CodeEntry* entry);
153 void IncrementSelfTicks() { ++self_ticks_; } 163 void IncrementSelfTicks() { ++self_ticks_; }
154 void IncreaseSelfTicks(unsigned amount) { self_ticks_ += amount; } 164 void IncreaseSelfTicks(unsigned amount) { self_ticks_ += amount; }
155 void IncrementLineTicks(int src_line); 165 void IncrementLineTicks(int src_line);
156 166
157 CodeEntry* entry() const { return entry_; } 167 CodeEntry* entry() const { return entry_; }
158 unsigned self_ticks() const { return self_ticks_; } 168 unsigned self_ticks() const { return self_ticks_; }
159 const List<ProfileNode*>* children() const { return &children_list_; } 169 const List<ProfileNode*>* children() const { return &children_list_; }
160 unsigned id() const { return id_; } 170 unsigned id() const { return id_; }
161 unsigned function_id() const; 171 unsigned function_id() const;
162 unsigned int GetHitLineCount() const { return line_ticks_.occupancy(); } 172 unsigned int GetHitLineCount() const { return line_ticks_.occupancy(); }
163 bool GetLineTicks(v8::CpuProfileNode::LineTick* entries, 173 bool GetLineTicks(v8::CpuProfileNode::LineTick* entries,
164 unsigned int length) const; 174 unsigned int length) const;
165 void CollectDeoptInfo(CodeEntry* entry); 175 void CollectDeoptInfo(CodeEntry* entry);
166 const List<DeoptInfo>& deopt_infos() const { return deopt_infos_; } 176 const std::vector<DeoptInfo>& deopt_infos() const { return deopt_infos_; }
167 177
168 void Print(int indent); 178 void Print(int indent);
169 179
170 static bool CodeEntriesMatch(void* entry1, void* entry2) { 180 static bool CodeEntriesMatch(void* entry1, void* entry2) {
171 return reinterpret_cast<CodeEntry*>(entry1) 181 return reinterpret_cast<CodeEntry*>(entry1)
172 ->IsSameFunctionAs(reinterpret_cast<CodeEntry*>(entry2)); 182 ->IsSameFunctionAs(reinterpret_cast<CodeEntry*>(entry2));
173 } 183 }
174 184
175 private: 185 private:
176 static uint32_t CodeEntryHash(CodeEntry* entry) { return entry->GetHash(); } 186 static uint32_t CodeEntryHash(CodeEntry* entry) { return entry->GetHash(); }
177 187
178 static bool LineTickMatch(void* a, void* b) { return a == b; } 188 static bool LineTickMatch(void* a, void* b) { return a == b; }
179 189
180 ProfileTree* tree_; 190 ProfileTree* tree_;
181 CodeEntry* entry_; 191 CodeEntry* entry_;
182 unsigned self_ticks_; 192 unsigned self_ticks_;
183 // Mapping from CodeEntry* to ProfileNode* 193 // Mapping from CodeEntry* to ProfileNode*
184 HashMap children_; 194 HashMap children_;
185 List<ProfileNode*> children_list_; 195 List<ProfileNode*> children_list_;
186 unsigned id_; 196 unsigned id_;
187 HashMap line_ticks_; 197 HashMap line_ticks_;
188 198
189 List<DeoptInfo> deopt_infos_; 199 std::vector<DeoptInfo> deopt_infos_;
200
190 DISALLOW_COPY_AND_ASSIGN(ProfileNode); 201 DISALLOW_COPY_AND_ASSIGN(ProfileNode);
191 }; 202 };
192 203
193 204
194 class ProfileTree { 205 class ProfileTree {
195 public: 206 public:
196 ProfileTree(); 207 ProfileTree();
197 ~ProfileTree(); 208 ~ProfileTree();
198 209
199 ProfileNode* AddPathFromEnd( 210 ProfileNode* AddPathFromEnd(
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 CodeEntry* gc_entry_; 389 CodeEntry* gc_entry_;
379 CodeEntry* unresolved_entry_; 390 CodeEntry* unresolved_entry_;
380 391
381 DISALLOW_COPY_AND_ASSIGN(ProfileGenerator); 392 DISALLOW_COPY_AND_ASSIGN(ProfileGenerator);
382 }; 393 };
383 394
384 395
385 } } // namespace v8::internal 396 } } // namespace v8::internal
386 397
387 #endif // V8_PROFILE_GENERATOR_H_ 398 #endif // V8_PROFILE_GENERATOR_H_
OLDNEW
« src/compiler.h ('K') | « src/hydrogen.cc ('k') | src/profile-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698