Y
Hacker News
new
|
ask
|
show
|
jobs
by
kg
48 days ago
The lack of a dup opcode in Wasm as mentioned in the post is quite annoying when trying to generate compact code. I wish something like it had made it into the spec.
1 comments
thomasmg
48 days ago
You could use "local.tee". It is kind of is "store" + "duplicate".
link
asibahi
48 days ago
`local.tee` doesn't duplicate. it just doesn't remove the value from the stack. (so it is "just" `local.set` followed by `local.get`)
link
thomasmg
48 days ago
Sure. But it does save you one instruction: "tee", "get" instead of "set", "get", "get".
link