| 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 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 int CodeGenerator::DefineDeoptimizationLiteral(Handle<Object> literal) { | 303 int CodeGenerator::DefineDeoptimizationLiteral(Handle<Object> literal) { |
| 304 int result = static_cast<int>(deoptimization_literals_.size()); | 304 int result = static_cast<int>(deoptimization_literals_.size()); |
| 305 for (unsigned i = 0; i < deoptimization_literals_.size(); ++i) { | 305 for (unsigned i = 0; i < deoptimization_literals_.size(); ++i) { |
| 306 if (deoptimization_literals_[i].is_identical_to(literal)) return i; | 306 if (deoptimization_literals_[i].is_identical_to(literal)) return i; |
| 307 } | 307 } |
| 308 deoptimization_literals_.push_back(literal); | 308 deoptimization_literals_.push_back(literal); |
| 309 return result; | 309 return result; |
| 310 } | 310 } |
| 311 | 311 |
| 312 | 312 |
| 313 void CodeGenerator::BuildTranslationForFrameStateDescriptor( |
| 314 FrameStateDescriptor* descriptor, Instruction* instr, |
| 315 Translation* translation, int frame_state_offset) { |
| 316 // Oldest parent must be added to translation first. |
| 317 if (descriptor->parent() != NULL) { |
| 318 BuildTranslationForFrameStateDescriptor( |
| 319 descriptor->parent(), instr, translation, |
| 320 frame_state_offset + descriptor->size()); |
| 321 } |
| 322 |
| 323 translation->BeginJSFrame( |
| 324 descriptor->bailout_id(), Translation::kSelfLiteralId, |
| 325 descriptor->size() - descriptor->parameters_count()); |
| 326 |
| 327 for (int i = 0; i < descriptor->size(); i++) { |
| 328 AddTranslationForOperand(translation, instr, |
| 329 instr->InputAt(i + frame_state_offset)); |
| 330 } |
| 331 } |
| 332 |
| 333 |
| 313 int CodeGenerator::BuildTranslation(Instruction* instr, | 334 int CodeGenerator::BuildTranslation(Instruction* instr, |
| 314 int frame_state_offset) { | 335 int frame_state_offset) { |
| 315 InstructionOperandConverter i(this, instr); | 336 InstructionOperandConverter i(this, instr); |
| 316 int deoptimization_id = i.InputInt32(frame_state_offset); | 337 int deoptimization_id = i.InputInt32(frame_state_offset); |
| 317 frame_state_offset++; | 338 frame_state_offset++; |
| 318 | 339 |
| 319 // We should build translation only once. | 340 // We should build translation only once. |
| 320 DCHECK_EQ(NULL, deoptimization_states_[deoptimization_id]); | 341 DCHECK_EQ(NULL, deoptimization_states_[deoptimization_id]); |
| 321 | 342 |
| 322 FrameStateDescriptor* descriptor = | 343 FrameStateDescriptor* descriptor = |
| 323 code()->GetDeoptimizationEntry(deoptimization_id); | 344 code()->GetDeoptimizationEntry(deoptimization_id); |
| 324 Translation translation(&translations_, 1, 1, zone()); | 345 int frame_count = descriptor->GetFrameCount(); |
| 325 translation.BeginJSFrame(descriptor->bailout_id(), | 346 Translation translation(&translations_, frame_count, frame_count, zone()); |
| 326 Translation::kSelfLiteralId, | 347 BuildTranslationForFrameStateDescriptor(descriptor, instr, &translation, |
| 327 descriptor->size() - descriptor->parameters_count()); | 348 frame_state_offset); |
| 328 | |
| 329 for (int i = 0; i < descriptor->size(); i++) { | |
| 330 AddTranslationForOperand(&translation, instr, | |
| 331 instr->InputAt(i + frame_state_offset)); | |
| 332 } | |
| 333 | 349 |
| 334 deoptimization_states_[deoptimization_id] = | 350 deoptimization_states_[deoptimization_id] = |
| 335 new (zone()) DeoptimizationState(translation.index()); | 351 new (zone()) DeoptimizationState(translation.index()); |
| 336 | 352 |
| 337 return deoptimization_id; | 353 return deoptimization_id; |
| 338 } | 354 } |
| 339 | 355 |
| 340 | 356 |
| 341 void CodeGenerator::AddTranslationForOperand(Translation* translation, | 357 void CodeGenerator::AddTranslationForOperand(Translation* translation, |
| 342 Instruction* instr, | 358 Instruction* instr, |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 } | 430 } |
| 415 | 431 |
| 416 | 432 |
| 417 void CodeGenerator::AddNopForSmiCodeInlining() { UNIMPLEMENTED(); } | 433 void CodeGenerator::AddNopForSmiCodeInlining() { UNIMPLEMENTED(); } |
| 418 | 434 |
| 419 #endif // !V8_TURBOFAN_BACKEND | 435 #endif // !V8_TURBOFAN_BACKEND |
| 420 | 436 |
| 421 } // namespace compiler | 437 } // namespace compiler |
| 422 } // namespace internal | 438 } // namespace internal |
| 423 } // namespace v8 | 439 } // namespace v8 |
| OLD | NEW |