Skip to content
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

Reflect spec changes in delegate immediate operand #178

Merged
merged 9 commits into from
Sep 15, 2021

Conversation

aheejin
Copy link
Member

@aheejin aheejin commented Sep 7, 2021

This adds the changes decided in #176 and adds a modified version from
#146 (comment)
for clarification. (The example is not the same by the way; the catch
from the outermost try has been moved)

Closes #176.

This adds the changes decided in WebAssembly#176 and adds a modified version from
WebAssembly#146 (comment)
for clarification. (The example is not the same by the way; the `catch`
from the outermost `try` has been moved)

Closes WebAssembly#176.
Copy link
Member

@rossberg rossberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, LGTM, merely some nits.

Comment on lines 310 to 313
`delegate` can only target `catch`/`catch_all`s that are below the current
instruction, i.e., it can only delegate downwards. It also targets all
`catch`/`catch_all`s of a `try` as a whole and does not target individual
`catch`/`catch_all` within a `try`. Here is another example:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Delegate is no longer targeting catch after this change, it simply targets a block. I would perhaps rephrase this accordingly and say that all properties of Wasm's structured control flow labels apply, i.e., you can only target labels of outer blocks.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, but the example below is, the delegate targets $l1, which is outside of the instruction because the label is attached to the try, but because it is below catch so it ends up not targeting $l1 but rather $l0, and this was what I tried to explain. Do you think simply describing that delegate target labels of outer blocks can explain this case?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rossberg Do you still think this needs fixing?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say s.th like this:

"""
Like branches, delegate can only target outer blocks, and effectively rethrows the exception in that block. Consequently, delegating to a specific catch or catch_all handler requires targeting the respective label from within the associated try block. Delegating to a label from within a catch block does delegate the exception to the next enclosing handler -- analogous to performing a throw within a catch block, that handler is no longer active at that point.
"""

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

proposals/exception-handling/Exceptions.md Outdated Show resolved Hide resolved
aheejin and others added 2 commits September 7, 2021 16:06
Co-authored-by: Thibaud Michaud <thibaudmichaud.1@gmail.com>
Co-authored-by: Andreas Rossberg <rossberg@mpi-sws.org>
```
In case `foo` throws, `delegate 1` here delegates the exception handling to the
caller, i.e., the exception escapes the current function. If the immediate is
greater than the depth of the outermost block + 1, it is a validation failure.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be "greater than or equal to"? (or "depth of the outermost block" without +1?)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, yeah, "the depth of the outermost block" is confusing. I tried to rephrase it to

If the immediate is greater than the number of block nesting including the implicit function-level block, it is a validation failure.

Do you think it's better?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there's still some potential for confusion if someone interprets "number of block nesting" as counting from 1 and not 0. (In the example right above here you might count nestings of try and function body as 2, but immediates >=2 are not allowed here) Perhaps it could explicitly say it's counting from zero?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, yeah, it should change to "greater than equal to". Intuitively the level of nesting is a number > 0 when there's any, and that's what I meant too. I changed it to

If the immediate is greater than or equal to the number of block nesting including the implicit function-level block, it is a validation failure. In this example, any number equal to or greater than 2 is now allowed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh... now allowed -> not allowed...

@aheejin
Copy link
Member Author

aheejin commented Sep 14, 2021

@takikawa I'm not very familiar with what the status of newly added CI is, but is it expected to fail? This PR doesn't modify anything with the interpreter or the spec tests though.

@takikawa
Copy link
Collaborator

takikawa commented Sep 14, 2021

@aheejin Yes, it should be ok that these two things (ref interpreter & core spec) are failing, and it should be ok to just merge. Sorry for the confusion.

The issue with the interpreter CI is that the interpreter changes haven't been merged yet so the exception tests don't pass (BTW, did you or anyone else want to look at that PR more or should I merge it as it has one approval already?), but it should be ok after it's merged.

The core spec fails most likely because it's out of sync with the upstream spec. This should be fixed once it's rebased.

@aheejin aheejin merged commit c830a2f into WebAssembly:master Sep 15, 2021
@aheejin aheejin deleted the delegate_spec branch September 15, 2021 20:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inconsistency in documentation for try-delegate behavior for function body
4 participants