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 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(rax); | 3265 context()->Plug(rax); |
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 |
3291 // Load function and argument count into edi and eax. | 3288 // Load original constructor into rcx. |
| 3289 VisitForAccumulatorValue(super_call_ref->new_target_var()); |
| 3290 __ movp(rcx, result_register()); |
| 3291 |
| 3292 // Load function and argument count into rdi and rax. |
3292 __ Set(rax, arg_count); | 3293 __ Set(rax, arg_count); |
3293 __ movp(rdi, Operand(rsp, arg_count * kPointerSize)); | 3294 __ movp(rdi, Operand(rsp, 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 __ Move(rbx, FeedbackVector()); | 3306 __ Move(rbx, FeedbackVector()); |
3306 __ Move(rdx, SmiFromSlot(expr->CallFeedbackSlot())); | 3307 __ Move(rdx, 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(rax); | 3315 context()->Plug(rax); |
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 902 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4225 DCHECK(args->length() == 2); | 4224 DCHECK(args->length() == 2); |
4226 | 4225 |
4227 // new.target | 4226 // new.target |
4228 VisitForStackValue(args->at(0)); | 4227 VisitForStackValue(args->at(0)); |
4229 | 4228 |
4230 // .this_function | 4229 // .this_function |
4231 VisitForStackValue(args->at(1)); | 4230 VisitForStackValue(args->at(1)); |
4232 __ CallRuntime(Runtime::kGetPrototype, 1); | 4231 __ CallRuntime(Runtime::kGetPrototype, 1); |
4233 __ Push(result_register()); | 4232 __ Push(result_register()); |
4234 | 4233 |
| 4234 // Load original constructor into rcx. |
| 4235 __ movp(rcx, Operand(rsp, 1 * kPointerSize)); |
| 4236 |
4235 // Check if the calling frame is an arguments adaptor frame. | 4237 // Check if the calling frame is an arguments adaptor frame. |
4236 Label adaptor_frame, args_set_up, runtime; | 4238 Label adaptor_frame, args_set_up, runtime; |
4237 __ movp(rdx, Operand(rbp, StandardFrameConstants::kCallerFPOffset)); | 4239 __ movp(rdx, Operand(rbp, StandardFrameConstants::kCallerFPOffset)); |
4238 __ movp(rcx, Operand(rdx, StandardFrameConstants::kContextOffset)); | 4240 __ movp(rbx, Operand(rdx, StandardFrameConstants::kContextOffset)); |
4239 __ Cmp(rcx, Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)); | 4241 __ Cmp(rbx, Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)); |
4240 __ j(equal, &adaptor_frame); | 4242 __ j(equal, &adaptor_frame); |
4241 // default constructor has no arguments, so no adaptor frame means no args. | 4243 // default constructor has no arguments, so no adaptor frame means no args. |
4242 __ movp(rax, Immediate(0)); | 4244 __ movp(rax, Immediate(0)); |
4243 __ jmp(&args_set_up); | 4245 __ jmp(&args_set_up); |
4244 | 4246 |
4245 // Copy arguments from adaptor frame. | 4247 // Copy arguments from adaptor frame. |
4246 { | 4248 { |
4247 __ bind(&adaptor_frame); | 4249 __ bind(&adaptor_frame); |
4248 __ movp(rcx, Operand(rdx, ArgumentsAdaptorFrameConstants::kLengthOffset)); | 4250 __ movp(rbx, Operand(rdx, ArgumentsAdaptorFrameConstants::kLengthOffset)); |
4249 __ SmiToInteger64(rcx, rcx); | 4251 __ SmiToInteger64(rbx, rbx); |
4250 | 4252 |
4251 __ movp(rax, rcx); | 4253 __ movp(rax, rbx); |
4252 __ leap(rdx, Operand(rdx, rcx, times_pointer_size, | 4254 __ leap(rdx, Operand(rdx, rbx, times_pointer_size, |
4253 StandardFrameConstants::kCallerSPOffset)); | 4255 StandardFrameConstants::kCallerSPOffset)); |
4254 Label loop; | 4256 Label loop; |
4255 __ bind(&loop); | 4257 __ bind(&loop); |
4256 __ Push(Operand(rdx, -1 * kPointerSize)); | 4258 __ Push(Operand(rdx, -1 * kPointerSize)); |
4257 __ subp(rdx, Immediate(kPointerSize)); | 4259 __ subp(rdx, Immediate(kPointerSize)); |
4258 __ decp(rcx); | 4260 __ decp(rbx); |
4259 __ j(not_zero, &loop); | 4261 __ j(not_zero, &loop); |
4260 } | 4262 } |
4261 | 4263 |
4262 __ bind(&args_set_up); | 4264 __ bind(&args_set_up); |
4263 __ movp(rdi, Operand(rsp, rax, times_pointer_size, 0)); | 4265 __ movp(rdi, Operand(rsp, rax, times_pointer_size, 0)); |
4264 __ LoadRoot(rbx, Heap::kUndefinedValueRootIndex); | 4266 __ LoadRoot(rbx, Heap::kUndefinedValueRootIndex); |
4265 | 4267 |
4266 CallConstructStub stub(isolate(), SUPER_CONSTRUCTOR_CALL); | 4268 CallConstructStub stub(isolate(), SUPER_CONSTRUCTOR_CALL); |
4267 __ call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); | 4269 __ call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); |
4268 | 4270 |
(...skipping 1263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5532 Assembler::target_address_at(call_target_address, | 5534 Assembler::target_address_at(call_target_address, |
5533 unoptimized_code)); | 5535 unoptimized_code)); |
5534 return OSR_AFTER_STACK_CHECK; | 5536 return OSR_AFTER_STACK_CHECK; |
5535 } | 5537 } |
5536 | 5538 |
5537 | 5539 |
5538 } // namespace internal | 5540 } // namespace internal |
5539 } // namespace v8 | 5541 } // namespace v8 |
5540 | 5542 |
5541 #endif // V8_TARGET_ARCH_X64 | 5543 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |