mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-14 05:09:36 +02:00
* WebAssembly threads: call fpc_wasm32_init_tls from inline asm code to avoid
race condition in branchful exceptions mode
This commit is contained in:
parent
fcfce9f2d5
commit
a0e1dce1fd
@ -342,7 +342,6 @@ procedure WasiAllocateThreadVars; forward;
|
||||
procedure FPCWasmThreadStartPascal(tid: longint; start_arg: PWasmThread);
|
||||
begin
|
||||
{$IFDEF DEBUGWASMTHREADS}DebugWriteln('FPCWasmThreadStartPascal(...)');{$ENDIF}
|
||||
fpc_wasm32_init_tls(start_arg^.InitTLSBase);
|
||||
|
||||
start_arg^.ID:=tid;
|
||||
GlobalCurrentThread:=@start_arg;
|
||||
@ -383,6 +382,16 @@ asm
|
||||
i32.load
|
||||
global.set $__stack_pointer
|
||||
|
||||
;; call fpc_wasm32_init_tls from within assembly code, because in branchful
|
||||
;; exceptions mode, Free Pascal generates threadvar access after every
|
||||
;; function call. Therefore, we want threadvars to be initialized, before we
|
||||
;; call any sort of Pascal code.
|
||||
local.get 1 ;; start_arg
|
||||
i32.const 4 ;; offset to InitTLSBase
|
||||
i32.add
|
||||
i32.load
|
||||
call $fpc_wasm32_init_tls
|
||||
|
||||
local.get 0
|
||||
local.get 1
|
||||
call $FPCWasmThreadStartPascal
|
||||
|
Loading…
Reference in New Issue
Block a user