| 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/address-map.h" | 7 #include "src/address-map.h" |
| 8 #include "src/compiler/code-generator-impl.h" | 8 #include "src/compiler/code-generator-impl.h" |
| 9 #include "src/compiler/linkage.h" | 9 #include "src/compiler/linkage.h" |
| 10 #include "src/compiler/pipeline.h" | 10 #include "src/compiler/pipeline.h" |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 | 201 |
| 202 // Emit a code line info recording stop event. | 202 // Emit a code line info recording stop event. |
| 203 void* line_info = recorder->DetachJITHandlerData(); | 203 void* line_info = recorder->DetachJITHandlerData(); |
| 204 LOG_CODE_EVENT(isolate(), CodeEndLinePosInfoRecordEvent(*result, line_info)); | 204 LOG_CODE_EVENT(isolate(), CodeEndLinePosInfoRecordEvent(*result, line_info)); |
| 205 | 205 |
| 206 return result; | 206 return result; |
| 207 } | 207 } |
| 208 | 208 |
| 209 | 209 |
| 210 bool CodeGenerator::IsNextInAssemblyOrder(RpoNumber block) const { | 210 bool CodeGenerator::IsNextInAssemblyOrder(RpoNumber block) const { |
| 211 return code()->InstructionBlockAt(current_block_)->ao_number().IsNext( | 211 return code() |
| 212 code()->InstructionBlockAt(block)->ao_number()); | 212 ->InstructionBlockAt(current_block_) |
| 213 ->ao_number() |
| 214 .IsNext(code()->InstructionBlockAt(block)->ao_number()); |
| 213 } | 215 } |
| 214 | 216 |
| 215 | 217 |
| 216 void CodeGenerator::RecordSafepoint(ReferenceMap* references, | 218 void CodeGenerator::RecordSafepoint(ReferenceMap* references, |
| 217 Safepoint::Kind kind, int arguments, | 219 Safepoint::Kind kind, int arguments, |
| 218 Safepoint::DeoptMode deopt_mode) { | 220 Safepoint::DeoptMode deopt_mode) { |
| 219 Safepoint safepoint = | 221 Safepoint safepoint = |
| 220 safepoints()->DefineSafepoint(masm(), kind, arguments, deopt_mode); | 222 safepoints()->DefineSafepoint(masm(), kind, arguments, deopt_mode); |
| 221 int stackSlotToSpillSlotDelta = | 223 int stackSlotToSpillSlotDelta = |
| 222 frame()->GetTotalFrameSlotCount() - frame()->GetSpillSlotCount(); | 224 frame()->GetTotalFrameSlotCount() - frame()->GetSpillSlotCount(); |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 | 476 |
| 475 FrameStateDescriptor* CodeGenerator::GetFrameStateDescriptor( | 477 FrameStateDescriptor* CodeGenerator::GetFrameStateDescriptor( |
| 476 Instruction* instr, size_t frame_state_offset) { | 478 Instruction* instr, size_t frame_state_offset) { |
| 477 InstructionOperandConverter i(this, instr); | 479 InstructionOperandConverter i(this, instr); |
| 478 InstructionSequence::StateId state_id = | 480 InstructionSequence::StateId state_id = |
| 479 InstructionSequence::StateId::FromInt(i.InputInt32(frame_state_offset)); | 481 InstructionSequence::StateId::FromInt(i.InputInt32(frame_state_offset)); |
| 480 return code()->GetFrameStateDescriptor(state_id); | 482 return code()->GetFrameStateDescriptor(state_id); |
| 481 } | 483 } |
| 482 | 484 |
| 483 | 485 |
| 484 namespace { | |
| 485 | |
| 486 struct OperandAndType { | |
| 487 InstructionOperand* const operand; | |
| 488 MachineType const type; | |
| 489 }; | |
| 490 | |
| 491 | |
| 492 OperandAndType TypedOperandForFrameState(FrameStateDescriptor* descriptor, | |
| 493 Instruction* instr, | |
| 494 size_t frame_state_offset, | |
| 495 size_t index, | |
| 496 OutputFrameStateCombine combine) { | |
| 497 DCHECK(index < descriptor->GetSize(combine)); | |
| 498 switch (combine.kind()) { | |
| 499 case OutputFrameStateCombine::kPushOutput: { | |
| 500 DCHECK(combine.GetPushCount() <= instr->OutputCount()); | |
| 501 size_t size_without_output = | |
| 502 descriptor->GetSize(OutputFrameStateCombine::Ignore()); | |
| 503 // If the index is past the existing stack items, return the output. | |
| 504 if (index >= size_without_output) { | |
| 505 return {instr->OutputAt(index - size_without_output), kMachAnyTagged}; | |
| 506 } | |
| 507 break; | |
| 508 } | |
| 509 case OutputFrameStateCombine::kPokeAt: | |
| 510 size_t index_from_top = | |
| 511 descriptor->GetSize(combine) - 1 - combine.GetOffsetToPokeAt(); | |
| 512 if (index >= index_from_top && | |
| 513 index < index_from_top + instr->OutputCount()) { | |
| 514 return {instr->OutputAt(index - index_from_top), kMachAnyTagged}; | |
| 515 } | |
| 516 break; | |
| 517 } | |
| 518 return {instr->InputAt(frame_state_offset + index), | |
| 519 descriptor->GetType(index)}; | |
| 520 } | |
| 521 | |
| 522 } // namespace | |
| 523 | |
| 524 | |
| 525 void CodeGenerator::BuildTranslationForFrameStateDescriptor( | 486 void CodeGenerator::BuildTranslationForFrameStateDescriptor( |
| 526 FrameStateDescriptor* descriptor, Instruction* instr, | 487 FrameStateDescriptor* descriptor, Instruction* instr, |
| 527 Translation* translation, size_t frame_state_offset, | 488 Translation* translation, size_t frame_state_offset, |
| 528 OutputFrameStateCombine state_combine) { | 489 OutputFrameStateCombine state_combine) { |
| 529 // Outer-most state must be added to translation first. | 490 // Outer-most state must be added to translation first. |
| 530 if (descriptor->outer_state() != nullptr) { | 491 if (descriptor->outer_state() != nullptr) { |
| 531 BuildTranslationForFrameStateDescriptor(descriptor->outer_state(), instr, | 492 BuildTranslationForFrameStateDescriptor(descriptor->outer_state(), instr, |
| 532 translation, frame_state_offset, | 493 translation, frame_state_offset, |
| 533 OutputFrameStateCombine::Ignore()); | 494 OutputFrameStateCombine::Ignore()); |
| 534 } | 495 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 553 shared_info_id, | 514 shared_info_id, |
| 554 static_cast<unsigned int>(descriptor->parameters_count())); | 515 static_cast<unsigned int>(descriptor->parameters_count())); |
| 555 break; | 516 break; |
| 556 case FrameStateType::kConstructStub: | 517 case FrameStateType::kConstructStub: |
| 557 translation->BeginConstructStubFrame( | 518 translation->BeginConstructStubFrame( |
| 558 shared_info_id, | 519 shared_info_id, |
| 559 static_cast<unsigned int>(descriptor->parameters_count())); | 520 static_cast<unsigned int>(descriptor->parameters_count())); |
| 560 break; | 521 break; |
| 561 } | 522 } |
| 562 | 523 |
| 563 for (size_t i = 0; i < descriptor->GetSize(state_combine); i++) { | 524 descriptor->TranslateOperands(this, instr, frame_state_offset, state_combine, |
| 564 OperandAndType op = TypedOperandForFrameState( | 525 translation); |
| 565 descriptor, instr, frame_state_offset, i, state_combine); | |
| 566 AddTranslationForOperand(translation, instr, op.operand, op.type); | |
| 567 } | |
| 568 } | 526 } |
| 569 | 527 |
| 570 | 528 |
| 571 int CodeGenerator::BuildTranslation(Instruction* instr, int pc_offset, | 529 int CodeGenerator::BuildTranslation(Instruction* instr, int pc_offset, |
| 572 size_t frame_state_offset, | 530 size_t frame_state_offset, |
| 573 OutputFrameStateCombine state_combine) { | 531 OutputFrameStateCombine state_combine) { |
| 574 FrameStateDescriptor* descriptor = | 532 FrameStateDescriptor* descriptor = |
| 575 GetFrameStateDescriptor(instr, frame_state_offset); | 533 GetFrameStateDescriptor(instr, frame_state_offset); |
| 576 frame_state_offset++; | 534 frame_state_offset++; |
| 577 | 535 |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 691 : frame_(gen->frame()), masm_(gen->masm()), next_(gen->ools_) { | 649 : frame_(gen->frame()), masm_(gen->masm()), next_(gen->ools_) { |
| 692 gen->ools_ = this; | 650 gen->ools_ = this; |
| 693 } | 651 } |
| 694 | 652 |
| 695 | 653 |
| 696 OutOfLineCode::~OutOfLineCode() {} | 654 OutOfLineCode::~OutOfLineCode() {} |
| 697 | 655 |
| 698 } // namespace compiler | 656 } // namespace compiler |
| 699 } // namespace internal | 657 } // namespace internal |
| 700 } // namespace v8 | 658 } // namespace v8 |
| OLD | NEW |