mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-11 16:06:09 +02:00
+ implemented support for the local.get, local.set and local.tee instructions in TWasmValidationStacks.Validate
This commit is contained in:
parent
3a5db26abf
commit
e073d5f7f7
@ -89,14 +89,17 @@ uses
|
|||||||
|
|
||||||
taicpu = class;
|
taicpu = class;
|
||||||
|
|
||||||
|
TGetLocalTypeProc = function(localidx: Integer): TWasmBasicType of object;
|
||||||
|
|
||||||
{ TWasmValidationStacks }
|
{ TWasmValidationStacks }
|
||||||
|
|
||||||
TWasmValidationStacks = class
|
TWasmValidationStacks = class
|
||||||
private
|
private
|
||||||
FValueStack: TWasmValueStack;
|
FValueStack: TWasmValueStack;
|
||||||
FCtrlStack: TWasmControlStack;
|
FCtrlStack: TWasmControlStack;
|
||||||
|
FGetLocalType: TGetLocalTypeProc;
|
||||||
public
|
public
|
||||||
constructor Create;
|
constructor Create(AGetLocalType: TGetLocalTypeProc);
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
|
|
||||||
procedure PushVal(vt: TWasmBasicType);
|
procedure PushVal(vt: TWasmBasicType);
|
||||||
@ -475,8 +478,9 @@ uses
|
|||||||
|
|
||||||
{ TWasmValidationStacks }
|
{ TWasmValidationStacks }
|
||||||
|
|
||||||
constructor TWasmValidationStacks.Create;
|
constructor TWasmValidationStacks.Create(AGetLocalType: TGetLocalTypeProc);
|
||||||
begin
|
begin
|
||||||
|
FGetLocalType:=AGetLocalType;
|
||||||
FValueStack:=TWasmValueStack.Create;
|
FValueStack:=TWasmValueStack.Create;
|
||||||
FCtrlStack:=TWasmControlStack.Create;
|
FCtrlStack:=TWasmControlStack.Create;
|
||||||
end;
|
end;
|
||||||
@ -585,6 +589,32 @@ uses
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TWasmValidationStacks.Validate(a: taicpu);
|
procedure TWasmValidationStacks.Validate(a: taicpu);
|
||||||
|
|
||||||
|
function GetLocalIndex: Integer;
|
||||||
|
begin
|
||||||
|
Result:=-1;
|
||||||
|
with a do
|
||||||
|
begin
|
||||||
|
if ops<>1 then
|
||||||
|
internalerror(2024020801);
|
||||||
|
with oper[0]^ do
|
||||||
|
case typ of
|
||||||
|
top_ref:
|
||||||
|
begin
|
||||||
|
if assigned(ref^.symbol) then
|
||||||
|
internalerror(2024020802);
|
||||||
|
if ref^.base<>NR_STACK_POINTER_REG then
|
||||||
|
internalerror(2024020803);
|
||||||
|
if ref^.index<>NR_NO then
|
||||||
|
internalerror(2024020804);
|
||||||
|
Result:=ref^.offset;
|
||||||
|
end;
|
||||||
|
top_const:
|
||||||
|
Result:=val;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
case a.opcode of
|
case a.opcode of
|
||||||
a_nop:
|
a_nop:
|
||||||
@ -932,6 +962,15 @@ uses
|
|||||||
PopVal(wbt_i32);
|
PopVal(wbt_i32);
|
||||||
PopVal(wbt_i32);
|
PopVal(wbt_i32);
|
||||||
end;
|
end;
|
||||||
|
a_local_get:
|
||||||
|
PushVal(FGetLocalType(GetLocalIndex));
|
||||||
|
a_local_set:
|
||||||
|
PopVal(FGetLocalType(GetLocalIndex));
|
||||||
|
a_local_tee:
|
||||||
|
begin
|
||||||
|
PopVal(FGetLocalType(GetLocalIndex));
|
||||||
|
PushVal(FGetLocalType(GetLocalIndex));
|
||||||
|
end;
|
||||||
else
|
else
|
||||||
internalerror(2024030502);
|
internalerror(2024030502);
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user