Index: src/builtins/arm64/builtins-arm64.cc |
diff --git a/src/builtins/arm64/builtins-arm64.cc b/src/builtins/arm64/builtins-arm64.cc |
index 7d7146da540526628aed2800d34ee630c1f7ff5f..35473679e63cd911e69d920d46873bc4e89f9858 100644 |
--- a/src/builtins/arm64/builtins-arm64.cc |
+++ b/src/builtins/arm64/builtins-arm64.cc |
@@ -1171,6 +1171,40 @@ void Builtins::Generate_InterpreterMarkBaselineOnReturn(MacroAssembler* masm) { |
__ Ret(); |
} |
+static void Generate_InterpreterPushArgs(MacroAssembler* masm, |
+ Register num_args, Register first_arg, |
+ bool receiver_available) { |
+ Register scratch = x5, last_addr = x6, stack_addr = x7; |
rmcilroy
2016/09/06 10:59:35
please pass these as arguments
mythria
2016/09/07 08:59:44
Done.
|
+ |
+ // TODO(mythria): Add a stack check before pushing arguments. |
+ // Find the size of arguments. |
+ __ add(scratch, num_args, Operand(1)); // Add one for receiver. |
+ __ lsl(scratch, scratch, kPointerSizeLog2); |
+ |
+ // Set stack pointer and where to stop. |
+ __ Mov(stack_addr, jssp); |
+ __ Claim(scratch, 1); |
+ |
+ // Find the last destination address. |
+ __ sub(last_addr, stack_addr, scratch); |
+ |
+ if (!receiver_available) { |
+ // Push a slot for the receiver. |
+ __ Str(xzr, MemOperand(stack_addr, -kPointerSize, PreIndex)); |
+ } |
rmcilroy
2016/09/06 10:59:35
nit - could you just do this in InterpreterPushArg
mythria
2016/09/07 08:59:44
Done.
|
+ |
+ // Push the arguments. |
+ Label loop_header, loop_check; |
+ __ B(&loop_check); |
+ __ Bind(&loop_header); |
+ // TODO(rmcilroy): Push two at a time once we ensure we keep stack aligned. |
+ __ Ldr(scratch, MemOperand(first_arg, -kPointerSize, PostIndex)); |
+ __ Str(scratch, MemOperand(stack_addr, -kPointerSize, PreIndex)); |
+ __ Bind(&loop_check); |
+ __ Cmp(stack_addr, last_addr); |
+ __ B(gt, &loop_header); |
+} |
+ |
// static |
void Builtins::Generate_InterpreterPushArgsAndCallImpl( |
MacroAssembler* masm, TailCallMode tail_call_mode, |
@@ -1183,24 +1217,8 @@ void Builtins::Generate_InterpreterPushArgsAndCallImpl( |
// -- x1 : the target to call (can be any Object). |
// ----------------------------------- |
- // Find the address of the last argument. |
- __ add(x3, x0, Operand(1)); // Add one for receiver. |
- __ lsl(x3, x3, kPointerSizeLog2); |
- __ sub(x4, x2, x3); |
- |
- // TODO(mythria): Add a stack check before pushing arguments. |
// Push the arguments. |
- Label loop_header, loop_check; |
- __ Mov(x5, jssp); |
- __ Claim(x3, 1); |
- __ B(&loop_check); |
- __ Bind(&loop_header); |
- // TODO(rmcilroy): Push two at a time once we ensure we keep stack aligned. |
- __ Ldr(x3, MemOperand(x2, -kPointerSize, PostIndex)); |
- __ Str(x3, MemOperand(x5, -kPointerSize, PreIndex)); |
- __ Bind(&loop_check); |
- __ Cmp(x2, x4); |
- __ B(gt, &loop_header); |
+ Generate_InterpreterPushArgs(masm, x0, x2, true); |
// Call the target. |
if (function_type == CallableType::kJSFunction) { |
@@ -1226,29 +1244,8 @@ void Builtins::Generate_InterpreterPushArgsAndConstructImpl( |
// -- x4 : address of the first argument |
// ----------------------------------- |
- // Find the address of the last argument. |
- __ add(x5, x0, Operand(1)); // Add one for receiver (to be constructed). |
- __ lsl(x5, x5, kPointerSizeLog2); |
- |
- // Set stack pointer and where to stop. |
- __ Mov(x6, jssp); |
- __ Claim(x5, 1); |
- __ sub(x7, x6, x5); |
- |
- // Push a slot for the receiver. |
- __ Str(xzr, MemOperand(x6, -kPointerSize, PreIndex)); |
- |
- Label loop_header, loop_check; |
- // TODO(mythria): Add a stack check before pushing arguments. |
// Push the arguments. |
- __ B(&loop_check); |
- __ Bind(&loop_header); |
- // TODO(rmcilroy): Push two at a time once we ensure we keep stack aligned. |
- __ Ldr(x5, MemOperand(x4, -kPointerSize, PostIndex)); |
- __ Str(x5, MemOperand(x6, -kPointerSize, PreIndex)); |
- __ Bind(&loop_check); |
- __ Cmp(x6, x7); |
- __ B(gt, &loop_header); |
+ Generate_InterpreterPushArgs(masm, x0, x4, false); |
__ AssertUndefinedOrAllocationSite(x2, x6); |
if (construct_type == CallableType::kJSFunction) { |
@@ -1267,6 +1264,26 @@ void Builtins::Generate_InterpreterPushArgsAndConstructImpl( |
} |
} |
+// static |
+void Builtins::Generate_InterpreterPushArgsAndConstructArray( |
+ MacroAssembler* masm) { |
+ // ----------- S t a t e ------------- |
+ // -- x0 : argument count (not including receiver) |
+ // -- x1 : target to call verified to be Array function |
+ // -- x2 : allocation site feedback if available, undefined otherwise. |
+ // -- x3 : address of the first argument |
+ // ----------------------------------- |
+ |
+ // Push the arguments. |
+ Generate_InterpreterPushArgs(masm, x0, x3, true); |
+ |
+ // Array constructor expects constructor in x3. It is same as call target. |
+ __ mov(x3, x1); |
+ |
+ ArrayConstructorStub stub(masm->isolate()); |
+ __ TailCallStub(&stub); |
+} |
+ |
void Builtins::Generate_InterpreterEnterBytecodeDispatch(MacroAssembler* masm) { |
// Set the return address to the correct point in the interpreter entry |
// trampoline. |