dylibso / chicory

Native JVM WebAssembly runtime
Apache License 2.0
365 stars 31 forks source link

Exception passthrough #338

Open SoniEx2 opened 2 months ago

SoniEx2 commented 2 months ago

It would be nice to have some way to pass (most) exceptions through, instead of having them wrapped in WASMMachineException.

In particular because WASMMachineException is extremely slow for the things this little special constructor enables one to do. The specific pattern is usually called "non-local control flow".

Granted, one can still use Error for this purpose, since Error has similar semantics to RuntimeException and also includes the appropriate constructor. And using Error for "normal occurrences" isn't completely unheard of.

andreaTP commented 2 months ago

Thanks for opening this issue!

The specific pattern is usually called "non-local control flow".

I have a few questions/doubts about enabling this functionality, at this stage of the project.

If you are able to share a concrete use case(although slow) it will be great, so that we can continue the discussion being sure we are on the same page.

SoniEx2 commented 2 months ago

Sure! Running pre-EH emscripten modules that make heavy use of setjmp/longjmp, for starters. (Does chicory even support wasm EH at this point?) This includes things such as Lua.

andreaTP commented 2 months ago

Does chicory even support wasm EH at this point?

Not yet, if I understand it correctly we can evaluate this request after we have a more solid exception handling story.

SoniEx2 commented 2 months ago

Yes, the pre-EH system exists for runtimes that don't support EH, like Chicory. Except it doesn't work with Chicory properly. Unless you implement it on top of Error.