WebAssembly / proposals

Tracking WebAssembly proposals
1k stars 58 forks source link

Reverse the order of stack inputs for the store instructions. #165

Closed fredericomba closed 1 year ago

fredericomba commented 1 year ago

The stack store instructions take arguments like this: [pointer, value]. However, if the arguments were in the order [value, pointer], it would be easier to use the store instructions with long data structures on the stack. Of course, making this change would break backwards compatibility, so a "reverse" or "swap" instruction that reverses the last two values on the stack could address this.

I can't elaborate on this point right now, but if you also faced this, you'll probably know what I'm talking about.

yfzhe commented 1 year ago

With the multi-value feature, you don't need the "reserve" or "swap" instruction but rather implement it as a function by yourself.

See: https://github.com/WebAssembly/multi-value/blob/master/proposals/multi-value/Overview.md#functions-with-multiple-return-values

eqrion commented 1 year ago

Changes to wasm must follow this process document, and generally starts as an issue on the WebAssembly/design repository, not in this repository.

We can't break backwards compatibility, so changing stack operand order is a non-starter. However stack manipulation instructions have been actively discussed before.

tlively commented 1 year ago

I think we can close this as a duplicate of https://github.com/WebAssembly/design/issues/1381.