| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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_PPC | 5 #if V8_TARGET_ARCH_PPC |
| 6 | 6 |
| 7 #include "src/codegen.h" | 7 #include "src/codegen.h" |
| 8 #include "src/debug/debug.h" | 8 #include "src/debug/debug.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" |
| (...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 | 553 |
| 554 __ bind(&ok); | 554 __ bind(&ok); |
| 555 GenerateTailCallToSharedCode(masm); | 555 GenerateTailCallToSharedCode(masm); |
| 556 } | 556 } |
| 557 | 557 |
| 558 namespace { | 558 namespace { |
| 559 | 559 |
| 560 void Generate_JSConstructStubHelper(MacroAssembler* masm, bool is_api_function, | 560 void Generate_JSConstructStubHelper(MacroAssembler* masm, bool is_api_function, |
| 561 bool create_implicit_receiver, | 561 bool create_implicit_receiver, |
| 562 bool check_derived_construct) { | 562 bool check_derived_construct) { |
| 563 Label post_instantiation_deopt_entry; |
| 563 // ----------- S t a t e ------------- | 564 // ----------- S t a t e ------------- |
| 564 // -- r3 : number of arguments | 565 // -- r3 : number of arguments |
| 565 // -- r4 : constructor function | 566 // -- r4 : constructor function |
| 566 // -- r6 : new target | 567 // -- r6 : new target |
| 567 // -- cp : context | 568 // -- cp : context |
| 568 // -- lr : return address | 569 // -- lr : return address |
| 569 // -- sp[...]: constructor arguments | 570 // -- sp[...]: constructor arguments |
| 570 // ----------------------------------- | 571 // ----------------------------------- |
| 571 | 572 |
| 572 Isolate* isolate = masm->isolate(); | 573 Isolate* isolate = masm->isolate(); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 601 // Retrieve smi-tagged arguments count from the stack. | 602 // Retrieve smi-tagged arguments count from the stack. |
| 602 __ LoadP(r3, MemOperand(sp)); | 603 __ LoadP(r3, MemOperand(sp)); |
| 603 __ SmiUntag(r3, SetRC); | 604 __ SmiUntag(r3, SetRC); |
| 604 | 605 |
| 605 // Push the allocated receiver to the stack. We need two copies | 606 // Push the allocated receiver to the stack. We need two copies |
| 606 // because we may have to return the original one and the calling | 607 // because we may have to return the original one and the calling |
| 607 // conventions dictate that the called function pops the receiver. | 608 // conventions dictate that the called function pops the receiver. |
| 608 __ Push(r7, r7); | 609 __ Push(r7, r7); |
| 609 } | 610 } |
| 610 | 611 |
| 612 // Deoptimizer re-enters stub code here. |
| 613 __ bind(&post_instantiation_deopt_entry); |
| 614 |
| 611 // Set up pointer to last argument. | 615 // Set up pointer to last argument. |
| 612 __ addi(r5, fp, Operand(StandardFrameConstants::kCallerSPOffset)); | 616 __ addi(r5, fp, Operand(StandardFrameConstants::kCallerSPOffset)); |
| 613 | 617 |
| 614 // Copy arguments and receiver to the expression stack. | 618 // Copy arguments and receiver to the expression stack. |
| 615 // r3: number of arguments | 619 // r3: number of arguments |
| 616 // r4: constructor function | 620 // r4: constructor function |
| 617 // r5: address of last argument (caller sp) | 621 // r5: address of last argument (caller sp) |
| 618 // r6: new target | 622 // r6: new target |
| 619 // cr0: condition indicating whether r3 is zero | 623 // cr0: condition indicating whether r3 is zero |
| 620 // sp[0]: receiver | 624 // sp[0]: receiver |
| (...skipping 15 matching lines...) Expand all Loading... |
| 636 // r3: number of arguments | 640 // r3: number of arguments |
| 637 // r4: constructor function | 641 // r4: constructor function |
| 638 // r6: new target | 642 // r6: new target |
| 639 | 643 |
| 640 ParameterCount actual(r3); | 644 ParameterCount actual(r3); |
| 641 __ InvokeFunction(r4, r6, actual, CALL_FUNCTION, | 645 __ InvokeFunction(r4, r6, actual, CALL_FUNCTION, |
| 642 CheckDebugStepCallWrapper()); | 646 CheckDebugStepCallWrapper()); |
| 643 | 647 |
| 644 // Store offset of return address for deoptimizer. | 648 // Store offset of return address for deoptimizer. |
| 645 if (create_implicit_receiver && !is_api_function) { | 649 if (create_implicit_receiver && !is_api_function) { |
| 646 masm->isolate()->heap()->SetConstructStubDeoptPCOffset(masm->pc_offset()); | 650 masm->isolate()->heap()->SetConstructStubInvokeDeoptPCOffset( |
| 651 masm->pc_offset()); |
| 647 } | 652 } |
| 648 | 653 |
| 649 // Restore context from the frame. | 654 // Restore context from the frame. |
| 650 // r3: result | 655 // r3: result |
| 651 // sp[0]: receiver | 656 // sp[0]: receiver |
| 652 // sp[1]: number of arguments (smi-tagged) | 657 // sp[1]: number of arguments (smi-tagged) |
| 653 __ LoadP(cp, MemOperand(fp, ConstructFrameConstants::kContextOffset)); | 658 __ LoadP(cp, MemOperand(fp, ConstructFrameConstants::kContextOffset)); |
| 654 | 659 |
| 655 if (create_implicit_receiver) { | 660 if (create_implicit_receiver) { |
| 656 // If the result is an object (in the ECMA sense), we should get rid | 661 // If the result is an object (in the ECMA sense), we should get rid |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 701 __ bind(&dont_throw); | 706 __ bind(&dont_throw); |
| 702 } | 707 } |
| 703 | 708 |
| 704 __ SmiToPtrArrayOffset(r4, r4); | 709 __ SmiToPtrArrayOffset(r4, r4); |
| 705 __ add(sp, sp, r4); | 710 __ add(sp, sp, r4); |
| 706 __ addi(sp, sp, Operand(kPointerSize)); | 711 __ addi(sp, sp, Operand(kPointerSize)); |
| 707 if (create_implicit_receiver) { | 712 if (create_implicit_receiver) { |
| 708 __ IncrementCounter(isolate->counters()->constructed_objects(), 1, r4, r5); | 713 __ IncrementCounter(isolate->counters()->constructed_objects(), 1, r4, r5); |
| 709 } | 714 } |
| 710 __ blr(); | 715 __ blr(); |
| 716 // Store offset of trampoline address for deoptimizer. This is the bailout |
| 717 // point after the receiver instantiation but before the function invocation. |
| 718 // We need to restore some registers in order to continue the above code. |
| 719 if (create_implicit_receiver && !is_api_function) { |
| 720 masm->isolate()->heap()->SetConstructStubCreateDeoptPCOffset( |
| 721 masm->pc_offset()); |
| 722 |
| 723 // ----------- S t a t e ------------- |
| 724 // -- r3 : newly allocated object |
| 725 // -- sp[0] : constructor function |
| 726 // ----------------------------------- |
| 727 |
| 728 __ pop(r4); |
| 729 __ Push(r3, r3); |
| 730 |
| 731 // Retrieve smi-tagged arguments count from the stack. |
| 732 __ LoadP(r3, MemOperand(fp, ConstructFrameConstants::kLengthOffset)); |
| 733 __ SmiUntag(r3); |
| 734 |
| 735 // Retrieve the new target value from the stack. This was placed into the |
| 736 // frame description in place of the receiver by the optimizing compiler. |
| 737 __ addi(r6, fp, Operand(StandardFrameConstants::kCallerSPOffset)); |
| 738 __ ShiftLeftImm(ip, r3, Operand(kPointerSizeLog2)); |
| 739 __ LoadPX(r6, MemOperand(r6, ip)); |
| 740 |
| 741 // Continue with constructor function invocation. |
| 742 __ b(&post_instantiation_deopt_entry); |
| 743 } |
| 711 } | 744 } |
| 712 | 745 |
| 713 } // namespace | 746 } // namespace |
| 714 | 747 |
| 715 void Builtins::Generate_JSConstructStubGeneric(MacroAssembler* masm) { | 748 void Builtins::Generate_JSConstructStubGeneric(MacroAssembler* masm) { |
| 716 Generate_JSConstructStubHelper(masm, false, true, false); | 749 Generate_JSConstructStubHelper(masm, false, true, false); |
| 717 } | 750 } |
| 718 | 751 |
| 719 void Builtins::Generate_JSConstructStubApi(MacroAssembler* masm) { | 752 void Builtins::Generate_JSConstructStubApi(MacroAssembler* masm) { |
| 720 Generate_JSConstructStubHelper(masm, true, false, false); | 753 Generate_JSConstructStubHelper(masm, true, false, false); |
| (...skipping 2477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3198 __ CallRuntime(Runtime::kThrowStackOverflow); | 3231 __ CallRuntime(Runtime::kThrowStackOverflow); |
| 3199 __ bkpt(0); | 3232 __ bkpt(0); |
| 3200 } | 3233 } |
| 3201 } | 3234 } |
| 3202 | 3235 |
| 3203 #undef __ | 3236 #undef __ |
| 3204 } // namespace internal | 3237 } // namespace internal |
| 3205 } // namespace v8 | 3238 } // namespace v8 |
| 3206 | 3239 |
| 3207 #endif // V8_TARGET_ARCH_PPC | 3240 #endif // V8_TARGET_ARCH_PPC |
| OLD | NEW |