-
Notifications
You must be signed in to change notification settings - Fork 695
BinaryEncoding.md changes implied by #682 #727
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
Note that the initial/maximum fields are specified in units of | ||
[WebAssembly pages](AstSemantics.md#linear-memory). | ||
|
||
### Global section |
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.
Can you indicate in the High Level structure section where this section is located? (and add a link to this anchor)
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.
It appears that in this patch, the Global section is placed after the Import section. I assume there is a single Global index space; so this means that in the index space, all the imported global indexes will be strictly less than the first locally defined global, is that right? Independently of the final choice (imported global being before or after the locally defined globals), it might be worth telling something about it here or somewhere else (Modules.md), maybe?
Actually, if call_import
is removed, function calls also share the functions index space and the same precision could be useful too.
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.
That's right; that's how it works for all the importable definitions (functions, memories, tables, globals) as well as arguments+locals. This is documented in Modules.md in the "X index space" sections which I've tried to link to, where appropriate, from this doc. But I could try to add a few more links.
On 19 July 2016 at 00:33, Luke Wagner [email protected] wrote:
Come to think about it, would it make sense to declare defaults in their |
I think these two are in conflict since you won't be able to tell whether
Agreed; we actually need to do this so that we can initialize imported table/memory. (This is what we've done in SM's proto s-expr format which I forgot to mention above.)
Oops, yes, that's what we've implemented in our s-expr proto, I forgot to mention it above; I'll update it.
When we allow multiple tables/memories (which I think will necessarily block on GC, so it'll be a while, and by then I'm thinking we'll have a non-s-expr text format), I was thinking we could introduce it in a backwards-compatible way by saying: if you specify a name in the import/definition of a table/memory, then it's non-default. Then to refer to a non-default memory/table you write
I kinda see the abstract point, but I don't see any practical downside to putting it on the import/def or practical upside to having a separate "defaults" section. It might actually be a hair more complicated since it produces a window, in the decoding process, where you have a memory/table but don't yet know if it's default or not. Until we allow non-default memories/tables it is definitely more work (b/c atm you trivially just check that the bit is set), |
On 19 July 2016 at 17:40, Luke Wagner [email protected] wrote:
We should make the syntax future proof wrt to multi-tables/memories.
Yeah, that has the disadvantage that you cannot represent a case that
It's a bit weird right now that the default flag is part of the |
(in the MVP, *every* memory/table import/definition must be flagged as default) | ||
* `0x2` : indicates that the memory/table has a specified maximum | ||
|
||
### init_expr |
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.
Btw, are all uses of init_expr
evaluated in order? What happens if a get_global
in one of them refers to a not-yet-initialised global?
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.
I should also state the requirement here but Modules.md#initializer-expression requires that the get_global
only refer to an immutable import which will necessarily precede all the uses.
sgtm. The current hack in SM is just to allow existing .wasts to work unchanged (so it's easy to test on existing demo builds), but I'm happy to unhack.
Oh, then I guess I misunderstood what you were proposing; so you're just saying that, when there's only 1, it's the default by, well, default. Then post-MVP, when we support >1, we can decide how to pick which is default. That sounds good to me and keeps our options open. |
Btw, shouldn't this be a PR against the binary_0xc (or binary_0xd) branch? |
Right, some binary_0x* branch; I'm not expecting to merge this into master. As I noted in the OP, I'm waiting to see what people want to do for either folding this into binary_0xc or waiting until binary_0xd. |
@lukewagner, actually, shouldn't the same have applied to #682? I just realised it got merged into master. ;) |
@rossberg-chromium Well, the nascent protocol we've been using is to only use the binary_0x* branch for BinaryEncoding.md changes (hence "binary_" :) for the purpose of coordinating landing the breaking binary format changes in engines. Post-MVP, breaking changes will cease, so probably we should shift to a more regular "everything related to a proposed feature is on a branch until the whole thing merges". |
| `call` | `0x16` | argument_count : `varuint1`, function_index : `varuint32` | call a function by its index | | ||
| `get_global` | `0x18` | global_index : `varuint32` | read a global variable | | ||
| `set_global` | `0x19` | global_index : `varuint32` | write a global variable | | ||
| `call` | `0x16` | argument_count : `varuint1`, function_index : `varuint32` | call a function by its [index](Modules.md#function-index-space) | |
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.
Thought I had commented on that already, but can't find the comment anymore: fyi, this conflicts with #711, will have to resolve somehow.
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.
Since we're going to defragment this opcode space anyway, I'll change these codes.
Luke this seems good, can you resolve conflicts and merge? |
…686) * Clarify that wasm may be viewed as either an AST or a stack machine. * Reword the introductory paragraph. * Add parens, remove "typed".
Make opcode 0x00 `unreachable`, and move `nop` to a non-zero opcode. All-zeros is one of the more common patterns of corrupted data. This change makes it more likely that code that is accidentally zeroed, in whole or in part, will be noticed when executed rather than silently running through a nop slide. Obviously, this doesn't matter when an opcode table is present, but if there is a default opcode table, it would presumably use the opcodes defined here.
…ble going before Memory
…entation of globals
0419cc1
to
fd4268f
Compare
Righto. Merged to |
This PR makes the binary format changes to import, export, memory, table, global, code, data and element sections as implied by #682. The PR is currently a branch off master but I'm expecting to rebase it against whatever
binary_0x*
branch we choose when we're ready to merge.The existing s-expr text format can produce this new binary format, but new s-expr forms are necessary to activate the new functionality of #682:
(import "m" "f" memory <min> <max?>)
/(import "m" "f" table <min> <max?>)
to import (the default) module/table(export "x" memory)
/(export "y" table)
to export (the default) module/table(elem <off> x y z)
to specify an element segment that writes functionsx
,y
andz
into the default table with offset specified by the initializer s-expr(data <off> "data")
to specify a data segment that writes data into the default memory with offset specified by the initializer s-expr(table x y z)
would now produce both atable
section and anelem
sectioninitial
/maximum
(without elements); for SM prototype/testing purposes I used(table (resizable initial maximum))
, but happy to have alternativesThis PR makes one change to Modules.md: the elements of the element section are changed to simply be indices (into the appropriate index space); the per-element type was redundant.