Open landersonfigma opened 10 months ago
My guess is that the auto-rewriter is that not that smart and can only reason about expression inside of the HEAPXX[...]
accessors.
The tools is here by the way: https://github.com/emscripten-core/emscripten/blob/0a6f54b1276481fab90e474f2c4fd35d00c5fa6b/tools/acorn-optimizer.js#L1235-L1238
@kripken is that right? I don't suppose there is any way to know that value >>= 2
happens to be a pointer value?
In general I think the solution here is to use value = {{{ getHeapOffset('offset', 'i32') }}}
.
Yeah, the pass has a little magic but that's it:
Aside from the standard heap names + those two there, it doesn't do any guessing.
Renaming view
to heap
would enable the magic, so that is an option to fix this. And more generally there is getHeapOffset
as mentioned.
When using 4GB support, my understanding is that memory accesses are rewritten to use unsigned shifts. In library_webgl.js, glUniform4fv is rewritten from:
to:
The memory accesses inside the loop look correct but should
value >>= 2
bevalue >>>= 2
? Withvalue >>= 2
, I get memory accesses that read out of bounds. Possibly the same issue here. Let me know if I'm misunderstanding the expected output.