| OLD | NEW |
| 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 19 matching lines...) Expand all Loading... |
| 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 | 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 |
| 40 class CodeEntry { | 50 class CodeEntry { |
| 41 public: | 51 public: |
| 42 // CodeEntry doesn't own name strings, just references them. | 52 // CodeEntry doesn't own name strings, just references them. |
| 43 inline CodeEntry(Logger::LogEventsAndTags tag, const char* name, | 53 inline CodeEntry(Logger::LogEventsAndTags tag, const char* name, |
| 44 const char* name_prefix = CodeEntry::kEmptyNamePrefix, | 54 const char* name_prefix = CodeEntry::kEmptyNamePrefix, |
| 45 const char* resource_name = CodeEntry::kEmptyResourceName, | 55 const char* resource_name = CodeEntry::kEmptyResourceName, |
| 46 int line_number = v8::CpuProfileNode::kNoLineNumberInfo, | 56 int line_number = v8::CpuProfileNode::kNoLineNumberInfo, |
| 47 int column_number = v8::CpuProfileNode::kNoColumnNumberInfo, | 57 int column_number = v8::CpuProfileNode::kNoColumnNumberInfo, |
| 48 JITLineInfoTable* line_info = NULL, | 58 JITLineInfoTable* line_info = NULL, |
| 49 Address instruction_start = NULL); | 59 Address instruction_start = NULL); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 66 } | 76 } |
| 67 const char* bailout_reason() const { return bailout_reason_; } | 77 const char* bailout_reason() const { return bailout_reason_; } |
| 68 | 78 |
| 69 void set_deopt_info(const char* deopt_reason, SourcePosition position, | 79 void set_deopt_info(const char* deopt_reason, SourcePosition position, |
| 70 size_t pc_offset) { | 80 size_t pc_offset) { |
| 71 DCHECK(deopt_position_.IsUnknown()); | 81 DCHECK(deopt_position_.IsUnknown()); |
| 72 deopt_reason_ = deopt_reason; | 82 deopt_reason_ = deopt_reason; |
| 73 deopt_position_ = position; | 83 deopt_position_ = position; |
| 74 pc_offset_ = pc_offset; | 84 pc_offset_ = pc_offset; |
| 75 } | 85 } |
| 76 CpuProfileDeoptInfo GetDeoptInfo(); | 86 DeoptInfo GetDeoptInfo(); |
| 77 const char* deopt_reason() const { return deopt_reason_; } | 87 const char* deopt_reason() const { return deopt_reason_; } |
| 78 SourcePosition deopt_position() const { return deopt_position_; } | 88 SourcePosition deopt_position() const { return deopt_position_; } |
| 79 bool has_deopt_info() const { return !deopt_position_.IsUnknown(); } | 89 bool has_deopt_info() const { return !deopt_position_.IsUnknown(); } |
| 80 void clear_deopt_info() { | 90 void clear_deopt_info() { |
| 81 deopt_reason_ = kNoDeoptReason; | 91 deopt_reason_ = kNoDeoptReason; |
| 82 deopt_position_ = SourcePosition::Unknown(); | 92 deopt_position_ = SourcePosition::Unknown(); |
| 83 } | 93 } |
| 84 | 94 |
| 85 void FillFunctionInfo(SharedFunctionInfo* shared); | 95 void FillFunctionInfo(SharedFunctionInfo* shared); |
| 86 | 96 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 std::vector<CpuProfileDeoptInfo>& deopt_infos() const { | 176 const std::vector<DeoptInfo>& deopt_infos() const { return deopt_infos_; } |
| 167 return deopt_infos_; | |
| 168 } | |
| 169 | 177 |
| 170 void Print(int indent); | 178 void Print(int indent); |
| 171 | 179 |
| 172 static bool CodeEntriesMatch(void* entry1, void* entry2) { | 180 static bool CodeEntriesMatch(void* entry1, void* entry2) { |
| 173 return reinterpret_cast<CodeEntry*>(entry1) | 181 return reinterpret_cast<CodeEntry*>(entry1) |
| 174 ->IsSameFunctionAs(reinterpret_cast<CodeEntry*>(entry2)); | 182 ->IsSameFunctionAs(reinterpret_cast<CodeEntry*>(entry2)); |
| 175 } | 183 } |
| 176 | 184 |
| 177 private: | 185 private: |
| 178 static uint32_t CodeEntryHash(CodeEntry* entry) { return entry->GetHash(); } | 186 static uint32_t CodeEntryHash(CodeEntry* entry) { return entry->GetHash(); } |
| 179 | 187 |
| 180 static bool LineTickMatch(void* a, void* b) { return a == b; } | 188 static bool LineTickMatch(void* a, void* b) { return a == b; } |
| 181 | 189 |
| 182 ProfileTree* tree_; | 190 ProfileTree* tree_; |
| 183 CodeEntry* entry_; | 191 CodeEntry* entry_; |
| 184 unsigned self_ticks_; | 192 unsigned self_ticks_; |
| 185 // Mapping from CodeEntry* to ProfileNode* | 193 // Mapping from CodeEntry* to ProfileNode* |
| 186 HashMap children_; | 194 HashMap children_; |
| 187 List<ProfileNode*> children_list_; | 195 List<ProfileNode*> children_list_; |
| 188 unsigned id_; | 196 unsigned id_; |
| 189 HashMap line_ticks_; | 197 HashMap line_ticks_; |
| 190 | 198 |
| 191 std::vector<CpuProfileDeoptInfo> deopt_infos_; | 199 std::vector<DeoptInfo> deopt_infos_; |
| 192 | 200 |
| 193 DISALLOW_COPY_AND_ASSIGN(ProfileNode); | 201 DISALLOW_COPY_AND_ASSIGN(ProfileNode); |
| 194 }; | 202 }; |
| 195 | 203 |
| 196 | 204 |
| 197 class ProfileTree { | 205 class ProfileTree { |
| 198 public: | 206 public: |
| 199 ProfileTree(); | 207 ProfileTree(); |
| 200 ~ProfileTree(); | 208 ~ProfileTree(); |
| 201 | 209 |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 CodeEntry* gc_entry_; | 389 CodeEntry* gc_entry_; |
| 382 CodeEntry* unresolved_entry_; | 390 CodeEntry* unresolved_entry_; |
| 383 | 391 |
| 384 DISALLOW_COPY_AND_ASSIGN(ProfileGenerator); | 392 DISALLOW_COPY_AND_ASSIGN(ProfileGenerator); |
| 385 }; | 393 }; |
| 386 | 394 |
| 387 | 395 |
| 388 } } // namespace v8::internal | 396 } } // namespace v8::internal |
| 389 | 397 |
| 390 #endif // V8_PROFILE_GENERATOR_H_ | 398 #endif // V8_PROFILE_GENERATOR_H_ |
| OLD | NEW |