| 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 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 566 if (instr->InputAt(4)->IsRegister()) { \ | 566 if (instr->InputAt(4)->IsRegister()) { \ |
| 567 Register value = i.InputRegister(4); \ | 567 Register value = i.InputRegister(4); \ |
| 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() { | 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 stack_slots = frame()->GetSpillSlotCount(); |
| 579 if (descriptor->IsJSFunctionCall() || stack_slots > 0) { | 579 if (descriptor->IsJSFunctionCall() || stack_slots > 0) { |
| 580 __ movq(rsp, rbp); | 580 __ movq(rsp, rbp); |
| 581 __ popq(rbp); | 581 __ popq(rbp); |
| 582 } | 582 } |
| 583 if (stack_param_delta < 0) { |
| 584 int offset = -(stack_param_delta + 1) * kPointerSize; |
| 585 __ popq(Operand(rsp, offset)); |
| 586 if (offset != 0) { |
| 587 __ addq(rsp, Immediate(offset)); |
| 588 } |
| 589 } |
| 583 } | 590 } |
| 584 | 591 |
| 585 | 592 |
| 586 // Assembles an instruction after register allocation, producing machine code. | 593 // Assembles an instruction after register allocation, producing machine code. |
| 587 void CodeGenerator::AssembleArchInstruction(Instruction* instr) { | 594 void CodeGenerator::AssembleArchInstruction(Instruction* instr) { |
| 588 X64OperandConverter i(this, instr); | 595 X64OperandConverter i(this, instr); |
| 589 | 596 |
| 590 switch (ArchOpcodeField::decode(instr->opcode())) { | 597 switch (ArchOpcodeField::decode(instr->opcode())) { |
| 591 case kArchCallCodeObject: { | 598 case kArchCallCodeObject: { |
| 592 EnsureSpaceForLazyDeopt(); | 599 EnsureSpaceForLazyDeopt(); |
| 593 if (HasImmediateInput(instr, 0)) { | 600 if (HasImmediateInput(instr, 0)) { |
| 594 Handle<Code> code = Handle<Code>::cast(i.InputHeapObject(0)); | 601 Handle<Code> code = Handle<Code>::cast(i.InputHeapObject(0)); |
| 595 __ Call(code, RelocInfo::CODE_TARGET); | 602 __ Call(code, RelocInfo::CODE_TARGET); |
| 596 } else { | 603 } else { |
| 597 Register reg = i.InputRegister(0); | 604 Register reg = i.InputRegister(0); |
| 598 __ addp(reg, Immediate(Code::kHeaderSize - kHeapObjectTag)); | 605 __ addp(reg, Immediate(Code::kHeaderSize - kHeapObjectTag)); |
| 599 __ call(reg); | 606 __ call(reg); |
| 600 } | 607 } |
| 601 RecordCallPosition(instr); | 608 RecordCallPosition(instr); |
| 602 break; | 609 break; |
| 603 } | 610 } |
| 604 case kArchTailCallCodeObject: { | 611 case kArchTailCallCodeObject: { |
| 605 AssembleDeconstructActivationRecord(); | 612 int stack_param_delta = i.InputInt32(instr->InputCount() - 1); |
| 613 AssembleDeconstructActivationRecord(stack_param_delta); |
| 606 if (HasImmediateInput(instr, 0)) { | 614 if (HasImmediateInput(instr, 0)) { |
| 607 Handle<Code> code = Handle<Code>::cast(i.InputHeapObject(0)); | 615 Handle<Code> code = Handle<Code>::cast(i.InputHeapObject(0)); |
| 608 __ jmp(code, RelocInfo::CODE_TARGET); | 616 __ jmp(code, RelocInfo::CODE_TARGET); |
| 609 } else { | 617 } else { |
| 610 Register reg = i.InputRegister(0); | 618 Register reg = i.InputRegister(0); |
| 611 __ addp(reg, Immediate(Code::kHeaderSize - kHeapObjectTag)); | 619 __ addp(reg, Immediate(Code::kHeaderSize - kHeapObjectTag)); |
| 612 __ jmp(reg); | 620 __ jmp(reg); |
| 613 } | 621 } |
| 614 break; | 622 break; |
| 615 } | 623 } |
| 616 case kArchCallJSFunction: { | 624 case kArchCallJSFunction: { |
| 617 EnsureSpaceForLazyDeopt(); | 625 EnsureSpaceForLazyDeopt(); |
| 618 Register func = i.InputRegister(0); | 626 Register func = i.InputRegister(0); |
| 619 if (FLAG_debug_code) { | 627 if (FLAG_debug_code) { |
| 620 // Check the function's context matches the context argument. | 628 // Check the function's context matches the context argument. |
| 621 __ cmpp(rsi, FieldOperand(func, JSFunction::kContextOffset)); | 629 __ cmpp(rsi, FieldOperand(func, JSFunction::kContextOffset)); |
| 622 __ Assert(equal, kWrongFunctionContext); | 630 __ Assert(equal, kWrongFunctionContext); |
| 623 } | 631 } |
| 624 __ Call(FieldOperand(func, JSFunction::kCodeEntryOffset)); | 632 __ Call(FieldOperand(func, JSFunction::kCodeEntryOffset)); |
| 625 RecordCallPosition(instr); | 633 RecordCallPosition(instr); |
| 626 break; | 634 break; |
| 627 } | 635 } |
| 628 case kArchTailCallJSFunction: { | 636 case kArchTailCallJSFunction: { |
| 629 Register func = i.InputRegister(0); | 637 Register func = i.InputRegister(0); |
| 630 if (FLAG_debug_code) { | 638 if (FLAG_debug_code) { |
| 631 // Check the function's context matches the context argument. | 639 // Check the function's context matches the context argument. |
| 632 __ cmpp(rsi, FieldOperand(func, JSFunction::kContextOffset)); | 640 __ cmpp(rsi, FieldOperand(func, JSFunction::kContextOffset)); |
| 633 __ Assert(equal, kWrongFunctionContext); | 641 __ Assert(equal, kWrongFunctionContext); |
| 634 } | 642 } |
| 635 AssembleDeconstructActivationRecord(); | 643 int stack_param_delta = i.InputInt32(instr->InputCount() - 1); |
| 644 AssembleDeconstructActivationRecord(stack_param_delta); |
| 636 __ jmp(FieldOperand(func, JSFunction::kCodeEntryOffset)); | 645 __ jmp(FieldOperand(func, JSFunction::kCodeEntryOffset)); |
| 637 break; | 646 break; |
| 638 } | 647 } |
| 639 case kArchLazyBailout: { | 648 case kArchLazyBailout: { |
| 640 EnsureSpaceForLazyDeopt(); | 649 EnsureSpaceForLazyDeopt(); |
| 641 RecordCallPosition(instr); | 650 RecordCallPosition(instr); |
| 642 break; | 651 break; |
| 643 } | 652 } |
| 644 case kArchPrepareCallCFunction: { | 653 case kArchPrepareCallCFunction: { |
| 645 int const num_parameters = MiscField::decode(instr->opcode()); | 654 int const num_parameters = MiscField::decode(instr->opcode()); |
| (...skipping 1269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1915 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; | 1924 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; |
| 1916 __ Nop(padding_size); | 1925 __ Nop(padding_size); |
| 1917 } | 1926 } |
| 1918 } | 1927 } |
| 1919 | 1928 |
| 1920 #undef __ | 1929 #undef __ |
| 1921 | 1930 |
| 1922 } // namespace compiler | 1931 } // namespace compiler |
| 1923 } // namespace internal | 1932 } // namespace internal |
| 1924 } // namespace v8 | 1933 } // namespace v8 |
| OLD | NEW |