Hacker News new | past | comments | ask | show | jobs | submit login

Yes, they can. You instrument the module/byte code/JIT'd code to consume a virtual "gas", and when it's consumed, execution returns to the host. E.g., in wasmtime: https://docs.rs/wasmtime/latest/wasmtime/struct.Config.html#...

(I presume the browsers implement something similar, but I've not tested it to see.)




No browser I'm aware of implements that under normal circumstances.

If you run with the debugger open they do tend to insert a lot of instrumentation to enable pausing/breakpoints/etc but that comes at a massive performance hit - in some cases 'debugger open' WASM is slower than JS.


Interesting. I figured they would, given that "normal" JS will happily get aborted if it uses 100%. ("This site is slowing your machine down", etc.)


My guess is that the performance overhead of inserting it into wasm was judged unacceptable. It's a little odd to me, I was surprised when I discovered I couldn't realistically pause a tab running wasm benchmarks - often when I try to close the chrome tab it just hangs.

The runtime I work on (.NET) inserts safepoints at back branches in some cases specifically to enable pausing for GC. It wouldn't surprise me if using WASM GC would cause the runtime to start inserting safepoints as well.




Consider applying for YC's W25 batch! Applications are open till Nov 12.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: