Index: src/arm/code-stubs-arm.cc |
diff --git a/src/arm/code-stubs-arm.cc b/src/arm/code-stubs-arm.cc |
index 12bccf2ad56c8df8d2b1142849e439eab014dd8f..f0fb38fe51094995fcb9987851375e1316214b9c 100644 |
--- a/src/arm/code-stubs-arm.cc |
+++ b/src/arm/code-stubs-arm.cc |
@@ -5406,12 +5406,16 @@ |
__ jmp(&leave_exit_frame); |
} |
-void CallApiCallbackStub::Generate(MacroAssembler* masm) { |
+static void CallApiFunctionStubHelper(MacroAssembler* masm, |
+ const ParameterCount& argc, |
+ bool return_first_arg, |
+ bool call_data_undefined, bool is_lazy) { |
// ----------- S t a t e ------------- |
// -- r0 : callee |
// -- r4 : call_data |
// -- r2 : holder |
// -- r1 : api_function_address |
+ // -- r3 : number of arguments if argc is a register |
// -- cp : context |
// -- |
// -- sp[0] : last argument |
@@ -5437,9 +5441,11 @@ |
STATIC_ASSERT(FCA::kHolderIndex == 0); |
STATIC_ASSERT(FCA::kArgsLength == 7); |
+ DCHECK(argc.is_immediate() || r3.is(argc.reg())); |
+ |
// context save |
__ push(context); |
- if (!is_lazy()) { |
+ if (!is_lazy) { |
// load context from callee |
__ ldr(context, FieldMemOperand(callee, JSFunction::kContextOffset)); |
} |
@@ -5451,7 +5457,7 @@ |
__ push(call_data); |
Register scratch = call_data; |
- if (!call_data_undefined()) { |
+ if (!call_data_undefined) { |
__ LoadRoot(scratch, Heap::kUndefinedValueRootIndex); |
} |
// return value |
@@ -5480,15 +5486,29 @@ |
__ add(r0, sp, Operand(1 * kPointerSize)); |
// FunctionCallbackInfo::implicit_args_ |
__ str(scratch, MemOperand(r0, 0 * kPointerSize)); |
- // FunctionCallbackInfo::values_ |
- __ add(ip, scratch, Operand((FCA::kArgsLength - 1 + argc()) * kPointerSize)); |
- __ str(ip, MemOperand(r0, 1 * kPointerSize)); |
- // FunctionCallbackInfo::length_ = argc |
- __ mov(ip, Operand(argc())); |
- __ str(ip, MemOperand(r0, 2 * kPointerSize)); |
- // FunctionCallbackInfo::is_construct_call_ = 0 |
- __ mov(ip, Operand::Zero()); |
- __ str(ip, MemOperand(r0, 3 * kPointerSize)); |
+ if (argc.is_immediate()) { |
+ // FunctionCallbackInfo::values_ |
+ __ add(ip, scratch, |
+ Operand((FCA::kArgsLength - 1 + argc.immediate()) * kPointerSize)); |
+ __ str(ip, MemOperand(r0, 1 * kPointerSize)); |
+ // FunctionCallbackInfo::length_ = argc |
+ __ mov(ip, Operand(argc.immediate())); |
+ __ str(ip, MemOperand(r0, 2 * kPointerSize)); |
+ // FunctionCallbackInfo::is_construct_call_ = 0 |
+ __ mov(ip, Operand::Zero()); |
+ __ str(ip, MemOperand(r0, 3 * kPointerSize)); |
+ } else { |
+ // FunctionCallbackInfo::values_ |
+ __ add(ip, scratch, Operand(argc.reg(), LSL, kPointerSizeLog2)); |
+ __ add(ip, ip, Operand((FCA::kArgsLength - 1) * kPointerSize)); |
+ __ str(ip, MemOperand(r0, 1 * kPointerSize)); |
+ // FunctionCallbackInfo::length_ = argc |
+ __ str(argc.reg(), MemOperand(r0, 2 * kPointerSize)); |
+ // FunctionCallbackInfo::is_construct_call_ |
+ __ add(argc.reg(), argc.reg(), Operand(FCA::kArgsLength + 1)); |
+ __ mov(ip, Operand(argc.reg(), LSL, kPointerSizeLog2)); |
+ __ str(ip, MemOperand(r0, 3 * kPointerSize)); |
+ } |
ExternalReference thunk_ref = |
ExternalReference::invoke_function_callback(masm->isolate()); |
@@ -5498,7 +5518,7 @@ |
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; |
@@ -5507,12 +5527,30 @@ |
int stack_space = 0; |
MemOperand is_construct_call_operand = MemOperand(sp, 4 * kPointerSize); |
MemOperand* stack_space_operand = &is_construct_call_operand; |
- stack_space = argc() + FCA::kArgsLength + 1; |
- stack_space_operand = NULL; |
- |
+ if (argc.is_immediate()) { |
+ stack_space = argc.immediate() + FCA::kArgsLength + 1; |
+ stack_space_operand = NULL; |
+ } |
CallApiFunctionAndReturn(masm, 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(r3), false, |
+ call_data_undefined, false); |
+} |
+ |
+ |
+void CallApiAccessorStub::Generate(MacroAssembler* masm) { |
+ bool is_store = this->is_store(); |
+ int argc = this->argc(); |
+ bool call_data_undefined = this->call_data_undefined(); |
+ bool is_lazy = this->is_lazy(); |
+ CallApiFunctionStubHelper(masm, ParameterCount(argc), is_store, |
+ call_data_undefined, is_lazy); |
} |