Browse Source

+ introduced the AT_WASM_EXCEPTION_TAG asm symbol type, use that for specifying
the parameter to the 'throw' and 'catch' instructions

Nikolay Nikolov 3 years ago
parent
commit
82b6450f19

+ 4 - 1
compiler/aasmbase.pas

@@ -72,7 +72,10 @@ interface
          { GNU indirect function (ELF targets) }
          { GNU indirect function (ELF targets) }
          AT_GNU_IFUNC,
          AT_GNU_IFUNC,
          { WebAssembly global variable }
          { 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
        { is the label only there for getting an DataOffset (e.g. for i/o

+ 1 - 1
compiler/wasm32/itcpugas.pas

@@ -84,7 +84,7 @@ interface
       // additional memory
       // additional memory
       'memory.grow 0', 'memory.size 0',
       'memory.grow 0', 'memory.size 0',
       // exceptions
       // 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');
     gas_wasm_basic_type_str : array [TWasmBasicType] of string = ('i32','i64','f32','f64');

+ 1 - 1
compiler/wasm32/nwasmflw.pas

@@ -691,7 +691,7 @@ implementation
         hlcg.g_exception_reason_save_const(current_asmdata.CurrAsmList,exceptionreasontype,0,excepttemps.reasonbuf);
         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_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;
         thlcgwasm(hlcg).decblock;
         { exceptionreason:=1 (exception) }
         { exceptionreason:=1 (exception) }
         hlcg.g_exception_reason_save_const(current_asmdata.CurrAsmList,exceptionreasontype,1,excepttemps.reasonbuf);
         hlcg.g_exception_reason_save_const(current_asmdata.CurrAsmList,exceptionreasontype,1,excepttemps.reasonbuf);

+ 1 - 1
compiler/wasm32/nwasminl.pas

@@ -159,7 +159,7 @@ implementation
     procedure twasminlinenode.second_throw_fpcexception;
     procedure twasminlinenode.second_throw_fpcexception;
       begin
       begin
         location_reset(location,LOC_VOID,OS_NO);
         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;
       end;