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 3023 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3034 // a1: the start position of the scope the calls resides in. | 3034 // a1: the start position of the scope the calls resides in. |
3035 __ li(a1, Operand(Smi::FromInt(scope()->start_position()))); | 3035 __ li(a1, Operand(Smi::FromInt(scope()->start_position()))); |
3036 | 3036 |
3037 // Do the runtime call. | 3037 // Do the runtime call. |
3038 __ Push(t3); | 3038 __ Push(t3); |
3039 __ Push(t2, t1, t0, a1); | 3039 __ Push(t2, t1, t0, a1); |
3040 __ CallRuntime(Runtime::kResolvePossiblyDirectEval, 6); | 3040 __ CallRuntime(Runtime::kResolvePossiblyDirectEval, 6); |
3041 } | 3041 } |
3042 | 3042 |
3043 | 3043 |
3044 void FullCodeGenerator::EmitLoadSuperConstructor(SuperReference* super_ref) { | 3044 void FullCodeGenerator::EmitLoadSuperConstructor() { |
3045 DCHECK(super_ref != NULL); | |
3046 __ lw(a0, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); | 3045 __ lw(a0, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
3047 __ Push(a0); | 3046 __ Push(a0); |
3048 __ CallRuntime(Runtime::kGetPrototype, 1); | 3047 __ CallRuntime(Runtime::kGetPrototype, 1); |
3049 } | 3048 } |
3050 | 3049 |
3051 | 3050 |
3052 void FullCodeGenerator::VisitCall(Call* expr) { | 3051 void FullCodeGenerator::VisitCall(Call* expr) { |
3053 #ifdef DEBUG | 3052 #ifdef DEBUG |
3054 // We want to verify that RecordJSReturnSite gets called on all paths | 3053 // We want to verify that RecordJSReturnSite gets called on all paths |
3055 // through this function. Avoid early returns. | 3054 // through this function. Avoid early returns. |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3159 if (is_named_call) { | 3158 if (is_named_call) { |
3160 EmitCallWithLoadIC(expr); | 3159 EmitCallWithLoadIC(expr); |
3161 } else { | 3160 } else { |
3162 EmitKeyedCallWithLoadIC(expr, property->key()); | 3161 EmitKeyedCallWithLoadIC(expr, property->key()); |
3163 } | 3162 } |
3164 } | 3163 } |
3165 } else if (call_type == Call::SUPER_CALL) { | 3164 } else if (call_type == Call::SUPER_CALL) { |
3166 if (FLAG_experimental_classes) { | 3165 if (FLAG_experimental_classes) { |
3167 EmitSuperConstructorCall(expr); | 3166 EmitSuperConstructorCall(expr); |
3168 } else { | 3167 } else { |
| 3168 EmitLoadSuperConstructor(); |
| 3169 __ Push(result_register()); |
3169 SuperReference* super_ref = callee->AsSuperReference(); | 3170 SuperReference* super_ref = callee->AsSuperReference(); |
3170 EmitLoadSuperConstructor(super_ref); | |
3171 __ Push(result_register()); | |
3172 VisitForStackValue(super_ref->this_var()); | 3171 VisitForStackValue(super_ref->this_var()); |
3173 EmitCall(expr, CallICState::METHOD); | 3172 EmitCall(expr, CallICState::METHOD); |
3174 } | 3173 } |
3175 } else { | 3174 } else { |
3176 DCHECK(call_type == Call::OTHER_CALL); | 3175 DCHECK(call_type == Call::OTHER_CALL); |
3177 // Call to an arbitrary expression not handled specially above. | 3176 // Call to an arbitrary expression not handled specially above. |
3178 { PreservePositionScope scope(masm()->positions_recorder()); | 3177 { PreservePositionScope scope(masm()->positions_recorder()); |
3179 VisitForStackValue(callee); | 3178 VisitForStackValue(callee); |
3180 } | 3179 } |
3181 __ LoadRoot(a1, Heap::kUndefinedValueRootIndex); | 3180 __ LoadRoot(a1, Heap::kUndefinedValueRootIndex); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3234 context()->Plug(v0); | 3233 context()->Plug(v0); |
3235 } | 3234 } |
3236 | 3235 |
3237 | 3236 |
3238 void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) { | 3237 void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) { |
3239 Comment cmnt(masm_, "[ SuperConstructorCall"); | 3238 Comment cmnt(masm_, "[ SuperConstructorCall"); |
3240 Variable* new_target_var = scope()->DeclarationScope()->new_target_var(); | 3239 Variable* new_target_var = scope()->DeclarationScope()->new_target_var(); |
3241 GetVar(result_register(), new_target_var); | 3240 GetVar(result_register(), new_target_var); |
3242 __ Push(result_register()); | 3241 __ Push(result_register()); |
3243 | 3242 |
3244 SuperReference* super_ref = expr->expression()->AsSuperReference(); | 3243 EmitLoadSuperConstructor(); |
3245 EmitLoadSuperConstructor(super_ref); | |
3246 __ push(result_register()); | 3244 __ push(result_register()); |
3247 | 3245 |
| 3246 SuperReference* super_ref = expr->expression()->AsSuperReference(); |
3248 Variable* this_var = super_ref->this_var()->var(); | 3247 Variable* this_var = super_ref->this_var()->var(); |
3249 | 3248 |
3250 GetVar(a0, this_var); | 3249 GetVar(a0, this_var); |
3251 __ LoadRoot(at, Heap::kTheHoleValueRootIndex); | 3250 __ LoadRoot(at, Heap::kTheHoleValueRootIndex); |
3252 Label uninitialized_this; | 3251 Label uninitialized_this; |
3253 __ Branch(&uninitialized_this, eq, a0, Operand(at)); | 3252 __ Branch(&uninitialized_this, eq, a0, Operand(at)); |
3254 __ li(a0, Operand(this_var->name())); | 3253 __ li(a0, Operand(this_var->name())); |
3255 __ Push(a0); | 3254 __ Push(a0); |
3256 __ CallRuntime(Runtime::kThrowReferenceError, 1); | 3255 __ CallRuntime(Runtime::kThrowReferenceError, 1); |
3257 __ bind(&uninitialized_this); | 3256 __ bind(&uninitialized_this); |
(...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4168 | 4167 |
4169 __ bind(&runtime); | 4168 __ bind(&runtime); |
4170 __ push(v0); | 4169 __ push(v0); |
4171 __ CallRuntime(Runtime::kCall, args->length()); | 4170 __ CallRuntime(Runtime::kCall, args->length()); |
4172 __ bind(&done); | 4171 __ bind(&done); |
4173 | 4172 |
4174 context()->Plug(v0); | 4173 context()->Plug(v0); |
4175 } | 4174 } |
4176 | 4175 |
4177 | 4176 |
| 4177 void FullCodeGenerator::EmitDefaultConstructorCallSuper(CallRuntime* expr) { |
| 4178 Variable* new_target_var = scope()->DeclarationScope()->new_target_var(); |
| 4179 GetVar(result_register(), new_target_var); |
| 4180 __ Push(result_register()); |
| 4181 |
| 4182 EmitLoadSuperConstructor(); |
| 4183 __ Push(result_register()); |
| 4184 |
| 4185 // Check if the calling frame is an arguments adaptor frame. |
| 4186 Label adaptor_frame, args_set_up, runtime; |
| 4187 __ lw(a2, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); |
| 4188 __ lw(a3, MemOperand(a2, StandardFrameConstants::kContextOffset)); |
| 4189 __ Branch(&adaptor_frame, eq, a3, |
| 4190 Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); |
| 4191 // default constructor has no arguments, so no adaptor frame means no args. |
| 4192 __ mov(a0, zero_reg); |
| 4193 __ Branch(&args_set_up); |
| 4194 |
| 4195 // Copy arguments from adaptor frame. |
| 4196 { |
| 4197 __ bind(&adaptor_frame); |
| 4198 __ lw(a1, MemOperand(a2, ArgumentsAdaptorFrameConstants::kLengthOffset)); |
| 4199 __ SmiUntag(a1, a1); |
| 4200 |
| 4201 // Subtract 1 from arguments count, for new.target. |
| 4202 __ Addu(a1, a1, Operand(-1)); |
| 4203 __ mov(a0, a1); |
| 4204 |
| 4205 // Get arguments pointer in a2. |
| 4206 __ sll(at, a1, kPointerSizeLog2); |
| 4207 __ addu(a2, a2, at); |
| 4208 __ Addu(a2, a2, Operand(StandardFrameConstants::kCallerSPOffset)); |
| 4209 Label loop; |
| 4210 __ bind(&loop); |
| 4211 // Pre-decrement a2 with kPointerSize on each iteration. |
| 4212 // Pre-decrement in order to skip receiver. |
| 4213 __ Addu(a2, a2, Operand(-kPointerSize)); |
| 4214 __ lw(a3, MemOperand(a2)); |
| 4215 __ Push(a3); |
| 4216 __ Addu(a1, a1, Operand(-1)); |
| 4217 __ Branch(&loop, ne, a1, Operand(zero_reg)); |
| 4218 } |
| 4219 |
| 4220 __ bind(&args_set_up); |
| 4221 __ sll(at, a0, kPointerSizeLog2); |
| 4222 __ Addu(at, at, Operand(sp)); |
| 4223 __ lw(a1, MemOperand(at, 0)); |
| 4224 |
| 4225 CallConstructStub stub(isolate(), SUPER_CONSTRUCTOR_CALL); |
| 4226 __ Call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); |
| 4227 |
| 4228 __ Drop(1); |
| 4229 |
| 4230 context()->Plug(result_register()); |
| 4231 } |
| 4232 |
| 4233 |
4178 void FullCodeGenerator::EmitRegExpConstructResult(CallRuntime* expr) { | 4234 void FullCodeGenerator::EmitRegExpConstructResult(CallRuntime* expr) { |
4179 RegExpConstructResultStub stub(isolate()); | 4235 RegExpConstructResultStub stub(isolate()); |
4180 ZoneList<Expression*>* args = expr->arguments(); | 4236 ZoneList<Expression*>* args = expr->arguments(); |
4181 DCHECK(args->length() == 3); | 4237 DCHECK(args->length() == 3); |
4182 VisitForStackValue(args->at(0)); | 4238 VisitForStackValue(args->at(0)); |
4183 VisitForStackValue(args->at(1)); | 4239 VisitForStackValue(args->at(1)); |
4184 VisitForAccumulatorValue(args->at(2)); | 4240 VisitForAccumulatorValue(args->at(2)); |
4185 __ mov(a0, result_register()); | 4241 __ mov(a0, result_register()); |
4186 __ pop(a1); | 4242 __ pop(a1); |
4187 __ pop(a2); | 4243 __ pop(a2); |
(...skipping 1188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5376 Assembler::target_address_at(pc_immediate_load_address)) == | 5432 Assembler::target_address_at(pc_immediate_load_address)) == |
5377 reinterpret_cast<uint32_t>( | 5433 reinterpret_cast<uint32_t>( |
5378 isolate->builtins()->OsrAfterStackCheck()->entry())); | 5434 isolate->builtins()->OsrAfterStackCheck()->entry())); |
5379 return OSR_AFTER_STACK_CHECK; | 5435 return OSR_AFTER_STACK_CHECK; |
5380 } | 5436 } |
5381 | 5437 |
5382 | 5438 |
5383 } } // namespace v8::internal | 5439 } } // namespace v8::internal |
5384 | 5440 |
5385 #endif // V8_TARGET_ARCH_MIPS | 5441 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |