Skip to content

Commit 15b01e8

Browse files
authored
Make STACK_BASE refer to the starting stack location on threads (#9033)
This is already a case on the main thread. However, on WASM backend, STACK_BASE == STACK_MAX == the lowest address on the stack, i.e. the point where the stack can grow to. This makes it impossible to find the highest address on the stack, i.e. the bottom of the stack. This PR makes the behaviour consistent between the main thread and other threads by making other threads follow the conventions of the main thread.
1 parent 225dd7d commit 15b01e8

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/worker.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ this.onmessage = function(e) {
183183
var max = e.data.stackBase + e.data.stackSize;
184184
var top = e.data.stackBase;
185185
#endif
186-
{{{ makeAsmExportAndGlobalAssignTargetInPthread('STACK_BASE') }}} = e.data.stackBase;
186+
{{{ makeAsmExportAndGlobalAssignTargetInPthread('STACK_BASE') }}} = top;
187187
{{{ makeAsmExportAndGlobalAssignTargetInPthread('STACKTOP') }}} = top;
188188
{{{ makeAsmExportAndGlobalAssignTargetInPthread('STACK_MAX') }}} = max;
189189
#if ASSERTIONS
@@ -194,7 +194,6 @@ this.onmessage = function(e) {
194194
#if WASM_BACKEND
195195
assert(max === e.data.stackBase);
196196
assert(top > max);
197-
assert(e.data.stackBase == max);
198197
#else
199198
assert(max > e.data.stackBase);
200199
assert(max > top);

0 commit comments

Comments
 (0)