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 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_PPC | 7 #if V8_TARGET_ARCH_PPC |
8 | 8 |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
(...skipping 2770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2781 | 2781 |
2782 void CallFunctionStub::Generate(MacroAssembler* masm) { | 2782 void CallFunctionStub::Generate(MacroAssembler* masm) { |
2783 CallFunctionNoFeedback(masm, argc(), NeedsChecks(), CallAsMethod()); | 2783 CallFunctionNoFeedback(masm, argc(), NeedsChecks(), CallAsMethod()); |
2784 } | 2784 } |
2785 | 2785 |
2786 | 2786 |
2787 void CallConstructStub::Generate(MacroAssembler* masm) { | 2787 void CallConstructStub::Generate(MacroAssembler* masm) { |
2788 // r3 : number of arguments | 2788 // r3 : number of arguments |
2789 // r4 : the function to call | 2789 // r4 : the function to call |
2790 // r5 : feedback vector | 2790 // r5 : feedback vector |
2791 // r6 : (only if r5 is not the megamorphic symbol) slot in feedback | 2791 // r6 : slot in feedback vector (Smi, for RecordCallTarget) |
2792 // vector (Smi) | 2792 // r7 : original constructor (for IsSuperConstructorCall) |
2793 Label slow, non_function_call; | 2793 Label slow, non_function_call; |
2794 | 2794 |
2795 // Check that the function is not a smi. | 2795 // Check that the function is not a smi. |
2796 __ JumpIfSmi(r4, &non_function_call); | 2796 __ JumpIfSmi(r4, &non_function_call); |
2797 // Check that the function is a JSFunction. | 2797 // Check that the function is a JSFunction. |
2798 __ CompareObjectType(r4, r7, r7, JS_FUNCTION_TYPE); | 2798 __ CompareObjectType(r4, r8, r8, JS_FUNCTION_TYPE); |
2799 __ bne(&slow); | 2799 __ bne(&slow); |
2800 | 2800 |
2801 if (RecordCallTarget()) { | 2801 if (RecordCallTarget()) { |
| 2802 if (IsSuperConstructorCall()) { |
| 2803 __ push(r7); |
| 2804 } |
| 2805 // TODO(mstarzinger): Consider tweaking target recording to avoid push/pop. |
2802 GenerateRecordCallTarget(masm); | 2806 GenerateRecordCallTarget(masm); |
| 2807 if (IsSuperConstructorCall()) { |
| 2808 __ pop(r7); |
| 2809 } |
2803 | 2810 |
2804 __ SmiToPtrArrayOffset(r8, r6); | 2811 __ SmiToPtrArrayOffset(r8, r6); |
2805 __ add(r8, r5, r8); | 2812 __ add(r8, r5, r8); |
2806 if (FLAG_pretenuring_call_new) { | 2813 if (FLAG_pretenuring_call_new) { |
2807 // Put the AllocationSite from the feedback vector into r5. | 2814 // Put the AllocationSite from the feedback vector into r5. |
2808 // By adding kPointerSize we encode that we know the AllocationSite | 2815 // By adding kPointerSize we encode that we know the AllocationSite |
2809 // entry is at the feedback vector slot given by r6 + 1. | 2816 // entry is at the feedback vector slot given by r6 + 1. |
2810 __ LoadP(r5, FieldMemOperand(r8, FixedArray::kHeaderSize + kPointerSize)); | 2817 __ LoadP(r5, FieldMemOperand(r8, FixedArray::kHeaderSize + kPointerSize)); |
2811 } else { | 2818 } else { |
2812 // Put the AllocationSite from the feedback vector into r5, or undefined. | 2819 // Put the AllocationSite from the feedback vector into r5, or undefined. |
2813 __ LoadP(r5, FieldMemOperand(r8, FixedArray::kHeaderSize)); | 2820 __ LoadP(r5, FieldMemOperand(r8, FixedArray::kHeaderSize)); |
2814 __ LoadP(r8, FieldMemOperand(r5, AllocationSite::kMapOffset)); | 2821 __ LoadP(r8, FieldMemOperand(r5, AllocationSite::kMapOffset)); |
2815 __ CompareRoot(r8, Heap::kAllocationSiteMapRootIndex); | 2822 __ CompareRoot(r8, Heap::kAllocationSiteMapRootIndex); |
2816 if (CpuFeatures::IsSupported(ISELECT)) { | 2823 if (CpuFeatures::IsSupported(ISELECT)) { |
2817 __ LoadRoot(r8, Heap::kUndefinedValueRootIndex); | 2824 __ LoadRoot(r8, Heap::kUndefinedValueRootIndex); |
2818 __ isel(eq, r5, r5, r8); | 2825 __ isel(eq, r5, r5, r8); |
2819 } else { | 2826 } else { |
2820 Label feedback_register_initialized; | 2827 Label feedback_register_initialized; |
2821 __ beq(&feedback_register_initialized); | 2828 __ beq(&feedback_register_initialized); |
2822 __ LoadRoot(r5, Heap::kUndefinedValueRootIndex); | 2829 __ LoadRoot(r5, Heap::kUndefinedValueRootIndex); |
2823 __ bind(&feedback_register_initialized); | 2830 __ bind(&feedback_register_initialized); |
2824 } | 2831 } |
2825 } | 2832 } |
2826 | 2833 |
2827 __ AssertUndefinedOrAllocationSite(r5, r8); | 2834 __ AssertUndefinedOrAllocationSite(r5, r8); |
2828 } | 2835 } |
2829 | 2836 |
2830 // Pass function as original constructor. | 2837 // Pass function as original constructor. |
2831 if (IsSuperConstructorCall()) { | 2838 if (IsSuperConstructorCall()) { |
2832 __ ShiftLeftImm(r7, r3, Operand(kPointerSizeLog2)); | 2839 __ mr(r6, r7); |
2833 __ addi(r7, r7, Operand(kPointerSize)); | |
2834 __ LoadPX(r6, MemOperand(sp, r7)); | |
2835 } else { | 2840 } else { |
2836 __ mr(r6, r4); | 2841 __ mr(r6, r4); |
2837 } | 2842 } |
2838 | 2843 |
2839 // Jump to the function-specific construct stub. | 2844 // Jump to the function-specific construct stub. |
2840 Register jmp_reg = r7; | 2845 Register jmp_reg = r7; |
2841 __ LoadP(jmp_reg, FieldMemOperand(r4, JSFunction::kSharedFunctionInfoOffset)); | 2846 __ LoadP(jmp_reg, FieldMemOperand(r4, JSFunction::kSharedFunctionInfoOffset)); |
2842 __ LoadP(jmp_reg, | 2847 __ LoadP(jmp_reg, |
2843 FieldMemOperand(jmp_reg, SharedFunctionInfo::kConstructStubOffset)); | 2848 FieldMemOperand(jmp_reg, SharedFunctionInfo::kConstructStubOffset)); |
2844 __ addi(ip, jmp_reg, Operand(Code::kHeaderSize - kHeapObjectTag)); | 2849 __ addi(ip, jmp_reg, Operand(Code::kHeaderSize - kHeapObjectTag)); |
2845 __ JumpToJSEntry(ip); | 2850 __ JumpToJSEntry(ip); |
2846 | 2851 |
2847 // r3: number of arguments | 2852 // r3: number of arguments |
2848 // r4: called object | 2853 // r4: called object |
2849 // r7: object type | 2854 // r8: object type |
2850 Label do_call; | 2855 Label do_call; |
2851 __ bind(&slow); | 2856 __ bind(&slow); |
2852 STATIC_ASSERT(JS_FUNCTION_PROXY_TYPE < 0xffffu); | 2857 STATIC_ASSERT(JS_FUNCTION_PROXY_TYPE < 0xffffu); |
2853 __ cmpi(r7, Operand(JS_FUNCTION_PROXY_TYPE)); | 2858 __ cmpi(r8, Operand(JS_FUNCTION_PROXY_TYPE)); |
2854 __ bne(&non_function_call); | 2859 __ bne(&non_function_call); |
2855 __ GetBuiltinFunction(r4, Builtins::CALL_FUNCTION_PROXY_AS_CONSTRUCTOR); | 2860 __ GetBuiltinFunction(r4, Builtins::CALL_FUNCTION_PROXY_AS_CONSTRUCTOR); |
2856 __ b(&do_call); | 2861 __ b(&do_call); |
2857 | 2862 |
2858 __ bind(&non_function_call); | 2863 __ bind(&non_function_call); |
2859 __ GetBuiltinFunction(r4, Builtins::CALL_NON_FUNCTION_AS_CONSTRUCTOR); | 2864 __ GetBuiltinFunction(r4, Builtins::CALL_NON_FUNCTION_AS_CONSTRUCTOR); |
2860 __ bind(&do_call); | 2865 __ bind(&do_call); |
2861 // Set expected number of arguments to zero (not changing r3). | 2866 // Set expected number of arguments to zero (not changing r3). |
2862 __ li(r5, Operand::Zero()); | 2867 __ li(r5, Operand::Zero()); |
2863 __ Jump(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), | 2868 __ Jump(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), |
(...skipping 2805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5669 kStackUnwindSpace, NULL, | 5674 kStackUnwindSpace, NULL, |
5670 MemOperand(fp, 6 * kPointerSize), NULL); | 5675 MemOperand(fp, 6 * kPointerSize), NULL); |
5671 } | 5676 } |
5672 | 5677 |
5673 | 5678 |
5674 #undef __ | 5679 #undef __ |
5675 } // namespace internal | 5680 } // namespace internal |
5676 } // namespace v8 | 5681 } // namespace v8 |
5677 | 5682 |
5678 #endif // V8_TARGET_ARCH_PPC | 5683 #endif // V8_TARGET_ARCH_PPC |
OLD | NEW |