Here is a more controversial point: Are you interested in adding a preliminary tail-call instruction? The WASM spec people rejected it for being too "high-level". But the C committee also rejected proposals from Dennis Ritchie. My money is still on Ritchie. Rob Pike's money seems to be on Ritchie direction as well. Otherwise, why create Golang? Tail-calls are only high-level if calls are high-level.
I Wrote a WebAssembly VM in C
61–70 of 104 posts
Re: I Wrote a WebAssembly VM in C
#62Earlier quoted context omitted.
Well, if you want to just-in-time compile, then it seems like a compiler is one way to go. They are now in the size realm of Lisp and Smalltalk. Forth may lean towards the lighter side.
Lisp and Smalltalk are 266 MB? tcc is 100KB https://www.bellard.org/tcc/
Re: I Wrote a WebAssembly VM in C
#63This is great! The WebAssembly Core Specification is actually quite readable, although some of the language can be a bit intimidating if you're not used to reading programming language papers. If anyone is looking for a slightly more accessible way to learn WebAssembly, you might enjoy WebAssembly from the Ground Up: https://wasmgroundup.com (Disclaimer: I'm one of the authors)
Re: I Wrote a WebAssembly VM in C
#64This is great! The WebAssembly Core Specification is actually quite readable, although some of the language can be a bit intimidating if you're not used to reading programming language papers. If anyone is looking for a slightly more accessible way to learn WebAssembly, you might enjoy WebAssembly from the Ground Up: https://wasmgroundup.com (Disclaimer: I'm one of the authors)
I bought the early access of your book a while ago and completed the first few chapters which were available. I found it a fantastic resource, and I was keen to continue but other responsibilities have gotten in the way since. I recommend it!
If you haven't looked at it in a while — we just published a draft of the final technical chapter, and are planning an official launch on March 4. So, might be a good time to dig back in :-)
Re: I Wrote a WebAssembly VM in C
#65Here is a more controversial point: Are you interested in adding a preliminary tail-call instruction? The WASM spec people rejected it for being too "high-level". But the C committee also rejected proposals from Dennis Ritchie. My money is still on Ritchie. Rob Pike's money seems to be on Ritchie direction as well. Otherwise, why create Golang? Tail-calls are only high-level if calls are high-level.
The WebAssembly tail call proposal has been accepted, finished, and implemented for over two years now. https://github.com/WebAssembly/meetings/blob/main/main/2023/...
Re: I Wrote a WebAssembly VM in C
#66Re: I Wrote a WebAssembly VM in C
#67Earlier quoted context omitted.
Well, if you want to just-in-time compile, then it seems like a compiler is one way to go. They are now in the size realm of Lisp and Smalltalk. Forth may lean towards the lighter side.
Lisp and Smalltalk are 266 MB? tcc is 100KB https://www.bellard.org/tcc/
Re: I Wrote a WebAssembly VM in C
#68Earlier quoted context omitted.
A JIT should be able to translate most arithmetic and binary instructions to single-opcodes, however anything involving memory and functions calls needs safety checks that becomes multi-instruction. branches could mostly be direct _unless_ the runtime has any kind of metering (it should) to stop eternal loops (if it also wants to be crash-safe even if it's exploit safe).
> anything involving memory [..] needs safety checks that becomes multi-instruction Not necessarily; on AMD64 you can do memory accesses in a single instruction relatively easily by using the CPU's paging machinery for safety checks plus some clever use of address space. > branches could mostly be direct _unless_ the runtime has any kind of metering (it should) to stop eternal loops Even with metering the branches wo…
Re: I Wrote a WebAssembly VM in C
#69Earlier quoted context omitted.
> actually quite readable, although some of the language can be a bit intimidating if you're not used to reading programming language papers You're more generous than me, I think it's rubbish. Would have been easier to read if they had written it more like an ISA manual.
You can understand the WASM spec in your sleep if you’ve ever worked through a type-system paper from the last two decades (or a logic paper from even earlier I guess). Granted, not many people have, but there’s a reason why it makes sense for it to be written in that style: they want it to be very clear that the verification (typechecking, really) algorithm doesn’t have any holes, and for that it’s reasonable to spe…
Is there a lot of crossover between those people and people who work with assemblers or code generation? There's even more crossover with those people and understanding how to read a minimal ISA document.
Re: I Wrote a WebAssembly VM in C
#70Earlier quoted context omitted.
> actually quite readable, although some of the language can be a bit intimidating if you're not used to reading programming language papers You're more generous than me, I think it's rubbish. Would have been easier to read if they had written it more like an ISA manual.
This is an opportunity to learn. The way WebAssembly is defined is the standard way PL semantics are defined.