Skip to content

Use jsvu to get SpiderMonkey to test asm.js validation#1443

Merged
kripken merged 3 commits into
masterfrom
jsvu
Mar 16, 2018
Merged

Use jsvu to get SpiderMonkey to test asm.js validation#1443
kripken merged 3 commits into
masterfrom
jsvu

Conversation

@kripken

@kripken kripken commented Feb 23, 2018

Copy link
Copy Markdown
Member

jsvu is an easy way to get JS VMs. This uses it to get SpiderMonkey, which is then used to check asm.js validation in the wasm2asm tests.

Those currently fail, so we should merge this only after those are fixed. We should probably make fixing those a priority. cc @froydnj

@froydnj

froydnj commented Feb 23, 2018

Copy link
Copy Markdown
Contributor

Cool! I'll look at removing the extraneous return statements next week.

@kripken

kripken commented Feb 23, 2018

Copy link
Copy Markdown
Member Author

I think the extra return statements would be good to remove, but the optimizer could do that for us, so if it's not easy to do in wasm2asm then we don't need to. But removing those warnings would make seeing the errors easier, though.

@froydnj

froydnj commented Feb 23, 2018

Copy link
Copy Markdown
Contributor

It looks like this is all that's needed:

diff --git a/src/wasm2asm.h b/src/wasm2asm.h
index 59f2d6a..5cd757e 100644
--- a/src/wasm2asm.h
+++ b/src/wasm2asm.h
@@ -655,7 +655,8 @@ Ref Wasm2AsmBuilder::processFunction(Function* func) {
   ExpressionList* stats = isBodyBlock ?
       &static_cast<Block*>(func->body)->list : nullptr;
   bool endsInReturn =
-      (isBodyBlock && ((*stats)[stats->size()-1]->_id == Expression::ReturnId));
+      (isBodyBlock && ((*stats)[stats->size()-1]->_id == Expression::ReturnId)) ||
+    func->body->_id == Expression::ReturnId;
   if (endsInReturn) {
     // return already taken care of
     flattenAppend(ret, processFunctionBody(func, NO_RESULT));

which requires regenerating all the .2asm.js files; I'm going to wait until at least #1442 lands before putting together a PR for this.

@kripken

kripken commented Feb 24, 2018

Copy link
Copy Markdown
Member Author

which requires regenerating all the .2asm.js files

Just wanted to make sure you're aware of auto_update_tests.py, which does that automatically.

@froydnj

froydnj commented Feb 26, 2018

Copy link
Copy Markdown
Contributor

Just wanted to make sure you're aware of auto_update_tests.py, which does that automatically.

I was not, that's super useful! I had written a one-liner to update the tests, but it wasn't perfect; having an already-written script will make things much easier.

froydnj added a commit to froydnj/binaryen that referenced this pull request Feb 27, 2018
This change eliminates one issue that prevents asm.js validation of the
generated code, see WebAssembly#1443.
froydnj added a commit to froydnj/binaryen that referenced this pull request Feb 27, 2018
This change eliminates one issue that prevents asm.js validation of the
generated code, see WebAssembly#1443.
froydnj added a commit to froydnj/binaryen that referenced this pull request Feb 28, 2018
This change eliminates one issue that prevents asm.js validation of the
generated code, see WebAssembly#1443.
froydnj added a commit to froydnj/binaryen that referenced this pull request Feb 28, 2018
This change eliminates one issue that prevents asm.js validation of the
generated code, see WebAssembly#1443.
froydnj added a commit to froydnj/binaryen that referenced this pull request Feb 28, 2018
This change eliminates one issue that prevents asm.js validation of the
generated code, see WebAssembly#1443.
froydnj added a commit to froydnj/binaryen that referenced this pull request Mar 1, 2018
This change eliminates one issue that prevents asm.js validation of the
generated code, see WebAssembly#1443.
kripken pushed a commit that referenced this pull request Mar 1, 2018
This change eliminates one issue that prevents asm.js validation of the
generated code, see #1443.
@froydnj

froydnj commented Mar 5, 2018

Copy link
Copy Markdown
Contributor

@kripken Can you repush this to re-run CI now that multiple return statements have been fixed?

@kripken

kripken commented Mar 5, 2018

Copy link
Copy Markdown
Member Author

Done.

froydnj added a commit to froydnj/binaryen that referenced this pull request Mar 15, 2018
We were using Math_{min,max} in wasm2asm-generated files without
declaring said functions.  This decision created problems for tests,
because Math_min (resp. max) would first be used on f32s, thus returning
f32, and then validation would fail when it was used on f64s.

The resulting changes make wasm2asm tests pass with MOZJS asm.js
validation, which moves WebAssembly#1443 forward.
froydnj added a commit to froydnj/binaryen that referenced this pull request Mar 16, 2018
We were using Math_{min,max} in wasm2asm-generated files without
declaring said functions.  This decision created problems for tests,
because Math_min (resp. max) would first be used on f32s, thus returning
f32, and then validation would fail when it was used on f64s.

The resulting changes make wasm2asm tests pass with MOZJS asm.js
validation, which moves WebAssembly#1443 forward.
kripken pushed a commit that referenced this pull request Mar 16, 2018
We were using Math_{min,max} in wasm2asm-generated files without
declaring said functions.  This decision created problems for tests,
because Math_min (resp. max) would first be used on f32s, thus returning
f32, and then validation would fail when it was used on f64s.

The resulting changes make wasm2asm tests pass with MOZJS asm.js
validation, which moves #1443 forward.
@kripken

kripken commented Mar 16, 2018

Copy link
Copy Markdown
Member Author

Great, after your last fixes @froydnj this PR is now green!

Any concerns or should I land this?

@froydnj

froydnj commented Mar 16, 2018

Copy link
Copy Markdown
Contributor

I would have said mentioning testing with node and spidermonkey in the README.md, but I see there's nothing specifically mentioning wasm2asm there in the first place. So I don't think we need anything there. No other concerns from me!

@kripken kripken merged commit c52f236 into master Mar 16, 2018
@kripken kripken deleted the jsvu branch March 16, 2018 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants