| ▲ | trj 3 days ago | |
I'm working on an embeddable mini VM (RISC-V rather than WASM) and am considering this. In my model, there's something akin to a hardware watchdog where the VM is considered hung if it executes too many instructions without calling a yield() function in the host, then there's the ability to set a maximum number of instructions to execute before returning to the caller. This lets it be handled asynchronously at the pace the host code chooses https://github.com/ringtailsoftware/uvm32 | ||
| ▲ | usrnm 3 days ago | parent [-] | |
Lua has hooks, which are callbacks that can be registered for a variety of different events, including every N instructions, and every call can decide to terminate the whole thing with an error. This mechanism can be used for different purposes, including tracing, some kind of performance stats and, of course, cancellation. I always found it to be a nice general solution. | ||