OLD | NEW |
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 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/profile-generator-inl.h" | 7 #include "src/profile-generator-inl.h" |
8 | 8 |
9 #include "src/compiler.h" | 9 #include "src/compiler.h" |
10 #include "src/debug.h" | 10 #include "src/debug.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 | 105 |
106 void CodeEntry::FillFunctionInfo(SharedFunctionInfo* shared) { | 106 void CodeEntry::FillFunctionInfo(SharedFunctionInfo* shared) { |
107 if (!shared->script()->IsScript()) return; | 107 if (!shared->script()->IsScript()) return; |
108 Script* script = Script::cast(shared->script()); | 108 Script* script = Script::cast(shared->script()); |
109 set_script_id(script->id()->value()); | 109 set_script_id(script->id()->value()); |
110 set_position(shared->start_position()); | 110 set_position(shared->start_position()); |
111 set_bailout_reason(GetBailoutReason(shared->disable_optimization_reason())); | 111 set_bailout_reason(GetBailoutReason(shared->disable_optimization_reason())); |
112 } | 112 } |
113 | 113 |
114 | 114 |
115 CpuProfileDeoptInfo CodeEntry::GetDeoptInfo() { | 115 DeoptInfo CodeEntry::GetDeoptInfo() { |
116 DCHECK(has_deopt_info()); | 116 DCHECK(has_deopt_info()); |
117 | 117 |
118 CpuProfileDeoptInfo info; | 118 DeoptInfo info; |
119 info.deopt_reason = deopt_reason_; | 119 info.deopt_reason = deopt_reason_; |
120 if (inlined_function_infos_.empty()) { | 120 if (inlined_function_infos_.empty()) { |
121 info.stack.push_back(CpuProfileDeoptInfo::Frame( | 121 info.stack.push_back(DeoptInfo::Frame( |
122 {script_id_, position_ + deopt_position_.position()})); | 122 {script_id_, |
| 123 static_cast<int>(position_ + deopt_position_.position())})); |
123 return info; | 124 return info; |
124 } | 125 } |
125 // Copy the only branch from the inlining tree where the deopt happened. | 126 // Copy the only branch from the inlining tree where the deopt happened. |
126 SourcePosition position = deopt_position_; | 127 SourcePosition position = deopt_position_; |
127 int inlining_id = InlinedFunctionInfo::kNoParentId; | 128 int inlining_id = InlinedFunctionInfo::kNoParentId; |
128 for (size_t i = 0; i < inlined_function_infos_.size(); ++i) { | 129 for (size_t i = 0; i < inlined_function_infos_.size(); ++i) { |
129 InlinedFunctionInfo& current_info = inlined_function_infos_.at(i); | 130 InlinedFunctionInfo& current_info = inlined_function_infos_.at(i); |
130 if (std::binary_search(current_info.deopt_pc_offsets.begin(), | 131 if (std::binary_search(current_info.deopt_pc_offsets.begin(), |
131 current_info.deopt_pc_offsets.end(), pc_offset_)) { | 132 current_info.deopt_pc_offsets.end(), pc_offset_)) { |
132 inlining_id = static_cast<int>(i); | 133 inlining_id = static_cast<int>(i); |
133 break; | 134 break; |
134 } | 135 } |
135 } | 136 } |
136 while (inlining_id != InlinedFunctionInfo::kNoParentId) { | 137 while (inlining_id != InlinedFunctionInfo::kNoParentId) { |
137 InlinedFunctionInfo& inlined_info = inlined_function_infos_.at(inlining_id); | 138 InlinedFunctionInfo& inlined_info = inlined_function_infos_.at(inlining_id); |
138 info.stack.push_back(CpuProfileDeoptInfo::Frame( | 139 info.stack.push_back(DeoptInfo::Frame( |
139 {inlined_info.script_id, | 140 {inlined_info.script_id, |
140 inlined_info.start_position + position.raw()})); | 141 static_cast<int>(inlined_info.start_position + position.raw())})); |
141 position = inlined_info.inline_position; | 142 position = inlined_info.inline_position; |
142 inlining_id = inlined_info.parent_id; | 143 inlining_id = inlined_info.parent_id; |
143 } | 144 } |
144 return info; | 145 return info; |
145 } | 146 } |
146 | 147 |
147 | 148 |
148 void ProfileNode::CollectDeoptInfo(CodeEntry* entry) { | 149 void ProfileNode::CollectDeoptInfo(CodeEntry* entry) { |
149 deopt_infos_.push_back(entry->GetDeoptInfo()); | 150 deopt_infos_.push_back(entry->GetDeoptInfo()); |
150 entry->clear_deopt_info(); | 151 entry->clear_deopt_info(); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 | 209 |
209 | 210 |
210 void ProfileNode::Print(int indent) { | 211 void ProfileNode::Print(int indent) { |
211 base::OS::Print("%5u %*s %s%s %d #%d", self_ticks_, indent, "", | 212 base::OS::Print("%5u %*s %s%s %d #%d", self_ticks_, indent, "", |
212 entry_->name_prefix(), entry_->name(), entry_->script_id(), | 213 entry_->name_prefix(), entry_->name(), entry_->script_id(), |
213 id()); | 214 id()); |
214 if (entry_->resource_name()[0] != '\0') | 215 if (entry_->resource_name()[0] != '\0') |
215 base::OS::Print(" %s:%d", entry_->resource_name(), entry_->line_number()); | 216 base::OS::Print(" %s:%d", entry_->resource_name(), entry_->line_number()); |
216 base::OS::Print("\n"); | 217 base::OS::Print("\n"); |
217 for (size_t i = 0; i < deopt_infos_.size(); ++i) { | 218 for (size_t i = 0; i < deopt_infos_.size(); ++i) { |
218 CpuProfileDeoptInfo& info = deopt_infos_[i]; | 219 DeoptInfo& info = deopt_infos_[i]; |
219 base::OS::Print( | 220 base::OS::Print( |
220 "%*s;;; deopted at script_id: %d position: %d with reason '%s'.\n", | 221 "%*s;;; deopted at script_id: %d position: %d with reason '%s'.\n", |
221 indent + 10, "", info.stack[0].script_id, info.stack[0].position, | 222 indent + 10, "", info.stack[0].script_id, info.stack[0].position, |
222 info.deopt_reason); | 223 info.deopt_reason); |
223 for (size_t index = 1; index < info.stack.size(); ++index) { | 224 for (size_t index = 1; index < info.stack.size(); ++index) { |
224 base::OS::Print("%*s;;; Inline point: script_id %d position: %d.\n", | 225 base::OS::Print("%*s;;; Inline point: script_id %d position: %d.\n", |
225 indent + 10, "", info.stack[index].script_id, | 226 indent + 10, "", info.stack[index].script_id, |
226 info.stack[index].position); | 227 info.stack[index].position); |
227 } | 228 } |
228 } | 229 } |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
691 case OTHER: | 692 case OTHER: |
692 case EXTERNAL: | 693 case EXTERNAL: |
693 return program_entry_; | 694 return program_entry_; |
694 case IDLE: | 695 case IDLE: |
695 return idle_entry_; | 696 return idle_entry_; |
696 default: return NULL; | 697 default: return NULL; |
697 } | 698 } |
698 } | 699 } |
699 | 700 |
700 } } // namespace v8::internal | 701 } } // namespace v8::internal |
OLD | NEW |