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/base/bits.h" | 7 #include "src/base/bits.h" |
8 #include "src/bootstrapper.h" | 8 #include "src/bootstrapper.h" |
9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
(...skipping 5595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5606 __ StoreP(r15, MemOperand(r17, kLimitOffset)); | 5606 __ StoreP(r15, MemOperand(r17, kLimitOffset)); |
5607 __ mr(r14, r3); | 5607 __ mr(r14, r3); |
5608 __ PrepareCallCFunction(1, r15); | 5608 __ PrepareCallCFunction(1, r15); |
5609 __ mov(r3, Operand(ExternalReference::isolate_address(isolate))); | 5609 __ mov(r3, Operand(ExternalReference::isolate_address(isolate))); |
5610 __ CallCFunction(ExternalReference::delete_handle_scope_extensions(isolate), | 5610 __ CallCFunction(ExternalReference::delete_handle_scope_extensions(isolate), |
5611 1); | 5611 1); |
5612 __ mr(r3, r14); | 5612 __ mr(r3, r14); |
5613 __ b(&leave_exit_frame); | 5613 __ b(&leave_exit_frame); |
5614 } | 5614 } |
5615 | 5615 |
5616 static void CallApiFunctionStubHelper(MacroAssembler* masm, | 5616 void CallApiCallbackStub::Generate(MacroAssembler* masm) { |
5617 const ParameterCount& argc, | |
5618 bool return_first_arg, | |
5619 bool call_data_undefined, bool is_lazy) { | |
5620 // ----------- S t a t e ------------- | 5617 // ----------- S t a t e ------------- |
5621 // -- r3 : callee | 5618 // -- r3 : callee |
5622 // -- r7 : call_data | 5619 // -- r7 : call_data |
5623 // -- r5 : holder | 5620 // -- r5 : holder |
5624 // -- r4 : api_function_address | 5621 // -- r4 : api_function_address |
5625 // -- r6 : number of arguments if argc is a register | |
5626 // -- cp : context | 5622 // -- cp : context |
5627 // -- | 5623 // -- |
5628 // -- sp[0] : last argument | 5624 // -- sp[0] : last argument |
5629 // -- ... | 5625 // -- ... |
5630 // -- sp[(argc - 1)* 4] : first argument | 5626 // -- sp[(argc - 1)* 4] : first argument |
5631 // -- sp[argc * 4] : receiver | 5627 // -- sp[argc * 4] : receiver |
5632 // ----------------------------------- | 5628 // ----------------------------------- |
5633 | 5629 |
5634 Register callee = r3; | 5630 Register callee = r3; |
5635 Register call_data = r7; | 5631 Register call_data = r7; |
5636 Register holder = r5; | 5632 Register holder = r5; |
5637 Register api_function_address = r4; | 5633 Register api_function_address = r4; |
5638 Register context = cp; | 5634 Register context = cp; |
5639 | 5635 |
5640 typedef FunctionCallbackArguments FCA; | 5636 typedef FunctionCallbackArguments FCA; |
5641 | 5637 |
5642 STATIC_ASSERT(FCA::kContextSaveIndex == 6); | 5638 STATIC_ASSERT(FCA::kContextSaveIndex == 6); |
5643 STATIC_ASSERT(FCA::kCalleeIndex == 5); | 5639 STATIC_ASSERT(FCA::kCalleeIndex == 5); |
5644 STATIC_ASSERT(FCA::kDataIndex == 4); | 5640 STATIC_ASSERT(FCA::kDataIndex == 4); |
5645 STATIC_ASSERT(FCA::kReturnValueOffset == 3); | 5641 STATIC_ASSERT(FCA::kReturnValueOffset == 3); |
5646 STATIC_ASSERT(FCA::kReturnValueDefaultValueIndex == 2); | 5642 STATIC_ASSERT(FCA::kReturnValueDefaultValueIndex == 2); |
5647 STATIC_ASSERT(FCA::kIsolateIndex == 1); | 5643 STATIC_ASSERT(FCA::kIsolateIndex == 1); |
5648 STATIC_ASSERT(FCA::kHolderIndex == 0); | 5644 STATIC_ASSERT(FCA::kHolderIndex == 0); |
5649 STATIC_ASSERT(FCA::kArgsLength == 7); | 5645 STATIC_ASSERT(FCA::kArgsLength == 7); |
5650 | 5646 |
5651 DCHECK(argc.is_immediate() || r6.is(argc.reg())); | 5647 DCHECK(argc.is_immediate() || r6.is(argc.reg())); |
5652 | 5648 |
5653 // context save | 5649 // context save |
5654 __ push(context); | 5650 __ push(context); |
5655 if (!is_lazy) { | 5651 if (!is_lazy()) { |
5656 // load context from callee | 5652 // load context from callee |
5657 __ LoadP(context, FieldMemOperand(callee, JSFunction::kContextOffset)); | 5653 __ LoadP(context, FieldMemOperand(callee, JSFunction::kContextOffset)); |
5658 } | 5654 } |
5659 | 5655 |
5660 // callee | 5656 // callee |
5661 __ push(callee); | 5657 __ push(callee); |
5662 | 5658 |
5663 // call data | 5659 // call data |
5664 __ push(call_data); | 5660 __ push(call_data); |
5665 | 5661 |
5666 Register scratch = call_data; | 5662 Register scratch = call_data; |
5667 if (!call_data_undefined) { | 5663 if (!call_data_undefined()) { |
5668 __ LoadRoot(scratch, Heap::kUndefinedValueRootIndex); | 5664 __ LoadRoot(scratch, Heap::kUndefinedValueRootIndex); |
5669 } | 5665 } |
5670 // return value | 5666 // return value |
5671 __ push(scratch); | 5667 __ push(scratch); |
5672 // return value default | 5668 // return value default |
5673 __ push(scratch); | 5669 __ push(scratch); |
5674 // isolate | 5670 // isolate |
5675 __ mov(scratch, Operand(ExternalReference::isolate_address(masm->isolate()))); | 5671 __ mov(scratch, Operand(ExternalReference::isolate_address(masm->isolate()))); |
5676 __ push(scratch); | 5672 __ push(scratch); |
5677 // holder | 5673 // holder |
(...skipping 15 matching lines...) Expand all Loading... |
5693 | 5689 |
5694 FrameScope frame_scope(masm, StackFrame::MANUAL); | 5690 FrameScope frame_scope(masm, StackFrame::MANUAL); |
5695 __ EnterExitFrame(false, kApiStackSpace); | 5691 __ EnterExitFrame(false, kApiStackSpace); |
5696 | 5692 |
5697 DCHECK(!api_function_address.is(r3) && !scratch.is(r3)); | 5693 DCHECK(!api_function_address.is(r3) && !scratch.is(r3)); |
5698 // r3 = FunctionCallbackInfo& | 5694 // r3 = FunctionCallbackInfo& |
5699 // Arguments is after the return address. | 5695 // Arguments is after the return address. |
5700 __ addi(r3, sp, Operand(kFunctionCallbackInfoOffset)); | 5696 __ addi(r3, sp, Operand(kFunctionCallbackInfoOffset)); |
5701 // FunctionCallbackInfo::implicit_args_ | 5697 // FunctionCallbackInfo::implicit_args_ |
5702 __ StoreP(scratch, MemOperand(r3, 0 * kPointerSize)); | 5698 __ StoreP(scratch, MemOperand(r3, 0 * kPointerSize)); |
5703 if (argc.is_immediate()) { | 5699 // FunctionCallbackInfo::values_ |
5704 // FunctionCallbackInfo::values_ | 5700 __ addi(ip, scratch, Operand((FCA::kArgsLength - 1 + argc()) * kPointerSize)); |
5705 __ addi(ip, scratch, | 5701 __ StoreP(ip, MemOperand(r3, 1 * kPointerSize)); |
5706 Operand((FCA::kArgsLength - 1 + argc.immediate()) * kPointerSize)); | 5702 // FunctionCallbackInfo::length_ = argc |
5707 __ StoreP(ip, MemOperand(r3, 1 * kPointerSize)); | 5703 __ li(ip, Operand(argc())); |
5708 // FunctionCallbackInfo::length_ = argc | 5704 __ stw(ip, MemOperand(r3, 2 * kPointerSize)); |
5709 __ li(ip, Operand(argc.immediate())); | 5705 // FunctionCallbackInfo::is_construct_call_ = 0 |
5710 __ stw(ip, MemOperand(r3, 2 * kPointerSize)); | 5706 __ li(ip, Operand::Zero()); |
5711 // FunctionCallbackInfo::is_construct_call_ = 0 | 5707 __ stw(ip, MemOperand(r3, 2 * kPointerSize + kIntSize)); |
5712 __ li(ip, Operand::Zero()); | |
5713 __ stw(ip, MemOperand(r3, 2 * kPointerSize + kIntSize)); | |
5714 } else { | |
5715 __ ShiftLeftImm(ip, argc.reg(), Operand(kPointerSizeLog2)); | |
5716 __ addi(ip, ip, Operand((FCA::kArgsLength - 1) * kPointerSize)); | |
5717 // FunctionCallbackInfo::values_ | |
5718 __ add(r0, scratch, ip); | |
5719 __ StoreP(r0, MemOperand(r3, 1 * kPointerSize)); | |
5720 // FunctionCallbackInfo::length_ = argc | |
5721 __ stw(argc.reg(), MemOperand(r3, 2 * kPointerSize)); | |
5722 // FunctionCallbackInfo::is_construct_call_ | |
5723 __ stw(ip, MemOperand(r3, 2 * kPointerSize + kIntSize)); | |
5724 } | |
5725 | 5708 |
5726 ExternalReference thunk_ref = | 5709 ExternalReference thunk_ref = |
5727 ExternalReference::invoke_function_callback(masm->isolate()); | 5710 ExternalReference::invoke_function_callback(masm->isolate()); |
5728 | 5711 |
5729 AllowExternalCallThatCantCauseGC scope(masm); | 5712 AllowExternalCallThatCantCauseGC scope(masm); |
5730 MemOperand context_restore_operand( | 5713 MemOperand context_restore_operand( |
5731 fp, (2 + FCA::kContextSaveIndex) * kPointerSize); | 5714 fp, (2 + FCA::kContextSaveIndex) * kPointerSize); |
5732 // Stores return the first js argument | 5715 // Stores return the first js argument |
5733 int return_value_offset = 0; | 5716 int return_value_offset = 0; |
5734 if (return_first_arg) { | 5717 if (is_store()) { |
5735 return_value_offset = 2 + FCA::kArgsLength; | 5718 return_value_offset = 2 + FCA::kArgsLength; |
5736 } else { | 5719 } else { |
5737 return_value_offset = 2 + FCA::kReturnValueOffset; | 5720 return_value_offset = 2 + FCA::kReturnValueOffset; |
5738 } | 5721 } |
5739 MemOperand return_value_operand(fp, return_value_offset * kPointerSize); | 5722 MemOperand return_value_operand(fp, return_value_offset * kPointerSize); |
5740 int stack_space = 0; | 5723 int stack_space = 0; |
5741 MemOperand is_construct_call_operand = | 5724 MemOperand is_construct_call_operand = |
5742 MemOperand(sp, kFunctionCallbackInfoOffset + 2 * kPointerSize + kIntSize); | 5725 MemOperand(sp, kFunctionCallbackInfoOffset + 2 * kPointerSize + kIntSize); |
5743 MemOperand* stack_space_operand = &is_construct_call_operand; | 5726 MemOperand* stack_space_operand = &is_construct_call_operand; |
5744 if (argc.is_immediate()) { | 5727 stack_space = argc() + FCA::kArgsLength + 1; |
5745 stack_space = argc.immediate() + FCA::kArgsLength + 1; | 5728 stack_space_operand = NULL; |
5746 stack_space_operand = NULL; | |
5747 } | |
5748 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, stack_space, | 5729 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, stack_space, |
5749 stack_space_operand, return_value_operand, | 5730 stack_space_operand, return_value_operand, |
5750 &context_restore_operand); | 5731 &context_restore_operand); |
5751 } | 5732 } |
5752 | 5733 |
5753 | 5734 |
5754 void CallApiFunctionStub::Generate(MacroAssembler* masm) { | |
5755 bool call_data_undefined = this->call_data_undefined(); | |
5756 CallApiFunctionStubHelper(masm, ParameterCount(r6), false, | |
5757 call_data_undefined, false); | |
5758 } | |
5759 | |
5760 | |
5761 void CallApiAccessorStub::Generate(MacroAssembler* masm) { | |
5762 bool is_store = this->is_store(); | |
5763 int argc = this->argc(); | |
5764 bool call_data_undefined = this->call_data_undefined(); | |
5765 bool is_lazy = this->is_lazy(); | |
5766 CallApiFunctionStubHelper(masm, ParameterCount(argc), is_store, | |
5767 call_data_undefined, is_lazy); | |
5768 } | |
5769 | |
5770 | |
5771 void CallApiGetterStub::Generate(MacroAssembler* masm) { | 5735 void CallApiGetterStub::Generate(MacroAssembler* masm) { |
5772 // ----------- S t a t e ------------- | 5736 // ----------- S t a t e ------------- |
5773 // -- sp[0] : name | 5737 // -- sp[0] : name |
5774 // -- sp[4 .. (4 + kArgsLength*4)] : v8::PropertyCallbackInfo::args_ | 5738 // -- sp[4 .. (4 + kArgsLength*4)] : v8::PropertyCallbackInfo::args_ |
5775 // -- ... | 5739 // -- ... |
5776 // -- r5 : api_function_address | 5740 // -- r5 : api_function_address |
5777 // ----------------------------------- | 5741 // ----------------------------------- |
5778 | 5742 |
5779 Register api_function_address = ApiGetterDescriptor::function_address(); | 5743 Register api_function_address = ApiGetterDescriptor::function_address(); |
5780 int arg0Slot = 0; | 5744 int arg0Slot = 0; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5834 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, | 5798 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, |
5835 kStackUnwindSpace, NULL, return_value_operand, NULL); | 5799 kStackUnwindSpace, NULL, return_value_operand, NULL); |
5836 } | 5800 } |
5837 | 5801 |
5838 | 5802 |
5839 #undef __ | 5803 #undef __ |
5840 } // namespace internal | 5804 } // namespace internal |
5841 } // namespace v8 | 5805 } // namespace v8 |
5842 | 5806 |
5843 #endif // V8_TARGET_ARCH_PPC | 5807 #endif // V8_TARGET_ARCH_PPC |
OLD | NEW |