Browse Source

+ added target switch ts_wasm_native_exnref_exceptions for the future implementation of WebAssembly 'exceptions with exnref' support

Nikolay Nikolov 1 day ago
parent
commit
adc93a26d5
4 changed files with 14 additions and 4 deletions
  1. 4 0
      compiler/fppu.pas
  2. 6 2
      compiler/globtype.pas
  3. 2 1
      compiler/options.pas
  4. 2 1
      compiler/utils/ppuutils/ppudump.pp

+ 4 - 0
compiler/fppu.pas

@@ -394,6 +394,8 @@ var
               (ts_wasm_no_exceptions in current_settings.targetswitches)) or
              ((mf_wasm_bf_exceptions in moduleflags) <>
               (ts_wasm_bf_exceptions in current_settings.targetswitches)) or
+             ((mf_wasm_exnref_exceptions in moduleflags) <>
+              (ts_wasm_native_exnref_exceptions in current_settings.targetswitches)) or
              ((mf_wasm_native_exceptions in moduleflags) <>
               (ts_wasm_native_legacy_exceptions in current_settings.targetswitches)) then
             begin
@@ -1119,6 +1121,8 @@ var
 {$ifdef wasm}
         if ts_wasm_no_exceptions in current_settings.targetswitches then
           include(moduleflags,mf_wasm_no_exceptions);
+        if ts_wasm_native_exnref_exceptions in current_settings.targetswitches then
+          include(moduleflags,mf_wasm_exnref_exceptions);
         if ts_wasm_native_legacy_exceptions in current_settings.targetswitches then
           include(moduleflags,mf_wasm_native_exceptions);
         if ts_wasm_bf_exceptions in current_settings.targetswitches then

+ 6 - 2
compiler/globtype.pas

@@ -327,6 +327,9 @@ interface
          ts_wasm_no_exceptions,
          { Branchful exceptions support. A global threadvar is checked after each function call. }
          ts_wasm_bf_exceptions,
+         { WebAssembly exnref exceptions support:
+           https://github.com/WebAssembly/exception-handling/blob/master/proposals/exception-handling/Exceptions.md }
+         ts_wasm_native_exnref_exceptions,
          { WebAssembly legacy exceptions support:
            https://github.com/WebAssembly/exception-handling/blob/master/proposals/exception-handling/legacy/Exceptions.md }
          ts_wasm_native_legacy_exceptions,
@@ -424,8 +427,8 @@ interface
          mf_symansistr,               { symbols are ansistrings (for ppudump) }
          mf_wasm_no_exceptions,       { unit was compiled in WebAssembly 'no exceptions' mode }
          mf_wasm_bf_exceptions,       { unit was compiled in WebAssembly 'branchful' exceptions mode }
-         mf_wasm_js_exceptions,       { unit was compiled in WebAssembly JavaScript-based exceptions mode }
-         mf_wasm_native_exceptions,   { unit was compiled in WebAssembly native exceptions mode }
+         mf_wasm_exnref_exceptions,   { unit was compiled in WebAssembly exceptions with exnref mode }
+         mf_wasm_native_exceptions,   { unit was compiled in WebAssembly native legacy exceptions mode }
          mf_wasm_threads,             { unit was compiled with WebAssembly multithreading support turned on }
          mf_system_unit               { unit was compiled as a System unit }
        );
@@ -473,6 +476,7 @@ interface
          (name: 'FARPROCSPUSHODDBP';   hasvalue: false; isglobal: false; define: 'FPC_FAR_PROCS_PUSH_ODD_BP'),
          (name: 'NOEXCEPTIONS';        hasvalue: false; isglobal: true ; define: 'FPC_WASM_NO_EXCEPTIONS'),
          (name: 'BFEXCEPTIONS';        hasvalue: false; isglobal: true ; define: 'FPC_WASM_BRANCHFUL_EXCEPTIONS'),
+         (name: 'EXNREFEXCEPTIONS';    hasvalue: false; isglobal: true ; define: 'FPC_WASM_EXNREF_EXCEPTIONS'),
          (name: 'WASMEXCEPTIONS';      hasvalue: false; isglobal: true ; define: 'FPC_WASM_NATIVE_EXCEPTIONS'),
          (name: 'WASMTHREADS';         hasvalue: false; isglobal: true ; define: 'FPC_WASM_THREADS'),
          (name: 'SATURATINGFLOATTOINT';hasvalue: false; isglobal: false; define: 'FPC_WASM_SATURATING_FLOAT_TO_INT')

+ 2 - 1
compiler/options.pas

@@ -2239,6 +2239,7 @@ procedure TOption.CheckOptionsCompatibility;
 begin
 {$ifdef wasm}
   if (Ord(ts_wasm_no_exceptions in init_settings.targetswitches)+
+      Ord(ts_wasm_native_exnref_exceptions in init_settings.targetswitches)+
       Ord(ts_wasm_native_legacy_exceptions in init_settings.targetswitches)+
       Ord(ts_wasm_bf_exceptions in init_settings.targetswitches))>1 then
     begin
@@ -5663,7 +5664,7 @@ begin
 {$endif m68k}
 {$ifdef wasm}
   { if no explicit exception handling mode is set for WebAssembly, assume no exceptions }
-  if init_settings.targetswitches*[ts_wasm_no_exceptions,ts_wasm_native_legacy_exceptions,ts_wasm_bf_exceptions]=[] then
+  if init_settings.targetswitches*[ts_wasm_no_exceptions,ts_wasm_native_exnref_exceptions,ts_wasm_native_legacy_exceptions,ts_wasm_bf_exceptions]=[] then
     begin
       def_system_macro(TargetSwitchStr[ts_wasm_no_exceptions].define);
       include(init_settings.targetswitches,ts_wasm_no_exceptions);

+ 2 - 1
compiler/utils/ppuutils/ppudump.pp

@@ -2288,7 +2288,8 @@ const
         'Use odd BP for far procs', {ts_x86_far_procs_push_odd_bp}
         'No exception support', {ts_wasm_no_exceptions}
         'Branchful exceptions support', {ts_wasm_bf_exceptions}
-        'Native WebAssembly exceptions support', {ts_wasm_native_exceptions}
+        'Native WebAssembly exceptions with exnref support', {ts_wasm_native_exnref_exceptions}
+        'Native WebAssembly legacy exceptions support', {ts_wasm_native_legacy_exceptions}
         'WebAssembly threads support', {ts_wasm_threads}
         'Use WebAssembly saturating (nontrapping) float to int conversion instructions' {ts_wasm_saturating_float_to_int}
        );