-
Notifications
You must be signed in to change notification settings - Fork 460
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
[spec] Can memory.grow take n < 0 ? #924
Comments
In particular
Where "added" works for both signed and unsigned integers, but "divided" does not specify if a signed / unsigned dive operation is performed. And the check for "overflow" happens afterwards:
So if Also, in step 3, "is larger than", does not specify whether the greater than signed or unsigned instruction is used. The |
For reference, the design PR where |
Runtime integer values are always stored on the execution stack unsigned, see the definition of Values here, which references the definition of integers here:
You can see an example of this in the definition of i32.gt_s.
The numerics in the formal syntax always use the standard mathematical syntax. Unsigned integer division, for example, is defined like this: Similarly, none of the numbers in the formal definitions use modular arithmetic (you can see an example of how that would be specified in i32.add) so it is not possible for them to wrap around.
I don't see the definition of that either, though perhaps I missed it. It is indeed meant to be a concatenation. |
@binji Thanks for the details! :) Perhaps |
For this example, maybe, but this form of concatenation is used pervasively elsewhere in the spec (see the binary section for example) where it would be visually very noisy to do this. |
@binji ah; makes sense -- how about adding |
Sounds good to me, but I'll defer to @rossberg for that :-) |
Since sequences are simply represented by iterations of a certain phrase class, juxtaposition already is concatenation by construction. Hence no further convention needs to be defined. If that is non-obvious we could add a note, but it seems like everybody read it correctly? |
@rossberg I do think someone who is not familiar with reading literature on operational semantics could be confused so it seems noteworthy with a sentence somewhere. :) I understood what |
Perhaps the formal semantics could be clearer, but I think the meaning of "grow" and "append" in the prose would have to be awkwardly contorted to allow shrinking. As described here the purpose of the prose to provide the intuitive meaning, which seems to have been understood here. Closing, but feel free to reopen if you feel strongly here. |
Now that we switched to the WebIDL specification, the {Table,Memory}.grow takes an unsigned 32 bits int. |
Reading the operational semantics of
memory.grow
it isn't clear whether you can shrink the amount of memory with that instruction (the meaning of "grow" and "append" isn't detailed but once can guess what it means...).Similarly, reading
growmem
does not bring clarity; I didn't see the syntaxmeminst.data (0x00)n⋅64Ki
defined anywhere; I assume it means thatmeminst.data
is concatenated with(0x00)n⋅64Ki
but it would be nice to make this clearer wrt. behavior and inductively define the operationA B
.cc rust-lang/rust#56292
Some advice would be good. :)
The text was updated successfully, but these errors were encountered: