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/compiler.h" | 5 #include "src/compiler.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "src/ast-numbering.h" | 9 #include "src/ast-numbering.h" |
10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
116 : parse_info_(parse_info), | 116 : parse_info_(parse_info), |
117 isolate_(isolate), | 117 isolate_(isolate), |
118 flags_(0), | 118 flags_(0), |
119 code_stub_(code_stub), | 119 code_stub_(code_stub), |
120 mode_(mode), | 120 mode_(mode), |
121 osr_ast_id_(BailoutId::None()), | 121 osr_ast_id_(BailoutId::None()), |
122 zone_(zone), | 122 zone_(zone), |
123 deferred_handles_(nullptr), | 123 deferred_handles_(nullptr), |
124 bailout_reason_(kNoReason), | 124 bailout_reason_(kNoReason), |
125 prologue_offset_(Code::kPrologueOffsetNotSet), | 125 prologue_offset_(Code::kPrologueOffsetNotSet), |
126 no_frame_ranges_(isolate->cpu_profiler()->is_profiling() | |
127 ? new List<OffsetRange>(2) | |
128 : nullptr), | |
129 track_positions_(FLAG_hydrogen_track_positions), | 126 track_positions_(FLAG_hydrogen_track_positions), |
130 opt_count_(has_shared_info() ? shared_info()->opt_count() : 0), | 127 opt_count_(has_shared_info() ? shared_info()->opt_count() : 0), |
131 parameter_count_(0), | 128 parameter_count_(0), |
132 optimization_id_(-1), | 129 optimization_id_(-1), |
133 aborted_due_to_dependency_change_(false), | 130 aborted_due_to_dependency_change_(false), |
134 osr_expr_stack_height_(0) { | 131 osr_expr_stack_height_(0) { |
135 std::fill_n(dependencies_, DependentCode::kGroupCount, nullptr); | 132 std::fill_n(dependencies_, DependentCode::kGroupCount, nullptr); |
133 if (isolate->cpu_profiler()->is_profiling()) { | |
134 no_frame_ranges_.Reset(new List<OffsetRange>(2)); | |
Sven Panne
2015/03/23 10:13:26
No need for this, see comment in the header.
| |
135 track_positions_ = true; | |
Sven Panne
2015/03/23 10:13:26
Instead of doing this assignment to track_position
| |
136 } | |
137 if (track_positions_) { | |
138 inlined_function_infos_.Reset(new std::vector<InlinedFunctionInfo>()); | |
Sven Panne
2015/03/23 10:13:26
No need for this, see comment in the header.
| |
139 } | |
136 } | 140 } |
137 | 141 |
138 | 142 |
139 CompilationInfo::~CompilationInfo() { | 143 CompilationInfo::~CompilationInfo() { |
140 DisableFutureOptimization(); | 144 DisableFutureOptimization(); |
141 delete deferred_handles_; | 145 delete deferred_handles_; |
142 delete no_frame_ranges_; | |
143 #ifdef DEBUG | 146 #ifdef DEBUG |
144 // Check that no dependent maps have been added or added dependent maps have | 147 // Check that no dependent maps have been added or added dependent maps have |
145 // been rolled back or committed. | 148 // been rolled back or committed. |
146 for (int i = 0; i < DependentCode::kGroupCount; i++) { | 149 for (int i = 0; i < DependentCode::kGroupCount; i++) { |
147 DCHECK(!dependencies_[i]); | 150 DCHECK(!dependencies_[i]); |
148 } | 151 } |
149 #endif // DEBUG | 152 #endif // DEBUG |
150 } | 153 } |
151 | 154 |
152 | 155 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
238 bool CompilationInfo::is_simple_parameter_list() { | 241 bool CompilationInfo::is_simple_parameter_list() { |
239 return scope()->is_simple_parameter_list(); | 242 return scope()->is_simple_parameter_list(); |
240 } | 243 } |
241 | 244 |
242 | 245 |
243 int CompilationInfo::TraceInlinedFunction(Handle<SharedFunctionInfo> shared, | 246 int CompilationInfo::TraceInlinedFunction(Handle<SharedFunctionInfo> shared, |
244 SourcePosition position, | 247 SourcePosition position, |
245 int parent_id) { | 248 int parent_id) { |
246 DCHECK(track_positions_); | 249 DCHECK(track_positions_); |
247 | 250 |
248 int inline_id = static_cast<int>(inlined_function_infos_.size()); | 251 int inline_id = static_cast<int>(inlined_function_infos_->size()); |
249 InlinedFunctionInfo info(parent_id, position, UnboundScript::kNoScriptId, | 252 InlinedFunctionInfo info(parent_id, position, UnboundScript::kNoScriptId, |
250 shared->start_position()); | 253 shared->start_position()); |
251 if (!shared->script()->IsUndefined()) { | 254 if (!shared->script()->IsUndefined()) { |
252 Handle<Script> script(Script::cast(shared->script())); | 255 Handle<Script> script(Script::cast(shared->script())); |
253 info.script_id = script->id()->value(); | 256 info.script_id = script->id()->value(); |
254 | 257 |
255 if (FLAG_hydrogen_track_positions && !script->source()->IsUndefined()) { | 258 if (FLAG_hydrogen_track_positions && !script->source()->IsUndefined()) { |
256 CodeTracer::Scope tracing_scope(isolate()->GetCodeTracer()); | 259 CodeTracer::Scope tracing_scope(isolate()->GetCodeTracer()); |
257 OFStream os(tracing_scope.file()); | 260 OFStream os(tracing_scope.file()); |
258 os << "--- FUNCTION SOURCE (" << shared->DebugName()->ToCString().get() | 261 os << "--- FUNCTION SOURCE (" << shared->DebugName()->ToCString().get() |
259 << ") id{" << optimization_id() << "," << inline_id << "} ---\n"; | 262 << ") id{" << optimization_id() << "," << inline_id << "} ---\n"; |
260 { | 263 { |
261 DisallowHeapAllocation no_allocation; | 264 DisallowHeapAllocation no_allocation; |
262 int start = shared->start_position(); | 265 int start = shared->start_position(); |
263 int len = shared->end_position() - start; | 266 int len = shared->end_position() - start; |
264 String::SubStringRange source(String::cast(script->source()), start, | 267 String::SubStringRange source(String::cast(script->source()), start, |
265 len); | 268 len); |
266 for (const auto& c : source) { | 269 for (const auto& c : source) { |
267 os << AsReversiblyEscapedUC16(c); | 270 os << AsReversiblyEscapedUC16(c); |
268 } | 271 } |
269 } | 272 } |
270 | |
271 os << "\n--- END ---\n"; | 273 os << "\n--- END ---\n"; |
272 } | 274 } |
273 } | 275 } |
274 | 276 |
275 inlined_function_infos_.push_back(info); | 277 inlined_function_infos_->push_back(info); |
276 | 278 |
277 if (FLAG_hydrogen_track_positions && inline_id != 0) { | 279 if (FLAG_hydrogen_track_positions && inline_id != 0) { |
278 CodeTracer::Scope tracing_scope(isolate()->GetCodeTracer()); | 280 CodeTracer::Scope tracing_scope(isolate()->GetCodeTracer()); |
279 OFStream os(tracing_scope.file()); | 281 OFStream os(tracing_scope.file()); |
280 os << "INLINE (" << shared->DebugName()->ToCString().get() << ") id{" | 282 os << "INLINE (" << shared->DebugName()->ToCString().get() << ") id{" |
281 << optimization_id() << "," << inline_id << "} AS " << inline_id | 283 << optimization_id() << "," << inline_id << "} AS " << inline_id |
282 << " AT " << position << std::endl; | 284 << " AT " << position << std::endl; |
283 } | 285 } |
284 | 286 |
285 return inline_id; | 287 return inline_id; |
286 } | 288 } |
287 | 289 |
288 | 290 |
289 void CompilationInfo::LogDeoptCallPosition(int pc_offset, int inlining_id) { | 291 void CompilationInfo::LogDeoptCallPosition(int pc_offset, int inlining_id) { |
290 if (!track_positions_ || IsStub()) return; | 292 if (!track_positions_ || IsStub()) return; |
291 DCHECK_LT(static_cast<size_t>(inlining_id), inlined_function_infos_.size()); | 293 DCHECK_LT(static_cast<size_t>(inlining_id), inlined_function_infos_->size()); |
292 inlined_function_infos_.at(inlining_id).deopt_pc_offsets.push_back(pc_offset); | 294 inlined_function_infos_->at(inlining_id) |
295 .deopt_pc_offsets.push_back(pc_offset); | |
293 } | 296 } |
294 | 297 |
295 | 298 |
296 class HOptimizedGraphBuilderWithPositions: public HOptimizedGraphBuilder { | 299 class HOptimizedGraphBuilderWithPositions: public HOptimizedGraphBuilder { |
297 public: | 300 public: |
298 explicit HOptimizedGraphBuilderWithPositions(CompilationInfo* info) | 301 explicit HOptimizedGraphBuilderWithPositions(CompilationInfo* info) |
299 : HOptimizedGraphBuilder(info) { | 302 : HOptimizedGraphBuilder(info) { |
300 } | 303 } |
301 | 304 |
302 #define DEF_VISIT(type) \ | 305 #define DEF_VISIT(type) \ |
(...skipping 1262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1565 parse_info_ = nullptr; | 1568 parse_info_ = nullptr; |
1566 } | 1569 } |
1567 | 1570 |
1568 #if DEBUG | 1571 #if DEBUG |
1569 void CompilationInfo::PrintAstForTesting() { | 1572 void CompilationInfo::PrintAstForTesting() { |
1570 PrintF("--- Source from AST ---\n%s\n", | 1573 PrintF("--- Source from AST ---\n%s\n", |
1571 PrettyPrinter(isolate(), zone()).PrintProgram(function())); | 1574 PrettyPrinter(isolate(), zone()).PrintProgram(function())); |
1572 } | 1575 } |
1573 #endif | 1576 #endif |
1574 } } // namespace v8::internal | 1577 } } // namespace v8::internal |
OLD | NEW |