Index: src/mips64/code-stubs-mips64.cc |
diff --git a/src/mips64/code-stubs-mips64.cc b/src/mips64/code-stubs-mips64.cc |
index 6bbd1a3183a21baba02a4e177e5798b4a3cd95be..944ed3ccf6e3a1d8401f4f6045fefe54dd995d41 100644 |
--- a/src/mips64/code-stubs-mips64.cc |
+++ b/src/mips64/code-stubs-mips64.cc |
@@ -4873,12 +4873,16 @@ void InternalArrayConstructorStub::Generate(MacroAssembler* masm) { |
} |
-void CallApiFunctionStub::Generate(MacroAssembler* masm) { |
+static void CallApiFunctionStubHelper(MacroAssembler* masm, |
+ const ParameterCount& argc, |
+ bool return_first_arg, |
+ bool call_data_undefined) { |
// ----------- S t a t e ------------- |
// -- a0 : callee |
// -- a4 : call_data |
// -- a2 : holder |
// -- a1 : api_function_address |
+ // -- a3 : number of arguments if argc is a register |
// -- cp : context |
// -- |
// -- sp[0] : last argument |
@@ -4893,10 +4897,6 @@ void CallApiFunctionStub::Generate(MacroAssembler* masm) { |
Register api_function_address = a1; |
Register context = cp; |
- int argc = this->argc(); |
- bool is_store = this->is_store(); |
- bool call_data_undefined = this->call_data_undefined(); |
- |
typedef FunctionCallbackArguments FCA; |
STATIC_ASSERT(FCA::kContextSaveIndex == 6); |
@@ -4908,6 +4908,8 @@ void CallApiFunctionStub::Generate(MacroAssembler* masm) { |
STATIC_ASSERT(FCA::kHolderIndex == 0); |
STATIC_ASSERT(FCA::kArgsLength == 7); |
+ DCHECK(argc.is_immediate() || a3.is(argc.reg())); |
+ |
// Save context, callee and call data. |
__ Push(context, callee, call_data); |
// Load context from callee. |
@@ -4919,8 +4921,7 @@ void CallApiFunctionStub::Generate(MacroAssembler* masm) { |
} |
// Push return value and default return value. |
__ Push(scratch, scratch); |
- __ li(scratch, |
- Operand(ExternalReference::isolate_address(isolate()))); |
+ __ li(scratch, Operand(ExternalReference::isolate_address(masm->isolate()))); |
// Push isolate and holder. |
__ Push(scratch, holder); |
@@ -4940,39 +4941,73 @@ void CallApiFunctionStub::Generate(MacroAssembler* masm) { |
__ Daddu(a0, sp, Operand(1 * kPointerSize)); |
// FunctionCallbackInfo::implicit_args_ |
__ sd(scratch, MemOperand(a0, 0 * kPointerSize)); |
- // FunctionCallbackInfo::values_ |
- __ Daddu(at, scratch, Operand((FCA::kArgsLength - 1 + argc) * kPointerSize)); |
- __ sd(at, MemOperand(a0, 1 * kPointerSize)); |
- // FunctionCallbackInfo::length_ = argc |
- __ li(at, Operand(argc)); |
- __ sd(at, MemOperand(a0, 2 * kPointerSize)); |
- // FunctionCallbackInfo::is_construct_call = 0 |
- __ sd(zero_reg, MemOperand(a0, 3 * kPointerSize)); |
- |
- const int kStackUnwindSpace = argc + FCA::kArgsLength + 1; |
+ if (argc.is_immediate()) { |
+ // FunctionCallbackInfo::values_ |
+ __ Daddu(at, scratch, |
+ Operand((FCA::kArgsLength - 1 + argc.immediate()) * kPointerSize)); |
+ __ sd(at, MemOperand(a0, 1 * kPointerSize)); |
+ // FunctionCallbackInfo::length_ = argc |
+ __ li(at, Operand(argc.immediate())); |
+ __ sd(at, MemOperand(a0, 2 * kPointerSize)); |
+ // FunctionCallbackInfo::is_construct_call_ = 0 |
+ __ sd(zero_reg, MemOperand(a0, 3 * kPointerSize)); |
+ } else { |
+ // FunctionCallbackInfo::values_ |
+ __ dsll(at, argc.reg(), kPointerSizeLog2); |
+ __ Daddu(at, at, scratch); |
+ __ Daddu(at, at, Operand((FCA::kArgsLength - 1) * kPointerSize)); |
+ __ sd(at, MemOperand(a0, 1 * kPointerSize)); |
+ // FunctionCallbackInfo::length_ = argc |
+ __ sd(argc.reg(), MemOperand(a0, 2 * kPointerSize)); |
+ // FunctionCallbackInfo::is_construct_call_ |
+ __ Daddu(argc.reg(), argc.reg(), Operand(FCA::kArgsLength + 1)); |
+ __ dsll(at, argc.reg(), kPointerSizeLog2); |
+ __ sd(at, MemOperand(a0, 3 * kPointerSize)); |
+ } |
+ |
ExternalReference thunk_ref = |
- ExternalReference::invoke_function_callback(isolate()); |
+ ExternalReference::invoke_function_callback(masm->isolate()); |
AllowExternalCallThatCantCauseGC scope(masm); |
MemOperand context_restore_operand( |
fp, (2 + FCA::kContextSaveIndex) * kPointerSize); |
// Stores return the first js argument. |
int return_value_offset = 0; |
- if (is_store) { |
+ if (return_first_arg) { |
return_value_offset = 2 + FCA::kArgsLength; |
} else { |
return_value_offset = 2 + FCA::kReturnValueOffset; |
} |
MemOperand return_value_operand(fp, return_value_offset * kPointerSize); |
- |
- __ CallApiFunctionAndReturn(api_function_address, |
- thunk_ref, |
- kStackUnwindSpace, |
- return_value_operand, |
+ int stack_space = 0; |
+ MemOperand is_construct_call_operand = MemOperand(sp, 4 * kPointerSize); |
+ MemOperand* stack_space_operand = &is_construct_call_operand; |
+ if (argc.is_immediate()) { |
+ stack_space = argc.immediate() + FCA::kArgsLength + 1; |
+ stack_space_operand = NULL; |
+ } |
+ __ CallApiFunctionAndReturn(api_function_address, thunk_ref, stack_space, |
+ stack_space_operand, return_value_operand, |
&context_restore_operand); |
} |
+void CallApiFunctionStub::Generate(MacroAssembler* masm) { |
+ bool call_data_undefined = this->call_data_undefined(); |
+ CallApiFunctionStubHelper(masm, ParameterCount(a3), false, |
+ call_data_undefined); |
+} |
+ |
+ |
+void CallApiAccessorStub::Generate(MacroAssembler* masm) { |
+ bool is_store = this->is_store(); |
+ int argc = is_store ? 1 : 0; |
+ bool call_data_undefined = this->call_data_undefined(); |
+ CallApiFunctionStubHelper(masm, ParameterCount(argc), is_store, |
+ call_data_undefined); |
+} |
+ |
+ |
void CallApiGetterStub::Generate(MacroAssembler* masm) { |
// ----------- S t a t e ------------- |
// -- sp[0] : name |
@@ -5000,11 +5035,9 @@ void CallApiGetterStub::Generate(MacroAssembler* masm) { |
ExternalReference thunk_ref = |
ExternalReference::invoke_accessor_getter_callback(isolate()); |
- __ CallApiFunctionAndReturn(api_function_address, |
- thunk_ref, |
- kStackUnwindSpace, |
- MemOperand(fp, 6 * kPointerSize), |
- NULL); |
+ __ CallApiFunctionAndReturn(api_function_address, thunk_ref, |
+ kStackUnwindSpace, NULL, |
+ MemOperand(fp, 6 * kPointerSize), NULL); |
} |