|
@@ -38,6 +38,7 @@ interface
|
|
private
|
|
private
|
|
FFirstFreeLocal: Integer;
|
|
FFirstFreeLocal: Integer;
|
|
FAllocatedLocals: array of TWasmBasicType;
|
|
FAllocatedLocals: array of TWasmBasicType;
|
|
|
|
+ FGotoTargets: TFPHashObjectList;
|
|
|
|
|
|
function ConvertBranchTargetNumbersToLabels(ai: tai; blockstack: twasmstruc_stack): TAsmMapFuncResult;
|
|
function ConvertBranchTargetNumbersToLabels(ai: tai; blockstack: twasmstruc_stack): TAsmMapFuncResult;
|
|
function ConvertIfToBrIf(ai: tai; blockstack: twasmstruc_stack): TAsmMapFuncResult;
|
|
function ConvertIfToBrIf(ai: tai; blockstack: twasmstruc_stack): TAsmMapFuncResult;
|
|
@@ -51,11 +52,14 @@ interface
|
|
CurrRaiseLabel : tasmlabel;
|
|
CurrRaiseLabel : tasmlabel;
|
|
|
|
|
|
constructor create(aparent: tprocinfo); override;
|
|
constructor create(aparent: tprocinfo); override;
|
|
|
|
+ destructor destroy; override;
|
|
function calc_stackframe_size : longint;override;
|
|
function calc_stackframe_size : longint;override;
|
|
procedure setup_eh; override;
|
|
procedure setup_eh; override;
|
|
procedure generate_exit_label(list: tasmlist); override;
|
|
procedure generate_exit_label(list: tasmlist); override;
|
|
procedure postprocess_code; override;
|
|
procedure postprocess_code; override;
|
|
procedure set_first_temp_offset;override;
|
|
procedure set_first_temp_offset;override;
|
|
|
|
+ procedure add_goto_target(l : tasmlabel);
|
|
|
|
+ function is_goto_target(l : tasmlabel): Boolean;
|
|
end;
|
|
end;
|
|
|
|
|
|
implementation
|
|
implementation
|
|
@@ -424,10 +428,17 @@ implementation
|
|
constructor tcpuprocinfo.create(aparent: tprocinfo);
|
|
constructor tcpuprocinfo.create(aparent: tprocinfo);
|
|
begin
|
|
begin
|
|
inherited create(aparent);
|
|
inherited create(aparent);
|
|
|
|
+ FGotoTargets:=TFPHashObjectList.Create(false);
|
|
if ts_wasm_bf_exceptions in current_settings.targetswitches then
|
|
if ts_wasm_bf_exceptions in current_settings.targetswitches then
|
|
current_asmdata.getjumplabel(CurrRaiseLabel);
|
|
current_asmdata.getjumplabel(CurrRaiseLabel);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+ destructor tcpuprocinfo.destroy;
|
|
|
|
+ begin
|
|
|
|
+ FGotoTargets.Free;
|
|
|
|
+ inherited destroy;
|
|
|
|
+ end;
|
|
|
|
+
|
|
function tcpuprocinfo.calc_stackframe_size: longint;
|
|
function tcpuprocinfo.calc_stackframe_size: longint;
|
|
begin
|
|
begin
|
|
{ the stack frame in WebAssembly should always have a 16-byte alignment }
|
|
{ the stack frame in WebAssembly should always have a 16-byte alignment }
|
|
@@ -947,6 +958,16 @@ implementation
|
|
tg.setfirsttemp(sz);
|
|
tg.setfirsttemp(sz);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+ procedure tcpuprocinfo.add_goto_target(l: tasmlabel);
|
|
|
|
+ begin
|
|
|
|
+ FGotoTargets.Add(l.Name,l);
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+ function tcpuprocinfo.is_goto_target(l: tasmlabel): Boolean;
|
|
|
|
+ begin
|
|
|
|
+ result:=FGotoTargets.FindIndexOf(l.Name)<>-1;
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
|
|
initialization
|
|
initialization
|
|
cprocinfo:=tcpuprocinfo;
|
|
cprocinfo:=tcpuprocinfo;
|