| 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_PROFILER_PROFILE_GENERATOR_H_ | 5 #ifndef V8_PROFILER_PROFILE_GENERATOR_H_ |
| 6 #define V8_PROFILER_PROFILE_GENERATOR_H_ | 6 #define V8_PROFILER_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 29 matching lines...) Expand all Loading... |
| 40 // CodeEntry doesn't own name strings, just references them. | 40 // CodeEntry doesn't own name strings, just references them. |
| 41 inline CodeEntry(Logger::LogEventsAndTags tag, const char* name, | 41 inline CodeEntry(Logger::LogEventsAndTags tag, const char* name, |
| 42 const char* name_prefix = CodeEntry::kEmptyNamePrefix, | 42 const char* name_prefix = CodeEntry::kEmptyNamePrefix, |
| 43 const char* resource_name = CodeEntry::kEmptyResourceName, | 43 const char* resource_name = CodeEntry::kEmptyResourceName, |
| 44 int line_number = v8::CpuProfileNode::kNoLineNumberInfo, | 44 int line_number = v8::CpuProfileNode::kNoLineNumberInfo, |
| 45 int column_number = v8::CpuProfileNode::kNoColumnNumberInfo, | 45 int column_number = v8::CpuProfileNode::kNoColumnNumberInfo, |
| 46 JITLineInfoTable* line_info = NULL, | 46 JITLineInfoTable* line_info = NULL, |
| 47 Address instruction_start = NULL); | 47 Address instruction_start = NULL); |
| 48 ~CodeEntry(); | 48 ~CodeEntry(); |
| 49 | 49 |
| 50 // Container describing inlined frames at eager deopt points. Is eventually |
| 51 // being translated into v8::CpuProfileDeoptFrame by the profiler. |
| 52 struct DeoptInlinedFrame { |
| 53 int position; |
| 54 int script_id; |
| 55 }; |
| 56 |
| 50 const char* name_prefix() const { return name_prefix_; } | 57 const char* name_prefix() const { return name_prefix_; } |
| 51 bool has_name_prefix() const { return name_prefix_[0] != '\0'; } | 58 bool has_name_prefix() const { return name_prefix_[0] != '\0'; } |
| 52 const char* name() const { return name_; } | 59 const char* name() const { return name_; } |
| 53 const char* resource_name() const { return resource_name_; } | 60 const char* resource_name() const { return resource_name_; } |
| 54 int line_number() const { return line_number_; } | 61 int line_number() const { return line_number_; } |
| 55 int column_number() const { return column_number_; } | 62 int column_number() const { return column_number_; } |
| 56 const JITLineInfoTable* line_info() const { return line_info_; } | 63 const JITLineInfoTable* line_info() const { return line_info_; } |
| 57 int script_id() const { return script_id_; } | 64 int script_id() const { return script_id_; } |
| 58 void set_script_id(int script_id) { script_id_ = script_id; } | 65 void set_script_id(int script_id) { script_id_ = script_id; } |
| 59 int position() const { return position_; } | 66 int position() const { return position_; } |
| 60 void set_position(int position) { position_ = position; } | 67 void set_position(int position) { position_ = position; } |
| 61 void set_bailout_reason(const char* bailout_reason) { | 68 void set_bailout_reason(const char* bailout_reason) { |
| 62 bailout_reason_ = bailout_reason; | 69 bailout_reason_ = bailout_reason; |
| 63 } | 70 } |
| 64 const char* bailout_reason() const { return bailout_reason_; } | 71 const char* bailout_reason() const { return bailout_reason_; } |
| 65 | 72 |
| 66 void set_deopt_info(const char* deopt_reason, SourcePosition position, | 73 void set_deopt_info(const char* deopt_reason, SourcePosition position, |
| 67 int inlining_id) { | 74 int deopt_id) { |
| 68 DCHECK(deopt_position_.IsUnknown()); | 75 DCHECK(deopt_position_.IsUnknown()); |
| 69 deopt_reason_ = deopt_reason; | 76 deopt_reason_ = deopt_reason; |
| 70 deopt_position_ = position; | 77 deopt_position_ = position; |
| 71 deopt_inlining_id_ = inlining_id; | 78 deopt_id_ = deopt_id; |
| 72 } | 79 } |
| 73 CpuProfileDeoptInfo GetDeoptInfo(); | 80 CpuProfileDeoptInfo GetDeoptInfo(); |
| 74 const char* deopt_reason() const { return deopt_reason_; } | 81 const char* deopt_reason() const { return deopt_reason_; } |
| 75 SourcePosition deopt_position() const { return deopt_position_; } | 82 SourcePosition deopt_position() const { return deopt_position_; } |
| 76 bool has_deopt_info() const { return !deopt_position_.IsUnknown(); } | 83 bool has_deopt_info() const { return !deopt_position_.IsUnknown(); } |
| 77 void clear_deopt_info() { | 84 void clear_deopt_info() { |
| 78 deopt_reason_ = kNoDeoptReason; | 85 deopt_reason_ = kNoDeoptReason; |
| 79 deopt_position_ = SourcePosition::Unknown(); | 86 deopt_position_ = SourcePosition::Unknown(); |
| 80 } | 87 } |
| 81 | 88 |
| 82 void FillFunctionInfo(SharedFunctionInfo* shared); | 89 void FillFunctionInfo(SharedFunctionInfo* shared); |
| 83 | 90 |
| 84 void set_inlined_function_infos( | |
| 85 const std::vector<InlinedFunctionInfo>& infos) { | |
| 86 inlined_function_infos_ = infos; | |
| 87 } | |
| 88 const std::vector<InlinedFunctionInfo> inlined_function_infos() { | |
| 89 return inlined_function_infos_; | |
| 90 } | |
| 91 | |
| 92 void SetBuiltinId(Builtins::Name id); | 91 void SetBuiltinId(Builtins::Name id); |
| 93 Builtins::Name builtin_id() const { | 92 Builtins::Name builtin_id() const { |
| 94 return BuiltinIdField::decode(bit_field_); | 93 return BuiltinIdField::decode(bit_field_); |
| 95 } | 94 } |
| 96 | 95 |
| 97 uint32_t GetHash() const; | 96 uint32_t GetHash() const; |
| 98 bool IsSameFunctionAs(CodeEntry* entry) const; | 97 bool IsSameFunctionAs(CodeEntry* entry) const; |
| 99 | 98 |
| 100 int GetSourceLine(int pc_offset) const; | 99 int GetSourceLine(int pc_offset) const; |
| 101 | 100 |
| 102 void AddInlineStack(int pc_offset, std::vector<CodeEntry*>& inline_stack); | 101 void AddInlineStack(int pc_offset, std::vector<CodeEntry*>& inline_stack); |
| 103 const std::vector<CodeEntry*>* GetInlineStack(int pc_offset) const; | 102 const std::vector<CodeEntry*>* GetInlineStack(int pc_offset) const; |
| 104 | 103 |
| 104 void AddDeoptInlinedFrames(int deopt_id, std::vector<DeoptInlinedFrame>&); |
| 105 bool HasDeoptInlinedFramesFor(int deopt_id) const; |
| 106 |
| 105 Address instruction_start() const { return instruction_start_; } | 107 Address instruction_start() const { return instruction_start_; } |
| 106 Logger::LogEventsAndTags tag() const { return TagField::decode(bit_field_); } | 108 Logger::LogEventsAndTags tag() const { return TagField::decode(bit_field_); } |
| 107 | 109 |
| 108 static const char* const kEmptyNamePrefix; | 110 static const char* const kEmptyNamePrefix; |
| 109 static const char* const kEmptyResourceName; | 111 static const char* const kEmptyResourceName; |
| 110 static const char* const kEmptyBailoutReason; | 112 static const char* const kEmptyBailoutReason; |
| 111 static const char* const kNoDeoptReason; | 113 static const char* const kNoDeoptReason; |
| 112 | 114 |
| 113 private: | 115 private: |
| 114 class TagField : public BitField<Logger::LogEventsAndTags, 0, 8> {}; | 116 class TagField : public BitField<Logger::LogEventsAndTags, 0, 8> {}; |
| 115 class BuiltinIdField : public BitField<Builtins::Name, 8, 8> {}; | 117 class BuiltinIdField : public BitField<Builtins::Name, 8, 8> {}; |
| 116 | 118 |
| 117 uint32_t bit_field_; | 119 uint32_t bit_field_; |
| 118 const char* name_prefix_; | 120 const char* name_prefix_; |
| 119 const char* name_; | 121 const char* name_; |
| 120 const char* resource_name_; | 122 const char* resource_name_; |
| 121 int line_number_; | 123 int line_number_; |
| 122 int column_number_; | 124 int column_number_; |
| 123 int script_id_; | 125 int script_id_; |
| 124 int position_; | 126 int position_; |
| 125 const char* bailout_reason_; | 127 const char* bailout_reason_; |
| 126 const char* deopt_reason_; | 128 const char* deopt_reason_; |
| 127 SourcePosition deopt_position_; | 129 SourcePosition deopt_position_; |
| 128 int deopt_inlining_id_; | 130 int deopt_id_; |
| 129 JITLineInfoTable* line_info_; | 131 JITLineInfoTable* line_info_; |
| 130 Address instruction_start_; | 132 Address instruction_start_; |
| 131 // Should be an unordered_map, but it doesn't currently work on Win & MacOS. | 133 // Should be an unordered_map, but it doesn't currently work on Win & MacOS. |
| 132 std::map<int, std::vector<CodeEntry*>> inline_locations_; | 134 std::map<int, std::vector<CodeEntry*>> inline_locations_; |
| 133 | 135 std::map<int, std::vector<DeoptInlinedFrame>> deopt_inlined_frames_; |
| 134 std::vector<InlinedFunctionInfo> inlined_function_infos_; | |
| 135 | 136 |
| 136 DISALLOW_COPY_AND_ASSIGN(CodeEntry); | 137 DISALLOW_COPY_AND_ASSIGN(CodeEntry); |
| 137 }; | 138 }; |
| 138 | 139 |
| 139 | 140 |
| 140 class ProfileTree; | 141 class ProfileTree; |
| 141 | 142 |
| 142 class ProfileNode { | 143 class ProfileNode { |
| 143 public: | 144 public: |
| 144 inline ProfileNode(ProfileTree* tree, CodeEntry* entry); | 145 inline ProfileNode(ProfileTree* tree, CodeEntry* entry); |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 CodeEntry* unresolved_entry_; | 387 CodeEntry* unresolved_entry_; |
| 387 | 388 |
| 388 DISALLOW_COPY_AND_ASSIGN(ProfileGenerator); | 389 DISALLOW_COPY_AND_ASSIGN(ProfileGenerator); |
| 389 }; | 390 }; |
| 390 | 391 |
| 391 | 392 |
| 392 } // namespace internal | 393 } // namespace internal |
| 393 } // namespace v8 | 394 } // namespace v8 |
| 394 | 395 |
| 395 #endif // V8_PROFILER_PROFILE_GENERATOR_H_ | 396 #endif // V8_PROFILER_PROFILE_GENERATOR_H_ |
| OLD | NEW |