I feel the need to repost this link: https://www.destroyallsoftware.com/talks/the-birth-and-death...
I'm somewhat curious at what pace WASM will gain "market share" while it's only practical to target it with C, C++, Rust, etc. Supposedly, there are plans to expand it to where it looks more like a virtual machine and less like ASM. Adding things like garbage collection, direct DOM manipulation, polymorphic inline cache, etc. Things that would make it possible to run a decent scripting language without pulling in som…
Wasm3 compiles itself (using LLVM/Clang compiled to WASM)
21–30 of 106 posts
Re: Wasm3 compiles itself (using LLVM/Clang compiled to WASM)
#22For those wondering, Wasm3 describes itself as "the fastest WebAssembly interpreter". Other webassembly runtimes are JIT based, rather than being interpreters. The project's readme ( https://github.com/wasm3/wasm3 ) talks more about this decision. For more on the difference, and an explanation of what JIT is, check out this section of the book Crafting Interpreters ( https://craftinginterpreters.com/a-map-of-the-terr…
> Other webassembly runtimes are JIT based, rather than being interpreters. Do none of the notable ones do normal compilation?
Re: Wasm3 compiles itself (using LLVM/Clang compiled to WASM)
#23Earlier quoted context omitted.
An AOT compiler would do a one-time translation to a platform-specific binary. If the environment you run on doesn’t support JIT compilation (iOS for example), AOT compiling WASM is useful.
How can a platform not support j.i.t. compilation? In what way does a platform need to coöperate with that?
To support that, the environment must allow the JIT to write machine code to memory, and then execute that same code.
CPUs have memory protection flags to control which memory areas can be written, and which can be executed. The OS is in charge of setting those flags, on request from the application. Eg. mmap and mprotect system calls.
iOS denies requests for memory that is both writable and executable at the same time. So applications cannot get the type of memory area a JIT needs. There are indirect methods where a file is written then mapped, like generating a small program or shared library on the fly. But iOS restricts these as well.
There are workarounds for a developer's personal applications, used on their own registered iOS devices. But these workarounds cannot be run by everyone else, except people with a jailbroken iOS. They cannot be used in applications on the App Store.
Re: Wasm3 compiles itself (using LLVM/Clang compiled to WASM)
#24I feel the need to repost this link: https://www.destroyallsoftware.com/talks/the-birth-and-death...
I'm somewhat curious at what pace WASM will gain "market share" while it's only practical to target it with C, C++, Rust, etc. Supposedly, there are plans to expand it to where it looks more like a virtual machine and less like ASM. Adding things like garbage collection, direct DOM manipulation, polymorphic inline cache, etc. Things that would make it possible to run a decent scripting language without pulling in som…
Doesnt this just imply building a 'huge runtime' into the language?
Re: Wasm3 compiles itself (using LLVM/Clang compiled to WASM)
#25Earlier quoted context omitted.
It seems like it's headed that way. At the moment, it's only really practical to generate WASM from compiled languages, or really small languages, like Lua. And your interfaces to the browser (and thus, the outside world) itself are pretty limited, so still lots of javascript involved.
Can confirm that Lua does run in WASM in the browser: https://github.com/vvanders/wasm_lua I sometimes wonder what the world would be like if Lua had zero based indices and saw a bit broader adoption. It's such an easy language to embed/extends although QuickJS looks like it's going to give it a run for the money in the long term given the similar goals on ease of embedding. I wonder if anyone has compiled QuickJS to…
Fabrice Bellard actually did it himself here: http://numcalc.com/
Re: Wasm3 compiles itself (using LLVM/Clang compiled to WASM)
#26Earlier quoted context omitted.
I'm somewhat curious at what pace WASM will gain "market share" while it's only practical to target it with C, C++, Rust, etc. Supposedly, there are plans to expand it to where it looks more like a virtual machine and less like ASM. Adding things like garbage collection, direct DOM manipulation, polymorphic inline cache, etc. Things that would make it possible to run a decent scripting language without pulling in som…
I think WASM success won't be measured by market share gain on the web, but by number of new non-browser things that are programmed with WASM.
[0]: https://forums.flightsimulator.com/t/getting-started-with-wa... [1]: https://news.ycombinator.com/item?id=24281400
Re: Wasm3 compiles itself (using LLVM/Clang compiled to WASM)
#27I feel the need to repost this link: https://www.destroyallsoftware.com/talks/the-birth-and-death...
I'm somewhat curious at what pace WASM will gain "market share" while it's only practical to target it with C, C++, Rust, etc. Supposedly, there are plans to expand it to where it looks more like a virtual machine and less like ASM. Adding things like garbage collection, direct DOM manipulation, polymorphic inline cache, etc. Things that would make it possible to run a decent scripting language without pulling in som…
Seems to me the web already has an answer for that: transpile to JavaScript, and leverage the existing high-performance JavaScript engines.
Dart does this, for instance.
Re: Wasm3 compiles itself (using LLVM/Clang compiled to WASM)
#28Would be fun to make it so that native apps for any platform can be run from an interpreter
Re: Wasm3 compiles itself (using LLVM/Clang compiled to WASM)
#29I'm a newer dev so pardon my ignorance. Is webassembly the new, more open JVM? Feels like that write once, run everywhere but this time with any(most) mainstream language.
As I understand, the JVM adds a thick layer of abstraction between incoming bytecode and output machine instructions. A wasm "runtime" OTOH adds a much thinner abstraction between incoming wasm and outputted machine code. It's a fairly 1:1 transformation.
However, I think you're correct in that, in order to serve as a host for GC'd and/or web-API-aware scripting languages (DOM, etc), a wasm runtime will need to become more JVM-like. How will wasm remain "web assembly" while doing that? No idea. This is where my mental model breaks down.
Re: Wasm3 compiles itself (using LLVM/Clang compiled to WASM)
#30Has anyone built a compiler extension and libffi-based runtime that supports compiling otherwise normal native code to WASM (eschewing hard linking for runtime resolution)? Would be fun to make it so that native apps for any platform can be run from an interpreter