瀏覽代碼

- don't generate any WebAssembly native exception handling instructions, nor
relocations, when compiling in branchful exceptions mode. This produces a
currently not working, but accepted by wasmtime binary (otherwise, it
complains it doesn't support exceptions and refuses to try to run it).

Nikolay Nikolov 3 年之前
父節點
當前提交
6599f1d898
共有 2 個文件被更改,包括 23 次插入24 次删除
  1. 22 22
      compiler/wasm32/nwasmflw.pas
  2. 1 2
      compiler/wasm32/nwasmutil.pas

+ 22 - 22
compiler/wasm32/nwasmflw.pas

@@ -575,8 +575,8 @@ implementation
         //flowcontrol:=[fc_inflowcontrol,fc_catching_exceptions];
         cexceptionstatehandler.new_exception(current_asmdata.CurrAsmList,excepttemps,tek_except,trystate);
 
-        current_asmdata.CurrAsmList.concat(taicpu.op_none(a_try));
-        thlcgwasm(hlcg).incblock;
+        //current_asmdata.CurrAsmList.concat(taicpu.op_none(a_try));
+        //thlcgwasm(hlcg).incblock;
 
         { try block }
         secondpass(left);
@@ -587,7 +587,7 @@ implementation
         //flowcontrol:=exceptionstate.oldflowcontrol;
         cexceptionstatehandler.end_try_block(current_asmdata.CurrAsmList,tek_except,excepttemps,trystate,nil);
 
-        current_asmdata.CurrAsmList.concat(taicpu.op_sym(a_catch,current_asmdata.WeakRefAsmSymbol(FPC_EXCEPTION_TAG_SYM,AT_WASM_EXCEPTION_TAG)));
+        //current_asmdata.CurrAsmList.concat(taicpu.op_sym(a_catch,current_asmdata.WeakRefAsmSymbol(FPC_EXCEPTION_TAG_SYM,AT_WASM_EXCEPTION_TAG)));
 
         flowcontrol:=[fc_inflowcontrol]+trystate.oldflowcontrol*[fc_catching_exceptions];
         { on statements }
@@ -626,19 +626,19 @@ implementation
                   flowcontrol+
                   afteronflowcontrol;
 
-                current_asmdata.CurrAsmList.concat(taicpu.op_none(a_try));
-                thlcgwasm(hlcg).incblock;
+                //current_asmdata.CurrAsmList.concat(taicpu.op_none(a_try));
+                //thlcgwasm(hlcg).incblock;
 
                 secondpass(t1);
 
                 hlcg.g_call_system_proc(current_asmdata.CurrAsmList,'fpc_doneexception',[],nil).resetiftemp;
 
-                current_asmdata.CurrAsmList.concat(taicpu.op_sym(a_catch,current_asmdata.WeakRefAsmSymbol(FPC_EXCEPTION_TAG_SYM,AT_WASM_EXCEPTION_TAG)));
+                //current_asmdata.CurrAsmList.concat(taicpu.op_sym(a_catch,current_asmdata.WeakRefAsmSymbol(FPC_EXCEPTION_TAG_SYM,AT_WASM_EXCEPTION_TAG)));
 
                 hlcg.g_call_system_proc(current_asmdata.CurrAsmList,'fpc_raise_nested',[],nil).resetiftemp;
 
-                current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_try));
-                thlcgwasm(hlcg).decblock;
+                //current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_try));
+                //thlcgwasm(hlcg).decblock;
               end
             else
               begin
@@ -648,12 +648,12 @@ implementation
           end
         else
           begin
-            current_asmdata.CurrAsmList.concat(taicpu.op_const(a_rethrow,0));
+            //current_asmdata.CurrAsmList.concat(taicpu.op_const(a_rethrow,0));
             doobjectdestroyandreraisestate.newflowcontrol:=afteronflowcontrol;
           end;
 
-        current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_try));
-        thlcgwasm(hlcg).decblock;
+        //current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_try));
+        //thlcgwasm(hlcg).decblock;
 
       errorexit:
         { return all used control flow statements }
@@ -1118,7 +1118,7 @@ implementation
           current_asmdata.CurrAsmList.concat(taicpu.op_none(a_if));
           thlcgwasm(hlcg).incblock;
           thlcgwasm(hlcg).decstack(current_asmdata.CurrAsmList,1);
