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 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
524 MemOperand(fp, ArgumentsAdaptorFrameConstants::kLengthOffset)); | 524 MemOperand(fp, ArgumentsAdaptorFrameConstants::kLengthOffset)); |
525 __ SmiUntag(caller_args_count_reg); | 525 __ SmiUntag(caller_args_count_reg); |
526 | 526 |
527 ParameterCount callee_args_count(args_reg); | 527 ParameterCount callee_args_count(args_reg); |
528 __ PrepareForTailCall(callee_args_count, caller_args_count_reg, scratch2, | 528 __ PrepareForTailCall(callee_args_count, caller_args_count_reg, scratch2, |
529 scratch3); | 529 scratch3); |
530 __ bind(&done); | 530 __ bind(&done); |
531 } | 531 } |
532 | 532 |
533 // Assembles an instruction after register allocation, producing machine code. | 533 // Assembles an instruction after register allocation, producing machine code. |
534 void CodeGenerator::AssembleArchInstruction(Instruction* instr) { | 534 CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( |
| 535 Instruction* instr) { |
535 MipsOperandConverter i(this, instr); | 536 MipsOperandConverter i(this, instr); |
536 InstructionCode opcode = instr->opcode(); | 537 InstructionCode opcode = instr->opcode(); |
537 ArchOpcode arch_opcode = ArchOpcodeField::decode(opcode); | 538 ArchOpcode arch_opcode = ArchOpcodeField::decode(opcode); |
538 switch (arch_opcode) { | 539 switch (arch_opcode) { |
539 case kArchCallCodeObject: { | 540 case kArchCallCodeObject: { |
540 EnsureSpaceForLazyDeopt(); | 541 EnsureSpaceForLazyDeopt(); |
541 if (instr->InputAt(0)->IsImmediate()) { | 542 if (instr->InputAt(0)->IsImmediate()) { |
542 __ Call(Handle<Code>::cast(i.InputHeapObject(0)), | 543 __ Call(Handle<Code>::cast(i.InputHeapObject(0)), |
543 RelocInfo::CODE_TARGET); | 544 RelocInfo::CODE_TARGET); |
544 } else { | 545 } else { |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
646 break; | 647 break; |
647 case kArchNop: | 648 case kArchNop: |
648 case kArchThrowTerminator: | 649 case kArchThrowTerminator: |
649 // don't emit code for nops. | 650 // don't emit code for nops. |
650 break; | 651 break; |
651 case kArchDeoptimize: { | 652 case kArchDeoptimize: { |
652 int deopt_state_id = | 653 int deopt_state_id = |
653 BuildTranslation(instr, -1, 0, OutputFrameStateCombine::Ignore()); | 654 BuildTranslation(instr, -1, 0, OutputFrameStateCombine::Ignore()); |
654 Deoptimizer::BailoutType bailout_type = | 655 Deoptimizer::BailoutType bailout_type = |
655 Deoptimizer::BailoutType(MiscField::decode(instr->opcode())); | 656 Deoptimizer::BailoutType(MiscField::decode(instr->opcode())); |
656 AssembleDeoptimizerCall(deopt_state_id, bailout_type); | 657 CodeGenResult result = |
| 658 AssembleDeoptimizerCall(deopt_state_id, bailout_type); |
| 659 if (result != kSuccess) return result; |
657 break; | 660 break; |
658 } | 661 } |
659 case kArchRet: | 662 case kArchRet: |
660 AssembleReturn(); | 663 AssembleReturn(); |
661 break; | 664 break; |
662 case kArchStackPointer: | 665 case kArchStackPointer: |
663 __ mov(i.OutputRegister(), sp); | 666 __ mov(i.OutputRegister(), sp); |
664 break; | 667 break; |
665 case kArchFramePointer: | 668 case kArchFramePointer: |
666 __ mov(i.OutputRegister(), fp); | 669 __ mov(i.OutputRegister(), fp); |
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1337 case kAtomicLoadInt16: | 1340 case kAtomicLoadInt16: |
1338 ASSEMBLE_ATOMIC_LOAD_INTEGER(lh); | 1341 ASSEMBLE_ATOMIC_LOAD_INTEGER(lh); |
1339 break; | 1342 break; |
1340 case kAtomicLoadUint16: | 1343 case kAtomicLoadUint16: |
1341 ASSEMBLE_ATOMIC_LOAD_INTEGER(lhu); | 1344 ASSEMBLE_ATOMIC_LOAD_INTEGER(lhu); |
1342 break; | 1345 break; |
1343 case kAtomicLoadWord32: | 1346 case kAtomicLoadWord32: |
1344 ASSEMBLE_ATOMIC_LOAD_INTEGER(lw); | 1347 ASSEMBLE_ATOMIC_LOAD_INTEGER(lw); |
1345 break; | 1348 break; |
1346 } | 1349 } |
| 1350 return kSuccess; |
1347 } // NOLINT(readability/fn_size) | 1351 } // NOLINT(readability/fn_size) |
1348 | 1352 |
1349 | 1353 |
1350 #define UNSUPPORTED_COND(opcode, condition) \ | 1354 #define UNSUPPORTED_COND(opcode, condition) \ |
1351 OFStream out(stdout); \ | 1355 OFStream out(stdout); \ |
1352 out << "Unsupported " << #opcode << " condition: \"" << condition << "\""; \ | 1356 out << "Unsupported " << #opcode << " condition: \"" << condition << "\""; \ |
1353 UNIMPLEMENTED(); | 1357 UNIMPLEMENTED(); |
1354 | 1358 |
1355 static bool convertCondition(FlagsCondition condition, Condition& cc) { | 1359 static bool convertCondition(FlagsCondition condition, Condition& cc) { |
1356 switch (condition) { | 1360 switch (condition) { |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1631 void CodeGenerator::AssembleArchTableSwitch(Instruction* instr) { | 1635 void CodeGenerator::AssembleArchTableSwitch(Instruction* instr) { |
1632 MipsOperandConverter i(this, instr); | 1636 MipsOperandConverter i(this, instr); |
1633 Register input = i.InputRegister(0); | 1637 Register input = i.InputRegister(0); |
1634 size_t const case_count = instr->InputCount() - 2; | 1638 size_t const case_count = instr->InputCount() - 2; |
1635 __ Branch(GetLabel(i.InputRpo(1)), hs, input, Operand(case_count)); | 1639 __ Branch(GetLabel(i.InputRpo(1)), hs, input, Operand(case_count)); |
1636 __ GenerateSwitchTable(input, case_count, [&i, this](size_t index) { | 1640 __ GenerateSwitchTable(input, case_count, [&i, this](size_t index) { |
1637 return GetLabel(i.InputRpo(index + 2)); | 1641 return GetLabel(i.InputRpo(index + 2)); |
1638 }); | 1642 }); |
1639 } | 1643 } |
1640 | 1644 |
1641 | 1645 CodeGenerator::CodeGenResult CodeGenerator::AssembleDeoptimizerCall( |
1642 void CodeGenerator::AssembleDeoptimizerCall( | |
1643 int deoptimization_id, Deoptimizer::BailoutType bailout_type) { | 1646 int deoptimization_id, Deoptimizer::BailoutType bailout_type) { |
1644 Address deopt_entry = Deoptimizer::GetDeoptimizationEntry( | 1647 Address deopt_entry = Deoptimizer::GetDeoptimizationEntry( |
1645 isolate(), deoptimization_id, bailout_type); | 1648 isolate(), deoptimization_id, bailout_type); |
| 1649 if (deopt_entry == nullptr) return kTooManyDeoptimizationBailouts; |
1646 __ Call(deopt_entry, RelocInfo::RUNTIME_ENTRY); | 1650 __ Call(deopt_entry, RelocInfo::RUNTIME_ENTRY); |
| 1651 return kSuccess; |
1647 } | 1652 } |
1648 | 1653 |
1649 void CodeGenerator::FinishFrame(Frame* frame) { | 1654 void CodeGenerator::FinishFrame(Frame* frame) { |
1650 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); | 1655 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); |
1651 | 1656 |
1652 const RegList saves_fpu = descriptor->CalleeSavedFPRegisters(); | 1657 const RegList saves_fpu = descriptor->CalleeSavedFPRegisters(); |
1653 if (saves_fpu != 0) { | 1658 if (saves_fpu != 0) { |
1654 frame->AlignSavedCalleeRegisterSlots(); | 1659 frame->AlignSavedCalleeRegisterSlots(); |
1655 } | 1660 } |
1656 | 1661 |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1962 padding_size -= v8::internal::Assembler::kInstrSize; | 1967 padding_size -= v8::internal::Assembler::kInstrSize; |
1963 } | 1968 } |
1964 } | 1969 } |
1965 } | 1970 } |
1966 | 1971 |
1967 #undef __ | 1972 #undef __ |
1968 | 1973 |
1969 } // namespace compiler | 1974 } // namespace compiler |
1970 } // namespace internal | 1975 } // namespace internal |
1971 } // namespace v8 | 1976 } // namespace v8 |
OLD | NEW |