I Wrote a WebAssembly VM in C
71–80 of 104 posts
Re: I Wrote a WebAssembly VM in C
#72Earlier quoted context omitted.
Lisp and Smalltalk are 266 MB? tcc is 100KB https://www.bellard.org/tcc/
TCC doesn't do much optimization in turn, while commercial implementations of Lisp and Smalltalk are surely much larger than that.
Re: I Wrote a WebAssembly VM in C
#73Earlier quoted context omitted.
TCC doesn't do much optimization in turn, while commercial implementations of Lisp and Smalltalk are surely much larger than that.
I'm not sure what your point is. The person I replied to was justifying a 266MB binary by saying a compiler was included. Are you saying optimization would make tcc 2,660 times as big?
Re: I Wrote a WebAssembly VM in C
#74This is an interesting approach, great work! For anyone that wants to check where the meat is at, is mostly in this file: https://github.com/irrio/semblance/blob/main/src/wrun.c Thinking out loud, I think it would have been a great idea to conform with the Wasm-C-API ( https://github.com/WebAssembly/wasm-c-api ) as a standard interface for the project (which most of the Wasm runtimes: Wasmer, V8, wasmi, etc. have ado…
Re: I Wrote a WebAssembly VM in C
#75Earlier quoted context omitted.
I'm not sure what your point is. The person I replied to was justifying a 266MB binary by saying a compiler was included. Are you saying optimization would make tcc 2,660 times as big?
The point is that LLVM does much, much more than TCC and, while it is definitely possible that LLVM could have done that in a smaller binary, TCC is probably not a good thing to compare with because it only does a bare minimum. I should also note that LLVM is a cross-compiler by default...
https://github.com/bytecodealliance/wasm-micro-runtime
This says 4000 lines
https://github.com/explodingcamera/tinywasm
What are we talking about here? There is obviously no reason a wasm jit has to be 266 MB
Re: I Wrote a WebAssembly VM in C
#76This is an interesting approach, great work! For anyone that wants to check where the meat is at, is mostly in this file: https://github.com/irrio/semblance/blob/main/src/wrun.c Thinking out loud, I think it would have been a great idea to conform with the Wasm-C-API ( https://github.com/WebAssembly/wasm-c-api ) as a standard interface for the project (which most of the Wasm runtimes: Wasmer, V8, wasmi, etc. have ado…
afaik it's far from adopted by Wasmer. https://github.com/wasmerio/wasmer/issues/2615 - stale then autoclosed
Wasmer supports most of the Wasm-C-API, with some exceptions for APIs that are not that common to use: finalize, hostref and threads (tables just had some quirks on the implementation that we had to polish, but is generally implemented [1]).
https://github.com/wasmerio/wasmer/blob/main/lib/c-api/tests...
If you are interested in running any of these cases using Wasmer via the Wasm-C-API please let us know... it should be mostly trivial to add support!
[1] https://github.com/wasmerio/wasmer/blob/main/lib/c-api/src/w...
Re: I Wrote a WebAssembly VM in C
#77Earlier quoted context omitted.
This is an opportunity to learn. The way WebAssembly is defined is the standard way PL semantics are defined.
WebAssembly isn't a programming language, it's an ISA or a bytecode VM. They've defined it in a very over-engineered way, with different representations all the way through. It has created issues for people working on assemblers and code generation because it's hard to choose a good representation for compilers to generate. This all could have been avoided.
Re: I Wrote a WebAssembly VM in C
#78Earlier quoted context omitted.
I think it's much better to just learn how to read inference rules. They're actually quite simple, and are used ubiquitously to define PL semantics definitions. Constraining this on "that's not an option" is a big waste of time - learning this will open up all of the literature written on the subject.
The WASM spec is so well defined presumably because Andreas Rossberg is the editor - and he did a bunch of PL research on extensions to Standard ML, which is famous for it's specification!
Re: I Wrote a WebAssembly VM in C
#79Earlier quoted context omitted.
> 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…
How do you avoid branches in 64-bit WASM?
Re: I Wrote a WebAssembly VM in C
#80Earlier quoted context omitted.
afaik it's far from adopted by Wasmer. https://github.com/wasmerio/wasmer/issues/2615 - stale then autoclosed
It seems the issue was not up to date, thanks for pointing it out (just commented in Github to make it clear for future readers). Wasmer supports most of the Wasm-C-API, with some exceptions for APIs that are not that common to use: finalize, hostref and threads (tables just had some quirks on the implementation that we had to polish, but is generally implemented [1]). https://github.com/wasmerio/wasmer/blob/main/lib…