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_MIPS64 | 5 #if V8_TARGET_ARCH_MIPS64 |
6 | 6 |
7 #include "src/bootstrapper.h" | 7 #include "src/bootstrapper.h" |
8 #include "src/code-stubs.h" | 8 #include "src/code-stubs.h" |
9 #include "src/codegen.h" | 9 #include "src/codegen.h" |
10 #include "src/ic/handler-compiler.h" | 10 #include "src/ic/handler-compiler.h" |
(...skipping 5600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5611 __ mov(s0, v0); | 5611 __ mov(s0, v0); |
5612 __ mov(a0, v0); | 5612 __ mov(a0, v0); |
5613 __ PrepareCallCFunction(1, s1); | 5613 __ PrepareCallCFunction(1, s1); |
5614 __ li(a0, Operand(ExternalReference::isolate_address(isolate))); | 5614 __ li(a0, Operand(ExternalReference::isolate_address(isolate))); |
5615 __ CallCFunction(ExternalReference::delete_handle_scope_extensions(isolate), | 5615 __ CallCFunction(ExternalReference::delete_handle_scope_extensions(isolate), |
5616 1); | 5616 1); |
5617 __ mov(v0, s0); | 5617 __ mov(v0, s0); |
5618 __ jmp(&leave_exit_frame); | 5618 __ jmp(&leave_exit_frame); |
5619 } | 5619 } |
5620 | 5620 |
5621 static void CallApiFunctionStubHelper(MacroAssembler* masm, | 5621 void CallApiCallbackStub::Generate(MacroAssembler* masm) { |
5622 const ParameterCount& argc, | |
5623 bool return_first_arg, | |
5624 bool call_data_undefined, bool is_lazy) { | |
5625 // ----------- S t a t e ------------- | 5622 // ----------- S t a t e ------------- |
5626 // -- a0 : callee | 5623 // -- a0 : callee |
5627 // -- a4 : call_data | 5624 // -- a4 : call_data |
5628 // -- a2 : holder | 5625 // -- a2 : holder |
5629 // -- a1 : api_function_address | 5626 // -- a1 : api_function_address |
5630 // -- a3 : number of arguments if argc is a register | |
5631 // -- cp : context | 5627 // -- cp : context |
5632 // -- | 5628 // -- |
5633 // -- sp[0] : last argument | 5629 // -- sp[0] : last argument |
5634 // -- ... | 5630 // -- ... |
5635 // -- sp[(argc - 1)* 8] : first argument | 5631 // -- sp[(argc - 1)* 8] : first argument |
5636 // -- sp[argc * 8] : receiver | 5632 // -- sp[argc * 8] : receiver |
5637 // ----------------------------------- | 5633 // ----------------------------------- |
5638 | 5634 |
5639 Register callee = a0; | 5635 Register callee = a0; |
5640 Register call_data = a4; | 5636 Register call_data = a4; |
5641 Register holder = a2; | 5637 Register holder = a2; |
5642 Register api_function_address = a1; | 5638 Register api_function_address = a1; |
5643 Register context = cp; | 5639 Register context = cp; |
5644 | 5640 |
5645 typedef FunctionCallbackArguments FCA; | 5641 typedef FunctionCallbackArguments FCA; |
5646 | 5642 |
5647 STATIC_ASSERT(FCA::kContextSaveIndex == 6); | 5643 STATIC_ASSERT(FCA::kContextSaveIndex == 6); |
5648 STATIC_ASSERT(FCA::kCalleeIndex == 5); | 5644 STATIC_ASSERT(FCA::kCalleeIndex == 5); |
5649 STATIC_ASSERT(FCA::kDataIndex == 4); | 5645 STATIC_ASSERT(FCA::kDataIndex == 4); |
5650 STATIC_ASSERT(FCA::kReturnValueOffset == 3); | 5646 STATIC_ASSERT(FCA::kReturnValueOffset == 3); |
5651 STATIC_ASSERT(FCA::kReturnValueDefaultValueIndex == 2); | 5647 STATIC_ASSERT(FCA::kReturnValueDefaultValueIndex == 2); |
5652 STATIC_ASSERT(FCA::kIsolateIndex == 1); | 5648 STATIC_ASSERT(FCA::kIsolateIndex == 1); |
5653 STATIC_ASSERT(FCA::kHolderIndex == 0); | 5649 STATIC_ASSERT(FCA::kHolderIndex == 0); |
5654 STATIC_ASSERT(FCA::kArgsLength == 7); | 5650 STATIC_ASSERT(FCA::kArgsLength == 7); |
5655 | 5651 |
5656 DCHECK(argc.is_immediate() || a3.is(argc.reg())); | |
5657 | |
5658 // Save context, callee and call data. | 5652 // Save context, callee and call data. |
5659 __ Push(context, callee, call_data); | 5653 __ Push(context, callee, call_data); |
5660 if (!is_lazy) { | 5654 if (!is_lazy()) { |
5661 // Load context from callee. | 5655 // Load context from callee. |
5662 __ ld(context, FieldMemOperand(callee, JSFunction::kContextOffset)); | 5656 __ ld(context, FieldMemOperand(callee, JSFunction::kContextOffset)); |
5663 } | 5657 } |
5664 | 5658 |
5665 Register scratch = call_data; | 5659 Register scratch = call_data; |
5666 if (!call_data_undefined) { | 5660 if (!call_data_undefined()) { |
5667 __ LoadRoot(scratch, Heap::kUndefinedValueRootIndex); | 5661 __ LoadRoot(scratch, Heap::kUndefinedValueRootIndex); |
5668 } | 5662 } |
5669 // Push return value and default return value. | 5663 // Push return value and default return value. |
5670 __ Push(scratch, scratch); | 5664 __ Push(scratch, scratch); |
5671 __ li(scratch, Operand(ExternalReference::isolate_address(masm->isolate()))); | 5665 __ li(scratch, Operand(ExternalReference::isolate_address(masm->isolate()))); |
5672 // Push isolate and holder. | 5666 // Push isolate and holder. |
5673 __ Push(scratch, holder); | 5667 __ Push(scratch, holder); |
5674 | 5668 |
5675 // Prepare arguments. | 5669 // Prepare arguments. |
5676 __ mov(scratch, sp); | 5670 __ mov(scratch, sp); |
5677 | 5671 |
5678 // Allocate the v8::Arguments structure in the arguments' space since | 5672 // Allocate the v8::Arguments structure in the arguments' space since |
5679 // it's not controlled by GC. | 5673 // it's not controlled by GC. |
5680 const int kApiStackSpace = 4; | 5674 const int kApiStackSpace = 4; |
5681 | 5675 |
5682 FrameScope frame_scope(masm, StackFrame::MANUAL); | 5676 FrameScope frame_scope(masm, StackFrame::MANUAL); |
5683 __ EnterExitFrame(false, kApiStackSpace); | 5677 __ EnterExitFrame(false, kApiStackSpace); |
5684 | 5678 |
5685 DCHECK(!api_function_address.is(a0) && !scratch.is(a0)); | 5679 DCHECK(!api_function_address.is(a0) && !scratch.is(a0)); |
5686 // a0 = FunctionCallbackInfo& | 5680 // a0 = FunctionCallbackInfo& |
5687 // Arguments is after the return address. | 5681 // Arguments is after the return address. |
5688 __ Daddu(a0, sp, Operand(1 * kPointerSize)); | 5682 __ Daddu(a0, sp, Operand(1 * kPointerSize)); |
5689 // FunctionCallbackInfo::implicit_args_ | 5683 // FunctionCallbackInfo::implicit_args_ |
5690 __ sd(scratch, MemOperand(a0, 0 * kPointerSize)); | 5684 __ sd(scratch, MemOperand(a0, 0 * kPointerSize)); |
5691 if (argc.is_immediate()) { | 5685 // FunctionCallbackInfo::values_ |
5692 // FunctionCallbackInfo::values_ | 5686 __ Daddu(at, scratch, |
5693 __ Daddu(at, scratch, | 5687 Operand((FCA::kArgsLength - 1 + argc()) * kPointerSize)); |
5694 Operand((FCA::kArgsLength - 1 + argc.immediate()) * kPointerSize)); | 5688 __ sd(at, MemOperand(a0, 1 * kPointerSize)); |
5695 __ sd(at, MemOperand(a0, 1 * kPointerSize)); | 5689 // FunctionCallbackInfo::length_ = argc |
5696 // FunctionCallbackInfo::length_ = argc | 5690 // Stored as int field, 32-bit integers within struct on stack always left |
5697 // Stored as int field, 32-bit integers within struct on stack always left | 5691 // justified by n64 ABI. |
5698 // justified by n64 ABI. | 5692 __ li(at, Operand(argc())); |
5699 __ li(at, Operand(argc.immediate())); | 5693 __ sw(at, MemOperand(a0, 2 * kPointerSize)); |
5700 __ sw(at, MemOperand(a0, 2 * kPointerSize)); | 5694 // FunctionCallbackInfo::is_construct_call_ = 0 |
5701 // FunctionCallbackInfo::is_construct_call_ = 0 | 5695 __ sw(zero_reg, MemOperand(a0, 2 * kPointerSize + kIntSize)); |
5702 __ sw(zero_reg, MemOperand(a0, 2 * kPointerSize + kIntSize)); | |
5703 } else { | |
5704 // FunctionCallbackInfo::values_ | |
5705 __ dsll(at, argc.reg(), kPointerSizeLog2); | |
5706 __ Daddu(at, at, scratch); | |
5707 __ Daddu(at, at, Operand((FCA::kArgsLength - 1) * kPointerSize)); | |
5708 __ sd(at, MemOperand(a0, 1 * kPointerSize)); | |
5709 // FunctionCallbackInfo::length_ = argc | |
5710 // Stored as int field, 32-bit integers within struct on stack always left | |
5711 // justified by n64 ABI. | |
5712 __ sw(argc.reg(), MemOperand(a0, 2 * kPointerSize)); | |
5713 // FunctionCallbackInfo::is_construct_call_ | |
5714 __ Daddu(argc.reg(), argc.reg(), Operand(FCA::kArgsLength + 1)); | |
5715 __ dsll(at, argc.reg(), kPointerSizeLog2); | |
5716 __ sw(at, MemOperand(a0, 2 * kPointerSize + kIntSize)); | |
5717 } | |
5718 | 5696 |
5719 ExternalReference thunk_ref = | 5697 ExternalReference thunk_ref = |
5720 ExternalReference::invoke_function_callback(masm->isolate()); | 5698 ExternalReference::invoke_function_callback(masm->isolate()); |
5721 | 5699 |
5722 AllowExternalCallThatCantCauseGC scope(masm); | 5700 AllowExternalCallThatCantCauseGC scope(masm); |
5723 MemOperand context_restore_operand( | 5701 MemOperand context_restore_operand( |
5724 fp, (2 + FCA::kContextSaveIndex) * kPointerSize); | 5702 fp, (2 + FCA::kContextSaveIndex) * kPointerSize); |
5725 // Stores return the first js argument. | 5703 // Stores return the first js argument. |
5726 int return_value_offset = 0; | 5704 int return_value_offset = 0; |
5727 if (return_first_arg) { | 5705 if (is_store()) { |
5728 return_value_offset = 2 + FCA::kArgsLength; | 5706 return_value_offset = 2 + FCA::kArgsLength; |
5729 } else { | 5707 } else { |
5730 return_value_offset = 2 + FCA::kReturnValueOffset; | 5708 return_value_offset = 2 + FCA::kReturnValueOffset; |
5731 } | 5709 } |
5732 MemOperand return_value_operand(fp, return_value_offset * kPointerSize); | 5710 MemOperand return_value_operand(fp, return_value_offset * kPointerSize); |
5733 int stack_space = 0; | 5711 int stack_space = 0; |
5734 int32_t stack_space_offset = 4 * kPointerSize; | 5712 int32_t stack_space_offset = 4 * kPointerSize; |
5735 if (argc.is_immediate()) { | 5713 stack_space = argc() + FCA::kArgsLength + 1; |
5736 stack_space = argc.immediate() + FCA::kArgsLength + 1; | 5714 stack_space_offset = kInvalidStackOffset; |
5737 stack_space_offset = kInvalidStackOffset; | |
5738 } | |
5739 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, stack_space, | 5715 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, stack_space, |
5740 stack_space_offset, return_value_operand, | 5716 stack_space_offset, return_value_operand, |
5741 &context_restore_operand); | 5717 &context_restore_operand); |
5742 } | 5718 } |
5743 | 5719 |
5744 | 5720 |
5745 void CallApiFunctionStub::Generate(MacroAssembler* masm) { | |
5746 bool call_data_undefined = this->call_data_undefined(); | |
5747 CallApiFunctionStubHelper(masm, ParameterCount(a3), false, | |
5748 call_data_undefined, false); | |
5749 } | |
5750 | |
5751 | |
5752 void CallApiAccessorStub::Generate(MacroAssembler* masm) { | |
5753 bool is_store = this->is_store(); | |
5754 int argc = this->argc(); | |
5755 bool call_data_undefined = this->call_data_undefined(); | |
5756 bool is_lazy = this->is_lazy(); | |
5757 CallApiFunctionStubHelper(masm, ParameterCount(argc), is_store, | |
5758 call_data_undefined, is_lazy); | |
5759 } | |
5760 | |
5761 | |
5762 void CallApiGetterStub::Generate(MacroAssembler* masm) { | 5721 void CallApiGetterStub::Generate(MacroAssembler* masm) { |
5763 // ----------- S t a t e ------------- | 5722 // ----------- S t a t e ------------- |
5764 // -- sp[0] : name | 5723 // -- sp[0] : name |
5765 // -- sp[8 .. (8 + kArgsLength*8)] : v8::PropertyCallbackInfo::args_ | 5724 // -- sp[8 .. (8 + kArgsLength*8)] : v8::PropertyCallbackInfo::args_ |
5766 // -- ... | 5725 // -- ... |
5767 // -- a2 : api_function_address | 5726 // -- a2 : api_function_address |
5768 // ----------------------------------- | 5727 // ----------------------------------- |
5769 | 5728 |
5770 Register api_function_address = ApiGetterDescriptor::function_address(); | 5729 Register api_function_address = ApiGetterDescriptor::function_address(); |
5771 DCHECK(api_function_address.is(a2)); | 5730 DCHECK(api_function_address.is(a2)); |
(...skipping 26 matching lines...) Expand all Loading... |
5798 return_value_operand, NULL); | 5757 return_value_operand, NULL); |
5799 } | 5758 } |
5800 | 5759 |
5801 | 5760 |
5802 #undef __ | 5761 #undef __ |
5803 | 5762 |
5804 } // namespace internal | 5763 } // namespace internal |
5805 } // namespace v8 | 5764 } // namespace v8 |
5806 | 5765 |
5807 #endif // V8_TARGET_ARCH_MIPS64 | 5766 #endif // V8_TARGET_ARCH_MIPS64 |
OLD | NEW |