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

Don't emit mutable globals #2391

Merged
merged 1 commit into from
Dec 6, 2020
Merged

Don't emit mutable globals #2391

merged 1 commit into from
Dec 6, 2020

Conversation

arilotter
Copy link
Contributor

@arilotter arilotter commented Dec 4, 2020

A proposed fix for #2386, based on @alexcrichton's comment here: #2386 (comment)

We emit a shim function that sets the stack pointer, so we can avoid emitting mutable globals.
Mutable globals aren't supported everywhere Wasm is.

This PR seems to pass tests, but I believe it doesn't actually avoid exporting the stack pointer yet.
I'm not sure where to look for that, and I imagine we should add a test to ensure we actually don't export mutable globals.

This is my first foray into the wasm-bindgen codebase, so I expect there to be some mistakes in this code.

I think I might still need to modify export_shadow_stack_pointer to not export it to the wasm module...

Copy link
Contributor

@alexcrichton alexcrichton left a comment

Choose a reason for hiding this comment

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

Looks great to me, thanks for tackling this!

crates/cli-support/src/js/mod.rs Outdated Show resolved Hide resolved
crates/cli-support/src/js/mod.rs Outdated Show resolved Hide resolved
crates/cli-support/src/js/mod.rs Outdated Show resolved Hide resolved
We emit a shim function that sets the stack pointer,
so we can avoid emitting mutable globals.
Mutable globals aren't supported everywhere Wasm is.
@arilotter arilotter marked this pull request as ready for review December 5, 2020 19:50
@arilotter
Copy link
Contributor Author

arilotter commented Dec 5, 2020

@alexcrichton I've resolved all the comments from your previous review :)

@alexcrichton alexcrichton merged commit b584407 into rustwasm:master Dec 6, 2020
@alexcrichton
Copy link
Contributor

Thanks!

@arilotter arilotter deleted the stack-pointer-shim-mutable-globals branch December 7, 2020 07:14
@stuartZhang
Copy link

Which version will include the improvement? I need it as well. @alexcrichton

@alexcrichton
Copy link
Contributor

I've done a version bump at #2435

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