From 4ef13670199c291abe5407f878f5fd4b29a61959 Mon Sep 17 00:00:00 2001 From: nickysn Date: Thu, 28 Jan 2021 12:48:56 +0000 Subject: [PATCH] + added wasm32 inline procedure for generating the 'unreachable' instruction git-svn-id: branches/wasm@48442 - --- compiler/wasm32/ccpuinnr.inc | 3 ++- compiler/wasm32/nwasminl.pas | 17 +++++++++++++++++ rtl/wasm32/cpuh.inc | 1 + rtl/wasm32/cpuinnr.inc | 1 + 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/compiler/wasm32/ccpuinnr.inc b/compiler/wasm32/ccpuinnr.inc index 9342aa1c98..0cc75061b9 100644 --- a/compiler/wasm32/ccpuinnr.inc +++ b/compiler/wasm32/ccpuinnr.inc @@ -13,5 +13,6 @@ **********************************************************************} in_wasm32_memory_size = in_cpu_first, - in_wasm32_memory_grow = in_cpu_first+1 + in_wasm32_memory_grow = in_cpu_first+1, + in_wasm32_unreachable = in_cpu_first+2 diff --git a/compiler/wasm32/nwasminl.pas b/compiler/wasm32/nwasminl.pas index 63572e8a2d..b24a6d2516 100644 --- a/compiler/wasm32/nwasminl.pas +++ b/compiler/wasm32/nwasminl.pas @@ -36,6 +36,7 @@ interface private procedure second_memory_size; procedure second_memory_grow; + procedure second_unreachable; public function pass_typecheck_cpu: tnode; override; function first_cpu: tnode; override; @@ -84,6 +85,13 @@ implementation end; + procedure twasminlinenode.second_unreachable; + begin + location_reset(location,LOC_VOID,OS_NO); + current_asmdata.CurrAsmList.Concat(taicpu.op_none(a_unreachable)); + end; + + function twasminlinenode.pass_typecheck_cpu: tnode; begin Result:=nil; @@ -98,6 +106,11 @@ implementation CheckParameters(1); resultdef:=u32inttype; end; + in_wasm32_unreachable: + begin + CheckParameters(0); + resultdef:=voidtype; + end; else Result:=inherited pass_typecheck_cpu; end; @@ -111,6 +124,8 @@ implementation in_wasm32_memory_size, in_wasm32_memory_grow: expectloc:=LOC_REGISTER; + in_wasm32_unreachable: + expectloc:=LOC_VOID; else Result:=inherited first_cpu; end; @@ -124,6 +139,8 @@ implementation second_memory_size; in_wasm32_memory_grow: second_memory_grow; + in_wasm32_unreachable: + second_unreachable; else inherited pass_generate_code_cpu; end; diff --git a/rtl/wasm32/cpuh.inc b/rtl/wasm32/cpuh.inc index 0967365009..38ef7ab5c0 100644 --- a/rtl/wasm32/cpuh.inc +++ b/rtl/wasm32/cpuh.inc @@ -19,3 +19,4 @@ const function fpc_wasm32_memory_size: longword;[internproc:fpc_in_wasm32_memory_size]; function fpc_wasm32_memory_grow(n: longword): longword;[internproc:fpc_in_wasm32_memory_grow]; +procedure fpc_wasm32_unreachable;[internproc:fpc_in_wasm32_unreachable]; diff --git a/rtl/wasm32/cpuinnr.inc b/rtl/wasm32/cpuinnr.inc index c4147bc68b..4671821ca1 100644 --- a/rtl/wasm32/cpuinnr.inc +++ b/rtl/wasm32/cpuinnr.inc @@ -14,4 +14,5 @@ fpc_in_wasm32_memory_size = fpc_in_cpu_first; fpc_in_wasm32_memory_grow = fpc_in_cpu_first+1; + fpc_in_wasm32_unreachable = fpc_in_cpu_first+2;