OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 #if V8_TARGET_ARCH_X64 | 5 #if V8_TARGET_ARCH_X64 |
6 | 6 |
7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
8 #include "src/codegen.h" | 8 #include "src/codegen.h" |
9 #include "src/deoptimizer.h" | 9 #include "src/deoptimizer.h" |
10 #include "src/full-codegen/full-codegen.h" | 10 #include "src/full-codegen/full-codegen.h" |
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
618 __ bind(&loop_header); | 618 __ bind(&loop_header); |
619 __ Push(Operand(rbx, 0)); | 619 __ Push(Operand(rbx, 0)); |
620 __ subp(rbx, Immediate(kPointerSize)); | 620 __ subp(rbx, Immediate(kPointerSize)); |
621 __ bind(&loop_check); | 621 __ bind(&loop_check); |
622 __ cmpp(rbx, rcx); | 622 __ cmpp(rbx, rcx); |
623 __ j(greater, &loop_header, Label::kNear); | 623 __ j(greater, &loop_header, Label::kNear); |
624 } | 624 } |
625 | 625 |
626 | 626 |
627 // static | 627 // static |
628 void Builtins::Generate_InterpreterPushArgsAndCallICImpl( | 628 void Builtins::Generate_InterpreterPushArgsAndCallImpl( |
629 MacroAssembler* masm, TailCallMode tail_call_mode) { | 629 MacroAssembler* masm, TailCallMode tail_call_mode) { |
630 // ----------- S t a t e ------------- | 630 // ----------- S t a t e ------------- |
631 // -- rax : the number of arguments (not including the receiver) | 631 // -- rax : the number of arguments (not including the receiver) |
632 // -- rbx : the address of the first argument to be pushed. Subsequent | 632 // -- rbx : the address of the first argument to be pushed. Subsequent |
633 // arguments should be consecutive above this, in the same order as | 633 // arguments should be consecutive above this, in the same order as |
634 // they are to be pushed onto the stack. | 634 // they are to be pushed onto the stack. |
635 // -- rdi : the target to call (can be any Object). | 635 // -- rdi : the target to call (can be any Object). |
636 // -- rdx : Feedback vector slot-id. | |
637 // -- r9 : type feedback vector. // TODO(mythria): move to rbx to match | |
638 // CallICStub expectation. | |
639 // ----------------------------------- | |
640 | |
641 { | |
642 FrameScope scope(masm, StackFrame::INTERNAL); | |
643 | |
644 Generate_InterpreterPushArgs(masm, true); | |
645 | |
646 __ Move(rbx, r9); | |
647 | |
648 // Call via the CallIC stub. | |
649 CallICState call_ic_state(0, ConvertReceiverMode::kAny, tail_call_mode, | |
650 true); | |
651 CallICStub stub(masm->isolate(), call_ic_state); | |
652 // TODO(mythria): This should be replaced by a TailCallStub, when we | |
653 // update the code to find the target IC from jump instructions. | |
654 __ CallStub(&stub); | |
655 } | |
656 __ Ret(); | |
657 } | |
658 | |
659 // static | |
660 void Builtins::Generate_InterpreterPushArgsAndCallImpl( | |
661 MacroAssembler* masm, TailCallMode tail_call_mode) { | |
662 // ----------- S t a t e ------------- | |
663 // -- rax : the number of arguments (not including the receiver) | |
664 // -- rbx : the address of the first argument to be pushed. Subsequent | |
665 // arguments should be consecutive above this, in the same order as | |
666 // they are to be pushed onto the stack. | |
667 // -- rdi : the target to call (can be any Object). | |
668 // ----------------------------------- | 636 // ----------------------------------- |
669 | 637 |
670 // Pop return address to allow tail-call after pushing arguments. | 638 // Pop return address to allow tail-call after pushing arguments. |
671 __ PopReturnAddressTo(kScratchRegister); | 639 __ PopReturnAddressTo(kScratchRegister); |
672 | 640 |
673 Generate_InterpreterPushArgs(masm, true); | 641 Generate_InterpreterPushArgs(masm, true); |
674 | 642 |
675 // Call the target. | 643 // Call the target. |
676 __ PushReturnAddressFrom(kScratchRegister); // Re-push return address. | 644 __ PushReturnAddressFrom(kScratchRegister); // Re-push return address. |
677 __ Jump(masm->isolate()->builtins()->Call(ConvertReceiverMode::kAny, | 645 __ Jump(masm->isolate()->builtins()->Call(ConvertReceiverMode::kAny, |
678 tail_call_mode), | 646 tail_call_mode), |
679 RelocInfo::CODE_TARGET); | 647 RelocInfo::CODE_TARGET); |
680 } | 648 } |
681 | 649 |
| 650 |
682 // static | 651 // static |
683 void Builtins::Generate_InterpreterPushArgsAndConstruct(MacroAssembler* masm) { | 652 void Builtins::Generate_InterpreterPushArgsAndConstruct(MacroAssembler* masm) { |
684 // ----------- S t a t e ------------- | 653 // ----------- S t a t e ------------- |
685 // -- rax : the number of arguments (not including the receiver) | 654 // -- rax : the number of arguments (not including the receiver) |
686 // -- rdx : the new target (either the same as the constructor or | 655 // -- rdx : the new target (either the same as the constructor or |
687 // the JSFunction on which new was invoked initially) | 656 // the JSFunction on which new was invoked initially) |
688 // -- rdi : the constructor to call (can be any Object) | 657 // -- rdi : the constructor to call (can be any Object) |
689 // -- rbx : the address of the first argument to be pushed. Subsequent | 658 // -- rbx : the address of the first argument to be pushed. Subsequent |
690 // arguments should be consecutive above this, in the same order as | 659 // arguments should be consecutive above this, in the same order as |
691 // they are to be pushed onto the stack. | 660 // they are to be pushed onto the stack. |
(...skipping 1390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2082 Comment cmnt(masm, "[ PrepareForTailCall"); | 2051 Comment cmnt(masm, "[ PrepareForTailCall"); |
2083 | 2052 |
2084 // Prepare for tail call only if the debugger is not active. | 2053 // Prepare for tail call only if the debugger is not active. |
2085 Label done; | 2054 Label done; |
2086 ExternalReference debug_is_active = | 2055 ExternalReference debug_is_active = |
2087 ExternalReference::debug_is_active_address(masm->isolate()); | 2056 ExternalReference::debug_is_active_address(masm->isolate()); |
2088 __ Move(kScratchRegister, debug_is_active); | 2057 __ Move(kScratchRegister, debug_is_active); |
2089 __ cmpb(Operand(kScratchRegister, 0), Immediate(0)); | 2058 __ cmpb(Operand(kScratchRegister, 0), Immediate(0)); |
2090 __ j(not_equal, &done); | 2059 __ j(not_equal, &done); |
2091 | 2060 |
2092 // Drop possible internal frame pushed for calling CallICStub. | |
2093 // TODO(mythria): when we tail call the CallICStub, remove this. | |
2094 { | |
2095 Label no_internal_callic_frame; | |
2096 __ Cmp(Operand(rbp, StandardFrameConstants::kMarkerOffset), | |
2097 Smi::FromInt(StackFrame::INTERNAL)); | |
2098 __ j(not_equal, &no_internal_callic_frame, Label::kNear); | |
2099 __ movp(rbp, Operand(rbp, StandardFrameConstants::kCallerFPOffset)); | |
2100 __ bind(&no_internal_callic_frame); | |
2101 } | |
2102 | |
2103 // Drop possible interpreter handler/stub frame. | 2061 // Drop possible interpreter handler/stub frame. |
2104 { | 2062 { |
2105 Label no_interpreter_frame; | 2063 Label no_interpreter_frame; |
2106 __ Cmp(Operand(rbp, StandardFrameConstants::kMarkerOffset), | 2064 __ Cmp(Operand(rbp, StandardFrameConstants::kMarkerOffset), |
2107 Smi::FromInt(StackFrame::STUB)); | 2065 Smi::FromInt(StackFrame::STUB)); |
2108 __ j(not_equal, &no_interpreter_frame, Label::kNear); | 2066 __ j(not_equal, &no_interpreter_frame, Label::kNear); |
2109 __ movp(rbp, Operand(rbp, StandardFrameConstants::kCallerFPOffset)); | 2067 __ movp(rbp, Operand(rbp, StandardFrameConstants::kCallerFPOffset)); |
2110 __ bind(&no_interpreter_frame); | 2068 __ bind(&no_interpreter_frame); |
2111 } | 2069 } |
2112 | 2070 |
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2768 __ ret(0); | 2726 __ ret(0); |
2769 } | 2727 } |
2770 | 2728 |
2771 | 2729 |
2772 #undef __ | 2730 #undef __ |
2773 | 2731 |
2774 } // namespace internal | 2732 } // namespace internal |
2775 } // namespace v8 | 2733 } // namespace v8 |
2776 | 2734 |
2777 #endif // V8_TARGET_ARCH_X64 | 2735 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |