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

Apply the sbrk/brk value at compile time #2366

Merged
merged 4 commits into from
Oct 1, 2019
Merged

Apply the sbrk/brk value at compile time #2366

merged 4 commits into from
Oct 1, 2019

Conversation

kripken
Copy link
Member

@kripken kripken commented Sep 30, 2019

We've had an option to set the location of the sbrk ptr, but not the value. Applying the value as well is necessary for standalone wasm, as otherwise we set it in JS.

@@ -80,6 +81,23 @@ struct PostEmscripten : public Pass {
func->body = builder.makeConst(Literal(int32_t(sbrkPtr)));
func->module = func->base = Name();
}
// Apply the sbrk ptr value, if it was provided.
Copy link
Member

Choose a reason for hiding this comment

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

It would be good if this comment explained what it means to apply the sbrk ptr value. I'm still not sure why the value needs to be written into memory.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, added more text there now.

@kripken kripken merged commit fc6d2df into master Oct 1, 2019
@kripken kripken deleted the sbrk-val branch October 1, 2019 00:15
kripken added a commit to emscripten-core/emscripten that referenced this pull request Oct 2, 2019
Emscripten side of WebAssembly/binaryen#2366 (that must roll first), this tells
binaryen to set the value in the wasm binary, which fixes standalone wasm
module's sbrk() usage (as normally we set this is JS).

This also disables eval-ctors for the wasm backend, see #9527 , which made an
incorrect assumption about the sbrk initial location - JS may modify it during
startup, so we can't assume it's constant. This affects only -Oz so it's
probably not many users.

After this PR we should be correct in both standalone and non-standalone modes,
and later we can look into re-enabling eval-ctors.
belraquib pushed a commit to belraquib/emscripten that referenced this pull request Dec 23, 2020
Emscripten side of WebAssembly/binaryen#2366 (that must roll first), this tells
binaryen to set the value in the wasm binary, which fixes standalone wasm
module's sbrk() usage (as normally we set this is JS).

This also disables eval-ctors for the wasm backend, see emscripten-core#9527 , which made an
incorrect assumption about the sbrk initial location - JS may modify it during
startup, so we can't assume it's constant. This affects only -Oz so it's
probably not many users.

After this PR we should be correct in both standalone and non-standalone modes,
and later we can look into re-enabling eval-ctors.
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