Skip to content
This repository was archived by the owner on Apr 25, 2025. It is now read-only.

Address additional review of #222, also fixing label types everywhere. #241

Merged
merged 7 commits into from
Dec 23, 2022

Conversation

ioannad
Copy link
Collaborator

@ioannad ioannad commented Oct 21, 2022

This addresses additional review comments to PR #222, that were made after it was merged. The last review comment in the discussion suggests to adjust all validation labels to use label types instead of just result types. Should address all occurrences of validation labels.

Additionally adds a boolean catch_label to control frames in the validation algorithm, and some related functionality, fixing the cases for opcodes catch and catch_all.

… everywhere.

This addresses additional review comments to PR WebAssembly#222, that were made after it was merged.
The last review comment in the discussion suggests to adjust all validation labels to use label types instead of just result types.
Should address all occurrences of validation labels.

Additionally adds a boolean catch_label to control frames in the validation algorithm,
and some related functionality, fixing the cases for opcodes `catch` and `catch_all`.
@@ -122,9 +123,16 @@ The control stack is likewise manipulated through auxiliary functions:
ctrls.pop()
return frame

func label_types(frame : ctrl_frame) : list(val_types) =
func label_val_types(frame : ctrl_frame) : list(val_type) =
Copy link
Member

Choose a reason for hiding this comment

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

Why rename the function?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It was in the spirit of now calling such labeltypes "label types" , as requested in this comment but I see now that I may have overdone it. :) Reverting/removing as suggested.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

@@ -51,6 +51,7 @@ the latter surrounding :ref:`structured control instructions <syntax-instr-contr
end_types : list(val_type)
height : nat
unreachable : bool
catch_label : bool
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we need this flag, given that we already store the opcode.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

removed


func set_catch(catch : bool) =
error_if(ctrls.is_empty())
ctrls[0].catch_label := catch
Copy link
Member

Choose a reason for hiding this comment

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

Remove.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

The type of the :ref:`label <syntax-label>` associated with a control frame is either that of the stack at the start or the end of the frame, determined by the opcode that it originates from.
The result type of the :ref:`label <syntax-label>` associated with a control frame is either that of the stack at the start or the end of the frame, determined by the opcode that it originates from.

Whether a label has :ref:`label type <syntax-labeltype>` with present |LCATCH| is stored with the boolean :math:`catch_label` of the frame, which can be checked with :math:`is_catch`, or modified in the top control frame with :math:`set_catch`.
Copy link
Member

Choose a reason for hiding this comment

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

Remove.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

@@ -219,32 +229,34 @@ Other instructions are checked in a similar manner.
error_if(frame.opcode =/= try || frame.opcode =/= catch)
let params = tags[x].type.params
push_ctrl(catch, params , frame.end_types)
if (frame.opcode =/= try) then set_catch(true)
Copy link
Member

Choose a reason for hiding this comment

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

Remove.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done


case (catch_all)
let frame = pop_ctrl()
error_if(frame.opcode =/= try || frame.opcode =/= catch)
push_ctrl(catch_all, [], frame.end_types)
if (frame.opcode =/= try) then set_catch(true)
Copy link
Member

Choose a reason for hiding this comment

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

Remove.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

}{
S; C,\CLABELS\,[t^\ast] \vdashadmininstr \CAUGHTadm\{\tagaddr~\val^\ast\}~\instr^\ast~\END : [] \to [t^\ast]
Copy link
Member

Choose a reason for hiding this comment

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

Why change this formulation?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This does seem misplaced. I was trying to follow the formulation for the typing of \DELEGATEadm in the formal overview, but not only this change is misplaced here, but it seems unnecessary to change this in the appendix, given the latest comment on the DELEGATEadm typing rule.

Reverting this change.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

@@ -1458,11 +1460,11 @@ Control Instructions
:math:`\RETHROW~l`
..................

* The label :math:`C.\CLABELS[l]` must be defined in the context.
* The label type :math:`C.\CLABELS[l]` must be defined in the context.
Copy link
Member

Choose a reason for hiding this comment

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

Actually, it is the label that must be defined (with a type). So I'd revert this (similarly several occurrences below).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done, for the other occurrences as well.

* The label type :math:`C.\CLABELS[0]` must be defined in the context.

* Let :math:`C'` be the same :ref:`context <context>` as :math:`C`, but with the :ref:`label type <syntax-labeltype>` :math:`C.\CLABELS[0]` modified to :math:`(\LCATCH~[t^\ast])` in the |CLABELS| vector.
* Let :math:`C'` be the same :ref:`context <context>` as :math:`C`, but with the label :math:`(\LCATCH~[t^\ast])` prepended to the |CLABELS| vector.
Copy link
Member

Choose a reason for hiding this comment

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

