-
Notifications
You must be signed in to change notification settings - Fork 9
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
Rule prose with state variable z #89
Conversation
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 good to me.
As a separate change, the "ref.func ..." should probably be rendered with the parentheses.
Also, can we render |...| in prose, as "the length of ..."?
This is handled in the latest commit: Add parentheses to EL SeqE when translated from AL CaseE.
This is somewhat complicated, for there are AL expressions in the form
It relates to the discussion made in #61, but I am not sure how the Or, we can add a hacky pass on AL, such that if there is an occurrence of
|
Yeah, this is not high priority, but eventually I'd prefer to have something like that. (Of course, the condition should ideally read "a is smaller than the length of $arrayinst(z)" and be an assertion. :) ) |
Thank you for the comments :) I'll merge this with two things in mind, |
Yes, more generally, it should be possible to implement an AL-to-AL pass that performs a kind of normalisation, such that it lifts out complex subexpressions (of various shape) and names them. Sort of like a partial A-normal form. |
There is a small inconsistency between the reference implementation in Wasm-DSL#84 and the explainer. In the explainer we write that the type index `$ft` on `cont $ft` should be encoded as an `u32` in the binary format. However, the reference interpreter actually encodes it as `s33`, similarly to how concrete heap types are encoded.
This adds the state variable
z
to rule prose.What has changed
Previously, we have removed all state variable
z
from the prose, for the stores
inz
is regarded as an implicit global variable throughout the prose semantics. This has incurred problems when rendering the prose, for the removedz
caused arity mismatch on applying the display hints.For example, below is the generated spec document before this PR. The prose calls
![image](https://private-user-images.githubusercontent.com/44872014/317205588-a8d374f7-a8e5-4eaf-af9d-6f225a167e6a.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkwMjc5NjcsIm5iZiI6MTczOTAyNzY2NywicGF0aCI6Ii80NDg3MjAxNC8zMTcyMDU1ODgtYThkMzc0ZjctYThlNS00ZWFmLWFmOWQtNmYyMjVhMTY3ZTZhLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA4VDE1MTQyN1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTc4NzY0YjZlNzZhM2E4NzJlZWM0MjkwOWUwM2QyNmUzZDMzZmY0NTE3YTA0YWU5OTFhZDUyNzRhMWM1OWVjZDkmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.pLy9o1ogq1doAQvEA-aonncarqslX5rf-qBm2VrnYKQ)
$funcaddr
with no argument, so the display hint,z.module.func
is not applied. This happens throughout many helper function (getters and setters for notational shorthand) applications.With this PR, the IL-2-AL phase does not remove the state variable
![image](https://private-user-images.githubusercontent.com/44872014/317208446-9d7219d1-db5a-4942-9411-9756f6ea0fd8.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkwMjc5NjcsIm5iZiI6MTczOTAyNzY2NywicGF0aCI6Ii80NDg3MjAxNC8zMTcyMDg0NDYtOWQ3MjE5ZDEtZGI1YS00OTQyLTk0MTEtOTc1NmY2ZWEwZmQ4LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA4VDE1MTQyN1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWM4NjYwODJlMTM4NzYyYTFiMTI0NzAwMGRkY2FkNzE0YjJlZGVkNmQ5YTU0NzlhNmJiNjVkNDhmNmFmYzU1ODQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.KWuktB87YfXCgA3oNa7Bpc6FNEeZzHKmdMqmlooypcg)
z
. Thus, display hints withz
now works well in rendered prose also. For all generated prose from the reduction rules that usez
, an instruction "Letz
be the current state.` is added as the first instruction.What should be addressed afterwards
Yet, the AL interpreter still works on the assumption that the state variable
z
is removed during IL-to-AL.Thus, after generating AL from IL, the interpreter backend runs one last pass that removes the state variables, and the prose backend runs one last pass that adds the instruction "Let
z
be the current state."The immediate result is that there is a slight difference between what is seen (prose backend) and what is executed (interpreter backend).
We plan to work on reconciling the two in a separate PR, i.e., adjust our AL interpreter so that we can get to execute the rendered prose by handling the state variable
z
somehow.