Closed
Bug 1410082
Opened 8 years ago
Closed 4 years ago
wasm: Reuse stored values in subsequent loads from same ptr when there are no side effects in between
Categories
(Core :: JavaScript: WebAssembly, enhancement, P3)
Core
JavaScript: WebAssembly
Tracking
()
RESOLVED
WONTFIX
| Tracking | Status | |
|---|---|---|
| firefox58 | --- | affected |
People
(Reporter: bbouvier, Unassigned)
References
(Blocks 1 open bug)
Details
Analyzing code generated by Faust [1], I can see this pattern (sorry for high-level psuedo code) comes often:
(store (expr) (i32.const 0x42))
;; ... non-effectful instructions here...
(load (i32.const 0x42))
I have warned the compiler authors to use local variables here, but I thought alias analysis would be able to replace the subsequent load by the stored expr, since these happen at the same memory address and there are no side-effects in between.
Not sure if it is something we should fix:
- I don't know if it happens also with emscripten generated code
- I don't know if it happens often that we store/load at the same (address, offset) couple.
- maybe we just rely on the wasm generator to have done the right thing (used a local variable here).
Note this could maybe also be beneficial to JS in general, if alias analysis was generically improved to handle this particular behavior.
Does it sound like something worth investigating?
[1] http://faust.grame.fr/
Updated•8 years ago
|
Priority: -- → P3
Updated•5 years ago
|
Component: JavaScript Engine: JIT → Javascript: WebAssembly
Comment 1•4 years ago
|
||
This optimization won't apply when shared memory is in use, as data races are allowed and another thread's store could reach memory between this thread's store and the subsequent load.
Generally speaking we would want the front end to generate better code. It's possible it won't, since in eg C++ the code would have UB if there was a racing store, and so a C++ compiler might feel it's better to reload the value than to keep it around and possibly spill it. However, most likely that would only happen if the region across which the value was live-but-in-memory would be so large that a JIT would not want to track it.
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → WONTFIX
You need to log in
before you can comment on or make changes to this bug.
Description
•