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 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_X64 | 7 #if V8_TARGET_ARCH_X64 |
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 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 } | 232 } |
233 } | 233 } |
234 } | 234 } |
235 } | 235 } |
236 | 236 |
237 Variable* home_object_var = scope()->home_object_var(); | 237 Variable* home_object_var = scope()->home_object_var(); |
238 if (home_object_var != nullptr) { | 238 if (home_object_var != nullptr) { |
239 __ Push(rdi); | 239 __ Push(rdi); |
240 } | 240 } |
241 | 241 |
| 242 // Possibly set up a local binding to the this function which is used in |
| 243 // derived constructors with super calls. |
| 244 Variable* this_function_var = scope()->this_function_var(); |
| 245 if (this_function_var != nullptr) { |
| 246 Comment cmnt(masm_, "[ This function"); |
| 247 SetVar(this_function_var, rdi, rbx, rdx); |
| 248 } |
| 249 |
| 250 Variable* new_target_var = scope()->new_target_var(); |
| 251 if (new_target_var != nullptr) { |
| 252 Comment cmnt(masm_, "[ new.target"); |
| 253 // new.target is parameter -2. |
| 254 int offset = 2 * kPointerSize + kFPOnStackSize + kPCOnStackSize + |
| 255 (info_->scope()->num_parameters() - 1) * kPointerSize; |
| 256 __ movp(rax, Operand(rbp, offset)); |
| 257 SetVar(new_target_var, rax, rbx, rdx); |
| 258 } |
| 259 |
242 ArgumentsAccessStub::HasNewTarget has_new_target = | 260 ArgumentsAccessStub::HasNewTarget has_new_target = |
243 IsSubclassConstructor(info->function()->kind()) | 261 IsSubclassConstructor(info->function()->kind()) |
244 ? ArgumentsAccessStub::HAS_NEW_TARGET | 262 ? ArgumentsAccessStub::HAS_NEW_TARGET |
245 : ArgumentsAccessStub::NO_NEW_TARGET; | 263 : ArgumentsAccessStub::NO_NEW_TARGET; |
246 | 264 |
247 // Possibly allocate RestParameters | 265 // Possibly allocate RestParameters |
248 int rest_index; | 266 int rest_index; |
249 Variable* rest_param = scope()->rest_parameter(&rest_index); | 267 Variable* rest_param = scope()->rest_parameter(&rest_index); |
250 if (rest_param) { | 268 if (rest_param) { |
251 Comment cmnt(masm_, "[ Allocate rest parameter array"); | 269 Comment cmnt(masm_, "[ Allocate rest parameter array"); |
(...skipping 1700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1952 case NAMED_PROPERTY: | 1970 case NAMED_PROPERTY: |
1953 if (expr->is_compound()) { | 1971 if (expr->is_compound()) { |
1954 // We need the receiver both on the stack and in the register. | 1972 // We need the receiver both on the stack and in the register. |
1955 VisitForStackValue(property->obj()); | 1973 VisitForStackValue(property->obj()); |
1956 __ movp(LoadDescriptor::ReceiverRegister(), Operand(rsp, 0)); | 1974 __ movp(LoadDescriptor::ReceiverRegister(), Operand(rsp, 0)); |
1957 } else { | 1975 } else { |
1958 VisitForStackValue(property->obj()); | 1976 VisitForStackValue(property->obj()); |
1959 } | 1977 } |
1960 break; | 1978 break; |
1961 case NAMED_SUPER_PROPERTY: | 1979 case NAMED_SUPER_PROPERTY: |
1962 VisitForStackValue(property->obj()->AsSuperReference()->this_var()); | 1980 VisitForStackValue( |
| 1981 property->obj()->AsSuperPropertyReference()->this_var()); |
1963 VisitForAccumulatorValue( | 1982 VisitForAccumulatorValue( |
1964 property->obj()->AsSuperReference()->home_object_var()); | 1983 property->obj()->AsSuperPropertyReference()->home_object_var()); |
1965 __ Push(result_register()); | 1984 __ Push(result_register()); |
1966 if (expr->is_compound()) { | 1985 if (expr->is_compound()) { |
1967 __ Push(MemOperand(rsp, kPointerSize)); | 1986 __ Push(MemOperand(rsp, kPointerSize)); |
1968 __ Push(result_register()); | 1987 __ Push(result_register()); |
1969 } | 1988 } |
1970 break; | 1989 break; |
1971 case KEYED_SUPER_PROPERTY: | 1990 case KEYED_SUPER_PROPERTY: |
1972 VisitForStackValue(property->obj()->AsSuperReference()->this_var()); | |
1973 VisitForStackValue( | 1991 VisitForStackValue( |
1974 property->obj()->AsSuperReference()->home_object_var()); | 1992 property->obj()->AsSuperPropertyReference()->this_var()); |
| 1993 VisitForStackValue( |
| 1994 property->obj()->AsSuperPropertyReference()->home_object_var()); |
1975 VisitForAccumulatorValue(property->key()); | 1995 VisitForAccumulatorValue(property->key()); |
1976 __ Push(result_register()); | 1996 __ Push(result_register()); |
1977 if (expr->is_compound()) { | 1997 if (expr->is_compound()) { |
1978 __ Push(MemOperand(rsp, 2 * kPointerSize)); | 1998 __ Push(MemOperand(rsp, 2 * kPointerSize)); |
1979 __ Push(MemOperand(rsp, 2 * kPointerSize)); | 1999 __ Push(MemOperand(rsp, 2 * kPointerSize)); |
1980 __ Push(result_register()); | 2000 __ Push(result_register()); |
1981 } | 2001 } |
1982 break; | 2002 break; |
1983 case KEYED_PROPERTY: { | 2003 case KEYED_PROPERTY: { |
1984 if (expr->is_compound()) { | 2004 if (expr->is_compound()) { |
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2556 __ Move(StoreDescriptor::ReceiverRegister(), rax); | 2576 __ Move(StoreDescriptor::ReceiverRegister(), rax); |
2557 __ Pop(StoreDescriptor::ValueRegister()); // Restore value. | 2577 __ Pop(StoreDescriptor::ValueRegister()); // Restore value. |
2558 __ Move(StoreDescriptor::NameRegister(), | 2578 __ Move(StoreDescriptor::NameRegister(), |
2559 prop->key()->AsLiteral()->value()); | 2579 prop->key()->AsLiteral()->value()); |
2560 if (FLAG_vector_stores) EmitLoadStoreICSlot(slot); | 2580 if (FLAG_vector_stores) EmitLoadStoreICSlot(slot); |
2561 CallStoreIC(); | 2581 CallStoreIC(); |
2562 break; | 2582 break; |
2563 } | 2583 } |
2564 case NAMED_SUPER_PROPERTY: { | 2584 case NAMED_SUPER_PROPERTY: { |
2565 __ Push(rax); | 2585 __ Push(rax); |
2566 VisitForStackValue(prop->obj()->AsSuperReference()->this_var()); | 2586 VisitForStackValue(prop->obj()->AsSuperPropertyReference()->this_var()); |
2567 VisitForAccumulatorValue( | 2587 VisitForAccumulatorValue( |
2568 prop->obj()->AsSuperReference()->home_object_var()); | 2588 prop->obj()->AsSuperPropertyReference()->home_object_var()); |
2569 // stack: value, this; rax: home_object | 2589 // stack: value, this; rax: home_object |
2570 Register scratch = rcx; | 2590 Register scratch = rcx; |
2571 Register scratch2 = rdx; | 2591 Register scratch2 = rdx; |
2572 __ Move(scratch, result_register()); // home_object | 2592 __ Move(scratch, result_register()); // home_object |
2573 __ movp(rax, MemOperand(rsp, kPointerSize)); // value | 2593 __ movp(rax, MemOperand(rsp, kPointerSize)); // value |
2574 __ movp(scratch2, MemOperand(rsp, 0)); // this | 2594 __ movp(scratch2, MemOperand(rsp, 0)); // this |
2575 __ movp(MemOperand(rsp, kPointerSize), scratch2); // this | 2595 __ movp(MemOperand(rsp, kPointerSize), scratch2); // this |
2576 __ movp(MemOperand(rsp, 0), scratch); // home_object | 2596 __ movp(MemOperand(rsp, 0), scratch); // home_object |
2577 // stack: this, home_object; rax: value | 2597 // stack: this, home_object; rax: value |
2578 EmitNamedSuperPropertyStore(prop); | 2598 EmitNamedSuperPropertyStore(prop); |
2579 break; | 2599 break; |
2580 } | 2600 } |
2581 case KEYED_SUPER_PROPERTY: { | 2601 case KEYED_SUPER_PROPERTY: { |
2582 __ Push(rax); | 2602 __ Push(rax); |
2583 VisitForStackValue(prop->obj()->AsSuperReference()->this_var()); | 2603 VisitForStackValue(prop->obj()->AsSuperPropertyReference()->this_var()); |
2584 VisitForStackValue(prop->obj()->AsSuperReference()->home_object_var()); | 2604 VisitForStackValue( |
| 2605 prop->obj()->AsSuperPropertyReference()->home_object_var()); |
2585 VisitForAccumulatorValue(prop->key()); | 2606 VisitForAccumulatorValue(prop->key()); |
2586 Register scratch = rcx; | 2607 Register scratch = rcx; |
2587 Register scratch2 = rdx; | 2608 Register scratch2 = rdx; |
2588 __ movp(scratch2, MemOperand(rsp, 2 * kPointerSize)); // value | 2609 __ movp(scratch2, MemOperand(rsp, 2 * kPointerSize)); // value |
2589 // stack: value, this, home_object; rax: key, rdx: value | 2610 // stack: value, this, home_object; rax: key, rdx: value |
2590 __ movp(scratch, MemOperand(rsp, kPointerSize)); // this | 2611 __ movp(scratch, MemOperand(rsp, kPointerSize)); // this |
2591 __ movp(MemOperand(rsp, 2 * kPointerSize), scratch); | 2612 __ movp(MemOperand(rsp, 2 * kPointerSize), scratch); |
2592 __ movp(scratch, MemOperand(rsp, 0)); // home_object | 2613 __ movp(scratch, MemOperand(rsp, 0)); // home_object |
2593 __ movp(MemOperand(rsp, kPointerSize), scratch); | 2614 __ movp(MemOperand(rsp, kPointerSize), scratch); |
2594 __ movp(MemOperand(rsp, 0), rax); | 2615 __ movp(MemOperand(rsp, 0), rax); |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2793 Comment cmnt(masm_, "[ Property"); | 2814 Comment cmnt(masm_, "[ Property"); |
2794 Expression* key = expr->key(); | 2815 Expression* key = expr->key(); |
2795 | 2816 |
2796 if (key->IsPropertyName()) { | 2817 if (key->IsPropertyName()) { |
2797 if (!expr->IsSuperAccess()) { | 2818 if (!expr->IsSuperAccess()) { |
2798 VisitForAccumulatorValue(expr->obj()); | 2819 VisitForAccumulatorValue(expr->obj()); |
2799 DCHECK(!rax.is(LoadDescriptor::ReceiverRegister())); | 2820 DCHECK(!rax.is(LoadDescriptor::ReceiverRegister())); |
2800 __ movp(LoadDescriptor::ReceiverRegister(), rax); | 2821 __ movp(LoadDescriptor::ReceiverRegister(), rax); |
2801 EmitNamedPropertyLoad(expr); | 2822 EmitNamedPropertyLoad(expr); |
2802 } else { | 2823 } else { |
2803 VisitForStackValue(expr->obj()->AsSuperReference()->this_var()); | 2824 VisitForStackValue(expr->obj()->AsSuperPropertyReference()->this_var()); |
2804 VisitForStackValue(expr->obj()->AsSuperReference()->home_object_var()); | 2825 VisitForStackValue( |
| 2826 expr->obj()->AsSuperPropertyReference()->home_object_var()); |
2805 EmitNamedSuperPropertyLoad(expr); | 2827 EmitNamedSuperPropertyLoad(expr); |
2806 } | 2828 } |
2807 } else { | 2829 } else { |
2808 if (!expr->IsSuperAccess()) { | 2830 if (!expr->IsSuperAccess()) { |
2809 VisitForStackValue(expr->obj()); | 2831 VisitForStackValue(expr->obj()); |
2810 VisitForAccumulatorValue(expr->key()); | 2832 VisitForAccumulatorValue(expr->key()); |
2811 __ Move(LoadDescriptor::NameRegister(), rax); | 2833 __ Move(LoadDescriptor::NameRegister(), rax); |
2812 __ Pop(LoadDescriptor::ReceiverRegister()); | 2834 __ Pop(LoadDescriptor::ReceiverRegister()); |
2813 EmitKeyedPropertyLoad(expr); | 2835 EmitKeyedPropertyLoad(expr); |
2814 } else { | 2836 } else { |
2815 VisitForStackValue(expr->obj()->AsSuperReference()->this_var()); | 2837 VisitForStackValue(expr->obj()->AsSuperPropertyReference()->this_var()); |
2816 VisitForStackValue(expr->obj()->AsSuperReference()->home_object_var()); | 2838 VisitForStackValue( |
| 2839 expr->obj()->AsSuperPropertyReference()->home_object_var()); |
2817 VisitForStackValue(expr->key()); | 2840 VisitForStackValue(expr->key()); |
2818 EmitKeyedSuperPropertyLoad(expr); | 2841 EmitKeyedSuperPropertyLoad(expr); |
2819 } | 2842 } |
2820 } | 2843 } |
2821 PrepareForBailoutForId(expr->LoadId(), TOS_REG); | 2844 PrepareForBailoutForId(expr->LoadId(), TOS_REG); |
2822 context()->Plug(rax); | 2845 context()->Plug(rax); |
2823 } | 2846 } |
2824 | 2847 |
2825 | 2848 |
2826 void FullCodeGenerator::CallIC(Handle<Code> code, | 2849 void FullCodeGenerator::CallIC(Handle<Code> code, |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2864 void FullCodeGenerator::EmitSuperCallWithLoadIC(Call* expr) { | 2887 void FullCodeGenerator::EmitSuperCallWithLoadIC(Call* expr) { |
2865 Expression* callee = expr->expression(); | 2888 Expression* callee = expr->expression(); |
2866 DCHECK(callee->IsProperty()); | 2889 DCHECK(callee->IsProperty()); |
2867 Property* prop = callee->AsProperty(); | 2890 Property* prop = callee->AsProperty(); |
2868 DCHECK(prop->IsSuperAccess()); | 2891 DCHECK(prop->IsSuperAccess()); |
2869 | 2892 |
2870 SetSourcePosition(prop->position()); | 2893 SetSourcePosition(prop->position()); |
2871 Literal* key = prop->key()->AsLiteral(); | 2894 Literal* key = prop->key()->AsLiteral(); |
2872 DCHECK(!key->value()->IsSmi()); | 2895 DCHECK(!key->value()->IsSmi()); |
2873 // Load the function from the receiver. | 2896 // Load the function from the receiver. |
2874 SuperReference* super_ref = prop->obj()->AsSuperReference(); | 2897 SuperPropertyReference* super_ref = prop->obj()->AsSuperPropertyReference(); |
2875 VisitForStackValue(super_ref->home_object_var()); | 2898 VisitForStackValue(super_ref->home_object_var()); |
2876 VisitForAccumulatorValue(super_ref->this_var()); | 2899 VisitForAccumulatorValue(super_ref->this_var()); |
2877 __ Push(rax); | 2900 __ Push(rax); |
2878 __ Push(rax); | 2901 __ Push(rax); |
2879 __ Push(Operand(rsp, kPointerSize * 2)); | 2902 __ Push(Operand(rsp, kPointerSize * 2)); |
2880 __ Push(key->value()); | 2903 __ Push(key->value()); |
2881 | 2904 |
2882 // Stack here: | 2905 // Stack here: |
2883 // - home_object | 2906 // - home_object |
2884 // - this (receiver) | 2907 // - this (receiver) |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2921 | 2944 |
2922 | 2945 |
2923 void FullCodeGenerator::EmitKeyedSuperCallWithLoadIC(Call* expr) { | 2946 void FullCodeGenerator::EmitKeyedSuperCallWithLoadIC(Call* expr) { |
2924 Expression* callee = expr->expression(); | 2947 Expression* callee = expr->expression(); |
2925 DCHECK(callee->IsProperty()); | 2948 DCHECK(callee->IsProperty()); |
2926 Property* prop = callee->AsProperty(); | 2949 Property* prop = callee->AsProperty(); |
2927 DCHECK(prop->IsSuperAccess()); | 2950 DCHECK(prop->IsSuperAccess()); |
2928 | 2951 |
2929 SetSourcePosition(prop->position()); | 2952 SetSourcePosition(prop->position()); |
2930 // Load the function from the receiver. | 2953 // Load the function from the receiver. |
2931 SuperReference* super_ref = prop->obj()->AsSuperReference(); | 2954 SuperPropertyReference* super_ref = prop->obj()->AsSuperPropertyReference(); |
2932 VisitForStackValue(super_ref->home_object_var()); | 2955 VisitForStackValue(super_ref->home_object_var()); |
2933 VisitForAccumulatorValue(super_ref->this_var()); | 2956 VisitForAccumulatorValue(super_ref->this_var()); |
2934 __ Push(rax); | 2957 __ Push(rax); |
2935 __ Push(rax); | 2958 __ Push(rax); |
2936 __ Push(Operand(rsp, kPointerSize * 2)); | 2959 __ Push(Operand(rsp, kPointerSize * 2)); |
2937 VisitForStackValue(prop->key()); | 2960 VisitForStackValue(prop->key()); |
2938 | 2961 |
2939 // Stack here: | 2962 // Stack here: |
2940 // - home_object | 2963 // - home_object |
2941 // - this (receiver) | 2964 // - this (receiver) |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3002 __ Push(Smi::FromInt(language_mode())); | 3025 __ Push(Smi::FromInt(language_mode())); |
3003 | 3026 |
3004 // Push the start position of the scope the calls resides in. | 3027 // Push the start position of the scope the calls resides in. |
3005 __ Push(Smi::FromInt(scope()->start_position())); | 3028 __ Push(Smi::FromInt(scope()->start_position())); |
3006 | 3029 |
3007 // Do the runtime call. | 3030 // Do the runtime call. |
3008 __ CallRuntime(Runtime::kResolvePossiblyDirectEval, 6); | 3031 __ CallRuntime(Runtime::kResolvePossiblyDirectEval, 6); |
3009 } | 3032 } |
3010 | 3033 |
3011 | 3034 |
3012 void FullCodeGenerator::EmitLoadSuperConstructor() { | |
3013 __ Push(Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); | |
3014 __ CallRuntime(Runtime::kGetPrototype, 1); | |
3015 } | |
3016 | |
3017 | |
3018 void FullCodeGenerator::EmitInitializeThisAfterSuper( | 3035 void FullCodeGenerator::EmitInitializeThisAfterSuper( |
3019 SuperReference* super_ref, FeedbackVectorICSlot slot) { | 3036 SuperCallReference* super_ref, FeedbackVectorICSlot slot) { |
3020 Variable* this_var = super_ref->this_var()->var(); | 3037 Variable* this_var = super_ref->this_var()->var(); |
3021 GetVar(rcx, this_var); | 3038 GetVar(rcx, this_var); |
3022 __ CompareRoot(rcx, Heap::kTheHoleValueRootIndex); | 3039 __ CompareRoot(rcx, Heap::kTheHoleValueRootIndex); |
3023 Label uninitialized_this; | 3040 Label uninitialized_this; |
3024 __ j(equal, &uninitialized_this); | 3041 __ j(equal, &uninitialized_this); |
3025 __ Push(this_var->name()); | 3042 __ Push(this_var->name()); |
3026 __ CallRuntime(Runtime::kThrowReferenceError, 1); | 3043 __ CallRuntime(Runtime::kThrowReferenceError, 1); |
3027 __ bind(&uninitialized_this); | 3044 __ bind(&uninitialized_this); |
3028 | 3045 |
3029 EmitVariableAssignment(this_var, Token::INIT_CONST, slot); | 3046 EmitVariableAssignment(this_var, Token::INIT_CONST, slot); |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3159 | 3176 |
3160 void FullCodeGenerator::VisitCallNew(CallNew* expr) { | 3177 void FullCodeGenerator::VisitCallNew(CallNew* expr) { |
3161 Comment cmnt(masm_, "[ CallNew"); | 3178 Comment cmnt(masm_, "[ CallNew"); |
3162 // According to ECMA-262, section 11.2.2, page 44, the function | 3179 // According to ECMA-262, section 11.2.2, page 44, the function |
3163 // expression in new calls must be evaluated before the | 3180 // expression in new calls must be evaluated before the |
3164 // arguments. | 3181 // arguments. |
3165 | 3182 |
3166 // Push constructor on the stack. If it's not a function it's used as | 3183 // Push constructor on the stack. If it's not a function it's used as |
3167 // receiver for CALL_NON_FUNCTION, otherwise the value on the stack is | 3184 // receiver for CALL_NON_FUNCTION, otherwise the value on the stack is |
3168 // ignored. | 3185 // ignored. |
3169 DCHECK(!expr->expression()->IsSuperReference()); | 3186 DCHECK(!expr->expression()->IsSuperPropertyReference()); |
3170 VisitForStackValue(expr->expression()); | 3187 VisitForStackValue(expr->expression()); |
3171 | 3188 |
3172 // Push the arguments ("left-to-right") on the stack. | 3189 // Push the arguments ("left-to-right") on the stack. |
3173 ZoneList<Expression*>* args = expr->arguments(); | 3190 ZoneList<Expression*>* args = expr->arguments(); |
3174 int arg_count = args->length(); | 3191 int arg_count = args->length(); |
3175 for (int i = 0; i < arg_count; i++) { | 3192 for (int i = 0; i < arg_count; i++) { |
3176 VisitForStackValue(args->at(i)); | 3193 VisitForStackValue(args->at(i)); |
3177 } | 3194 } |
3178 | 3195 |
3179 // Call the construct call builtin that handles allocation and | 3196 // Call the construct call builtin that handles allocation and |
(...skipping 15 matching lines...) Expand all Loading... |
3195 __ Move(rdx, SmiFromSlot(expr->CallNewFeedbackSlot())); | 3212 __ Move(rdx, SmiFromSlot(expr->CallNewFeedbackSlot())); |
3196 | 3213 |
3197 CallConstructStub stub(isolate(), RECORD_CONSTRUCTOR_TARGET); | 3214 CallConstructStub stub(isolate(), RECORD_CONSTRUCTOR_TARGET); |
3198 __ Call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); | 3215 __ Call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); |
3199 PrepareForBailoutForId(expr->ReturnId(), TOS_REG); | 3216 PrepareForBailoutForId(expr->ReturnId(), TOS_REG); |
3200 context()->Plug(rax); | 3217 context()->Plug(rax); |
3201 } | 3218 } |
3202 | 3219 |
3203 | 3220 |
3204 void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) { | 3221 void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) { |
3205 Variable* new_target_var = scope()->DeclarationScope()->new_target_var(); | 3222 SuperCallReference* super_call_ref = |
3206 GetVar(result_register(), new_target_var); | 3223 expr->expression()->AsSuperCallReference(); |
3207 __ Push(result_register()); | 3224 DCHECK_NOT_NULL(super_call_ref); |
3208 | 3225 |
3209 EmitLoadSuperConstructor(); | 3226 VariableProxy* new_target_proxy = super_call_ref->new_target_var(); |
| 3227 VisitForStackValue(new_target_proxy); |
| 3228 |
| 3229 EmitLoadSuperConstructor(super_call_ref); |
3210 __ Push(result_register()); | 3230 __ Push(result_register()); |
3211 | 3231 |
3212 // Push the arguments ("left-to-right") on the stack. | 3232 // Push the arguments ("left-to-right") on the stack. |
3213 ZoneList<Expression*>* args = expr->arguments(); | 3233 ZoneList<Expression*>* args = expr->arguments(); |
3214 int arg_count = args->length(); | 3234 int arg_count = args->length(); |
3215 for (int i = 0; i < arg_count; i++) { | 3235 for (int i = 0; i < arg_count; i++) { |
3216 VisitForStackValue(args->at(i)); | 3236 VisitForStackValue(args->at(i)); |
3217 } | 3237 } |
3218 | 3238 |
3219 // Call the construct call builtin that handles allocation and | 3239 // Call the construct call builtin that handles allocation and |
(...skipping 17 matching lines...) Expand all Loading... |
3237 __ Move(rbx, FeedbackVector()); | 3257 __ Move(rbx, FeedbackVector()); |
3238 __ Move(rdx, SmiFromSlot(expr->CallFeedbackSlot())); | 3258 __ Move(rdx, SmiFromSlot(expr->CallFeedbackSlot())); |
3239 | 3259 |
3240 CallConstructStub stub(isolate(), SUPER_CALL_RECORD_TARGET); | 3260 CallConstructStub stub(isolate(), SUPER_CALL_RECORD_TARGET); |
3241 __ call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); | 3261 __ call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); |
3242 | 3262 |
3243 __ Drop(1); | 3263 __ Drop(1); |
3244 | 3264 |
3245 RecordJSReturnSite(expr); | 3265 RecordJSReturnSite(expr); |
3246 | 3266 |
3247 EmitInitializeThisAfterSuper(expr->expression()->AsSuperReference(), | 3267 EmitInitializeThisAfterSuper(super_call_ref, expr->CallFeedbackICSlot()); |
3248 expr->CallFeedbackICSlot()); | |
3249 context()->Plug(rax); | 3268 context()->Plug(rax); |
3250 } | 3269 } |
3251 | 3270 |
3252 | 3271 |
3253 void FullCodeGenerator::EmitIsSmi(CallRuntime* expr) { | 3272 void FullCodeGenerator::EmitIsSmi(CallRuntime* expr) { |
3254 ZoneList<Expression*>* args = expr->arguments(); | 3273 ZoneList<Expression*>* args = expr->arguments(); |
3255 DCHECK(args->length() == 1); | 3274 DCHECK(args->length() == 1); |
3256 | 3275 |
3257 VisitForAccumulatorValue(args->at(0)); | 3276 VisitForAccumulatorValue(args->at(0)); |
3258 | 3277 |
(...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4105 __ bind(&runtime); | 4124 __ bind(&runtime); |
4106 __ Push(rax); | 4125 __ Push(rax); |
4107 __ CallRuntime(Runtime::kCall, args->length()); | 4126 __ CallRuntime(Runtime::kCall, args->length()); |
4108 __ bind(&done); | 4127 __ bind(&done); |
4109 | 4128 |
4110 context()->Plug(rax); | 4129 context()->Plug(rax); |
4111 } | 4130 } |
4112 | 4131 |
4113 | 4132 |
4114 void FullCodeGenerator::EmitDefaultConstructorCallSuper(CallRuntime* expr) { | 4133 void FullCodeGenerator::EmitDefaultConstructorCallSuper(CallRuntime* expr) { |
4115 Variable* new_target_var = scope()->DeclarationScope()->new_target_var(); | 4134 ZoneList<Expression*>* args = expr->arguments(); |
4116 GetVar(result_register(), new_target_var); | 4135 DCHECK(args->length() == 2); |
4117 __ Push(result_register()); | |
4118 | 4136 |
4119 EmitLoadSuperConstructor(); | 4137 // new.target |
| 4138 VisitForStackValue(args->at(0)); |
| 4139 |
| 4140 // .this_function |
| 4141 VisitForStackValue(args->at(1)); |
| 4142 __ CallRuntime(Runtime::kGetPrototype, 1); |
4120 __ Push(result_register()); | 4143 __ Push(result_register()); |
4121 | 4144 |
4122 // Check if the calling frame is an arguments adaptor frame. | 4145 // Check if the calling frame is an arguments adaptor frame. |
4123 Label adaptor_frame, args_set_up, runtime; | 4146 Label adaptor_frame, args_set_up, runtime; |
4124 __ movp(rdx, Operand(rbp, StandardFrameConstants::kCallerFPOffset)); | 4147 __ movp(rdx, Operand(rbp, StandardFrameConstants::kCallerFPOffset)); |
4125 __ movp(rcx, Operand(rdx, StandardFrameConstants::kContextOffset)); | 4148 __ movp(rcx, Operand(rdx, StandardFrameConstants::kContextOffset)); |
4126 __ Cmp(rcx, Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)); | 4149 __ Cmp(rcx, Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)); |
4127 __ j(equal, &adaptor_frame); | 4150 __ j(equal, &adaptor_frame); |
4128 // default constructor has no arguments, so no adaptor frame means no args. | 4151 // default constructor has no arguments, so no adaptor frame means no args. |
4129 __ movp(rax, Immediate(0)); | 4152 __ movp(rax, Immediate(0)); |
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4561 ExternalReference::debug_is_active_address(isolate()); | 4584 ExternalReference::debug_is_active_address(isolate()); |
4562 __ Move(kScratchRegister, debug_is_active); | 4585 __ Move(kScratchRegister, debug_is_active); |
4563 __ movzxbp(rax, Operand(kScratchRegister, 0)); | 4586 __ movzxbp(rax, Operand(kScratchRegister, 0)); |
4564 __ Integer32ToSmi(rax, rax); | 4587 __ Integer32ToSmi(rax, rax); |
4565 context()->Plug(rax); | 4588 context()->Plug(rax); |
4566 } | 4589 } |
4567 | 4590 |
4568 | 4591 |
4569 void FullCodeGenerator::EmitCallSuperWithSpread(CallRuntime* expr) { | 4592 void FullCodeGenerator::EmitCallSuperWithSpread(CallRuntime* expr) { |
4570 // Assert: expr === CallRuntime("ReflectConstruct") | 4593 // Assert: expr === CallRuntime("ReflectConstruct") |
| 4594 DCHECK_EQ(1, expr->arguments()->length()); |
4571 CallRuntime* call = expr->arguments()->at(0)->AsCallRuntime(); | 4595 CallRuntime* call = expr->arguments()->at(0)->AsCallRuntime(); |
| 4596 |
4572 ZoneList<Expression*>* args = call->arguments(); | 4597 ZoneList<Expression*>* args = call->arguments(); |
4573 DCHECK_EQ(3, args->length()); | 4598 DCHECK_EQ(3, args->length()); |
4574 | 4599 |
4575 SuperReference* super_reference = args->at(0)->AsSuperReference(); | 4600 SuperCallReference* super_call_ref = args->at(0)->AsSuperCallReference(); |
| 4601 DCHECK_NOT_NULL(super_call_ref); |
4576 | 4602 |
4577 // Load ReflectConstruct function | 4603 // Load ReflectConstruct function |
4578 EmitLoadJSRuntimeFunction(call); | 4604 EmitLoadJSRuntimeFunction(call); |
4579 | 4605 |
4580 // Push the target function under the receiver. | 4606 // Push the target function under the receiver. |
4581 __ Push(Operand(rsp, 0)); | 4607 __ Push(Operand(rsp, 0)); |
4582 __ movp(Operand(rsp, kPointerSize), rax); | 4608 __ movp(Operand(rsp, kPointerSize), rax); |
4583 | 4609 |
4584 // Push super | 4610 // Push super constructor |
4585 EmitLoadSuperConstructor(); | 4611 EmitLoadSuperConstructor(super_call_ref); |
4586 __ Push(result_register()); | 4612 __ Push(result_register()); |
4587 | 4613 |
4588 // Push arguments array | 4614 // Push arguments array |
4589 VisitForStackValue(args->at(1)); | 4615 VisitForStackValue(args->at(1)); |
4590 | 4616 |
4591 // Push NewTarget | 4617 // Push NewTarget |
4592 DCHECK(args->at(2)->IsVariableProxy()); | 4618 DCHECK(args->at(2)->IsVariableProxy()); |
4593 VisitForStackValue(args->at(2)); | 4619 VisitForStackValue(args->at(2)); |
4594 | 4620 |
4595 EmitCallJSRuntimeFunction(call); | 4621 EmitCallJSRuntimeFunction(call); |
4596 | 4622 |
4597 // Restore context register. | 4623 // Restore context register. |
4598 __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); | 4624 __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); |
4599 context()->DropAndPlug(1, rax); | 4625 context()->DropAndPlug(1, rax); |
4600 | 4626 |
4601 // TODO(mvstanton): with FLAG_vector_stores this needs a slot id. | 4627 // TODO(mvstanton): with FLAG_vector_stores this needs a slot id. |
4602 EmitInitializeThisAfterSuper(super_reference); | 4628 EmitInitializeThisAfterSuper(super_call_ref); |
4603 } | 4629 } |
4604 | 4630 |
4605 | 4631 |
4606 void FullCodeGenerator::EmitLoadJSRuntimeFunction(CallRuntime* expr) { | 4632 void FullCodeGenerator::EmitLoadJSRuntimeFunction(CallRuntime* expr) { |
4607 // Push the builtins object as receiver. | 4633 // Push the builtins object as receiver. |
4608 __ movp(rax, GlobalObjectOperand()); | 4634 __ movp(rax, GlobalObjectOperand()); |
4609 __ Push(FieldOperand(rax, GlobalObject::kBuiltinsOffset)); | 4635 __ Push(FieldOperand(rax, GlobalObject::kBuiltinsOffset)); |
4610 | 4636 |
4611 // Load the function from the receiver. | 4637 // Load the function from the receiver. |
4612 __ movp(LoadDescriptor::ReceiverRegister(), Operand(rsp, 0)); | 4638 __ movp(LoadDescriptor::ReceiverRegister(), Operand(rsp, 0)); |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4817 } | 4843 } |
4818 switch (assign_type) { | 4844 switch (assign_type) { |
4819 case NAMED_PROPERTY: { | 4845 case NAMED_PROPERTY: { |
4820 VisitForStackValue(prop->obj()); | 4846 VisitForStackValue(prop->obj()); |
4821 __ movp(LoadDescriptor::ReceiverRegister(), Operand(rsp, 0)); | 4847 __ movp(LoadDescriptor::ReceiverRegister(), Operand(rsp, 0)); |
4822 EmitNamedPropertyLoad(prop); | 4848 EmitNamedPropertyLoad(prop); |
4823 break; | 4849 break; |
4824 } | 4850 } |
4825 | 4851 |
4826 case NAMED_SUPER_PROPERTY: { | 4852 case NAMED_SUPER_PROPERTY: { |
4827 VisitForStackValue(prop->obj()->AsSuperReference()->this_var()); | 4853 VisitForStackValue(prop->obj()->AsSuperPropertyReference()->this_var()); |
4828 VisitForAccumulatorValue( | 4854 VisitForAccumulatorValue( |
4829 prop->obj()->AsSuperReference()->home_object_var()); | 4855 prop->obj()->AsSuperPropertyReference()->home_object_var()); |
4830 __ Push(result_register()); | 4856 __ Push(result_register()); |
4831 __ Push(MemOperand(rsp, kPointerSize)); | 4857 __ Push(MemOperand(rsp, kPointerSize)); |
4832 __ Push(result_register()); | 4858 __ Push(result_register()); |
4833 EmitNamedSuperPropertyLoad(prop); | 4859 EmitNamedSuperPropertyLoad(prop); |
4834 break; | 4860 break; |
4835 } | 4861 } |
4836 | 4862 |
4837 case KEYED_SUPER_PROPERTY: { | 4863 case KEYED_SUPER_PROPERTY: { |
4838 VisitForStackValue(prop->obj()->AsSuperReference()->this_var()); | 4864 VisitForStackValue(prop->obj()->AsSuperPropertyReference()->this_var()); |
4839 VisitForStackValue(prop->obj()->AsSuperReference()->home_object_var()); | 4865 VisitForStackValue( |
| 4866 prop->obj()->AsSuperPropertyReference()->home_object_var()); |
4840 VisitForAccumulatorValue(prop->key()); | 4867 VisitForAccumulatorValue(prop->key()); |
4841 __ Push(result_register()); | 4868 __ Push(result_register()); |
4842 __ Push(MemOperand(rsp, 2 * kPointerSize)); | 4869 __ Push(MemOperand(rsp, 2 * kPointerSize)); |
4843 __ Push(MemOperand(rsp, 2 * kPointerSize)); | 4870 __ Push(MemOperand(rsp, 2 * kPointerSize)); |
4844 __ Push(result_register()); | 4871 __ Push(result_register()); |
4845 EmitKeyedSuperPropertyLoad(prop); | 4872 EmitKeyedSuperPropertyLoad(prop); |
4846 break; | 4873 break; |
4847 } | 4874 } |
4848 | 4875 |
4849 case KEYED_PROPERTY: { | 4876 case KEYED_PROPERTY: { |
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5451 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), | 5478 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), |
5452 Assembler::target_address_at(call_target_address, | 5479 Assembler::target_address_at(call_target_address, |
5453 unoptimized_code)); | 5480 unoptimized_code)); |
5454 return OSR_AFTER_STACK_CHECK; | 5481 return OSR_AFTER_STACK_CHECK; |
5455 } | 5482 } |
5456 | 5483 |
5457 | 5484 |
5458 } } // namespace v8::internal | 5485 } } // namespace v8::internal |
5459 | 5486 |
5460 #endif // V8_TARGET_ARCH_X64 | 5487 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |