mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-15 11:00:15 +02:00
* WASI: preserve the initial value of the stack pointer on startup, so that we
can later use the area after that, until the end of memory as an initial heap
This commit is contained in:
parent
5cfd214b68
commit
7d1999eedb
rtl/wasi
@ -32,7 +32,7 @@ procedure PASCALMAIN; external 'PASCALMAIN';
|
||||
{$if defined(FPC_WASM_BRANCHFUL_EXCEPTIONS) or defined(FPC_WASM_NATIVE_EXCEPTIONS)}
|
||||
Procedure DoUnHandledException; external name 'FPC_DOUNHANDLEDEXCEPTION';
|
||||
|
||||
procedure _initialize;
|
||||
procedure _initialize_pascal;
|
||||
begin
|
||||
try
|
||||
PASCALMAIN;
|
||||
@ -41,12 +41,28 @@ begin
|
||||
end;
|
||||
end;
|
||||
{$else}
|
||||
procedure _initialize;
|
||||
procedure _initialize_pascal;
|
||||
begin
|
||||
PASCALMAIN;
|
||||
end;
|
||||
{$endif}
|
||||
|
||||
procedure SetInitialHeapBlockStart(p: Pointer); external name 'FPC_WASM_SETINITIALHEAPBLOCKSTART';
|
||||
|
||||
{ TODO: remove this, when calling SetInitialHeapBlockStart works directly from within inline asm }
|
||||
procedure SetInitialHeapBlockStart2(p: Pointer);
|
||||
begin
|
||||
SetInitialHeapBlockStart(p);
|
||||
end;
|
||||
|
||||
procedure _initialize; assembler; nostackframe;
|
||||
asm
|
||||
global.get $__stack_pointer
|
||||
call $SetInitialHeapBlockStart2
|
||||
|
||||
call $_initialize_pascal
|
||||
end;
|
||||
|
||||
exports
|
||||
_initialize,
|
||||
_initialize name '_initialize_promising' promising;
|
||||
|
@ -32,7 +32,7 @@ procedure PASCALMAIN; external 'PASCALMAIN';
|
||||
{$if defined(FPC_WASM_BRANCHFUL_EXCEPTIONS) or defined(FPC_WASM_NATIVE_EXCEPTIONS)}
|
||||
Procedure DoUnHandledException; external name 'FPC_DOUNHANDLEDEXCEPTION';
|
||||
|
||||
procedure _start;
|
||||
procedure _start_pascal;
|
||||
begin
|
||||
try
|
||||
PASCALMAIN;
|
||||
@ -41,12 +41,28 @@ begin
|
||||
end;
|
||||
end;
|
||||
{$else}
|
||||
procedure _start;
|
||||
procedure _start_pascal;
|
||||
begin
|
||||
PASCALMAIN;
|
||||
end;
|
||||
{$endif}
|
||||
|
||||
procedure SetInitialHeapBlockStart(p: Pointer); external name 'FPC_WASM_SETINITIALHEAPBLOCKSTART';
|
||||
|
||||
{ TODO: remove this, when calling SetInitialHeapBlockStart works directly from within inline asm }
|
||||
procedure SetInitialHeapBlockStart2(p: Pointer);
|
||||
begin
|
||||
SetInitialHeapBlockStart(p);
|
||||
end;
|
||||
|
||||
procedure _start; assembler; nostackframe;
|
||||
asm
|
||||
global.get $__stack_pointer
|
||||
call $SetInitialHeapBlockStart2
|
||||
|
||||
call $_start_pascal
|
||||
end;
|
||||
|
||||
exports
|
||||
_start,
|
||||
_start name '_start_promising' promising;
|
||||
|
@ -20,6 +20,14 @@
|
||||
Heap Management
|
||||
*****************************************************************************}
|
||||
|
||||
var
|
||||
InitialHeapBlockStart: Pointer;
|
||||
|
||||
procedure SetInitialHeapBlockStart(p: Pointer);[Public, Alias : 'FPC_WASM_SETINITIALHEAPBLOCKSTART'];
|
||||
begin
|
||||
InitialHeapBlockStart:=p;
|
||||
end;
|
||||
|
||||
function SysOSAlloc(size: ptruint): pointer;
|
||||
const
|
||||
page_size = 65536;
|
||||
|
Loading…
Reference in New Issue
Block a user