-
Notifications
You must be signed in to change notification settings - Fork 40
Finalize opcode encodings #29
Comments
I wouldn't mind moving table.get/set to 0xfc as well, but I'm fine either way. On the other hand I think ref.func should remain single-byte -- note that one of its uses will be as a constant instruction in generalised element segments, where it could be fairly frequent. |
I agree that making ref.func two-byte will bloat the passive element segments that contain functions, but given how regular such an element segment would look to a level-1 wasm compressor or even a generic compressor, I'd expect that use case not to be all that important for compact encoding (during transmission). (No objection to moving table.get / table.set.) |
But why rely on external compression for cases where we can avoid it without notable drawback? In this case there really seems to be no benefit in doing so. |
The benefit would be saving a scarce single-byte opcode (but only that). |
I believe the MVP leaves us with 68 single-byte opcodes, assuming all opcodes from Making Keeping |
Okay, I'd propose leaving all three as single-byte then. |
Would it be worth finalizing the table index encodings as well? It looks like the interpreter in this repo for |
Firefox is going to be updated shortly to follow the interpreter here. The flag byte is not useful, it's just a holdover from an older regime. |
Summarizing the discussion so far, the proposal is:
Additionally, the table arguments to all the table operations are simple varuint32 values that are always present, there are no flags. This includes the second operand to |
Landed and fixed everywhere. |
…able.copy`. (#29) This would make it simpler to extend those instructions to support multiple memories/tables, and copying between different memories/tables. The current encoding has a single placeholder zero byte for those instructions, which allows extension to multiple memories/tables, but would require a more complicated encoding to add two immediate indices.
As part of the effort to drive both this proposal and the bulk memory proposal toward shipping status, let's nail down the opcode encodings. (The bulk memory proposal depends on what we choose for
ref.null
andref.func
, since those are used to express passive element segments.)The spec interpreter in this repo has some TODO comments around the opcode encodings, and some opcodes are missing from the interpreter at present, and all proposed opcodes are precious single-byte ones.
From the interpreter in this repo we have:
From the bulk memory proposal we have these proposed codes:
In addition we need opcodes in this proposal for
table.grow
,table.size
, and (possibly)table.fill
.We are in somewhat short supply of single-byte opcodes so I propose that we (a) change the encoding of
ref.func
since is not likely to be a very common opcode, and (b) allocate prefixed opcodes also for the three table operations mentioned above, yielding the following table for the present proposal:with the idea that
0xfc 0x20
can be the start of the group for multi-byte gc/reftypes operations, and0xd0
remains the start of the group for single-byte gc operations.@rossberg @binji @lukewagner @titzer, opinions?
The text was updated successfully, but these errors were encountered: