+ introduced the AT_WASM_EXCEPTION_TAG asm symbol type, use that for specifying

the parameter to the 'throw' and 'catch' instructions
This commit is contained in:
Nikolay Nikolov 2021-09-27 17:49:30 +03:00
parent e0ad427b6c
commit 82b6450f19
4 changed files with 7 additions and 4 deletions

View File

@ -72,7 +72,10 @@ interface
{ GNU indirect function (ELF targets) }
AT_GNU_IFUNC,
{ WebAssembly global variable }
AT_WASM_GLOBAL
AT_WASM_GLOBAL,
{ WebAssembly exception tag (used as a parameter for the 'throw' and
'catch' instructions) }
AT_WASM_EXCEPTION_TAG
);
{ is the label only there for getting an DataOffset (e.g. for i/o

View File

@ -84,7 +84,7 @@ interface
// additional memory
'memory.grow 0', 'memory.size 0',
// exceptions
'try','catch __FPC_exception','catch_all','delegate','throw __FPC_exception','rethrow','end_try'
'try','catch','catch_all','delegate','throw','rethrow','end_try'
);
gas_wasm_basic_type_str : array [TWasmBasicType] of string = ('i32','i64','f32','f64');

View File

@ -691,7 +691,7 @@ implementation
hlcg.g_exception_reason_save_const(current_asmdata.CurrAsmList,exceptionreasontype,0,excepttemps.reasonbuf);
current_asmdata.CurrAsmList.concat(taicpu.op_const(a_br,4)); // jump to the 'finally' section
current_asmdata.CurrAsmList.concat(taicpu.op_none(a_catch));
current_asmdata.CurrAsmList.concat(taicpu.op_sym(a_catch,current_asmdata.RefAsmSymbol(FPC_EXCEPTION_TAG_SYM,AT_WASM_EXCEPTION_TAG)));
thlcgwasm(hlcg).decblock;
{ exceptionreason:=1 (exception) }
hlcg.g_exception_reason_save_const(current_asmdata.CurrAsmList,exceptionreasontype,1,excepttemps.reasonbuf);

View File

@ -159,7 +159,7 @@ implementation
procedure twasminlinenode.second_throw_fpcexception;
begin
location_reset(location,LOC_VOID,OS_NO);
current_asmdata.CurrAsmList.Concat(taicpu.op_none(a_throw));
current_asmdata.CurrAsmList.Concat(taicpu.op_sym(a_throw,current_asmdata.RefAsmSymbol(FPC_EXCEPTION_TAG_SYM,AT_WASM_EXCEPTION_TAG)));
end;