| 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/ast/scopes.h" | 7 #include "src/ast/scopes.h" |
| 8 #include "src/code-factory.h" | 8 #include "src/code-factory.h" |
| 9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
| 10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
| (...skipping 1970 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1981 // result = receiver[f](arg); | 1981 // result = receiver[f](arg); |
| 1982 __ bind(&l_call); | 1982 __ bind(&l_call); |
| 1983 __ movp(load_receiver, Operand(rsp, kPointerSize)); | 1983 __ movp(load_receiver, Operand(rsp, kPointerSize)); |
| 1984 __ Move(LoadDescriptor::SlotRegister(), | 1984 __ Move(LoadDescriptor::SlotRegister(), |
| 1985 SmiFromSlot(expr->KeyedLoadFeedbackSlot())); | 1985 SmiFromSlot(expr->KeyedLoadFeedbackSlot())); |
| 1986 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate(), SLOPPY).code(); | 1986 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate(), SLOPPY).code(); |
| 1987 CallIC(ic, TypeFeedbackId::None()); | 1987 CallIC(ic, TypeFeedbackId::None()); |
| 1988 __ movp(rdi, rax); | 1988 __ movp(rdi, rax); |
| 1989 __ movp(Operand(rsp, 2 * kPointerSize), rdi); | 1989 __ movp(Operand(rsp, 2 * kPointerSize), rdi); |
| 1990 | 1990 |
| 1991 SetCallPosition(expr, 1); | 1991 SetCallPosition(expr); |
| 1992 __ Set(rax, 1); | 1992 __ Set(rax, 1); |
| 1993 __ Call( | 1993 __ Call( |
| 1994 isolate()->builtins()->Call(ConvertReceiverMode::kNotNullOrUndefined), | 1994 isolate()->builtins()->Call(ConvertReceiverMode::kNotNullOrUndefined), |
| 1995 RelocInfo::CODE_TARGET); | 1995 RelocInfo::CODE_TARGET); |
| 1996 | 1996 |
| 1997 __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); | 1997 __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); |
| 1998 __ Drop(1); // The function is still on the stack; drop it. | 1998 __ Drop(1); // The function is still on the stack; drop it. |
| 1999 | 1999 |
| 2000 // if (!result.done) goto l_try; | 2000 // if (!result.done) goto l_try; |
| 2001 __ bind(&l_loop); | 2001 __ bind(&l_loop); |
| (...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2740 | 2740 |
| 2741 void FullCodeGenerator::EmitCall(Call* expr, ConvertReceiverMode mode) { | 2741 void FullCodeGenerator::EmitCall(Call* expr, ConvertReceiverMode mode) { |
| 2742 // Load the arguments. | 2742 // Load the arguments. |
| 2743 ZoneList<Expression*>* args = expr->arguments(); | 2743 ZoneList<Expression*>* args = expr->arguments(); |
| 2744 int arg_count = args->length(); | 2744 int arg_count = args->length(); |
| 2745 for (int i = 0; i < arg_count; i++) { | 2745 for (int i = 0; i < arg_count; i++) { |
| 2746 VisitForStackValue(args->at(i)); | 2746 VisitForStackValue(args->at(i)); |
| 2747 } | 2747 } |
| 2748 | 2748 |
| 2749 PrepareForBailoutForId(expr->CallId(), NO_REGISTERS); | 2749 PrepareForBailoutForId(expr->CallId(), NO_REGISTERS); |
| 2750 SetCallPosition(expr, arg_count); | 2750 SetCallPosition(expr); |
| 2751 Handle<Code> ic = CodeFactory::CallIC(isolate(), arg_count, mode).code(); | 2751 Handle<Code> ic = CodeFactory::CallIC(isolate(), arg_count, mode).code(); |
| 2752 __ Move(rdx, SmiFromSlot(expr->CallFeedbackICSlot())); | 2752 __ Move(rdx, SmiFromSlot(expr->CallFeedbackICSlot())); |
| 2753 __ movp(rdi, Operand(rsp, (arg_count + 1) * kPointerSize)); | 2753 __ movp(rdi, Operand(rsp, (arg_count + 1) * kPointerSize)); |
| 2754 // Don't assign a type feedback id to the IC, since type feedback is provided | 2754 // Don't assign a type feedback id to the IC, since type feedback is provided |
| 2755 // by the vector above. | 2755 // by the vector above. |
| 2756 CallIC(ic); | 2756 CallIC(ic); |
| 2757 | 2757 |
| 2758 RecordJSReturnSite(expr); | 2758 RecordJSReturnSite(expr); |
| 2759 | 2759 |
| 2760 // Restore context register. | 2760 // Restore context register. |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2843 // Push a copy of the function (found below the arguments) and resolve | 2843 // Push a copy of the function (found below the arguments) and resolve |
| 2844 // eval. | 2844 // eval. |
| 2845 __ Push(Operand(rsp, (arg_count + 1) * kPointerSize)); | 2845 __ Push(Operand(rsp, (arg_count + 1) * kPointerSize)); |
| 2846 EmitResolvePossiblyDirectEval(arg_count); | 2846 EmitResolvePossiblyDirectEval(arg_count); |
| 2847 | 2847 |
| 2848 // Touch up the callee. | 2848 // Touch up the callee. |
| 2849 __ movp(Operand(rsp, (arg_count + 1) * kPointerSize), rax); | 2849 __ movp(Operand(rsp, (arg_count + 1) * kPointerSize), rax); |
| 2850 | 2850 |
| 2851 PrepareForBailoutForId(expr->EvalId(), NO_REGISTERS); | 2851 PrepareForBailoutForId(expr->EvalId(), NO_REGISTERS); |
| 2852 | 2852 |
| 2853 SetCallPosition(expr, arg_count); | 2853 SetCallPosition(expr); |
| 2854 __ movp(rdi, Operand(rsp, (arg_count + 1) * kPointerSize)); | 2854 __ movp(rdi, Operand(rsp, (arg_count + 1) * kPointerSize)); |
| 2855 __ Set(rax, arg_count); | 2855 __ Set(rax, arg_count); |
| 2856 __ Call(isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); | 2856 __ Call(isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); |
| 2857 RecordJSReturnSite(expr); | 2857 RecordJSReturnSite(expr); |
| 2858 // Restore context register. | 2858 // Restore context register. |
| 2859 __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); | 2859 __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); |
| 2860 context()->DropAndPlug(1, rax); | 2860 context()->DropAndPlug(1, rax); |
| 2861 } | 2861 } |
| 2862 | 2862 |
| 2863 | 2863 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2875 | 2875 |
| 2876 // Push the arguments ("left-to-right") on the stack. | 2876 // Push the arguments ("left-to-right") on the stack. |
| 2877 ZoneList<Expression*>* args = expr->arguments(); | 2877 ZoneList<Expression*>* args = expr->arguments(); |
| 2878 int arg_count = args->length(); | 2878 int arg_count = args->length(); |
| 2879 for (int i = 0; i < arg_count; i++) { | 2879 for (int i = 0; i < arg_count; i++) { |
| 2880 VisitForStackValue(args->at(i)); | 2880 VisitForStackValue(args->at(i)); |
| 2881 } | 2881 } |
| 2882 | 2882 |
| 2883 // Call the construct call builtin that handles allocation and | 2883 // Call the construct call builtin that handles allocation and |
| 2884 // constructor invocation. | 2884 // constructor invocation. |
| 2885 SetConstructCallPosition(expr, arg_count); | 2885 SetConstructCallPosition(expr); |
| 2886 | 2886 |
| 2887 // Load function and argument count into rdi and rax. | 2887 // Load function and argument count into rdi and rax. |
| 2888 __ Set(rax, arg_count); | 2888 __ Set(rax, arg_count); |
| 2889 __ movp(rdi, Operand(rsp, arg_count * kPointerSize)); | 2889 __ movp(rdi, Operand(rsp, arg_count * kPointerSize)); |
| 2890 | 2890 |
| 2891 // Record call targets in unoptimized code, but not in the snapshot. | 2891 // Record call targets in unoptimized code, but not in the snapshot. |
| 2892 __ EmitLoadTypeFeedbackVector(rbx); | 2892 __ EmitLoadTypeFeedbackVector(rbx); |
| 2893 __ Move(rdx, SmiFromSlot(expr->CallNewFeedbackSlot())); | 2893 __ Move(rdx, SmiFromSlot(expr->CallNewFeedbackSlot())); |
| 2894 | 2894 |
| 2895 Handle<Code> code = CodeFactory::ConstructIC(isolate()).code(); | 2895 Handle<Code> code = CodeFactory::ConstructIC(isolate()).code(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2911 | 2911 |
| 2912 // Push the arguments ("left-to-right") on the stack. | 2912 // Push the arguments ("left-to-right") on the stack. |
| 2913 ZoneList<Expression*>* args = expr->arguments(); | 2913 ZoneList<Expression*>* args = expr->arguments(); |
| 2914 int arg_count = args->length(); | 2914 int arg_count = args->length(); |
| 2915 for (int i = 0; i < arg_count; i++) { | 2915 for (int i = 0; i < arg_count; i++) { |
| 2916 VisitForStackValue(args->at(i)); | 2916 VisitForStackValue(args->at(i)); |
| 2917 } | 2917 } |
| 2918 | 2918 |
| 2919 // Call the construct call builtin that handles allocation and | 2919 // Call the construct call builtin that handles allocation and |
| 2920 // constructor invocation. | 2920 // constructor invocation. |
| 2921 SetConstructCallPosition(expr, arg_count); | 2921 SetConstructCallPosition(expr); |
| 2922 | 2922 |
| 2923 // Load new target into rdx. | 2923 // Load new target into rdx. |
| 2924 VisitForAccumulatorValue(super_call_ref->new_target_var()); | 2924 VisitForAccumulatorValue(super_call_ref->new_target_var()); |
| 2925 __ movp(rdx, result_register()); | 2925 __ movp(rdx, result_register()); |
| 2926 | 2926 |
| 2927 // Load function and argument count into rdi and rax. | 2927 // Load function and argument count into rdi and rax. |
| 2928 __ Set(rax, arg_count); | 2928 __ Set(rax, arg_count); |
| 2929 __ movp(rdi, Operand(rsp, arg_count * kPointerSize)); | 2929 __ movp(rdi, Operand(rsp, arg_count * kPointerSize)); |
| 2930 | 2930 |
| 2931 __ Call(isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET); | 2931 __ Call(isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET); |
| (...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3654 void FullCodeGenerator::EmitDefaultConstructorCallSuper(CallRuntime* expr) { | 3654 void FullCodeGenerator::EmitDefaultConstructorCallSuper(CallRuntime* expr) { |
| 3655 ZoneList<Expression*>* args = expr->arguments(); | 3655 ZoneList<Expression*>* args = expr->arguments(); |
| 3656 DCHECK(args->length() == 2); | 3656 DCHECK(args->length() == 2); |
| 3657 | 3657 |
| 3658 // Evaluate new.target and super constructor. | 3658 // Evaluate new.target and super constructor. |
| 3659 VisitForStackValue(args->at(0)); | 3659 VisitForStackValue(args->at(0)); |
| 3660 VisitForStackValue(args->at(1)); | 3660 VisitForStackValue(args->at(1)); |
| 3661 | 3661 |
| 3662 // Call the construct call builtin that handles allocation and | 3662 // Call the construct call builtin that handles allocation and |
| 3663 // constructor invocation. | 3663 // constructor invocation. |
| 3664 SetConstructCallPosition(expr, 0); | 3664 SetConstructCallPosition(expr); |
| 3665 | 3665 |
| 3666 // Check if the calling frame is an arguments adaptor frame. | 3666 // Check if the calling frame is an arguments adaptor frame. |
| 3667 Label adaptor_frame, args_set_up, runtime; | 3667 Label adaptor_frame, args_set_up, runtime; |
| 3668 __ movp(rdx, Operand(rbp, StandardFrameConstants::kCallerFPOffset)); | 3668 __ movp(rdx, Operand(rbp, StandardFrameConstants::kCallerFPOffset)); |
| 3669 __ movp(rbx, Operand(rdx, StandardFrameConstants::kContextOffset)); | 3669 __ movp(rbx, Operand(rdx, StandardFrameConstants::kContextOffset)); |
| 3670 __ Cmp(rbx, Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)); | 3670 __ Cmp(rbx, Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)); |
| 3671 __ j(equal, &adaptor_frame); | 3671 __ j(equal, &adaptor_frame); |
| 3672 // default constructor has no arguments, so no adaptor frame means no args. | 3672 // default constructor has no arguments, so no adaptor frame means no args. |
| 3673 __ movp(rax, Immediate(0)); | 3673 __ movp(rax, Immediate(0)); |
| 3674 __ jmp(&args_set_up); | 3674 __ jmp(&args_set_up); |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4073 __ PushRoot(Heap::kUndefinedValueRootIndex); | 4073 __ PushRoot(Heap::kUndefinedValueRootIndex); |
| 4074 | 4074 |
| 4075 __ LoadNativeContextSlot(expr->context_index(), rax); | 4075 __ LoadNativeContextSlot(expr->context_index(), rax); |
| 4076 } | 4076 } |
| 4077 | 4077 |
| 4078 | 4078 |
| 4079 void FullCodeGenerator::EmitCallJSRuntimeFunction(CallRuntime* expr) { | 4079 void FullCodeGenerator::EmitCallJSRuntimeFunction(CallRuntime* expr) { |
| 4080 ZoneList<Expression*>* args = expr->arguments(); | 4080 ZoneList<Expression*>* args = expr->arguments(); |
| 4081 int arg_count = args->length(); | 4081 int arg_count = args->length(); |
| 4082 | 4082 |
| 4083 SetCallPosition(expr, arg_count); | 4083 SetCallPosition(expr); |
| 4084 __ movp(rdi, Operand(rsp, (arg_count + 1) * kPointerSize)); | 4084 __ movp(rdi, Operand(rsp, (arg_count + 1) * kPointerSize)); |
| 4085 __ Set(rax, arg_count); | 4085 __ Set(rax, arg_count); |
| 4086 __ Call(isolate()->builtins()->Call(ConvertReceiverMode::kNullOrUndefined), | 4086 __ Call(isolate()->builtins()->Call(ConvertReceiverMode::kNullOrUndefined), |
| 4087 RelocInfo::CODE_TARGET); | 4087 RelocInfo::CODE_TARGET); |
| 4088 } | 4088 } |
| 4089 | 4089 |
| 4090 | 4090 |
| 4091 void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) { | 4091 void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) { |
| 4092 ZoneList<Expression*>* args = expr->arguments(); | 4092 ZoneList<Expression*>* args = expr->arguments(); |
| 4093 int arg_count = args->length(); | 4093 int arg_count = args->length(); |
| (...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4879 Assembler::target_address_at(call_target_address, | 4879 Assembler::target_address_at(call_target_address, |
| 4880 unoptimized_code)); | 4880 unoptimized_code)); |
| 4881 return OSR_AFTER_STACK_CHECK; | 4881 return OSR_AFTER_STACK_CHECK; |
| 4882 } | 4882 } |
| 4883 | 4883 |
| 4884 | 4884 |
| 4885 } // namespace internal | 4885 } // namespace internal |
| 4886 } // namespace v8 | 4886 } // namespace v8 |
| 4887 | 4887 |
| 4888 #endif // V8_TARGET_ARCH_X64 | 4888 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |