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

Fix a number of anyref related bugs in our passes #1692

Merged
merged 4 commits into from
Aug 2, 2019

Conversation

alexcrichton
Copy link
Contributor

This commit goes through and fixes a number of bugs around the anyref pass in wasm-bindgen. Most of the issues were around initialization and tests, but after this commit the full test suite passes in Node.js. Yay!

This functionality got lost in recent refactorings for WebIDL bindings
unfortunately, so this commit touches things up to ensure that the
anyref table initialization in anyref-mode is hooked up correctly, even
when tests are enabled. This invovled moving injection of the start
function to the webidl processing pass and ensuring its intrinsic is
registered in the internal maps of wasm-bindgen.
With more than two anyref stack arguments we were accidentally storing
the anyref values one higher in the stack than intended, so fix this
off-by-one by switching up some addition logic.
This is currently required by our ABI for wasm-bindgen where `None` js
values going out have an index of 0 and are intended to be `undefined`.
This also refactors initialization a bit to be slightly more generic
over the constants we already have defined in this module.
This `base` value is the raw value coming out of the first call to
`table.grow`. Throwing in the addition of `JSIDX_RESERVED` just wasn't
right!
Copy link
Member

@fitzgen fitzgen left a comment

Choose a reason for hiding this comment

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

Very nice 👏

@@ -145,7 +145,7 @@ intrinsics! {
#[symbol = "__wbindgen_anyref_heap_live_count"]
#[signature = fn() -> I32]
AnyrefHeapLiveCount,
#[symbol = "__wbindgen_init_nyref_table"]
Copy link
Member

Choose a reason for hiding this comment

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

lolsob...

@fitzgen
Copy link
Member

fitzgen commented Aug 1, 2019

So now that node has proper anyref support, can we actually run our test suite (or a subset of it) with anyref enabled in CI?

@alexcrichton alexcrichton merged commit 117fce1 into rustwasm:master Aug 2, 2019
@alexcrichton
Copy link
Contributor Author

Soon we can I think! The support just (like 24 hours ago) landed on the master branch of nodejs, so I think we'll need to wait for the next release and then we should be able to download a recent verison of Node to test with.

@alexcrichton alexcrichton deleted the fix-anyref-bugs branch August 2, 2019 14:47
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