diff --git a/packages/wasm-utils/fpmake.pp b/packages/wasm-utils/fpmake.pp index 0666afaa50..e09615d852 100644 --- a/packages/wasm-utils/fpmake.pp +++ b/packages/wasm-utils/fpmake.pp @@ -27,6 +27,8 @@ begin P.SourcePath.Add('src'); // Logger T:=P.Targets.AddUnit('wasm.logger.api.pas'); + // Memutils + T:=P.Targets.AddUnit('wasm.memutils.pas'); // Timer T:=P.Targets.AddUnit('wasm.timer.shared.pas'); diff --git a/rtl/wasicommon/sysheap.inc b/rtl/wasicommon/sysheap.inc index b76edc67ce..c45c1395a2 100644 --- a/rtl/wasicommon/sysheap.inc +++ b/rtl/wasicommon/sysheap.inc @@ -71,6 +71,8 @@ begin end else SysOSAlloc:=nil; + if assigned(WasmGrowMemoryCallback) then + WasmGrowMemoryCallback(grow_pages); end; {$ifdef FPC_WASM_THREADS} if InitialHeapCriticalSectionInitialized then diff --git a/rtl/wasicommon/system.pp b/rtl/wasicommon/system.pp index 15604af216..2ad5bacf40 100644 --- a/rtl/wasicommon/system.pp +++ b/rtl/wasicommon/system.pp @@ -66,17 +66,23 @@ const sLineBreak = LineEnding; DefaultTextLineBreakStyle : TTextLineBreakStyle = tlbsLF; +type + TWasmGrowMemoryCallBack = procedure(aGrowPages: longint); + var argc: longint; argv: PPAnsiChar; envp: PPAnsiChar; ___fpc_wasm_suspender: WasmExternRef; section 'WebAssembly.Global'; - + WasmGrowMemoryCallback : TWasmGrowMemoryCallBack; + function __fpc_get_wasm_suspender: WasmExternRef; procedure __fpc_set_wasm_suspender(v: WasmExternRef); property __fpc_wasm_suspender: WasmExternRef read __fpc_get_wasm_suspender write __fpc_set_wasm_suspender; + + Procedure DebugWriteln(aString : ShortString); implementation