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/arm64/frames-arm64.h" | 7 #include "src/arm64/frames-arm64.h" |
8 #include "src/arm64/macro-assembler-arm64.h" | 8 #include "src/arm64/macro-assembler-arm64.h" |
9 #include "src/ast/scopes.h" | 9 #include "src/ast/scopes.h" |
10 #include "src/compiler/code-generator-impl.h" | 10 #include "src/compiler/code-generator-impl.h" |
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
530 MemOperand(fp, ArgumentsAdaptorFrameConstants::kLengthOffset)); | 530 MemOperand(fp, ArgumentsAdaptorFrameConstants::kLengthOffset)); |
531 __ SmiUntag(caller_args_count_reg); | 531 __ SmiUntag(caller_args_count_reg); |
532 | 532 |
533 ParameterCount callee_args_count(args_reg); | 533 ParameterCount callee_args_count(args_reg); |
534 __ PrepareForTailCall(callee_args_count, caller_args_count_reg, scratch2, | 534 __ PrepareForTailCall(callee_args_count, caller_args_count_reg, scratch2, |
535 scratch3); | 535 scratch3); |
536 __ bind(&done); | 536 __ bind(&done); |
537 } | 537 } |
538 | 538 |
539 // Assembles an instruction after register allocation, producing machine code. | 539 // Assembles an instruction after register allocation, producing machine code. |
540 void CodeGenerator::AssembleArchInstruction(Instruction* instr) { | 540 CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( |
| 541 Instruction* instr) { |
541 Arm64OperandConverter i(this, instr); | 542 Arm64OperandConverter i(this, instr); |
542 InstructionCode opcode = instr->opcode(); | 543 InstructionCode opcode = instr->opcode(); |
543 ArchOpcode arch_opcode = ArchOpcodeField::decode(opcode); | 544 ArchOpcode arch_opcode = ArchOpcodeField::decode(opcode); |
544 switch (arch_opcode) { | 545 switch (arch_opcode) { |
545 case kArchCallCodeObject: { | 546 case kArchCallCodeObject: { |
546 EnsureSpaceForLazyDeopt(); | 547 EnsureSpaceForLazyDeopt(); |
547 if (instr->InputAt(0)->IsImmediate()) { | 548 if (instr->InputAt(0)->IsImmediate()) { |
548 __ Call(Handle<Code>::cast(i.InputHeapObject(0)), | 549 __ Call(Handle<Code>::cast(i.InputHeapObject(0)), |
549 RelocInfo::CODE_TARGET); | 550 RelocInfo::CODE_TARGET); |
550 } else { | 551 } else { |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
682 break; | 683 break; |
683 case kArchNop: | 684 case kArchNop: |
684 case kArchThrowTerminator: | 685 case kArchThrowTerminator: |
685 // don't emit code for nops. | 686 // don't emit code for nops. |
686 break; | 687 break; |
687 case kArchDeoptimize: { | 688 case kArchDeoptimize: { |
688 int deopt_state_id = | 689 int deopt_state_id = |
689 BuildTranslation(instr, -1, 0, OutputFrameStateCombine::Ignore()); | 690 BuildTranslation(instr, -1, 0, OutputFrameStateCombine::Ignore()); |
690 Deoptimizer::BailoutType bailout_type = | 691 Deoptimizer::BailoutType bailout_type = |
691 Deoptimizer::BailoutType(MiscField::decode(instr->opcode())); | 692 Deoptimizer::BailoutType(MiscField::decode(instr->opcode())); |
692 AssembleDeoptimizerCall(deopt_state_id, bailout_type); | 693 CodeGenResult result = |
| 694 AssembleDeoptimizerCall(deopt_state_id, bailout_type); |
| 695 if (result != kSuccess) return result; |
693 break; | 696 break; |
694 } | 697 } |
695 case kArchRet: | 698 case kArchRet: |
696 AssembleReturn(); | 699 AssembleReturn(); |
697 break; | 700 break; |
698 case kArchStackPointer: | 701 case kArchStackPointer: |
699 __ mov(i.OutputRegister(), masm()->StackPointer()); | 702 __ mov(i.OutputRegister(), masm()->StackPointer()); |
700 break; | 703 break; |
701 case kArchFramePointer: | 704 case kArchFramePointer: |
702 __ mov(i.OutputRegister(), fp); | 705 __ mov(i.OutputRegister(), fp); |
(...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1422 break; | 1425 break; |
1423 case kAtomicLoadUint16: | 1426 case kAtomicLoadUint16: |
1424 ASSEMBLE_ATOMIC_LOAD_INTEGER(Ldrh); | 1427 ASSEMBLE_ATOMIC_LOAD_INTEGER(Ldrh); |
1425 break; | 1428 break; |
1426 case kAtomicLoadWord32: | 1429 case kAtomicLoadWord32: |
1427 __ Ldr(i.OutputRegister32(), | 1430 __ Ldr(i.OutputRegister32(), |
1428 MemOperand(i.InputRegister(0), i.InputRegister(1))); | 1431 MemOperand(i.InputRegister(0), i.InputRegister(1))); |
1429 __ Dmb(InnerShareable, BarrierAll); | 1432 __ Dmb(InnerShareable, BarrierAll); |
1430 break; | 1433 break; |
1431 } | 1434 } |
| 1435 return kSuccess; |
1432 } // NOLINT(readability/fn_size) | 1436 } // NOLINT(readability/fn_size) |
1433 | 1437 |
1434 | 1438 |
1435 // Assemble branches after this instruction. | 1439 // Assemble branches after this instruction. |
1436 void CodeGenerator::AssembleArchBranch(Instruction* instr, BranchInfo* branch) { | 1440 void CodeGenerator::AssembleArchBranch(Instruction* instr, BranchInfo* branch) { |
1437 Arm64OperandConverter i(this, instr); | 1441 Arm64OperandConverter i(this, instr); |
1438 Label* tlabel = branch->true_label; | 1442 Label* tlabel = branch->true_label; |
1439 Label* flabel = branch->false_label; | 1443 Label* flabel = branch->false_label; |
1440 FlagsCondition condition = branch->condition; | 1444 FlagsCondition condition = branch->condition; |
1441 ArchOpcode opcode = instr->arch_opcode(); | 1445 ArchOpcode opcode = instr->arch_opcode(); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1524 __ Add(temp, temp, Operand(input, UXTW, 2)); | 1528 __ Add(temp, temp, Operand(input, UXTW, 2)); |
1525 __ Br(temp); | 1529 __ Br(temp); |
1526 __ StartBlockPools(); | 1530 __ StartBlockPools(); |
1527 __ Bind(&table); | 1531 __ Bind(&table); |
1528 for (size_t index = 0; index < case_count; ++index) { | 1532 for (size_t index = 0; index < case_count; ++index) { |
1529 __ B(GetLabel(i.InputRpo(index + 2))); | 1533 __ B(GetLabel(i.InputRpo(index + 2))); |
1530 } | 1534 } |
1531 __ EndBlockPools(); | 1535 __ EndBlockPools(); |
1532 } | 1536 } |
1533 | 1537 |
1534 | 1538 CodeGenerator::CodeGenResult CodeGenerator::AssembleDeoptimizerCall( |
1535 void CodeGenerator::AssembleDeoptimizerCall( | |
1536 int deoptimization_id, Deoptimizer::BailoutType bailout_type) { | 1539 int deoptimization_id, Deoptimizer::BailoutType bailout_type) { |
1537 Address deopt_entry = Deoptimizer::GetDeoptimizationEntry( | 1540 Address deopt_entry = Deoptimizer::GetDeoptimizationEntry( |
1538 isolate(), deoptimization_id, bailout_type); | 1541 isolate(), deoptimization_id, bailout_type); |
| 1542 if (deopt_entry == nullptr) return kTooManyDeoptimizationBailouts; |
1539 __ Call(deopt_entry, RelocInfo::RUNTIME_ENTRY); | 1543 __ Call(deopt_entry, RelocInfo::RUNTIME_ENTRY); |
| 1544 return kSuccess; |
1540 } | 1545 } |
1541 | 1546 |
1542 void CodeGenerator::FinishFrame(Frame* frame) { | 1547 void CodeGenerator::FinishFrame(Frame* frame) { |
1543 frame->AlignFrame(16); | 1548 frame->AlignFrame(16); |
1544 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); | 1549 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); |
1545 | 1550 |
1546 if (descriptor->UseNativeStack() || descriptor->IsCFunctionCall()) { | 1551 if (descriptor->UseNativeStack() || descriptor->IsCFunctionCall()) { |
1547 __ SetStackPointer(csp); | 1552 __ SetStackPointer(csp); |
1548 } else { | 1553 } else { |
1549 __ SetStackPointer(jssp); | 1554 __ SetStackPointer(jssp); |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1855 padding_size -= kInstructionSize; | 1860 padding_size -= kInstructionSize; |
1856 } | 1861 } |
1857 } | 1862 } |
1858 } | 1863 } |
1859 | 1864 |
1860 #undef __ | 1865 #undef __ |
1861 | 1866 |
1862 } // namespace compiler | 1867 } // namespace compiler |
1863 } // namespace internal | 1868 } // namespace internal |
1864 } // namespace v8 | 1869 } // namespace v8 |
OLD | NEW |