You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In V8 we have the additional problem that we use the same stack overflow detection for WebAssembly and JavaScript. This makes it difficult for us to throw a different exception for stack overflows in WebAssembly.
For these reasons I think that in the case of stack overflows, being consistent with JavaScript is more important than being consistent within WebAssembly. Since the exception for stack overflows is browser dependent (at the moment), I suggest to leave the exception type of stack overflows undefined.
I feel like this might've been discussed recently with @rossberg-chromium in an issue. The resolution though agreed with you: while all traps may throw a RuntimeError, stack overflow isn't a trap.
lukewagner, I believe stack overflow only came up in the context of what errors to use for signalling resource exhaustion in the JS API grow methods.
Anyways, agreed with the conclusion. Since browsers disagree on the exception used for JS SO, the design doc should probably just state that Wasm uses the same exn.
Pondering a bit, I guess the actual question here is whether we want future Wasm to be able to handle traps and whether that should include stack overflow. If so, then stack overflow should remain a regular trap/RuntimeError, and moreover any stack overflow caused while calling back from Wasm into JS should also be mapped to a trap.
From either a wasm or JS perspective, whether a stack overflow occurred in JS vs. wasm probably isn't a meaningful distinction and I think you'd want one way to catch both. One way to achieve this is to say that, to JS, stack overflow is reported using the same exception type as a current JS stack overflow. However, when we allow catching in wasm, we won't specifically refer to WebAssembly.RuntimeError (b/c RuntimeError is a JS API detail from wasm's pov), but rather I would think the catch block would more abstractly refer to wasm traps via a trap code. We could then have a specific stack-overflow trap code that matched both wasm and JS stack overflows.
I changed Semantics.md so that stack overflows are not called traps anymore, and I handle stack overflows explicitly in JS.md. I think this is a clean solution for now.
When we allow catching in wasm, then we have to define how we deal with stack overflows and exceptions in imported (JS) functions. I think we can define the handling of WebAssembly stack overflow the same as the handling of these exceptions in imported functions.
Activity
jfbastien commentedon Nov 10, 2016
Sounds fine.
lukewagner commentedon Nov 10, 2016
I feel like this might've been discussed recently with @rossberg-chromium in an issue. The resolution though agreed with you: while all traps may throw a
RuntimeError, stack overflow isn't a trap.rossberg commentedon Nov 11, 2016
lukewagner, I believe stack overflow only came up in the context of what errors to use for signalling resource exhaustion in the JS API grow methods.
Anyways, agreed with the conclusion. Since browsers disagree on the exception used for JS SO, the design doc should probably just state that Wasm uses the same exn.
rossberg commentedon Nov 16, 2016
Pondering a bit, I guess the actual question here is whether we want future Wasm to be able to handle traps and whether that should include stack overflow. If so, then stack overflow should remain a regular trap/RuntimeError, and moreover any stack overflow caused while calling back from Wasm into JS should also be mapped to a trap.
Define the exception type for stack overflows
lukewagner commentedon Nov 16, 2016
From either a wasm or JS perspective, whether a stack overflow occurred in JS vs. wasm probably isn't a meaningful distinction and I think you'd want one way to catch both. One way to achieve this is to say that, to JS, stack overflow is reported using the same exception type as a current JS stack overflow. However, when we allow catching in wasm, we won't specifically refer to
WebAssembly.RuntimeError(b/cRuntimeErroris a JS API detail from wasm's pov), but rather I would think the catch block would more abstractly refer to wasm traps via a trap code. We could then have a specific stack-overflow trap code that matched both wasm and JS stack overflows.gahaas commentedon Dec 12, 2016
Please take a look at #875
I changed Semantics.md so that stack overflows are not called traps anymore, and I handle stack overflows explicitly in JS.md. I think this is a clean solution for now.
When we allow catching in wasm, then we have to define how we deal with stack overflows and exceptions in imported (JS) functions. I think we can define the handling of WebAssembly stack overflow the same as the handling of these exceptions in imported functions.
jfbastien commentedon Dec 15, 2016
This is done, closing.