You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At the Oct. 2 CG meeting, there was unanimous consent to consider making changes to the text format to improve the consistency of instruction names and remove special characters. Specifically, interest has been expressed in removing slashes from all type conversion (wrap, trunc, extend, convert, demote, promote, and reinterpret) instructions and unifying the formats of memory and global instructions.
To minimize ecosystem disruption, we will plan to make all changes we agree on at once and update as many tools as possible at roughly the same time. We would like to resolve this issue quickly to avoid holding up the standardization process.
I'm fine with underscore for conversions. If we do that, I would propose switching around the _u/_s suffixes, so that they consistently go last in all mnemonics. That is,
i32.trunc_f32_u, i32.trunc_f32_s and so on
This makes it easier to consistently recognise e.g. all i32_xxx_u operating specifically on unsigned i32's.
The other changes I would propose, for consistency with memory and upcoming table instructions (see bulk operations proposal):
{get,set}_global -> global.{get,set}
{get,set,tee}_local -> local.{get,set,tee}
(For the record, one could also consider call -> func.call, but I won't be proposing that.)
Reacted by Thomas Lively, Andreas Rossberg and Liigo Zhuang
Note: Edited to reflect @rossberg's comment below.
Reacted by Thomas Lively, Clemens Backes, Liigo Zhuang, Luke Wagner, Stephen Akinyemi, Xuan Huang (黄玄), Duong Nguyen-Huu, Dmitry Iv. and Dominik Gruntz
@lars-t-hansen, I suppose you cannot interpret the type before the dot strictly as the result type of an operator. It's the type that the operator "is defined at" in some looser sense.
I'm not sure why I wouldn't want to interpret the type strictly as the result type of the operator, though, since that pattern is used very broadly, just not in some cases where it's suddenly about the arguments and the result type is implied (in all cases I can think of the implied result type is i32). Of course there's a succinctness to the instructions that fall under that exception that would be lost if we applied the general pattern, but I don't know why that is an argument either.
(I'm not just trolling, I actually think the current syntax for comparisons is confusing and counterintuitive. Even lt_f64 -- without any type-designating prefix -- would have been better than the current f64.lt.)
I dunno, i32.lt_f64 looks super weird to me. If we think of the type before the . as a result type, many instructions don't make sense, such as i32.store or even memory.size. Personally I don't think it's that valuable to encode the types in the instruction name anyway, we just need a way to differentiate them.
I think of the type before the dot as signifying what type the generic instruction is specialized on. Since all lts return i32, the type before the dot tells me what type the operands are instead, since those still need to be disambiguated.
FWIW some possible breakage I think that may want to be considered when doing I believe is:
Libraries which want to be idiomatic with the current wasm spec will need breaking changes to update their type names to reflect these name changes. For example a parser library in Rust, parity-wasm, would need a breaking change to rename Instruction::GetLocal to Instruction::LocalGet.
We've got tests in Rust which verify that the correct instruction is generated for a particular function (namely for intrinsics like SIMD and such). These instruction names come from disassembly the wasm binary itself with wasm2wat and the instructions to assert for are embedded in the source code. If wasm2wat changes its output, these tests will start to break.
A final one is one we've talked about in the Rust project historically is the "blog post" problem. This is where (for example) there's blog posts, tutorials, reference materials, etc on the internet today which may reference wasm instructions by the old names. If the standard changes a number of instructions (especially common ones like get_local) then all this documentation becomes out of date and needs and update.
To be clear I'm not opposed to changing the instructions to be more consistent, but I wanted to be sure to point out some perhaps more subtle locations that "breakage" can arise in the non-traditional sense. They're all pretty minor and we're certainly more than willing to do the updates on the Rust side of things, but points that may want to be considered!
Right, we've already experienced some of the same issues when changing grow_memory to memory.grow and current_memory -> memory.size, and these instructions are much more common.
@lars-t-hansen is right about atomics too, these are odd now:
Activity
tlively commentedon Oct 2, 2018
I propose replacing slashes with underscores. For example,
i32.wrap/i64would becomei32.wrap_i64.Related discussion for nontrapping float to int conversions here: WebAssembly/nontrapping-float-to-int-conversions#4.
rossberg commentedon Oct 2, 2018
I'm fine with underscore for conversions. If we do that, I would propose switching around the
_u/_ssuffixes, so that they consistently go last in all mnemonics. That is,i32.trunc_f32_u,i32.trunc_f32_sand so onThis makes it easier to consistently recognise e.g. all
i32_xxx_uoperating specifically on unsigned i32's.The other changes I would propose, for consistency with memory and upcoming table instructions (see bulk operations proposal):
{get,set}_global->global.{get,set}{get,set,tee}_local->local.{get,set,tee}(For the record, one could also consider
call->func.call, but I won't be proposing that.)binji commentedon Oct 2, 2018
OK, so then the full list would be like this, right?
Note: Edited to reflect @rossberg's comment below.
rossberg commentedon Oct 2, 2018
It would be more consistent to have the
_u/_sgo after the_sat, for the same reasons mentioned above.In fact, I suggest establishing the following consistent naming scheme for numeric instruction mnemonics:
t.xxxfor all numeric instructions agnostic to signednesst.xxx_u/t.xxx_sfor all numeric instructions sensitive to signednesswhere
xxxdescribes the specific operation (e.g.,add). (That already holds for everything but conversions.)Conversions are then instantiations of this scheme with
xxx=yyy_t, yielding:t.yyy_tfor conversions agnostic to signednesst.yyy_t_u/t.yyy_t_sfor conversions sensitive to signwhere
yyydescribes the kind of conversion (e.g.,truncortrunc_sat).binji commentedon Oct 3, 2018
OK, I've updated the comment above to match this.
lars-t-hansen commentedon Oct 3, 2018
Since we're just chatting anyway: It irks me that
f64.lt(say) does not fit the general pattern; it should really bei32.lt_f64.lars-t-hansen commentedon Oct 3, 2018
Oh, and atomics:
i32.atomic.load8_ufits the proposed pattern.i32.atomic.rmw8_u.addmore or less does not.rossberg commentedon Oct 3, 2018
@lars-t-hansen, I suppose you cannot interpret the type before the dot strictly as the result type of an operator. It's the type that the operator "is defined at" in some looser sense.
lars-t-hansen commentedon Oct 3, 2018
I'm not sure why I wouldn't want to interpret the type strictly as the result type of the operator, though, since that pattern is used very broadly, just not in some cases where it's suddenly about the arguments and the result type is implied (in all cases I can think of the implied result type is i32). Of course there's a succinctness to the instructions that fall under that exception that would be lost if we applied the general pattern, but I don't know why that is an argument either.
(I'm not just trolling, I actually think the current syntax for comparisons is confusing and counterintuitive. Even lt_f64 -- without any type-designating prefix -- would have been better than the current f64.lt.)
binji commentedon Oct 3, 2018
I dunno,
i32.lt_f64looks super weird to me. If we think of the type before the.as a result type, many instructions don't make sense, such asi32.storeor evenmemory.size. Personally I don't think it's that valuable to encode the types in the instruction name anyway, we just need a way to differentiate them.tlively commentedon Oct 4, 2018
I think of the type before the dot as signifying what type the generic instruction is specialized on. Since all
lts return i32, the type before the dot tells me what type the operands are instead, since those still need to be disambiguated.alexcrichton commentedon Oct 4, 2018
FWIW some possible breakage I think that may want to be considered when doing I believe is:
parity-wasm, would need a breaking change to renameInstruction::GetLocaltoInstruction::LocalGet.wasm2watand the instructions to assert for are embedded in the source code. Ifwasm2watchanges its output, these tests will start to break.get_local) then all this documentation becomes out of date and needs and update.To be clear I'm not opposed to changing the instructions to be more consistent, but I wanted to be sure to point out some perhaps more subtle locations that "breakage" can arise in the non-traditional sense. They're all pretty minor and we're certainly more than willing to do the updates on the Rust side of things, but points that may want to be considered!
Also @binji your comment with an exhaustive list of renames is super helpful!
binji commentedon Oct 4, 2018
Right, we've already experienced some of the same issues when changing
grow_memorytomemory.growandcurrent_memory->memory.size, and these instructions are much more common.@lars-t-hansen is right about atomics too, these are odd now:
rossberg commentedon Oct 9, 2018
@binji, good point. I propose moving the _u/_s to the end for those as well (which arguably fits existing instructions).
binji commentedon Oct 9, 2018
OK, updated my comment above to include these as well.
25 remaining items
Atomic instruction renaming (#132)
Instruction renaming
Instruction renaming
Instruction renaming
[wasm] Use new names for instructions
Instruction renaming
Rename opcodes.
Update conversion op names
Update conversion op names (#108)
[spec] Fix comment still referring to old syntax (#957)
Update conversion op names (WebAssembly#108)
Define non-trapping float-to-int conversions. (#1089)
[interpreter] Rename atomic opcodes (WebAssembly#129)
[spec] Rename atomic RMW instructions (WebAssembly#130)
Atomic instruction renaming (WebAssembly#132)