Index: src/builtins/x64/builtins-x64.cc |
diff --git a/src/builtins/x64/builtins-x64.cc b/src/builtins/x64/builtins-x64.cc |
index b4f63c6a33b08dbb840e8b9895477fe53f38ddb2..f3d6f252de8442a5a15155f90427bbdfc08769c5 100644 |
--- a/src/builtins/x64/builtins-x64.cc |
+++ b/src/builtins/x64/builtins-x64.cc |
@@ -3185,6 +3185,41 @@ void Builtins::Generate_InterpreterOnStackReplacement(MacroAssembler* masm) { |
Generate_OnStackReplacementHelper(masm, true); |
} |
+void Builtins::Generate_WasmCompileLazy(MacroAssembler* masm) { |
+ { |
+ FrameScope scope(masm, StackFrame::INTERNAL); |
+ |
+ // Save all parameter registers (see wasm-linkage.cc). They might be |
+ // overwritten in the runtime call below. |
+ // Other registers (like context and root) are not relevant here. The |
+ // CEntryStub will overwrite them anyway. |
+ constexpr Register gp_regs[]{rax, rbx, rcx, rdx, rsi, rdi}; |
+ constexpr XMMRegister xmm_regs[]{xmm1, xmm2, xmm3, xmm4, xmm5, xmm6}; |
+ |
+ for (auto reg : gp_regs) __ Push(reg); |
+ __ subp(rsp, Immediate(16 * arraysize(xmm_regs))); |
+ for (int i = 0, e = arraysize(xmm_regs); i < e; ++i) { |
+ __ movdqu(Operand(rsp, 16 * i), xmm_regs[i]); |
+ } |
+ |
+ // Initialize rsi register with kZero, CEntryStub will use it to set the |
+ // current context on the isolate. |
+ __ Move(rsi, Smi::kZero); |
+ __ CallRuntime(Runtime::kWasmCompileLazy); |
+ // Store returned instruction start in r11. |
+ __ leap(r11, FieldOperand(rax, Code::kHeaderSize)); |
+ |
+ // Restore registers. |
+ for (int i = arraysize(xmm_regs) - 1; i >= 0; --i) { |
+ __ movdqu(xmm_regs[i], Operand(rsp, 16 * i)); |
+ } |
+ __ addp(rsp, Immediate(16 * arraysize(xmm_regs))); |
+ for (int i = arraysize(gp_regs) - 1; i >= 0; --i) __ Pop(gp_regs[i]); |
+ } |
+ // Now jump to the instructions of the returned code object. |
+ __ jmp(r11); |
+} |
+ |
#undef __ |
} // namespace internal |