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

[wasi] Implement TODO in mono-threads-wasi.S #101337

Merged
merged 8 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions src/mono/mono/utils/mono-threads-wasi.S
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
// TODO after https://github.com/llvm/llvm-project/commit/1532be98f99384990544bd5289ba339bca61e15b
// use __stack_low && __stack_high
.globl get_wasm_stack_low
.globl get_wasm_stack_high

.globl get_wasm_data_end
.globl get_wasm_heap_base

get_wasm_data_end:
.functype get_wasm_data_end () -> (i32)
global.get __data_end@GOT
get_wasm_stack_low:
.functype get_wasm_stack_low () -> (i32)
global.get __stack_low@GOT
end_function

get_wasm_heap_base:
.functype get_wasm_heap_base () -> (i32)
global.get __heap_base@GOT
get_wasm_stack_high:
.functype get_wasm_stack_high () -> (i32)
global.get __stack_high@GOT
end_function
13 changes: 5 additions & 8 deletions src/mono/mono/utils/mono-threads-wasm.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,8 @@ wasm_get_stack_size (void)

#else /* HOST_BROWSER -> WASI */

// TODO after https://github.com/llvm/llvm-project/commit/1532be98f99384990544bd5289ba339bca61e15b
// use __stack_low && __stack_high
// see mono-threads-wasi.S
uintptr_t get_wasm_heap_base(void);
uintptr_t get_wasm_data_end(void);
uintptr_t get_wasm_stack_high(void);
uintptr_t get_wasm_stack_low(void);

static int
wasm_get_stack_size (void)
Expand All @@ -60,8 +57,8 @@ wasm_get_stack_size (void)
* | -- increasing address ---> |
* | data (data_end)| stack |(heap_base) heap |
*/
size_t heap_base = get_wasm_heap_base();
size_t data_end = get_wasm_data_end();
size_t heap_base = get_wasm_stack_high();
size_t data_end = get_wasm_stack_low();
size_t max_stack_size = heap_base - data_end;

g_assert (data_end > 0);
Expand All @@ -75,7 +72,7 @@ wasm_get_stack_size (void)
static int
wasm_get_stack_base (void)
{
return get_wasm_data_end();
return get_wasm_stack_high();
lambdageek marked this conversation as resolved.
Show resolved Hide resolved
// this will need further change for multithreading as the stack will allocated be per thread at different addresses
}

Expand Down
Loading