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_IA32 | 5 #if V8_TARGET_ARCH_IA32 |
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 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
670 __ bind(&loop_header); | 670 __ bind(&loop_header); |
671 __ Push(Operand(ebx, 0)); | 671 __ Push(Operand(ebx, 0)); |
672 __ sub(ebx, Immediate(kPointerSize)); | 672 __ sub(ebx, Immediate(kPointerSize)); |
673 __ bind(&loop_check); | 673 __ bind(&loop_check); |
674 __ cmp(ebx, array_limit); | 674 __ cmp(ebx, array_limit); |
675 __ j(greater, &loop_header, Label::kNear); | 675 __ j(greater, &loop_header, Label::kNear); |
676 } | 676 } |
677 | 677 |
678 | 678 |
679 // static | 679 // static |
680 void Builtins::Generate_InterpreterPushArgsAndCall(MacroAssembler* masm) { | 680 void Builtins::Generate_InterpreterPushArgsAndCallImpl( |
| 681 MacroAssembler* masm, TailCallMode tail_call_mode) { |
681 // ----------- S t a t e ------------- | 682 // ----------- S t a t e ------------- |
682 // -- eax : the number of arguments (not including the receiver) | 683 // -- eax : the number of arguments (not including the receiver) |
683 // -- ebx : the address of the first argument to be pushed. Subsequent | 684 // -- ebx : the address of the first argument to be pushed. Subsequent |
684 // arguments should be consecutive above this, in the same order as | 685 // arguments should be consecutive above this, in the same order as |
685 // they are to be pushed onto the stack. | 686 // they are to be pushed onto the stack. |
686 // -- edi : the target to call (can be any Object). | 687 // -- edi : the target to call (can be any Object). |
687 // ----------------------------------- | 688 // ----------------------------------- |
688 | 689 |
689 // Pop return address to allow tail-call after pushing arguments. | 690 // Pop return address to allow tail-call after pushing arguments. |
690 __ Pop(edx); | 691 __ Pop(edx); |
691 | 692 |
692 // Find the address of the last argument. | 693 // Find the address of the last argument. |
693 __ mov(ecx, eax); | 694 __ mov(ecx, eax); |
694 __ add(ecx, Immediate(1)); // Add one for receiver. | 695 __ add(ecx, Immediate(1)); // Add one for receiver. |
695 __ shl(ecx, kPointerSizeLog2); | 696 __ shl(ecx, kPointerSizeLog2); |
696 __ neg(ecx); | 697 __ neg(ecx); |
697 __ add(ecx, ebx); | 698 __ add(ecx, ebx); |
698 | 699 |
699 Generate_InterpreterPushArgs(masm, ecx); | 700 Generate_InterpreterPushArgs(masm, ecx); |
700 | 701 |
701 // Call the target. | 702 // Call the target. |
702 __ Push(edx); // Re-push return address. | 703 __ Push(edx); // Re-push return address. |
703 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); | 704 __ Jump(masm->isolate()->builtins()->Call(ConvertReceiverMode::kAny, |
| 705 tail_call_mode), |
| 706 RelocInfo::CODE_TARGET); |
704 } | 707 } |
705 | 708 |
706 | 709 |
707 // static | 710 // static |
708 void Builtins::Generate_InterpreterPushArgsAndConstruct(MacroAssembler* masm) { | 711 void Builtins::Generate_InterpreterPushArgsAndConstruct(MacroAssembler* masm) { |
709 // ----------- S t a t e ------------- | 712 // ----------- S t a t e ------------- |
710 // -- eax : the number of arguments (not including the receiver) | 713 // -- eax : the number of arguments (not including the receiver) |
711 // -- edx : the new target | 714 // -- edx : the new target |
712 // -- edi : the constructor | 715 // -- edi : the constructor |
713 // -- ebx : the address of the first argument to be pushed. Subsequent | 716 // -- ebx : the address of the first argument to be pushed. Subsequent |
(...skipping 1271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1985 Comment cmnt(masm, "[ PrepareForTailCall"); | 1988 Comment cmnt(masm, "[ PrepareForTailCall"); |
1986 | 1989 |
1987 // Prepare for tail call only if the debugger is not active. | 1990 // Prepare for tail call only if the debugger is not active. |
1988 Label done; | 1991 Label done; |
1989 ExternalReference debug_is_active = | 1992 ExternalReference debug_is_active = |
1990 ExternalReference::debug_is_active_address(masm->isolate()); | 1993 ExternalReference::debug_is_active_address(masm->isolate()); |
1991 __ movzx_b(scratch1, Operand::StaticVariable(debug_is_active)); | 1994 __ movzx_b(scratch1, Operand::StaticVariable(debug_is_active)); |
1992 __ cmp(scratch1, Immediate(0)); | 1995 __ cmp(scratch1, Immediate(0)); |
1993 __ j(not_equal, &done, Label::kNear); | 1996 __ j(not_equal, &done, Label::kNear); |
1994 | 1997 |
| 1998 // Drop possible interpreter handler/stub frame. |
| 1999 { |
| 2000 Label no_interpreter_frame; |
| 2001 __ cmp(Operand(ebp, StandardFrameConstants::kMarkerOffset), |
| 2002 Immediate(Smi::FromInt(StackFrame::STUB))); |
| 2003 __ j(not_equal, &no_interpreter_frame, Label::kNear); |
| 2004 __ mov(ebp, Operand(ebp, StandardFrameConstants::kCallerFPOffset)); |
| 2005 __ bind(&no_interpreter_frame); |
| 2006 } |
| 2007 |
1995 // Check if next frame is an arguments adaptor frame. | 2008 // Check if next frame is an arguments adaptor frame. |
1996 Label no_arguments_adaptor, formal_parameter_count_loaded; | 2009 Label no_arguments_adaptor, formal_parameter_count_loaded; |
1997 __ mov(scratch2, Operand(ebp, StandardFrameConstants::kCallerFPOffset)); | 2010 __ mov(scratch2, Operand(ebp, StandardFrameConstants::kCallerFPOffset)); |
1998 __ cmp(Operand(scratch2, StandardFrameConstants::kContextOffset), | 2011 __ cmp(Operand(scratch2, StandardFrameConstants::kContextOffset), |
1999 Immediate(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); | 2012 Immediate(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); |
2000 __ j(not_equal, &no_arguments_adaptor, Label::kNear); | 2013 __ j(not_equal, &no_arguments_adaptor, Label::kNear); |
2001 | 2014 |
2002 // Drop arguments adaptor frame and load arguments count. | 2015 // Drop arguments adaptor frame and load arguments count. |
2003 __ mov(ebp, scratch2); | 2016 __ mov(ebp, scratch2); |
2004 __ mov(scratch1, Operand(ebp, ArgumentsAdaptorFrameConstants::kLengthOffset)); | 2017 __ mov(scratch1, Operand(ebp, ArgumentsAdaptorFrameConstants::kLengthOffset)); |
(...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2772 | 2785 |
2773 __ bind(&ok); | 2786 __ bind(&ok); |
2774 __ ret(0); | 2787 __ ret(0); |
2775 } | 2788 } |
2776 | 2789 |
2777 #undef __ | 2790 #undef __ |
2778 } // namespace internal | 2791 } // namespace internal |
2779 } // namespace v8 | 2792 } // namespace v8 |
2780 | 2793 |
2781 #endif // V8_TARGET_ARCH_IA32 | 2794 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |