Index: src/builtins/x87/builtins-x87.cc |
diff --git a/src/builtins/x87/builtins-x87.cc b/src/builtins/x87/builtins-x87.cc |
index ff5597b539e37d1d63453415d1389a7b5bed46f0..532f7d796b391a1564a6cc9c1c05c9a49701f4e3 100644 |
--- a/src/builtins/x87/builtins-x87.cc |
+++ b/src/builtins/x87/builtins-x87.cc |
@@ -1011,6 +1011,8 @@ void Builtins::Generate_InstantiateAsmJs(MacroAssembler* masm) { |
Label failed; |
{ |
FrameScope scope(masm, StackFrame::INTERNAL); |
+ // Preserve argument count for later compare. |
+ __ mov(ecx, eax); |
// Push the number of arguments to the callee. |
__ SmiTag(eax); |
__ push(eax); |
@@ -1021,16 +1023,56 @@ void Builtins::Generate_InstantiateAsmJs(MacroAssembler* masm) { |
// The function. |
__ push(edi); |
// Copy arguments from caller (stdlib, foreign, heap). |
- for (int i = 2; i >= 0; --i) { |
- __ push(Operand( |
- ebp, StandardFrameConstants::kCallerSPOffset + i * kPointerSize)); |
- } |
+ Label args_done; |
+ __ cmp(ecx, Immediate(0)); |
+ __ j(equal, &args_done, Label::kNear); |
+ |
+ Label args2; |
+ __ cmp(ecx, Immediate(1)); |
+ __ j(not_equal, &args2, Label::kNear); |
+ __ Push(Operand( |
+ ebp, StandardFrameConstants::kCallerSPOffset + 0 * kPointerSize)); |
+ __ jmp(&args_done, Label::kNear); |
+ |
+ __ bind(&args2); |
+ Label args3; |
+ __ cmp(ecx, Immediate(2)); |
+ __ j(not_equal, &args3, Label::kNear); |
+ __ Push(Operand( |
+ ebp, StandardFrameConstants::kCallerSPOffset + 1 * kPointerSize)); |
+ __ Push(Operand( |
+ ebp, StandardFrameConstants::kCallerSPOffset + 0 * kPointerSize)); |
+ __ jmp(&args_done, Label::kNear); |
+ |
+ __ bind(&args3); |
+ __ Push(Operand( |
+ ebp, StandardFrameConstants::kCallerSPOffset + 2 * kPointerSize)); |
+ __ Push(Operand( |
+ ebp, StandardFrameConstants::kCallerSPOffset + 1 * kPointerSize)); |
+ __ Push(Operand( |
+ ebp, StandardFrameConstants::kCallerSPOffset + 0 * kPointerSize)); |
+ __ bind(&args_done); |
+ |
+ // Increment and restore argument count to call runtime method |
+ // with function as extra argument. |
+ __ inc(ecx); |
+ __ mov(eax, ecx); |
// Call runtime, on success unwind frame, and parent frame. |
- __ CallRuntime(Runtime::kInstantiateAsmJs, 4); |
+ __ CallRuntime(Runtime::kInstantiateAsmJs, -1); |
// A smi 0 is returned on failure, an object on success. |
__ JumpIfSmi(eax, &failed, Label::kNear); |
+ |
+ __ Pop(ecx); |
+ __ Pop(ecx); |
+ __ Pop(ecx); |
+ __ SmiUntag(ecx); |
scope.GenerateLeaveFrame(); |
- __ ret(4 * kPointerSize); |
+ |
+ __ Pop(ebx); |
+ __ inc(ecx); |
+ __ lea(esp, Operand(esp, ecx, times_pointer_size, 0)); |
+ __ Push(ebx); |
+ __ ret(0); |
__ bind(&failed); |
// Restore target function and new target. |
@@ -1040,7 +1082,7 @@ void Builtins::Generate_InstantiateAsmJs(MacroAssembler* masm) { |
__ SmiUntag(eax); |
} |
// On failure, tail call back to regular js. |
- GenerateTailCallToReturnedCode(masm, Runtime::kCompileLazy); |
+ GenerateTailCallToReturnedCode(masm, Runtime::kCompileBaseline); |
} |
static void GenerateMakeCodeYoungAgainCommon(MacroAssembler* masm) { |