Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support wasm globals #650

Merged
merged 1 commit into from
Jul 21, 2016
Merged

Support wasm globals #650

merged 1 commit into from
Jul 21, 2016

Conversation

kripken
Copy link
Member

@kripken kripken commented Jul 21, 2016

Support for the new globals preparing to land in the spec repo,

WebAssembly/spec#313

This passes the wast test in that PR.

// Execute an expression in global init
class GlobalInitRunner : public ExpressionRunner<GlobalInitRunner> {
public:
Flow visitLoop(Loop* curr) { WASM_UNREACHABLE(); }
Copy link
Member

Choose a reason for hiding this comment

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

This should probably result in some kind of validation error, rather than WASM_UNREACHABLE (since otherwise well-formed input could reach this code?)

Copy link
Member Author

Choose a reason for hiding this comment

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

This code is reached when we execute the init statement for the global, which is when we instantiate the module, which is after we fully parse and validate it. That means we can assume the expression is valid, in which case none of these unreachables would be hit. Assuming we don't have a bug in our validation ;)

Copy link
Member

Choose a reason for hiding this comment

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

Got it; but I don't see code for that in wasm-validator.h?

Copy link
Member Author

Choose a reason for hiding this comment

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

Look at https://github.com/WebAssembly/binaryen/pull/650/files/0dc286f78cd3d5d1f5fd1cb21c16485cd9f2fd1f#diff-33a3856e71772f6165f55c85cb076496R264 , it's actually a stronger check than needed - it only accepts Const (because that's all that is tested currently, and I'm not sure what else will be allowed).

Copy link
Member

Choose a reason for hiding this comment

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

Ah, got it.

@kripken kripken merged commit fdbba5e into master Jul 21, 2016
@kripken kripken deleted the globals branch July 21, 2016 23:07
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