| 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/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 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 642 caller_args_count_reg, | 642 caller_args_count_reg, |
| 643 Operand(rbp, ArgumentsAdaptorFrameConstants::kLengthOffset)); | 643 Operand(rbp, ArgumentsAdaptorFrameConstants::kLengthOffset)); |
| 644 | 644 |
| 645 ParameterCount callee_args_count(args_reg); | 645 ParameterCount callee_args_count(args_reg); |
| 646 __ PrepareForTailCall(callee_args_count, caller_args_count_reg, scratch2, | 646 __ PrepareForTailCall(callee_args_count, caller_args_count_reg, scratch2, |
| 647 scratch3, ReturnAddressState::kOnStack); | 647 scratch3, ReturnAddressState::kOnStack); |
| 648 __ bind(&done); | 648 __ bind(&done); |
| 649 } | 649 } |
| 650 | 650 |
| 651 // Assembles an instruction after register allocation, producing machine code. | 651 // Assembles an instruction after register allocation, producing machine code. |
| 652 void CodeGenerator::AssembleArchInstruction(Instruction* instr) { | 652 CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( |
| 653 Instruction* instr) { |
| 653 X64OperandConverter i(this, instr); | 654 X64OperandConverter i(this, instr); |
| 654 InstructionCode opcode = instr->opcode(); | 655 InstructionCode opcode = instr->opcode(); |
| 655 ArchOpcode arch_opcode = ArchOpcodeField::decode(opcode); | 656 ArchOpcode arch_opcode = ArchOpcodeField::decode(opcode); |
| 656 switch (arch_opcode) { | 657 switch (arch_opcode) { |
| 657 case kArchCallCodeObject: { | 658 case kArchCallCodeObject: { |
| 658 EnsureSpaceForLazyDeopt(); | 659 EnsureSpaceForLazyDeopt(); |
| 659 if (HasImmediateInput(instr, 0)) { | 660 if (HasImmediateInput(instr, 0)) { |
| 660 Handle<Code> code = Handle<Code>::cast(i.InputHeapObject(0)); | 661 Handle<Code> code = Handle<Code>::cast(i.InputHeapObject(0)); |
| 661 __ Call(code, RelocInfo::CODE_TARGET); | 662 __ Call(code, RelocInfo::CODE_TARGET); |
| 662 } else { | 663 } else { |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 763 break; | 764 break; |
| 764 case kArchNop: | 765 case kArchNop: |
| 765 case kArchThrowTerminator: | 766 case kArchThrowTerminator: |
| 766 // don't emit code for nops. | 767 // don't emit code for nops. |
| 767 break; | 768 break; |
| 768 case kArchDeoptimize: { | 769 case kArchDeoptimize: { |
| 769 int deopt_state_id = | 770 int deopt_state_id = |
| 770 BuildTranslation(instr, -1, 0, OutputFrameStateCombine::Ignore()); | 771 BuildTranslation(instr, -1, 0, OutputFrameStateCombine::Ignore()); |
| 771 Deoptimizer::BailoutType bailout_type = | 772 Deoptimizer::BailoutType bailout_type = |
| 772 Deoptimizer::BailoutType(MiscField::decode(instr->opcode())); | 773 Deoptimizer::BailoutType(MiscField::decode(instr->opcode())); |
| 773 AssembleDeoptimizerCall(deopt_state_id, bailout_type); | 774 CodeGenResult result = |
| 775 AssembleDeoptimizerCall(deopt_state_id, bailout_type); |
| 776 if (result != kSuccess) return result; |
| 774 break; | 777 break; |
| 775 } | 778 } |
| 776 case kArchRet: | 779 case kArchRet: |
| 777 AssembleReturn(); | 780 AssembleReturn(); |
| 778 break; | 781 break; |
| 779 case kArchStackPointer: | 782 case kArchStackPointer: |
| 780 __ movq(i.OutputRegister(), rsp); | 783 __ movq(i.OutputRegister(), rsp); |
| 781 break; | 784 break; |
| 782 case kArchFramePointer: | 785 case kArchFramePointer: |
| 783 __ movq(i.OutputRegister(), rbp); | 786 __ movq(i.OutputRegister(), rbp); |
| (...skipping 977 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1761 __ CompareRoot(rsp, Heap::kStackLimitRootIndex); | 1764 __ CompareRoot(rsp, Heap::kStackLimitRootIndex); |
| 1762 break; | 1765 break; |
| 1763 case kAtomicLoadInt8: | 1766 case kAtomicLoadInt8: |
| 1764 case kAtomicLoadUint8: | 1767 case kAtomicLoadUint8: |
| 1765 case kAtomicLoadInt16: | 1768 case kAtomicLoadInt16: |
| 1766 case kAtomicLoadUint16: | 1769 case kAtomicLoadUint16: |
| 1767 case kAtomicLoadWord32: | 1770 case kAtomicLoadWord32: |
| 1768 UNREACHABLE(); // Won't be generated by instruction selector. | 1771 UNREACHABLE(); // Won't be generated by instruction selector. |
| 1769 break; | 1772 break; |
| 1770 } | 1773 } |
| 1774 return kSuccess; |
| 1771 } // NOLINT(readability/fn_size) | 1775 } // NOLINT(readability/fn_size) |
| 1772 | 1776 |
| 1773 | 1777 |
| 1774 // Assembles branches after this instruction. | 1778 // Assembles branches after this instruction. |
| 1775 void CodeGenerator::AssembleArchBranch(Instruction* instr, BranchInfo* branch) { | 1779 void CodeGenerator::AssembleArchBranch(Instruction* instr, BranchInfo* branch) { |
| 1776 X64OperandConverter i(this, instr); | 1780 X64OperandConverter i(this, instr); |
| 1777 Label::Distance flabel_distance = | 1781 Label::Distance flabel_distance = |
| 1778 branch->fallthru ? Label::kNear : Label::kFar; | 1782 branch->fallthru ? Label::kNear : Label::kFar; |
| 1779 Label* tlabel = branch->true_label; | 1783 Label* tlabel = branch->true_label; |
| 1780 Label* flabel = branch->false_label; | 1784 Label* flabel = branch->false_label; |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1923 for (int32_t index = 0; index < case_count; ++index) { | 1927 for (int32_t index = 0; index < case_count; ++index) { |
| 1924 cases[index] = GetLabel(i.InputRpo(index + 2)); | 1928 cases[index] = GetLabel(i.InputRpo(index + 2)); |
| 1925 } | 1929 } |
| 1926 Label* const table = AddJumpTable(cases, case_count); | 1930 Label* const table = AddJumpTable(cases, case_count); |
| 1927 __ cmpl(input, Immediate(case_count)); | 1931 __ cmpl(input, Immediate(case_count)); |
| 1928 __ j(above_equal, GetLabel(i.InputRpo(1))); | 1932 __ j(above_equal, GetLabel(i.InputRpo(1))); |
| 1929 __ leaq(kScratchRegister, Operand(table)); | 1933 __ leaq(kScratchRegister, Operand(table)); |
| 1930 __ jmp(Operand(kScratchRegister, input, times_8, 0)); | 1934 __ jmp(Operand(kScratchRegister, input, times_8, 0)); |
| 1931 } | 1935 } |
| 1932 | 1936 |
| 1933 | 1937 CodeGenerator::CodeGenResult CodeGenerator::AssembleDeoptimizerCall( |
| 1934 void CodeGenerator::AssembleDeoptimizerCall( | |
| 1935 int deoptimization_id, Deoptimizer::BailoutType bailout_type) { | 1938 int deoptimization_id, Deoptimizer::BailoutType bailout_type) { |
| 1936 Address deopt_entry = Deoptimizer::GetDeoptimizationEntry( | 1939 Address deopt_entry = Deoptimizer::GetDeoptimizationEntry( |
| 1937 isolate(), deoptimization_id, bailout_type); | 1940 isolate(), deoptimization_id, bailout_type); |
| 1941 if (deopt_entry == nullptr) return kTooManyDeoptimizationBailouts; |
| 1938 __ call(deopt_entry, RelocInfo::RUNTIME_ENTRY); | 1942 __ call(deopt_entry, RelocInfo::RUNTIME_ENTRY); |
| 1943 return kSuccess; |
| 1939 } | 1944 } |
| 1940 | 1945 |
| 1941 | 1946 |
| 1942 namespace { | 1947 namespace { |
| 1943 | 1948 |
| 1944 static const int kQuadWordSize = 16; | 1949 static const int kQuadWordSize = 16; |
| 1945 | 1950 |
| 1946 } // namespace | 1951 } // namespace |
| 1947 | 1952 |
| 1948 void CodeGenerator::FinishFrame(Frame* frame) { | 1953 void CodeGenerator::FinishFrame(Frame* frame) { |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2289 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; | 2294 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; |
| 2290 __ Nop(padding_size); | 2295 __ Nop(padding_size); |
| 2291 } | 2296 } |
| 2292 } | 2297 } |
| 2293 | 2298 |
| 2294 #undef __ | 2299 #undef __ |
| 2295 | 2300 |
| 2296 } // namespace compiler | 2301 } // namespace compiler |
| 2297 } // namespace internal | 2302 } // namespace internal |
| 2298 } // namespace v8 | 2303 } // namespace v8 |
| OLD | NEW |