| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 720 MemOperand(fp, ArgumentsAdaptorFrameConstants::kLengthOffset)); | 720 MemOperand(fp, ArgumentsAdaptorFrameConstants::kLengthOffset)); |
| 721 __ SmiUntag(caller_args_count_reg); | 721 __ SmiUntag(caller_args_count_reg); |
| 722 | 722 |
| 723 ParameterCount callee_args_count(args_reg); | 723 ParameterCount callee_args_count(args_reg); |
| 724 __ PrepareForTailCall(callee_args_count, caller_args_count_reg, scratch2, | 724 __ PrepareForTailCall(callee_args_count, caller_args_count_reg, scratch2, |
| 725 scratch3); | 725 scratch3); |
| 726 __ bind(&done); | 726 __ bind(&done); |
| 727 } | 727 } |
| 728 | 728 |
| 729 // Assembles an instruction after register allocation, producing machine code. | 729 // Assembles an instruction after register allocation, producing machine code. |
| 730 void CodeGenerator::AssembleArchInstruction(Instruction* instr) { | 730 CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( |
| 731 Instruction* instr) { |
| 731 PPCOperandConverter i(this, instr); | 732 PPCOperandConverter i(this, instr); |
| 732 ArchOpcode opcode = ArchOpcodeField::decode(instr->opcode()); | 733 ArchOpcode opcode = ArchOpcodeField::decode(instr->opcode()); |
| 733 | 734 |
| 734 switch (opcode) { | 735 switch (opcode) { |
| 735 case kArchCallCodeObject: { | 736 case kArchCallCodeObject: { |
| 736 v8::internal::Assembler::BlockTrampolinePoolScope block_trampoline_pool( | 737 v8::internal::Assembler::BlockTrampolinePoolScope block_trampoline_pool( |
| 737 masm()); | 738 masm()); |
| 738 EnsureSpaceForLazyDeopt(); | 739 EnsureSpaceForLazyDeopt(); |
| 739 if (HasRegisterInput(instr, 0)) { | 740 if (HasRegisterInput(instr, 0)) { |
| 740 __ addi(ip, i.InputRegister(0), | 741 __ addi(ip, i.InputRegister(0), |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 861 case kArchNop: | 862 case kArchNop: |
| 862 case kArchThrowTerminator: | 863 case kArchThrowTerminator: |
| 863 // don't emit code for nops. | 864 // don't emit code for nops. |
| 864 DCHECK_EQ(LeaveRC, i.OutputRCBit()); | 865 DCHECK_EQ(LeaveRC, i.OutputRCBit()); |
| 865 break; | 866 break; |
| 866 case kArchDeoptimize: { | 867 case kArchDeoptimize: { |
| 867 int deopt_state_id = | 868 int deopt_state_id = |
| 868 BuildTranslation(instr, -1, 0, OutputFrameStateCombine::Ignore()); | 869 BuildTranslation(instr, -1, 0, OutputFrameStateCombine::Ignore()); |
| 869 Deoptimizer::BailoutType bailout_type = | 870 Deoptimizer::BailoutType bailout_type = |
| 870 Deoptimizer::BailoutType(MiscField::decode(instr->opcode())); | 871 Deoptimizer::BailoutType(MiscField::decode(instr->opcode())); |
| 871 AssembleDeoptimizerCall(deopt_state_id, bailout_type); | 872 CodeGenResult result = |
| 873 AssembleDeoptimizerCall(deopt_state_id, bailout_type); |
| 874 if (result != kSuccess) return result; |
| 872 break; | 875 break; |
| 873 } | 876 } |
| 874 case kArchRet: | 877 case kArchRet: |
| 875 AssembleReturn(); | 878 AssembleReturn(); |
| 876 DCHECK_EQ(LeaveRC, i.OutputRCBit()); | 879 DCHECK_EQ(LeaveRC, i.OutputRCBit()); |
| 877 break; | 880 break; |
| 878 case kArchStackPointer: | 881 case kArchStackPointer: |
| 879 __ mr(i.OutputRegister(), sp); | 882 __ mr(i.OutputRegister(), sp); |
| 880 DCHECK_EQ(LeaveRC, i.OutputRCBit()); | 883 DCHECK_EQ(LeaveRC, i.OutputRCBit()); |
| 881 break; | 884 break; |
| (...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1604 case kAtomicLoadUint16: | 1607 case kAtomicLoadUint16: |
| 1605 ASSEMBLE_ATOMIC_LOAD_INTEGER(lhz, lhzx); | 1608 ASSEMBLE_ATOMIC_LOAD_INTEGER(lhz, lhzx); |
| 1606 break; | 1609 break; |
| 1607 case kAtomicLoadWord32: | 1610 case kAtomicLoadWord32: |
| 1608 ASSEMBLE_ATOMIC_LOAD_INTEGER(lwz, lwzx); | 1611 ASSEMBLE_ATOMIC_LOAD_INTEGER(lwz, lwzx); |
| 1609 break; | 1612 break; |
| 1610 default: | 1613 default: |
| 1611 UNREACHABLE(); | 1614 UNREACHABLE(); |
| 1612 break; | 1615 break; |
| 1613 } | 1616 } |
| 1617 return kSuccess; |
| 1614 } // NOLINT(readability/fn_size) | 1618 } // NOLINT(readability/fn_size) |
| 1615 | 1619 |
| 1616 | 1620 |
| 1617 // Assembles branches after an instruction. | 1621 // Assembles branches after an instruction. |
| 1618 void CodeGenerator::AssembleArchBranch(Instruction* instr, BranchInfo* branch) { | 1622 void CodeGenerator::AssembleArchBranch(Instruction* instr, BranchInfo* branch) { |
| 1619 PPCOperandConverter i(this, instr); | 1623 PPCOperandConverter i(this, instr); |
| 1620 Label* tlabel = branch->true_label; | 1624 Label* tlabel = branch->true_label; |
| 1621 Label* flabel = branch->false_label; | 1625 Label* flabel = branch->false_label; |
| 1622 ArchOpcode op = instr->arch_opcode(); | 1626 ArchOpcode op = instr->arch_opcode(); |
| 1623 FlagsCondition condition = branch->condition; | 1627 FlagsCondition condition = branch->condition; |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1723 } | 1727 } |
| 1724 Label* const table = AddJumpTable(cases, case_count); | 1728 Label* const table = AddJumpTable(cases, case_count); |
| 1725 __ Cmpli(input, Operand(case_count), r0); | 1729 __ Cmpli(input, Operand(case_count), r0); |
| 1726 __ bge(GetLabel(i.InputRpo(1))); | 1730 __ bge(GetLabel(i.InputRpo(1))); |
| 1727 __ mov_label_addr(kScratchReg, table); | 1731 __ mov_label_addr(kScratchReg, table); |
| 1728 __ ShiftLeftImm(r0, input, Operand(kPointerSizeLog2)); | 1732 __ ShiftLeftImm(r0, input, Operand(kPointerSizeLog2)); |
| 1729 __ LoadPX(kScratchReg, MemOperand(kScratchReg, r0)); | 1733 __ LoadPX(kScratchReg, MemOperand(kScratchReg, r0)); |
| 1730 __ Jump(kScratchReg); | 1734 __ Jump(kScratchReg); |
| 1731 } | 1735 } |
| 1732 | 1736 |
| 1733 | 1737 CodeGenerator::CodeGenResult CodeGenerator::AssembleDeoptimizerCall( |
| 1734 void CodeGenerator::AssembleDeoptimizerCall( | |
| 1735 int deoptimization_id, Deoptimizer::BailoutType bailout_type) { | 1738 int deoptimization_id, Deoptimizer::BailoutType bailout_type) { |
| 1736 Address deopt_entry = Deoptimizer::GetDeoptimizationEntry( | 1739 Address deopt_entry = Deoptimizer::GetDeoptimizationEntry( |
| 1737 isolate(), deoptimization_id, bailout_type); | 1740 isolate(), deoptimization_id, bailout_type); |
| 1738 // TODO(turbofan): We should be able to generate better code by sharing the | 1741 // TODO(turbofan): We should be able to generate better code by sharing the |
| 1739 // actual final call site and just bl'ing to it here, similar to what we do | 1742 // actual final call site and just bl'ing to it here, similar to what we do |
| 1740 // in the lithium backend. | 1743 // in the lithium backend. |
| 1744 if (deopt_entry == nullptr) return kTooManyDeoptimizationBailouts; |
| 1741 __ Call(deopt_entry, RelocInfo::RUNTIME_ENTRY); | 1745 __ Call(deopt_entry, RelocInfo::RUNTIME_ENTRY); |
| 1746 return kSuccess; |
| 1742 } | 1747 } |
| 1743 | 1748 |
| 1744 void CodeGenerator::FinishFrame(Frame* frame) { | 1749 void CodeGenerator::FinishFrame(Frame* frame) { |
| 1745 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); | 1750 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); |
| 1746 const RegList double_saves = descriptor->CalleeSavedFPRegisters(); | 1751 const RegList double_saves = descriptor->CalleeSavedFPRegisters(); |
| 1747 | 1752 |
| 1748 // Save callee-saved Double registers. | 1753 // Save callee-saved Double registers. |
| 1749 if (double_saves != 0) { | 1754 if (double_saves != 0) { |
| 1750 frame->AlignSavedCalleeRegisterSlots(); | 1755 frame->AlignSavedCalleeRegisterSlots(); |
| 1751 DCHECK(kNumCalleeSavedDoubles == | 1756 DCHECK(kNumCalleeSavedDoubles == |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2083 padding_size -= v8::internal::Assembler::kInstrSize; | 2088 padding_size -= v8::internal::Assembler::kInstrSize; |
| 2084 } | 2089 } |
| 2085 } | 2090 } |
| 2086 } | 2091 } |
| 2087 | 2092 |
| 2088 #undef __ | 2093 #undef __ |
| 2089 | 2094 |
| 2090 } // namespace compiler | 2095 } // namespace compiler |
| 2091 } // namespace internal | 2096 } // namespace internal |
| 2092 } // namespace v8 | 2097 } // namespace v8 |
| OLD | NEW |