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