C is an (implicit) input to the rules, so you'll have to write the prose the other way round, i.e., first check that the last entry is [t*], then define C' to be C with that entry updated. (That means that the C in the prose and the C in the formal rule denote different contexts, but I think that's fine.)

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* Let :math:`C'` be the same :ref:`context <context>` as :math:`C`, but with the label :math:`(\LCATCH~[t^\ast])` prepended to the |CLABELS| vector.
* Let :math:`C'` be the same :ref:`context <context>` as :math:`C`, but with the label type :math:`(\LCATCH~[t^\ast])` prepended to the |CLABELS| vector.

Isn't type missing? All other similar clauses have it.

@rossberg Not sure if I understand. Also I wonder if making C's meaning different from that in the equation will be confusing.. Can we change the equation to use the same symbol?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, we could use C' in the formal rule, though the tick would just be noise there. In general, I have opted to not artificially complicate the formal rules for the sake of the prose, though this case is minor enough.

Adding type sounds okay be me.

Copy link
Member

Choose a reason for hiding this comment

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

Then can we change the symbol in the prose?

Copy link
Member

Choose a reason for hiding this comment

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

Actually I'm not sure if I understood your comment correctly:

C is an (implicit) input to the rules, so you'll have to write the prose the other way round, i.e., first check that the last entry is [t*], then define C' to be C with that entry updated.

Can you elaborate a little more on what this means? And if the symbols don't cause much confusion, that might be fine.

Copy link
Member

@rossberg rossberg Nov 23, 2022

Choose a reason for hiding this comment

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

In the formal rules, the context is always explicit. We just call it C, or something else, and we can even "pattern match" it in the rules, which is what happens in the rule for caught. This implicitly imposes a constraint, because the rule is only applicable if the context has that specific form.

In the prose, the context is treated as a parameter to the "algorithm". And we keep it implicit to avoid more excessive verbosity. That implicit context is available under the fixed name C. This convention is described here. A constraint on that context (e.g., the presence of a certain entry) then has to be checked explicitly.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Moved these changes to PR #244, reverting these changes to whatever the document had previously.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Please ignore the last two commits (the second reverting the first) - the changes to the typing of CAUGHTadm were already reverted.

Changes to the typing of CAUGHTadm are now done in PR #244.

Copy link
Member

@aheejin aheejin left a comment

Choose a reason for hiding this comment

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

The caught validation rule is shown like this now:
image

The numerator says labels(catch [t*]), but the denominator says labels[t*]. Should we change the denominator to labels(catch [t*]) as well?

* The label type :math:`C.\CLABELS[0]` must be defined in the context.

* Let :math:`C'` be the same :ref:`context <context>` as :math:`C`, but with the :ref:`label type <syntax-labeltype>` :math:`C.\CLABELS[0]` modified to :math:`(\LCATCH~[t^\ast])` in the |CLABELS| vector.
* Let :math:`C'` be the same :ref:`context <context>` as :math:`C`, but with the label :math:`(\LCATCH~[t^\ast])` prepended to the |CLABELS| vector.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* Let :math:`C'` be the same :ref:`context <context>` as :math:`C`, but with the label :math:`(\LCATCH~[t^\ast])` prepended to the |CLABELS| vector.
* Let :math:`C'` be the same :ref:`context <context>` as :math:`C`, but with the label type :math:`(\LCATCH~[t^\ast])` prepended to the |CLABELS| vector.

Isn't type missing? All other similar clauses have it.

@rossberg Not sure if I understand. Also I wonder if making C's meaning different from that in the equation will be confusing.. Can we change the equation to use the same symbol?

@rossberg
Copy link
Member

@aheejin:

Should we change the denominator to labels(catch [t*]) as well?

The rule is intended as is, the purpose being that it refines the existing label binding to a catch label, enabling its use for rethrow in the premise.

@ioannad
Copy link
Collaborator Author

ioannad commented Dec 9, 2022

@aheejin @rossberg
All review comments should now be addressed here, except those involving the prose for the typing of CAUGHTadm: these changes are now moved to PR #244 as mentioned in my previous comment.

@ioannad ioannad merged commit a8056e5 into WebAssembly:main Dec 23, 2022
ioannad added a commit that referenced this pull request Feb 15, 2023
* Fixes the typing rule of CAUGHTadm as suggested in:
#229 (comment)
* Applying suggestion from PR #241
https://github.com/WebAssembly/exception-handling/pull/241/files/201ff276be6c458e7a819662eb2862bd475f2fcd..f97c9d108a999c3c3fd30f25554a113822bed1b8#r1030097793
* Applied suggestions from code review, fixed notation, also adding the missing _n to CAUGHTadm.
  The subscript is introduced by the changes in PR #226
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants