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_MIPS64 | 7 #if V8_TARGET_ARCH_MIPS64 |
8 | 8 |
9 // Note on Mips implementation: | 9 // Note on Mips implementation: |
10 // | 10 // |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 } | 246 } |
247 } | 247 } |
248 } | 248 } |
249 } | 249 } |
250 | 250 |
251 Variable* home_object_var = scope()->home_object_var(); | 251 Variable* home_object_var = scope()->home_object_var(); |
252 if (home_object_var != nullptr) { | 252 if (home_object_var != nullptr) { |
253 __ Push(a1); | 253 __ Push(a1); |
254 } | 254 } |
255 | 255 |
| 256 // Possibly set up a local binding to the this function which is used in |
| 257 // derived constructors with super calls. |
| 258 Variable* this_function_var = scope()->this_function_var(); |
| 259 if (this_function_var != nullptr) { |
| 260 Comment cmnt(masm_, "[ This function"); |
| 261 SetVar(this_function_var, a1, a2, a3); |
| 262 } |
| 263 |
| 264 Variable* new_target_var = scope()->new_target_var(); |
| 265 if (new_target_var != nullptr) { |
| 266 Comment cmnt(masm_, "[ new.target"); |
| 267 // new.target is parameter -2. |
| 268 int offset = 2 * kPointerSize + |
| 269 (info_->scope()->num_parameters() + 1) * kPointerSize; |
| 270 __ lw(v0, MemOperand(fp, offset)); |
| 271 SetVar(new_target_var, v0, a2, a3); |
| 272 } |
| 273 |
256 ArgumentsAccessStub::HasNewTarget has_new_target = | 274 ArgumentsAccessStub::HasNewTarget has_new_target = |
257 IsSubclassConstructor(info->function()->kind()) | 275 IsSubclassConstructor(info->function()->kind()) |
258 ? ArgumentsAccessStub::HAS_NEW_TARGET | 276 ? ArgumentsAccessStub::HAS_NEW_TARGET |
259 : ArgumentsAccessStub::NO_NEW_TARGET; | 277 : ArgumentsAccessStub::NO_NEW_TARGET; |
260 | 278 |
261 // Possibly allocate RestParameters | 279 // Possibly allocate RestParameters |
262 int rest_index; | 280 int rest_index; |
263 Variable* rest_param = scope()->rest_parameter(&rest_index); | 281 Variable* rest_param = scope()->rest_parameter(&rest_index); |
264 if (rest_param) { | 282 if (rest_param) { |
265 Comment cmnt(masm_, "[ Allocate rest parameter array"); | 283 Comment cmnt(masm_, "[ Allocate rest parameter array"); |
(...skipping 1714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1980 case NAMED_PROPERTY: | 1998 case NAMED_PROPERTY: |
1981 if (expr->is_compound()) { | 1999 if (expr->is_compound()) { |
1982 // We need the receiver both on the stack and in the register. | 2000 // We need the receiver both on the stack and in the register. |
1983 VisitForStackValue(property->obj()); | 2001 VisitForStackValue(property->obj()); |
1984 __ ld(LoadDescriptor::ReceiverRegister(), MemOperand(sp, 0)); | 2002 __ ld(LoadDescriptor::ReceiverRegister(), MemOperand(sp, 0)); |
1985 } else { | 2003 } else { |
1986 VisitForStackValue(property->obj()); | 2004 VisitForStackValue(property->obj()); |
1987 } | 2005 } |
1988 break; | 2006 break; |
1989 case NAMED_SUPER_PROPERTY: | 2007 case NAMED_SUPER_PROPERTY: |
1990 VisitForStackValue(property->obj()->AsSuperReference()->this_var()); | 2008 VisitForStackValue( |
| 2009 property->obj()->AsSuperPropertyReference()->this_var()); |
1991 VisitForAccumulatorValue( | 2010 VisitForAccumulatorValue( |
1992 property->obj()->AsSuperReference()->home_object_var()); | 2011 property->obj()->AsSuperPropertyReference()->home_object_var()); |
1993 __ Push(result_register()); | 2012 __ Push(result_register()); |
1994 if (expr->is_compound()) { | 2013 if (expr->is_compound()) { |
1995 const Register scratch = a1; | 2014 const Register scratch = a1; |
1996 __ ld(scratch, MemOperand(sp, kPointerSize)); | 2015 __ ld(scratch, MemOperand(sp, kPointerSize)); |
1997 __ Push(scratch, result_register()); | 2016 __ Push(scratch, result_register()); |
1998 } | 2017 } |
1999 break; | 2018 break; |
2000 case KEYED_SUPER_PROPERTY: { | 2019 case KEYED_SUPER_PROPERTY: { |
2001 const Register scratch = a1; | 2020 const Register scratch = a1; |
2002 VisitForStackValue(property->obj()->AsSuperReference()->this_var()); | 2021 VisitForStackValue( |
| 2022 property->obj()->AsSuperPropertyReference()->this_var()); |
2003 VisitForAccumulatorValue( | 2023 VisitForAccumulatorValue( |
2004 property->obj()->AsSuperReference()->home_object_var()); | 2024 property->obj()->AsSuperPropertyReference()->home_object_var()); |
2005 __ Move(scratch, result_register()); | 2025 __ Move(scratch, result_register()); |
2006 VisitForAccumulatorValue(property->key()); | 2026 VisitForAccumulatorValue(property->key()); |
2007 __ Push(scratch, result_register()); | 2027 __ Push(scratch, result_register()); |
2008 if (expr->is_compound()) { | 2028 if (expr->is_compound()) { |
2009 const Register scratch1 = a4; | 2029 const Register scratch1 = a4; |
2010 __ ld(scratch1, MemOperand(sp, 2 * kPointerSize)); | 2030 __ ld(scratch1, MemOperand(sp, 2 * kPointerSize)); |
2011 __ Push(scratch1, scratch, result_register()); | 2031 __ Push(scratch1, scratch, result_register()); |
2012 } | 2032 } |
2013 break; | 2033 break; |
2014 } | 2034 } |
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2628 __ mov(StoreDescriptor::ReceiverRegister(), result_register()); | 2648 __ mov(StoreDescriptor::ReceiverRegister(), result_register()); |
2629 __ pop(StoreDescriptor::ValueRegister()); // Restore value. | 2649 __ pop(StoreDescriptor::ValueRegister()); // Restore value. |
2630 __ li(StoreDescriptor::NameRegister(), | 2650 __ li(StoreDescriptor::NameRegister(), |
2631 Operand(prop->key()->AsLiteral()->value())); | 2651 Operand(prop->key()->AsLiteral()->value())); |
2632 if (FLAG_vector_stores) EmitLoadStoreICSlot(slot); | 2652 if (FLAG_vector_stores) EmitLoadStoreICSlot(slot); |
2633 CallStoreIC(); | 2653 CallStoreIC(); |
2634 break; | 2654 break; |
2635 } | 2655 } |
2636 case NAMED_SUPER_PROPERTY: { | 2656 case NAMED_SUPER_PROPERTY: { |
2637 __ Push(v0); | 2657 __ Push(v0); |
2638 VisitForStackValue(prop->obj()->AsSuperReference()->this_var()); | 2658 VisitForStackValue(prop->obj()->AsSuperPropertyReference()->this_var()); |
2639 VisitForAccumulatorValue( | 2659 VisitForAccumulatorValue( |
2640 prop->obj()->AsSuperReference()->home_object_var()); | 2660 prop->obj()->AsSuperPropertyReference()->home_object_var()); |
2641 // stack: value, this; v0: home_object | 2661 // stack: value, this; v0: home_object |
2642 Register scratch = a2; | 2662 Register scratch = a2; |
2643 Register scratch2 = a3; | 2663 Register scratch2 = a3; |
2644 __ mov(scratch, result_register()); // home_object | 2664 __ mov(scratch, result_register()); // home_object |
2645 __ ld(v0, MemOperand(sp, kPointerSize)); // value | 2665 __ ld(v0, MemOperand(sp, kPointerSize)); // value |
2646 __ ld(scratch2, MemOperand(sp, 0)); // this | 2666 __ ld(scratch2, MemOperand(sp, 0)); // this |
2647 __ sd(scratch2, MemOperand(sp, kPointerSize)); // this | 2667 __ sd(scratch2, MemOperand(sp, kPointerSize)); // this |
2648 __ sd(scratch, MemOperand(sp, 0)); // home_object | 2668 __ sd(scratch, MemOperand(sp, 0)); // home_object |
2649 // stack: this, home_object; v0: value | 2669 // stack: this, home_object; v0: value |
2650 EmitNamedSuperPropertyStore(prop); | 2670 EmitNamedSuperPropertyStore(prop); |
2651 break; | 2671 break; |
2652 } | 2672 } |
2653 case KEYED_SUPER_PROPERTY: { | 2673 case KEYED_SUPER_PROPERTY: { |
2654 __ Push(v0); | 2674 __ Push(v0); |
2655 VisitForStackValue(prop->obj()->AsSuperReference()->this_var()); | 2675 VisitForStackValue(prop->obj()->AsSuperPropertyReference()->this_var()); |
2656 VisitForStackValue(prop->obj()->AsSuperReference()->home_object_var()); | 2676 VisitForStackValue( |
| 2677 prop->obj()->AsSuperPropertyReference()->home_object_var()); |
2657 VisitForAccumulatorValue(prop->key()); | 2678 VisitForAccumulatorValue(prop->key()); |
2658 Register scratch = a2; | 2679 Register scratch = a2; |
2659 Register scratch2 = a3; | 2680 Register scratch2 = a3; |
2660 __ ld(scratch2, MemOperand(sp, 2 * kPointerSize)); // value | 2681 __ ld(scratch2, MemOperand(sp, 2 * kPointerSize)); // value |
2661 // stack: value, this, home_object; v0: key, a3: value | 2682 // stack: value, this, home_object; v0: key, a3: value |
2662 __ ld(scratch, MemOperand(sp, kPointerSize)); // this | 2683 __ ld(scratch, MemOperand(sp, kPointerSize)); // this |
2663 __ sd(scratch, MemOperand(sp, 2 * kPointerSize)); | 2684 __ sd(scratch, MemOperand(sp, 2 * kPointerSize)); |
2664 __ ld(scratch, MemOperand(sp, 0)); // home_object | 2685 __ ld(scratch, MemOperand(sp, 0)); // home_object |
2665 __ sd(scratch, MemOperand(sp, kPointerSize)); | 2686 __ sd(scratch, MemOperand(sp, kPointerSize)); |
2666 __ sd(v0, MemOperand(sp, 0)); | 2687 __ sd(v0, MemOperand(sp, 0)); |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2879 void FullCodeGenerator::VisitProperty(Property* expr) { | 2900 void FullCodeGenerator::VisitProperty(Property* expr) { |
2880 Comment cmnt(masm_, "[ Property"); | 2901 Comment cmnt(masm_, "[ Property"); |
2881 Expression* key = expr->key(); | 2902 Expression* key = expr->key(); |
2882 | 2903 |
2883 if (key->IsPropertyName()) { | 2904 if (key->IsPropertyName()) { |
2884 if (!expr->IsSuperAccess()) { | 2905 if (!expr->IsSuperAccess()) { |
2885 VisitForAccumulatorValue(expr->obj()); | 2906 VisitForAccumulatorValue(expr->obj()); |
2886 __ Move(LoadDescriptor::ReceiverRegister(), v0); | 2907 __ Move(LoadDescriptor::ReceiverRegister(), v0); |
2887 EmitNamedPropertyLoad(expr); | 2908 EmitNamedPropertyLoad(expr); |
2888 } else { | 2909 } else { |
2889 VisitForStackValue(expr->obj()->AsSuperReference()->this_var()); | 2910 VisitForStackValue(expr->obj()->AsSuperPropertyReference()->this_var()); |
2890 VisitForStackValue(expr->obj()->AsSuperReference()->home_object_var()); | 2911 VisitForStackValue( |
| 2912 expr->obj()->AsSuperPropertyReference()->home_object_var()); |
2891 EmitNamedSuperPropertyLoad(expr); | 2913 EmitNamedSuperPropertyLoad(expr); |
2892 } | 2914 } |
2893 } else { | 2915 } else { |
2894 if (!expr->IsSuperAccess()) { | 2916 if (!expr->IsSuperAccess()) { |
2895 VisitForStackValue(expr->obj()); | 2917 VisitForStackValue(expr->obj()); |
2896 VisitForAccumulatorValue(expr->key()); | 2918 VisitForAccumulatorValue(expr->key()); |
2897 __ Move(LoadDescriptor::NameRegister(), v0); | 2919 __ Move(LoadDescriptor::NameRegister(), v0); |
2898 __ pop(LoadDescriptor::ReceiverRegister()); | 2920 __ pop(LoadDescriptor::ReceiverRegister()); |
2899 EmitKeyedPropertyLoad(expr); | 2921 EmitKeyedPropertyLoad(expr); |
2900 } else { | 2922 } else { |
2901 VisitForStackValue(expr->obj()->AsSuperReference()->this_var()); | 2923 VisitForStackValue(expr->obj()->AsSuperPropertyReference()->this_var()); |
2902 VisitForStackValue(expr->obj()->AsSuperReference()->home_object_var()); | 2924 VisitForStackValue( |
| 2925 expr->obj()->AsSuperPropertyReference()->home_object_var()); |
2903 VisitForStackValue(expr->key()); | 2926 VisitForStackValue(expr->key()); |
2904 EmitKeyedSuperPropertyLoad(expr); | 2927 EmitKeyedSuperPropertyLoad(expr); |
2905 } | 2928 } |
2906 } | 2929 } |
2907 PrepareForBailoutForId(expr->LoadId(), TOS_REG); | 2930 PrepareForBailoutForId(expr->LoadId(), TOS_REG); |
2908 context()->Plug(v0); | 2931 context()->Plug(v0); |
2909 } | 2932 } |
2910 | 2933 |
2911 | 2934 |
2912 void FullCodeGenerator::CallIC(Handle<Code> code, | 2935 void FullCodeGenerator::CallIC(Handle<Code> code, |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2954 Expression* callee = expr->expression(); | 2977 Expression* callee = expr->expression(); |
2955 DCHECK(callee->IsProperty()); | 2978 DCHECK(callee->IsProperty()); |
2956 Property* prop = callee->AsProperty(); | 2979 Property* prop = callee->AsProperty(); |
2957 DCHECK(prop->IsSuperAccess()); | 2980 DCHECK(prop->IsSuperAccess()); |
2958 | 2981 |
2959 SetSourcePosition(prop->position()); | 2982 SetSourcePosition(prop->position()); |
2960 Literal* key = prop->key()->AsLiteral(); | 2983 Literal* key = prop->key()->AsLiteral(); |
2961 DCHECK(!key->value()->IsSmi()); | 2984 DCHECK(!key->value()->IsSmi()); |
2962 // Load the function from the receiver. | 2985 // Load the function from the receiver. |
2963 const Register scratch = a1; | 2986 const Register scratch = a1; |
2964 SuperReference* super_ref = prop->obj()->AsSuperReference(); | 2987 SuperPropertyReference* super_ref = prop->obj()->AsSuperPropertyReference(); |
2965 VisitForAccumulatorValue(super_ref->home_object_var()); | 2988 VisitForAccumulatorValue(super_ref->home_object_var()); |
2966 __ mov(scratch, v0); | 2989 __ mov(scratch, v0); |
2967 VisitForAccumulatorValue(super_ref->this_var()); | 2990 VisitForAccumulatorValue(super_ref->this_var()); |
2968 __ Push(scratch, v0, v0, scratch); | 2991 __ Push(scratch, v0, v0, scratch); |
2969 __ Push(key->value()); | 2992 __ Push(key->value()); |
2970 | 2993 |
2971 // Stack here: | 2994 // Stack here: |
2972 // - home_object | 2995 // - home_object |
2973 // - this (receiver) | 2996 // - this (receiver) |
2974 // - this (receiver) <-- LoadFromSuper will pop here and below. | 2997 // - this (receiver) <-- LoadFromSuper will pop here and below. |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3012 | 3035 |
3013 void FullCodeGenerator::EmitKeyedSuperCallWithLoadIC(Call* expr) { | 3036 void FullCodeGenerator::EmitKeyedSuperCallWithLoadIC(Call* expr) { |
3014 Expression* callee = expr->expression(); | 3037 Expression* callee = expr->expression(); |
3015 DCHECK(callee->IsProperty()); | 3038 DCHECK(callee->IsProperty()); |
3016 Property* prop = callee->AsProperty(); | 3039 Property* prop = callee->AsProperty(); |
3017 DCHECK(prop->IsSuperAccess()); | 3040 DCHECK(prop->IsSuperAccess()); |
3018 | 3041 |
3019 SetSourcePosition(prop->position()); | 3042 SetSourcePosition(prop->position()); |
3020 // Load the function from the receiver. | 3043 // Load the function from the receiver. |
3021 const Register scratch = a1; | 3044 const Register scratch = a1; |
3022 SuperReference* super_ref = prop->obj()->AsSuperReference(); | 3045 SuperPropertyReference* super_ref = prop->obj()->AsSuperPropertyReference(); |
3023 VisitForAccumulatorValue(super_ref->home_object_var()); | 3046 VisitForAccumulatorValue(super_ref->home_object_var()); |
3024 __ Move(scratch, v0); | 3047 __ Move(scratch, v0); |
3025 VisitForAccumulatorValue(super_ref->this_var()); | 3048 VisitForAccumulatorValue(super_ref->this_var()); |
3026 __ Push(scratch, v0, v0, scratch); | 3049 __ Push(scratch, v0, v0, scratch); |
3027 VisitForStackValue(prop->key()); | 3050 VisitForStackValue(prop->key()); |
3028 | 3051 |
3029 // Stack here: | 3052 // Stack here: |
3030 // - home_object | 3053 // - home_object |
3031 // - this (receiver) | 3054 // - this (receiver) |
3032 // - this (receiver) <-- LoadKeyedFromSuper will pop here and below. | 3055 // - this (receiver) <-- LoadKeyedFromSuper will pop here and below. |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3091 // a1: the start position of the scope the calls resides in. | 3114 // a1: the start position of the scope the calls resides in. |
3092 __ li(a1, Operand(Smi::FromInt(scope()->start_position()))); | 3115 __ li(a1, Operand(Smi::FromInt(scope()->start_position()))); |
3093 | 3116 |
3094 // Do the runtime call. | 3117 // Do the runtime call. |
3095 __ Push(a7); | 3118 __ Push(a7); |
3096 __ Push(a6, a5, a4, a1); | 3119 __ Push(a6, a5, a4, a1); |
3097 __ CallRuntime(Runtime::kResolvePossiblyDirectEval, 6); | 3120 __ CallRuntime(Runtime::kResolvePossiblyDirectEval, 6); |
3098 } | 3121 } |
3099 | 3122 |
3100 | 3123 |
3101 void FullCodeGenerator::EmitLoadSuperConstructor() { | |
3102 __ ld(a0, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); | |
3103 __ Push(a0); | |
3104 __ CallRuntime(Runtime::kGetPrototype, 1); | |
3105 } | |
3106 | |
3107 | |
3108 void FullCodeGenerator::EmitInitializeThisAfterSuper( | 3124 void FullCodeGenerator::EmitInitializeThisAfterSuper( |
3109 SuperReference* super_ref, FeedbackVectorICSlot slot) { | 3125 SuperCallReference* super_ref, FeedbackVectorICSlot slot) { |
3110 Variable* this_var = super_ref->this_var()->var(); | 3126 Variable* this_var = super_ref->this_var()->var(); |
3111 GetVar(a1, this_var); | 3127 GetVar(a1, this_var); |
3112 __ LoadRoot(at, Heap::kTheHoleValueRootIndex); | 3128 __ LoadRoot(at, Heap::kTheHoleValueRootIndex); |
3113 Label uninitialized_this; | 3129 Label uninitialized_this; |
3114 __ Branch(&uninitialized_this, eq, a1, Operand(at)); | 3130 __ Branch(&uninitialized_this, eq, a1, Operand(at)); |
3115 __ li(a0, Operand(this_var->name())); | 3131 __ li(a0, Operand(this_var->name())); |
3116 __ Push(a0); | 3132 __ Push(a0); |
3117 __ CallRuntime(Runtime::kThrowReferenceError, 1); | 3133 __ CallRuntime(Runtime::kThrowReferenceError, 1); |
3118 __ bind(&uninitialized_this); | 3134 __ bind(&uninitialized_this); |
3119 | 3135 |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3257 | 3273 |
3258 void FullCodeGenerator::VisitCallNew(CallNew* expr) { | 3274 void FullCodeGenerator::VisitCallNew(CallNew* expr) { |
3259 Comment cmnt(masm_, "[ CallNew"); | 3275 Comment cmnt(masm_, "[ CallNew"); |
3260 // According to ECMA-262, section 11.2.2, page 44, the function | 3276 // According to ECMA-262, section 11.2.2, page 44, the function |
3261 // expression in new calls must be evaluated before the | 3277 // expression in new calls must be evaluated before the |
3262 // arguments. | 3278 // arguments. |
3263 | 3279 |
3264 // Push constructor on the stack. If it's not a function it's used as | 3280 // Push constructor on the stack. If it's not a function it's used as |
3265 // receiver for CALL_NON_FUNCTION, otherwise the value on the stack is | 3281 // receiver for CALL_NON_FUNCTION, otherwise the value on the stack is |
3266 // ignored. | 3282 // ignored. |
3267 DCHECK(!expr->expression()->IsSuperReference()); | 3283 DCHECK(!expr->expression()->IsSuperPropertyReference()); |
3268 VisitForStackValue(expr->expression()); | 3284 VisitForStackValue(expr->expression()); |
3269 | 3285 |
3270 // Push the arguments ("left-to-right") on the stack. | 3286 // Push the arguments ("left-to-right") on the stack. |
3271 ZoneList<Expression*>* args = expr->arguments(); | 3287 ZoneList<Expression*>* args = expr->arguments(); |
3272 int arg_count = args->length(); | 3288 int arg_count = args->length(); |
3273 for (int i = 0; i < arg_count; i++) { | 3289 for (int i = 0; i < arg_count; i++) { |
3274 VisitForStackValue(args->at(i)); | 3290 VisitForStackValue(args->at(i)); |
3275 } | 3291 } |
3276 | 3292 |
3277 // Call the construct call builtin that handles allocation and | 3293 // Call the construct call builtin that handles allocation and |
(...skipping 15 matching lines...) Expand all Loading... |
3293 __ li(a3, Operand(SmiFromSlot(expr->CallNewFeedbackSlot()))); | 3309 __ li(a3, Operand(SmiFromSlot(expr->CallNewFeedbackSlot()))); |
3294 | 3310 |
3295 CallConstructStub stub(isolate(), RECORD_CONSTRUCTOR_TARGET); | 3311 CallConstructStub stub(isolate(), RECORD_CONSTRUCTOR_TARGET); |
3296 __ Call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); | 3312 __ Call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); |
3297 PrepareForBailoutForId(expr->ReturnId(), TOS_REG); | 3313 PrepareForBailoutForId(expr->ReturnId(), TOS_REG); |
3298 context()->Plug(v0); | 3314 context()->Plug(v0); |
3299 } | 3315 } |
3300 | 3316 |
3301 | 3317 |
3302 void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) { | 3318 void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) { |
3303 Variable* new_target_var = scope()->DeclarationScope()->new_target_var(); | 3319 SuperCallReference* super_call_ref = |
3304 GetVar(result_register(), new_target_var); | 3320 expr->expression()->AsSuperCallReference(); |
3305 __ Push(result_register()); | 3321 DCHECK_NOT_NULL(super_call_ref); |
3306 | 3322 |
3307 EmitLoadSuperConstructor(); | 3323 VariableProxy* new_target_proxy = super_call_ref->new_target_var(); |
| 3324 VisitForStackValue(new_target_proxy); |
| 3325 |
| 3326 EmitLoadSuperConstructor(super_call_ref); |
3308 __ push(result_register()); | 3327 __ push(result_register()); |
3309 | 3328 |
3310 // Push the arguments ("left-to-right") on the stack. | 3329 // Push the arguments ("left-to-right") on the stack. |
3311 ZoneList<Expression*>* args = expr->arguments(); | 3330 ZoneList<Expression*>* args = expr->arguments(); |
3312 int arg_count = args->length(); | 3331 int arg_count = args->length(); |
3313 for (int i = 0; i < arg_count; i++) { | 3332 for (int i = 0; i < arg_count; i++) { |
3314 VisitForStackValue(args->at(i)); | 3333 VisitForStackValue(args->at(i)); |
3315 } | 3334 } |
3316 | 3335 |
3317 // Call the construct call builtin that handles allocation and | 3336 // Call the construct call builtin that handles allocation and |
(...skipping 17 matching lines...) Expand all Loading... |
3335 __ li(a2, FeedbackVector()); | 3354 __ li(a2, FeedbackVector()); |
3336 __ li(a3, Operand(SmiFromSlot(expr->CallFeedbackSlot()))); | 3355 __ li(a3, Operand(SmiFromSlot(expr->CallFeedbackSlot()))); |
3337 | 3356 |
3338 CallConstructStub stub(isolate(), SUPER_CALL_RECORD_TARGET); | 3357 CallConstructStub stub(isolate(), SUPER_CALL_RECORD_TARGET); |
3339 __ Call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); | 3358 __ Call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); |
3340 | 3359 |
3341 __ Drop(1); | 3360 __ Drop(1); |
3342 | 3361 |
3343 RecordJSReturnSite(expr); | 3362 RecordJSReturnSite(expr); |
3344 | 3363 |
3345 EmitInitializeThisAfterSuper(expr->expression()->AsSuperReference(), | 3364 EmitInitializeThisAfterSuper(super_call_ref, expr->CallFeedbackICSlot()); |
3346 expr->CallFeedbackICSlot()); | |
3347 context()->Plug(v0); | 3365 context()->Plug(v0); |
3348 } | 3366 } |
3349 | 3367 |
3350 | 3368 |
3351 void FullCodeGenerator::EmitIsSmi(CallRuntime* expr) { | 3369 void FullCodeGenerator::EmitIsSmi(CallRuntime* expr) { |
3352 ZoneList<Expression*>* args = expr->arguments(); | 3370 ZoneList<Expression*>* args = expr->arguments(); |
3353 DCHECK(args->length() == 1); | 3371 DCHECK(args->length() == 1); |
3354 | 3372 |
3355 VisitForAccumulatorValue(args->at(0)); | 3373 VisitForAccumulatorValue(args->at(0)); |
3356 | 3374 |
(...skipping 867 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4224 __ bind(&runtime); | 4242 __ bind(&runtime); |
4225 __ push(v0); | 4243 __ push(v0); |
4226 __ CallRuntime(Runtime::kCall, args->length()); | 4244 __ CallRuntime(Runtime::kCall, args->length()); |
4227 __ bind(&done); | 4245 __ bind(&done); |
4228 | 4246 |
4229 context()->Plug(v0); | 4247 context()->Plug(v0); |
4230 } | 4248 } |
4231 | 4249 |
4232 | 4250 |
4233 void FullCodeGenerator::EmitDefaultConstructorCallSuper(CallRuntime* expr) { | 4251 void FullCodeGenerator::EmitDefaultConstructorCallSuper(CallRuntime* expr) { |
4234 Variable* new_target_var = scope()->DeclarationScope()->new_target_var(); | 4252 ZoneList<Expression*>* args = expr->arguments(); |
4235 GetVar(result_register(), new_target_var); | 4253 DCHECK(args->length() == 2); |
4236 __ Push(result_register()); | |
4237 | 4254 |
4238 EmitLoadSuperConstructor(); | 4255 // new.target |
| 4256 VisitForStackValue(args->at(0)); |
| 4257 |
| 4258 // .this_function |
| 4259 VisitForStackValue(args->at(1)); |
| 4260 __ CallRuntime(Runtime::kGetPrototype, 1); |
4239 __ Push(result_register()); | 4261 __ Push(result_register()); |
4240 | 4262 |
4241 // Check if the calling frame is an arguments adaptor frame. | 4263 // Check if the calling frame is an arguments adaptor frame. |
4242 Label adaptor_frame, args_set_up, runtime; | 4264 Label adaptor_frame, args_set_up, runtime; |
4243 __ ld(a2, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); | 4265 __ ld(a2, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); |
4244 __ ld(a3, MemOperand(a2, StandardFrameConstants::kContextOffset)); | 4266 __ ld(a3, MemOperand(a2, StandardFrameConstants::kContextOffset)); |
4245 __ Branch(&adaptor_frame, eq, a3, | 4267 __ Branch(&adaptor_frame, eq, a3, |
4246 Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); | 4268 Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); |
4247 // default constructor has no arguments, so no adaptor frame means no args. | 4269 // default constructor has no arguments, so no adaptor frame means no args. |
4248 __ mov(a0, zero_reg); | 4270 __ mov(a0, zero_reg); |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4630 ExternalReference::debug_is_active_address(isolate()); | 4652 ExternalReference::debug_is_active_address(isolate()); |
4631 __ li(at, Operand(debug_is_active)); | 4653 __ li(at, Operand(debug_is_active)); |
4632 __ lbu(v0, MemOperand(at)); | 4654 __ lbu(v0, MemOperand(at)); |
4633 __ SmiTag(v0); | 4655 __ SmiTag(v0); |
4634 context()->Plug(v0); | 4656 context()->Plug(v0); |
4635 } | 4657 } |
4636 | 4658 |
4637 | 4659 |
4638 void FullCodeGenerator::EmitCallSuperWithSpread(CallRuntime* expr) { | 4660 void FullCodeGenerator::EmitCallSuperWithSpread(CallRuntime* expr) { |
4639 // Assert: expr === CallRuntime("ReflectConstruct") | 4661 // Assert: expr === CallRuntime("ReflectConstruct") |
| 4662 DCHECK_EQ(1, expr->arguments()->length()); |
4640 CallRuntime* call = expr->arguments()->at(0)->AsCallRuntime(); | 4663 CallRuntime* call = expr->arguments()->at(0)->AsCallRuntime(); |
| 4664 |
4641 ZoneList<Expression*>* args = call->arguments(); | 4665 ZoneList<Expression*>* args = call->arguments(); |
4642 DCHECK_EQ(3, args->length()); | 4666 DCHECK_EQ(3, args->length()); |
4643 | 4667 |
4644 SuperReference* super_reference = args->at(0)->AsSuperReference(); | 4668 SuperCallReference* super_call_ref = args->at(0)->AsSuperCallReference(); |
| 4669 DCHECK_NOT_NULL(super_call_ref); |
4645 | 4670 |
4646 // Load ReflectConstruct function | 4671 // Load ReflectConstruct function |
4647 EmitLoadJSRuntimeFunction(call); | 4672 EmitLoadJSRuntimeFunction(call); |
4648 | 4673 |
4649 // Push the target function under the receiver. | 4674 // Push the target function under the receiver. |
4650 __ ld(at, MemOperand(sp, 0)); | 4675 __ ld(at, MemOperand(sp, 0)); |
4651 __ push(at); | 4676 __ push(at); |
4652 __ sd(v0, MemOperand(sp, kPointerSize)); | 4677 __ sd(v0, MemOperand(sp, kPointerSize)); |
4653 | 4678 |
4654 // Push super | 4679 // Push super constructor |
4655 EmitLoadSuperConstructor(); | 4680 EmitLoadSuperConstructor(super_call_ref); |
4656 __ Push(result_register()); | 4681 __ Push(result_register()); |
4657 | 4682 |
4658 // Push arguments array | 4683 // Push arguments array |
4659 VisitForStackValue(args->at(1)); | 4684 VisitForStackValue(args->at(1)); |
4660 | 4685 |
4661 // Push NewTarget | 4686 // Push NewTarget |
4662 DCHECK(args->at(2)->IsVariableProxy()); | 4687 DCHECK(args->at(2)->IsVariableProxy()); |
4663 VisitForStackValue(args->at(2)); | 4688 VisitForStackValue(args->at(2)); |
4664 | 4689 |
4665 EmitCallJSRuntimeFunction(call); | 4690 EmitCallJSRuntimeFunction(call); |
4666 | 4691 |
4667 // Restore context register. | 4692 // Restore context register. |
4668 __ ld(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 4693 __ ld(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
4669 context()->DropAndPlug(1, v0); | 4694 context()->DropAndPlug(1, v0); |
4670 | 4695 |
4671 // TODO(mvstanton): with FLAG_vector_stores this needs a slot id. | 4696 // TODO(mvstanton): with FLAG_vector_stores this needs a slot id. |
4672 EmitInitializeThisAfterSuper(super_reference); | 4697 EmitInitializeThisAfterSuper(super_call_ref); |
4673 } | 4698 } |
4674 | 4699 |
4675 | 4700 |
4676 void FullCodeGenerator::EmitLoadJSRuntimeFunction(CallRuntime* expr) { | 4701 void FullCodeGenerator::EmitLoadJSRuntimeFunction(CallRuntime* expr) { |
4677 // Push the builtins object as the receiver. | 4702 // Push the builtins object as the receiver. |
4678 Register receiver = LoadDescriptor::ReceiverRegister(); | 4703 Register receiver = LoadDescriptor::ReceiverRegister(); |
4679 __ ld(receiver, GlobalObjectOperand()); | 4704 __ ld(receiver, GlobalObjectOperand()); |
4680 __ ld(receiver, FieldMemOperand(receiver, GlobalObject::kBuiltinsOffset)); | 4705 __ ld(receiver, FieldMemOperand(receiver, GlobalObject::kBuiltinsOffset)); |
4681 __ push(receiver); | 4706 __ push(receiver); |
4682 | 4707 |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4886 switch (assign_type) { | 4911 switch (assign_type) { |
4887 case NAMED_PROPERTY: { | 4912 case NAMED_PROPERTY: { |
4888 // Put the object both on the stack and in the register. | 4913 // Put the object both on the stack and in the register. |
4889 VisitForStackValue(prop->obj()); | 4914 VisitForStackValue(prop->obj()); |
4890 __ ld(LoadDescriptor::ReceiverRegister(), MemOperand(sp, 0)); | 4915 __ ld(LoadDescriptor::ReceiverRegister(), MemOperand(sp, 0)); |
4891 EmitNamedPropertyLoad(prop); | 4916 EmitNamedPropertyLoad(prop); |
4892 break; | 4917 break; |
4893 } | 4918 } |
4894 | 4919 |
4895 case NAMED_SUPER_PROPERTY: { | 4920 case NAMED_SUPER_PROPERTY: { |
4896 VisitForStackValue(prop->obj()->AsSuperReference()->this_var()); | 4921 VisitForStackValue(prop->obj()->AsSuperPropertyReference()->this_var()); |
4897 VisitForAccumulatorValue( | 4922 VisitForAccumulatorValue( |
4898 prop->obj()->AsSuperReference()->home_object_var()); | 4923 prop->obj()->AsSuperPropertyReference()->home_object_var()); |
4899 __ Push(result_register()); | 4924 __ Push(result_register()); |
4900 const Register scratch = a1; | 4925 const Register scratch = a1; |
4901 __ ld(scratch, MemOperand(sp, kPointerSize)); | 4926 __ ld(scratch, MemOperand(sp, kPointerSize)); |
4902 __ Push(scratch, result_register()); | 4927 __ Push(scratch, result_register()); |
4903 EmitNamedSuperPropertyLoad(prop); | 4928 EmitNamedSuperPropertyLoad(prop); |
4904 break; | 4929 break; |
4905 } | 4930 } |
4906 | 4931 |
4907 case KEYED_SUPER_PROPERTY: { | 4932 case KEYED_SUPER_PROPERTY: { |
4908 VisitForStackValue(prop->obj()->AsSuperReference()->this_var()); | 4933 VisitForStackValue(prop->obj()->AsSuperPropertyReference()->this_var()); |
4909 VisitForAccumulatorValue( | 4934 VisitForAccumulatorValue( |
4910 prop->obj()->AsSuperReference()->home_object_var()); | 4935 prop->obj()->AsSuperPropertyReference()->home_object_var()); |
4911 const Register scratch = a1; | 4936 const Register scratch = a1; |
4912 const Register scratch1 = a4; | 4937 const Register scratch1 = a4; |
4913 __ Move(scratch, result_register()); | 4938 __ Move(scratch, result_register()); |
4914 VisitForAccumulatorValue(prop->key()); | 4939 VisitForAccumulatorValue(prop->key()); |
4915 __ Push(scratch, result_register()); | 4940 __ Push(scratch, result_register()); |
4916 __ ld(scratch1, MemOperand(sp, 2 * kPointerSize)); | 4941 __ ld(scratch1, MemOperand(sp, 2 * kPointerSize)); |
4917 __ Push(scratch1, scratch, result_register()); | 4942 __ Push(scratch1, scratch, result_register()); |
4918 EmitKeyedSuperPropertyLoad(prop); | 4943 EmitKeyedSuperPropertyLoad(prop); |
4919 break; | 4944 break; |
4920 } | 4945 } |
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5525 Assembler::target_address_at(pc_immediate_load_address)) == | 5550 Assembler::target_address_at(pc_immediate_load_address)) == |
5526 reinterpret_cast<uint64_t>( | 5551 reinterpret_cast<uint64_t>( |
5527 isolate->builtins()->OsrAfterStackCheck()->entry())); | 5552 isolate->builtins()->OsrAfterStackCheck()->entry())); |
5528 return OSR_AFTER_STACK_CHECK; | 5553 return OSR_AFTER_STACK_CHECK; |
5529 } | 5554 } |
5530 | 5555 |
5531 | 5556 |
5532 } } // namespace v8::internal | 5557 } } // namespace v8::internal |
5533 | 5558 |
5534 #endif // V8_TARGET_ARCH_MIPS64 | 5559 #endif // V8_TARGET_ARCH_MIPS64 |
OLD | NEW |