3 ms·
Really cool article. This sort of stuff is mind expanding for me! I wonder what it would take to make a version that works on Windows. Will you indulge me?
by metadat 2y ago
Really cool article. This sort of stuff is mind expanding for me!
I wonder what it would take to make a version that works on Windows. Will you indulge me?
- ncruces 2y agowazero works fine on Windows. 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.
- metadat 2y agoPerhaps I was unclear (or I'm confused now, haha): > 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?
- ncruces 2y agoOh, OK. 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 https://pkg.go.dev/golang.org/x/sys/windows#VirtualAlloc
- evacchi 2y agoand for reference see how it's done in wazero https://github.com/tetratelabs/wazero/blob/c397a402ad17e495a5a22fef709a1d4abef1f3ce/internal/platform/mmap_windows.go https://github.com/tetratelabs/wazero/blob/c397a402ad17e495a...