Commit 51993d89 authored by Katharina Brandl's avatar Katharina Brandl
Browse files

Redesign of Memory and GlobalState interface

parent 28e80883
Pipeline #100753 passed with stages
in 72 minutes and 49 seconds
......@@ -150,14 +150,14 @@ evalNumericInst inst stack =
--type TransStack = FrameT FrameData Value (StackT Value (->))
--
evalVariableInst :: (Instruction Natural) -> [Value] -> FrameData -> Vector Value
-> GlobalState Value -> Int -> ([Value], (Vector Value, (GlobalState Value, ())))
evalVariableInst inst stack fd locals store currentMem =
-> GlobalState Value -> ([Value], (Vector Value, (GlobalState Value, ())))
evalVariableInst inst stack fd locals store =
Trans.run
(Generic.evalVariableInst ::
GlobalStateT Value
(FrameT FrameData Value
(StackT Value
(->))) (Instruction Natural) ()) (stack, (locals, (fd,(store, (currentMem,inst)))))
(->))) (Instruction Natural) ()) (stack, (locals, (fd,(store, inst))))
evalParametricInst :: (Instruction Natural) -> [Value] -> ([Value], ())
......@@ -210,7 +210,7 @@ invokeExported store modInst funcName args =
(FrameT FrameData Value
(FailureT String
(LoggerT String
(->)))))))) (Text, [Value]) [Value]) ([],(Vec.empty,((0,modInst),(store,(0,([],(Generic.LabelArities [],(funcName,args))))))))
(->)))))))) (Text, [Value]) [Value]) ([],(Vec.empty,((0,modInst),(store,([],(Generic.LabelArities [],(funcName,args)))))))
instantiate :: ValidModule -> IO (Either String (ModuleInstance, GlobalState Value))
......
......@@ -26,7 +26,7 @@ import Language.Wasm.Interpreter (ModuleInstance(..))
class ArrowGlobalState v c | c -> v where
class ArrowGlobalState v m c | c -> v, c -> m where
-- | Reads a global variable. Cannot fail due to validation.
readGlobal :: c Int v
-- | Writes a global variable. Cannot fail due to validation.
......@@ -44,11 +44,14 @@ class ArrowGlobalState v c | c -> v where
-- | Invokes `h (ta,ix,x)` if `ix` cell is uninitialized.
readTable :: c (Int,x) y -> c (Int,Int,x) y -> c (Int,Int,x) y -> c (Int,Int,x) y
fetchMemory :: c Int m
storeMemory :: c (Int, m) ()
-- | Executes a function relative to a memory instance. The memory instance exists due to validation.
withMemoryInstance :: c x y -> c (Int,x) y
-- withMemoryInstance :: c x y -> c (Int,x) y
deriving instance (ArrowGlobalState v c) => ArrowGlobalState v (ValueT v2 c)
instance (Profunctor c, Arrow c, ArrowGlobalState v c) => ArrowGlobalState v (StateT s c) where
deriving instance (ArrowGlobalState v m c) => ArrowGlobalState v m (ValueT v2 c)
instance (Profunctor c, Arrow c, ArrowGlobalState v m c) => ArrowGlobalState v m (StateT s c) where
readGlobal = lift' readGlobal
writeGlobal = lift' writeGlobal
-- readFunction :: (StateT s c) (f, x) y -> (StateT s c) (Int, x) y
......@@ -97,13 +100,13 @@ instance (Profunctor c, Arrow c, ArrowGlobalState v c) => ArrowGlobalState v (St
-- y <- func ((proc (f,(s2,x)) -> arr -< (s2, (f,x))) >>^ snd) -< (i,(s,x))
-- returnA -< (s,y)
deriving instance (Arrow c, Profunctor c, ArrowGlobalState v c) => ArrowGlobalState v (ExceptT e c)
deriving instance (Arrow c, Profunctor c, ArrowGlobalState v c) => ArrowGlobalState v (StackT s c)
instance (Monad f, Arrow c, Profunctor c, ArrowGlobalState v c) => ArrowGlobalState v (KleisliT f c) where
deriving instance (Arrow c, Profunctor c, ArrowGlobalState v m c) => ArrowGlobalState v m (ExceptT e c)
deriving instance (Arrow c, Profunctor c, ArrowGlobalState v m c) => ArrowGlobalState v m (StackT s c)
instance (Monad f, Arrow c, Profunctor c, ArrowGlobalState v m c) => ArrowGlobalState v m (KleisliT f c) where
readGlobal = lift' readGlobal
writeGlobal = lift' writeGlobal
readFunction a = lift (readFunction (unlift a))
instance (Arrow c, Profunctor c, ArrowGlobalState v c) => ArrowGlobalState v (ReaderT r c) where
instance (Arrow c, Profunctor c, ArrowGlobalState v m c) => ArrowGlobalState v m (ReaderT r c) where
readGlobal = lift' readGlobal
writeGlobal = lift' writeGlobal
-- unlift arr :: c (r, (f,x)) y
......@@ -114,7 +117,7 @@ instance (Arrow c, Profunctor c, ArrowGlobalState v c) => ArrowGlobalState v (Re
where transform f = proc (r, (i,x)) ->
readFunction (proc (f,(r,x)) -> f -< (r, (f,x))) -< (i,(r,x))
instance (Arrow c, Profunctor c, Monoid w, ArrowGlobalState v c) => ArrowGlobalState v (WriterT w c) where
instance (Arrow c, Profunctor c, Monoid w, ArrowGlobalState v m c) => ArrowGlobalState v m (WriterT w c) where
readGlobal = lift' readGlobal
writeGlobal = lift' writeGlobal
readFunction a = lift (readFunction (unlift a))
{-# LANGUAGE Arrows #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
......@@ -6,6 +7,8 @@
module Control.Arrow.Memory where
import Control.Arrow
import Control.Arrow.Transformer.Concrete.Except
import Control.Arrow.Transformer.Kleisli
import Control.Arrow.Transformer.Reader
......@@ -14,18 +17,28 @@ import Control.Arrow.Transformer.State
import Control.Arrow.Transformer.Value
import Control.Arrow.Transformer.Writer
class ArrowMemory addr bytes c | c -> addr, c -> bytes where
memread :: c (bytes, x) y -> c x y -> c (addr, Int, x) y
memstore :: c x y -> c x y -> c (addr, bytes, x) y
class ArrowMemory m addr bytes c | c -> addr, c -> bytes, c -> m where
memread :: c (bytes, x) y -> c x y -> c (m, (addr, Int, x)) (m,y)
memstore :: c x y -> c x y -> c (m, (addr, bytes, x)) (m,y)
-- getMemory :: c () m
-- putMemory :: c m ()
--
--withMemory :: (Arrow c, ArrowMemory m addr bytes c) => c x y -> c (m,x) (m,y)
--withMemory f = proc (m,x) -> do
-- putMemory -< m
-- y <- f -< x
-- newMem <- getMemory -< ()
-- returnA -< (m,y)
deriving instance (ArrowMemory addr bytes c) => ArrowMemory addr bytes (ValueT val2 c)
deriving instance (ArrowMemory addr bytes c) => ArrowMemory addr bytes (ExceptT e c)
instance (ArrowMemory addr bytes c) => ArrowMemory addr bytes (KleisliT e c) where
deriving instance (ArrowMemory m addr bytes c) => ArrowMemory m addr bytes (ValueT val2 c)
deriving instance (ArrowMemory m addr bytes c) => ArrowMemory m addr bytes (ExceptT e c)
instance (ArrowMemory m addr bytes c) => ArrowMemory m addr bytes (KleisliT e c) where
-- TODO
deriving instance (ArrowMemory addr bytes c) => ArrowMemory addr bytes (StackT e c)
instance (ArrowMemory addr bytes c) => ArrowMemory addr bytes (StateT s c) where
deriving instance (ArrowMemory m addr bytes c) => ArrowMemory m addr bytes (StackT e c)
instance (ArrowMemory m addr bytes c) => ArrowMemory m addr bytes (StateT s c) where
-- TODO
instance (ArrowMemory addr bytes c) => ArrowMemory addr bytes (ReaderT r c) where
instance (ArrowMemory m addr bytes c) => ArrowMemory m addr bytes (ReaderT r c) where
-- TODO
instance (ArrowMemory addr bytes c) => ArrowMemory addr bytes (WriterT r c) where
instance (ArrowMemory m addr bytes c) => ArrowMemory m addr bytes (WriterT r c) where
-- TODO
......@@ -78,7 +78,7 @@ newtype TableInst = TableInst Wasm.TableInstance deriving (Show,Eq)
data MemInst = MemInst (Maybe Word32) (Vector Word8) deriving (Show,Eq)
data GlobInst v = GlobInst Mut v deriving (Show, Eq)
newtype GlobalStateT v c x y = GlobalStateT (ReaderT Int (StateT (GlobalState v) c) x y)
newtype GlobalStateT v c x y = GlobalStateT (StateT (GlobalState v) c x y)
deriving (Profunctor, Category, Arrow, ArrowChoice, ArrowLift,
ArrowFail e, ArrowExcept e, ArrowConst r, ArrowStore var' val', ArrowRun, ArrowFrame fd val,
ArrowStack st, ArrowLogger l)--, ArrowState (GlobalState v))
......@@ -88,12 +88,13 @@ instance (ArrowReader r c) => ArrowReader r (GlobalStateT v c) where
local a = lift $ lmap shuffle1 (local (unlift a))
instance (ArrowState s c) => ArrowState s (GlobalStateT v c) where
-- TODO
instance ArrowTrans (GlobalStateT v) where
-- lift' :: c x y -> GlobalStateT v c x y
lift' a = GlobalStateT (lift' (lift' a))
lift' a = GlobalStateT (lift' a)
instance (ArrowChoice c, Profunctor c) => ArrowGlobalState v (GlobalStateT v c) where
instance (ArrowChoice c, Profunctor c) => ArrowGlobalState v Int (GlobalStateT v c) where
readGlobal =
GlobalStateT $ proc i -> do
GlobalState{globalInstances=vec} <- get -< ()
......@@ -116,31 +117,40 @@ instance (ArrowChoice c, Profunctor c) => ArrowGlobalState v (GlobalStateT v c)
FuncInst fTy modInst code -> funcCont -< ((fTy,modInst,code),x)
_ -> returnA -< error "not yet implemented" --hostCont -< ((fTy,code),x)
withMemoryInstance (GlobalStateT f) = GlobalStateT $ local f
--withMemoryInstance (GlobalStateT f) = GlobalStateT $ local f
instance (ArrowChoice c, Profunctor c) => ArrowMemory Word32 (Vector Word8) (GlobalStateT v c) where
memread (GlobalStateT sCont) (GlobalStateT eCont) = GlobalStateT $ proc (addr, size, x) -> do
fetchMemory = arr Prelude.id
storeMemory = arr $ const ()
instance (ArrowChoice c, Profunctor c) => ArrowMemory Int Word32 (Vector Word8) (GlobalStateT v c) where
memread (GlobalStateT sCont) (GlobalStateT eCont) = GlobalStateT $ proc (i, (addr, size, x)) -> do
GlobalState{memInstances=mems} <- get -< ()
currMem <- ask -< ()
let MemInst _ vec = mems ! currMem
--currMem <- ask -< ()
let MemInst _ vec = mems ! i
let addrI = fromIntegral addr
case (addrI+size <= length vec) of
True -> do
let content = Vec.slice addrI size vec
sCont -< (content,x)
False -> eCont -< x
memstore (GlobalStateT sCont) (GlobalStateT eCont) = GlobalStateT $ proc (addr, content, x) -> do
y <- sCont -< (content,x)
returnA -< (i,y)
False -> do
y <- eCont -< x
returnA -< (i,y)
memstore (GlobalStateT sCont) (GlobalStateT eCont) = GlobalStateT $ proc (i, (addr, content, x)) -> do
store@GlobalState{memInstances=mems} <- get -< ()
currMem <- ask -< ()
let MemInst s vec = mems ! currMem
--currMem <- ask -< ()
let MemInst s vec = mems ! i
let addrI = fromIntegral addr
let size = length content
case (addrI+size <= length vec) of
True -> do
let ind = Vec.enumFromN addrI size
put -< (store{memInstances=mems // [(currMem,MemInst s $ Vec.update_ vec ind content)]})
sCont -< x
False -> eCont -< x
put -< (store{memInstances=mems // [(i,MemInst s $ Vec.update_ vec ind content)]})
y <- sCont -< x
returnA -< (i,y)
False -> do
y <- eCont -< x
returnA -< (i,y)
instance (Arrow c, Profunctor c) => ArrowMemAddress Value Natural Word32 (GlobalStateT v c) where
memaddr = proc (Value (Wasm.VI32 base), off) -> returnA -< (base+ (fromIntegral off))
......
......@@ -33,7 +33,7 @@ import Data.Profunctor
newtype DebuggableStackT v c x y = DebuggableStackT (StackT v c x y)
deriving (Profunctor,Category,Arrow,ArrowChoice,ArrowTrans,ArrowLift,ArrowRun,
ArrowConst r, ArrowReader r, ArrowFail e, ArrowExcept e, ArrowStack v,
ArrowGlobalState v1 , ArrowFrame fd v1, ArrowMemory addr bytes,
ArrowGlobalState v1 m, ArrowFrame fd v1, ArrowMemory m addr bytes,
ArrowMemAddress v1 n addr, ArrowSerialize v1 bytes valTy loadTy storeTy,
ArrowMemSizable v1, ArrowWriter w, ArrowLogger l)
......
......@@ -32,7 +32,7 @@ import Data.Profunctor
newtype LoggerT v c x y = LoggerT (StackT v c x y)
deriving (Profunctor, Category, Arrow, ArrowChoice, ArrowTrans, ArrowLift, ArrowRun,
ArrowConst r, ArrowReader r, ArrowFail e, ArrowExcept e,
ArrowGlobalState v1, ArrowFrame fd v1, ArrowMemory addr bytes,
ArrowGlobalState v1 m, ArrowFrame fd v1, ArrowMemory m addr bytes,
ArrowMemAddress v1 n addr, ArrowSerialize v1 bytes valTy loadTy storeTy,
ArrowMemSizable v1, ArrowWriter w)
......
......@@ -53,7 +53,7 @@ newtype LabelArities = LabelArities {labels :: [Natural]}
type FrameData = (Natural, ModuleInstance)
---- constraints to support (and call) host functions
--type HostFunctionSupport addr bytes v c = (ArrowApply c, ArrowGlobalState v c, ArrowWasmMemory addr bytes v c)
--type HostFunctionSupport addr bytes v c = (ArrowApply c, ArrowGlobalState v m c, ArrowWasmMemory m addr bytes v c)
---- a host function is a function from a list of values (parameters) to a list of values (return values)
--newtype HostFunction v c = HostFunction (
-- forall addr bytes. HostFunctionSupport addr bytes v c => (c [v] [v]) )
......@@ -65,16 +65,20 @@ type FrameData = (Natural, ModuleInstance)
type ArrowWasmMemory addr bytes v c =
( ArrowMemory addr bytes c,
type ArrowWasmMemory m addr bytes v c =
( ArrowMemory m addr bytes c,
ArrowMemAddress v Natural addr c,
ArrowSerialize v bytes ValueType LoadType StoreType c,
ArrowMemSizable v c,
Show addr, Show bytes)
withMemoryInstance :: (Arrow c, ArrowGlobalState v m c) => c (m,x) (m,y) -> c (Int,x) y
withMemoryInstance f = proc (i,x) -> do
mem <- fetchMemory -< i
(newMem,y) <- f -< (mem,x)
storeMemory -< (i, newMem)
returnA -< y
......@@ -121,11 +125,11 @@ class Show v => IsVal v c | c -> v where
-- argument Text: name of the function to execute
-- argument [v]: arguments going to be passed to the function
invokeExported ::
( ArrowChoice c, ArrowFrame FrameData v c, ArrowGlobalState v c,
( ArrowChoice c, ArrowFrame FrameData v c, ArrowGlobalState v m c,
ArrowStack v c,
ArrowDebuggableStack v c,
ArrowExcept (Exc v) c, ArrowReader LabelArities c,
ArrowWasmMemory addr bytes v c, --HostFunctionSupport addr bytes v c,
ArrowWasmMemory m addr bytes v c, --HostFunctionSupport addr bytes v c,
IsVal v c, Show v,
Exc.Join () c,
Fail.Join [v] c,
......@@ -145,11 +149,11 @@ invokeExported = proc (funcName, args) -> do
_ -> fail -< printf "Function with name %s was not found in module's exports" (show funcName)
invokeExternal ::
( ArrowChoice c, ArrowFrame FrameData v c, ArrowGlobalState v c,
( ArrowChoice c, ArrowFrame FrameData v c, ArrowGlobalState v m c,
ArrowStack v c,
ArrowDebuggableStack v c,
ArrowExcept (Exc v) c, ArrowReader LabelArities c,
ArrowWasmMemory addr bytes v c, --HostFunctionSupport addr bytes v c,
ArrowWasmMemory m addr bytes v c, --HostFunctionSupport addr bytes v c,
IsVal v c, Show v,
Exc.Join () c,
Fail.Join () c,
......@@ -195,11 +199,11 @@ invokeExternal = proc (funcAddr, args) ->
eval ::
( ArrowChoice c, ArrowFrame FrameData v c, ArrowGlobalState v c,
( ArrowChoice c, ArrowFrame FrameData v c, ArrowGlobalState v m c,
ArrowStack v c,
ArrowDebuggableStack v c,
ArrowExcept (Exc v) c, ArrowReader LabelArities c,
ArrowWasmMemory addr bytes v c, --HostFunctionSupport addr bytes v c,
ArrowWasmMemory m addr bytes v c, --HostFunctionSupport addr bytes v c,
IsVal v c, Show v,
Exc.Join () c,
ArrowFix (c [Instruction Natural] ()),
......@@ -250,7 +254,7 @@ evalControlInst ::
ArrowExcept (Exc v) c,
ArrowReader LabelArities c, -- return arity of nested labels
ArrowFrame FrameData v c, -- frame data and local variables
ArrowGlobalState v c,
ArrowGlobalState v m c,
ArrowLogger String c,
--HostFunctionSupport addr bytes v c,
Exc.Join () c)
......@@ -305,7 +309,7 @@ evalControlInst eval' = proc i -> case i of
-< (tableAddr, fromIntegral ix, ftExpect)
invokeChecked ::
( ArrowChoice c, ArrowGlobalState v c, ArrowStack v c, ArrowReader LabelArities c,
( ArrowChoice c, ArrowGlobalState v m c, ArrowStack v c, ArrowReader LabelArities c,
IsVal v c, ArrowFrame FrameData v c, ArrowExcept (Exc v) c, Exc.Join () c,
ArrowDebuggableStack v c, ArrowLogger String c)
--HostFunctionSupport addr bytes v c)
......@@ -434,10 +438,10 @@ evalParametricInst = proc i -> case i of
evalMemoryInst ::
( ArrowChoice c,
ArrowWasmMemory addr bytes v c,
ArrowGlobalState v c, ArrowFrame FrameData v c, ArrowStack v c, IsVal v c, ArrowExcept (Exc v) c)
ArrowWasmMemory m addr bytes v c,
ArrowGlobalState v m c, ArrowFrame FrameData v c, ArrowStack v c, IsVal v c, ArrowExcept (Exc v) c)
=> c (Instruction Natural) ()
evalMemoryInst = withCurrentMemory $ proc i -> case i of
evalMemoryInst = proc i -> case i of --withCurrentMemory $ proc (m,i) -> case i of
I32Load (MemArg off _) -> load 4 L_I32 I32 -< off
I64Load (MemArg off _) -> load 8 L_I64 I64 -< off
F32Load (MemArg off _) -> load 4 L_F32 F32 -< off
......@@ -461,15 +465,15 @@ evalMemoryInst = withCurrentMemory $ proc i -> case i of
I64Store8 (MemArg off _) -> store S_I8 I64 -< off
I64Store16 (MemArg off _) -> store S_I16 I64 -< off
I64Store32 (MemArg off _) -> store S_I32 I64 -< off
CurrentMemory -> push <<< memsize -< ()
GrowMemory -> do
n <- pop -< ()
memgrow
(push <<^ fst)
(proc _ -> push <<< i32const -< 0xFFFFFFFF) -- 0xFFFFFFFF ~= -1
-< (n, ())
withCurrentMemory :: (ArrowChoice c, ArrowGlobalState v c, ArrowFrame FrameData v c) => c x y -> c x y
-- CurrentMemory -> push <<< memsize -< ()
-- GrowMemory -> do
-- n <- pop -< ()
-- memgrow
-- (push <<^ fst)
-- (proc _ -> push <<< i32const -< 0xFFFFFFFF) -- 0xFFFFFFFF ~= -1
-- -< (n, ())
withCurrentMemory :: (ArrowChoice c, ArrowGlobalState v m c, ArrowMemory m addr bytes c, ArrowFrame FrameData v c) => c (m,x) (m,y) -> c x y
withCurrentMemory f = proc x -> do
(_,modInst) <- frameData -< ()
let memAddr = memaddrs modInst ! 0
......@@ -477,25 +481,25 @@ withCurrentMemory f = proc x -> do
load ::
( ArrowChoice c,
ArrowWasmMemory addr bytes v c,
ArrowGlobalState v c, ArrowFrame FrameData v c, ArrowStack v c, IsVal v c, ArrowExcept (Exc v) c)
ArrowWasmMemory m addr bytes v c,
ArrowGlobalState v m c, ArrowFrame FrameData v c, ArrowStack v c, IsVal v c, ArrowExcept (Exc v) c)
=> Int -> LoadType -> ValueType -> c Natural ()
load byteSize loadType valType = proc off -> do
base <- pop -< ()
addr <- memaddr -< (base, off)
memread
withCurrentMemory (memread
(proc (bytes,_) ->
decode
(push <<^ fst)
(error "decode failure")
-< (bytes, loadType, valType, ()))
(proc addr -> throw -< Trap $ printf "Memory access out of bounds: Cannot read %d bytes at address %s in current memory" byteSize (show addr))
(proc addr -> throw -< Trap $ printf "Memory access out of bounds: Cannot read %d bytes at address %s in current memory" byteSize (show addr)))
-< (addr, byteSize, addr)
store ::
( ArrowChoice c,
ArrowWasmMemory addr bytes v c,
ArrowGlobalState v c, ArrowFrame FrameData v c, ArrowStack v c, IsVal v c, ArrowExcept (Exc v) c)
ArrowWasmMemory m addr bytes v c,
ArrowGlobalState v m c, ArrowFrame FrameData v c, ArrowStack v c, IsVal v c, ArrowExcept (Exc v) c)
=> StoreType -> ValueType -> c Natural ()
store storeType valType = proc off -> do
v <- pop -< ()
......@@ -503,15 +507,15 @@ store storeType valType = proc off -> do
(proc (bytes,off) -> do
base <- pop -< ()
addr <- memaddr -< (base, off)
memstore
withCurrentMemory (memstore
(arr $ const ())
(proc (addr,bytes) -> throw -< Trap $ printf "Memory access out of bounds: Cannot write %s at address %s in current memory" (show bytes) (show addr))
(proc (addr,bytes) -> throw -< Trap $ printf "Memory access out of bounds: Cannot write %s at address %s in current memory" (show bytes) (show addr)))
-< (addr, bytes, (addr, bytes)))
(error "encode failure")
-< (v, valType, storeType, off)
evalVariableInst ::
( ArrowChoice c, ArrowFrame FrameData v c, ArrowGlobalState v c,
( ArrowChoice c, ArrowFrame FrameData v c, ArrowGlobalState v m c,
ArrowStack v c)
=> c (Instruction Natural) ()
evalVariableInst = proc i -> case i of
......
......@@ -38,19 +38,19 @@ spec = do
let inst = GetLocal 1
let fd = (0, Wasm.emptyModInstance)
let store = emptyGlobalState
(fst $ evalVariableInst inst [] fd (fromList $ map (Value . Wasm.VI32) [5,8,7]) store 0) `shouldBe`
(fst $ evalVariableInst inst [] fd (fromList $ map (Value . Wasm.VI32) [5,8,7]) store) `shouldBe`
[Value $ Wasm.VI32 8]
it "evalVariableInst GetGlobal" $ do
let inst = GetGlobal 1
let store = emptyGlobalState{globalInstances = fromList $ map (\x -> GlobInst Mutable (Value $ Wasm.VI32 x)) [3,4,5]}
let fd = (0, Wasm.emptyModInstance{globaladdrs = fromList [0,1,2]})
(fst $ evalVariableInst inst [] fd empty store 0) `shouldBe` [Value $ Wasm.VI32 4]
(fst $ evalVariableInst inst [] fd empty store) `shouldBe` [Value $ Wasm.VI32 4]
it "evalVariabelInst SetGlobal" $ do
let inst = SetGlobal 1
let store = emptyGlobalState{globalInstances = fromList $ map (\x -> GlobInst Mutable (Value $ Wasm.VI32 x)) [3,4,5]}
let fd = (0, Wasm.emptyModInstance{globaladdrs = fromList [0,1,2]})
let stack = [Value $ Wasm.VI32 6]
(globalInstances $ fst $ snd $ snd $ evalVariableInst inst stack fd empty store 0) `shouldBe`
(globalInstances $ fst $ snd $ snd $ evalVariableInst inst stack fd empty store) `shouldBe`
(fromList $ map (\x -> GlobInst Mutable (Value $ Wasm.VI32 x)) [3,6,5])
it "evalParametricInst" $ do
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment