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_MIPS | 7 #if V8_TARGET_ARCH_MIPS |
8 | 8 |
9 // Note on Mips implementation: | 9 // Note on Mips implementation: |
10 // | 10 // |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 } else if (FLAG_debug_code) { | 244 } else if (FLAG_debug_code) { |
245 Label done; | 245 Label done; |
246 __ JumpIfInNewSpace(cp, a0, &done); | 246 __ JumpIfInNewSpace(cp, a0, &done); |
247 __ Abort(kExpectedNewSpaceObject); | 247 __ Abort(kExpectedNewSpaceObject); |
248 __ bind(&done); | 248 __ bind(&done); |
249 } | 249 } |
250 } | 250 } |
251 } | 251 } |
252 } | 252 } |
253 | 253 |
| 254 // Possibly set up a local binding to the this function which is used in |
| 255 // derived constructors with super calls. |
| 256 Variable* this_function_var = scope()->this_function_var(); |
| 257 if (this_function_var != nullptr) { |
| 258 Comment cmnt(masm_, "[ This function"); |
| 259 SetVar(this_function_var, a1, a2, a3); |
| 260 } |
| 261 |
| 262 Variable* new_target_var = scope()->new_target_var(); |
| 263 if (new_target_var != nullptr) { |
| 264 Comment cmnt(masm_, "[ new.target"); |
| 265 // new.target is parameter -2. |
| 266 int offset = 2 * kPointerSize + |
| 267 (info_->scope()->num_parameters() + 1) * kPointerSize; |
| 268 __ lw(v0, MemOperand(fp, offset)); |
| 269 SetVar(new_target_var, v0, a2, a3); |
| 270 } |
| 271 |
254 Variable* home_object_var = scope()->home_object_var(); | 272 Variable* home_object_var = scope()->home_object_var(); |
255 if (home_object_var != nullptr) { | 273 if (home_object_var != nullptr) { |
256 __ Push(a1); | 274 __ Push(a1); |
257 } | 275 } |
258 | 276 |
259 ArgumentsAccessStub::HasNewTarget has_new_target = | 277 ArgumentsAccessStub::HasNewTarget has_new_target = |
260 IsSubclassConstructor(info->function()->kind()) | 278 IsSubclassConstructor(info->function()->kind()) |
261 ? ArgumentsAccessStub::HAS_NEW_TARGET | 279 ? ArgumentsAccessStub::HAS_NEW_TARGET |
262 : ArgumentsAccessStub::NO_NEW_TARGET; | 280 : ArgumentsAccessStub::NO_NEW_TARGET; |
263 | 281 |
(...skipping 1716 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 __ lw(LoadDescriptor::ReceiverRegister(), MemOperand(sp, 0)); | 2002 __ lw(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 __ lw(scratch, MemOperand(sp, kPointerSize)); | 2015 __ lw(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 = t0; | 2029 const Register scratch1 = t0; |
2010 __ lw(scratch1, MemOperand(sp, 2 * kPointerSize)); | 2030 __ lw(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 __ lw(v0, MemOperand(sp, kPointerSize)); // value | 2665 __ lw(v0, MemOperand(sp, kPointerSize)); // value |
2646 __ lw(scratch2, MemOperand(sp, 0)); // this | 2666 __ lw(scratch2, MemOperand(sp, 0)); // this |
2647 __ sw(scratch2, MemOperand(sp, kPointerSize)); // this | 2667 __ sw(scratch2, MemOperand(sp, kPointerSize)); // this |
2648 __ sw(scratch, MemOperand(sp, 0)); // home_object | 2668 __ sw(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 __ lw(scratch2, MemOperand(sp, 2 * kPointerSize)); // value | 2681 __ lw(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 __ lw(scratch, MemOperand(sp, kPointerSize)); // this | 2683 __ lw(scratch, MemOperand(sp, kPointerSize)); // this |
2663 __ sw(scratch, MemOperand(sp, 2 * kPointerSize)); | 2684 __ sw(scratch, MemOperand(sp, 2 * kPointerSize)); |
2664 __ lw(scratch, MemOperand(sp, 0)); // home_object | 2685 __ lw(scratch, MemOperand(sp, 0)); // home_object |
2665 __ sw(scratch, MemOperand(sp, kPointerSize)); | 2686 __ sw(scratch, MemOperand(sp, kPointerSize)); |
2666 __ sw(v0, MemOperand(sp, 0)); | 2687 __ sw(v0, MemOperand(sp, 0)); |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2875 void FullCodeGenerator::VisitProperty(Property* expr) { | 2896 void FullCodeGenerator::VisitProperty(Property* expr) { |
2876 Comment cmnt(masm_, "[ Property"); | 2897 Comment cmnt(masm_, "[ Property"); |
2877 Expression* key = expr->key(); | 2898 Expression* key = expr->key(); |
2878 | 2899 |
2879 if (key->IsPropertyName()) { | 2900 if (key->IsPropertyName()) { |
2880 if (!expr->IsSuperAccess()) { | 2901 if (!expr->IsSuperAccess()) { |
2881 VisitForAccumulatorValue(expr->obj()); | 2902 VisitForAccumulatorValue(expr->obj()); |
2882 __ Move(LoadDescriptor::ReceiverRegister(), v0); | 2903 __ Move(LoadDescriptor::ReceiverRegister(), v0); |
2883 EmitNamedPropertyLoad(expr); | 2904 EmitNamedPropertyLoad(expr); |
2884 } else { | 2905 } else { |
2885 VisitForStackValue(expr->obj()->AsSuperReference()->this_var()); | 2906 VisitForStackValue(expr->obj()->AsSuperPropertyReference()->this_var()); |
2886 VisitForStackValue(expr->obj()->AsSuperReference()->home_object_var()); | 2907 VisitForStackValue( |
| 2908 expr->obj()->AsSuperPropertyReference()->home_object_var()); |
2887 EmitNamedSuperPropertyLoad(expr); | 2909 EmitNamedSuperPropertyLoad(expr); |
2888 } | 2910 } |
2889 } else { | 2911 } else { |
2890 if (!expr->IsSuperAccess()) { | 2912 if (!expr->IsSuperAccess()) { |
2891 VisitForStackValue(expr->obj()); | 2913 VisitForStackValue(expr->obj()); |
2892 VisitForAccumulatorValue(expr->key()); | 2914 VisitForAccumulatorValue(expr->key()); |
2893 __ Move(LoadDescriptor::NameRegister(), v0); | 2915 __ Move(LoadDescriptor::NameRegister(), v0); |
2894 __ pop(LoadDescriptor::ReceiverRegister()); | 2916 __ pop(LoadDescriptor::ReceiverRegister()); |
2895 EmitKeyedPropertyLoad(expr); | 2917 EmitKeyedPropertyLoad(expr); |
2896 } else { | 2918 } else { |
2897 VisitForStackValue(expr->obj()->AsSuperReference()->this_var()); | 2919 VisitForStackValue(expr->obj()->AsSuperPropertyReference()->this_var()); |
2898 VisitForStackValue(expr->obj()->AsSuperReference()->home_object_var()); | 2920 VisitForStackValue( |
| 2921 expr->obj()->AsSuperPropertyReference()->home_object_var()); |
2899 VisitForStackValue(expr->key()); | 2922 VisitForStackValue(expr->key()); |
2900 EmitKeyedSuperPropertyLoad(expr); | 2923 EmitKeyedSuperPropertyLoad(expr); |
2901 } | 2924 } |
2902 } | 2925 } |
2903 PrepareForBailoutForId(expr->LoadId(), TOS_REG); | 2926 PrepareForBailoutForId(expr->LoadId(), TOS_REG); |
2904 context()->Plug(v0); | 2927 context()->Plug(v0); |
2905 } | 2928 } |
2906 | 2929 |
2907 | 2930 |
2908 void FullCodeGenerator::CallIC(Handle<Code> code, | 2931 void FullCodeGenerator::CallIC(Handle<Code> code, |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2950 Expression* callee = expr->expression(); | 2973 Expression* callee = expr->expression(); |
2951 DCHECK(callee->IsProperty()); | 2974 DCHECK(callee->IsProperty()); |
2952 Property* prop = callee->AsProperty(); | 2975 Property* prop = callee->AsProperty(); |
2953 DCHECK(prop->IsSuperAccess()); | 2976 DCHECK(prop->IsSuperAccess()); |
2954 | 2977 |
2955 SetSourcePosition(prop->position()); | 2978 SetSourcePosition(prop->position()); |
2956 Literal* key = prop->key()->AsLiteral(); | 2979 Literal* key = prop->key()->AsLiteral(); |
2957 DCHECK(!key->value()->IsSmi()); | 2980 DCHECK(!key->value()->IsSmi()); |
2958 // Load the function from the receiver. | 2981 // Load the function from the receiver. |
2959 const Register scratch = a1; | 2982 const Register scratch = a1; |
2960 SuperReference* super_ref = prop->obj()->AsSuperReference(); | 2983 SuperPropertyReference* super_ref = prop->obj()->AsSuperPropertyReference(); |
2961 VisitForAccumulatorValue(super_ref->home_object_var()); | 2984 VisitForAccumulatorValue(super_ref->home_object_var()); |
2962 __ mov(scratch, v0); | 2985 __ mov(scratch, v0); |
2963 VisitForAccumulatorValue(super_ref->this_var()); | 2986 VisitForAccumulatorValue(super_ref->this_var()); |
2964 __ Push(scratch, v0, v0, scratch); | 2987 __ Push(scratch, v0, v0, scratch); |
2965 __ Push(key->value()); | 2988 __ Push(key->value()); |
2966 | 2989 |
2967 // Stack here: | 2990 // Stack here: |
2968 // - home_object | 2991 // - home_object |
2969 // - this (receiver) | 2992 // - this (receiver) |
2970 // - this (receiver) <-- LoadFromSuper will pop here and below. | 2993 // - this (receiver) <-- LoadFromSuper will pop here and below. |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3008 | 3031 |
3009 void FullCodeGenerator::EmitKeyedSuperCallWithLoadIC(Call* expr) { | 3032 void FullCodeGenerator::EmitKeyedSuperCallWithLoadIC(Call* expr) { |
3010 Expression* callee = expr->expression(); | 3033 Expression* callee = expr->expression(); |
3011 DCHECK(callee->IsProperty()); | 3034 DCHECK(callee->IsProperty()); |
3012 Property* prop = callee->AsProperty(); | 3035 Property* prop = callee->AsProperty(); |
3013 DCHECK(prop->IsSuperAccess()); | 3036 DCHECK(prop->IsSuperAccess()); |
3014 | 3037 |
3015 SetSourcePosition(prop->position()); | 3038 SetSourcePosition(prop->position()); |
3016 // Load the function from the receiver. | 3039 // Load the function from the receiver. |
3017 const Register scratch = a1; | 3040 const Register scratch = a1; |
3018 SuperReference* super_ref = prop->obj()->AsSuperReference(); | 3041 SuperPropertyReference* super_ref = prop->obj()->AsSuperPropertyReference(); |
3019 VisitForAccumulatorValue(super_ref->home_object_var()); | 3042 VisitForAccumulatorValue(super_ref->home_object_var()); |
3020 __ Move(scratch, v0); | 3043 __ Move(scratch, v0); |
3021 VisitForAccumulatorValue(super_ref->this_var()); | 3044 VisitForAccumulatorValue(super_ref->this_var()); |
3022 __ Push(scratch, v0, v0, scratch); | 3045 __ Push(scratch, v0, v0, scratch); |
3023 VisitForStackValue(prop->key()); | 3046 VisitForStackValue(prop->key()); |
3024 | 3047 |
3025 // Stack here: | 3048 // Stack here: |
3026 // - home_object | 3049 // - home_object |
3027 // - this (receiver) | 3050 // - this (receiver) |
3028 // - this (receiver) <-- LoadKeyedFromSuper will pop here and below. | 3051 // - this (receiver) <-- LoadKeyedFromSuper will pop here and below. |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3088 // a1: the start position of the scope the calls resides in. | 3111 // a1: the start position of the scope the calls resides in. |
3089 __ li(a1, Operand(Smi::FromInt(scope()->start_position()))); | 3112 __ li(a1, Operand(Smi::FromInt(scope()->start_position()))); |
3090 | 3113 |
3091 // Do the runtime call. | 3114 // Do the runtime call. |
3092 __ Push(t3); | 3115 __ Push(t3); |
3093 __ Push(t2, t1, t0, a1); | 3116 __ Push(t2, t1, t0, a1); |
3094 __ CallRuntime(Runtime::kResolvePossiblyDirectEval, 6); | 3117 __ CallRuntime(Runtime::kResolvePossiblyDirectEval, 6); |
3095 } | 3118 } |
3096 | 3119 |
3097 | 3120 |
3098 void FullCodeGenerator::EmitLoadSuperConstructor() { | |
3099 __ lw(a0, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); | |
3100 __ Push(a0); | |
3101 __ CallRuntime(Runtime::kGetPrototype, 1); | |
3102 } | |
3103 | |
3104 | |
3105 void FullCodeGenerator::EmitInitializeThisAfterSuper( | 3121 void FullCodeGenerator::EmitInitializeThisAfterSuper( |
3106 SuperReference* super_ref, FeedbackVectorICSlot slot) { | 3122 SuperCallReference* super_ref, FeedbackVectorICSlot slot) { |
3107 Variable* this_var = super_ref->this_var()->var(); | 3123 Variable* this_var = super_ref->this_var()->var(); |
3108 GetVar(a1, this_var); | 3124 GetVar(a1, this_var); |
3109 __ LoadRoot(at, Heap::kTheHoleValueRootIndex); | 3125 __ LoadRoot(at, Heap::kTheHoleValueRootIndex); |
3110 Label uninitialized_this; | 3126 Label uninitialized_this; |
3111 __ Branch(&uninitialized_this, eq, a1, Operand(at)); | 3127 __ Branch(&uninitialized_this, eq, a1, Operand(at)); |
3112 __ li(a0, Operand(this_var->name())); | 3128 __ li(a0, Operand(this_var->name())); |
3113 __ Push(a0); | 3129 __ Push(a0); |
3114 __ CallRuntime(Runtime::kThrowReferenceError, 1); | 3130 __ CallRuntime(Runtime::kThrowReferenceError, 1); |
3115 __ bind(&uninitialized_this); | 3131 __ bind(&uninitialized_this); |
3116 | 3132 |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3254 | 3270 |
3255 void FullCodeGenerator::VisitCallNew(CallNew* expr) { | 3271 void FullCodeGenerator::VisitCallNew(CallNew* expr) { |
3256 Comment cmnt(masm_, "[ CallNew"); | 3272 Comment cmnt(masm_, "[ CallNew"); |
3257 // According to ECMA-262, section 11.2.2, page 44, the function | 3273 // According to ECMA-262, section 11.2.2, page 44, the function |
3258 // expression in new calls must be evaluated before the | 3274 // expression in new calls must be evaluated before the |
3259 // arguments. | 3275 // arguments. |
3260 | 3276 |
3261 // Push constructor on the stack. If it's not a function it's used as | 3277 // Push constructor on the stack. If it's not a function it's used as |
3262 // receiver for CALL_NON_FUNCTION, otherwise the value on the stack is | 3278 // receiver for CALL_NON_FUNCTION, otherwise the value on the stack is |
3263 // ignored. | 3279 // ignored. |
3264 DCHECK(!expr->expression()->IsSuperReference()); | 3280 DCHECK(!expr->expression()->IsSuperPropertyReference()); |
3265 VisitForStackValue(expr->expression()); | 3281 VisitForStackValue(expr->expression()); |
3266 | 3282 |
3267 // Push the arguments ("left-to-right") on the stack. | 3283 // Push the arguments ("left-to-right") on the stack. |
3268 ZoneList<Expression*>* args = expr->arguments(); | 3284 ZoneList<Expression*>* args = expr->arguments(); |
3269 int arg_count = args->length(); | 3285 int arg_count = args->length(); |
3270 for (int i = 0; i < arg_count; i++) { | 3286 for (int i = 0; i < arg_count; i++) { |
3271 VisitForStackValue(args->at(i)); | 3287 VisitForStackValue(args->at(i)); |
3272 } | 3288 } |
3273 | 3289 |
3274 // Call the construct call builtin that handles allocation and | 3290 // Call the construct call builtin that handles allocation and |
(...skipping 15 matching lines...) Expand all Loading... |
3290 __ li(a3, Operand(SmiFromSlot(expr->CallNewFeedbackSlot()))); | 3306 __ li(a3, Operand(SmiFromSlot(expr->CallNewFeedbackSlot()))); |
3291 | 3307 |
3292 CallConstructStub stub(isolate(), RECORD_CONSTRUCTOR_TARGET); | 3308 CallConstructStub stub(isolate(), RECORD_CONSTRUCTOR_TARGET); |
3293 __ Call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); | 3309 __ Call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); |
3294 PrepareForBailoutForId(expr->ReturnId(), TOS_REG); | 3310 PrepareForBailoutForId(expr->ReturnId(), TOS_REG); |
3295 context()->Plug(v0); | 3311 context()->Plug(v0); |
3296 } | 3312 } |
3297 | 3313 |
3298 | 3314 |
3299 void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) { | 3315 void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) { |
3300 Variable* new_target_var = scope()->DeclarationScope()->new_target_var(); | 3316 SuperCallReference* super_call_ref = |
3301 GetVar(result_register(), new_target_var); | 3317 expr->expression()->AsSuperCallReference(); |
3302 __ Push(result_register()); | 3318 DCHECK_NOT_NULL(super_call_ref); |
3303 | 3319 |
3304 EmitLoadSuperConstructor(); | 3320 VariableProxy* new_target_proxy = super_call_ref->new_target_var(); |
| 3321 VisitForStackValue(new_target_proxy); |
| 3322 |
| 3323 EmitLoadSuperConstructor(super_call_ref); |
3305 __ push(result_register()); | 3324 __ push(result_register()); |
3306 | 3325 |
3307 // Push the arguments ("left-to-right") on the stack. | 3326 // Push the arguments ("left-to-right") on the stack. |
3308 ZoneList<Expression*>* args = expr->arguments(); | 3327 ZoneList<Expression*>* args = expr->arguments(); |
3309 int arg_count = args->length(); | 3328 int arg_count = args->length(); |
3310 for (int i = 0; i < arg_count; i++) { | 3329 for (int i = 0; i < arg_count; i++) { |
3311 VisitForStackValue(args->at(i)); | 3330 VisitForStackValue(args->at(i)); |
3312 } | 3331 } |
3313 | 3332 |
3314 // Call the construct call builtin that handles allocation and | 3333 // Call the construct call builtin that handles allocation and |
(...skipping 17 matching lines...) Expand all Loading... |
3332 __ li(a2, FeedbackVector()); | 3351 __ li(a2, FeedbackVector()); |
3333 __ li(a3, Operand(SmiFromSlot(expr->CallFeedbackSlot()))); | 3352 __ li(a3, Operand(SmiFromSlot(expr->CallFeedbackSlot()))); |
3334 | 3353 |
3335 CallConstructStub stub(isolate(), SUPER_CALL_RECORD_TARGET); | 3354 CallConstructStub stub(isolate(), SUPER_CALL_RECORD_TARGET); |
3336 __ Call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); | 3355 __ Call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); |
3337 | 3356 |
3338 __ Drop(1); | 3357 __ Drop(1); |
3339 | 3358 |
3340 RecordJSReturnSite(expr); | 3359 RecordJSReturnSite(expr); |
3341 | 3360 |
3342 EmitInitializeThisAfterSuper(expr->expression()->AsSuperReference(), | 3361 EmitInitializeThisAfterSuper(super_call_ref, expr->CallFeedbackICSlot()); |
3343 expr->CallFeedbackICSlot()); | |
3344 context()->Plug(v0); | 3362 context()->Plug(v0); |
3345 } | 3363 } |
3346 | 3364 |
3347 | 3365 |
3348 void FullCodeGenerator::EmitIsSmi(CallRuntime* expr) { | 3366 void FullCodeGenerator::EmitIsSmi(CallRuntime* expr) { |
3349 ZoneList<Expression*>* args = expr->arguments(); | 3367 ZoneList<Expression*>* args = expr->arguments(); |
3350 DCHECK(args->length() == 1); | 3368 DCHECK(args->length() == 1); |
3351 | 3369 |
3352 VisitForAccumulatorValue(args->at(0)); | 3370 VisitForAccumulatorValue(args->at(0)); |
3353 | 3371 |
(...skipping 865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4219 __ bind(&runtime); | 4237 __ bind(&runtime); |
4220 __ push(v0); | 4238 __ push(v0); |
4221 __ CallRuntime(Runtime::kCall, args->length()); | 4239 __ CallRuntime(Runtime::kCall, args->length()); |
4222 __ bind(&done); | 4240 __ bind(&done); |
4223 | 4241 |
4224 context()->Plug(v0); | 4242 context()->Plug(v0); |
4225 } | 4243 } |
4226 | 4244 |
4227 | 4245 |
4228 void FullCodeGenerator::EmitDefaultConstructorCallSuper(CallRuntime* expr) { | 4246 void FullCodeGenerator::EmitDefaultConstructorCallSuper(CallRuntime* expr) { |
4229 Variable* new_target_var = scope()->DeclarationScope()->new_target_var(); | 4247 ZoneList<Expression*>* args = expr->arguments(); |
4230 GetVar(result_register(), new_target_var); | 4248 DCHECK(args->length() == 2); |
4231 __ Push(result_register()); | |
4232 | 4249 |
4233 EmitLoadSuperConstructor(); | 4250 // new.target |
| 4251 VisitForStackValue(args->at(0)); |
| 4252 |
| 4253 // .this_function |
| 4254 VisitForStackValue(args->at(1)); |
| 4255 __ CallRuntime(Runtime::kGetPrototype, 1); |
4234 __ Push(result_register()); | 4256 __ Push(result_register()); |
4235 | 4257 |
4236 // Check if the calling frame is an arguments adaptor frame. | 4258 // Check if the calling frame is an arguments adaptor frame. |
4237 Label adaptor_frame, args_set_up, runtime; | 4259 Label adaptor_frame, args_set_up, runtime; |
4238 __ lw(a2, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); | 4260 __ lw(a2, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); |
4239 __ lw(a3, MemOperand(a2, StandardFrameConstants::kContextOffset)); | 4261 __ lw(a3, MemOperand(a2, StandardFrameConstants::kContextOffset)); |
4240 __ Branch(&adaptor_frame, eq, a3, | 4262 __ Branch(&adaptor_frame, eq, a3, |
4241 Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); | 4263 Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); |
4242 // default constructor has no arguments, so no adaptor frame means no args. | 4264 // default constructor has no arguments, so no adaptor frame means no args. |
4243 __ mov(a0, zero_reg); | 4265 __ mov(a0, zero_reg); |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4629 context()->Plug(v0); | 4651 context()->Plug(v0); |
4630 } | 4652 } |
4631 | 4653 |
4632 | 4654 |
4633 void FullCodeGenerator::EmitCallSuperWithSpread(CallRuntime* expr) { | 4655 void FullCodeGenerator::EmitCallSuperWithSpread(CallRuntime* expr) { |
4634 // Assert: expr == CallRuntime("ReflectConstruct") | 4656 // Assert: expr == CallRuntime("ReflectConstruct") |
4635 CallRuntime* call = expr->arguments()->at(0)->AsCallRuntime(); | 4657 CallRuntime* call = expr->arguments()->at(0)->AsCallRuntime(); |
4636 ZoneList<Expression*>* args = call->arguments(); | 4658 ZoneList<Expression*>* args = call->arguments(); |
4637 DCHECK_EQ(3, args->length()); | 4659 DCHECK_EQ(3, args->length()); |
4638 | 4660 |
4639 SuperReference* super_reference = args->at(0)->AsSuperReference(); | 4661 SuperCallReference* super_call_ref = args->at(0)->AsSuperCallReference(); |
| 4662 DCHECK_NOT_NULL(super_call_ref); |
4640 | 4663 |
4641 // Load ReflectConstruct function | 4664 // Load ReflectConstruct function |
4642 EmitLoadJSRuntimeFunction(call); | 4665 EmitLoadJSRuntimeFunction(call); |
4643 | 4666 |
4644 // Push the target function under the receiver | 4667 // Push the target function under the receiver |
4645 __ lw(at, MemOperand(sp, 0)); | 4668 __ lw(at, MemOperand(sp, 0)); |
4646 __ push(at); | 4669 __ push(at); |
4647 __ sw(v0, MemOperand(sp, kPointerSize)); | 4670 __ sw(v0, MemOperand(sp, kPointerSize)); |
4648 | 4671 |
4649 // Push super | 4672 // Push super constructor |
4650 EmitLoadSuperConstructor(); | 4673 EmitLoadSuperConstructor(super_call_ref); |
4651 __ Push(result_register()); | 4674 __ Push(result_register()); |
4652 | 4675 |
4653 // Push arguments array | 4676 // Push arguments array |
4654 VisitForStackValue(args->at(1)); | 4677 VisitForStackValue(args->at(1)); |
4655 | 4678 |
4656 // Push NewTarget | 4679 // Push NewTarget |
4657 DCHECK(args->at(2)->IsVariableProxy()); | 4680 DCHECK(args->at(2)->IsVariableProxy()); |
4658 VisitForStackValue(args->at(2)); | 4681 VisitForStackValue(args->at(2)); |
4659 | 4682 |
4660 EmitCallJSRuntimeFunction(call); | 4683 EmitCallJSRuntimeFunction(call); |
4661 | 4684 |
4662 // Restore context register. | 4685 // Restore context register. |
4663 __ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 4686 __ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
4664 context()->DropAndPlug(1, v0); | 4687 context()->DropAndPlug(1, v0); |
4665 | 4688 |
4666 // TODO(mvstanton): with FLAG_vector_stores this needs a slot id. | 4689 // TODO(mvstanton): with FLAG_vector_stores this needs a slot id. |
4667 EmitInitializeThisAfterSuper(super_reference); | 4690 EmitInitializeThisAfterSuper(super_call_ref); |
4668 } | 4691 } |
4669 | 4692 |
4670 | 4693 |
4671 void FullCodeGenerator::EmitLoadJSRuntimeFunction(CallRuntime* expr) { | 4694 void FullCodeGenerator::EmitLoadJSRuntimeFunction(CallRuntime* expr) { |
4672 // Push the builtins object as the receiver. | 4695 // Push the builtins object as the receiver. |
4673 Register receiver = LoadDescriptor::ReceiverRegister(); | 4696 Register receiver = LoadDescriptor::ReceiverRegister(); |
4674 __ lw(receiver, GlobalObjectOperand()); | 4697 __ lw(receiver, GlobalObjectOperand()); |
4675 __ lw(receiver, FieldMemOperand(receiver, GlobalObject::kBuiltinsOffset)); | 4698 __ lw(receiver, FieldMemOperand(receiver, GlobalObject::kBuiltinsOffset)); |
4676 __ push(receiver); | 4699 __ push(receiver); |
4677 | 4700 |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4882 switch (assign_type) { | 4905 switch (assign_type) { |
4883 case NAMED_PROPERTY: { | 4906 case NAMED_PROPERTY: { |
4884 // Put the object both on the stack and in the register. | 4907 // Put the object both on the stack and in the register. |
4885 VisitForStackValue(prop->obj()); | 4908 VisitForStackValue(prop->obj()); |
4886 __ lw(LoadDescriptor::ReceiverRegister(), MemOperand(sp, 0)); | 4909 __ lw(LoadDescriptor::ReceiverRegister(), MemOperand(sp, 0)); |
4887 EmitNamedPropertyLoad(prop); | 4910 EmitNamedPropertyLoad(prop); |
4888 break; | 4911 break; |
4889 } | 4912 } |
4890 | 4913 |
4891 case NAMED_SUPER_PROPERTY: { | 4914 case NAMED_SUPER_PROPERTY: { |
4892 VisitForStackValue(prop->obj()->AsSuperReference()->this_var()); | 4915 VisitForStackValue(prop->obj()->AsSuperPropertyReference()->this_var()); |
4893 VisitForAccumulatorValue( | 4916 VisitForAccumulatorValue( |
4894 prop->obj()->AsSuperReference()->home_object_var()); | 4917 prop->obj()->AsSuperPropertyReference()->home_object_var()); |
4895 __ Push(result_register()); | 4918 __ Push(result_register()); |
4896 const Register scratch = a1; | 4919 const Register scratch = a1; |
4897 __ lw(scratch, MemOperand(sp, kPointerSize)); | 4920 __ lw(scratch, MemOperand(sp, kPointerSize)); |
4898 __ Push(scratch, result_register()); | 4921 __ Push(scratch, result_register()); |
4899 EmitNamedSuperPropertyLoad(prop); | 4922 EmitNamedSuperPropertyLoad(prop); |
4900 break; | 4923 break; |
4901 } | 4924 } |
4902 | 4925 |
4903 case KEYED_SUPER_PROPERTY: { | 4926 case KEYED_SUPER_PROPERTY: { |
4904 VisitForStackValue(prop->obj()->AsSuperReference()->this_var()); | 4927 VisitForStackValue(prop->obj()->AsSuperPropertyReference()->this_var()); |
4905 VisitForAccumulatorValue( | 4928 VisitForAccumulatorValue( |
4906 prop->obj()->AsSuperReference()->home_object_var()); | 4929 prop->obj()->AsSuperPropertyReference()->home_object_var()); |
4907 const Register scratch = a1; | 4930 const Register scratch = a1; |
4908 const Register scratch1 = t0; | 4931 const Register scratch1 = t0; |
4909 __ Move(scratch, result_register()); | 4932 __ Move(scratch, result_register()); |
4910 VisitForAccumulatorValue(prop->key()); | 4933 VisitForAccumulatorValue(prop->key()); |
4911 __ Push(scratch, result_register()); | 4934 __ Push(scratch, result_register()); |
4912 __ lw(scratch1, MemOperand(sp, 2 * kPointerSize)); | 4935 __ lw(scratch1, MemOperand(sp, 2 * kPointerSize)); |
4913 __ Push(scratch1, scratch, result_register()); | 4936 __ Push(scratch1, scratch, result_register()); |
4914 EmitKeyedSuperPropertyLoad(prop); | 4937 EmitKeyedSuperPropertyLoad(prop); |
4915 break; | 4938 break; |
4916 } | 4939 } |
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5517 Assembler::target_address_at(pc_immediate_load_address)) == | 5540 Assembler::target_address_at(pc_immediate_load_address)) == |
5518 reinterpret_cast<uint32_t>( | 5541 reinterpret_cast<uint32_t>( |
5519 isolate->builtins()->OsrAfterStackCheck()->entry())); | 5542 isolate->builtins()->OsrAfterStackCheck()->entry())); |
5520 return OSR_AFTER_STACK_CHECK; | 5543 return OSR_AFTER_STACK_CHECK; |
5521 } | 5544 } |
5522 | 5545 |
5523 | 5546 |
5524 } } // namespace v8::internal | 5547 } } // namespace v8::internal |
5525 | 5548 |
5526 #endif // V8_TARGET_ARCH_MIPS | 5549 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |