This repository has been archived by the owner on Jun 26, 2020. It is now read-only.
Relax verification to allow I8X16 to act as a default vector type #1236
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This change uses I8X16 as a default type to represent Wasm's V128 type. Values of Wasm's V128 type can be used in any instruction of similar width (e.g.
i32x4.add
). Cranelift must build signatures for Wasm functions using V128 and, lacking a special type to do so, Cranelift uses I8X16 for V128. To avoid excessive bitcasting, however, we relax the verifier to allow I8X16 to type-check as the other 128-bit types. This implies that:v1 = iadd.i8x16 v0, v0; v2 = isub.i32x4 v1, v0
(presumably we wantv0
andv1
to beI8X16
in fact and would want the verifier to tell us that we should not add them asI32X4
s).With this change, we still might choose to bitcast between SIMD instructions. Consider the Wasm snippet
i64x2.add (f32x4.sub (local.get 0) (local.get 1))
for the following three options:we retain all the current bitcasts between SIMD instructions when translating from Wasm; this means that the Wasm snippet is valid and compilable
we remove all of the current bitcasts between SIMD instructions when translating from Wasm; this makes the Wasm snippet invalid and compilation would fail with a verifier error
we retain the bitcasts but make this a configurable feature; in strict mode the snippet above would fail to compile but in relaxed mode it would succeed.
This PR contains test cases, if meaningful.
A reviewer from the core maintainer team has been assigned for this PR.