Live data from Hacker News

I Wrote a WebAssembly VM in C

irreducible.io

51–60 of 104 posts

Re: I Wrote a WebAssembly VM in C

#51
Regarding using WebAssembly as a plugin API, like for zed:

how do plugin developers debug their code? Is there a way for them to do breakpoint debugging for example? What happens if their code crash, do they get a stacktrace?

Re: I Wrote a WebAssembly VM in C

#52

This 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…

Um, the author is clearly familiar enough with Wasm, but probably knows enough to know to avoid a company that tried to trademark WebAssembly. > understandable concerns about the fact we, Wasmer, a VC-backed corporation, attempted to trademark the name of a non-profit organization, specifically WebAssembly Acknowledgement of wrongdoing.

Just for defensive purposes obviously

Re: I Wrote a WebAssembly VM in C

#53
post #5

Earlier quoted context omitted.

I know one of WebAssembly's biggest features by design is security / "sandbox". But I've always gotten confused with... it is secure because by default it can't do much. I don't quite understand how to view WebAssembly. You write in one language, it compiles things like basic math (nothing with network or filesystem) to another and it runs in an interpreter. I feel like I have a severe lack/misunderstanding. There's…

WebAssembly can communicate through buffers. WebAssembly can also import foreign functions (Javascript functions in the browser). You can get output by reading the buffer at the end of execution/when receiving callbacks. So, for instance, you pass a few frames worth of buffers to WASM, WASM renders pixels into the buffers, calls a callback, and the Javascript reads data from the buffer (sending it to a or similar). T…

WASI Preview 1 and WASI Preview 2 can do file and network I/O IIUC.

Re: tty support in container2wasm and fixed 80x25 due to lack of SIGWINCH support in WASI Preview 1: https://github.com/ktock/container2wasm/issues/146

The File System Access API requires granting each app access to each folder.

jupyterlab-filesystem-access only works with Chromium based browsers, because FF doesn't support the File System Access API: https://github.com/jupyterlab-contrib/jupyterlab-filesystem-...

The File System Access API is useful for opening a local .ipynb and .csv with JupyterLite, which builds CPython for WASM as Pyodide.

There is a "Direct Sockets API in Chrome 131" but not in FF; so WebRTC and WebSocket relaying is unnecessary for WASM apps like WebVM: https://news.ycombinator.com/item?id=42029188

Re: I Wrote a WebAssembly VM in C

#54
post #5

Earlier quoted context omitted.

WebAssembly can communicate through buffers. WebAssembly can also import foreign functions (Javascript functions in the browser). You can get output by reading the buffer at the end of execution/when receiving callbacks. So, for instance, you pass a few frames worth of buffers to WASM, WASM renders pixels into the buffers, calls a callback, and the Javascript reads data from the buffer (sending it to a or similar). T…

WASI Preview 1 and WASI Preview 2 can do file and network I/O IIUC. Re: tty support in container2wasm and fixed 80x25 due to lack of SIGWINCH support in WASI Preview 1: https://github.com/ktock/container2wasm/issues/146 The File System Access API requires granting each app access to each folder. jupyterlab-filesystem-access only works with Chromium based browsers, because FF doesn't support the File System Access API…

WASI Preview 2: https://github.com/WebAssembly/WASI/blob/main/wasip2/README.... :

> wasi-io, wasi-clocks, wasi-random, wasi-filesystem, wasi-sockets, wasi-cli, wasi-http

Re: I Wrote a WebAssembly VM in C

#55
post #48
post #35

Earlier quoted context omitted.

I hadn't heard about this - terrible.

Read the whole blogpost that quote was taken from: https://wasmer.io/posts/wasmer-and-trademarks-extended I don't think this is as much of a smoking gun as it is made out to be.

Attention is all we need.

Re: I Wrote a WebAssembly VM in C

#56

Earlier quoted context omitted.

Indeed, we need to improve further the base binary size! Most of the size comes from the LLVM backend, which is a bit heavy. Wasmer ships many backends by default, and if you were to use Wasmer headless that would be just a bit less than a Mb. If you want, you can always customize the build with only the backends that you are interested in using. Note: I've seen some builds of LLVM under 5-10Mb, but those require hea…

So you are shipping all of llvm?

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.

Re: I Wrote a WebAssembly VM in C

#57
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.

Re: I Wrote a WebAssembly VM in C

#58

Earlier quoted context omitted.

So you are shipping all of llvm?

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

#59
Newbie questions:

How do you debug an interpreter when you aren't coding for it directly? How far does fuzzing strings of opcodes get you?

How much practical difference is there between a server side WASM engine and a browser-based one? How much work would be involved converting one to the other?

Re: I Wrote a WebAssembly VM in C

#60

One tip for the author from another one, the spec-test contains various weird forms of textual wasm that isn't obvious how to compile but the wast2json converter can produce a simpler JSON desc accompanies by regular binary wasm files.

Thank you! Not the author, but I'm also building a compiler. I've stumbled across these tests before and mostly just been irritated and confused about what to do with them.
Post reply on HN