-
Notifications
You must be signed in to change notification settings - Fork 786
MemoryPacking changes d8 results #2528
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Turned out this is not a Binaryen bug but a V8 bug. V8 does not trap when dropping an active segment, when it is supposed to. It also doesn't trap when it drops a segment twice. I filed a bug in V8. |
I believe this is an intended behaviour on V8's part. The drop operation was recently changed to behave as you describe (repeated dropping is a no-op). (WebAssembly/bulk-memory-operations#126) Maybe @tlively has insight, since that spec change PR as a whole was intended to facilitate memory-packing optimisations. (WebAssembly/bulk-memory-operations#124) |
Thanks! I didn't know about the recent spec changes. I'll fix Binaryen interpreter to match the V8's behavior. |
This implements recent bulk memory spec changes (WebAssembly/bulk-memory-operations#126) in Binaryen. Now `data.drop` is equivalent to shrinking a segment size to 0, and dropping already dropped segments or active segments (which are thought to be dropped in the beginning) is treated as a no-op. And all bounds checking is performed in advance, so partial copying/filling/initializing does not occur. I tried to implement `visitDataDrop` in the interpreter as `segment.data.clear();`, which is exactly what the revised spec says. I didn't end up doing that because this also deletes all contents from active segments, and there are cases we shouldn't do that: - `wasm-ctor-eval` shouldn't delete active segments, because it will store the changed contents back into segments - When `--fuzz-exec` is given to `wasm-opt`, it runs the module and compare the execution call results before and after transformations. But if running a module will nullify all active segments, applying any transformation to the module or re-running it does not make any sense. Fixes WebAssembly#2528.
This implements recent bulk memory spec changes (WebAssembly/bulk-memory-operations#126) in Binaryen. Now `data.drop` is equivalent to shrinking a segment size to 0, and dropping already dropped segments or active segments (which are thought to be dropped in the beginning) is treated as a no-op. And all bounds checking is performed in advance, so partial copying/filling/initializing does not occur. I tried to implement `visitDataDrop` in the interpreter as `segment.data.clear();`, which is exactly what the revised spec says. I didn't end up doing that because this also deletes all contents from active segments, and there are cases we shouldn't do that: - `wasm-ctor-eval` shouldn't delete active segments, because it will store the changed contents back into segments - When `--fuzz-exec` is given to `wasm-opt`, it runs the module and compare the execution call results before and after transformations. But if running a module will nullify all active segments, applying any transformation to the module or re-running it does not make any sense. Fixes WebAssembly#2528.
The original file,
a.wasm
, when run withd8
,prints this:
But if we run
--memory-packing
on this,and run d8 on it:
The result changes:
I attached
a.wasm
anda.js
here.a.wasm.tar.gz
a.js.tar.gz
The text was updated successfully, but these errors were encountered: