Skip to content
This repository was archived by the owner on Dec 22, 2021. It is now read-only.

Update some of the test assertions in simd_lane.wast #140

Merged
merged 6 commits into from
Dec 17, 2019

Conversation

alexcrichton
Copy link
Contributor

This updates a few of the assertions in simd_lane.wast found after writing a parser which consumes *.wast files and choking on a few of the test cases here. I'm not 100% sure if all of these changes are correct, so feedback is appreciated!

Additionally, are these tests currently run through a reference implementation somewhere? I'm not sure if the spec interpreter in this repo has been updated for the tests yet.

I believe these constants were placed there by mistake since the tests
seem to be for the immediate argument of the instruction rather than the
text format.
The tests here seem to be for the text format either specifying too few
or too few lanes, so this moves them to `assert_malformed` instead of
inline as an expected-valid module. This way parsers don't need to
handle a variable number of lanes but can always expect 16 lanes to be
specified.
Copy link
Contributor

@abrown abrown left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! I could use these changes if merged.

Copy link
Contributor

@penzn penzn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using malformed rather than invalid makes sense, there is only one valid form of shuffle with just the right number of lanes.

Nit: too few or too few

Comment on lines 492 to 493
(assert_malformed (module quote "(func v8x16.shuffle 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14)") "invalid lane length")
(assert_malformed (module quote "(func v8x16.shuffle 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16)") "invalid lane length")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this work like this without arguments?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm sorry I'm not sure I quite understand, could you clarify what you're thinking should work without arguments?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the shuffle instruction need all arguments for this test to work correctly? You are not providing the two v128 arguments to it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree this should be malformed, but I think we should provide the two v128 arguments to distinguish the malformed is from missing arguments or the invalid lane length. BTW, missing arguments is another test that worth testing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok, I see what you mean, and sure! I've updated the test to typecheck but still have this expected assertion failure.

Sorry I also don't know how to have multiline strings in the wat format so it's a bit messy...

@penzn
Copy link
Contributor

penzn commented Nov 15, 2019

We are working on interpreter, skeleton code is in #138, @ngzhian has some code he might be able to add soon after. I can try to prioritize support for shuffles, but there might be other things on the way to it.

Also adding @Honry

Copy link
Contributor

@Honry Honry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexcrichton, thank you! LGTM except the test for "invalid lane length", I think we should keep the two v128 arguments.

Comment on lines 492 to 493
(assert_malformed (module quote "(func v8x16.shuffle 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14)") "invalid lane length")
(assert_malformed (module quote "(func v8x16.shuffle 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16)") "invalid lane length")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree this should be malformed, but I think we should provide the two v128 arguments to distinguish the malformed is from missing arguments or the invalid lane length. BTW, missing arguments is another test that worth testing.

(v128.const i8x16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0)
(v128.const i8x16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15)))) "invalid lane length")
(assert_malformed (module quote "(func (param v128) (result v128) local.get 0 local.get 0 v8x16.shuffle 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14)") "invalid lane length")
(assert_malformed (module quote "(func (param v128) (result v128) local.get 0 local.get 0 v8x16.shuffle 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16)") "invalid lane length")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
(assert_malformed (module quote "(func (param v128) (result v128) local.get 0 local.get 0 v8x16.shuffle 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16)") "invalid lane length")
(assert_malformed (module quote "(func (param v128) (result v128) "
"(local.get 0) (local.get 0)"
"v8x16.shuffle 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16)")
"invalid lane length")

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's more readable with above suggestion. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh right!

Copy link
Contributor

@Honry Honry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, pretty good now.

Honry added a commit to Honry/WAVM that referenced this pull request Nov 20, 2019
AndrewScheidecker pushed a commit to WAVM/WAVM that referenced this pull request Nov 21, 2019
@arunetm arunetm merged commit 84b527f into WebAssembly:master Dec 17, 2019
@alexcrichton alexcrichton deleted the tweak-tests branch December 17, 2019 17:56
kenohassler pushed a commit to fgsect/WAFL that referenced this pull request Oct 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants