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

Side by Side Diff: src/log.h

Issue 424973004: Extend CPU profiler with mapping ticks to source lines (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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_LOG_H_ 5 #ifndef V8_LOG_H_
6 #define V8_LOG_H_ 6 #define V8_LOG_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "src/allocation.h" 10 #include "src/allocation.h"
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 // Note that 'NATIVE_' cases for functions and scripts are mapped onto 142 // Note that 'NATIVE_' cases for functions and scripts are mapped onto
143 // original tags when writing to the log. 143 // original tags when writing to the log.
144 144
145 145
146 class JitLogger; 146 class JitLogger;
147 class PerfBasicLogger; 147 class PerfBasicLogger;
148 class LowLevelLogger; 148 class LowLevelLogger;
149 class PerfJitLogger; 149 class PerfJitLogger;
150 class Sampler; 150 class Sampler;
151 151
152 // Mapping from the offset within generated code to source line number.
153 class JITLineInfoTable : public Malloced {
154 public:
155 JITLineInfoTable() : pc_offset_infos_(20) {}
156
157 void SetPosition(unsigned int pc_offset, unsigned int src_line) {
158 AddPcOffsetInfo(PcOffsetInfo(pc_offset, src_line));
159 }
160
161 int GetSourceLineNumber(unsigned int pc_offset) const {
162 int length = pc_offset_infos_.length();
danno 2014/07/29 09:24:51 Why not use binary_search/lower_bound here?
163 if (0 == length) return 0;
alph 2014/07/29 12:55:56 nit style: the v8 code doesn't seem to use const a
164
165 int low = 0;
166 int high = length - 1;
167
168 if (pc_offset > pc_offset_infos_[high].pc_offset_) {
169 return 0; // out of range
170 }
171
172 while (low < high) {
173 int mid = (low + high) / 2;
174 const JITLineInfoTable::PcOffsetInfo& elem = pc_offset_infos_[mid];
175 if (elem.pc_offset_ > pc_offset) {
176 high = mid;
177 continue;
178 }
179 if (elem.pc_offset_ < pc_offset) {
180 low = mid + 1;
181 continue;
182 }
183 return elem.line_; // found the element
184 }
185
186 int line = pc_offset_infos_[high].line_;
187 return line;
188 }
189
190 struct PcOffsetInfo {
191 PcOffsetInfo(unsigned int pc_offset, unsigned int src_line)
192 : pc_offset_(pc_offset), line_(src_line) { }
193
194 unsigned int pc_offset_;
195 unsigned int line_;
196 };
197
198 List<PcOffsetInfo>* entries() { return &pc_offset_infos_; }
199 const List<PcOffsetInfo>* entries() const { return &pc_offset_infos_; }
200
201 JITLineInfoTable& operator=(const JITLineInfoTable& other) {
202 if (this != &other) {
203 const List<PcOffsetInfo>* entries = other.entries();
204 if (entries) {
205 pc_offset_infos_.Clear();
206 pc_offset_infos_.AddAll(*entries);
207 }
208 }
209 return *this;
210 }
211
212 private:
213 void AddPcOffsetInfo(const PcOffsetInfo& pc_offset_info) {
214 pc_offset_infos_.Add(pc_offset_info);
alph 2014/07/29 12:55:56 As long as the algo expects the entries are sorted
215 }
216
217 // The data reported by code generator.
218 List<PcOffsetInfo> pc_offset_infos_;
219 };
220
221
152 class Logger { 222 class Logger {
153 public: 223 public:
154 enum StartEnd { START = 0, END = 1 }; 224 enum StartEnd { START = 0, END = 1 };
155 225
156 #define DECLARE_ENUM(enum_item, ignore) enum_item, 226 #define DECLARE_ENUM(enum_item, ignore) enum_item,
157 enum LogEventsAndTags { 227 enum LogEventsAndTags {
158 LOG_EVENTS_AND_TAGS_LIST(DECLARE_ENUM) 228 LOG_EVENTS_AND_TAGS_LIST(DECLARE_ENUM)
159 NUMBER_OF_LOG_EVENTS 229 NUMBER_OF_LOG_EVENTS
160 }; 230 };
161 #undef DECLARE_ENUM 231 #undef DECLARE_ENUM
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 int length) = 0; 602 int length) = 0;
533 603
534 NameBuffer* name_buffer_; 604 NameBuffer* name_buffer_;
535 }; 605 };
536 606
537 607
538 } } // namespace v8::internal 608 } } // namespace v8::internal
539 609
540 610
541 #endif // V8_LOG_H_ 611 #endif // V8_LOG_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698