Index: src/x87/builtins-x87.cc |
diff --git a/src/x87/builtins-x87.cc b/src/x87/builtins-x87.cc |
index 0600f0d3ccc809953a6019de7fe4d2fc7443ca6e..3631002969e50c8f7c6f44b8285800a1c6a554c8 100644 |
--- a/src/x87/builtins-x87.cc |
+++ b/src/x87/builtins-x87.cc |
@@ -1018,6 +1018,46 @@ void Builtins::Generate_CompileOptimizedConcurrent(MacroAssembler* masm) { |
GenerateTailCallToReturnedCode(masm, Runtime::kCompileOptimized_Concurrent); |
} |
+void Builtins::Generate_InstantiateAsmJs(MacroAssembler* masm) { |
+ // ----------- S t a t e ------------- |
+ // -- eax : argument count (preserved for callee) |
+ // -- edx : new target (preserved for callee) |
+ // -- edi : target function (preserved for callee) |
+ // ----------------------------------- |
+ Label failed; |
+ { |
+ FrameScope scope(masm, StackFrame::INTERNAL); |
+ // Push the number of arguments to the callee. |
+ __ SmiTag(eax); |
+ __ push(eax); |
+ // Push a copy of the target function and the new target. |
+ __ push(edi); |
+ __ push(edx); |
+ |
+ // 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)); |
+ } |
+ // 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(eax, &failed, Label::kNear); |
+ scope.GenerateLeaveFrame(); |
+ __ ret(4 * kPointerSize); |
+ |
+ __ bind(&failed); |
+ // Restore target function and new target. |
+ __ pop(edx); |
+ __ pop(edi); |
+ __ pop(eax); |
+ __ SmiUntag(eax); |
+ } |
+ // On failure, tail call back to regular js. |
+ GenerateTailCallToReturnedCode(masm, Runtime::kCompileLazy); |
+} |
static void GenerateMakeCodeYoungAgainCommon(MacroAssembler* masm) { |
// For now, we are relying on the fact that make_code_young doesn't do any |