Skip to content

Use 0 instead of None for alignment#235

Merged
lukewagner merged 1 commit intomasterfrom
tweak-alignment
Feb 8, 2016
Merged

Use 0 instead of None for alignment#235
lukewagner merged 1 commit intomasterfrom
tweak-alignment

Conversation

@lukewagner
Copy link
Member

I realized that since 0 is already an invalid alignment (currently fails the "is a power of 2" check) we don't need alignment to be an int option, we can simply use an int; no reason to have two sentinel cases. This also makes it an epsilon simpler when talking about binary encoding.

@sunfishcode
Copy link
Member

Another approach would be to make alignment non-optional, and then optimize the binary encoding using the idea of including immediate values in the opcode table. That way we wouldn't need any sentinel values. What do you think?

@lukewagner
Copy link
Member Author

Oh right, that's even simpler and all of the encoding schemes we're talking about shouldn't benefit from having 0 vs. 4.

@lukewagner
Copy link
Member Author

Updated. So 0 is back to invalid and the parser fills in natural alignment if you leave it off. For testing purposes, explicitly setting align=0 will continue to emit 0 and cause a validation error. On a side note, this was much easier than last time I mucked loads/stores; nice job @rossberg-chromium!

@sunfishcode
Copy link
Member

lgtm

@rossberg
Copy link
Member

rossberg commented Feb 8, 2016

LGTM, I like this better as well

lukewagner added a commit that referenced this pull request Feb 8, 2016
Use 0 instead of None for alignment
@lukewagner lukewagner merged commit 6d586b0 into master Feb 8, 2016
@lukewagner lukewagner deleted the tweak-alignment branch February 8, 2016 16:16
ngzhian pushed a commit to ngzhian/spec that referenced this pull request Nov 4, 2021
dhil pushed a commit to dhil/webassembly-spec that referenced this pull request Mar 2, 2023
Fixes related .. todo:: section.
Addressed review comment.
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.

3 participants