Skip to content

Conversation

@kripken
Copy link
Member

@kripken kripken commented Sep 28, 2016

This rewrites the type checking code to use block/if/loop sigs properly, as read in s-expr files.

This passes all the spec tests and is basically done I think. but as mentioned in #711 (comment) fails on the binary format tests on round-tripping.

This is based on #711, so it should be rebased on master after that lands.

@kripken
Copy link
Member Author

kripken commented Sep 28, 2016

This also

  • Prints out if and loop sigs, which was missing and is now necessary.
  • Removes the DSL in OptimizeInstructions (after these type checking changes, using wasm for the DSL became too annoying, not sure what to do there).

Copy link
Member

@dschuff dschuff left a comment

Choose a reason for hiding this comment

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

Do we actually still need to do all the type merging now? Seems like if we give blocks their type on construction then we don't need to do anything on finalizing, and we can check break types, etc without that?

}
// For blocks with type unreachable but whose breaks have arity 1, encode i32 as their
// signature so that the decoder knows to pop a value for the breaks' values.
o << binaryWasmType(curr->type != unreachable ? curr->type : arity ? i32 : none);
Copy link
Member

@dschuff dschuff Sep 28, 2016

Choose a reason for hiding this comment

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

Once we parse block signatures, we can just encode curr->type here which should never be unreachable. Likewise for ifs and loops.

@kripken
Copy link
Member Author

kripken commented Sep 28, 2016

Finalizing might still matter for code generators other than wasm-s-parser. But maybe that is worth refactoring later into something on the side.

@dschuff
Copy link
Member

dschuff commented Sep 28, 2016

So the binary format difference is because in the wast parser you replaced the block finalization with the logic that instead only marks the block as unreachable if no breaks target it and the fallthrough is unreachable. If you do that in the binary parser too then it works correctly (I have that working in my local branch).

I do think the "primary" behavior should be that the type of blocks doesn't get changed by default. It might make sense to have a service for binaryen library users that might not know the block type up front (which I guess may include the optimization passes) but it doesn't need to have the same behavior.

@kripken
Copy link
Member Author

kripken commented Sep 28, 2016

Yeah, as discussed in person that's indeed the issue. I'll continue work towards that, with finalize(type) on loop/block/if using a given type (as by the s-parser or binary decoder), while finalize() with no args autodetects the type fully (which is useful in the optimizer, as you said).

…ats. print if and loop sigs which were missing. remove dsl from OptimizeInstructions as after those changes it needs rethinking
@kripken kripken force-pushed the type-check-block-sigs branch from a48b4b8 to c6fe3db Compare September 28, 2016 18:03
@kripken
Copy link
Member Author

kripken commented Sep 28, 2016

Ok, this is hopefully good to go. Tests pass locally.

@kripken kripken merged commit 2da1b20 into master Sep 28, 2016
@kripken kripken deleted the type-check-block-sigs branch September 28, 2016 20:11
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.

3 participants