Index: src/arm64/builtins-arm64.cc |
diff --git a/src/arm64/builtins-arm64.cc b/src/arm64/builtins-arm64.cc |
index 6615eb23b2629eb5f5e127695d246dcacdee0667..9580e8bc049380ec4a9ef1207f90aa5a207fea42 100644 |
--- a/src/arm64/builtins-arm64.cc |
+++ b/src/arm64/builtins-arm64.cc |
@@ -1415,6 +1415,42 @@ void Builtins::Generate_CompileOptimizedConcurrent(MacroAssembler* masm) { |
GenerateTailCallToReturnedCode(masm, Runtime::kCompileOptimized_Concurrent); |
} |
+void Builtins::Generate_InstantiateAsmJs(MacroAssembler* masm) { |
+ // ----------- S t a t e ------------- |
+ // -- x0 : argument count (preserved for callee) |
+ // -- x1 : new target (preserved for callee) |
+ // -- x3 : target function (preserved for callee) |
+ // ----------------------------------- |
+ Label failed; |
+ { |
+ FrameScope scope(masm, StackFrame::INTERNAL); |
+ // Push a copy of the target function and the new target. |
+ __ SmiTag(x0); |
+ // Push another copy as a parameter to the runtime call. |
+ __ Push(x0, x1, x3, x1); |
+ |
+ // Copy arguments from caller (stdlib, foreign, heap). |
+ for (int i = 2; i >= 0; --i) { |
+ __ ldr(x4, MemOperand(fp, StandardFrameConstants::kCallerSPOffset + |
+ i * kPointerSize)); |
+ __ push(x4); |
+ } |
+ // 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(x0, &failed); |
+ scope.GenerateLeaveFrame(); |
+ __ Drop(4); |
+ __ Ret(); |
+ |
+ __ bind(&failed); |
+ // Restore target function and new target. |
+ __ Pop(x3, x1, x0); |
+ __ SmiUntag(x0); |
+ } |
+ // 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 |