Browse Source

- WebAssembly code generator: removed the g_fingerprint hack, that added 4
useless i64 constants on the stack with random numbers and then drop them. It
was used for primitive debugging, since previously it wasn't possible to
identify the function name. Now we can produce DWARF debug info, as well as a
"names" custom section to give each function a name and most WebAssembly
environments support at least one of the two mechanisms. Therefore the
g_fingerprint hack is no longer necessary.

Nikolay Nikolov 10 months ago
parent
commit
29ee863e8f
1 changed files with 0 additions and 28 deletions
  1. 0 28
      compiler/wasm32/hlcgcpu.pas

+ 0 - 28
compiler/wasm32/hlcgcpu.pas

@@ -220,19 +220,6 @@ uses
         slots used for parameters and the provided resultdef }
         slots used for parameters and the provided resultdef }
       procedure g_adjust_stack_after_call(list: TAsmList; pd: tabstractprocdef);
       procedure g_adjust_stack_after_call(list: TAsmList; pd: tabstractprocdef);
 
 
-      { because WebAssembly has no spec for any sort of debug info, and the
-        only linker that we support (LLVM's wasm-ld) does not support creating
-        map files in its stable version, and crashes when attempting to create
-        a map file in its development version from git, we have no way to
-        identify which procedure a crash occurred in. So, to identify the
-        procedure, we call this procedure on proc entry, which generates a few
-        useless loads of random numbers on the stack, that are immediately
-        discarded, so they are essentially equivalent to a nop. This allows
-        finding the procedure in the FPC output assembly, produced with -al by
-        searching for these random numbers, as taken from the disassembly of the
-        final binary. }
-      procedure g_fingerprint(list: TAsmList);
-
       property maxevalstackheight: longint read fmaxevalstackheight;
       property maxevalstackheight: longint read fmaxevalstackheight;
 
 
      protected
      protected
@@ -2073,8 +2060,6 @@ implementation
           if pd.base_pointer_ref.base<>NR_LOCAL_STACK_POINTER_REG then
           if pd.base_pointer_ref.base<>NR_LOCAL_STACK_POINTER_REG then
             ttgwasm(tg).allocbasepointer(list,pd.base_pointer_ref);
             ttgwasm(tg).allocbasepointer(list,pd.base_pointer_ref);
 
 
-          g_fingerprint(list);
-
           list.Concat(taicpu.op_sym(a_global_get,RefStackPointerSym));
           list.Concat(taicpu.op_sym(a_global_get,RefStackPointerSym));
           incstack(list,1);
           incstack(list,1);
           list.Concat(taicpu.op_ref(a_local_set,pd.base_pointer_ref));
           list.Concat(taicpu.op_ref(a_local_set,pd.base_pointer_ref));
@@ -2819,19 +2804,6 @@ implementation
     end;
     end;
 
 
 
 
-  procedure thlcgwasm.g_fingerprint(list: TAsmList);
-    begin
-      list.concat(taicpu.op_const(a_i64_const,Random(high(int64))));
-      list.concat(taicpu.op_const(a_i64_const,Random(high(int64))));
-      list.concat(taicpu.op_const(a_i64_const,Random(high(int64))));
-      list.concat(taicpu.op_const(a_i64_const,Random(high(int64))));
-      list.concat(taicpu.op_none(a_drop));
-      list.concat(taicpu.op_none(a_drop));
-      list.concat(taicpu.op_none(a_drop));
-      list.concat(taicpu.op_none(a_drop));
-    end;
-
-
   procedure thlcgwasm.resizestackfpuval(list: TAsmList; fromsize, tosize: tcgsize);
   procedure thlcgwasm.resizestackfpuval(list: TAsmList; fromsize, tosize: tcgsize);
     begin
     begin
       if (fromsize=OS_F32) and
       if (fromsize=OS_F32) and