| 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/ast/scopes.h" | 5 #include "src/ast/scopes.h" |
| 6 #include "src/compiler/code-generator.h" | 6 #include "src/compiler/code-generator.h" |
| 7 #include "src/compiler/code-generator-impl.h" | 7 #include "src/compiler/code-generator-impl.h" |
| 8 #include "src/compiler/gap-resolver.h" | 8 #include "src/compiler/gap-resolver.h" |
| 9 #include "src/compiler/node-matchers.h" | 9 #include "src/compiler/node-matchers.h" |
| 10 #include "src/compiler/osr.h" | 10 #include "src/compiler/osr.h" |
| (...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 MemOperand(fp, ArgumentsAdaptorFrameConstants::kLengthOffset)); | 536 MemOperand(fp, ArgumentsAdaptorFrameConstants::kLengthOffset)); |
| 537 __ SmiUntag(caller_args_count_reg); | 537 __ SmiUntag(caller_args_count_reg); |
| 538 | 538 |
| 539 ParameterCount callee_args_count(args_reg); | 539 ParameterCount callee_args_count(args_reg); |
| 540 __ PrepareForTailCall(callee_args_count, caller_args_count_reg, scratch2, | 540 __ PrepareForTailCall(callee_args_count, caller_args_count_reg, scratch2, |
| 541 scratch3); | 541 scratch3); |
| 542 __ bind(&done); | 542 __ bind(&done); |
| 543 } | 543 } |
| 544 | 544 |
| 545 // Assembles an instruction after register allocation, producing machine code. | 545 // Assembles an instruction after register allocation, producing machine code. |
| 546 void CodeGenerator::AssembleArchInstruction(Instruction* instr) { | 546 CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( |
| 547 Instruction* instr) { |
| 547 MipsOperandConverter i(this, instr); | 548 MipsOperandConverter i(this, instr); |
| 548 InstructionCode opcode = instr->opcode(); | 549 InstructionCode opcode = instr->opcode(); |
| 549 ArchOpcode arch_opcode = ArchOpcodeField::decode(opcode); | 550 ArchOpcode arch_opcode = ArchOpcodeField::decode(opcode); |
| 550 switch (arch_opcode) { | 551 switch (arch_opcode) { |
| 551 case kArchCallCodeObject: { | 552 case kArchCallCodeObject: { |
| 552 EnsureSpaceForLazyDeopt(); | 553 EnsureSpaceForLazyDeopt(); |
| 553 if (instr->InputAt(0)->IsImmediate()) { | 554 if (instr->InputAt(0)->IsImmediate()) { |
| 554 __ Call(Handle<Code>::cast(i.InputHeapObject(0)), | 555 __ Call(Handle<Code>::cast(i.InputHeapObject(0)), |
| 555 RelocInfo::CODE_TARGET); | 556 RelocInfo::CODE_TARGET); |
| 556 } else { | 557 } else { |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 656 break; | 657 break; |
| 657 case kArchNop: | 658 case kArchNop: |
| 658 case kArchThrowTerminator: | 659 case kArchThrowTerminator: |
| 659 // don't emit code for nops. | 660 // don't emit code for nops. |
| 660 break; | 661 break; |
| 661 case kArchDeoptimize: { | 662 case kArchDeoptimize: { |
| 662 int deopt_state_id = | 663 int deopt_state_id = |
| 663 BuildTranslation(instr, -1, 0, OutputFrameStateCombine::Ignore()); | 664 BuildTranslation(instr, -1, 0, OutputFrameStateCombine::Ignore()); |
| 664 Deoptimizer::BailoutType bailout_type = | 665 Deoptimizer::BailoutType bailout_type = |
| 665 Deoptimizer::BailoutType(MiscField::decode(instr->opcode())); | 666 Deoptimizer::BailoutType(MiscField::decode(instr->opcode())); |
| 666 AssembleDeoptimizerCall(deopt_state_id, bailout_type); | 667 CodeGenResult result = |
| 668 AssembleDeoptimizerCall(deopt_state_id, bailout_type); |
| 669 if (result != kSuccess) return result; |
| 667 break; | 670 break; |
| 668 } | 671 } |
| 669 case kArchRet: | 672 case kArchRet: |
| 670 AssembleReturn(); | 673 AssembleReturn(); |
| 671 break; | 674 break; |
| 672 case kArchStackPointer: | 675 case kArchStackPointer: |
| 673 __ mov(i.OutputRegister(), sp); | 676 __ mov(i.OutputRegister(), sp); |
| 674 break; | 677 break; |
| 675 case kArchFramePointer: | 678 case kArchFramePointer: |
| 676 __ mov(i.OutputRegister(), fp); | 679 __ mov(i.OutputRegister(), fp); |
| (...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1587 case kAtomicLoadInt16: | 1590 case kAtomicLoadInt16: |
| 1588 ASSEMBLE_ATOMIC_LOAD_INTEGER(lh); | 1591 ASSEMBLE_ATOMIC_LOAD_INTEGER(lh); |
| 1589 break; | 1592 break; |
| 1590 case kAtomicLoadUint16: | 1593 case kAtomicLoadUint16: |
| 1591 ASSEMBLE_ATOMIC_LOAD_INTEGER(lhu); | 1594 ASSEMBLE_ATOMIC_LOAD_INTEGER(lhu); |
| 1592 break; | 1595 break; |
| 1593 case kAtomicLoadWord32: | 1596 case kAtomicLoadWord32: |
| 1594 ASSEMBLE_ATOMIC_LOAD_INTEGER(lw); | 1597 ASSEMBLE_ATOMIC_LOAD_INTEGER(lw); |
| 1595 break; | 1598 break; |
| 1596 } | 1599 } |
| 1600 return kSuccess; |
| 1597 } // NOLINT(readability/fn_size) | 1601 } // NOLINT(readability/fn_size) |
| 1598 | 1602 |
| 1599 | 1603 |
| 1600 #define UNSUPPORTED_COND(opcode, condition) \ | 1604 #define UNSUPPORTED_COND(opcode, condition) \ |
| 1601 OFStream out(stdout); \ | 1605 OFStream out(stdout); \ |
| 1602 out << "Unsupported " << #opcode << " condition: \"" << condition << "\""; \ | 1606 out << "Unsupported " << #opcode << " condition: \"" << condition << "\""; \ |
| 1603 UNIMPLEMENTED(); | 1607 UNIMPLEMENTED(); |
| 1604 | 1608 |
| 1605 static bool convertCondition(FlagsCondition condition, Condition& cc) { | 1609 static bool convertCondition(FlagsCondition condition, Condition& cc) { |
| 1606 switch (condition) { | 1610 switch (condition) { |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1898 MipsOperandConverter i(this, instr); | 1902 MipsOperandConverter i(this, instr); |
| 1899 Register input = i.InputRegister(0); | 1903 Register input = i.InputRegister(0); |
| 1900 size_t const case_count = instr->InputCount() - 2; | 1904 size_t const case_count = instr->InputCount() - 2; |
| 1901 | 1905 |
| 1902 __ Branch(GetLabel(i.InputRpo(1)), hs, input, Operand(case_count)); | 1906 __ Branch(GetLabel(i.InputRpo(1)), hs, input, Operand(case_count)); |
| 1903 __ GenerateSwitchTable(input, case_count, [&i, this](size_t index) { | 1907 __ GenerateSwitchTable(input, case_count, [&i, this](size_t index) { |
| 1904 return GetLabel(i.InputRpo(index + 2)); | 1908 return GetLabel(i.InputRpo(index + 2)); |
| 1905 }); | 1909 }); |
| 1906 } | 1910 } |
| 1907 | 1911 |
| 1908 | 1912 CodeGenerator::CodeGenResult CodeGenerator::AssembleDeoptimizerCall( |
| 1909 void CodeGenerator::AssembleDeoptimizerCall( | |
| 1910 int deoptimization_id, Deoptimizer::BailoutType bailout_type) { | 1913 int deoptimization_id, Deoptimizer::BailoutType bailout_type) { |
| 1911 Address deopt_entry = Deoptimizer::GetDeoptimizationEntry( | 1914 Address deopt_entry = Deoptimizer::GetDeoptimizationEntry( |
| 1912 isolate(), deoptimization_id, bailout_type); | 1915 isolate(), deoptimization_id, bailout_type); |
| 1916 if (deopt_entry == nullptr) return kTooManyDeoptimizationBailouts; |
| 1913 __ Call(deopt_entry, RelocInfo::RUNTIME_ENTRY); | 1917 __ Call(deopt_entry, RelocInfo::RUNTIME_ENTRY); |
| 1918 return kSuccess; |
| 1914 } | 1919 } |
| 1915 | 1920 |
| 1916 void CodeGenerator::FinishFrame(Frame* frame) { | 1921 void CodeGenerator::FinishFrame(Frame* frame) { |
| 1917 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); | 1922 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); |
| 1918 | 1923 |
| 1919 const RegList saves_fpu = descriptor->CalleeSavedFPRegisters(); | 1924 const RegList saves_fpu = descriptor->CalleeSavedFPRegisters(); |
| 1920 if (saves_fpu != 0) { | 1925 if (saves_fpu != 0) { |
| 1921 int count = base::bits::CountPopulation32(saves_fpu); | 1926 int count = base::bits::CountPopulation32(saves_fpu); |
| 1922 DCHECK(kNumCalleeSavedFPU == count); | 1927 DCHECK(kNumCalleeSavedFPU == count); |
| 1923 frame->AllocateSavedCalleeRegisterSlots(count * | 1928 frame->AllocateSavedCalleeRegisterSlots(count * |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2226 padding_size -= v8::internal::Assembler::kInstrSize; | 2231 padding_size -= v8::internal::Assembler::kInstrSize; |
| 2227 } | 2232 } |
| 2228 } | 2233 } |
| 2229 } | 2234 } |
| 2230 | 2235 |
| 2231 #undef __ | 2236 #undef __ |
| 2232 | 2237 |
| 2233 } // namespace compiler | 2238 } // namespace compiler |
| 2234 } // namespace internal | 2239 } // namespace internal |
| 2235 } // namespace v8 | 2240 } // namespace v8 |
| OLD | NEW |