+ add "fingerprints" in the beginning of each routine for easier debugging (this

will be disabled later, and only enabled with -g or some other target flag,
  but for now, it's always on)

git-svn-id: branches/wasm@48272 -
This commit is contained in:
nickysn 2021-01-21 16:34:39 +00:00
parent 43f9dedb00
commit 72abf6f472

View File

@ -201,6 +201,19 @@ uses
slots used for parameters and the provided resultdef }
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;
protected
@ -1510,6 +1523,8 @@ implementation
list.Concat(tai_local.create(wbt_i32,FRAME_POINTER_SYM)); //TWasmBasicType
list.Concat(tai_local.create(wbt_i32,BASE_POINTER_SYM)); //TWasmBasicType
g_fingerprint(list);
list.Concat(taicpu.op_sym(a_get_global,current_asmdata.RefAsmSymbol(STACK_POINTER_SYM,AT_LABEL)));
incstack(list,1);
list.Concat(taicpu.op_ref(a_set_local,pd.base_pointer_ref));
@ -1951,6 +1966,19 @@ implementation
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);
begin
if (fromsize=OS_F32) and