11.extern __stack_pointer
2- .extern __stack_base
3- .extern __stack_end
42
53#ifdef __wasm64__
64#define PTR i64
1311#endif
1412
1513.globaltype __stack_pointer, PTR
16- .globaltype __stack_end , PTR
17- .globaltype __stack_base , PTR
14+ .globaltype __tls_size , PTR, immutable
15+ .functype emscripten_stack_set_limits (PTR /*base*/ , PTR /*end*/ ) -> ()
1816
1917.globl _emscripten_wasm_worker_initialize
2018_emscripten_wasm_worker_initialize:
2119 .functype _emscripten_wasm_worker_initialize (PTR /*stackLowestAddress*/ , i32 /*stackSize*/ ) -> ()
20+ .local PTR, PTR
2221
23- // __stack_end = stackLowestAddress + (__builtin_wasm_tls_size() + 15) & -16;
22+ // stack_end = stackLowestAddress + (__builtin_wasm_tls_size() + 15) & -16;
2423 local.get 0
25- .globaltype __tls_size, PTR, immutable
2624 global.get __tls_size
2725 PTR.add
2826 PTR.const 0xf
2927 PTR.add
3028 PTR.const -0x10
3129 PTR.and
32- global .set __stack_end
30+ local .set 2
3331
34- // __stack_base = stackLowestAddress + stackSize;
32+ // stack_base = stackLowestAddress + stackSize;
3533 local.get 0
3634 local.get 1
3735#ifdef __wasm64__
3836 i64.extend_i32_u
3937#endif
4038 PTR.add
41- global.set __stack_base
39+ local.set 3
40+
41+ local.get 3
42+ local.get 2
43+ // emscripten_stack_set_limits(stack_base, stack_end);
44+ call emscripten_stack_set_limits
4245
4346// TODO: We'd like to do this here to avoid JS side calls to __set_stack_limits.
4447// (or even better, we'd like to avoid duplicate versions of the stack variables)
@@ -48,6 +51,7 @@ _emscripten_wasm_worker_initialize:
4851// .functype __set_stack_limits (PTR, PTR) -> ()
4952// call __set_stack_limits
5053
54+
5155 // __wasm_init_tls(stackLowestAddress);
5256 local.get 0
5357 .functype __wasm_init_tls (PTR) -> ()
@@ -57,8 +61,8 @@ _emscripten_wasm_worker_initialize:
5761 // __stack_pointer initialized, and it destroys the value it was set to.
5862 // So we must initialize __stack_pointer only *after* completing __wasm_init_tls:
5963
60- // __stack_pointer = __stack_base ;
61- global .get __stack_base
64+ // __stack_pointer = stack_base ;
65+ local .get 3
6266 global.set __stack_pointer
6367
6468 end_function
0 commit comments