emscripten-core / emscripten-core/emscripten
Wasm2JS redundant asm.jsism
- Dominant language
- C++
- Stars
- 27.6k
- Forks
- 3.6k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 105
Description
Building juj/wasm_webgpu@4c2600b clear_screen sample for testing WebGPU on Wasm2JS, I notice the following kind of statements appear:
```js
function ObtainedWebGpuAdapter($0, $1) {
$0 = $0 | 0;
$1 = $1 | 0;
$1 = __stack_pointer - 80 | 0;
__stack_pointer = $1;
HEAP32[282] = $0;
memcpy($1 + 8 | 0);
wgpu_adapter_request_device_async($0 | 0, $1 + 8 | 0, 2, 0);
__stack_pointer = $1 + 80 | 0;
}
```
There are these asm.js style `$0 = $0 | 0;` and `$1 = $1 | 0;` statements, which do not go away with closure:
```js
function R(a, b) {
a = a | 0;
b = b | 0;
b = M - 80 | 0;
M = b;
e[282] = a;
P(b + 8 | 0);
G(a | 0, b + 8 | 0, 2, 0);
M = b + 80 | 0;
}
```
Here
```
$1 = $1 | 0;
$1 = __stack_pointer - 80 | 0;
```
is redundant, the `$1 = $1 | 0;` part could be dropped. Also applying the missed optimization #13363 could give
```js
__stack_pointer = $1 = __stack_pointer - 80 | 0;
```
Then again
```js
wgpu_adapter_request_device_async($0 | 0, $1 + 8 | 0, 2, 0);
```
looks redundant, `$0` is already i32, so would not need coerced again (and the callee prelude will also coerce it once more)
Contributor guide
Assessment
This issue has not been assessed yet.