From a1c8e92904f3504fe6c3a7140134b910aadc04d9 Mon Sep 17 00:00:00 2001 From: Nikolay Nikolov Date: Mon, 27 Sep 2021 00:33:57 +0300 Subject: [PATCH] * emit a tai_tagtype for __FPC_exception instead of hardcoding the asm output directly when wasm native exceptions are enabled --- compiler/aggas.pas | 2 ++ compiler/wasm32/agllvmmc.pas | 5 ----- compiler/wasm32/nwasmutil.pas | 6 +++++- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/compiler/aggas.pas b/compiler/aggas.pas index 43ace2a07c..c24c4a486f 100644 --- a/compiler/aggas.pas +++ b/compiler/aggas.pas @@ -840,6 +840,8 @@ implementation writer.AsmWrite(gas_wasm_basic_type_str[wasm_basic_typ]); end; writer.AsmLn; + writer.AsmWrite(hp.tagname); + writer.AsmWriteLn(':'); end; {$endif WASM} diff --git a/compiler/wasm32/agllvmmc.pas b/compiler/wasm32/agllvmmc.pas index 4b43adb725..0b44e832b6 100644 --- a/compiler/wasm32/agllvmmc.pas +++ b/compiler/wasm32/agllvmmc.pas @@ -83,11 +83,6 @@ implementation procedure TLLVMMachineCodePlaygroundAssembler.WriteAsmList; begin writer.AsmWriteLn(#9'.globaltype'#9+STACK_POINTER_SYM+', i32'); - if ts_wasm_native_exceptions in current_settings.targetswitches then - begin - writer.AsmWriteLn(#9'.tagtype'#9'__FPC_exception'); - writer.AsmWriteLn('__FPC_exception:'); - end; inherited; end; diff --git a/compiler/wasm32/nwasmutil.pas b/compiler/wasm32/nwasmutil.pas index 27042f4e4b..d74c5b424b 100644 --- a/compiler/wasm32/nwasmutil.pas +++ b/compiler/wasm32/nwasmutil.pas @@ -40,7 +40,7 @@ interface implementation uses - globtype, + globtype,globals, cpubase, aasmdata,aasmcpu, hlcgobj,hlcgcpu, @@ -68,6 +68,10 @@ implementation inherited; list:=current_asmdata.asmlists[al_start]; + + if ts_wasm_native_exceptions in current_settings.targetswitches then + list.Concat(tai_tagtype.create('__FPC_exception', [])); + for i:=0 to current_module.deflist.Count-1 do begin def:=tdef(current_module.deflist[i]);