Index: src/builtins/s390/builtins-s390.cc |
diff --git a/src/builtins/s390/builtins-s390.cc b/src/builtins/s390/builtins-s390.cc |
index aaa31bde27f463757561f2537faca5341df34837..4e7b585e32052142e50b48037504111e689c818e 100644 |
--- a/src/builtins/s390/builtins-s390.cc |
+++ b/src/builtins/s390/builtins-s390.cc |
@@ -1465,23 +1465,48 @@ void Builtins::Generate_InstantiateAsmJs(MacroAssembler* masm) { |
Label failed; |
{ |
FrameScope scope(masm, StackFrame::INTERNAL); |
+ // Preserve argument count for later compare. |
+ __ Move(r4, r2); |
// Push a copy of the target function and the new target. |
__ SmiTag(r2); |
// Push another copy as a parameter to the runtime call. |
__ Push(r2, r3, r5, r3); |
// Copy arguments from caller (stdlib, foreign, heap). |
- for (int i = 2; i >= 0; --i) { |
- __ LoadP(r4, MemOperand(fp, StandardFrameConstants::kCallerSPOffset + |
- i * kPointerSize)); |
- __ push(r4); |
+ Label args_done; |
+ for (int j = 0; j < 4; ++j) { |
+ Label over; |
+ if (j < 3) { |
+ __ CmpP(r4, Operand(j)); |
+ __ b(ne, &over); |
+ } |
+ for (int i = j - 1; i >= 0; --i) { |
+ __ LoadP(r9, MemOperand(fp, StandardFrameConstants::kCallerSPOffset + |
+ i * kPointerSize)); |
+ __ push(r9); |
+ } |
+ 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(r2, &failed); |
+ |
+ __ Drop(2); |
+ __ pop(r4); |
+ __ SmiUntag(r4); |
scope.GenerateLeaveFrame(); |
- __ Drop(4); |
+ |
+ __ AddP(r4, r4, Operand(1)); |
+ __ Drop(r4, r7); |
__ Ret(); |
__ bind(&failed); |