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 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 __ PrepareForTailCall(callee_args_count, caller_args_count_reg, scratch2, | 427 __ PrepareForTailCall(callee_args_count, caller_args_count_reg, scratch2, |
428 scratch3, ReturnAddressState::kOnStack, scratch_count); | 428 scratch3, ReturnAddressState::kOnStack, scratch_count); |
429 __ pop(scratch3); | 429 __ pop(scratch3); |
430 __ pop(scratch2); | 430 __ pop(scratch2); |
431 __ pop(scratch1); | 431 __ pop(scratch1); |
432 | 432 |
433 __ bind(&done); | 433 __ bind(&done); |
434 } | 434 } |
435 | 435 |
436 // Assembles an instruction after register allocation, producing machine code. | 436 // Assembles an instruction after register allocation, producing machine code. |
437 void CodeGenerator::AssembleArchInstruction(Instruction* instr) { | 437 CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( |
| 438 Instruction* instr) { |
438 X87OperandConverter i(this, instr); | 439 X87OperandConverter i(this, instr); |
439 InstructionCode opcode = instr->opcode(); | 440 InstructionCode opcode = instr->opcode(); |
440 ArchOpcode arch_opcode = ArchOpcodeField::decode(opcode); | 441 ArchOpcode arch_opcode = ArchOpcodeField::decode(opcode); |
441 | 442 |
442 switch (arch_opcode) { | 443 switch (arch_opcode) { |
443 case kArchCallCodeObject: { | 444 case kArchCallCodeObject: { |
444 if (FLAG_debug_code && FLAG_enable_slow_asserts) { | 445 if (FLAG_debug_code && FLAG_enable_slow_asserts) { |
445 __ VerifyX87StackDepth(1); | 446 __ VerifyX87StackDepth(1); |
446 } | 447 } |
447 __ fstp(0); | 448 __ fstp(0); |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
625 x87_layout = (0 << 3) | 1; | 626 x87_layout = (0 << 3) | 1; |
626 } | 627 } |
627 // The layout of x87 register stack is loaded on the top of FPU register | 628 // The layout of x87 register stack is loaded on the top of FPU register |
628 // stack for deoptimization. | 629 // stack for deoptimization. |
629 __ push(Immediate(x87_layout)); | 630 __ push(Immediate(x87_layout)); |
630 __ fild_s(MemOperand(esp, 0)); | 631 __ fild_s(MemOperand(esp, 0)); |
631 __ lea(esp, Operand(esp, kPointerSize)); | 632 __ lea(esp, Operand(esp, kPointerSize)); |
632 | 633 |
633 Deoptimizer::BailoutType bailout_type = | 634 Deoptimizer::BailoutType bailout_type = |
634 Deoptimizer::BailoutType(MiscField::decode(instr->opcode())); | 635 Deoptimizer::BailoutType(MiscField::decode(instr->opcode())); |
635 AssembleDeoptimizerCall(deopt_state_id, bailout_type); | 636 CodeGenResult result = |
| 637 AssembleDeoptimizerCall(deopt_state_id, bailout_type); |
| 638 if (result != kSuccess) return result; |
636 break; | 639 break; |
637 } | 640 } |
638 case kArchRet: | 641 case kArchRet: |
639 AssembleReturn(); | 642 AssembleReturn(); |
640 break; | 643 break; |
641 case kArchFramePointer: | 644 case kArchFramePointer: |
642 __ mov(i.OutputRegister(), ebp); | 645 __ mov(i.OutputRegister(), ebp); |
643 break; | 646 break; |
644 case kArchStackPointer: | 647 case kArchStackPointer: |
645 __ mov(i.OutputRegister(), esp); | 648 __ mov(i.OutputRegister(), esp); |
(...skipping 1118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1764 UNREACHABLE(); // currently unsupported checked int64 load/store. | 1767 UNREACHABLE(); // currently unsupported checked int64 load/store. |
1765 break; | 1768 break; |
1766 case kAtomicLoadInt8: | 1769 case kAtomicLoadInt8: |
1767 case kAtomicLoadUint8: | 1770 case kAtomicLoadUint8: |
1768 case kAtomicLoadInt16: | 1771 case kAtomicLoadInt16: |
1769 case kAtomicLoadUint16: | 1772 case kAtomicLoadUint16: |
1770 case kAtomicLoadWord32: | 1773 case kAtomicLoadWord32: |
1771 UNREACHABLE(); // Won't be generated by instruction selector. | 1774 UNREACHABLE(); // Won't be generated by instruction selector. |
1772 break; | 1775 break; |
1773 } | 1776 } |
| 1777 return kSuccess; |
1774 } // NOLINT(readability/fn_size) | 1778 } // NOLINT(readability/fn_size) |
1775 | 1779 |
1776 | 1780 |
1777 // Assembles a branch after an instruction. | 1781 // Assembles a branch after an instruction. |
1778 void CodeGenerator::AssembleArchBranch(Instruction* instr, BranchInfo* branch) { | 1782 void CodeGenerator::AssembleArchBranch(Instruction* instr, BranchInfo* branch) { |
1779 X87OperandConverter i(this, instr); | 1783 X87OperandConverter i(this, instr); |
1780 Label::Distance flabel_distance = | 1784 Label::Distance flabel_distance = |
1781 branch->fallthru ? Label::kNear : Label::kFar; | 1785 branch->fallthru ? Label::kNear : Label::kFar; |
1782 | 1786 |
1783 Label done; | 1787 Label done; |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1973 Label** cases = zone()->NewArray<Label*>(case_count); | 1977 Label** cases = zone()->NewArray<Label*>(case_count); |
1974 for (size_t index = 0; index < case_count; ++index) { | 1978 for (size_t index = 0; index < case_count; ++index) { |
1975 cases[index] = GetLabel(i.InputRpo(index + 2)); | 1979 cases[index] = GetLabel(i.InputRpo(index + 2)); |
1976 } | 1980 } |
1977 Label* const table = AddJumpTable(cases, case_count); | 1981 Label* const table = AddJumpTable(cases, case_count); |
1978 __ cmp(input, Immediate(case_count)); | 1982 __ cmp(input, Immediate(case_count)); |
1979 __ j(above_equal, GetLabel(i.InputRpo(1))); | 1983 __ j(above_equal, GetLabel(i.InputRpo(1))); |
1980 __ jmp(Operand::JumpTable(input, times_4, table)); | 1984 __ jmp(Operand::JumpTable(input, times_4, table)); |
1981 } | 1985 } |
1982 | 1986 |
1983 | 1987 CodeGenerator::CodeGenResult CodeGenerator::AssembleDeoptimizerCall( |
1984 void CodeGenerator::AssembleDeoptimizerCall( | |
1985 int deoptimization_id, Deoptimizer::BailoutType bailout_type) { | 1988 int deoptimization_id, Deoptimizer::BailoutType bailout_type) { |
1986 Address deopt_entry = Deoptimizer::GetDeoptimizationEntry( | 1989 Address deopt_entry = Deoptimizer::GetDeoptimizationEntry( |
1987 isolate(), deoptimization_id, bailout_type); | 1990 isolate(), deoptimization_id, bailout_type); |
| 1991 if (deopt_entry == nullptr) return kTooManyDeoptimizationBailouts; |
1988 __ call(deopt_entry, RelocInfo::RUNTIME_ENTRY); | 1992 __ call(deopt_entry, RelocInfo::RUNTIME_ENTRY); |
| 1993 return kSuccess; |
1989 } | 1994 } |
1990 | 1995 |
1991 | 1996 |
1992 // The calling convention for JSFunctions on X87 passes arguments on the | 1997 // The calling convention for JSFunctions on X87 passes arguments on the |
1993 // stack and the JSFunction and context in EDI and ESI, respectively, thus | 1998 // stack and the JSFunction and context in EDI and ESI, respectively, thus |
1994 // the steps of the call look as follows: | 1999 // the steps of the call look as follows: |
1995 | 2000 |
1996 // --{ before the call instruction }-------------------------------------------- | 2001 // --{ before the call instruction }-------------------------------------------- |
1997 // | caller frame | | 2002 // | caller frame | |
1998 // ^ esp ^ ebp | 2003 // ^ esp ^ ebp |
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2466 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; | 2471 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; |
2467 __ Nop(padding_size); | 2472 __ Nop(padding_size); |
2468 } | 2473 } |
2469 } | 2474 } |
2470 | 2475 |
2471 #undef __ | 2476 #undef __ |
2472 | 2477 |
2473 } // namespace compiler | 2478 } // namespace compiler |
2474 } // namespace internal | 2479 } // namespace internal |
2475 } // namespace v8 | 2480 } // namespace v8 |
OLD | NEW |