OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/ast/scopes.h" | 7 #include "src/ast/scopes.h" |
8 #include "src/compiler/code-generator-impl.h" | 8 #include "src/compiler/code-generator-impl.h" |
9 #include "src/compiler/gap-resolver.h" | 9 #include "src/compiler/gap-resolver.h" |
10 #include "src/compiler/node-matchers.h" | 10 #include "src/compiler/node-matchers.h" |
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
586 MemOperand(fp, ArgumentsAdaptorFrameConstants::kLengthOffset)); | 586 MemOperand(fp, ArgumentsAdaptorFrameConstants::kLengthOffset)); |
587 __ SmiUntag(caller_args_count_reg); | 587 __ SmiUntag(caller_args_count_reg); |
588 | 588 |
589 ParameterCount callee_args_count(args_reg); | 589 ParameterCount callee_args_count(args_reg); |
590 __ PrepareForTailCall(callee_args_count, caller_args_count_reg, scratch2, | 590 __ PrepareForTailCall(callee_args_count, caller_args_count_reg, scratch2, |
591 scratch3); | 591 scratch3); |
592 __ bind(&done); | 592 __ bind(&done); |
593 } | 593 } |
594 | 594 |
595 // Assembles an instruction after register allocation, producing machine code. | 595 // Assembles an instruction after register allocation, producing machine code. |
596 void CodeGenerator::AssembleArchInstruction(Instruction* instr) { | 596 CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( |
| 597 Instruction* instr) { |
597 S390OperandConverter i(this, instr); | 598 S390OperandConverter i(this, instr); |
598 ArchOpcode opcode = ArchOpcodeField::decode(instr->opcode()); | 599 ArchOpcode opcode = ArchOpcodeField::decode(instr->opcode()); |
599 | 600 |
600 switch (opcode) { | 601 switch (opcode) { |
601 case kArchCallCodeObject: { | 602 case kArchCallCodeObject: { |
602 EnsureSpaceForLazyDeopt(); | 603 EnsureSpaceForLazyDeopt(); |
603 if (HasRegisterInput(instr, 0)) { | 604 if (HasRegisterInput(instr, 0)) { |
604 __ AddP(ip, i.InputRegister(0), | 605 __ AddP(ip, i.InputRegister(0), |
605 Operand(Code::kHeaderSize - kHeapObjectTag)); | 606 Operand(Code::kHeaderSize - kHeapObjectTag)); |
606 __ Call(ip); | 607 __ Call(ip); |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
715 break; | 716 break; |
716 case kArchNop: | 717 case kArchNop: |
717 case kArchThrowTerminator: | 718 case kArchThrowTerminator: |
718 // don't emit code for nops. | 719 // don't emit code for nops. |
719 break; | 720 break; |
720 case kArchDeoptimize: { | 721 case kArchDeoptimize: { |
721 int deopt_state_id = | 722 int deopt_state_id = |
722 BuildTranslation(instr, -1, 0, OutputFrameStateCombine::Ignore()); | 723 BuildTranslation(instr, -1, 0, OutputFrameStateCombine::Ignore()); |
723 Deoptimizer::BailoutType bailout_type = | 724 Deoptimizer::BailoutType bailout_type = |
724 Deoptimizer::BailoutType(MiscField::decode(instr->opcode())); | 725 Deoptimizer::BailoutType(MiscField::decode(instr->opcode())); |
725 AssembleDeoptimizerCall(deopt_state_id, bailout_type); | 726 CodeGenResult result = |
| 727 AssembleDeoptimizerCall(deopt_state_id, bailout_type); |
| 728 if (result != kSuccess) return result; |
726 break; | 729 break; |
727 } | 730 } |
728 case kArchRet: | 731 case kArchRet: |
729 AssembleReturn(); | 732 AssembleReturn(); |
730 break; | 733 break; |
731 case kArchStackPointer: | 734 case kArchStackPointer: |
732 __ LoadRR(i.OutputRegister(), sp); | 735 __ LoadRR(i.OutputRegister(), sp); |
733 break; | 736 break; |
734 case kArchFramePointer: | 737 case kArchFramePointer: |
735 __ LoadRR(i.OutputRegister(), fp); | 738 __ LoadRR(i.OutputRegister(), fp); |
(...skipping 918 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1654 case kAtomicLoadUint16: | 1657 case kAtomicLoadUint16: |
1655 __ LoadLogicalHalfWordP(i.OutputRegister(), i.MemoryOperand()); | 1658 __ LoadLogicalHalfWordP(i.OutputRegister(), i.MemoryOperand()); |
1656 break; | 1659 break; |
1657 case kAtomicLoadWord32: | 1660 case kAtomicLoadWord32: |
1658 __ LoadlW(i.OutputRegister(), i.MemoryOperand()); | 1661 __ LoadlW(i.OutputRegister(), i.MemoryOperand()); |
1659 break; | 1662 break; |
1660 default: | 1663 default: |
1661 UNREACHABLE(); | 1664 UNREACHABLE(); |
1662 break; | 1665 break; |
1663 } | 1666 } |
| 1667 return kSuccess; |
1664 } // NOLINT(readability/fn_size) | 1668 } // NOLINT(readability/fn_size) |
1665 | 1669 |
1666 // Assembles branches after an instruction. | 1670 // Assembles branches after an instruction. |
1667 void CodeGenerator::AssembleArchBranch(Instruction* instr, BranchInfo* branch) { | 1671 void CodeGenerator::AssembleArchBranch(Instruction* instr, BranchInfo* branch) { |
1668 S390OperandConverter i(this, instr); | 1672 S390OperandConverter i(this, instr); |
1669 Label* tlabel = branch->true_label; | 1673 Label* tlabel = branch->true_label; |
1670 Label* flabel = branch->false_label; | 1674 Label* flabel = branch->false_label; |
1671 ArchOpcode op = instr->arch_opcode(); | 1675 ArchOpcode op = instr->arch_opcode(); |
1672 FlagsCondition condition = branch->condition; | 1676 FlagsCondition condition = branch->condition; |
1673 | 1677 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1773 } | 1777 } |
1774 Label* const table = AddJumpTable(cases, case_count); | 1778 Label* const table = AddJumpTable(cases, case_count); |
1775 __ CmpLogicalP(input, Operand(case_count)); | 1779 __ CmpLogicalP(input, Operand(case_count)); |
1776 __ bge(GetLabel(i.InputRpo(1))); | 1780 __ bge(GetLabel(i.InputRpo(1))); |
1777 __ larl(kScratchReg, table); | 1781 __ larl(kScratchReg, table); |
1778 __ ShiftLeftP(r1, input, Operand(kPointerSizeLog2)); | 1782 __ ShiftLeftP(r1, input, Operand(kPointerSizeLog2)); |
1779 __ LoadP(kScratchReg, MemOperand(kScratchReg, r1)); | 1783 __ LoadP(kScratchReg, MemOperand(kScratchReg, r1)); |
1780 __ Jump(kScratchReg); | 1784 __ Jump(kScratchReg); |
1781 } | 1785 } |
1782 | 1786 |
1783 void CodeGenerator::AssembleDeoptimizerCall( | 1787 CodeGenerator::CodeGenResult CodeGenerator::AssembleDeoptimizerCall( |
1784 int deoptimization_id, Deoptimizer::BailoutType bailout_type) { | 1788 int deoptimization_id, Deoptimizer::BailoutType bailout_type) { |
1785 Address deopt_entry = Deoptimizer::GetDeoptimizationEntry( | 1789 Address deopt_entry = Deoptimizer::GetDeoptimizationEntry( |
1786 isolate(), deoptimization_id, bailout_type); | 1790 isolate(), deoptimization_id, bailout_type); |
1787 // TODO(turbofan): We should be able to generate better code by sharing the | 1791 // TODO(turbofan): We should be able to generate better code by sharing the |
1788 // actual final call site and just bl'ing to it here, similar to what we do | 1792 // actual final call site and just bl'ing to it here, similar to what we do |
1789 // in the lithium backend. | 1793 // in the lithium backend. |
| 1794 if (deopt_entry == nullptr) return kTooManyDeoptimizationBailouts; |
1790 __ Call(deopt_entry, RelocInfo::RUNTIME_ENTRY); | 1795 __ Call(deopt_entry, RelocInfo::RUNTIME_ENTRY); |
| 1796 return kSuccess; |
1791 } | 1797 } |
1792 | 1798 |
1793 void CodeGenerator::FinishFrame(Frame* frame) { | 1799 void CodeGenerator::FinishFrame(Frame* frame) { |
1794 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); | 1800 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); |
1795 const RegList double_saves = descriptor->CalleeSavedFPRegisters(); | 1801 const RegList double_saves = descriptor->CalleeSavedFPRegisters(); |
1796 | 1802 |
1797 // Save callee-saved Double registers. | 1803 // Save callee-saved Double registers. |
1798 if (double_saves != 0) { | 1804 if (double_saves != 0) { |
1799 frame->AlignSavedCalleeRegisterSlots(); | 1805 frame->AlignSavedCalleeRegisterSlots(); |
1800 DCHECK(kNumCalleeSavedDoubles == | 1806 DCHECK(kNumCalleeSavedDoubles == |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2112 padding_size -= 2; | 2118 padding_size -= 2; |
2113 } | 2119 } |
2114 } | 2120 } |
2115 } | 2121 } |
2116 | 2122 |
2117 #undef __ | 2123 #undef __ |
2118 | 2124 |
2119 } // namespace compiler | 2125 } // namespace compiler |
2120 } // namespace internal | 2126 } // namespace internal |
2121 } // namespace v8 | 2127 } // namespace v8 |
OLD | NEW |