-          current_asmdata.CurrAsmList.Concat(taicpu.op_sym(a_throw,current_asmdata.WeakRefAsmSymbol(FPC_EXCEPTION_TAG_SYM,AT_WASM_EXCEPTION_TAG)));
+          //current_asmdata.CurrAsmList.Concat(taicpu.op_sym(a_throw,current_asmdata.WeakRefAsmSymbol(FPC_EXCEPTION_TAG_SYM,AT_WASM_EXCEPTION_TAG)));
           current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_if));
           thlcgwasm(hlcg).decblock;
         end;
@@ -1190,8 +1190,8 @@ implementation
           end;
 
         { the inner 'try..end_try' block }
-        current_asmdata.CurrAsmList.concat(taicpu.op_none(a_try));
-        thlcgwasm(hlcg).incblock;
+        //current_asmdata.CurrAsmList.concat(taicpu.op_none(a_try));
+        //thlcgwasm(hlcg).incblock;
 
         { try code }
         if assigned(left) then
@@ -1210,14 +1210,14 @@ 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_sym(a_catch,current_asmdata.WeakRefAsmSymbol(FPC_EXCEPTION_TAG_SYM,AT_WASM_EXCEPTION_TAG)));
+        //current_asmdata.CurrAsmList.concat(taicpu.op_sym(a_catch,current_asmdata.WeakRefAsmSymbol(FPC_EXCEPTION_TAG_SYM,AT_WASM_EXCEPTION_TAG)));
         { exceptionreason:=1 (exception) }
         hlcg.g_exception_reason_save_const(current_asmdata.CurrAsmList,exceptionreasontype,1,excepttemps.reasonbuf);
         current_asmdata.CurrAsmList.concat(taicpu.op_const(a_br,4)); // jump to the 'finally' section
 
         { exit the inner 'try..end_try' block }
-        current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_try));
-        thlcgwasm(hlcg).decblock;
+        //current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_try));
+        //thlcgwasm(hlcg).decblock;
 
         { exit the 'continue' block }
         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_block));
@@ -1399,8 +1399,8 @@ implementation
         { in the case that another exception is risen
           we've to destroy the old one, so create a new
           exception frame for the catch-handler }
-        current_asmdata.CurrAsmList.concat(taicpu.op_none(a_try));
-        thlcgwasm(hlcg).incblock;
+        //current_asmdata.CurrAsmList.concat(taicpu.op_none(a_try));
+        //thlcgwasm(hlcg).incblock;
 
         if assigned(right) then
           secondpass(right);
@@ -1408,12 +1408,12 @@ implementation
         hlcg.g_call_system_proc(current_asmdata.CurrAsmList,'fpc_doneexception',[],nil).resetiftemp;
         current_asmdata.CurrAsmList.concat(taicpu.op_const(a_br,2));
 
-        current_asmdata.CurrAsmList.concat(taicpu.op_sym(a_catch,current_asmdata.WeakRefAsmSymbol(FPC_EXCEPTION_TAG_SYM,AT_WASM_EXCEPTION_TAG)));
+        //current_asmdata.CurrAsmList.concat(taicpu.op_sym(a_catch,current_asmdata.WeakRefAsmSymbol(FPC_EXCEPTION_TAG_SYM,AT_WASM_EXCEPTION_TAG)));
 
         hlcg.g_call_system_proc(current_asmdata.CurrAsmList,'fpc_raise_nested',[],nil).resetiftemp;
 
-        current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_try));
-        thlcgwasm(hlcg).decblock;
+        //current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_try));
+        //thlcgwasm(hlcg).decblock;
 
         { clear some stuff }
         if assigned(exceptvarsym) then

+ 1 - 2
compiler/wasm32/nwasmutil.pas

@@ -71,8 +71,7 @@ implementation
 
       list.Concat(tai_globaltype.create(STACK_POINTER_SYM,wbt_i32,false));
 
-      if (ts_wasm_native_exceptions in current_settings.targetswitches) or
-         (ts_wasm_bf_exceptions in current_settings.targetswitches) then
+      if ts_wasm_native_exceptions in current_settings.targetswitches then
         begin
           list.Concat(tai_tagtype.create(FPC_EXCEPTION_TAG_SYM, []));
           list.Concat(tai_symbol.Create_Weak(current_asmdata.WeakRefAsmSymbol(FPC_EXCEPTION_TAG_SYM,AT_WASM_EXCEPTION_TAG),0));