OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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/code-generator.h" | 5 #include "src/compiler/code-generator.h" |
6 | 6 |
7 #include "src/compiler/code-generator-impl.h" | 7 #include "src/compiler/code-generator-impl.h" |
8 #include "src/compiler/linkage.h" | 8 #include "src/compiler/linkage.h" |
9 #include "src/compiler/pipeline.h" | 9 #include "src/compiler/pipeline.h" |
10 | 10 |
(...skipping 10 matching lines...) Expand all Loading... |
21 labels_(zone()->NewArray<Label>(code->InstructionBlockCount())), | 21 labels_(zone()->NewArray<Label>(code->InstructionBlockCount())), |
22 current_block_(BasicBlock::RpoNumber::Invalid()), | 22 current_block_(BasicBlock::RpoNumber::Invalid()), |
23 current_source_position_(SourcePosition::Invalid()), | 23 current_source_position_(SourcePosition::Invalid()), |
24 masm_(code->zone()->isolate(), NULL, 0), | 24 masm_(code->zone()->isolate(), NULL, 0), |
25 resolver_(this), | 25 resolver_(this), |
26 safepoints_(code->zone()), | 26 safepoints_(code->zone()), |
27 deoptimization_states_(code->zone()), | 27 deoptimization_states_(code->zone()), |
28 deoptimization_literals_(code->zone()), | 28 deoptimization_literals_(code->zone()), |
29 translations_(code->zone()), | 29 translations_(code->zone()), |
30 last_lazy_deopt_pc_(0), | 30 last_lazy_deopt_pc_(0), |
31 ools_(nullptr) { | 31 ools_(nullptr), |
| 32 osr_pc_offset_(-1) { |
32 for (int i = 0; i < code->InstructionBlockCount(); ++i) { | 33 for (int i = 0; i < code->InstructionBlockCount(); ++i) { |
33 new (&labels_[i]) Label; | 34 new (&labels_[i]) Label; |
34 } | 35 } |
35 } | 36 } |
36 | 37 |
37 | 38 |
38 Handle<Code> CodeGenerator::GenerateCode() { | 39 Handle<Code> CodeGenerator::GenerateCode() { |
39 CompilationInfo* info = this->info(); | 40 CompilationInfo* info = this->info(); |
40 | 41 |
41 // Emit a code line info recording start event. | 42 // Emit a code line info recording start event. |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 static_cast<GapInstruction::InnerPosition>(i); | 230 static_cast<GapInstruction::InnerPosition>(i); |
230 ParallelMove* move = instr->GetParallelMove(inner_pos); | 231 ParallelMove* move = instr->GetParallelMove(inner_pos); |
231 if (move != NULL) resolver()->Resolve(move); | 232 if (move != NULL) resolver()->Resolve(move); |
232 } | 233 } |
233 } | 234 } |
234 | 235 |
235 | 236 |
236 void CodeGenerator::PopulateDeoptimizationData(Handle<Code> code_object) { | 237 void CodeGenerator::PopulateDeoptimizationData(Handle<Code> code_object) { |
237 CompilationInfo* info = this->info(); | 238 CompilationInfo* info = this->info(); |
238 int deopt_count = static_cast<int>(deoptimization_states_.size()); | 239 int deopt_count = static_cast<int>(deoptimization_states_.size()); |
239 if (deopt_count == 0) return; | 240 if (deopt_count == 0 && !info->is_osr()) return; |
240 Handle<DeoptimizationInputData> data = | 241 Handle<DeoptimizationInputData> data = |
241 DeoptimizationInputData::New(isolate(), deopt_count, TENURED); | 242 DeoptimizationInputData::New(isolate(), deopt_count, TENURED); |
242 | 243 |
243 Handle<ByteArray> translation_array = | 244 Handle<ByteArray> translation_array = |
244 translations_.CreateByteArray(isolate()->factory()); | 245 translations_.CreateByteArray(isolate()->factory()); |
245 | 246 |
246 data->SetTranslationByteArray(*translation_array); | 247 data->SetTranslationByteArray(*translation_array); |
247 data->SetInlinedFunctionCount(Smi::FromInt(0)); | 248 data->SetInlinedFunctionCount(Smi::FromInt(0)); |
248 data->SetOptimizationId(Smi::FromInt(info->optimization_id())); | 249 data->SetOptimizationId(Smi::FromInt(info->optimization_id())); |
249 // TODO(jarin) The following code was copied over from Lithium, not sure | 250 // TODO(jarin) The following code was copied over from Lithium, not sure |
250 // whether the scope or the IsOptimizing condition are really needed. | 251 // whether the scope or the IsOptimizing condition are really needed. |
251 if (info->IsOptimizing()) { | 252 if (info->IsOptimizing()) { |
252 // Reference to shared function info does not change between phases. | 253 // Reference to shared function info does not change between phases. |
253 AllowDeferredHandleDereference allow_handle_dereference; | 254 AllowDeferredHandleDereference allow_handle_dereference; |
254 data->SetSharedFunctionInfo(*info->shared_info()); | 255 data->SetSharedFunctionInfo(*info->shared_info()); |
255 } else { | 256 } else { |
256 data->SetSharedFunctionInfo(Smi::FromInt(0)); | 257 data->SetSharedFunctionInfo(Smi::FromInt(0)); |
257 } | 258 } |
258 | 259 |
259 Handle<FixedArray> literals = isolate()->factory()->NewFixedArray( | 260 Handle<FixedArray> literals = isolate()->factory()->NewFixedArray( |
260 static_cast<int>(deoptimization_literals_.size()), TENURED); | 261 static_cast<int>(deoptimization_literals_.size()), TENURED); |
261 { | 262 { |
262 AllowDeferredHandleDereference copy_handles; | 263 AllowDeferredHandleDereference copy_handles; |
263 for (unsigned i = 0; i < deoptimization_literals_.size(); i++) { | 264 for (unsigned i = 0; i < deoptimization_literals_.size(); i++) { |
264 literals->set(i, *deoptimization_literals_[i]); | 265 literals->set(i, *deoptimization_literals_[i]); |
265 } | 266 } |
266 data->SetLiteralArray(*literals); | 267 data->SetLiteralArray(*literals); |
267 } | 268 } |
268 | 269 |
269 // No OSR in Turbofan yet... | 270 if (info->is_osr()) { |
270 BailoutId osr_ast_id = BailoutId::None(); | 271 DCHECK(osr_pc_offset_ >= 0); |
271 data->SetOsrAstId(Smi::FromInt(osr_ast_id.ToInt())); | 272 data->SetOsrAstId(Smi::FromInt(info_->osr_ast_id().ToInt())); |
272 data->SetOsrPcOffset(Smi::FromInt(-1)); | 273 data->SetOsrPcOffset(Smi::FromInt(osr_pc_offset_)); |
| 274 } else { |
| 275 BailoutId osr_ast_id = BailoutId::None(); |
| 276 data->SetOsrAstId(Smi::FromInt(osr_ast_id.ToInt())); |
| 277 data->SetOsrPcOffset(Smi::FromInt(-1)); |
| 278 } |
273 | 279 |
274 // Populate deoptimization entries. | 280 // Populate deoptimization entries. |
275 for (int i = 0; i < deopt_count; i++) { | 281 for (int i = 0; i < deopt_count; i++) { |
276 DeoptimizationState* deoptimization_state = deoptimization_states_[i]; | 282 DeoptimizationState* deoptimization_state = deoptimization_states_[i]; |
277 data->SetAstId(i, deoptimization_state->bailout_id()); | 283 data->SetAstId(i, deoptimization_state->bailout_id()); |
278 CHECK_NE(NULL, deoptimization_states_[i]); | 284 CHECK_NE(NULL, deoptimization_states_[i]); |
279 data->SetTranslationIndex( | 285 data->SetTranslationIndex( |
280 i, Smi::FromInt(deoptimization_states_[i]->translation_id())); | 286 i, Smi::FromInt(deoptimization_states_[i]->translation_id())); |
281 data->SetArgumentsStackHeight(i, Smi::FromInt(0)); | 287 data->SetArgumentsStackHeight(i, Smi::FromInt(0)); |
282 data->SetPc(i, Smi::FromInt(deoptimization_state->pc_offset())); | 288 data->SetPc(i, Smi::FromInt(deoptimization_state->pc_offset())); |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
578 : masm_(gen->masm()), next_(gen->ools_) { | 584 : masm_(gen->masm()), next_(gen->ools_) { |
579 gen->ools_ = this; | 585 gen->ools_ = this; |
580 } | 586 } |
581 | 587 |
582 | 588 |
583 OutOfLineCode::~OutOfLineCode() {} | 589 OutOfLineCode::~OutOfLineCode() {} |
584 | 590 |
585 } // namespace compiler | 591 } // namespace compiler |
586 } // namespace internal | 592 } // namespace internal |
587 } // namespace v8 | 593 } // namespace v8 |
OLD | NEW |