v128 cannot be used in untyped select instruction
Categories
(Core :: JavaScript: WebAssembly, defect, P3)
Tracking
()
Tracking | Status | |
---|---|---|
firefox83 | --- | fixed |
People
(Reporter: nabeel, Assigned: rhunt)
References
(Blocks 1 open bug)
Details
Attachments
(1 file)
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.42 Safari/537.36
Steps to reproduce:
Build wasm from C++ using emscripten 2.0.0
Actual results:
Firefox Nightly reported an error during wasm validation:
wasm validation error: invalid types for old-style 'select'
Expected results:
Firefox Nightly should still be supporting old-style 'select'
Comment 1•4 years ago
|
||
Bugbug thinks this bug should belong to this component, but please revert this change in case of error.
Assignee | ||
Comment 2•4 years ago
|
||
(In reply to nabeel from comment #0)
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.42 Safari/537.36
Steps to reproduce:
Build wasm from C++ using emscripten 2.0.0
Actual results:
Firefox Nightly reported an error during wasm validation:
wasm validation error: invalid types for old-style 'select'
Expected results:
Firefox Nightly should still be supporting old-style 'select'
Could you attach the files (html, js, wasm) required to reproduce this issue?
Unfortunately, I am not able to share the initial files where I experienced this. I did try to write a small example, but when I use a simple switch expression it does not trigger this error.
Assignee | ||
Comment 4•4 years ago
|
||
This is likely an issue with emscripten generating invalid wasm code. The 'old-style' select instruction is only valid when operating on [i32, i64, f32, f64] input types [1]. This error indicates one of the input types is not one of those types. A new encoding of the select instruction was added to handle more types, and emscripten should be using it.
I'd file an issue on the emscripten repo with repro steps to see if they can figure it out. If it's not an issue with emscripten, then I'll need some way to reproduce the issue in order to fix it.
Do number types include v128?
I see that SpiderMonkey complains about this:
(module
(memory 1 1)
(func $v128.const.i32x4 (result v128)
(select
(v128.const i32x4 1 2 3 4)
(v128.const i32x4 1 2 3 4)
(i32.const 1)
)
)
)
with
failed to asynchronously prepare wasm: CompileError: wasm validation error: at offset 68: invalid types for old-style 'select'
I don't see a flag to enable SIMD in the shell (there is only a flag to disable it). V8, with the flag for SIMD, accepts that wasm.
Assignee | ||
Comment 6•4 years ago
|
||
(In reply to alonzakai from comment #5)
Do number types include v128?
I see that SpiderMonkey complains about this:
(module
(memory 1 1)
(func $v128.const.i32x4 (result v128)
(select
(v128.const i32x4 1 2 3 4)
(v128.const i32x4 1 2 3 4)
(i32.const 1)
)
)
)with
failed to asynchronously prepare wasm: CompileError: wasm validation error: at offset 68: invalid types for old-style 'select'
I don't see a flag to enable SIMD in the shell (there is only a flag to disable it). V8, with the flag for SIMD, accepts that wasm.
Ah, that's a good point; a fun little interaction between the different proposals. The reference-types proposal introduces the 'number type' category and defines it as i32,i64,f32,f64 and that's how we've implemented it. The simd proposal is not based off the reference-types proposal, and so it's unclear what we should do here.
There's no reason we can't allow v128 in the untyped select instruction, I wouldn't expect it to ever have a subtyping relation that would motivate excluding it. But I think it's worth bringing up in the SIMD repo just to make sure there are no strong opinions against it.
Assignee | ||
Comment 7•4 years ago
|
||
Alon, was that snippet taken from generated code from llvm/emscripten/binaryen? I'm curious if any toolchains are currently generating code like this.
That's a hand-written code sample by me. But the Binaryen optimizer can definitely optimize various patterns into a select (of any type, including v128).
I opened https://github.com/WebAssembly/simd/issues/363 on the spec repo.
Assignee | ||
Comment 9•4 years ago
|
||
Thanks!
Assignee | ||
Updated•4 years ago
|
Comment 10•4 years ago
|
||
Reopening until we know what we're doing here.
Updated•4 years ago
|
Assignee | ||
Comment 11•4 years ago
|
||
I think it makes sense to make v128 a number type. In either case, we don't actually support v128 even with the typed select instruction. So there's some work to do here.
Assignee | ||
Comment 12•4 years ago
|
||
- Reclassify v128 as a number type, introducing that category in our code base.
- Add support to baseline and ion for v128 select.
- Split off and extend test for select instruction.
- Add tests for typed select with reftypes
- Add tests for untyped select with v128
Updated•4 years ago
|
Comment 13•4 years ago
|
||
Pushed by rhunt@eqrion.net: https://hg.mozilla.org/integration/autoland/rev/4065a1a701bb Add support for v128 in typed select instructions. r=lth
Comment 14•4 years ago
|
||
Backed out changeset 4065a1a701bb (bug 1666939) for select.js failures.
Backout link: https://hg.mozilla.org/integration/autoland/rev/548312dae23095e9d7d2887b67fcdabe2d96ca15
Failure log: https://treeherder.mozilla.org/logviewer.html#/jobs?job_id=316940949&repo=autoland&lineNumber=45207
...
[task 2020-09-28T21:05:33.930Z] TEST-PASS | js/src/jit-test/tests/wasm/simd/js-api.js | Success (code 0, args "--ion-eager --ion-offthread-compile=off --more-compartments") [0.3 s]
[task 2020-09-28T21:05:33.942Z] -e:1:6 ReferenceError: wasmSimdSupported is not defined
[task 2020-09-28T21:05:33.942Z] Stack:
[task 2020-09-28T21:05:33.942Z] @-e:1:6
[task 2020-09-28T21:05:33.942Z] Exit code: 3
[task 2020-09-28T21:05:33.942Z] FAIL - wasm/simd/select.js
[task 2020-09-28T21:05:33.942Z] TEST-UNEXPECTED-FAIL | js/src/jit-test/tests/wasm/simd/select.js | -e:1:6 ReferenceError: wasmSimdSupported is not defined (code 3, args "") [0.2 s]
[task 2020-09-28T21:05:33.942Z] INFO exit-status : 3
[task 2020-09-28T21:05:33.942Z] INFO timed-out : False
[task 2020-09-28T21:05:33.942Z] INFO stderr 2> -e:1:6 ReferenceError: wasmSimdSupported is not defined
[task 2020-09-28T21:05:33.942Z] INFO stderr 2> Stack:
[task 2020-09-28T21:05:33.942Z] INFO stderr 2> @-e:1:6
[task 2020-09-28T21:05:33.971Z] TEST-PASS | js/src/jit-test/tests/wasm/simd/js-api.js | Success (code 0, args "--wasm-compiler=ion") [0.2 s]
[task 2020-09-28T21:05:33.971Z] TEST-PASS | js/src/jit-test/tests/wasm/simd/js-api.js | Success (code 0, args "--wasm-compiler=baseline") [0.2 s]
[task 2020-09-28T21:05:33.994Z] -e:1:6 ReferenceError: wasmSimdSupported is not defined
[task 2020-09-28T21:05:33.994Z] Stack:
[task 2020-09-28T21:05:33.994Z] @-e:1:6
[task 2020-09-28T21:05:33.994Z] Exit code: 3
[task 2020-09-28T21:05:33.994Z] FAIL - wasm/simd/select.js
[task 2020-09-28T21:05:33.994Z] TEST-UNEXPECTED-FAIL | js/src/jit-test/tests/wasm/simd/select.js | -e:1:6 ReferenceError: wasmSimdSupported is not defined (code 3, args "--no-blinterp --no-baseline --no-ion --more-compartments") [0.2 s]
[task 2020-09-28T21:05:33.994Z] INFO exit-status : 3
[task 2020-09-28T21:05:33.995Z] INFO timed-out : False
[task 2020-09-28T21:05:33.995Z] INFO stderr 2> -e:1:6 ReferenceError: wasmSimdSupported is not defined
[task 2020-09-28T21:05:33.995Z] INFO stderr 2> Stack:
[task 2020-09-28T21:05:33.995Z] INFO stderr 2> @-e:1:6
[task 2020-09-28T21:05:34.009Z] -e:1:6 ReferenceError: wasmSimdSupported is not defined
[task 2020-09-28T21:05:34.009Z] Stack:
[task 2020-09-28T21:05:34.009Z] @-e:1:6
[task 2020-09-28T21:05:34.009Z] Exit code: 3
[task 2020-09-28T21:05:34.009Z] FAIL - wasm/simd/select.js
[task 2020-09-28T21:05:34.009Z] TEST-UNEXPECTED-FAIL | js/src/jit-test/tests/wasm/simd/select.js | -e:1:6 ReferenceError: wasmSimdSupported is not defined (code 3, args "--blinterp-eager") [0.2 s]
[task 2020-09-28T21:05:34.009Z] INFO exit-status : 3
[task 2020-09-28T21:05:34.009Z] INFO timed-out : False
[task 2020-09-28T21:05:34.009Z] INFO stderr 2> -e:1:6 ReferenceError: wasmSimdSupported is not defined
[task 2020-09-28T21:05:34.009Z] INFO stderr 2> Stack:
[task 2020-09-28T21:05:34.009Z] INFO stderr 2> @-e:1:6
[task 2020-09-28T21:05:34.026Z] -e:1:6 ReferenceError: wasmSimdSupported is not defined
...
Assignee | ||
Comment 15•4 years ago
|
||
Ah, landed two patches at the same time that conflicted with each other.
Comment 16•4 years ago
|
||
Pushed by rhunt@eqrion.net: https://hg.mozilla.org/integration/autoland/rev/167a8edf5dee Add support for v128 in typed select instructions. r=lth
Comment 17•4 years ago
|
||
bugherder |
Description
•