| 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/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 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 568 ASSEMBLE_CHECKED_STORE_INTEGER_IMPL(asm_instr, Register); \ | 568 ASSEMBLE_CHECKED_STORE_INTEGER_IMPL(asm_instr, Register); \ |
| 569 } else { \ | 569 } else { \ |
| 570 Immediate value = i.InputImmediate(4); \ | 570 Immediate value = i.InputImmediate(4); \ |
| 571 ASSEMBLE_CHECKED_STORE_INTEGER_IMPL(asm_instr, Immediate); \ | 571 ASSEMBLE_CHECKED_STORE_INTEGER_IMPL(asm_instr, Immediate); \ |
| 572 } \ | 572 } \ |
| 573 } while (false) | 573 } while (false) |
| 574 | 574 |
| 575 | 575 |
| 576 void CodeGenerator::AssembleDeconstructActivationRecord(int stack_param_delta) { | 576 void CodeGenerator::AssembleDeconstructActivationRecord(int stack_param_delta) { |
| 577 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); | 577 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); |
| 578 int stack_slots = frame()->GetSpillSlotCount(); | 578 int spill_slots = frame()->GetSpillSlotCount(); |
| 579 if (descriptor->IsJSFunctionCall() || stack_slots > 0) { | 579 bool has_frame = descriptor->IsJSFunctionCall() || spill_slots > 0; |
| 580 __ movq(rsp, rbp); | 580 if (has_frame) { |
| 581 if (stack_param_delta != 0) { |
| 582 int total_discarded_slots = frame()->GetTotalFrameSlotCount(); |
| 583 // Leave the PC and saved frame pointer on the stack. |
| 584 total_discarded_slots -= |
| 585 StandardFrameConstants::kFixedFrameSizeFromFp / kPointerSize; |
| 586 // Discard only slots that won't be used by new parameters. |
| 587 total_discarded_slots -= stack_param_delta; |
| 588 if (total_discarded_slots > 0) { |
| 589 __ addq(rsp, Immediate(total_discarded_slots * kPointerSize)); |
| 590 } |
| 591 } else { |
| 592 __ movq(rsp, rbp); |
| 593 } |
| 581 __ popq(rbp); | 594 __ popq(rbp); |
| 582 } | 595 } |
| 583 if (stack_param_delta < 0) { | 596 } |
| 584 int offset = -(stack_param_delta + 1) * kPointerSize; | 597 |
| 585 __ popq(Operand(rsp, offset)); | 598 |
| 586 if (offset != 0) { | 599 void CodeGenerator::AssemblePrepareTailCall(int stack_param_delta) { |
| 587 __ addq(rsp, Immediate(offset)); | 600 if (stack_param_delta > 0) { |
| 601 int total_discarded_slots = frame()->GetTotalFrameSlotCount(); |
| 602 // Leave the PC and saved frame pointer on the stack. |
| 603 total_discarded_slots -= |
| 604 StandardFrameConstants::kFixedFrameSizeFromFp / kPointerSize; |
| 605 // Discard only slots that won't be used by new parameters. |
| 606 total_discarded_slots -= stack_param_delta; |
| 607 if (total_discarded_slots < 0) { |
| 608 __ subq(rsp, Immediate(-total_discarded_slots * kPointerSize)); |
| 588 } | 609 } |
| 589 } | 610 } |
| 590 } | 611 } |
| 591 | 612 |
| 592 | 613 |
| 593 // Assembles an instruction after register allocation, producing machine code. | 614 // Assembles an instruction after register allocation, producing machine code. |
| 594 void CodeGenerator::AssembleArchInstruction(Instruction* instr) { | 615 void CodeGenerator::AssembleArchInstruction(Instruction* instr) { |
| 595 X64OperandConverter i(this, instr); | 616 X64OperandConverter i(this, instr); |
| 596 | 617 |
| 597 switch (ArchOpcodeField::decode(instr->opcode())) { | 618 switch (ArchOpcodeField::decode(instr->opcode())) { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 648 case kArchLazyBailout: { | 669 case kArchLazyBailout: { |
| 649 EnsureSpaceForLazyDeopt(); | 670 EnsureSpaceForLazyDeopt(); |
| 650 RecordCallPosition(instr); | 671 RecordCallPosition(instr); |
| 651 break; | 672 break; |
| 652 } | 673 } |
| 653 case kArchPrepareCallCFunction: { | 674 case kArchPrepareCallCFunction: { |
| 654 int const num_parameters = MiscField::decode(instr->opcode()); | 675 int const num_parameters = MiscField::decode(instr->opcode()); |
| 655 __ PrepareCallCFunction(num_parameters); | 676 __ PrepareCallCFunction(num_parameters); |
| 656 break; | 677 break; |
| 657 } | 678 } |
| 679 case kArchPrepareTailCall: |
| 680 AssemblePrepareTailCall(i.InputInt32(instr->InputCount() - 1)); |
| 681 break; |
| 658 case kArchCallCFunction: { | 682 case kArchCallCFunction: { |
| 659 int const num_parameters = MiscField::decode(instr->opcode()); | 683 int const num_parameters = MiscField::decode(instr->opcode()); |
| 660 if (HasImmediateInput(instr, 0)) { | 684 if (HasImmediateInput(instr, 0)) { |
| 661 ExternalReference ref = i.InputExternalReference(0); | 685 ExternalReference ref = i.InputExternalReference(0); |
| 662 __ CallCFunction(ref, num_parameters); | 686 __ CallCFunction(ref, num_parameters); |
| 663 } else { | 687 } else { |
| 664 Register func = i.InputRegister(0); | 688 Register func = i.InputRegister(0); |
| 665 __ CallCFunction(func, num_parameters); | 689 __ CallCFunction(func, num_parameters); |
| 666 } | 690 } |
| 667 break; | 691 break; |
| (...skipping 1272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1940 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; | 1964 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; |
| 1941 __ Nop(padding_size); | 1965 __ Nop(padding_size); |
| 1942 } | 1966 } |
| 1943 } | 1967 } |
| 1944 | 1968 |
| 1945 #undef __ | 1969 #undef __ |
| 1946 | 1970 |
| 1947 } // namespace compiler | 1971 } // namespace compiler |
| 1948 } // namespace internal | 1972 } // namespace internal |
| 1949 } // namespace v8 | 1973 } // namespace v8 |
| OLD | NEW |