| 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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 // Possibly set up a local binding to the this function which is used in | 233 // Possibly set up a local binding to the this function which is used in |
| 234 // derived constructors with super calls. | 234 // derived constructors with super calls. |
| 235 Variable* this_function_var = scope()->this_function_var(); | 235 Variable* this_function_var = scope()->this_function_var(); |
| 236 if (this_function_var != nullptr) { | 236 if (this_function_var != nullptr) { |
| 237 Comment cmnt(masm_, "[ This function"); | 237 Comment cmnt(masm_, "[ This function"); |
| 238 SetVar(this_function_var, rdi, rbx, rdx); | 238 SetVar(this_function_var, rdi, rbx, rdx); |
| 239 } | 239 } |
| 240 | 240 |
| 241 Variable* new_target_var = scope()->new_target_var(); | 241 Variable* new_target_var = scope()->new_target_var(); |
| 242 if (new_target_var != nullptr) { | 242 if (new_target_var != nullptr) { |
| 243 // If this is a [[Construct]] then the new.target is passed as the -2 |
| 244 // argument. If it is a [[Call]] this is always undefined. |
| 243 Comment cmnt(masm_, "[ new.target"); | 245 Comment cmnt(masm_, "[ new.target"); |
| 246 Label assign, construct, check_frame_marker; |
| 247 __ movp(rax, Operand(rbp, StandardFrameConstants::kCallerFPOffset)); |
| 248 __ Cmp(Operand(rax, StandardFrameConstants::kContextOffset), |
| 249 Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)); |
| 250 __ j(not_equal, &check_frame_marker); |
| 251 __ movp(rax, Operand(rax, StandardFrameConstants::kCallerFPOffset)); |
| 252 __ bind(&check_frame_marker); |
| 253 __ Cmp(Operand(rax, StandardFrameConstants::kMarkerOffset), |
| 254 Smi::FromInt(StackFrame::CONSTRUCT)); |
| 255 __ j(equal, &construct); |
| 256 |
| 257 // [[Call]] |
| 258 __ LoadRoot(rax, Heap::kUndefinedValueRootIndex); |
| 259 __ jmp(&assign); |
| 260 |
| 261 // [[Construct]] |
| 262 __ bind(&construct); |
| 263 |
| 244 // new.target is parameter -2. | 264 // new.target is parameter -2. |
| 245 int offset = 2 * kPointerSize + kFPOnStackSize + kPCOnStackSize + | 265 int offset = 2 * kPointerSize + kFPOnStackSize + kPCOnStackSize + |
| 246 (info_->scope()->num_parameters() - 1) * kPointerSize; | 266 (info_->scope()->num_parameters() - 1) * kPointerSize; |
| 247 __ movp(rax, Operand(rbp, offset)); | 267 __ movp(rax, Operand(rbp, offset)); |
| 268 |
| 269 __ bind(&assign); |
| 248 SetVar(new_target_var, rax, rbx, rdx); | 270 SetVar(new_target_var, rax, rbx, rdx); |
| 249 } | 271 } |
| 250 | 272 |
| 251 ArgumentsAccessStub::HasNewTarget has_new_target = | 273 ArgumentsAccessStub::HasNewTarget has_new_target = |
| 252 IsSubclassConstructor(info->function()->kind()) | 274 (info->scope()->new_target_var() != nullptr || |
| 275 IsSubclassConstructor(info->function()->kind())) |
| 253 ? ArgumentsAccessStub::HAS_NEW_TARGET | 276 ? ArgumentsAccessStub::HAS_NEW_TARGET |
| 254 : ArgumentsAccessStub::NO_NEW_TARGET; | 277 : ArgumentsAccessStub::NO_NEW_TARGET; |
| 255 | 278 |
| 256 // Possibly allocate RestParameters | 279 // Possibly allocate RestParameters |
| 257 int rest_index; | 280 int rest_index; |
| 258 Variable* rest_param = scope()->rest_parameter(&rest_index); | 281 Variable* rest_param = scope()->rest_parameter(&rest_index); |
| 259 if (rest_param) { | 282 if (rest_param) { |
| 260 Comment cmnt(masm_, "[ Allocate rest parameter array"); | 283 Comment cmnt(masm_, "[ Allocate rest parameter array"); |
| 261 | 284 |
| 262 int num_parameters = info->scope()->num_parameters(); | 285 int num_parameters = info->scope()->num_parameters(); |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 #endif | 481 #endif |
| 459 CodeGenerator::RecordPositions(masm_, function()->end_position() - 1); | 482 CodeGenerator::RecordPositions(masm_, function()->end_position() - 1); |
| 460 __ RecordJSReturn(); | 483 __ RecordJSReturn(); |
| 461 // Do not use the leave instruction here because it is too short to | 484 // Do not use the leave instruction here because it is too short to |
| 462 // patch with the code required by the debugger. | 485 // patch with the code required by the debugger. |
| 463 __ movp(rsp, rbp); | 486 __ movp(rsp, rbp); |
| 464 __ popq(rbp); | 487 __ popq(rbp); |
| 465 int no_frame_start = masm_->pc_offset(); | 488 int no_frame_start = masm_->pc_offset(); |
| 466 | 489 |
| 467 int arg_count = info_->scope()->num_parameters() + 1; | 490 int arg_count = info_->scope()->num_parameters() + 1; |
| 468 if (IsSubclassConstructor(info_->function()->kind())) { | 491 if (info_->scope()->new_target_var() != nullptr || |
| 492 IsSubclassConstructor(info_->function()->kind())) { |
| 469 arg_count++; | 493 arg_count++; |
| 470 } | 494 } |
| 471 int arguments_bytes = arg_count * kPointerSize; | 495 int arguments_bytes = arg_count * kPointerSize; |
| 472 __ Ret(arguments_bytes, rcx); | 496 __ Ret(arguments_bytes, rcx); |
| 473 | 497 |
| 474 // Add padding that will be overwritten by a debugger breakpoint. We | 498 // Add padding that will be overwritten by a debugger breakpoint. We |
| 475 // have just generated at least 7 bytes: "movp rsp, rbp; pop rbp; ret k" | 499 // have just generated at least 7 bytes: "movp rsp, rbp; pop rbp; ret k" |
| 476 // (3 + 1 + 3) for x64 and at least 6 (2 + 1 + 3) bytes for x32. | 500 // (3 + 1 + 3) for x64 and at least 6 (2 + 1 + 3) bytes for x32. |
| 477 const int kPadding = Assembler::kJSReturnSequenceLength - | 501 const int kPadding = Assembler::kJSReturnSequenceLength - |
| 478 kPointerSize == kInt64Size ? 7 : 6; | 502 kPointerSize == kInt64Size ? 7 : 6; |
| (...skipping 5002 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5481 Assembler::target_address_at(call_target_address, | 5505 Assembler::target_address_at(call_target_address, |
| 5482 unoptimized_code)); | 5506 unoptimized_code)); |
| 5483 return OSR_AFTER_STACK_CHECK; | 5507 return OSR_AFTER_STACK_CHECK; |
| 5484 } | 5508 } |
| 5485 | 5509 |
| 5486 | 5510 |
| 5487 } // namespace internal | 5511 } // namespace internal |
| 5488 } // namespace v8 | 5512 } // namespace v8 |
| 5489 | 5513 |
| 5490 #endif // V8_TARGET_ARCH_X64 | 5514 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |