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_IA32 | 7 #if V8_TARGET_ARCH_IA32 |
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 3253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3264 PrepareForBailoutForId(expr->ReturnId(), TOS_REG); | 3264 PrepareForBailoutForId(expr->ReturnId(), TOS_REG); |
3265 context()->Plug(eax); | 3265 context()->Plug(eax); |
3266 } | 3266 } |
3267 | 3267 |
3268 | 3268 |
3269 void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) { | 3269 void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) { |
3270 SuperCallReference* super_call_ref = | 3270 SuperCallReference* super_call_ref = |
3271 expr->expression()->AsSuperCallReference(); | 3271 expr->expression()->AsSuperCallReference(); |
3272 DCHECK_NOT_NULL(super_call_ref); | 3272 DCHECK_NOT_NULL(super_call_ref); |
3273 | 3273 |
3274 VariableProxy* new_target_proxy = super_call_ref->new_target_var(); | |
3275 VisitForStackValue(new_target_proxy); | |
3276 | |
3277 EmitLoadSuperConstructor(super_call_ref); | 3274 EmitLoadSuperConstructor(super_call_ref); |
3278 __ push(result_register()); | 3275 __ push(result_register()); |
3279 | 3276 |
3280 // Push the arguments ("left-to-right") on the stack. | 3277 // Push the arguments ("left-to-right") on the stack. |
3281 ZoneList<Expression*>* args = expr->arguments(); | 3278 ZoneList<Expression*>* args = expr->arguments(); |
3282 int arg_count = args->length(); | 3279 int arg_count = args->length(); |
3283 for (int i = 0; i < arg_count; i++) { | 3280 for (int i = 0; i < arg_count; i++) { |
3284 VisitForStackValue(args->at(i)); | 3281 VisitForStackValue(args->at(i)); |
3285 } | 3282 } |
3286 | 3283 |
3287 // Call the construct call builtin that handles allocation and | 3284 // Call the construct call builtin that handles allocation and |
3288 // constructor invocation. | 3285 // constructor invocation. |
3289 SetConstructCallPosition(expr); | 3286 SetConstructCallPosition(expr); |
3290 | 3287 |
| 3288 // Load original constructor into ecx. |
| 3289 VisitForAccumulatorValue(super_call_ref->new_target_var()); |
| 3290 __ mov(ecx, result_register()); |
| 3291 |
3291 // Load function and argument count into edi and eax. | 3292 // Load function and argument count into edi and eax. |
3292 __ Move(eax, Immediate(arg_count)); | 3293 __ Move(eax, Immediate(arg_count)); |
3293 __ mov(edi, Operand(esp, arg_count * kPointerSize)); | 3294 __ mov(edi, Operand(esp, arg_count * kPointerSize)); |
3294 | 3295 |
3295 // Record call targets in unoptimized code. | 3296 // Record call targets in unoptimized code. |
3296 if (FLAG_pretenuring_call_new) { | 3297 if (FLAG_pretenuring_call_new) { |
3297 UNREACHABLE(); | 3298 UNREACHABLE(); |
3298 /* TODO(dslomov): support pretenuring. | 3299 /* TODO(dslomov): support pretenuring. |
3299 EnsureSlotContainsAllocationSite(expr->AllocationSiteFeedbackSlot()); | 3300 EnsureSlotContainsAllocationSite(expr->AllocationSiteFeedbackSlot()); |
3300 DCHECK(expr->AllocationSiteFeedbackSlot().ToInt() == | 3301 DCHECK(expr->AllocationSiteFeedbackSlot().ToInt() == |
3301 expr->CallNewFeedbackSlot().ToInt() + 1); | 3302 expr->CallNewFeedbackSlot().ToInt() + 1); |
3302 */ | 3303 */ |
3303 } | 3304 } |
3304 | 3305 |
3305 __ LoadHeapObject(ebx, FeedbackVector()); | 3306 __ LoadHeapObject(ebx, FeedbackVector()); |
3306 __ mov(edx, Immediate(SmiFromSlot(expr->CallFeedbackSlot()))); | 3307 __ mov(edx, Immediate(SmiFromSlot(expr->CallFeedbackSlot()))); |
3307 | 3308 |
3308 CallConstructStub stub(isolate(), SUPER_CALL_RECORD_TARGET); | 3309 CallConstructStub stub(isolate(), SUPER_CALL_RECORD_TARGET); |
3309 __ call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); | 3310 __ call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); |
3310 | 3311 |
3311 __ Drop(1); | |
3312 | |
3313 RecordJSReturnSite(expr); | 3312 RecordJSReturnSite(expr); |
3314 | 3313 |
3315 EmitInitializeThisAfterSuper(super_call_ref, expr->CallFeedbackICSlot()); | 3314 EmitInitializeThisAfterSuper(super_call_ref, expr->CallFeedbackICSlot()); |
3316 context()->Plug(eax); | 3315 context()->Plug(eax); |
3317 } | 3316 } |
3318 | 3317 |
3319 | 3318 |
3320 void FullCodeGenerator::EmitIsSmi(CallRuntime* expr) { | 3319 void FullCodeGenerator::EmitIsSmi(CallRuntime* expr) { |
3321 ZoneList<Expression*>* args = expr->arguments(); | 3320 ZoneList<Expression*>* args = expr->arguments(); |
3322 DCHECK(args->length() == 1); | 3321 DCHECK(args->length() == 1); |
(...skipping 905 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4228 DCHECK(args->length() == 2); | 4227 DCHECK(args->length() == 2); |
4229 | 4228 |
4230 // new.target | 4229 // new.target |
4231 VisitForStackValue(args->at(0)); | 4230 VisitForStackValue(args->at(0)); |
4232 | 4231 |
4233 // .this_function | 4232 // .this_function |
4234 VisitForStackValue(args->at(1)); | 4233 VisitForStackValue(args->at(1)); |
4235 __ CallRuntime(Runtime::kGetPrototype, 1); | 4234 __ CallRuntime(Runtime::kGetPrototype, 1); |
4236 __ push(result_register()); | 4235 __ push(result_register()); |
4237 | 4236 |
| 4237 // Load original constructor into ecx. |
| 4238 __ mov(ecx, Operand(esp, 1 * kPointerSize)); |
| 4239 |
4238 // Check if the calling frame is an arguments adaptor frame. | 4240 // Check if the calling frame is an arguments adaptor frame. |
4239 Label adaptor_frame, args_set_up, runtime; | 4241 Label adaptor_frame, args_set_up, runtime; |
4240 __ mov(edx, Operand(ebp, StandardFrameConstants::kCallerFPOffset)); | 4242 __ mov(edx, Operand(ebp, StandardFrameConstants::kCallerFPOffset)); |
4241 __ mov(ecx, Operand(edx, StandardFrameConstants::kContextOffset)); | 4243 __ mov(ebx, Operand(edx, StandardFrameConstants::kContextOffset)); |
4242 __ cmp(ecx, Immediate(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); | 4244 __ cmp(ebx, Immediate(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); |
4243 __ j(equal, &adaptor_frame); | 4245 __ j(equal, &adaptor_frame); |
4244 // default constructor has no arguments, so no adaptor frame means no args. | 4246 // default constructor has no arguments, so no adaptor frame means no args. |
4245 __ mov(eax, Immediate(0)); | 4247 __ mov(eax, Immediate(0)); |
4246 __ jmp(&args_set_up); | 4248 __ jmp(&args_set_up); |
4247 | 4249 |
4248 // Copy arguments from adaptor frame. | 4250 // Copy arguments from adaptor frame. |
4249 { | 4251 { |
4250 __ bind(&adaptor_frame); | 4252 __ bind(&adaptor_frame); |
4251 __ mov(ecx, Operand(edx, ArgumentsAdaptorFrameConstants::kLengthOffset)); | 4253 __ mov(ebx, Operand(edx, ArgumentsAdaptorFrameConstants::kLengthOffset)); |
4252 __ SmiUntag(ecx); | 4254 __ SmiUntag(ebx); |
4253 | 4255 |
4254 __ mov(eax, ecx); | 4256 __ mov(eax, ebx); |
4255 __ lea(edx, Operand(edx, ecx, times_pointer_size, | 4257 __ lea(edx, Operand(edx, ebx, times_pointer_size, |
4256 StandardFrameConstants::kCallerSPOffset)); | 4258 StandardFrameConstants::kCallerSPOffset)); |
4257 Label loop; | 4259 Label loop; |
4258 __ bind(&loop); | 4260 __ bind(&loop); |
4259 __ push(Operand(edx, -1 * kPointerSize)); | 4261 __ push(Operand(edx, -1 * kPointerSize)); |
4260 __ sub(edx, Immediate(kPointerSize)); | 4262 __ sub(edx, Immediate(kPointerSize)); |
4261 __ dec(ecx); | 4263 __ dec(ebx); |
4262 __ j(not_zero, &loop); | 4264 __ j(not_zero, &loop); |
4263 } | 4265 } |
4264 | 4266 |
4265 __ bind(&args_set_up); | 4267 __ bind(&args_set_up); |
4266 | 4268 |
4267 __ mov(edi, Operand(esp, eax, times_pointer_size, 0)); | 4269 __ mov(edi, Operand(esp, eax, times_pointer_size, 0)); |
4268 __ mov(ebx, Immediate(isolate()->factory()->undefined_value())); | 4270 __ mov(ebx, Immediate(isolate()->factory()->undefined_value())); |
4269 CallConstructStub stub(isolate(), SUPER_CONSTRUCTOR_CALL); | 4271 CallConstructStub stub(isolate(), SUPER_CONSTRUCTOR_CALL); |
4270 __ call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); | 4272 __ call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); |
4271 | 4273 |
(...skipping 1235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5507 Assembler::target_address_at(call_target_address, | 5509 Assembler::target_address_at(call_target_address, |
5508 unoptimized_code)); | 5510 unoptimized_code)); |
5509 return OSR_AFTER_STACK_CHECK; | 5511 return OSR_AFTER_STACK_CHECK; |
5510 } | 5512 } |
5511 | 5513 |
5512 | 5514 |
5513 } // namespace internal | 5515 } // namespace internal |
5514 } // namespace v8 | 5516 } // namespace v8 |
5515 | 5517 |
5516 #endif // V8_TARGET_ARCH_IA32 | 5518 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |