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