-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Add functions for access emscripten stack layout information #11437
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tests/core/test_stack_get_free.out
is empty?
lgtm aside from test issues
tests/core/test_stack_get_free.c
Outdated
|
||
uintptr_t prevFree = emscripten_stack_get_free(); | ||
for(int i = 0; i < 10; ++i) { | ||
void *p = alloca(emscripten_random() >= 0 ? 256*1024 : 255 * 1024); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the use of random here seems odd. is this to confuse the optimizer?
(also, spaces around *
look inconsistent)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just copied this test from the other PR :) But yes I agree its strange.. @juj, why this?
This change adds emscripten_stack_get_base/free/end/current. This is a cut down version of #11162 which uses wasm assembly rather than relying on binaryen changes. Also remove old emscripten_get_stack_base/emscripten_get_stack_top from src/library.js. emscripten_get_stack_top never worked anyway since its was not marked as asm and therefore not referencing the arm-internal version of STACKTOP.
if | ||
call emscripten_stack_get_end | ||
global.set __stack_end | ||
end_if |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, thanks for working on this!
Having this in a .s file is a cool approach. However, this if
branch makes this suboptimal compared to the solution that was presented in #11162 + WebAssembly/binaryen#2849 that did not need the branch :( (the original solution was just a single sub.
Any change we could get rid of this comparison?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, that sounds perfectly reasonable. Should be trivial change. I'm OK doing it, or you do you want to?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, if you have the cycles, that would be much appreciated!
This is a followup on #11437 which added this API. Sadly today the linker doesn't know the final memory layout so until we fix #11773 this extra `init` function is needed. The alternative, which is to modify binaryen and emscripten to inject the stack end value post-link is IMHO way to much complexity to justify the convenience of not having the call this init function. Once we fix #11773 the init function can become uneeded/no-op.
This is a followup on #11437 which added this API. Sadly today the linker doesn't know the final memory layout so until we fix #11773 this extra `init` function is needed. The alternative, which is to modify binaryen and emscripten to inject the stack end value post-link is IMHO way to much complexity to justify the convenience of not having the call this init function. Once we fix #11773 the init function can become uneeded/no-op.
This is a followup on #11437 which added this API. Sadly today the linker doesn't know the final memory layout so until we fix #11773 this extra `init` function is needed. The alternative, which is to modify binaryen and emscripten to inject the stack end value post-link is IMHO way to much complexity to justify the convenience of not having the call this init function. Once we fix #11773 the init function can become uneeded/no-op.
This is a followup on #11437 which added this API. Sadly today the linker doesn't know the final memory layout so until we fix #11773 this extra `init` function is needed. The alternative, which is to modify binaryen and emscripten to inject the stack end value post-link is IMHO way to much complexity to justify the convenience of not having the call this init function. Once we fix #11773 the init function can become uneeded/no-op.
This is a followup on #11437 which added this API. Sadly today the linker doesn't know the final memory layout so until we fix #11773 this extra `init` function is needed. The alternative, which is to modify binaryen and emscripten to inject the stack end value post-link is IMHO way to much complexity to justify the convenience of not having the call this init function. Once we fix #11773 the init function can become uneeded/no-op.
This is a followup on #11437 which added this API. Sadly today the linker doesn't know the final memory layout so until we fix #11773 this extra `init` function is needed. The alternative, which is to modify binaryen and emscripten to inject the stack end value post-link is IMHO way to much complexity to justify the convenience of not having the call this init function. Once we fix #11773 the init function can become unneeded/no-op.
This change adds emscripten_stack_get_base/free/end/current.
This is a cut down version of #11162 which uses wasm assembly
rather than relying on binaryen changes.