Index: src/builtins/arm/builtins-arm.cc |
diff --git a/src/builtins/arm/builtins-arm.cc b/src/builtins/arm/builtins-arm.cc |
index 63f3fa97a6f0d8dcdec4ba30fa9721d5f9966dcb..0ee3010ed9650a69589c042aed78247c72b298c9 100644 |
--- a/src/builtins/arm/builtins-arm.cc |
+++ b/src/builtins/arm/builtins-arm.cc |
@@ -1449,6 +1449,8 @@ void Builtins::Generate_InstantiateAsmJs(MacroAssembler* masm) { |
Label failed; |
{ |
FrameScope scope(masm, StackFrame::INTERNAL); |
+ // Preserve argument count for later compare. |
+ __ Move(r4, r0); |
// Push the number of arguments to the callee. |
__ SmiTag(r0); |
__ push(r0); |
@@ -1459,17 +1461,40 @@ void Builtins::Generate_InstantiateAsmJs(MacroAssembler* masm) { |
// The function. |
__ push(r1); |
// Copy arguments from caller (stdlib, foreign, heap). |
- for (int i = 2; i >= 0; --i) { |
- __ ldr(r4, MemOperand(fp, StandardFrameConstants::kCallerSPOffset + |
- i * kPointerSize)); |
- __ push(r4); |
+ Label args_done; |
+ for (int j = 0; j < 4; ++j) { |
+ Label over; |
+ if (j < 3) { |
+ __ cmp(r4, Operand(j)); |
+ __ b(ne, &over); |
+ } |
+ for (int i = j - 1; i >= 0; --i) { |
+ __ ldr(r4, MemOperand(fp, StandardFrameConstants::kCallerSPOffset + |
+ i * kPointerSize)); |
+ __ push(r4); |
+ } |
+ for (int i = 0; i < 3 - j; ++i) { |
+ __ PushRoot(Heap::kUndefinedValueRootIndex); |
+ } |
+ if (j < 3) { |
+ __ jmp(&args_done); |
+ __ bind(&over); |
+ } |
} |
+ __ bind(&args_done); |
+ |
// Call runtime, on success unwind frame, and parent frame. |
__ CallRuntime(Runtime::kInstantiateAsmJs, 4); |
// A smi 0 is returned on failure, an object on success. |
__ JumpIfSmi(r0, &failed); |
+ |
+ __ Drop(2); |
+ __ pop(r4); |
+ __ SmiUntag(r4); |
scope.GenerateLeaveFrame(); |
- __ Drop(4); |
+ |
+ __ add(r4, r4, Operand(1)); |
+ __ Drop(r4); |
__ Ret(); |
__ bind(&failed); |