-
Notifications
You must be signed in to change notification settings - Fork 14
[BoS] Rename instructions #51
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
Conversation
`switch` becomes `stack.switch` because we are using the `stack` prefix for all bag-o-stacks instructions. `switch.call` becomes `stack.new_switch` because it is the composition of `stack.new` (not yet documented) and `stack.switch`. Similarly, `switch.return` becomes `stack.switch_retire` because it performs a switch and retires the previous active stack. We use "retire" instead of "return" because "return" is not really an accurate description of what is happening.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
proposals/bag-o-stacks/Explainer.md
Outdated
@@ -86,15 +86,15 @@ The return stack type must be of the form: | |||
|
|||
where $c is the index of a stack type. | |||
|
|||
>This affects which instructions are legal to perform; the switch.return instruction passes a null stack as the return stack, whereas the regular switch instruction never passes a null stack. | |||
>This affects which instructions are legal to perform; the stack.switch_retire instruction passes a null stack as the return stack, whereas the regular strack.switch instruction never passes a null stack. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: "strack.switch"
These seem like sensible renamings to me. However, I know that @rossberg consciously tries to follow a particular naming convention that I've never quite internalised. For typed continuations we have We should be wary of using the |
My reasoning was that Wasm so far is not using prefixes for instructions that actually affect control and instead treats those as more primary constructs, otherwise we'd already have e.g. func.call etc. |
And the distinction is that |
Yes, it just allocates. This is my rationalisation of what Wasm has been using so far anyway. |
So IIUC based on that convention the instructions @tlively mentioned could be named |
The only thing you can do with a stack that doesn’t involve a control flow transfer is allocate it, so
I agree we should be clear on this point, but I don’t think the instruction names are the right documentation mechanism. |
I don't have a strong view either, but I think it would be helpful to use the same convention between proposals - so I'd suggest just using the prefix in the case of
Agreed. I don't think it matters too much as long as we don't run into name clashes (speaking of which let's make sure we allocate different byte codes for the instructions for the purposes of experimentation!). However, it is worth remembering that the |
Quick question: if |
In fact there are very good reasons to have the three instructions. Originally there was only switch.call (stack.new.switch). Ergonomically, having stack.new is nice, but not necessary. So, if we were going to drop something, it would be stack.new. Note that this is super early in the process. |
@dead-claudia, another point in favor of an explicit |
How would we feel about keeping |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine.
That doesn't really make a lot of sense to me, but at the same time, naming isn't something to get too hung up about at this stage. |
I suspect that depends on how regular semantics and arguments are. Such complexity can be an indication that there is a more fitting factorisation of primitives hidden underneath. As a data point, the corresponding primitive in the continuations proposal is quite straightforward to implement (and I believe that difference is largely orthogonal to other differences). |
@rossberg The same issue (argument register shuffling) would apply to cont.new. |
I've updated this to rename |
That may be a V8 artefact. @dhil, @frank-emrich, isn't the cont.new implementation in Wasmtime rather straightforward? |
Yes, |
switch.call
becomesstack.new_switch
because it is the composition ofstack.new
(not yet documented) andswitch
.Similarly,
switch.return
becomesswitch_retire
because it performs a switchand retires the previous active stack. We use "retire" instead of "return"
because "return" is not really an accurate description of what is happening.