From 64b2d8ef85776a03a4a2afcbeec459983d171948 Mon Sep 17 00:00:00 2001 From: nickysn Date: Sat, 24 Oct 2020 17:28:43 +0000 Subject: [PATCH] * wasm base and index reference access fixes git-svn-id: branches/wasm@47177 - --- compiler/wasm32/agllvmmc.pas | 2 +- compiler/wasm32/hlcgcpu.pas | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/compiler/wasm32/agllvmmc.pas b/compiler/wasm32/agllvmmc.pas index f2dbefd683..626d385089 100644 --- a/compiler/wasm32/agllvmmc.pas +++ b/compiler/wasm32/agllvmmc.pas @@ -197,7 +197,7 @@ implementation begin // local symbol -> stack slot, stored in offset result:=''; - if ref.base<>NR_STACK_POINTER_REG then + if (ref.base<>NR_STACK_POINTER_REG) and (ref.base<>NR_NO) then result:=std_regname(ref.base); if ref.index<>NR_NO then if result<>'' then diff --git a/compiler/wasm32/hlcgcpu.pas b/compiler/wasm32/hlcgcpu.pas index 892b054154..c3f1ab4f2b 100644 --- a/compiler/wasm32/hlcgcpu.pas +++ b/compiler/wasm32/hlcgcpu.pas @@ -1044,14 +1044,16 @@ implementation if (ref.base=NR_EVAL_STACK_BASE) or (ref.islocal) then exit; - // setting up memory offset if assigned(ref.symbol) then + begin + Writeln(ref.symbol.name, ' ', std_Regname(ref.base), ' ', std_regname(ref.index)); + end; + // setting up memory offset + if assigned(ref.symbol) and (ref.base=NR_NO) and (ref.index=NR_NO) then begin list.Concat(taicpu.op_const(a_i32_const,0)); incstack(list,1); result:=1; - if (ref.base<>NR_NO) or (ref.index<>NR_NO) then - internalerror(2020102401); end else if ref.index <> NR_NO then // array access begin @@ -1059,6 +1061,10 @@ implementation list.Concat(taicpu.op_reg(a_get_local, ref.base)); list.Concat(taicpu.op_reg(a_get_local, ref.index)); list.Concat(taicpu.op_none(a_i32_add)); + ref.base:=NR_NO; + ref.index:=NR_NO; + incstack(list,1); + result:=1; end else if (ref.base<>NR_NO) then begin @@ -1075,6 +1081,7 @@ implementation end; { field name/type encoded in symbol, no index/offset } result:=1; + ref.base:=NR_NO; end else // if (ref.base = NR_FRAME_POINTER_REG) then begin