| 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 #if V8_TARGET_ARCH_X64 | 5 #if V8_TARGET_ARCH_X64 |
| 6 | 6 |
| 7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
| 8 #include "src/codegen.h" | 8 #include "src/codegen.h" |
| 9 #include "src/deoptimizer.h" | 9 #include "src/deoptimizer.h" |
| 10 #include "src/full-codegen/full-codegen.h" | 10 #include "src/full-codegen/full-codegen.h" |
| 11 | 11 |
| 12 namespace v8 { | 12 namespace v8 { |
| 13 namespace internal { | 13 namespace internal { |
| 14 | 14 |
| 15 | 15 |
| 16 #define __ ACCESS_MASM(masm) | 16 #define __ ACCESS_MASM(masm) |
| 17 | 17 |
| 18 | 18 |
| 19 void Builtins::Generate_Adaptor(MacroAssembler* masm, | 19 void Builtins::Generate_Adaptor(MacroAssembler* masm, |
| 20 CFunctionId id, | 20 CFunctionId id, |
| 21 BuiltinExtraArguments extra_args) { | 21 BuiltinExtraArguments extra_args) { |
| 22 // ----------- S t a t e ------------- | 22 // ----------- S t a t e ------------- |
| 23 // -- rax : number of arguments excluding receiver | 23 // -- rax : number of arguments excluding receiver |
| 24 // -- rdi : called function (only guaranteed when | 24 // -- rdi : called function (only guaranteed when |
| 25 // extra_args requires it) | 25 // extra_args requires it) |
| 26 // -- rsi : context | |
| 27 // -- rsp[0] : return address | 26 // -- rsp[0] : return address |
| 28 // -- rsp[8] : last argument | 27 // -- rsp[8] : last argument |
| 29 // -- ... | 28 // -- ... |
| 30 // -- rsp[8 * argc] : first argument (argc == rax) | 29 // -- rsp[8 * argc] : first argument (argc == rax) |
| 31 // -- rsp[8 * (argc + 1)] : receiver | 30 // -- rsp[8 * (argc + 1)] : receiver |
| 32 // ----------------------------------- | 31 // ----------------------------------- |
| 32 __ AssertFunction(rdi); |
| 33 |
| 34 // Make sure we operate in the context of the called function (for example |
| 35 // ConstructStubs implemented in C++ will be run in the context of the caller |
| 36 // instead of the callee, due to the way that [[Construct]] is defined for |
| 37 // ordinary functions). |
| 38 // TODO(bmeurer): Can we make this more robust? |
| 39 __ movp(rsi, FieldOperand(rdi, JSFunction::kContextOffset)); |
| 33 | 40 |
| 34 // Insert extra arguments. | 41 // Insert extra arguments. |
| 35 int num_extra_args = 0; | 42 int num_extra_args = 0; |
| 36 if (extra_args == NEEDS_CALLED_FUNCTION) { | 43 if (extra_args == NEEDS_CALLED_FUNCTION) { |
| 37 num_extra_args = 1; | 44 num_extra_args = 1; |
| 38 __ PopReturnAddressTo(kScratchRegister); | 45 __ PopReturnAddressTo(kScratchRegister); |
| 39 __ Push(rdi); | 46 __ Push(rdi); |
| 40 __ PushReturnAddressFrom(kScratchRegister); | 47 __ PushReturnAddressFrom(kScratchRegister); |
| 41 } else { | 48 } else { |
| 42 DCHECK(extra_args == NO_EXTRA_ARGUMENTS); | 49 DCHECK(extra_args == NO_EXTRA_ARGUMENTS); |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 SmiIndex index = masm->SmiToIndex(rbx, rbx, kPointerSizeLog2); | 441 SmiIndex index = masm->SmiToIndex(rbx, rbx, kPointerSizeLog2); |
| 435 __ leap(rsp, Operand(rsp, index.reg, index.scale, 1 * kPointerSize)); | 442 __ leap(rsp, Operand(rsp, index.reg, index.scale, 1 * kPointerSize)); |
| 436 __ PushReturnAddressFrom(rcx); | 443 __ PushReturnAddressFrom(rcx); |
| 437 __ ret(0); | 444 __ ret(0); |
| 438 } | 445 } |
| 439 | 446 |
| 440 | 447 |
| 441 enum IsTagged { kRaxIsSmiTagged, kRaxIsUntaggedInt }; | 448 enum IsTagged { kRaxIsSmiTagged, kRaxIsUntaggedInt }; |
| 442 | 449 |
| 443 | 450 |
| 444 // Clobbers rcx, rdx, kScratchRegister; preserves all other registers. | 451 // Clobbers rcx, r11, kScratchRegister; preserves all other registers. |
| 445 static void Generate_CheckStackOverflow(MacroAssembler* masm, | 452 static void Generate_CheckStackOverflow(MacroAssembler* masm, |
| 446 const int calleeOffset, | 453 const int calleeOffset, |
| 447 IsTagged rax_is_tagged) { | 454 IsTagged rax_is_tagged) { |
| 448 // rax : the number of items to be pushed to the stack | 455 // rax : the number of items to be pushed to the stack |
| 449 // | 456 // |
| 450 // Check the stack for overflow. We are not trying to catch | 457 // Check the stack for overflow. We are not trying to catch |
| 451 // interruptions (e.g. debug break and preemption) here, so the "real stack | 458 // interruptions (e.g. debug break and preemption) here, so the "real stack |
| 452 // limit" is checked. | 459 // limit" is checked. |
| 453 Label okay; | 460 Label okay; |
| 454 __ LoadRoot(kScratchRegister, Heap::kRealStackLimitRootIndex); | 461 __ LoadRoot(kScratchRegister, Heap::kRealStackLimitRootIndex); |
| 455 __ movp(rcx, rsp); | 462 __ movp(rcx, rsp); |
| 456 // Make rcx the space we have left. The stack might already be overflowed | 463 // Make rcx the space we have left. The stack might already be overflowed |
| 457 // here which will cause rcx to become negative. | 464 // here which will cause rcx to become negative. |
| 458 __ subp(rcx, kScratchRegister); | 465 __ subp(rcx, kScratchRegister); |
| 459 // Make rdx the space we need for the array when it is unrolled onto the | 466 // Make r11 the space we need for the array when it is unrolled onto the |
| 460 // stack. | 467 // stack. |
| 461 if (rax_is_tagged == kRaxIsSmiTagged) { | 468 if (rax_is_tagged == kRaxIsSmiTagged) { |
| 462 __ PositiveSmiTimesPowerOfTwoToInteger64(rdx, rax, kPointerSizeLog2); | 469 __ PositiveSmiTimesPowerOfTwoToInteger64(r11, rax, kPointerSizeLog2); |
| 463 } else { | 470 } else { |
| 464 DCHECK(rax_is_tagged == kRaxIsUntaggedInt); | 471 DCHECK(rax_is_tagged == kRaxIsUntaggedInt); |
| 465 __ movp(rdx, rax); | 472 __ movp(r11, rax); |
| 466 __ shlq(rdx, Immediate(kPointerSizeLog2)); | 473 __ shlq(r11, Immediate(kPointerSizeLog2)); |
| 467 } | 474 } |
| 468 // Check if the arguments will overflow the stack. | 475 // Check if the arguments will overflow the stack. |
| 469 __ cmpp(rcx, rdx); | 476 __ cmpp(rcx, r11); |
| 470 __ j(greater, &okay); // Signed comparison. | 477 __ j(greater, &okay); // Signed comparison. |
| 471 | 478 |
| 472 // Out of stack space. | 479 // Out of stack space. |
| 473 __ Push(Operand(rbp, calleeOffset)); | 480 __ Push(Operand(rbp, calleeOffset)); |
| 474 if (rax_is_tagged == kRaxIsUntaggedInt) { | 481 if (rax_is_tagged == kRaxIsUntaggedInt) { |
| 475 __ Integer32ToSmi(rax, rax); | 482 __ Integer32ToSmi(rax, rax); |
| 476 } | 483 } |
| 477 __ Push(rax); | 484 __ Push(rax); |
| 478 __ CallRuntime(Runtime::kThrowStackOverflow, 0); | 485 __ CallRuntime(Runtime::kThrowStackOverflow, 0); |
| 479 | 486 |
| 480 __ bind(&okay); | 487 __ bind(&okay); |
| 481 } | 488 } |
| 482 | 489 |
| 483 | 490 |
| 484 static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm, | 491 static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm, |
| 485 bool is_construct) { | 492 bool is_construct) { |
| 486 ProfileEntryHookStub::MaybeCallEntryHook(masm); | 493 ProfileEntryHookStub::MaybeCallEntryHook(masm); |
| 487 | 494 |
| 488 // Expects five C++ function parameters. | 495 // Expects five C++ function parameters. |
| 489 // - Address entry (ignored) | 496 // - Object* new_target |
| 490 // - JSFunction* function ( | 497 // - JSFunction* function |
| 491 // - Object* receiver | 498 // - Object* receiver |
| 492 // - int argc | 499 // - int argc |
| 493 // - Object*** argv | 500 // - Object*** argv |
| 494 // (see Handle::Invoke in execution.cc). | 501 // (see Handle::Invoke in execution.cc). |
| 495 | 502 |
| 496 // Open a C++ scope for the FrameScope. | 503 // Open a C++ scope for the FrameScope. |
| 497 { | 504 { |
| 498 // Platform specific argument handling. After this, the stack contains | 505 // Platform specific argument handling. After this, the stack contains |
| 499 // an internal frame and the pushed function and receiver, and | 506 // an internal frame and the pushed function and receiver, and |
| 500 // register rax and rbx holds the argument count and argument array, | 507 // register rax and rbx holds the argument count and argument array, |
| 501 // while rdi holds the function pointer and rsi the context. | 508 // while rdi holds the function pointer, rsi the context, and rdx the |
| 509 // new.target. |
| 502 | 510 |
| 503 #ifdef _WIN64 | 511 #ifdef _WIN64 |
| 504 // MSVC parameters in: | 512 // MSVC parameters in: |
| 505 // rcx : entry (ignored) | 513 // rcx : new_target |
| 506 // rdx : function | 514 // rdx : function |
| 507 // r8 : receiver | 515 // r8 : receiver |
| 508 // r9 : argc | 516 // r9 : argc |
| 509 // [rsp+0x20] : argv | 517 // [rsp+0x20] : argv |
| 510 | 518 |
| 511 // Clear the context before we push it when entering the internal frame. | 519 // Clear the context before we push it when entering the internal frame. |
| 512 __ Set(rsi, 0); | 520 __ Set(rsi, 0); |
| 521 |
| 513 // Enter an internal frame. | 522 // Enter an internal frame. |
| 514 FrameScope scope(masm, StackFrame::INTERNAL); | 523 FrameScope scope(masm, StackFrame::INTERNAL); |
| 515 | 524 |
| 516 // Load the function context into rsi. | 525 // Setup the context (we need to use the caller context from the isolate). |
| 517 __ movp(rsi, FieldOperand(rdx, JSFunction::kContextOffset)); | 526 ExternalReference context_address(Isolate::kContextAddress, |
| 527 masm->isolate()); |
| 528 __ movp(rsi, masm->ExternalOperand(context_address)); |
| 518 | 529 |
| 519 // Push the function and the receiver onto the stack. | 530 // Push the function and the receiver onto the stack. |
| 520 __ Push(rdx); | 531 __ Push(rdx); |
| 521 __ Push(r8); | 532 __ Push(r8); |
| 522 | 533 |
| 523 // Load the number of arguments and setup pointer to the arguments. | 534 // Load the number of arguments and setup pointer to the arguments. |
| 524 __ movp(rax, r9); | 535 __ movp(rax, r9); |
| 525 // Load the previous frame pointer to access C argument on stack | 536 // Load the previous frame pointer to access C argument on stack |
| 526 __ movp(kScratchRegister, Operand(rbp, 0)); | 537 __ movp(kScratchRegister, Operand(rbp, 0)); |
| 527 __ movp(rbx, Operand(kScratchRegister, EntryFrameConstants::kArgvOffset)); | 538 __ movp(rbx, Operand(kScratchRegister, EntryFrameConstants::kArgvOffset)); |
| 528 // Load the function pointer into rdi. | 539 // Load the function pointer into rdi. |
| 529 __ movp(rdi, rdx); | 540 __ movp(rdi, rdx); |
| 541 // Load the new.target into rdx. |
| 542 __ movp(rdx, rcx); |
| 530 #else // _WIN64 | 543 #else // _WIN64 |
| 531 // GCC parameters in: | 544 // GCC parameters in: |
| 532 // rdi : entry (ignored) | 545 // rdi : new_target |
| 533 // rsi : function | 546 // rsi : function |
| 534 // rdx : receiver | 547 // rdx : receiver |
| 535 // rcx : argc | 548 // rcx : argc |
| 536 // r8 : argv | 549 // r8 : argv |
| 537 | 550 |
| 551 __ movp(r11, rdi); |
| 538 __ movp(rdi, rsi); | 552 __ movp(rdi, rsi); |
| 539 // rdi : function | 553 // rdi : function |
| 554 // r11 : new_target |
| 540 | 555 |
| 541 // Clear the context before we push it when entering the internal frame. | 556 // Clear the context before we push it when entering the internal frame. |
| 542 __ Set(rsi, 0); | 557 __ Set(rsi, 0); |
| 558 |
| 543 // Enter an internal frame. | 559 // Enter an internal frame. |
| 544 FrameScope scope(masm, StackFrame::INTERNAL); | 560 FrameScope scope(masm, StackFrame::INTERNAL); |
| 545 | 561 |
| 546 // Push the function and receiver and setup the context. | 562 // Setup the context (we need to use the caller context from the isolate). |
| 563 ExternalReference context_address(Isolate::kContextAddress, |
| 564 masm->isolate()); |
| 565 __ movp(rsi, masm->ExternalOperand(context_address)); |
| 566 |
| 567 // Push the function and receiver onto the stack. |
| 547 __ Push(rdi); | 568 __ Push(rdi); |
| 548 __ Push(rdx); | 569 __ Push(rdx); |
| 549 __ movp(rsi, FieldOperand(rdi, JSFunction::kContextOffset)); | |
| 550 | 570 |
| 551 // Load the number of arguments and setup pointer to the arguments. | 571 // Load the number of arguments and setup pointer to the arguments. |
| 552 __ movp(rax, rcx); | 572 __ movp(rax, rcx); |
| 553 __ movp(rbx, r8); | 573 __ movp(rbx, r8); |
| 574 |
| 575 // Load the new.target into rdx. |
| 576 __ movp(rdx, r11); |
| 554 #endif // _WIN64 | 577 #endif // _WIN64 |
| 555 | 578 |
| 556 // Current stack contents: | 579 // Current stack contents: |
| 557 // [rsp + 2 * kPointerSize ... ] : Internal frame | 580 // [rsp + 2 * kPointerSize ... ] : Internal frame |
| 558 // [rsp + kPointerSize] : function | 581 // [rsp + kPointerSize] : function |
| 559 // [rsp] : receiver | 582 // [rsp] : receiver |
| 560 // Current register contents: | 583 // Current register contents: |
| 561 // rax : argc | 584 // rax : argc |
| 562 // rbx : argv | 585 // rbx : argv |
| 563 // rsi : context | 586 // rsi : context |
| 564 // rdi : function | 587 // rdi : function |
| 588 // rdx : new.target |
| 565 | 589 |
| 566 // Check if we have enough stack space to push all arguments. | 590 // Check if we have enough stack space to push all arguments. |
| 567 // The function is the first thing that was pushed above after entering | 591 // The function is the first thing that was pushed above after entering |
| 568 // the internal frame. | 592 // the internal frame. |
| 569 const int kFunctionOffset = | 593 const int kFunctionOffset = |
| 570 InternalFrameConstants::kCodeOffset - kRegisterSize; | 594 InternalFrameConstants::kCodeOffset - kRegisterSize; |
| 571 // Expects argument count in rax. Clobbers rcx, rdx. | 595 // Expects argument count in rax. Clobbers rcx, r11. |
| 572 Generate_CheckStackOverflow(masm, kFunctionOffset, kRaxIsUntaggedInt); | 596 Generate_CheckStackOverflow(masm, kFunctionOffset, kRaxIsUntaggedInt); |
| 573 | 597 |
| 574 // Copy arguments to the stack in a loop. | 598 // Copy arguments to the stack in a loop. |
| 575 // Register rbx points to array of pointers to handle locations. | 599 // Register rbx points to array of pointers to handle locations. |
| 576 // Push the values of these handles. | 600 // Push the values of these handles. |
| 577 Label loop, entry; | 601 Label loop, entry; |
| 578 __ Set(rcx, 0); // Set loop variable to 0. | 602 __ Set(rcx, 0); // Set loop variable to 0. |
| 579 __ jmp(&entry); | 603 __ jmp(&entry, Label::kNear); |
| 580 __ bind(&loop); | 604 __ bind(&loop); |
| 581 __ movp(kScratchRegister, Operand(rbx, rcx, times_pointer_size, 0)); | 605 __ movp(kScratchRegister, Operand(rbx, rcx, times_pointer_size, 0)); |
| 582 __ Push(Operand(kScratchRegister, 0)); // dereference handle | 606 __ Push(Operand(kScratchRegister, 0)); // dereference handle |
| 583 __ addp(rcx, Immediate(1)); | 607 __ addp(rcx, Immediate(1)); |
| 584 __ bind(&entry); | 608 __ bind(&entry); |
| 585 __ cmpp(rcx, rax); | 609 __ cmpp(rcx, rax); |
| 586 __ j(not_equal, &loop); | 610 __ j(not_equal, &loop); |
| 587 | 611 |
| 588 // Invoke the code. | 612 // Invoke the builtin code. |
| 589 if (is_construct) { | 613 Handle<Code> builtin = is_construct |
| 590 // No type feedback cell is available | 614 ? masm->isolate()->builtins()->Construct() |
| 591 __ LoadRoot(rbx, Heap::kUndefinedValueRootIndex); | 615 : masm->isolate()->builtins()->Call(); |
| 592 // Expects rdi to hold function pointer. | 616 __ Call(builtin, RelocInfo::CODE_TARGET); |
| 593 CallConstructStub stub(masm->isolate(), NO_CALL_CONSTRUCTOR_FLAGS); | 617 |
| 594 __ CallStub(&stub); | |
| 595 } else { | |
| 596 __ Call(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); | |
| 597 } | |
| 598 // Exit the internal frame. Notice that this also removes the empty | 618 // Exit the internal frame. Notice that this also removes the empty |
| 599 // context and the function left on the stack by the code | 619 // context and the function left on the stack by the code |
| 600 // invocation. | 620 // invocation. |
| 601 } | 621 } |
| 602 | 622 |
| 603 // TODO(X64): Is argument correct? Is there a receiver to remove? | 623 // TODO(X64): Is argument correct? Is there a receiver to remove? |
| 604 __ ret(1 * kPointerSize); // Remove receiver. | 624 __ ret(1 * kPointerSize); // Remove receiver. |
| 605 } | 625 } |
| 606 | 626 |
| 607 | 627 |
| (...skipping 1080 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1688 ParameterCount actual(rax); | 1708 ParameterCount actual(rax); |
| 1689 ParameterCount expected(rbx); | 1709 ParameterCount expected(rbx); |
| 1690 __ InvokeCode(rdx, expected, actual, JUMP_FUNCTION, NullCallWrapper()); | 1710 __ InvokeCode(rdx, expected, actual, JUMP_FUNCTION, NullCallWrapper()); |
| 1691 } | 1711 } |
| 1692 | 1712 |
| 1693 | 1713 |
| 1694 // static | 1714 // static |
| 1695 void Builtins::Generate_Call(MacroAssembler* masm) { | 1715 void Builtins::Generate_Call(MacroAssembler* masm) { |
| 1696 // ----------- S t a t e ------------- | 1716 // ----------- S t a t e ------------- |
| 1697 // -- rax : the number of arguments (not including the receiver) | 1717 // -- rax : the number of arguments (not including the receiver) |
| 1698 // -- rdi : the target to call (can be any Object). | 1718 // -- rdi : the target to call (can be any Object) |
| 1699 // ----------------------------------- | 1719 // ----------------------------------- |
| 1700 | 1720 |
| 1701 Label non_smi, non_function; | 1721 Label non_smi, non_function; |
| 1702 __ JumpIfSmi(rdi, &non_function); | 1722 __ JumpIfSmi(rdi, &non_function); |
| 1703 __ bind(&non_smi); | 1723 __ bind(&non_smi); |
| 1704 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, rdx); | 1724 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, rdx); |
| 1705 __ j(equal, masm->isolate()->builtins()->CallFunction(), | 1725 __ j(equal, masm->isolate()->builtins()->CallFunction(), |
| 1706 RelocInfo::CODE_TARGET); | 1726 RelocInfo::CODE_TARGET); |
| 1707 __ CmpInstanceType(rdx, JS_FUNCTION_PROXY_TYPE); | 1727 __ CmpInstanceType(rdx, JS_FUNCTION_PROXY_TYPE); |
| 1708 __ j(not_equal, &non_function); | 1728 __ j(not_equal, &non_function); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1736 __ Pop(rax); | 1756 __ Pop(rax); |
| 1737 __ SmiToInteger32(rax, rax); | 1757 __ SmiToInteger32(rax, rax); |
| 1738 } | 1758 } |
| 1739 // The delegate is always a regular function. | 1759 // The delegate is always a regular function. |
| 1740 __ AssertFunction(rdi); | 1760 __ AssertFunction(rdi); |
| 1741 __ Jump(masm->isolate()->builtins()->CallFunction(), RelocInfo::CODE_TARGET); | 1761 __ Jump(masm->isolate()->builtins()->CallFunction(), RelocInfo::CODE_TARGET); |
| 1742 } | 1762 } |
| 1743 | 1763 |
| 1744 | 1764 |
| 1745 // static | 1765 // static |
| 1766 void Builtins::Generate_ConstructFunction(MacroAssembler* masm) { |
| 1767 // ----------- S t a t e ------------- |
| 1768 // -- rax : the number of arguments (not including the receiver) |
| 1769 // -- rdx : the original constructor (checked to be a JSFunction) |
| 1770 // -- rdi : the constructor to call (checked to be a JSFunction) |
| 1771 // ----------------------------------- |
| 1772 __ AssertFunction(rdx); |
| 1773 __ AssertFunction(rdi); |
| 1774 |
| 1775 // Calling convention for function specific ConstructStubs require |
| 1776 // rbx to contain either an AllocationSite or undefined. |
| 1777 __ LoadRoot(rbx, Heap::kUndefinedValueRootIndex); |
| 1778 |
| 1779 // Tail call to the function-specific construct stub (still in the caller |
| 1780 // context at this point). |
| 1781 __ movp(rcx, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset)); |
| 1782 __ movp(rcx, FieldOperand(rcx, SharedFunctionInfo::kConstructStubOffset)); |
| 1783 __ leap(rcx, FieldOperand(rcx, Code::kHeaderSize)); |
| 1784 __ jmp(rcx); |
| 1785 } |
| 1786 |
| 1787 |
| 1788 // static |
| 1789 void Builtins::Generate_Construct(MacroAssembler* masm) { |
| 1790 // ----------- S t a t e ------------- |
| 1791 // -- rax : the number of arguments (not including the receiver) |
| 1792 // -- rdx : the original constructor (either the same as the constructor or |
| 1793 // the JSFunction on which new was invoked initially) |
| 1794 // -- rdi : the constructor to call (can be any Object) |
| 1795 // ----------------------------------- |
| 1796 |
| 1797 Label slow; |
| 1798 __ JumpIfSmi(rdi, &slow, Label::kNear); |
| 1799 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, rcx); |
| 1800 __ j(equal, masm->isolate()->builtins()->ConstructFunction(), |
| 1801 RelocInfo::CODE_TARGET); |
| 1802 __ CmpInstanceType(rcx, JS_FUNCTION_PROXY_TYPE); |
| 1803 __ j(not_equal, &slow, Label::kNear); |
| 1804 |
| 1805 // TODO(neis): This doesn't match the ES6 spec for [[Construct]] on proxies. |
| 1806 __ movp(rdi, FieldOperand(rdi, JSFunctionProxy::kConstructTrapOffset)); |
| 1807 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); |
| 1808 |
| 1809 __ bind(&slow); |
| 1810 { |
| 1811 // Determine the delegate for the target (if any). |
| 1812 FrameScope scope(masm, StackFrame::INTERNAL); |
| 1813 __ Integer32ToSmi(rax, rax); |
| 1814 __ Push(rax); |
| 1815 __ Push(rdi); |
| 1816 __ CallRuntime(Runtime::kGetConstructorDelegate, 1); |
| 1817 __ movp(rdi, rax); |
| 1818 __ Pop(rax); |
| 1819 __ SmiToInteger32(rax, rax); |
| 1820 } |
| 1821 // The delegate is always a regular function. |
| 1822 __ AssertFunction(rdi); |
| 1823 __ Jump(masm->isolate()->builtins()->CallFunction(), RelocInfo::CODE_TARGET); |
| 1824 } |
| 1825 |
| 1826 |
| 1827 // static |
| 1746 void Builtins::Generate_PushArgsAndCall(MacroAssembler* masm) { | 1828 void Builtins::Generate_PushArgsAndCall(MacroAssembler* masm) { |
| 1747 // ----------- S t a t e ------------- | 1829 // ----------- S t a t e ------------- |
| 1748 // -- rax : the number of arguments (not including the receiver) | 1830 // -- rax : the number of arguments (not including the receiver) |
| 1749 // -- rbx : the address of the first argument to be pushed. Subsequent | 1831 // -- rbx : the address of the first argument to be pushed. Subsequent |
| 1750 // arguments should be consecutive above this, in the same order as | 1832 // arguments should be consecutive above this, in the same order as |
| 1751 // they are to be pushed onto the stack. | 1833 // they are to be pushed onto the stack. |
| 1752 // -- rdi : the target to call (can be any Object). | 1834 // -- rdi : the target to call (can be any Object). |
| 1753 | 1835 |
| 1754 // Pop return address to allow tail-call after pushing arguments. | 1836 // Pop return address to allow tail-call after pushing arguments. |
| 1755 __ Pop(rdx); | 1837 __ Pop(rdx); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1829 __ ret(0); | 1911 __ ret(0); |
| 1830 } | 1912 } |
| 1831 | 1913 |
| 1832 | 1914 |
| 1833 #undef __ | 1915 #undef __ |
| 1834 | 1916 |
| 1835 } // namespace internal | 1917 } // namespace internal |
| 1836 } // namespace v8 | 1918 } // namespace v8 |
| 1837 | 1919 |
| 1838 #endif // V8_TARGET_ARCH_X64 | 1920 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |