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/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_ARM64 | 7 #if V8_TARGET_ARCH_ARM64 |
8 | 8 |
9 #include "src/code-factory.h" | 9 #include "src/code-factory.h" |
10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
(...skipping 2736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2747 __ Mov(x13, Smi::FromInt(scope()->start_position())); | 2747 __ Mov(x13, Smi::FromInt(scope()->start_position())); |
2748 | 2748 |
2749 // Push. | 2749 // Push. |
2750 __ Push(x9, x10, x11, x12, x13); | 2750 __ Push(x9, x10, x11, x12, x13); |
2751 | 2751 |
2752 // Do the runtime call. | 2752 // Do the runtime call. |
2753 __ CallRuntime(Runtime::kResolvePossiblyDirectEval, 6); | 2753 __ CallRuntime(Runtime::kResolvePossiblyDirectEval, 6); |
2754 } | 2754 } |
2755 | 2755 |
2756 | 2756 |
2757 void FullCodeGenerator::EmitLoadSuperConstructor(SuperReference* super_ref) { | 2757 void FullCodeGenerator::EmitLoadSuperConstructor() { |
2758 DCHECK(super_ref != NULL); | |
2759 __ ldr(x0, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); | 2758 __ ldr(x0, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
2760 __ Push(x0); | 2759 __ Push(x0); |
2761 __ CallRuntime(Runtime::kGetPrototype, 1); | 2760 __ CallRuntime(Runtime::kGetPrototype, 1); |
2762 } | 2761 } |
2763 | 2762 |
2764 | 2763 |
2765 void FullCodeGenerator::VisitCall(Call* expr) { | 2764 void FullCodeGenerator::VisitCall(Call* expr) { |
2766 #ifdef DEBUG | 2765 #ifdef DEBUG |
2767 // We want to verify that RecordJSReturnSite gets called on all paths | 2766 // We want to verify that RecordJSReturnSite gets called on all paths |
2768 // through this function. Avoid early returns. | 2767 // through this function. Avoid early returns. |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2876 EmitCallWithLoadIC(expr); | 2875 EmitCallWithLoadIC(expr); |
2877 } else { | 2876 } else { |
2878 EmitKeyedCallWithLoadIC(expr, property->key()); | 2877 EmitKeyedCallWithLoadIC(expr, property->key()); |
2879 } | 2878 } |
2880 } | 2879 } |
2881 } else if (call_type == Call::SUPER_CALL) { | 2880 } else if (call_type == Call::SUPER_CALL) { |
2882 if (FLAG_experimental_classes) { | 2881 if (FLAG_experimental_classes) { |
2883 EmitSuperConstructorCall(expr); | 2882 EmitSuperConstructorCall(expr); |
2884 } else { | 2883 } else { |
2885 SuperReference* super_ref = callee->AsSuperReference(); | 2884 SuperReference* super_ref = callee->AsSuperReference(); |
2886 EmitLoadSuperConstructor(super_ref); | 2885 EmitLoadSuperConstructor(); |
2887 __ Push(result_register()); | 2886 __ Push(result_register()); |
2888 VisitForStackValue(super_ref->this_var()); | 2887 VisitForStackValue(super_ref->this_var()); |
2889 EmitCall(expr, CallICState::METHOD); | 2888 EmitCall(expr, CallICState::METHOD); |
2890 } | 2889 } |
2891 } else { | 2890 } else { |
2892 DCHECK(call_type == Call::OTHER_CALL); | 2891 DCHECK(call_type == Call::OTHER_CALL); |
2893 // Call to an arbitrary expression not handled specially above. | 2892 // Call to an arbitrary expression not handled specially above. |
2894 { PreservePositionScope scope(masm()->positions_recorder()); | 2893 { PreservePositionScope scope(masm()->positions_recorder()); |
2895 VisitForStackValue(callee); | 2894 VisitForStackValue(callee); |
2896 } | 2895 } |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2951 } | 2950 } |
2952 | 2951 |
2953 | 2952 |
2954 void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) { | 2953 void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) { |
2955 Comment cmnt(masm_, "[ SuperConstructorCall"); | 2954 Comment cmnt(masm_, "[ SuperConstructorCall"); |
2956 Variable* new_target_var = scope()->DeclarationScope()->new_target_var(); | 2955 Variable* new_target_var = scope()->DeclarationScope()->new_target_var(); |
2957 GetVar(result_register(), new_target_var); | 2956 GetVar(result_register(), new_target_var); |
2958 __ Push(result_register()); | 2957 __ Push(result_register()); |
2959 | 2958 |
2960 SuperReference* super_ref = expr->expression()->AsSuperReference(); | 2959 SuperReference* super_ref = expr->expression()->AsSuperReference(); |
2961 EmitLoadSuperConstructor(super_ref); | 2960 EmitLoadSuperConstructor(); |
2962 __ push(result_register()); | 2961 __ push(result_register()); |
2963 | 2962 |
2964 Variable* this_var = super_ref->this_var()->var(); | 2963 Variable* this_var = super_ref->this_var()->var(); |
2965 | 2964 |
2966 GetVar(x0, this_var); | 2965 GetVar(x0, this_var); |
2967 Label uninitialized_this; | 2966 Label uninitialized_this; |
2968 __ JumpIfRoot(x0, Heap::kTheHoleValueRootIndex, &uninitialized_this); | 2967 __ JumpIfRoot(x0, Heap::kTheHoleValueRootIndex, &uninitialized_this); |
2969 __ Mov(x0, Operand(this_var->name())); | 2968 __ Mov(x0, Operand(this_var->name())); |
2970 __ Push(x0); | 2969 __ Push(x0); |
2971 __ CallRuntime(Runtime::kThrowReferenceError, 1); | 2970 __ CallRuntime(Runtime::kThrowReferenceError, 1); |
(...skipping 905 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3877 | 3876 |
3878 __ Bind(&runtime); | 3877 __ Bind(&runtime); |
3879 __ Push(x0); | 3878 __ Push(x0); |
3880 __ CallRuntime(Runtime::kCall, args->length()); | 3879 __ CallRuntime(Runtime::kCall, args->length()); |
3881 __ Bind(&done); | 3880 __ Bind(&done); |
3882 | 3881 |
3883 context()->Plug(x0); | 3882 context()->Plug(x0); |
3884 } | 3883 } |
3885 | 3884 |
3886 | 3885 |
| 3886 void FullCodeGenerator::EmitDefaultConstructorCallSuper(CallRuntime* expr) { |
| 3887 Variable* new_target_var = scope()->DeclarationScope()->new_target_var(); |
| 3888 GetVar(result_register(), new_target_var); |
| 3889 __ Push(result_register()); |
| 3890 |
| 3891 EmitLoadSuperConstructor(); |
| 3892 __ Push(result_register()); |
| 3893 |
| 3894 // Check if the calling frame is an arguments adaptor frame. |
| 3895 Label adaptor_frame, args_set_up, runtime; |
| 3896 Register caller_fp = x11; |
| 3897 __ Ldr(x11, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); |
| 3898 __ Ldr(x12, MemOperand(x11, StandardFrameConstants::kContextOffset)); |
| 3899 __ Cmp(x12, Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)); |
| 3900 __ B(eq, &adaptor_frame); |
| 3901 // default constructor has no arguments, so no adaptor frame means no args. |
| 3902 __ Mov(x0, Operand(0)); |
| 3903 __ B(&args_set_up); |
| 3904 |
| 3905 // Copy arguments from adaptor frame. |
| 3906 { |
| 3907 __ bind(&adaptor_frame); |
| 3908 __ Ldr(x1, MemOperand(x11, ArgumentsAdaptorFrameConstants::kLengthOffset)); |
| 3909 __ SmiUntag(x1, x1); |
| 3910 |
| 3911 // Subtract 1 from arguments count, for new.target. |
| 3912 __ Sub(x1, x1, Operand(1)); |
| 3913 __ Mov(x0, x1); |
| 3914 |
| 3915 // Get arguments pointer in x11. |
| 3916 __ Add(x11, x11, Operand(x1, LSL, kPointerSizeLog2)); |
| 3917 __ Add(x11, x11, StandardFrameConstants::kCallerSPOffset); |
| 3918 Label loop; |
| 3919 __ bind(&loop); |
| 3920 // Pre-decrement x11 with kPointerSize on each iteration. |
| 3921 // Pre-decrement in order to skip receiver. |
| 3922 __ Ldr(x10, MemOperand(x11, -kPointerSize, PreIndex)); |
| 3923 __ Push(x10); |
| 3924 __ Sub(x1, x1, Operand(1)); |
| 3925 __ Cbnz(x1, &loop); |
| 3926 } |
| 3927 |
| 3928 __ bind(&args_set_up); |
| 3929 __ Peek(x1, Operand(x0, LSL, kPointerSizeLog2)); |
| 3930 |
| 3931 CallConstructStub stub(isolate(), SUPER_CONSTRUCTOR_CALL); |
| 3932 __ Call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); |
| 3933 |
| 3934 __ Drop(1); |
| 3935 |
| 3936 context()->Plug(result_register()); |
| 3937 } |
| 3938 |
| 3939 |
3887 void FullCodeGenerator::EmitRegExpConstructResult(CallRuntime* expr) { | 3940 void FullCodeGenerator::EmitRegExpConstructResult(CallRuntime* expr) { |
3888 RegExpConstructResultStub stub(isolate()); | 3941 RegExpConstructResultStub stub(isolate()); |
3889 ZoneList<Expression*>* args = expr->arguments(); | 3942 ZoneList<Expression*>* args = expr->arguments(); |
3890 DCHECK(args->length() == 3); | 3943 DCHECK(args->length() == 3); |
3891 VisitForStackValue(args->at(0)); | 3944 VisitForStackValue(args->at(0)); |
3892 VisitForStackValue(args->at(1)); | 3945 VisitForStackValue(args->at(1)); |
3893 VisitForAccumulatorValue(args->at(2)); | 3946 VisitForAccumulatorValue(args->at(2)); |
3894 __ Pop(x1, x2); | 3947 __ Pop(x1, x2); |
3895 __ CallStub(&stub); | 3948 __ CallStub(&stub); |
3896 context()->Plug(x0); | 3949 context()->Plug(x0); |
(...skipping 1520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5417 return previous_; | 5470 return previous_; |
5418 } | 5471 } |
5419 | 5472 |
5420 | 5473 |
5421 #undef __ | 5474 #undef __ |
5422 | 5475 |
5423 | 5476 |
5424 } } // namespace v8::internal | 5477 } } // namespace v8::internal |
5425 | 5478 |
5426 #endif // V8_TARGET_ARCH_ARM64 | 5479 #endif // V8_TARGET_ARCH_ARM64 |
OLD | NEW |