Closed Bug 1609887 Opened 5 years ago Closed 5 years ago

Prevent uses of webassembly results from being reordered past another webassembly result

Categories

(Core :: JavaScript: WebAssembly, defect, P2)

defect

Tracking

()

RESOLVED FIXED
mozilla74
Tracking Status
firefox74 --- fixed

People

(Reporter: wingo, Assigned: wingo)

References

Details

Attachments

(1 file)

WebAssembly functions may have multiple results, and there may (in the future) be more than one register result. Consider the instruction sequence:

MWasmCall (() -> (i32, i32))
x = MWasmRegisterResult(%rax)
y = MWasmRegisterResult(%rcx)
z = MConstant(1)
w = MAdd(truncate, i32, x, z)

We wouldn't want it to optimize to:

z = MConstant(1)
MWasmCall (() -> (i32, i32))
x = MWasmRegisterResult(%rax)
w = MAdd(truncate, i32, x, z)
y = MWasmRegisterResult(%rcx)

Reordering the z to the top of the block is fine, because it won't be between a call and the result definition, but moving w is not fine, because it could clobber the result that y is meant to capture.

Fix will be to add something to InstructionReordering.cpp. However it can't be based on isEffectful because the instruction being reordered could be pure, without aliases.

Blocks: 1607200
Priority: -- → P2
Pushed by nbeleuzu@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/66cf77a1b464 Prevent instruction reordering between wasm call and result r=lth
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla74
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: