* fixed bug in the handling of WebAssembly goto

This commit is contained in:
Nikolay Nikolov 2024-01-16 08:12:40 +02:00
parent 21ffa221e6
commit f65e4f2385

View File

@ -918,15 +918,17 @@ implementation
end;
end;
procedure check_goto_br_instructions(list: TAsmList);
procedure check_goto_br_instructions(list: TAsmList; out HasGotoBrInstructions: boolean);
var
hp: tai;
begin
HasGotoBrInstructions:=False;
hp:=tai(list.first);
while assigned(hp) do
begin
if (hp.typ=ait_instruction) and (taicpu(hp).is_br_generated_by_goto) then
begin
HasGotoBrInstructions:=True;
if (taicpu(hp).opcode<>a_br) or
(taicpu(hp).ops<>1) or
(taicpu(hp).oper[0]^.typ<>top_ref) or
@ -944,15 +946,18 @@ implementation
var
localslist: TAsmList;
labels_resolved: Boolean;
labels_resolved, has_goto: Boolean;
begin
check_goto_br_instructions(aktproccode);
check_goto_br_instructions(aktproccode,has_goto);
localslist:=prepare_locals;
replace_local_frame_pointer(aktproccode);
labels_resolved:=resolve_labels_simple(aktproccode);
labels_resolved:=false;
if not has_goto then
{ TODO: make resolve_labels_simple handle goto labels correctly }
labels_resolved:=resolve_labels_simple(aktproccode);
{$ifndef DEBUG_WASM_GOTO}
if not labels_resolved then
{$endif DEBUG_WASM_GOTO}