Index: src/builtins/ppc/builtins-ppc.cc |
diff --git a/src/builtins/ppc/builtins-ppc.cc b/src/builtins/ppc/builtins-ppc.cc |
index ef01f40b6eee0bff9c548ecad65977a0dd8d95c1..b799819dbdf71b5af1394eb4079d63761213bddb 100644 |
--- a/src/builtins/ppc/builtins-ppc.cc |
+++ b/src/builtins/ppc/builtins-ppc.cc |
@@ -1458,23 +1458,47 @@ void Builtins::Generate_InstantiateAsmJs(MacroAssembler* masm) { |
Label failed; |
{ |
FrameScope scope(masm, StackFrame::INTERNAL); |
+ // Preserve argument count for later compare. |
+ __ Move(r5, r3); |
// Push a copy of the target function and the new target. |
// Push function as parameter to the runtime call. |
__ SmiTag(r3); |
__ Push(r3, r4, r6, r4); |
// 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) { |
+ __ cmpi(r5, Operand(j)); |
+ __ bne(&over); |
+ } |
+ for (int i = j - 1; i >= 0; --i) { |
+ __ LoadP(r5, MemOperand(fp, StandardFrameConstants::kCallerSPOffset + |
+ i * kPointerSize)); |
+ __ push(r5); |
+ } |
+ 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(r3, &failed); |
+ |
+ __ Drop(2); |
+ __ pop(r5); |
+ __ SmiUntag(r5); |
scope.GenerateLeaveFrame(); |
- __ Drop(4); |
+ |
+ __ Drop(r5); |
__ Ret(); |
__ bind(&failed); |