-
Notifications
You must be signed in to change notification settings - Fork 454
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Are un-exitable blocks ok to ignore? #355
Comments
The blocks have a declared type now, so the |
@JSStats I'm not sure I follow that. Is it documented somewhere? Anyhow, the more I think about it, the less I think I understand what "ok to ignore unreachable code" means. Here is a larger example from the fuzzer:
This is accepted as valid by the spec interpreter. Note that the second In other words, it looks like the spec interpreter is not ignoring unreachable code, as changes to unreachable code affect it. I guess since it's ok but not mandated to ignore such code, it's ok to either report an error or not report an error? But that raises two questions:
Note btw that corner cases like the above appear to not be tested (or it is only tested in |
IIRC there's a TODO in the interpreter for a "soft error" that it would On Tue, Oct 4, 2016 at 3:58 PM Alon Zakai notifications@github.com wrote:
|
@dschuff: Yeah, I just saw the soft error stuff in #345 thanks to @sunfishcode. I just tried that branch though, and it doesn't affect the testcase in #355 (comment). That is, even with that branch that reintroduces type-checking dead code, there is unreachable code that cannot be removed, and I'm not sure that makes sense. |
Can Binaryen replace the I'd personally prefer that the spec either required or prohibited validation of unreachable code. Optional validation increases the burden on producers, since you can't even be sure you've produced valid code if it validates on a single implementation. From an implementation point of view, validating unreachable code is simpler than not. The only argument for optional validation seems to be performance, but it's hard to imagine a situation where there's a lot of unreachable code and validation is the bottleneck rather than the download. |
@kripken It seems a long standing design decision that There is still a design issue to be resolved for the block fall-through, it's almost resolved, a block has a declared type now and the block fall-through can now have the same semantics as a branch out. I'd suggest that binaryen just end blocks with I don't think binaryen should be running DCE on tests intended to check that dead code is valid. It's fine to run DCE but it then changes the test. |
Yeah, that's exactly what it does if it can't eliminate the code entirely, so it's what happens after I made it not remove the return (WebAssembly/binaryen#736).
I think the same. |
There was a proposal to have a branch out of a block end the block, and was there some show-stopper that prevented that from being practical? |
WebAssembly/design#778 - I'm not aware of any show-stoppers for the proposal, but it wouldn't change affect a return following an unreachable block end, as in this issue. |
Any progress here?
Can people agree on this as the next step? This might result in some potentially unnecessary uses of |
That's a fair question. I suppose it depends on whether you prefer to view In any case, the license to skip validation of unreachable code specifically does not mean that any unreachable code is considered valid. Just that the engine doesn't need to check. The spec interpreter performs full checking, obviously (and so does V8). So your first example is invalid, even if some engines might happen to not notice. (Fixing the block signature is enough to make it valid.) As @dschuff says, that implies that producers need to generate type-correct code, even if it's unreachable. However, the type system is intentionally designed such that an @AndrewScheidecker, I would likewise prefer to make type-checking of unreachable code mandatory, but we could not agree on that after long discussion, hence the compromise. @JSStats, there is no dispute that the type of a block always is its declared type. The question only is whether an engine needs to check that if its end is unreachable. |
@rossberg-chromium: regarding the first example, I'm still not sure I follow. Consider it and a variation:
The block in One downside of this is as follows: say I have a node |
@kripken: This seems to be the general trend of the format for preferring consumers over producers. It is now the producer's responsibility to annotate types up-front. So in your example, you'll have to determine the type of Anyway, the issue with your example isn't the |
@binji: yeah, I guess this is part of a trend to prefer consumers over producers. But I still don't quite see the benefit to consumers, though - why is it easier for them to not propagate the |
Not sure, but I assume the benefit is in having the block signatures up-front. But as soon as you have explicit types on blocks, it seems weird to me to ignore those when the content is unreachable. What you're suggesting is equivalent to this:
The unreachable doesn't propagate past the function boundary, because we rely on the function signature for type checking, not the contents of the function. |
Yeah, I see your point, the simple thing is to always use the block signature. Ok, the downsides of this for producers are annoying - in particular not being able to do simple transformations like |
Add pmin/pmax and mark pmin/pmax and floating-point rounding instructions as implemented on both V8 and SM (based on this mozilla/gecko-dev@8070228).
[test] Add tentative JS API tests for Exported GC Object
It's my understanding that it is ok to ignore unreachable code. Does a block whose end is never reached count as unreachable code? Example:
The block is entered but never exited. The spec interpreter doesn't accept this, but binaryen does (it gives the block type
unreachable
, just like it would to e.g.(i32.ctz (unreachable))
).The text was updated successfully, but these errors were encountered: