* Allow wasm guest & host to be notified of wasm memory growth

This commit is contained in:
Michaël Van Canneyt 2025-04-02 11:21:03 +02:00
parent 62236ec2bb
commit 736fc12e55
3 changed files with 11 additions and 1 deletions

View File

@ -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');

View File

@ -71,6 +71,8 @@ begin
end
else
SysOSAlloc:=nil;
if assigned(WasmGrowMemoryCallback) then
WasmGrowMemoryCallback(grow_pages);
end;
{$ifdef FPC_WASM_THREADS}
if InitialHeapCriticalSectionInitialized then

View File

@ -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