I wonder what it would take to make a version that works on Windows. Will you indulge me?
I wonder what it would take to make a version that works on Windows. Will you indulge me?
In fact the exact same assembly works across Windows, macOS, Linux and FreeBSD: the calling convention used by the compiler is entirely custom, and all "host calls" are provided by wazero, so assembly ports fine across OSes.
> The following is the tiny demo of the runtime code generation and execution in Go. I assume you are on a Unix-like system like Linux or macOS on an AArch64 machine.
Is there a way to get tinydemo working on Windows?
You need to replace calls to syscall.Mmap with windows.VirtualAlloc [1], syscall.Mprotect with windows.VirtualProtect, etc.
You don't even need to change the ASM preamble.
[1]: https://pkg.go.dev/golang.org/x/sys/windows#VirtualAlloc