forked from GitHub/haskell-wasm
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7d199ddc03 | ||
|
|
f8bec75b25 |
@@ -1,12 +1,3 @@
|
|||||||
.stack-work
|
.stack-work
|
||||||
tests/runnable/*
|
tests/runnable/*
|
||||||
dist/
|
dist/
|
||||||
.DS_Store
|
|
||||||
build/
|
|
||||||
cabal-config-flags
|
|
||||||
dist-newstyle/
|
|
||||||
doc/
|
|
||||||
setup-config
|
|
||||||
wasm-*-docs.tar.gz
|
|
||||||
cache
|
|
||||||
packagedb
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
[submodule "tests/spec"]
|
|
||||||
path = tests/spec
|
|
||||||
url = https://github.com/WebAssembly/testsuite
|
|
||||||
@@ -20,10 +20,9 @@
|
|||||||
* [ ] Text Representation pretty-printer
|
* [ ] Text Representation pretty-printer
|
||||||
* [ ] Command line tool for calling interpreter/compiler/validator
|
* [ ] Command line tool for calling interpreter/compiler/validator
|
||||||
* [ ] Codegen interface for type enforced generating valid WASM code
|
* [ ] Codegen interface for type enforced generating valid WASM code
|
||||||
* [ ] Support for building if, loop, block
|
|
||||||
|
|
||||||
## Development
|
## Development
|
||||||
Clone sources to directory and use `stack` for running tests:
|
Clond sources to directory and use `stack` for running tests:
|
||||||
```
|
```
|
||||||
stack build && stack test
|
stack && stack test
|
||||||
```
|
```
|
||||||
|
|||||||
+7
-2
@@ -5,7 +5,9 @@ import qualified Data.ByteString.Lazy as LBS
|
|||||||
import qualified Data.ByteString.Base64.Lazy as Base64
|
import qualified Data.ByteString.Base64.Lazy as Base64
|
||||||
import Data.Maybe (fromMaybe)
|
import Data.Maybe (fromMaybe)
|
||||||
|
|
||||||
import qualified Language.Wasm as Wasm
|
import qualified Language.Wasm.Lexer as Lexer
|
||||||
|
import qualified Language.Wasm.Parser as Parser
|
||||||
|
import qualified Language.Wasm.Binary as Binary
|
||||||
|
|
||||||
import Options.Applicative
|
import Options.Applicative
|
||||||
import Data.Semigroup ((<>))
|
import Data.Semigroup ((<>))
|
||||||
@@ -103,7 +105,10 @@ config = subparser (
|
|||||||
)
|
)
|
||||||
|
|
||||||
toBinary :: LBS.ByteString -> Either String LBS.ByteString
|
toBinary :: LBS.ByteString -> Either String LBS.ByteString
|
||||||
toBinary = fmap Wasm.encodeLazy . Wasm.parse
|
toBinary content = do
|
||||||
|
lexemes <- Lexer.scanner content
|
||||||
|
mod <- Parser.parseModule lexemes
|
||||||
|
return $ Binary.dumpModuleLazy mod
|
||||||
|
|
||||||
compileAs :: (LBS.ByteString -> LBS.ByteString) -> String -> String -> IO ()
|
compileAs :: (LBS.ByteString -> LBS.ByteString) -> String -> String -> IO ()
|
||||||
compileAs transform input output = do
|
compileAs transform input output = do
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
name: wasm
|
||||||
|
version: '0.1.0'
|
||||||
|
author: Ilya Rezvov
|
||||||
|
maintainer: rezvov.ilya@gmail.com
|
||||||
|
license: MIT
|
||||||
|
extra-source-files:
|
||||||
|
- README.md
|
||||||
|
- src/Language/Wasm/Parser.y
|
||||||
|
- src/Language/Wasm/Lexer.x
|
||||||
|
build-tools:
|
||||||
|
- alex >=3.1.3
|
||||||
|
- happy >=1.9.4
|
||||||
|
dependencies:
|
||||||
|
- base >=4.6 && <5.0
|
||||||
|
|
||||||
|
library:
|
||||||
|
source-dirs: src
|
||||||
|
ghc-options:
|
||||||
|
- -Wwarn
|
||||||
|
- -fwarn-incomplete-patterns
|
||||||
|
- -fwarn-unused-imports
|
||||||
|
exposed-modules:
|
||||||
|
- Language.Wasm.Lexer
|
||||||
|
- Language.Wasm
|
||||||
|
dependencies:
|
||||||
|
- array >= 0.5 && <0.6
|
||||||
|
- text >= 1.1
|
||||||
|
- bytestring >= 0.10
|
||||||
|
- mtl >= 2.2 && <3.0
|
||||||
|
- transformers >= 0.4 && <0.6
|
||||||
|
- containers >= 0.5 && <0.6
|
||||||
|
- utf8-string >= 1.0
|
||||||
|
|
||||||
|
tests:
|
||||||
|
test:
|
||||||
|
main: Test.hs
|
||||||
|
source-dirs: tests
|
||||||
|
dependencies:
|
||||||
|
- wasm == 0.1.0
|
||||||
|
- filepath >=1.3 && <1.5
|
||||||
|
- directory >= 1.3
|
||||||
|
- text >=1.1 && <1.3
|
||||||
|
- bytestring >=0.10 && <0.11
|
||||||
|
- mtl ==2.2.1
|
||||||
|
- tasty >=0.7
|
||||||
|
- tasty-hunit >=0.4.1 && <0.10
|
||||||
+3
-52
@@ -1,55 +1,6 @@
|
|||||||
module Language.Wasm (
|
module Language.Wasm (
|
||||||
Module,
|
something
|
||||||
ValidModule,
|
|
||||||
ValidationError(..),
|
|
||||||
parse,
|
|
||||||
validate,
|
|
||||||
Language.Wasm.parseScript,
|
|
||||||
encode,
|
|
||||||
encodeLazy,
|
|
||||||
decode,
|
|
||||||
decodeLazy,
|
|
||||||
Script,
|
|
||||||
Command(..),
|
|
||||||
ModuleDef(..),
|
|
||||||
Action(..),
|
|
||||||
Assertion(..),
|
|
||||||
Ident(..),
|
|
||||||
Meta(..),
|
|
||||||
runScript,
|
|
||||||
Valid.getModule
|
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import qualified Data.ByteString as BS
|
something :: Int
|
||||||
import qualified Data.ByteString.Lazy as LBS
|
something = 42
|
||||||
|
|
||||||
import Language.Wasm.Structure as Struct
|
|
||||||
import Language.Wasm.Script as Script
|
|
||||||
import Language.Wasm.Lexer as Lexer
|
|
||||||
import Language.Wasm.Parser as Parser
|
|
||||||
import Language.Wasm.Validate as Valid
|
|
||||||
import Language.Wasm.Binary as Binary
|
|
||||||
|
|
||||||
-- | Parse WebAssembly text representation to `Module`
|
|
||||||
parse :: LBS.ByteString -> Either String Module
|
|
||||||
parse content = Lexer.scanner content >>= Parser.parseModule
|
|
||||||
|
|
||||||
-- | Parse WebAssembly extended script grammar
|
|
||||||
parseScript :: LBS.ByteString -> Either String Script
|
|
||||||
parseScript content = Lexer.scanner content >>= Parser.parseScript
|
|
||||||
|
|
||||||
-- | Dump `Module` to binary representation
|
|
||||||
encode :: Module -> BS.ByteString
|
|
||||||
encode = dumpModule
|
|
||||||
|
|
||||||
-- | Dump `Module` to binary representation lazily
|
|
||||||
encodeLazy :: Module -> LBS.ByteString
|
|
||||||
encodeLazy = dumpModuleLazy
|
|
||||||
|
|
||||||
-- | Decode `Module` from binary representation
|
|
||||||
decode :: BS.ByteString -> Either String Module
|
|
||||||
decode = decodeModule
|
|
||||||
|
|
||||||
-- | Decode `Module` from binary representation lazily
|
|
||||||
decodeLazy :: LBS.ByteString -> Either String Module
|
|
||||||
decodeLazy = decodeModuleLazy
|
|
||||||
|
|||||||
+32
-225
@@ -130,10 +130,7 @@ getSection sectionType parser def = do
|
|||||||
where
|
where
|
||||||
parseSection op
|
parseSection op
|
||||||
| op == 0 = skipCustomSection >> getSection sectionType parser def
|
| op == 0 = skipCustomSection >> getSection sectionType parser def
|
||||||
| op == fromEnum sectionType = do
|
| op == fromEnum sectionType = getWord8 >> (getULEB128 32 :: Get Natural) >> parser
|
||||||
getWord8
|
|
||||||
len <- getULEB128 32
|
|
||||||
isolate len parser
|
|
||||||
| op > fromEnum DataSection = fail "invalid section id"
|
| op > fromEnum DataSection = fail "invalid section id"
|
||||||
| op > fromEnum sectionType = return def
|
| op > fromEnum sectionType = return def
|
||||||
| otherwise =
|
| otherwise =
|
||||||
@@ -157,7 +154,7 @@ getName = do
|
|||||||
putResultType :: ResultType -> Put
|
putResultType :: ResultType -> Put
|
||||||
putResultType [] = putWord8 0x40
|
putResultType [] = putWord8 0x40
|
||||||
putResultType [valType] = put valType
|
putResultType [valType] = put valType
|
||||||
putResultType _ = error "Current WebAssembly spec does not support returning more then one value"
|
putResultType _ = fail "Current WebAssembly spec does not support returning more then one value"
|
||||||
|
|
||||||
getResultType :: Get ResultType
|
getResultType :: Get ResultType
|
||||||
getResultType = do
|
getResultType = do
|
||||||
@@ -170,29 +167,6 @@ getResultType = do
|
|||||||
0x7C -> return [F64]
|
0x7C -> return [F64]
|
||||||
_ -> fail "unexpected byte in result type position"
|
_ -> fail "unexpected byte in result type position"
|
||||||
|
|
||||||
putBlockType :: BlockType -> Put
|
|
||||||
putBlockType (Inline Nothing) = putWord8 0x40
|
|
||||||
putBlockType (Inline (Just valType)) = put valType
|
|
||||||
putBlockType (TypeIndex idx) = putSLEB128 idx
|
|
||||||
|
|
||||||
getInlineBlockType :: Get (Maybe (Maybe ValueType))
|
|
||||||
getInlineBlockType = do
|
|
||||||
op <- getWord8
|
|
||||||
case op of
|
|
||||||
0x40 -> return $ Just Nothing
|
|
||||||
0x7F -> return $ Just (Just I32)
|
|
||||||
0x7E -> return $ Just (Just I64)
|
|
||||||
0x7D -> return $ Just (Just F32)
|
|
||||||
0x7C -> return $ Just (Just F64)
|
|
||||||
_ -> return Nothing
|
|
||||||
|
|
||||||
getBlockType :: Get BlockType
|
|
||||||
getBlockType = do
|
|
||||||
inlineType <- lookAheadM getInlineBlockType
|
|
||||||
case inlineType of
|
|
||||||
Just inline -> return $ Inline inline
|
|
||||||
Nothing -> TypeIndex <$> getSLEB128 33
|
|
||||||
|
|
||||||
data SectionType =
|
data SectionType =
|
||||||
CustomSection
|
CustomSection
|
||||||
| TypeSection
|
| TypeSection
|
||||||
@@ -243,14 +217,8 @@ instance Serialize FuncType where
|
|||||||
return $ FuncType { params, results }
|
return $ FuncType { params, results }
|
||||||
|
|
||||||
instance Serialize ElemType where
|
instance Serialize ElemType where
|
||||||
put FuncRef = putWord8 0x70
|
put AnyFunc = putWord8 0x70
|
||||||
put ExternRef = putWord8 0x6F
|
get = byteGuard 0x70 >> return AnyFunc
|
||||||
get = do
|
|
||||||
op <- getWord8
|
|
||||||
case op of
|
|
||||||
0x70 -> return FuncRef
|
|
||||||
0x69 -> return ExternRef
|
|
||||||
_ -> fail "unknown reference type"
|
|
||||||
|
|
||||||
instance Serialize Limit where
|
instance Serialize Limit where
|
||||||
put (Limit min Nothing) = putWord8 0x00 >> putULEB128 min
|
put (Limit min Nothing) = putWord8 0x00 >> putULEB128 min
|
||||||
@@ -326,12 +294,6 @@ instance Serialize Index where
|
|||||||
put (Index idx) = putULEB128 idx
|
put (Index idx) = putULEB128 idx
|
||||||
get = Index <$> getULEB128 32
|
get = Index <$> getULEB128 32
|
||||||
|
|
||||||
newtype Expr = Expr { unExpr :: Expression } deriving (Show, Eq)
|
|
||||||
|
|
||||||
instance Serialize Expr where
|
|
||||||
put (Expr expr) = putExpression expr
|
|
||||||
get = Expr <$> getExpression
|
|
||||||
|
|
||||||
instance Serialize MemArg where
|
instance Serialize MemArg where
|
||||||
put MemArg { align, offset } = putULEB128 align >> putULEB128 offset
|
put MemArg { align, offset } = putULEB128 align >> putULEB128 offset
|
||||||
get = do
|
get = do
|
||||||
@@ -342,21 +304,21 @@ instance Serialize MemArg where
|
|||||||
instance Serialize (Instruction Natural) where
|
instance Serialize (Instruction Natural) where
|
||||||
put Unreachable = putWord8 0x00
|
put Unreachable = putWord8 0x00
|
||||||
put Nop = putWord8 0x01
|
put Nop = putWord8 0x01
|
||||||
put (Block blockType body) = do
|
put (Block result body) = do
|
||||||
putWord8 0x02
|
putWord8 0x02
|
||||||
putBlockType blockType
|
putResultType result
|
||||||
putExpression body
|
putExpression body
|
||||||
put (Loop blockType body) = do
|
put (Loop result body) = do
|
||||||
putWord8 0x03
|
putWord8 0x03
|
||||||
putBlockType blockType
|
putResultType result
|
||||||
putExpression body
|
putExpression body
|
||||||
put If {blockType, true, false = []} = do
|
put If {resultType, true, false = []} = do
|
||||||
putWord8 0x04
|
putWord8 0x04
|
||||||
putBlockType blockType
|
putResultType resultType
|
||||||
putExpression true
|
putExpression true
|
||||||
put If {blockType, true, false} = do
|
put If {resultType, true, false} = do
|
||||||
putWord8 0x04
|
putWord8 0x04
|
||||||
putBlockType blockType
|
putResultType resultType
|
||||||
mapM_ put true
|
mapM_ put true
|
||||||
putWord8 0x05 -- ELSE
|
putWord8 0x05 -- ELSE
|
||||||
putExpression false
|
putExpression false
|
||||||
@@ -365,50 +327,16 @@ instance Serialize (Instruction Natural) where
|
|||||||
put (BrTable labels label) = putWord8 0x0E >> putVec (map Index labels) >> putULEB128 label
|
put (BrTable labels label) = putWord8 0x0E >> putVec (map Index labels) >> putULEB128 label
|
||||||
put Return = putWord8 0x0F
|
put Return = putWord8 0x0F
|
||||||
put (Call funcIdx) = putWord8 0x10 >> putULEB128 funcIdx
|
put (Call funcIdx) = putWord8 0x10 >> putULEB128 funcIdx
|
||||||
put (CallIndirect tableIdx typeIdx) = putWord8 0x11 >> putULEB128 typeIdx >> putULEB128 tableIdx
|
put (CallIndirect typeIdx) = putWord8 0x11 >> putULEB128 typeIdx >> putWord8 0x00
|
||||||
-- Reference instructions
|
|
||||||
put (RefNull refType) = putWord8 0xD0 >> put refType
|
|
||||||
put RefIsNull = putWord8 0xD1
|
|
||||||
put (RefFunc index) = putWord8 0xD2 >> putULEB128 index
|
|
||||||
-- Parametric instructions
|
-- Parametric instructions
|
||||||
put Drop = putWord8 0x1A
|
put Drop = putWord8 0x1A
|
||||||
put (Select Nothing) = putWord8 0x1B
|
put Select = putWord8 0x1B
|
||||||
put (Select (Just types)) = putWord8 0x1C >> putVec types
|
|
||||||
-- Variable instructions
|
-- Variable instructions
|
||||||
put (GetLocal idx) = putWord8 0x20 >> putULEB128 idx
|
put (GetLocal idx) = putWord8 0x20 >> putULEB128 idx
|
||||||
put (SetLocal idx) = putWord8 0x21 >> putULEB128 idx
|
put (SetLocal idx) = putWord8 0x21 >> putULEB128 idx
|
||||||
put (TeeLocal idx) = putWord8 0x22 >> putULEB128 idx
|
put (TeeLocal idx) = putWord8 0x22 >> putULEB128 idx
|
||||||
put (GetGlobal idx) = putWord8 0x23 >> putULEB128 idx
|
put (GetGlobal idx) = putWord8 0x23 >> putULEB128 idx
|
||||||
put (SetGlobal idx) = putWord8 0x24 >> putULEB128 idx
|
put (SetGlobal idx) = putWord8 0x24 >> putULEB128 idx
|
||||||
-- Table instructions
|
|
||||||
put (TableGet idx) = putWord8 0x25 >> putULEB128 idx
|
|
||||||
put (TableSet idx) = putWord8 0x26 >> putULEB128 idx
|
|
||||||
put (TableInit tableIdx elemIdx) = do
|
|
||||||
putWord8 0xFC
|
|
||||||
putULEB128 (0x0C :: Word32)
|
|
||||||
putULEB128 tableIdx
|
|
||||||
putULEB128 elemIdx
|
|
||||||
put (ElemDrop elemIdx) = do
|
|
||||||
putWord8 0xFC
|
|
||||||
putULEB128 (0x0D :: Word32)
|
|
||||||
putULEB128 elemIdx
|
|
||||||
put (TableCopy fromIdx toIdx) = do
|
|
||||||
putWord8 0xFC
|
|
||||||
putULEB128 (0x0E :: Word32)
|
|
||||||
putULEB128 fromIdx
|
|
||||||
putULEB128 toIdx
|
|
||||||
put (TableGrow tableIdx) = do
|
|
||||||
putWord8 0xFC
|
|
||||||
putULEB128 (0x0F :: Word32)
|
|
||||||
putULEB128 tableIdx
|
|
||||||
put (TableSize tableIdx) = do
|
|
||||||
putWord8 0xFC
|
|
||||||
putULEB128 (0x10 :: Word32)
|
|
||||||
putULEB128 tableIdx
|
|
||||||
put (TableFill tableIdx) = do
|
|
||||||
putWord8 0xFC
|
|
||||||
putULEB128 (0x11 :: Word32)
|
|
||||||
putULEB128 tableIdx
|
|
||||||
-- Memory instructions
|
-- Memory instructions
|
||||||
put (I32Load memArg) = putWord8 0x28 >> put memArg
|
put (I32Load memArg) = putWord8 0x28 >> put memArg
|
||||||
put (I64Load memArg) = putWord8 0x29 >> put memArg
|
put (I64Load memArg) = putWord8 0x29 >> put memArg
|
||||||
@@ -433,26 +361,8 @@ instance Serialize (Instruction Natural) where
|
|||||||
put (I64Store8 memArg) = putWord8 0x3C >> put memArg
|
put (I64Store8 memArg) = putWord8 0x3C >> put memArg
|
||||||
put (I64Store16 memArg) = putWord8 0x3D >> put memArg
|
put (I64Store16 memArg) = putWord8 0x3D >> put memArg
|
||||||
put (I64Store32 memArg) = putWord8 0x3E >> put memArg
|
put (I64Store32 memArg) = putWord8 0x3E >> put memArg
|
||||||
put MemorySize = putWord8 0x3F >> putWord8 0x00
|
put CurrentMemory = putWord8 0x3F >> putWord8 0x00
|
||||||
put MemoryGrow = putWord8 0x40 >> putWord8 0x00
|
put GrowMemory = putWord8 0x40 >> putWord8 0x00
|
||||||
put (MemoryInit dataIdx) = do
|
|
||||||
putWord8 0xFC
|
|
||||||
putULEB128 (0x08 :: Word32)
|
|
||||||
putULEB128 dataIdx
|
|
||||||
putWord8 0
|
|
||||||
put (DataDrop dataIdx) = do
|
|
||||||
putWord8 0xFC
|
|
||||||
putULEB128 (0x09 :: Word32)
|
|
||||||
putULEB128 dataIdx
|
|
||||||
put MemoryCopy = do
|
|
||||||
putWord8 0xFC
|
|
||||||
putULEB128 (0x0A :: Word32)
|
|
||||||
putWord8 0
|
|
||||||
putWord8 0
|
|
||||||
put MemoryFill = do
|
|
||||||
putWord8 0xFC
|
|
||||||
putULEB128 (0x0B :: Word32)
|
|
||||||
putWord8 0
|
|
||||||
-- Numeric instructions
|
-- Numeric instructions
|
||||||
put (I32Const val) = putWord8 0x41 >> putSLEB128 (asInt32 val)
|
put (I32Const val) = putWord8 0x41 >> putSLEB128 (asInt32 val)
|
||||||
put (I64Const val) = putWord8 0x42 >> putSLEB128 (asInt64 val)
|
put (I64Const val) = putWord8 0x42 >> putSLEB128 (asInt64 val)
|
||||||
@@ -582,34 +492,18 @@ instance Serialize (Instruction Natural) where
|
|||||||
put (FReinterpretI BS32) = putWord8 0xBE
|
put (FReinterpretI BS32) = putWord8 0xBE
|
||||||
put (FReinterpretI BS64) = putWord8 0xBF
|
put (FReinterpretI BS64) = putWord8 0xBF
|
||||||
|
|
||||||
put (IUnOp BS32 IExtend8S) = putWord8 0xC0
|
|
||||||
put (IUnOp BS32 IExtend16S) = putWord8 0xC1
|
|
||||||
put (IUnOp BS32 IExtend32S) = error "Opcode for i32.extend32_s doesn't exist"
|
|
||||||
put (IUnOp BS64 IExtend8S) = putWord8 0xC2
|
|
||||||
put (IUnOp BS64 IExtend16S) = putWord8 0xC3
|
|
||||||
put (IUnOp BS64 IExtend32S) = putWord8 0xC4
|
|
||||||
|
|
||||||
put (ITruncSatFS BS32 BS32) = putWord8 0xFC >> putULEB128 (0x00 :: Word32)
|
|
||||||
put (ITruncSatFU BS32 BS32) = putWord8 0xFC >> putULEB128 (0x01 :: Word32)
|
|
||||||
put (ITruncSatFS BS32 BS64) = putWord8 0xFC >> putULEB128 (0x02 :: Word32)
|
|
||||||
put (ITruncSatFU BS32 BS64) = putWord8 0xFC >> putULEB128 (0x03 :: Word32)
|
|
||||||
put (ITruncSatFS BS64 BS32) = putWord8 0xFC >> putULEB128 (0x04 :: Word32)
|
|
||||||
put (ITruncSatFU BS64 BS32) = putWord8 0xFC >> putULEB128 (0x05 :: Word32)
|
|
||||||
put (ITruncSatFS BS64 BS64) = putWord8 0xFC >> putULEB128 (0x06 :: Word32)
|
|
||||||
put (ITruncSatFU BS64 BS64) = putWord8 0xFC >> putULEB128 (0x07 :: Word32)
|
|
||||||
|
|
||||||
get = do
|
get = do
|
||||||
op <- getWord8
|
op <- getWord8
|
||||||
case op of
|
case op of
|
||||||
0x00 -> return Unreachable
|
0x00 -> return Unreachable
|
||||||
0x01 -> return Nop
|
0x01 -> return Nop
|
||||||
0x02 -> Block <$> getBlockType <*> getExpression
|
0x02 -> Block <$> getResultType <*> getExpression
|
||||||
0x03 -> Loop <$> getBlockType <*> getExpression
|
0x03 -> Loop <$> getResultType <*> getExpression
|
||||||
0x04 -> do
|
0x04 -> do
|
||||||
blockType <- getBlockType
|
resultType <- getResultType
|
||||||
(true, hasElse) <- getTrueBranch
|
(true, hasElse) <- getTrueBranch
|
||||||
false <- if hasElse then getExpression else return []
|
false <- if hasElse then getExpression else return []
|
||||||
return $ If blockType true false
|
return $ If resultType true false
|
||||||
0x0C -> Br <$> getULEB128 32
|
0x0C -> Br <$> getULEB128 32
|
||||||
0x0D -> BrIf <$> getULEB128 32
|
0x0D -> BrIf <$> getULEB128 32
|
||||||
0x0E -> BrTable <$> (map unIndex <$> getVec) <*> getULEB128 32
|
0x0E -> BrTable <$> (map unIndex <$> getVec) <*> getULEB128 32
|
||||||
@@ -617,15 +511,11 @@ instance Serialize (Instruction Natural) where
|
|||||||
0x10 -> Call <$> getULEB128 32
|
0x10 -> Call <$> getULEB128 32
|
||||||
0x11 -> do
|
0x11 -> do
|
||||||
typeIdx <- getULEB128 32
|
typeIdx <- getULEB128 32
|
||||||
tableIdx <- getULEB128 32
|
byteGuard 0x00
|
||||||
return $ CallIndirect tableIdx typeIdx
|
return $ CallIndirect typeIdx
|
||||||
-- Reference instructions
|
|
||||||
0xD0 -> RefNull <$> get
|
|
||||||
0xD1 -> return RefIsNull
|
|
||||||
0xD2 -> RefFunc <$> getULEB128 32
|
|
||||||
-- Parametric instructions
|
-- Parametric instructions
|
||||||
0x1A -> return $ Drop
|
0x1A -> return $ Drop
|
||||||
0x1B -> return $ Select Nothing
|
0x1B -> return $ Select
|
||||||
-- Variable instructions
|
-- Variable instructions
|
||||||
0x20 -> GetLocal <$> getULEB128 32
|
0x20 -> GetLocal <$> getULEB128 32
|
||||||
0x21 -> SetLocal <$> getULEB128 32
|
0x21 -> SetLocal <$> getULEB128 32
|
||||||
@@ -656,8 +546,8 @@ instance Serialize (Instruction Natural) where
|
|||||||
0x3C -> I64Store8 <$> get
|
0x3C -> I64Store8 <$> get
|
||||||
0x3D -> I64Store16 <$> get
|
0x3D -> I64Store16 <$> get
|
||||||
0x3E -> I64Store32 <$> get
|
0x3E -> I64Store32 <$> get
|
||||||
0x3F -> byteGuard 0x00 >> (return $ MemorySize)
|
0x3F -> byteGuard 0x00 >> (return $ CurrentMemory)
|
||||||
0x40 -> byteGuard 0x00 >> (return $ MemoryGrow)
|
0x40 -> byteGuard 0x00 >> (return $ GrowMemory)
|
||||||
-- Numeric instructions
|
-- Numeric instructions
|
||||||
0x41 -> I32Const <$> getSLEB128 32
|
0x41 -> I32Const <$> getSLEB128 32
|
||||||
0x42 -> I64Const <$> getSLEB128 64
|
0x42 -> I64Const <$> getSLEB128 64
|
||||||
@@ -786,24 +676,7 @@ instance Serialize (Instruction Natural) where
|
|||||||
0xBD -> return $ IReinterpretF BS64
|
0xBD -> return $ IReinterpretF BS64
|
||||||
0xBE -> return $ FReinterpretI BS32
|
0xBE -> return $ FReinterpretI BS32
|
||||||
0xBF -> return $ FReinterpretI BS64
|
0xBF -> return $ FReinterpretI BS64
|
||||||
0xC0 -> return $ IUnOp BS32 IExtend8S
|
_ -> fail "Unknown byte value in place of instruction opcode"
|
||||||
0xC1 -> return $ IUnOp BS32 IExtend16S
|
|
||||||
0xC2 -> return $ IUnOp BS64 IExtend8S
|
|
||||||
0xC3 -> return $ IUnOp BS64 IExtend16S
|
|
||||||
0xC4 -> return $ IUnOp BS64 IExtend32S
|
|
||||||
0xFC -> do -- misc
|
|
||||||
ext <- getULEB128 32
|
|
||||||
case (ext :: Word32) of
|
|
||||||
0x00 -> return $ ITruncSatFS BS32 BS32
|
|
||||||
0x01 -> return $ ITruncSatFU BS32 BS32
|
|
||||||
0x02 -> return $ ITruncSatFS BS32 BS64
|
|
||||||
0x03 -> return $ ITruncSatFU BS32 BS64
|
|
||||||
0x04 -> return $ ITruncSatFS BS64 BS32
|
|
||||||
0x05 -> return $ ITruncSatFU BS64 BS32
|
|
||||||
0x06 -> return $ ITruncSatFS BS64 BS64
|
|
||||||
0x07 -> return $ ITruncSatFU BS64 BS64
|
|
||||||
_ -> fail "Unknown byte value after misc instruction byte"
|
|
||||||
byte -> fail $ "Unknown byte value in place of instruction opcode: " ++ (show byte)
|
|
||||||
|
|
||||||
putExpression :: Expression -> Put
|
putExpression :: Expression -> Put
|
||||||
putExpression expr = do
|
putExpression expr = do
|
||||||
@@ -861,56 +734,11 @@ instance Serialize Export where
|
|||||||
get = Export <$> getName <*> get
|
get = Export <$> getName <*> get
|
||||||
|
|
||||||
instance Serialize ElemSegment where
|
instance Serialize ElemSegment where
|
||||||
put (ElemSegment elemType Passive elements) = do
|
put (ElemSegment tableIndex offset funcIndexes) = do
|
||||||
putWord8 0x05
|
|
||||||
put elemType
|
|
||||||
putVec $ map Expr elements
|
|
||||||
put (ElemSegment elemType (Active tableIndex offset) elements) = do
|
|
||||||
putWord8 0x06
|
|
||||||
putULEB128 tableIndex
|
putULEB128 tableIndex
|
||||||
putExpression offset
|
putExpression offset
|
||||||
put elemType
|
putVec $ map Index funcIndexes
|
||||||
putVec $ map Expr elements
|
get = ElemSegment <$> getULEB128 32 <*> getExpression <*> (map unIndex <$> getVec)
|
||||||
put (ElemSegment elemType Declarative elements) = do
|
|
||||||
putWord8 0x07
|
|
||||||
put elemType
|
|
||||||
putVec $ map Expr elements
|
|
||||||
|
|
||||||
get = do
|
|
||||||
op <- getWord8
|
|
||||||
let funcIndexes = map ((:[]) . RefFunc . unIndex) <$> getVec
|
|
||||||
let elemKind = byteGuard 0x00 >> return FuncRef
|
|
||||||
case op of
|
|
||||||
0x00 -> do
|
|
||||||
offset <- getExpression
|
|
||||||
ElemSegment FuncRef (Active 0 offset) <$> funcIndexes
|
|
||||||
0x01 -> do
|
|
||||||
elemType <- elemKind
|
|
||||||
ElemSegment elemType Passive <$> funcIndexes
|
|
||||||
0x02 -> do
|
|
||||||
tableIndex <- getULEB128 32
|
|
||||||
offset <- getExpression
|
|
||||||
elemType <- elemKind
|
|
||||||
ElemSegment elemType (Active tableIndex offset) <$> funcIndexes
|
|
||||||
0x03 -> do
|
|
||||||
elemType <- elemKind
|
|
||||||
ElemSegment elemType Declarative <$> funcIndexes
|
|
||||||
0x04 -> do
|
|
||||||
offset <- getExpression
|
|
||||||
ElemSegment FuncRef (Active 0 offset) <$> funcIndexes
|
|
||||||
0x05 -> do
|
|
||||||
elemType <- get
|
|
||||||
ElemSegment elemType Passive . map unExpr <$> getVec
|
|
||||||
0x06 -> do
|
|
||||||
tableIndex <- getULEB128 32
|
|
||||||
offset <- getExpression
|
|
||||||
elemType <- get
|
|
||||||
ElemSegment elemType (Active tableIndex offset) <$> getVec
|
|
||||||
0x07 -> do
|
|
||||||
elemType <- get
|
|
||||||
ElemSegment elemType Declarative <$> getVec
|
|
||||||
_ ->
|
|
||||||
fail "unknown element segment type"
|
|
||||||
|
|
||||||
data LocalTypeRange = LocalTypeRange Natural ValueType deriving (Show, Eq)
|
data LocalTypeRange = LocalTypeRange Natural ValueType deriving (Show, Eq)
|
||||||
|
|
||||||
@@ -929,43 +757,22 @@ instance Serialize Function where
|
|||||||
putByteString bs
|
putByteString bs
|
||||||
get = do
|
get = do
|
||||||
_size <- getULEB128 32 :: Get Natural
|
_size <- getULEB128 32 :: Get Natural
|
||||||
localRanges <- getVec
|
locals <- concat . map (\(LocalTypeRange n val) -> replicate (fromIntegral n) val) <$> getVec
|
||||||
let localLen = sum $ map (\(LocalTypeRange n _) -> n) localRanges
|
|
||||||
if localLen < 2^32 then return () else fail "too many locals"
|
|
||||||
let locals = concat $ map (\(LocalTypeRange n val) -> replicate (fromIntegral n) val) localRanges
|
|
||||||
body <- getExpression
|
body <- getExpression
|
||||||
return $ Function 0 locals body
|
return $ Function 0 locals body
|
||||||
|
|
||||||
instance Serialize DataSegment where
|
instance Serialize DataSegment where
|
||||||
put (DataSegment (ActiveData memIdx offset) init) = do
|
put (DataSegment memIdx offset init) = do
|
||||||
putWord8 0x02
|
|
||||||
putULEB128 memIdx
|
putULEB128 memIdx
|
||||||
putExpression offset
|
putExpression offset
|
||||||
putULEB128 $ LBS.length init
|
putULEB128 $ LBS.length init
|
||||||
putLazyByteString init
|
putLazyByteString init
|
||||||
put (DataSegment PassiveData init) = do
|
|
||||||
putWord8 0x01
|
|
||||||
putULEB128 $ LBS.length init
|
|
||||||
putLazyByteString init
|
|
||||||
get = do
|
get = do
|
||||||
op <- getULEB128 32
|
|
||||||
case (op :: Word8) of
|
|
||||||
0x00 -> do
|
|
||||||
offset <- getExpression
|
|
||||||
len <- getULEB128 32
|
|
||||||
init <- getLazyByteString len
|
|
||||||
return $ DataSegment (ActiveData 0 offset) init
|
|
||||||
0x01 -> do
|
|
||||||
len <- getULEB128 32
|
|
||||||
init <- getLazyByteString len
|
|
||||||
return $ DataSegment PassiveData init
|
|
||||||
0x02 -> do
|
|
||||||
memIdx <- getULEB128 32
|
memIdx <- getULEB128 32
|
||||||
offset <- getExpression
|
offset <- getExpression
|
||||||
len <- getULEB128 32
|
len <- getULEB128 32
|
||||||
init <- getLazyByteString len
|
init <- getLazyByteString len
|
||||||
return $ DataSegment (ActiveData memIdx offset) init
|
return $ DataSegment memIdx offset init
|
||||||
byte -> fail $ "unknown data segment type: " ++ show byte
|
|
||||||
|
|
||||||
instance Serialize Module where
|
instance Serialize Module where
|
||||||
put mod = do
|
put mod = do
|
||||||
|
|||||||
+318
-457
File diff suppressed because it is too large
Load Diff
+148
-506
File diff suppressed because it is too large
Load Diff
+36
-94
@@ -5,27 +5,23 @@ module Language.Wasm.Lexer (
|
|||||||
Lexeme(..),
|
Lexeme(..),
|
||||||
Token(..),
|
Token(..),
|
||||||
AlexPosn(..),
|
AlexPosn(..),
|
||||||
FloatRep(..),
|
|
||||||
NaN(..),
|
|
||||||
scanner,
|
scanner,
|
||||||
asFloat,
|
asFloat,
|
||||||
asDouble,
|
asDouble
|
||||||
doubleFromInteger
|
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import qualified Data.ByteString.Lazy as LBS
|
import qualified Data.ByteString.Lazy as LBS
|
||||||
import qualified Data.Char as Char
|
import qualified Data.Char as Char
|
||||||
import qualified Data.ByteString.Lazy.UTF8 as LBSUtf8
|
import qualified Data.ByteString.Lazy.UTF8 as LBSUtf8
|
||||||
|
import Control.Applicative ((<$>))
|
||||||
import Control.Monad (when)
|
import Control.Monad (when)
|
||||||
import Numeric.IEEE (infinity, nan, nanWithPayload)
|
import Numeric.IEEE (infinity, nan)
|
||||||
import Language.Wasm.FloatUtils (makeNaN, doubleToFloat, wordToFloat, wordToDouble)
|
import Language.Wasm.FloatUtils (makeNaN, doubleToFloat)
|
||||||
import Data.Word (Word8, Word64)
|
import Data.Word (Word8)
|
||||||
import Data.List (isPrefixOf)
|
import Data.List (isPrefixOf)
|
||||||
import Text.Read (readEither)
|
import Text.Read (readEither)
|
||||||
import Data.Bits
|
|
||||||
import Numeric (showHex)
|
import qualified Debug.Trace as Debug
|
||||||
import Control.DeepSeq (NFData)
|
|
||||||
import GHC.Generics (Generic)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,8 +65,6 @@ tokens :-
|
|||||||
<0> "nan" { constToken $ TFloatLit $ BinRep (abs nan) }
|
<0> "nan" { constToken $ TFloatLit $ BinRep (abs nan) }
|
||||||
<0> "+nan" { constToken $ TFloatLit $ BinRep (abs nan) }
|
<0> "+nan" { constToken $ TFloatLit $ BinRep (abs nan) }
|
||||||
<0> "-nan" { constToken $ TFloatLit $ BinRep nan }
|
<0> "-nan" { constToken $ TFloatLit $ BinRep nan }
|
||||||
<0> "nan:canonical" { constToken $ TFloatLit $ NanRep Canonical }
|
|
||||||
<0> "nan:arithmetic" { constToken $ TFloatLit $ NanRep Arithmetic }
|
|
||||||
<0> $sign? @nanhex { parseNanSigned }
|
<0> $sign? @nanhex { parseNanSigned }
|
||||||
<0> "inf" { constToken $ TFloatLit $ BinRep inf }
|
<0> "inf" { constToken $ TFloatLit $ BinRep inf }
|
||||||
<0> "+inf" { constToken $ TFloatLit $ BinRep inf }
|
<0> "+inf" { constToken $ TFloatLit $ BinRep inf }
|
||||||
@@ -138,13 +132,9 @@ parseHexalSignedInt = token $ \(pos, _, s, _) len ->
|
|||||||
|
|
||||||
parseNanSigned :: AlexAction Lexeme
|
parseNanSigned :: AlexAction Lexeme
|
||||||
parseNanSigned = token $ \(pos, _, s, _) len ->
|
parseNanSigned = token $ \(pos, _, s, _) len ->
|
||||||
let (sign, slen) = case LBSUtf8.decode s of
|
let (sign, slen) = parseSign s in
|
||||||
Just ('-', _) -> (False, 1)
|
|
||||||
Just ('+', _) -> (True, 1)
|
|
||||||
otherwise -> (True, 0)
|
|
||||||
in
|
|
||||||
let num = readHexFromPrefix (len - 6 - slen) $ LBSUtf8.drop (6 + slen) s in
|
let num = readHexFromPrefix (len - 6 - slen) $ LBSUtf8.drop (6 + slen) s in
|
||||||
Lexeme (Just pos) $ TFloatLit $ NanRep $ NanHex sign $ fromIntegral num
|
Lexeme (Just pos) $ TFloatLit $ BinRep $ sign $ makeNaN $ fromIntegral num
|
||||||
|
|
||||||
parseDecimalSignedInt :: AlexAction Lexeme
|
parseDecimalSignedInt :: AlexAction Lexeme
|
||||||
parseDecimalSignedInt = token $ \(pos, _, s, _) len ->
|
parseDecimalSignedInt = token $ \(pos, _, s, _) len ->
|
||||||
@@ -196,85 +186,44 @@ parseHexFloat :: AlexAction Lexeme
|
|||||||
parseHexFloat = token $ \(pos, _, s, _) len ->
|
parseHexFloat = token $ \(pos, _, s, _) len ->
|
||||||
Lexeme (Just pos) $ TFloatLit $ HexRep $ filter (/= '_') $ takeChars len s
|
Lexeme (Just pos) $ TFloatLit $ HexRep $ filter (/= '_') $ takeChars len s
|
||||||
|
|
||||||
readHexFloat :: (Integral w, Bits w) => (w -> f) -> Int -> Int -> Int -> String -> Either String f
|
readHexFloat :: Int -> String -> String -> Either String Double
|
||||||
readHexFloat toFloat sz expLimit manitisaSize str = do
|
readHexFloat expLimit restrictedPrefix str =
|
||||||
let (sign, '0':'x':rest) = case str of
|
let (sign, '0':'x':rest) = case str of
|
||||||
('+':rest) -> (0, rest)
|
('+':rest) -> (abs, rest)
|
||||||
('-':rest) -> (1 `shiftL` (sz - 1), rest)
|
('-':rest) -> (negate, rest)
|
||||||
rest -> (0, rest)
|
rest -> (abs, rest)
|
||||||
let (val, expStr) = splitBy (\c -> c == 'P' || c == 'p') rest
|
in
|
||||||
let (intRaw, fracRaw) = splitBy (== '.') val
|
let (val, exp) = splitBy (\c -> c == 'P' || c == 'p') rest in
|
||||||
let int = dropWhile (== '0') intRaw
|
let (int, frac) = splitBy (== '.') val in
|
||||||
let fracWithZeros = int ++ (reverse $ dropWhile (== '0') $ reverse fracRaw)
|
let intLen = length int in
|
||||||
let frac = dropWhile (== '0') fracWithZeros
|
let expInt = expAsInt exp in
|
||||||
let exp = expAsInt expStr + length int * 4 - (length $ takeWhile (== '0') fracWithZeros) * 4
|
if int == "1" && ((restrictedPrefix `isPrefixOf` frac && expInt == expLimit - 1) || expInt >= expLimit)
|
||||||
if length frac == 0
|
then Left $ "constant out of range"
|
||||||
then return $ toFloat sign
|
else
|
||||||
else do
|
let intVal = sum $ zipWith (\i c -> readHexFromChar c * (16 ^ (intLen - i))) [1..] int in
|
||||||
let fracBits = reverse $ dropWhile (== False) $ reverse $ toBits frac
|
Right $ sign $ (intVal + readHexFrac frac) * readHexExp exp
|
||||||
let exp' = exp - (length $ takeWhile (== False) fracBits) - 1
|
|
||||||
let bits = dropWhile (== False) fracBits
|
|
||||||
let budget = min (manitisaSize + 1) $ (expLimit + manitisaSize) + exp'
|
|
||||||
let (bits', a, exp'') = if length bits <= budget
|
|
||||||
then (bits, 0, exp')
|
|
||||||
else do
|
|
||||||
let rounded = take budget bits
|
|
||||||
let rest = drop budget bits
|
|
||||||
if head rest == True && (length rest > 1 || (length rounded > 0 && last rounded == True))
|
|
||||||
then do
|
|
||||||
if length rounded > 0 && all (== True) rounded
|
|
||||||
then ([True], 0, exp' + 1)
|
|
||||||
else (rounded, 1, exp')
|
|
||||||
else (rounded, 0, exp')
|
|
||||||
if exp'' > expLimit || exp'' < (negate $ expLimit + manitisaSize) then Left "constant out of range" else return ()
|
|
||||||
if exp'' >= (negate $ expLimit - 1)
|
|
||||||
then return $ toFloat $ sign .|. ((fromIntegral $ exp'' + expLimit) `shiftL` manitisaSize) .|. ((fromBits (tail bits') + a) `shiftL` (manitisaSize + 1 - length bits'))
|
|
||||||
else do
|
|
||||||
let shift = expLimit + manitisaSize - length bits' - abs exp''
|
|
||||||
if shift < 0
|
|
||||||
then return $ toFloat sign
|
|
||||||
else return $ toFloat $ sign .|. ((fromBits bits' + a) `shiftL` shift)
|
|
||||||
|
|
||||||
type BitString = [Bool]
|
|
||||||
|
|
||||||
toBits :: String -> BitString
|
|
||||||
toBits = concat . map (asBits . readHexFromChar)
|
|
||||||
where
|
where
|
||||||
asBits :: Word8 -> BitString
|
readHexExp :: String -> Double
|
||||||
asBits w = [
|
readHexExp [] = 1
|
||||||
if w .&. 8 == 0 then False else True,
|
readHexExp ('+' : rest) = readHexExp rest
|
||||||
if w .&. 4 == 0 then False else True,
|
readHexExp ('-' : rest) = 1 / readHexExp rest
|
||||||
if w .&. 2 == 0 then False else True,
|
readHexExp expStr = 2 ^ read expStr
|
||||||
if w .&. 1 == 0 then False else True
|
|
||||||
]
|
|
||||||
|
|
||||||
fromBits :: (Integral i) => BitString -> i
|
readHexFrac :: String -> Double
|
||||||
fromBits = foldr (\b acc -> acc * 2 + if b then 1 else 0) 0 . reverse . dropWhile (== False)
|
readHexFrac [] = 0
|
||||||
|
readHexFrac val =
|
||||||
|
let len = length val in
|
||||||
|
sum $ zipWith (\i c -> readHexFromChar c / (16 ^ i)) [1..] val
|
||||||
|
|
||||||
asFloat :: FloatRep -> Either String Float
|
asFloat :: FloatRep -> Either String Float
|
||||||
asFloat (BinRep d) = Right $ doubleToFloat d
|
asFloat (BinRep d) = Right $ doubleToFloat d
|
||||||
asFloat (HexRep s) = readHexFloat wordToFloat 32 127 23 s
|
asFloat (HexRep s) = doubleToFloat <$> readHexFloat 128 "ffffff" s
|
||||||
asFloat (DecRep s) = readDecFloat s
|
asFloat (DecRep s) = readDecFloat s
|
||||||
asFloat (NanRep Canonical) = Right nan
|
|
||||||
asFloat (NanRep Arithmetic) = Right nan
|
|
||||||
asFloat (NanRep (NanHex isPos payload)) =
|
|
||||||
if payload >= 1 && payload < 2 ^ 23
|
|
||||||
then return $ doubleToFloat $ (if isPos then id else negate) $ makeNaN payload
|
|
||||||
else Left "constant out of range"
|
|
||||||
|
|
||||||
asDouble :: FloatRep -> Either String Double
|
asDouble :: FloatRep -> Either String Double
|
||||||
asDouble (BinRep d) = Right d
|
asDouble (BinRep d) = Right d
|
||||||
asDouble (HexRep s) = readHexFloat wordToDouble 64 1023 52 s
|
asDouble (HexRep s) = readHexFloat 1024 "fffffffffffff8" s
|
||||||
asDouble (DecRep s) = readDecDouble s
|
asDouble (DecRep s) = readDecDouble s
|
||||||
asDouble (NanRep Canonical) = Right nan
|
|
||||||
asDouble (NanRep Arithmetic) = Right nan
|
|
||||||
asDouble (NanRep (NanHex isPos payload)) =
|
|
||||||
if payload >= 1 && payload < 2 ^ 52
|
|
||||||
then return $ (if isPos then id else negate) $ makeNaN payload
|
|
||||||
else Left "constant out of range"
|
|
||||||
|
|
||||||
doubleFromInteger :: Integer -> Either String Double
|
|
||||||
doubleFromInteger int = asDouble . HexRep . ((if int < 0 then "-0x" else "0x") ++) . flip showHex "" $ abs int
|
|
||||||
|
|
||||||
startBlockComment :: AlexAction Lexeme
|
startBlockComment :: AlexAction Lexeme
|
||||||
startBlockComment _inp _len = do
|
startBlockComment _inp _len = do
|
||||||
@@ -352,13 +301,6 @@ data FloatRep
|
|||||||
= BinRep Double
|
= BinRep Double
|
||||||
| DecRep String
|
| DecRep String
|
||||||
| HexRep String
|
| HexRep String
|
||||||
| NanRep NaN
|
|
||||||
deriving (Show, Eq)
|
|
||||||
|
|
||||||
data NaN
|
|
||||||
= Canonical
|
|
||||||
| Arithmetic
|
|
||||||
| NanHex Bool Word64
|
|
||||||
deriving (Show, Eq)
|
deriving (Show, Eq)
|
||||||
|
|
||||||
data Token = TKeyword LBS.ByteString
|
data Token = TKeyword LBS.ByteString
|
||||||
|
|||||||
+511
-782
File diff suppressed because it is too large
Load Diff
+64
-100
@@ -8,12 +8,9 @@ import qualified Data.Map as Map
|
|||||||
import qualified Data.Vector as Vector
|
import qualified Data.Vector as Vector
|
||||||
import qualified Data.Text.Lazy as TL
|
import qualified Data.Text.Lazy as TL
|
||||||
import qualified Data.Text.Lazy.Encoding as TLEncoding
|
import qualified Data.Text.Lazy.Encoding as TLEncoding
|
||||||
import qualified Control.Monad.State as State
|
|
||||||
import Control.Monad.IO.Class (liftIO)
|
|
||||||
import Numeric.IEEE (identicalIEEE)
|
import Numeric.IEEE (identicalIEEE)
|
||||||
import qualified Control.DeepSeq as DeepSeq
|
import qualified Control.DeepSeq as DeepSeq
|
||||||
import Data.Maybe (fromJust, isNothing)
|
import Data.Maybe (fromJust, isNothing)
|
||||||
import Debug.Trace (trace)
|
|
||||||
|
|
||||||
import Language.Wasm.Parser (
|
import Language.Wasm.Parser (
|
||||||
Ident(..),
|
Ident(..),
|
||||||
@@ -48,11 +45,9 @@ emptyState = ScriptState {
|
|||||||
moduleRegistery = Map.empty
|
moduleRegistery = Map.empty
|
||||||
}
|
}
|
||||||
|
|
||||||
type AssertM = State.StateT (ScriptState, String) IO
|
|
||||||
|
|
||||||
runScript :: OnAssertFail -> Script -> IO ()
|
runScript :: OnAssertFail -> Script -> IO ()
|
||||||
runScript onAssertFail script = do
|
runScript onAssertFail script = do
|
||||||
(globI32, globI64, globF32, globF64) <- hostGlobals
|
(globI32, globF32, globF64) <- hostGlobals
|
||||||
(st, inst) <- Interpreter.makeHostModule Interpreter.emptyStore [
|
(st, inst) <- Interpreter.makeHostModule Interpreter.emptyStore [
|
||||||
("print", hostPrint []),
|
("print", hostPrint []),
|
||||||
("print_i32", hostPrint [Struct.I32]),
|
("print_i32", hostPrint [Struct.I32]),
|
||||||
@@ -61,7 +56,6 @@ runScript onAssertFail script = do
|
|||||||
("print_f32", hostPrint [Struct.F32]),
|
("print_f32", hostPrint [Struct.F32]),
|
||||||
("print_f64", hostPrint [Struct.F64]),
|
("print_f64", hostPrint [Struct.F64]),
|
||||||
("global_i32", globI32),
|
("global_i32", globI32),
|
||||||
("global_i64", globI64),
|
|
||||||
("global_f32", globF32),
|
("global_f32", globF32),
|
||||||
("global_f64", globF64),
|
("global_f64", globF64),
|
||||||
("memory", Interpreter.HostMemory $ Struct.Limit 1 (Just 2)),
|
("memory", Interpreter.HostMemory $ Struct.Limit 1 (Just 2)),
|
||||||
@@ -71,16 +65,10 @@ runScript onAssertFail script = do
|
|||||||
where
|
where
|
||||||
hostPrint paramTypes = Interpreter.HostFunction (Struct.FuncType paramTypes []) (\args -> return [])
|
hostPrint paramTypes = Interpreter.HostFunction (Struct.FuncType paramTypes []) (\args -> return [])
|
||||||
hostGlobals = do
|
hostGlobals = do
|
||||||
let globI32 = Interpreter.makeConstGlobal $ Interpreter.VI32 666
|
globI32 <- Interpreter.makeMutGlobal $ Interpreter.VI32 666
|
||||||
let globI64 = Interpreter.makeConstGlobal $ Interpreter.VI64 666
|
globF32 <- Interpreter.makeMutGlobal $ Interpreter.VF32 666
|
||||||
let globF32 = Interpreter.makeConstGlobal $ Interpreter.VF32 666
|
globF64 <- Interpreter.makeMutGlobal $ Interpreter.VF64 666
|
||||||
let globF64 = Interpreter.makeConstGlobal $ Interpreter.VF64 666
|
return (Interpreter.HostGlobal globI32, Interpreter.HostGlobal globF32, Interpreter.HostGlobal globF64)
|
||||||
return (
|
|
||||||
Interpreter.HostGlobal globI32,
|
|
||||||
Interpreter.HostGlobal globI64,
|
|
||||||
Interpreter.HostGlobal globF32,
|
|
||||||
Interpreter.HostGlobal globF64
|
|
||||||
)
|
|
||||||
|
|
||||||
go [] _ = return ()
|
go [] _ = return ()
|
||||||
go (c:cs) st = runCommand st c >>= go cs
|
go (c:cs) st = runCommand st c >>= go cs
|
||||||
@@ -107,12 +95,12 @@ runScript onAssertFail script = do
|
|||||||
addModule :: Maybe Ident -> Struct.Module -> ScriptState -> IO ScriptState
|
addModule :: Maybe Ident -> Struct.Module -> ScriptState -> IO ScriptState
|
||||||
addModule ident m st =
|
addModule ident m st =
|
||||||
case Validate.validate m of
|
case Validate.validate m of
|
||||||
Right m -> do
|
Validate.Valid -> do
|
||||||
(res, store') <- Interpreter.instantiate (store st) (buildImports st) m
|
res <- Interpreter.instantiate (store st) (buildImports st) m
|
||||||
case res of
|
case res of
|
||||||
Right modInst -> return $ addToStore ident modInst $ st { lastModule = Just modInst, store = store' }
|
Right (modInst, store') -> return $ addToStore ident modInst $ st { lastModule = Just modInst, store = store' }
|
||||||
Left reason -> error $ "Module instantiation failed due to invalid module with reason: " ++ show reason
|
Left reason -> error $ "Module instantiation failed dut to invalid module with reason: " ++ show reason
|
||||||
Left reason -> error $ "Module instantiation failed due to invalid module with reason: " ++ show reason
|
reason -> error $ "Module instantiation failed dut to invalid module with reason: " ++ show reason
|
||||||
|
|
||||||
getModule :: ScriptState -> Maybe Ident -> Maybe Interpreter.ModuleInstance
|
getModule :: ScriptState -> Maybe Ident -> Maybe Interpreter.ModuleInstance
|
||||||
getModule st (Just (Ident i)) = Map.lookup i (modules st)
|
getModule st (Just (Ident i)) = Map.lookup i (modules st)
|
||||||
@@ -123,10 +111,7 @@ runScript onAssertFail script = do
|
|||||||
asArg [Struct.F32Const v] = Interpreter.VF32 v
|
asArg [Struct.F32Const v] = Interpreter.VF32 v
|
||||||
asArg [Struct.I64Const v] = Interpreter.VI64 v
|
asArg [Struct.I64Const v] = Interpreter.VI64 v
|
||||||
asArg [Struct.F64Const v] = Interpreter.VF64 v
|
asArg [Struct.F64Const v] = Interpreter.VF64 v
|
||||||
asArg [Struct.RefNull Struct.FuncRef] = Interpreter.RF Nothing
|
asArg _ = error "Only const instructions supported as arguments for actions"
|
||||||
asArg [Struct.RefNull Struct.ExternRef] = Interpreter.RE Nothing
|
|
||||||
asArg [Struct.RefExtern v] = Interpreter.RE (Just v)
|
|
||||||
asArg expr = error $ "Only const instructions supported as arguments for actions: " ++ show expr
|
|
||||||
|
|
||||||
runAction :: ScriptState -> Action -> IO (Maybe [Interpreter.Value])
|
runAction :: ScriptState -> Action -> IO (Maybe [Interpreter.Value])
|
||||||
runAction st (Invoke ident name args) = do
|
runAction st (Invoke ident name args) = do
|
||||||
@@ -141,25 +126,23 @@ runScript onAssertFail script = do
|
|||||||
isValueEqual :: Interpreter.Value -> Interpreter.Value -> Bool
|
isValueEqual :: Interpreter.Value -> Interpreter.Value -> Bool
|
||||||
isValueEqual (Interpreter.VI32 v1) (Interpreter.VI32 v2) = v1 == v2
|
isValueEqual (Interpreter.VI32 v1) (Interpreter.VI32 v2) = v1 == v2
|
||||||
isValueEqual (Interpreter.VI64 v1) (Interpreter.VI64 v2) = v1 == v2
|
isValueEqual (Interpreter.VI64 v1) (Interpreter.VI64 v2) = v1 == v2
|
||||||
isValueEqual (Interpreter.VF32 v1) (Interpreter.VF32 v2) = (isNaN v1 && isNaN v2) || identicalIEEE v1 v2
|
isValueEqual (Interpreter.VF32 v1) (Interpreter.VF32 v2) = identicalIEEE v1 v2
|
||||||
isValueEqual (Interpreter.VF64 v1) (Interpreter.VF64 v2) = (isNaN v1 && isNaN v2) || identicalIEEE v1 v2
|
isValueEqual (Interpreter.VF64 v1) (Interpreter.VF64 v2) = identicalIEEE v1 v2
|
||||||
isValueEqual (Interpreter.RF f1) (Interpreter.RF f2) = f1 == f2
|
|
||||||
isValueEqual (Interpreter.RE e1) (Interpreter.RE e2) = e1 == e2
|
|
||||||
isValueEqual _ _ = False
|
isValueEqual _ _ = False
|
||||||
|
|
||||||
isNaNReturned :: Action -> Assertion -> AssertM ()
|
isNaNReturned :: ScriptState -> Action -> Assertion -> IO ()
|
||||||
isNaNReturned action assert = do
|
isNaNReturned st action assert = do
|
||||||
result <- runActionInAssert action
|
result <- runAction st action
|
||||||
case result of
|
case result of
|
||||||
Just [Interpreter.VF32 v] ->
|
Just [Interpreter.VF32 v] ->
|
||||||
if isNaN v
|
if isNaN v
|
||||||
then return ()
|
then return ()
|
||||||
else printFailedAssert ("Expected NaN, but action returned " ++ show v) assert
|
else onAssertFail ("Expected NaN, but action returned " ++ show v) assert
|
||||||
Just [Interpreter.VF64 v] ->
|
Just [Interpreter.VF64 v] ->
|
||||||
if isNaN v
|
if isNaN v
|
||||||
then return ()
|
then return ()
|
||||||
else printFailedAssert ("Expected NaN, but action returned " ++ show v) assert
|
else onAssertFail ("Expected NaN, but action returned " ++ show v) assert
|
||||||
_ -> printFailedAssert ("Expected NaN, but action returned " ++ show result) assert
|
_ -> onAssertFail ("Expected NaN, but action returned " ++ show result) assert
|
||||||
|
|
||||||
buildModule :: ModuleDef -> (Maybe Ident, Struct.Module)
|
buildModule :: ModuleDef -> (Maybe Ident, Struct.Module)
|
||||||
buildModule (RawModDef ident m) = (ident, m)
|
buildModule (RawModDef ident m) = (ident, m)
|
||||||
@@ -173,16 +156,16 @@ runScript onAssertFail script = do
|
|||||||
checkModuleInvalid :: Struct.Module -> IO ()
|
checkModuleInvalid :: Struct.Module -> IO ()
|
||||||
checkModuleInvalid _ = return ()
|
checkModuleInvalid _ = return ()
|
||||||
|
|
||||||
getFailureString :: Validate.ValidationError -> [TL.Text]
|
getFailureString :: Validate.ValidationResult -> [TL.Text]
|
||||||
getFailureString (Validate.TypeMismatch _ _) = ["type mismatch"]
|
getFailureString (Validate.TypeMismatch _ _) = ["type mismatch"]
|
||||||
getFailureString (Validate.RefTypeMismatch _ _) = ["type mismatch"]
|
|
||||||
getFailureString Validate.ResultTypeDoesntMatch = ["type mismatch"]
|
getFailureString Validate.ResultTypeDoesntMatch = ["type mismatch"]
|
||||||
getFailureString Validate.MoreThanOneMemory = ["multiple memories"]
|
getFailureString Validate.MoreThanOneMemory = ["multiple memories"]
|
||||||
getFailureString (Validate.LocalIndexOutOfRange idx) = ["unknown local", "unknown local " <> TL.pack (show idx)]
|
getFailureString Validate.MoreThanOneTable = ["multiple tables"]
|
||||||
getFailureString (Validate.MemoryIndexOutOfRange idx) = ["unknown memory", "unknown memory " <> TL.pack (show idx)]
|
getFailureString Validate.LocalIndexOutOfRange = ["unknown local"]
|
||||||
getFailureString (Validate.TableIndexOutOfRange idx) = ["unknown table", "unknown table " <> TL.pack (show idx)]
|
getFailureString Validate.MemoryIndexOutOfRange = ["unknown memory", "unknown memory 0"]
|
||||||
getFailureString (Validate.FunctionIndexOutOfRange idx) = ["unknown function", "unknown function " <> TL.pack (show idx)]
|
getFailureString Validate.TableIndexOutOfRange = ["unknown table", "unknown table 0"]
|
||||||
getFailureString (Validate.GlobalIndexOutOfRange idx) = ["unknown global", "unknown global " <> TL.pack (show idx)]
|
getFailureString Validate.FunctionIndexOutOfRange = ["unknown function", "unknown function 0"]
|
||||||
|
getFailureString Validate.GlobalIndexOutOfRange = ["unknown global"]
|
||||||
getFailureString Validate.LabelIndexOutOfRange = ["unknown label"]
|
getFailureString Validate.LabelIndexOutOfRange = ["unknown label"]
|
||||||
getFailureString Validate.TypeIndexOutOfRange = ["unknown type"]
|
getFailureString Validate.TypeIndexOutOfRange = ["unknown type"]
|
||||||
getFailureString Validate.MinMoreThanMaxInMemoryLimit = ["size minimum must not be greater than maximum"]
|
getFailureString Validate.MinMoreThanMaxInMemoryLimit = ["size minimum must not be greater than maximum"]
|
||||||
@@ -192,90 +175,72 @@ runScript onAssertFail script = do
|
|||||||
getFailureString Validate.InvalidConstantExpr = ["constant expression required"]
|
getFailureString Validate.InvalidConstantExpr = ["constant expression required"]
|
||||||
getFailureString Validate.InvalidResultArity = ["invalid result arity"]
|
getFailureString Validate.InvalidResultArity = ["invalid result arity"]
|
||||||
getFailureString Validate.GlobalIsImmutable = ["global is immutable"]
|
getFailureString Validate.GlobalIsImmutable = ["global is immutable"]
|
||||||
|
getFailureString Validate.ImportedGlobalIsNotConst = ["mutable globals cannot be imported"]
|
||||||
|
getFailureString Validate.ExportedGlobalIsNotConst = ["mutable globals cannot be exported"]
|
||||||
getFailureString Validate.InvalidStartFunctionType = ["start function"]
|
getFailureString Validate.InvalidStartFunctionType = ["start function"]
|
||||||
getFailureString Validate.InvalidTableType = ["size minimum must not be greater than maximum"]
|
getFailureString r = [TL.concat ["not implemented ", (TL.pack $ show r)]]
|
||||||
getFailureString (Validate.ElemIndexOutOfRange idx) = ["unknown elem segment " <> TL.pack (show idx)]
|
|
||||||
getFailureString (Validate.DataIndexOutOfRange idx) = ["unknown data segment", "unknown data segment " <> TL.pack (show idx)]
|
|
||||||
getFailureString (Validate.UndeclaredFunctionRef _) = ["undeclared function reference"]
|
|
||||||
getFailureString r = [TL.concat ["not implemented ", TL.pack $ show r]]
|
|
||||||
|
|
||||||
printFailedAssert :: String -> Assertion -> AssertM ()
|
runAssert :: ScriptState -> Assertion -> IO ()
|
||||||
printFailedAssert msg assert = do
|
runAssert st assert@(AssertReturn action expected) = do
|
||||||
(_, pos) <- State.get
|
result <- runAction st action
|
||||||
liftIO $ onAssertFail (pos ++ ": " ++ msg) assert
|
|
||||||
|
|
||||||
runActionInAssert :: Action -> AssertM (Maybe [Interpreter.Value])
|
|
||||||
runActionInAssert action = do
|
|
||||||
(st, _) <- State.get
|
|
||||||
liftIO $ runAction st action
|
|
||||||
|
|
||||||
runAssert :: Assertion -> AssertM ()
|
|
||||||
runAssert assert@(AssertReturn action expected) = do
|
|
||||||
(st, _) <- State.get
|
|
||||||
result <- runActionInAssert action
|
|
||||||
case result of
|
case result of
|
||||||
Just result -> do
|
Just result -> do
|
||||||
if length result == length expected && (all id $ zipWith isValueEqual result (map asArg expected))
|
if length result == length expected && (all id $ zipWith isValueEqual result (map asArg expected))
|
||||||
then return ()
|
then return ()
|
||||||
else printFailedAssert ("Expected " ++ show (map asArg expected) ++ ", but action returned " ++ show result) assert
|
else onAssertFail ("Expected " ++ show (map asArg expected) ++ ", but action returned " ++ show result) assert
|
||||||
Nothing -> printFailedAssert ("Expected " ++ show (map asArg expected) ++ ", but action returned Trap") assert
|
Nothing -> onAssertFail ("Expected " ++ show (map asArg expected) ++ ", but action returned Trap") assert
|
||||||
runAssert assert@(AssertReturnCanonicalNaN action) = isNaNReturned action assert
|
runAssert st assert@(AssertReturnCanonicalNaN action) = isNaNReturned st action assert
|
||||||
runAssert assert@(AssertReturnArithmeticNaN action) = isNaNReturned action assert
|
runAssert st assert@(AssertReturnArithmeticNaN action) = isNaNReturned st action assert
|
||||||
runAssert assert@(AssertInvalid moduleDef failureString) =
|
runAssert st assert@(AssertInvalid moduleDef failureString) =
|
||||||
let (_, m) = buildModule moduleDef in
|
let (_, m) = buildModule moduleDef in
|
||||||
case Validate.validate m of
|
case Validate.validate m of
|
||||||
Right _ -> printFailedAssert "An invalid module passed validation step" assert
|
Validate.Valid -> onAssertFail "Invalid module pass validation" assert
|
||||||
Left reason ->
|
reason ->
|
||||||
if failureString `elem` getFailureString reason
|
if failureString `elem` getFailureString reason
|
||||||
then return ()
|
then return ()
|
||||||
else
|
else
|
||||||
let msg = "Module is invalid for other reason. Expected "
|
let msg = "Module invalid for other reason. Expected "
|
||||||
++ show failureString
|
++ show failureString
|
||||||
++ ", but actual is "
|
++ ", but actual is "
|
||||||
++ show (getFailureString reason)
|
++ show (getFailureString reason)
|
||||||
in printFailedAssert msg assert
|
in onAssertFail msg assert
|
||||||
runAssert assert@(AssertMalformed (TextModDef _ textRep) failureString) =
|
runAssert st assert@(AssertMalformed (TextModDef _ textRep) failureString) =
|
||||||
case DeepSeq.force $ Lexer.scanner (TLEncoding.encodeUtf8 textRep) >>= Parser.parseModule of
|
case DeepSeq.force $ Lexer.scanner (TLEncoding.encodeUtf8 textRep) >>= Parser.parseModule of
|
||||||
Right _ -> printFailedAssert ("Module parsing should fail with failure string " ++ show failureString) assert
|
Right _ -> onAssertFail ("Module parsing should fail with failure string " ++ show failureString) assert
|
||||||
Left _ -> return ()
|
Left _ -> return ()
|
||||||
runAssert assert@(AssertMalformed (BinaryModDef ident binaryRep) failureString) =
|
runAssert st assert@(AssertMalformed (BinaryModDef ident binaryRep) failureString) =
|
||||||
case Binary.decodeModuleLazy binaryRep of
|
case Binary.decodeModuleLazy binaryRep of
|
||||||
Right _ -> printFailedAssert ("Module decoding should fail with failure string " ++ show failureString) assert
|
Right _ -> onAssertFail ("Module decoding should fail with failure string " ++ show failureString) assert
|
||||||
Left _ -> return ()
|
Left _ -> return ()
|
||||||
runAssert assert@(AssertMalformed (RawModDef _ _) failureString) = return ()
|
runAssert st assert@(AssertMalformed (RawModDef _ _) failureString) = return ()
|
||||||
runAssert assert@(AssertUnlinkable moduleDef failureString) =
|
runAssert st assert@(AssertUnlinkable moduleDef failureString) =
|
||||||
let (_, m) = buildModule moduleDef in
|
let (_, m) = buildModule moduleDef in
|
||||||
case Validate.validate m of
|
case Validate.validate m of
|
||||||
Right m -> do
|
Validate.Valid -> do
|
||||||
st <- fst <$> State.get
|
res <- Interpreter.instantiate (store st) (buildImports st) m
|
||||||
(res, _) <- liftIO $ Interpreter.instantiate (store st) (buildImports st) m
|
|
||||||
case res of
|
case res of
|
||||||
Left err -> return ()
|
Left err -> return ()
|
||||||
Right _ -> printFailedAssert ("Module linking should fail with failure string " ++ show failureString) assert
|
Right _ -> onAssertFail ("Module linking should fail with failure string " ++ show failureString) assert
|
||||||
Left reason -> error $ "Module linking failed due to invalid module with reason: " ++ show reason
|
reason -> error $ "Module linking failed dut to invalid module with reason: " ++ show reason
|
||||||
runAssert assert@(AssertTrap (Left action) failureString) = do
|
runAssert st assert@(AssertTrap (Left action) failureString) = do
|
||||||
result <- runActionInAssert action
|
result <- runAction st action
|
||||||
if isNothing result
|
if isNothing result
|
||||||
then return ()
|
then return ()
|
||||||
else printFailedAssert ("Expected trap, but action returned " ++ show (fromJust result)) assert
|
else onAssertFail ("Expected trap, but action returned " ++ show (fromJust result)) assert
|
||||||
runAssert assert@(AssertTrap (Right moduleDef) failureString) =
|
runAssert st assert@(AssertTrap (Right moduleDef) failureString) =
|
||||||
let (_, m) = buildModule moduleDef in
|
let (_, m) = buildModule moduleDef in
|
||||||
case Validate.validate m of
|
case Validate.validate m of
|
||||||
Right m -> do
|
Validate.Valid -> do
|
||||||
(st, pos) <- State.get
|
res <- Interpreter.instantiate (store st) (buildImports st) m
|
||||||
(res, store') <- liftIO $ Interpreter.instantiate (store st) (buildImports st) m
|
|
||||||
State.put (st { store = store' }, pos)
|
|
||||||
case res of
|
case res of
|
||||||
Left err | err == TL.unpack failureString -> return ()
|
Left "Start function terminated with trap" -> return ()
|
||||||
Left "Start function terminated with trap" ->
|
_ -> onAssertFail ("Module linking should fail with trap during execution of a start function") assert
|
||||||
State.modify $ \(st, pos) -> (st { store = store' }, pos)
|
reason -> error $ "Module linking failed dut to invalid module with reason: " ++ show reason
|
||||||
r -> printFailedAssert "Module linking should fail with trap during execution of a start function" assert
|
runAssert st assert@(AssertExhaustion action failureString) = do
|
||||||
Left reason -> error $ "Module linking failed due to invalid module with reason: " ++ show reason
|
result <- runAction st action
|
||||||
runAssert assert@(AssertExhaustion action failureString) = do
|
|
||||||
result <- runActionInAssert action
|
|
||||||
if isNothing result
|
if isNothing result
|
||||||
then return ()
|
then return ()
|
||||||
else printFailedAssert ("Expected exhaustion, but action returned " ++ show (fromJust result)) assert
|
else onAssertFail ("Expected exhaustion, but action returned " ++ show (fromJust result)) assert
|
||||||
|
|
||||||
runCommand :: ScriptState -> Command -> IO ScriptState
|
runCommand :: ScriptState -> Command -> IO ScriptState
|
||||||
runCommand st (ModuleDef moduleDef) =
|
runCommand st (ModuleDef moduleDef) =
|
||||||
@@ -283,6 +248,5 @@ runScript onAssertFail script = do
|
|||||||
addModule ident m st
|
addModule ident m st
|
||||||
runCommand st (Register name i) = return $ addToRegistery name i st
|
runCommand st (Register name i) = return $ addToRegistery name i st
|
||||||
runCommand st (Action action) = runAction st action >> return st
|
runCommand st (Action action) = runAction st action >> return st
|
||||||
runCommand st (Assertion pos assertion) = do
|
runCommand st (Assertion assertion) = runAssert st assertion >> return st
|
||||||
fst <$> flip State.execStateT (st, ("Line " ++ show pos)) (runAssert assertion)
|
|
||||||
runCommand st _ = return st
|
runCommand st _ = return st
|
||||||
|
|||||||
@@ -4,10 +4,8 @@
|
|||||||
|
|
||||||
module Language.Wasm.Structure (
|
module Language.Wasm.Structure (
|
||||||
Module(..),
|
Module(..),
|
||||||
DataMode(..),
|
|
||||||
DataSegment(..),
|
DataSegment(..),
|
||||||
ElemSegment(..),
|
ElemSegment(..),
|
||||||
ElemMode(..),
|
|
||||||
StartFunction(..),
|
StartFunction(..),
|
||||||
Export(..),
|
Export(..),
|
||||||
ExportDesc(..),
|
ExportDesc(..),
|
||||||
@@ -32,18 +30,11 @@ module Language.Wasm.Structure (
|
|||||||
GlobalType(..),
|
GlobalType(..),
|
||||||
FuncType(..),
|
FuncType(..),
|
||||||
ValueType(..),
|
ValueType(..),
|
||||||
BlockType(..),
|
|
||||||
ParamsType,
|
|
||||||
ResultType,
|
ResultType,
|
||||||
LocalsType,
|
|
||||||
Expression,
|
Expression,
|
||||||
LabelIndex,
|
LabelIndex,
|
||||||
FuncIndex,
|
|
||||||
TypeIndex,
|
|
||||||
LocalIndex,
|
LocalIndex,
|
||||||
GlobalIndex,
|
GlobalIndex,
|
||||||
MemoryIndex,
|
|
||||||
TableIndex,
|
|
||||||
emptyModule,
|
emptyModule,
|
||||||
isFuncImport,
|
isFuncImport,
|
||||||
isTableImport,
|
isTableImport,
|
||||||
@@ -60,14 +51,7 @@ import GHC.Generics (Generic)
|
|||||||
|
|
||||||
data BitSize = BS32 | BS64 deriving (Show, Eq, Generic, NFData)
|
data BitSize = BS32 | BS64 deriving (Show, Eq, Generic, NFData)
|
||||||
|
|
||||||
data IUnOp =
|
data IUnOp = IClz | ICtz | IPopcnt deriving (Show, Eq, Generic, NFData)
|
||||||
IClz
|
|
||||||
| ICtz
|
|
||||||
| IPopcnt
|
|
||||||
| IExtend8S
|
|
||||||
| IExtend16S
|
|
||||||
| IExtend32S
|
|
||||||
deriving (Show, Eq, Generic, NFData)
|
|
||||||
|
|
||||||
data IBinOp =
|
data IBinOp =
|
||||||
IAdd
|
IAdd
|
||||||
@@ -104,16 +88,12 @@ type LocalIndex = Natural
|
|||||||
type GlobalIndex = Natural
|
type GlobalIndex = Natural
|
||||||
type MemoryIndex = Natural
|
type MemoryIndex = Natural
|
||||||
type TableIndex = Natural
|
type TableIndex = Natural
|
||||||
type DataIndex = Natural
|
|
||||||
type ElemIndex = Natural
|
|
||||||
|
|
||||||
data ValueType =
|
data ValueType =
|
||||||
I32
|
I32
|
||||||
| I64
|
| I64
|
||||||
| F32
|
| F32
|
||||||
| F64
|
| F64
|
||||||
| Func
|
|
||||||
| Extern
|
|
||||||
deriving (Show, Eq, Generic, NFData)
|
deriving (Show, Eq, Generic, NFData)
|
||||||
|
|
||||||
type ResultType = [ValueType]
|
type ResultType = [ValueType]
|
||||||
@@ -122,32 +102,22 @@ type LocalsType = [ValueType]
|
|||||||
|
|
||||||
data FuncType = FuncType { params :: ParamsType, results :: ResultType } deriving (Show, Eq, Generic, NFData)
|
data FuncType = FuncType { params :: ParamsType, results :: ResultType } deriving (Show, Eq, Generic, NFData)
|
||||||
|
|
||||||
data BlockType =
|
|
||||||
Inline (Maybe ValueType)
|
|
||||||
| TypeIndex TypeIndex
|
|
||||||
deriving (Show, Eq, Generic, NFData)
|
|
||||||
|
|
||||||
data Instruction index =
|
data Instruction index =
|
||||||
-- Control instructions
|
-- Control instructions
|
||||||
Unreachable
|
Unreachable
|
||||||
| Nop
|
| Nop
|
||||||
| Block { blockType :: BlockType, body :: Expression }
|
| Block { resultType :: ResultType, body :: Expression }
|
||||||
| Loop { blockType :: BlockType, body :: Expression }
|
| Loop { resultType :: ResultType, body :: Expression }
|
||||||
| If { blockType :: BlockType, true :: Expression, false :: Expression }
|
| If { resultType :: ResultType, true :: Expression, false :: Expression }
|
||||||
| Br index
|
| Br index
|
||||||
| BrIf index
|
| BrIf index
|
||||||
| BrTable [index] index
|
| BrTable [index] index
|
||||||
| Return
|
| Return
|
||||||
| Call index
|
| Call index
|
||||||
| CallIndirect index index
|
| CallIndirect index
|
||||||
-- Reference instructions
|
|
||||||
| RefNull ElemType
|
|
||||||
| RefIsNull
|
|
||||||
| RefFunc index
|
|
||||||
| RefExtern Natural
|
|
||||||
-- Parametric instructions
|
-- Parametric instructions
|
||||||
| Drop
|
| Drop
|
||||||
| Select (Maybe [ValueType])
|
| Select
|
||||||
-- Variable instructions
|
-- Variable instructions
|
||||||
| GetLocal index
|
| GetLocal index
|
||||||
| SetLocal index
|
| SetLocal index
|
||||||
@@ -178,21 +148,8 @@ data Instruction index =
|
|||||||
| I64Store8 MemArg
|
| I64Store8 MemArg
|
||||||
| I64Store16 MemArg
|
| I64Store16 MemArg
|
||||||
| I64Store32 MemArg
|
| I64Store32 MemArg
|
||||||
| MemorySize
|
| CurrentMemory
|
||||||
| MemoryGrow
|
| GrowMemory
|
||||||
| MemoryFill
|
|
||||||
| MemoryCopy
|
|
||||||
| MemoryInit DataIndex
|
|
||||||
| DataDrop DataIndex
|
|
||||||
-- Table instructions
|
|
||||||
| TableInit TableIndex ElemIndex
|
|
||||||
| TableGrow TableIndex
|
|
||||||
| TableSize TableIndex
|
|
||||||
| TableFill TableIndex
|
|
||||||
| TableGet TableIndex
|
|
||||||
| TableSet TableIndex
|
|
||||||
| TableCopy TableIndex TableIndex
|
|
||||||
| ElemDrop ElemIndex
|
|
||||||
-- Numeric instructions
|
-- Numeric instructions
|
||||||
| I32Const Word32
|
| I32Const Word32
|
||||||
| I64Const Word64
|
| I64Const Word64
|
||||||
@@ -209,8 +166,6 @@ data Instruction index =
|
|||||||
| I32WrapI64
|
| I32WrapI64
|
||||||
| ITruncFU {- Int Size -} BitSize {- Float Size -} BitSize
|
| ITruncFU {- Int Size -} BitSize {- Float Size -} BitSize
|
||||||
| ITruncFS {- Int Size -} BitSize {- Float Size -} BitSize
|
| ITruncFS {- Int Size -} BitSize {- Float Size -} BitSize
|
||||||
| ITruncSatFU {- Int Size -} BitSize {- Float Size -} BitSize
|
|
||||||
| ITruncSatFS {- Int Size -} BitSize {- Float Size -} BitSize
|
|
||||||
| I64ExtendSI32
|
| I64ExtendSI32
|
||||||
| I64ExtendUI32
|
| I64ExtendUI32
|
||||||
| FConvertIU {- Float Size -} BitSize {- Int Size -} BitSize
|
| FConvertIU {- Float Size -} BitSize {- Int Size -} BitSize
|
||||||
@@ -231,7 +186,7 @@ data Function = Function {
|
|||||||
|
|
||||||
data Limit = Limit Natural (Maybe Natural) deriving (Show, Eq, Generic, NFData)
|
data Limit = Limit Natural (Maybe Natural) deriving (Show, Eq, Generic, NFData)
|
||||||
|
|
||||||
data ElemType = FuncRef | ExternRef deriving (Show, Eq, Generic, NFData)
|
data ElemType = AnyFunc deriving (Show, Eq, Generic, NFData)
|
||||||
|
|
||||||
data TableType = TableType Limit ElemType deriving (Show, Eq, Generic, NFData)
|
data TableType = TableType Limit ElemType deriving (Show, Eq, Generic, NFData)
|
||||||
|
|
||||||
@@ -246,25 +201,15 @@ data Global = Global {
|
|||||||
initializer :: Expression
|
initializer :: Expression
|
||||||
} deriving (Show, Eq, Generic, NFData)
|
} deriving (Show, Eq, Generic, NFData)
|
||||||
|
|
||||||
data ElemMode =
|
|
||||||
Passive
|
|
||||||
| Active TableIndex Expression
|
|
||||||
| Declarative
|
|
||||||
deriving (Show, Eq, Generic, NFData)
|
|
||||||
|
|
||||||
data ElemSegment = ElemSegment {
|
data ElemSegment = ElemSegment {
|
||||||
elemType :: ElemType,
|
tableIndex :: TableIndex,
|
||||||
mode :: ElemMode,
|
offset :: Expression,
|
||||||
elements :: [Expression]
|
funcIndexes :: [FuncIndex]
|
||||||
} deriving (Show, Eq, Generic, NFData)
|
} deriving (Show, Eq, Generic, NFData)
|
||||||
|
|
||||||
data DataMode =
|
|
||||||
PassiveData
|
|
||||||
| ActiveData MemoryIndex Expression
|
|
||||||
deriving (Show, Eq, Generic, NFData)
|
|
||||||
|
|
||||||
data DataSegment = DataSegment {
|
data DataSegment = DataSegment {
|
||||||
dataMode :: DataMode,
|
memIndex :: MemoryIndex,
|
||||||
|
offset :: Expression,
|
||||||
chunk :: LBS.ByteString
|
chunk :: LBS.ByteString
|
||||||
} deriving (Show, Eq, Generic, NFData)
|
} deriving (Show, Eq, Generic, NFData)
|
||||||
|
|
||||||
|
|||||||
+256
-426
@@ -3,76 +3,66 @@
|
|||||||
{-# LANGUAGE FlexibleInstances #-}
|
{-# LANGUAGE FlexibleInstances #-}
|
||||||
|
|
||||||
module Language.Wasm.Validate (
|
module Language.Wasm.Validate (
|
||||||
ValidationError(..),
|
|
||||||
ValidationResult(..),
|
ValidationResult(..),
|
||||||
validate,
|
validate,
|
||||||
isValid,
|
isValid
|
||||||
ValidModule,
|
|
||||||
getModule
|
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Language.Wasm.Structure
|
import Language.Wasm.Structure
|
||||||
import qualified Data.Set as Set
|
import qualified Data.Set as Set
|
||||||
import Data.List (foldl')
|
import Data.List (foldl')
|
||||||
import qualified Data.Text.Lazy as TL
|
import qualified Data.Text.Lazy as TL
|
||||||
import Data.Maybe (fromMaybe, catMaybes)
|
import Data.Maybe (fromMaybe, maybeToList, catMaybes)
|
||||||
|
import Data.Monoid ((<>))
|
||||||
import Numeric.Natural (Natural)
|
import Numeric.Natural (Natural)
|
||||||
import Prelude hiding ((<>))
|
|
||||||
|
|
||||||
import Control.Monad (foldM, forM_, when, unless)
|
import Control.Monad (foldM)
|
||||||
import Control.Monad.Reader (ReaderT, runReaderT, withReaderT, ask)
|
import Control.Monad.Reader (ReaderT, runReaderT, withReaderT, ask)
|
||||||
import Control.Monad.Except (Except, runExcept, throwError)
|
import Control.Monad.Except (Except, runExcept, throwError)
|
||||||
|
|
||||||
import Debug.Trace as Debug
|
import Debug.Trace as Debug
|
||||||
|
|
||||||
data ValidationError =
|
data ValidationResult =
|
||||||
DuplicatedExportNames [String]
|
DuplicatedExportNames [String]
|
||||||
| InvalidTableType
|
| InvalidTableType
|
||||||
| MinMoreThanMaxInMemoryLimit
|
| MinMoreThanMaxInMemoryLimit
|
||||||
| MemoryLimitExceeded
|
| MemoryLimitExceeded
|
||||||
| AlignmentOverflow
|
| AlignmentOverflow
|
||||||
| MoreThanOneMemory
|
| MoreThanOneMemory
|
||||||
| FunctionIndexOutOfRange Natural
|
| MoreThanOneTable
|
||||||
| TableIndexOutOfRange Natural
|
| FunctionIndexOutOfRange
|
||||||
| MemoryIndexOutOfRange Natural
|
| TableIndexOutOfRange
|
||||||
| LocalIndexOutOfRange Natural
|
| MemoryIndexOutOfRange
|
||||||
| GlobalIndexOutOfRange Natural
|
| LocalIndexOutOfRange
|
||||||
| ElemIndexOutOfRange Natural
|
| GlobalIndexOutOfRange
|
||||||
| DataIndexOutOfRange Natural
|
|
||||||
| LabelIndexOutOfRange
|
| LabelIndexOutOfRange
|
||||||
| TypeIndexOutOfRange
|
| TypeIndexOutOfRange
|
||||||
| ResultTypeDoesntMatch
|
| ResultTypeDoesntMatch
|
||||||
| TypeMismatch { actual :: Arrow, expected :: Arrow }
|
| TypeMismatch { actual :: Arrow, expected :: Arrow }
|
||||||
| RefTypeMismatch ElemType ElemType
|
|
||||||
| InvalidResultArity
|
| InvalidResultArity
|
||||||
| InvalidConstantExpr
|
| InvalidConstantExpr
|
||||||
| InvalidStartFunctionType
|
| InvalidStartFunctionType
|
||||||
|
| ImportedGlobalIsNotConst
|
||||||
|
| ExportedGlobalIsNotConst
|
||||||
| GlobalIsImmutable
|
| GlobalIsImmutable
|
||||||
| UndeclaredFunctionRef Natural
|
| Valid
|
||||||
deriving (Show, Eq)
|
deriving (Show, Eq)
|
||||||
|
|
||||||
type ValidationResult = Either ValidationError ()
|
|
||||||
|
|
||||||
-- semigroup definition for Either a b is in conflict with my ad-hoc instance
|
|
||||||
-- to keep an old code Prelude version is hidden and redefined locally
|
|
||||||
(<>) = mappend
|
|
||||||
|
|
||||||
instance Monoid ValidationResult where
|
instance Monoid ValidationResult where
|
||||||
mempty = Right ()
|
mempty = Valid
|
||||||
mappend (Right ()) vr = vr
|
mappend Valid vr = vr
|
||||||
mappend vr (Right ()) = vr
|
mappend vr Valid = vr
|
||||||
mappend vr _ = vr
|
mappend vr _ = vr
|
||||||
|
|
||||||
isValid :: ValidationResult -> Bool
|
isValid :: ValidationResult -> Bool
|
||||||
isValid (Right ()) = True
|
isValid Valid = True
|
||||||
isValid (Left reason) = False
|
isValid reason = Debug.trace ("Module mismatched with reason " ++ show reason) $ False
|
||||||
|
|
||||||
type Validator = Module -> ValidationResult
|
type Validator = Module -> ValidationResult
|
||||||
|
|
||||||
data VType =
|
data VType =
|
||||||
Val ValueType
|
Val ValueType
|
||||||
| Var
|
| Var
|
||||||
| NonRefVar
|
|
||||||
| Any
|
| Any
|
||||||
deriving (Show, Eq)
|
deriving (Show, Eq)
|
||||||
|
|
||||||
@@ -102,16 +92,11 @@ data Arrow = Arrow End End deriving (Show, Eq)
|
|||||||
(==>) a b = Arrow (toEnd a) (toEnd b)
|
(==>) a b = Arrow (toEnd a) (toEnd b)
|
||||||
|
|
||||||
asArrow :: FuncType -> Arrow
|
asArrow :: FuncType -> Arrow
|
||||||
asArrow (FuncType params results) = Arrow (map Val params) (map Val $ reverse results)
|
asArrow (FuncType params results) = Arrow (map Val params) (map Val results)
|
||||||
|
|
||||||
isArrowMatch :: Arrow -> Arrow -> Bool
|
isArrowMatch :: Arrow -> Arrow -> Bool
|
||||||
isArrowMatch (f `Arrow` t) ( f' `Arrow` t') = isEndMatch f f' && isEndMatch t t'
|
isArrowMatch (f `Arrow` t) ( f' `Arrow` t') = isEndMatch f f' && isEndMatch t t'
|
||||||
where
|
where
|
||||||
isRef :: VType -> Bool
|
|
||||||
isRef (Val Func) = True
|
|
||||||
isRef (Val Extern) = True
|
|
||||||
isRef _ = False
|
|
||||||
|
|
||||||
isEndMatch :: End -> End -> Bool
|
isEndMatch :: End -> End -> Bool
|
||||||
isEndMatch (Any:l) (Any:r) =
|
isEndMatch (Any:l) (Any:r) =
|
||||||
let (leftTail, rightTail) = unzip $ zip (takeWhile (/= Any) $ reverse l) (takeWhile (/= Any) $ reverse r) in
|
let (leftTail, rightTail) = unzip $ zip (takeWhile (/= Any) $ reverse l) (takeWhile (/= Any) $ reverse r) in
|
||||||
@@ -128,12 +113,6 @@ isArrowMatch (f `Arrow` t) ( f' `Arrow` t') = isEndMatch f f' && isEndMatch t t'
|
|||||||
isEndMatch (x:l) (Var:r) =
|
isEndMatch (x:l) (Var:r) =
|
||||||
let subst = replace Var x in
|
let subst = replace Var x in
|
||||||
isEndMatch (subst l) (subst r)
|
isEndMatch (subst l) (subst r)
|
||||||
isEndMatch (NonRefVar:l) (x:r) =
|
|
||||||
let subst = replace NonRefVar x in
|
|
||||||
isEndMatch (subst l) (subst r)
|
|
||||||
isEndMatch (x:l) (NonRefVar:r) =
|
|
||||||
let subst = replace NonRefVar x in
|
|
||||||
isEndMatch (subst l) (subst r)
|
|
||||||
isEndMatch (Val v:l) (Val v':r) = v == v' && isEndMatch l r
|
isEndMatch (Val v:l) (Val v':r) = v == v' && isEndMatch l r
|
||||||
isEndMatch [] [] = True
|
isEndMatch [] [] = True
|
||||||
isEndMatch _ _ = False
|
isEndMatch _ _ = False
|
||||||
@@ -142,23 +121,20 @@ data Ctx = Ctx {
|
|||||||
types :: [FuncType],
|
types :: [FuncType],
|
||||||
funcs :: [FuncType],
|
funcs :: [FuncType],
|
||||||
tables :: [TableType],
|
tables :: [TableType],
|
||||||
elems :: [ElemType],
|
|
||||||
datas :: [DataMode],
|
|
||||||
mems :: [Limit],
|
mems :: [Limit],
|
||||||
globals :: [GlobalType],
|
globals :: [GlobalType],
|
||||||
locals :: [ValueType],
|
locals :: [ValueType],
|
||||||
labels :: [[ValueType]],
|
labels :: [Maybe ValueType],
|
||||||
returns :: [ValueType],
|
returns :: Maybe ValueType,
|
||||||
importedGlobals :: Natural,
|
importedGlobals :: Natural
|
||||||
refs :: Set.Set Natural
|
|
||||||
} deriving (Show, Eq)
|
} deriving (Show, Eq)
|
||||||
|
|
||||||
type Checker = ReaderT Ctx (Except ValidationError)
|
type Checker = ReaderT Ctx (Except ValidationResult)
|
||||||
|
|
||||||
freshVar :: Checker VType
|
freshVar :: Checker VType
|
||||||
freshVar = return Var
|
freshVar = return Var
|
||||||
|
|
||||||
runChecker :: Ctx -> Checker a -> Either ValidationError a
|
runChecker :: Ctx -> Checker a -> Either ValidationResult a
|
||||||
runChecker ctx = runExcept . flip runReaderT ctx
|
runChecker ctx = runExcept . flip runReaderT ctx
|
||||||
|
|
||||||
(!?) :: [a] -> Natural -> Maybe a
|
(!?) :: [a] -> Natural -> Maybe a
|
||||||
@@ -170,7 +146,7 @@ safeHead :: [a] -> Maybe a
|
|||||||
safeHead (x: _) = Just x
|
safeHead (x: _) = Just x
|
||||||
safeHead [] = Nothing
|
safeHead [] = Nothing
|
||||||
|
|
||||||
maybeToEither :: ValidationError -> Maybe a -> Checker a
|
maybeToEither :: ValidationResult -> Maybe a -> Checker a
|
||||||
maybeToEither _ (Just a) = return a
|
maybeToEither _ (Just a) = return a
|
||||||
maybeToEither l Nothing = throwError l
|
maybeToEither l Nothing = throwError l
|
||||||
|
|
||||||
@@ -182,7 +158,7 @@ shouldBeMut :: GlobalType -> Checker ()
|
|||||||
shouldBeMut (Mut _) = return ()
|
shouldBeMut (Mut _) = return ()
|
||||||
shouldBeMut (Const v) = throwError GlobalIsImmutable
|
shouldBeMut (Const v) = throwError GlobalIsImmutable
|
||||||
|
|
||||||
getLabel :: LabelIndex -> Checker [ValueType]
|
getLabel :: LabelIndex -> Checker (Maybe ValueType)
|
||||||
getLabel lbl = do
|
getLabel lbl = do
|
||||||
Ctx { labels } <- ask
|
Ctx { labels } <- ask
|
||||||
case labels !? lbl of
|
case labels !? lbl of
|
||||||
@@ -190,7 +166,7 @@ getLabel lbl = do
|
|||||||
Just v -> return v
|
Just v -> return v
|
||||||
|
|
||||||
withLabel :: [ValueType] -> Checker a -> Checker a
|
withLabel :: [ValueType] -> Checker a -> Checker a
|
||||||
withLabel result = withReaderT (\ctx -> ctx { labels = result : labels ctx })
|
withLabel result = withReaderT (\ctx -> ctx { labels = safeHead result : labels ctx })
|
||||||
|
|
||||||
isMemArgValid :: Int -> MemArg -> Checker ()
|
isMemArgValid :: Int -> MemArg -> Checker ()
|
||||||
isMemArgValid sizeInBytes MemArg { align } = if 2 ^ align <= sizeInBytes then return () else throwError AlignmentOverflow
|
isMemArgValid sizeInBytes MemArg { align } = if 2 ^ align <= sizeInBytes then return () else throwError AlignmentOverflow
|
||||||
@@ -199,340 +175,214 @@ checkMemoryInstr :: Int -> MemArg -> Checker ()
|
|||||||
checkMemoryInstr size memarg = do
|
checkMemoryInstr size memarg = do
|
||||||
isMemArgValid size memarg
|
isMemArgValid size memarg
|
||||||
Ctx { mems } <- ask
|
Ctx { mems } <- ask
|
||||||
if length mems < 1 then throwError (MemoryIndexOutOfRange 0) else return ()
|
if length mems < 1 then throwError MemoryIndexOutOfRange else return ()
|
||||||
|
|
||||||
getBlockType :: BlockType -> Checker Arrow
|
getInstrType :: Instruction Natural -> Checker Arrow
|
||||||
getBlockType (Inline Nothing) = return $ empty ==> empty
|
getInstrType Unreachable = return $ Any ==> Any
|
||||||
getBlockType (Inline (Just valType)) = return $ empty ==> valType
|
getInstrType Nop = return $ empty ==> empty
|
||||||
getBlockType (TypeIndex typeIdx) = do
|
getInstrType Block { resultType, body } = do
|
||||||
Ctx { types } <- ask
|
let blockType = empty ==> resultType
|
||||||
maybeToEither TypeIndexOutOfRange $ asArrow <$> types !? typeIdx
|
t <- withLabel resultType $ getExpressionType body
|
||||||
|
if isArrowMatch t blockType
|
||||||
getResultType :: BlockType -> Checker [ValueType]
|
then return $ empty ==> resultType
|
||||||
getResultType (Inline Nothing) = return []
|
else throwError $ TypeMismatch t blockType
|
||||||
getResultType (Inline (Just valType)) = return [valType]
|
getInstrType Loop { resultType, body } = do
|
||||||
getResultType (TypeIndex typeIdx) = do
|
let blockType = empty ==> resultType
|
||||||
Ctx { types } <- ask
|
t <- withLabel [] $ getExpressionType body
|
||||||
maybeToEither TypeIndexOutOfRange $ results <$> types !? typeIdx
|
if isArrowMatch t blockType
|
||||||
|
then return $ empty ==> resultType
|
||||||
elemTypeToRefType :: ElemType -> ValueType
|
else throwError $ TypeMismatch t blockType
|
||||||
elemTypeToRefType FuncRef = Func
|
getInstrType If { resultType, true, false } = do
|
||||||
elemTypeToRefType ExternRef = Extern
|
let blockType = empty ==> resultType
|
||||||
|
l <- withLabel resultType $ getExpressionType true
|
||||||
getInstrType :: [VType] -> Instruction Natural -> Checker Arrow
|
r <- withLabel resultType $ getExpressionType false
|
||||||
getInstrType _ Unreachable = return $ Any ==> Any
|
if isArrowMatch l blockType
|
||||||
getInstrType _ Nop = return $ empty ==> empty
|
then (if isArrowMatch r blockType then (return $ I32 ==> resultType) else (throwError $ TypeMismatch r blockType))
|
||||||
getInstrType _ Block { blockType, body } = do
|
else throwError $ TypeMismatch l blockType
|
||||||
bt@(Arrow from _) <- getBlockType blockType
|
getInstrType (Br lbl) = do
|
||||||
resultType <- getResultType blockType
|
r <- map Val . maybeToList <$> getLabel lbl
|
||||||
t <- withLabel resultType $ getExpressionTypeWithInput from body
|
|
||||||
if isArrowMatch t bt
|
|
||||||
then return bt
|
|
||||||
else throwError $ TypeMismatch t bt
|
|
||||||
getInstrType _ Loop { blockType, body } = do
|
|
||||||
bt@(Arrow from _) <- getBlockType blockType
|
|
||||||
resultType <- getResultType blockType
|
|
||||||
t <- withLabel (map (\(Val v) -> v) from) $ getExpressionTypeWithInput from body
|
|
||||||
if isArrowMatch t bt
|
|
||||||
then return bt
|
|
||||||
else throwError $ TypeMismatch t bt
|
|
||||||
getInstrType _ If { blockType, true, false } = do
|
|
||||||
bt@(Arrow from _) <- getBlockType blockType
|
|
||||||
resultType <- getResultType blockType
|
|
||||||
l <- withLabel resultType $ getExpressionTypeWithInput from true
|
|
||||||
r <- withLabel resultType $ getExpressionTypeWithInput from false
|
|
||||||
if isArrowMatch l bt
|
|
||||||
then (
|
|
||||||
if isArrowMatch r bt
|
|
||||||
then let Arrow from to = bt in
|
|
||||||
(return $ (from ++ [Val I32]) ==> to)
|
|
||||||
else (throwError $ TypeMismatch r bt)
|
|
||||||
)
|
|
||||||
else throwError $ TypeMismatch l bt
|
|
||||||
getInstrType _ (Br lbl) = do
|
|
||||||
r <- map Val <$> getLabel lbl
|
|
||||||
return $ (Any : r) ==> Any
|
return $ (Any : r) ==> Any
|
||||||
getInstrType _ (BrIf lbl) = do
|
getInstrType (BrIf lbl) = do
|
||||||
r <- map Val <$> getLabel lbl
|
r <- map Val . maybeToList <$> getLabel lbl
|
||||||
return $ (r ++ [Val I32]) ==> r
|
return $ (r ++ [Val I32]) ==> r
|
||||||
getInstrType stack (BrTable lbls lbl) = do
|
getInstrType (BrTable lbls lbl) = do
|
||||||
r <- getLabel lbl
|
r <- getLabel lbl
|
||||||
let returns lbl = do
|
rs <- mapM getLabel lbls
|
||||||
args <- map Val <$> getLabel lbl
|
if all (== r) rs
|
||||||
res <- matchStack stack (Val I32 : reverse args) []
|
then return $ ([Any] ++ (map Val $ maybeToList r) ++ [Val I32]) ==> Any
|
||||||
return (args, res)
|
|
||||||
alternatives <- mapM returns lbls
|
|
||||||
(_, def) <- returns lbl
|
|
||||||
if all (\(args, res) -> res == def && length args == length r) alternatives
|
|
||||||
then return $ ([Any] ++ (map Val r) ++ [Val I32]) ==> Any
|
|
||||||
else throwError ResultTypeDoesntMatch
|
else throwError ResultTypeDoesntMatch
|
||||||
getInstrType _ Return = do
|
getInstrType Return = do
|
||||||
Ctx { returns } <- ask
|
Ctx { returns } <- ask
|
||||||
return $ (Any : (map Val returns)) ==> Any
|
return $ (Any : (map Val $ maybeToList returns)) ==> Any
|
||||||
getInstrType _ (Call fun) = do
|
getInstrType (Call fun) = do
|
||||||
Ctx { funcs } <- ask
|
Ctx { funcs } <- ask
|
||||||
maybeToEither (FunctionIndexOutOfRange fun) $ asArrow <$> funcs !? fun
|
maybeToEither FunctionIndexOutOfRange $ asArrow <$> funcs !? fun
|
||||||
getInstrType _ (CallIndirect tableIdx sign) = do
|
getInstrType (CallIndirect sign) = do
|
||||||
Ctx { types, tables } <- ask
|
Ctx { types, tables } <- ask
|
||||||
if length tables <= fromIntegral tableIdx
|
if length tables < 1
|
||||||
then throwError (TableIndexOutOfRange tableIdx)
|
then throwError TableIndexOutOfRange
|
||||||
else do
|
else do
|
||||||
Arrow from to <- maybeToEither TypeIndexOutOfRange $ asArrow <$> types !? sign
|
Arrow from to <- maybeToEither TypeIndexOutOfRange $ asArrow <$> types !? sign
|
||||||
return $ (from ++ [Val I32]) ==> to
|
return $ (from ++ [Val I32]) ==> to
|
||||||
getInstrType _ Drop = do
|
getInstrType Drop = do
|
||||||
var <- freshVar
|
var <- freshVar
|
||||||
return $ var ==> empty
|
return $ var ==> empty
|
||||||
getInstrType _ (Select Nothing) = do
|
getInstrType Select = do
|
||||||
var <- return NonRefVar
|
|
||||||
return $ [var, var, Val I32] ==> var
|
|
||||||
getInstrType _ (Select (Just vt)) =
|
|
||||||
case vt of
|
|
||||||
[t] -> return $ [t, t, I32] ==> t
|
|
||||||
_ -> throwError InvalidResultArity
|
|
||||||
getInstrType _ (RefNull elType) = do
|
|
||||||
let t = case elType of { FuncRef -> Func; ExternRef -> Extern }
|
|
||||||
return $ empty ==> Val t
|
|
||||||
getInstrType _ RefIsNull = do
|
|
||||||
var <- freshVar
|
var <- freshVar
|
||||||
return $ var ==> Val I32
|
return $ [var, var, Val I32] ==> var
|
||||||
getInstrType _ (RefFunc funIdx) = do
|
getInstrType (GetLocal local) = do
|
||||||
Ctx { funcs, refs } <- ask
|
|
||||||
if fromIntegral funIdx < length funcs
|
|
||||||
then do
|
|
||||||
unless (Set.member funIdx refs) $
|
|
||||||
throwError $ UndeclaredFunctionRef $ fromIntegral funIdx
|
|
||||||
return $ empty ==> Val Func
|
|
||||||
else throwError $ FunctionIndexOutOfRange $ fromIntegral funIdx
|
|
||||||
getInstrType _ (GetLocal local) = do
|
|
||||||
Ctx { locals } <- ask
|
Ctx { locals } <- ask
|
||||||
t <- maybeToEither (LocalIndexOutOfRange local) $ locals !? local
|
t <- maybeToEither LocalIndexOutOfRange $ locals !? local
|
||||||
return $ empty ==> Val t
|
return $ empty ==> Val t
|
||||||
getInstrType _ (SetLocal local) = do
|
getInstrType (SetLocal local) = do
|
||||||
Ctx { locals } <- ask
|
Ctx { locals } <- ask
|
||||||
t <- maybeToEither (LocalIndexOutOfRange local) $ locals !? local
|
t <- maybeToEither LocalIndexOutOfRange $ locals !? local
|
||||||
return $ Val t ==> empty
|
return $ Val t ==> empty
|
||||||
getInstrType _ (TeeLocal local) = do
|
getInstrType (TeeLocal local) = do
|
||||||
Ctx { locals } <- ask
|
Ctx { locals } <- ask
|
||||||
t <- maybeToEither (LocalIndexOutOfRange local) $ locals !? local
|
t <- maybeToEither LocalIndexOutOfRange $ locals !? local
|
||||||
return $ Val t ==> Val t
|
return $ Val t ==> Val t
|
||||||
getInstrType _ (GetGlobal global) = do
|
getInstrType (GetGlobal global) = do
|
||||||
Ctx { globals } <- ask
|
Ctx { globals } <- ask
|
||||||
t <- maybeToEither (GlobalIndexOutOfRange global) $ asType <$> globals !? global
|
t <- maybeToEither GlobalIndexOutOfRange $ asType <$> globals !? global
|
||||||
return $ empty ==> t
|
return $ empty ==> t
|
||||||
getInstrType _ (SetGlobal global) = do
|
getInstrType (SetGlobal global) = do
|
||||||
Ctx { globals } <- ask
|
Ctx { globals } <- ask
|
||||||
t <- maybeToEither (GlobalIndexOutOfRange global) $ asType <$> globals !? global
|
t <- maybeToEither GlobalIndexOutOfRange $ asType <$> globals !? global
|
||||||
shouldBeMut $ globals !! fromIntegral global
|
shouldBeMut $ globals !! fromIntegral global
|
||||||
return $ t ==> empty
|
return $ t ==> empty
|
||||||
getInstrType _ (I32Load memarg) = do
|
getInstrType (I32Load memarg) = do
|
||||||
checkMemoryInstr 4 memarg
|
checkMemoryInstr 4 memarg
|
||||||
return $ I32 ==> I32
|
return $ I32 ==> I32
|
||||||
getInstrType _ (I64Load memarg) = do
|
getInstrType (I64Load memarg) = do
|
||||||
checkMemoryInstr 8 memarg
|
checkMemoryInstr 8 memarg
|
||||||
return $ I32 ==> I64
|
return $ I32 ==> I64
|
||||||
getInstrType _ (F32Load memarg) = do
|
getInstrType (F32Load memarg) = do
|
||||||
checkMemoryInstr 4 memarg
|
checkMemoryInstr 4 memarg
|
||||||
return $ I32 ==> F32
|
return $ I32 ==> F32
|
||||||
getInstrType _ (F64Load memarg) = do
|
getInstrType (F64Load memarg) = do
|
||||||
checkMemoryInstr 8 memarg
|
checkMemoryInstr 8 memarg
|
||||||
return $ I32 ==> F64
|
return $ I32 ==> F64
|
||||||
getInstrType _ (I32Load8S memarg) = do
|
getInstrType (I32Load8S memarg) = do
|
||||||
checkMemoryInstr 1 memarg
|
checkMemoryInstr 1 memarg
|
||||||
return $ I32 ==> I32
|
return $ I32 ==> I32
|
||||||
getInstrType _ (I32Load8U memarg) = do
|
getInstrType (I32Load8U memarg) = do
|
||||||
checkMemoryInstr 1 memarg
|
checkMemoryInstr 1 memarg
|
||||||
return $ I32 ==> I32
|
return $ I32 ==> I32
|
||||||
getInstrType _ (I32Load16S memarg) = do
|
getInstrType (I32Load16S memarg) = do
|
||||||
checkMemoryInstr 2 memarg
|
checkMemoryInstr 2 memarg
|
||||||
return $ I32 ==> I32
|
return $ I32 ==> I32
|
||||||
getInstrType _ (I32Load16U memarg) = do
|
getInstrType (I32Load16U memarg) = do
|
||||||
checkMemoryInstr 2 memarg
|
checkMemoryInstr 2 memarg
|
||||||
return $ I32 ==> I32
|
return $ I32 ==> I32
|
||||||
getInstrType _ (I64Load8S memarg) = do
|
getInstrType (I64Load8S memarg) = do
|
||||||
checkMemoryInstr 1 memarg
|
checkMemoryInstr 1 memarg
|
||||||
return $ I32 ==> I64
|
return $ I32 ==> I64
|
||||||
getInstrType _ (I64Load8U memarg) = do
|
getInstrType (I64Load8U memarg) = do
|
||||||
checkMemoryInstr 1 memarg
|
checkMemoryInstr 1 memarg
|
||||||
return $ I32 ==> I64
|
return $ I32 ==> I64
|
||||||
getInstrType _ (I64Load16S memarg) = do
|
getInstrType (I64Load16S memarg) = do
|
||||||
checkMemoryInstr 2 memarg
|
checkMemoryInstr 2 memarg
|
||||||
return $ I32 ==> I64
|
return $ I32 ==> I64
|
||||||
getInstrType _ (I64Load16U memarg) = do
|
getInstrType (I64Load16U memarg) = do
|
||||||
checkMemoryInstr 2 memarg
|
checkMemoryInstr 2 memarg
|
||||||
return $ I32 ==> I64
|
return $ I32 ==> I64
|
||||||
getInstrType _ (I64Load32S memarg) = do
|
getInstrType (I64Load32S memarg) = do
|
||||||
checkMemoryInstr 4 memarg
|
checkMemoryInstr 4 memarg
|
||||||
return $ I32 ==> I64
|
return $ I32 ==> I64
|
||||||
getInstrType _ (I64Load32U memarg) = do
|
getInstrType (I64Load32U memarg) = do
|
||||||
checkMemoryInstr 4 memarg
|
checkMemoryInstr 8 memarg
|
||||||
return $ I32 ==> I64
|
return $ I32 ==> I64
|
||||||
getInstrType _ (I32Store memarg) = do
|
getInstrType (I32Store memarg) = do
|
||||||
checkMemoryInstr 4 memarg
|
checkMemoryInstr 4 memarg
|
||||||
return $ [I32, I32] ==> empty
|
return $ [I32, I32] ==> empty
|
||||||
getInstrType _ (I64Store memarg) = do
|
getInstrType (I64Store memarg) = do
|
||||||
checkMemoryInstr 8 memarg
|
checkMemoryInstr 8 memarg
|
||||||
return $ [I32, I64] ==> empty
|
return $ [I32, I64] ==> empty
|
||||||
getInstrType _ (F32Store memarg) = do
|
getInstrType (F32Store memarg) = do
|
||||||
checkMemoryInstr 4 memarg
|
checkMemoryInstr 4 memarg
|
||||||
return $ [I32, F32] ==> empty
|
return $ [I32, F32] ==> empty
|
||||||
getInstrType _ (F64Store memarg) = do
|
getInstrType (F64Store memarg) = do
|
||||||
checkMemoryInstr 8 memarg
|
checkMemoryInstr 8 memarg
|
||||||
return $ [I32, F64] ==> empty
|
return $ [I32, F64] ==> empty
|
||||||
getInstrType _ (I32Store8 memarg) = do
|
getInstrType (I32Store8 memarg) = do
|
||||||
checkMemoryInstr 1 memarg
|
checkMemoryInstr 1 memarg
|
||||||
return $ [I32, I32] ==> empty
|
return $ [I32, I32] ==> empty
|
||||||
getInstrType _ (I32Store16 memarg) = do
|
getInstrType (I32Store16 memarg) = do
|
||||||
checkMemoryInstr 2 memarg
|
checkMemoryInstr 2 memarg
|
||||||
return $ [I32, I32] ==> empty
|
return $ [I32, I32] ==> empty
|
||||||
getInstrType _ (I64Store8 memarg) = do
|
getInstrType (I64Store8 memarg) = do
|
||||||
checkMemoryInstr 1 memarg
|
checkMemoryInstr 1 memarg
|
||||||
return $ [I32, I64] ==> empty
|
return $ [I32, I64] ==> empty
|
||||||
getInstrType _ (I64Store16 memarg) = do
|
getInstrType (I64Store16 memarg) = do
|
||||||
checkMemoryInstr 2 memarg
|
checkMemoryInstr 2 memarg
|
||||||
return $ [I32, I64] ==> empty
|
return $ [I32, I64] ==> empty
|
||||||
getInstrType _ (I64Store32 memarg) = do
|
getInstrType (I64Store32 memarg) = do
|
||||||
checkMemoryInstr 4 memarg
|
checkMemoryInstr 4 memarg
|
||||||
return $ [I32, I64] ==> empty
|
return $ [I32, I64] ==> empty
|
||||||
getInstrType _ MemorySize = do
|
getInstrType CurrentMemory = do
|
||||||
Ctx { mems } <- ask
|
Ctx { mems } <- ask
|
||||||
when (length mems < 1) $ throwError (MemoryIndexOutOfRange 0)
|
if length mems < 1 then throwError MemoryIndexOutOfRange else return $ empty ==> I32
|
||||||
return $ empty ==> I32
|
getInstrType GrowMemory = do
|
||||||
getInstrType _ MemoryGrow = do
|
|
||||||
Ctx { mems } <- ask
|
Ctx { mems } <- ask
|
||||||
when (length mems < 1) $ throwError (MemoryIndexOutOfRange 0)
|
if length mems < 1 then throwError MemoryIndexOutOfRange else return $ I32 ==> I32
|
||||||
return $ I32 ==> I32
|
getInstrType (I32Const _) = return $ empty ==> I32
|
||||||
getInstrType _ MemoryFill = do
|
getInstrType (I64Const _) = return $ empty ==> I64
|
||||||
Ctx { mems } <- ask
|
getInstrType (F32Const _) = return $ empty ==> F32
|
||||||
when (length mems < 1) $ throwError (MemoryIndexOutOfRange 0)
|
getInstrType (F64Const _) = return $ empty ==> F64
|
||||||
return $ [I32, I32, I32] ==> empty
|
getInstrType (IUnOp BS32 _) = return $ I32 ==> I32
|
||||||
getInstrType _ MemoryCopy = do
|
getInstrType (IUnOp BS64 _) = return $ I64 ==> I64
|
||||||
Ctx { mems } <- ask
|
getInstrType (IBinOp BS32 _) = return $ [I32, I32] ==> I32
|
||||||
when (length mems < 1) $ throwError (MemoryIndexOutOfRange 0)
|
getInstrType (IBinOp BS64 _) = return $ [I64, I64] ==> I64
|
||||||
return $ [I32, I32, I32] ==> empty
|
getInstrType I32Eqz = return $ I32 ==> I32
|
||||||
getInstrType _ (MemoryInit dataIdx) = do
|
getInstrType I64Eqz = return $ I64 ==> I32
|
||||||
Ctx { mems, datas } <- ask
|
getInstrType (IRelOp BS32 _) = return $ [I32, I32] ==> I32
|
||||||
when (length mems < 1) $ throwError (MemoryIndexOutOfRange 0)
|
getInstrType (IRelOp BS64 _) = return $ [I64, I64] ==> I32
|
||||||
when (length datas <= fromIntegral dataIdx) $ throwError (DataIndexOutOfRange dataIdx)
|
getInstrType (FUnOp BS32 _) = return $ F32 ==> F32
|
||||||
return $ [I32, I32, I32] ==> empty
|
getInstrType (FUnOp BS64 _) = return $ F64 ==> F64
|
||||||
getInstrType _ (DataDrop dataIdx) = do
|
getInstrType (FBinOp BS32 _) = return $ [F32, F32] ==> F32
|
||||||
Ctx { datas } <- ask
|
getInstrType (FBinOp BS64 _) = return $ [F64, F64] ==> F64
|
||||||
when (length datas <= fromIntegral dataIdx) $ throwError (DataIndexOutOfRange dataIdx)
|
getInstrType (FRelOp BS32 _) = return $ [F32, F32] ==> I32
|
||||||
return $ empty ==> empty
|
getInstrType (FRelOp BS64 _) = return $ [F64, F64] ==> I32
|
||||||
getInstrType _ (TableInit tableIdx elemIdx) = do
|
getInstrType I32WrapI64 = return $ I64 ==> I32
|
||||||
Ctx { tables, elems } <- ask
|
getInstrType (ITruncFU BS32 BS32) = return $ F32 ==> I32
|
||||||
when (length tables <= fromIntegral tableIdx) $ throwError (TableIndexOutOfRange tableIdx)
|
getInstrType (ITruncFU BS32 BS64) = return $ F64 ==> I32
|
||||||
when (length elems <= fromIntegral elemIdx) $ throwError (ElemIndexOutOfRange elemIdx)
|
getInstrType (ITruncFU BS64 BS32) = return $ F32 ==> I64
|
||||||
let TableType _ tableType = tables !! fromIntegral tableIdx
|
getInstrType (ITruncFU BS64 BS64) = return $ F64 ==> I64
|
||||||
let elemType = elems !! fromIntegral elemIdx
|
getInstrType (ITruncFS BS32 BS32) = return $ F32 ==> I32
|
||||||
when (elemType /= tableType) $ throwError (RefTypeMismatch tableType elemType)
|
getInstrType (ITruncFS BS32 BS64) = return $ F64 ==> I32
|
||||||
return $ [I32, I32, I32] ==> empty
|
getInstrType (ITruncFS BS64 BS32) = return $ F32 ==> I64
|
||||||
getInstrType _ (TableCopy toIdx fromIdx) = do
|
getInstrType (ITruncFS BS64 BS64) = return $ F64 ==> I64
|
||||||
Ctx { tables } <- ask
|
getInstrType I64ExtendSI32 = return $ I32 ==> I64
|
||||||
let (from, to) = (fromIntegral fromIdx, fromIntegral toIdx)
|
getInstrType I64ExtendUI32 = return $ I32 ==> I64
|
||||||
when (length tables <= from) $ throwError (TableIndexOutOfRange fromIdx)
|
getInstrType (FConvertIU BS32 BS32) = return $ I32 ==> F32
|
||||||
when (length tables <= to) $ throwError (TableIndexOutOfRange toIdx)
|
getInstrType (FConvertIU BS32 BS64) = return $ I64 ==> F32
|
||||||
let TableType _ fromType = tables !! from
|
getInstrType (FConvertIU BS64 BS32) = return $ I32 ==> F64
|
||||||
let TableType _ toType = tables !! to
|
getInstrType (FConvertIU BS64 BS64) = return $ I64 ==> F64
|
||||||
when (fromType /= toType) $ throwError (RefTypeMismatch fromType toType)
|
getInstrType (FConvertIS BS32 BS32) = return $ I32 ==> F32
|
||||||
return $ [I32, I32, I32] ==> empty
|
getInstrType (FConvertIS BS32 BS64) = return $ I64 ==> F32
|
||||||
getInstrType _ (TableFill tableIdx) = do
|
getInstrType (FConvertIS BS64 BS32) = return $ I32 ==> F64
|
||||||
Ctx { tables } <- ask
|
getInstrType (FConvertIS BS64 BS64) = return $ I64 ==> F64
|
||||||
when (length tables <= fromIntegral tableIdx) $ throwError (TableIndexOutOfRange tableIdx)
|
getInstrType F32DemoteF64 = return $ F64 ==> F32
|
||||||
let TableType _ tableType = tables !! fromIntegral tableIdx
|
getInstrType F64PromoteF32 = return $ F32 ==> F64
|
||||||
return $ [I32, elemTypeToRefType tableType, I32] ==> empty
|
getInstrType (IReinterpretF BS32) = return $ F32 ==> I32
|
||||||
getInstrType _ (TableSize tableIdx) = do
|
getInstrType (IReinterpretF BS64) = return $ F64 ==> I64
|
||||||
Ctx { tables } <- ask
|
getInstrType (FReinterpretI BS32) = return $ I32 ==> F32
|
||||||
when (length tables <= fromIntegral tableIdx) $ throwError (TableIndexOutOfRange tableIdx)
|
getInstrType (FReinterpretI BS64) = return $ I64 ==> F64
|
||||||
return $ empty ==> I32
|
|
||||||
getInstrType _ (TableGrow tableIdx) = do
|
|
||||||
Ctx { tables } <- ask
|
|
||||||
when (length tables <= fromIntegral tableIdx) $ throwError (TableIndexOutOfRange tableIdx)
|
|
||||||
let TableType _ tableType = tables !! fromIntegral tableIdx
|
|
||||||
return $ [elemTypeToRefType tableType, I32] ==> I32
|
|
||||||
getInstrType _ (TableGet tableIdx) = do
|
|
||||||
Ctx { tables } <- ask
|
|
||||||
when (length tables <= fromIntegral tableIdx) $ throwError (TableIndexOutOfRange tableIdx)
|
|
||||||
let TableType _ tableType = tables !! fromIntegral tableIdx
|
|
||||||
return $ I32 ==> (elemTypeToRefType tableType)
|
|
||||||
getInstrType _ (TableSet tableIdx) = do
|
|
||||||
Ctx { tables } <- ask
|
|
||||||
when (length tables <= fromIntegral tableIdx) $ throwError (TableIndexOutOfRange tableIdx)
|
|
||||||
let TableType _ tableType = tables !! fromIntegral tableIdx
|
|
||||||
return $ [I32, elemTypeToRefType tableType] ==> empty
|
|
||||||
getInstrType _ (ElemDrop elemIdx) = do
|
|
||||||
Ctx { elems } <- ask
|
|
||||||
when (length elems <= fromIntegral elemIdx) $ throwError (ElemIndexOutOfRange elemIdx)
|
|
||||||
return $ empty ==> empty
|
|
||||||
getInstrType _ (I32Const _) = return $ empty ==> I32
|
|
||||||
getInstrType _ (I64Const _) = return $ empty ==> I64
|
|
||||||
getInstrType _ (F32Const _) = return $ empty ==> F32
|
|
||||||
getInstrType _ (F64Const _) = return $ empty ==> F64
|
|
||||||
getInstrType _ (IUnOp BS32 _) = return $ I32 ==> I32
|
|
||||||
getInstrType _ (IUnOp BS64 _) = return $ I64 ==> I64
|
|
||||||
getInstrType _ (IBinOp BS32 _) = return $ [I32, I32] ==> I32
|
|
||||||
getInstrType _ (IBinOp BS64 _) = return $ [I64, I64] ==> I64
|
|
||||||
getInstrType _ I32Eqz = return $ I32 ==> I32
|
|
||||||
getInstrType _ I64Eqz = return $ I64 ==> I32
|
|
||||||
getInstrType _ (IRelOp BS32 _) = return $ [I32, I32] ==> I32
|
|
||||||
getInstrType _ (IRelOp BS64 _) = return $ [I64, I64] ==> I32
|
|
||||||
getInstrType _ (FUnOp BS32 _) = return $ F32 ==> F32
|
|
||||||
getInstrType _ (FUnOp BS64 _) = return $ F64 ==> F64
|
|
||||||
getInstrType _ (FBinOp BS32 _) = return $ [F32, F32] ==> F32
|
|
||||||
getInstrType _ (FBinOp BS64 _) = return $ [F64, F64] ==> F64
|
|
||||||
getInstrType _ (FRelOp BS32 _) = return $ [F32, F32] ==> I32
|
|
||||||
getInstrType _ (FRelOp BS64 _) = return $ [F64, F64] ==> I32
|
|
||||||
getInstrType _ I32WrapI64 = return $ I64 ==> I32
|
|
||||||
getInstrType _ (ITruncFU BS32 BS32) = return $ F32 ==> I32
|
|
||||||
getInstrType _ (ITruncFU BS32 BS64) = return $ F64 ==> I32
|
|
||||||
getInstrType _ (ITruncFU BS64 BS32) = return $ F32 ==> I64
|
|
||||||
getInstrType _ (ITruncFU BS64 BS64) = return $ F64 ==> I64
|
|
||||||
getInstrType _ (ITruncFS BS32 BS32) = return $ F32 ==> I32
|
|
||||||
getInstrType _ (ITruncFS BS32 BS64) = return $ F64 ==> I32
|
|
||||||
getInstrType _ (ITruncFS BS64 BS32) = return $ F32 ==> I64
|
|
||||||
getInstrType _ (ITruncFS BS64 BS64) = return $ F64 ==> I64
|
|
||||||
getInstrType _ (ITruncSatFU BS32 BS32) = return $ F32 ==> I32
|
|
||||||
getInstrType _ (ITruncSatFU BS32 BS64) = return $ F64 ==> I32
|
|
||||||
getInstrType _ (ITruncSatFU BS64 BS32) = return $ F32 ==> I64
|
|
||||||
getInstrType _ (ITruncSatFU BS64 BS64) = return $ F64 ==> I64
|
|
||||||
getInstrType _ (ITruncSatFS BS32 BS32) = return $ F32 ==> I32
|
|
||||||
getInstrType _ (ITruncSatFS BS32 BS64) = return $ F64 ==> I32
|
|
||||||
getInstrType _ (ITruncSatFS BS64 BS32) = return $ F32 ==> I64
|
|
||||||
getInstrType _ (ITruncSatFS BS64 BS64) = return $ F64 ==> I64
|
|
||||||
getInstrType _ I64ExtendSI32 = return $ I32 ==> I64
|
|
||||||
getInstrType _ I64ExtendUI32 = return $ I32 ==> I64
|
|
||||||
getInstrType _ (FConvertIU BS32 BS32) = return $ I32 ==> F32
|
|
||||||
getInstrType _ (FConvertIU BS32 BS64) = return $ I64 ==> F32
|
|
||||||
getInstrType _ (FConvertIU BS64 BS32) = return $ I32 ==> F64
|
|
||||||
getInstrType _ (FConvertIU BS64 BS64) = return $ I64 ==> F64
|
|
||||||
getInstrType _ (FConvertIS BS32 BS32) = return $ I32 ==> F32
|
|
||||||
getInstrType _ (FConvertIS BS32 BS64) = return $ I64 ==> F32
|
|
||||||
getInstrType _ (FConvertIS BS64 BS32) = return $ I32 ==> F64
|
|
||||||
getInstrType _ (FConvertIS BS64 BS64) = return $ I64 ==> F64
|
|
||||||
getInstrType _ F32DemoteF64 = return $ F64 ==> F32
|
|
||||||
getInstrType _ F64PromoteF32 = return $ F32 ==> F64
|
|
||||||
getInstrType _ (IReinterpretF BS32) = return $ F32 ==> I32
|
|
||||||
getInstrType _ (IReinterpretF BS64) = return $ F64 ==> I64
|
|
||||||
getInstrType _ (FReinterpretI BS32) = return $ I32 ==> F32
|
|
||||||
getInstrType _ (FReinterpretI BS64) = return $ I64 ==> F64
|
|
||||||
|
|
||||||
|
|
||||||
replace :: (Eq a) => a -> a -> [a] -> [a]
|
replace :: (Eq a) => a -> a -> [a] -> [a]
|
||||||
replace _ _ [] = []
|
replace _ _ [] = []
|
||||||
replace x y (v:r) = (if x == v then y else v) : replace x y r
|
replace x y (v:r) = (if x == v then y else v) : replace x y r
|
||||||
|
|
||||||
getExpressionTypeWithInput :: [VType] -> Expression -> Checker Arrow
|
getExpressionType :: Expression -> Checker Arrow
|
||||||
getExpressionTypeWithInput inp = fmap (inp `Arrow`) . foldM go inp
|
getExpressionType = fmap ([] `Arrow`) . foldM go []
|
||||||
where
|
where
|
||||||
go :: [VType] -> Instruction Natural -> Checker [VType]
|
go :: [VType] -> Instruction Natural -> Checker [VType]
|
||||||
go stack instr = do
|
go stack instr = do
|
||||||
(f `Arrow` t) <- getInstrType stack instr
|
(f `Arrow` t) <- getInstrType instr
|
||||||
matchStack stack (reverse f) t
|
matchStack stack (reverse f) t
|
||||||
|
|
||||||
isRef :: ValueType -> Bool
|
|
||||||
isRef (Func) = True
|
|
||||||
isRef (Extern) = True
|
|
||||||
isRef _ = False
|
|
||||||
|
|
||||||
matchStack :: [VType] -> [VType] -> [VType] -> Checker [VType]
|
matchStack :: [VType] -> [VType] -> [VType] -> Checker [VType]
|
||||||
matchStack stack@(Any:_) _arg res = return $ res ++ stack
|
matchStack stack@(Any:_) _arg res = return $ res ++ stack
|
||||||
matchStack (Val v:stack) (Val v':args) res =
|
matchStack (Val v:stack) (Val v':args) res =
|
||||||
@@ -543,31 +393,9 @@ matchStack _ (Any:_) res = return $ res
|
|||||||
matchStack (Val v:stack) (Var:args) res =
|
matchStack (Val v:stack) (Var:args) res =
|
||||||
let subst = replace Var (Val v) in
|
let subst = replace Var (Val v) in
|
||||||
matchStack stack (subst args) (subst res)
|
matchStack stack (subst args) (subst res)
|
||||||
matchStack (Var:stack) (Val v:args) res =
|
|
||||||
let subst = replace Var (Val v) in
|
|
||||||
matchStack stack (subst args) (subst res)
|
|
||||||
matchStack (Val v:stack) (NonRefVar:args) res =
|
|
||||||
let subst = replace NonRefVar (Val v) in
|
|
||||||
if isRef v
|
|
||||||
then throwError $ TypeMismatch (empty ==> empty) (empty ==> empty)
|
|
||||||
else matchStack stack (subst args) (subst res)
|
|
||||||
matchStack (NonRefVar:stack) (Val v:args) res =
|
|
||||||
let subst = replace NonRefVar (Val v) in
|
|
||||||
if isRef v
|
|
||||||
then throwError $ TypeMismatch (empty ==> empty) (empty ==> empty)
|
|
||||||
else matchStack stack (subst args) (subst res)
|
|
||||||
matchStack (Var:stack) (NonRefVar:args) res =
|
|
||||||
let subst = replace NonRefVar NonRefVar in
|
|
||||||
matchStack stack (subst args) (subst res)
|
|
||||||
matchStack (NonRefVar:stack) (Var:args) res =
|
|
||||||
let subst = replace Var NonRefVar in
|
|
||||||
matchStack stack (subst args) (subst res)
|
|
||||||
matchStack stack [] res = return $ res ++ stack
|
matchStack stack [] res = return $ res ++ stack
|
||||||
matchStack [] args res = throwError $ TypeMismatch ((reverse args) `Arrow` res) ([] `Arrow` [])
|
matchStack [] args res = throwError $ TypeMismatch ((reverse args) `Arrow` res) ([] `Arrow` [])
|
||||||
matchStack st args res = error $ "inconsistent checker state: " ++ show (st, args, res)
|
matchStack _ _ _ = error "inconsistent checker state"
|
||||||
|
|
||||||
getExpressionType :: Expression -> Checker Arrow
|
|
||||||
getExpressionType = getExpressionTypeWithInput []
|
|
||||||
|
|
||||||
isConstExpression :: Expression -> Checker ()
|
isConstExpression :: Expression -> Checker ()
|
||||||
isConstExpression [] = return ()
|
isConstExpression [] = return ()
|
||||||
@@ -575,12 +403,10 @@ isConstExpression ((I32Const _):rest) = isConstExpression rest
|
|||||||
isConstExpression ((I64Const _):rest) = isConstExpression rest
|
isConstExpression ((I64Const _):rest) = isConstExpression rest
|
||||||
isConstExpression ((F32Const _):rest) = isConstExpression rest
|
isConstExpression ((F32Const _):rest) = isConstExpression rest
|
||||||
isConstExpression ((F64Const _):rest) = isConstExpression rest
|
isConstExpression ((F64Const _):rest) = isConstExpression rest
|
||||||
isConstExpression ((RefNull _):rest) = isConstExpression rest
|
|
||||||
isConstExpression ((RefFunc _):rest) = isConstExpression rest
|
|
||||||
isConstExpression ((GetGlobal idx):rest) = do
|
isConstExpression ((GetGlobal idx):rest) = do
|
||||||
Ctx {globals, importedGlobals} <- ask
|
Ctx {globals, importedGlobals} <- ask
|
||||||
if importedGlobals <= idx
|
if importedGlobals <= idx
|
||||||
then throwError (GlobalIndexOutOfRange idx)
|
then throwError GlobalIndexOutOfRange
|
||||||
else return ()
|
else return ()
|
||||||
case globals !! fromIntegral idx of
|
case globals !! fromIntegral idx of
|
||||||
Const _ -> isConstExpression rest
|
Const _ -> isConstExpression rest
|
||||||
@@ -595,9 +421,8 @@ getFuncTypes Module {types, functions, imports} =
|
|||||||
getFuncType (Import _ _ (ImportFunc typeIdx)) = Just $ types !! (fromIntegral typeIdx)
|
getFuncType (Import _ _ (ImportFunc typeIdx)) = Just $ types !! (fromIntegral typeIdx)
|
||||||
getFuncType _ = Nothing
|
getFuncType _ = Nothing
|
||||||
|
|
||||||
ctxFromModule :: [ValueType] -> [[ValueType]] -> [ValueType] -> Module -> Ctx
|
ctxFromModule :: [ValueType] -> [Maybe ValueType] -> Maybe ValueType -> Module -> Ctx
|
||||||
ctxFromModule locals labels returns m =
|
ctxFromModule locals labels returns m@Module {types, tables, mems, globals, imports} =
|
||||||
let Module {types, tables, mems, globals, imports, elems, exports, datas} = m in
|
|
||||||
let tableImports = catMaybes $ map getTableType imports in
|
let tableImports = catMaybes $ map getTableType imports in
|
||||||
let memsImports = catMaybes $ map getMemType imports in
|
let memsImports = catMaybes $ map getMemType imports in
|
||||||
let globalImports = catMaybes $ map getGlobalType imports in
|
let globalImports = catMaybes $ map getGlobalType imports in
|
||||||
@@ -605,17 +430,12 @@ ctxFromModule locals labels returns m =
|
|||||||
types,
|
types,
|
||||||
funcs = getFuncTypes m,
|
funcs = getFuncTypes m,
|
||||||
tables = tableImports ++ map (\(Table t) -> t) tables,
|
tables = tableImports ++ map (\(Table t) -> t) tables,
|
||||||
elems = map elemType elems,
|
|
||||||
datas = map dataMode datas,
|
|
||||||
mems = memsImports ++ map (\(Memory l) -> l) mems,
|
mems = memsImports ++ map (\(Memory l) -> l) mems,
|
||||||
globals = globalImports ++ map (\(Global g _) -> g) globals,
|
globals = globalImports ++ map (\(Global g _) -> g) globals,
|
||||||
locals,
|
locals,
|
||||||
labels,
|
labels,
|
||||||
returns,
|
returns,
|
||||||
importedGlobals = fromIntegral $ length globalImports,
|
importedGlobals = fromIntegral $ length globalImports
|
||||||
refs = Set.unions $ map getElemRefs elems
|
|
||||||
++ map getGlobalRefs globals
|
|
||||||
++ map getExportRefs exports
|
|
||||||
}
|
}
|
||||||
where
|
where
|
||||||
getTableType (Import _ _ (ImportTable tableType)) = Just tableType
|
getTableType (Import _ _ (ImportTable tableType)) = Just tableType
|
||||||
@@ -627,30 +447,23 @@ ctxFromModule locals labels returns m =
|
|||||||
getGlobalType (Import _ _ (ImportGlobal gl)) = Just gl
|
getGlobalType (Import _ _ (ImportGlobal gl)) = Just gl
|
||||||
getGlobalType _ = Nothing
|
getGlobalType _ = Nothing
|
||||||
|
|
||||||
getElemRefs ElemSegment{ elemType = FuncRef, elements} =
|
|
||||||
foldl extractRef Set.empty elements
|
|
||||||
where
|
|
||||||
extractRef refs [RefFunc idx] = Set.insert idx refs
|
|
||||||
extractRef refs _ = refs
|
|
||||||
getElemRefs _ = Set.empty
|
|
||||||
|
|
||||||
getGlobalRefs Global {initializer = [RefFunc idx]} = Set.singleton idx
|
|
||||||
getGlobalRefs _ = Set.empty
|
|
||||||
|
|
||||||
getExportRefs Export {desc = ExportFunc idx} = Set.singleton idx
|
|
||||||
getExportRefs _ = Set.empty
|
|
||||||
|
|
||||||
isFunctionValid :: Function -> Validator
|
isFunctionValid :: Function -> Validator
|
||||||
isFunctionValid Function {funcType, localTypes = locals, body} mod@Module {types} =
|
isFunctionValid Function {funcType, localTypes = locals, body} mod@Module {types} =
|
||||||
if fromIntegral funcType < length types
|
if fromIntegral funcType < length types
|
||||||
then do
|
then
|
||||||
let FuncType params results = types !! fromIntegral funcType
|
let FuncType params results = types !! fromIntegral funcType in
|
||||||
let ctx = ctxFromModule (params ++ locals) [results] results mod
|
if length results > 1
|
||||||
arr <- runChecker ctx $ getExpressionType body
|
then InvalidResultArity
|
||||||
if isArrowMatch arr (empty ==> (reverse results))
|
else
|
||||||
then return ()
|
let r = safeHead results in
|
||||||
else Left $ TypeMismatch arr (empty ==> (reverse results))
|
let ctx = ctxFromModule (params ++ locals) [r] r mod in
|
||||||
else Left TypeIndexOutOfRange
|
case runChecker ctx $ getExpressionType body of
|
||||||
|
Left err -> err
|
||||||
|
Right arr ->
|
||||||
|
if isArrowMatch arr (empty ==> results)
|
||||||
|
then Valid
|
||||||
|
else TypeMismatch arr (empty ==> results)
|
||||||
|
else TypeIndexOutOfRange
|
||||||
|
|
||||||
functionsShouldBeValid :: Validator
|
functionsShouldBeValid :: Validator
|
||||||
functionsShouldBeValid mod@Module {functions} =
|
functionsShouldBeValid mod@Module {functions} =
|
||||||
@@ -660,13 +473,16 @@ tablesShouldBeValid :: Validator
|
|||||||
tablesShouldBeValid Module { imports, tables } =
|
tablesShouldBeValid Module { imports, tables } =
|
||||||
let tableImports = filter isTableImport imports in
|
let tableImports = filter isTableImport imports in
|
||||||
let res = foldMap (\Import { desc = ImportTable t } -> isValidTableType t) tableImports in
|
let res = foldMap (\Import { desc = ImportTable t } -> isValidTableType t) tableImports in
|
||||||
foldl' (\r (Table t) -> r <> isValidTableType t) res tables
|
let res' = foldl' (\r (Table t) -> r <> isValidTableType t) res tables in
|
||||||
|
if length tableImports + length tables <= 1
|
||||||
|
then res'
|
||||||
|
else MoreThanOneTable
|
||||||
where
|
where
|
||||||
isValidTableType :: TableType -> ValidationResult
|
isValidTableType :: TableType -> ValidationResult
|
||||||
isValidTableType (TableType (Limit min max) _) =
|
isValidTableType (TableType (Limit min max) _) =
|
||||||
if min <= fromMaybe min max
|
if min <= fromMaybe min max
|
||||||
then return ()
|
then Valid
|
||||||
else Left InvalidTableType
|
else InvalidTableType
|
||||||
|
|
||||||
memoryShouldBeValid :: Validator
|
memoryShouldBeValid :: Validator
|
||||||
memoryShouldBeValid Module { imports, mems } =
|
memoryShouldBeValid Module { imports, mems } =
|
||||||
@@ -675,17 +491,17 @@ memoryShouldBeValid Module { imports, mems } =
|
|||||||
let res' = foldl' (\r (Memory l) -> r <> isValidLimit l) res mems in
|
let res' = foldl' (\r (Memory l) -> r <> isValidLimit l) res mems in
|
||||||
if length memImports + length mems <= 1
|
if length memImports + length mems <= 1
|
||||||
then res'
|
then res'
|
||||||
else Left MoreThanOneMemory
|
else MoreThanOneMemory
|
||||||
where
|
where
|
||||||
isValidLimit :: Limit -> ValidationResult
|
isValidLimit :: Limit -> ValidationResult
|
||||||
isValidLimit (Limit min max) =
|
isValidLimit (Limit min max) =
|
||||||
let minMax = if min <= fromMaybe min max then return () else Left MinMoreThanMaxInMemoryLimit in
|
let minMax = if min <= fromMaybe min max then Valid else MinMoreThanMaxInMemoryLimit in
|
||||||
let maxLim = if fromMaybe min max <= 65536 then return () else Left MemoryLimitExceeded in
|
let maxLim = if fromMaybe min max <= 65536 then Valid else MemoryLimitExceeded in
|
||||||
minMax <> maxLim
|
minMax <> maxLim
|
||||||
|
|
||||||
globalsShouldBeValid :: Validator
|
globalsShouldBeValid :: Validator
|
||||||
globalsShouldBeValid m@Module { imports, globals } =
|
globalsShouldBeValid m@Module { imports, globals } =
|
||||||
let ctx = ctxFromModule [] [] [] m in
|
let ctx = ctxFromModule [] [] Nothing m in
|
||||||
foldMap (isGlobalValid ctx) globals
|
foldMap (isGlobalValid ctx) globals
|
||||||
where
|
where
|
||||||
getGlobalType :: GlobalType -> ValueType
|
getGlobalType :: GlobalType -> ValueType
|
||||||
@@ -693,70 +509,73 @@ globalsShouldBeValid m@Module { imports, globals } =
|
|||||||
getGlobalType (Mut vt) = vt
|
getGlobalType (Mut vt) = vt
|
||||||
|
|
||||||
isGlobalValid :: Ctx -> Global -> ValidationResult
|
isGlobalValid :: Ctx -> Global -> ValidationResult
|
||||||
isGlobalValid ctx (Global gt init) = runChecker ctx $ do
|
isGlobalValid ctx (Global gt init) =
|
||||||
|
let check = runChecker ctx $ do
|
||||||
isConstExpression init
|
isConstExpression init
|
||||||
t <- getExpressionType init
|
t <- getExpressionType init
|
||||||
let expected = empty ==> getGlobalType gt
|
let expected = empty ==> getGlobalType gt
|
||||||
if isArrowMatch expected t then return () else throwError $ TypeMismatch t expected
|
return $ if isArrowMatch expected t then Valid else TypeMismatch t expected
|
||||||
|
in
|
||||||
|
case check of
|
||||||
|
Left err -> err
|
||||||
|
Right res -> res
|
||||||
|
|
||||||
elemsShouldBeValid :: Validator
|
elemsShouldBeValid :: Validator
|
||||||
elemsShouldBeValid m@Module { elems, functions, tables, imports } =
|
elemsShouldBeValid m@Module { elems, functions, tables, imports } =
|
||||||
let ctx = ctxFromModule [] [] [] m in
|
let ctx = ctxFromModule [] [] Nothing m in
|
||||||
foldMap (isElemValid ctx) elems
|
foldMap (isElemValid ctx) elems
|
||||||
where
|
where
|
||||||
isElemValid :: Ctx -> ElemSegment -> ValidationResult
|
isElemValid :: Ctx -> ElemSegment -> ValidationResult
|
||||||
isElemValid ctx (ElemSegment elemType mode elements) = do
|
isElemValid ctx (ElemSegment tableIdx offset funs) =
|
||||||
unless (elemType == FuncRef)
|
|
||||||
$ throwError $ RefTypeMismatch FuncRef elemType
|
|
||||||
forM_ elements $ \elem -> runChecker ctx $ do
|
|
||||||
arr <- getExpressionType elem
|
|
||||||
isConstExpression elem
|
|
||||||
unless (isValidRef elemType arr)
|
|
||||||
$ throwError $ RefTypeMismatch elemType elemType
|
|
||||||
case mode of
|
|
||||||
Active tableIdx offset -> runChecker ctx $ do
|
|
||||||
isConstExpression offset
|
|
||||||
t <- getExpressionType offset
|
|
||||||
unless (isArrowMatch (empty ==> I32) t) $ do
|
|
||||||
throwError $ TypeMismatch t (empty ==> I32)
|
|
||||||
let tableImports = filter isTableImport imports
|
|
||||||
when (tableIdx >= fromIntegral (length tableImports + length tables)) $ do
|
|
||||||
throwError $ TableIndexOutOfRange tableIdx
|
|
||||||
_ -> return ()
|
|
||||||
|
|
||||||
isValidRef :: ElemType -> Arrow -> Bool
|
|
||||||
isValidRef FuncRef arr | arr == (empty ==> Func) = True
|
|
||||||
isValidRef ExternRef arr | arr == (empty ==> Extern) = True
|
|
||||||
isValidRef _ _ = False
|
|
||||||
|
|
||||||
datasShouldBeValid :: Validator
|
|
||||||
datasShouldBeValid m@Module { datas, mems, imports } =
|
|
||||||
let ctx = ctxFromModule [] [] [] m in
|
|
||||||
foldMap (isDataValid ctx) datas
|
|
||||||
where
|
|
||||||
isDataValid :: Ctx -> DataSegment -> ValidationResult
|
|
||||||
isDataValid ctx (DataSegment (ActiveData memIdx offset) _) =
|
|
||||||
let check = runChecker ctx $ do
|
let check = runChecker ctx $ do
|
||||||
isConstExpression offset
|
isConstExpression offset
|
||||||
t <- getExpressionType offset
|
t <- getExpressionType offset
|
||||||
if isArrowMatch (empty ==> I32) t
|
return $ if isArrowMatch (empty ==> I32) t then Valid else TypeMismatch t (empty ==> I32)
|
||||||
then return ()
|
in
|
||||||
else throwError $ TypeMismatch t (empty ==> I32)
|
let isIniterValid = case check of
|
||||||
|
Left err -> err
|
||||||
|
Right res -> res
|
||||||
|
in
|
||||||
|
let tableImports = filter isTableImport imports in
|
||||||
|
let isTableIndexValid =
|
||||||
|
if tableIdx < (fromIntegral $ length tableImports + length tables)
|
||||||
|
then Valid
|
||||||
|
else TableIndexOutOfRange
|
||||||
|
in
|
||||||
|
let funImports = filter isFuncImport imports in
|
||||||
|
let funsLength = fromIntegral $ length functions + length funImports in
|
||||||
|
let isFunsValid = foldMap (\i -> if i < funsLength then Valid else FunctionIndexOutOfRange) funs in
|
||||||
|
isIniterValid <> isFunsValid <> isTableIndexValid
|
||||||
|
|
||||||
|
datasShouldBeValid :: Validator
|
||||||
|
datasShouldBeValid m@Module { datas, mems, imports } =
|
||||||
|
let ctx = ctxFromModule [] [] Nothing m in
|
||||||
|
foldMap (isDataValid ctx) datas
|
||||||
|
where
|
||||||
|
isDataValid :: Ctx -> DataSegment -> ValidationResult
|
||||||
|
isDataValid ctx (DataSegment memIdx offset _) =
|
||||||
|
let check = runChecker ctx $ do
|
||||||
|
isConstExpression offset
|
||||||
|
t <- getExpressionType offset
|
||||||
|
return $ if isArrowMatch (empty ==> I32) t then Valid else TypeMismatch t (empty ==> I32)
|
||||||
|
in
|
||||||
|
let isOffsetValid = case check of
|
||||||
|
Left err -> err
|
||||||
|
Right res -> res
|
||||||
in
|
in
|
||||||
let memImports = filter isMemImport imports in
|
let memImports = filter isMemImport imports in
|
||||||
if memIdx < (fromIntegral $ length memImports + length mems)
|
if memIdx < (fromIntegral $ length memImports + length mems)
|
||||||
then check
|
then isOffsetValid
|
||||||
else Left (MemoryIndexOutOfRange memIdx)
|
else MemoryIndexOutOfRange
|
||||||
isDataValid ctx (DataSegment PassiveData _) = return ()
|
|
||||||
|
|
||||||
startShouldBeValid :: Validator
|
startShouldBeValid :: Validator
|
||||||
startShouldBeValid Module { start = Nothing } = return ()
|
startShouldBeValid Module { start = Nothing } = Valid
|
||||||
startShouldBeValid m@Module { start = Just (StartFunction idx) } =
|
startShouldBeValid m@Module { start = Just (StartFunction idx) } =
|
||||||
let types = getFuncTypes m in
|
let types = getFuncTypes m in
|
||||||
let i = fromIntegral idx in
|
let i = fromIntegral idx in
|
||||||
if length types > i
|
if length types > i
|
||||||
then if FuncType [] [] == types !! i then return () else Left InvalidStartFunctionType
|
then if FuncType [] [] == types !! i then Valid else InvalidStartFunctionType
|
||||||
else Left $ FunctionIndexOutOfRange $ fromIntegral i
|
else FunctionIndexOutOfRange
|
||||||
|
|
||||||
exportsShouldBeValid :: Validator
|
exportsShouldBeValid :: Validator
|
||||||
exportsShouldBeValid Module { exports, imports, functions, mems, tables, globals } =
|
exportsShouldBeValid Module { exports, imports, functions, mems, tables, globals } =
|
||||||
@@ -769,21 +588,29 @@ exportsShouldBeValid Module { exports, imports, functions, mems, tables, globals
|
|||||||
|
|
||||||
isExportValid :: Export -> ValidationResult
|
isExportValid :: Export -> ValidationResult
|
||||||
isExportValid (Export _ (ExportFunc funIdx)) =
|
isExportValid (Export _ (ExportFunc funIdx)) =
|
||||||
if fromIntegral funIdx < length funcImports + length functions then return () else Left (FunctionIndexOutOfRange funIdx)
|
if fromIntegral funIdx < length funcImports + length functions then Valid else FunctionIndexOutOfRange
|
||||||
isExportValid (Export _ (ExportTable tableIdx)) =
|
isExportValid (Export _ (ExportTable tableIdx)) =
|
||||||
if fromIntegral tableIdx < length tableImports + length tables then return () else Left (TableIndexOutOfRange tableIdx)
|
if fromIntegral tableIdx < length tableImports + length tables then Valid else TableIndexOutOfRange
|
||||||
isExportValid (Export _ (ExportMemory memIdx)) =
|
isExportValid (Export _ (ExportMemory memIdx)) =
|
||||||
if fromIntegral memIdx < length memImports + length mems then return () else Left (MemoryIndexOutOfRange memIdx)
|
if fromIntegral memIdx < length memImports + length mems then Valid else MemoryIndexOutOfRange
|
||||||
isExportValid (Export _ (ExportGlobal globalIdx)) =
|
isExportValid (Export _ (ExportGlobal globalIdx)) =
|
||||||
if fromIntegral globalIdx < length globalImports + length globals
|
if fromIntegral globalIdx < length globalImports + length globals
|
||||||
then return ()
|
then (
|
||||||
else Left (GlobalIndexOutOfRange globalIdx)
|
if fromIntegral globalIdx >= length globalImports
|
||||||
|
then (
|
||||||
|
case globals !! (fromIntegral globalIdx - length globalImports) of
|
||||||
|
(Global (Mut _) _) -> ExportedGlobalIsNotConst
|
||||||
|
_ -> Valid
|
||||||
|
)
|
||||||
|
else Valid
|
||||||
|
)
|
||||||
|
else GlobalIndexOutOfRange
|
||||||
|
|
||||||
areExportNamesUnique :: ValidationResult
|
areExportNamesUnique :: ValidationResult
|
||||||
areExportNamesUnique =
|
areExportNamesUnique =
|
||||||
case foldl' go (Set.empty, []) exports of
|
case foldl' go (Set.empty, []) exports of
|
||||||
(_, []) -> return ()
|
(_, []) -> Valid
|
||||||
(_, dup) -> Left $ DuplicatedExportNames dup
|
(_, dup) -> DuplicatedExportNames dup
|
||||||
where
|
where
|
||||||
go :: (Set.Set TL.Text, [String]) -> Export -> (Set.Set TL.Text, [String])
|
go :: (Set.Set TL.Text, [String]) -> Export -> (Set.Set TL.Text, [String])
|
||||||
go (set, dup) (Export name _) =
|
go (set, dup) (Export name _) =
|
||||||
@@ -796,21 +623,24 @@ importsShouldBeValid Module { imports, types } =
|
|||||||
foldMap isImportValid imports
|
foldMap isImportValid imports
|
||||||
where
|
where
|
||||||
isImportValid :: Import -> ValidationResult
|
isImportValid :: Import -> ValidationResult
|
||||||
isImportValid (Import _ _ (ImportFunc typeIdx)) =
|
isImportValid (Import _ _ (ImportFunc typeIdx)) = if fromIntegral typeIdx < length types then Valid else TypeIndexOutOfRange
|
||||||
if fromIntegral typeIdx < length types
|
isImportValid (Import _ _ (ImportTable _)) = Valid -- checked in tables section
|
||||||
then return ()
|
isImportValid (Import _ _ (ImportMemory _)) = Valid -- checked in mems section
|
||||||
else Left TypeIndexOutOfRange
|
isImportValid (Import _ _ (ImportGlobal (Const _))) = Valid
|
||||||
isImportValid (Import _ _ (ImportTable _)) = return () -- checked in tables section
|
isImportValid (Import _ _ (ImportGlobal (Mut _))) = ImportedGlobalIsNotConst
|
||||||
isImportValid (Import _ _ (ImportMemory _)) = return () -- checked in mems section
|
|
||||||
isImportValid (Import _ _ (ImportGlobal _)) = return ()
|
|
||||||
|
|
||||||
newtype ValidModule = ValidModule { getModule :: Module } deriving (Show, Eq)
|
typesShouldBeValid :: Validator
|
||||||
|
typesShouldBeValid Module { types } = foldMap isTypeValid types
|
||||||
|
where
|
||||||
|
isTypeValid :: FuncType -> ValidationResult
|
||||||
|
isTypeValid FuncType { results } = if length results <= 1 then Valid else InvalidResultArity
|
||||||
|
|
||||||
validate :: Module -> Either ValidationError ValidModule
|
validate :: Validator
|
||||||
validate mod = const (ValidModule mod) <$> foldMap ($ mod) validators
|
validate mod = foldMap ($ mod) validators
|
||||||
where
|
where
|
||||||
validators :: [Validator]
|
validators :: [Validator]
|
||||||
validators = [
|
validators = [
|
||||||
|
typesShouldBeValid,
|
||||||
functionsShouldBeValid,
|
functionsShouldBeValid,
|
||||||
tablesShouldBeValid,
|
tablesShouldBeValid,
|
||||||
memoryShouldBeValid,
|
memoryShouldBeValid,
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
resolver: lts-20.23
|
resolver: lts-10.0
|
||||||
packages:
|
packages:
|
||||||
- '.'
|
- '.'
|
||||||
extra-deps: []
|
extra-deps: []
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
# This file was autogenerated by Stack.
|
|
||||||
# You should not edit this file by hand.
|
|
||||||
# For more information, please see the documentation at:
|
|
||||||
# https://docs.haskellstack.org/en/stable/lock_files
|
|
||||||
|
|
||||||
packages: []
|
|
||||||
snapshots:
|
|
||||||
- completed:
|
|
||||||
sha256: 4c972e067bae16b95961dbfdd12e07f1ee6c8fffabbfa05c3d65100b03f548b7
|
|
||||||
size: 650253
|
|
||||||
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/20/23.yaml
|
|
||||||
original: lts-20.23
|
|
||||||
+23
-11
@@ -10,22 +10,34 @@ import qualified System.Directory as Directory
|
|||||||
|
|
||||||
import qualified Data.ByteString.Lazy as LBS
|
import qualified Data.ByteString.Lazy as LBS
|
||||||
|
|
||||||
import qualified Language.Wasm as Wasm
|
import qualified Language.Wasm.Lexer as Lexer
|
||||||
|
import qualified Language.Wasm.Parser as Parser
|
||||||
|
import qualified Language.Wasm.Structure as Structure
|
||||||
|
import qualified Language.Wasm.Binary as Binary
|
||||||
|
import qualified Language.Wasm.Validate as Validate
|
||||||
|
import qualified Language.Wasm.Interpreter as Interpreter
|
||||||
import qualified Language.Wasm.Script as Script
|
import qualified Language.Wasm.Script as Script
|
||||||
import qualified Data.List as List
|
|
||||||
|
import qualified Debug.Trace as Debug
|
||||||
|
|
||||||
|
isRight :: (Show b) => Either a b -> Bool
|
||||||
|
isRight (Right x) = x `seq` True
|
||||||
|
isRight _ = False
|
||||||
|
|
||||||
|
compile :: String -> IO ()
|
||||||
|
compile file = do
|
||||||
|
content <- LBS.readFile $ "tests/samples/" ++ file
|
||||||
|
let Right mod = Lexer.scanner content >>= Parser.parseModule
|
||||||
|
LBS.writeFile ("tests/runnable/" ++ file) $ Binary.dumpModuleLazy mod
|
||||||
|
-- to run: python -m SimpleHTTPServer 8081 && open http://localhost:8081/tests/runnable
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = do
|
main = do
|
||||||
files <-
|
files <- Directory.listDirectory "tests/samples"
|
||||||
filter (not . List.isPrefixOf "simd") . filter (List.isSuffixOf ".wast")
|
-- let files = ["address.wast"]
|
||||||
<$> Directory.listDirectory "tests/spec"
|
|
||||||
-- let files = ["bulk.wast"]
|
|
||||||
scriptTestCases <- (`mapM` files) $ \file -> do
|
scriptTestCases <- (`mapM` files) $ \file -> do
|
||||||
test <- LBS.readFile ("tests/spec/" ++ file)
|
content <- LBS.readFile $ "tests/samples/" ++ file
|
||||||
|
let Right script = Lexer.scanner content >>= Parser.parseScript
|
||||||
return $ testCase file $ do
|
return $ testCase file $ do
|
||||||
case Wasm.parseScript test of
|
|
||||||
Right script ->
|
|
||||||
Script.runScript (\msg assert -> assertFailure ("Failed assert: " ++ msg ++ ". Assert " ++ show assert)) script
|
Script.runScript (\msg assert -> assertFailure ("Failed assert: " ++ msg ++ ". Assert " ++ show assert)) script
|
||||||
Left error ->
|
|
||||||
assertFailure $ "Failed to parse with error: " ++ show error
|
|
||||||
defaultMain $ testGroup "Wasm Core Test Suit" scriptTestCases
|
defaultMain $ testGroup "Wasm Core Test Suit" scriptTestCases
|
||||||
|
|||||||
@@ -0,0 +1,103 @@
|
|||||||
|
(module
|
||||||
|
(memory 1)
|
||||||
|
(data (i32.const 0) "abcdefghijklmnopqrstuvwxyz")
|
||||||
|
|
||||||
|
(func (export "good1") (param $i i32) (result i32)
|
||||||
|
(i32.load8_u offset=0 (get_local $i)) ;; 97 'a'
|
||||||
|
)
|
||||||
|
(func (export "good2") (param $i i32) (result i32)
|
||||||
|
(i32.load8_u offset=1 (get_local $i)) ;; 98 'b'
|
||||||
|
)
|
||||||
|
(func (export "good3") (param $i i32) (result i32)
|
||||||
|
(i32.load8_u offset=2 (get_local $i)) ;; 99 'c'
|
||||||
|
)
|
||||||
|
(func (export "good4") (param $i i32) (result i32)
|
||||||
|
(i32.load8_u offset=25 (get_local $i)) ;; 122 'z'
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "good5") (param $i i32) (result i32)
|
||||||
|
(i32.load16_u offset=0 (get_local $i)) ;; 25185 'ab'
|
||||||
|
)
|
||||||
|
(func (export "good6") (param $i i32) (result i32)
|
||||||
|
(i32.load16_u align=1 (get_local $i)) ;; 25185 'ab'
|
||||||
|
)
|
||||||
|
(func (export "good7") (param $i i32) (result i32)
|
||||||
|
(i32.load16_u offset=1 align=1 (get_local $i)) ;; 25442 'bc'
|
||||||
|
)
|
||||||
|
(func (export "good8") (param $i i32) (result i32)
|
||||||
|
(i32.load16_u offset=2 (get_local $i)) ;; 25699 'cd'
|
||||||
|
)
|
||||||
|
(func (export "good9") (param $i i32) (result i32)
|
||||||
|
(i32.load16_u offset=25 align=1 (get_local $i)) ;; 122 'z\0'
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "good10") (param $i i32) (result i32)
|
||||||
|
(i32.load offset=0 (get_local $i)) ;; 1684234849 'abcd'
|
||||||
|
)
|
||||||
|
(func (export "good11") (param $i i32) (result i32)
|
||||||
|
(i32.load offset=1 align=1 (get_local $i)) ;; 1701077858 'bcde'
|
||||||
|
)
|
||||||
|
(func (export "good12") (param $i i32) (result i32)
|
||||||
|
(i32.load offset=2 align=2 (get_local $i)) ;; 1717920867 'cdef'
|
||||||
|
)
|
||||||
|
(func (export "good13") (param $i i32) (result i32)
|
||||||
|
(i32.load offset=25 align=1 (get_local $i)) ;; 122 'z\0\0\0'
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "bad") (param $i i32)
|
||||||
|
(drop (i32.load offset=4294967295 (get_local $i)))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke "good1" (i32.const 0)) (i32.const 97))
|
||||||
|
(assert_return (invoke "good2" (i32.const 0)) (i32.const 98))
|
||||||
|
(assert_return (invoke "good3" (i32.const 0)) (i32.const 99))
|
||||||
|
(assert_return (invoke "good4" (i32.const 0)) (i32.const 122))
|
||||||
|
(assert_return (invoke "good5" (i32.const 0)) (i32.const 25185))
|
||||||
|
(assert_return (invoke "good6" (i32.const 0)) (i32.const 25185))
|
||||||
|
(assert_return (invoke "good7" (i32.const 0)) (i32.const 25442))
|
||||||
|
(assert_return (invoke "good8" (i32.const 0)) (i32.const 25699))
|
||||||
|
(assert_return (invoke "good9" (i32.const 0)) (i32.const 122))
|
||||||
|
(assert_return (invoke "good10" (i32.const 0)) (i32.const 1684234849))
|
||||||
|
(assert_return (invoke "good11" (i32.const 0)) (i32.const 1701077858))
|
||||||
|
(assert_return (invoke "good12" (i32.const 0)) (i32.const 1717920867))
|
||||||
|
(assert_return (invoke "good13" (i32.const 0)) (i32.const 122))
|
||||||
|
|
||||||
|
(assert_return (invoke "good1" (i32.const 65507)) (i32.const 0))
|
||||||
|
(assert_return (invoke "good2" (i32.const 65507)) (i32.const 0))
|
||||||
|
(assert_return (invoke "good3" (i32.const 65507)) (i32.const 0))
|
||||||
|
(assert_return (invoke "good4" (i32.const 65507)) (i32.const 0))
|
||||||
|
(assert_return (invoke "good5" (i32.const 65507)) (i32.const 0))
|
||||||
|
(assert_return (invoke "good6" (i32.const 65507)) (i32.const 0))
|
||||||
|
(assert_return (invoke "good7" (i32.const 65507)) (i32.const 0))
|
||||||
|
(assert_return (invoke "good8" (i32.const 65507)) (i32.const 0))
|
||||||
|
(assert_return (invoke "good9" (i32.const 65507)) (i32.const 0))
|
||||||
|
(assert_return (invoke "good10" (i32.const 65507)) (i32.const 0))
|
||||||
|
(assert_return (invoke "good11" (i32.const 65507)) (i32.const 0))
|
||||||
|
(assert_return (invoke "good12" (i32.const 65507)) (i32.const 0))
|
||||||
|
(assert_return (invoke "good13" (i32.const 65507)) (i32.const 0))
|
||||||
|
|
||||||
|
(assert_return (invoke "good1" (i32.const 65508)) (i32.const 0))
|
||||||
|
(assert_return (invoke "good2" (i32.const 65508)) (i32.const 0))
|
||||||
|
(assert_return (invoke "good3" (i32.const 65508)) (i32.const 0))
|
||||||
|
(assert_return (invoke "good4" (i32.const 65508)) (i32.const 0))
|
||||||
|
(assert_return (invoke "good5" (i32.const 65508)) (i32.const 0))
|
||||||
|
(assert_return (invoke "good6" (i32.const 65508)) (i32.const 0))
|
||||||
|
(assert_return (invoke "good7" (i32.const 65508)) (i32.const 0))
|
||||||
|
(assert_return (invoke "good8" (i32.const 65508)) (i32.const 0))
|
||||||
|
(assert_return (invoke "good9" (i32.const 65508)) (i32.const 0))
|
||||||
|
(assert_return (invoke "good10" (i32.const 65508)) (i32.const 0))
|
||||||
|
(assert_return (invoke "good11" (i32.const 65508)) (i32.const 0))
|
||||||
|
(assert_return (invoke "good12" (i32.const 65508)) (i32.const 0))
|
||||||
|
(assert_trap (invoke "good13" (i32.const 65508)) "out of bounds memory access")
|
||||||
|
|
||||||
|
(assert_trap (invoke "bad" (i32.const 0)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "bad" (i32.const 1)) "out of bounds memory access")
|
||||||
|
|
||||||
|
(assert_malformed
|
||||||
|
(module quote
|
||||||
|
"(memory 1)"
|
||||||
|
"(func (drop (i32.load offset=4294967296 (i32.const 0))))"
|
||||||
|
)
|
||||||
|
"i32 constant"
|
||||||
|
)
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
(assert_malformed
|
||||||
|
(module quote
|
||||||
|
"(module (memory 0) (func (drop (i64.load align=0 (i32.const 0)))))"
|
||||||
|
)
|
||||||
|
"alignment"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote
|
||||||
|
"(module (memory 0) (func (drop (i64.load align=7 (i32.const 0)))))"
|
||||||
|
)
|
||||||
|
"alignment"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (memory 0) (func (drop (i64.load align=16 (i32.const 0)))))
|
||||||
|
"alignment"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_malformed
|
||||||
|
(module quote
|
||||||
|
"(module (memory 0) (func (i64.store align=0 (i32.const 0) (i64.const 0))))"
|
||||||
|
)
|
||||||
|
"alignment"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote
|
||||||
|
"(module (memory 0) (func (i64.store align=5 (i32.const 0) (i64.const 0))))"
|
||||||
|
)
|
||||||
|
"alignment"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (memory 0) (func (i64.store align=16 (i32.const 0) (i64.const 0))))
|
||||||
|
"alignment"
|
||||||
|
)
|
||||||
@@ -0,0 +1,327 @@
|
|||||||
|
(module binary "\00asm\01\00\00\00")
|
||||||
|
(module binary "\00asm" "\01\00\00\00")
|
||||||
|
(module $M1 binary "\00asm\01\00\00\00")
|
||||||
|
(module $M2 binary "\00asm" "\01\00\00\00")
|
||||||
|
|
||||||
|
(assert_malformed (module binary "") "unexpected end")
|
||||||
|
(assert_malformed (module binary "\01") "unexpected end")
|
||||||
|
(assert_malformed (module binary "\00as") "unexpected end")
|
||||||
|
(assert_malformed (module binary "asm\00") "magic header not detected")
|
||||||
|
(assert_malformed (module binary "msa\00") "magic header not detected")
|
||||||
|
(assert_malformed (module binary "msa\00\01\00\00\00") "magic header not detected")
|
||||||
|
(assert_malformed (module binary "msa\00\00\00\00\01") "magic header not detected")
|
||||||
|
(assert_malformed (module binary "asm\01\00\00\00\00") "magic header not detected")
|
||||||
|
(assert_malformed (module binary "wasm\01\00\00\00") "magic header not detected")
|
||||||
|
(assert_malformed (module binary "\7fasm\01\00\00\00") "magic header not detected")
|
||||||
|
(assert_malformed (module binary "\80asm\01\00\00\00") "magic header not detected")
|
||||||
|
(assert_malformed (module binary "\82asm\01\00\00\00") "magic header not detected")
|
||||||
|
(assert_malformed (module binary "\ffasm\01\00\00\00") "magic header not detected")
|
||||||
|
|
||||||
|
;; 8-byte endian-reversed.
|
||||||
|
(assert_malformed (module binary "\00\00\00\01msa\00") "magic header not detected")
|
||||||
|
|
||||||
|
;; Middle-endian byte orderings.
|
||||||
|
(assert_malformed (module binary "a\00ms\00\01\00\00") "magic header not detected")
|
||||||
|
(assert_malformed (module binary "sm\00a\00\00\01\00") "magic header not detected")
|
||||||
|
|
||||||
|
;; Upper-cased.
|
||||||
|
(assert_malformed (module binary "\00ASM\01\00\00\00") "magic header not detected")
|
||||||
|
|
||||||
|
;; EBCDIC-encoded magic.
|
||||||
|
(assert_malformed (module binary "\00\81\a2\94\01\00\00\00") "magic header not detected")
|
||||||
|
|
||||||
|
;; Leading UTF-8 BOM.
|
||||||
|
(assert_malformed (module binary "\ef\bb\bf\00asm\01\00\00\00") "magic header not detected")
|
||||||
|
|
||||||
|
(assert_malformed (module binary "\00asm") "unexpected end")
|
||||||
|
(assert_malformed (module binary "\00asm\01") "unexpected end")
|
||||||
|
(assert_malformed (module binary "\00asm\01\00\00") "unexpected end")
|
||||||
|
(assert_malformed (module binary "\00asm\00\00\00\00") "unknown binary version")
|
||||||
|
(assert_malformed (module binary "\00asm\0d\00\00\00") "unknown binary version")
|
||||||
|
(assert_malformed (module binary "\00asm\0e\00\00\00") "unknown binary version")
|
||||||
|
(assert_malformed (module binary "\00asm\00\01\00\00") "unknown binary version")
|
||||||
|
(assert_malformed (module binary "\00asm\00\00\01\00") "unknown binary version")
|
||||||
|
(assert_malformed (module binary "\00asm\00\00\00\01") "unknown binary version")
|
||||||
|
|
||||||
|
;; Unsigned LEB128 can have non-minimal length
|
||||||
|
(module binary
|
||||||
|
"\00asm" "\01\00\00\00"
|
||||||
|
"\05\04\01" ;; Memory section with 1 entry
|
||||||
|
"\00\82\00" ;; no max, minimum 2
|
||||||
|
)
|
||||||
|
(module binary
|
||||||
|
"\00asm" "\01\00\00\00"
|
||||||
|
"\05\07\01" ;; Memory section with 1 entry
|
||||||
|
"\00\82\80\80\80\00" ;; no max, minimum 2
|
||||||
|
)
|
||||||
|
|
||||||
|
;; Signed LEB128 can have non-minimal length
|
||||||
|
(module binary
|
||||||
|
"\00asm" "\01\00\00\00"
|
||||||
|
"\06\07\01" ;; Global section with 1 entry
|
||||||
|
"\7f\00" ;; i32, immutable
|
||||||
|
"\41\80\00" ;; i32.const 0
|
||||||
|
"\0b" ;; end
|
||||||
|
)
|
||||||
|
(module binary
|
||||||
|
"\00asm" "\01\00\00\00"
|
||||||
|
"\06\07\01" ;; Global section with 1 entry
|
||||||
|
"\7f\00" ;; i32, immutable
|
||||||
|
"\41\ff\7f" ;; i32.const -1
|
||||||
|
"\0b" ;; end
|
||||||
|
)
|
||||||
|
(module binary
|
||||||
|
"\00asm" "\01\00\00\00"
|
||||||
|
"\06\0a\01" ;; Global section with 1 entry
|
||||||
|
"\7f\00" ;; i32, immutable
|
||||||
|
"\41\80\80\80\80\00" ;; i32.const 0
|
||||||
|
"\0b" ;; end
|
||||||
|
)
|
||||||
|
(module binary
|
||||||
|
"\00asm" "\01\00\00\00"
|
||||||
|
"\06\0a\01" ;; Global section with 1 entry
|
||||||
|
"\7f\00" ;; i32, immutable
|
||||||
|
"\41\ff\ff\ff\ff\7f" ;; i32.const -1
|
||||||
|
"\0b" ;; end
|
||||||
|
)
|
||||||
|
|
||||||
|
(module binary
|
||||||
|
"\00asm" "\01\00\00\00"
|
||||||
|
"\06\07\01" ;; Global section with 1 entry
|
||||||
|
"\7e\00" ;; i64, immutable
|
||||||
|
"\42\80\00" ;; i64.const 0 with unused bits set
|
||||||
|
"\0b" ;; end
|
||||||
|
)
|
||||||
|
(module binary
|
||||||
|
"\00asm" "\01\00\00\00"
|
||||||
|
"\06\07\01" ;; Global section with 1 entry
|
||||||
|
"\7e\00" ;; i64, immutable
|
||||||
|
"\42\ff\7f" ;; i64.const -1 with unused bits unset
|
||||||
|
"\0b" ;; end
|
||||||
|
)
|
||||||
|
(module binary
|
||||||
|
"\00asm" "\01\00\00\00"
|
||||||
|
"\06\0f\01" ;; Global section with 1 entry
|
||||||
|
"\7e\00" ;; i64, immutable
|
||||||
|
"\42\80\80\80\80\80\80\80\80\80\00" ;; i64.const 0 with unused bits set
|
||||||
|
"\0b" ;; end
|
||||||
|
)
|
||||||
|
(module binary
|
||||||
|
"\00asm" "\01\00\00\00"
|
||||||
|
"\06\0f\01" ;; Global section with 1 entry
|
||||||
|
"\7e\00" ;; i64, immutable
|
||||||
|
"\42\ff\ff\ff\ff\ff\ff\ff\ff\ff\7f" ;; i64.const -1 with unused bits unset
|
||||||
|
"\0b" ;; end
|
||||||
|
)
|
||||||
|
|
||||||
|
;; Unsigned LEB128 must not be overlong
|
||||||
|
(assert_malformed
|
||||||
|
(module binary
|
||||||
|
"\00asm" "\01\00\00\00"
|
||||||
|
"\05\08\01" ;; Memory section with 1 entry
|
||||||
|
"\00\82\80\80\80\80\00" ;; no max, minimum 2 with one byte too many
|
||||||
|
)
|
||||||
|
"integer representation too long"
|
||||||
|
)
|
||||||
|
|
||||||
|
;; Signed LEB128 must not be overlong
|
||||||
|
(assert_malformed
|
||||||
|
(module binary
|
||||||
|
"\00asm" "\01\00\00\00"
|
||||||
|
"\06\0b\01" ;; Global section with 1 entry
|
||||||
|
"\7f\00" ;; i32, immutable
|
||||||
|
"\41\80\80\80\80\80\00" ;; i32.const 0 with one byte too many
|
||||||
|
"\0b" ;; end
|
||||||
|
)
|
||||||
|
"integer representation too long"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module binary
|
||||||
|
"\00asm" "\01\00\00\00"
|
||||||
|
"\06\0b\01" ;; Global section with 1 entry
|
||||||
|
"\7f\00" ;; i32, immutable
|
||||||
|
"\41\ff\ff\ff\ff\ff\7f" ;; i32.const -1 with one byte too many
|
||||||
|
"\0b" ;; end
|
||||||
|
)
|
||||||
|
"integer representation too long"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_malformed
|
||||||
|
(module binary
|
||||||
|
"\00asm" "\01\00\00\00"
|
||||||
|
"\06\10\01" ;; Global section with 1 entry
|
||||||
|
"\7e\00" ;; i64, immutable
|
||||||
|
"\42\80\80\80\80\80\80\80\80\80\80\00" ;; i64.const 0 with one byte too many
|
||||||
|
"\0b" ;; end
|
||||||
|
)
|
||||||
|
"integer representation too long"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module binary
|
||||||
|
"\00asm" "\01\00\00\00"
|
||||||
|
"\06\10\01" ;; Global section with 1 entry
|
||||||
|
"\7e\00" ;; i64, immutable
|
||||||
|
"\42\ff\ff\ff\ff\ff\ff\ff\ff\ff\ff\7f" ;; i64.const -1 with one byte too many
|
||||||
|
"\0b" ;; end
|
||||||
|
)
|
||||||
|
"integer representation too long"
|
||||||
|
)
|
||||||
|
|
||||||
|
;; Unsigned LEB128s zero-extend
|
||||||
|
(assert_malformed
|
||||||
|
(module binary
|
||||||
|
"\00asm" "\01\00\00\00"
|
||||||
|
"\05\04\01" ;; Memory section with 1 entry
|
||||||
|
"\00\82\80\80\80\70" ;; no max, minimum 2 with unused bits set
|
||||||
|
)
|
||||||
|
"integer too large"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module binary
|
||||||
|
"\00asm" "\01\00\00\00"
|
||||||
|
"\05\04\01" ;; Memory section with 1 entry
|
||||||
|
"\00\82\80\80\80\40" ;; no max, minimum 2 with some unused bits set
|
||||||
|
)
|
||||||
|
"integer too large"
|
||||||
|
)
|
||||||
|
|
||||||
|
;; Signed LEB128s sign-extend
|
||||||
|
(assert_malformed
|
||||||
|
(module binary
|
||||||
|
"\00asm" "\01\00\00\00"
|
||||||
|
"\06\0a\01" ;; Global section with 1 entry
|
||||||
|
"\7f\00" ;; i32, immutable
|
||||||
|
"\41\80\80\80\80\70" ;; i32.const 0 with unused bits set
|
||||||
|
"\0b" ;; end
|
||||||
|
)
|
||||||
|
"integer too large"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module binary
|
||||||
|
"\00asm" "\01\00\00\00"
|
||||||
|
"\06\0a\01" ;; Global section with 1 entry
|
||||||
|
"\7f\00" ;; i32, immutable
|
||||||
|
"\41\ff\ff\ff\ff\0f" ;; i32.const -1 with unused bits unset
|
||||||
|
"\0b" ;; end
|
||||||
|
)
|
||||||
|
"integer too large"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module binary
|
||||||
|
"\00asm" "\01\00\00\00"
|
||||||
|
"\06\0a\01" ;; Global section with 1 entry
|
||||||
|
"\7f\00" ;; i32, immutable
|
||||||
|
"\41\80\80\80\80\1f" ;; i32.const 0 with some unused bits set
|
||||||
|
"\0b" ;; end
|
||||||
|
)
|
||||||
|
"integer too large"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module binary
|
||||||
|
"\00asm" "\01\00\00\00"
|
||||||
|
"\06\0a\01" ;; Global section with 1 entry
|
||||||
|
"\7f\00" ;; i32, immutable
|
||||||
|
"\41\ff\ff\ff\ff\4f" ;; i32.const -1 with some unused bits unset
|
||||||
|
"\0b" ;; end
|
||||||
|
)
|
||||||
|
"integer too large"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_malformed
|
||||||
|
(module binary
|
||||||
|
"\00asm" "\01\00\00\00"
|
||||||
|
"\06\0f\01" ;; Global section with 1 entry
|
||||||
|
"\7e\00" ;; i64, immutable
|
||||||
|
"\42\80\80\80\80\80\80\80\80\80\7e" ;; i64.const 0 with unused bits set
|
||||||
|
"\0b" ;; end
|
||||||
|
)
|
||||||
|
"integer too large"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module binary
|
||||||
|
"\00asm" "\01\00\00\00"
|
||||||
|
"\06\0f\01" ;; Global section with 1 entry
|
||||||
|
"\7e\00" ;; i64, immutable
|
||||||
|
"\42\ff\ff\ff\ff\ff\ff\ff\ff\ff\01" ;; i64.const -1 with unused bits unset
|
||||||
|
"\0b" ;; end
|
||||||
|
)
|
||||||
|
"integer too large"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module binary
|
||||||
|
"\00asm" "\01\00\00\00"
|
||||||
|
"\06\0f\01" ;; Global section with 1 entry
|
||||||
|
"\7e\00" ;; i64, immutable
|
||||||
|
"\42\80\80\80\80\80\80\80\80\80\02" ;; i64.const 0 with some unused bits set
|
||||||
|
"\0b" ;; end
|
||||||
|
)
|
||||||
|
"integer too large"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module binary
|
||||||
|
"\00asm" "\01\00\00\00"
|
||||||
|
"\06\0f\01" ;; Global section with 1 entry
|
||||||
|
"\7e\00" ;; i64, immutable
|
||||||
|
"\42\ff\ff\ff\ff\ff\ff\ff\ff\ff\41" ;; i64.const -1 with some unused bits unset
|
||||||
|
"\0b" ;; end
|
||||||
|
)
|
||||||
|
"integer too large"
|
||||||
|
)
|
||||||
|
|
||||||
|
;; call_indirect reserved byte equal to zero.
|
||||||
|
(assert_malformed
|
||||||
|
(module binary
|
||||||
|
"\00asm" "\01\00\00\00"
|
||||||
|
"\01\04\01\60\00\00" ;; Type section
|
||||||
|
"\03\02\01\00" ;; Function section
|
||||||
|
"\04\04\01\70\00\00" ;; Table section
|
||||||
|
"\0a\09\01" ;; Code section
|
||||||
|
|
||||||
|
;; function 0
|
||||||
|
"\07\00"
|
||||||
|
"\41\00" ;; i32.const 0
|
||||||
|
"\11\00" ;; call_indirect (type 0)
|
||||||
|
"\01" ;; call_indirect reserved byte is not equal to zero!
|
||||||
|
"\0b" ;; end
|
||||||
|
)
|
||||||
|
"zero flag expected"
|
||||||
|
)
|
||||||
|
|
||||||
|
;; memory.grow reserved byte equal to zero.
|
||||||
|
(assert_malformed
|
||||||
|
(module binary
|
||||||
|
"\00asm" "\01\00\00\00"
|
||||||
|
"\01\04\01\60\00\00" ;; Type section
|
||||||
|
"\03\02\01\00" ;; Function section
|
||||||
|
"\05\03\01\00\00" ;; Memory section
|
||||||
|
"\0a\09\01" ;; Code section
|
||||||
|
|
||||||
|
;; function 0
|
||||||
|
"\07\00"
|
||||||
|
"\41\00" ;; i32.const 0
|
||||||
|
"\40" ;; memory.grow
|
||||||
|
"\01" ;; memory.grow reserved byte is not equal to zero!
|
||||||
|
"\1a" ;; drop
|
||||||
|
"\0b" ;; end
|
||||||
|
)
|
||||||
|
"zero flag expected"
|
||||||
|
)
|
||||||
|
|
||||||
|
;; memory.size reserved byte equal to zero.
|
||||||
|
(assert_malformed
|
||||||
|
(module binary
|
||||||
|
"\00asm" "\01\00\00\00"
|
||||||
|
"\01\04\01\60\00\00" ;; Type section
|
||||||
|
"\03\02\01\00" ;; Function section
|
||||||
|
"\05\03\01\00\00" ;; Memory section
|
||||||
|
"\0a\07\01" ;; Code section
|
||||||
|
|
||||||
|
;; function 0
|
||||||
|
"\05\00"
|
||||||
|
"\3f" ;; memory.size
|
||||||
|
"\01" ;; memory.size reserved byte is not equal to zero!
|
||||||
|
"\1a" ;; drop
|
||||||
|
"\0b" ;; end
|
||||||
|
)
|
||||||
|
"zero flag expected"
|
||||||
|
)
|
||||||
@@ -0,0 +1,299 @@
|
|||||||
|
;; Test `block` operator
|
||||||
|
|
||||||
|
(module
|
||||||
|
;; Auxiliary definition
|
||||||
|
(func $dummy)
|
||||||
|
|
||||||
|
(func (export "empty")
|
||||||
|
(block)
|
||||||
|
(block $l)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "singular") (result i32)
|
||||||
|
(block (nop))
|
||||||
|
(block (result i32) (i32.const 7))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "multi") (result i32)
|
||||||
|
(block (call $dummy) (call $dummy) (call $dummy) (call $dummy))
|
||||||
|
(block (result i32) (call $dummy) (call $dummy) (call $dummy) (i32.const 8))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "nested") (result i32)
|
||||||
|
(block (result i32)
|
||||||
|
(block (call $dummy) (block) (nop))
|
||||||
|
(block (result i32) (call $dummy) (i32.const 9))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "deep") (result i32)
|
||||||
|
(block (result i32) (block (result i32)
|
||||||
|
(block (result i32) (block (result i32)
|
||||||
|
(block (result i32) (block (result i32)
|
||||||
|
(block (result i32) (block (result i32)
|
||||||
|
(block (result i32) (block (result i32)
|
||||||
|
(block (result i32) (block (result i32)
|
||||||
|
(block (result i32) (block (result i32)
|
||||||
|
(block (result i32) (block (result i32)
|
||||||
|
(block (result i32) (block (result i32)
|
||||||
|
(block (result i32) (block (result i32)
|
||||||
|
(block (result i32) (block (result i32)
|
||||||
|
(block (result i32) (block (result i32)
|
||||||
|
(block (result i32) (block (result i32)
|
||||||
|
(block (result i32) (block (result i32)
|
||||||
|
(block (result i32) (block (result i32)
|
||||||
|
(block (result i32) (block (result i32)
|
||||||
|
(block (result i32) (block (result i32)
|
||||||
|
(block (result i32) (block (result i32)
|
||||||
|
(block (result i32) (block (result i32)
|
||||||
|
(call $dummy) (i32.const 150)
|
||||||
|
))
|
||||||
|
))
|
||||||
|
))
|
||||||
|
))
|
||||||
|
))
|
||||||
|
))
|
||||||
|
))
|
||||||
|
))
|
||||||
|
))
|
||||||
|
))
|
||||||
|
))
|
||||||
|
))
|
||||||
|
))
|
||||||
|
))
|
||||||
|
))
|
||||||
|
))
|
||||||
|
))
|
||||||
|
))
|
||||||
|
))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "as-unary-operand") (result i32)
|
||||||
|
(i32.ctz (block (result i32) (call $dummy) (i32.const 13)))
|
||||||
|
)
|
||||||
|
(func (export "as-binary-operand") (result i32)
|
||||||
|
(i32.mul
|
||||||
|
(block (result i32) (call $dummy) (i32.const 3))
|
||||||
|
(block (result i32) (call $dummy) (i32.const 4))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(func (export "as-test-operand") (result i32)
|
||||||
|
(i32.eqz (block (result i32) (call $dummy) (i32.const 13)))
|
||||||
|
)
|
||||||
|
(func (export "as-compare-operand") (result i32)
|
||||||
|
(f32.gt
|
||||||
|
(block (result f32) (call $dummy) (f32.const 3))
|
||||||
|
(block (result f32) (call $dummy) (f32.const 3))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "break-bare") (result i32)
|
||||||
|
(block (br 0) (unreachable))
|
||||||
|
(block (br_if 0 (i32.const 1)) (unreachable))
|
||||||
|
(block (br_table 0 (i32.const 0)) (unreachable))
|
||||||
|
(block (br_table 0 0 0 (i32.const 1)) (unreachable))
|
||||||
|
(i32.const 19)
|
||||||
|
)
|
||||||
|
(func (export "break-value") (result i32)
|
||||||
|
(block (result i32) (br 0 (i32.const 18)) (i32.const 19))
|
||||||
|
)
|
||||||
|
(func (export "break-repeated") (result i32)
|
||||||
|
(block (result i32)
|
||||||
|
(br 0 (i32.const 18))
|
||||||
|
(br 0 (i32.const 19))
|
||||||
|
(drop (br_if 0 (i32.const 20) (i32.const 0)))
|
||||||
|
(drop (br_if 0 (i32.const 20) (i32.const 1)))
|
||||||
|
(br 0 (i32.const 21))
|
||||||
|
(br_table 0 (i32.const 22) (i32.const 4))
|
||||||
|
(br_table 0 0 0 (i32.const 23) (i32.const 1))
|
||||||
|
(i32.const 21)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(func (export "break-inner") (result i32)
|
||||||
|
(local i32)
|
||||||
|
(set_local 0 (i32.const 0))
|
||||||
|
(set_local 0 (i32.add (get_local 0) (block (result i32) (block (result i32) (br 1 (i32.const 0x1))))))
|
||||||
|
(set_local 0 (i32.add (get_local 0) (block (result i32) (block (br 0)) (i32.const 0x2))))
|
||||||
|
(set_local 0
|
||||||
|
(i32.add (get_local 0) (block (result i32) (i32.ctz (br 0 (i32.const 0x4)))))
|
||||||
|
)
|
||||||
|
(set_local 0
|
||||||
|
(i32.add (get_local 0) (block (result i32) (i32.ctz (block (result i32) (br 1 (i32.const 0x8))))))
|
||||||
|
)
|
||||||
|
(get_local 0)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "effects") (result i32)
|
||||||
|
(local i32)
|
||||||
|
(block
|
||||||
|
(set_local 0 (i32.const 1))
|
||||||
|
(set_local 0 (i32.mul (get_local 0) (i32.const 3)))
|
||||||
|
(set_local 0 (i32.sub (get_local 0) (i32.const 5)))
|
||||||
|
(set_local 0 (i32.mul (get_local 0) (i32.const 7)))
|
||||||
|
(br 0)
|
||||||
|
(set_local 0 (i32.mul (get_local 0) (i32.const 100)))
|
||||||
|
)
|
||||||
|
(i32.eq (get_local 0) (i32.const -14))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke "empty"))
|
||||||
|
(assert_return (invoke "singular") (i32.const 7))
|
||||||
|
(assert_return (invoke "multi") (i32.const 8))
|
||||||
|
(assert_return (invoke "nested") (i32.const 9))
|
||||||
|
(assert_return (invoke "deep") (i32.const 150))
|
||||||
|
|
||||||
|
(assert_return (invoke "as-unary-operand") (i32.const 0))
|
||||||
|
(assert_return (invoke "as-binary-operand") (i32.const 12))
|
||||||
|
(assert_return (invoke "as-test-operand") (i32.const 0))
|
||||||
|
(assert_return (invoke "as-compare-operand") (i32.const 0))
|
||||||
|
|
||||||
|
(assert_return (invoke "break-bare") (i32.const 19))
|
||||||
|
(assert_return (invoke "break-value") (i32.const 18))
|
||||||
|
(assert_return (invoke "break-repeated") (i32.const 18))
|
||||||
|
(assert_return (invoke "break-inner") (i32.const 0xf))
|
||||||
|
|
||||||
|
(assert_return (invoke "effects") (i32.const 1))
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-empty-i32 (result i32) (block)))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-empty-i64 (result i64) (block)))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-empty-f32 (result f32) (block)))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-empty-f64 (result f64) (block)))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-value-num-vs-void
|
||||||
|
(block (i32.const 1))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-value-empty-vs-num (result i32)
|
||||||
|
(block (result i32))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-value-void-vs-num (result i32)
|
||||||
|
(block (result i32) (nop))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-value-num-vs-num (result i32)
|
||||||
|
(block (result i32) (f32.const 0))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-value-unreached-select (result i32)
|
||||||
|
(block (result i64) (select (unreachable) (unreachable) (unreachable)))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-break-last-void-vs-num (result i32)
|
||||||
|
(block (result i32) (br 0))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-break-empty-vs-num (result i32)
|
||||||
|
(block (result i32) (br 0) (i32.const 1))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-break-void-vs-num (result i32)
|
||||||
|
(block (result i32) (br 0 (nop)) (i32.const 1))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-break-num-vs-num (result i32)
|
||||||
|
(block (result i32) (br 0 (i64.const 1)) (i32.const 1))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-break-first-void-vs-num (result i32)
|
||||||
|
(block (result i32) (br 0 (nop)) (br 0 (i32.const 1)))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-break-first-num-vs-num (result i32)
|
||||||
|
(block (result i32) (br 0 (i64.const 1)) (br 0 (i32.const 1)))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-break-nested-num-vs-void
|
||||||
|
(block (result i32) (block (result i32) (br 1 (i32.const 1))) (br 0))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-break-nested-empty-vs-num (result i32)
|
||||||
|
(block (result i32) (block (br 1)) (br 0 (i32.const 1)))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-break-nested-void-vs-num (result i32)
|
||||||
|
(block (result i32) (block (result i32) (br 1 (nop))) (br 0 (i32.const 1)))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-break-nested-num-vs-num (result i32)
|
||||||
|
(block (result i32)
|
||||||
|
(block (result i32) (br 1 (i64.const 1))) (br 0 (i32.const 1))
|
||||||
|
)
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-break-operand-empty-vs-num (result i32)
|
||||||
|
(i32.ctz (block (br 0)))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-break-operand-void-vs-num (result i32)
|
||||||
|
(i64.ctz (block (br 0 (nop))))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-break-operand-num-vs-num (result i32)
|
||||||
|
(i64.ctz (block (br 0 (i64.const 9))))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(func block end $l)")
|
||||||
|
"mismatching label"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(func block $a end $l)")
|
||||||
|
"mismatching label"
|
||||||
|
)
|
||||||
@@ -0,0 +1,447 @@
|
|||||||
|
;; Test `br` operator
|
||||||
|
|
||||||
|
(module
|
||||||
|
;; Auxiliary definition
|
||||||
|
(func $dummy)
|
||||||
|
|
||||||
|
(func (export "type-i32") (block (drop (i32.ctz (br 0)))))
|
||||||
|
(func (export "type-i64") (block (drop (i64.ctz (br 0)))))
|
||||||
|
(func (export "type-f32") (block (drop (f32.neg (br 0)))))
|
||||||
|
(func (export "type-f64") (block (drop (f64.neg (br 0)))))
|
||||||
|
|
||||||
|
(func (export "type-i32-value") (result i32)
|
||||||
|
(block (result i32) (i32.ctz (br 0 (i32.const 1))))
|
||||||
|
)
|
||||||
|
(func (export "type-i64-value") (result i64)
|
||||||
|
(block (result i64) (i64.ctz (br 0 (i64.const 2))))
|
||||||
|
)
|
||||||
|
(func (export "type-f32-value") (result f32)
|
||||||
|
(block (result f32) (f32.neg (br 0 (f32.const 3))))
|
||||||
|
)
|
||||||
|
(func (export "type-f64-value") (result f64)
|
||||||
|
(block (result f64) (f64.neg (br 0 (f64.const 4))))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "as-block-first")
|
||||||
|
(block (br 0) (call $dummy))
|
||||||
|
)
|
||||||
|
(func (export "as-block-mid")
|
||||||
|
(block (call $dummy) (br 0) (call $dummy))
|
||||||
|
)
|
||||||
|
(func (export "as-block-last")
|
||||||
|
(block (nop) (call $dummy) (br 0))
|
||||||
|
)
|
||||||
|
(func (export "as-block-value") (result i32)
|
||||||
|
(block (result i32) (nop) (call $dummy) (br 0 (i32.const 2)))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "as-loop-first") (result i32)
|
||||||
|
(block (result i32) (loop (result i32) (br 1 (i32.const 3)) (i32.const 2)))
|
||||||
|
)
|
||||||
|
(func (export "as-loop-mid") (result i32)
|
||||||
|
(block (result i32)
|
||||||
|
(loop (result i32) (call $dummy) (br 1 (i32.const 4)) (i32.const 2))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(func (export "as-loop-last") (result i32)
|
||||||
|
(block (result i32)
|
||||||
|
(loop (result i32) (nop) (call $dummy) (br 1 (i32.const 5)))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "as-br-value") (result i32)
|
||||||
|
(block (result i32) (br 0 (br 0 (i32.const 9))))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "as-br_if-cond")
|
||||||
|
(block (br_if 0 (br 0)))
|
||||||
|
)
|
||||||
|
(func (export "as-br_if-value") (result i32)
|
||||||
|
(block (result i32)
|
||||||
|
(drop (br_if 0 (br 0 (i32.const 8)) (i32.const 1))) (i32.const 7)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(func (export "as-br_if-value-cond") (result i32)
|
||||||
|
(block (result i32)
|
||||||
|
(drop (br_if 0 (i32.const 6) (br 0 (i32.const 9)))) (i32.const 7)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "as-br_table-index")
|
||||||
|
(block (br_table 0 0 0 (br 0)))
|
||||||
|
)
|
||||||
|
(func (export "as-br_table-value") (result i32)
|
||||||
|
(block (result i32)
|
||||||
|
(br_table 0 0 0 (br 0 (i32.const 10)) (i32.const 1)) (i32.const 7)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(func (export "as-br_table-value-index") (result i32)
|
||||||
|
(block (result i32)
|
||||||
|
(br_table 0 0 (i32.const 6) (br 0 (i32.const 11))) (i32.const 7)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "as-return-value") (result i64)
|
||||||
|
(block (result i64) (return (br 0 (i64.const 7))))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "as-if-cond") (result i32)
|
||||||
|
(block (result i32)
|
||||||
|
(if (result i32) (br 0 (i32.const 2))
|
||||||
|
(then (i32.const 0))
|
||||||
|
(else (i32.const 1))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(func (export "as-if-then") (param i32 i32) (result i32)
|
||||||
|
(block (result i32)
|
||||||
|
(if (result i32) (get_local 0)
|
||||||
|
(then (br 1 (i32.const 3)))
|
||||||
|
(else (get_local 1))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(func (export "as-if-else") (param i32 i32) (result i32)
|
||||||
|
(block (result i32)
|
||||||
|
(if (result i32) (get_local 0)
|
||||||
|
(then (get_local 1))
|
||||||
|
(else (br 1 (i32.const 4)))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "as-select-first") (param i32 i32) (result i32)
|
||||||
|
(block (result i32)
|
||||||
|
(select (br 0 (i32.const 5)) (get_local 0) (get_local 1))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(func (export "as-select-second") (param i32 i32) (result i32)
|
||||||
|
(block (result i32)
|
||||||
|
(select (get_local 0) (br 0 (i32.const 6)) (get_local 1))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(func (export "as-select-cond") (result i32)
|
||||||
|
(block (result i32)
|
||||||
|
(select (i32.const 0) (i32.const 1) (br 0 (i32.const 7)))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func $f (param i32 i32 i32) (result i32) (i32.const -1))
|
||||||
|
(func (export "as-call-first") (result i32)
|
||||||
|
(block (result i32)
|
||||||
|
(call $f (br 0 (i32.const 12)) (i32.const 2) (i32.const 3))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(func (export "as-call-mid") (result i32)
|
||||||
|
(block (result i32)
|
||||||
|
(call $f (i32.const 1) (br 0 (i32.const 13)) (i32.const 3))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(func (export "as-call-last") (result i32)
|
||||||
|
(block (result i32)
|
||||||
|
(call $f (i32.const 1) (i32.const 2) (br 0 (i32.const 14)))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(type $sig (func (param i32 i32 i32) (result i32)))
|
||||||
|
(table anyfunc (elem $f))
|
||||||
|
(func (export "as-call_indirect-func") (result i32)
|
||||||
|
(block (result i32)
|
||||||
|
(call_indirect (type $sig)
|
||||||
|
(br 0 (i32.const 20))
|
||||||
|
(i32.const 1) (i32.const 2) (i32.const 3)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(func (export "as-call_indirect-first") (result i32)
|
||||||
|
(block (result i32)
|
||||||
|
(call_indirect (type $sig)
|
||||||
|
(i32.const 0)
|
||||||
|
(br 0 (i32.const 21)) (i32.const 2) (i32.const 3)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(func (export "as-call_indirect-mid") (result i32)
|
||||||
|
(block (result i32)
|
||||||
|
(call_indirect (type $sig)
|
||||||
|
(i32.const 0)
|
||||||
|
(i32.const 1) (br 0 (i32.const 22)) (i32.const 3)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(func (export "as-call_indirect-last") (result i32)
|
||||||
|
(block (result i32)
|
||||||
|
(call_indirect (type $sig)
|
||||||
|
(i32.const 0)
|
||||||
|
(i32.const 1) (i32.const 2) (br 0 (i32.const 23))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "as-set_local-value") (result i32) (local f32)
|
||||||
|
(block (result i32) (set_local 0 (br 0 (i32.const 17))) (i32.const -1))
|
||||||
|
)
|
||||||
|
|
||||||
|
(memory 1)
|
||||||
|
(func (export "as-load-address") (result f32)
|
||||||
|
(block (result f32) (f32.load (br 0 (f32.const 1.7))))
|
||||||
|
)
|
||||||
|
(func (export "as-loadN-address") (result i64)
|
||||||
|
(block (result i64) (i64.load8_s (br 0 (i64.const 30))))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "as-store-address") (result i32)
|
||||||
|
(block (result i32)
|
||||||
|
(f64.store (br 0 (i32.const 30)) (f64.const 7)) (i32.const -1)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(func (export "as-store-value") (result i32)
|
||||||
|
(block (result i32)
|
||||||
|
(i64.store (i32.const 2) (br 0 (i32.const 31))) (i32.const -1)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "as-storeN-address") (result i32)
|
||||||
|
(block (result i32)
|
||||||
|
(i32.store8 (br 0 (i32.const 32)) (i32.const 7)) (i32.const -1)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(func (export "as-storeN-value") (result i32)
|
||||||
|
(block (result i32)
|
||||||
|
(i64.store16 (i32.const 2) (br 0 (i32.const 33))) (i32.const -1)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "as-unary-operand") (result f32)
|
||||||
|
(block (result f32) (f32.neg (br 0 (f32.const 3.4))))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "as-binary-left") (result i32)
|
||||||
|
(block (result i32) (i32.add (br 0 (i32.const 3)) (i32.const 10)))
|
||||||
|
)
|
||||||
|
(func (export "as-binary-right") (result i64)
|
||||||
|
(block (result i64) (i64.sub (i64.const 10) (br 0 (i64.const 45))))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "as-test-operand") (result i32)
|
||||||
|
(block (result i32) (i32.eqz (br 0 (i32.const 44))))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "as-compare-left") (result i32)
|
||||||
|
(block (result i32) (f64.le (br 0 (i32.const 43)) (f64.const 10)))
|
||||||
|
)
|
||||||
|
(func (export "as-compare-right") (result i32)
|
||||||
|
(block (result i32) (f32.ne (f32.const 10) (br 0 (i32.const 42))))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "as-convert-operand") (result i32)
|
||||||
|
(block (result i32) (i32.wrap/i64 (br 0 (i32.const 41))))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "as-memory.grow-size") (result i32)
|
||||||
|
(block (result i32) (memory.grow (br 0 (i32.const 40))))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "nested-block-value") (result i32)
|
||||||
|
(i32.add
|
||||||
|
(i32.const 1)
|
||||||
|
(block (result i32)
|
||||||
|
(call $dummy)
|
||||||
|
(i32.add (i32.const 4) (br 0 (i32.const 8)))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "nested-br-value") (result i32)
|
||||||
|
(i32.add
|
||||||
|
(i32.const 1)
|
||||||
|
(block (result i32)
|
||||||
|
(drop (i32.const 2))
|
||||||
|
(drop
|
||||||
|
(block (result i32)
|
||||||
|
(drop (i32.const 4))
|
||||||
|
(br 0 (br 1 (i32.const 8)))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(i32.const 16)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "nested-br_if-value") (result i32)
|
||||||
|
(i32.add
|
||||||
|
(i32.const 1)
|
||||||
|
(block (result i32)
|
||||||
|
(drop (i32.const 2))
|
||||||
|
(drop
|
||||||
|
(block (result i32)
|
||||||
|
(drop (i32.const 4))
|
||||||
|
(drop (br_if 0 (br 1 (i32.const 8)) (i32.const 1)))
|
||||||
|
(i32.const 32)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(i32.const 16)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "nested-br_if-value-cond") (result i32)
|
||||||
|
(i32.add
|
||||||
|
(i32.const 1)
|
||||||
|
(block (result i32)
|
||||||
|
(drop (i32.const 2))
|
||||||
|
(drop (br_if 0 (i32.const 4) (br 0 (i32.const 8))))
|
||||||
|
(i32.const 16)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "nested-br_table-value") (result i32)
|
||||||
|
(i32.add
|
||||||
|
(i32.const 1)
|
||||||
|
(block (result i32)
|
||||||
|
(drop (i32.const 2))
|
||||||
|
(drop
|
||||||
|
(block (result i32)
|
||||||
|
(drop (i32.const 4))
|
||||||
|
(br_table 0 (br 1 (i32.const 8)) (i32.const 1))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(i32.const 16)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "nested-br_table-value-index") (result i32)
|
||||||
|
(i32.add
|
||||||
|
(i32.const 1)
|
||||||
|
(block (result i32)
|
||||||
|
(drop (i32.const 2))
|
||||||
|
(br_table 0 (i32.const 4) (br 0 (i32.const 8)))
|
||||||
|
(i32.const 16)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke "type-i32"))
|
||||||
|
(assert_return (invoke "type-i64"))
|
||||||
|
(assert_return (invoke "type-f32"))
|
||||||
|
(assert_return (invoke "type-f64"))
|
||||||
|
|
||||||
|
(assert_return (invoke "type-i32-value") (i32.const 1))
|
||||||
|
(assert_return (invoke "type-i64-value") (i64.const 2))
|
||||||
|
(assert_return (invoke "type-f32-value") (f32.const 3))
|
||||||
|
(assert_return (invoke "type-f64-value") (f64.const 4))
|
||||||
|
|
||||||
|
(assert_return (invoke "as-block-first"))
|
||||||
|
(assert_return (invoke "as-block-mid"))
|
||||||
|
(assert_return (invoke "as-block-last"))
|
||||||
|
(assert_return (invoke "as-block-value") (i32.const 2))
|
||||||
|
|
||||||
|
(assert_return (invoke "as-loop-first") (i32.const 3))
|
||||||
|
(assert_return (invoke "as-loop-mid") (i32.const 4))
|
||||||
|
(assert_return (invoke "as-loop-last") (i32.const 5))
|
||||||
|
|
||||||
|
(assert_return (invoke "as-br-value") (i32.const 9))
|
||||||
|
|
||||||
|
(assert_return (invoke "as-br_if-cond"))
|
||||||
|
(assert_return (invoke "as-br_if-value") (i32.const 8))
|
||||||
|
(assert_return (invoke "as-br_if-value-cond") (i32.const 9))
|
||||||
|
|
||||||
|
(assert_return (invoke "as-br_table-index"))
|
||||||
|
(assert_return (invoke "as-br_table-value") (i32.const 10))
|
||||||
|
(assert_return (invoke "as-br_table-value-index") (i32.const 11))
|
||||||
|
|
||||||
|
(assert_return (invoke "as-return-value") (i64.const 7))
|
||||||
|
|
||||||
|
(assert_return (invoke "as-if-cond") (i32.const 2))
|
||||||
|
(assert_return (invoke "as-if-then" (i32.const 1) (i32.const 6)) (i32.const 3))
|
||||||
|
(assert_return (invoke "as-if-then" (i32.const 0) (i32.const 6)) (i32.const 6))
|
||||||
|
(assert_return (invoke "as-if-else" (i32.const 0) (i32.const 6)) (i32.const 4))
|
||||||
|
(assert_return (invoke "as-if-else" (i32.const 1) (i32.const 6)) (i32.const 6))
|
||||||
|
|
||||||
|
(assert_return (invoke "as-select-first" (i32.const 0) (i32.const 6)) (i32.const 5))
|
||||||
|
(assert_return (invoke "as-select-first" (i32.const 1) (i32.const 6)) (i32.const 5))
|
||||||
|
(assert_return (invoke "as-select-second" (i32.const 0) (i32.const 6)) (i32.const 6))
|
||||||
|
(assert_return (invoke "as-select-second" (i32.const 1) (i32.const 6)) (i32.const 6))
|
||||||
|
(assert_return (invoke "as-select-cond") (i32.const 7))
|
||||||
|
|
||||||
|
(assert_return (invoke "as-call-first") (i32.const 12))
|
||||||
|
(assert_return (invoke "as-call-mid") (i32.const 13))
|
||||||
|
(assert_return (invoke "as-call-last") (i32.const 14))
|
||||||
|
|
||||||
|
(assert_return (invoke "as-call_indirect-func") (i32.const 20))
|
||||||
|
(assert_return (invoke "as-call_indirect-first") (i32.const 21))
|
||||||
|
(assert_return (invoke "as-call_indirect-mid") (i32.const 22))
|
||||||
|
(assert_return (invoke "as-call_indirect-last") (i32.const 23))
|
||||||
|
|
||||||
|
(assert_return (invoke "as-set_local-value") (i32.const 17))
|
||||||
|
|
||||||
|
(assert_return (invoke "as-load-address") (f32.const 1.7))
|
||||||
|
(assert_return (invoke "as-loadN-address") (i64.const 30))
|
||||||
|
|
||||||
|
(assert_return (invoke "as-store-address") (i32.const 30))
|
||||||
|
(assert_return (invoke "as-store-value") (i32.const 31))
|
||||||
|
(assert_return (invoke "as-storeN-address") (i32.const 32))
|
||||||
|
(assert_return (invoke "as-storeN-value") (i32.const 33))
|
||||||
|
|
||||||
|
(assert_return (invoke "as-unary-operand") (f32.const 3.4))
|
||||||
|
|
||||||
|
(assert_return (invoke "as-binary-left") (i32.const 3))
|
||||||
|
(assert_return (invoke "as-binary-right") (i64.const 45))
|
||||||
|
|
||||||
|
(assert_return (invoke "as-test-operand") (i32.const 44))
|
||||||
|
|
||||||
|
(assert_return (invoke "as-compare-left") (i32.const 43))
|
||||||
|
(assert_return (invoke "as-compare-right") (i32.const 42))
|
||||||
|
|
||||||
|
(assert_return (invoke "as-convert-operand") (i32.const 41))
|
||||||
|
|
||||||
|
(assert_return (invoke "as-memory.grow-size") (i32.const 40))
|
||||||
|
|
||||||
|
(assert_return (invoke "nested-block-value") (i32.const 9))
|
||||||
|
(assert_return (invoke "nested-br-value") (i32.const 9))
|
||||||
|
(assert_return (invoke "nested-br_if-value") (i32.const 9))
|
||||||
|
(assert_return (invoke "nested-br_if-value-cond") (i32.const 9))
|
||||||
|
(assert_return (invoke "nested-br_table-value") (i32.const 9))
|
||||||
|
(assert_return (invoke "nested-br_table-value-index") (i32.const 9))
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-arg-empty-vs-num (result i32)
|
||||||
|
(block (result i32) (br 0) (i32.const 1))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-arg-void-vs-num (result i32)
|
||||||
|
(block (result i32) (br 0 (nop)) (i32.const 1))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-arg-void-vs-num-nested (result i32)
|
||||||
|
(block (result i32) (i32.const 0) (block (br 1)))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-arg-num-vs-num (result i32)
|
||||||
|
(block (result i32) (br 0 (i64.const 1)) (i32.const 1))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $unbound-label (br 1)))
|
||||||
|
"unknown label"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $unbound-nested-label (block (block (br 5)))))
|
||||||
|
"unknown label"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $large-label (br 0x10000001)))
|
||||||
|
"unknown label"
|
||||||
|
)
|
||||||
@@ -0,0 +1,321 @@
|
|||||||
|
;; Test `br_if` operator
|
||||||
|
|
||||||
|
(module
|
||||||
|
(func $dummy)
|
||||||
|
|
||||||
|
(func (export "as-block-first") (param i32) (result i32)
|
||||||
|
(block (br_if 0 (get_local 0)) (return (i32.const 2))) (i32.const 3)
|
||||||
|
)
|
||||||
|
(func (export "as-block-mid") (param i32) (result i32)
|
||||||
|
(block (call $dummy) (br_if 0 (get_local 0)) (return (i32.const 2)))
|
||||||
|
(i32.const 3)
|
||||||
|
)
|
||||||
|
(func (export "as-block-last") (param i32)
|
||||||
|
(block (call $dummy) (call $dummy) (br_if 0 (get_local 0)))
|
||||||
|
)
|
||||||
|
(func (export "as-block-first-value") (param i32) (result i32)
|
||||||
|
(block (result i32)
|
||||||
|
(drop (br_if 0 (i32.const 10) (get_local 0))) (return (i32.const 11))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(func (export "as-block-mid-value") (param i32) (result i32)
|
||||||
|
(block (result i32)
|
||||||
|
(call $dummy)
|
||||||
|
(drop (br_if 0 (i32.const 20) (get_local 0)))
|
||||||
|
(return (i32.const 21))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(func (export "as-block-last-value") (param i32) (result i32)
|
||||||
|
(block (result i32)
|
||||||
|
(call $dummy) (call $dummy) (br_if 0 (i32.const 11) (get_local 0))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "as-loop-first") (param i32) (result i32)
|
||||||
|
(block (loop (br_if 1 (get_local 0)) (return (i32.const 2)))) (i32.const 3)
|
||||||
|
)
|
||||||
|
(func (export "as-loop-mid") (param i32) (result i32)
|
||||||
|
(block (loop (call $dummy) (br_if 1 (get_local 0)) (return (i32.const 2))))
|
||||||
|
(i32.const 4)
|
||||||
|
)
|
||||||
|
(func (export "as-loop-last") (param i32)
|
||||||
|
(loop (call $dummy) (br_if 1 (get_local 0)))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "as-if-then") (param i32 i32)
|
||||||
|
(block
|
||||||
|
(if (get_local 0) (then (br_if 1 (get_local 1))) (else (call $dummy)))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(func (export "as-if-else") (param i32 i32)
|
||||||
|
(block
|
||||||
|
(if (get_local 0) (then (call $dummy)) (else (br_if 1 (get_local 1))))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "nested-block-value") (param i32) (result i32)
|
||||||
|
(i32.add
|
||||||
|
(i32.const 1)
|
||||||
|
(block (result i32)
|
||||||
|
(drop (i32.const 2))
|
||||||
|
(i32.add
|
||||||
|
(i32.const 4)
|
||||||
|
(block (result i32)
|
||||||
|
(drop (br_if 1 (i32.const 8) (get_local 0)))
|
||||||
|
(i32.const 16)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "nested-br-value") (param i32) (result i32)
|
||||||
|
(i32.add
|
||||||
|
(i32.const 1)
|
||||||
|
(block (result i32)
|
||||||
|
(drop (i32.const 2))
|
||||||
|
(br 0
|
||||||
|
(block (result i32)
|
||||||
|
(drop (br_if 1 (i32.const 8) (get_local 0))) (i32.const 4)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(i32.const 16)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "nested-br_if-value") (param i32) (result i32)
|
||||||
|
(i32.add
|
||||||
|
(i32.const 1)
|
||||||
|
(block (result i32)
|
||||||
|
(drop (i32.const 2))
|
||||||
|
(drop (br_if 0
|
||||||
|
(block (result i32)
|
||||||
|
(drop (br_if 1 (i32.const 8) (get_local 0))) (i32.const 4)
|
||||||
|
)
|
||||||
|
(i32.const 1)
|
||||||
|
))
|
||||||
|
(i32.const 16)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "nested-br_if-value-cond") (param i32) (result i32)
|
||||||
|
(i32.add
|
||||||
|
(i32.const 1)
|
||||||
|
(block (result i32)
|
||||||
|
(drop (i32.const 2))
|
||||||
|
(drop (br_if 0
|
||||||
|
(i32.const 4)
|
||||||
|
(block (result i32)
|
||||||
|
(drop (br_if 1 (i32.const 8) (get_local 0))) (i32.const 1)
|
||||||
|
)
|
||||||
|
))
|
||||||
|
(i32.const 16)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "nested-br_table-value") (param i32) (result i32)
|
||||||
|
(i32.add
|
||||||
|
(i32.const 1)
|
||||||
|
(block (result i32)
|
||||||
|
(drop (i32.const 2))
|
||||||
|
(br_table 0
|
||||||
|
(block (result i32)
|
||||||
|
(drop (br_if 1 (i32.const 8) (get_local 0))) (i32.const 4)
|
||||||
|
)
|
||||||
|
(i32.const 1)
|
||||||
|
)
|
||||||
|
(i32.const 16)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "nested-br_table-value-index") (param i32) (result i32)
|
||||||
|
(i32.add
|
||||||
|
(i32.const 1)
|
||||||
|
(block (result i32)
|
||||||
|
(drop (i32.const 2))
|
||||||
|
(br_table 0
|
||||||
|
(i32.const 4)
|
||||||
|
(block (result i32)
|
||||||
|
(drop (br_if 1 (i32.const 8) (get_local 0))) (i32.const 1)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(i32.const 16)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke "as-block-first" (i32.const 0)) (i32.const 2))
|
||||||
|
(assert_return (invoke "as-block-first" (i32.const 1)) (i32.const 3))
|
||||||
|
(assert_return (invoke "as-block-mid" (i32.const 0)) (i32.const 2))
|
||||||
|
(assert_return (invoke "as-block-mid" (i32.const 1)) (i32.const 3))
|
||||||
|
(assert_return (invoke "as-block-last" (i32.const 0)))
|
||||||
|
(assert_return (invoke "as-block-last" (i32.const 1)))
|
||||||
|
(assert_return (invoke "as-block-last-value" (i32.const 0)) (i32.const 11))
|
||||||
|
(assert_return (invoke "as-block-last-value" (i32.const 1)) (i32.const 11))
|
||||||
|
|
||||||
|
(assert_return (invoke "as-loop-first" (i32.const 0)) (i32.const 2))
|
||||||
|
(assert_return (invoke "as-loop-first" (i32.const 1)) (i32.const 3))
|
||||||
|
(assert_return (invoke "as-loop-mid" (i32.const 0)) (i32.const 2))
|
||||||
|
(assert_return (invoke "as-loop-mid" (i32.const 1)) (i32.const 4))
|
||||||
|
(assert_return (invoke "as-loop-last" (i32.const 0)))
|
||||||
|
(assert_return (invoke "as-loop-last" (i32.const 1)))
|
||||||
|
|
||||||
|
(assert_return (invoke "as-if-then" (i32.const 0) (i32.const 0)))
|
||||||
|
(assert_return (invoke "as-if-then" (i32.const 4) (i32.const 0)))
|
||||||
|
(assert_return (invoke "as-if-then" (i32.const 0) (i32.const 1)))
|
||||||
|
(assert_return (invoke "as-if-then" (i32.const 4) (i32.const 1)))
|
||||||
|
(assert_return (invoke "as-if-else" (i32.const 0) (i32.const 0)))
|
||||||
|
(assert_return (invoke "as-if-else" (i32.const 3) (i32.const 0)))
|
||||||
|
(assert_return (invoke "as-if-else" (i32.const 0) (i32.const 1)))
|
||||||
|
(assert_return (invoke "as-if-else" (i32.const 3) (i32.const 1)))
|
||||||
|
|
||||||
|
(assert_return (invoke "nested-block-value" (i32.const 0)) (i32.const 21))
|
||||||
|
(assert_return (invoke "nested-block-value" (i32.const 1)) (i32.const 9))
|
||||||
|
(assert_return (invoke "nested-br-value" (i32.const 0)) (i32.const 5))
|
||||||
|
(assert_return (invoke "nested-br-value" (i32.const 1)) (i32.const 9))
|
||||||
|
(assert_return (invoke "nested-br_if-value" (i32.const 0)) (i32.const 5))
|
||||||
|
(assert_return (invoke "nested-br_if-value" (i32.const 1)) (i32.const 9))
|
||||||
|
(assert_return (invoke "nested-br_if-value-cond" (i32.const 0)) (i32.const 5))
|
||||||
|
(assert_return (invoke "nested-br_if-value-cond" (i32.const 1)) (i32.const 9))
|
||||||
|
(assert_return (invoke "nested-br_table-value" (i32.const 0)) (i32.const 5))
|
||||||
|
(assert_return (invoke "nested-br_table-value" (i32.const 1)) (i32.const 9))
|
||||||
|
(assert_return (invoke "nested-br_table-value-index" (i32.const 0)) (i32.const 5))
|
||||||
|
(assert_return (invoke "nested-br_table-value-index" (i32.const 1)) (i32.const 9))
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-false-i32 (block (i32.ctz (br_if 0 (i32.const 0))))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-false-i64 (block (i64.ctz (br_if 0 (i32.const 0))))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-false-f32 (block (f32.neg (br_if 0 (i32.const 0))))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-false-f64 (block (f64.neg (br_if 0 (i32.const 0))))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-true-i32 (block (i32.ctz (br_if 0 (i32.const 1))))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-true-i64 (block (i64.ctz (br_if 0 (i64.const 1))))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-true-f32 (block (f32.neg (br_if 0 (f32.const 1))))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-true-f64 (block (f64.neg (br_if 0 (i64.const 1))))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-false-arg-void-vs-num (result i32)
|
||||||
|
(block (result i32) (br_if 0 (i32.const 0)) (i32.const 1))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-true-arg-void-vs-num (result i32)
|
||||||
|
(block (result i32) (br_if 0 (i32.const 1)) (i32.const 1))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-false-arg-num-vs-void
|
||||||
|
(block (br_if 0 (i32.const 0) (i32.const 0)))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-true-arg-num-vs-void
|
||||||
|
(block (br_if 0 (i32.const 0) (i32.const 1)))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-false-arg-void-vs-num (result i32)
|
||||||
|
(block (result i32) (br_if 0 (nop) (i32.const 0)) (i32.const 1))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-true-arg-void-vs-num (result i32)
|
||||||
|
(block (result i32) (br_if 0 (nop) (i32.const 1)) (i32.const 1))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-false-arg-num-vs-num (result i32)
|
||||||
|
(block (result i32)
|
||||||
|
(drop (br_if 0 (i64.const 1) (i32.const 0))) (i32.const 1)
|
||||||
|
)
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-true-arg-num-vs-num (result i32)
|
||||||
|
(block (result i32)
|
||||||
|
(drop (br_if 0 (i64.const 1) (i32.const 0))) (i32.const 1)
|
||||||
|
)
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-cond-void-vs-i32
|
||||||
|
(block (br_if 0 (nop)))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-cond-num-vs-i32
|
||||||
|
(block (br_if 0 (i64.const 0)))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-arg-cond-void-vs-i32 (result i32)
|
||||||
|
(block (result i32) (br_if 0 (i32.const 0) (nop)) (i32.const 1))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-arg-void-vs-num-nested (result i32)
|
||||||
|
(block (result i32) (i32.const 0) (block (br_if 1 (i32.const 1))))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-arg-cond-num-vs-i32 (result i32)
|
||||||
|
(block (result i32) (br_if 0 (i32.const 0) (i64.const 0)) (i32.const 1))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $unbound-label (br_if 1 (i32.const 1))))
|
||||||
|
"unknown label"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $unbound-nested-label (block (block (br_if 5 (i32.const 1))))))
|
||||||
|
"unknown label"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $large-label (br_if 0x10000001 (i32.const 1))))
|
||||||
|
"unknown label"
|
||||||
|
)
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,9 @@
|
|||||||
|
(module
|
||||||
|
(func (export "br") (block (br 0)))
|
||||||
|
(func (export "br_if") (block (br_if 0 (i32.const 1))))
|
||||||
|
(func (export "br_table") (block (br_table 0 (i32.const 0))))
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke "br"))
|
||||||
|
(assert_return (invoke "br_if"))
|
||||||
|
(assert_return (invoke "br_table"))
|
||||||
@@ -0,0 +1,242 @@
|
|||||||
|
;; Test `call` operator
|
||||||
|
|
||||||
|
(module
|
||||||
|
;; Auxiliary definitions
|
||||||
|
(func $const-i32 (result i32) (i32.const 0x132))
|
||||||
|
(func $const-i64 (result i64) (i64.const 0x164))
|
||||||
|
(func $const-f32 (result f32) (f32.const 0xf32))
|
||||||
|
(func $const-f64 (result f64) (f64.const 0xf64))
|
||||||
|
|
||||||
|
(func $id-i32 (param i32) (result i32) (get_local 0))
|
||||||
|
(func $id-i64 (param i64) (result i64) (get_local 0))
|
||||||
|
(func $id-f32 (param f32) (result f32) (get_local 0))
|
||||||
|
(func $id-f64 (param f64) (result f64) (get_local 0))
|
||||||
|
|
||||||
|
(func $f32-i32 (param f32 i32) (result i32) (get_local 1))
|
||||||
|
(func $i32-i64 (param i32 i64) (result i64) (get_local 1))
|
||||||
|
(func $f64-f32 (param f64 f32) (result f32) (get_local 1))
|
||||||
|
(func $i64-f64 (param i64 f64) (result f64) (get_local 1))
|
||||||
|
|
||||||
|
;; Typing
|
||||||
|
|
||||||
|
(func (export "type-i32") (result i32) (call $const-i32))
|
||||||
|
(func (export "type-i64") (result i64) (call $const-i64))
|
||||||
|
(func (export "type-f32") (result f32) (call $const-f32))
|
||||||
|
(func (export "type-f64") (result f64) (call $const-f64))
|
||||||
|
|
||||||
|
(func (export "type-first-i32") (result i32) (call $id-i32 (i32.const 32)))
|
||||||
|
(func (export "type-first-i64") (result i64) (call $id-i64 (i64.const 64)))
|
||||||
|
(func (export "type-first-f32") (result f32) (call $id-f32 (f32.const 1.32)))
|
||||||
|
(func (export "type-first-f64") (result f64) (call $id-f64 (f64.const 1.64)))
|
||||||
|
|
||||||
|
(func (export "type-second-i32") (result i32)
|
||||||
|
(call $f32-i32 (f32.const 32.1) (i32.const 32))
|
||||||
|
)
|
||||||
|
(func (export "type-second-i64") (result i64)
|
||||||
|
(call $i32-i64 (i32.const 32) (i64.const 64))
|
||||||
|
)
|
||||||
|
(func (export "type-second-f32") (result f32)
|
||||||
|
(call $f64-f32 (f64.const 64) (f32.const 32))
|
||||||
|
)
|
||||||
|
(func (export "type-second-f64") (result f64)
|
||||||
|
(call $i64-f64 (i64.const 64) (f64.const 64.1))
|
||||||
|
)
|
||||||
|
|
||||||
|
;; Recursion
|
||||||
|
|
||||||
|
(func $fac (export "fac") (param i64) (result i64)
|
||||||
|
(if (result i64) (i64.eqz (get_local 0))
|
||||||
|
(then (i64.const 1))
|
||||||
|
(else
|
||||||
|
(i64.mul
|
||||||
|
(get_local 0)
|
||||||
|
(call $fac (i64.sub (get_local 0) (i64.const 1)))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func $fac-acc (export "fac-acc") (param i64 i64) (result i64)
|
||||||
|
(if (result i64) (i64.eqz (get_local 0))
|
||||||
|
(then (get_local 1))
|
||||||
|
(else
|
||||||
|
(call $fac-acc
|
||||||
|
(i64.sub (get_local 0) (i64.const 1))
|
||||||
|
(i64.mul (get_local 0) (get_local 1))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func $fib (export "fib") (param i64) (result i64)
|
||||||
|
(if (result i64) (i64.le_u (get_local 0) (i64.const 1))
|
||||||
|
(then (i64.const 1))
|
||||||
|
(else
|
||||||
|
(i64.add
|
||||||
|
(call $fib (i64.sub (get_local 0) (i64.const 2)))
|
||||||
|
(call $fib (i64.sub (get_local 0) (i64.const 1)))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func $even (export "even") (param i64) (result i32)
|
||||||
|
(if (result i32) (i64.eqz (get_local 0))
|
||||||
|
(then (i32.const 44))
|
||||||
|
(else (call $odd (i64.sub (get_local 0) (i64.const 1))))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(func $odd (export "odd") (param i64) (result i32)
|
||||||
|
(if (result i32) (i64.eqz (get_local 0))
|
||||||
|
(then (i32.const 99))
|
||||||
|
(else (call $even (i64.sub (get_local 0) (i64.const 1))))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
;; Stack exhaustion
|
||||||
|
|
||||||
|
;; Implementations are required to have every call consume some abstract
|
||||||
|
;; resource towards exhausting some abstract finite limit, such that
|
||||||
|
;; infinitely recursive test cases reliably trap in finite time. This is
|
||||||
|
;; because otherwise applications could come to depend on it on those
|
||||||
|
;; implementations and be incompatible with implementations that don't do
|
||||||
|
;; it (or don't do it under the same circumstances).
|
||||||
|
|
||||||
|
(func $runaway (export "runaway") (call $runaway))
|
||||||
|
|
||||||
|
(func $mutual-runaway1 (export "mutual-runaway") (call $mutual-runaway2))
|
||||||
|
(func $mutual-runaway2 (call $mutual-runaway1))
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke "type-i32") (i32.const 0x132))
|
||||||
|
(assert_return (invoke "type-i64") (i64.const 0x164))
|
||||||
|
(assert_return (invoke "type-f32") (f32.const 0xf32))
|
||||||
|
(assert_return (invoke "type-f64") (f64.const 0xf64))
|
||||||
|
|
||||||
|
(assert_return (invoke "type-first-i32") (i32.const 32))
|
||||||
|
(assert_return (invoke "type-first-i64") (i64.const 64))
|
||||||
|
(assert_return (invoke "type-first-f32") (f32.const 1.32))
|
||||||
|
(assert_return (invoke "type-first-f64") (f64.const 1.64))
|
||||||
|
|
||||||
|
(assert_return (invoke "type-second-i32") (i32.const 32))
|
||||||
|
(assert_return (invoke "type-second-i64") (i64.const 64))
|
||||||
|
(assert_return (invoke "type-second-f32") (f32.const 32))
|
||||||
|
(assert_return (invoke "type-second-f64") (f64.const 64.1))
|
||||||
|
|
||||||
|
(assert_return (invoke "fac" (i64.const 0)) (i64.const 1))
|
||||||
|
(assert_return (invoke "fac" (i64.const 1)) (i64.const 1))
|
||||||
|
(assert_return (invoke "fac" (i64.const 5)) (i64.const 120))
|
||||||
|
(assert_return (invoke "fac" (i64.const 25)) (i64.const 7034535277573963776))
|
||||||
|
(assert_return (invoke "fac-acc" (i64.const 0) (i64.const 1)) (i64.const 1))
|
||||||
|
(assert_return (invoke "fac-acc" (i64.const 1) (i64.const 1)) (i64.const 1))
|
||||||
|
(assert_return (invoke "fac-acc" (i64.const 5) (i64.const 1)) (i64.const 120))
|
||||||
|
(assert_return
|
||||||
|
(invoke "fac-acc" (i64.const 25) (i64.const 1))
|
||||||
|
(i64.const 7034535277573963776)
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke "fib" (i64.const 0)) (i64.const 1))
|
||||||
|
(assert_return (invoke "fib" (i64.const 1)) (i64.const 1))
|
||||||
|
(assert_return (invoke "fib" (i64.const 2)) (i64.const 2))
|
||||||
|
(assert_return (invoke "fib" (i64.const 5)) (i64.const 8))
|
||||||
|
(assert_return (invoke "fib" (i64.const 20)) (i64.const 10946))
|
||||||
|
|
||||||
|
(assert_return (invoke "even" (i64.const 0)) (i32.const 44))
|
||||||
|
(assert_return (invoke "even" (i64.const 1)) (i32.const 99))
|
||||||
|
(assert_return (invoke "even" (i64.const 100)) (i32.const 44))
|
||||||
|
(assert_return (invoke "even" (i64.const 77)) (i32.const 99))
|
||||||
|
(assert_return (invoke "odd" (i64.const 0)) (i32.const 99))
|
||||||
|
(assert_return (invoke "odd" (i64.const 1)) (i32.const 44))
|
||||||
|
(assert_return (invoke "odd" (i64.const 200)) (i32.const 99))
|
||||||
|
(assert_return (invoke "odd" (i64.const 77)) (i32.const 44))
|
||||||
|
|
||||||
|
(assert_exhaustion (invoke "runaway") "call stack exhausted")
|
||||||
|
(assert_exhaustion (invoke "mutual-runaway") "call stack exhausted")
|
||||||
|
|
||||||
|
|
||||||
|
;; Invalid typing
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module
|
||||||
|
(func $type-void-vs-num (i32.eqz (call 1)))
|
||||||
|
(func)
|
||||||
|
)
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module
|
||||||
|
(func $type-num-vs-num (i32.eqz (call 1)))
|
||||||
|
(func (result i64) (i64.const 1))
|
||||||
|
)
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module
|
||||||
|
(func $arity-0-vs-1 (call 1))
|
||||||
|
(func (param i32))
|
||||||
|
)
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module
|
||||||
|
(func $arity-0-vs-2 (call 1))
|
||||||
|
(func (param f64 i32))
|
||||||
|
)
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module
|
||||||
|
(func $arity-1-vs-0 (call 1 (i32.const 1)))
|
||||||
|
(func)
|
||||||
|
)
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module
|
||||||
|
(func $arity-2-vs-0 (call 1 (f64.const 2) (i32.const 1)))
|
||||||
|
(func)
|
||||||
|
)
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module
|
||||||
|
(func $type-first-void-vs-num (call 1 (nop) (i32.const 1)))
|
||||||
|
(func (param i32 i32))
|
||||||
|
)
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module
|
||||||
|
(func $type-second-void-vs-num (call 1 (i32.const 1) (nop)))
|
||||||
|
(func (param i32 i32))
|
||||||
|
)
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module
|
||||||
|
(func $type-first-num-vs-num (call 1 (f64.const 1) (i32.const 1)))
|
||||||
|
(func (param i32 f64))
|
||||||
|
)
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module
|
||||||
|
(func $type-second-num-vs-num (call 1 (i32.const 1) (f64.const 1)))
|
||||||
|
(func (param f64 i32))
|
||||||
|
)
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
;; Unbound function
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $unbound-func (call 1)))
|
||||||
|
"unknown function"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $large-func (call 1012321300)))
|
||||||
|
"unknown function"
|
||||||
|
)
|
||||||
@@ -0,0 +1,536 @@
|
|||||||
|
;; Test `call_indirect` operator
|
||||||
|
|
||||||
|
(module
|
||||||
|
;; Auxiliary definitions
|
||||||
|
(type $proc (func))
|
||||||
|
(type $out-i32 (func (result i32)))
|
||||||
|
(type $out-i64 (func (result i64)))
|
||||||
|
(type $out-f32 (func (result f32)))
|
||||||
|
(type $out-f64 (func (result f64)))
|
||||||
|
(type $over-i32 (func (param i32) (result i32)))
|
||||||
|
(type $over-i64 (func (param i64) (result i64)))
|
||||||
|
(type $over-f32 (func (param f32) (result f32)))
|
||||||
|
(type $over-f64 (func (param f64) (result f64)))
|
||||||
|
(type $f32-i32 (func (param f32 i32) (result i32)))
|
||||||
|
(type $i32-i64 (func (param i32 i64) (result i64)))
|
||||||
|
(type $f64-f32 (func (param f64 f32) (result f32)))
|
||||||
|
(type $i64-f64 (func (param i64 f64) (result f64)))
|
||||||
|
(type $over-i32-duplicate (func (param i32) (result i32)))
|
||||||
|
(type $over-i64-duplicate (func (param i64) (result i64)))
|
||||||
|
(type $over-f32-duplicate (func (param f32) (result f32)))
|
||||||
|
(type $over-f64-duplicate (func (param f64) (result f64)))
|
||||||
|
|
||||||
|
(func $const-i32 (type $out-i32) (i32.const 0x132))
|
||||||
|
(func $const-i64 (type $out-i64) (i64.const 0x164))
|
||||||
|
(func $const-f32 (type $out-f32) (f32.const 0xf32))
|
||||||
|
(func $const-f64 (type $out-f64) (f64.const 0xf64))
|
||||||
|
|
||||||
|
(func $id-i32 (type $over-i32) (get_local 0))
|
||||||
|
(func $id-i64 (type $over-i64) (get_local 0))
|
||||||
|
(func $id-f32 (type $over-f32) (get_local 0))
|
||||||
|
(func $id-f64 (type $over-f64) (get_local 0))
|
||||||
|
|
||||||
|
(func $i32-i64 (type $i32-i64) (get_local 1))
|
||||||
|
(func $i64-f64 (type $i64-f64) (get_local 1))
|
||||||
|
(func $f32-i32 (type $f32-i32) (get_local 1))
|
||||||
|
(func $f64-f32 (type $f64-f32) (get_local 1))
|
||||||
|
|
||||||
|
(func $over-i32-duplicate (type $over-i32-duplicate) (get_local 0))
|
||||||
|
(func $over-i64-duplicate (type $over-i64-duplicate) (get_local 0))
|
||||||
|
(func $over-f32-duplicate (type $over-f32-duplicate) (get_local 0))
|
||||||
|
(func $over-f64-duplicate (type $over-f64-duplicate) (get_local 0))
|
||||||
|
|
||||||
|
(table anyfunc
|
||||||
|
(elem
|
||||||
|
$const-i32 $const-i64 $const-f32 $const-f64
|
||||||
|
$id-i32 $id-i64 $id-f32 $id-f64
|
||||||
|
$f32-i32 $i32-i64 $f64-f32 $i64-f64
|
||||||
|
$fac $fib $even $odd
|
||||||
|
$runaway $mutual-runaway1 $mutual-runaway2
|
||||||
|
$over-i32-duplicate $over-i64-duplicate
|
||||||
|
$over-f32-duplicate $over-f64-duplicate
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
;; Syntax
|
||||||
|
|
||||||
|
(func
|
||||||
|
(call_indirect (i32.const 0))
|
||||||
|
(call_indirect (param i64) (i64.const 0) (i32.const 0))
|
||||||
|
(call_indirect (param i64) (param) (param f64 i32 i64)
|
||||||
|
(i64.const 0) (f64.const 0) (i32.const 0) (i64.const 0) (i32.const 0)
|
||||||
|
)
|
||||||
|
(call_indirect (result) (i32.const 0))
|
||||||
|
(drop (i32.eqz (call_indirect (result i32) (i32.const 0))))
|
||||||
|
(drop (i32.eqz (call_indirect (result i32) (result) (i32.const 0))))
|
||||||
|
(drop (i32.eqz
|
||||||
|
(call_indirect (param i64) (result i32) (i64.const 0) (i32.const 0))
|
||||||
|
))
|
||||||
|
(drop (i32.eqz
|
||||||
|
(call_indirect
|
||||||
|
(param) (param i64) (param) (param f64 i32 i64) (param) (param)
|
||||||
|
(result) (result i32) (result) (result)
|
||||||
|
(i64.const 0) (f64.const 0) (i32.const 0) (i64.const 0) (i32.const 0)
|
||||||
|
)
|
||||||
|
))
|
||||||
|
(drop (i64.eqz
|
||||||
|
(call_indirect (type $over-i64) (param i64) (result i64)
|
||||||
|
(i64.const 0) (i32.const 0)
|
||||||
|
)
|
||||||
|
))
|
||||||
|
)
|
||||||
|
|
||||||
|
;; Typing
|
||||||
|
|
||||||
|
(func (export "type-i32") (result i32)
|
||||||
|
(call_indirect (type $out-i32) (i32.const 0))
|
||||||
|
)
|
||||||
|
(func (export "type-i64") (result i64)
|
||||||
|
(call_indirect (type $out-i64) (i32.const 1))
|
||||||
|
)
|
||||||
|
(func (export "type-f32") (result f32)
|
||||||
|
(call_indirect (type $out-f32) (i32.const 2))
|
||||||
|
)
|
||||||
|
(func (export "type-f64") (result f64)
|
||||||
|
(call_indirect (type $out-f64) (i32.const 3))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "type-index") (result i64)
|
||||||
|
(call_indirect (type $over-i64) (i64.const 100) (i32.const 5))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "type-first-i32") (result i32)
|
||||||
|
(call_indirect (type $over-i32) (i32.const 32) (i32.const 4))
|
||||||
|
)
|
||||||
|
(func (export "type-first-i64") (result i64)
|
||||||
|
(call_indirect (type $over-i64) (i64.const 64) (i32.const 5))
|
||||||
|
)
|
||||||
|
(func (export "type-first-f32") (result f32)
|
||||||
|
(call_indirect (type $over-f32) (f32.const 1.32) (i32.const 6))
|
||||||
|
)
|
||||||
|
(func (export "type-first-f64") (result f64)
|
||||||
|
(call_indirect (type $over-f64) (f64.const 1.64) (i32.const 7))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "type-second-i32") (result i32)
|
||||||
|
(call_indirect (type $f32-i32) (f32.const 32.1) (i32.const 32) (i32.const 8))
|
||||||
|
)
|
||||||
|
(func (export "type-second-i64") (result i64)
|
||||||
|
(call_indirect (type $i32-i64) (i32.const 32) (i64.const 64) (i32.const 9))
|
||||||
|
)
|
||||||
|
(func (export "type-second-f32") (result f32)
|
||||||
|
(call_indirect (type $f64-f32) (f64.const 64) (f32.const 32) (i32.const 10))
|
||||||
|
)
|
||||||
|
(func (export "type-second-f64") (result f64)
|
||||||
|
(call_indirect (type $i64-f64) (i64.const 64) (f64.const 64.1) (i32.const 11))
|
||||||
|
)
|
||||||
|
|
||||||
|
;; Dispatch
|
||||||
|
|
||||||
|
(func (export "dispatch") (param i32 i64) (result i64)
|
||||||
|
(call_indirect (type $over-i64) (get_local 1) (get_local 0))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "dispatch-structural") (param i32) (result i64)
|
||||||
|
(call_indirect (type $over-i64-duplicate) (i64.const 9) (get_local 0))
|
||||||
|
)
|
||||||
|
|
||||||
|
;; Recursion
|
||||||
|
|
||||||
|
(func $fac (export "fac") (type $over-i64)
|
||||||
|
(if (result i64) (i64.eqz (get_local 0))
|
||||||
|
(then (i64.const 1))
|
||||||
|
(else
|
||||||
|
(i64.mul
|
||||||
|
(get_local 0)
|
||||||
|
(call_indirect (type $over-i64)
|
||||||
|
(i64.sub (get_local 0) (i64.const 1))
|
||||||
|
(i32.const 12)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func $fib (export "fib") (type $over-i64)
|
||||||
|
(if (result i64) (i64.le_u (get_local 0) (i64.const 1))
|
||||||
|
(then (i64.const 1))
|
||||||
|
(else
|
||||||
|
(i64.add
|
||||||
|
(call_indirect (type $over-i64)
|
||||||
|
(i64.sub (get_local 0) (i64.const 2))
|
||||||
|
(i32.const 13)
|
||||||
|
)
|
||||||
|
(call_indirect (type $over-i64)
|
||||||
|
(i64.sub (get_local 0) (i64.const 1))
|
||||||
|
(i32.const 13)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func $even (export "even") (param i32) (result i32)
|
||||||
|
(if (result i32) (i32.eqz (get_local 0))
|
||||||
|
(then (i32.const 44))
|
||||||
|
(else
|
||||||
|
(call_indirect (type $over-i32)
|
||||||
|
(i32.sub (get_local 0) (i32.const 1))
|
||||||
|
(i32.const 15)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(func $odd (export "odd") (param i32) (result i32)
|
||||||
|
(if (result i32) (i32.eqz (get_local 0))
|
||||||
|
(then (i32.const 99))
|
||||||
|
(else
|
||||||
|
(call_indirect (type $over-i32)
|
||||||
|
(i32.sub (get_local 0) (i32.const 1))
|
||||||
|
(i32.const 14)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
;; Stack exhaustion
|
||||||
|
|
||||||
|
;; Implementations are required to have every call consume some abstract
|
||||||
|
;; resource towards exhausting some abstract finite limit, such that
|
||||||
|
;; infinitely recursive test cases reliably trap in finite time. This is
|
||||||
|
;; because otherwise applications could come to depend on it on those
|
||||||
|
;; implementations and be incompatible with implementations that don't do
|
||||||
|
;; it (or don't do it under the same circumstances).
|
||||||
|
|
||||||
|
(func $runaway (export "runaway") (call_indirect (type $proc) (i32.const 16)))
|
||||||
|
|
||||||
|
(func $mutual-runaway1 (export "mutual-runaway") (call_indirect (type $proc) (i32.const 18)))
|
||||||
|
(func $mutual-runaway2 (call_indirect (type $proc) (i32.const 17)))
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke "type-i32") (i32.const 0x132))
|
||||||
|
(assert_return (invoke "type-i64") (i64.const 0x164))
|
||||||
|
(assert_return (invoke "type-f32") (f32.const 0xf32))
|
||||||
|
(assert_return (invoke "type-f64") (f64.const 0xf64))
|
||||||
|
|
||||||
|
(assert_return (invoke "type-index") (i64.const 100))
|
||||||
|
|
||||||
|
(assert_return (invoke "type-first-i32") (i32.const 32))
|
||||||
|
(assert_return (invoke "type-first-i64") (i64.const 64))
|
||||||
|
(assert_return (invoke "type-first-f32") (f32.const 1.32))
|
||||||
|
(assert_return (invoke "type-first-f64") (f64.const 1.64))
|
||||||
|
|
||||||
|
(assert_return (invoke "type-second-i32") (i32.const 32))
|
||||||
|
(assert_return (invoke "type-second-i64") (i64.const 64))
|
||||||
|
(assert_return (invoke "type-second-f32") (f32.const 32))
|
||||||
|
(assert_return (invoke "type-second-f64") (f64.const 64.1))
|
||||||
|
|
||||||
|
(assert_return (invoke "dispatch" (i32.const 5) (i64.const 2)) (i64.const 2))
|
||||||
|
(assert_return (invoke "dispatch" (i32.const 5) (i64.const 5)) (i64.const 5))
|
||||||
|
(assert_return (invoke "dispatch" (i32.const 12) (i64.const 5)) (i64.const 120))
|
||||||
|
(assert_return (invoke "dispatch" (i32.const 13) (i64.const 5)) (i64.const 8))
|
||||||
|
(assert_return (invoke "dispatch" (i32.const 20) (i64.const 2)) (i64.const 2))
|
||||||
|
(assert_trap (invoke "dispatch" (i32.const 0) (i64.const 2)) "indirect call type mismatch")
|
||||||
|
(assert_trap (invoke "dispatch" (i32.const 15) (i64.const 2)) "indirect call type mismatch")
|
||||||
|
(assert_trap (invoke "dispatch" (i32.const 23) (i64.const 2)) "undefined element")
|
||||||
|
(assert_trap (invoke "dispatch" (i32.const -1) (i64.const 2)) "undefined element")
|
||||||
|
(assert_trap (invoke "dispatch" (i32.const 1213432423) (i64.const 2)) "undefined element")
|
||||||
|
|
||||||
|
(assert_return (invoke "dispatch-structural" (i32.const 5)) (i64.const 9))
|
||||||
|
(assert_return (invoke "dispatch-structural" (i32.const 5)) (i64.const 9))
|
||||||
|
(assert_return (invoke "dispatch-structural" (i32.const 12)) (i64.const 362880))
|
||||||
|
(assert_return (invoke "dispatch-structural" (i32.const 20)) (i64.const 9))
|
||||||
|
(assert_trap (invoke "dispatch-structural" (i32.const 11)) "indirect call type mismatch")
|
||||||
|
(assert_trap (invoke "dispatch-structural" (i32.const 22)) "indirect call type mismatch")
|
||||||
|
|
||||||
|
(assert_return (invoke "fac" (i64.const 0)) (i64.const 1))
|
||||||
|
(assert_return (invoke "fac" (i64.const 1)) (i64.const 1))
|
||||||
|
(assert_return (invoke "fac" (i64.const 5)) (i64.const 120))
|
||||||
|
(assert_return (invoke "fac" (i64.const 25)) (i64.const 7034535277573963776))
|
||||||
|
|
||||||
|
(assert_return (invoke "fib" (i64.const 0)) (i64.const 1))
|
||||||
|
(assert_return (invoke "fib" (i64.const 1)) (i64.const 1))
|
||||||
|
(assert_return (invoke "fib" (i64.const 2)) (i64.const 2))
|
||||||
|
(assert_return (invoke "fib" (i64.const 5)) (i64.const 8))
|
||||||
|
(assert_return (invoke "fib" (i64.const 20)) (i64.const 10946))
|
||||||
|
|
||||||
|
(assert_return (invoke "even" (i32.const 0)) (i32.const 44))
|
||||||
|
(assert_return (invoke "even" (i32.const 1)) (i32.const 99))
|
||||||
|
(assert_return (invoke "even" (i32.const 100)) (i32.const 44))
|
||||||
|
(assert_return (invoke "even" (i32.const 77)) (i32.const 99))
|
||||||
|
(assert_return (invoke "odd" (i32.const 0)) (i32.const 99))
|
||||||
|
(assert_return (invoke "odd" (i32.const 1)) (i32.const 44))
|
||||||
|
(assert_return (invoke "odd" (i32.const 200)) (i32.const 99))
|
||||||
|
(assert_return (invoke "odd" (i32.const 77)) (i32.const 44))
|
||||||
|
|
||||||
|
(assert_exhaustion (invoke "runaway") "call stack exhausted")
|
||||||
|
(assert_exhaustion (invoke "mutual-runaway") "call stack exhausted")
|
||||||
|
|
||||||
|
|
||||||
|
;; Invalid syntax
|
||||||
|
|
||||||
|
(assert_malformed
|
||||||
|
(module quote
|
||||||
|
"(type $sig (func (param i32) (result i32)))"
|
||||||
|
"(table 0 anyfunc)"
|
||||||
|
"(func (result i32)"
|
||||||
|
" (call_indirect (type $sig) (result i32) (param i32)"
|
||||||
|
" (i32.const 0) (i32.const 0)"
|
||||||
|
" )"
|
||||||
|
")"
|
||||||
|
)
|
||||||
|
"unexpected token"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote
|
||||||
|
"(type $sig (func (param i32) (result i32)))"
|
||||||
|
"(table 0 anyfunc)"
|
||||||
|
"(func (result i32)"
|
||||||
|
" (call_indirect (param i32) (type $sig) (result i32)"
|
||||||
|
" (i32.const 0) (i32.const 0)"
|
||||||
|
" )"
|
||||||
|
")"
|
||||||
|
)
|
||||||
|
"unexpected token"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote
|
||||||
|
"(type $sig (func (param i32) (result i32)))"
|
||||||
|
"(table 0 anyfunc)"
|
||||||
|
"(func (result i32)"
|
||||||
|
" (call_indirect (param i32) (result i32) (type $sig)"
|
||||||
|
" (i32.const 0) (i32.const 0)"
|
||||||
|
" )"
|
||||||
|
")"
|
||||||
|
)
|
||||||
|
"unexpected token"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote
|
||||||
|
"(type $sig (func (param i32) (result i32)))"
|
||||||
|
"(table 0 anyfunc)"
|
||||||
|
"(func (result i32)"
|
||||||
|
" (call_indirect (result i32) (type $sig) (param i32)"
|
||||||
|
" (i32.const 0) (i32.const 0)"
|
||||||
|
" )"
|
||||||
|
")"
|
||||||
|
)
|
||||||
|
"unexpected token"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote
|
||||||
|
"(type $sig (func (param i32) (result i32)))"
|
||||||
|
"(table 0 anyfunc)"
|
||||||
|
"(func (result i32)"
|
||||||
|
" (call_indirect (result i32) (param i32) (type $sig)"
|
||||||
|
" (i32.const 0) (i32.const 0)"
|
||||||
|
" )"
|
||||||
|
")"
|
||||||
|
)
|
||||||
|
"unexpected token"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote
|
||||||
|
"(table 0 anyfunc)"
|
||||||
|
"(func (result i32)"
|
||||||
|
" (call_indirect (result i32) (param i32) (i32.const 0) (i32.const 0))"
|
||||||
|
")"
|
||||||
|
)
|
||||||
|
"unexpected token"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_malformed
|
||||||
|
(module quote
|
||||||
|
"(table 0 anyfunc)"
|
||||||
|
"(func (call_indirect (param $x i32) (i32.const 0) (i32.const 0)))"
|
||||||
|
)
|
||||||
|
"unexpected token"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote
|
||||||
|
"(type $sig (func))"
|
||||||
|
"(table 0 anyfunc)"
|
||||||
|
"(func (result i32)"
|
||||||
|
" (call_indirect (type $sig) (result i32) (i32.const 0))"
|
||||||
|
")"
|
||||||
|
)
|
||||||
|
"inline function type"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote
|
||||||
|
"(type $sig (func (param i32) (result i32)))"
|
||||||
|
"(table 0 anyfunc)"
|
||||||
|
"(func (result i32)"
|
||||||
|
" (call_indirect (type $sig) (result i32) (i32.const 0))"
|
||||||
|
")"
|
||||||
|
)
|
||||||
|
"inline function type"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote
|
||||||
|
"(type $sig (func (param i32) (result i32)))"
|
||||||
|
"(table 0 anyfunc)"
|
||||||
|
"(func"
|
||||||
|
" (call_indirect (type $sig) (param i32) (i32.const 0) (i32.const 0))"
|
||||||
|
")"
|
||||||
|
)
|
||||||
|
"inline function type"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote
|
||||||
|
"(type $sig (func (param i32 i32) (result i32)))"
|
||||||
|
"(table 0 anyfunc)"
|
||||||
|
"(func (result i32)"
|
||||||
|
" (call_indirect (type $sig) (param i32) (result i32)"
|
||||||
|
" (i32.const 0) (i32.const 0)"
|
||||||
|
" )"
|
||||||
|
")"
|
||||||
|
)
|
||||||
|
"inline function type"
|
||||||
|
)
|
||||||
|
|
||||||
|
;; Invalid typing
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module
|
||||||
|
(type (func))
|
||||||
|
(func $no-table (call_indirect (type 0) (i32.const 0)))
|
||||||
|
)
|
||||||
|
"unknown table"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module
|
||||||
|
(type (func))
|
||||||
|
(table 0 anyfunc)
|
||||||
|
(func $type-void-vs-num (i32.eqz (call_indirect (type 0) (i32.const 0))))
|
||||||
|
)
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module
|
||||||
|
(type (func (result i64)))
|
||||||
|
(table 0 anyfunc)
|
||||||
|
(func $type-num-vs-num (i32.eqz (call_indirect (type 0) (i32.const 0))))
|
||||||
|
)
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module
|
||||||
|
(type (func (param i32)))
|
||||||
|
(table 0 anyfunc)
|
||||||
|
(func $arity-0-vs-1 (call_indirect (type 0) (i32.const 0)))
|
||||||
|
)
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module
|
||||||
|
(type (func (param f64 i32)))
|
||||||
|
(table 0 anyfunc)
|
||||||
|
(func $arity-0-vs-2 (call_indirect (type 0) (i32.const 0)))
|
||||||
|
)
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module
|
||||||
|
(type (func))
|
||||||
|
(table 0 anyfunc)
|
||||||
|
(func $arity-1-vs-0 (call_indirect (type 0) (i32.const 1) (i32.const 0)))
|
||||||
|
)
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module
|
||||||
|
(type (func))
|
||||||
|
(table 0 anyfunc)
|
||||||
|
(func $arity-2-vs-0
|
||||||
|
(call_indirect (type 0) (f64.const 2) (i32.const 1) (i32.const 0))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module
|
||||||
|
(type (func (param i32)))
|
||||||
|
(table 0 anyfunc)
|
||||||
|
(func $type-func-void-vs-i32 (call_indirect (type 0) (i32.const 1) (nop)))
|
||||||
|
)
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module
|
||||||
|
(type (func (param i32)))
|
||||||
|
(table 0 anyfunc)
|
||||||
|
(func $type-func-num-vs-i32 (call_indirect (type 0) (i32.const 0) (i64.const 1)))
|
||||||
|
)
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module
|
||||||
|
(type (func (param i32 i32)))
|
||||||
|
(table 0 anyfunc)
|
||||||
|
(func $type-first-void-vs-num
|
||||||
|
(call_indirect (type 0) (nop) (i32.const 1) (i32.const 0))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module
|
||||||
|
(type (func (param i32 i32)))
|
||||||
|
(table 0 anyfunc)
|
||||||
|
(func $type-second-void-vs-num
|
||||||
|
(call_indirect (type 0) (i32.const 1) (nop) (i32.const 0))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module
|
||||||
|
(type (func (param i32 f64)))
|
||||||
|
(table 0 anyfunc)
|
||||||
|
(func $type-first-num-vs-num
|
||||||
|
(call_indirect (type 0) (f64.const 1) (i32.const 1) (i32.const 0))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module
|
||||||
|
(type (func (param f64 i32)))
|
||||||
|
(table 0 anyfunc)
|
||||||
|
(func $type-second-num-vs-num
|
||||||
|
(call_indirect (type 0) (i32.const 1) (f64.const 1) (i32.const 0))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
;; Unbound type
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module
|
||||||
|
(table 0 anyfunc)
|
||||||
|
(func $unbound-type (call_indirect (type 1) (i32.const 0)))
|
||||||
|
)
|
||||||
|
"unknown type"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module
|
||||||
|
(table 0 anyfunc)
|
||||||
|
(func $large-type (call_indirect (type 1012321300) (i32.const 0)))
|
||||||
|
)
|
||||||
|
"unknown type"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
;; Unbound function in table
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (table anyfunc (elem 0 0)))
|
||||||
|
"unknown function 0"
|
||||||
|
)
|
||||||
Binary file not shown.
@@ -0,0 +1,137 @@
|
|||||||
|
;; Test t.const instructions
|
||||||
|
|
||||||
|
;; Syntax error
|
||||||
|
|
||||||
|
(module (func (i32.const 0xffffffff) drop))
|
||||||
|
(module (func (i32.const -0x80000000) drop))
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(func (i32.const 0x100000000) drop)")
|
||||||
|
"constant out of range"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(func (i32.const -0x80000001) drop)")
|
||||||
|
"constant out of range"
|
||||||
|
)
|
||||||
|
|
||||||
|
(module (func (i32.const 4294967295) drop))
|
||||||
|
(module (func (i32.const -2147483648) drop))
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(func (i32.const 4294967296) drop)")
|
||||||
|
"constant out of range"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(func (i32.const -2147483649) drop)")
|
||||||
|
"constant out of range"
|
||||||
|
)
|
||||||
|
|
||||||
|
(module (func (i64.const 0xffffffffffffffff) drop))
|
||||||
|
(module (func (i64.const -0x8000000000000000) drop))
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(func (i64.const 0x10000000000000000) drop)")
|
||||||
|
"constant out of range"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(func (i64.const -0x8000000000000001) drop)")
|
||||||
|
"constant out of range"
|
||||||
|
)
|
||||||
|
|
||||||
|
(module (func (i64.const 18446744073709551615) drop))
|
||||||
|
(module (func (i64.const -9223372036854775808) drop))
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(func (i64.const 18446744073709551616) drop)")
|
||||||
|
"constant out of range"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(func (i64.const -9223372036854775809) drop)")
|
||||||
|
"constant out of range"
|
||||||
|
)
|
||||||
|
|
||||||
|
(module (func (f32.const 0x1p127) drop))
|
||||||
|
(module (func (f32.const -0x1p127) drop))
|
||||||
|
(module (func (f32.const 0x1.fffffep127) drop))
|
||||||
|
(module (func (f32.const -0x1.fffffep127) drop))
|
||||||
|
(module (func (f32.const 0x1.fffffe7p127) drop))
|
||||||
|
(module (func (f32.const -0x1.fffffe7p127) drop))
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(func (f32.const 0x1p128) drop)")
|
||||||
|
"constant out of range"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(func (f32.const -0x1p128) drop)")
|
||||||
|
"constant out of range"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(func (f32.const 0x1.ffffffp127) drop)")
|
||||||
|
"constant out of range"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(func (f32.const -0x1.ffffffp127) drop)")
|
||||||
|
"constant out of range"
|
||||||
|
)
|
||||||
|
|
||||||
|
(module (func (f32.const 1e38) drop))
|
||||||
|
(module (func (f32.const -1e38) drop))
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(func (f32.const 1e39) drop)")
|
||||||
|
"constant out of range"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(func (f32.const -1e39) drop)")
|
||||||
|
"constant out of range"
|
||||||
|
)
|
||||||
|
|
||||||
|
(module (func (f32.const 340282356779733623858607532500980858880) drop))
|
||||||
|
(module (func (f32.const -340282356779733623858607532500980858880) drop))
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(func (f32.const 340282356779733661637539395458142568448) drop)")
|
||||||
|
"constant out of range"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(func (f32.const -340282356779733661637539395458142568448) drop)")
|
||||||
|
"constant out of range"
|
||||||
|
)
|
||||||
|
|
||||||
|
(module (func (f64.const 0x1p1023) drop))
|
||||||
|
(module (func (f64.const -0x1p1023) drop))
|
||||||
|
(module (func (f64.const 0x1.fffffffffffffp1023) drop))
|
||||||
|
(module (func (f64.const -0x1.fffffffffffffp1023) drop))
|
||||||
|
(module (func (f64.const 0x1.fffffffffffff7p1023) drop))
|
||||||
|
(module (func (f64.const -0x1.fffffffffffff7p1023) drop))
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(func (f64.const 0x1p1024) drop)")
|
||||||
|
"constant out of range"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(func (f64.const -0x1p1024) drop)")
|
||||||
|
"constant out of range"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(func (f64.const 0x1.fffffffffffff8p1023) drop)")
|
||||||
|
"constant out of range"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(func (f64.const -0x1.fffffffffffff8p1023) drop)")
|
||||||
|
"constant out of range"
|
||||||
|
)
|
||||||
|
|
||||||
|
(module (func (f64.const 1e308) drop))
|
||||||
|
(module (func (f64.const -1e308) drop))
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(func (f64.const 1e309) drop)")
|
||||||
|
"constant out of range"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(func (f64.const -1e309) drop)")
|
||||||
|
"constant out of range"
|
||||||
|
)
|
||||||
|
|
||||||
|
(module (func (f64.const 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368) drop))
|
||||||
|
(module (func (f64.const -179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368) drop))
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(func (f64.const 269653970229347356221791135597556535197105851288767494898376215204735891170042808140884337949150317257310688430271573696351481990334196274152701320055306275479074865864826923114368235135583993416113802762682700913456874855354834422248712838998185022412196739306217084753107265771378949821875606039276187287552) drop)")
|
||||||
|
"constant out of range"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(func (f64.const -269653970229347356221791135597556535197105851288767494898376215204735891170042808140884337949150317257310688430271573696351481990334196274152701320055306275479074865864826923114368235135583993416113802762682700913456874855354834422248712838998185022412196739306217084753107265771378949821875606039276187287552) drop)")
|
||||||
|
"constant out of range"
|
||||||
|
)
|
||||||
@@ -0,0 +1,461 @@
|
|||||||
|
(module
|
||||||
|
(func (export "i64.extend_s_i32") (param $x i32) (result i64) (i64.extend_s/i32 (get_local $x)))
|
||||||
|
(func (export "i64.extend_u_i32") (param $x i32) (result i64) (i64.extend_u/i32 (get_local $x)))
|
||||||
|
(func (export "i32.wrap_i64") (param $x i64) (result i32) (i32.wrap/i64 (get_local $x)))
|
||||||
|
(func (export "i32.trunc_s_f32") (param $x f32) (result i32) (i32.trunc_s/f32 (get_local $x)))
|
||||||
|
(func (export "i32.trunc_u_f32") (param $x f32) (result i32) (i32.trunc_u/f32 (get_local $x)))
|
||||||
|
(func (export "i32.trunc_s_f64") (param $x f64) (result i32) (i32.trunc_s/f64 (get_local $x)))
|
||||||
|
(func (export "i32.trunc_u_f64") (param $x f64) (result i32) (i32.trunc_u/f64 (get_local $x)))
|
||||||
|
(func (export "i64.trunc_s_f32") (param $x f32) (result i64) (i64.trunc_s/f32 (get_local $x)))
|
||||||
|
(func (export "i64.trunc_u_f32") (param $x f32) (result i64) (i64.trunc_u/f32 (get_local $x)))
|
||||||
|
(func (export "i64.trunc_s_f64") (param $x f64) (result i64) (i64.trunc_s/f64 (get_local $x)))
|
||||||
|
(func (export "i64.trunc_u_f64") (param $x f64) (result i64) (i64.trunc_u/f64 (get_local $x)))
|
||||||
|
(func (export "f32.convert_s_i32") (param $x i32) (result f32) (f32.convert_s/i32 (get_local $x)))
|
||||||
|
(func (export "f32.convert_s_i64") (param $x i64) (result f32) (f32.convert_s/i64 (get_local $x)))
|
||||||
|
(func (export "f64.convert_s_i32") (param $x i32) (result f64) (f64.convert_s/i32 (get_local $x)))
|
||||||
|
(func (export "f64.convert_s_i64") (param $x i64) (result f64) (f64.convert_s/i64 (get_local $x)))
|
||||||
|
(func (export "f32.convert_u_i32") (param $x i32) (result f32) (f32.convert_u/i32 (get_local $x)))
|
||||||
|
(func (export "f32.convert_u_i64") (param $x i64) (result f32) (f32.convert_u/i64 (get_local $x)))
|
||||||
|
(func (export "f64.convert_u_i32") (param $x i32) (result f64) (f64.convert_u/i32 (get_local $x)))
|
||||||
|
(func (export "f64.convert_u_i64") (param $x i64) (result f64) (f64.convert_u/i64 (get_local $x)))
|
||||||
|
(func (export "f64.promote_f32") (param $x f32) (result f64) (f64.promote/f32 (get_local $x)))
|
||||||
|
(func (export "f32.demote_f64") (param $x f64) (result f32) (f32.demote/f64 (get_local $x)))
|
||||||
|
(func (export "f32.reinterpret_i32") (param $x i32) (result f32) (f32.reinterpret/i32 (get_local $x)))
|
||||||
|
(func (export "f64.reinterpret_i64") (param $x i64) (result f64) (f64.reinterpret/i64 (get_local $x)))
|
||||||
|
(func (export "i32.reinterpret_f32") (param $x f32) (result i32) (i32.reinterpret/f32 (get_local $x)))
|
||||||
|
(func (export "i64.reinterpret_f64") (param $x f64) (result i64) (i64.reinterpret/f64 (get_local $x)))
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke "i64.extend_s_i32" (i32.const 0)) (i64.const 0))
|
||||||
|
(assert_return (invoke "i64.extend_s_i32" (i32.const 10000)) (i64.const 10000))
|
||||||
|
(assert_return (invoke "i64.extend_s_i32" (i32.const -10000)) (i64.const -10000))
|
||||||
|
(assert_return (invoke "i64.extend_s_i32" (i32.const -1)) (i64.const -1))
|
||||||
|
(assert_return (invoke "i64.extend_s_i32" (i32.const 0x7fffffff)) (i64.const 0x000000007fffffff))
|
||||||
|
(assert_return (invoke "i64.extend_s_i32" (i32.const 0x80000000)) (i64.const 0xffffffff80000000))
|
||||||
|
|
||||||
|
(assert_return (invoke "i64.extend_u_i32" (i32.const 0)) (i64.const 0))
|
||||||
|
(assert_return (invoke "i64.extend_u_i32" (i32.const 10000)) (i64.const 10000))
|
||||||
|
(assert_return (invoke "i64.extend_u_i32" (i32.const -10000)) (i64.const 0x00000000ffffd8f0))
|
||||||
|
(assert_return (invoke "i64.extend_u_i32" (i32.const -1)) (i64.const 0xffffffff))
|
||||||
|
(assert_return (invoke "i64.extend_u_i32" (i32.const 0x7fffffff)) (i64.const 0x000000007fffffff))
|
||||||
|
(assert_return (invoke "i64.extend_u_i32" (i32.const 0x80000000)) (i64.const 0x0000000080000000))
|
||||||
|
|
||||||
|
(assert_return (invoke "i32.wrap_i64" (i64.const -1)) (i32.const -1))
|
||||||
|
(assert_return (invoke "i32.wrap_i64" (i64.const -100000)) (i32.const -100000))
|
||||||
|
(assert_return (invoke "i32.wrap_i64" (i64.const 0x80000000)) (i32.const 0x80000000))
|
||||||
|
(assert_return (invoke "i32.wrap_i64" (i64.const 0xffffffff7fffffff)) (i32.const 0x7fffffff))
|
||||||
|
(assert_return (invoke "i32.wrap_i64" (i64.const 0xffffffff00000000)) (i32.const 0x00000000))
|
||||||
|
(assert_return (invoke "i32.wrap_i64" (i64.const 0xfffffffeffffffff)) (i32.const 0xffffffff))
|
||||||
|
(assert_return (invoke "i32.wrap_i64" (i64.const 0xffffffff00000001)) (i32.const 0x00000001))
|
||||||
|
(assert_return (invoke "i32.wrap_i64" (i64.const 0)) (i32.const 0))
|
||||||
|
(assert_return (invoke "i32.wrap_i64" (i64.const 1311768467463790320)) (i32.const 0x9abcdef0))
|
||||||
|
(assert_return (invoke "i32.wrap_i64" (i64.const 0x00000000ffffffff)) (i32.const 0xffffffff))
|
||||||
|
(assert_return (invoke "i32.wrap_i64" (i64.const 0x0000000100000000)) (i32.const 0x00000000))
|
||||||
|
(assert_return (invoke "i32.wrap_i64" (i64.const 0x0000000100000001)) (i32.const 0x00000001))
|
||||||
|
|
||||||
|
(assert_return (invoke "i32.trunc_s_f32" (f32.const 0.0)) (i32.const 0))
|
||||||
|
(assert_return (invoke "i32.trunc_s_f32" (f32.const -0.0)) (i32.const 0))
|
||||||
|
(assert_return (invoke "i32.trunc_s_f32" (f32.const 0x1p-149)) (i32.const 0))
|
||||||
|
(assert_return (invoke "i32.trunc_s_f32" (f32.const -0x1p-149)) (i32.const 0))
|
||||||
|
(assert_return (invoke "i32.trunc_s_f32" (f32.const 1.0)) (i32.const 1))
|
||||||
|
(assert_return (invoke "i32.trunc_s_f32" (f32.const 0x1.19999ap+0)) (i32.const 1))
|
||||||
|
(assert_return (invoke "i32.trunc_s_f32" (f32.const 1.5)) (i32.const 1))
|
||||||
|
(assert_return (invoke "i32.trunc_s_f32" (f32.const -1.0)) (i32.const -1))
|
||||||
|
(assert_return (invoke "i32.trunc_s_f32" (f32.const -0x1.19999ap+0)) (i32.const -1))
|
||||||
|
(assert_return (invoke "i32.trunc_s_f32" (f32.const -1.5)) (i32.const -1))
|
||||||
|
(assert_return (invoke "i32.trunc_s_f32" (f32.const -1.9)) (i32.const -1))
|
||||||
|
(assert_return (invoke "i32.trunc_s_f32" (f32.const -2.0)) (i32.const -2))
|
||||||
|
(assert_return (invoke "i32.trunc_s_f32" (f32.const 2147483520.0)) (i32.const 2147483520))
|
||||||
|
(assert_return (invoke "i32.trunc_s_f32" (f32.const -2147483648.0)) (i32.const -2147483648))
|
||||||
|
(assert_trap (invoke "i32.trunc_s_f32" (f32.const 2147483648.0)) "integer overflow")
|
||||||
|
(assert_trap (invoke "i32.trunc_s_f32" (f32.const -2147483904.0)) "integer overflow")
|
||||||
|
(assert_trap (invoke "i32.trunc_s_f32" (f32.const inf)) "integer overflow")
|
||||||
|
(assert_trap (invoke "i32.trunc_s_f32" (f32.const -inf)) "integer overflow")
|
||||||
|
(assert_trap (invoke "i32.trunc_s_f32" (f32.const nan)) "invalid conversion to integer")
|
||||||
|
(assert_trap (invoke "i32.trunc_s_f32" (f32.const nan:0x200000)) "invalid conversion to integer")
|
||||||
|
(assert_trap (invoke "i32.trunc_s_f32" (f32.const -nan)) "invalid conversion to integer")
|
||||||
|
(assert_trap (invoke "i32.trunc_s_f32" (f32.const -nan:0x200000)) "invalid conversion to integer")
|
||||||
|
|
||||||
|
(assert_return (invoke "i32.trunc_u_f32" (f32.const 0.0)) (i32.const 0))
|
||||||
|
(assert_return (invoke "i32.trunc_u_f32" (f32.const -0.0)) (i32.const 0))
|
||||||
|
(assert_return (invoke "i32.trunc_u_f32" (f32.const 0x1p-149)) (i32.const 0))
|
||||||
|
(assert_return (invoke "i32.trunc_u_f32" (f32.const -0x1p-149)) (i32.const 0))
|
||||||
|
(assert_return (invoke "i32.trunc_u_f32" (f32.const 1.0)) (i32.const 1))
|
||||||
|
(assert_return (invoke "i32.trunc_u_f32" (f32.const 0x1.19999ap+0)) (i32.const 1))
|
||||||
|
(assert_return (invoke "i32.trunc_u_f32" (f32.const 1.5)) (i32.const 1))
|
||||||
|
(assert_return (invoke "i32.trunc_u_f32" (f32.const 1.9)) (i32.const 1))
|
||||||
|
(assert_return (invoke "i32.trunc_u_f32" (f32.const 2.0)) (i32.const 2))
|
||||||
|
(assert_return (invoke "i32.trunc_u_f32" (f32.const 2147483648)) (i32.const -2147483648)) ;; 0x1.00000p+31 -> 8000 0000
|
||||||
|
(assert_return (invoke "i32.trunc_u_f32" (f32.const 4294967040.0)) (i32.const -256))
|
||||||
|
(assert_return (invoke "i32.trunc_u_f32" (f32.const -0x1.ccccccp-1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "i32.trunc_u_f32" (f32.const -0x1.fffffep-1)) (i32.const 0))
|
||||||
|
(assert_trap (invoke "i32.trunc_u_f32" (f32.const 4294967296.0)) "integer overflow")
|
||||||
|
(assert_trap (invoke "i32.trunc_u_f32" (f32.const -1.0)) "integer overflow")
|
||||||
|
(assert_trap (invoke "i32.trunc_u_f32" (f32.const inf)) "integer overflow")
|
||||||
|
(assert_trap (invoke "i32.trunc_u_f32" (f32.const -inf)) "integer overflow")
|
||||||
|
(assert_trap (invoke "i32.trunc_u_f32" (f32.const nan)) "invalid conversion to integer")
|
||||||
|
(assert_trap (invoke "i32.trunc_u_f32" (f32.const nan:0x200000)) "invalid conversion to integer")
|
||||||
|
(assert_trap (invoke "i32.trunc_u_f32" (f32.const -nan)) "invalid conversion to integer")
|
||||||
|
(assert_trap (invoke "i32.trunc_u_f32" (f32.const -nan:0x200000)) "invalid conversion to integer")
|
||||||
|
|
||||||
|
(assert_return (invoke "i32.trunc_s_f64" (f64.const 0.0)) (i32.const 0))
|
||||||
|
(assert_return (invoke "i32.trunc_s_f64" (f64.const -0.0)) (i32.const 0))
|
||||||
|
(assert_return (invoke "i32.trunc_s_f64" (f64.const 0x0.0000000000001p-1022)) (i32.const 0))
|
||||||
|
(assert_return (invoke "i32.trunc_s_f64" (f64.const -0x0.0000000000001p-1022)) (i32.const 0))
|
||||||
|
(assert_return (invoke "i32.trunc_s_f64" (f64.const 1.0)) (i32.const 1))
|
||||||
|
(assert_return (invoke "i32.trunc_s_f64" (f64.const 0x1.199999999999ap+0)) (i32.const 1))
|
||||||
|
(assert_return (invoke "i32.trunc_s_f64" (f64.const 1.5)) (i32.const 1))
|
||||||
|
(assert_return (invoke "i32.trunc_s_f64" (f64.const -1.0)) (i32.const -1))
|
||||||
|
(assert_return (invoke "i32.trunc_s_f64" (f64.const -0x1.199999999999ap+0)) (i32.const -1))
|
||||||
|
(assert_return (invoke "i32.trunc_s_f64" (f64.const -1.5)) (i32.const -1))
|
||||||
|
(assert_return (invoke "i32.trunc_s_f64" (f64.const -1.9)) (i32.const -1))
|
||||||
|
(assert_return (invoke "i32.trunc_s_f64" (f64.const -2.0)) (i32.const -2))
|
||||||
|
(assert_return (invoke "i32.trunc_s_f64" (f64.const 2147483647.0)) (i32.const 2147483647))
|
||||||
|
(assert_return (invoke "i32.trunc_s_f64" (f64.const -2147483648.0)) (i32.const -2147483648))
|
||||||
|
(assert_trap (invoke "i32.trunc_s_f64" (f64.const 2147483648.0)) "integer overflow")
|
||||||
|
(assert_trap (invoke "i32.trunc_s_f64" (f64.const -2147483649.0)) "integer overflow")
|
||||||
|
(assert_trap (invoke "i32.trunc_s_f64" (f64.const inf)) "integer overflow")
|
||||||
|
(assert_trap (invoke "i32.trunc_s_f64" (f64.const -inf)) "integer overflow")
|
||||||
|
(assert_trap (invoke "i32.trunc_s_f64" (f64.const nan)) "invalid conversion to integer")
|
||||||
|
(assert_trap (invoke "i32.trunc_s_f64" (f64.const nan:0x4000000000000)) "invalid conversion to integer")
|
||||||
|
(assert_trap (invoke "i32.trunc_s_f64" (f64.const -nan)) "invalid conversion to integer")
|
||||||
|
(assert_trap (invoke "i32.trunc_s_f64" (f64.const -nan:0x4000000000000)) "invalid conversion to integer")
|
||||||
|
|
||||||
|
(assert_return (invoke "i32.trunc_u_f64" (f64.const 0.0)) (i32.const 0))
|
||||||
|
(assert_return (invoke "i32.trunc_u_f64" (f64.const -0.0)) (i32.const 0))
|
||||||
|
(assert_return (invoke "i32.trunc_u_f64" (f64.const 0x0.0000000000001p-1022)) (i32.const 0))
|
||||||
|
(assert_return (invoke "i32.trunc_u_f64" (f64.const -0x0.0000000000001p-1022)) (i32.const 0))
|
||||||
|
(assert_return (invoke "i32.trunc_u_f64" (f64.const 1.0)) (i32.const 1))
|
||||||
|
(assert_return (invoke "i32.trunc_u_f64" (f64.const 0x1.199999999999ap+0)) (i32.const 1))
|
||||||
|
(assert_return (invoke "i32.trunc_u_f64" (f64.const 1.5)) (i32.const 1))
|
||||||
|
(assert_return (invoke "i32.trunc_u_f64" (f64.const 1.9)) (i32.const 1))
|
||||||
|
(assert_return (invoke "i32.trunc_u_f64" (f64.const 2.0)) (i32.const 2))
|
||||||
|
(assert_return (invoke "i32.trunc_u_f64" (f64.const 2147483648)) (i32.const -2147483648)) ;; 0x1.00000p+31 -> 8000 0000
|
||||||
|
(assert_return (invoke "i32.trunc_u_f64" (f64.const 4294967295.0)) (i32.const -1))
|
||||||
|
(assert_return (invoke "i32.trunc_u_f64" (f64.const -0x1.ccccccccccccdp-1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "i32.trunc_u_f64" (f64.const -0x1.fffffffffffffp-1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "i32.trunc_u_f64" (f64.const 1e8)) (i32.const 100000000))
|
||||||
|
(assert_trap (invoke "i32.trunc_u_f64" (f64.const 4294967296.0)) "integer overflow")
|
||||||
|
(assert_trap (invoke "i32.trunc_u_f64" (f64.const -1.0)) "integer overflow")
|
||||||
|
(assert_trap (invoke "i32.trunc_u_f64" (f64.const 1e16)) "integer overflow")
|
||||||
|
(assert_trap (invoke "i32.trunc_u_f64" (f64.const 1e30)) "integer overflow")
|
||||||
|
(assert_trap (invoke "i32.trunc_u_f64" (f64.const 9223372036854775808)) "integer overflow")
|
||||||
|
(assert_trap (invoke "i32.trunc_u_f64" (f64.const inf)) "integer overflow")
|
||||||
|
(assert_trap (invoke "i32.trunc_u_f64" (f64.const -inf)) "integer overflow")
|
||||||
|
(assert_trap (invoke "i32.trunc_u_f64" (f64.const nan)) "invalid conversion to integer")
|
||||||
|
(assert_trap (invoke "i32.trunc_u_f64" (f64.const nan:0x4000000000000)) "invalid conversion to integer")
|
||||||
|
(assert_trap (invoke "i32.trunc_u_f64" (f64.const -nan)) "invalid conversion to integer")
|
||||||
|
(assert_trap (invoke "i32.trunc_u_f64" (f64.const -nan:0x4000000000000)) "invalid conversion to integer")
|
||||||
|
|
||||||
|
(assert_return (invoke "i64.trunc_s_f32" (f32.const 0.0)) (i64.const 0))
|
||||||
|
(assert_return (invoke "i64.trunc_s_f32" (f32.const -0.0)) (i64.const 0))
|
||||||
|
(assert_return (invoke "i64.trunc_s_f32" (f32.const 0x1p-149)) (i64.const 0))
|
||||||
|
(assert_return (invoke "i64.trunc_s_f32" (f32.const -0x1p-149)) (i64.const 0))
|
||||||
|
(assert_return (invoke "i64.trunc_s_f32" (f32.const 1.0)) (i64.const 1))
|
||||||
|
(assert_return (invoke "i64.trunc_s_f32" (f32.const 0x1.19999ap+0)) (i64.const 1))
|
||||||
|
(assert_return (invoke "i64.trunc_s_f32" (f32.const 1.5)) (i64.const 1))
|
||||||
|
(assert_return (invoke "i64.trunc_s_f32" (f32.const -1.0)) (i64.const -1))
|
||||||
|
(assert_return (invoke "i64.trunc_s_f32" (f32.const -0x1.19999ap+0)) (i64.const -1))
|
||||||
|
(assert_return (invoke "i64.trunc_s_f32" (f32.const -1.5)) (i64.const -1))
|
||||||
|
(assert_return (invoke "i64.trunc_s_f32" (f32.const -1.9)) (i64.const -1))
|
||||||
|
(assert_return (invoke "i64.trunc_s_f32" (f32.const -2.0)) (i64.const -2))
|
||||||
|
(assert_return (invoke "i64.trunc_s_f32" (f32.const 4294967296)) (i64.const 4294967296)) ;; 0x1.00000p+32 -> 1 0000 0000
|
||||||
|
(assert_return (invoke "i64.trunc_s_f32" (f32.const -4294967296)) (i64.const -4294967296)) ;; -0x1.00000p+32 -> ffff ffff 0000 0000
|
||||||
|
(assert_return (invoke "i64.trunc_s_f32" (f32.const 9223371487098961920.0)) (i64.const 9223371487098961920))
|
||||||
|
(assert_return (invoke "i64.trunc_s_f32" (f32.const -9223372036854775808.0)) (i64.const -9223372036854775808))
|
||||||
|
(assert_trap (invoke "i64.trunc_s_f32" (f32.const 9223372036854775808.0)) "integer overflow")
|
||||||
|
(assert_trap (invoke "i64.trunc_s_f32" (f32.const -9223373136366403584.0)) "integer overflow")
|
||||||
|
(assert_trap (invoke "i64.trunc_s_f32" (f32.const inf)) "integer overflow")
|
||||||
|
(assert_trap (invoke "i64.trunc_s_f32" (f32.const -inf)) "integer overflow")
|
||||||
|
(assert_trap (invoke "i64.trunc_s_f32" (f32.const nan)) "invalid conversion to integer")
|
||||||
|
(assert_trap (invoke "i64.trunc_s_f32" (f32.const nan:0x200000)) "invalid conversion to integer")
|
||||||
|
(assert_trap (invoke "i64.trunc_s_f32" (f32.const -nan)) "invalid conversion to integer")
|
||||||
|
(assert_trap (invoke "i64.trunc_s_f32" (f32.const -nan:0x200000)) "invalid conversion to integer")
|
||||||
|
|
||||||
|
(assert_return (invoke "i64.trunc_u_f32" (f32.const 0.0)) (i64.const 0))
|
||||||
|
(assert_return (invoke "i64.trunc_u_f32" (f32.const -0.0)) (i64.const 0))
|
||||||
|
(assert_return (invoke "i64.trunc_u_f32" (f32.const 0x1p-149)) (i64.const 0))
|
||||||
|
(assert_return (invoke "i64.trunc_u_f32" (f32.const -0x1p-149)) (i64.const 0))
|
||||||
|
(assert_return (invoke "i64.trunc_u_f32" (f32.const 1.0)) (i64.const 1))
|
||||||
|
(assert_return (invoke "i64.trunc_u_f32" (f32.const 0x1.19999ap+0)) (i64.const 1))
|
||||||
|
(assert_return (invoke "i64.trunc_u_f32" (f32.const 1.5)) (i64.const 1))
|
||||||
|
(assert_return (invoke "i64.trunc_u_f32" (f32.const 4294967296)) (i64.const 4294967296))
|
||||||
|
(assert_return (invoke "i64.trunc_u_f32" (f32.const 18446742974197923840.0)) (i64.const -1099511627776))
|
||||||
|
(assert_return (invoke "i64.trunc_u_f32" (f32.const -0x1.ccccccp-1)) (i64.const 0))
|
||||||
|
(assert_return (invoke "i64.trunc_u_f32" (f32.const -0x1.fffffep-1)) (i64.const 0))
|
||||||
|
(assert_trap (invoke "i64.trunc_u_f32" (f32.const 18446744073709551616.0)) "integer overflow")
|
||||||
|
(assert_trap (invoke "i64.trunc_u_f32" (f32.const -1.0)) "integer overflow")
|
||||||
|
(assert_trap (invoke "i64.trunc_u_f32" (f32.const inf)) "integer overflow")
|
||||||
|
(assert_trap (invoke "i64.trunc_u_f32" (f32.const -inf)) "integer overflow")
|
||||||
|
(assert_trap (invoke "i64.trunc_u_f32" (f32.const nan)) "invalid conversion to integer")
|
||||||
|
(assert_trap (invoke "i64.trunc_u_f32" (f32.const nan:0x200000)) "invalid conversion to integer")
|
||||||
|
(assert_trap (invoke "i64.trunc_u_f32" (f32.const -nan)) "invalid conversion to integer")
|
||||||
|
(assert_trap (invoke "i64.trunc_u_f32" (f32.const -nan:0x200000)) "invalid conversion to integer")
|
||||||
|
|
||||||
|
(assert_return (invoke "i64.trunc_s_f64" (f64.const 0.0)) (i64.const 0))
|
||||||
|
(assert_return (invoke "i64.trunc_s_f64" (f64.const -0.0)) (i64.const 0))
|
||||||
|
(assert_return (invoke "i64.trunc_s_f64" (f64.const 0x0.0000000000001p-1022)) (i64.const 0))
|
||||||
|
(assert_return (invoke "i64.trunc_s_f64" (f64.const -0x0.0000000000001p-1022)) (i64.const 0))
|
||||||
|
(assert_return (invoke "i64.trunc_s_f64" (f64.const 1.0)) (i64.const 1))
|
||||||
|
(assert_return (invoke "i64.trunc_s_f64" (f64.const 0x1.199999999999ap+0)) (i64.const 1))
|
||||||
|
(assert_return (invoke "i64.trunc_s_f64" (f64.const 1.5)) (i64.const 1))
|
||||||
|
(assert_return (invoke "i64.trunc_s_f64" (f64.const -1.0)) (i64.const -1))
|
||||||
|
(assert_return (invoke "i64.trunc_s_f64" (f64.const -0x1.199999999999ap+0)) (i64.const -1))
|
||||||
|
(assert_return (invoke "i64.trunc_s_f64" (f64.const -1.5)) (i64.const -1))
|
||||||
|
(assert_return (invoke "i64.trunc_s_f64" (f64.const -1.9)) (i64.const -1))
|
||||||
|
(assert_return (invoke "i64.trunc_s_f64" (f64.const -2.0)) (i64.const -2))
|
||||||
|
(assert_return (invoke "i64.trunc_s_f64" (f64.const 4294967296)) (i64.const 4294967296)) ;; 0x1.00000p+32 -> 1 0000 0000
|
||||||
|
(assert_return (invoke "i64.trunc_s_f64" (f64.const -4294967296)) (i64.const -4294967296)) ;; -0x1.00000p+32 -> ffff ffff 0000 0000
|
||||||
|
(assert_return (invoke "i64.trunc_s_f64" (f64.const 9223372036854774784.0)) (i64.const 9223372036854774784))
|
||||||
|
(assert_return (invoke "i64.trunc_s_f64" (f64.const -9223372036854775808.0)) (i64.const -9223372036854775808))
|
||||||
|
(assert_trap (invoke "i64.trunc_s_f64" (f64.const 9223372036854775808.0)) "integer overflow")
|
||||||
|
(assert_trap (invoke "i64.trunc_s_f64" (f64.const -9223372036854777856.0)) "integer overflow")
|
||||||
|
(assert_trap (invoke "i64.trunc_s_f64" (f64.const inf)) "integer overflow")
|
||||||
|
(assert_trap (invoke "i64.trunc_s_f64" (f64.const -inf)) "integer overflow")
|
||||||
|
(assert_trap (invoke "i64.trunc_s_f64" (f64.const nan)) "invalid conversion to integer")
|
||||||
|
(assert_trap (invoke "i64.trunc_s_f64" (f64.const nan:0x4000000000000)) "invalid conversion to integer")
|
||||||
|
(assert_trap (invoke "i64.trunc_s_f64" (f64.const -nan)) "invalid conversion to integer")
|
||||||
|
(assert_trap (invoke "i64.trunc_s_f64" (f64.const -nan:0x4000000000000)) "invalid conversion to integer")
|
||||||
|
|
||||||
|
(assert_return (invoke "i64.trunc_u_f64" (f64.const 0.0)) (i64.const 0))
|
||||||
|
(assert_return (invoke "i64.trunc_u_f64" (f64.const -0.0)) (i64.const 0))
|
||||||
|
(assert_return (invoke "i64.trunc_u_f64" (f64.const 0x0.0000000000001p-1022)) (i64.const 0))
|
||||||
|
(assert_return (invoke "i64.trunc_u_f64" (f64.const -0x0.0000000000001p-1022)) (i64.const 0))
|
||||||
|
(assert_return (invoke "i64.trunc_u_f64" (f64.const 1.0)) (i64.const 1))
|
||||||
|
(assert_return (invoke "i64.trunc_u_f64" (f64.const 0x1.199999999999ap+0)) (i64.const 1))
|
||||||
|
(assert_return (invoke "i64.trunc_u_f64" (f64.const 1.5)) (i64.const 1))
|
||||||
|
(assert_return (invoke "i64.trunc_u_f64" (f64.const 4294967295)) (i64.const 0xffffffff))
|
||||||
|
(assert_return (invoke "i64.trunc_u_f64" (f64.const 4294967296)) (i64.const 0x100000000))
|
||||||
|
(assert_return (invoke "i64.trunc_u_f64" (f64.const 18446744073709549568.0)) (i64.const -2048))
|
||||||
|
(assert_return (invoke "i64.trunc_u_f64" (f64.const -0x1.ccccccccccccdp-1)) (i64.const 0))
|
||||||
|
(assert_return (invoke "i64.trunc_u_f64" (f64.const -0x1.fffffffffffffp-1)) (i64.const 0))
|
||||||
|
(assert_return (invoke "i64.trunc_u_f64" (f64.const 1e8)) (i64.const 100000000))
|
||||||
|
(assert_return (invoke "i64.trunc_u_f64" (f64.const 1e16)) (i64.const 10000000000000000))
|
||||||
|
(assert_return (invoke "i64.trunc_u_f64" (f64.const 9223372036854775808)) (i64.const -9223372036854775808))
|
||||||
|
(assert_trap (invoke "i64.trunc_u_f64" (f64.const 18446744073709551616.0)) "integer overflow")
|
||||||
|
(assert_trap (invoke "i64.trunc_u_f64" (f64.const -1.0)) "integer overflow")
|
||||||
|
(assert_trap (invoke "i64.trunc_u_f64" (f64.const inf)) "integer overflow")
|
||||||
|
(assert_trap (invoke "i64.trunc_u_f64" (f64.const -inf)) "integer overflow")
|
||||||
|
(assert_trap (invoke "i64.trunc_u_f64" (f64.const nan)) "invalid conversion to integer")
|
||||||
|
(assert_trap (invoke "i64.trunc_u_f64" (f64.const nan:0x4000000000000)) "invalid conversion to integer")
|
||||||
|
(assert_trap (invoke "i64.trunc_u_f64" (f64.const -nan)) "invalid conversion to integer")
|
||||||
|
(assert_trap (invoke "i64.trunc_u_f64" (f64.const -nan:0x4000000000000)) "invalid conversion to integer")
|
||||||
|
|
||||||
|
(assert_return (invoke "f32.convert_s_i32" (i32.const 1)) (f32.const 1.0))
|
||||||
|
(assert_return (invoke "f32.convert_s_i32" (i32.const -1)) (f32.const -1.0))
|
||||||
|
(assert_return (invoke "f32.convert_s_i32" (i32.const 0)) (f32.const 0.0))
|
||||||
|
(assert_return (invoke "f32.convert_s_i32" (i32.const 2147483647)) (f32.const 2147483648))
|
||||||
|
(assert_return (invoke "f32.convert_s_i32" (i32.const -2147483648)) (f32.const -2147483648))
|
||||||
|
(assert_return (invoke "f32.convert_s_i32" (i32.const 1234567890)) (f32.const 0x1.26580cp+30))
|
||||||
|
;; Test rounding directions.
|
||||||
|
(assert_return (invoke "f32.convert_s_i32" (i32.const 16777217)) (f32.const 16777216.0))
|
||||||
|
(assert_return (invoke "f32.convert_s_i32" (i32.const -16777217)) (f32.const -16777216.0))
|
||||||
|
(assert_return (invoke "f32.convert_s_i32" (i32.const 16777219)) (f32.const 16777220.0))
|
||||||
|
(assert_return (invoke "f32.convert_s_i32" (i32.const -16777219)) (f32.const -16777220.0))
|
||||||
|
|
||||||
|
(assert_return (invoke "f32.convert_s_i64" (i64.const 1)) (f32.const 1.0))
|
||||||
|
(assert_return (invoke "f32.convert_s_i64" (i64.const -1)) (f32.const -1.0))
|
||||||
|
(assert_return (invoke "f32.convert_s_i64" (i64.const 0)) (f32.const 0.0))
|
||||||
|
(assert_return (invoke "f32.convert_s_i64" (i64.const 9223372036854775807)) (f32.const 9223372036854775807))
|
||||||
|
(assert_return (invoke "f32.convert_s_i64" (i64.const -9223372036854775808)) (f32.const -9223372036854775808))
|
||||||
|
(assert_return (invoke "f32.convert_s_i64" (i64.const 314159265358979)) (f32.const 0x1.1db9e8p+48)) ;; PI
|
||||||
|
;; Test rounding directions.
|
||||||
|
(assert_return (invoke "f32.convert_s_i64" (i64.const 16777217)) (f32.const 16777216.0))
|
||||||
|
(assert_return (invoke "f32.convert_s_i64" (i64.const -16777217)) (f32.const -16777216.0))
|
||||||
|
(assert_return (invoke "f32.convert_s_i64" (i64.const 16777219)) (f32.const 16777220.0))
|
||||||
|
(assert_return (invoke "f32.convert_s_i64" (i64.const -16777219)) (f32.const -16777220.0))
|
||||||
|
|
||||||
|
(assert_return (invoke "f64.convert_s_i32" (i32.const 1)) (f64.const 1.0))
|
||||||
|
(assert_return (invoke "f64.convert_s_i32" (i32.const -1)) (f64.const -1.0))
|
||||||
|
(assert_return (invoke "f64.convert_s_i32" (i32.const 0)) (f64.const 0.0))
|
||||||
|
(assert_return (invoke "f64.convert_s_i32" (i32.const 2147483647)) (f64.const 2147483647))
|
||||||
|
(assert_return (invoke "f64.convert_s_i32" (i32.const -2147483648)) (f64.const -2147483648))
|
||||||
|
(assert_return (invoke "f64.convert_s_i32" (i32.const 987654321)) (f64.const 987654321))
|
||||||
|
|
||||||
|
(assert_return (invoke "f64.convert_s_i64" (i64.const 1)) (f64.const 1.0))
|
||||||
|
(assert_return (invoke "f64.convert_s_i64" (i64.const -1)) (f64.const -1.0))
|
||||||
|
(assert_return (invoke "f64.convert_s_i64" (i64.const 0)) (f64.const 0.0))
|
||||||
|
(assert_return (invoke "f64.convert_s_i64" (i64.const 9223372036854775807)) (f64.const 9223372036854775807))
|
||||||
|
(assert_return (invoke "f64.convert_s_i64" (i64.const -9223372036854775808)) (f64.const -9223372036854775808))
|
||||||
|
(assert_return (invoke "f64.convert_s_i64" (i64.const 4669201609102990)) (f64.const 4669201609102990)) ;; Feigenbaum
|
||||||
|
;; Test rounding directions.
|
||||||
|
(assert_return (invoke "f64.convert_s_i64" (i64.const 9007199254740993)) (f64.const 9007199254740992))
|
||||||
|
(assert_return (invoke "f64.convert_s_i64" (i64.const -9007199254740993)) (f64.const -9007199254740992))
|
||||||
|
(assert_return (invoke "f64.convert_s_i64" (i64.const 9007199254740995)) (f64.const 9007199254740996))
|
||||||
|
(assert_return (invoke "f64.convert_s_i64" (i64.const -9007199254740995)) (f64.const -9007199254740996))
|
||||||
|
|
||||||
|
(assert_return (invoke "f32.convert_u_i32" (i32.const 1)) (f32.const 1.0))
|
||||||
|
(assert_return (invoke "f32.convert_u_i32" (i32.const 0)) (f32.const 0.0))
|
||||||
|
(assert_return (invoke "f32.convert_u_i32" (i32.const 2147483647)) (f32.const 2147483648))
|
||||||
|
(assert_return (invoke "f32.convert_u_i32" (i32.const -2147483648)) (f32.const 2147483648))
|
||||||
|
(assert_return (invoke "f32.convert_u_i32" (i32.const 0x12345678)) (f32.const 0x1.234568p+28))
|
||||||
|
(assert_return (invoke "f32.convert_u_i32" (i32.const 0xffffffff)) (f32.const 4294967296.0))
|
||||||
|
(assert_return (invoke "f32.convert_u_i32" (i32.const 0x80000080)) (f32.const 0x1.000000p+31))
|
||||||
|
(assert_return (invoke "f32.convert_u_i32" (i32.const 0x80000081)) (f32.const 0x1.000002p+31))
|
||||||
|
(assert_return (invoke "f32.convert_u_i32" (i32.const 0x80000082)) (f32.const 0x1.000002p+31))
|
||||||
|
(assert_return (invoke "f32.convert_u_i32" (i32.const 0xfffffe80)) (f32.const 0x1.fffffcp+31))
|
||||||
|
(assert_return (invoke "f32.convert_u_i32" (i32.const 0xfffffe81)) (f32.const 0x1.fffffep+31))
|
||||||
|
(assert_return (invoke "f32.convert_u_i32" (i32.const 0xfffffe82)) (f32.const 0x1.fffffep+31))
|
||||||
|
;; Test rounding directions.
|
||||||
|
(assert_return (invoke "f32.convert_u_i32" (i32.const 16777217)) (f32.const 16777216.0))
|
||||||
|
(assert_return (invoke "f32.convert_u_i32" (i32.const 16777219)) (f32.const 16777220.0))
|
||||||
|
|
||||||
|
(assert_return (invoke "f32.convert_u_i64" (i64.const 1)) (f32.const 1.0))
|
||||||
|
(assert_return (invoke "f32.convert_u_i64" (i64.const 0)) (f32.const 0.0))
|
||||||
|
(assert_return (invoke "f32.convert_u_i64" (i64.const 9223372036854775807)) (f32.const 9223372036854775807))
|
||||||
|
(assert_return (invoke "f32.convert_u_i64" (i64.const -9223372036854775808)) (f32.const 9223372036854775808))
|
||||||
|
(assert_return (invoke "f32.convert_u_i64" (i64.const 0xffffffffffffffff)) (f32.const 18446744073709551616.0))
|
||||||
|
;; Test rounding directions.
|
||||||
|
(assert_return (invoke "f32.convert_u_i64" (i64.const 16777217)) (f32.const 16777216.0))
|
||||||
|
(assert_return (invoke "f32.convert_u_i64" (i64.const 16777219)) (f32.const 16777220.0))
|
||||||
|
|
||||||
|
(assert_return (invoke "f64.convert_u_i32" (i32.const 1)) (f64.const 1.0))
|
||||||
|
(assert_return (invoke "f64.convert_u_i32" (i32.const 0)) (f64.const 0.0))
|
||||||
|
(assert_return (invoke "f64.convert_u_i32" (i32.const 2147483647)) (f64.const 2147483647))
|
||||||
|
(assert_return (invoke "f64.convert_u_i32" (i32.const -2147483648)) (f64.const 2147483648))
|
||||||
|
(assert_return (invoke "f64.convert_u_i32" (i32.const 0xffffffff)) (f64.const 4294967295.0))
|
||||||
|
|
||||||
|
(assert_return (invoke "f64.convert_u_i64" (i64.const 1)) (f64.const 1.0))
|
||||||
|
(assert_return (invoke "f64.convert_u_i64" (i64.const 0)) (f64.const 0.0))
|
||||||
|
(assert_return (invoke "f64.convert_u_i64" (i64.const 9223372036854775807)) (f64.const 9223372036854775807))
|
||||||
|
(assert_return (invoke "f64.convert_u_i64" (i64.const -9223372036854775808)) (f64.const 9223372036854775808))
|
||||||
|
(assert_return (invoke "f64.convert_u_i64" (i64.const 0xffffffffffffffff)) (f64.const 18446744073709551616.0))
|
||||||
|
(assert_return (invoke "f64.convert_u_i64" (i64.const 0x8000000000000400)) (f64.const 0x1.0000000000000p+63))
|
||||||
|
(assert_return (invoke "f64.convert_u_i64" (i64.const 0x8000000000000401)) (f64.const 0x1.0000000000001p+63))
|
||||||
|
(assert_return (invoke "f64.convert_u_i64" (i64.const 0x8000000000000402)) (f64.const 0x1.0000000000001p+63))
|
||||||
|
(assert_return (invoke "f64.convert_u_i64" (i64.const 0xfffffffffffff400)) (f64.const 0x1.ffffffffffffep+63))
|
||||||
|
(assert_return (invoke "f64.convert_u_i64" (i64.const 0xfffffffffffff401)) (f64.const 0x1.fffffffffffffp+63))
|
||||||
|
(assert_return (invoke "f64.convert_u_i64" (i64.const 0xfffffffffffff402)) (f64.const 0x1.fffffffffffffp+63))
|
||||||
|
;; Test rounding directions.
|
||||||
|
(assert_return (invoke "f64.convert_u_i64" (i64.const 9007199254740993)) (f64.const 9007199254740992))
|
||||||
|
(assert_return (invoke "f64.convert_u_i64" (i64.const 9007199254740995)) (f64.const 9007199254740996))
|
||||||
|
|
||||||
|
(assert_return (invoke "f64.promote_f32" (f32.const 0.0)) (f64.const 0.0))
|
||||||
|
(assert_return (invoke "f64.promote_f32" (f32.const -0.0)) (f64.const -0.0))
|
||||||
|
(assert_return (invoke "f64.promote_f32" (f32.const 0x1p-149)) (f64.const 0x1p-149))
|
||||||
|
(assert_return (invoke "f64.promote_f32" (f32.const -0x1p-149)) (f64.const -0x1p-149))
|
||||||
|
(assert_return (invoke "f64.promote_f32" (f32.const 1.0)) (f64.const 1.0))
|
||||||
|
(assert_return (invoke "f64.promote_f32" (f32.const -1.0)) (f64.const -1.0))
|
||||||
|
(assert_return (invoke "f64.promote_f32" (f32.const -0x1.fffffep+127)) (f64.const -0x1.fffffep+127))
|
||||||
|
(assert_return (invoke "f64.promote_f32" (f32.const 0x1.fffffep+127)) (f64.const 0x1.fffffep+127))
|
||||||
|
;; Generated randomly by picking a random int and reinterpret it to float.
|
||||||
|
(assert_return (invoke "f64.promote_f32" (f32.const 0x1p-119)) (f64.const 0x1p-119))
|
||||||
|
;; Generated randomly by picking a random float.
|
||||||
|
(assert_return (invoke "f64.promote_f32" (f32.const 0x1.8f867ep+125)) (f64.const 6.6382536710104395e+37))
|
||||||
|
(assert_return (invoke "f64.promote_f32" (f32.const inf)) (f64.const inf))
|
||||||
|
(assert_return (invoke "f64.promote_f32" (f32.const -inf)) (f64.const -inf))
|
||||||
|
(assert_return_canonical_nan (invoke "f64.promote_f32" (f32.const nan)))
|
||||||
|
(assert_return_arithmetic_nan (invoke "f64.promote_f32" (f32.const nan:0x200000)))
|
||||||
|
(assert_return_canonical_nan (invoke "f64.promote_f32" (f32.const -nan)))
|
||||||
|
(assert_return_arithmetic_nan (invoke "f64.promote_f32" (f32.const -nan:0x200000)))
|
||||||
|
|
||||||
|
(assert_return (invoke "f32.demote_f64" (f64.const 0.0)) (f32.const 0.0))
|
||||||
|
(assert_return (invoke "f32.demote_f64" (f64.const -0.0)) (f32.const -0.0))
|
||||||
|
(assert_return (invoke "f32.demote_f64" (f64.const 0x0.0000000000001p-1022)) (f32.const 0.0))
|
||||||
|
(assert_return (invoke "f32.demote_f64" (f64.const -0x0.0000000000001p-1022)) (f32.const -0.0))
|
||||||
|
(assert_return (invoke "f32.demote_f64" (f64.const 1.0)) (f32.const 1.0))
|
||||||
|
(assert_return (invoke "f32.demote_f64" (f64.const -1.0)) (f32.const -1.0))
|
||||||
|
(assert_return (invoke "f32.demote_f64" (f64.const 0x1.fffffe0000000p-127)) (f32.const 0x1p-126))
|
||||||
|
(assert_return (invoke "f32.demote_f64" (f64.const -0x1.fffffe0000000p-127)) (f32.const -0x1p-126))
|
||||||
|
(assert_return (invoke "f32.demote_f64" (f64.const 0x1.fffffdfffffffp-127)) (f32.const 0x1.fffffcp-127))
|
||||||
|
(assert_return (invoke "f32.demote_f64" (f64.const -0x1.fffffdfffffffp-127)) (f32.const -0x1.fffffcp-127))
|
||||||
|
(assert_return (invoke "f32.demote_f64" (f64.const 0x1p-149)) (f32.const 0x1p-149))
|
||||||
|
(assert_return (invoke "f32.demote_f64" (f64.const -0x1p-149)) (f32.const -0x1p-149))
|
||||||
|
(assert_return (invoke "f32.demote_f64" (f64.const 0x1.fffffd0000000p+127)) (f32.const 0x1.fffffcp+127))
|
||||||
|
(assert_return (invoke "f32.demote_f64" (f64.const -0x1.fffffd0000000p+127)) (f32.const -0x1.fffffcp+127))
|
||||||
|
(assert_return (invoke "f32.demote_f64" (f64.const 0x1.fffffd0000001p+127)) (f32.const 0x1.fffffep+127))
|
||||||
|
(assert_return (invoke "f32.demote_f64" (f64.const -0x1.fffffd0000001p+127)) (f32.const -0x1.fffffep+127))
|
||||||
|
(assert_return (invoke "f32.demote_f64" (f64.const 0x1.fffffep+127)) (f32.const 0x1.fffffep+127))
|
||||||
|
(assert_return (invoke "f32.demote_f64" (f64.const -0x1.fffffep+127)) (f32.const -0x1.fffffep+127))
|
||||||
|
(assert_return (invoke "f32.demote_f64" (f64.const 0x1.fffffefffffffp+127)) (f32.const 0x1.fffffep+127))
|
||||||
|
(assert_return (invoke "f32.demote_f64" (f64.const -0x1.fffffefffffffp+127)) (f32.const -0x1.fffffep+127))
|
||||||
|
(assert_return (invoke "f32.demote_f64" (f64.const 0x1.ffffffp+127)) (f32.const inf))
|
||||||
|
(assert_return (invoke "f32.demote_f64" (f64.const -0x1.ffffffp+127)) (f32.const -inf))
|
||||||
|
(assert_return (invoke "f32.demote_f64" (f64.const 0x1p-119)) (f32.const 0x1p-119))
|
||||||
|
(assert_return (invoke "f32.demote_f64" (f64.const 0x1.8f867ep+125)) (f32.const 0x1.8f867ep+125))
|
||||||
|
(assert_return (invoke "f32.demote_f64" (f64.const inf)) (f32.const inf))
|
||||||
|
(assert_return (invoke "f32.demote_f64" (f64.const -inf)) (f32.const -inf))
|
||||||
|
(assert_return (invoke "f32.demote_f64" (f64.const 0x1.0000000000001p+0)) (f32.const 1.0))
|
||||||
|
(assert_return (invoke "f32.demote_f64" (f64.const 0x1.fffffffffffffp-1)) (f32.const 1.0))
|
||||||
|
(assert_return (invoke "f32.demote_f64" (f64.const 0x1.0000010000000p+0)) (f32.const 0x1.000000p+0))
|
||||||
|
(assert_return (invoke "f32.demote_f64" (f64.const 0x1.0000010000001p+0)) (f32.const 0x1.000002p+0))
|
||||||
|
(assert_return (invoke "f32.demote_f64" (f64.const 0x1.000002fffffffp+0)) (f32.const 0x1.000002p+0))
|
||||||
|
(assert_return (invoke "f32.demote_f64" (f64.const 0x1.0000030000000p+0)) (f32.const 0x1.000004p+0))
|
||||||
|
(assert_return (invoke "f32.demote_f64" (f64.const 0x1.0000050000000p+0)) (f32.const 0x1.000004p+0))
|
||||||
|
(assert_return (invoke "f32.demote_f64" (f64.const 0x1.0000010000000p+24)) (f32.const 0x1.0p+24))
|
||||||
|
(assert_return (invoke "f32.demote_f64" (f64.const 0x1.0000010000001p+24)) (f32.const 0x1.000002p+24))
|
||||||
|
(assert_return (invoke "f32.demote_f64" (f64.const 0x1.000002fffffffp+24)) (f32.const 0x1.000002p+24))
|
||||||
|
(assert_return (invoke "f32.demote_f64" (f64.const 0x1.0000030000000p+24)) (f32.const 0x1.000004p+24))
|
||||||
|
(assert_return (invoke "f32.demote_f64" (f64.const 0x1.4eae4f7024c7p+108)) (f32.const 0x1.4eae5p+108))
|
||||||
|
(assert_return (invoke "f32.demote_f64" (f64.const 0x1.a12e71e358685p-113)) (f32.const 0x1.a12e72p-113))
|
||||||
|
(assert_return (invoke "f32.demote_f64" (f64.const 0x1.cb98354d521ffp-127)) (f32.const 0x1.cb9834p-127))
|
||||||
|
(assert_return (invoke "f32.demote_f64" (f64.const -0x1.6972b30cfb562p+1)) (f32.const -0x1.6972b4p+1))
|
||||||
|
(assert_return (invoke "f32.demote_f64" (f64.const -0x1.bedbe4819d4c4p+112)) (f32.const -0x1.bedbe4p+112))
|
||||||
|
(assert_return_canonical_nan (invoke "f32.demote_f64" (f64.const nan)))
|
||||||
|
(assert_return_arithmetic_nan (invoke "f32.demote_f64" (f64.const nan:0x4000000000000)))
|
||||||
|
(assert_return_canonical_nan (invoke "f32.demote_f64" (f64.const -nan)))
|
||||||
|
(assert_return_arithmetic_nan (invoke "f32.demote_f64" (f64.const -nan:0x4000000000000)))
|
||||||
|
(assert_return (invoke "f32.demote_f64" (f64.const 0x1p-1022)) (f32.const 0.0))
|
||||||
|
(assert_return (invoke "f32.demote_f64" (f64.const -0x1p-1022)) (f32.const -0.0))
|
||||||
|
(assert_return (invoke "f32.demote_f64" (f64.const 0x1.0p-150)) (f32.const 0.0))
|
||||||
|
(assert_return (invoke "f32.demote_f64" (f64.const -0x1.0p-150)) (f32.const -0.0))
|
||||||
|
(assert_return (invoke "f32.demote_f64" (f64.const 0x1.0000000000001p-150)) (f32.const 0x1p-149))
|
||||||
|
(assert_return (invoke "f32.demote_f64" (f64.const -0x1.0000000000001p-150)) (f32.const -0x1p-149))
|
||||||
|
|
||||||
|
(assert_return (invoke "f32.reinterpret_i32" (i32.const 0)) (f32.const 0.0))
|
||||||
|
(assert_return (invoke "f32.reinterpret_i32" (i32.const 0x80000000)) (f32.const -0.0))
|
||||||
|
(assert_return (invoke "f32.reinterpret_i32" (i32.const 1)) (f32.const 0x1p-149))
|
||||||
|
(assert_return (invoke "f32.reinterpret_i32" (i32.const -1)) (f32.const -nan:0x7fffff))
|
||||||
|
(assert_return (invoke "f32.reinterpret_i32" (i32.const 123456789)) (f32.const 0x1.b79a2ap-113))
|
||||||
|
(assert_return (invoke "f32.reinterpret_i32" (i32.const -2147483647)) (f32.const -0x1p-149))
|
||||||
|
(assert_return (invoke "f32.reinterpret_i32" (i32.const 0x7f800000)) (f32.const inf))
|
||||||
|
(assert_return (invoke "f32.reinterpret_i32" (i32.const 0xff800000)) (f32.const -inf))
|
||||||
|
(assert_return (invoke "f32.reinterpret_i32" (i32.const 0x7fc00000)) (f32.const nan))
|
||||||
|
(assert_return (invoke "f32.reinterpret_i32" (i32.const 0xffc00000)) (f32.const -nan))
|
||||||
|
(assert_return (invoke "f32.reinterpret_i32" (i32.const 0x7fa00000)) (f32.const nan:0x200000))
|
||||||
|
(assert_return (invoke "f32.reinterpret_i32" (i32.const 0xffa00000)) (f32.const -nan:0x200000))
|
||||||
|
|
||||||
|
(assert_return (invoke "f64.reinterpret_i64" (i64.const 0)) (f64.const 0.0))
|
||||||
|
(assert_return (invoke "f64.reinterpret_i64" (i64.const 1)) (f64.const 0x0.0000000000001p-1022))
|
||||||
|
(assert_return (invoke "f64.reinterpret_i64" (i64.const -1)) (f64.const -nan:0xfffffffffffff))
|
||||||
|
(assert_return (invoke "f64.reinterpret_i64" (i64.const 0x8000000000000000)) (f64.const -0.0))
|
||||||
|
(assert_return (invoke "f64.reinterpret_i64" (i64.const 1234567890)) (f64.const 0x0.00000499602d2p-1022))
|
||||||
|
(assert_return (invoke "f64.reinterpret_i64" (i64.const -9223372036854775807)) (f64.const -0x0.0000000000001p-1022))
|
||||||
|
(assert_return (invoke "f64.reinterpret_i64" (i64.const 0x7ff0000000000000)) (f64.const inf))
|
||||||
|
(assert_return (invoke "f64.reinterpret_i64" (i64.const 0xfff0000000000000)) (f64.const -inf))
|
||||||
|
(assert_return (invoke "f64.reinterpret_i64" (i64.const 0x7ff8000000000000)) (f64.const nan))
|
||||||
|
(assert_return (invoke "f64.reinterpret_i64" (i64.const 0xfff8000000000000)) (f64.const -nan))
|
||||||
|
(assert_return (invoke "f64.reinterpret_i64" (i64.const 0x7ff4000000000000)) (f64.const nan:0x4000000000000))
|
||||||
|
(assert_return (invoke "f64.reinterpret_i64" (i64.const 0xfff4000000000000)) (f64.const -nan:0x4000000000000))
|
||||||
|
|
||||||
|
(assert_return (invoke "i32.reinterpret_f32" (f32.const 0.0)) (i32.const 0))
|
||||||
|
(assert_return (invoke "i32.reinterpret_f32" (f32.const -0.0)) (i32.const 0x80000000))
|
||||||
|
(assert_return (invoke "i32.reinterpret_f32" (f32.const 0x1p-149)) (i32.const 1))
|
||||||
|
(assert_return (invoke "i32.reinterpret_f32" (f32.const -nan:0x7fffff)) (i32.const -1))
|
||||||
|
(assert_return (invoke "i32.reinterpret_f32" (f32.const -0x1p-149)) (i32.const 0x80000001))
|
||||||
|
(assert_return (invoke "i32.reinterpret_f32" (f32.const 1.0)) (i32.const 1065353216))
|
||||||
|
(assert_return (invoke "i32.reinterpret_f32" (f32.const 3.1415926)) (i32.const 1078530010))
|
||||||
|
(assert_return (invoke "i32.reinterpret_f32" (f32.const 0x1.fffffep+127)) (i32.const 2139095039))
|
||||||
|
(assert_return (invoke "i32.reinterpret_f32" (f32.const -0x1.fffffep+127)) (i32.const -8388609))
|
||||||
|
(assert_return (invoke "i32.reinterpret_f32" (f32.const inf)) (i32.const 0x7f800000))
|
||||||
|
(assert_return (invoke "i32.reinterpret_f32" (f32.const -inf)) (i32.const 0xff800000))
|
||||||
|
(assert_return (invoke "i32.reinterpret_f32" (f32.const nan)) (i32.const 0x7fc00000))
|
||||||
|
(assert_return (invoke "i32.reinterpret_f32" (f32.const -nan)) (i32.const 0xffc00000))
|
||||||
|
(assert_return (invoke "i32.reinterpret_f32" (f32.const nan:0x200000)) (i32.const 0x7fa00000))
|
||||||
|
(assert_return (invoke "i32.reinterpret_f32" (f32.const -nan:0x200000)) (i32.const 0xffa00000))
|
||||||
|
|
||||||
|
(assert_return (invoke "i64.reinterpret_f64" (f64.const 0.0)) (i64.const 0))
|
||||||
|
(assert_return (invoke "i64.reinterpret_f64" (f64.const -0.0)) (i64.const 0x8000000000000000))
|
||||||
|
(assert_return (invoke "i64.reinterpret_f64" (f64.const 0x0.0000000000001p-1022)) (i64.const 1))
|
||||||
|
(assert_return (invoke "i64.reinterpret_f64" (f64.const -nan:0xfffffffffffff)) (i64.const -1))
|
||||||
|
(assert_return (invoke "i64.reinterpret_f64" (f64.const -0x0.0000000000001p-1022)) (i64.const 0x8000000000000001))
|
||||||
|
(assert_return (invoke "i64.reinterpret_f64" (f64.const 1.0)) (i64.const 4607182418800017408))
|
||||||
|
(assert_return (invoke "i64.reinterpret_f64" (f64.const 3.14159265358979)) (i64.const 4614256656552045841))
|
||||||
|
(assert_return (invoke "i64.reinterpret_f64" (f64.const 0x1.fffffffffffffp+1023)) (i64.const 9218868437227405311))
|
||||||
|
(assert_return (invoke "i64.reinterpret_f64" (f64.const -0x1.fffffffffffffp+1023)) (i64.const -4503599627370497))
|
||||||
|
(assert_return (invoke "i64.reinterpret_f64" (f64.const inf)) (i64.const 0x7ff0000000000000))
|
||||||
|
(assert_return (invoke "i64.reinterpret_f64" (f64.const -inf)) (i64.const 0xfff0000000000000))
|
||||||
|
(assert_return (invoke "i64.reinterpret_f64" (f64.const nan)) (i64.const 0x7ff8000000000000))
|
||||||
|
(assert_return (invoke "i64.reinterpret_f64" (f64.const -nan)) (i64.const 0xfff8000000000000))
|
||||||
|
(assert_return (invoke "i64.reinterpret_f64" (f64.const nan:0x4000000000000)) (i64.const 0x7ff4000000000000))
|
||||||
|
(assert_return (invoke "i64.reinterpret_f64" (f64.const -nan:0x4000000000000)) (i64.const 0xfff4000000000000))
|
||||||
@@ -0,0 +1,120 @@
|
|||||||
|
(module binary
|
||||||
|
"\00asm" "\01\00\00\00"
|
||||||
|
"\00\24\10" "a custom section" "this is the payload"
|
||||||
|
"\00\20\10" "a custom section" "this is payload"
|
||||||
|
"\00\11\10" "a custom section" ""
|
||||||
|
"\00\10\00" "" "this is payload"
|
||||||
|
"\00\01\00" "" ""
|
||||||
|
"\00\24\10" "\00\00custom sectio\00" "this is the payload"
|
||||||
|
"\00\24\10" "\ef\bb\bfa custom sect" "this is the payload"
|
||||||
|
"\00\24\10" "a custom sect\e2\8c\a3" "this is the payload"
|
||||||
|
"\00\1f\16" "module within a module" "\00asm" "\01\00\00\00"
|
||||||
|
)
|
||||||
|
|
||||||
|
(module binary
|
||||||
|
"\00asm" "\01\00\00\00"
|
||||||
|
"\00\0e\06" "custom" "payload"
|
||||||
|
"\00\0e\06" "custom" "payload"
|
||||||
|
"\01\01\00" ;; type section
|
||||||
|
"\00\0e\06" "custom" "payload"
|
||||||
|
"\00\0e\06" "custom" "payload"
|
||||||
|
"\02\01\00" ;; import section
|
||||||
|
"\00\0e\06" "custom" "payload"
|
||||||
|
"\00\0e\06" "custom" "payload"
|
||||||
|
"\03\01\00" ;; function section
|
||||||
|
"\00\0e\06" "custom" "payload"
|
||||||
|
"\00\0e\06" "custom" "payload"
|
||||||
|
"\04\01\00" ;; table section
|
||||||
|
"\00\0e\06" "custom" "payload"
|
||||||
|
"\00\0e\06" "custom" "payload"
|
||||||
|
"\05\01\00" ;; memory section
|
||||||
|
"\00\0e\06" "custom" "payload"
|
||||||
|
"\00\0e\06" "custom" "payload"
|
||||||
|
"\06\01\00" ;; global section
|
||||||
|
"\00\0e\06" "custom" "payload"
|
||||||
|
"\00\0e\06" "custom" "payload"
|
||||||
|
"\07\01\00" ;; export section
|
||||||
|
"\00\0e\06" "custom" "payload"
|
||||||
|
"\00\0e\06" "custom" "payload"
|
||||||
|
"\09\01\00" ;; element section
|
||||||
|
"\00\0e\06" "custom" "payload"
|
||||||
|
"\00\0e\06" "custom" "payload"
|
||||||
|
"\0a\01\00" ;; code section
|
||||||
|
"\00\0e\06" "custom" "payload"
|
||||||
|
"\00\0e\06" "custom" "payload"
|
||||||
|
"\0b\01\00" ;; data section
|
||||||
|
"\00\0e\06" "custom" "payload"
|
||||||
|
"\00\0e\06" "custom" "payload"
|
||||||
|
)
|
||||||
|
|
||||||
|
(module binary
|
||||||
|
"\00asm" "\01\00\00\00"
|
||||||
|
"\01\07\01\60\02\7f\7f\01\7f" ;; type section
|
||||||
|
"\00\1a\06" "custom" "this is the payload" ;; custom section
|
||||||
|
"\03\02\01\00" ;; function section
|
||||||
|
"\07\0a\01\06\61\64\64\54\77\6f\00\00" ;; export section
|
||||||
|
"\0a\09\01\07\00\20\00\20\01\6a\0b" ;; code section
|
||||||
|
"\00\1b\07" "custom2" "this is the payload" ;; custom section
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_malformed
|
||||||
|
(module binary
|
||||||
|
"\00asm" "\01\00\00\00"
|
||||||
|
"\00"
|
||||||
|
)
|
||||||
|
"unexpected end"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_malformed
|
||||||
|
(module binary
|
||||||
|
"\00asm" "\01\00\00\00"
|
||||||
|
"\00\00"
|
||||||
|
)
|
||||||
|
"unexpected end"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_malformed
|
||||||
|
(module binary
|
||||||
|
"\00asm" "\01\00\00\00"
|
||||||
|
"\00\00\00\05\01\00\07\00\00"
|
||||||
|
)
|
||||||
|
"unexpected end"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_malformed
|
||||||
|
(module binary
|
||||||
|
"\00asm" "\01\00\00\00"
|
||||||
|
"\00\26\10" "a custom section" "this is the payload"
|
||||||
|
)
|
||||||
|
"unexpected end"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_malformed
|
||||||
|
(module binary
|
||||||
|
"\00asm" "\01\00\00\00"
|
||||||
|
"\00\25\10" "a custom section" "this is the payload"
|
||||||
|
"\00\24\10" "a custom section" "this is the payload"
|
||||||
|
)
|
||||||
|
"invalid section id"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_malformed
|
||||||
|
(module binary
|
||||||
|
"\00asm" "\01\00\00\00"
|
||||||
|
"\01\07\01\60\02\7f\7f\01\7f" ;; type section
|
||||||
|
"\00\25\10" "a custom section" "this is the payload" ;; invalid length!
|
||||||
|
"\03\02\01\00" ;; function section
|
||||||
|
"\0a\09\01\07\00\20\00\20\01\6a\0b" ;; code section
|
||||||
|
"\00\1b\07" "custom2" "this is the payload" ;; custom section
|
||||||
|
)
|
||||||
|
"function and code section have inconsistent lengths"
|
||||||
|
)
|
||||||
|
|
||||||
|
;; Test concatenated modules.
|
||||||
|
(assert_malformed
|
||||||
|
(module binary
|
||||||
|
"\00asm\01\00\00\00"
|
||||||
|
"\00asm\01\00\00\00"
|
||||||
|
)
|
||||||
|
"length out of bounds"
|
||||||
|
)
|
||||||
@@ -0,0 +1,335 @@
|
|||||||
|
;; Test the data section
|
||||||
|
|
||||||
|
;; Syntax
|
||||||
|
|
||||||
|
(module
|
||||||
|
(memory $m 1)
|
||||||
|
(data (i32.const 0))
|
||||||
|
(data (i32.const 1) "a" "" "bcd")
|
||||||
|
(data (offset (i32.const 0)))
|
||||||
|
(data (offset (i32.const 0)) "" "a" "bc" "")
|
||||||
|
(data 0 (i32.const 0))
|
||||||
|
(data 0x0 (i32.const 1) "a" "" "bcd")
|
||||||
|
(data 0x000 (offset (i32.const 0)))
|
||||||
|
(data 0 (offset (i32.const 0)) "" "a" "bc" "")
|
||||||
|
(data $m (i32.const 0))
|
||||||
|
(data $m (i32.const 1) "a" "" "bcd")
|
||||||
|
(data $m (offset (i32.const 0)))
|
||||||
|
(data $m (offset (i32.const 0)) "" "a" "bc" "")
|
||||||
|
)
|
||||||
|
|
||||||
|
;; Basic use
|
||||||
|
|
||||||
|
(module
|
||||||
|
(memory 1)
|
||||||
|
(data (i32.const 0) "a")
|
||||||
|
)
|
||||||
|
(module
|
||||||
|
(import "spectest" "memory" (memory 1))
|
||||||
|
(data (i32.const 0) "a")
|
||||||
|
)
|
||||||
|
|
||||||
|
(module
|
||||||
|
(memory 1)
|
||||||
|
(data (i32.const 0) "a")
|
||||||
|
(data (i32.const 3) "b")
|
||||||
|
(data (i32.const 100) "cde")
|
||||||
|
(data (i32.const 5) "x")
|
||||||
|
(data (i32.const 3) "c")
|
||||||
|
)
|
||||||
|
(module
|
||||||
|
(import "spectest" "memory" (memory 1))
|
||||||
|
(data (i32.const 0) "a")
|
||||||
|
(data (i32.const 1) "b")
|
||||||
|
(data (i32.const 2) "cde")
|
||||||
|
(data (i32.const 3) "f")
|
||||||
|
(data (i32.const 2) "g")
|
||||||
|
(data (i32.const 1) "h")
|
||||||
|
)
|
||||||
|
|
||||||
|
(module
|
||||||
|
(global (import "spectest" "global_i32") i32)
|
||||||
|
(memory 1)
|
||||||
|
(data (get_global 0) "a")
|
||||||
|
)
|
||||||
|
(module
|
||||||
|
(global (import "spectest" "global_i32") i32)
|
||||||
|
(import "spectest" "memory" (memory 1))
|
||||||
|
(data (get_global 0) "a")
|
||||||
|
)
|
||||||
|
|
||||||
|
(module
|
||||||
|
(global $g (import "spectest" "global_i32") i32)
|
||||||
|
(memory 1)
|
||||||
|
(data (get_global $g) "a")
|
||||||
|
)
|
||||||
|
(module
|
||||||
|
(global $g (import "spectest" "global_i32") i32)
|
||||||
|
(import "spectest" "memory" (memory 1))
|
||||||
|
(data (get_global $g) "a")
|
||||||
|
)
|
||||||
|
|
||||||
|
;; Use of internal globals in constant expressions is not allowed in MVP.
|
||||||
|
;; (module (memory 1) (data (get_global 0) "a") (global i32 (i32.const 0)))
|
||||||
|
;; (module (memory 1) (data (get_global $g) "a") (global $g i32 (i32.const 0)))
|
||||||
|
|
||||||
|
;; Corner cases
|
||||||
|
|
||||||
|
(module
|
||||||
|
(memory 1)
|
||||||
|
(data (i32.const 0) "a")
|
||||||
|
(data (i32.const 0xffff) "b")
|
||||||
|
)
|
||||||
|
(module
|
||||||
|
(import "spectest" "memory" (memory 1))
|
||||||
|
(data (i32.const 0) "a")
|
||||||
|
(data (i32.const 0xffff) "b")
|
||||||
|
)
|
||||||
|
|
||||||
|
(module
|
||||||
|
(memory 2)
|
||||||
|
(data (i32.const 0x1_ffff) "a")
|
||||||
|
)
|
||||||
|
|
||||||
|
(module
|
||||||
|
(memory 0)
|
||||||
|
(data (i32.const 0))
|
||||||
|
)
|
||||||
|
(module
|
||||||
|
(import "spectest" "memory" (memory 0))
|
||||||
|
(data (i32.const 0))
|
||||||
|
)
|
||||||
|
|
||||||
|
(module
|
||||||
|
(memory 0 0)
|
||||||
|
(data (i32.const 0))
|
||||||
|
)
|
||||||
|
|
||||||
|
(module
|
||||||
|
(memory 1)
|
||||||
|
(data (i32.const 0x1_0000) "")
|
||||||
|
)
|
||||||
|
|
||||||
|
(module
|
||||||
|
(memory 0)
|
||||||
|
(data (i32.const 0) "" "")
|
||||||
|
)
|
||||||
|
(module
|
||||||
|
(import "spectest" "memory" (memory 0))
|
||||||
|
(data (i32.const 0) "" "")
|
||||||
|
)
|
||||||
|
|
||||||
|
(module
|
||||||
|
(memory 0 0)
|
||||||
|
(data (i32.const 0) "" "")
|
||||||
|
)
|
||||||
|
|
||||||
|
(module
|
||||||
|
(import "spectest" "memory" (memory 0))
|
||||||
|
(data (i32.const 0) "a")
|
||||||
|
)
|
||||||
|
|
||||||
|
(module
|
||||||
|
(import "spectest" "memory" (memory 0 3))
|
||||||
|
(data (i32.const 0) "a")
|
||||||
|
)
|
||||||
|
|
||||||
|
(module
|
||||||
|
(global (import "spectest" "global_i32") i32)
|
||||||
|
(import "spectest" "memory" (memory 0))
|
||||||
|
(data (get_global 0) "a")
|
||||||
|
)
|
||||||
|
|
||||||
|
(module
|
||||||
|
(global (import "spectest" "global_i32") i32)
|
||||||
|
(import "spectest" "memory" (memory 0 3))
|
||||||
|
(data (get_global 0) "a")
|
||||||
|
)
|
||||||
|
|
||||||
|
(module
|
||||||
|
(import "spectest" "memory" (memory 0))
|
||||||
|
(data (i32.const 1) "a")
|
||||||
|
)
|
||||||
|
|
||||||
|
(module
|
||||||
|
(import "spectest" "memory" (memory 0 3))
|
||||||
|
(data (i32.const 1) "a")
|
||||||
|
)
|
||||||
|
|
||||||
|
;; Invalid bounds for data
|
||||||
|
|
||||||
|
(assert_unlinkable
|
||||||
|
(module
|
||||||
|
(memory 0)
|
||||||
|
(data (i32.const 0) "a")
|
||||||
|
)
|
||||||
|
"data segment does not fit"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_unlinkable
|
||||||
|
(module
|
||||||
|
(memory 0 0)
|
||||||
|
(data (i32.const 0) "a")
|
||||||
|
)
|
||||||
|
"data segment does not fit"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_unlinkable
|
||||||
|
(module
|
||||||
|
(memory 0 1)
|
||||||
|
(data (i32.const 0) "a")
|
||||||
|
)
|
||||||
|
"data segment does not fit"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_unlinkable
|
||||||
|
(module
|
||||||
|
(memory 0)
|
||||||
|
(data (i32.const 1))
|
||||||
|
)
|
||||||
|
"data segment does not fit"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_unlinkable
|
||||||
|
(module
|
||||||
|
(memory 0 1)
|
||||||
|
(data (i32.const 1))
|
||||||
|
)
|
||||||
|
"data segment does not fit"
|
||||||
|
)
|
||||||
|
|
||||||
|
;; This seems to cause a time-out on Travis.
|
||||||
|
(;assert_unlinkable
|
||||||
|
(module
|
||||||
|
(memory 0x10000)
|
||||||
|
(data (i32.const 0xffffffff) "ab")
|
||||||
|
)
|
||||||
|
"" ;; either out of memory or segment does not fit
|
||||||
|
;)
|
||||||
|
|
||||||
|
(assert_unlinkable
|
||||||
|
(module
|
||||||
|
(global (import "spectest" "global_i32") i32)
|
||||||
|
(memory 0)
|
||||||
|
(data (get_global 0) "a")
|
||||||
|
)
|
||||||
|
"data segment does not fit"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_unlinkable
|
||||||
|
(module
|
||||||
|
(memory 1 2)
|
||||||
|
(data (i32.const 0x1_0000) "a")
|
||||||
|
)
|
||||||
|
"data segment does not fit"
|
||||||
|
)
|
||||||
|
(assert_unlinkable
|
||||||
|
(module
|
||||||
|
(import "spectest" "memory" (memory 1))
|
||||||
|
(data (i32.const 0x1_0000) "a")
|
||||||
|
)
|
||||||
|
"data segment does not fit"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_unlinkable
|
||||||
|
(module
|
||||||
|
(memory 2)
|
||||||
|
(data (i32.const 0x2_0000) "a")
|
||||||
|
)
|
||||||
|
"data segment does not fit"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_unlinkable
|
||||||
|
(module
|
||||||
|
(memory 2 3)
|
||||||
|
(data (i32.const 0x2_0000) "a")
|
||||||
|
)
|
||||||
|
"data segment does not fit"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_unlinkable
|
||||||
|
(module
|
||||||
|
(memory 1)
|
||||||
|
(data (i32.const -1) "a")
|
||||||
|
)
|
||||||
|
"data segment does not fit"
|
||||||
|
)
|
||||||
|
(assert_unlinkable
|
||||||
|
(module
|
||||||
|
(import "spectest" "memory" (memory 1))
|
||||||
|
(data (i32.const -1) "a")
|
||||||
|
)
|
||||||
|
"data segment does not fit"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_unlinkable
|
||||||
|
(module
|
||||||
|
(memory 2)
|
||||||
|
(data (i32.const -100) "a")
|
||||||
|
)
|
||||||
|
"data segment does not fit"
|
||||||
|
)
|
||||||
|
(assert_unlinkable
|
||||||
|
(module
|
||||||
|
(import "spectest" "memory" (memory 1))
|
||||||
|
(data (i32.const -100) "a")
|
||||||
|
)
|
||||||
|
"data segment does not fit"
|
||||||
|
)
|
||||||
|
|
||||||
|
;; Data without memory
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module
|
||||||
|
(data (i32.const 0) "")
|
||||||
|
)
|
||||||
|
"unknown memory 0"
|
||||||
|
)
|
||||||
|
|
||||||
|
;; Invalid offsets
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module
|
||||||
|
(memory 1)
|
||||||
|
(data (i64.const 0))
|
||||||
|
)
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module
|
||||||
|
(memory 1)
|
||||||
|
(data (i32.ctz (i32.const 0)))
|
||||||
|
)
|
||||||
|
"constant expression required"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module
|
||||||
|
(memory 1)
|
||||||
|
(data (nop))
|
||||||
|
)
|
||||||
|
"constant expression required"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module
|
||||||
|
(memory 1)
|
||||||
|
(data (offset (nop) (i32.const 0)))
|
||||||
|
)
|
||||||
|
"constant expression required"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module
|
||||||
|
(memory 1)
|
||||||
|
(data (offset (i32.const 0) (nop)))
|
||||||
|
)
|
||||||
|
"constant expression required"
|
||||||
|
)
|
||||||
|
|
||||||
|
;; Use of internal globals in constant expressions is not allowed in MVP.
|
||||||
|
;; (assert_invalid
|
||||||
|
;; (module (memory 1) (data (get_global $g)) (global $g (mut i32) (i32.const 0)))
|
||||||
|
;; "constant expression required"
|
||||||
|
;; )
|
||||||
@@ -0,0 +1,381 @@
|
|||||||
|
;; Test the element section
|
||||||
|
|
||||||
|
;; Syntax
|
||||||
|
(module
|
||||||
|
(table $t 10 anyfunc)
|
||||||
|
(func $f)
|
||||||
|
(elem (i32.const 0))
|
||||||
|
(elem (i32.const 0) $f $f)
|
||||||
|
(elem (offset (i32.const 0)))
|
||||||
|
(elem (offset (i32.const 0)) $f $f)
|
||||||
|
(elem 0 (i32.const 0))
|
||||||
|
(elem 0x0 (i32.const 0) $f $f)
|
||||||
|
(elem 0x000 (offset (i32.const 0)))
|
||||||
|
(elem 0 (offset (i32.const 0)) $f $f)
|
||||||
|
(elem $t (i32.const 0))
|
||||||
|
(elem $t (i32.const 0) $f $f)
|
||||||
|
(elem $t (offset (i32.const 0)))
|
||||||
|
(elem $t (offset (i32.const 0)) $f $f)
|
||||||
|
)
|
||||||
|
|
||||||
|
;; Basic use
|
||||||
|
|
||||||
|
(module
|
||||||
|
(table 10 anyfunc)
|
||||||
|
(func $f)
|
||||||
|
(elem (i32.const 0) $f)
|
||||||
|
)
|
||||||
|
(module
|
||||||
|
(import "spectest" "table" (table 10 anyfunc))
|
||||||
|
(func $f)
|
||||||
|
(elem (i32.const 0) $f)
|
||||||
|
)
|
||||||
|
|
||||||
|
(module
|
||||||
|
(table 10 anyfunc)
|
||||||
|
(func $f)
|
||||||
|
(elem (i32.const 0) $f)
|
||||||
|
(elem (i32.const 3) $f)
|
||||||
|
(elem (i32.const 7) $f)
|
||||||
|
(elem (i32.const 5) $f)
|
||||||
|
(elem (i32.const 3) $f)
|
||||||
|
)
|
||||||
|
(module
|
||||||
|
(import "spectest" "table" (table 10 anyfunc))
|
||||||
|
(func $f)
|
||||||
|
(elem (i32.const 9) $f)
|
||||||
|
(elem (i32.const 3) $f)
|
||||||
|
(elem (i32.const 7) $f)
|
||||||
|
(elem (i32.const 3) $f)
|
||||||
|
(elem (i32.const 5) $f)
|
||||||
|
)
|
||||||
|
|
||||||
|
(module
|
||||||
|
(global (import "spectest" "global_i32") i32)
|
||||||
|
(table 1000 anyfunc)
|
||||||
|
(func $f)
|
||||||
|
(elem (get_global 0) $f)
|
||||||
|
)
|
||||||
|
|
||||||
|
(module
|
||||||
|
(global $g (import "spectest" "global_i32") i32)
|
||||||
|
(table 1000 anyfunc)
|
||||||
|
(func $f)
|
||||||
|
(elem (get_global $g) $f)
|
||||||
|
)
|
||||||
|
|
||||||
|
(module
|
||||||
|
(type $out-i32 (func (result i32)))
|
||||||
|
(table 10 anyfunc)
|
||||||
|
(elem (i32.const 7) $const-i32-a)
|
||||||
|
(elem (i32.const 9) $const-i32-b)
|
||||||
|
(func $const-i32-a (type $out-i32) (i32.const 65))
|
||||||
|
(func $const-i32-b (type $out-i32) (i32.const 66))
|
||||||
|
(func (export "call-7") (type $out-i32)
|
||||||
|
(call_indirect (type $out-i32) (i32.const 7))
|
||||||
|
)
|
||||||
|
(func (export "call-9") (type $out-i32)
|
||||||
|
(call_indirect (type $out-i32) (i32.const 9))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(assert_return (invoke "call-7") (i32.const 65))
|
||||||
|
(assert_return (invoke "call-9") (i32.const 66))
|
||||||
|
|
||||||
|
;; Corner cases
|
||||||
|
|
||||||
|
(module
|
||||||
|
(table 10 anyfunc)
|
||||||
|
(func $f)
|
||||||
|
(elem (i32.const 9) $f)
|
||||||
|
)
|
||||||
|
(module
|
||||||
|
(import "spectest" "table" (table 10 anyfunc))
|
||||||
|
(func $f)
|
||||||
|
(elem (i32.const 9) $f)
|
||||||
|
)
|
||||||
|
|
||||||
|
(module
|
||||||
|
(table 0 anyfunc)
|
||||||
|
(elem (i32.const 0))
|
||||||
|
)
|
||||||
|
(module
|
||||||
|
(import "spectest" "table" (table 0 anyfunc))
|
||||||
|
(elem (i32.const 0))
|
||||||
|
)
|
||||||
|
|
||||||
|
(module
|
||||||
|
(table 0 0 anyfunc)
|
||||||
|
(elem (i32.const 0))
|
||||||
|
)
|
||||||
|
|
||||||
|
(module
|
||||||
|
(table 20 anyfunc)
|
||||||
|
(elem (i32.const 20))
|
||||||
|
)
|
||||||
|
|
||||||
|
(module
|
||||||
|
(import "spectest" "table" (table 0 anyfunc))
|
||||||
|
(func $f)
|
||||||
|
(elem (i32.const 0) $f)
|
||||||
|
)
|
||||||
|
|
||||||
|
(module
|
||||||
|
(import "spectest" "table" (table 0 100 anyfunc))
|
||||||
|
(func $f)
|
||||||
|
(elem (i32.const 0) $f)
|
||||||
|
)
|
||||||
|
|
||||||
|
(module
|
||||||
|
(import "spectest" "table" (table 0 anyfunc))
|
||||||
|
(func $f)
|
||||||
|
(elem (i32.const 1) $f)
|
||||||
|
)
|
||||||
|
|
||||||
|
(module
|
||||||
|
(import "spectest" "table" (table 0 30 anyfunc))
|
||||||
|
(func $f)
|
||||||
|
(elem (i32.const 1) $f)
|
||||||
|
)
|
||||||
|
|
||||||
|
;; Invalid bounds for elements
|
||||||
|
|
||||||
|
(assert_unlinkable
|
||||||
|
(module
|
||||||
|
(table 0 anyfunc)
|
||||||
|
(func $f)
|
||||||
|
(elem (i32.const 0) $f)
|
||||||
|
)
|
||||||
|
"elements segment does not fit"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_unlinkable
|
||||||
|
(module
|
||||||
|
(table 0 0 anyfunc)
|
||||||
|
(func $f)
|
||||||
|
(elem (i32.const 0) $f)
|
||||||
|
)
|
||||||
|
"elements segment does not fit"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_unlinkable
|
||||||
|
(module
|
||||||
|
(table 0 1 anyfunc)
|
||||||
|
(func $f)
|
||||||
|
(elem (i32.const 0) $f)
|
||||||
|
)
|
||||||
|
"elements segment does not fit"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_unlinkable
|
||||||
|
(module
|
||||||
|
(table 0 anyfunc)
|
||||||
|
(elem (i32.const 1))
|
||||||
|
)
|
||||||
|
"elements segment does not fit"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_unlinkable
|
||||||
|
(module
|
||||||
|
(table 10 anyfunc)
|
||||||
|
(func $f)
|
||||||
|
(elem (i32.const 10) $f)
|
||||||
|
)
|
||||||
|
"elements segment does not fit"
|
||||||
|
)
|
||||||
|
(assert_unlinkable
|
||||||
|
(module
|
||||||
|
(import "spectest" "table" (table 10 anyfunc))
|
||||||
|
(func $f)
|
||||||
|
(elem (i32.const 10) $f)
|
||||||
|
)
|
||||||
|
"elements segment does not fit"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_unlinkable
|
||||||
|
(module
|
||||||
|
(table 10 20 anyfunc)
|
||||||
|
(func $f)
|
||||||
|
(elem (i32.const 10) $f)
|
||||||
|
)
|
||||||
|
"elements segment does not fit"
|
||||||
|
)
|
||||||
|
(assert_unlinkable
|
||||||
|
(module
|
||||||
|
(import "spectest" "table" (table 10 anyfunc))
|
||||||
|
(func $f)
|
||||||
|
(elem (i32.const 10) $f)
|
||||||
|
)
|
||||||
|
"elements segment does not fit"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_unlinkable
|
||||||
|
(module
|
||||||
|
(table 10 anyfunc)
|
||||||
|
(func $f)
|
||||||
|
(elem (i32.const -1) $f)
|
||||||
|
)
|
||||||
|
"elements segment does not fit"
|
||||||
|
)
|
||||||
|
(assert_unlinkable
|
||||||
|
(module
|
||||||
|
(import "spectest" "table" (table 10 anyfunc))
|
||||||
|
(func $f)
|
||||||
|
(elem (i32.const -1) $f)
|
||||||
|
)
|
||||||
|
"elements segment does not fit"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_unlinkable
|
||||||
|
(module
|
||||||
|
(table 10 anyfunc)
|
||||||
|
(func $f)
|
||||||
|
(elem (i32.const -10) $f)
|
||||||
|
)
|
||||||
|
"elements segment does not fit"
|
||||||
|
)
|
||||||
|
(assert_unlinkable
|
||||||
|
(module
|
||||||
|
(import "spectest" "table" (table 10 anyfunc))
|
||||||
|
(func $f)
|
||||||
|
(elem (i32.const -10) $f)
|
||||||
|
)
|
||||||
|
"elements segment does not fit"
|
||||||
|
)
|
||||||
|
|
||||||
|
;; Element without table
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module
|
||||||
|
(func $f)
|
||||||
|
(elem (i32.const 0) $f)
|
||||||
|
)
|
||||||
|
"unknown table 0"
|
||||||
|
)
|
||||||
|
|
||||||
|
;; Invalid offsets
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module
|
||||||
|
(table 1 anyfunc)
|
||||||
|
(elem (i64.const 0))
|
||||||
|
)
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module
|
||||||
|
(table 1 anyfunc)
|
||||||
|
(elem (i32.ctz (i32.const 0)))
|
||||||
|
)
|
||||||
|
"constant expression required"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module
|
||||||
|
(table 1 anyfunc)
|
||||||
|
(elem (nop))
|
||||||
|
)
|
||||||
|
"constant expression required"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module
|
||||||
|
(table 1 anyfunc)
|
||||||
|
(elem (offset (nop) (i32.const 0)))
|
||||||
|
)
|
||||||
|
"constant expression required"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module
|
||||||
|
(table 1 anyfunc)
|
||||||
|
(elem (offset (i32.const 0) (nop)))
|
||||||
|
)
|
||||||
|
"constant expression required"
|
||||||
|
)
|
||||||
|
|
||||||
|
;; Use of internal globals in constant expressions is not allowed in MVP.
|
||||||
|
;; (assert_invalid
|
||||||
|
;; (module (memory 1) (data (get_global $g)) (global $g (mut i32) (i32.const 0)))
|
||||||
|
;; "constant expression required"
|
||||||
|
;; )
|
||||||
|
|
||||||
|
;; Two elements target the same slot
|
||||||
|
|
||||||
|
(module
|
||||||
|
(type $out-i32 (func (result i32)))
|
||||||
|
(table 10 anyfunc)
|
||||||
|
(elem (i32.const 9) $const-i32-a)
|
||||||
|
(elem (i32.const 9) $const-i32-b)
|
||||||
|
(func $const-i32-a (type $out-i32) (i32.const 65))
|
||||||
|
(func $const-i32-b (type $out-i32) (i32.const 66))
|
||||||
|
(func (export "call-overwritten") (type $out-i32)
|
||||||
|
(call_indirect (type $out-i32) (i32.const 9))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(assert_return (invoke "call-overwritten") (i32.const 66))
|
||||||
|
|
||||||
|
(module
|
||||||
|
(type $out-i32 (func (result i32)))
|
||||||
|
(import "spectest" "table" (table 10 anyfunc))
|
||||||
|
(elem (i32.const 9) $const-i32-a)
|
||||||
|
(elem (i32.const 9) $const-i32-b)
|
||||||
|
(func $const-i32-a (type $out-i32) (i32.const 65))
|
||||||
|
(func $const-i32-b (type $out-i32) (i32.const 66))
|
||||||
|
(func (export "call-overwritten-element") (type $out-i32)
|
||||||
|
(call_indirect (type $out-i32) (i32.const 9))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(assert_return (invoke "call-overwritten-element") (i32.const 66))
|
||||||
|
|
||||||
|
;; Element sections across multiple modules change the same table
|
||||||
|
|
||||||
|
(module $module1
|
||||||
|
(type $out-i32 (func (result i32)))
|
||||||
|
(table (export "shared-table") 10 anyfunc)
|
||||||
|
(elem (i32.const 8) $const-i32-a)
|
||||||
|
(elem (i32.const 9) $const-i32-b)
|
||||||
|
(func $const-i32-a (type $out-i32) (i32.const 65))
|
||||||
|
(func $const-i32-b (type $out-i32) (i32.const 66))
|
||||||
|
(func (export "call-7") (type $out-i32)
|
||||||
|
(call_indirect (type $out-i32) (i32.const 7))
|
||||||
|
)
|
||||||
|
(func (export "call-8") (type $out-i32)
|
||||||
|
(call_indirect (type $out-i32) (i32.const 8))
|
||||||
|
)
|
||||||
|
(func (export "call-9") (type $out-i32)
|
||||||
|
(call_indirect (type $out-i32) (i32.const 9))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(register "module1" $module1)
|
||||||
|
|
||||||
|
(assert_trap (invoke $module1 "call-7") "uninitialized element 7")
|
||||||
|
(assert_return (invoke $module1 "call-8") (i32.const 65))
|
||||||
|
(assert_return (invoke $module1 "call-9") (i32.const 66))
|
||||||
|
|
||||||
|
(module $module2
|
||||||
|
(type $out-i32 (func (result i32)))
|
||||||
|
(import "module1" "shared-table" (table 10 anyfunc))
|
||||||
|
(elem (i32.const 7) $const-i32-c)
|
||||||
|
(elem (i32.const 8) $const-i32-d)
|
||||||
|
(func $const-i32-c (type $out-i32) (i32.const 67))
|
||||||
|
(func $const-i32-d (type $out-i32) (i32.const 68))
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke $module1 "call-7") (i32.const 67))
|
||||||
|
(assert_return (invoke $module1 "call-8") (i32.const 68))
|
||||||
|
(assert_return (invoke $module1 "call-9") (i32.const 66))
|
||||||
|
|
||||||
|
(module $module3
|
||||||
|
(type $out-i32 (func (result i32)))
|
||||||
|
(import "module1" "shared-table" (table 10 anyfunc))
|
||||||
|
(elem (i32.const 8) $const-i32-e)
|
||||||
|
(elem (i32.const 9) $const-i32-f)
|
||||||
|
(func $const-i32-e (type $out-i32) (i32.const 69))
|
||||||
|
(func $const-i32-f (type $out-i32) (i32.const 70))
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke $module1 "call-7") (i32.const 67))
|
||||||
|
(assert_return (invoke $module1 "call-8") (i32.const 69))
|
||||||
|
(assert_return (invoke $module1 "call-9") (i32.const 70))
|
||||||
@@ -0,0 +1,131 @@
|
|||||||
|
(module
|
||||||
|
(memory 1)
|
||||||
|
|
||||||
|
;; Stores an i16 value in little-endian-format
|
||||||
|
(func $i16_store_little (param $address i32) (param $value i32)
|
||||||
|
(i32.store8 (get_local $address) (get_local $value))
|
||||||
|
(i32.store8 (i32.add (get_local $address) (i32.const 1)) (i32.shr_u (get_local $value) (i32.const 8)))
|
||||||
|
)
|
||||||
|
|
||||||
|
;; Stores an i32 value in little-endian format
|
||||||
|
(func $i32_store_little (param $address i32) (param $value i32)
|
||||||
|
(call $i16_store_little (get_local $address) (get_local $value))
|
||||||
|
(call $i16_store_little (i32.add (get_local $address) (i32.const 2)) (i32.shr_u (get_local $value) (i32.const 16)))
|
||||||
|
)
|
||||||
|
|
||||||
|
;; Stores an i64 value in little-endian format
|
||||||
|
(func $i64_store_little (param $address i32) (param $value i64)
|
||||||
|
(call $i32_store_little (get_local $address) (i32.wrap/i64 (get_local $value)))
|
||||||
|
(call $i32_store_little (i32.add (get_local $address) (i32.const 4)) (i32.wrap/i64 (i64.shr_u (get_local $value) (i64.const 32))))
|
||||||
|
)
|
||||||
|
|
||||||
|
;; Loads an i16 value in little-endian format
|
||||||
|
(func $i16_load_little (param $address i32) (result i32)
|
||||||
|
(i32.or
|
||||||
|
(i32.load8_u (get_local $address))
|
||||||
|
(i32.shl (i32.load8_u (i32.add (get_local $address) (i32.const 1))) (i32.const 8))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
;; Loads an i32 value in little-endian format
|
||||||
|
(func $i32_load_little (param $address i32) (result i32)
|
||||||
|
(i32.or
|
||||||
|
(call $i16_load_little (get_local $address))
|
||||||
|
(i32.shl (call $i16_load_little (i32.add (get_local $address) (i32.const 2))) (i32.const 16))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
;; Loads an i64 value in little-endian format
|
||||||
|
(func $i64_load_little (param $address i32) (result i64)
|
||||||
|
(i64.or
|
||||||
|
(i64.extend_u/i32 (call $i32_load_little (get_local $address)))
|
||||||
|
(i64.shl (i64.extend_u/i32 (call $i32_load_little (i32.add (get_local $address) (i32.const 4)))) (i64.const 32))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "i32_load16_s") (param $value i32) (result i32)
|
||||||
|
(call $i16_store_little (i32.const 0) (get_local $value))
|
||||||
|
(i32.load16_s (i32.const 0))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "i32_load16_u") (param $value i32) (result i32)
|
||||||
|
(call $i16_store_little (i32.const 0) (get_local $value))
|
||||||
|
(i32.load16_u (i32.const 0))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "i32_load") (param $value i32) (result i32)
|
||||||
|
(call $i32_store_little (i32.const 0) (get_local $value))
|
||||||
|
(i32.load (i32.const 0))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "i64_load16_s") (param $value i64) (result i64)
|
||||||
|
(call $i16_store_little (i32.const 0) (i32.wrap/i64 (get_local $value)))
|
||||||
|
(i64.load16_s (i32.const 0))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "i64_load16_u") (param $value i64) (result i64)
|
||||||
|
(call $i16_store_little (i32.const 0) (i32.wrap/i64 (get_local $value)))
|
||||||
|
(i64.load16_u (i32.const 0))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "i64_load32_s") (param $value i64) (result i64)
|
||||||
|
(call $i32_store_little (i32.const 0) (i32.wrap/i64 (get_local $value)))
|
||||||
|
(i64.load32_s (i32.const 0))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "i64_load32_u") (param $value i64) (result i64)
|
||||||
|
(call $i32_store_little (i32.const 0) (i32.wrap/i64 (get_local $value)))
|
||||||
|
(i64.load32_u (i32.const 0))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "i64_load") (param $value i64) (result i64)
|
||||||
|
(call $i64_store_little (i32.const 0) (get_local $value))
|
||||||
|
(i64.load (i32.const 0))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "f32_load") (param $value f32) (result f32)
|
||||||
|
(call $i32_store_little (i32.const 0) (i32.reinterpret/f32 (get_local $value)))
|
||||||
|
(f32.load (i32.const 0))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "f64_load") (param $value f64) (result f64)
|
||||||
|
(call $i64_store_little (i32.const 0) (i64.reinterpret/f64 (get_local $value)))
|
||||||
|
(f64.load (i32.const 0))
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
(func (export "i32_store16") (param $value i32) (result i32)
|
||||||
|
(i32.store16 (i32.const 0) (get_local $value))
|
||||||
|
(call $i16_load_little (i32.const 0))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "i32_store") (param $value i32) (result i32)
|
||||||
|
(i32.store (i32.const 0) (get_local $value))
|
||||||
|
(call $i32_load_little (i32.const 0))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "i64_store16") (param $value i64) (result i64)
|
||||||
|
(i64.store16 (i32.const 0) (get_local $value))
|
||||||
|
(i64.extend_u/i32 (call $i16_load_little (i32.const 0)))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "i64_store32") (param $value i64) (result i64)
|
||||||
|
(i64.store32 (i32.const 0) (get_local $value))
|
||||||
|
(i64.extend_u/i32 (call $i32_load_little (i32.const 0)))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "i64_store") (param $value i64) (result i64)
|
||||||
|
(i64.store (i32.const 0) (get_local $value))
|
||||||
|
(call $i64_load_little (i32.const 0))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "f32_store") (param $value f32) (result f32)
|
||||||
|
(f32.store (i32.const 0) (get_local $value))
|
||||||
|
(f32.reinterpret/i32 (call $i32_load_little (i32.const 0)))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "f64_store") (param $value f64) (result f64)
|
||||||
|
(f64.store (i32.const 0) (get_local $value))
|
||||||
|
(f64.reinterpret/i64 (call $i64_load_little (i32.const 0)))
|
||||||
|
)
|
||||||
|
)
|
||||||
@@ -0,0 +1,217 @@
|
|||||||
|
(module
|
||||||
|
(memory 1)
|
||||||
|
|
||||||
|
;; Stores an i16 value in little-endian-format
|
||||||
|
(func $i16_store_little (param $address i32) (param $value i32)
|
||||||
|
(i32.store8 (get_local $address) (get_local $value))
|
||||||
|
(i32.store8 (i32.add (get_local $address) (i32.const 1)) (i32.shr_u (get_local $value) (i32.const 8)))
|
||||||
|
)
|
||||||
|
|
||||||
|
;; Stores an i32 value in little-endian format
|
||||||
|
(func $i32_store_little (param $address i32) (param $value i32)
|
||||||
|
(call $i16_store_little (get_local $address) (get_local $value))
|
||||||
|
(call $i16_store_little (i32.add (get_local $address) (i32.const 2)) (i32.shr_u (get_local $value) (i32.const 16)))
|
||||||
|
)
|
||||||
|
|
||||||
|
;; Stores an i64 value in little-endian format
|
||||||
|
(func $i64_store_little (param $address i32) (param $value i64)
|
||||||
|
(call $i32_store_little (get_local $address) (i32.wrap/i64 (get_local $value)))
|
||||||
|
(call $i32_store_little (i32.add (get_local $address) (i32.const 4)) (i32.wrap/i64 (i64.shr_u (get_local $value) (i64.const 32))))
|
||||||
|
)
|
||||||
|
|
||||||
|
;; Loads an i16 value in little-endian format
|
||||||
|
(func $i16_load_little (param $address i32) (result i32)
|
||||||
|
(i32.or
|
||||||
|
(i32.load8_u (get_local $address))
|
||||||
|
(i32.shl (i32.load8_u (i32.add (get_local $address) (i32.const 1))) (i32.const 8))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
;; Loads an i32 value in little-endian format
|
||||||
|
(func $i32_load_little (param $address i32) (result i32)
|
||||||
|
(i32.or
|
||||||
|
(call $i16_load_little (get_local $address))
|
||||||
|
(i32.shl (call $i16_load_little (i32.add (get_local $address) (i32.const 2))) (i32.const 16))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
;; Loads an i64 value in little-endian format
|
||||||
|
(func $i64_load_little (param $address i32) (result i64)
|
||||||
|
(i64.or
|
||||||
|
(i64.extend_u/i32 (call $i32_load_little (get_local $address)))
|
||||||
|
(i64.shl (i64.extend_u/i32 (call $i32_load_little (i32.add (get_local $address) (i32.const 4)))) (i64.const 32))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "i32_load16_s") (param $value i32) (result i32)
|
||||||
|
(call $i16_store_little (i32.const 0) (get_local $value))
|
||||||
|
(i32.load16_s (i32.const 0))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "i32_load16_u") (param $value i32) (result i32)
|
||||||
|
(call $i16_store_little (i32.const 0) (get_local $value))
|
||||||
|
(i32.load16_u (i32.const 0))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "i32_load") (param $value i32) (result i32)
|
||||||
|
(call $i32_store_little (i32.const 0) (get_local $value))
|
||||||
|
(i32.load (i32.const 0))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "i64_load16_s") (param $value i64) (result i64)
|
||||||
|
(call $i16_store_little (i32.const 0) (i32.wrap/i64 (get_local $value)))
|
||||||
|
(i64.load16_s (i32.const 0))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "i64_load16_u") (param $value i64) (result i64)
|
||||||
|
(call $i16_store_little (i32.const 0) (i32.wrap/i64 (get_local $value)))
|
||||||
|
(i64.load16_u (i32.const 0))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "i64_load32_s") (param $value i64) (result i64)
|
||||||
|
(call $i32_store_little (i32.const 0) (i32.wrap/i64 (get_local $value)))
|
||||||
|
(i64.load32_s (i32.const 0))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "i64_load32_u") (param $value i64) (result i64)
|
||||||
|
(call $i32_store_little (i32.const 0) (i32.wrap/i64 (get_local $value)))
|
||||||
|
(i64.load32_u (i32.const 0))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "i64_load") (param $value i64) (result i64)
|
||||||
|
(call $i64_store_little (i32.const 0) (get_local $value))
|
||||||
|
(i64.load (i32.const 0))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "f32_load") (param $value f32) (result f32)
|
||||||
|
(call $i32_store_little (i32.const 0) (i32.reinterpret/f32 (get_local $value)))
|
||||||
|
(f32.load (i32.const 0))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "f64_load") (param $value f64) (result f64)
|
||||||
|
(call $i64_store_little (i32.const 0) (i64.reinterpret/f64 (get_local $value)))
|
||||||
|
(f64.load (i32.const 0))
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
(func (export "i32_store16") (param $value i32) (result i32)
|
||||||
|
(i32.store16 (i32.const 0) (get_local $value))
|
||||||
|
(call $i16_load_little (i32.const 0))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "i32_store") (param $value i32) (result i32)
|
||||||
|
(i32.store (i32.const 0) (get_local $value))
|
||||||
|
(call $i32_load_little (i32.const 0))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "i64_store16") (param $value i64) (result i64)
|
||||||
|
(i64.store16 (i32.const 0) (get_local $value))
|
||||||
|
(i64.extend_u/i32 (call $i16_load_little (i32.const 0)))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "i64_store32") (param $value i64) (result i64)
|
||||||
|
(i64.store32 (i32.const 0) (get_local $value))
|
||||||
|
(i64.extend_u/i32 (call $i32_load_little (i32.const 0)))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "i64_store") (param $value i64) (result i64)
|
||||||
|
(i64.store (i32.const 0) (get_local $value))
|
||||||
|
(call $i64_load_little (i32.const 0))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "f32_store") (param $value f32) (result f32)
|
||||||
|
(f32.store (i32.const 0) (get_local $value))
|
||||||
|
(f32.reinterpret/i32 (call $i32_load_little (i32.const 0)))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "f64_store") (param $value f64) (result f64)
|
||||||
|
(f64.store (i32.const 0) (get_local $value))
|
||||||
|
(f64.reinterpret/i64 (call $i64_load_little (i32.const 0)))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke "i32_load16_s" (i32.const -1)) (i32.const -1))
|
||||||
|
(assert_return (invoke "i32_load16_s" (i32.const -4242)) (i32.const -4242))
|
||||||
|
(assert_return (invoke "i32_load16_s" (i32.const 42)) (i32.const 42))
|
||||||
|
(assert_return (invoke "i32_load16_s" (i32.const 0x3210)) (i32.const 0x3210))
|
||||||
|
|
||||||
|
(assert_return (invoke "i32_load16_u" (i32.const -1)) (i32.const 0xFFFF))
|
||||||
|
(assert_return (invoke "i32_load16_u" (i32.const -4242)) (i32.const 61294))
|
||||||
|
(assert_return (invoke "i32_load16_u" (i32.const 42)) (i32.const 42))
|
||||||
|
(assert_return (invoke "i32_load16_u" (i32.const 0xCAFE)) (i32.const 0xCAFE))
|
||||||
|
|
||||||
|
(assert_return (invoke "i32_load" (i32.const -1)) (i32.const -1))
|
||||||
|
(assert_return (invoke "i32_load" (i32.const -42424242)) (i32.const -42424242))
|
||||||
|
(assert_return (invoke "i32_load" (i32.const 42424242)) (i32.const 42424242))
|
||||||
|
(assert_return (invoke "i32_load" (i32.const 0xABAD1DEA)) (i32.const 0xABAD1DEA))
|
||||||
|
|
||||||
|
(assert_return (invoke "i64_load16_s" (i64.const -1)) (i64.const -1))
|
||||||
|
(assert_return (invoke "i64_load16_s" (i64.const -4242)) (i64.const -4242))
|
||||||
|
(assert_return (invoke "i64_load16_s" (i64.const 42)) (i64.const 42))
|
||||||
|
(assert_return (invoke "i64_load16_s" (i64.const 0x3210)) (i64.const 0x3210))
|
||||||
|
|
||||||
|
(assert_return (invoke "i64_load16_u" (i64.const -1)) (i64.const 0xFFFF))
|
||||||
|
(assert_return (invoke "i64_load16_u" (i64.const -4242)) (i64.const 61294))
|
||||||
|
(assert_return (invoke "i64_load16_u" (i64.const 42)) (i64.const 42))
|
||||||
|
(assert_return (invoke "i64_load16_u" (i64.const 0xCAFE)) (i64.const 0xCAFE))
|
||||||
|
|
||||||
|
(assert_return (invoke "i64_load32_s" (i64.const -1)) (i64.const -1))
|
||||||
|
(assert_return (invoke "i64_load32_s" (i64.const -42424242)) (i64.const -42424242))
|
||||||
|
(assert_return (invoke "i64_load32_s" (i64.const 42424242)) (i64.const 42424242))
|
||||||
|
(assert_return (invoke "i64_load32_s" (i64.const 0x12345678)) (i64.const 0x12345678))
|
||||||
|
|
||||||
|
(assert_return (invoke "i64_load32_u" (i64.const -1)) (i64.const 0xFFFFFFFF))
|
||||||
|
(assert_return (invoke "i64_load32_u" (i64.const -42424242)) (i64.const 4252543054))
|
||||||
|
(assert_return (invoke "i64_load32_u" (i64.const 42424242)) (i64.const 42424242))
|
||||||
|
(assert_return (invoke "i64_load32_u" (i64.const 0xABAD1DEA)) (i64.const 0xABAD1DEA))
|
||||||
|
|
||||||
|
(assert_return (invoke "i64_load" (i64.const -1)) (i64.const -1))
|
||||||
|
(assert_return (invoke "i64_load" (i64.const -42424242)) (i64.const -42424242))
|
||||||
|
(assert_return (invoke "i64_load" (i64.const 0xABAD1DEA)) (i64.const 0xABAD1DEA))
|
||||||
|
(assert_return (invoke "i64_load" (i64.const 0xABADCAFEDEAD1DEA)) (i64.const 0xABADCAFEDEAD1DEA))
|
||||||
|
|
||||||
|
(assert_return (invoke "f32_load" (f32.const -1)) (f32.const -1))
|
||||||
|
(assert_return (invoke "f32_load" (f32.const 1234e-5)) (f32.const 1234e-5))
|
||||||
|
(assert_return (invoke "f32_load" (f32.const 4242.4242)) (f32.const 4242.4242))
|
||||||
|
(assert_return (invoke "f32_load" (f32.const 0x1.fffffep+127)) (f32.const 0x1.fffffep+127))
|
||||||
|
|
||||||
|
(assert_return (invoke "f64_load" (f64.const -1)) (f64.const -1))
|
||||||
|
(assert_return (invoke "f64_load" (f64.const 123456789e-5)) (f64.const 123456789e-5))
|
||||||
|
(assert_return (invoke "f64_load" (f64.const 424242.424242)) (f64.const 424242.424242))
|
||||||
|
(assert_return (invoke "f64_load" (f64.const 0x1.fffffffffffffp+1023)) (f64.const 0x1.fffffffffffffp+1023))
|
||||||
|
|
||||||
|
|
||||||
|
(assert_return (invoke "i32_store16" (i32.const -1)) (i32.const 0xFFFF))
|
||||||
|
(assert_return (invoke "i32_store16" (i32.const -4242)) (i32.const 61294))
|
||||||
|
(assert_return (invoke "i32_store16" (i32.const 42)) (i32.const 42))
|
||||||
|
(assert_return (invoke "i32_store16" (i32.const 0xCAFE)) (i32.const 0xCAFE))
|
||||||
|
|
||||||
|
(assert_return (invoke "i32_store" (i32.const -1)) (i32.const -1))
|
||||||
|
(assert_return (invoke "i32_store" (i32.const -4242)) (i32.const -4242))
|
||||||
|
(assert_return (invoke "i32_store" (i32.const 42424242)) (i32.const 42424242))
|
||||||
|
(assert_return (invoke "i32_store" (i32.const 0xDEADCAFE)) (i32.const 0xDEADCAFE))
|
||||||
|
|
||||||
|
(assert_return (invoke "i64_store16" (i64.const -1)) (i64.const 0xFFFF))
|
||||||
|
(assert_return (invoke "i64_store16" (i64.const -4242)) (i64.const 61294))
|
||||||
|
(assert_return (invoke "i64_store16" (i64.const 42)) (i64.const 42))
|
||||||
|
(assert_return (invoke "i64_store16" (i64.const 0xCAFE)) (i64.const 0xCAFE))
|
||||||
|
|
||||||
|
(assert_return (invoke "i64_store32" (i64.const -1)) (i64.const 0xFFFFFFFF))
|
||||||
|
(assert_return (invoke "i64_store32" (i64.const -4242)) (i64.const 4294963054))
|
||||||
|
(assert_return (invoke "i64_store32" (i64.const 42424242)) (i64.const 42424242))
|
||||||
|
(assert_return (invoke "i64_store32" (i64.const 0xDEADCAFE)) (i64.const 0xDEADCAFE))
|
||||||
|
|
||||||
|
(assert_return (invoke "i64_store" (i64.const -1)) (i64.const -1))
|
||||||
|
(assert_return (invoke "i64_store" (i64.const -42424242)) (i64.const -42424242))
|
||||||
|
(assert_return (invoke "i64_store" (i64.const 0xABAD1DEA)) (i64.const 0xABAD1DEA))
|
||||||
|
(assert_return (invoke "i64_store" (i64.const 0xABADCAFEDEAD1DEA)) (i64.const 0xABADCAFEDEAD1DEA))
|
||||||
|
|
||||||
|
(assert_return (invoke "f32_store" (f32.const -1)) (f32.const -1))
|
||||||
|
(assert_return (invoke "f32_store" (f32.const 1234e-5)) (f32.const 1234e-5))
|
||||||
|
(assert_return (invoke "f32_store" (f32.const 4242.4242)) (f32.const 4242.4242))
|
||||||
|
(assert_return (invoke "f32_store" (f32.const 0x1.fffffep+127)) (f32.const 0x1.fffffep+127))
|
||||||
|
|
||||||
|
(assert_return (invoke "f64_store" (f64.const -1)) (f64.const -1))
|
||||||
|
(assert_return (invoke "f64_store" (f64.const 123456789e-5)) (f64.const 123456789e-5))
|
||||||
|
(assert_return (invoke "f64_store" (f64.const 424242.424242)) (f64.const 424242.424242))
|
||||||
|
(assert_return (invoke "f64_store" (f64.const 0x1.fffffffffffffp+1023)) (f64.const 0x1.fffffffffffffp+1023))
|
||||||
@@ -0,0 +1,198 @@
|
|||||||
|
;; Functions
|
||||||
|
|
||||||
|
(module (func) (export "a" (func 0)))
|
||||||
|
(module (func) (export "a" (func 0)) (export "b" (func 0)))
|
||||||
|
(module (func) (func) (export "a" (func 0)) (export "b" (func 1)))
|
||||||
|
|
||||||
|
(module (func (export "a")))
|
||||||
|
(module (func (export "a") (export "b") (export "c")))
|
||||||
|
(module (func (export "a") (export "b") (param i32)))
|
||||||
|
(module (func) (export "a" (func 0)))
|
||||||
|
(module (func $a (export "a")))
|
||||||
|
(module (func $a) (export "a" (func $a)))
|
||||||
|
(module (export "a" (func 0)) (func))
|
||||||
|
(module (export "a" (func $a)) (func $a))
|
||||||
|
|
||||||
|
(module $Func
|
||||||
|
(export "e" (func $f))
|
||||||
|
(func $f (param $n i32) (result i32)
|
||||||
|
(return (i32.add (get_local $n) (i32.const 1)))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(assert_return (invoke "e" (i32.const 42)) (i32.const 43))
|
||||||
|
(assert_return (invoke $Func "e" (i32.const 42)) (i32.const 43))
|
||||||
|
(module)
|
||||||
|
(module $Other1)
|
||||||
|
(assert_return (invoke $Func "e" (i32.const 42)) (i32.const 43))
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func) (export "a" (func 1)))
|
||||||
|
"unknown function"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func) (export "a" (func 0)) (export "a" (func 0)))
|
||||||
|
"duplicate export name"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func) (func) (export "a" (func 0)) (export "a" (func 1)))
|
||||||
|
"duplicate export name"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func) (global i32 (i32.const 0)) (export "a" (func 0)) (export "a" (global 0)))
|
||||||
|
"duplicate export name"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func) (table 0 anyfunc) (export "a" (func 0)) (export "a" (table 0)))
|
||||||
|
"duplicate export name"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func) (memory 0) (export "a" (func 0)) (export "a" (memory 0)))
|
||||||
|
"duplicate export name"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
;; Globals
|
||||||
|
|
||||||
|
(module (global i32 (i32.const 0)) (export "a" (global 0)))
|
||||||
|
(module (global i32 (i32.const 0)) (export "a" (global 0)) (export "b" (global 0)))
|
||||||
|
(module (global i32 (i32.const 0)) (global i32 (i32.const 0)) (export "a" (global 0)) (export "b" (global 1)))
|
||||||
|
|
||||||
|
(module (global (export "a") i32 (i32.const 0)))
|
||||||
|
(module (global i32 (i32.const 0)) (export "a" (global 0)))
|
||||||
|
(module (global $a (export "a") i32 (i32.const 0)))
|
||||||
|
(module (global $a i32 (i32.const 0)) (export "a" (global $a)))
|
||||||
|
(module (export "a" (global 0)) (global i32 (i32.const 0)))
|
||||||
|
(module (export "a" (global $a)) (global $a i32 (i32.const 0)))
|
||||||
|
|
||||||
|
(module $Global
|
||||||
|
(export "e" (global $g))
|
||||||
|
(global $g i32 (i32.const 42))
|
||||||
|
)
|
||||||
|
(assert_return (get "e") (i32.const 42))
|
||||||
|
(assert_return (get $Global "e") (i32.const 42))
|
||||||
|
(module)
|
||||||
|
(module $Other2)
|
||||||
|
(assert_return (get $Global "e") (i32.const 42))
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (global i32 (i32.const 0)) (export "a" (global 1)))
|
||||||
|
"unknown global"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (global i32 (i32.const 0)) (export "a" (global 0)) (export "a" (global 0)))
|
||||||
|
"duplicate export name"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (global i32 (i32.const 0)) (global i32 (i32.const 0)) (export "a" (global 0)) (export "a" (global 1)))
|
||||||
|
"duplicate export name"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (global i32 (i32.const 0)) (func) (export "a" (global 0)) (export "a" (func 0)))
|
||||||
|
"duplicate export name"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (global i32 (i32.const 0)) (table 0 anyfunc) (export "a" (global 0)) (export "a" (table 0)))
|
||||||
|
"duplicate export name"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (global i32 (i32.const 0)) (memory 0) (export "a" (global 0)) (export "a" (memory 0)))
|
||||||
|
"duplicate export name"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
;; Tables
|
||||||
|
|
||||||
|
(module (table 0 anyfunc) (export "a" (table 0)))
|
||||||
|
(module (table 0 anyfunc) (export "a" (table 0)) (export "b" (table 0)))
|
||||||
|
;; No multiple tables yet.
|
||||||
|
;; (module (table 0 anyfunc) (table 0 anyfunc) (export "a" (table 0)) (export "b" (table 1)))
|
||||||
|
|
||||||
|
(module (table (export "a") 0 anyfunc))
|
||||||
|
(module (table (export "a") 0 1 anyfunc))
|
||||||
|
(module (table 0 anyfunc) (export "a" (table 0)))
|
||||||
|
(module (table 0 1 anyfunc) (export "a" (table 0)))
|
||||||
|
(module (table $a (export "a") 0 anyfunc))
|
||||||
|
(module (table $a (export "a") 0 1 anyfunc))
|
||||||
|
(module (table $a 0 anyfunc) (export "a" (table $a)))
|
||||||
|
(module (table $a 0 1 anyfunc) (export "a" (table $a)))
|
||||||
|
(module (export "a" (table 0)) (table 0 anyfunc))
|
||||||
|
(module (export "a" (table 0)) (table 0 1 anyfunc))
|
||||||
|
(module (export "a" (table $a)) (table $a 0 anyfunc))
|
||||||
|
(module (export "a" (table $a)) (table $a 0 1 anyfunc))
|
||||||
|
|
||||||
|
(; TODO: access table ;)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (table 0 anyfunc) (export "a" (table 1)))
|
||||||
|
"unknown table"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (table 0 anyfunc) (export "a" (table 0)) (export "a" (table 0)))
|
||||||
|
"duplicate export name"
|
||||||
|
)
|
||||||
|
;; No multiple tables yet.
|
||||||
|
;; (assert_invalid
|
||||||
|
;; (module (table 0 anyfunc) (table 0 anyfunc) (export "a" (table 0)) (export "a" (table 1)))
|
||||||
|
;; "duplicate export name"
|
||||||
|
;; )
|
||||||
|
(assert_invalid
|
||||||
|
(module (table 0 anyfunc) (func) (export "a" (table 0)) (export "a" (func 0)))
|
||||||
|
"duplicate export name"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (table 0 anyfunc) (global i32 (i32.const 0)) (export "a" (table 0)) (export "a" (global 0)))
|
||||||
|
"duplicate export name"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (table 0 anyfunc) (memory 0) (export "a" (table 0)) (export "a" (memory 0)))
|
||||||
|
"duplicate export name"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
;; Memories
|
||||||
|
|
||||||
|
(module (memory 0) (export "a" (memory 0)))
|
||||||
|
(module (memory 0) (export "a" (memory 0)) (export "b" (memory 0)))
|
||||||
|
;; No multiple memories yet.
|
||||||
|
;; (module (memory 0) (memory 0) (export "a" (memory 0)) (export "b" (memory 1)))
|
||||||
|
|
||||||
|
(module (memory (export "a") 0))
|
||||||
|
(module (memory (export "a") 0 1))
|
||||||
|
(module (memory 0) (export "a" (memory 0)))
|
||||||
|
(module (memory 0 1) (export "a" (memory 0)))
|
||||||
|
(module (memory $a (export "a") 0))
|
||||||
|
(module (memory $a (export "a") 0 1))
|
||||||
|
(module (memory $a 0) (export "a" (memory $a)))
|
||||||
|
(module (memory $a 0 1) (export "a" (memory $a)))
|
||||||
|
(module (export "a" (memory 0)) (memory 0))
|
||||||
|
(module (export "a" (memory 0)) (memory 0 1))
|
||||||
|
(module (export "a" (memory $a)) (memory $a 0))
|
||||||
|
(module (export "a" (memory $a)) (memory $a 0 1))
|
||||||
|
|
||||||
|
(; TODO: access memory ;)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (memory 0) (export "a" (memory 1)))
|
||||||
|
"unknown memory"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (memory 0) (export "a" (memory 0)) (export "a" (memory 0)))
|
||||||
|
"duplicate export name"
|
||||||
|
)
|
||||||
|
;; No multiple memories yet.
|
||||||
|
;; (assert_invalid
|
||||||
|
;; (module (memory 0) (memory 0) (export "a" (memory 0)) (export "a" (memory 1)))
|
||||||
|
;; "duplicate export name"
|
||||||
|
;; )
|
||||||
|
(assert_invalid
|
||||||
|
(module (memory 0) (func) (export "a" (memory 0)) (export "a" (func 0)))
|
||||||
|
"duplicate export name"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (memory 0) (global i32 (i32.const 0)) (export "a" (memory 0)) (export "a" (global 0)))
|
||||||
|
"duplicate export name"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (memory 0) (table 0 anyfunc) (export "a" (memory 0)) (export "a" (table 0)))
|
||||||
|
"duplicate export name"
|
||||||
|
)
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,369 @@
|
|||||||
|
;; Test all the f32 bitwise operators on major boundary values and all special
|
||||||
|
;; values.
|
||||||
|
|
||||||
|
(module
|
||||||
|
(func (export "abs") (param $x f32) (result f32) (f32.abs (get_local $x)))
|
||||||
|
(func (export "neg") (param $x f32) (result f32) (f32.neg (get_local $x)))
|
||||||
|
(func (export "copysign") (param $x f32) (param $y f32) (result f32) (f32.copysign (get_local $x) (get_local $y)))
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x0p+0) (f32.const -0x0p+0)) (f32.const -0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x0p+0) (f32.const 0x0p+0)) (f32.const 0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x0p+0) (f32.const -0x0p+0)) (f32.const -0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x0p+0) (f32.const 0x0p+0)) (f32.const 0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x0p+0) (f32.const -0x1p-149)) (f32.const -0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x0p+0) (f32.const 0x1p-149)) (f32.const 0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x0p+0) (f32.const -0x1p-149)) (f32.const -0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x0p+0) (f32.const 0x1p-149)) (f32.const 0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x0p+0) (f32.const -0x1p-126)) (f32.const -0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x0p+0) (f32.const 0x1p-126)) (f32.const 0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x0p+0) (f32.const -0x1p-126)) (f32.const -0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x0p+0) (f32.const 0x1p-126)) (f32.const 0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x0p+0) (f32.const -0x1p-1)) (f32.const -0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x0p+0) (f32.const 0x1p-1)) (f32.const 0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x0p+0) (f32.const -0x1p-1)) (f32.const -0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x0p+0) (f32.const 0x1p-1)) (f32.const 0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x0p+0) (f32.const -0x1p+0)) (f32.const -0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x0p+0) (f32.const 0x1p+0)) (f32.const 0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x0p+0) (f32.const -0x1p+0)) (f32.const -0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x0p+0) (f32.const 0x1p+0)) (f32.const 0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x0p+0) (f32.const -0x1.921fb6p+2)) (f32.const -0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x0p+0) (f32.const 0x1.921fb6p+2)) (f32.const 0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x0p+0) (f32.const -0x1.921fb6p+2)) (f32.const -0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x0p+0) (f32.const 0x1.921fb6p+2)) (f32.const 0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x0p+0) (f32.const -0x1.fffffep+127)) (f32.const -0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x0p+0) (f32.const 0x1.fffffep+127)) (f32.const 0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x0p+0) (f32.const -0x1.fffffep+127)) (f32.const -0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x0p+0) (f32.const 0x1.fffffep+127)) (f32.const 0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x0p+0) (f32.const -inf)) (f32.const -0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x0p+0) (f32.const inf)) (f32.const 0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x0p+0) (f32.const -inf)) (f32.const -0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x0p+0) (f32.const inf)) (f32.const 0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x0p+0) (f32.const -nan)) (f32.const -0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x0p+0) (f32.const nan)) (f32.const 0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x0p+0) (f32.const -nan)) (f32.const -0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x0p+0) (f32.const nan)) (f32.const 0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p-149) (f32.const -0x0p+0)) (f32.const -0x1p-149))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p-149) (f32.const 0x0p+0)) (f32.const 0x1p-149))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p-149) (f32.const -0x0p+0)) (f32.const -0x1p-149))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p-149) (f32.const 0x0p+0)) (f32.const 0x1p-149))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p-149) (f32.const -0x1p-149)) (f32.const -0x1p-149))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p-149) (f32.const 0x1p-149)) (f32.const 0x1p-149))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p-149) (f32.const -0x1p-149)) (f32.const -0x1p-149))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p-149) (f32.const 0x1p-149)) (f32.const 0x1p-149))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p-149) (f32.const -0x1p-126)) (f32.const -0x1p-149))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p-149) (f32.const 0x1p-126)) (f32.const 0x1p-149))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p-149) (f32.const -0x1p-126)) (f32.const -0x1p-149))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p-149) (f32.const 0x1p-126)) (f32.const 0x1p-149))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p-149) (f32.const -0x1p-1)) (f32.const -0x1p-149))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p-149) (f32.const 0x1p-1)) (f32.const 0x1p-149))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p-149) (f32.const -0x1p-1)) (f32.const -0x1p-149))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p-149) (f32.const 0x1p-1)) (f32.const 0x1p-149))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p-149) (f32.const -0x1p+0)) (f32.const -0x1p-149))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p-149) (f32.const 0x1p+0)) (f32.const 0x1p-149))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p-149) (f32.const -0x1p+0)) (f32.const -0x1p-149))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p-149) (f32.const 0x1p+0)) (f32.const 0x1p-149))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p-149) (f32.const -0x1.921fb6p+2)) (f32.const -0x1p-149))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p-149) (f32.const 0x1.921fb6p+2)) (f32.const 0x1p-149))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p-149) (f32.const -0x1.921fb6p+2)) (f32.const -0x1p-149))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p-149) (f32.const 0x1.921fb6p+2)) (f32.const 0x1p-149))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p-149) (f32.const -0x1.fffffep+127)) (f32.const -0x1p-149))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p-149) (f32.const 0x1.fffffep+127)) (f32.const 0x1p-149))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p-149) (f32.const -0x1.fffffep+127)) (f32.const -0x1p-149))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p-149) (f32.const 0x1.fffffep+127)) (f32.const 0x1p-149))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p-149) (f32.const -inf)) (f32.const -0x1p-149))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p-149) (f32.const inf)) (f32.const 0x1p-149))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p-149) (f32.const -inf)) (f32.const -0x1p-149))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p-149) (f32.const inf)) (f32.const 0x1p-149))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p-149) (f32.const -nan)) (f32.const -0x1p-149))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p-149) (f32.const nan)) (f32.const 0x1p-149))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p-149) (f32.const -nan)) (f32.const -0x1p-149))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p-149) (f32.const nan)) (f32.const 0x1p-149))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p-126) (f32.const -0x0p+0)) (f32.const -0x1p-126))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p-126) (f32.const 0x0p+0)) (f32.const 0x1p-126))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p-126) (f32.const -0x0p+0)) (f32.const -0x1p-126))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p-126) (f32.const 0x0p+0)) (f32.const 0x1p-126))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p-126) (f32.const -0x1p-149)) (f32.const -0x1p-126))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p-126) (f32.const 0x1p-149)) (f32.const 0x1p-126))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p-126) (f32.const -0x1p-149)) (f32.const -0x1p-126))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p-126) (f32.const 0x1p-149)) (f32.const 0x1p-126))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p-126) (f32.const -0x1p-126)) (f32.const -0x1p-126))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p-126) (f32.const 0x1p-126)) (f32.const 0x1p-126))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p-126) (f32.const -0x1p-126)) (f32.const -0x1p-126))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p-126) (f32.const 0x1p-126)) (f32.const 0x1p-126))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p-126) (f32.const -0x1p-1)) (f32.const -0x1p-126))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p-126) (f32.const 0x1p-1)) (f32.const 0x1p-126))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p-126) (f32.const -0x1p-1)) (f32.const -0x1p-126))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p-126) (f32.const 0x1p-1)) (f32.const 0x1p-126))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p-126) (f32.const -0x1p+0)) (f32.const -0x1p-126))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p-126) (f32.const 0x1p+0)) (f32.const 0x1p-126))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p-126) (f32.const -0x1p+0)) (f32.const -0x1p-126))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p-126) (f32.const 0x1p+0)) (f32.const 0x1p-126))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p-126) (f32.const -0x1.921fb6p+2)) (f32.const -0x1p-126))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p-126) (f32.const 0x1.921fb6p+2)) (f32.const 0x1p-126))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p-126) (f32.const -0x1.921fb6p+2)) (f32.const -0x1p-126))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p-126) (f32.const 0x1.921fb6p+2)) (f32.const 0x1p-126))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p-126) (f32.const -0x1.fffffep+127)) (f32.const -0x1p-126))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p-126) (f32.const 0x1.fffffep+127)) (f32.const 0x1p-126))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p-126) (f32.const -0x1.fffffep+127)) (f32.const -0x1p-126))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p-126) (f32.const 0x1.fffffep+127)) (f32.const 0x1p-126))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p-126) (f32.const -inf)) (f32.const -0x1p-126))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p-126) (f32.const inf)) (f32.const 0x1p-126))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p-126) (f32.const -inf)) (f32.const -0x1p-126))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p-126) (f32.const inf)) (f32.const 0x1p-126))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p-126) (f32.const -nan)) (f32.const -0x1p-126))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p-126) (f32.const nan)) (f32.const 0x1p-126))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p-126) (f32.const -nan)) (f32.const -0x1p-126))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p-126) (f32.const nan)) (f32.const 0x1p-126))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p-1) (f32.const -0x0p+0)) (f32.const -0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p-1) (f32.const 0x0p+0)) (f32.const 0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p-1) (f32.const -0x0p+0)) (f32.const -0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p-1) (f32.const 0x0p+0)) (f32.const 0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p-1) (f32.const -0x1p-149)) (f32.const -0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p-1) (f32.const 0x1p-149)) (f32.const 0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p-1) (f32.const -0x1p-149)) (f32.const -0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p-1) (f32.const 0x1p-149)) (f32.const 0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p-1) (f32.const -0x1p-126)) (f32.const -0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p-1) (f32.const 0x1p-126)) (f32.const 0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p-1) (f32.const -0x1p-126)) (f32.const -0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p-1) (f32.const 0x1p-126)) (f32.const 0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p-1) (f32.const -0x1p-1)) (f32.const -0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p-1) (f32.const 0x1p-1)) (f32.const 0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p-1) (f32.const -0x1p-1)) (f32.const -0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p-1) (f32.const 0x1p-1)) (f32.const 0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p-1) (f32.const -0x1p+0)) (f32.const -0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p-1) (f32.const 0x1p+0)) (f32.const 0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p-1) (f32.const -0x1p+0)) (f32.const -0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p-1) (f32.const 0x1p+0)) (f32.const 0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p-1) (f32.const -0x1.921fb6p+2)) (f32.const -0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p-1) (f32.const 0x1.921fb6p+2)) (f32.const 0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p-1) (f32.const -0x1.921fb6p+2)) (f32.const -0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p-1) (f32.const 0x1.921fb6p+2)) (f32.const 0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p-1) (f32.const -0x1.fffffep+127)) (f32.const -0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p-1) (f32.const 0x1.fffffep+127)) (f32.const 0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p-1) (f32.const -0x1.fffffep+127)) (f32.const -0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p-1) (f32.const 0x1.fffffep+127)) (f32.const 0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p-1) (f32.const -inf)) (f32.const -0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p-1) (f32.const inf)) (f32.const 0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p-1) (f32.const -inf)) (f32.const -0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p-1) (f32.const inf)) (f32.const 0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p-1) (f32.const -nan)) (f32.const -0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p-1) (f32.const nan)) (f32.const 0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p-1) (f32.const -nan)) (f32.const -0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p-1) (f32.const nan)) (f32.const 0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p+0) (f32.const -0x0p+0)) (f32.const -0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p+0) (f32.const 0x0p+0)) (f32.const 0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p+0) (f32.const -0x0p+0)) (f32.const -0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p+0) (f32.const 0x0p+0)) (f32.const 0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p+0) (f32.const -0x1p-149)) (f32.const -0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p+0) (f32.const 0x1p-149)) (f32.const 0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p+0) (f32.const -0x1p-149)) (f32.const -0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p+0) (f32.const 0x1p-149)) (f32.const 0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p+0) (f32.const -0x1p-126)) (f32.const -0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p+0) (f32.const 0x1p-126)) (f32.const 0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p+0) (f32.const -0x1p-126)) (f32.const -0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p+0) (f32.const 0x1p-126)) (f32.const 0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p+0) (f32.const -0x1p-1)) (f32.const -0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p+0) (f32.const 0x1p-1)) (f32.const 0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p+0) (f32.const -0x1p-1)) (f32.const -0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p+0) (f32.const 0x1p-1)) (f32.const 0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p+0) (f32.const -0x1p+0)) (f32.const -0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p+0) (f32.const 0x1p+0)) (f32.const 0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p+0) (f32.const -0x1p+0)) (f32.const -0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p+0) (f32.const 0x1p+0)) (f32.const 0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p+0) (f32.const -0x1.921fb6p+2)) (f32.const -0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p+0) (f32.const 0x1.921fb6p+2)) (f32.const 0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p+0) (f32.const -0x1.921fb6p+2)) (f32.const -0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p+0) (f32.const 0x1.921fb6p+2)) (f32.const 0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p+0) (f32.const -0x1.fffffep+127)) (f32.const -0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p+0) (f32.const 0x1.fffffep+127)) (f32.const 0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p+0) (f32.const -0x1.fffffep+127)) (f32.const -0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p+0) (f32.const 0x1.fffffep+127)) (f32.const 0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p+0) (f32.const -inf)) (f32.const -0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p+0) (f32.const inf)) (f32.const 0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p+0) (f32.const -inf)) (f32.const -0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p+0) (f32.const inf)) (f32.const 0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p+0) (f32.const -nan)) (f32.const -0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1p+0) (f32.const nan)) (f32.const 0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p+0) (f32.const -nan)) (f32.const -0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1p+0) (f32.const nan)) (f32.const 0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1.921fb6p+2) (f32.const -0x0p+0)) (f32.const -0x1.921fb6p+2))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1.921fb6p+2) (f32.const 0x0p+0)) (f32.const 0x1.921fb6p+2))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1.921fb6p+2) (f32.const -0x0p+0)) (f32.const -0x1.921fb6p+2))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1.921fb6p+2) (f32.const 0x0p+0)) (f32.const 0x1.921fb6p+2))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1.921fb6p+2) (f32.const -0x1p-149)) (f32.const -0x1.921fb6p+2))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1.921fb6p+2) (f32.const 0x1p-149)) (f32.const 0x1.921fb6p+2))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1.921fb6p+2) (f32.const -0x1p-149)) (f32.const -0x1.921fb6p+2))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1.921fb6p+2) (f32.const 0x1p-149)) (f32.const 0x1.921fb6p+2))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1.921fb6p+2) (f32.const -0x1p-126)) (f32.const -0x1.921fb6p+2))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1.921fb6p+2) (f32.const 0x1p-126)) (f32.const 0x1.921fb6p+2))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1.921fb6p+2) (f32.const -0x1p-126)) (f32.const -0x1.921fb6p+2))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1.921fb6p+2) (f32.const 0x1p-126)) (f32.const 0x1.921fb6p+2))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1.921fb6p+2) (f32.const -0x1p-1)) (f32.const -0x1.921fb6p+2))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1.921fb6p+2) (f32.const 0x1p-1)) (f32.const 0x1.921fb6p+2))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1.921fb6p+2) (f32.const -0x1p-1)) (f32.const -0x1.921fb6p+2))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1.921fb6p+2) (f32.const 0x1p-1)) (f32.const 0x1.921fb6p+2))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1.921fb6p+2) (f32.const -0x1p+0)) (f32.const -0x1.921fb6p+2))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1.921fb6p+2) (f32.const 0x1p+0)) (f32.const 0x1.921fb6p+2))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1.921fb6p+2) (f32.const -0x1p+0)) (f32.const -0x1.921fb6p+2))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1.921fb6p+2) (f32.const 0x1p+0)) (f32.const 0x1.921fb6p+2))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1.921fb6p+2) (f32.const -0x1.921fb6p+2)) (f32.const -0x1.921fb6p+2))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1.921fb6p+2) (f32.const 0x1.921fb6p+2)) (f32.const 0x1.921fb6p+2))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1.921fb6p+2) (f32.const -0x1.921fb6p+2)) (f32.const -0x1.921fb6p+2))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1.921fb6p+2) (f32.const 0x1.921fb6p+2)) (f32.const 0x1.921fb6p+2))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1.921fb6p+2) (f32.const -0x1.fffffep+127)) (f32.const -0x1.921fb6p+2))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1.921fb6p+2) (f32.const 0x1.fffffep+127)) (f32.const 0x1.921fb6p+2))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1.921fb6p+2) (f32.const -0x1.fffffep+127)) (f32.const -0x1.921fb6p+2))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1.921fb6p+2) (f32.const 0x1.fffffep+127)) (f32.const 0x1.921fb6p+2))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1.921fb6p+2) (f32.const -inf)) (f32.const -0x1.921fb6p+2))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1.921fb6p+2) (f32.const inf)) (f32.const 0x1.921fb6p+2))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1.921fb6p+2) (f32.const -inf)) (f32.const -0x1.921fb6p+2))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1.921fb6p+2) (f32.const inf)) (f32.const 0x1.921fb6p+2))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1.921fb6p+2) (f32.const -nan)) (f32.const -0x1.921fb6p+2))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1.921fb6p+2) (f32.const nan)) (f32.const 0x1.921fb6p+2))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1.921fb6p+2) (f32.const -nan)) (f32.const -0x1.921fb6p+2))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1.921fb6p+2) (f32.const nan)) (f32.const 0x1.921fb6p+2))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1.fffffep+127) (f32.const -0x0p+0)) (f32.const -0x1.fffffep+127))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1.fffffep+127) (f32.const 0x0p+0)) (f32.const 0x1.fffffep+127))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1.fffffep+127) (f32.const -0x0p+0)) (f32.const -0x1.fffffep+127))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1.fffffep+127) (f32.const 0x0p+0)) (f32.const 0x1.fffffep+127))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1.fffffep+127) (f32.const -0x1p-149)) (f32.const -0x1.fffffep+127))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1.fffffep+127) (f32.const 0x1p-149)) (f32.const 0x1.fffffep+127))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1.fffffep+127) (f32.const -0x1p-149)) (f32.const -0x1.fffffep+127))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1.fffffep+127) (f32.const 0x1p-149)) (f32.const 0x1.fffffep+127))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1.fffffep+127) (f32.const -0x1p-126)) (f32.const -0x1.fffffep+127))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1.fffffep+127) (f32.const 0x1p-126)) (f32.const 0x1.fffffep+127))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1.fffffep+127) (f32.const -0x1p-126)) (f32.const -0x1.fffffep+127))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1.fffffep+127) (f32.const 0x1p-126)) (f32.const 0x1.fffffep+127))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1.fffffep+127) (f32.const -0x1p-1)) (f32.const -0x1.fffffep+127))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1.fffffep+127) (f32.const 0x1p-1)) (f32.const 0x1.fffffep+127))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1.fffffep+127) (f32.const -0x1p-1)) (f32.const -0x1.fffffep+127))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1.fffffep+127) (f32.const 0x1p-1)) (f32.const 0x1.fffffep+127))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1.fffffep+127) (f32.const -0x1p+0)) (f32.const -0x1.fffffep+127))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1.fffffep+127) (f32.const 0x1p+0)) (f32.const 0x1.fffffep+127))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1.fffffep+127) (f32.const -0x1p+0)) (f32.const -0x1.fffffep+127))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1.fffffep+127) (f32.const 0x1p+0)) (f32.const 0x1.fffffep+127))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1.fffffep+127) (f32.const -0x1.921fb6p+2)) (f32.const -0x1.fffffep+127))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1.fffffep+127) (f32.const 0x1.921fb6p+2)) (f32.const 0x1.fffffep+127))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1.fffffep+127) (f32.const -0x1.921fb6p+2)) (f32.const -0x1.fffffep+127))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1.fffffep+127) (f32.const 0x1.921fb6p+2)) (f32.const 0x1.fffffep+127))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1.fffffep+127) (f32.const -0x1.fffffep+127)) (f32.const -0x1.fffffep+127))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1.fffffep+127) (f32.const 0x1.fffffep+127)) (f32.const 0x1.fffffep+127))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1.fffffep+127) (f32.const -0x1.fffffep+127)) (f32.const -0x1.fffffep+127))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1.fffffep+127) (f32.const 0x1.fffffep+127)) (f32.const 0x1.fffffep+127))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1.fffffep+127) (f32.const -inf)) (f32.const -0x1.fffffep+127))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1.fffffep+127) (f32.const inf)) (f32.const 0x1.fffffep+127))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1.fffffep+127) (f32.const -inf)) (f32.const -0x1.fffffep+127))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1.fffffep+127) (f32.const inf)) (f32.const 0x1.fffffep+127))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1.fffffep+127) (f32.const -nan)) (f32.const -0x1.fffffep+127))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -0x1.fffffep+127) (f32.const nan)) (f32.const 0x1.fffffep+127))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1.fffffep+127) (f32.const -nan)) (f32.const -0x1.fffffep+127))
|
||||||
|
(assert_return (invoke "copysign" (f32.const 0x1.fffffep+127) (f32.const nan)) (f32.const 0x1.fffffep+127))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -inf) (f32.const -0x0p+0)) (f32.const -inf))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -inf) (f32.const 0x0p+0)) (f32.const inf))
|
||||||
|
(assert_return (invoke "copysign" (f32.const inf) (f32.const -0x0p+0)) (f32.const -inf))
|
||||||
|
(assert_return (invoke "copysign" (f32.const inf) (f32.const 0x0p+0)) (f32.const inf))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -inf) (f32.const -0x1p-149)) (f32.const -inf))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -inf) (f32.const 0x1p-149)) (f32.const inf))
|
||||||
|
(assert_return (invoke "copysign" (f32.const inf) (f32.const -0x1p-149)) (f32.const -inf))
|
||||||
|
(assert_return (invoke "copysign" (f32.const inf) (f32.const 0x1p-149)) (f32.const inf))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -inf) (f32.const -0x1p-126)) (f32.const -inf))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -inf) (f32.const 0x1p-126)) (f32.const inf))
|
||||||
|
(assert_return (invoke "copysign" (f32.const inf) (f32.const -0x1p-126)) (f32.const -inf))
|
||||||
|
(assert_return (invoke "copysign" (f32.const inf) (f32.const 0x1p-126)) (f32.const inf))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -inf) (f32.const -0x1p-1)) (f32.const -inf))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -inf) (f32.const 0x1p-1)) (f32.const inf))
|
||||||
|
(assert_return (invoke "copysign" (f32.const inf) (f32.const -0x1p-1)) (f32.const -inf))
|
||||||
|
(assert_return (invoke "copysign" (f32.const inf) (f32.const 0x1p-1)) (f32.const inf))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -inf) (f32.const -0x1p+0)) (f32.const -inf))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -inf) (f32.const 0x1p+0)) (f32.const inf))
|
||||||
|
(assert_return (invoke "copysign" (f32.const inf) (f32.const -0x1p+0)) (f32.const -inf))
|
||||||
|
(assert_return (invoke "copysign" (f32.const inf) (f32.const 0x1p+0)) (f32.const inf))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -inf) (f32.const -0x1.921fb6p+2)) (f32.const -inf))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -inf) (f32.const 0x1.921fb6p+2)) (f32.const inf))
|
||||||
|
(assert_return (invoke "copysign" (f32.const inf) (f32.const -0x1.921fb6p+2)) (f32.const -inf))
|
||||||
|
(assert_return (invoke "copysign" (f32.const inf) (f32.const 0x1.921fb6p+2)) (f32.const inf))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -inf) (f32.const -0x1.fffffep+127)) (f32.const -inf))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -inf) (f32.const 0x1.fffffep+127)) (f32.const inf))
|
||||||
|
(assert_return (invoke "copysign" (f32.const inf) (f32.const -0x1.fffffep+127)) (f32.const -inf))
|
||||||
|
(assert_return (invoke "copysign" (f32.const inf) (f32.const 0x1.fffffep+127)) (f32.const inf))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -inf) (f32.const -inf)) (f32.const -inf))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -inf) (f32.const inf)) (f32.const inf))
|
||||||
|
(assert_return (invoke "copysign" (f32.const inf) (f32.const -inf)) (f32.const -inf))
|
||||||
|
(assert_return (invoke "copysign" (f32.const inf) (f32.const inf)) (f32.const inf))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -inf) (f32.const -nan)) (f32.const -inf))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -inf) (f32.const nan)) (f32.const inf))
|
||||||
|
(assert_return (invoke "copysign" (f32.const inf) (f32.const -nan)) (f32.const -inf))
|
||||||
|
(assert_return (invoke "copysign" (f32.const inf) (f32.const nan)) (f32.const inf))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -nan) (f32.const -0x0p+0)) (f32.const -nan))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -nan) (f32.const 0x0p+0)) (f32.const nan))
|
||||||
|
(assert_return (invoke "copysign" (f32.const nan) (f32.const -0x0p+0)) (f32.const -nan))
|
||||||
|
(assert_return (invoke "copysign" (f32.const nan) (f32.const 0x0p+0)) (f32.const nan))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -nan) (f32.const -0x1p-149)) (f32.const -nan))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -nan) (f32.const 0x1p-149)) (f32.const nan))
|
||||||
|
(assert_return (invoke "copysign" (f32.const nan) (f32.const -0x1p-149)) (f32.const -nan))
|
||||||
|
(assert_return (invoke "copysign" (f32.const nan) (f32.const 0x1p-149)) (f32.const nan))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -nan) (f32.const -0x1p-126)) (f32.const -nan))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -nan) (f32.const 0x1p-126)) (f32.const nan))
|
||||||
|
(assert_return (invoke "copysign" (f32.const nan) (f32.const -0x1p-126)) (f32.const -nan))
|
||||||
|
(assert_return (invoke "copysign" (f32.const nan) (f32.const 0x1p-126)) (f32.const nan))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -nan) (f32.const -0x1p-1)) (f32.const -nan))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -nan) (f32.const 0x1p-1)) (f32.const nan))
|
||||||
|
(assert_return (invoke "copysign" (f32.const nan) (f32.const -0x1p-1)) (f32.const -nan))
|
||||||
|
(assert_return (invoke "copysign" (f32.const nan) (f32.const 0x1p-1)) (f32.const nan))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -nan) (f32.const -0x1p+0)) (f32.const -nan))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -nan) (f32.const 0x1p+0)) (f32.const nan))
|
||||||
|
(assert_return (invoke "copysign" (f32.const nan) (f32.const -0x1p+0)) (f32.const -nan))
|
||||||
|
(assert_return (invoke "copysign" (f32.const nan) (f32.const 0x1p+0)) (f32.const nan))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -nan) (f32.const -0x1.921fb6p+2)) (f32.const -nan))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -nan) (f32.const 0x1.921fb6p+2)) (f32.const nan))
|
||||||
|
(assert_return (invoke "copysign" (f32.const nan) (f32.const -0x1.921fb6p+2)) (f32.const -nan))
|
||||||
|
(assert_return (invoke "copysign" (f32.const nan) (f32.const 0x1.921fb6p+2)) (f32.const nan))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -nan) (f32.const -0x1.fffffep+127)) (f32.const -nan))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -nan) (f32.const 0x1.fffffep+127)) (f32.const nan))
|
||||||
|
(assert_return (invoke "copysign" (f32.const nan) (f32.const -0x1.fffffep+127)) (f32.const -nan))
|
||||||
|
(assert_return (invoke "copysign" (f32.const nan) (f32.const 0x1.fffffep+127)) (f32.const nan))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -nan) (f32.const -inf)) (f32.const -nan))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -nan) (f32.const inf)) (f32.const nan))
|
||||||
|
(assert_return (invoke "copysign" (f32.const nan) (f32.const -inf)) (f32.const -nan))
|
||||||
|
(assert_return (invoke "copysign" (f32.const nan) (f32.const inf)) (f32.const nan))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -nan) (f32.const -nan)) (f32.const -nan))
|
||||||
|
(assert_return (invoke "copysign" (f32.const -nan) (f32.const nan)) (f32.const nan))
|
||||||
|
(assert_return (invoke "copysign" (f32.const nan) (f32.const -nan)) (f32.const -nan))
|
||||||
|
(assert_return (invoke "copysign" (f32.const nan) (f32.const nan)) (f32.const nan))
|
||||||
|
(assert_return (invoke "abs" (f32.const -0x0p+0)) (f32.const 0x0p+0))
|
||||||
|
(assert_return (invoke "abs" (f32.const 0x0p+0)) (f32.const 0x0p+0))
|
||||||
|
(assert_return (invoke "abs" (f32.const -0x1p-149)) (f32.const 0x1p-149))
|
||||||
|
(assert_return (invoke "abs" (f32.const 0x1p-149)) (f32.const 0x1p-149))
|
||||||
|
(assert_return (invoke "abs" (f32.const -0x1p-126)) (f32.const 0x1p-126))
|
||||||
|
(assert_return (invoke "abs" (f32.const 0x1p-126)) (f32.const 0x1p-126))
|
||||||
|
(assert_return (invoke "abs" (f32.const -0x1p-1)) (f32.const 0x1p-1))
|
||||||
|
(assert_return (invoke "abs" (f32.const 0x1p-1)) (f32.const 0x1p-1))
|
||||||
|
(assert_return (invoke "abs" (f32.const -0x1p+0)) (f32.const 0x1p+0))
|
||||||
|
(assert_return (invoke "abs" (f32.const 0x1p+0)) (f32.const 0x1p+0))
|
||||||
|
(assert_return (invoke "abs" (f32.const -0x1.921fb6p+2)) (f32.const 0x1.921fb6p+2))
|
||||||
|
(assert_return (invoke "abs" (f32.const 0x1.921fb6p+2)) (f32.const 0x1.921fb6p+2))
|
||||||
|
(assert_return (invoke "abs" (f32.const -0x1.fffffep+127)) (f32.const 0x1.fffffep+127))
|
||||||
|
(assert_return (invoke "abs" (f32.const 0x1.fffffep+127)) (f32.const 0x1.fffffep+127))
|
||||||
|
(assert_return (invoke "abs" (f32.const -inf)) (f32.const inf))
|
||||||
|
(assert_return (invoke "abs" (f32.const inf)) (f32.const inf))
|
||||||
|
(assert_return (invoke "abs" (f32.const -nan)) (f32.const nan))
|
||||||
|
(assert_return (invoke "abs" (f32.const nan)) (f32.const nan))
|
||||||
|
(assert_return (invoke "neg" (f32.const -0x0p+0)) (f32.const 0x0p+0))
|
||||||
|
(assert_return (invoke "neg" (f32.const 0x0p+0)) (f32.const -0x0p+0))
|
||||||
|
(assert_return (invoke "neg" (f32.const -0x1p-149)) (f32.const 0x1p-149))
|
||||||
|
(assert_return (invoke "neg" (f32.const 0x1p-149)) (f32.const -0x1p-149))
|
||||||
|
(assert_return (invoke "neg" (f32.const -0x1p-126)) (f32.const 0x1p-126))
|
||||||
|
(assert_return (invoke "neg" (f32.const 0x1p-126)) (f32.const -0x1p-126))
|
||||||
|
(assert_return (invoke "neg" (f32.const -0x1p-1)) (f32.const 0x1p-1))
|
||||||
|
(assert_return (invoke "neg" (f32.const 0x1p-1)) (f32.const -0x1p-1))
|
||||||
|
(assert_return (invoke "neg" (f32.const -0x1p+0)) (f32.const 0x1p+0))
|
||||||
|
(assert_return (invoke "neg" (f32.const 0x1p+0)) (f32.const -0x1p+0))
|
||||||
|
(assert_return (invoke "neg" (f32.const -0x1.921fb6p+2)) (f32.const 0x1.921fb6p+2))
|
||||||
|
(assert_return (invoke "neg" (f32.const 0x1.921fb6p+2)) (f32.const -0x1.921fb6p+2))
|
||||||
|
(assert_return (invoke "neg" (f32.const -0x1.fffffep+127)) (f32.const 0x1.fffffep+127))
|
||||||
|
(assert_return (invoke "neg" (f32.const 0x1.fffffep+127)) (f32.const -0x1.fffffep+127))
|
||||||
|
(assert_return (invoke "neg" (f32.const -inf)) (f32.const inf))
|
||||||
|
(assert_return (invoke "neg" (f32.const inf)) (f32.const -inf))
|
||||||
|
(assert_return (invoke "neg" (f32.const -nan)) (f32.const nan))
|
||||||
|
(assert_return (invoke "neg" (f32.const nan)) (f32.const -nan))
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,369 @@
|
|||||||
|
;; Test all the f64 bitwise operators on major boundary values and all special
|
||||||
|
;; values.
|
||||||
|
|
||||||
|
(module
|
||||||
|
(func (export "abs") (param $x f64) (result f64) (f64.abs (get_local $x)))
|
||||||
|
(func (export "neg") (param $x f64) (result f64) (f64.neg (get_local $x)))
|
||||||
|
(func (export "copysign") (param $x f64) (param $y f64) (result f64) (f64.copysign (get_local $x) (get_local $y)))
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x0p+0) (f64.const -0x0p+0)) (f64.const -0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x0p+0) (f64.const 0x0p+0)) (f64.const 0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x0p+0) (f64.const -0x0p+0)) (f64.const -0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x0p+0) (f64.const 0x0p+0)) (f64.const 0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x0p+0) (f64.const -0x0.0000000000001p-1022)) (f64.const -0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x0p+0) (f64.const 0x0.0000000000001p-1022)) (f64.const 0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x0p+0) (f64.const -0x0.0000000000001p-1022)) (f64.const -0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x0p+0) (f64.const 0x0.0000000000001p-1022)) (f64.const 0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x0p+0) (f64.const -0x1p-1022)) (f64.const -0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x0p+0) (f64.const 0x1p-1022)) (f64.const 0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x0p+0) (f64.const -0x1p-1022)) (f64.const -0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x0p+0) (f64.const 0x1p-1022)) (f64.const 0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x0p+0) (f64.const -0x1p-1)) (f64.const -0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x0p+0) (f64.const 0x1p-1)) (f64.const 0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x0p+0) (f64.const -0x1p-1)) (f64.const -0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x0p+0) (f64.const 0x1p-1)) (f64.const 0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x0p+0) (f64.const -0x1p+0)) (f64.const -0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x0p+0) (f64.const 0x1p+0)) (f64.const 0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x0p+0) (f64.const -0x1p+0)) (f64.const -0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x0p+0) (f64.const 0x1p+0)) (f64.const 0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x0p+0) (f64.const -0x1.921fb54442d18p+2)) (f64.const -0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x0p+0) (f64.const 0x1.921fb54442d18p+2)) (f64.const 0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x0p+0) (f64.const -0x1.921fb54442d18p+2)) (f64.const -0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x0p+0) (f64.const 0x1.921fb54442d18p+2)) (f64.const 0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x0p+0) (f64.const -0x1.fffffffffffffp+1023)) (f64.const -0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x0p+0) (f64.const 0x1.fffffffffffffp+1023)) (f64.const 0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x0p+0) (f64.const -0x1.fffffffffffffp+1023)) (f64.const -0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x0p+0) (f64.const 0x1.fffffffffffffp+1023)) (f64.const 0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x0p+0) (f64.const -inf)) (f64.const -0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x0p+0) (f64.const inf)) (f64.const 0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x0p+0) (f64.const -inf)) (f64.const -0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x0p+0) (f64.const inf)) (f64.const 0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x0p+0) (f64.const -nan)) (f64.const -0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x0p+0) (f64.const nan)) (f64.const 0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x0p+0) (f64.const -nan)) (f64.const -0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x0p+0) (f64.const nan)) (f64.const 0x0p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x0.0000000000001p-1022) (f64.const -0x0p+0)) (f64.const -0x0.0000000000001p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x0.0000000000001p-1022) (f64.const 0x0p+0)) (f64.const 0x0.0000000000001p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x0.0000000000001p-1022) (f64.const -0x0p+0)) (f64.const -0x0.0000000000001p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x0.0000000000001p-1022) (f64.const 0x0p+0)) (f64.const 0x0.0000000000001p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x0.0000000000001p-1022) (f64.const -0x0.0000000000001p-1022)) (f64.const -0x0.0000000000001p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x0.0000000000001p-1022) (f64.const 0x0.0000000000001p-1022)) (f64.const 0x0.0000000000001p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x0.0000000000001p-1022) (f64.const -0x0.0000000000001p-1022)) (f64.const -0x0.0000000000001p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x0.0000000000001p-1022) (f64.const 0x0.0000000000001p-1022)) (f64.const 0x0.0000000000001p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x0.0000000000001p-1022) (f64.const -0x1p-1022)) (f64.const -0x0.0000000000001p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x0.0000000000001p-1022) (f64.const 0x1p-1022)) (f64.const 0x0.0000000000001p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x0.0000000000001p-1022) (f64.const -0x1p-1022)) (f64.const -0x0.0000000000001p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x0.0000000000001p-1022) (f64.const 0x1p-1022)) (f64.const 0x0.0000000000001p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x0.0000000000001p-1022) (f64.const -0x1p-1)) (f64.const -0x0.0000000000001p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x0.0000000000001p-1022) (f64.const 0x1p-1)) (f64.const 0x0.0000000000001p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x0.0000000000001p-1022) (f64.const -0x1p-1)) (f64.const -0x0.0000000000001p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x0.0000000000001p-1022) (f64.const 0x1p-1)) (f64.const 0x0.0000000000001p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x0.0000000000001p-1022) (f64.const -0x1p+0)) (f64.const -0x0.0000000000001p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x0.0000000000001p-1022) (f64.const 0x1p+0)) (f64.const 0x0.0000000000001p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x0.0000000000001p-1022) (f64.const -0x1p+0)) (f64.const -0x0.0000000000001p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x0.0000000000001p-1022) (f64.const 0x1p+0)) (f64.const 0x0.0000000000001p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x0.0000000000001p-1022) (f64.const -0x1.921fb54442d18p+2)) (f64.const -0x0.0000000000001p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x0.0000000000001p-1022) (f64.const 0x1.921fb54442d18p+2)) (f64.const 0x0.0000000000001p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x0.0000000000001p-1022) (f64.const -0x1.921fb54442d18p+2)) (f64.const -0x0.0000000000001p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x0.0000000000001p-1022) (f64.const 0x1.921fb54442d18p+2)) (f64.const 0x0.0000000000001p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x0.0000000000001p-1022) (f64.const -0x1.fffffffffffffp+1023)) (f64.const -0x0.0000000000001p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x0.0000000000001p-1022) (f64.const 0x1.fffffffffffffp+1023)) (f64.const 0x0.0000000000001p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x0.0000000000001p-1022) (f64.const -0x1.fffffffffffffp+1023)) (f64.const -0x0.0000000000001p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x0.0000000000001p-1022) (f64.const 0x1.fffffffffffffp+1023)) (f64.const 0x0.0000000000001p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x0.0000000000001p-1022) (f64.const -inf)) (f64.const -0x0.0000000000001p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x0.0000000000001p-1022) (f64.const inf)) (f64.const 0x0.0000000000001p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x0.0000000000001p-1022) (f64.const -inf)) (f64.const -0x0.0000000000001p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x0.0000000000001p-1022) (f64.const inf)) (f64.const 0x0.0000000000001p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x0.0000000000001p-1022) (f64.const -nan)) (f64.const -0x0.0000000000001p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x0.0000000000001p-1022) (f64.const nan)) (f64.const 0x0.0000000000001p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x0.0000000000001p-1022) (f64.const -nan)) (f64.const -0x0.0000000000001p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x0.0000000000001p-1022) (f64.const nan)) (f64.const 0x0.0000000000001p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1p-1022) (f64.const -0x0p+0)) (f64.const -0x1p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1p-1022) (f64.const 0x0p+0)) (f64.const 0x1p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1p-1022) (f64.const -0x0p+0)) (f64.const -0x1p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1p-1022) (f64.const 0x0p+0)) (f64.const 0x1p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1p-1022) (f64.const -0x0.0000000000001p-1022)) (f64.const -0x1p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1p-1022) (f64.const 0x0.0000000000001p-1022)) (f64.const 0x1p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1p-1022) (f64.const -0x0.0000000000001p-1022)) (f64.const -0x1p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1p-1022) (f64.const 0x0.0000000000001p-1022)) (f64.const 0x1p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1p-1022) (f64.const -0x1p-1022)) (f64.const -0x1p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1p-1022) (f64.const 0x1p-1022)) (f64.const 0x1p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1p-1022) (f64.const -0x1p-1022)) (f64.const -0x1p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1p-1022) (f64.const 0x1p-1022)) (f64.const 0x1p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1p-1022) (f64.const -0x1p-1)) (f64.const -0x1p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1p-1022) (f64.const 0x1p-1)) (f64.const 0x1p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1p-1022) (f64.const -0x1p-1)) (f64.const -0x1p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1p-1022) (f64.const 0x1p-1)) (f64.const 0x1p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1p-1022) (f64.const -0x1p+0)) (f64.const -0x1p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1p-1022) (f64.const 0x1p+0)) (f64.const 0x1p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1p-1022) (f64.const -0x1p+0)) (f64.const -0x1p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1p-1022) (f64.const 0x1p+0)) (f64.const 0x1p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1p-1022) (f64.const -0x1.921fb54442d18p+2)) (f64.const -0x1p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1p-1022) (f64.const 0x1.921fb54442d18p+2)) (f64.const 0x1p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1p-1022) (f64.const -0x1.921fb54442d18p+2)) (f64.const -0x1p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1p-1022) (f64.const 0x1.921fb54442d18p+2)) (f64.const 0x1p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1p-1022) (f64.const -0x1.fffffffffffffp+1023)) (f64.const -0x1p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1p-1022) (f64.const 0x1.fffffffffffffp+1023)) (f64.const 0x1p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1p-1022) (f64.const -0x1.fffffffffffffp+1023)) (f64.const -0x1p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1p-1022) (f64.const 0x1.fffffffffffffp+1023)) (f64.const 0x1p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1p-1022) (f64.const -inf)) (f64.const -0x1p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1p-1022) (f64.const inf)) (f64.const 0x1p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1p-1022) (f64.const -inf)) (f64.const -0x1p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1p-1022) (f64.const inf)) (f64.const 0x1p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1p-1022) (f64.const -nan)) (f64.const -0x1p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1p-1022) (f64.const nan)) (f64.const 0x1p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1p-1022) (f64.const -nan)) (f64.const -0x1p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1p-1022) (f64.const nan)) (f64.const 0x1p-1022))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1p-1) (f64.const -0x0p+0)) (f64.const -0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1p-1) (f64.const 0x0p+0)) (f64.const 0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1p-1) (f64.const -0x0p+0)) (f64.const -0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1p-1) (f64.const 0x0p+0)) (f64.const 0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1p-1) (f64.const -0x0.0000000000001p-1022)) (f64.const -0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1p-1) (f64.const 0x0.0000000000001p-1022)) (f64.const 0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1p-1) (f64.const -0x0.0000000000001p-1022)) (f64.const -0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1p-1) (f64.const 0x0.0000000000001p-1022)) (f64.const 0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1p-1) (f64.const -0x1p-1022)) (f64.const -0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1p-1) (f64.const 0x1p-1022)) (f64.const 0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1p-1) (f64.const -0x1p-1022)) (f64.const -0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1p-1) (f64.const 0x1p-1022)) (f64.const 0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1p-1) (f64.const -0x1p-1)) (f64.const -0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1p-1) (f64.const 0x1p-1)) (f64.const 0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1p-1) (f64.const -0x1p-1)) (f64.const -0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1p-1) (f64.const 0x1p-1)) (f64.const 0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1p-1) (f64.const -0x1p+0)) (f64.const -0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1p-1) (f64.const 0x1p+0)) (f64.const 0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1p-1) (f64.const -0x1p+0)) (f64.const -0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1p-1) (f64.const 0x1p+0)) (f64.const 0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1p-1) (f64.const -0x1.921fb54442d18p+2)) (f64.const -0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1p-1) (f64.const 0x1.921fb54442d18p+2)) (f64.const 0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1p-1) (f64.const -0x1.921fb54442d18p+2)) (f64.const -0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1p-1) (f64.const 0x1.921fb54442d18p+2)) (f64.const 0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1p-1) (f64.const -0x1.fffffffffffffp+1023)) (f64.const -0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1p-1) (f64.const 0x1.fffffffffffffp+1023)) (f64.const 0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1p-1) (f64.const -0x1.fffffffffffffp+1023)) (f64.const -0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1p-1) (f64.const 0x1.fffffffffffffp+1023)) (f64.const 0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1p-1) (f64.const -inf)) (f64.const -0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1p-1) (f64.const inf)) (f64.const 0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1p-1) (f64.const -inf)) (f64.const -0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1p-1) (f64.const inf)) (f64.const 0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1p-1) (f64.const -nan)) (f64.const -0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1p-1) (f64.const nan)) (f64.const 0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1p-1) (f64.const -nan)) (f64.const -0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1p-1) (f64.const nan)) (f64.const 0x1p-1))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1p+0) (f64.const -0x0p+0)) (f64.const -0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1p+0) (f64.const 0x0p+0)) (f64.const 0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1p+0) (f64.const -0x0p+0)) (f64.const -0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1p+0) (f64.const 0x0p+0)) (f64.const 0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1p+0) (f64.const -0x0.0000000000001p-1022)) (f64.const -0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1p+0) (f64.const 0x0.0000000000001p-1022)) (f64.const 0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1p+0) (f64.const -0x0.0000000000001p-1022)) (f64.const -0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1p+0) (f64.const 0x0.0000000000001p-1022)) (f64.const 0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1p+0) (f64.const -0x1p-1022)) (f64.const -0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1p+0) (f64.const 0x1p-1022)) (f64.const 0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1p+0) (f64.const -0x1p-1022)) (f64.const -0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1p+0) (f64.const 0x1p-1022)) (f64.const 0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1p+0) (f64.const -0x1p-1)) (f64.const -0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1p+0) (f64.const 0x1p-1)) (f64.const 0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1p+0) (f64.const -0x1p-1)) (f64.const -0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1p+0) (f64.const 0x1p-1)) (f64.const 0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1p+0) (f64.const -0x1p+0)) (f64.const -0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1p+0) (f64.const 0x1p+0)) (f64.const 0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1p+0) (f64.const -0x1p+0)) (f64.const -0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1p+0) (f64.const 0x1p+0)) (f64.const 0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1p+0) (f64.const -0x1.921fb54442d18p+2)) (f64.const -0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1p+0) (f64.const 0x1.921fb54442d18p+2)) (f64.const 0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1p+0) (f64.const -0x1.921fb54442d18p+2)) (f64.const -0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1p+0) (f64.const 0x1.921fb54442d18p+2)) (f64.const 0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1p+0) (f64.const -0x1.fffffffffffffp+1023)) (f64.const -0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1p+0) (f64.const 0x1.fffffffffffffp+1023)) (f64.const 0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1p+0) (f64.const -0x1.fffffffffffffp+1023)) (f64.const -0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1p+0) (f64.const 0x1.fffffffffffffp+1023)) (f64.const 0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1p+0) (f64.const -inf)) (f64.const -0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1p+0) (f64.const inf)) (f64.const 0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1p+0) (f64.const -inf)) (f64.const -0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1p+0) (f64.const inf)) (f64.const 0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1p+0) (f64.const -nan)) (f64.const -0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1p+0) (f64.const nan)) (f64.const 0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1p+0) (f64.const -nan)) (f64.const -0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1p+0) (f64.const nan)) (f64.const 0x1p+0))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1.921fb54442d18p+2) (f64.const -0x0p+0)) (f64.const -0x1.921fb54442d18p+2))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1.921fb54442d18p+2) (f64.const 0x0p+0)) (f64.const 0x1.921fb54442d18p+2))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1.921fb54442d18p+2) (f64.const -0x0p+0)) (f64.const -0x1.921fb54442d18p+2))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1.921fb54442d18p+2) (f64.const 0x0p+0)) (f64.const 0x1.921fb54442d18p+2))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1.921fb54442d18p+2) (f64.const -0x0.0000000000001p-1022)) (f64.const -0x1.921fb54442d18p+2))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1.921fb54442d18p+2) (f64.const 0x0.0000000000001p-1022)) (f64.const 0x1.921fb54442d18p+2))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1.921fb54442d18p+2) (f64.const -0x0.0000000000001p-1022)) (f64.const -0x1.921fb54442d18p+2))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1.921fb54442d18p+2) (f64.const 0x0.0000000000001p-1022)) (f64.const 0x1.921fb54442d18p+2))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1.921fb54442d18p+2) (f64.const -0x1p-1022)) (f64.const -0x1.921fb54442d18p+2))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1.921fb54442d18p+2) (f64.const 0x1p-1022)) (f64.const 0x1.921fb54442d18p+2))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1.921fb54442d18p+2) (f64.const -0x1p-1022)) (f64.const -0x1.921fb54442d18p+2))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1.921fb54442d18p+2) (f64.const 0x1p-1022)) (f64.const 0x1.921fb54442d18p+2))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1.921fb54442d18p+2) (f64.const -0x1p-1)) (f64.const -0x1.921fb54442d18p+2))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1.921fb54442d18p+2) (f64.const 0x1p-1)) (f64.const 0x1.921fb54442d18p+2))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1.921fb54442d18p+2) (f64.const -0x1p-1)) (f64.const -0x1.921fb54442d18p+2))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1.921fb54442d18p+2) (f64.const 0x1p-1)) (f64.const 0x1.921fb54442d18p+2))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1.921fb54442d18p+2) (f64.const -0x1p+0)) (f64.const -0x1.921fb54442d18p+2))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1.921fb54442d18p+2) (f64.const 0x1p+0)) (f64.const 0x1.921fb54442d18p+2))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1.921fb54442d18p+2) (f64.const -0x1p+0)) (f64.const -0x1.921fb54442d18p+2))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1.921fb54442d18p+2) (f64.const 0x1p+0)) (f64.const 0x1.921fb54442d18p+2))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1.921fb54442d18p+2) (f64.const -0x1.921fb54442d18p+2)) (f64.const -0x1.921fb54442d18p+2))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1.921fb54442d18p+2) (f64.const 0x1.921fb54442d18p+2)) (f64.const 0x1.921fb54442d18p+2))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1.921fb54442d18p+2) (f64.const -0x1.921fb54442d18p+2)) (f64.const -0x1.921fb54442d18p+2))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1.921fb54442d18p+2) (f64.const 0x1.921fb54442d18p+2)) (f64.const 0x1.921fb54442d18p+2))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1.921fb54442d18p+2) (f64.const -0x1.fffffffffffffp+1023)) (f64.const -0x1.921fb54442d18p+2))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1.921fb54442d18p+2) (f64.const 0x1.fffffffffffffp+1023)) (f64.const 0x1.921fb54442d18p+2))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1.921fb54442d18p+2) (f64.const -0x1.fffffffffffffp+1023)) (f64.const -0x1.921fb54442d18p+2))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1.921fb54442d18p+2) (f64.const 0x1.fffffffffffffp+1023)) (f64.const 0x1.921fb54442d18p+2))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1.921fb54442d18p+2) (f64.const -inf)) (f64.const -0x1.921fb54442d18p+2))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1.921fb54442d18p+2) (f64.const inf)) (f64.const 0x1.921fb54442d18p+2))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1.921fb54442d18p+2) (f64.const -inf)) (f64.const -0x1.921fb54442d18p+2))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1.921fb54442d18p+2) (f64.const inf)) (f64.const 0x1.921fb54442d18p+2))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1.921fb54442d18p+2) (f64.const -nan)) (f64.const -0x1.921fb54442d18p+2))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1.921fb54442d18p+2) (f64.const nan)) (f64.const 0x1.921fb54442d18p+2))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1.921fb54442d18p+2) (f64.const -nan)) (f64.const -0x1.921fb54442d18p+2))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1.921fb54442d18p+2) (f64.const nan)) (f64.const 0x1.921fb54442d18p+2))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1.fffffffffffffp+1023) (f64.const -0x0p+0)) (f64.const -0x1.fffffffffffffp+1023))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1.fffffffffffffp+1023) (f64.const 0x0p+0)) (f64.const 0x1.fffffffffffffp+1023))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1.fffffffffffffp+1023) (f64.const -0x0p+0)) (f64.const -0x1.fffffffffffffp+1023))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1.fffffffffffffp+1023) (f64.const 0x0p+0)) (f64.const 0x1.fffffffffffffp+1023))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1.fffffffffffffp+1023) (f64.const -0x0.0000000000001p-1022)) (f64.const -0x1.fffffffffffffp+1023))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1.fffffffffffffp+1023) (f64.const 0x0.0000000000001p-1022)) (f64.const 0x1.fffffffffffffp+1023))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1.fffffffffffffp+1023) (f64.const -0x0.0000000000001p-1022)) (f64.const -0x1.fffffffffffffp+1023))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1.fffffffffffffp+1023) (f64.const 0x0.0000000000001p-1022)) (f64.const 0x1.fffffffffffffp+1023))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1.fffffffffffffp+1023) (f64.const -0x1p-1022)) (f64.const -0x1.fffffffffffffp+1023))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1.fffffffffffffp+1023) (f64.const 0x1p-1022)) (f64.const 0x1.fffffffffffffp+1023))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1.fffffffffffffp+1023) (f64.const -0x1p-1022)) (f64.const -0x1.fffffffffffffp+1023))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1.fffffffffffffp+1023) (f64.const 0x1p-1022)) (f64.const 0x1.fffffffffffffp+1023))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1.fffffffffffffp+1023) (f64.const -0x1p-1)) (f64.const -0x1.fffffffffffffp+1023))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1.fffffffffffffp+1023) (f64.const 0x1p-1)) (f64.const 0x1.fffffffffffffp+1023))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1.fffffffffffffp+1023) (f64.const -0x1p-1)) (f64.const -0x1.fffffffffffffp+1023))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1.fffffffffffffp+1023) (f64.const 0x1p-1)) (f64.const 0x1.fffffffffffffp+1023))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1.fffffffffffffp+1023) (f64.const -0x1p+0)) (f64.const -0x1.fffffffffffffp+1023))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1.fffffffffffffp+1023) (f64.const 0x1p+0)) (f64.const 0x1.fffffffffffffp+1023))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1.fffffffffffffp+1023) (f64.const -0x1p+0)) (f64.const -0x1.fffffffffffffp+1023))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1.fffffffffffffp+1023) (f64.const 0x1p+0)) (f64.const 0x1.fffffffffffffp+1023))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1.fffffffffffffp+1023) (f64.const -0x1.921fb54442d18p+2)) (f64.const -0x1.fffffffffffffp+1023))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1.fffffffffffffp+1023) (f64.const 0x1.921fb54442d18p+2)) (f64.const 0x1.fffffffffffffp+1023))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1.fffffffffffffp+1023) (f64.const -0x1.921fb54442d18p+2)) (f64.const -0x1.fffffffffffffp+1023))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1.fffffffffffffp+1023) (f64.const 0x1.921fb54442d18p+2)) (f64.const 0x1.fffffffffffffp+1023))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1.fffffffffffffp+1023) (f64.const -0x1.fffffffffffffp+1023)) (f64.const -0x1.fffffffffffffp+1023))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1.fffffffffffffp+1023) (f64.const 0x1.fffffffffffffp+1023)) (f64.const 0x1.fffffffffffffp+1023))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1.fffffffffffffp+1023) (f64.const -0x1.fffffffffffffp+1023)) (f64.const -0x1.fffffffffffffp+1023))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1.fffffffffffffp+1023) (f64.const 0x1.fffffffffffffp+1023)) (f64.const 0x1.fffffffffffffp+1023))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1.fffffffffffffp+1023) (f64.const -inf)) (f64.const -0x1.fffffffffffffp+1023))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1.fffffffffffffp+1023) (f64.const inf)) (f64.const 0x1.fffffffffffffp+1023))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1.fffffffffffffp+1023) (f64.const -inf)) (f64.const -0x1.fffffffffffffp+1023))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1.fffffffffffffp+1023) (f64.const inf)) (f64.const 0x1.fffffffffffffp+1023))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1.fffffffffffffp+1023) (f64.const -nan)) (f64.const -0x1.fffffffffffffp+1023))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -0x1.fffffffffffffp+1023) (f64.const nan)) (f64.const 0x1.fffffffffffffp+1023))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1.fffffffffffffp+1023) (f64.const -nan)) (f64.const -0x1.fffffffffffffp+1023))
|
||||||
|
(assert_return (invoke "copysign" (f64.const 0x1.fffffffffffffp+1023) (f64.const nan)) (f64.const 0x1.fffffffffffffp+1023))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -inf) (f64.const -0x0p+0)) (f64.const -inf))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -inf) (f64.const 0x0p+0)) (f64.const inf))
|
||||||
|
(assert_return (invoke "copysign" (f64.const inf) (f64.const -0x0p+0)) (f64.const -inf))
|
||||||
|
(assert_return (invoke "copysign" (f64.const inf) (f64.const 0x0p+0)) (f64.const inf))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -inf) (f64.const -0x0.0000000000001p-1022)) (f64.const -inf))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -inf) (f64.const 0x0.0000000000001p-1022)) (f64.const inf))
|
||||||
|
(assert_return (invoke "copysign" (f64.const inf) (f64.const -0x0.0000000000001p-1022)) (f64.const -inf))
|
||||||
|
(assert_return (invoke "copysign" (f64.const inf) (f64.const 0x0.0000000000001p-1022)) (f64.const inf))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -inf) (f64.const -0x1p-1022)) (f64.const -inf))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -inf) (f64.const 0x1p-1022)) (f64.const inf))
|
||||||
|
(assert_return (invoke "copysign" (f64.const inf) (f64.const -0x1p-1022)) (f64.const -inf))
|
||||||
|
(assert_return (invoke "copysign" (f64.const inf) (f64.const 0x1p-1022)) (f64.const inf))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -inf) (f64.const -0x1p-1)) (f64.const -inf))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -inf) (f64.const 0x1p-1)) (f64.const inf))
|
||||||
|
(assert_return (invoke "copysign" (f64.const inf) (f64.const -0x1p-1)) (f64.const -inf))
|
||||||
|
(assert_return (invoke "copysign" (f64.const inf) (f64.const 0x1p-1)) (f64.const inf))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -inf) (f64.const -0x1p+0)) (f64.const -inf))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -inf) (f64.const 0x1p+0)) (f64.const inf))
|
||||||
|
(assert_return (invoke "copysign" (f64.const inf) (f64.const -0x1p+0)) (f64.const -inf))
|
||||||
|
(assert_return (invoke "copysign" (f64.const inf) (f64.const 0x1p+0)) (f64.const inf))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -inf) (f64.const -0x1.921fb54442d18p+2)) (f64.const -inf))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -inf) (f64.const 0x1.921fb54442d18p+2)) (f64.const inf))
|
||||||
|
(assert_return (invoke "copysign" (f64.const inf) (f64.const -0x1.921fb54442d18p+2)) (f64.const -inf))
|
||||||
|
(assert_return (invoke "copysign" (f64.const inf) (f64.const 0x1.921fb54442d18p+2)) (f64.const inf))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -inf) (f64.const -0x1.fffffffffffffp+1023)) (f64.const -inf))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -inf) (f64.const 0x1.fffffffffffffp+1023)) (f64.const inf))
|
||||||
|
(assert_return (invoke "copysign" (f64.const inf) (f64.const -0x1.fffffffffffffp+1023)) (f64.const -inf))
|
||||||
|
(assert_return (invoke "copysign" (f64.const inf) (f64.const 0x1.fffffffffffffp+1023)) (f64.const inf))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -inf) (f64.const -inf)) (f64.const -inf))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -inf) (f64.const inf)) (f64.const inf))
|
||||||
|
(assert_return (invoke "copysign" (f64.const inf) (f64.const -inf)) (f64.const -inf))
|
||||||
|
(assert_return (invoke "copysign" (f64.const inf) (f64.const inf)) (f64.const inf))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -inf) (f64.const -nan)) (f64.const -inf))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -inf) (f64.const nan)) (f64.const inf))
|
||||||
|
(assert_return (invoke "copysign" (f64.const inf) (f64.const -nan)) (f64.const -inf))
|
||||||
|
(assert_return (invoke "copysign" (f64.const inf) (f64.const nan)) (f64.const inf))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -nan) (f64.const -0x0p+0)) (f64.const -nan))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -nan) (f64.const 0x0p+0)) (f64.const nan))
|
||||||
|
(assert_return (invoke "copysign" (f64.const nan) (f64.const -0x0p+0)) (f64.const -nan))
|
||||||
|
(assert_return (invoke "copysign" (f64.const nan) (f64.const 0x0p+0)) (f64.const nan))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -nan) (f64.const -0x0.0000000000001p-1022)) (f64.const -nan))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -nan) (f64.const 0x0.0000000000001p-1022)) (f64.const nan))
|
||||||
|
(assert_return (invoke "copysign" (f64.const nan) (f64.const -0x0.0000000000001p-1022)) (f64.const -nan))
|
||||||
|
(assert_return (invoke "copysign" (f64.const nan) (f64.const 0x0.0000000000001p-1022)) (f64.const nan))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -nan) (f64.const -0x1p-1022)) (f64.const -nan))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -nan) (f64.const 0x1p-1022)) (f64.const nan))
|
||||||
|
(assert_return (invoke "copysign" (f64.const nan) (f64.const -0x1p-1022)) (f64.const -nan))
|
||||||
|
(assert_return (invoke "copysign" (f64.const nan) (f64.const 0x1p-1022)) (f64.const nan))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -nan) (f64.const -0x1p-1)) (f64.const -nan))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -nan) (f64.const 0x1p-1)) (f64.const nan))
|
||||||
|
(assert_return (invoke "copysign" (f64.const nan) (f64.const -0x1p-1)) (f64.const -nan))
|
||||||
|
(assert_return (invoke "copysign" (f64.const nan) (f64.const 0x1p-1)) (f64.const nan))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -nan) (f64.const -0x1p+0)) (f64.const -nan))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -nan) (f64.const 0x1p+0)) (f64.const nan))
|
||||||
|
(assert_return (invoke "copysign" (f64.const nan) (f64.const -0x1p+0)) (f64.const -nan))
|
||||||
|
(assert_return (invoke "copysign" (f64.const nan) (f64.const 0x1p+0)) (f64.const nan))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -nan) (f64.const -0x1.921fb54442d18p+2)) (f64.const -nan))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -nan) (f64.const 0x1.921fb54442d18p+2)) (f64.const nan))
|
||||||
|
(assert_return (invoke "copysign" (f64.const nan) (f64.const -0x1.921fb54442d18p+2)) (f64.const -nan))
|
||||||
|
(assert_return (invoke "copysign" (f64.const nan) (f64.const 0x1.921fb54442d18p+2)) (f64.const nan))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -nan) (f64.const -0x1.fffffffffffffp+1023)) (f64.const -nan))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -nan) (f64.const 0x1.fffffffffffffp+1023)) (f64.const nan))
|
||||||
|
(assert_return (invoke "copysign" (f64.const nan) (f64.const -0x1.fffffffffffffp+1023)) (f64.const -nan))
|
||||||
|
(assert_return (invoke "copysign" (f64.const nan) (f64.const 0x1.fffffffffffffp+1023)) (f64.const nan))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -nan) (f64.const -inf)) (f64.const -nan))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -nan) (f64.const inf)) (f64.const nan))
|
||||||
|
(assert_return (invoke "copysign" (f64.const nan) (f64.const -inf)) (f64.const -nan))
|
||||||
|
(assert_return (invoke "copysign" (f64.const nan) (f64.const inf)) (f64.const nan))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -nan) (f64.const -nan)) (f64.const -nan))
|
||||||
|
(assert_return (invoke "copysign" (f64.const -nan) (f64.const nan)) (f64.const nan))
|
||||||
|
(assert_return (invoke "copysign" (f64.const nan) (f64.const -nan)) (f64.const -nan))
|
||||||
|
(assert_return (invoke "copysign" (f64.const nan) (f64.const nan)) (f64.const nan))
|
||||||
|
(assert_return (invoke "abs" (f64.const -0x0p+0)) (f64.const 0x0p+0))
|
||||||
|
(assert_return (invoke "abs" (f64.const 0x0p+0)) (f64.const 0x0p+0))
|
||||||
|
(assert_return (invoke "abs" (f64.const -0x0.0000000000001p-1022)) (f64.const 0x0.0000000000001p-1022))
|
||||||
|
(assert_return (invoke "abs" (f64.const 0x0.0000000000001p-1022)) (f64.const 0x0.0000000000001p-1022))
|
||||||
|
(assert_return (invoke "abs" (f64.const -0x1p-1022)) (f64.const 0x1p-1022))
|
||||||
|
(assert_return (invoke "abs" (f64.const 0x1p-1022)) (f64.const 0x1p-1022))
|
||||||
|
(assert_return (invoke "abs" (f64.const -0x1p-1)) (f64.const 0x1p-1))
|
||||||
|
(assert_return (invoke "abs" (f64.const 0x1p-1)) (f64.const 0x1p-1))
|
||||||
|
(assert_return (invoke "abs" (f64.const -0x1p+0)) (f64.const 0x1p+0))
|
||||||
|
(assert_return (invoke "abs" (f64.const 0x1p+0)) (f64.const 0x1p+0))
|
||||||
|
(assert_return (invoke "abs" (f64.const -0x1.921fb54442d18p+2)) (f64.const 0x1.921fb54442d18p+2))
|
||||||
|
(assert_return (invoke "abs" (f64.const 0x1.921fb54442d18p+2)) (f64.const 0x1.921fb54442d18p+2))
|
||||||
|
(assert_return (invoke "abs" (f64.const -0x1.fffffffffffffp+1023)) (f64.const 0x1.fffffffffffffp+1023))
|
||||||
|
(assert_return (invoke "abs" (f64.const 0x1.fffffffffffffp+1023)) (f64.const 0x1.fffffffffffffp+1023))
|
||||||
|
(assert_return (invoke "abs" (f64.const -inf)) (f64.const inf))
|
||||||
|
(assert_return (invoke "abs" (f64.const inf)) (f64.const inf))
|
||||||
|
(assert_return (invoke "abs" (f64.const -nan)) (f64.const nan))
|
||||||
|
(assert_return (invoke "abs" (f64.const nan)) (f64.const nan))
|
||||||
|
(assert_return (invoke "neg" (f64.const -0x0p+0)) (f64.const 0x0p+0))
|
||||||
|
(assert_return (invoke "neg" (f64.const 0x0p+0)) (f64.const -0x0p+0))
|
||||||
|
(assert_return (invoke "neg" (f64.const -0x0.0000000000001p-1022)) (f64.const 0x0.0000000000001p-1022))
|
||||||
|
(assert_return (invoke "neg" (f64.const 0x0.0000000000001p-1022)) (f64.const -0x0.0000000000001p-1022))
|
||||||
|
(assert_return (invoke "neg" (f64.const -0x1p-1022)) (f64.const 0x1p-1022))
|
||||||
|
(assert_return (invoke "neg" (f64.const 0x1p-1022)) (f64.const -0x1p-1022))
|
||||||
|
(assert_return (invoke "neg" (f64.const -0x1p-1)) (f64.const 0x1p-1))
|
||||||
|
(assert_return (invoke "neg" (f64.const 0x1p-1)) (f64.const -0x1p-1))
|
||||||
|
(assert_return (invoke "neg" (f64.const -0x1p+0)) (f64.const 0x1p+0))
|
||||||
|
(assert_return (invoke "neg" (f64.const 0x1p+0)) (f64.const -0x1p+0))
|
||||||
|
(assert_return (invoke "neg" (f64.const -0x1.921fb54442d18p+2)) (f64.const 0x1.921fb54442d18p+2))
|
||||||
|
(assert_return (invoke "neg" (f64.const 0x1.921fb54442d18p+2)) (f64.const -0x1.921fb54442d18p+2))
|
||||||
|
(assert_return (invoke "neg" (f64.const -0x1.fffffffffffffp+1023)) (f64.const 0x1.fffffffffffffp+1023))
|
||||||
|
(assert_return (invoke "neg" (f64.const 0x1.fffffffffffffp+1023)) (f64.const -0x1.fffffffffffffp+1023))
|
||||||
|
(assert_return (invoke "neg" (f64.const -inf)) (f64.const inf))
|
||||||
|
(assert_return (invoke "neg" (f64.const inf)) (f64.const -inf))
|
||||||
|
(assert_return (invoke "neg" (f64.const -nan)) (f64.const nan))
|
||||||
|
(assert_return (invoke "neg" (f64.const nan)) (f64.const -nan))
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,89 @@
|
|||||||
|
(module
|
||||||
|
;; Recursive factorial
|
||||||
|
(func (export "fac-rec") (param i64) (result i64)
|
||||||
|
(if (result i64) (i64.eq (get_local 0) (i64.const 0))
|
||||||
|
(then (i64.const 1))
|
||||||
|
(else
|
||||||
|
(i64.mul (get_local 0) (call 0 (i64.sub (get_local 0) (i64.const 1))))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
;; Recursive factorial named
|
||||||
|
(func $fac-rec-named (export "fac-rec-named") (param $n i64) (result i64)
|
||||||
|
(if (result i64) (i64.eq (get_local $n) (i64.const 0))
|
||||||
|
(then (i64.const 1))
|
||||||
|
(else
|
||||||
|
(i64.mul
|
||||||
|
(get_local $n)
|
||||||
|
(call $fac-rec-named (i64.sub (get_local $n) (i64.const 1)))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
;; Iterative factorial
|
||||||
|
(func (export "fac-iter") (param i64) (result i64)
|
||||||
|
(local i64 i64)
|
||||||
|
(set_local 1 (get_local 0))
|
||||||
|
(set_local 2 (i64.const 1))
|
||||||
|
(block
|
||||||
|
(loop
|
||||||
|
(if
|
||||||
|
(i64.eq (get_local 1) (i64.const 0))
|
||||||
|
(then (br 2))
|
||||||
|
(else
|
||||||
|
(set_local 2 (i64.mul (get_local 1) (get_local 2)))
|
||||||
|
(set_local 1 (i64.sub (get_local 1) (i64.const 1)))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(br 0)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(get_local 2)
|
||||||
|
)
|
||||||
|
|
||||||
|
;; Iterative factorial named
|
||||||
|
(func (export "fac-iter-named") (param $n i64) (result i64)
|
||||||
|
(local $i i64)
|
||||||
|
(local $res i64)
|
||||||
|
(set_local $i (get_local $n))
|
||||||
|
(set_local $res (i64.const 1))
|
||||||
|
(block $done
|
||||||
|
(loop $loop
|
||||||
|
(if
|
||||||
|
(i64.eq (get_local $i) (i64.const 0))
|
||||||
|
(then (br $done))
|
||||||
|
(else
|
||||||
|
(set_local $res (i64.mul (get_local $i) (get_local $res)))
|
||||||
|
(set_local $i (i64.sub (get_local $i) (i64.const 1)))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(br $loop)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(get_local $res)
|
||||||
|
)
|
||||||
|
|
||||||
|
;; Optimized factorial.
|
||||||
|
(func (export "fac-opt") (param i64) (result i64)
|
||||||
|
(local i64)
|
||||||
|
(set_local 1 (i64.const 1))
|
||||||
|
(block
|
||||||
|
(br_if 0 (i64.lt_s (get_local 0) (i64.const 2)))
|
||||||
|
(loop
|
||||||
|
(set_local 1 (i64.mul (get_local 1) (get_local 0)))
|
||||||
|
(set_local 0 (i64.add (get_local 0) (i64.const -1)))
|
||||||
|
(br_if 0 (i64.gt_s (get_local 0) (i64.const 1)))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(get_local 1)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke "fac-rec" (i64.const 25)) (i64.const 7034535277573963776))
|
||||||
|
(assert_return (invoke "fac-iter" (i64.const 25)) (i64.const 7034535277573963776))
|
||||||
|
(assert_return (invoke "fac-rec-named" (i64.const 25)) (i64.const 7034535277573963776))
|
||||||
|
(assert_return (invoke "fac-iter-named" (i64.const 25)) (i64.const 7034535277573963776))
|
||||||
|
(assert_return (invoke "fac-opt" (i64.const 25)) (i64.const 7034535277573963776))
|
||||||
|
(assert_exhaustion (invoke "fac-rec" (i64.const 1073741824)) "call stack exhausted")
|
||||||
@@ -0,0 +1,117 @@
|
|||||||
|
(module
|
||||||
|
;; Recursive factorial
|
||||||
|
(func (export "fac-rec") (param i64) (result i64)
|
||||||
|
(if (result i64) (i64.eq (get_local 0) (i64.const 0))
|
||||||
|
(then (i64.const 1))
|
||||||
|
(else
|
||||||
|
(i64.mul (get_local 0) (call 0 (i64.sub (get_local 0) (i64.const 1))))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
;; Recursive factorial named
|
||||||
|
(func $fac-rec-named (export "fac-rec-named") (param $n i64) (result i64)
|
||||||
|
(if (result i64) (i64.eq (get_local $n) (i64.const 0))
|
||||||
|
(then (i64.const 1))
|
||||||
|
(else
|
||||||
|
(i64.mul
|
||||||
|
(get_local $n)
|
||||||
|
(call $fac-rec-named (i64.sub (get_local $n) (i64.const 1)))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
;; Recursive factorial named
|
||||||
|
(func $fac-rec-named-32 (export "fac-rec-named-32") (param $n i32) (result i32)
|
||||||
|
(if (result i32) (i32.eq (get_local $n) (i32.const 0))
|
||||||
|
(then (i32.const 1))
|
||||||
|
(else
|
||||||
|
(i32.mul
|
||||||
|
(get_local $n)
|
||||||
|
(call $fac-rec-named-32 (i32.sub (get_local $n) (i32.const 1)))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
;; Iterative factorial
|
||||||
|
(func (export "fac-iter") (param i64) (result i64)
|
||||||
|
(local i64 i64)
|
||||||
|
(set_local 1 (get_local 0))
|
||||||
|
(set_local 2 (i64.const 1))
|
||||||
|
(block
|
||||||
|
(loop
|
||||||
|
(if
|
||||||
|
(i64.eq (get_local 1) (i64.const 0))
|
||||||
|
(then (br 2))
|
||||||
|
(else
|
||||||
|
(set_local 2 (i64.mul (get_local 1) (get_local 2)))
|
||||||
|
(set_local 1 (i64.sub (get_local 1) (i64.const 1)))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(br 0)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(get_local 2)
|
||||||
|
)
|
||||||
|
|
||||||
|
;; Iterative factorial named
|
||||||
|
(func (export "fac-iter-named") (param $n i64) (result i64)
|
||||||
|
(local $i i64)
|
||||||
|
(local $res i64)
|
||||||
|
(set_local $i (get_local $n))
|
||||||
|
(set_local $res (i64.const 1))
|
||||||
|
(block $done
|
||||||
|
(loop $loop
|
||||||
|
(if
|
||||||
|
(i64.eq (get_local $i) (i64.const 0))
|
||||||
|
(then (br $done))
|
||||||
|
(else
|
||||||
|
(set_local $res (i64.mul (get_local $i) (get_local $res)))
|
||||||
|
(set_local $i (i64.sub (get_local $i) (i64.const 1)))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(br $loop)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(get_local $res)
|
||||||
|
)
|
||||||
|
|
||||||
|
;; Iterative factorial named
|
||||||
|
(func (export "fac-iter-named-32") (param $n i32) (result i32)
|
||||||
|
(local $i i32)
|
||||||
|
(local $res i32)
|
||||||
|
(set_local $i (get_local $n))
|
||||||
|
(set_local $res (i32.const 1))
|
||||||
|
(block $done
|
||||||
|
(loop $loop
|
||||||
|
(if
|
||||||
|
(i32.eq (get_local $i) (i32.const 0))
|
||||||
|
(then (br $done))
|
||||||
|
(else
|
||||||
|
(set_local $res (i32.mul (get_local $i) (get_local $res)))
|
||||||
|
(set_local $i (i32.sub (get_local $i) (i32.const 1)))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(br $loop)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(get_local $res)
|
||||||
|
)
|
||||||
|
|
||||||
|
;; Optimized factorial.
|
||||||
|
(func (export "fac-opt") (param i64) (result i64)
|
||||||
|
(local i64)
|
||||||
|
(set_local 1 (i64.const 1))
|
||||||
|
(block
|
||||||
|
(br_if 0 (i64.lt_s (get_local 0) (i64.const 2)))
|
||||||
|
(loop
|
||||||
|
(set_local 1 (i64.mul (get_local 1) (get_local 0)))
|
||||||
|
(set_local 0 (i64.add (get_local 0) (i64.const -1)))
|
||||||
|
(br_if 0 (i64.gt_s (get_local 0) (i64.const 1)))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(get_local 1)
|
||||||
|
)
|
||||||
|
)
|
||||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,499 @@
|
|||||||
|
;; Test floating-point literal parsing.
|
||||||
|
|
||||||
|
(module
|
||||||
|
;; f32 special values
|
||||||
|
(func (export "f32.nan") (result i32) (i32.reinterpret/f32 (f32.const nan)))
|
||||||
|
(func (export "f32.positive_nan") (result i32) (i32.reinterpret/f32 (f32.const +nan)))
|
||||||
|
(func (export "f32.negative_nan") (result i32) (i32.reinterpret/f32 (f32.const -nan)))
|
||||||
|
(func (export "f32.plain_nan") (result i32) (i32.reinterpret/f32 (f32.const nan:0x400000)))
|
||||||
|
(func (export "f32.informally_known_as_plain_snan") (result i32) (i32.reinterpret/f32 (f32.const nan:0x200000)))
|
||||||
|
(func (export "f32.all_ones_nan") (result i32) (i32.reinterpret/f32 (f32.const -nan:0x7fffff)))
|
||||||
|
(func (export "f32.misc_nan") (result i32) (i32.reinterpret/f32 (f32.const nan:0x012345)))
|
||||||
|
(func (export "f32.misc_positive_nan") (result i32) (i32.reinterpret/f32 (f32.const +nan:0x304050)))
|
||||||
|
(func (export "f32.misc_negative_nan") (result i32) (i32.reinterpret/f32 (f32.const -nan:0x2abcde)))
|
||||||
|
(func (export "f32.infinity") (result i32) (i32.reinterpret/f32 (f32.const inf)))
|
||||||
|
(func (export "f32.positive_infinity") (result i32) (i32.reinterpret/f32 (f32.const +inf)))
|
||||||
|
(func (export "f32.negative_infinity") (result i32) (i32.reinterpret/f32 (f32.const -inf)))
|
||||||
|
|
||||||
|
;; f32 numbers
|
||||||
|
(func (export "f32.zero") (result i32) (i32.reinterpret/f32 (f32.const 0x0.0p0)))
|
||||||
|
(func (export "f32.positive_zero") (result i32) (i32.reinterpret/f32 (f32.const +0x0.0p0)))
|
||||||
|
(func (export "f32.negative_zero") (result i32) (i32.reinterpret/f32 (f32.const -0x0.0p0)))
|
||||||
|
(func (export "f32.misc") (result i32) (i32.reinterpret/f32 (f32.const 0x1.921fb6p+2)))
|
||||||
|
(func (export "f32.min_positive") (result i32) (i32.reinterpret/f32 (f32.const 0x1p-149)))
|
||||||
|
(func (export "f32.min_normal") (result i32) (i32.reinterpret/f32 (f32.const 0x1p-126)))
|
||||||
|
(func (export "f32.max_finite") (result i32) (i32.reinterpret/f32 (f32.const 0x1.fffffep+127)))
|
||||||
|
(func (export "f32.max_subnormal") (result i32) (i32.reinterpret/f32 (f32.const 0x1.fffffcp-127)))
|
||||||
|
(func (export "f32.trailing_dot") (result i32) (i32.reinterpret/f32 (f32.const 0x1.p10)))
|
||||||
|
|
||||||
|
;; f32 in decimal format
|
||||||
|
(func (export "f32_dec.zero") (result i32) (i32.reinterpret/f32 (f32.const 0.0e0)))
|
||||||
|
(func (export "f32_dec.positive_zero") (result i32) (i32.reinterpret/f32 (f32.const +0.0e0)))
|
||||||
|
(func (export "f32_dec.negative_zero") (result i32) (i32.reinterpret/f32 (f32.const -0.0e0)))
|
||||||
|
(func (export "f32_dec.misc") (result i32) (i32.reinterpret/f32 (f32.const 6.28318548202514648)))
|
||||||
|
(func (export "f32_dec.min_positive") (result i32) (i32.reinterpret/f32 (f32.const 1.4013e-45)))
|
||||||
|
(func (export "f32_dec.min_normal") (result i32) (i32.reinterpret/f32 (f32.const 1.1754944e-38)))
|
||||||
|
(func (export "f32_dec.max_subnormal") (result i32) (i32.reinterpret/f32 (f32.const 1.1754942e-38)))
|
||||||
|
(func (export "f32_dec.max_finite") (result i32) (i32.reinterpret/f32 (f32.const 3.4028234e+38)))
|
||||||
|
(func (export "f32_dec.trailing_dot") (result i32) (i32.reinterpret/f32 (f32.const 1.e10)))
|
||||||
|
|
||||||
|
;; f64 special values
|
||||||
|
(func (export "f64.nan") (result i64) (i64.reinterpret/f64 (f64.const nan)))
|
||||||
|
(func (export "f64.positive_nan") (result i64) (i64.reinterpret/f64 (f64.const +nan)))
|
||||||
|
(func (export "f64.negative_nan") (result i64) (i64.reinterpret/f64 (f64.const -nan)))
|
||||||
|
(func (export "f64.plain_nan") (result i64) (i64.reinterpret/f64 (f64.const nan:0x8000000000000)))
|
||||||
|
(func (export "f64.informally_known_as_plain_snan") (result i64) (i64.reinterpret/f64 (f64.const nan:0x4000000000000)))
|
||||||
|
(func (export "f64.all_ones_nan") (result i64) (i64.reinterpret/f64 (f64.const -nan:0xfffffffffffff)))
|
||||||
|
(func (export "f64.misc_nan") (result i64) (i64.reinterpret/f64 (f64.const nan:0x0123456789abc)))
|
||||||
|
(func (export "f64.misc_positive_nan") (result i64) (i64.reinterpret/f64 (f64.const +nan:0x3040506070809)))
|
||||||
|
(func (export "f64.misc_negative_nan") (result i64) (i64.reinterpret/f64 (f64.const -nan:0x2abcdef012345)))
|
||||||
|
(func (export "f64.infinity") (result i64) (i64.reinterpret/f64 (f64.const inf)))
|
||||||
|
(func (export "f64.positive_infinity") (result i64) (i64.reinterpret/f64 (f64.const +inf)))
|
||||||
|
(func (export "f64.negative_infinity") (result i64) (i64.reinterpret/f64 (f64.const -inf)))
|
||||||
|
|
||||||
|
;; f64 numbers
|
||||||
|
(func (export "f64.zero") (result i64) (i64.reinterpret/f64 (f64.const 0x0.0p0)))
|
||||||
|
(func (export "f64.positive_zero") (result i64) (i64.reinterpret/f64 (f64.const +0x0.0p0)))
|
||||||
|
(func (export "f64.negative_zero") (result i64) (i64.reinterpret/f64 (f64.const -0x0.0p0)))
|
||||||
|
(func (export "f64.misc") (result i64) (i64.reinterpret/f64 (f64.const 0x1.921fb54442d18p+2)))
|
||||||
|
(func (export "f64.min_positive") (result i64) (i64.reinterpret/f64 (f64.const 0x0.0000000000001p-1022)))
|
||||||
|
(func (export "f64.min_normal") (result i64) (i64.reinterpret/f64 (f64.const 0x1p-1022)))
|
||||||
|
(func (export "f64.max_subnormal") (result i64) (i64.reinterpret/f64 (f64.const 0x0.fffffffffffffp-1022)))
|
||||||
|
(func (export "f64.max_finite") (result i64) (i64.reinterpret/f64 (f64.const 0x1.fffffffffffffp+1023)))
|
||||||
|
(func (export "f64.trailing_dot") (result i64) (i64.reinterpret/f64 (f64.const 0x1.p100)))
|
||||||
|
|
||||||
|
;; f64 numbers in decimal format
|
||||||
|
(func (export "f64_dec.zero") (result i64) (i64.reinterpret/f64 (f64.const 0.0e0)))
|
||||||
|
(func (export "f64_dec.positive_zero") (result i64) (i64.reinterpret/f64 (f64.const +0.0e0)))
|
||||||
|
(func (export "f64_dec.negative_zero") (result i64) (i64.reinterpret/f64 (f64.const -0.0e0)))
|
||||||
|
(func (export "f64_dec.misc") (result i64) (i64.reinterpret/f64 (f64.const 6.28318530717958623)))
|
||||||
|
(func (export "f64_dec.min_positive") (result i64) (i64.reinterpret/f64 (f64.const 4.94066e-324)))
|
||||||
|
(func (export "f64_dec.min_normal") (result i64) (i64.reinterpret/f64 (f64.const 2.2250738585072012e-308)))
|
||||||
|
(func (export "f64_dec.max_subnormal") (result i64) (i64.reinterpret/f64 (f64.const 2.2250738585072011e-308)))
|
||||||
|
(func (export "f64_dec.max_finite") (result i64) (i64.reinterpret/f64 (f64.const 1.7976931348623157e+308)))
|
||||||
|
(func (export "f64_dec.trailing_dot") (result i64) (i64.reinterpret/f64 (f64.const 1.e100)))
|
||||||
|
|
||||||
|
(func (export "f32-dec-sep1") (result f32) (f32.const 1_000_000))
|
||||||
|
(func (export "f32-dec-sep2") (result f32) (f32.const 1_0_0_0))
|
||||||
|
(func (export "f32-dec-sep3") (result f32) (f32.const 100_3.141_592))
|
||||||
|
(func (export "f32-dec-sep4") (result f32) (f32.const 99e+1_3))
|
||||||
|
(func (export "f32-dec-sep5") (result f32) (f32.const 122_000.11_3_54E0_2_3))
|
||||||
|
(func (export "f32-hex-sep1") (result f32) (f32.const 0xa_0f_00_99))
|
||||||
|
(func (export "f32-hex-sep2") (result f32) (f32.const 0x1_a_A_0_f))
|
||||||
|
(func (export "f32-hex-sep3") (result f32) (f32.const 0xa0_ff.f141_a59a))
|
||||||
|
(func (export "f32-hex-sep4") (result f32) (f32.const 0xf0P+1_3))
|
||||||
|
(func (export "f32-hex-sep5") (result f32) (f32.const 0x2a_f00a.1f_3_eep2_3))
|
||||||
|
|
||||||
|
(func (export "f64-dec-sep1") (result f64) (f64.const 1_000_000))
|
||||||
|
(func (export "f64-dec-sep2") (result f64) (f64.const 1_0_0_0))
|
||||||
|
(func (export "f64-dec-sep3") (result f64) (f64.const 100_3.141_592))
|
||||||
|
(func (export "f64-dec-sep4") (result f64) (f64.const 99e-1_23))
|
||||||
|
(func (export "f64-dec-sep5") (result f64) (f64.const 122_000.11_3_54e0_2_3))
|
||||||
|
(func (export "f64-hex-sep1") (result f64) (f64.const 0xa_f00f_0000_9999))
|
||||||
|
(func (export "f64-hex-sep2") (result f64) (f64.const 0x1_a_A_0_f))
|
||||||
|
(func (export "f64-hex-sep3") (result f64) (f64.const 0xa0_ff.f141_a59a))
|
||||||
|
(func (export "f64-hex-sep4") (result f64) (f64.const 0xf0P+1_3))
|
||||||
|
(func (export "f64-hex-sep5") (result f64) (f64.const 0x2a_f00a.1f_3_eep2_3))
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke "f32.nan") (i32.const 0x7fc00000))
|
||||||
|
(assert_return (invoke "f32.positive_nan") (i32.const 0x7fc00000))
|
||||||
|
(assert_return (invoke "f32.negative_nan") (i32.const 0xffc00000))
|
||||||
|
(assert_return (invoke "f32.plain_nan") (i32.const 0x7fc00000))
|
||||||
|
(assert_return (invoke "f32.informally_known_as_plain_snan") (i32.const 0x7fa00000))
|
||||||
|
(assert_return (invoke "f32.all_ones_nan") (i32.const 0xffffffff))
|
||||||
|
(assert_return (invoke "f32.misc_nan") (i32.const 0x7f812345))
|
||||||
|
(assert_return (invoke "f32.misc_positive_nan") (i32.const 0x7fb04050))
|
||||||
|
(assert_return (invoke "f32.misc_negative_nan") (i32.const 0xffaabcde))
|
||||||
|
(assert_return (invoke "f32.infinity") (i32.const 0x7f800000))
|
||||||
|
(assert_return (invoke "f32.positive_infinity") (i32.const 0x7f800000))
|
||||||
|
(assert_return (invoke "f32.negative_infinity") (i32.const 0xff800000))
|
||||||
|
(assert_return (invoke "f32.zero") (i32.const 0))
|
||||||
|
(assert_return (invoke "f32.positive_zero") (i32.const 0))
|
||||||
|
(assert_return (invoke "f32.negative_zero") (i32.const 0x80000000))
|
||||||
|
(assert_return (invoke "f32.misc") (i32.const 0x40c90fdb))
|
||||||
|
(assert_return (invoke "f32.min_positive") (i32.const 1))
|
||||||
|
(assert_return (invoke "f32.min_normal") (i32.const 0x800000))
|
||||||
|
(assert_return (invoke "f32.max_subnormal") (i32.const 0x7fffff))
|
||||||
|
(assert_return (invoke "f32.max_finite") (i32.const 0x7f7fffff))
|
||||||
|
(assert_return (invoke "f32.trailing_dot") (i32.const 0x44800000))
|
||||||
|
(assert_return (invoke "f32_dec.zero") (i32.const 0))
|
||||||
|
(assert_return (invoke "f32_dec.positive_zero") (i32.const 0))
|
||||||
|
(assert_return (invoke "f32_dec.negative_zero") (i32.const 0x80000000))
|
||||||
|
(assert_return (invoke "f32_dec.misc") (i32.const 0x40c90fdb))
|
||||||
|
(assert_return (invoke "f32_dec.min_positive") (i32.const 1))
|
||||||
|
(assert_return (invoke "f32_dec.min_normal") (i32.const 0x800000))
|
||||||
|
(assert_return (invoke "f32_dec.max_subnormal") (i32.const 0x7fffff))
|
||||||
|
(assert_return (invoke "f32_dec.max_finite") (i32.const 0x7f7fffff))
|
||||||
|
(assert_return (invoke "f32_dec.trailing_dot") (i32.const 0x501502f9))
|
||||||
|
|
||||||
|
(assert_return (invoke "f64.nan") (i64.const 0x7ff8000000000000))
|
||||||
|
(assert_return (invoke "f64.positive_nan") (i64.const 0x7ff8000000000000))
|
||||||
|
(assert_return (invoke "f64.negative_nan") (i64.const 0xfff8000000000000))
|
||||||
|
(assert_return (invoke "f64.plain_nan") (i64.const 0x7ff8000000000000))
|
||||||
|
(assert_return (invoke "f64.informally_known_as_plain_snan") (i64.const 0x7ff4000000000000))
|
||||||
|
(assert_return (invoke "f64.all_ones_nan") (i64.const 0xffffffffffffffff))
|
||||||
|
(assert_return (invoke "f64.misc_nan") (i64.const 0x7ff0123456789abc))
|
||||||
|
(assert_return (invoke "f64.misc_positive_nan") (i64.const 0x7ff3040506070809))
|
||||||
|
(assert_return (invoke "f64.misc_negative_nan") (i64.const 0xfff2abcdef012345))
|
||||||
|
(assert_return (invoke "f64.infinity") (i64.const 0x7ff0000000000000))
|
||||||
|
(assert_return (invoke "f64.positive_infinity") (i64.const 0x7ff0000000000000))
|
||||||
|
(assert_return (invoke "f64.negative_infinity") (i64.const 0xfff0000000000000))
|
||||||
|
(assert_return (invoke "f64.zero") (i64.const 0))
|
||||||
|
(assert_return (invoke "f64.positive_zero") (i64.const 0))
|
||||||
|
(assert_return (invoke "f64.negative_zero") (i64.const 0x8000000000000000))
|
||||||
|
(assert_return (invoke "f64.misc") (i64.const 0x401921fb54442d18))
|
||||||
|
(assert_return (invoke "f64.min_positive") (i64.const 1))
|
||||||
|
(assert_return (invoke "f64.min_normal") (i64.const 0x10000000000000))
|
||||||
|
(assert_return (invoke "f64.max_subnormal") (i64.const 0xfffffffffffff))
|
||||||
|
(assert_return (invoke "f64.max_finite") (i64.const 0x7fefffffffffffff))
|
||||||
|
(assert_return (invoke "f64.trailing_dot") (i64.const 0x4630000000000000))
|
||||||
|
(assert_return (invoke "f64_dec.zero") (i64.const 0))
|
||||||
|
(assert_return (invoke "f64_dec.positive_zero") (i64.const 0))
|
||||||
|
(assert_return (invoke "f64_dec.negative_zero") (i64.const 0x8000000000000000))
|
||||||
|
(assert_return (invoke "f64_dec.misc") (i64.const 0x401921fb54442d18))
|
||||||
|
(assert_return (invoke "f64_dec.min_positive") (i64.const 1))
|
||||||
|
(assert_return (invoke "f64_dec.min_normal") (i64.const 0x10000000000000))
|
||||||
|
(assert_return (invoke "f64_dec.max_subnormal") (i64.const 0xfffffffffffff))
|
||||||
|
(assert_return (invoke "f64_dec.max_finite") (i64.const 0x7fefffffffffffff))
|
||||||
|
(assert_return (invoke "f64_dec.trailing_dot") (i64.const 0x54b249ad2594c37d))
|
||||||
|
|
||||||
|
(assert_return (invoke "f32-dec-sep1") (f32.const 1000000))
|
||||||
|
(assert_return (invoke "f32-dec-sep2") (f32.const 1000))
|
||||||
|
(assert_return (invoke "f32-dec-sep3") (f32.const 1003.141592))
|
||||||
|
(assert_return (invoke "f32-dec-sep4") (f32.const 99e+13))
|
||||||
|
(assert_return (invoke "f32-dec-sep5") (f32.const 122000.11354e23))
|
||||||
|
(assert_return (invoke "f32-hex-sep1") (f32.const 0xa0f0099))
|
||||||
|
(assert_return (invoke "f32-hex-sep2") (f32.const 0x1aa0f))
|
||||||
|
(assert_return (invoke "f32-hex-sep3") (f32.const 0xa0ff.f141a59a))
|
||||||
|
(assert_return (invoke "f32-hex-sep4") (f32.const 0xf0P+13))
|
||||||
|
(assert_return (invoke "f32-hex-sep5") (f32.const 0x2af00a.1f3eep23))
|
||||||
|
|
||||||
|
(assert_return (invoke "f64-dec-sep1") (f64.const 1000000))
|
||||||
|
(assert_return (invoke "f64-dec-sep2") (f64.const 1000))
|
||||||
|
(assert_return (invoke "f64-dec-sep3") (f64.const 1003.141592))
|
||||||
|
(assert_return (invoke "f64-dec-sep4") (f64.const 99e-123))
|
||||||
|
(assert_return (invoke "f64-dec-sep5") (f64.const 122000.11354e23))
|
||||||
|
(assert_return (invoke "f64-hex-sep1") (f64.const 0xaf00f00009999))
|
||||||
|
(assert_return (invoke "f64-hex-sep2") (f64.const 0x1aa0f))
|
||||||
|
(assert_return (invoke "f64-hex-sep3") (f64.const 0xa0ff.f141a59a))
|
||||||
|
(assert_return (invoke "f64-hex-sep4") (f64.const 0xf0P+13))
|
||||||
|
(assert_return (invoke "f64-hex-sep5") (f64.const 0x2af00a.1f3eep23))
|
||||||
|
|
||||||
|
;; Test parsing a float from binary
|
||||||
|
(module binary
|
||||||
|
;; (func (export "4294967249") (result f64) (f64.const 4294967249))
|
||||||
|
"\00\61\73\6d\01\00\00\00\01\85\80\80\80\00\01\60"
|
||||||
|
"\00\01\7c\03\82\80\80\80\00\01\00\07\8e\80\80\80"
|
||||||
|
"\00\01\0a\34\32\39\34\39\36\37\32\34\39\00\00\0a"
|
||||||
|
"\91\80\80\80\00\01\8b\80\80\80\00\00\44\00\00\20"
|
||||||
|
"\fa\ff\ff\ef\41\0b"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke "4294967249") (f64.const 4294967249))
|
||||||
|
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f32 (f32.const _100))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f32 (f32.const +_100))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f32 (f32.const -_100))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f32 (f32.const 99_))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f32 (f32.const 1__000))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f32 (f32.const _1.0))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f32 (f32.const 1.0_))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f32 (f32.const 1_.0))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f32 (f32.const 1._0))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f32 (f32.const _1e1))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f32 (f32.const 1e1_))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f32 (f32.const 1_e1))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f32 (f32.const 1e_1))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f32 (f32.const _1.0e1))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f32 (f32.const 1.0e1_))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f32 (f32.const 1.0_e1))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f32 (f32.const 1.0e_1))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f32 (f32.const 1.0e+_1))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f32 (f32.const 1.0e_+1))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f32 (f32.const _0x100))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f32 (f32.const 0_x100))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f32 (f32.const 0x_100))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f32 (f32.const 0x00_))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f32 (f32.const 0xff__ffff))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f32 (f32.const 0x_1.0))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f32 (f32.const 0x1.0_))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f32 (f32.const 0x1_.0))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f32 (f32.const 0x1._0))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f32 (f32.const 0x_1p1))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f32 (f32.const 0x1p1_))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f32 (f32.const 0x1_p1))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f32 (f32.const 0x1p_1))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f32 (f32.const 0x_1.0p1))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f32 (f32.const 0x1.0p1_))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f32 (f32.const 0x1.0_p1))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f32 (f32.const 0x1.0p_1))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f32 (f32.const 0x1.0p+_1))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f32 (f32.const 0x1.0p_+1))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f64 (f64.const _100))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f64 (f64.const +_100))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f64 (f64.const -_100))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f64 (f64.const 99_))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f64 (f64.const 1__000))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f64 (f64.const _1.0))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f64 (f64.const 1.0_))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f64 (f64.const 1_.0))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f64 (f64.const 1._0))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f64 (f64.const _1e1))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f64 (f64.const 1e1_))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f64 (f64.const 1_e1))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f64 (f64.const 1e_1))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f64 (f64.const _1.0e1))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f64 (f64.const 1.0e1_))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f64 (f64.const 1.0_e1))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f64 (f64.const 1.0e_1))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f64 (f64.const 1.0e+_1))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f64 (f64.const 1.0e_+1))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f64 (f64.const _0x100))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f64 (f64.const 0_x100))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f64 (f64.const 0x_100))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f64 (f64.const 0x00_))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f64 (f64.const 0xff__ffff))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f64 (f64.const 0x_1.0))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f64 (f64.const 0x1.0_))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f64 (f64.const 0x1_.0))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f64 (f64.const 0x1._0))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f64 (f64.const 0x_1p1))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f64 (f64.const 0x1p1_))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f64 (f64.const 0x1_p1))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f64 (f64.const 0x1p_1))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f64 (f64.const 0x_1.0p1))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f64 (f64.const 0x1.0p1_))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f64 (f64.const 0x1.0_p1))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f64 (f64.const 0x1.0p_1))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f64 (f64.const 0x1.0p+_1))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global f64 (f64.const 0x1.0p_+1))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
@@ -0,0 +1,157 @@
|
|||||||
|
;; Test that floating-point load and store are bit-preserving.
|
||||||
|
|
||||||
|
;; Test that load and store do not canonicalize NaNs as x87 does.
|
||||||
|
|
||||||
|
(module
|
||||||
|
(memory (data "\00\00\a0\7f"))
|
||||||
|
|
||||||
|
(func (export "f32.load") (result f32) (f32.load (i32.const 0)))
|
||||||
|
(func (export "i32.load") (result i32) (i32.load (i32.const 0)))
|
||||||
|
(func (export "f32.store") (f32.store (i32.const 0) (f32.const nan:0x200000)))
|
||||||
|
(func (export "i32.store") (i32.store (i32.const 0) (i32.const 0x7fa00000)))
|
||||||
|
(func (export "reset") (i32.store (i32.const 0) (i32.const 0)))
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke "i32.load") (i32.const 0x7fa00000))
|
||||||
|
(assert_return (invoke "f32.load") (f32.const nan:0x200000))
|
||||||
|
(invoke "reset")
|
||||||
|
(assert_return (invoke "i32.load") (i32.const 0x0))
|
||||||
|
(assert_return (invoke "f32.load") (f32.const 0.0))
|
||||||
|
(invoke "f32.store")
|
||||||
|
(assert_return (invoke "i32.load") (i32.const 0x7fa00000))
|
||||||
|
(assert_return (invoke "f32.load") (f32.const nan:0x200000))
|
||||||
|
(invoke "reset")
|
||||||
|
(assert_return (invoke "i32.load") (i32.const 0x0))
|
||||||
|
(assert_return (invoke "f32.load") (f32.const 0.0))
|
||||||
|
(invoke "i32.store")
|
||||||
|
(assert_return (invoke "i32.load") (i32.const 0x7fa00000))
|
||||||
|
(assert_return (invoke "f32.load") (f32.const nan:0x200000))
|
||||||
|
|
||||||
|
(module
|
||||||
|
(memory (data "\00\00\00\00\00\00\f4\7f"))
|
||||||
|
|
||||||
|
(func (export "f64.load") (result f64) (f64.load (i32.const 0)))
|
||||||
|
(func (export "i64.load") (result i64) (i64.load (i32.const 0)))
|
||||||
|
(func (export "f64.store") (f64.store (i32.const 0) (f64.const nan:0x4000000000000)))
|
||||||
|
(func (export "i64.store") (i64.store (i32.const 0) (i64.const 0x7ff4000000000000)))
|
||||||
|
(func (export "reset") (i64.store (i32.const 0) (i64.const 0)))
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke "i64.load") (i64.const 0x7ff4000000000000))
|
||||||
|
(assert_return (invoke "f64.load") (f64.const nan:0x4000000000000))
|
||||||
|
(invoke "reset")
|
||||||
|
(assert_return (invoke "i64.load") (i64.const 0x0))
|
||||||
|
(assert_return (invoke "f64.load") (f64.const 0.0))
|
||||||
|
(invoke "f64.store")
|
||||||
|
(assert_return (invoke "i64.load") (i64.const 0x7ff4000000000000))
|
||||||
|
(assert_return (invoke "f64.load") (f64.const nan:0x4000000000000))
|
||||||
|
(invoke "reset")
|
||||||
|
(assert_return (invoke "i64.load") (i64.const 0x0))
|
||||||
|
(assert_return (invoke "f64.load") (f64.const 0.0))
|
||||||
|
(invoke "i64.store")
|
||||||
|
(assert_return (invoke "i64.load") (i64.const 0x7ff4000000000000))
|
||||||
|
(assert_return (invoke "f64.load") (f64.const nan:0x4000000000000))
|
||||||
|
|
||||||
|
;; Test that unaligned load and store do not canonicalize NaNs.
|
||||||
|
|
||||||
|
(module
|
||||||
|
(memory (data "\00\00\00\a0\7f"))
|
||||||
|
|
||||||
|
(func (export "f32.load") (result f32) (f32.load (i32.const 1)))
|
||||||
|
(func (export "i32.load") (result i32) (i32.load (i32.const 1)))
|
||||||
|
(func (export "f32.store") (f32.store (i32.const 1) (f32.const nan:0x200000)))
|
||||||
|
(func (export "i32.store") (i32.store (i32.const 1) (i32.const 0x7fa00000)))
|
||||||
|
(func (export "reset") (i32.store (i32.const 1) (i32.const 0)))
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke "i32.load") (i32.const 0x7fa00000))
|
||||||
|
(assert_return (invoke "f32.load") (f32.const nan:0x200000))
|
||||||
|
(invoke "reset")
|
||||||
|
(assert_return (invoke "i32.load") (i32.const 0x0))
|
||||||
|
(assert_return (invoke "f32.load") (f32.const 0.0))
|
||||||
|
(invoke "f32.store")
|
||||||
|
(assert_return (invoke "i32.load") (i32.const 0x7fa00000))
|
||||||
|
(assert_return (invoke "f32.load") (f32.const nan:0x200000))
|
||||||
|
(invoke "reset")
|
||||||
|
(assert_return (invoke "i32.load") (i32.const 0x0))
|
||||||
|
(assert_return (invoke "f32.load") (f32.const 0.0))
|
||||||
|
(invoke "i32.store")
|
||||||
|
(assert_return (invoke "i32.load") (i32.const 0x7fa00000))
|
||||||
|
(assert_return (invoke "f32.load") (f32.const nan:0x200000))
|
||||||
|
|
||||||
|
(module
|
||||||
|
(memory (data "\00\00\00\00\00\00\00\f4\7f"))
|
||||||
|
|
||||||
|
(func (export "f64.load") (result f64) (f64.load (i32.const 1)))
|
||||||
|
(func (export "i64.load") (result i64) (i64.load (i32.const 1)))
|
||||||
|
(func (export "f64.store") (f64.store (i32.const 1) (f64.const nan:0x4000000000000)))
|
||||||
|
(func (export "i64.store") (i64.store (i32.const 1) (i64.const 0x7ff4000000000000)))
|
||||||
|
(func (export "reset") (i64.store (i32.const 1) (i64.const 0)))
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke "i64.load") (i64.const 0x7ff4000000000000))
|
||||||
|
(assert_return (invoke "f64.load") (f64.const nan:0x4000000000000))
|
||||||
|
(invoke "reset")
|
||||||
|
(assert_return (invoke "i64.load") (i64.const 0x0))
|
||||||
|
(assert_return (invoke "f64.load") (f64.const 0.0))
|
||||||
|
(invoke "f64.store")
|
||||||
|
(assert_return (invoke "i64.load") (i64.const 0x7ff4000000000000))
|
||||||
|
(assert_return (invoke "f64.load") (f64.const nan:0x4000000000000))
|
||||||
|
(invoke "reset")
|
||||||
|
(assert_return (invoke "i64.load") (i64.const 0x0))
|
||||||
|
(assert_return (invoke "f64.load") (f64.const 0.0))
|
||||||
|
(invoke "i64.store")
|
||||||
|
(assert_return (invoke "i64.load") (i64.const 0x7ff4000000000000))
|
||||||
|
(assert_return (invoke "f64.load") (f64.const nan:0x4000000000000))
|
||||||
|
|
||||||
|
;; Test that load and store do not canonicalize NaNs as some JS engines do.
|
||||||
|
|
||||||
|
(module
|
||||||
|
(memory (data "\01\00\d0\7f"))
|
||||||
|
|
||||||
|
(func (export "f32.load") (result f32) (f32.load (i32.const 0)))
|
||||||
|
(func (export "i32.load") (result i32) (i32.load (i32.const 0)))
|
||||||
|
(func (export "f32.store") (f32.store (i32.const 0) (f32.const nan:0x500001)))
|
||||||
|
(func (export "i32.store") (i32.store (i32.const 0) (i32.const 0x7fd00001)))
|
||||||
|
(func (export "reset") (i32.store (i32.const 0) (i32.const 0)))
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke "i32.load") (i32.const 0x7fd00001))
|
||||||
|
(assert_return (invoke "f32.load") (f32.const nan:0x500001))
|
||||||
|
(invoke "reset")
|
||||||
|
(assert_return (invoke "i32.load") (i32.const 0x0))
|
||||||
|
(assert_return (invoke "f32.load") (f32.const 0.0))
|
||||||
|
(invoke "f32.store")
|
||||||
|
(assert_return (invoke "i32.load") (i32.const 0x7fd00001))
|
||||||
|
(assert_return (invoke "f32.load") (f32.const nan:0x500001))
|
||||||
|
(invoke "reset")
|
||||||
|
(assert_return (invoke "i32.load") (i32.const 0x0))
|
||||||
|
(assert_return (invoke "f32.load") (f32.const 0.0))
|
||||||
|
(invoke "i32.store")
|
||||||
|
(assert_return (invoke "i32.load") (i32.const 0x7fd00001))
|
||||||
|
(assert_return (invoke "f32.load") (f32.const nan:0x500001))
|
||||||
|
|
||||||
|
(module
|
||||||
|
(memory (data "\01\00\00\00\00\00\fc\7f"))
|
||||||
|
|
||||||
|
(func (export "f64.load") (result f64) (f64.load (i32.const 0)))
|
||||||
|
(func (export "i64.load") (result i64) (i64.load (i32.const 0)))
|
||||||
|
(func (export "f64.store") (f64.store (i32.const 0) (f64.const nan:0xc000000000001)))
|
||||||
|
(func (export "i64.store") (i64.store (i32.const 0) (i64.const 0x7ffc000000000001)))
|
||||||
|
(func (export "reset") (i64.store (i32.const 0) (i64.const 0)))
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke "i64.load") (i64.const 0x7ffc000000000001))
|
||||||
|
(assert_return (invoke "f64.load") (f64.const nan:0xc000000000001))
|
||||||
|
(invoke "reset")
|
||||||
|
(assert_return (invoke "i64.load") (i64.const 0x0))
|
||||||
|
(assert_return (invoke "f64.load") (f64.const 0.0))
|
||||||
|
(invoke "f64.store")
|
||||||
|
(assert_return (invoke "i64.load") (i64.const 0x7ffc000000000001))
|
||||||
|
(assert_return (invoke "f64.load") (f64.const nan:0xc000000000001))
|
||||||
|
(invoke "reset")
|
||||||
|
(assert_return (invoke "i64.load") (i64.const 0x0))
|
||||||
|
(assert_return (invoke "f64.load") (f64.const 0.0))
|
||||||
|
(invoke "i64.store")
|
||||||
|
(assert_return (invoke "i64.load") (i64.const 0x7ffc000000000001))
|
||||||
|
(assert_return (invoke "f64.load") (f64.const nan:0xc000000000001))
|
||||||
@@ -0,0 +1,678 @@
|
|||||||
|
;; Platforms intended to run WebAssembly must support IEEE 754 arithmetic.
|
||||||
|
;; This testsuite is not currently sufficient for full IEEE 754 conformance
|
||||||
|
;; testing; platforms are currently expected to meet these requirements in
|
||||||
|
;; their own way (widely-used hardware platforms already do this).
|
||||||
|
;;
|
||||||
|
;; What this testsuite does test is that (a) the platform is basically IEEE 754
|
||||||
|
;; rather than something else entirely, (b) it's configured correctly for
|
||||||
|
;; WebAssembly (rounding direction, exception masks, precision level, subnormal
|
||||||
|
;; mode, etc.), (c) the WebAssembly implementation doesn't perform any common
|
||||||
|
;; value-changing optimizations, and (d) that the WebAssembly implementation
|
||||||
|
;; doesn't exhibit any known implementation bugs.
|
||||||
|
;;
|
||||||
|
;; This file supplements f32.wast, f64.wast, f32_bitwise.wast, f64_bitwise.wast,
|
||||||
|
;; f32_cmp.wast, and f64_cmp.wast with additional single-instruction tests
|
||||||
|
;; covering additional miscellaneous interesting cases.
|
||||||
|
|
||||||
|
(module
|
||||||
|
(func (export "f32.add") (param $x f32) (param $y f32) (result f32) (f32.add (get_local $x) (get_local $y)))
|
||||||
|
(func (export "f32.sub") (param $x f32) (param $y f32) (result f32) (f32.sub (get_local $x) (get_local $y)))
|
||||||
|
(func (export "f32.mul") (param $x f32) (param $y f32) (result f32) (f32.mul (get_local $x) (get_local $y)))
|
||||||
|
(func (export "f32.div") (param $x f32) (param $y f32) (result f32) (f32.div (get_local $x) (get_local $y)))
|
||||||
|
(func (export "f32.sqrt") (param $x f32) (result f32) (f32.sqrt (get_local $x)))
|
||||||
|
(func (export "f32.abs") (param $x f32) (result f32) (f32.abs (get_local $x)))
|
||||||
|
(func (export "f32.neg") (param $x f32) (result f32) (f32.neg (get_local $x)))
|
||||||
|
(func (export "f32.copysign") (param $x f32) (param $y f32) (result f32) (f32.copysign (get_local $x) (get_local $y)))
|
||||||
|
(func (export "f32.ceil") (param $x f32) (result f32) (f32.ceil (get_local $x)))
|
||||||
|
(func (export "f32.floor") (param $x f32) (result f32) (f32.floor (get_local $x)))
|
||||||
|
(func (export "f32.trunc") (param $x f32) (result f32) (f32.trunc (get_local $x)))
|
||||||
|
(func (export "f32.nearest") (param $x f32) (result f32) (f32.nearest (get_local $x)))
|
||||||
|
(func (export "f32.min") (param $x f32) (param $y f32) (result f32) (f32.min (get_local $x) (get_local $y)))
|
||||||
|
(func (export "f32.max") (param $x f32) (param $y f32) (result f32) (f32.max (get_local $x) (get_local $y)))
|
||||||
|
|
||||||
|
(func (export "f64.add") (param $x f64) (param $y f64) (result f64) (f64.add (get_local $x) (get_local $y)))
|
||||||
|
(func (export "f64.sub") (param $x f64) (param $y f64) (result f64) (f64.sub (get_local $x) (get_local $y)))
|
||||||
|
(func (export "f64.mul") (param $x f64) (param $y f64) (result f64) (f64.mul (get_local $x) (get_local $y)))
|
||||||
|
(func (export "f64.div") (param $x f64) (param $y f64) (result f64) (f64.div (get_local $x) (get_local $y)))
|
||||||
|
(func (export "f64.sqrt") (param $x f64) (result f64) (f64.sqrt (get_local $x)))
|
||||||
|
(func (export "f64.abs") (param $x f64) (result f64) (f64.abs (get_local $x)))
|
||||||
|
(func (export "f64.neg") (param $x f64) (result f64) (f64.neg (get_local $x)))
|
||||||
|
(func (export "f64.copysign") (param $x f64) (param $y f64) (result f64) (f64.copysign (get_local $x) (get_local $y)))
|
||||||
|
(func (export "f64.ceil") (param $x f64) (result f64) (f64.ceil (get_local $x)))
|
||||||
|
(func (export "f64.floor") (param $x f64) (result f64) (f64.floor (get_local $x)))
|
||||||
|
(func (export "f64.trunc") (param $x f64) (result f64) (f64.trunc (get_local $x)))
|
||||||
|
(func (export "f64.nearest") (param $x f64) (result f64) (f64.nearest (get_local $x)))
|
||||||
|
(func (export "f64.min") (param $x f64) (param $y f64) (result f64) (f64.min (get_local $x) (get_local $y)))
|
||||||
|
(func (export "f64.max") (param $x f64) (param $y f64) (result f64) (f64.max (get_local $x) (get_local $y)))
|
||||||
|
)
|
||||||
|
|
||||||
|
;; Miscellaneous values.
|
||||||
|
(assert_return (invoke "f32.add" (f32.const 1.1234567890) (f32.const 1.2345e-10)) (f32.const 1.123456789))
|
||||||
|
(assert_return (invoke "f64.add" (f64.const 1.1234567890) (f64.const 1.2345e-10)) (f64.const 0x1.1f9add37c11f7p+0))
|
||||||
|
|
||||||
|
;; Test adding the greatest value to 1.0 that rounds back to 1.0, and the
|
||||||
|
;; least that rounds to something greater.
|
||||||
|
(assert_return (invoke "f32.add" (f32.const 1.0) (f32.const 0x1p-24)) (f32.const 0x1.0p+0))
|
||||||
|
(assert_return (invoke "f32.add" (f32.const 1.0) (f32.const 0x1.000002p-24)) (f32.const 0x1.000002p+0))
|
||||||
|
(assert_return (invoke "f64.add" (f64.const 1.0) (f64.const 0x1p-53)) (f64.const 0x1.0p+0))
|
||||||
|
(assert_return (invoke "f64.add" (f64.const 1.0) (f64.const 0x1.0000000000001p-53)) (f64.const 0x1.0000000000001p+0))
|
||||||
|
|
||||||
|
;; Max subnormal + min subnormal = min normal.
|
||||||
|
(assert_return (invoke "f32.add" (f32.const 0x1p-149) (f32.const 0x1.fffffcp-127)) (f32.const 0x1p-126))
|
||||||
|
(assert_return (invoke "f64.add" (f64.const 0x0.0000000000001p-1022) (f64.const 0x0.fffffffffffffp-1022)) (f64.const 0x1p-1022))
|
||||||
|
|
||||||
|
;; Test for a case of double rounding, example from:
|
||||||
|
;; http://perso.ens-lyon.fr/jean-michel.muller/Handbook.html
|
||||||
|
;; section 3.3.1: A typical problem: "double rounding"
|
||||||
|
(assert_return (invoke "f32.add" (f32.const 0x1p+31) (f32.const 1024.25)) (f32.const 0x1.000008p+31))
|
||||||
|
(assert_return (invoke "f64.add" (f64.const 0x1p+63) (f64.const 1024.25)) (f64.const 0x1.0000000000001p+63))
|
||||||
|
|
||||||
|
;; Test a case that was "tricky" on MMIX.
|
||||||
|
;; http://mmix.cs.hm.edu/bugs/bug_rounding.html
|
||||||
|
(assert_return (invoke "f64.add" (f64.const -0x1p-1008) (f64.const 0x0.0000000001716p-1022)) (f64.const -0x1.fffffffffffffp-1009))
|
||||||
|
|
||||||
|
;; http://www.vinc17.org/software/tst-ieee754.xsl
|
||||||
|
(assert_return (invoke "f64.add" (f64.const 9007199254740992) (f64.const 1.00001)) (f64.const 9007199254740994))
|
||||||
|
|
||||||
|
;; http://www.vinc17.org/software/test.java
|
||||||
|
(assert_return (invoke "f64.add" (f64.const 9007199254740994) (f64.const 0x1.fffep-1)) (f64.const 9007199254740994))
|
||||||
|
|
||||||
|
;; Computations that round differently in ties-to-odd mode.
|
||||||
|
(assert_return (invoke "f32.add" (f32.const 0x1p23) (f32.const 0x1p-1)) (f32.const 0x1p23))
|
||||||
|
(assert_return (invoke "f32.add" (f32.const 0x1.000002p+23) (f32.const 0x1p-1)) (f32.const 0x1.000004p+23))
|
||||||
|
(assert_return (invoke "f64.add" (f64.const 0x1p52) (f64.const 0x1p-1)) (f64.const 0x1p52))
|
||||||
|
(assert_return (invoke "f64.add" (f64.const 0x1.0000000000001p+52) (f64.const 0x1p-1)) (f64.const 0x1.0000000000002p+52))
|
||||||
|
|
||||||
|
;; Computations that round differently in round-upward mode.
|
||||||
|
(assert_return (invoke "f32.add" (f32.const -0x1.39675ap+102) (f32.const 0x1.76c94cp-99)) (f32.const -0x1.39675ap+102))
|
||||||
|
(assert_return (invoke "f32.add" (f32.const 0x1.6c0f24p+67) (f32.const -0x1.2b92dp+52)) (f32.const 0x1.6c0cccp+67))
|
||||||
|
(assert_return (invoke "f32.add" (f32.const 0x1.e62318p-83) (f32.const 0x1.f74abep-125)) (f32.const 0x1.e62318p-83))
|
||||||
|
(assert_return (invoke "f32.add" (f32.const 0x1.2a71d4p+39) (f32.const -0x1.c9f10cp+55)) (f32.const -0x1.c9efe2p+55))
|
||||||
|
(assert_return (invoke "f32.add" (f32.const 0x1.f8f736p-15) (f32.const 0x1.7bd45ep+106)) (f32.const 0x1.7bd45ep+106))
|
||||||
|
(assert_return (invoke "f64.add" (f64.const 0x1.f33e1fbca27aap-413) (f64.const -0x1.6b192891ed61p+249)) (f64.const -0x1.6b192891ed61p+249))
|
||||||
|
(assert_return (invoke "f64.add" (f64.const -0x1.46f75d130eeb1p+76) (f64.const 0x1.25275d6f7a4acp-184)) (f64.const -0x1.46f75d130eeb1p+76))
|
||||||
|
(assert_return (invoke "f64.add" (f64.const 0x1.04dec9265a731p-148) (f64.const -0x1.11eed4e8c127cp-12)) (f64.const -0x1.11eed4e8c127cp-12))
|
||||||
|
(assert_return (invoke "f64.add" (f64.const 0x1.05773b7166b0ap+497) (f64.const 0x1.134022f2da37bp+66)) (f64.const 0x1.05773b7166b0ap+497))
|
||||||
|
(assert_return (invoke "f64.add" (f64.const 0x1.ef4f794282a82p+321) (f64.const 0x1.14a82266badep+394)) (f64.const 0x1.14a82266badep+394))
|
||||||
|
|
||||||
|
;; Computations that round differently in round-downward mode.
|
||||||
|
(assert_return (invoke "f32.add" (f32.const 0x1.1bf976p+72) (f32.const -0x1.7f5868p+20)) (f32.const 0x1.1bf976p+72))
|
||||||
|
(assert_return (invoke "f32.add" (f32.const 0x1.7f9c6cp-45) (f32.const -0x1.b9bb0ep-78)) (f32.const 0x1.7f9c6cp-45))
|
||||||
|
(assert_return (invoke "f32.add" (f32.const -0x1.32d1bcp-42) (f32.const 0x1.f7d214p+125)) (f32.const 0x1.f7d214p+125))
|
||||||
|
(assert_return (invoke "f32.add" (f32.const -0x1.8e5c0ep-44) (f32.const -0x1.3afa4cp-106)) (f32.const -0x1.8e5c0ep-44))
|
||||||
|
(assert_return (invoke "f32.add" (f32.const 0x1.13cd78p-10) (f32.const -0x1.3af316p-107)) (f32.const 0x1.13cd78p-10))
|
||||||
|
(assert_return (invoke "f64.add" (f64.const 0x1.f8dd15ca97d4ap+179) (f64.const -0x1.367317d1fe8bfp-527)) (f64.const 0x1.f8dd15ca97d4ap+179))
|
||||||
|
(assert_return (invoke "f64.add" (f64.const 0x1.5db08d739228cp+155) (f64.const -0x1.fb316fa147dcbp-61)) (f64.const 0x1.5db08d739228cp+155))
|
||||||
|
(assert_return (invoke "f64.add" (f64.const 0x1.bbb403cb85c07p-404) (f64.const -0x1.7e44046b8bbf3p-979)) (f64.const 0x1.bbb403cb85c07p-404))
|
||||||
|
(assert_return (invoke "f64.add" (f64.const -0x1.34d38af291831p+147) (f64.const -0x1.9890b47439953p+139)) (f64.const -0x1.366c1ba705bcap+147))
|
||||||
|
(assert_return (invoke "f64.add" (f64.const -0x1.b61dedf4e0306p+3) (f64.const 0x1.09e2f31773c4ap+290)) (f64.const 0x1.09e2f31773c4ap+290))
|
||||||
|
|
||||||
|
;; Computations that round differently in round-toward-zero mode.
|
||||||
|
(assert_return (invoke "f32.add" (f32.const -0x1.129bd8p-117) (f32.const 0x1.c75012p-43)) (f32.const 0x1.c75012p-43))
|
||||||
|
(assert_return (invoke "f32.add" (f32.const -0x1.c204a2p-16) (f32.const 0x1.80b132p-27)) (f32.const -0x1.c1d48cp-16))
|
||||||
|
(assert_return (invoke "f32.add" (f32.const -0x1.decc1cp+36) (f32.const 0x1.c688dap-109)) (f32.const -0x1.decc1cp+36))
|
||||||
|
(assert_return (invoke "f32.add" (f32.const 0x1.61ce6ap-118) (f32.const -0x1.772892p+30)) (f32.const -0x1.772892p+30))
|
||||||
|
(assert_return (invoke "f32.add" (f32.const -0x1.3dc826p-120) (f32.const 0x1.fc3f66p+95)) (f32.const 0x1.fc3f66p+95))
|
||||||
|
(assert_return (invoke "f64.add" (f64.const 0x1.bf68acc263a0fp-777) (f64.const -0x1.5f9352965e5a6p+1004)) (f64.const -0x1.5f9352965e5a6p+1004))
|
||||||
|
(assert_return (invoke "f64.add" (f64.const -0x1.76eaa70911f51p+516) (f64.const -0x1.2d746324ce47ap+493)) (f64.const -0x1.76eaa963fabb6p+516))
|
||||||
|
(assert_return (invoke "f64.add" (f64.const -0x1.b637d82c15a7ap-967) (f64.const 0x1.cc654ccab4152p-283)) (f64.const 0x1.cc654ccab4152p-283))
|
||||||
|
(assert_return (invoke "f64.add" (f64.const -0x1.a5b1fb66e846ep-509) (f64.const 0x1.4bdd36f0bb5ccp-860)) (f64.const -0x1.a5b1fb66e846ep-509))
|
||||||
|
(assert_return (invoke "f64.add" (f64.const -0x1.14108da880f9ep+966) (f64.const 0x1.417f35701e89fp+800)) (f64.const -0x1.14108da880f9ep+966))
|
||||||
|
|
||||||
|
;; Computations that round differently on x87.
|
||||||
|
(assert_return (invoke "f64.add" (f64.const -0x1.fa0caf21ffebcp+804) (f64.const 0x1.4ca8fdcff89f9p+826)) (f64.const 0x1.4ca8f5e7c5e31p+826))
|
||||||
|
(assert_return (invoke "f64.add" (f64.const 0x1.016f1fcbdfd38p+784) (f64.const 0x1.375dffcbc9a2cp+746)) (f64.const 0x1.016f1fcbe4b0fp+784))
|
||||||
|
(assert_return (invoke "f64.add" (f64.const -0x1.dffda6d5bff3ap+624) (f64.const 0x1.f9e8cc2dff782p+674)) (f64.const 0x1.f9e8cc2dff77bp+674))
|
||||||
|
(assert_return (invoke "f64.add" (f64.const 0x1.fff4b43687dfbp+463) (f64.const 0x1.0fd5617c4a809p+517)) (f64.const 0x1.0fd5617c4a809p+517))
|
||||||
|
(assert_return (invoke "f64.add" (f64.const 0x1.535d380035da2p-995) (f64.const 0x1.cce37dddbb73bp-963)) (f64.const 0x1.cce37ddf0ed0fp-963))
|
||||||
|
|
||||||
|
;; Computations that round differently when computed via f32.
|
||||||
|
(assert_return (invoke "f64.add" (f64.const -0x1.d91cd3fc0c66fp+752) (f64.const -0x1.4e18c80229734p+952)) (f64.const -0x1.4e18c80229734p+952))
|
||||||
|
(assert_return (invoke "f64.add" (f64.const 0x1.afc70fd36e372p+193) (f64.const -0x1.bd10a9b377b46p+273)) (f64.const -0x1.bd10a9b377b46p+273))
|
||||||
|
(assert_return (invoke "f64.add" (f64.const -0x1.2abd570b078b2p+302) (f64.const 0x1.b3c1ad759cb5bp-423)) (f64.const -0x1.2abd570b078b2p+302))
|
||||||
|
(assert_return (invoke "f64.add" (f64.const -0x1.5b2ae84c0686cp-317) (f64.const -0x1.dba7a1c022823p+466)) (f64.const -0x1.dba7a1c022823p+466))
|
||||||
|
(assert_return (invoke "f64.add" (f64.const -0x1.ac627bd7cbf38p-198) (f64.const 0x1.2312e265b8d59p-990)) (f64.const -0x1.ac627bd7cbf38p-198))
|
||||||
|
|
||||||
|
;; Computations that utilize the maximum exponent value to avoid overflow.
|
||||||
|
(assert_return (invoke "f32.add" (f32.const 0x1.2b91ap+116) (f32.const 0x1.cbcd52p+127)) (f32.const 0x1.cbf2c4p+127))
|
||||||
|
(assert_return (invoke "f32.add" (f32.const 0x1.96f392p+127) (f32.const -0x1.6b3fecp+107)) (f32.const 0x1.96f37cp+127))
|
||||||
|
(assert_return (invoke "f32.add" (f32.const 0x1.132f1cp+118) (f32.const -0x1.63d632p+127)) (f32.const -0x1.634c9ap+127))
|
||||||
|
(assert_return (invoke "f32.add" (f32.const -0x1.1dda64p+120) (f32.const -0x1.ef02ep+127)) (f32.const -0x1.f13e94p+127))
|
||||||
|
(assert_return (invoke "f32.add" (f32.const -0x1.4ad8dap+127) (f32.const -0x1.eae082p+125)) (f32.const -0x1.c590fap+127))
|
||||||
|
(assert_return (invoke "f64.add" (f64.const 0x1.017099f2a4b8bp+1023) (f64.const 0x1.1f63b28f05454p+981)) (f64.const 0x1.017099f2a5009p+1023))
|
||||||
|
(assert_return (invoke "f64.add" (f64.const 0x1.d88b6c74984efp+1023) (f64.const 0x1.33b444775eabcp+990)) (f64.const 0x1.d88b6c7532291p+1023))
|
||||||
|
(assert_return (invoke "f64.add" (f64.const -0x1.84576422fdf5p+1023) (f64.const 0x1.60ee6aa12fb9cp+1012)) (f64.const -0x1.842b4655a9cf1p+1023))
|
||||||
|
(assert_return (invoke "f64.add" (f64.const -0x1.9aaace3e79f7dp+1001) (f64.const 0x1.e4068af295cb6p+1023)) (f64.const 0x1.e4068487ea926p+1023))
|
||||||
|
(assert_return (invoke "f64.add" (f64.const 0x1.06cdae79f27b9p+1023) (f64.const -0x1.e05cb0c96f975p+991)) (f64.const 0x1.06cdae78121eep+1023))
|
||||||
|
|
||||||
|
;; Computations that utilize the minimum exponent value.
|
||||||
|
(assert_return (invoke "f32.add" (f32.const 0x1.6a1a2p-127) (f32.const 0x1.378p-140)) (f32.const 0x1.6a23dcp-127))
|
||||||
|
(assert_return (invoke "f32.add" (f32.const 0x1.28p-144) (f32.const -0x1p-148)) (f32.const 0x1.18p-144))
|
||||||
|
(assert_return (invoke "f32.add" (f32.const -0x1p-146) (f32.const 0x1.c3cap-128)) (f32.const 0x1.c3c9cp-128))
|
||||||
|
(assert_return (invoke "f32.add" (f32.const -0x1.4p-145) (f32.const 0x1.424052p-122)) (f32.const 0x1.42405p-122))
|
||||||
|
(assert_return (invoke "f32.add" (f32.const 0x1.c5p-141) (f32.const -0x1.72f8p-135)) (f32.const -0x1.6be4p-135))
|
||||||
|
(assert_return (invoke "f64.add" (f64.const 0x1.4774c681d1e21p-1022) (f64.const -0x1.271e58e9f58cap-1021)) (f64.const -0x1.06c7eb5219373p-1022))
|
||||||
|
(assert_return (invoke "f64.add" (f64.const 0x1.10b3a75e31916p-1021) (f64.const -0x1.ffb82b0e868a7p-1021)) (f64.const -0x1.de090760a9f22p-1022))
|
||||||
|
(assert_return (invoke "f64.add" (f64.const -0x0.6b58448b8098ap-1022) (f64.const -0x1.579796ed04cbep-1022)) (f64.const -0x1.c2efdb7885648p-1022))
|
||||||
|
(assert_return (invoke "f64.add" (f64.const 0x1.9eb9e7baae8d1p-1020) (f64.const -0x1.d58e136f8c6eep-1020)) (f64.const -0x0.db50aed377874p-1022))
|
||||||
|
(assert_return (invoke "f64.add" (f64.const -0x1.f1115deeafa0bp-1022) (f64.const 0x1.221b1c87dca29p-1022)) (f64.const -0x0.cef64166d2fe2p-1022))
|
||||||
|
|
||||||
|
;; Test an add of the second-greatest finite value with the distance to greatest
|
||||||
|
;; finite value.
|
||||||
|
(assert_return (invoke "f32.add" (f32.const 0x1.fffffcp+127) (f32.const 0x1p+104)) (f32.const 0x1.fffffep+127))
|
||||||
|
(assert_return (invoke "f64.add" (f64.const 0x1.ffffffffffffep+1023) (f64.const 0x1p+971)) (f64.const 0x1.fffffffffffffp+1023))
|
||||||
|
|
||||||
|
;; http://news.harvard.edu/gazette/story/2013/09/dawn-of-a-revolution/
|
||||||
|
(assert_return (invoke "f32.add" (f32.const 2.0) (f32.const 2.0)) (f32.const 4.0))
|
||||||
|
(assert_return (invoke "f64.add" (f64.const 2.0) (f64.const 2.0)) (f64.const 4.0))
|
||||||
|
|
||||||
|
;; Test rounding above the greatest finite value.
|
||||||
|
(assert_return (invoke "f32.add" (f32.const 0x1.fffffep+127) (f32.const 0x1.fffffep+102)) (f32.const 0x1.fffffep+127))
|
||||||
|
(assert_return (invoke "f32.add" (f32.const 0x1.fffffep+127) (f32.const 0x1p+103)) (f32.const inf))
|
||||||
|
(assert_return (invoke "f64.add" (f64.const 0x1.fffffffffffffp+1023) (f64.const 0x1.fffffffffffffp+969)) (f64.const 0x1.fffffffffffffp+1023))
|
||||||
|
(assert_return (invoke "f64.add" (f64.const 0x1.fffffffffffffp+1023) (f64.const 0x1p+970)) (f64.const inf))
|
||||||
|
|
||||||
|
;; Test for a historic spreadsheet bug.
|
||||||
|
;; https://blogs.office.com/2007/09/25/calculation-issue-update/
|
||||||
|
(assert_return (invoke "f32.sub" (f32.const 65536.0) (f32.const 0x1p-37)) (f32.const 65536.0))
|
||||||
|
(assert_return (invoke "f64.sub" (f64.const 65536.0) (f64.const 0x1p-37)) (f64.const 0x1.fffffffffffffp+15))
|
||||||
|
|
||||||
|
;; Test subtracting the greatest value from 1.0 that rounds back to 1.0, and the
|
||||||
|
;; least that rounds to something less.
|
||||||
|
(assert_return (invoke "f32.sub" (f32.const 1.0) (f32.const 0x1p-25)) (f32.const 0x1.0p+0))
|
||||||
|
(assert_return (invoke "f32.sub" (f32.const 1.0) (f32.const 0x1.000002p-25)) (f32.const 0x1.fffffep-1))
|
||||||
|
(assert_return (invoke "f64.sub" (f64.const 1.0) (f64.const 0x1p-54)) (f64.const 0x1.0p+0))
|
||||||
|
(assert_return (invoke "f64.sub" (f64.const 1.0) (f64.const 0x1.0000000000001p-54)) (f64.const 0x1.fffffffffffffp-1))
|
||||||
|
|
||||||
|
;; Computations that round differently in round-upward mode.
|
||||||
|
(assert_return (invoke "f32.sub" (f32.const 0x1.ee2466p-106) (f32.const -0x1.16277ep+119)) (f32.const 0x1.16277ep+119))
|
||||||
|
(assert_return (invoke "f32.sub" (f32.const -0x1.446f9ep+119) (f32.const -0x1.4396a4p+43)) (f32.const -0x1.446f9ep+119))
|
||||||
|
(assert_return (invoke "f32.sub" (f32.const 0x1.74773cp+0) (f32.const -0x1.a25512p-82)) (f32.const 0x1.74773cp+0))
|
||||||
|
(assert_return (invoke "f32.sub" (f32.const 0x1.9345c4p-117) (f32.const 0x1.6792c2p-76)) (f32.const -0x1.6792c2p-76))
|
||||||
|
(assert_return (invoke "f32.sub" (f32.const 0x1.9ecfa4p-18) (f32.const -0x1.864b44p-107)) (f32.const 0x1.9ecfa4p-18))
|
||||||
|
(assert_return (invoke "f64.sub" (f64.const -0x1.5b798875e7845p-333) (f64.const -0x1.b5147117452fep-903)) (f64.const -0x1.5b798875e7845p-333))
|
||||||
|
(assert_return (invoke "f64.sub" (f64.const -0x1.6c87baeb6d72dp+552) (f64.const -0x1.64fb35d4b5571p-158)) (f64.const -0x1.6c87baeb6d72dp+552))
|
||||||
|
(assert_return (invoke "f64.sub" (f64.const 0x1.b3d369fcf74bp-461) (f64.const -0x1.ea1668c0dec93p-837)) (f64.const 0x1.b3d369fcf74bp-461))
|
||||||
|
(assert_return (invoke "f64.sub" (f64.const 0x1.0abd449353eadp-1005) (f64.const -0x1.0422ea3e82ee9p+154)) (f64.const 0x1.0422ea3e82ee9p+154))
|
||||||
|
(assert_return (invoke "f64.sub" (f64.const -0x1.aadbc6b43cc3dp-143) (f64.const -0x1.e7f922ef1ee58p-539)) (f64.const -0x1.aadbc6b43cc3dp-143))
|
||||||
|
|
||||||
|
;; Computations that round differently in round-downward mode.
|
||||||
|
(assert_return (invoke "f32.sub" (f32.const -0x1.61e262p+108) (f32.const -0x1.baf3e4p+112)) (f32.const 0x1.a4d5bep+112))
|
||||||
|
(assert_return (invoke "f32.sub" (f32.const -0x1.62c2f6p+109) (f32.const 0x1.6e514ap+6)) (f32.const -0x1.62c2f6p+109))
|
||||||
|
(assert_return (invoke "f32.sub" (f32.const -0x1.287c94p-83) (f32.const 0x1.0f2f9cp-24)) (f32.const -0x1.0f2f9cp-24))
|
||||||
|
(assert_return (invoke "f32.sub" (f32.const -0x1.c8825cp-77) (f32.const -0x1.4aead6p-12)) (f32.const 0x1.4aead6p-12))
|
||||||
|
(assert_return (invoke "f32.sub" (f32.const -0x1.2976a4p+99) (f32.const 0x1.c6e3b8p-59)) (f32.const -0x1.2976a4p+99))
|
||||||
|
(assert_return (invoke "f64.sub" (f64.const -0x1.76cb28ae6c045p+202) (f64.const -0x1.0611f2af4e9b9p+901)) (f64.const 0x1.0611f2af4e9b9p+901))
|
||||||
|
(assert_return (invoke "f64.sub" (f64.const 0x1.baf35eff22e9ep-368) (f64.const 0x1.5c3e08ecf73ecp-451)) (f64.const 0x1.baf35eff22e9ep-368))
|
||||||
|
(assert_return (invoke "f64.sub" (f64.const -0x1.8fd354b376f1fp-200) (f64.const 0x1.513c860f386ffp-508)) (f64.const -0x1.8fd354b376f1fp-200))
|
||||||
|
(assert_return (invoke "f64.sub" (f64.const -0x1.760d447230ae6p-992) (f64.const -0x1.16f788438ae3ep-328)) (f64.const 0x1.16f788438ae3ep-328))
|
||||||
|
(assert_return (invoke "f64.sub" (f64.const -0x1.73aab4fcfc7ap+112) (f64.const 0x1.7c589f990b884p+171)) (f64.const -0x1.7c589f990b884p+171))
|
||||||
|
|
||||||
|
;; Computations that round differently in round-toward-zero mode.
|
||||||
|
(assert_return (invoke "f32.sub" (f32.const 0x1.ea264cp+95) (f32.const 0x1.852988p-15)) (f32.const 0x1.ea264cp+95))
|
||||||
|
(assert_return (invoke "f32.sub" (f32.const -0x1.14ec7cp+19) (f32.const -0x1.0ad3fep-35)) (f32.const -0x1.14ec7cp+19))
|
||||||
|
(assert_return (invoke "f32.sub" (f32.const -0x1.3251dap-36) (f32.const -0x1.49c97ep-56)) (f32.const -0x1.3251c6p-36))
|
||||||
|
(assert_return (invoke "f32.sub" (f32.const -0x1.13565ep-14) (f32.const 0x1.2f89a8p-13)) (f32.const -0x1.b934d8p-13))
|
||||||
|
(assert_return (invoke "f32.sub" (f32.const -0x1.6032b6p-33) (f32.const -0x1.bb5196p-104)) (f32.const -0x1.6032b6p-33))
|
||||||
|
(assert_return (invoke "f64.sub" (f64.const -0x1.b5b0797af491p-157) (f64.const -0x1.694b8348189e8p+722)) (f64.const 0x1.694b8348189e8p+722))
|
||||||
|
(assert_return (invoke "f64.sub" (f64.const -0x1.72b142826ed73p+759) (f64.const -0x1.010477bc9afbdp+903)) (f64.const 0x1.010477bc9afbdp+903))
|
||||||
|
(assert_return (invoke "f64.sub" (f64.const 0x1.83273b6bb94cfp-796) (f64.const 0x1.1a93f948a2abbp+181)) (f64.const -0x1.1a93f948a2abbp+181))
|
||||||
|
(assert_return (invoke "f64.sub" (f64.const -0x1.207e7156cbf2p-573) (f64.const 0x1.cf3f12fd3814dp-544)) (f64.const -0x1.cf3f13063c086p-544))
|
||||||
|
(assert_return (invoke "f64.sub" (f64.const -0x1.837e6844f1718p-559) (f64.const -0x1.1c29b757f98abp-14)) (f64.const 0x1.1c29b757f98abp-14))
|
||||||
|
|
||||||
|
;; Computations that round differently on x87.
|
||||||
|
(assert_return (invoke "f64.sub" (f64.const 0x1.c21151a709b6cp-78) (f64.const 0x1.0a12fff8910f6p-115)) (f64.const 0x1.c21151a701663p-78))
|
||||||
|
(assert_return (invoke "f64.sub" (f64.const 0x1.c57912aae2f64p-982) (f64.const 0x1.dbfbd4800b7cfp-1010)) (f64.const 0x1.c579128d2338fp-982))
|
||||||
|
(assert_return (invoke "f64.sub" (f64.const 0x1.ffef4399af9c6p-254) (f64.const 0x1.edb96dfaea8b1p-200)) (f64.const -0x1.edb96dfaea8b1p-200))
|
||||||
|
(assert_return (invoke "f64.sub" (f64.const -0x1.363eee391cde2p-39) (f64.const -0x1.a65462000265fp-69)) (f64.const -0x1.363eee32838c9p-39))
|
||||||
|
(assert_return (invoke "f64.sub" (f64.const 0x1.59016dba002a1p-25) (f64.const 0x1.5d4374f124cccp-3)) (f64.const -0x1.5d436f8d1f15dp-3))
|
||||||
|
|
||||||
|
;; Computations that round differently when computed via f32.
|
||||||
|
(assert_return (invoke "f64.sub" (f64.const -0x1.18196bca005cfp-814) (f64.const -0x1.db7b01ce3f52fp-766)) (f64.const 0x1.db7b01ce3f51dp-766))
|
||||||
|
(assert_return (invoke "f64.sub" (f64.const -0x1.d17b3528d219p+33) (f64.const 0x1.fd739d4ea220ap+367)) (f64.const -0x1.fd739d4ea220ap+367))
|
||||||
|
(assert_return (invoke "f64.sub" (f64.const 0x1.dea46994de319p+114) (f64.const 0x1.b5b19cd55c7d3p-590)) (f64.const 0x1.dea46994de319p+114))
|
||||||
|
(assert_return (invoke "f64.sub" (f64.const 0x1.b60f9b2fbd9ecp-489) (f64.const -0x1.6f81c59ec5b8ep-694)) (f64.const 0x1.b60f9b2fbd9ecp-489))
|
||||||
|
(assert_return (invoke "f64.sub" (f64.const 0x1.5e423fe8571f4p-57) (f64.const 0x1.9624ed7c162dfp-618)) (f64.const 0x1.5e423fe8571f4p-57))
|
||||||
|
|
||||||
|
;; pow(e, π) - π
|
||||||
|
;; https://xkcd.com/217
|
||||||
|
(assert_return (invoke "f32.sub" (f32.const 0x1.724046p+4) (f32.const 0x1.921fb6p+1)) (f32.const 0x1.3ffc5p+4))
|
||||||
|
(assert_return (invoke "f64.sub" (f64.const 0x1.724046eb0933ap+4) (f64.const 0x1.921fb54442d18p+1)) (f64.const 0x1.3ffc504280d97p+4))
|
||||||
|
|
||||||
|
;; https://www.cnet.com/news/googles-calculator-muffs-some-math-problems/
|
||||||
|
(assert_return (invoke "f32.sub" (f32.const 2999999) (f32.const 2999998)) (f32.const 1.0))
|
||||||
|
(assert_return (invoke "f32.sub" (f32.const 1999999) (f32.const 1999995)) (f32.const 4.0))
|
||||||
|
(assert_return (invoke "f32.sub" (f32.const 1999999) (f32.const 1999993)) (f32.const 6.0))
|
||||||
|
(assert_return (invoke "f32.sub" (f32.const 400002) (f32.const 400001)) (f32.const 1.0))
|
||||||
|
(assert_return (invoke "f32.sub" (f32.const 400002) (f32.const 400000)) (f32.const 2.0))
|
||||||
|
(assert_return (invoke "f64.sub" (f64.const 2999999999999999) (f64.const 2999999999999998)) (f64.const 1.0))
|
||||||
|
(assert_return (invoke "f64.sub" (f64.const 1999999999999999) (f64.const 1999999999999995)) (f64.const 4.0))
|
||||||
|
(assert_return (invoke "f64.sub" (f64.const 1999999999999999) (f64.const 1999999999999993)) (f64.const 6.0))
|
||||||
|
(assert_return (invoke "f64.sub" (f64.const 400000000000002) (f64.const 400000000000001)) (f64.const 1.0))
|
||||||
|
(assert_return (invoke "f64.sub" (f64.const 400000000000002) (f64.const 400000000000000)) (f64.const 2.0))
|
||||||
|
|
||||||
|
;; Min normal - max subnormal = min subnormal.
|
||||||
|
(assert_return (invoke "f32.sub" (f32.const 0x1p-126) (f32.const 0x1.fffffcp-127)) (f32.const 0x1p-149))
|
||||||
|
(assert_return (invoke "f64.sub" (f64.const 0x1p-1022) (f64.const 0x0.fffffffffffffp-1022)) (f64.const 0x0.0000000000001p-1022))
|
||||||
|
|
||||||
|
;; Test subtraction of numbers very close to 1.
|
||||||
|
(assert_return (invoke "f32.sub" (f32.const 0x1.000002p+0) (f32.const 0x1.fffffep-1)) (f32.const 0x1.8p-23))
|
||||||
|
(assert_return (invoke "f32.sub" (f32.const 0x1.000002p+0) (f32.const 0x1.0p+0)) (f32.const 0x1p-23))
|
||||||
|
(assert_return (invoke "f32.sub" (f32.const 0x1p+0) (f32.const 0x1.fffffep-1)) (f32.const 0x1p-24))
|
||||||
|
(assert_return (invoke "f64.sub" (f64.const 0x1.0000000000001p+0) (f64.const 0x1.fffffffffffffp-1)) (f64.const 0x1.8p-52))
|
||||||
|
(assert_return (invoke "f64.sub" (f64.const 0x1.0000000000001p+0) (f64.const 0x1.0p+0)) (f64.const 0x1p-52))
|
||||||
|
(assert_return (invoke "f64.sub" (f64.const 0x1p+0) (f64.const 0x1.fffffffffffffp-1)) (f64.const 0x1p-53))
|
||||||
|
|
||||||
|
;; Test the least value that can be subtracted from the max value to produce a
|
||||||
|
;; different value.
|
||||||
|
(assert_return (invoke "f32.sub" (f32.const 0x1.fffffep+127) (f32.const 0x1.fffffep+102)) (f32.const 0x1.fffffep+127))
|
||||||
|
(assert_return (invoke "f32.sub" (f32.const 0x1.fffffep+127) (f32.const 0x1p+103)) (f32.const 0x1.fffffcp+127))
|
||||||
|
(assert_return (invoke "f64.sub" (f64.const 0x1.fffffffffffffp+1023) (f64.const 0x1.fffffffffffffp+969)) (f64.const 0x1.fffffffffffffp+1023))
|
||||||
|
(assert_return (invoke "f64.sub" (f64.const 0x1.fffffffffffffp+1023) (f64.const 0x1p+970)) (f64.const 0x1.ffffffffffffep+1023))
|
||||||
|
|
||||||
|
;; Miscellaneous values.
|
||||||
|
(assert_return (invoke "f32.mul" (f32.const 1e15) (f32.const 1e15)) (f32.const 0x1.93e592p+99))
|
||||||
|
(assert_return (invoke "f32.mul" (f32.const 1e20) (f32.const 1e20)) (f32.const inf))
|
||||||
|
(assert_return (invoke "f32.mul" (f32.const 1e25) (f32.const 1e25)) (f32.const inf))
|
||||||
|
(assert_return (invoke "f64.mul" (f64.const 1e15) (f64.const 1e15)) (f64.const 0x1.93e5939a08ceap+99))
|
||||||
|
(assert_return (invoke "f64.mul" (f64.const 1e20) (f64.const 1e20)) (f64.const 0x1.d6329f1c35ca5p+132))
|
||||||
|
(assert_return (invoke "f64.mul" (f64.const 1e25) (f64.const 1e25)) (f64.const 0x1.11b0ec57e649bp+166))
|
||||||
|
|
||||||
|
;; Test for a case of double rounding, example from:
|
||||||
|
;; http://perso.ens-lyon.fr/jean-michel.muller/Handbook.html
|
||||||
|
;; section 3.3.1: A typical problem: "double rounding"
|
||||||
|
(assert_return (invoke "f32.mul" (f32.const 1848874880.0) (f32.const 19954563072.0)) (f32.const 0x1.000002p+65))
|
||||||
|
(assert_return (invoke "f64.mul" (f64.const 1848874847.0) (f64.const 19954562207.0)) (f64.const 3.6893488147419111424e+19))
|
||||||
|
|
||||||
|
;; Test for a historic spreadsheet bug.
|
||||||
|
;; http://www.joelonsoftware.com/items/2007/09/26b.html
|
||||||
|
(assert_return (invoke "f32.mul" (f32.const 77.1) (f32.const 850)) (f32.const 65535))
|
||||||
|
(assert_return (invoke "f64.mul" (f64.const 77.1) (f64.const 850)) (f64.const 65534.99999999999272404))
|
||||||
|
|
||||||
|
;; Computations that round differently in round-upward mode.
|
||||||
|
(assert_return (invoke "f32.mul" (f32.const -0x1.14df2ep+61) (f32.const 0x1.748878p-36)) (f32.const -0x1.92e7e8p+25))
|
||||||
|
(assert_return (invoke "f32.mul" (f32.const -0x1.5629e2p+102) (f32.const -0x1.c33012p-102)) (f32.const 0x1.2d8604p+1))
|
||||||
|
(assert_return (invoke "f32.mul" (f32.const -0x1.b17694p+92) (f32.const -0x1.e4b56ap-97)) (f32.const 0x1.9a5baep-4))
|
||||||
|
(assert_return (invoke "f32.mul" (f32.const -0x1.1626a6p+79) (f32.const -0x1.c57d7p-75)) (f32.const 0x1.ecbaaep+4))
|
||||||
|
(assert_return (invoke "f32.mul" (f32.const 0x1.7acf72p+53) (f32.const 0x1.6c89acp+5)) (f32.const 0x1.0db556p+59))
|
||||||
|
(assert_return (invoke "f64.mul" (f64.const -0x1.25c293f6f37e4p+425) (f64.const 0x1.f5fd4fa41c6d8p+945)) (f64.const -inf))
|
||||||
|
(assert_return (invoke "f64.mul" (f64.const -0x1.cc1ae79fffc5bp-986) (f64.const -0x1.c36ccc2861ca6p-219)) (f64.const 0x0p+0))
|
||||||
|
(assert_return (invoke "f64.mul" (f64.const 0x1.c0232b3e64b56p+606) (f64.const -0x1.f6939cf3affaap+106)) (f64.const -0x1.b7e3aedf190d3p+713))
|
||||||
|
(assert_return (invoke "f64.mul" (f64.const -0x1.60f289966b271p-313) (f64.const 0x1.28a5497f0c259p+583)) (f64.const -0x1.98fc50bcec259p+270))
|
||||||
|
(assert_return (invoke "f64.mul" (f64.const 0x1.37dab12d3afa2p+795) (f64.const 0x1.81e156bd393f1p-858)) (f64.const 0x1.d6126554b8298p-63))
|
||||||
|
|
||||||
|
;; Computations that round differently in round-downward mode.
|
||||||
|
(assert_return (invoke "f32.mul" (f32.const -0x1.3f57a2p-89) (f32.const -0x1.041d68p+92)) (f32.const 0x1.4479bp+3))
|
||||||
|
(assert_return (invoke "f32.mul" (f32.const 0x1.4d0582p+73) (f32.const 0x1.6e043ap+19)) (f32.const 0x1.dc236p+92))
|
||||||
|
(assert_return (invoke "f32.mul" (f32.const -0x1.2fdap-32) (f32.const -0x1.e1731cp+74)) (f32.const 0x1.1db89ep+43))
|
||||||
|
(assert_return (invoke "f32.mul" (f32.const 0x1.7bc8fep+67) (f32.const -0x1.3ad592p+15)) (f32.const -0x1.d3115ep+82))
|
||||||
|
(assert_return (invoke "f32.mul" (f32.const 0x1.936742p+30) (f32.const -0x1.a7a19p+66)) (f32.const -0x1.4dc71ap+97))
|
||||||
|
(assert_return (invoke "f64.mul" (f64.const -0x1.ba737b4ca3b13p-639) (f64.const 0x1.8923309857438p-314)) (f64.const -0x1.53bc0d07baa37p-952))
|
||||||
|
(assert_return (invoke "f64.mul" (f64.const 0x1.7c1932e610219p-276) (f64.const -0x1.2605db646489fp-635)) (f64.const -0x1.b48da2b0d2ae3p-911))
|
||||||
|
(assert_return (invoke "f64.mul" (f64.const -0x1.e43cdf3b2108p+329) (f64.const -0x1.99d96abbd61d1p+835)) (f64.const inf))
|
||||||
|
(assert_return (invoke "f64.mul" (f64.const 0x1.4c19466551da3p+947) (f64.const 0x1.0bdcd6c7646e9p-439)) (f64.const 0x1.5b7cd8c3f638ap+508))
|
||||||
|
(assert_return (invoke "f64.mul" (f64.const 0x1.ff1da1726e3dfp+339) (f64.const -0x1.043c44f52b158p+169)) (f64.const -0x1.03c9364bb585cp+509))
|
||||||
|
|
||||||
|
;; Computations that round differently in round-toward-zero mode.
|
||||||
|
(assert_return (invoke "f32.mul" (f32.const -0x1.907e8ap+46) (f32.const -0x1.5d3668p+95)) (f32.const inf))
|
||||||
|
(assert_return (invoke "f32.mul" (f32.const -0x1.8c9f74p-3) (f32.const 0x1.e2b452p-99)) (f32.const -0x1.75edccp-101))
|
||||||
|
(assert_return (invoke "f32.mul" (f32.const -0x1.cc605ap-19) (f32.const 0x1.ec321ap+105)) (f32.const -0x1.ba91a4p+87))
|
||||||
|
(assert_return (invoke "f32.mul" (f32.const -0x1.5fbb7ap+56) (f32.const 0x1.a8965ep-96)) (f32.const -0x1.23ae8ep-39))
|
||||||
|
(assert_return (invoke "f32.mul" (f32.const -0x1.fb7f12p+16) (f32.const 0x1.3a701ap-119)) (f32.const -0x1.37ac0cp-102))
|
||||||
|
(assert_return (invoke "f64.mul" (f64.const -0x1.5b0266454c26bp-496) (f64.const -0x1.af5787e3e0399p+433)) (f64.const 0x1.2457d81949e0bp-62))
|
||||||
|
(assert_return (invoke "f64.mul" (f64.const 0x1.0d54a82393d45p+478) (f64.const -0x1.425760807ceaep-764)) (f64.const -0x1.532068c8d0d5dp-286))
|
||||||
|
(assert_return (invoke "f64.mul" (f64.const -0x1.b532af981786p+172) (f64.const 0x1.ada95085ba36fp+359)) (f64.const -0x1.6ee38c1e01864p+532))
|
||||||
|
(assert_return (invoke "f64.mul" (f64.const 0x1.e132f4d49d1cep+768) (f64.const -0x1.a75afe9a7d864p+374)) (f64.const -inf))
|
||||||
|
(assert_return (invoke "f64.mul" (f64.const 0x1.68bbf1cfff90ap+81) (f64.const 0x1.09cd17d652c5p+70)) (f64.const 0x1.768b8d67d794p+151))
|
||||||
|
|
||||||
|
;; Computations that round differently on x87.
|
||||||
|
(assert_return (invoke "f64.mul" (f64.const 0x1.f99fb602c89b7p-341) (f64.const 0x1.6caab46a31a2ep-575)) (f64.const 0x1.68201f986e9d7p-915))
|
||||||
|
(assert_return (invoke "f64.mul" (f64.const -0x1.86999c5eee379p-9) (f64.const 0x1.6e3b9e0d53e0dp+723)) (f64.const -0x1.17654a0ef35f5p+715))
|
||||||
|
(assert_return (invoke "f64.mul" (f64.const -0x1.069571b176f9p+367) (f64.const -0x1.e248b6ab0a0e3p-652)) (f64.const 0x1.eeaff575cae1dp-285))
|
||||||
|
(assert_return (invoke "f64.mul" (f64.const 0x1.c217645777dd2p+775) (f64.const 0x1.d93f5715dd646p+60)) (f64.const 0x1.a0064aa1d920dp+836))
|
||||||
|
(assert_return (invoke "f64.mul" (f64.const -0x1.848981b6e694ap-276) (f64.const 0x1.f5aacb64a0d19p+896)) (f64.const -0x1.7cb2296e6c2e5p+621))
|
||||||
|
|
||||||
|
;; Computations that round differently on x87 in double-precision mode.
|
||||||
|
(assert_return (invoke "f64.mul" (f64.const 0x1.db3bd2a286944p-599) (f64.const 0x1.ce910af1d55cap-425)) (f64.const 0x0.d6accdd538a39p-1022))
|
||||||
|
(assert_return (invoke "f64.mul" (f64.const -0x1.aca223916012p-57) (f64.const -0x1.2b2b4958dd228p-966)) (f64.const 0x0.fa74eccae5615p-1022))
|
||||||
|
(assert_return (invoke "f64.mul" (f64.const -0x1.bd062def16cffp-488) (f64.const -0x1.7ddd91a0c4c0ep-536)) (f64.const 0x0.a5f4d7769d90dp-1022))
|
||||||
|
(assert_return (invoke "f64.mul" (f64.const -0x1.c6a56169e9cep-772) (f64.const 0x1.517d55a474122p-255)) (f64.const -0x0.12baf260afb77p-1022))
|
||||||
|
(assert_return (invoke "f64.mul" (f64.const -0x1.08951b0b41705p-516) (f64.const -0x1.102dc27168d09p-507)) (f64.const 0x0.8ca6dbf3f592bp-1022))
|
||||||
|
|
||||||
|
;; Computations that round differently when computed via f32.
|
||||||
|
(assert_return (invoke "f64.mul" (f64.const 0x1.8d0dea50c8c9bp+852) (f64.const 0x1.21cac31d87a24p-881)) (f64.const 0x1.c177311f7cd73p-29))
|
||||||
|
(assert_return (invoke "f64.mul" (f64.const 0x1.98049118e3063p-7) (f64.const 0x1.6362525151b58p-149)) (f64.const 0x1.1b358514103f9p-155))
|
||||||
|
(assert_return (invoke "f64.mul" (f64.const -0x1.ea65cb0631323p+1) (f64.const 0x1.fce683201a19bp-41)) (f64.const -0x1.e76dc8c223667p-39))
|
||||||
|
(assert_return (invoke "f64.mul" (f64.const 0x1.e4d235961d543p-373) (f64.const 0x1.bc56f20ef9a48p-205)) (f64.const 0x1.a4c09efcb71d6p-577))
|
||||||
|
(assert_return (invoke "f64.mul" (f64.const -0x1.b9612e66faba8p+77) (f64.const 0x1.e2bc6aa782273p-348)) (f64.const -0x1.a026ea4f81db1p-270))
|
||||||
|
|
||||||
|
;; Test the least positive value with a positive square.
|
||||||
|
(assert_return (invoke "f32.mul" (f32.const 0x1p-75) (f32.const 0x1p-75)) (f32.const 0x0p+0))
|
||||||
|
(assert_return (invoke "f32.mul" (f32.const 0x1.000002p-75) (f32.const 0x1.000002p-75)) (f32.const 0x1p-149))
|
||||||
|
(assert_return (invoke "f64.mul" (f64.const 0x1.6a09e667f3bccp-538) (f64.const 0x1.6a09e667f3bccp-538)) (f64.const 0x0p+0))
|
||||||
|
(assert_return (invoke "f64.mul" (f64.const 0x1.6a09e667f3bcdp-538) (f64.const 0x1.6a09e667f3bcdp-538)) (f64.const 0x0.0000000000001p-1022))
|
||||||
|
|
||||||
|
;; Test the greatest positive value with a finite square.
|
||||||
|
(assert_return (invoke "f32.mul" (f32.const 0x1.fffffep+63) (f32.const 0x1.fffffep+63)) (f32.const 0x1.fffffcp+127))
|
||||||
|
(assert_return (invoke "f32.mul" (f32.const 0x1p+64) (f32.const 0x1p+64)) (f32.const inf))
|
||||||
|
(assert_return (invoke "f64.mul" (f64.const 0x1.fffffffffffffp+511) (f64.const 0x1.fffffffffffffp+511)) (f64.const 0x1.ffffffffffffep+1023))
|
||||||
|
(assert_return (invoke "f64.mul" (f64.const 0x1p+512) (f64.const 0x1p+512)) (f64.const inf))
|
||||||
|
|
||||||
|
;; Test the squares of values very close to 1.
|
||||||
|
(assert_return (invoke "f32.mul" (f32.const 0x1.000002p+0) (f32.const 0x1.000002p+0)) (f32.const 0x1.000004p+0))
|
||||||
|
(assert_return (invoke "f32.mul" (f32.const 0x1.fffffep-1) (f32.const 0x1.fffffep-1)) (f32.const 0x1.fffffcp-1))
|
||||||
|
(assert_return (invoke "f64.mul" (f64.const 0x1.0000000000001p+0) (f64.const 0x1.0000000000001p+0)) (f64.const 0x1.0000000000002p+0))
|
||||||
|
(assert_return (invoke "f64.mul" (f64.const 0x1.fffffffffffffp-1) (f64.const 0x1.fffffffffffffp-1)) (f64.const 0x1.ffffffffffffep-1))
|
||||||
|
|
||||||
|
;; Test multiplication of numbers very close to 1.
|
||||||
|
(assert_return (invoke "f32.mul" (f32.const 0x1.000002p+0) (f32.const 0x1.fffffep-1)) (f32.const 0x1p+0))
|
||||||
|
(assert_return (invoke "f32.mul" (f32.const 0x1.000004p+0) (f32.const 0x1.fffffcp-1)) (f32.const 0x1.000002p+0))
|
||||||
|
(assert_return (invoke "f64.mul" (f64.const 0x1.0000000000001p+0) (f64.const 0x1.fffffffffffffp-1)) (f64.const 0x1p+0))
|
||||||
|
(assert_return (invoke "f64.mul" (f64.const 0x1.0000000000002p+0) (f64.const 0x1.ffffffffffffep-1)) (f64.const 0x1.0000000000001p+0))
|
||||||
|
|
||||||
|
;; Test MIN * EPSILON.
|
||||||
|
;; http://www.mpfr.org/mpfr-2.0.1/patch2
|
||||||
|
(assert_return (invoke "f32.mul" (f32.const 0x1p-126) (f32.const 0x1p-23)) (f32.const 0x1p-149))
|
||||||
|
(assert_return (invoke "f64.mul" (f64.const 0x1p-1022) (f64.const 0x1p-52)) (f64.const 0x0.0000000000001p-1022))
|
||||||
|
|
||||||
|
;; http://opencores.org/bug,view,2454
|
||||||
|
(assert_return (invoke "f32.mul" (f32.const -0x1.0006p+4) (f32.const 0x1.ap-132)) (f32.const -0x1.a009cp-128))
|
||||||
|
|
||||||
|
;; Miscellaneous values.
|
||||||
|
(assert_return (invoke "f32.div" (f32.const 1.123456789) (f32.const 100)) (f32.const 0x1.702264p-7))
|
||||||
|
(assert_return (invoke "f32.div" (f32.const 8391667.0) (f32.const 12582905.0)) (f32.const 0x1.55754p-1))
|
||||||
|
(assert_return (invoke "f32.div" (f32.const 65536.0) (f32.const 0x1p-37)) (f32.const 0x1p+53))
|
||||||
|
(assert_return (invoke "f32.div" (f32.const 0x1.dcbf6ap+0) (f32.const 0x1.fffffep+127)) (f32.const 0x1.dcbf68p-128))
|
||||||
|
(assert_return (invoke "f32.div" (f32.const 4) (f32.const 3)) (f32.const 0x1.555556p+0))
|
||||||
|
(assert_return (invoke "f64.div" (f64.const 1.123456789) (f64.const 100)) (f64.const 0.01123456789))
|
||||||
|
(assert_return (invoke "f64.div" (f64.const 8391667.0) (f64.const 12582905.0)) (f64.const 0x1.55753f1d9ba27p-1))
|
||||||
|
(assert_return (invoke "f64.div" (f64.const 65536.0) (f64.const 0x1p-37)) (f64.const 0x1p+53))
|
||||||
|
(assert_return (invoke "f64.div" (f64.const 0x1.dcbf6ap+0) (f64.const 0x1.fffffffffffffp+1023)) (f64.const 0x0.772fda8p-1022))
|
||||||
|
(assert_return (invoke "f64.div" (f64.const 4) (f64.const 3)) (f64.const 0x1.5555555555555p+0))
|
||||||
|
|
||||||
|
;; Test for a historic hardware bug.
|
||||||
|
;; https://en.wikipedia.org/wiki/Pentium_FDIV_bug
|
||||||
|
(assert_return (invoke "f32.div" (f32.const 4195835) (f32.const 3145727)) (f32.const 0x1.557542p+0))
|
||||||
|
(assert_return (invoke "f64.div" (f64.const 4195835) (f64.const 3145727)) (f64.const 0x1.557541c7c6b43p+0))
|
||||||
|
|
||||||
|
;; Computations that round differently in round-upward mode.
|
||||||
|
(assert_return (invoke "f32.div" (f32.const 0x1.6a6c5ap-48) (f32.const 0x1.fa0b7p+127)) (f32.const 0x0p+0))
|
||||||
|
(assert_return (invoke "f32.div" (f32.const 0x1.616fb2p-87) (f32.const 0x1.332172p+68)) (f32.const 0x0p+0))
|
||||||
|
(assert_return (invoke "f32.div" (f32.const -0x1.96e778p+16) (f32.const 0x1.eb0c56p-80)) (f32.const -0x1.a8440ap+95))
|
||||||
|
(assert_return (invoke "f32.div" (f32.const -0x1.e2624p-76) (f32.const -0x1.ed236ep-122)) (f32.const 0x1.f4d584p+45))
|
||||||
|
(assert_return (invoke "f32.div" (f32.const -0x1.e2374ep+41) (f32.const 0x1.71fcdcp-80)) (f32.const -0x1.4da706p+121))
|
||||||
|
(assert_return (invoke "f64.div" (f64.const 0x1.163c09d0c38c1p+147) (f64.const 0x1.e04cc737348e6p+223)) (f64.const 0x1.289921caeed23p-77))
|
||||||
|
(assert_return (invoke "f64.div" (f64.const 0x1.d6867e741e0a9p-626) (f64.const 0x1.335eb19a9aae4p-972)) (f64.const 0x1.87e342d11f519p+346))
|
||||||
|
(assert_return (invoke "f64.div" (f64.const -0x1.d5edf648aeb98p+298) (f64.const 0x1.0dda15b079355p+640)) (f64.const -0x1.bdceaf9734b5cp-342))
|
||||||
|
(assert_return (invoke "f64.div" (f64.const -0x1.b683e3934aedap+691) (f64.const 0x1.c364e1df00dffp+246)) (f64.const -0x1.f16456e7afe3bp+444))
|
||||||
|
(assert_return (invoke "f64.div" (f64.const -0x1.44ca7539cc851p+540) (f64.const 0x1.58501bccc58fep+453)) (f64.const -0x1.e2f8657e0924ep+86))
|
||||||
|
|
||||||
|
;; Computations that round differently in round-downward mode.
|
||||||
|
(assert_return (invoke "f32.div" (f32.const -0x1.c2c54ap+69) (f32.const -0x1.00d142p-86)) (f32.const inf))
|
||||||
|
(assert_return (invoke "f32.div" (f32.const 0x1.e35abep-46) (f32.const 0x1.c69dfp+44)) (f32.const 0x1.102eb4p-90))
|
||||||
|
(assert_return (invoke "f32.div" (f32.const 0x1.45ff2ap+0) (f32.const -0x1.1e8754p+89)) (f32.const -0x1.23434ep-89))
|
||||||
|
(assert_return (invoke "f32.div" (f32.const 0x1.8db18ap-51) (f32.const 0x1.47c678p-128)) (f32.const 0x1.369b96p+77))
|
||||||
|
(assert_return (invoke "f32.div" (f32.const 0x1.78599p+90) (f32.const 0x1.534144p+87)) (f32.const 0x1.1bfddcp+3))
|
||||||
|
(assert_return (invoke "f64.div" (f64.const 0x0.f331c4f47eb51p-1022) (f64.const -0x1.c7ff45bf6f03ap+362)) (f64.const -0x0p+0))
|
||||||
|
(assert_return (invoke "f64.div" (f64.const -0x1.0fc8707b9d19cp-987) (f64.const 0x1.77524d5f4a563p-536)) (f64.const -0x1.72c1a937d231p-452))
|
||||||
|
(assert_return (invoke "f64.div" (f64.const -0x1.edb3aa64bb338p-403) (f64.const -0x1.1c7c164320e4p+45)) (f64.const 0x1.bc44cc1c5ae63p-448))
|
||||||
|
(assert_return (invoke "f64.div" (f64.const -0x1.6534b34e8686bp+80) (f64.const 0x1.c34a7fc59e3c3p-791)) (f64.const -0x1.95421bf291b66p+870))
|
||||||
|
(assert_return (invoke "f64.div" (f64.const -0x1.91f58d7ed1237p+236) (f64.const -0x1.f190d808383c8p+55)) (f64.const 0x1.9d9eb0836f906p+180))
|
||||||
|
|
||||||
|
;; Computations that round differently in round-toward-zero mode.
|
||||||
|
(assert_return (invoke "f32.div" (f32.const 0x1.64b2a4p+26) (f32.const 0x1.e95752p-119)) (f32.const inf))
|
||||||
|
(assert_return (invoke "f32.div" (f32.const -0x1.53c9b6p+77) (f32.const 0x1.d689ap+27)) (f32.const -0x1.71baa4p+49))
|
||||||
|
(assert_return (invoke "f32.div" (f32.const 0x1.664a8ap+38) (f32.const -0x1.59dba2p+96)) (f32.const -0x1.0933f4p-58))
|
||||||
|
(assert_return (invoke "f32.div" (f32.const -0x1.99e0fap+111) (f32.const -0x1.c2b5a8p+9)) (f32.const 0x1.d19de6p+101))
|
||||||
|
(assert_return (invoke "f32.div" (f32.const -0x1.5a815ap+92) (f32.const -0x1.b5820ap+13)) (f32.const 0x1.9580b8p+78))
|
||||||
|
(assert_return (invoke "f64.div" (f64.const -0x1.81fd1e2af7bebp-655) (f64.const 0x1.edefc4eae536cp-691)) (f64.const -0x1.901abdd91b661p+35))
|
||||||
|
(assert_return (invoke "f64.div" (f64.const -0x1.47cf932953c43p+782) (f64.const -0x1.bc40496b1f2a1p-553)) (f64.const inf))
|
||||||
|
(assert_return (invoke "f64.div" (f64.const -0x1.2bd2e8fbdcad7p-746) (f64.const 0x1.b115674cc476ep-65)) (f64.const -0x1.62752bf19fa81p-682))
|
||||||
|
(assert_return (invoke "f64.div" (f64.const -0x1.f923e3fea9efep+317) (f64.const -0x1.8044c74d27a39p-588)) (f64.const 0x1.5086518cc7186p+905))
|
||||||
|
(assert_return (invoke "f64.div" (f64.const 0x1.516ed2051d6bbp+181) (f64.const -0x1.c9f455eb9c2eep+214)) (f64.const -0x1.79414d67f2889p-34))
|
||||||
|
|
||||||
|
;; Computations that round differently on x87.
|
||||||
|
(assert_return (invoke "f64.div" (f64.const -0x1.9c52726aed366p+585) (f64.const -0x1.7d0568c75660fp+195)) (f64.const 0x1.1507ca2a65f23p+390))
|
||||||
|
(assert_return (invoke "f64.div" (f64.const -0x1.522672f461667p+546) (f64.const -0x1.36d36572c9f71p+330)) (f64.const 0x1.1681369370619p+216))
|
||||||
|
(assert_return (invoke "f64.div" (f64.const 0x1.01051b4e8cd61p+185) (f64.const -0x1.2cbb5ca3d33ebp+965)) (f64.const -0x1.b59471598a2f3p-781))
|
||||||
|
(assert_return (invoke "f64.div" (f64.const 0x1.5f93bb80fc2cbp+217) (f64.const 0x1.7e051aae9f0edp+427)) (f64.const 0x1.d732fa926ba4fp-211))
|
||||||
|
(assert_return (invoke "f64.div" (f64.const -0x1.e251d762163ccp+825) (f64.const 0x1.3ee63581e1796p+349)) (f64.const -0x1.8330077d90a07p+476))
|
||||||
|
|
||||||
|
;; Computations that round differently on x87 in double-precision mode.
|
||||||
|
(assert_return (invoke "f64.div" (f64.const 0x1.dcbf69f10006dp+0) (f64.const 0x1.fffffffffffffp+1023)) (f64.const 0x0.772fda7c4001bp-1022))
|
||||||
|
(assert_return (invoke "f64.div" (f64.const 0x1.e14169442fbcap-1011) (f64.const 0x1.505451d62ff7dp+12)) (f64.const 0x0.b727e85f38b39p-1022))
|
||||||
|
(assert_return (invoke "f64.div" (f64.const -0x1.d3ebe726ec964p-144) (f64.const -0x1.4a7bfc0b83608p+880)) (f64.const 0x0.5a9d8c50cbf87p-1022))
|
||||||
|
(assert_return (invoke "f64.div" (f64.const -0x1.6c3def770aee1p-393) (f64.const -0x1.8b84724347598p+631)) (f64.const 0x0.3af0707fcd0c7p-1022))
|
||||||
|
(assert_return (invoke "f64.div" (f64.const 0x1.16abda1bb3cb3p-856) (f64.const 0x1.6c9c7198eb1e6p+166)) (f64.const 0x0.c3a8fd6741649p-1022))
|
||||||
|
(assert_return (invoke "f64.div" (f64.const 0x1.7057d6ab553cap-1005) (f64.const -0x1.2abf1e98660ebp+23)) (f64.const -0x0.04ee8d8ec01cdp-1022))
|
||||||
|
|
||||||
|
;; Computations that round differently when div is mul by reciprocal.
|
||||||
|
(assert_return (invoke "f32.div" (f32.const 0x1.ada9aap+89) (f32.const 0x1.69884cp+42)) (f32.const 0x1.303e2ep+47))
|
||||||
|
(assert_return (invoke "f32.div" (f32.const 0x1.8281c8p+90) (f32.const -0x1.62883cp+106)) (f32.const -0x1.17169cp-16))
|
||||||
|
(assert_return (invoke "f32.div" (f32.const 0x1.5c6be2p+81) (f32.const 0x1.d01dfep-1)) (f32.const 0x1.805e32p+81))
|
||||||
|
(assert_return (invoke "f32.div" (f32.const -0x1.bbd252p+19) (f32.const -0x1.fba95p+33)) (f32.const 0x1.bf9d56p-15))
|
||||||
|
(assert_return (invoke "f32.div" (f32.const -0x1.0f41d6p-42) (f32.const -0x1.3f2dbep+56)) (f32.const 0x1.b320d8p-99))
|
||||||
|
(assert_return (invoke "f64.div" (f64.const 0x1.b2348a1c81899p+61) (f64.const -0x1.4a58aad903dd3p-861)) (f64.const -0x1.507c1e2a41b35p+922))
|
||||||
|
(assert_return (invoke "f64.div" (f64.const 0x1.23fa5137a918ap-130) (f64.const -0x1.7268db1951263p-521)) (f64.const -0x1.93965e0d896bep+390))
|
||||||
|
(assert_return (invoke "f64.div" (f64.const 0x1.dcb3915d82deep+669) (f64.const 0x1.50caaa1dc6b19p+638)) (f64.const 0x1.6a58ec814b09dp+31))
|
||||||
|
(assert_return (invoke "f64.div" (f64.const -0x1.046e378c0cc46p+182) (f64.const 0x1.ac925009a922bp+773)) (f64.const -0x1.3720aa94dab18p-592))
|
||||||
|
(assert_return (invoke "f64.div" (f64.const -0x1.8945fd69d8e11p-871) (f64.const -0x1.0a37870af809ap-646)) (f64.const 0x1.7a2e286c62382p-225))
|
||||||
|
|
||||||
|
;; Computations that round differently when computed via f32.
|
||||||
|
(assert_return (invoke "f64.div" (f64.const 0x1.82002af0ea1f3p-57) (f64.const 0x1.d0a9b0c2fa339p+0)) (f64.const 0x1.a952fbd1fc17cp-58))
|
||||||
|
(assert_return (invoke "f64.div" (f64.const 0x1.1e12b515db471p-102) (f64.const -0x1.41fc3c94fba5p-42)) (f64.const -0x1.c6e50cccb7cb6p-61))
|
||||||
|
(assert_return (invoke "f64.div" (f64.const 0x1.aba5adcd6f583p-41) (f64.const 0x1.17dfac639ce0fp-112)) (f64.const 0x1.872b0a008c326p+71))
|
||||||
|
(assert_return (invoke "f64.div" (f64.const 0x1.cf82510d0ae6bp+89) (f64.const 0x1.0207d86498053p+97)) (f64.const 0x1.cbdc804e2cf14p-8))
|
||||||
|
(assert_return (invoke "f64.div" (f64.const 0x1.4c82cbb508e21p-11) (f64.const -0x1.6b57208c2d5d5p+52)) (f64.const -0x1.d48e8b369129ap-64))
|
||||||
|
|
||||||
|
;; Division involving the maximum subnormal value and the minimum normal value.
|
||||||
|
(assert_return (invoke "f32.div" (f32.const 0x1p-126) (f32.const 0x1.fffffcp-127)) (f32.const 0x1.000002p+0))
|
||||||
|
(assert_return (invoke "f32.div" (f32.const 0x1.fffffcp-127) (f32.const 0x1p-126)) (f32.const 0x1.fffffcp-1))
|
||||||
|
(assert_return (invoke "f64.div" (f64.const 0x1p-1022) (f64.const 0x0.fffffffffffffp-1022)) (f64.const 0x1.0000000000001p+0))
|
||||||
|
(assert_return (invoke "f64.div" (f64.const 0x0.fffffffffffffp-1022) (f64.const 0x1p-1022)) (f64.const 0x1.ffffffffffffep-1))
|
||||||
|
|
||||||
|
;; Test the least positive value with a positive quotient with the maximum value.
|
||||||
|
(assert_return (invoke "f32.div" (f32.const 0x1.fffffep-23) (f32.const 0x1.fffffep+127)) (f32.const 0x0p+0))
|
||||||
|
(assert_return (invoke "f32.div" (f32.const 0x1p-22) (f32.const 0x1.fffffep+127)) (f32.const 0x1p-149))
|
||||||
|
(assert_return (invoke "f64.div" (f64.const 0x1.fffffffffffffp-52) (f64.const 0x1.fffffffffffffp+1023)) (f64.const 0x0p+0))
|
||||||
|
(assert_return (invoke "f64.div" (f64.const 0x1p-51) (f64.const 0x1.fffffffffffffp+1023)) (f64.const 0x0.0000000000001p-1022))
|
||||||
|
|
||||||
|
;; Test the least positive value with a finite reciprocal.
|
||||||
|
(assert_return (invoke "f32.div" (f32.const 1.0) (f32.const 0x1p-128)) (f32.const inf))
|
||||||
|
(assert_return (invoke "f32.div" (f32.const 1.0) (f32.const 0x1.000008p-128)) (f32.const 0x1.fffffp+127))
|
||||||
|
(assert_return (invoke "f64.div" (f64.const 1.0) (f64.const 0x0.4p-1022)) (f64.const inf))
|
||||||
|
(assert_return (invoke "f64.div" (f64.const 1.0) (f64.const 0x0.4000000000001p-1022)) (f64.const 0x1.ffffffffffff8p+1023))
|
||||||
|
|
||||||
|
;; Test the least positive value that has a subnormal reciprocal.
|
||||||
|
(assert_return (invoke "f32.div" (f32.const 1.0) (f32.const 0x1.000002p+126)) (f32.const 0x1.fffffcp-127))
|
||||||
|
(assert_return (invoke "f32.div" (f32.const 1.0) (f32.const 0x1p+126)) (f32.const 0x1p-126))
|
||||||
|
(assert_return (invoke "f64.div" (f64.const 1.0) (f64.const 0x1.0000000000001p+1022)) (f64.const 0x0.fffffffffffffp-1022))
|
||||||
|
(assert_return (invoke "f64.div" (f64.const 1.0) (f64.const 0x1p+1022)) (f64.const 0x1p-1022))
|
||||||
|
|
||||||
|
;; Test that the last binary digit of 1.0/3.0 is even in f32,
|
||||||
|
;; https://en.wikipedia.org/wiki/Single-precision_floating-point_format#Single-precision_examples
|
||||||
|
;;
|
||||||
|
;; and odd in f64,
|
||||||
|
;; https://en.wikipedia.org/wiki/Double-precision_floating-point_format#Double-precision_examples
|
||||||
|
;;
|
||||||
|
;; and that 1.0/3.0, 3.0/9.0, and 9.0/27.0 all agree.
|
||||||
|
;; http://www.netlib.org/paranoia
|
||||||
|
(assert_return (invoke "f32.div" (f32.const 0x1p+0) (f32.const 0x1.8p+1)) (f32.const 0x1.555556p-2))
|
||||||
|
(assert_return (invoke "f32.div" (f32.const 0x3p+0) (f32.const 0x1.2p+3)) (f32.const 0x1.555556p-2))
|
||||||
|
(assert_return (invoke "f32.div" (f32.const 0x1.2p+3) (f32.const 0x1.bp+4)) (f32.const 0x1.555556p-2))
|
||||||
|
(assert_return (invoke "f64.div" (f64.const 0x1p+0) (f64.const 0x1.8p+1)) (f64.const 0x1.5555555555555p-2))
|
||||||
|
(assert_return (invoke "f64.div" (f64.const 0x3p+0) (f64.const 0x1.2p+3)) (f64.const 0x1.5555555555555p-2))
|
||||||
|
(assert_return (invoke "f64.div" (f64.const 0x1.2p+3) (f64.const 0x1.bp+4)) (f64.const 0x1.5555555555555p-2))
|
||||||
|
|
||||||
|
;; Test division of numbers very close to 1.
|
||||||
|
(assert_return (invoke "f32.div" (f32.const 0x1.000002p+0) (f32.const 0x1.fffffep-1)) (f32.const 0x1.000004p+0))
|
||||||
|
(assert_return (invoke "f32.div" (f32.const 0x1.fffffep-1) (f32.const 0x1.000002p+0)) (f32.const 0x1.fffffap-1))
|
||||||
|
(assert_return (invoke "f32.div" (f32.const 0x1.0p+0) (f32.const 0x1.fffffep-1)) (f32.const 0x1.000002p+0))
|
||||||
|
(assert_return (invoke "f32.div" (f32.const 0x1.0p+0) (f32.const 0x1.000002p+0)) (f32.const 0x1.fffffcp-1))
|
||||||
|
(assert_return (invoke "f64.div" (f64.const 0x1.0000000000001p+0) (f64.const 0x1.fffffffffffffp-1)) (f64.const 0x1.0000000000002p+0))
|
||||||
|
(assert_return (invoke "f64.div" (f64.const 0x1.fffffffffffffp-1) (f64.const 0x1.0000000000001p+0)) (f64.const 0x1.ffffffffffffdp-1))
|
||||||
|
(assert_return (invoke "f64.div" (f64.const 0x1.0p+0) (f64.const 0x1.fffffffffffffp-1)) (f64.const 0x1.0000000000001p+0))
|
||||||
|
(assert_return (invoke "f64.div" (f64.const 0x1.0p+0) (f64.const 0x1.0000000000001p+0)) (f64.const 0x1.ffffffffffffep-1))
|
||||||
|
|
||||||
|
;; Test for bugs found in an early RISC-V implementation.
|
||||||
|
;; https://github.com/riscv/riscv-tests/pull/8
|
||||||
|
(assert_return (invoke "f32.sqrt" (f32.const 0x1.56p+7)) (f32.const 0x1.a2744cp+3))
|
||||||
|
(assert_return (invoke "f32.sqrt" (f32.const 0x1.594dfcp-23)) (f32.const 0x1.a4789cp-12))
|
||||||
|
(assert_return (invoke "f64.sqrt" (f64.const 0x1.56p+7)) (f64.const 0x1.a2744ce9674f5p+3))
|
||||||
|
(assert_return (invoke "f64.sqrt" (f64.const 0x1.594dfc70aa105p-23)) (f64.const 0x1.a4789c0e37f99p-12))
|
||||||
|
|
||||||
|
;; Computations that round differently on x87.
|
||||||
|
(assert_return (invoke "f64.sqrt" (f64.const 0x1.0263fcc94f259p-164)) (f64.const 0x1.0131485de579fp-82))
|
||||||
|
(assert_return (invoke "f64.sqrt" (f64.const 0x1.352dfa278c43dp+338)) (f64.const 0x1.195607dac5417p+169))
|
||||||
|
(assert_return (invoke "f64.sqrt" (f64.const 0x1.b15daa23924fap+402)) (f64.const 0x1.4d143db561493p+201))
|
||||||
|
(assert_return (invoke "f64.sqrt" (f64.const 0x1.518c8e68cb753p-37)) (f64.const 0x1.9fb8ef1ad5bfdp-19))
|
||||||
|
(assert_return (invoke "f64.sqrt" (f64.const 0x1.86d8b6518078ep-370)) (f64.const 0x1.3c5142a48fcadp-185))
|
||||||
|
|
||||||
|
;; Test another sqrt case on x87.
|
||||||
|
;; https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52593
|
||||||
|
(assert_return (invoke "f64.sqrt" (f64.const 0x1.fffffffffffffp-1)) (f64.const 0x1.fffffffffffffp-1))
|
||||||
|
|
||||||
|
;; Computations that round differently in round-upward mode.
|
||||||
|
(assert_return (invoke "f32.sqrt" (f32.const 0x1.098064p-3)) (f32.const 0x1.70b23p-2))
|
||||||
|
(assert_return (invoke "f32.sqrt" (f32.const 0x1.d9befp+100)) (f32.const 0x1.5c4052p+50))
|
||||||
|
(assert_return (invoke "f32.sqrt" (f32.const 0x1.42b5b6p-4)) (f32.const 0x1.1f6d0ep-2))
|
||||||
|
(assert_return (invoke "f32.sqrt" (f32.const 0x1.3684dp-71)) (f32.const 0x1.8ebae2p-36))
|
||||||
|
(assert_return (invoke "f32.sqrt" (f32.const 0x1.d8bc4ep-11)) (f32.const 0x1.ebf9eap-6))
|
||||||
|
(assert_return (invoke "f64.sqrt" (f64.const 0x1.5c39f220d5704p-924)) (f64.const 0x1.2a92bc24ceae9p-462))
|
||||||
|
(assert_return (invoke "f64.sqrt" (f64.const 0x1.53521a635745cp+727)) (f64.const 0x1.a0cfdc4ef8ff1p+363))
|
||||||
|
(assert_return (invoke "f64.sqrt" (f64.const 0x1.dfd5bbc9f4678p+385)) (f64.const 0x1.efa817117c94cp+192))
|
||||||
|
(assert_return (invoke "f64.sqrt" (f64.const 0x1.33f9640811cd4p+105)) (f64.const 0x1.8d17c9243baa3p+52))
|
||||||
|
(assert_return (invoke "f64.sqrt" (f64.const 0x1.6c0ef0267ff45p+999)) (f64.const 0x1.afbcfae3f2b4p+499))
|
||||||
|
|
||||||
|
;; Computations that round differently in round-downward mode.
|
||||||
|
(assert_return (invoke "f32.sqrt" (f32.const 0x1.26a62ep+27)) (f32.const 0x1.84685p+13))
|
||||||
|
(assert_return (invoke "f32.sqrt" (f32.const 0x1.166002p-113)) (f32.const 0x1.798762p-57))
|
||||||
|
(assert_return (invoke "f32.sqrt" (f32.const 0x1.3dfb5p-15)) (f32.const 0x1.937e38p-8))
|
||||||
|
(assert_return (invoke "f32.sqrt" (f32.const 0x1.30eb2cp-120)) (f32.const 0x1.176406p-60))
|
||||||
|
(assert_return (invoke "f32.sqrt" (f32.const 0x1.cb705cp-123)) (f32.const 0x1.e5020ap-62))
|
||||||
|
(assert_return (invoke "f64.sqrt" (f64.const 0x1.edae8aea0543p+695)) (f64.const 0x1.f6c1ea4fc8dd2p+347))
|
||||||
|
(assert_return (invoke "f64.sqrt" (f64.const 0x1.f7ee4bda5c9c3p-763)) (f64.const 0x1.fbf30bdaf11c5p-382))
|
||||||
|
(assert_return (invoke "f64.sqrt" (f64.const 0x1.a48f348266ad1p-30)) (f64.const 0x1.481ee7540baf7p-15))
|
||||||
|
(assert_return (invoke "f64.sqrt" (f64.const 0x1.feb5a1ce3ed9cp-242)) (f64.const 0x1.6995060c20d46p-121))
|
||||||
|
(assert_return (invoke "f64.sqrt" (f64.const 0x1.957d9796e3834p+930)) (f64.const 0x1.42305213157bap+465))
|
||||||
|
|
||||||
|
;; Computations that round differently in round-toward-zero mode.
|
||||||
|
(assert_return (invoke "f32.sqrt" (f32.const 0x1.65787cp+118)) (f32.const 0x1.2e82a4p+59))
|
||||||
|
(assert_return (invoke "f32.sqrt" (f32.const 0x1.736044p+15)) (f32.const 0x1.b40e4p+7))
|
||||||
|
(assert_return (invoke "f32.sqrt" (f32.const 0x1.a00edp-1)) (f32.const 0x1.cd8aecp-1))
|
||||||
|
(assert_return (invoke "f32.sqrt" (f32.const 0x1.7a4c8p-87)) (f32.const 0x1.b819e4p-44))
|
||||||
|
(assert_return (invoke "f32.sqrt" (f32.const 0x1.5d24d4p-94)) (f32.const 0x1.2af75ep-47))
|
||||||
|
(assert_return (invoke "f64.sqrt" (f64.const 0x1.a008948ead274p+738)) (f64.const 0x1.4659b37c39b19p+369))
|
||||||
|
(assert_return (invoke "f64.sqrt" (f64.const 0x1.70f6199ed21f5p-381)) (f64.const 0x1.b2a2bddf3300dp-191))
|
||||||
|
(assert_return (invoke "f64.sqrt" (f64.const 0x1.35c1d49f2a352p+965)) (f64.const 0x1.8e3d9f01a9716p+482))
|
||||||
|
(assert_return (invoke "f64.sqrt" (f64.const 0x1.3fbdcfb2b2a15p-45)) (f64.const 0x1.949ba4feca42ap-23))
|
||||||
|
(assert_return (invoke "f64.sqrt" (f64.const 0x1.c201b94757145p-492)) (f64.const 0x1.5369ee6bf2967p-246))
|
||||||
|
|
||||||
|
;; Computations that round differently when computed via f32.
|
||||||
|
(assert_return_canonical_nan (invoke "f64.sqrt" (f64.const -0x1.360e8d0032adp-963)))
|
||||||
|
(assert_return (invoke "f64.sqrt" (f64.const 0x1.d9a6f5eef0503p+103)) (f64.const 0x1.ec73f56c166f6p+51))
|
||||||
|
(assert_return (invoke "f64.sqrt" (f64.const 0x1.aa051a5c4ec27p-760)) (f64.const 0x1.4a3e771ff5149p-380))
|
||||||
|
(assert_return (invoke "f64.sqrt" (f64.const 0x1.e5522a741babep-276)) (f64.const 0x1.607ae2b6feb7dp-138))
|
||||||
|
(assert_return (invoke "f64.sqrt" (f64.const 0x1.4832badc0c061p+567)) (f64.const 0x1.99ec7934139b2p+283))
|
||||||
|
|
||||||
|
;; Test the least value with a sqrt that rounds to one.
|
||||||
|
(assert_return (invoke "f32.sqrt" (f32.const 0x1.000002p+0)) (f32.const 0x1p+0))
|
||||||
|
(assert_return (invoke "f32.sqrt" (f32.const 0x1.000004p+0)) (f32.const 0x1.000002p+0))
|
||||||
|
(assert_return (invoke "f64.sqrt" (f64.const 0x1.0000000000001p+0)) (f64.const 0x1p+0))
|
||||||
|
(assert_return (invoke "f64.sqrt" (f64.const 0x1.0000000000002p+0)) (f64.const 0x1.0000000000001p+0))
|
||||||
|
|
||||||
|
;; Test the greatest value less than one for which sqrt is not an identity.
|
||||||
|
(assert_return (invoke "f32.sqrt" (f32.const 0x1.fffffcp-1)) (f32.const 0x1.fffffep-1))
|
||||||
|
(assert_return (invoke "f32.sqrt" (f32.const 0x1.fffffap-1)) (f32.const 0x1.fffffcp-1))
|
||||||
|
(assert_return (invoke "f64.sqrt" (f64.const 0x1.ffffffffffffep-1)) (f64.const 0x1.fffffffffffffp-1))
|
||||||
|
(assert_return (invoke "f64.sqrt" (f64.const 0x1.ffffffffffffdp-1)) (f64.const 0x1.ffffffffffffep-1))
|
||||||
|
|
||||||
|
;; Test that the bitwise floating point operators are bitwise on NaN.
|
||||||
|
|
||||||
|
(assert_return (invoke "f32.abs" (f32.const nan:0x0f1e2)) (f32.const nan:0x0f1e2))
|
||||||
|
(assert_return (invoke "f32.abs" (f32.const -nan:0x0f1e2)) (f32.const nan:0x0f1e2))
|
||||||
|
(assert_return (invoke "f64.abs" (f64.const nan:0x0f1e27a6b)) (f64.const nan:0x0f1e27a6b))
|
||||||
|
(assert_return (invoke "f64.abs" (f64.const -nan:0x0f1e27a6b)) (f64.const nan:0x0f1e27a6b))
|
||||||
|
|
||||||
|
(assert_return (invoke "f32.neg" (f32.const nan:0x0f1e2)) (f32.const -nan:0x0f1e2))
|
||||||
|
(assert_return (invoke "f32.neg" (f32.const -nan:0x0f1e2)) (f32.const nan:0x0f1e2))
|
||||||
|
(assert_return (invoke "f64.neg" (f64.const nan:0x0f1e27a6b)) (f64.const -nan:0x0f1e27a6b))
|
||||||
|
(assert_return (invoke "f64.neg" (f64.const -nan:0x0f1e27a6b)) (f64.const nan:0x0f1e27a6b))
|
||||||
|
|
||||||
|
(assert_return (invoke "f32.copysign" (f32.const nan:0x0f1e2) (f32.const nan)) (f32.const nan:0x0f1e2))
|
||||||
|
(assert_return (invoke "f32.copysign" (f32.const nan:0x0f1e2) (f32.const -nan)) (f32.const -nan:0x0f1e2))
|
||||||
|
(assert_return (invoke "f32.copysign" (f32.const -nan:0x0f1e2) (f32.const nan)) (f32.const nan:0x0f1e2))
|
||||||
|
(assert_return (invoke "f32.copysign" (f32.const -nan:0x0f1e2) (f32.const -nan)) (f32.const -nan:0x0f1e2))
|
||||||
|
(assert_return (invoke "f64.copysign" (f64.const nan:0x0f1e27a6b) (f64.const nan)) (f64.const nan:0x0f1e27a6b))
|
||||||
|
(assert_return (invoke "f64.copysign" (f64.const nan:0x0f1e27a6b) (f64.const -nan)) (f64.const -nan:0x0f1e27a6b))
|
||||||
|
(assert_return (invoke "f64.copysign" (f64.const -nan:0x0f1e27a6b) (f64.const nan)) (f64.const nan:0x0f1e27a6b))
|
||||||
|
(assert_return (invoke "f64.copysign" (f64.const -nan:0x0f1e27a6b) (f64.const -nan)) (f64.const -nan:0x0f1e27a6b))
|
||||||
|
|
||||||
|
;; Test values close to 1.0.
|
||||||
|
(assert_return (invoke "f32.ceil" (f32.const 0x1.fffffep-1)) (f32.const 1.0))
|
||||||
|
(assert_return (invoke "f32.ceil" (f32.const 0x1.000002p+0)) (f32.const 2.0))
|
||||||
|
(assert_return (invoke "f64.ceil" (f64.const 0x1.fffffffffffffp-1)) (f64.const 1.0))
|
||||||
|
(assert_return (invoke "f64.ceil" (f64.const 0x1.0000000000001p+0)) (f64.const 2.0))
|
||||||
|
|
||||||
|
;; Test the maximum and minimum value for which ceil is not an identity operator.
|
||||||
|
(assert_return (invoke "f32.ceil" (f32.const 0x1.fffffep+22)) (f32.const 0x1p+23))
|
||||||
|
(assert_return (invoke "f32.ceil" (f32.const -0x1.fffffep+22)) (f32.const -0x1.fffffcp+22))
|
||||||
|
(assert_return (invoke "f64.ceil" (f64.const 0x1.fffffffffffffp+51)) (f64.const 0x1p+52))
|
||||||
|
(assert_return (invoke "f64.ceil" (f64.const -0x1.fffffffffffffp+51)) (f64.const -0x1.ffffffffffffep+51))
|
||||||
|
|
||||||
|
;; Test that implementations don't do the x+0x1p52-0x1p52 trick outside the
|
||||||
|
;; range where it's safe.
|
||||||
|
(assert_return (invoke "f32.ceil" (f32.const 0x1.fffffep+23)) (f32.const 0x1.fffffep+23))
|
||||||
|
(assert_return (invoke "f32.ceil" (f32.const -0x1.fffffep+23)) (f32.const -0x1.fffffep+23))
|
||||||
|
(assert_return (invoke "f64.ceil" (f64.const 0x1.fffffffffffffp+52)) (f64.const 0x1.fffffffffffffp+52))
|
||||||
|
(assert_return (invoke "f64.ceil" (f64.const -0x1.fffffffffffffp+52)) (f64.const -0x1.fffffffffffffp+52))
|
||||||
|
|
||||||
|
;; Test values close to -1.0.
|
||||||
|
(assert_return (invoke "f32.floor" (f32.const -0x1.fffffep-1)) (f32.const -1.0))
|
||||||
|
(assert_return (invoke "f32.floor" (f32.const -0x1.000002p+0)) (f32.const -2.0))
|
||||||
|
(assert_return (invoke "f64.floor" (f64.const -0x1.fffffffffffffp-1)) (f64.const -1.0))
|
||||||
|
(assert_return (invoke "f64.floor" (f64.const -0x1.0000000000001p+0)) (f64.const -2.0))
|
||||||
|
|
||||||
|
;; Test the maximum and minimum value for which floor is not an identity operator.
|
||||||
|
(assert_return (invoke "f32.floor" (f32.const -0x1.fffffep+22)) (f32.const -0x1p+23))
|
||||||
|
(assert_return (invoke "f32.floor" (f32.const 0x1.fffffep+22)) (f32.const 0x1.fffffcp+22))
|
||||||
|
(assert_return (invoke "f64.floor" (f64.const -0x1.fffffffffffffp+51)) (f64.const -0x1p+52))
|
||||||
|
(assert_return (invoke "f64.floor" (f64.const 0x1.fffffffffffffp+51)) (f64.const 0x1.ffffffffffffep+51))
|
||||||
|
|
||||||
|
;; Test that floor isn't implemented as XMVectorFloor.
|
||||||
|
;; http://dss.stephanierct.com/DevBlog/?p=8#comment-4
|
||||||
|
(assert_return (invoke "f32.floor" (f32.const 88607.0)) (f32.const 88607.0))
|
||||||
|
(assert_return (invoke "f64.floor" (f64.const 88607.0)) (f64.const 88607.0))
|
||||||
|
|
||||||
|
;; Test the maximum and minimum value for which trunc is not an identity operator.
|
||||||
|
(assert_return (invoke "f32.trunc" (f32.const -0x1.fffffep+22)) (f32.const -0x1.fffffcp+22))
|
||||||
|
(assert_return (invoke "f32.trunc" (f32.const 0x1.fffffep+22)) (f32.const 0x1.fffffcp+22))
|
||||||
|
(assert_return (invoke "f64.trunc" (f64.const -0x1.fffffffffffffp+51)) (f64.const -0x1.ffffffffffffep+51))
|
||||||
|
(assert_return (invoke "f64.trunc" (f64.const 0x1.fffffffffffffp+51)) (f64.const 0x1.ffffffffffffep+51))
|
||||||
|
|
||||||
|
;; Test that nearest isn't implemented naively.
|
||||||
|
;; http://blog.frama-c.com/index.php?post/2013/05/02/nearbyintf1
|
||||||
|
;; http://blog.frama-c.com/index.php?post/2013/05/04/nearbyintf3
|
||||||
|
(assert_return (invoke "f32.nearest" (f32.const 0x1.000002p+23)) (f32.const 0x1.000002p+23))
|
||||||
|
(assert_return (invoke "f32.nearest" (f32.const 0x1.000004p+23)) (f32.const 0x1.000004p+23))
|
||||||
|
(assert_return (invoke "f32.nearest" (f32.const 0x1.fffffep-2)) (f32.const 0.0))
|
||||||
|
(assert_return (invoke "f32.nearest" (f32.const 0x1.fffffep+47)) (f32.const 0x1.fffffep+47))
|
||||||
|
(assert_return (invoke "f64.nearest" (f64.const 0x1.0000000000001p+52)) (f64.const 0x1.0000000000001p+52))
|
||||||
|
(assert_return (invoke "f64.nearest" (f64.const 0x1.0000000000002p+52)) (f64.const 0x1.0000000000002p+52))
|
||||||
|
(assert_return (invoke "f64.nearest" (f64.const 0x1.fffffffffffffp-2)) (f64.const 0.0))
|
||||||
|
(assert_return (invoke "f64.nearest" (f64.const 0x1.fffffffffffffp+105)) (f64.const 0x1.fffffffffffffp+105))
|
||||||
|
|
||||||
|
;; Nearest should not round halfway cases away from zero (as C's round(3) does)
|
||||||
|
;; or up (as JS's Math.round does).
|
||||||
|
(assert_return (invoke "f32.nearest" (f32.const 4.5)) (f32.const 4.0))
|
||||||
|
(assert_return (invoke "f32.nearest" (f32.const -4.5)) (f32.const -4.0))
|
||||||
|
(assert_return (invoke "f32.nearest" (f32.const -3.5)) (f32.const -4.0))
|
||||||
|
(assert_return (invoke "f64.nearest" (f64.const 4.5)) (f64.const 4.0))
|
||||||
|
(assert_return (invoke "f64.nearest" (f64.const -4.5)) (f64.const -4.0))
|
||||||
|
(assert_return (invoke "f64.nearest" (f64.const -3.5)) (f64.const -4.0))
|
||||||
|
|
||||||
|
;; Test the maximum and minimum value for which nearest is not an identity operator.
|
||||||
|
(assert_return (invoke "f32.nearest" (f32.const -0x1.fffffep+22)) (f32.const -0x1p+23))
|
||||||
|
(assert_return (invoke "f32.nearest" (f32.const 0x1.fffffep+22)) (f32.const 0x1p+23))
|
||||||
|
(assert_return (invoke "f64.nearest" (f64.const -0x1.fffffffffffffp+51)) (f64.const -0x1p+52))
|
||||||
|
(assert_return (invoke "f64.nearest" (f64.const 0x1.fffffffffffffp+51)) (f64.const 0x1p+52))
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
(module
|
||||||
|
(func $even (export "even") (param $n i32) (result i32)
|
||||||
|
(if (result i32) (i32.eq (get_local $n) (i32.const 0))
|
||||||
|
(then (i32.const 1))
|
||||||
|
(else (call $odd (i32.sub (get_local $n) (i32.const 1))))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func $odd (export "odd") (param $n i32) (result i32)
|
||||||
|
(if (result i32) (i32.eq (get_local $n) (i32.const 0))
|
||||||
|
(then (i32.const 0))
|
||||||
|
(else (call $even (i32.sub (get_local $n) (i32.const 1))))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke "even" (i32.const 13)) (i32.const 0))
|
||||||
|
(assert_return (invoke "even" (i32.const 20)) (i32.const 1))
|
||||||
|
(assert_return (invoke "odd" (i32.const 13)) (i32.const 1))
|
||||||
|
(assert_return (invoke "odd" (i32.const 20)) (i32.const 0))
|
||||||
@@ -0,0 +1,661 @@
|
|||||||
|
;; Test `func` declarations, i.e. functions
|
||||||
|
|
||||||
|
(module
|
||||||
|
;; Auxiliary definition
|
||||||
|
(type $sig (func))
|
||||||
|
(func $dummy)
|
||||||
|
|
||||||
|
;; Syntax
|
||||||
|
|
||||||
|
(func)
|
||||||
|
(func (export "f"))
|
||||||
|
(func $f)
|
||||||
|
(func $h (export "g"))
|
||||||
|
|
||||||
|
(func (local))
|
||||||
|
(func (local) (local))
|
||||||
|
(func (local i32))
|
||||||
|
(func (local $x i32))
|
||||||
|
(func (local i32 f64 i64))
|
||||||
|
(func (local i32) (local f64))
|
||||||
|
(func (local i32 f32) (local $x i64) (local) (local i32 f64))
|
||||||
|
|
||||||
|
(func (param))
|
||||||
|
(func (param) (param))
|
||||||
|
(func (param i32))
|
||||||
|
(func (param $x i32))
|
||||||
|
(func (param i32 f64 i64))
|
||||||
|
(func (param i32) (param f64))
|
||||||
|
(func (param i32 f32) (param $x i64) (param) (param i32 f64))
|
||||||
|
|
||||||
|
(func (result i32) (unreachable))
|
||||||
|
|
||||||
|
(type $sig-1 (func))
|
||||||
|
(type $sig-2 (func (result i32)))
|
||||||
|
(type $sig-3 (func (param $x i32)))
|
||||||
|
(type $sig-4 (func (param i32 f64 i32) (result i32)))
|
||||||
|
|
||||||
|
(func (export "type-use-1") (type $sig-1))
|
||||||
|
(func (export "type-use-2") (type $sig-2) (i32.const 0))
|
||||||
|
(func (export "type-use-3") (type $sig-3))
|
||||||
|
(func (export "type-use-4") (type $sig-4) (i32.const 0))
|
||||||
|
(func (export "type-use-5") (type $sig-2) (result i32) (i32.const 0))
|
||||||
|
(func (export "type-use-6") (type $sig-3) (param i32))
|
||||||
|
(func (export "type-use-7")
|
||||||
|
(type $sig-4) (param i32) (param f64 i32) (result i32) (i32.const 0)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (type $sig))
|
||||||
|
(func (type $forward)) ;; forward reference
|
||||||
|
|
||||||
|
(func $complex
|
||||||
|
(param i32 f32) (param $x i64) (param) (param i32)
|
||||||
|
(result) (result i32) (result)
|
||||||
|
(local f32) (local $y i32) (local i64 i32) (local) (local f64 i32)
|
||||||
|
(unreachable) (unreachable)
|
||||||
|
)
|
||||||
|
(func $complex-sig
|
||||||
|
(type $sig)
|
||||||
|
(local f32) (local $y i32) (local i64 i32) (local) (local f64 i32)
|
||||||
|
(unreachable) (unreachable)
|
||||||
|
)
|
||||||
|
|
||||||
|
(type $forward (func))
|
||||||
|
|
||||||
|
;; Typing of locals
|
||||||
|
|
||||||
|
(func (export "local-first-i32") (result i32) (local i32 i32) (get_local 0))
|
||||||
|
(func (export "local-first-i64") (result i64) (local i64 i64) (get_local 0))
|
||||||
|
(func (export "local-first-f32") (result f32) (local f32 f32) (get_local 0))
|
||||||
|
(func (export "local-first-f64") (result f64) (local f64 f64) (get_local 0))
|
||||||
|
(func (export "local-second-i32") (result i32) (local i32 i32) (get_local 1))
|
||||||
|
(func (export "local-second-i64") (result i64) (local i64 i64) (get_local 1))
|
||||||
|
(func (export "local-second-f32") (result f32) (local f32 f32) (get_local 1))
|
||||||
|
(func (export "local-second-f64") (result f64) (local f64 f64) (get_local 1))
|
||||||
|
(func (export "local-mixed") (result f64)
|
||||||
|
(local f32) (local $x i32) (local i64 i32) (local) (local f64 i32)
|
||||||
|
(drop (f32.neg (get_local 0)))
|
||||||
|
(drop (i32.eqz (get_local 1)))
|
||||||
|
(drop (i64.eqz (get_local 2)))
|
||||||
|
(drop (i32.eqz (get_local 3)))
|
||||||
|
(drop (f64.neg (get_local 4)))
|
||||||
|
(drop (i32.eqz (get_local 5)))
|
||||||
|
(get_local 4)
|
||||||
|
)
|
||||||
|
|
||||||
|
;; Typing of parameters
|
||||||
|
|
||||||
|
(func (export "param-first-i32") (param i32 i32) (result i32) (get_local 0))
|
||||||
|
(func (export "param-first-i64") (param i64 i64) (result i64) (get_local 0))
|
||||||
|
(func (export "param-first-f32") (param f32 f32) (result f32) (get_local 0))
|
||||||
|
(func (export "param-first-f64") (param f64 f64) (result f64) (get_local 0))
|
||||||
|
(func (export "param-second-i32") (param i32 i32) (result i32) (get_local 1))
|
||||||
|
(func (export "param-second-i64") (param i64 i64) (result i64) (get_local 1))
|
||||||
|
(func (export "param-second-f32") (param f32 f32) (result f32) (get_local 1))
|
||||||
|
(func (export "param-second-f64") (param f64 f64) (result f64) (get_local 1))
|
||||||
|
(func (export "param-mixed") (param f32 i32) (param) (param $x i64) (param i32 f64 i32)
|
||||||
|
(result f64)
|
||||||
|
(drop (f32.neg (get_local 0)))
|
||||||
|
(drop (i32.eqz (get_local 1)))
|
||||||
|
(drop (i64.eqz (get_local 2)))
|
||||||
|
(drop (i32.eqz (get_local 3)))
|
||||||
|
(drop (f64.neg (get_local 4)))
|
||||||
|
(drop (i32.eqz (get_local 5)))
|
||||||
|
(get_local 4)
|
||||||
|
)
|
||||||
|
|
||||||
|
;; Typing of result
|
||||||
|
|
||||||
|
(func (export "empty"))
|
||||||
|
(func (export "value-void") (call $dummy))
|
||||||
|
(func (export "value-i32") (result i32) (i32.const 77))
|
||||||
|
(func (export "value-i64") (result i64) (i64.const 7777))
|
||||||
|
(func (export "value-f32") (result f32) (f32.const 77.7))
|
||||||
|
(func (export "value-f64") (result f64) (f64.const 77.77))
|
||||||
|
(func (export "value-block-void") (block (call $dummy) (call $dummy)))
|
||||||
|
(func (export "value-block-i32") (result i32)
|
||||||
|
(block (result i32) (call $dummy) (i32.const 77))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "return-empty") (return))
|
||||||
|
(func (export "return-i32") (result i32) (return (i32.const 78)))
|
||||||
|
(func (export "return-i64") (result i64) (return (i64.const 7878)))
|
||||||
|
(func (export "return-f32") (result f32) (return (f32.const 78.7)))
|
||||||
|
(func (export "return-f64") (result f64) (return (f64.const 78.78)))
|
||||||
|
(func (export "return-block-i32") (result i32)
|
||||||
|
(return (block (result i32) (call $dummy) (i32.const 77)))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "break-empty") (br 0))
|
||||||
|
(func (export "break-i32") (result i32) (br 0 (i32.const 79)))
|
||||||
|
(func (export "break-i64") (result i64) (br 0 (i64.const 7979)))
|
||||||
|
(func (export "break-f32") (result f32) (br 0 (f32.const 79.9)))
|
||||||
|
(func (export "break-f64") (result f64) (br 0 (f64.const 79.79)))
|
||||||
|
(func (export "break-block-i32") (result i32)
|
||||||
|
(br 0 (block (result i32) (call $dummy) (i32.const 77)))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "break-br_if-empty") (param i32)
|
||||||
|
(br_if 0 (get_local 0))
|
||||||
|
)
|
||||||
|
(func (export "break-br_if-num") (param i32) (result i32)
|
||||||
|
(drop (br_if 0 (i32.const 50) (get_local 0))) (i32.const 51)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "break-br_table-empty") (param i32)
|
||||||
|
(br_table 0 0 0 (get_local 0))
|
||||||
|
)
|
||||||
|
(func (export "break-br_table-num") (param i32) (result i32)
|
||||||
|
(br_table 0 0 (i32.const 50) (get_local 0)) (i32.const 51)
|
||||||
|
)
|
||||||
|
(func (export "break-br_table-nested-empty") (param i32)
|
||||||
|
(block (br_table 0 1 0 (get_local 0)))
|
||||||
|
)
|
||||||
|
(func (export "break-br_table-nested-num") (param i32) (result i32)
|
||||||
|
(i32.add
|
||||||
|
(block (result i32)
|
||||||
|
(br_table 0 1 0 (i32.const 50) (get_local 0)) (i32.const 51)
|
||||||
|
)
|
||||||
|
(i32.const 2)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
;; Default initialization of locals
|
||||||
|
|
||||||
|
(func (export "init-local-i32") (result i32) (local i32) (get_local 0))
|
||||||
|
(func (export "init-local-i64") (result i64) (local i64) (get_local 0))
|
||||||
|
(func (export "init-local-f32") (result f32) (local f32) (get_local 0))
|
||||||
|
(func (export "init-local-f64") (result f64) (local f64) (get_local 0))
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke "type-use-1"))
|
||||||
|
(assert_return (invoke "type-use-2") (i32.const 0))
|
||||||
|
(assert_return (invoke "type-use-3" (i32.const 1)))
|
||||||
|
(assert_return
|
||||||
|
(invoke "type-use-4" (i32.const 1) (f64.const 1) (i32.const 1))
|
||||||
|
(i32.const 0)
|
||||||
|
)
|
||||||
|
(assert_return (invoke "type-use-5") (i32.const 0))
|
||||||
|
(assert_return (invoke "type-use-6" (i32.const 1)))
|
||||||
|
(assert_return
|
||||||
|
(invoke "type-use-7" (i32.const 1) (f64.const 1) (i32.const 1))
|
||||||
|
(i32.const 0)
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke "local-first-i32") (i32.const 0))
|
||||||
|
(assert_return (invoke "local-first-i64") (i64.const 0))
|
||||||
|
(assert_return (invoke "local-first-f32") (f32.const 0))
|
||||||
|
(assert_return (invoke "local-first-f64") (f64.const 0))
|
||||||
|
(assert_return (invoke "local-second-i32") (i32.const 0))
|
||||||
|
(assert_return (invoke "local-second-i64") (i64.const 0))
|
||||||
|
(assert_return (invoke "local-second-f32") (f32.const 0))
|
||||||
|
(assert_return (invoke "local-second-f64") (f64.const 0))
|
||||||
|
(assert_return (invoke "local-mixed") (f64.const 0))
|
||||||
|
|
||||||
|
(assert_return
|
||||||
|
(invoke "param-first-i32" (i32.const 2) (i32.const 3)) (i32.const 2)
|
||||||
|
)
|
||||||
|
(assert_return
|
||||||
|
(invoke "param-first-i64" (i64.const 2) (i64.const 3)) (i64.const 2)
|
||||||
|
)
|
||||||
|
(assert_return
|
||||||
|
(invoke "param-first-f32" (f32.const 2) (f32.const 3)) (f32.const 2)
|
||||||
|
)
|
||||||
|
(assert_return
|
||||||
|
(invoke "param-first-f64" (f64.const 2) (f64.const 3)) (f64.const 2)
|
||||||
|
)
|
||||||
|
(assert_return
|
||||||
|
(invoke "param-second-i32" (i32.const 2) (i32.const 3)) (i32.const 3)
|
||||||
|
)
|
||||||
|
(assert_return
|
||||||
|
(invoke "param-second-i64" (i64.const 2) (i64.const 3)) (i64.const 3)
|
||||||
|
)
|
||||||
|
(assert_return
|
||||||
|
(invoke "param-second-f32" (f32.const 2) (f32.const 3)) (f32.const 3)
|
||||||
|
)
|
||||||
|
(assert_return
|
||||||
|
(invoke "param-second-f64" (f64.const 2) (f64.const 3)) (f64.const 3)
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return
|
||||||
|
(invoke "param-mixed"
|
||||||
|
(f32.const 1) (i32.const 2) (i64.const 3)
|
||||||
|
(i32.const 4) (f64.const 5.5) (i32.const 6)
|
||||||
|
)
|
||||||
|
(f64.const 5.5)
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke "empty"))
|
||||||
|
(assert_return (invoke "value-void"))
|
||||||
|
(assert_return (invoke "value-i32") (i32.const 77))
|
||||||
|
(assert_return (invoke "value-i64") (i64.const 7777))
|
||||||
|
(assert_return (invoke "value-f32") (f32.const 77.7))
|
||||||
|
(assert_return (invoke "value-f64") (f64.const 77.77))
|
||||||
|
(assert_return (invoke "value-block-void"))
|
||||||
|
(assert_return (invoke "value-block-i32") (i32.const 77))
|
||||||
|
|
||||||
|
(assert_return (invoke "return-empty"))
|
||||||
|
(assert_return (invoke "return-i32") (i32.const 78))
|
||||||
|
(assert_return (invoke "return-i64") (i64.const 7878))
|
||||||
|
(assert_return (invoke "return-f32") (f32.const 78.7))
|
||||||
|
(assert_return (invoke "return-f64") (f64.const 78.78))
|
||||||
|
(assert_return (invoke "return-block-i32") (i32.const 77))
|
||||||
|
|
||||||
|
(assert_return (invoke "break-empty"))
|
||||||
|
(assert_return (invoke "break-i32") (i32.const 79))
|
||||||
|
(assert_return (invoke "break-i64") (i64.const 7979))
|
||||||
|
(assert_return (invoke "break-f32") (f32.const 79.9))
|
||||||
|
(assert_return (invoke "break-f64") (f64.const 79.79))
|
||||||
|
(assert_return (invoke "break-block-i32") (i32.const 77))
|
||||||
|
|
||||||
|
(assert_return (invoke "break-br_if-empty" (i32.const 0)))
|
||||||
|
(assert_return (invoke "break-br_if-empty" (i32.const 2)))
|
||||||
|
(assert_return (invoke "break-br_if-num" (i32.const 0)) (i32.const 51))
|
||||||
|
(assert_return (invoke "break-br_if-num" (i32.const 1)) (i32.const 50))
|
||||||
|
|
||||||
|
(assert_return (invoke "break-br_table-empty" (i32.const 0)))
|
||||||
|
(assert_return (invoke "break-br_table-empty" (i32.const 1)))
|
||||||
|
(assert_return (invoke "break-br_table-empty" (i32.const 5)))
|
||||||
|
(assert_return (invoke "break-br_table-empty" (i32.const -1)))
|
||||||
|
(assert_return (invoke "break-br_table-num" (i32.const 0)) (i32.const 50))
|
||||||
|
(assert_return (invoke "break-br_table-num" (i32.const 1)) (i32.const 50))
|
||||||
|
(assert_return (invoke "break-br_table-num" (i32.const 10)) (i32.const 50))
|
||||||
|
(assert_return (invoke "break-br_table-num" (i32.const -100)) (i32.const 50))
|
||||||
|
(assert_return (invoke "break-br_table-nested-empty" (i32.const 0)))
|
||||||
|
(assert_return (invoke "break-br_table-nested-empty" (i32.const 1)))
|
||||||
|
(assert_return (invoke "break-br_table-nested-empty" (i32.const 3)))
|
||||||
|
(assert_return (invoke "break-br_table-nested-empty" (i32.const -2)))
|
||||||
|
(assert_return
|
||||||
|
(invoke "break-br_table-nested-num" (i32.const 0)) (i32.const 52)
|
||||||
|
)
|
||||||
|
(assert_return
|
||||||
|
(invoke "break-br_table-nested-num" (i32.const 1)) (i32.const 50)
|
||||||
|
)
|
||||||
|
(assert_return
|
||||||
|
(invoke "break-br_table-nested-num" (i32.const 2)) (i32.const 52)
|
||||||
|
)
|
||||||
|
(assert_return
|
||||||
|
(invoke "break-br_table-nested-num" (i32.const -3)) (i32.const 52)
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke "init-local-i32") (i32.const 0))
|
||||||
|
(assert_return (invoke "init-local-i64") (i64.const 0))
|
||||||
|
(assert_return (invoke "init-local-f32") (f32.const 0))
|
||||||
|
(assert_return (invoke "init-local-f64") (f64.const 0))
|
||||||
|
|
||||||
|
|
||||||
|
;; Expansion of inline function types
|
||||||
|
|
||||||
|
(module
|
||||||
|
(func $f (result f64) (f64.const 0)) ;; adds implicit type definition
|
||||||
|
(func $g (param i32)) ;; reuses explicit type definition
|
||||||
|
(type $t (func (param i32)))
|
||||||
|
|
||||||
|
(func $i32->void (type 0)) ;; (param i32)
|
||||||
|
(func $void->f64 (type 1) (f64.const 0)) ;; (result f64)
|
||||||
|
(func $check
|
||||||
|
(call $i32->void (i32.const 0))
|
||||||
|
(drop (call $void->f64))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module
|
||||||
|
(func $f (result f64) (f64.const 0)) ;; adds implicit type definition
|
||||||
|
(func $g (param i32)) ;; reuses explicit type definition
|
||||||
|
(func $h (result f64) (f64.const 1)) ;; reuses implicit type definition
|
||||||
|
(type $t (func (param i32)))
|
||||||
|
|
||||||
|
(func (type 2)) ;; does not exist
|
||||||
|
)
|
||||||
|
"unknown type"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
(module
|
||||||
|
(type $sig (func))
|
||||||
|
|
||||||
|
(func $empty-sig-1) ;; should be assigned type $sig
|
||||||
|
(func $complex-sig-1 (param f64 i64 f64 i64 f64 i64 f32 i32))
|
||||||
|
(func $empty-sig-2) ;; should be assigned type $sig
|
||||||
|
(func $complex-sig-2 (param f64 i64 f64 i64 f64 i64 f32 i32))
|
||||||
|
(func $complex-sig-3 (param f64 i64 f64 i64 f64 i64 f32 i32))
|
||||||
|
(func $complex-sig-4 (param i64 i64 f64 i64 f64 i64 f32 i32))
|
||||||
|
(func $complex-sig-5 (param i64 i64 f64 i64 f64 i64 f32 i32))
|
||||||
|
|
||||||
|
(type $empty-sig-duplicate (func))
|
||||||
|
(type $complex-sig-duplicate (func (param i64 i64 f64 i64 f64 i64 f32 i32)))
|
||||||
|
(table anyfunc
|
||||||
|
(elem
|
||||||
|
$complex-sig-3 $empty-sig-2 $complex-sig-1 $complex-sig-3 $empty-sig-1
|
||||||
|
$complex-sig-4 $complex-sig-5
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "signature-explicit-reused")
|
||||||
|
(call_indirect (type $sig) (i32.const 1))
|
||||||
|
(call_indirect (type $sig) (i32.const 4))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "signature-implicit-reused")
|
||||||
|
;; The implicit index 3 in this test depends on the function and
|
||||||
|
;; type definitions, and may need adapting if they change.
|
||||||
|
(call_indirect (type 3)
|
||||||
|
(f64.const 0) (i64.const 0) (f64.const 0) (i64.const 0)
|
||||||
|
(f64.const 0) (i64.const 0) (f32.const 0) (i32.const 0)
|
||||||
|
(i32.const 0)
|
||||||
|
)
|
||||||
|
(call_indirect (type 3)
|
||||||
|
(f64.const 0) (i64.const 0) (f64.const 0) (i64.const 0)
|
||||||
|
(f64.const 0) (i64.const 0) (f32.const 0) (i32.const 0)
|
||||||
|
(i32.const 2)
|
||||||
|
)
|
||||||
|
(call_indirect (type 3)
|
||||||
|
(f64.const 0) (i64.const 0) (f64.const 0) (i64.const 0)
|
||||||
|
(f64.const 0) (i64.const 0) (f32.const 0) (i32.const 0)
|
||||||
|
(i32.const 3)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "signature-explicit-duplicate")
|
||||||
|
(call_indirect (type $empty-sig-duplicate) (i32.const 1))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "signature-implicit-duplicate")
|
||||||
|
(call_indirect (type $complex-sig-duplicate)
|
||||||
|
(i64.const 0) (i64.const 0) (f64.const 0) (i64.const 0)
|
||||||
|
(f64.const 0) (i64.const 0) (f32.const 0) (i32.const 0)
|
||||||
|
(i32.const 5)
|
||||||
|
)
|
||||||
|
(call_indirect (type $complex-sig-duplicate)
|
||||||
|
(i64.const 0) (i64.const 0) (f64.const 0) (i64.const 0)
|
||||||
|
(f64.const 0) (i64.const 0) (f32.const 0) (i32.const 0)
|
||||||
|
(i32.const 6)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke "signature-explicit-reused"))
|
||||||
|
(assert_return (invoke "signature-implicit-reused"))
|
||||||
|
(assert_return (invoke "signature-explicit-duplicate"))
|
||||||
|
(assert_return (invoke "signature-implicit-duplicate"))
|
||||||
|
|
||||||
|
|
||||||
|
;; Malformed type use
|
||||||
|
|
||||||
|
(assert_malformed
|
||||||
|
(module quote
|
||||||
|
"(type $sig (func (param i32) (result i32)))"
|
||||||
|
"(func (type $sig) (result i32) (param i32) (i32.const 0))"
|
||||||
|
)
|
||||||
|
"unexpected token"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote
|
||||||
|
"(type $sig (func (param i32) (result i32)))"
|
||||||
|
"(func (param i32) (type $sig) (result i32) (i32.const 0))"
|
||||||
|
)
|
||||||
|
"unexpected token"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote
|
||||||
|
"(type $sig (func (param i32) (result i32)))"
|
||||||
|
"(func (param i32) (result i32) (type $sig) (i32.const 0))"
|
||||||
|
)
|
||||||
|
"unexpected token"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote
|
||||||
|
"(type $sig (func (param i32) (result i32)))"
|
||||||
|
"(func (result i32) (type $sig) (param i32) (i32.const 0))"
|
||||||
|
)
|
||||||
|
"unexpected token"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote
|
||||||
|
"(type $sig (func (param i32) (result i32)))"
|
||||||
|
"(func (result i32) (param i32) (type $sig) (i32.const 0))"
|
||||||
|
)
|
||||||
|
"unexpected token"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote
|
||||||
|
"(func (result i32) (param i32) (i32.const 0))"
|
||||||
|
)
|
||||||
|
"unexpected token"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_malformed
|
||||||
|
(module quote
|
||||||
|
"(type $sig (func))"
|
||||||
|
"(func (type $sig) (result i32) (i32.const 0))"
|
||||||
|
)
|
||||||
|
"inline function type"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote
|
||||||
|
"(type $sig (func (param i32) (result i32)))"
|
||||||
|
"(func (type $sig) (result i32) (i32.const 0))"
|
||||||
|
)
|
||||||
|
"inline function type"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote
|
||||||
|
"(type $sig (func (param i32) (result i32)))"
|
||||||
|
"(func (type $sig) (param i32) (i32.const 0))"
|
||||||
|
)
|
||||||
|
"inline function type"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote
|
||||||
|
"(type $sig (func (param i32 i32) (result i32)))"
|
||||||
|
"(func (type $sig) (param i32) (result i32) (unreachable))"
|
||||||
|
)
|
||||||
|
"inline function type"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
;; Invalid typing of locals
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-local-num-vs-num (result i64) (local i32) (get_local 0)))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-local-num-vs-num (local f32) (i32.eqz (get_local 0))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-local-num-vs-num (local f64 i64) (f64.neg (get_local 1))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
;; Invalid typing of parameters
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-param-num-vs-num (param i32) (result i64) (get_local 0)))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-param-num-vs-num (param f32) (i32.eqz (get_local 0))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-param-num-vs-num (param f64 i64) (f64.neg (get_local 1))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
;; Invalid typing of result
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-multiple-result (result i32 i32) (unreachable)))
|
||||||
|
"invalid result arity"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module
|
||||||
|
(type (func (result i32 i32)))
|
||||||
|
(func $type-multiple-result (type 0) (unreachable))
|
||||||
|
)
|
||||||
|
"invalid result arity"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-empty-i32 (result i32)))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-empty-i64 (result i64)))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-empty-f32 (result f32)))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-empty-f64 (result f64)))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-value-void-vs-num (result i32)
|
||||||
|
(nop)
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-value-num-vs-void
|
||||||
|
(i32.const 0)
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-value-num-vs-num (result i32)
|
||||||
|
(f32.const 0)
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-return-last-empty-vs-num (result i32)
|
||||||
|
(return)
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-return-last-void-vs-num (result i32)
|
||||||
|
(return (nop))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-return-last-num-vs-num (result i32)
|
||||||
|
(return (i64.const 0))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-return-empty-vs-num (result i32)
|
||||||
|
(return) (i32.const 1)
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-return-void-vs-num (result i32)
|
||||||
|
(return (nop)) (i32.const 1)
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-return-num-vs-num (result i32)
|
||||||
|
(return (i64.const 1)) (i32.const 1)
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-return-first-num-vs-num (result i32)
|
||||||
|
(return (i64.const 1)) (return (i32.const 1))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-break-last-void-vs-num (result i32)
|
||||||
|
(br 0)
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-break-last-num-vs-num (result i32)
|
||||||
|
(br 0 (f32.const 0))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-break-void-vs-num (result i32)
|
||||||
|
(br 0) (i32.const 1)
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-break-num-vs-num (result i32)
|
||||||
|
(br 0 (i64.const 1)) (i32.const 1)
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-break-first-num-vs-num (result i32)
|
||||||
|
(br 0 (i64.const 1)) (br 0 (i32.const 1))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-break-nested-empty-vs-num (result i32)
|
||||||
|
(block (br 1)) (br 0 (i32.const 1))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-break-nested-void-vs-num (result i32)
|
||||||
|
(block (br 1 (nop))) (br 0 (i32.const 1))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-break-nested-num-vs-num (result i32)
|
||||||
|
(block (br 1 (i64.const 1))) (br 0 (i32.const 1))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
;; Syntax errors
|
||||||
|
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(func (nop) (local i32))")
|
||||||
|
"unexpected token"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(func (nop) (param i32))")
|
||||||
|
"unexpected token"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(func (nop) (result i32))")
|
||||||
|
"unexpected token"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(func (local i32) (param i32))")
|
||||||
|
"unexpected token"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(func (local i32) (result i32) (get_local 0))")
|
||||||
|
"unexpected token"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(func (result i32) (param i32) (get_local 0))")
|
||||||
|
"unexpected token"
|
||||||
|
)
|
||||||
@@ -0,0 +1,106 @@
|
|||||||
|
(module
|
||||||
|
(type (func)) ;; 0: void -> void
|
||||||
|
(type $S (func)) ;; 1: void -> void
|
||||||
|
(type (func (param))) ;; 2: void -> void
|
||||||
|
(type (func (result i32))) ;; 3: void -> i32
|
||||||
|
(type (func (param) (result i32))) ;; 4: void -> i32
|
||||||
|
(type $T (func (param i32) (result i32))) ;; 5: i32 -> i32
|
||||||
|
(type $U (func (param i32))) ;; 6: i32 -> void
|
||||||
|
|
||||||
|
(func $print (import "spectest" "print_i32") (type 6))
|
||||||
|
|
||||||
|
(func (type 0))
|
||||||
|
(func (type $S))
|
||||||
|
|
||||||
|
(func (export "one") (type 4) (i32.const 13))
|
||||||
|
(func (export "two") (type $T) (i32.add (get_local 0) (i32.const 1)))
|
||||||
|
|
||||||
|
;; Both signature and parameters are allowed (and required to match)
|
||||||
|
;; since this allows the naming of parameters.
|
||||||
|
(func (export "three") (type $T) (param $a i32) (result i32)
|
||||||
|
(i32.sub (get_local 0) (i32.const 2))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "four") (type $U) (call $print (get_local 0)))
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke "one") (i32.const 13))
|
||||||
|
(assert_return (invoke "two" (i32.const 13)) (i32.const 14))
|
||||||
|
(assert_return (invoke "three" (i32.const 13)) (i32.const 11))
|
||||||
|
(invoke "four" (i32.const 83))
|
||||||
|
|
||||||
|
(assert_invalid (module (elem (i32.const 0))) "unknown table")
|
||||||
|
(assert_invalid (module (elem (i32.const 0) 0) (func)) "unknown table")
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (table 1 anyfunc) (elem (i64.const 0)))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (table 1 anyfunc) (elem (i32.ctz (i32.const 0))))
|
||||||
|
"constant expression required"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (table 1 anyfunc) (elem (nop)))
|
||||||
|
"constant expression required"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid (module (func (type 42))) "unknown type")
|
||||||
|
(assert_invalid (module (import "spectest" "print_i32" (func (type 43)))) "unknown type")
|
||||||
|
|
||||||
|
(module
|
||||||
|
(type $T (func (param) (result i32)))
|
||||||
|
(type $U (func (param) (result i32)))
|
||||||
|
(table anyfunc (elem $t1 $t2 $t3 $u1 $u2 $t1 $t3))
|
||||||
|
|
||||||
|
(func $t1 (type $T) (i32.const 1))
|
||||||
|
(func $t2 (type $T) (i32.const 2))
|
||||||
|
(func $t3 (type $T) (i32.const 3))
|
||||||
|
(func $u1 (type $U) (i32.const 4))
|
||||||
|
(func $u2 (type $U) (i32.const 5))
|
||||||
|
|
||||||
|
(func (export "callt") (param $i i32) (result i32)
|
||||||
|
(call_indirect (type $T) (get_local $i))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "callu") (param $i i32) (result i32)
|
||||||
|
(call_indirect (type $U) (get_local $i))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke "callt" (i32.const 0)) (i32.const 1))
|
||||||
|
(assert_return (invoke "callt" (i32.const 1)) (i32.const 2))
|
||||||
|
(assert_return (invoke "callt" (i32.const 2)) (i32.const 3))
|
||||||
|
(assert_return (invoke "callt" (i32.const 3)) (i32.const 4))
|
||||||
|
(assert_return (invoke "callt" (i32.const 4)) (i32.const 5))
|
||||||
|
(assert_return (invoke "callt" (i32.const 5)) (i32.const 1))
|
||||||
|
(assert_return (invoke "callt" (i32.const 6)) (i32.const 3))
|
||||||
|
(assert_trap (invoke "callt" (i32.const 7)) "undefined element")
|
||||||
|
(assert_trap (invoke "callt" (i32.const 100)) "undefined element")
|
||||||
|
(assert_trap (invoke "callt" (i32.const -1)) "undefined element")
|
||||||
|
|
||||||
|
(assert_return (invoke "callu" (i32.const 0)) (i32.const 1))
|
||||||
|
(assert_return (invoke "callu" (i32.const 1)) (i32.const 2))
|
||||||
|
(assert_return (invoke "callu" (i32.const 2)) (i32.const 3))
|
||||||
|
(assert_return (invoke "callu" (i32.const 3)) (i32.const 4))
|
||||||
|
(assert_return (invoke "callu" (i32.const 4)) (i32.const 5))
|
||||||
|
(assert_return (invoke "callu" (i32.const 5)) (i32.const 1))
|
||||||
|
(assert_return (invoke "callu" (i32.const 6)) (i32.const 3))
|
||||||
|
(assert_trap (invoke "callu" (i32.const 7)) "undefined element")
|
||||||
|
(assert_trap (invoke "callu" (i32.const 100)) "undefined element")
|
||||||
|
(assert_trap (invoke "callu" (i32.const -1)) "undefined element")
|
||||||
|
|
||||||
|
(module
|
||||||
|
(type $T (func (result i32)))
|
||||||
|
(table anyfunc (elem 0 1))
|
||||||
|
|
||||||
|
(func $t1 (type $T) (i32.const 1))
|
||||||
|
(func $t2 (type $T) (i32.const 2))
|
||||||
|
|
||||||
|
(func (export "callt") (param $i i32) (result i32)
|
||||||
|
(call_indirect (type $T) (get_local $i))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke "callt" (i32.const 0)) (i32.const 1))
|
||||||
|
(assert_return (invoke "callt" (i32.const 1)) (i32.const 2))
|
||||||
@@ -0,0 +1,148 @@
|
|||||||
|
;; Test `get_local` operator
|
||||||
|
|
||||||
|
(module
|
||||||
|
;; Typing
|
||||||
|
|
||||||
|
(func (export "type-local-i32") (result i32) (local i32) (get_local 0))
|
||||||
|
(func (export "type-local-i64") (result i64) (local i64) (get_local 0))
|
||||||
|
(func (export "type-local-f32") (result f32) (local f32) (get_local 0))
|
||||||
|
(func (export "type-local-f64") (result f64) (local f64) (get_local 0))
|
||||||
|
|
||||||
|
(func (export "type-param-i32") (param i32) (result i32) (get_local 0))
|
||||||
|
(func (export "type-param-i64") (param i64) (result i64) (get_local 0))
|
||||||
|
(func (export "type-param-f32") (param f32) (result f32) (get_local 0))
|
||||||
|
(func (export "type-param-f64") (param f64) (result f64) (get_local 0))
|
||||||
|
|
||||||
|
(func (export "type-mixed") (param i64 f32 f64 i32 i32)
|
||||||
|
(local f32 i64 i64 f64)
|
||||||
|
(drop (i64.eqz (get_local 0)))
|
||||||
|
(drop (f32.neg (get_local 1)))
|
||||||
|
(drop (f64.neg (get_local 2)))
|
||||||
|
(drop (i32.eqz (get_local 3)))
|
||||||
|
(drop (i32.eqz (get_local 4)))
|
||||||
|
(drop (f32.neg (get_local 5)))
|
||||||
|
(drop (i64.eqz (get_local 6)))
|
||||||
|
(drop (i64.eqz (get_local 7)))
|
||||||
|
(drop (f64.neg (get_local 8)))
|
||||||
|
)
|
||||||
|
|
||||||
|
;; Reading
|
||||||
|
|
||||||
|
(func (export "read") (param i64 f32 f64 i32 i32) (result f64)
|
||||||
|
(local f32 i64 i64 f64)
|
||||||
|
(set_local 5 (f32.const 5.5))
|
||||||
|
(set_local 6 (i64.const 6))
|
||||||
|
(set_local 8 (f64.const 8))
|
||||||
|
(f64.add
|
||||||
|
(f64.convert_u/i64 (get_local 0))
|
||||||
|
(f64.add
|
||||||
|
(f64.promote/f32 (get_local 1))
|
||||||
|
(f64.add
|
||||||
|
(get_local 2)
|
||||||
|
(f64.add
|
||||||
|
(f64.convert_u/i32 (get_local 3))
|
||||||
|
(f64.add
|
||||||
|
(f64.convert_s/i32 (get_local 4))
|
||||||
|
(f64.add
|
||||||
|
(f64.promote/f32 (get_local 5))
|
||||||
|
(f64.add
|
||||||
|
(f64.convert_u/i64 (get_local 6))
|
||||||
|
(f64.add
|
||||||
|
(f64.convert_u/i64 (get_local 7))
|
||||||
|
(get_local 8)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke "type-local-i32") (i32.const 0))
|
||||||
|
(assert_return (invoke "type-local-i64") (i64.const 0))
|
||||||
|
(assert_return (invoke "type-local-f32") (f32.const 0))
|
||||||
|
(assert_return (invoke "type-local-f64") (f64.const 0))
|
||||||
|
|
||||||
|
(assert_return (invoke "type-param-i32" (i32.const 2)) (i32.const 2))
|
||||||
|
(assert_return (invoke "type-param-i64" (i64.const 3)) (i64.const 3))
|
||||||
|
(assert_return (invoke "type-param-f32" (f32.const 4.4)) (f32.const 4.4))
|
||||||
|
(assert_return (invoke "type-param-f64" (f64.const 5.5)) (f64.const 5.5))
|
||||||
|
|
||||||
|
(assert_return
|
||||||
|
(invoke "type-mixed"
|
||||||
|
(i64.const 1) (f32.const 2.2) (f64.const 3.3) (i32.const 4) (i32.const 5)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return
|
||||||
|
(invoke "read"
|
||||||
|
(i64.const 1) (f32.const 2) (f64.const 3.3) (i32.const 4) (i32.const 5)
|
||||||
|
)
|
||||||
|
(f64.const 34.8)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
;; Invalid typing of access to locals
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-local-num-vs-num (result i64) (local i32) (get_local 0)))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-local-num-vs-num (local f32) (i32.eqz (get_local 0))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-local-num-vs-num (local f64 i64) (f64.neg (get_local 1))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
;; Invalid typing of access to parameters
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-param-num-vs-num (param i32) (result i64) (get_local 0)))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-param-num-vs-num (param f32) (i32.eqz (get_local 0))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-param-num-vs-num (param f64 i64) (f64.neg (get_local 1))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
;; Invalid local index
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $unbound-local (local i32 i64) (get_local 3)))
|
||||||
|
"unknown local"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $large-local (local i32 i64) (get_local 14324343)))
|
||||||
|
"unknown local"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $unbound-param (param i32 i64) (get_local 2)))
|
||||||
|
"unknown local"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $large-param (local i32 i64) (get_local 714324343)))
|
||||||
|
"unknown local"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $unbound-mixed (param i32) (local i32 i64) (get_local 3)))
|
||||||
|
"unknown local"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $large-mixed (param i64) (local i32 i64) (get_local 214324343)))
|
||||||
|
"unknown local"
|
||||||
|
)
|
||||||
|
|
||||||
@@ -0,0 +1,180 @@
|
|||||||
|
;; Test globals
|
||||||
|
|
||||||
|
(module
|
||||||
|
(global $a i32 (i32.const -2))
|
||||||
|
(global (;1;) f32 (f32.const -3))
|
||||||
|
(global (;2;) f64 (f64.const -4))
|
||||||
|
(global $b i64 (i64.const -5))
|
||||||
|
|
||||||
|
(global $x (mut i32) (i32.const -12))
|
||||||
|
(global (;5;) (mut f32) (f32.const -13))
|
||||||
|
(global (;6;) (mut f64) (f64.const -14))
|
||||||
|
(global $y (mut i64) (i64.const -15))
|
||||||
|
|
||||||
|
(func (export "get-a") (result i32) (get_global $a))
|
||||||
|
(func (export "get-b") (result i64) (get_global $b))
|
||||||
|
(func (export "get-x") (result i32) (get_global $x))
|
||||||
|
(func (export "get-y") (result i64) (get_global $y))
|
||||||
|
(func (export "set-x") (param i32) (set_global $x (get_local 0)))
|
||||||
|
(func (export "set-y") (param i64) (set_global $y (get_local 0)))
|
||||||
|
|
||||||
|
(func (export "get-1") (result f32) (get_global 1))
|
||||||
|
(func (export "get-2") (result f64) (get_global 2))
|
||||||
|
(func (export "get-5") (result f32) (get_global 5))
|
||||||
|
(func (export "get-6") (result f64) (get_global 6))
|
||||||
|
(func (export "set-5") (param f32) (set_global 5 (get_local 0)))
|
||||||
|
(func (export "set-6") (param f64) (set_global 6 (get_local 0)))
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke "get-a") (i32.const -2))
|
||||||
|
(assert_return (invoke "get-b") (i64.const -5))
|
||||||
|
(assert_return (invoke "get-x") (i32.const -12))
|
||||||
|
(assert_return (invoke "get-y") (i64.const -15))
|
||||||
|
|
||||||
|
(assert_return (invoke "get-1") (f32.const -3))
|
||||||
|
(assert_return (invoke "get-2") (f64.const -4))
|
||||||
|
(assert_return (invoke "get-5") (f32.const -13))
|
||||||
|
(assert_return (invoke "get-6") (f64.const -14))
|
||||||
|
|
||||||
|
(assert_return (invoke "set-x" (i32.const 6)))
|
||||||
|
(assert_return (invoke "set-y" (i64.const 7)))
|
||||||
|
(assert_return (invoke "set-5" (f32.const 8)))
|
||||||
|
(assert_return (invoke "set-6" (f64.const 9)))
|
||||||
|
|
||||||
|
(assert_return (invoke "get-x") (i32.const 6))
|
||||||
|
(assert_return (invoke "get-y") (i64.const 7))
|
||||||
|
(assert_return (invoke "get-5") (f32.const 8))
|
||||||
|
(assert_return (invoke "get-6") (f64.const 9))
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (global f32 (f32.const 0)) (func (set_global 0 (i32.const 1))))
|
||||||
|
"global is immutable"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (import "m" "a" (global (mut i32))))
|
||||||
|
"mutable globals cannot be imported"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (global (import "m" "a") (mut i32)))
|
||||||
|
"mutable globals cannot be imported"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (global (mut f32) (f32.const 0)) (export "a" (global 0)))
|
||||||
|
"mutable globals cannot be exported"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (global (export "a") (mut f32) (f32.const 0)))
|
||||||
|
"mutable globals cannot be exported"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (global f32 (f32.neg (f32.const 0))))
|
||||||
|
"constant expression required"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (global f32 (get_local 0)))
|
||||||
|
"constant expression required"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (global f32 (f32.neg (f32.const 1))))
|
||||||
|
"constant expression required"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (global i32 (i32.const 0) (nop)))
|
||||||
|
"constant expression required"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (global i32 (nop)))
|
||||||
|
"constant expression required"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (global i32 (f32.const 0)))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (global i32 (i32.const 0) (i32.const 0)))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (global i32 (;empty instruction sequence;)))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (global i32 (get_global 0)))
|
||||||
|
"unknown global"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (global i32 (get_global 1)) (global i32 (i32.const 0)))
|
||||||
|
"unknown global"
|
||||||
|
)
|
||||||
|
|
||||||
|
(module
|
||||||
|
(import "spectest" "global_i32" (global i32))
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module binary
|
||||||
|
"\00asm" "\01\00\00\00"
|
||||||
|
"\02\94\80\80\80\00" ;; import section
|
||||||
|
"\01" ;; length 1
|
||||||
|
"\08\73\70\65\63\74\65\73\74" ;; "spectest"
|
||||||
|
"\0a\67\6c\6f\62\61\6c\5f\69\33\32" ;; "global_i32"
|
||||||
|
"\03" ;; GlobalImport
|
||||||
|
"\7f" ;; i32
|
||||||
|
"\02" ;; invalid mutability
|
||||||
|
)
|
||||||
|
"invalid mutability"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module binary
|
||||||
|
"\00asm" "\01\00\00\00"
|
||||||
|
"\02\94\80\80\80\00" ;; import section
|
||||||
|
"\01" ;; length 1
|
||||||
|
"\08\73\70\65\63\74\65\73\74" ;; "spectest"
|
||||||
|
"\0a\67\6c\6f\62\61\6c\5f\69\33\32" ;; "global_i32"
|
||||||
|
"\03" ;; GlobalImport
|
||||||
|
"\7f" ;; i32
|
||||||
|
"\ff" ;; invalid mutability
|
||||||
|
)
|
||||||
|
"invalid mutability"
|
||||||
|
)
|
||||||
|
|
||||||
|
(module
|
||||||
|
(global i32 (i32.const 0))
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module binary
|
||||||
|
"\00asm" "\01\00\00\00"
|
||||||
|
"\06\86\80\80\80\00" ;; global section
|
||||||
|
"\01" ;; length 1
|
||||||
|
"\7f" ;; i32
|
||||||
|
"\02" ;; invalid mutability
|
||||||
|
"\41\00" ;; i32.const 0
|
||||||
|
"\0b" ;; end
|
||||||
|
)
|
||||||
|
"invalid mutability"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module binary
|
||||||
|
"\00asm" "\01\00\00\00"
|
||||||
|
"\06\86\80\80\80\00" ;; global section
|
||||||
|
"\01" ;; length 1
|
||||||
|
"\7f" ;; i32
|
||||||
|
"\ff" ;; invalid mutability
|
||||||
|
"\41\00" ;; i32.const 0
|
||||||
|
"\0b" ;; end
|
||||||
|
)
|
||||||
|
"invalid mutability"
|
||||||
|
)
|
||||||
@@ -0,0 +1,421 @@
|
|||||||
|
;; i32 operations
|
||||||
|
|
||||||
|
(module
|
||||||
|
(func (export "add") (param $x i32) (param $y i32) (result i32) (i32.add (get_local $x) (get_local $y)))
|
||||||
|
(func (export "sub") (param $x i32) (param $y i32) (result i32) (i32.sub (get_local $x) (get_local $y)))
|
||||||
|
(func (export "mul") (param $x i32) (param $y i32) (result i32) (i32.mul (get_local $x) (get_local $y)))
|
||||||
|
(func (export "div_s") (param $x i32) (param $y i32) (result i32) (i32.div_s (get_local $x) (get_local $y)))
|
||||||
|
(func (export "div_u") (param $x i32) (param $y i32) (result i32) (i32.div_u (get_local $x) (get_local $y)))
|
||||||
|
(func (export "rem_s") (param $x i32) (param $y i32) (result i32) (i32.rem_s (get_local $x) (get_local $y)))
|
||||||
|
(func (export "rem_u") (param $x i32) (param $y i32) (result i32) (i32.rem_u (get_local $x) (get_local $y)))
|
||||||
|
(func (export "and") (param $x i32) (param $y i32) (result i32) (i32.and (get_local $x) (get_local $y)))
|
||||||
|
(func (export "or") (param $x i32) (param $y i32) (result i32) (i32.or (get_local $x) (get_local $y)))
|
||||||
|
(func (export "xor") (param $x i32) (param $y i32) (result i32) (i32.xor (get_local $x) (get_local $y)))
|
||||||
|
(func (export "shl") (param $x i32) (param $y i32) (result i32) (i32.shl (get_local $x) (get_local $y)))
|
||||||
|
(func (export "shr_s") (param $x i32) (param $y i32) (result i32) (i32.shr_s (get_local $x) (get_local $y)))
|
||||||
|
(func (export "shr_u") (param $x i32) (param $y i32) (result i32) (i32.shr_u (get_local $x) (get_local $y)))
|
||||||
|
(func (export "rotl") (param $x i32) (param $y i32) (result i32) (i32.rotl (get_local $x) (get_local $y)))
|
||||||
|
(func (export "rotr") (param $x i32) (param $y i32) (result i32) (i32.rotr (get_local $x) (get_local $y)))
|
||||||
|
(func (export "clz") (param $x i32) (result i32) (i32.clz (get_local $x)))
|
||||||
|
(func (export "ctz") (param $x i32) (result i32) (i32.ctz (get_local $x)))
|
||||||
|
(func (export "popcnt") (param $x i32) (result i32) (i32.popcnt (get_local $x)))
|
||||||
|
(func (export "eqz") (param $x i32) (result i32) (i32.eqz (get_local $x)))
|
||||||
|
(func (export "eq") (param $x i32) (param $y i32) (result i32) (i32.eq (get_local $x) (get_local $y)))
|
||||||
|
(func (export "ne") (param $x i32) (param $y i32) (result i32) (i32.ne (get_local $x) (get_local $y)))
|
||||||
|
(func (export "lt_s") (param $x i32) (param $y i32) (result i32) (i32.lt_s (get_local $x) (get_local $y)))
|
||||||
|
(func (export "lt_u") (param $x i32) (param $y i32) (result i32) (i32.lt_u (get_local $x) (get_local $y)))
|
||||||
|
(func (export "le_s") (param $x i32) (param $y i32) (result i32) (i32.le_s (get_local $x) (get_local $y)))
|
||||||
|
(func (export "le_u") (param $x i32) (param $y i32) (result i32) (i32.le_u (get_local $x) (get_local $y)))
|
||||||
|
(func (export "gt_s") (param $x i32) (param $y i32) (result i32) (i32.gt_s (get_local $x) (get_local $y)))
|
||||||
|
(func (export "gt_u") (param $x i32) (param $y i32) (result i32) (i32.gt_u (get_local $x) (get_local $y)))
|
||||||
|
(func (export "ge_s") (param $x i32) (param $y i32) (result i32) (i32.ge_s (get_local $x) (get_local $y)))
|
||||||
|
(func (export "ge_u") (param $x i32) (param $y i32) (result i32) (i32.ge_u (get_local $x) (get_local $y)))
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke "add" (i32.const 1) (i32.const 1)) (i32.const 2))
|
||||||
|
(assert_return (invoke "add" (i32.const 1) (i32.const 0)) (i32.const 1))
|
||||||
|
(assert_return (invoke "add" (i32.const -1) (i32.const -1)) (i32.const -2))
|
||||||
|
(assert_return (invoke "add" (i32.const -1) (i32.const 1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "add" (i32.const 0x7fffffff) (i32.const 1)) (i32.const 0x80000000))
|
||||||
|
(assert_return (invoke "add" (i32.const 0x80000000) (i32.const -1)) (i32.const 0x7fffffff))
|
||||||
|
(assert_return (invoke "add" (i32.const 0x80000000) (i32.const 0x80000000)) (i32.const 0))
|
||||||
|
(assert_return (invoke "add" (i32.const 0x3fffffff) (i32.const 1)) (i32.const 0x40000000))
|
||||||
|
|
||||||
|
(assert_return (invoke "sub" (i32.const 1) (i32.const 1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "sub" (i32.const 1) (i32.const 0)) (i32.const 1))
|
||||||
|
(assert_return (invoke "sub" (i32.const -1) (i32.const -1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "sub" (i32.const 0x7fffffff) (i32.const -1)) (i32.const 0x80000000))
|
||||||
|
(assert_return (invoke "sub" (i32.const 0x80000000) (i32.const 1)) (i32.const 0x7fffffff))
|
||||||
|
(assert_return (invoke "sub" (i32.const 0x80000000) (i32.const 0x80000000)) (i32.const 0))
|
||||||
|
(assert_return (invoke "sub" (i32.const 0x3fffffff) (i32.const -1)) (i32.const 0x40000000))
|
||||||
|
|
||||||
|
(assert_return (invoke "mul" (i32.const 1) (i32.const 1)) (i32.const 1))
|
||||||
|
(assert_return (invoke "mul" (i32.const 1) (i32.const 0)) (i32.const 0))
|
||||||
|
(assert_return (invoke "mul" (i32.const -1) (i32.const -1)) (i32.const 1))
|
||||||
|
(assert_return (invoke "mul" (i32.const 0x10000000) (i32.const 4096)) (i32.const 0))
|
||||||
|
(assert_return (invoke "mul" (i32.const 0x80000000) (i32.const 0)) (i32.const 0))
|
||||||
|
(assert_return (invoke "mul" (i32.const 0x80000000) (i32.const -1)) (i32.const 0x80000000))
|
||||||
|
(assert_return (invoke "mul" (i32.const 0x7fffffff) (i32.const -1)) (i32.const 0x80000001))
|
||||||
|
(assert_return (invoke "mul" (i32.const 0x01234567) (i32.const 0x76543210)) (i32.const 0x358e7470))
|
||||||
|
(assert_return (invoke "mul" (i32.const 0x7fffffff) (i32.const 0x7fffffff)) (i32.const 1))
|
||||||
|
|
||||||
|
(assert_trap (invoke "div_s" (i32.const 1) (i32.const 0)) "integer divide by zero")
|
||||||
|
(assert_trap (invoke "div_s" (i32.const 0) (i32.const 0)) "integer divide by zero")
|
||||||
|
(assert_trap (invoke "div_s" (i32.const 0x80000000) (i32.const -1)) "integer overflow")
|
||||||
|
(assert_return (invoke "div_s" (i32.const 1) (i32.const 1)) (i32.const 1))
|
||||||
|
(assert_return (invoke "div_s" (i32.const 0) (i32.const 1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "div_s" (i32.const 0) (i32.const -1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "div_s" (i32.const -1) (i32.const -1)) (i32.const 1))
|
||||||
|
(assert_return (invoke "div_s" (i32.const 0x80000000) (i32.const 2)) (i32.const 0xc0000000))
|
||||||
|
(assert_return (invoke "div_s" (i32.const 0x80000001) (i32.const 1000)) (i32.const 0xffdf3b65))
|
||||||
|
(assert_return (invoke "div_s" (i32.const 5) (i32.const 2)) (i32.const 2))
|
||||||
|
(assert_return (invoke "div_s" (i32.const -5) (i32.const 2)) (i32.const -2))
|
||||||
|
(assert_return (invoke "div_s" (i32.const 5) (i32.const -2)) (i32.const -2))
|
||||||
|
(assert_return (invoke "div_s" (i32.const -5) (i32.const -2)) (i32.const 2))
|
||||||
|
(assert_return (invoke "div_s" (i32.const 7) (i32.const 3)) (i32.const 2))
|
||||||
|
(assert_return (invoke "div_s" (i32.const -7) (i32.const 3)) (i32.const -2))
|
||||||
|
(assert_return (invoke "div_s" (i32.const 7) (i32.const -3)) (i32.const -2))
|
||||||
|
(assert_return (invoke "div_s" (i32.const -7) (i32.const -3)) (i32.const 2))
|
||||||
|
(assert_return (invoke "div_s" (i32.const 11) (i32.const 5)) (i32.const 2))
|
||||||
|
(assert_return (invoke "div_s" (i32.const 17) (i32.const 7)) (i32.const 2))
|
||||||
|
|
||||||
|
(assert_trap (invoke "div_u" (i32.const 1) (i32.const 0)) "integer divide by zero")
|
||||||
|
(assert_trap (invoke "div_u" (i32.const 0) (i32.const 0)) "integer divide by zero")
|
||||||
|
(assert_return (invoke "div_u" (i32.const 1) (i32.const 1)) (i32.const 1))
|
||||||
|
(assert_return (invoke "div_u" (i32.const 0) (i32.const 1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "div_u" (i32.const -1) (i32.const -1)) (i32.const 1))
|
||||||
|
(assert_return (invoke "div_u" (i32.const 0x80000000) (i32.const -1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "div_u" (i32.const 0x80000000) (i32.const 2)) (i32.const 0x40000000))
|
||||||
|
(assert_return (invoke "div_u" (i32.const 0x8ff00ff0) (i32.const 0x10001)) (i32.const 0x8fef))
|
||||||
|
(assert_return (invoke "div_u" (i32.const 0x80000001) (i32.const 1000)) (i32.const 0x20c49b))
|
||||||
|
(assert_return (invoke "div_u" (i32.const 5) (i32.const 2)) (i32.const 2))
|
||||||
|
(assert_return (invoke "div_u" (i32.const -5) (i32.const 2)) (i32.const 0x7ffffffd))
|
||||||
|
(assert_return (invoke "div_u" (i32.const 5) (i32.const -2)) (i32.const 0))
|
||||||
|
(assert_return (invoke "div_u" (i32.const -5) (i32.const -2)) (i32.const 0))
|
||||||
|
(assert_return (invoke "div_u" (i32.const 7) (i32.const 3)) (i32.const 2))
|
||||||
|
(assert_return (invoke "div_u" (i32.const 11) (i32.const 5)) (i32.const 2))
|
||||||
|
(assert_return (invoke "div_u" (i32.const 17) (i32.const 7)) (i32.const 2))
|
||||||
|
|
||||||
|
(assert_trap (invoke "rem_s" (i32.const 1) (i32.const 0)) "integer divide by zero")
|
||||||
|
(assert_trap (invoke "rem_s" (i32.const 0) (i32.const 0)) "integer divide by zero")
|
||||||
|
(assert_return (invoke "rem_s" (i32.const 0x7fffffff) (i32.const -1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "rem_s" (i32.const 1) (i32.const 1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "rem_s" (i32.const 0) (i32.const 1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "rem_s" (i32.const 0) (i32.const -1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "rem_s" (i32.const -1) (i32.const -1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "rem_s" (i32.const 0x80000000) (i32.const -1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "rem_s" (i32.const 0x80000000) (i32.const 2)) (i32.const 0))
|
||||||
|
(assert_return (invoke "rem_s" (i32.const 0x80000001) (i32.const 1000)) (i32.const -647))
|
||||||
|
(assert_return (invoke "rem_s" (i32.const 5) (i32.const 2)) (i32.const 1))
|
||||||
|
(assert_return (invoke "rem_s" (i32.const -5) (i32.const 2)) (i32.const -1))
|
||||||
|
(assert_return (invoke "rem_s" (i32.const 5) (i32.const -2)) (i32.const 1))
|
||||||
|
(assert_return (invoke "rem_s" (i32.const -5) (i32.const -2)) (i32.const -1))
|
||||||
|
(assert_return (invoke "rem_s" (i32.const 7) (i32.const 3)) (i32.const 1))
|
||||||
|
(assert_return (invoke "rem_s" (i32.const -7) (i32.const 3)) (i32.const -1))
|
||||||
|
(assert_return (invoke "rem_s" (i32.const 7) (i32.const -3)) (i32.const 1))
|
||||||
|
(assert_return (invoke "rem_s" (i32.const -7) (i32.const -3)) (i32.const -1))
|
||||||
|
(assert_return (invoke "rem_s" (i32.const 11) (i32.const 5)) (i32.const 1))
|
||||||
|
(assert_return (invoke "rem_s" (i32.const 17) (i32.const 7)) (i32.const 3))
|
||||||
|
|
||||||
|
(assert_trap (invoke "rem_u" (i32.const 1) (i32.const 0)) "integer divide by zero")
|
||||||
|
(assert_trap (invoke "rem_u" (i32.const 0) (i32.const 0)) "integer divide by zero")
|
||||||
|
(assert_return (invoke "rem_u" (i32.const 1) (i32.const 1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "rem_u" (i32.const 0) (i32.const 1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "rem_u" (i32.const -1) (i32.const -1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "rem_u" (i32.const 0x80000000) (i32.const -1)) (i32.const 0x80000000))
|
||||||
|
(assert_return (invoke "rem_u" (i32.const 0x80000000) (i32.const 2)) (i32.const 0))
|
||||||
|
(assert_return (invoke "rem_u" (i32.const 0x8ff00ff0) (i32.const 0x10001)) (i32.const 0x8001))
|
||||||
|
(assert_return (invoke "rem_u" (i32.const 0x80000001) (i32.const 1000)) (i32.const 649))
|
||||||
|
(assert_return (invoke "rem_u" (i32.const 5) (i32.const 2)) (i32.const 1))
|
||||||
|
(assert_return (invoke "rem_u" (i32.const -5) (i32.const 2)) (i32.const 1))
|
||||||
|
(assert_return (invoke "rem_u" (i32.const 5) (i32.const -2)) (i32.const 5))
|
||||||
|
(assert_return (invoke "rem_u" (i32.const -5) (i32.const -2)) (i32.const -5))
|
||||||
|
(assert_return (invoke "rem_u" (i32.const 7) (i32.const 3)) (i32.const 1))
|
||||||
|
(assert_return (invoke "rem_u" (i32.const 11) (i32.const 5)) (i32.const 1))
|
||||||
|
(assert_return (invoke "rem_u" (i32.const 17) (i32.const 7)) (i32.const 3))
|
||||||
|
|
||||||
|
(assert_return (invoke "and" (i32.const 1) (i32.const 0)) (i32.const 0))
|
||||||
|
(assert_return (invoke "and" (i32.const 0) (i32.const 1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "and" (i32.const 1) (i32.const 1)) (i32.const 1))
|
||||||
|
(assert_return (invoke "and" (i32.const 0) (i32.const 0)) (i32.const 0))
|
||||||
|
(assert_return (invoke "and" (i32.const 0x7fffffff) (i32.const 0x80000000)) (i32.const 0))
|
||||||
|
(assert_return (invoke "and" (i32.const 0x7fffffff) (i32.const -1)) (i32.const 0x7fffffff))
|
||||||
|
(assert_return (invoke "and" (i32.const 0xf0f0ffff) (i32.const 0xfffff0f0)) (i32.const 0xf0f0f0f0))
|
||||||
|
(assert_return (invoke "and" (i32.const 0xffffffff) (i32.const 0xffffffff)) (i32.const 0xffffffff))
|
||||||
|
|
||||||
|
(assert_return (invoke "or" (i32.const 1) (i32.const 0)) (i32.const 1))
|
||||||
|
(assert_return (invoke "or" (i32.const 0) (i32.const 1)) (i32.const 1))
|
||||||
|
(assert_return (invoke "or" (i32.const 1) (i32.const 1)) (i32.const 1))
|
||||||
|
(assert_return (invoke "or" (i32.const 0) (i32.const 0)) (i32.const 0))
|
||||||
|
(assert_return (invoke "or" (i32.const 0x7fffffff) (i32.const 0x80000000)) (i32.const -1))
|
||||||
|
(assert_return (invoke "or" (i32.const 0x80000000) (i32.const 0)) (i32.const 0x80000000))
|
||||||
|
(assert_return (invoke "or" (i32.const 0xf0f0ffff) (i32.const 0xfffff0f0)) (i32.const 0xffffffff))
|
||||||
|
(assert_return (invoke "or" (i32.const 0xffffffff) (i32.const 0xffffffff)) (i32.const 0xffffffff))
|
||||||
|
|
||||||
|
(assert_return (invoke "xor" (i32.const 1) (i32.const 0)) (i32.const 1))
|
||||||
|
(assert_return (invoke "xor" (i32.const 0) (i32.const 1)) (i32.const 1))
|
||||||
|
(assert_return (invoke "xor" (i32.const 1) (i32.const 1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "xor" (i32.const 0) (i32.const 0)) (i32.const 0))
|
||||||
|
(assert_return (invoke "xor" (i32.const 0x7fffffff) (i32.const 0x80000000)) (i32.const -1))
|
||||||
|
(assert_return (invoke "xor" (i32.const 0x80000000) (i32.const 0)) (i32.const 0x80000000))
|
||||||
|
(assert_return (invoke "xor" (i32.const -1) (i32.const 0x80000000)) (i32.const 0x7fffffff))
|
||||||
|
(assert_return (invoke "xor" (i32.const -1) (i32.const 0x7fffffff)) (i32.const 0x80000000))
|
||||||
|
(assert_return (invoke "xor" (i32.const 0xf0f0ffff) (i32.const 0xfffff0f0)) (i32.const 0x0f0f0f0f))
|
||||||
|
(assert_return (invoke "xor" (i32.const 0xffffffff) (i32.const 0xffffffff)) (i32.const 0))
|
||||||
|
|
||||||
|
(assert_return (invoke "shl" (i32.const 1) (i32.const 1)) (i32.const 2))
|
||||||
|
(assert_return (invoke "shl" (i32.const 1) (i32.const 0)) (i32.const 1))
|
||||||
|
(assert_return (invoke "shl" (i32.const 0x7fffffff) (i32.const 1)) (i32.const 0xfffffffe))
|
||||||
|
(assert_return (invoke "shl" (i32.const 0xffffffff) (i32.const 1)) (i32.const 0xfffffffe))
|
||||||
|
(assert_return (invoke "shl" (i32.const 0x80000000) (i32.const 1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "shl" (i32.const 0x40000000) (i32.const 1)) (i32.const 0x80000000))
|
||||||
|
(assert_return (invoke "shl" (i32.const 1) (i32.const 31)) (i32.const 0x80000000))
|
||||||
|
(assert_return (invoke "shl" (i32.const 1) (i32.const 32)) (i32.const 1))
|
||||||
|
(assert_return (invoke "shl" (i32.const 1) (i32.const 33)) (i32.const 2))
|
||||||
|
(assert_return (invoke "shl" (i32.const 1) (i32.const -1)) (i32.const 0x80000000))
|
||||||
|
(assert_return (invoke "shl" (i32.const 1) (i32.const 0x7fffffff)) (i32.const 0x80000000))
|
||||||
|
|
||||||
|
(assert_return (invoke "shr_s" (i32.const 1) (i32.const 1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "shr_s" (i32.const 1) (i32.const 0)) (i32.const 1))
|
||||||
|
(assert_return (invoke "shr_s" (i32.const -1) (i32.const 1)) (i32.const -1))
|
||||||
|
(assert_return (invoke "shr_s" (i32.const 0x7fffffff) (i32.const 1)) (i32.const 0x3fffffff))
|
||||||
|
(assert_return (invoke "shr_s" (i32.const 0x80000000) (i32.const 1)) (i32.const 0xc0000000))
|
||||||
|
(assert_return (invoke "shr_s" (i32.const 0x40000000) (i32.const 1)) (i32.const 0x20000000))
|
||||||
|
(assert_return (invoke "shr_s" (i32.const 1) (i32.const 32)) (i32.const 1))
|
||||||
|
(assert_return (invoke "shr_s" (i32.const 1) (i32.const 33)) (i32.const 0))
|
||||||
|
(assert_return (invoke "shr_s" (i32.const 1) (i32.const -1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "shr_s" (i32.const 1) (i32.const 0x7fffffff)) (i32.const 0))
|
||||||
|
(assert_return (invoke "shr_s" (i32.const 1) (i32.const 0x80000000)) (i32.const 1))
|
||||||
|
(assert_return (invoke "shr_s" (i32.const 0x80000000) (i32.const 31)) (i32.const -1))
|
||||||
|
(assert_return (invoke "shr_s" (i32.const -1) (i32.const 32)) (i32.const -1))
|
||||||
|
(assert_return (invoke "shr_s" (i32.const -1) (i32.const 33)) (i32.const -1))
|
||||||
|
(assert_return (invoke "shr_s" (i32.const -1) (i32.const -1)) (i32.const -1))
|
||||||
|
(assert_return (invoke "shr_s" (i32.const -1) (i32.const 0x7fffffff)) (i32.const -1))
|
||||||
|
(assert_return (invoke "shr_s" (i32.const -1) (i32.const 0x80000000)) (i32.const -1))
|
||||||
|
|
||||||
|
(assert_return (invoke "shr_u" (i32.const 1) (i32.const 1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "shr_u" (i32.const 1) (i32.const 0)) (i32.const 1))
|
||||||
|
(assert_return (invoke "shr_u" (i32.const -1) (i32.const 1)) (i32.const 0x7fffffff))
|
||||||
|
(assert_return (invoke "shr_u" (i32.const 0x7fffffff) (i32.const 1)) (i32.const 0x3fffffff))
|
||||||
|
(assert_return (invoke "shr_u" (i32.const 0x80000000) (i32.const 1)) (i32.const 0x40000000))
|
||||||
|
(assert_return (invoke "shr_u" (i32.const 0x40000000) (i32.const 1)) (i32.const 0x20000000))
|
||||||
|
(assert_return (invoke "shr_u" (i32.const 1) (i32.const 32)) (i32.const 1))
|
||||||
|
(assert_return (invoke "shr_u" (i32.const 1) (i32.const 33)) (i32.const 0))
|
||||||
|
(assert_return (invoke "shr_u" (i32.const 1) (i32.const -1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "shr_u" (i32.const 1) (i32.const 0x7fffffff)) (i32.const 0))
|
||||||
|
(assert_return (invoke "shr_u" (i32.const 1) (i32.const 0x80000000)) (i32.const 1))
|
||||||
|
(assert_return (invoke "shr_u" (i32.const 0x80000000) (i32.const 31)) (i32.const 1))
|
||||||
|
(assert_return (invoke "shr_u" (i32.const -1) (i32.const 32)) (i32.const -1))
|
||||||
|
(assert_return (invoke "shr_u" (i32.const -1) (i32.const 33)) (i32.const 0x7fffffff))
|
||||||
|
(assert_return (invoke "shr_u" (i32.const -1) (i32.const -1)) (i32.const 1))
|
||||||
|
(assert_return (invoke "shr_u" (i32.const -1) (i32.const 0x7fffffff)) (i32.const 1))
|
||||||
|
(assert_return (invoke "shr_u" (i32.const -1) (i32.const 0x80000000)) (i32.const -1))
|
||||||
|
|
||||||
|
(assert_return (invoke "rotl" (i32.const 1) (i32.const 1)) (i32.const 2))
|
||||||
|
(assert_return (invoke "rotl" (i32.const 1) (i32.const 0)) (i32.const 1))
|
||||||
|
(assert_return (invoke "rotl" (i32.const -1) (i32.const 1)) (i32.const -1))
|
||||||
|
(assert_return (invoke "rotl" (i32.const 1) (i32.const 32)) (i32.const 1))
|
||||||
|
(assert_return (invoke "rotl" (i32.const 0xabcd9876) (i32.const 1)) (i32.const 0x579b30ed))
|
||||||
|
(assert_return (invoke "rotl" (i32.const 0xfe00dc00) (i32.const 4)) (i32.const 0xe00dc00f))
|
||||||
|
(assert_return (invoke "rotl" (i32.const 0xb0c1d2e3) (i32.const 5)) (i32.const 0x183a5c76))
|
||||||
|
(assert_return (invoke "rotl" (i32.const 0x00008000) (i32.const 37)) (i32.const 0x00100000))
|
||||||
|
(assert_return (invoke "rotl" (i32.const 0xb0c1d2e3) (i32.const 0xff05)) (i32.const 0x183a5c76))
|
||||||
|
(assert_return (invoke "rotl" (i32.const 0x769abcdf) (i32.const 0xffffffed)) (i32.const 0x579beed3))
|
||||||
|
(assert_return (invoke "rotl" (i32.const 0x769abcdf) (i32.const 0x8000000d)) (i32.const 0x579beed3))
|
||||||
|
(assert_return (invoke "rotl" (i32.const 1) (i32.const 31)) (i32.const 0x80000000))
|
||||||
|
(assert_return (invoke "rotl" (i32.const 0x80000000) (i32.const 1)) (i32.const 1))
|
||||||
|
|
||||||
|
(assert_return (invoke "rotr" (i32.const 1) (i32.const 1)) (i32.const 0x80000000))
|
||||||
|
(assert_return (invoke "rotr" (i32.const 1) (i32.const 0)) (i32.const 1))
|
||||||
|
(assert_return (invoke "rotr" (i32.const -1) (i32.const 1)) (i32.const -1))
|
||||||
|
(assert_return (invoke "rotr" (i32.const 1) (i32.const 32)) (i32.const 1))
|
||||||
|
(assert_return (invoke "rotr" (i32.const 0xff00cc00) (i32.const 1)) (i32.const 0x7f806600))
|
||||||
|
(assert_return (invoke "rotr" (i32.const 0x00080000) (i32.const 4)) (i32.const 0x00008000))
|
||||||
|
(assert_return (invoke "rotr" (i32.const 0xb0c1d2e3) (i32.const 5)) (i32.const 0x1d860e97))
|
||||||
|
(assert_return (invoke "rotr" (i32.const 0x00008000) (i32.const 37)) (i32.const 0x00000400))
|
||||||
|
(assert_return (invoke "rotr" (i32.const 0xb0c1d2e3) (i32.const 0xff05)) (i32.const 0x1d860e97))
|
||||||
|
(assert_return (invoke "rotr" (i32.const 0x769abcdf) (i32.const 0xffffffed)) (i32.const 0xe6fbb4d5))
|
||||||
|
(assert_return (invoke "rotr" (i32.const 0x769abcdf) (i32.const 0x8000000d)) (i32.const 0xe6fbb4d5))
|
||||||
|
(assert_return (invoke "rotr" (i32.const 1) (i32.const 31)) (i32.const 2))
|
||||||
|
(assert_return (invoke "rotr" (i32.const 0x80000000) (i32.const 31)) (i32.const 1))
|
||||||
|
|
||||||
|
(assert_return (invoke "clz" (i32.const 0xffffffff)) (i32.const 0))
|
||||||
|
(assert_return (invoke "clz" (i32.const 0)) (i32.const 32))
|
||||||
|
(assert_return (invoke "clz" (i32.const 0x00008000)) (i32.const 16))
|
||||||
|
(assert_return (invoke "clz" (i32.const 0xff)) (i32.const 24))
|
||||||
|
(assert_return (invoke "clz" (i32.const 0x80000000)) (i32.const 0))
|
||||||
|
(assert_return (invoke "clz" (i32.const 1)) (i32.const 31))
|
||||||
|
(assert_return (invoke "clz" (i32.const 2)) (i32.const 30))
|
||||||
|
(assert_return (invoke "clz" (i32.const 0x7fffffff)) (i32.const 1))
|
||||||
|
|
||||||
|
(assert_return (invoke "ctz" (i32.const -1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "ctz" (i32.const 0)) (i32.const 32))
|
||||||
|
(assert_return (invoke "ctz" (i32.const 0x00008000)) (i32.const 15))
|
||||||
|
(assert_return (invoke "ctz" (i32.const 0x00010000)) (i32.const 16))
|
||||||
|
(assert_return (invoke "ctz" (i32.const 0x80000000)) (i32.const 31))
|
||||||
|
(assert_return (invoke "ctz" (i32.const 0x7fffffff)) (i32.const 0))
|
||||||
|
|
||||||
|
(assert_return (invoke "popcnt" (i32.const -1)) (i32.const 32))
|
||||||
|
(assert_return (invoke "popcnt" (i32.const 0)) (i32.const 0))
|
||||||
|
(assert_return (invoke "popcnt" (i32.const 0x00008000)) (i32.const 1))
|
||||||
|
(assert_return (invoke "popcnt" (i32.const 0x80008000)) (i32.const 2))
|
||||||
|
(assert_return (invoke "popcnt" (i32.const 0x7fffffff)) (i32.const 31))
|
||||||
|
(assert_return (invoke "popcnt" (i32.const 0xAAAAAAAA)) (i32.const 16))
|
||||||
|
(assert_return (invoke "popcnt" (i32.const 0x55555555)) (i32.const 16))
|
||||||
|
(assert_return (invoke "popcnt" (i32.const 0xDEADBEEF)) (i32.const 24))
|
||||||
|
|
||||||
|
(assert_return (invoke "eqz" (i32.const 0)) (i32.const 1))
|
||||||
|
(assert_return (invoke "eqz" (i32.const 1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "eqz" (i32.const 0x80000000)) (i32.const 0))
|
||||||
|
(assert_return (invoke "eqz" (i32.const 0x7fffffff)) (i32.const 0))
|
||||||
|
(assert_return (invoke "eqz" (i32.const 0xffffffff)) (i32.const 0))
|
||||||
|
|
||||||
|
(assert_return (invoke "eq" (i32.const 0) (i32.const 0)) (i32.const 1))
|
||||||
|
(assert_return (invoke "eq" (i32.const 1) (i32.const 1)) (i32.const 1))
|
||||||
|
(assert_return (invoke "eq" (i32.const -1) (i32.const 1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "eq" (i32.const 0x80000000) (i32.const 0x80000000)) (i32.const 1))
|
||||||
|
(assert_return (invoke "eq" (i32.const 0x7fffffff) (i32.const 0x7fffffff)) (i32.const 1))
|
||||||
|
(assert_return (invoke "eq" (i32.const -1) (i32.const -1)) (i32.const 1))
|
||||||
|
(assert_return (invoke "eq" (i32.const 1) (i32.const 0)) (i32.const 0))
|
||||||
|
(assert_return (invoke "eq" (i32.const 0) (i32.const 1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "eq" (i32.const 0x80000000) (i32.const 0)) (i32.const 0))
|
||||||
|
(assert_return (invoke "eq" (i32.const 0) (i32.const 0x80000000)) (i32.const 0))
|
||||||
|
(assert_return (invoke "eq" (i32.const 0x80000000) (i32.const -1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "eq" (i32.const -1) (i32.const 0x80000000)) (i32.const 0))
|
||||||
|
(assert_return (invoke "eq" (i32.const 0x80000000) (i32.const 0x7fffffff)) (i32.const 0))
|
||||||
|
(assert_return (invoke "eq" (i32.const 0x7fffffff) (i32.const 0x80000000)) (i32.const 0))
|
||||||
|
|
||||||
|
(assert_return (invoke "ne" (i32.const 0) (i32.const 0)) (i32.const 0))
|
||||||
|
(assert_return (invoke "ne" (i32.const 1) (i32.const 1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "ne" (i32.const -1) (i32.const 1)) (i32.const 1))
|
||||||
|
(assert_return (invoke "ne" (i32.const 0x80000000) (i32.const 0x80000000)) (i32.const 0))
|
||||||
|
(assert_return (invoke "ne" (i32.const 0x7fffffff) (i32.const 0x7fffffff)) (i32.const 0))
|
||||||
|
(assert_return (invoke "ne" (i32.const -1) (i32.const -1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "ne" (i32.const 1) (i32.const 0)) (i32.const 1))
|
||||||
|
(assert_return (invoke "ne" (i32.const 0) (i32.const 1)) (i32.const 1))
|
||||||
|
(assert_return (invoke "ne" (i32.const 0x80000000) (i32.const 0)) (i32.const 1))
|
||||||
|
(assert_return (invoke "ne" (i32.const 0) (i32.const 0x80000000)) (i32.const 1))
|
||||||
|
(assert_return (invoke "ne" (i32.const 0x80000000) (i32.const -1)) (i32.const 1))
|
||||||
|
(assert_return (invoke "ne" (i32.const -1) (i32.const 0x80000000)) (i32.const 1))
|
||||||
|
(assert_return (invoke "ne" (i32.const 0x80000000) (i32.const 0x7fffffff)) (i32.const 1))
|
||||||
|
(assert_return (invoke "ne" (i32.const 0x7fffffff) (i32.const 0x80000000)) (i32.const 1))
|
||||||
|
|
||||||
|
(assert_return (invoke "lt_s" (i32.const 0) (i32.const 0)) (i32.const 0))
|
||||||
|
(assert_return (invoke "lt_s" (i32.const 1) (i32.const 1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "lt_s" (i32.const -1) (i32.const 1)) (i32.const 1))
|
||||||
|
(assert_return (invoke "lt_s" (i32.const 0x80000000) (i32.const 0x80000000)) (i32.const 0))
|
||||||
|
(assert_return (invoke "lt_s" (i32.const 0x7fffffff) (i32.const 0x7fffffff)) (i32.const 0))
|
||||||
|
(assert_return (invoke "lt_s" (i32.const -1) (i32.const -1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "lt_s" (i32.const 1) (i32.const 0)) (i32.const 0))
|
||||||
|
(assert_return (invoke "lt_s" (i32.const 0) (i32.const 1)) (i32.const 1))
|
||||||
|
(assert_return (invoke "lt_s" (i32.const 0x80000000) (i32.const 0)) (i32.const 1))
|
||||||
|
(assert_return (invoke "lt_s" (i32.const 0) (i32.const 0x80000000)) (i32.const 0))
|
||||||
|
(assert_return (invoke "lt_s" (i32.const 0x80000000) (i32.const -1)) (i32.const 1))
|
||||||
|
(assert_return (invoke "lt_s" (i32.const -1) (i32.const 0x80000000)) (i32.const 0))
|
||||||
|
(assert_return (invoke "lt_s" (i32.const 0x80000000) (i32.const 0x7fffffff)) (i32.const 1))
|
||||||
|
(assert_return (invoke "lt_s" (i32.const 0x7fffffff) (i32.const 0x80000000)) (i32.const 0))
|
||||||
|
|
||||||
|
(assert_return (invoke "lt_u" (i32.const 0) (i32.const 0)) (i32.const 0))
|
||||||
|
(assert_return (invoke "lt_u" (i32.const 1) (i32.const 1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "lt_u" (i32.const -1) (i32.const 1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "lt_u" (i32.const 0x80000000) (i32.const 0x80000000)) (i32.const 0))
|
||||||
|
(assert_return (invoke "lt_u" (i32.const 0x7fffffff) (i32.const 0x7fffffff)) (i32.const 0))
|
||||||
|
(assert_return (invoke "lt_u" (i32.const -1) (i32.const -1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "lt_u" (i32.const 1) (i32.const 0)) (i32.const 0))
|
||||||
|
(assert_return (invoke "lt_u" (i32.const 0) (i32.const 1)) (i32.const 1))
|
||||||
|
(assert_return (invoke "lt_u" (i32.const 0x80000000) (i32.const 0)) (i32.const 0))
|
||||||
|
(assert_return (invoke "lt_u" (i32.const 0) (i32.const 0x80000000)) (i32.const 1))
|
||||||
|
(assert_return (invoke "lt_u" (i32.const 0x80000000) (i32.const -1)) (i32.const 1))
|
||||||
|
(assert_return (invoke "lt_u" (i32.const -1) (i32.const 0x80000000)) (i32.const 0))
|
||||||
|
(assert_return (invoke "lt_u" (i32.const 0x80000000) (i32.const 0x7fffffff)) (i32.const 0))
|
||||||
|
(assert_return (invoke "lt_u" (i32.const 0x7fffffff) (i32.const 0x80000000)) (i32.const 1))
|
||||||
|
|
||||||
|
(assert_return (invoke "le_s" (i32.const 0) (i32.const 0)) (i32.const 1))
|
||||||
|
(assert_return (invoke "le_s" (i32.const 1) (i32.const 1)) (i32.const 1))
|
||||||
|
(assert_return (invoke "le_s" (i32.const -1) (i32.const 1)) (i32.const 1))
|
||||||
|
(assert_return (invoke "le_s" (i32.const 0x80000000) (i32.const 0x80000000)) (i32.const 1))
|
||||||
|
(assert_return (invoke "le_s" (i32.const 0x7fffffff) (i32.const 0x7fffffff)) (i32.const 1))
|
||||||
|
(assert_return (invoke "le_s" (i32.const -1) (i32.const -1)) (i32.const 1))
|
||||||
|
(assert_return (invoke "le_s" (i32.const 1) (i32.const 0)) (i32.const 0))
|
||||||
|
(assert_return (invoke "le_s" (i32.const 0) (i32.const 1)) (i32.const 1))
|
||||||
|
(assert_return (invoke "le_s" (i32.const 0x80000000) (i32.const 0)) (i32.const 1))
|
||||||
|
(assert_return (invoke "le_s" (i32.const 0) (i32.const 0x80000000)) (i32.const 0))
|
||||||
|
(assert_return (invoke "le_s" (i32.const 0x80000000) (i32.const -1)) (i32.const 1))
|
||||||
|
(assert_return (invoke "le_s" (i32.const -1) (i32.const 0x80000000)) (i32.const 0))
|
||||||
|
(assert_return (invoke "le_s" (i32.const 0x80000000) (i32.const 0x7fffffff)) (i32.const 1))
|
||||||
|
(assert_return (invoke "le_s" (i32.const 0x7fffffff) (i32.const 0x80000000)) (i32.const 0))
|
||||||
|
|
||||||
|
(assert_return (invoke "le_u" (i32.const 0) (i32.const 0)) (i32.const 1))
|
||||||
|
(assert_return (invoke "le_u" (i32.const 1) (i32.const 1)) (i32.const 1))
|
||||||
|
(assert_return (invoke "le_u" (i32.const -1) (i32.const 1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "le_u" (i32.const 0x80000000) (i32.const 0x80000000)) (i32.const 1))
|
||||||
|
(assert_return (invoke "le_u" (i32.const 0x7fffffff) (i32.const 0x7fffffff)) (i32.const 1))
|
||||||
|
(assert_return (invoke "le_u" (i32.const -1) (i32.const -1)) (i32.const 1))
|
||||||
|
(assert_return (invoke "le_u" (i32.const 1) (i32.const 0)) (i32.const 0))
|
||||||
|
(assert_return (invoke "le_u" (i32.const 0) (i32.const 1)) (i32.const 1))
|
||||||
|
(assert_return (invoke "le_u" (i32.const 0x80000000) (i32.const 0)) (i32.const 0))
|
||||||
|
(assert_return (invoke "le_u" (i32.const 0) (i32.const 0x80000000)) (i32.const 1))
|
||||||
|
(assert_return (invoke "le_u" (i32.const 0x80000000) (i32.const -1)) (i32.const 1))
|
||||||
|
(assert_return (invoke "le_u" (i32.const -1) (i32.const 0x80000000)) (i32.const 0))
|
||||||
|
(assert_return (invoke "le_u" (i32.const 0x80000000) (i32.const 0x7fffffff)) (i32.const 0))
|
||||||
|
(assert_return (invoke "le_u" (i32.const 0x7fffffff) (i32.const 0x80000000)) (i32.const 1))
|
||||||
|
|
||||||
|
(assert_return (invoke "gt_s" (i32.const 0) (i32.const 0)) (i32.const 0))
|
||||||
|
(assert_return (invoke "gt_s" (i32.const 1) (i32.const 1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "gt_s" (i32.const -1) (i32.const 1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "gt_s" (i32.const 0x80000000) (i32.const 0x80000000)) (i32.const 0))
|
||||||
|
(assert_return (invoke "gt_s" (i32.const 0x7fffffff) (i32.const 0x7fffffff)) (i32.const 0))
|
||||||
|
(assert_return (invoke "gt_s" (i32.const -1) (i32.const -1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "gt_s" (i32.const 1) (i32.const 0)) (i32.const 1))
|
||||||
|
(assert_return (invoke "gt_s" (i32.const 0) (i32.const 1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "gt_s" (i32.const 0x80000000) (i32.const 0)) (i32.const 0))
|
||||||
|
(assert_return (invoke "gt_s" (i32.const 0) (i32.const 0x80000000)) (i32.const 1))
|
||||||
|
(assert_return (invoke "gt_s" (i32.const 0x80000000) (i32.const -1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "gt_s" (i32.const -1) (i32.const 0x80000000)) (i32.const 1))
|
||||||
|
(assert_return (invoke "gt_s" (i32.const 0x80000000) (i32.const 0x7fffffff)) (i32.const 0))
|
||||||
|
(assert_return (invoke "gt_s" (i32.const 0x7fffffff) (i32.const 0x80000000)) (i32.const 1))
|
||||||
|
|
||||||
|
(assert_return (invoke "gt_u" (i32.const 0) (i32.const 0)) (i32.const 0))
|
||||||
|
(assert_return (invoke "gt_u" (i32.const 1) (i32.const 1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "gt_u" (i32.const -1) (i32.const 1)) (i32.const 1))
|
||||||
|
(assert_return (invoke "gt_u" (i32.const 0x80000000) (i32.const 0x80000000)) (i32.const 0))
|
||||||
|
(assert_return (invoke "gt_u" (i32.const 0x7fffffff) (i32.const 0x7fffffff)) (i32.const 0))
|
||||||
|
(assert_return (invoke "gt_u" (i32.const -1) (i32.const -1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "gt_u" (i32.const 1) (i32.const 0)) (i32.const 1))
|
||||||
|
(assert_return (invoke "gt_u" (i32.const 0) (i32.const 1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "gt_u" (i32.const 0x80000000) (i32.const 0)) (i32.const 1))
|
||||||
|
(assert_return (invoke "gt_u" (i32.const 0) (i32.const 0x80000000)) (i32.const 0))
|
||||||
|
(assert_return (invoke "gt_u" (i32.const 0x80000000) (i32.const -1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "gt_u" (i32.const -1) (i32.const 0x80000000)) (i32.const 1))
|
||||||
|
(assert_return (invoke "gt_u" (i32.const 0x80000000) (i32.const 0x7fffffff)) (i32.const 1))
|
||||||
|
(assert_return (invoke "gt_u" (i32.const 0x7fffffff) (i32.const 0x80000000)) (i32.const 0))
|
||||||
|
|
||||||
|
(assert_return (invoke "ge_s" (i32.const 0) (i32.const 0)) (i32.const 1))
|
||||||
|
(assert_return (invoke "ge_s" (i32.const 1) (i32.const 1)) (i32.const 1))
|
||||||
|
(assert_return (invoke "ge_s" (i32.const -1) (i32.const 1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "ge_s" (i32.const 0x80000000) (i32.const 0x80000000)) (i32.const 1))
|
||||||
|
(assert_return (invoke "ge_s" (i32.const 0x7fffffff) (i32.const 0x7fffffff)) (i32.const 1))
|
||||||
|
(assert_return (invoke "ge_s" (i32.const -1) (i32.const -1)) (i32.const 1))
|
||||||
|
(assert_return (invoke "ge_s" (i32.const 1) (i32.const 0)) (i32.const 1))
|
||||||
|
(assert_return (invoke "ge_s" (i32.const 0) (i32.const 1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "ge_s" (i32.const 0x80000000) (i32.const 0)) (i32.const 0))
|
||||||
|
(assert_return (invoke "ge_s" (i32.const 0) (i32.const 0x80000000)) (i32.const 1))
|
||||||
|
(assert_return (invoke "ge_s" (i32.const 0x80000000) (i32.const -1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "ge_s" (i32.const -1) (i32.const 0x80000000)) (i32.const 1))
|
||||||
|
(assert_return (invoke "ge_s" (i32.const 0x80000000) (i32.const 0x7fffffff)) (i32.const 0))
|
||||||
|
(assert_return (invoke "ge_s" (i32.const 0x7fffffff) (i32.const 0x80000000)) (i32.const 1))
|
||||||
|
|
||||||
|
(assert_return (invoke "ge_u" (i32.const 0) (i32.const 0)) (i32.const 1))
|
||||||
|
(assert_return (invoke "ge_u" (i32.const 1) (i32.const 1)) (i32.const 1))
|
||||||
|
(assert_return (invoke "ge_u" (i32.const -1) (i32.const 1)) (i32.const 1))
|
||||||
|
(assert_return (invoke "ge_u" (i32.const 0x80000000) (i32.const 0x80000000)) (i32.const 1))
|
||||||
|
(assert_return (invoke "ge_u" (i32.const 0x7fffffff) (i32.const 0x7fffffff)) (i32.const 1))
|
||||||
|
(assert_return (invoke "ge_u" (i32.const -1) (i32.const -1)) (i32.const 1))
|
||||||
|
(assert_return (invoke "ge_u" (i32.const 1) (i32.const 0)) (i32.const 1))
|
||||||
|
(assert_return (invoke "ge_u" (i32.const 0) (i32.const 1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "ge_u" (i32.const 0x80000000) (i32.const 0)) (i32.const 1))
|
||||||
|
(assert_return (invoke "ge_u" (i32.const 0) (i32.const 0x80000000)) (i32.const 0))
|
||||||
|
(assert_return (invoke "ge_u" (i32.const 0x80000000) (i32.const -1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "ge_u" (i32.const -1) (i32.const 0x80000000)) (i32.const 1))
|
||||||
|
(assert_return (invoke "ge_u" (i32.const 0x80000000) (i32.const 0x7fffffff)) (i32.const 1))
|
||||||
|
(assert_return (invoke "ge_u" (i32.const 0x7fffffff) (i32.const 0x80000000)) (i32.const 0))
|
||||||
@@ -0,0 +1,421 @@
|
|||||||
|
;; i64 operations
|
||||||
|
|
||||||
|
(module
|
||||||
|
(func (export "add") (param $x i64) (param $y i64) (result i64) (i64.add (get_local $x) (get_local $y)))
|
||||||
|
(func (export "sub") (param $x i64) (param $y i64) (result i64) (i64.sub (get_local $x) (get_local $y)))
|
||||||
|
(func (export "mul") (param $x i64) (param $y i64) (result i64) (i64.mul (get_local $x) (get_local $y)))
|
||||||
|
(func (export "div_s") (param $x i64) (param $y i64) (result i64) (i64.div_s (get_local $x) (get_local $y)))
|
||||||
|
(func (export "div_u") (param $x i64) (param $y i64) (result i64) (i64.div_u (get_local $x) (get_local $y)))
|
||||||
|
(func (export "rem_s") (param $x i64) (param $y i64) (result i64) (i64.rem_s (get_local $x) (get_local $y)))
|
||||||
|
(func (export "rem_u") (param $x i64) (param $y i64) (result i64) (i64.rem_u (get_local $x) (get_local $y)))
|
||||||
|
(func (export "and") (param $x i64) (param $y i64) (result i64) (i64.and (get_local $x) (get_local $y)))
|
||||||
|
(func (export "or") (param $x i64) (param $y i64) (result i64) (i64.or (get_local $x) (get_local $y)))
|
||||||
|
(func (export "xor") (param $x i64) (param $y i64) (result i64) (i64.xor (get_local $x) (get_local $y)))
|
||||||
|
(func (export "shl") (param $x i64) (param $y i64) (result i64) (i64.shl (get_local $x) (get_local $y)))
|
||||||
|
(func (export "shr_s") (param $x i64) (param $y i64) (result i64) (i64.shr_s (get_local $x) (get_local $y)))
|
||||||
|
(func (export "shr_u") (param $x i64) (param $y i64) (result i64) (i64.shr_u (get_local $x) (get_local $y)))
|
||||||
|
(func (export "rotl") (param $x i64) (param $y i64) (result i64) (i64.rotl (get_local $x) (get_local $y)))
|
||||||
|
(func (export "rotr") (param $x i64) (param $y i64) (result i64) (i64.rotr (get_local $x) (get_local $y)))
|
||||||
|
(func (export "clz") (param $x i64) (result i64) (i64.clz (get_local $x)))
|
||||||
|
(func (export "ctz") (param $x i64) (result i64) (i64.ctz (get_local $x)))
|
||||||
|
(func (export "popcnt") (param $x i64) (result i64) (i64.popcnt (get_local $x)))
|
||||||
|
(func (export "eqz") (param $x i64) (result i32) (i64.eqz (get_local $x)))
|
||||||
|
(func (export "eq") (param $x i64) (param $y i64) (result i32) (i64.eq (get_local $x) (get_local $y)))
|
||||||
|
(func (export "ne") (param $x i64) (param $y i64) (result i32) (i64.ne (get_local $x) (get_local $y)))
|
||||||
|
(func (export "lt_s") (param $x i64) (param $y i64) (result i32) (i64.lt_s (get_local $x) (get_local $y)))
|
||||||
|
(func (export "lt_u") (param $x i64) (param $y i64) (result i32) (i64.lt_u (get_local $x) (get_local $y)))
|
||||||
|
(func (export "le_s") (param $x i64) (param $y i64) (result i32) (i64.le_s (get_local $x) (get_local $y)))
|
||||||
|
(func (export "le_u") (param $x i64) (param $y i64) (result i32) (i64.le_u (get_local $x) (get_local $y)))
|
||||||
|
(func (export "gt_s") (param $x i64) (param $y i64) (result i32) (i64.gt_s (get_local $x) (get_local $y)))
|
||||||
|
(func (export "gt_u") (param $x i64) (param $y i64) (result i32) (i64.gt_u (get_local $x) (get_local $y)))
|
||||||
|
(func (export "ge_s") (param $x i64) (param $y i64) (result i32) (i64.ge_s (get_local $x) (get_local $y)))
|
||||||
|
(func (export "ge_u") (param $x i64) (param $y i64) (result i32) (i64.ge_u (get_local $x) (get_local $y)))
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke "add" (i64.const 1) (i64.const 1)) (i64.const 2))
|
||||||
|
(assert_return (invoke "add" (i64.const 1) (i64.const 0)) (i64.const 1))
|
||||||
|
(assert_return (invoke "add" (i64.const -1) (i64.const -1)) (i64.const -2))
|
||||||
|
(assert_return (invoke "add" (i64.const -1) (i64.const 1)) (i64.const 0))
|
||||||
|
(assert_return (invoke "add" (i64.const 0x7fffffffffffffff) (i64.const 1)) (i64.const 0x8000000000000000))
|
||||||
|
(assert_return (invoke "add" (i64.const 0x8000000000000000) (i64.const -1)) (i64.const 0x7fffffffffffffff))
|
||||||
|
(assert_return (invoke "add" (i64.const 0x8000000000000000) (i64.const 0x8000000000000000)) (i64.const 0))
|
||||||
|
(assert_return (invoke "add" (i64.const 0x3fffffff) (i64.const 1)) (i64.const 0x40000000))
|
||||||
|
|
||||||
|
(assert_return (invoke "sub" (i64.const 1) (i64.const 1)) (i64.const 0))
|
||||||
|
(assert_return (invoke "sub" (i64.const 1) (i64.const 0)) (i64.const 1))
|
||||||
|
(assert_return (invoke "sub" (i64.const -1) (i64.const -1)) (i64.const 0))
|
||||||
|
(assert_return (invoke "sub" (i64.const 0x7fffffffffffffff) (i64.const -1)) (i64.const 0x8000000000000000))
|
||||||
|
(assert_return (invoke "sub" (i64.const 0x8000000000000000) (i64.const 1)) (i64.const 0x7fffffffffffffff))
|
||||||
|
(assert_return (invoke "sub" (i64.const 0x8000000000000000) (i64.const 0x8000000000000000)) (i64.const 0))
|
||||||
|
(assert_return (invoke "sub" (i64.const 0x3fffffff) (i64.const -1)) (i64.const 0x40000000))
|
||||||
|
|
||||||
|
(assert_return (invoke "mul" (i64.const 1) (i64.const 1)) (i64.const 1))
|
||||||
|
(assert_return (invoke "mul" (i64.const 1) (i64.const 0)) (i64.const 0))
|
||||||
|
(assert_return (invoke "mul" (i64.const -1) (i64.const -1)) (i64.const 1))
|
||||||
|
(assert_return (invoke "mul" (i64.const 0x1000000000000000) (i64.const 4096)) (i64.const 0))
|
||||||
|
(assert_return (invoke "mul" (i64.const 0x8000000000000000) (i64.const 0)) (i64.const 0))
|
||||||
|
(assert_return (invoke "mul" (i64.const 0x8000000000000000) (i64.const -1)) (i64.const 0x8000000000000000))
|
||||||
|
(assert_return (invoke "mul" (i64.const 0x7fffffffffffffff) (i64.const -1)) (i64.const 0x8000000000000001))
|
||||||
|
(assert_return (invoke "mul" (i64.const 0x0123456789abcdef) (i64.const 0xfedcba9876543210)) (i64.const 0x2236d88fe5618cf0))
|
||||||
|
(assert_return (invoke "mul" (i64.const 0x7fffffffffffffff) (i64.const 0x7fffffffffffffff)) (i64.const 1))
|
||||||
|
|
||||||
|
(assert_trap (invoke "div_s" (i64.const 1) (i64.const 0)) "integer divide by zero")
|
||||||
|
(assert_trap (invoke "div_s" (i64.const 0) (i64.const 0)) "integer divide by zero")
|
||||||
|
(assert_trap (invoke "div_s" (i64.const 0x8000000000000000) (i64.const -1)) "integer overflow")
|
||||||
|
(assert_return (invoke "div_s" (i64.const 1) (i64.const 1)) (i64.const 1))
|
||||||
|
(assert_return (invoke "div_s" (i64.const 0) (i64.const 1)) (i64.const 0))
|
||||||
|
(assert_return (invoke "div_s" (i64.const 0) (i64.const -1)) (i64.const 0))
|
||||||
|
(assert_return (invoke "div_s" (i64.const -1) (i64.const -1)) (i64.const 1))
|
||||||
|
(assert_return (invoke "div_s" (i64.const 0x8000000000000000) (i64.const 2)) (i64.const 0xc000000000000000))
|
||||||
|
(assert_return (invoke "div_s" (i64.const 0x8000000000000001) (i64.const 1000)) (i64.const 0xffdf3b645a1cac09))
|
||||||
|
(assert_return (invoke "div_s" (i64.const 5) (i64.const 2)) (i64.const 2))
|
||||||
|
(assert_return (invoke "div_s" (i64.const -5) (i64.const 2)) (i64.const -2))
|
||||||
|
(assert_return (invoke "div_s" (i64.const 5) (i64.const -2)) (i64.const -2))
|
||||||
|
(assert_return (invoke "div_s" (i64.const -5) (i64.const -2)) (i64.const 2))
|
||||||
|
(assert_return (invoke "div_s" (i64.const 7) (i64.const 3)) (i64.const 2))
|
||||||
|
(assert_return (invoke "div_s" (i64.const -7) (i64.const 3)) (i64.const -2))
|
||||||
|
(assert_return (invoke "div_s" (i64.const 7) (i64.const -3)) (i64.const -2))
|
||||||
|
(assert_return (invoke "div_s" (i64.const -7) (i64.const -3)) (i64.const 2))
|
||||||
|
(assert_return (invoke "div_s" (i64.const 11) (i64.const 5)) (i64.const 2))
|
||||||
|
(assert_return (invoke "div_s" (i64.const 17) (i64.const 7)) (i64.const 2))
|
||||||
|
|
||||||
|
(assert_trap (invoke "div_u" (i64.const 1) (i64.const 0)) "integer divide by zero")
|
||||||
|
(assert_trap (invoke "div_u" (i64.const 0) (i64.const 0)) "integer divide by zero")
|
||||||
|
(assert_return (invoke "div_u" (i64.const 1) (i64.const 1)) (i64.const 1))
|
||||||
|
(assert_return (invoke "div_u" (i64.const 0) (i64.const 1)) (i64.const 0))
|
||||||
|
(assert_return (invoke "div_u" (i64.const -1) (i64.const -1)) (i64.const 1))
|
||||||
|
(assert_return (invoke "div_u" (i64.const 0x8000000000000000) (i64.const -1)) (i64.const 0))
|
||||||
|
(assert_return (invoke "div_u" (i64.const 0x8000000000000000) (i64.const 2)) (i64.const 0x4000000000000000))
|
||||||
|
(assert_return (invoke "div_u" (i64.const 0x8ff00ff00ff00ff0) (i64.const 0x100000001)) (i64.const 0x8ff00fef))
|
||||||
|
(assert_return (invoke "div_u" (i64.const 0x8000000000000001) (i64.const 1000)) (i64.const 0x20c49ba5e353f7))
|
||||||
|
(assert_return (invoke "div_u" (i64.const 5) (i64.const 2)) (i64.const 2))
|
||||||
|
(assert_return (invoke "div_u" (i64.const -5) (i64.const 2)) (i64.const 0x7ffffffffffffffd))
|
||||||
|
(assert_return (invoke "div_u" (i64.const 5) (i64.const -2)) (i64.const 0))
|
||||||
|
(assert_return (invoke "div_u" (i64.const -5) (i64.const -2)) (i64.const 0))
|
||||||
|
(assert_return (invoke "div_u" (i64.const 7) (i64.const 3)) (i64.const 2))
|
||||||
|
(assert_return (invoke "div_u" (i64.const 11) (i64.const 5)) (i64.const 2))
|
||||||
|
(assert_return (invoke "div_u" (i64.const 17) (i64.const 7)) (i64.const 2))
|
||||||
|
|
||||||
|
(assert_trap (invoke "rem_s" (i64.const 1) (i64.const 0)) "integer divide by zero")
|
||||||
|
(assert_trap (invoke "rem_s" (i64.const 0) (i64.const 0)) "integer divide by zero")
|
||||||
|
(assert_return (invoke "rem_s" (i64.const 0x7fffffffffffffff) (i64.const -1)) (i64.const 0))
|
||||||
|
(assert_return (invoke "rem_s" (i64.const 1) (i64.const 1)) (i64.const 0))
|
||||||
|
(assert_return (invoke "rem_s" (i64.const 0) (i64.const 1)) (i64.const 0))
|
||||||
|
(assert_return (invoke "rem_s" (i64.const 0) (i64.const -1)) (i64.const 0))
|
||||||
|
(assert_return (invoke "rem_s" (i64.const -1) (i64.const -1)) (i64.const 0))
|
||||||
|
(assert_return (invoke "rem_s" (i64.const 0x8000000000000000) (i64.const -1)) (i64.const 0))
|
||||||
|
(assert_return (invoke "rem_s" (i64.const 0x8000000000000000) (i64.const 2)) (i64.const 0))
|
||||||
|
(assert_return (invoke "rem_s" (i64.const 0x8000000000000001) (i64.const 1000)) (i64.const -807))
|
||||||
|
(assert_return (invoke "rem_s" (i64.const 5) (i64.const 2)) (i64.const 1))
|
||||||
|
(assert_return (invoke "rem_s" (i64.const -5) (i64.const 2)) (i64.const -1))
|
||||||
|
(assert_return (invoke "rem_s" (i64.const 5) (i64.const -2)) (i64.const 1))
|
||||||
|
(assert_return (invoke "rem_s" (i64.const -5) (i64.const -2)) (i64.const -1))
|
||||||
|
(assert_return (invoke "rem_s" (i64.const 7) (i64.const 3)) (i64.const 1))
|
||||||
|
(assert_return (invoke "rem_s" (i64.const -7) (i64.const 3)) (i64.const -1))
|
||||||
|
(assert_return (invoke "rem_s" (i64.const 7) (i64.const -3)) (i64.const 1))
|
||||||
|
(assert_return (invoke "rem_s" (i64.const -7) (i64.const -3)) (i64.const -1))
|
||||||
|
(assert_return (invoke "rem_s" (i64.const 11) (i64.const 5)) (i64.const 1))
|
||||||
|
(assert_return (invoke "rem_s" (i64.const 17) (i64.const 7)) (i64.const 3))
|
||||||
|
|
||||||
|
(assert_trap (invoke "rem_u" (i64.const 1) (i64.const 0)) "integer divide by zero")
|
||||||
|
(assert_trap (invoke "rem_u" (i64.const 0) (i64.const 0)) "integer divide by zero")
|
||||||
|
(assert_return (invoke "rem_u" (i64.const 1) (i64.const 1)) (i64.const 0))
|
||||||
|
(assert_return (invoke "rem_u" (i64.const 0) (i64.const 1)) (i64.const 0))
|
||||||
|
(assert_return (invoke "rem_u" (i64.const -1) (i64.const -1)) (i64.const 0))
|
||||||
|
(assert_return (invoke "rem_u" (i64.const 0x8000000000000000) (i64.const -1)) (i64.const 0x8000000000000000))
|
||||||
|
(assert_return (invoke "rem_u" (i64.const 0x8000000000000000) (i64.const 2)) (i64.const 0))
|
||||||
|
(assert_return (invoke "rem_u" (i64.const 0x8ff00ff00ff00ff0) (i64.const 0x100000001)) (i64.const 0x80000001))
|
||||||
|
(assert_return (invoke "rem_u" (i64.const 0x8000000000000001) (i64.const 1000)) (i64.const 809))
|
||||||
|
(assert_return (invoke "rem_u" (i64.const 5) (i64.const 2)) (i64.const 1))
|
||||||
|
(assert_return (invoke "rem_u" (i64.const -5) (i64.const 2)) (i64.const 1))
|
||||||
|
(assert_return (invoke "rem_u" (i64.const 5) (i64.const -2)) (i64.const 5))
|
||||||
|
(assert_return (invoke "rem_u" (i64.const -5) (i64.const -2)) (i64.const -5))
|
||||||
|
(assert_return (invoke "rem_u" (i64.const 7) (i64.const 3)) (i64.const 1))
|
||||||
|
(assert_return (invoke "rem_u" (i64.const 11) (i64.const 5)) (i64.const 1))
|
||||||
|
(assert_return (invoke "rem_u" (i64.const 17) (i64.const 7)) (i64.const 3))
|
||||||
|
|
||||||
|
(assert_return (invoke "and" (i64.const 1) (i64.const 0)) (i64.const 0))
|
||||||
|
(assert_return (invoke "and" (i64.const 0) (i64.const 1)) (i64.const 0))
|
||||||
|
(assert_return (invoke "and" (i64.const 1) (i64.const 1)) (i64.const 1))
|
||||||
|
(assert_return (invoke "and" (i64.const 0) (i64.const 0)) (i64.const 0))
|
||||||
|
(assert_return (invoke "and" (i64.const 0x7fffffffffffffff) (i64.const 0x8000000000000000)) (i64.const 0))
|
||||||
|
(assert_return (invoke "and" (i64.const 0x7fffffffffffffff) (i64.const -1)) (i64.const 0x7fffffffffffffff))
|
||||||
|
(assert_return (invoke "and" (i64.const 0xf0f0ffff) (i64.const 0xfffff0f0)) (i64.const 0xf0f0f0f0))
|
||||||
|
(assert_return (invoke "and" (i64.const 0xffffffffffffffff) (i64.const 0xffffffffffffffff)) (i64.const 0xffffffffffffffff))
|
||||||
|
|
||||||
|
(assert_return (invoke "or" (i64.const 1) (i64.const 0)) (i64.const 1))
|
||||||
|
(assert_return (invoke "or" (i64.const 0) (i64.const 1)) (i64.const 1))
|
||||||
|
(assert_return (invoke "or" (i64.const 1) (i64.const 1)) (i64.const 1))
|
||||||
|
(assert_return (invoke "or" (i64.const 0) (i64.const 0)) (i64.const 0))
|
||||||
|
(assert_return (invoke "or" (i64.const 0x7fffffffffffffff) (i64.const 0x8000000000000000)) (i64.const -1))
|
||||||
|
(assert_return (invoke "or" (i64.const 0x8000000000000000) (i64.const 0)) (i64.const 0x8000000000000000))
|
||||||
|
(assert_return (invoke "or" (i64.const 0xf0f0ffff) (i64.const 0xfffff0f0)) (i64.const 0xffffffff))
|
||||||
|
(assert_return (invoke "or" (i64.const 0xffffffffffffffff) (i64.const 0xffffffffffffffff)) (i64.const 0xffffffffffffffff))
|
||||||
|
|
||||||
|
(assert_return (invoke "xor" (i64.const 1) (i64.const 0)) (i64.const 1))
|
||||||
|
(assert_return (invoke "xor" (i64.const 0) (i64.const 1)) (i64.const 1))
|
||||||
|
(assert_return (invoke "xor" (i64.const 1) (i64.const 1)) (i64.const 0))
|
||||||
|
(assert_return (invoke "xor" (i64.const 0) (i64.const 0)) (i64.const 0))
|
||||||
|
(assert_return (invoke "xor" (i64.const 0x7fffffffffffffff) (i64.const 0x8000000000000000)) (i64.const -1))
|
||||||
|
(assert_return (invoke "xor" (i64.const 0x8000000000000000) (i64.const 0)) (i64.const 0x8000000000000000))
|
||||||
|
(assert_return (invoke "xor" (i64.const -1) (i64.const 0x8000000000000000)) (i64.const 0x7fffffffffffffff))
|
||||||
|
(assert_return (invoke "xor" (i64.const -1) (i64.const 0x7fffffffffffffff)) (i64.const 0x8000000000000000))
|
||||||
|
(assert_return (invoke "xor" (i64.const 0xf0f0ffff) (i64.const 0xfffff0f0)) (i64.const 0x0f0f0f0f))
|
||||||
|
(assert_return (invoke "xor" (i64.const 0xffffffffffffffff) (i64.const 0xffffffffffffffff)) (i64.const 0))
|
||||||
|
|
||||||
|
(assert_return (invoke "shl" (i64.const 1) (i64.const 1)) (i64.const 2))
|
||||||
|
(assert_return (invoke "shl" (i64.const 1) (i64.const 0)) (i64.const 1))
|
||||||
|
(assert_return (invoke "shl" (i64.const 0x7fffffffffffffff) (i64.const 1)) (i64.const 0xfffffffffffffffe))
|
||||||
|
(assert_return (invoke "shl" (i64.const 0xffffffffffffffff) (i64.const 1)) (i64.const 0xfffffffffffffffe))
|
||||||
|
(assert_return (invoke "shl" (i64.const 0x8000000000000000) (i64.const 1)) (i64.const 0))
|
||||||
|
(assert_return (invoke "shl" (i64.const 0x4000000000000000) (i64.const 1)) (i64.const 0x8000000000000000))
|
||||||
|
(assert_return (invoke "shl" (i64.const 1) (i64.const 63)) (i64.const 0x8000000000000000))
|
||||||
|
(assert_return (invoke "shl" (i64.const 1) (i64.const 64)) (i64.const 1))
|
||||||
|
(assert_return (invoke "shl" (i64.const 1) (i64.const 65)) (i64.const 2))
|
||||||
|
(assert_return (invoke "shl" (i64.const 1) (i64.const -1)) (i64.const 0x8000000000000000))
|
||||||
|
(assert_return (invoke "shl" (i64.const 1) (i64.const 0x7fffffffffffffff)) (i64.const 0x8000000000000000))
|
||||||
|
|
||||||
|
(assert_return (invoke "shr_s" (i64.const 1) (i64.const 1)) (i64.const 0))
|
||||||
|
(assert_return (invoke "shr_s" (i64.const 1) (i64.const 0)) (i64.const 1))
|
||||||
|
(assert_return (invoke "shr_s" (i64.const -1) (i64.const 1)) (i64.const -1))
|
||||||
|
(assert_return (invoke "shr_s" (i64.const 0x7fffffffffffffff) (i64.const 1)) (i64.const 0x3fffffffffffffff))
|
||||||
|
(assert_return (invoke "shr_s" (i64.const 0x8000000000000000) (i64.const 1)) (i64.const 0xc000000000000000))
|
||||||
|
(assert_return (invoke "shr_s" (i64.const 0x4000000000000000) (i64.const 1)) (i64.const 0x2000000000000000))
|
||||||
|
(assert_return (invoke "shr_s" (i64.const 1) (i64.const 64)) (i64.const 1))
|
||||||
|
(assert_return (invoke "shr_s" (i64.const 1) (i64.const 65)) (i64.const 0))
|
||||||
|
(assert_return (invoke "shr_s" (i64.const 1) (i64.const -1)) (i64.const 0))
|
||||||
|
(assert_return (invoke "shr_s" (i64.const 1) (i64.const 0x7fffffffffffffff)) (i64.const 0))
|
||||||
|
(assert_return (invoke "shr_s" (i64.const 1) (i64.const 0x8000000000000000)) (i64.const 1))
|
||||||
|
(assert_return (invoke "shr_s" (i64.const 0x8000000000000000) (i64.const 63)) (i64.const -1))
|
||||||
|
(assert_return (invoke "shr_s" (i64.const -1) (i64.const 64)) (i64.const -1))
|
||||||
|
(assert_return (invoke "shr_s" (i64.const -1) (i64.const 65)) (i64.const -1))
|
||||||
|
(assert_return (invoke "shr_s" (i64.const -1) (i64.const -1)) (i64.const -1))
|
||||||
|
(assert_return (invoke "shr_s" (i64.const -1) (i64.const 0x7fffffffffffffff)) (i64.const -1))
|
||||||
|
(assert_return (invoke "shr_s" (i64.const -1) (i64.const 0x8000000000000000)) (i64.const -1))
|
||||||
|
|
||||||
|
(assert_return (invoke "shr_u" (i64.const 1) (i64.const 1)) (i64.const 0))
|
||||||
|
(assert_return (invoke "shr_u" (i64.const 1) (i64.const 0)) (i64.const 1))
|
||||||
|
(assert_return (invoke "shr_u" (i64.const -1) (i64.const 1)) (i64.const 0x7fffffffffffffff))
|
||||||
|
(assert_return (invoke "shr_u" (i64.const 0x7fffffffffffffff) (i64.const 1)) (i64.const 0x3fffffffffffffff))
|
||||||
|
(assert_return (invoke "shr_u" (i64.const 0x8000000000000000) (i64.const 1)) (i64.const 0x4000000000000000))
|
||||||
|
(assert_return (invoke "shr_u" (i64.const 0x4000000000000000) (i64.const 1)) (i64.const 0x2000000000000000))
|
||||||
|
(assert_return (invoke "shr_u" (i64.const 1) (i64.const 64)) (i64.const 1))
|
||||||
|
(assert_return (invoke "shr_u" (i64.const 1) (i64.const 65)) (i64.const 0))
|
||||||
|
(assert_return (invoke "shr_u" (i64.const 1) (i64.const -1)) (i64.const 0))
|
||||||
|
(assert_return (invoke "shr_u" (i64.const 1) (i64.const 0x7fffffffffffffff)) (i64.const 0))
|
||||||
|
(assert_return (invoke "shr_u" (i64.const 1) (i64.const 0x8000000000000000)) (i64.const 1))
|
||||||
|
(assert_return (invoke "shr_u" (i64.const 0x8000000000000000) (i64.const 63)) (i64.const 1))
|
||||||
|
(assert_return (invoke "shr_u" (i64.const -1) (i64.const 64)) (i64.const -1))
|
||||||
|
(assert_return (invoke "shr_u" (i64.const -1) (i64.const 65)) (i64.const 0x7fffffffffffffff))
|
||||||
|
(assert_return (invoke "shr_u" (i64.const -1) (i64.const -1)) (i64.const 1))
|
||||||
|
(assert_return (invoke "shr_u" (i64.const -1) (i64.const 0x7fffffffffffffff)) (i64.const 1))
|
||||||
|
(assert_return (invoke "shr_u" (i64.const -1) (i64.const 0x8000000000000000)) (i64.const -1))
|
||||||
|
|
||||||
|
(assert_return (invoke "rotl" (i64.const 1) (i64.const 1)) (i64.const 2))
|
||||||
|
(assert_return (invoke "rotl" (i64.const 1) (i64.const 0)) (i64.const 1))
|
||||||
|
(assert_return (invoke "rotl" (i64.const -1) (i64.const 1)) (i64.const -1))
|
||||||
|
(assert_return (invoke "rotl" (i64.const 1) (i64.const 64)) (i64.const 1))
|
||||||
|
(assert_return (invoke "rotl" (i64.const 0xabcd987602468ace) (i64.const 1)) (i64.const 0x579b30ec048d159d))
|
||||||
|
(assert_return (invoke "rotl" (i64.const 0xfe000000dc000000) (i64.const 4)) (i64.const 0xe000000dc000000f))
|
||||||
|
(assert_return (invoke "rotl" (i64.const 0xabcd1234ef567809) (i64.const 53)) (i64.const 0x013579a2469deacf))
|
||||||
|
(assert_return (invoke "rotl" (i64.const 0xabd1234ef567809c) (i64.const 63)) (i64.const 0x55e891a77ab3c04e))
|
||||||
|
(assert_return (invoke "rotl" (i64.const 0xabcd1234ef567809) (i64.const 0xf5)) (i64.const 0x013579a2469deacf))
|
||||||
|
(assert_return (invoke "rotl" (i64.const 0xabcd7294ef567809) (i64.const 0xffffffffffffffed)) (i64.const 0xcf013579ae529dea))
|
||||||
|
(assert_return (invoke "rotl" (i64.const 0xabd1234ef567809c) (i64.const 0x800000000000003f)) (i64.const 0x55e891a77ab3c04e))
|
||||||
|
(assert_return (invoke "rotl" (i64.const 1) (i64.const 63)) (i64.const 0x8000000000000000))
|
||||||
|
(assert_return (invoke "rotl" (i64.const 0x8000000000000000) (i64.const 1)) (i64.const 1))
|
||||||
|
|
||||||
|
(assert_return (invoke "rotr" (i64.const 1) (i64.const 1)) (i64.const 0x8000000000000000))
|
||||||
|
(assert_return (invoke "rotr" (i64.const 1) (i64.const 0)) (i64.const 1))
|
||||||
|
(assert_return (invoke "rotr" (i64.const -1) (i64.const 1)) (i64.const -1))
|
||||||
|
(assert_return (invoke "rotr" (i64.const 1) (i64.const 64)) (i64.const 1))
|
||||||
|
(assert_return (invoke "rotr" (i64.const 0xabcd987602468ace) (i64.const 1)) (i64.const 0x55e6cc3b01234567))
|
||||||
|
(assert_return (invoke "rotr" (i64.const 0xfe000000dc000000) (i64.const 4)) (i64.const 0x0fe000000dc00000))
|
||||||
|
(assert_return (invoke "rotr" (i64.const 0xabcd1234ef567809) (i64.const 53)) (i64.const 0x6891a77ab3c04d5e))
|
||||||
|
(assert_return (invoke "rotr" (i64.const 0xabd1234ef567809c) (i64.const 63)) (i64.const 0x57a2469deacf0139))
|
||||||
|
(assert_return (invoke "rotr" (i64.const 0xabcd1234ef567809) (i64.const 0xf5)) (i64.const 0x6891a77ab3c04d5e))
|
||||||
|
(assert_return (invoke "rotr" (i64.const 0xabcd7294ef567809) (i64.const 0xffffffffffffffed)) (i64.const 0x94a77ab3c04d5e6b))
|
||||||
|
(assert_return (invoke "rotr" (i64.const 0xabd1234ef567809c) (i64.const 0x800000000000003f)) (i64.const 0x57a2469deacf0139))
|
||||||
|
(assert_return (invoke "rotr" (i64.const 1) (i64.const 63)) (i64.const 2))
|
||||||
|
(assert_return (invoke "rotr" (i64.const 0x8000000000000000) (i64.const 63)) (i64.const 1))
|
||||||
|
|
||||||
|
(assert_return (invoke "clz" (i64.const 0xffffffffffffffff)) (i64.const 0))
|
||||||
|
(assert_return (invoke "clz" (i64.const 0)) (i64.const 64))
|
||||||
|
(assert_return (invoke "clz" (i64.const 0x00008000)) (i64.const 48))
|
||||||
|
(assert_return (invoke "clz" (i64.const 0xff)) (i64.const 56))
|
||||||
|
(assert_return (invoke "clz" (i64.const 0x8000000000000000)) (i64.const 0))
|
||||||
|
(assert_return (invoke "clz" (i64.const 1)) (i64.const 63))
|
||||||
|
(assert_return (invoke "clz" (i64.const 2)) (i64.const 62))
|
||||||
|
(assert_return (invoke "clz" (i64.const 0x7fffffffffffffff)) (i64.const 1))
|
||||||
|
|
||||||
|
(assert_return (invoke "ctz" (i64.const -1)) (i64.const 0))
|
||||||
|
(assert_return (invoke "ctz" (i64.const 0)) (i64.const 64))
|
||||||
|
(assert_return (invoke "ctz" (i64.const 0x00008000)) (i64.const 15))
|
||||||
|
(assert_return (invoke "ctz" (i64.const 0x00010000)) (i64.const 16))
|
||||||
|
(assert_return (invoke "ctz" (i64.const 0x8000000000000000)) (i64.const 63))
|
||||||
|
(assert_return (invoke "ctz" (i64.const 0x7fffffffffffffff)) (i64.const 0))
|
||||||
|
|
||||||
|
(assert_return (invoke "popcnt" (i64.const -1)) (i64.const 64))
|
||||||
|
(assert_return (invoke "popcnt" (i64.const 0)) (i64.const 0))
|
||||||
|
(assert_return (invoke "popcnt" (i64.const 0x00008000)) (i64.const 1))
|
||||||
|
(assert_return (invoke "popcnt" (i64.const 0x8000800080008000)) (i64.const 4))
|
||||||
|
(assert_return (invoke "popcnt" (i64.const 0x7fffffffffffffff)) (i64.const 63))
|
||||||
|
(assert_return (invoke "popcnt" (i64.const 0xAAAAAAAA55555555)) (i64.const 32))
|
||||||
|
(assert_return (invoke "popcnt" (i64.const 0x99999999AAAAAAAA)) (i64.const 32))
|
||||||
|
(assert_return (invoke "popcnt" (i64.const 0xDEADBEEFDEADBEEF)) (i64.const 48))
|
||||||
|
|
||||||
|
(assert_return (invoke "eqz" (i64.const 0)) (i32.const 1))
|
||||||
|
(assert_return (invoke "eqz" (i64.const 1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "eqz" (i64.const 0x8000000000000000)) (i32.const 0))
|
||||||
|
(assert_return (invoke "eqz" (i64.const 0x7fffffffffffffff)) (i32.const 0))
|
||||||
|
(assert_return (invoke "eqz" (i64.const 0xffffffffffffffff)) (i32.const 0))
|
||||||
|
|
||||||
|
(assert_return (invoke "eq" (i64.const 0) (i64.const 0)) (i32.const 1))
|
||||||
|
(assert_return (invoke "eq" (i64.const 1) (i64.const 1)) (i32.const 1))
|
||||||
|
(assert_return (invoke "eq" (i64.const -1) (i64.const 1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "eq" (i64.const 0x8000000000000000) (i64.const 0x8000000000000000)) (i32.const 1))
|
||||||
|
(assert_return (invoke "eq" (i64.const 0x7fffffffffffffff) (i64.const 0x7fffffffffffffff)) (i32.const 1))
|
||||||
|
(assert_return (invoke "eq" (i64.const -1) (i64.const -1)) (i32.const 1))
|
||||||
|
(assert_return (invoke "eq" (i64.const 1) (i64.const 0)) (i32.const 0))
|
||||||
|
(assert_return (invoke "eq" (i64.const 0) (i64.const 1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "eq" (i64.const 0x8000000000000000) (i64.const 0)) (i32.const 0))
|
||||||
|
(assert_return (invoke "eq" (i64.const 0) (i64.const 0x8000000000000000)) (i32.const 0))
|
||||||
|
(assert_return (invoke "eq" (i64.const 0x8000000000000000) (i64.const -1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "eq" (i64.const -1) (i64.const 0x8000000000000000)) (i32.const 0))
|
||||||
|
(assert_return (invoke "eq" (i64.const 0x8000000000000000) (i64.const 0x7fffffffffffffff)) (i32.const 0))
|
||||||
|
(assert_return (invoke "eq" (i64.const 0x7fffffffffffffff) (i64.const 0x8000000000000000)) (i32.const 0))
|
||||||
|
|
||||||
|
(assert_return (invoke "ne" (i64.const 0) (i64.const 0)) (i32.const 0))
|
||||||
|
(assert_return (invoke "ne" (i64.const 1) (i64.const 1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "ne" (i64.const -1) (i64.const 1)) (i32.const 1))
|
||||||
|
(assert_return (invoke "ne" (i64.const 0x8000000000000000) (i64.const 0x8000000000000000)) (i32.const 0))
|
||||||
|
(assert_return (invoke "ne" (i64.const 0x7fffffffffffffff) (i64.const 0x7fffffffffffffff)) (i32.const 0))
|
||||||
|
(assert_return (invoke "ne" (i64.const -1) (i64.const -1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "ne" (i64.const 1) (i64.const 0)) (i32.const 1))
|
||||||
|
(assert_return (invoke "ne" (i64.const 0) (i64.const 1)) (i32.const 1))
|
||||||
|
(assert_return (invoke "ne" (i64.const 0x8000000000000000) (i64.const 0)) (i32.const 1))
|
||||||
|
(assert_return (invoke "ne" (i64.const 0) (i64.const 0x8000000000000000)) (i32.const 1))
|
||||||
|
(assert_return (invoke "ne" (i64.const 0x8000000000000000) (i64.const -1)) (i32.const 1))
|
||||||
|
(assert_return (invoke "ne" (i64.const -1) (i64.const 0x8000000000000000)) (i32.const 1))
|
||||||
|
(assert_return (invoke "ne" (i64.const 0x8000000000000000) (i64.const 0x7fffffffffffffff)) (i32.const 1))
|
||||||
|
(assert_return (invoke "ne" (i64.const 0x7fffffffffffffff) (i64.const 0x8000000000000000)) (i32.const 1))
|
||||||
|
|
||||||
|
(assert_return (invoke "lt_s" (i64.const 0) (i64.const 0)) (i32.const 0))
|
||||||
|
(assert_return (invoke "lt_s" (i64.const 1) (i64.const 1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "lt_s" (i64.const -1) (i64.const 1)) (i32.const 1))
|
||||||
|
(assert_return (invoke "lt_s" (i64.const 0x8000000000000000) (i64.const 0x8000000000000000)) (i32.const 0))
|
||||||
|
(assert_return (invoke "lt_s" (i64.const 0x7fffffffffffffff) (i64.const 0x7fffffffffffffff)) (i32.const 0))
|
||||||
|
(assert_return (invoke "lt_s" (i64.const -1) (i64.const -1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "lt_s" (i64.const 1) (i64.const 0)) (i32.const 0))
|
||||||
|
(assert_return (invoke "lt_s" (i64.const 0) (i64.const 1)) (i32.const 1))
|
||||||
|
(assert_return (invoke "lt_s" (i64.const 0x8000000000000000) (i64.const 0)) (i32.const 1))
|
||||||
|
(assert_return (invoke "lt_s" (i64.const 0) (i64.const 0x8000000000000000)) (i32.const 0))
|
||||||
|
(assert_return (invoke "lt_s" (i64.const 0x8000000000000000) (i64.const -1)) (i32.const 1))
|
||||||
|
(assert_return (invoke "lt_s" (i64.const -1) (i64.const 0x8000000000000000)) (i32.const 0))
|
||||||
|
(assert_return (invoke "lt_s" (i64.const 0x8000000000000000) (i64.const 0x7fffffffffffffff)) (i32.const 1))
|
||||||
|
(assert_return (invoke "lt_s" (i64.const 0x7fffffffffffffff) (i64.const 0x8000000000000000)) (i32.const 0))
|
||||||
|
|
||||||
|
(assert_return (invoke "lt_u" (i64.const 0) (i64.const 0)) (i32.const 0))
|
||||||
|
(assert_return (invoke "lt_u" (i64.const 1) (i64.const 1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "lt_u" (i64.const -1) (i64.const 1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "lt_u" (i64.const 0x8000000000000000) (i64.const 0x8000000000000000)) (i32.const 0))
|
||||||
|
(assert_return (invoke "lt_u" (i64.const 0x7fffffffffffffff) (i64.const 0x7fffffffffffffff)) (i32.const 0))
|
||||||
|
(assert_return (invoke "lt_u" (i64.const -1) (i64.const -1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "lt_u" (i64.const 1) (i64.const 0)) (i32.const 0))
|
||||||
|
(assert_return (invoke "lt_u" (i64.const 0) (i64.const 1)) (i32.const 1))
|
||||||
|
(assert_return (invoke "lt_u" (i64.const 0x8000000000000000) (i64.const 0)) (i32.const 0))
|
||||||
|
(assert_return (invoke "lt_u" (i64.const 0) (i64.const 0x8000000000000000)) (i32.const 1))
|
||||||
|
(assert_return (invoke "lt_u" (i64.const 0x8000000000000000) (i64.const -1)) (i32.const 1))
|
||||||
|
(assert_return (invoke "lt_u" (i64.const -1) (i64.const 0x8000000000000000)) (i32.const 0))
|
||||||
|
(assert_return (invoke "lt_u" (i64.const 0x8000000000000000) (i64.const 0x7fffffffffffffff)) (i32.const 0))
|
||||||
|
(assert_return (invoke "lt_u" (i64.const 0x7fffffffffffffff) (i64.const 0x8000000000000000)) (i32.const 1))
|
||||||
|
|
||||||
|
(assert_return (invoke "le_s" (i64.const 0) (i64.const 0)) (i32.const 1))
|
||||||
|
(assert_return (invoke "le_s" (i64.const 1) (i64.const 1)) (i32.const 1))
|
||||||
|
(assert_return (invoke "le_s" (i64.const -1) (i64.const 1)) (i32.const 1))
|
||||||
|
(assert_return (invoke "le_s" (i64.const 0x8000000000000000) (i64.const 0x8000000000000000)) (i32.const 1))
|
||||||
|
(assert_return (invoke "le_s" (i64.const 0x7fffffffffffffff) (i64.const 0x7fffffffffffffff)) (i32.const 1))
|
||||||
|
(assert_return (invoke "le_s" (i64.const -1) (i64.const -1)) (i32.const 1))
|
||||||
|
(assert_return (invoke "le_s" (i64.const 1) (i64.const 0)) (i32.const 0))
|
||||||
|
(assert_return (invoke "le_s" (i64.const 0) (i64.const 1)) (i32.const 1))
|
||||||
|
(assert_return (invoke "le_s" (i64.const 0x8000000000000000) (i64.const 0)) (i32.const 1))
|
||||||
|
(assert_return (invoke "le_s" (i64.const 0) (i64.const 0x8000000000000000)) (i32.const 0))
|
||||||
|
(assert_return (invoke "le_s" (i64.const 0x8000000000000000) (i64.const -1)) (i32.const 1))
|
||||||
|
(assert_return (invoke "le_s" (i64.const -1) (i64.const 0x8000000000000000)) (i32.const 0))
|
||||||
|
(assert_return (invoke "le_s" (i64.const 0x8000000000000000) (i64.const 0x7fffffffffffffff)) (i32.const 1))
|
||||||
|
(assert_return (invoke "le_s" (i64.const 0x7fffffffffffffff) (i64.const 0x8000000000000000)) (i32.const 0))
|
||||||
|
|
||||||
|
(assert_return (invoke "le_u" (i64.const 0) (i64.const 0)) (i32.const 1))
|
||||||
|
(assert_return (invoke "le_u" (i64.const 1) (i64.const 1)) (i32.const 1))
|
||||||
|
(assert_return (invoke "le_u" (i64.const -1) (i64.const 1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "le_u" (i64.const 0x8000000000000000) (i64.const 0x8000000000000000)) (i32.const 1))
|
||||||
|
(assert_return (invoke "le_u" (i64.const 0x7fffffffffffffff) (i64.const 0x7fffffffffffffff)) (i32.const 1))
|
||||||
|
(assert_return (invoke "le_u" (i64.const -1) (i64.const -1)) (i32.const 1))
|
||||||
|
(assert_return (invoke "le_u" (i64.const 1) (i64.const 0)) (i32.const 0))
|
||||||
|
(assert_return (invoke "le_u" (i64.const 0) (i64.const 1)) (i32.const 1))
|
||||||
|
(assert_return (invoke "le_u" (i64.const 0x8000000000000000) (i64.const 0)) (i32.const 0))
|
||||||
|
(assert_return (invoke "le_u" (i64.const 0) (i64.const 0x8000000000000000)) (i32.const 1))
|
||||||
|
(assert_return (invoke "le_u" (i64.const 0x8000000000000000) (i64.const -1)) (i32.const 1))
|
||||||
|
(assert_return (invoke "le_u" (i64.const -1) (i64.const 0x8000000000000000)) (i32.const 0))
|
||||||
|
(assert_return (invoke "le_u" (i64.const 0x8000000000000000) (i64.const 0x7fffffffffffffff)) (i32.const 0))
|
||||||
|
(assert_return (invoke "le_u" (i64.const 0x7fffffffffffffff) (i64.const 0x8000000000000000)) (i32.const 1))
|
||||||
|
|
||||||
|
(assert_return (invoke "gt_s" (i64.const 0) (i64.const 0)) (i32.const 0))
|
||||||
|
(assert_return (invoke "gt_s" (i64.const 1) (i64.const 1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "gt_s" (i64.const -1) (i64.const 1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "gt_s" (i64.const 0x8000000000000000) (i64.const 0x8000000000000000)) (i32.const 0))
|
||||||
|
(assert_return (invoke "gt_s" (i64.const 0x7fffffffffffffff) (i64.const 0x7fffffffffffffff)) (i32.const 0))
|
||||||
|
(assert_return (invoke "gt_s" (i64.const -1) (i64.const -1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "gt_s" (i64.const 1) (i64.const 0)) (i32.const 1))
|
||||||
|
(assert_return (invoke "gt_s" (i64.const 0) (i64.const 1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "gt_s" (i64.const 0x8000000000000000) (i64.const 0)) (i32.const 0))
|
||||||
|
(assert_return (invoke "gt_s" (i64.const 0) (i64.const 0x8000000000000000)) (i32.const 1))
|
||||||
|
(assert_return (invoke "gt_s" (i64.const 0x8000000000000000) (i64.const -1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "gt_s" (i64.const -1) (i64.const 0x8000000000000000)) (i32.const 1))
|
||||||
|
(assert_return (invoke "gt_s" (i64.const 0x8000000000000000) (i64.const 0x7fffffffffffffff)) (i32.const 0))
|
||||||
|
(assert_return (invoke "gt_s" (i64.const 0x7fffffffffffffff) (i64.const 0x8000000000000000)) (i32.const 1))
|
||||||
|
|
||||||
|
(assert_return (invoke "gt_u" (i64.const 0) (i64.const 0)) (i32.const 0))
|
||||||
|
(assert_return (invoke "gt_u" (i64.const 1) (i64.const 1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "gt_u" (i64.const -1) (i64.const 1)) (i32.const 1))
|
||||||
|
(assert_return (invoke "gt_u" (i64.const 0x8000000000000000) (i64.const 0x8000000000000000)) (i32.const 0))
|
||||||
|
(assert_return (invoke "gt_u" (i64.const 0x7fffffffffffffff) (i64.const 0x7fffffffffffffff)) (i32.const 0))
|
||||||
|
(assert_return (invoke "gt_u" (i64.const -1) (i64.const -1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "gt_u" (i64.const 1) (i64.const 0)) (i32.const 1))
|
||||||
|
(assert_return (invoke "gt_u" (i64.const 0) (i64.const 1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "gt_u" (i64.const 0x8000000000000000) (i64.const 0)) (i32.const 1))
|
||||||
|
(assert_return (invoke "gt_u" (i64.const 0) (i64.const 0x8000000000000000)) (i32.const 0))
|
||||||
|
(assert_return (invoke "gt_u" (i64.const 0x8000000000000000) (i64.const -1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "gt_u" (i64.const -1) (i64.const 0x8000000000000000)) (i32.const 1))
|
||||||
|
(assert_return (invoke "gt_u" (i64.const 0x8000000000000000) (i64.const 0x7fffffffffffffff)) (i32.const 1))
|
||||||
|
(assert_return (invoke "gt_u" (i64.const 0x7fffffffffffffff) (i64.const 0x8000000000000000)) (i32.const 0))
|
||||||
|
|
||||||
|
(assert_return (invoke "ge_s" (i64.const 0) (i64.const 0)) (i32.const 1))
|
||||||
|
(assert_return (invoke "ge_s" (i64.const 1) (i64.const 1)) (i32.const 1))
|
||||||
|
(assert_return (invoke "ge_s" (i64.const -1) (i64.const 1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "ge_s" (i64.const 0x8000000000000000) (i64.const 0x8000000000000000)) (i32.const 1))
|
||||||
|
(assert_return (invoke "ge_s" (i64.const 0x7fffffffffffffff) (i64.const 0x7fffffffffffffff)) (i32.const 1))
|
||||||
|
(assert_return (invoke "ge_s" (i64.const -1) (i64.const -1)) (i32.const 1))
|
||||||
|
(assert_return (invoke "ge_s" (i64.const 1) (i64.const 0)) (i32.const 1))
|
||||||
|
(assert_return (invoke "ge_s" (i64.const 0) (i64.const 1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "ge_s" (i64.const 0x8000000000000000) (i64.const 0)) (i32.const 0))
|
||||||
|
(assert_return (invoke "ge_s" (i64.const 0) (i64.const 0x8000000000000000)) (i32.const 1))
|
||||||
|
(assert_return (invoke "ge_s" (i64.const 0x8000000000000000) (i64.const -1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "ge_s" (i64.const -1) (i64.const 0x8000000000000000)) (i32.const 1))
|
||||||
|
(assert_return (invoke "ge_s" (i64.const 0x8000000000000000) (i64.const 0x7fffffffffffffff)) (i32.const 0))
|
||||||
|
(assert_return (invoke "ge_s" (i64.const 0x7fffffffffffffff) (i64.const 0x8000000000000000)) (i32.const 1))
|
||||||
|
|
||||||
|
(assert_return (invoke "ge_u" (i64.const 0) (i64.const 0)) (i32.const 1))
|
||||||
|
(assert_return (invoke "ge_u" (i64.const 1) (i64.const 1)) (i32.const 1))
|
||||||
|
(assert_return (invoke "ge_u" (i64.const -1) (i64.const 1)) (i32.const 1))
|
||||||
|
(assert_return (invoke "ge_u" (i64.const 0x8000000000000000) (i64.const 0x8000000000000000)) (i32.const 1))
|
||||||
|
(assert_return (invoke "ge_u" (i64.const 0x7fffffffffffffff) (i64.const 0x7fffffffffffffff)) (i32.const 1))
|
||||||
|
(assert_return (invoke "ge_u" (i64.const -1) (i64.const -1)) (i32.const 1))
|
||||||
|
(assert_return (invoke "ge_u" (i64.const 1) (i64.const 0)) (i32.const 1))
|
||||||
|
(assert_return (invoke "ge_u" (i64.const 0) (i64.const 1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "ge_u" (i64.const 0x8000000000000000) (i64.const 0)) (i32.const 1))
|
||||||
|
(assert_return (invoke "ge_u" (i64.const 0) (i64.const 0x8000000000000000)) (i32.const 0))
|
||||||
|
(assert_return (invoke "ge_u" (i64.const 0x8000000000000000) (i64.const -1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "ge_u" (i64.const -1) (i64.const 0x8000000000000000)) (i32.const 1))
|
||||||
|
(assert_return (invoke "ge_u" (i64.const 0x8000000000000000) (i64.const 0x7fffffffffffffff)) (i32.const 1))
|
||||||
|
(assert_return (invoke "ge_u" (i64.const 0x7fffffffffffffff) (i64.const 0x8000000000000000)) (i32.const 0))
|
||||||
@@ -0,0 +1,449 @@
|
|||||||
|
;; Test `if` operator
|
||||||
|
|
||||||
|
(module
|
||||||
|
;; Auxiliary definition
|
||||||
|
(func $dummy)
|
||||||
|
|
||||||
|
(func (export "empty") (param i32)
|
||||||
|
(if (get_local 0) (then))
|
||||||
|
(if (get_local 0) (then) (else))
|
||||||
|
(if $l (get_local 0) (then))
|
||||||
|
(if $l (get_local 0) (then) (else))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "singular") (param i32) (result i32)
|
||||||
|
(if (get_local 0) (then (nop)))
|
||||||
|
(if (get_local 0) (then (nop)) (else (nop)))
|
||||||
|
(if (result i32) (get_local 0) (then (i32.const 7)) (else (i32.const 8)))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "multi") (param i32) (result i32)
|
||||||
|
(if (get_local 0) (then (call $dummy) (call $dummy) (call $dummy)))
|
||||||
|
(if (get_local 0) (then) (else (call $dummy) (call $dummy) (call $dummy)))
|
||||||
|
(if (result i32) (get_local 0)
|
||||||
|
(then (call $dummy) (call $dummy) (i32.const 8))
|
||||||
|
(else (call $dummy) (call $dummy) (i32.const 9))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "nested") (param i32 i32) (result i32)
|
||||||
|
(if (result i32) (get_local 0)
|
||||||
|
(then
|
||||||
|
(if (get_local 1) (then (call $dummy) (block) (nop)))
|
||||||
|
(if (get_local 1) (then) (else (call $dummy) (block) (nop)))
|
||||||
|
(if (result i32) (get_local 1)
|
||||||
|
(then (call $dummy) (i32.const 9))
|
||||||
|
(else (call $dummy) (i32.const 10))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(else
|
||||||
|
(if (get_local 1) (then (call $dummy) (block) (nop)))
|
||||||
|
(if (get_local 1) (then) (else (call $dummy) (block) (nop)))
|
||||||
|
(if (result i32) (get_local 1)
|
||||||
|
(then (call $dummy) (i32.const 10))
|
||||||
|
(else (call $dummy) (i32.const 11))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "as-unary-operand") (param i32) (result i32)
|
||||||
|
(i32.ctz
|
||||||
|
(if (result i32) (get_local 0)
|
||||||
|
(then (call $dummy) (i32.const 13))
|
||||||
|
(else (call $dummy) (i32.const -13))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(func (export "as-binary-operand") (param i32 i32) (result i32)
|
||||||
|
(i32.mul
|
||||||
|
(if (result i32) (get_local 0)
|
||||||
|
(then (call $dummy) (i32.const 3))
|
||||||
|
(else (call $dummy) (i32.const -3))
|
||||||
|
)
|
||||||
|
(if (result i32) (get_local 1)
|
||||||
|
(then (call $dummy) (i32.const 4))
|
||||||
|
(else (call $dummy) (i32.const -5))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(func (export "as-test-operand") (param i32) (result i32)
|
||||||
|
(i32.eqz
|
||||||
|
(if (result i32) (get_local 0)
|
||||||
|
(then (call $dummy) (i32.const 13))
|
||||||
|
(else (call $dummy) (i32.const 0))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(func (export "as-compare-operand") (param i32 i32) (result i32)
|
||||||
|
(f32.gt
|
||||||
|
(if (result f32) (get_local 0)
|
||||||
|
(then (call $dummy) (f32.const 3))
|
||||||
|
(else (call $dummy) (f32.const -3))
|
||||||
|
)
|
||||||
|
(if (result f32) (get_local 1)
|
||||||
|
(then (call $dummy) (f32.const 4))
|
||||||
|
(else (call $dummy) (f32.const -4))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "break-bare") (result i32)
|
||||||
|
(if (i32.const 1) (then (br 0) (unreachable)))
|
||||||
|
(if (i32.const 1) (then (br 0) (unreachable)) (else (unreachable)))
|
||||||
|
(if (i32.const 0) (then (unreachable)) (else (br 0) (unreachable)))
|
||||||
|
(if (i32.const 1) (then (br_if 0 (i32.const 1)) (unreachable)))
|
||||||
|
(if (i32.const 1) (then (br_if 0 (i32.const 1)) (unreachable)) (else (unreachable)))
|
||||||
|
(if (i32.const 0) (then (unreachable)) (else (br_if 0 (i32.const 1)) (unreachable)))
|
||||||
|
(if (i32.const 1) (then (br_table 0 (i32.const 0)) (unreachable)))
|
||||||
|
(if (i32.const 1) (then (br_table 0 (i32.const 0)) (unreachable)) (else (unreachable)))
|
||||||
|
(if (i32.const 0) (then (unreachable)) (else (br_table 0 (i32.const 0)) (unreachable)))
|
||||||
|
(i32.const 19)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "break-value") (param i32) (result i32)
|
||||||
|
(if (result i32) (get_local 0)
|
||||||
|
(then (br 0 (i32.const 18)) (i32.const 19))
|
||||||
|
(else (br 0 (i32.const 21)) (i32.const 20))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "effects") (param i32) (result i32)
|
||||||
|
(local i32)
|
||||||
|
(if
|
||||||
|
(block (result i32) (set_local 1 (i32.const 1)) (get_local 0))
|
||||||
|
(then
|
||||||
|
(set_local 1 (i32.mul (get_local 1) (i32.const 3)))
|
||||||
|
(set_local 1 (i32.sub (get_local 1) (i32.const 5)))
|
||||||
|
(set_local 1 (i32.mul (get_local 1) (i32.const 7)))
|
||||||
|
(br 0)
|
||||||
|
(set_local 1 (i32.mul (get_local 1) (i32.const 100)))
|
||||||
|
)
|
||||||
|
(else
|
||||||
|
(set_local 1 (i32.mul (get_local 1) (i32.const 5)))
|
||||||
|
(set_local 1 (i32.sub (get_local 1) (i32.const 7)))
|
||||||
|
(set_local 1 (i32.mul (get_local 1) (i32.const 3)))
|
||||||
|
(br 0)
|
||||||
|
(set_local 1 (i32.mul (get_local 1) (i32.const 1000)))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(get_local 1)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke "empty" (i32.const 0)))
|
||||||
|
(assert_return (invoke "empty" (i32.const 1)))
|
||||||
|
(assert_return (invoke "empty" (i32.const 100)))
|
||||||
|
(assert_return (invoke "empty" (i32.const -2)))
|
||||||
|
|
||||||
|
(assert_return (invoke "singular" (i32.const 0)) (i32.const 8))
|
||||||
|
(assert_return (invoke "singular" (i32.const 1)) (i32.const 7))
|
||||||
|
(assert_return (invoke "singular" (i32.const 10)) (i32.const 7))
|
||||||
|
(assert_return (invoke "singular" (i32.const -10)) (i32.const 7))
|
||||||
|
|
||||||
|
(assert_return (invoke "multi" (i32.const 0)) (i32.const 9))
|
||||||
|
(assert_return (invoke "multi" (i32.const 1)) (i32.const 8))
|
||||||
|
(assert_return (invoke "multi" (i32.const 13)) (i32.const 8))
|
||||||
|
(assert_return (invoke "multi" (i32.const -5)) (i32.const 8))
|
||||||
|
|
||||||
|
(assert_return (invoke "nested" (i32.const 0) (i32.const 0)) (i32.const 11))
|
||||||
|
(assert_return (invoke "nested" (i32.const 1) (i32.const 0)) (i32.const 10))
|
||||||
|
(assert_return (invoke "nested" (i32.const 0) (i32.const 1)) (i32.const 10))
|
||||||
|
(assert_return (invoke "nested" (i32.const 3) (i32.const 2)) (i32.const 9))
|
||||||
|
(assert_return (invoke "nested" (i32.const 0) (i32.const -100)) (i32.const 10))
|
||||||
|
(assert_return (invoke "nested" (i32.const 10) (i32.const 10)) (i32.const 9))
|
||||||
|
(assert_return (invoke "nested" (i32.const 0) (i32.const -1)) (i32.const 10))
|
||||||
|
(assert_return (invoke "nested" (i32.const -111) (i32.const -2)) (i32.const 9))
|
||||||
|
|
||||||
|
(assert_return (invoke "as-unary-operand" (i32.const 0)) (i32.const 0))
|
||||||
|
(assert_return (invoke "as-unary-operand" (i32.const 1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "as-unary-operand" (i32.const -1)) (i32.const 0))
|
||||||
|
|
||||||
|
(assert_return (invoke "as-binary-operand" (i32.const 0) (i32.const 0)) (i32.const 15))
|
||||||
|
(assert_return (invoke "as-binary-operand" (i32.const 0) (i32.const 1)) (i32.const -12))
|
||||||
|
(assert_return (invoke "as-binary-operand" (i32.const 1) (i32.const 0)) (i32.const -15))
|
||||||
|
(assert_return (invoke "as-binary-operand" (i32.const 1) (i32.const 1)) (i32.const 12))
|
||||||
|
|
||||||
|
(assert_return (invoke "as-test-operand" (i32.const 0)) (i32.const 1))
|
||||||
|
(assert_return (invoke "as-test-operand" (i32.const 1)) (i32.const 0))
|
||||||
|
|
||||||
|
(assert_return (invoke "as-compare-operand" (i32.const 0) (i32.const 0)) (i32.const 1))
|
||||||
|
(assert_return (invoke "as-compare-operand" (i32.const 0) (i32.const 1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "as-compare-operand" (i32.const 1) (i32.const 0)) (i32.const 1))
|
||||||
|
(assert_return (invoke "as-compare-operand" (i32.const 1) (i32.const 1)) (i32.const 0))
|
||||||
|
|
||||||
|
(assert_return (invoke "break-bare") (i32.const 19))
|
||||||
|
(assert_return (invoke "break-value" (i32.const 1)) (i32.const 18))
|
||||||
|
(assert_return (invoke "break-value" (i32.const 0)) (i32.const 21))
|
||||||
|
|
||||||
|
(assert_return (invoke "effects" (i32.const 1)) (i32.const -14))
|
||||||
|
(assert_return (invoke "effects" (i32.const 0)) (i32.const -6))
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-empty-i32 (result i32) (if (i32.const 0) (then))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-empty-i64 (result i64) (if (i32.const 0) (then))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-empty-f32 (result f32) (if (i32.const 0) (then))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-empty-f64 (result f64) (if (i32.const 0) (then))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-empty-i32 (result i32) (if (i32.const 0) (then) (else))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-empty-i64 (result i64) (if (i32.const 0) (then) (else))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-empty-f32 (result f32) (if (i32.const 0) (then) (else))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-empty-f64 (result f64) (if (i32.const 0) (then) (else))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-then-value-num-vs-void
|
||||||
|
(if (i32.const 1) (then (i32.const 1)))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-then-value-num-vs-void
|
||||||
|
(if (i32.const 1) (then (i32.const 1)) (else))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-else-value-num-vs-void
|
||||||
|
(if (i32.const 1) (then) (else (i32.const 1)))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-both-value-num-vs-void
|
||||||
|
(if (i32.const 1) (then (i32.const 1)) (else (i32.const 1)))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-then-value-empty-vs-num (result i32)
|
||||||
|
(if (result i32) (i32.const 1) (then) (else (i32.const 0)))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-then-value-empty-vs-num (result i32)
|
||||||
|
(if (result i32) (i32.const 1) (then (i32.const 0)) (else))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-both-value-empty-vs-num (result i32)
|
||||||
|
(if (result i32) (i32.const 1) (then) (else))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-no-else-vs-num (result i32)
|
||||||
|
(if (result i32) (i32.const 1) (then (i32.const 1)))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-then-value-void-vs-num (result i32)
|
||||||
|
(if (result i32) (i32.const 1) (then (nop)) (else (i32.const 0)))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-then-value-void-vs-num (result i32)
|
||||||
|
(if (result i32) (i32.const 1) (then (i32.const 0)) (else (nop)))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-both-value-void-vs-num (result i32)
|
||||||
|
(if (result i32) (i32.const 1) (then (nop)) (else (nop)))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-then-value-num-vs-num (result i32)
|
||||||
|
(if (result i32) (i32.const 1) (then (i64.const 1)) (else (i32.const 1)))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-then-value-num-vs-num (result i32)
|
||||||
|
(if (result i32) (i32.const 1) (then (i32.const 1)) (else (i64.const 1)))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-both-value-num-vs-num (result i32)
|
||||||
|
(if (result i32) (i32.const 1) (then (i64.const 1)) (else (i64.const 1)))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-both-different-value-num-vs-num (result i32)
|
||||||
|
(if (result i32) (i32.const 1) (then (i64.const 1)) (else (f64.const 1)))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-then-value-unreached-select (result i32)
|
||||||
|
(if (result i64)
|
||||||
|
(i32.const 0)
|
||||||
|
(then (select (unreachable) (unreachable) (unreachable)))
|
||||||
|
(else (i64.const 0))
|
||||||
|
)
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-else-value-unreached-select (result i32)
|
||||||
|
(if (result i64)
|
||||||
|
(i32.const 1)
|
||||||
|
(then (i64.const 0))
|
||||||
|
(else (select (unreachable) (unreachable) (unreachable)))
|
||||||
|
)
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-else-value-unreached-select (result i32)
|
||||||
|
(if (result i64)
|
||||||
|
(i32.const 1)
|
||||||
|
(then (select (unreachable) (unreachable) (unreachable)))
|
||||||
|
(else (select (unreachable) (unreachable) (unreachable)))
|
||||||
|
)
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-then-break-last-void-vs-num (result i32)
|
||||||
|
(if (result i32) (i32.const 1) (then (br 0)) (else (i32.const 1)))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-else-break-last-void-vs-num (result i32)
|
||||||
|
(if (result i32) (i32.const 1) (then (i32.const 1)) (else (br 0)))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-then-break-empty-vs-num (result i32)
|
||||||
|
(if (result i32) (i32.const 1)
|
||||||
|
(then (br 0) (i32.const 1))
|
||||||
|
(else (i32.const 1))
|
||||||
|
)
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-else-break-empty-vs-num (result i32)
|
||||||
|
(if (result i32) (i32.const 1)
|
||||||
|
(then (i32.const 1))
|
||||||
|
(else (br 0) (i32.const 1))
|
||||||
|
)
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-then-break-void-vs-num (result i32)
|
||||||
|
(if (result i32) (i32.const 1)
|
||||||
|
(then (br 0 (nop)) (i32.const 1))
|
||||||
|
(else (i32.const 1))
|
||||||
|
)
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-else-break-void-vs-num (result i32)
|
||||||
|
(if (result i32) (i32.const 1)
|
||||||
|
(then (i32.const 1))
|
||||||
|
(else (br 0 (nop)) (i32.const 1))
|
||||||
|
)
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-then-break-num-vs-num (result i32)
|
||||||
|
(if (result i32) (i32.const 1)
|
||||||
|
(then (br 0 (i64.const 1)) (i32.const 1))
|
||||||
|
(else (i32.const 1))
|
||||||
|
)
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-else-break-num-vs-num (result i32)
|
||||||
|
(if (result i32) (i32.const 1)
|
||||||
|
(then (i32.const 1))
|
||||||
|
(else (br 0 (i64.const 1)) (i32.const 1))
|
||||||
|
)
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(func if end $l)")
|
||||||
|
"mismatching label"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(func if $a end $l)")
|
||||||
|
"mismatching label"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(func if else $l end)")
|
||||||
|
"mismatching label"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(func if $a else $l end)")
|
||||||
|
"mismatching label"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(func if else end $l)")
|
||||||
|
"mismatching label"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(func if else $l end $l)")
|
||||||
|
"mismatching label"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(func if else $l1 end $l2)")
|
||||||
|
"mismatching label"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(func if $a else end $l)")
|
||||||
|
"mismatching label"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(func if $a else $a end $l)")
|
||||||
|
"mismatching label"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(func if $a else $l end $l)")
|
||||||
|
"mismatching label"
|
||||||
|
)
|
||||||
@@ -0,0 +1,591 @@
|
|||||||
|
;; Auxiliary module to import from
|
||||||
|
|
||||||
|
(module
|
||||||
|
(func (export "func"))
|
||||||
|
(func (export "func-i32") (param i32))
|
||||||
|
(func (export "func-f32") (param f32))
|
||||||
|
(func (export "func->i32") (result i32) (i32.const 22))
|
||||||
|
(func (export "func->f32") (result f32) (f32.const 11))
|
||||||
|
(func (export "func-i32->i32") (param i32) (result i32) (get_local 0))
|
||||||
|
(func (export "func-i64->i64") (param i64) (result i64) (get_local 0))
|
||||||
|
(global (export "global-i32") i32 (i32.const 55))
|
||||||
|
(global (export "global-f32") f32 (f32.const 44))
|
||||||
|
(table (export "table-10-inf") 10 anyfunc)
|
||||||
|
;; (table (export "table-10-20") 10 20 anyfunc)
|
||||||
|
(memory (export "memory-2-inf") 2)
|
||||||
|
;; (memory (export "memory-2-4") 2 4)
|
||||||
|
)
|
||||||
|
|
||||||
|
(register "test")
|
||||||
|
|
||||||
|
|
||||||
|
;; Functions
|
||||||
|
|
||||||
|
(module
|
||||||
|
(type $func_i32 (func (param i32)))
|
||||||
|
(type $func_i64 (func (param i64)))
|
||||||
|
(type $func_f32 (func (param f32)))
|
||||||
|
(type $func_f64 (func (param f64)))
|
||||||
|
|
||||||
|
(import "spectest" "print_i32" (func (param i32)))
|
||||||
|
;; JavaScript can't handle i64 yet.
|
||||||
|
;; (func (import "spectest" "print_i64") (param i64))
|
||||||
|
(import "spectest" "print_i32" (func $print_i32 (param i32)))
|
||||||
|
;; JavaScript can't handle i64 yet.
|
||||||
|
;; (import "spectest" "print_i64" (func $print_i64 (param i64)))
|
||||||
|
(import "spectest" "print_f32" (func $print_f32 (param f32)))
|
||||||
|
(import "spectest" "print_f64" (func $print_f64 (param f64)))
|
||||||
|
(import "spectest" "print_i32_f32" (func $print_i32_f32 (param i32 f32)))
|
||||||
|
(import "spectest" "print_f64_f64" (func $print_f64_f64 (param f64 f64)))
|
||||||
|
(func $print_i32-2 (import "spectest" "print_i32") (param i32))
|
||||||
|
(func $print_f64-2 (import "spectest" "print_f64") (param f64))
|
||||||
|
(import "test" "func-i64->i64" (func $i64->i64 (param i64) (result i64)))
|
||||||
|
|
||||||
|
(func (export "p1") (import "spectest" "print_i32") (param i32))
|
||||||
|
(func $p (export "p2") (import "spectest" "print_i32") (param i32))
|
||||||
|
(func (export "p3") (export "p4") (import "spectest" "print_i32") (param i32))
|
||||||
|
(func (export "p5") (import "spectest" "print_i32") (type 0))
|
||||||
|
(func (export "p6") (import "spectest" "print_i32") (type 0) (param i32) (result))
|
||||||
|
|
||||||
|
(import "spectest" "print_i32" (func (type $forward)))
|
||||||
|
(func (import "spectest" "print_i32") (type $forward))
|
||||||
|
(type $forward (func (param i32)))
|
||||||
|
|
||||||
|
(table anyfunc (elem $print_i32 $print_f64))
|
||||||
|
|
||||||
|
(func (export "print32") (param $i i32)
|
||||||
|
(local $x f32)
|
||||||
|
(set_local $x (f32.convert_s/i32 (get_local $i)))
|
||||||
|
(call 0 (get_local $i))
|
||||||
|
(call $print_i32_f32
|
||||||
|
(i32.add (get_local $i) (i32.const 1))
|
||||||
|
(f32.const 42)
|
||||||
|
)
|
||||||
|
(call $print_i32 (get_local $i))
|
||||||
|
(call $print_i32-2 (get_local $i))
|
||||||
|
(call $print_f32 (get_local $x))
|
||||||
|
(call_indirect (type $func_i32) (get_local $i) (i32.const 0))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "print64") (param $i i64)
|
||||||
|
(local $x f64)
|
||||||
|
(set_local $x (f64.convert_s/i64 (call $i64->i64 (get_local $i))))
|
||||||
|
;; JavaScript can't handle i64 yet.
|
||||||
|
;; (call 1 (get_local $i))
|
||||||
|
(call $print_f64_f64
|
||||||
|
(f64.add (get_local $x) (f64.const 1))
|
||||||
|
(f64.const 53)
|
||||||
|
)
|
||||||
|
;; JavaScript can't handle i64 yet.
|
||||||
|
;; (call $print_i64 (get_local $i))
|
||||||
|
(call $print_f64 (get_local $x))
|
||||||
|
(call $print_f64-2 (get_local $x))
|
||||||
|
(call_indirect (type $func_f64) (get_local $x) (i32.const 1))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke "print32" (i32.const 13)))
|
||||||
|
(assert_return (invoke "print64" (i64.const 24)))
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module
|
||||||
|
(type (func (result i32)))
|
||||||
|
(import "test" "func" (func (type 1)))
|
||||||
|
)
|
||||||
|
"unknown type"
|
||||||
|
)
|
||||||
|
|
||||||
|
(module (import "test" "func" (func)))
|
||||||
|
(module (import "test" "func-i32" (func (param i32))))
|
||||||
|
(module (import "test" "func-f32" (func (param f32))))
|
||||||
|
(module (import "test" "func->i32" (func (result i32))))
|
||||||
|
(module (import "test" "func->f32" (func (result f32))))
|
||||||
|
(module (import "test" "func-i32->i32" (func (param i32) (result i32))))
|
||||||
|
(module (import "test" "func-i64->i64" (func (param i64) (result i64))))
|
||||||
|
|
||||||
|
(assert_unlinkable
|
||||||
|
(module (import "test" "unknown" (func)))
|
||||||
|
"unknown import"
|
||||||
|
)
|
||||||
|
(assert_unlinkable
|
||||||
|
(module (import "spectest" "unknown" (func)))
|
||||||
|
"unknown import"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_unlinkable
|
||||||
|
(module (import "test" "func" (func (param i32))))
|
||||||
|
"incompatible import type"
|
||||||
|
)
|
||||||
|
(assert_unlinkable
|
||||||
|
(module (import "test" "func" (func (result i32))))
|
||||||
|
"incompatible import type"
|
||||||
|
)
|
||||||
|
(assert_unlinkable
|
||||||
|
(module (import "test" "func" (func (param i32) (result i32))))
|
||||||
|
"incompatible import type"
|
||||||
|
)
|
||||||
|
(assert_unlinkable
|
||||||
|
(module (import "test" "func-i32" (func)))
|
||||||
|
"incompatible import type"
|
||||||
|
)
|
||||||
|
(assert_unlinkable
|
||||||
|
(module (import "test" "func-i32" (func (result i32))))
|
||||||
|
"incompatible import type"
|
||||||
|
)
|
||||||
|
(assert_unlinkable
|
||||||
|
(module (import "test" "func-i32" (func (param f32))))
|
||||||
|
"incompatible import type"
|
||||||
|
)
|
||||||
|
(assert_unlinkable
|
||||||
|
(module (import "test" "func-i32" (func (param i64))))
|
||||||
|
"incompatible import type"
|
||||||
|
)
|
||||||
|
(assert_unlinkable
|
||||||
|
(module (import "test" "func-i32" (func (param i32) (result i32))))
|
||||||
|
"incompatible import type"
|
||||||
|
)
|
||||||
|
(assert_unlinkable
|
||||||
|
(module (import "test" "func->i32" (func)))
|
||||||
|
"incompatible import type"
|
||||||
|
)
|
||||||
|
(assert_unlinkable
|
||||||
|
(module (import "test" "func->i32" (func (param i32))))
|
||||||
|
"incompatible import type"
|
||||||
|
)
|
||||||
|
(assert_unlinkable
|
||||||
|
(module (import "test" "func->i32" (func (result f32))))
|
||||||
|
"incompatible import type"
|
||||||
|
)
|
||||||
|
(assert_unlinkable
|
||||||
|
(module (import "test" "func->i32" (func (result i64))))
|
||||||
|
"incompatible import type"
|
||||||
|
)
|
||||||
|
(assert_unlinkable
|
||||||
|
(module (import "test" "func->i32" (func (param i32) (result i32))))
|
||||||
|
"incompatible import type"
|
||||||
|
)
|
||||||
|
(assert_unlinkable
|
||||||
|
(module (import "test" "func-i32->i32" (func)))
|
||||||
|
"incompatible import type"
|
||||||
|
)
|
||||||
|
(assert_unlinkable
|
||||||
|
(module (import "test" "func-i32->i32" (func (param i32))))
|
||||||
|
"incompatible import type"
|
||||||
|
)
|
||||||
|
(assert_unlinkable
|
||||||
|
(module (import "test" "func-i32->i32" (func (result i32))))
|
||||||
|
"incompatible import type"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_unlinkable
|
||||||
|
(module (import "test" "global-i32" (func (result i32))))
|
||||||
|
"incompatible import type"
|
||||||
|
)
|
||||||
|
(assert_unlinkable
|
||||||
|
(module (import "test" "table-10-inf" (func)))
|
||||||
|
"incompatible import type"
|
||||||
|
)
|
||||||
|
(assert_unlinkable
|
||||||
|
(module (import "test" "memory-2-inf" (func)))
|
||||||
|
"incompatible import type"
|
||||||
|
)
|
||||||
|
(assert_unlinkable
|
||||||
|
(module (import "spectest" "global_i32" (func)))
|
||||||
|
"incompatible import type"
|
||||||
|
)
|
||||||
|
(assert_unlinkable
|
||||||
|
(module (import "spectest" "table" (func)))
|
||||||
|
"incompatible import type"
|
||||||
|
)
|
||||||
|
(assert_unlinkable
|
||||||
|
(module (import "spectest" "memory" (func)))
|
||||||
|
"incompatible import type"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
;; Globals
|
||||||
|
|
||||||
|
(module
|
||||||
|
(import "spectest" "global_i32" (global i32))
|
||||||
|
(global (import "spectest" "global_i32") i32)
|
||||||
|
|
||||||
|
(import "spectest" "global_i32" (global $x i32))
|
||||||
|
(global $y (import "spectest" "global_i32") i32)
|
||||||
|
|
||||||
|
;; JavaScript can't handle i64 yet.
|
||||||
|
;; (import "spectest" "global_i64" (global i64))
|
||||||
|
(import "spectest" "global_f32" (global f32))
|
||||||
|
(import "spectest" "global_f64" (global f64))
|
||||||
|
|
||||||
|
(func (export "get-0") (result i32) (get_global 0))
|
||||||
|
(func (export "get-1") (result i32) (get_global 1))
|
||||||
|
(func (export "get-x") (result i32) (get_global $x))
|
||||||
|
(func (export "get-y") (result i32) (get_global $y))
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke "get-0") (i32.const 666))
|
||||||
|
(assert_return (invoke "get-1") (i32.const 666))
|
||||||
|
(assert_return (invoke "get-x") (i32.const 666))
|
||||||
|
(assert_return (invoke "get-y") (i32.const 666))
|
||||||
|
|
||||||
|
(module (import "test" "global-i32" (global i32)))
|
||||||
|
(module (import "test" "global-f32" (global f32)))
|
||||||
|
|
||||||
|
(assert_unlinkable
|
||||||
|
(module (import "test" "unknown" (global i32)))
|
||||||
|
"unknown import"
|
||||||
|
)
|
||||||
|
(assert_unlinkable
|
||||||
|
(module (import "spectest" "unknown" (global i32)))
|
||||||
|
"unknown import"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_unlinkable
|
||||||
|
(module (import "test" "func" (global i32)))
|
||||||
|
"incompatible import type"
|
||||||
|
)
|
||||||
|
(assert_unlinkable
|
||||||
|
(module (import "test" "table-10-inf" (global i32)))
|
||||||
|
"incompatible import type"
|
||||||
|
)
|
||||||
|
(assert_unlinkable
|
||||||
|
(module (import "test" "memory-2-inf" (global i32)))
|
||||||
|
"incompatible import type"
|
||||||
|
)
|
||||||
|
(assert_unlinkable
|
||||||
|
(module (import "spectest" "print_i32" (global i32)))
|
||||||
|
"incompatible import type"
|
||||||
|
)
|
||||||
|
(assert_unlinkable
|
||||||
|
(module (import "spectest" "table" (global i32)))
|
||||||
|
"incompatible import type"
|
||||||
|
)
|
||||||
|
(assert_unlinkable
|
||||||
|
(module (import "spectest" "memory" (global i32)))
|
||||||
|
"incompatible import type"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
;; Tables
|
||||||
|
|
||||||
|
(module
|
||||||
|
(type (func (result i32)))
|
||||||
|
(import "spectest" "table" (table 10 20 anyfunc))
|
||||||
|
(elem 0 (i32.const 1) $f $g)
|
||||||
|
|
||||||
|
(func (export "call") (param i32) (result i32)
|
||||||
|
(call_indirect (type 0) (get_local 0))
|
||||||
|
)
|
||||||
|
(func $f (result i32) (i32.const 11))
|
||||||
|
(func $g (result i32) (i32.const 22))
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_trap (invoke "call" (i32.const 0)) "uninitialized element")
|
||||||
|
(assert_return (invoke "call" (i32.const 1)) (i32.const 11))
|
||||||
|
(assert_return (invoke "call" (i32.const 2)) (i32.const 22))
|
||||||
|
(assert_trap (invoke "call" (i32.const 3)) "uninitialized element")
|
||||||
|
(assert_trap (invoke "call" (i32.const 100)) "undefined element")
|
||||||
|
|
||||||
|
|
||||||
|
(module
|
||||||
|
(type (func (result i32)))
|
||||||
|
(table (import "spectest" "table") 10 20 anyfunc)
|
||||||
|
(elem 0 (i32.const 1) $f $g)
|
||||||
|
|
||||||
|
(func (export "call") (param i32) (result i32)
|
||||||
|
(call_indirect (type 0) (get_local 0))
|
||||||
|
)
|
||||||
|
(func $f (result i32) (i32.const 11))
|
||||||
|
(func $g (result i32) (i32.const 22))
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_trap (invoke "call" (i32.const 0)) "uninitialized element")
|
||||||
|
(assert_return (invoke "call" (i32.const 1)) (i32.const 11))
|
||||||
|
(assert_return (invoke "call" (i32.const 2)) (i32.const 22))
|
||||||
|
(assert_trap (invoke "call" (i32.const 3)) "uninitialized element")
|
||||||
|
(assert_trap (invoke "call" (i32.const 100)) "undefined element")
|
||||||
|
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (import "" "" (table 10 anyfunc)) (import "" "" (table 10 anyfunc)))
|
||||||
|
"multiple tables"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (import "" "" (table 10 anyfunc)) (table 10 anyfunc))
|
||||||
|
"multiple tables"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (table 10 anyfunc) (table 10 anyfunc))
|
||||||
|
"multiple tables"
|
||||||
|
)
|
||||||
|
|
||||||
|
(module (import "test" "table-10-inf" (table 10 anyfunc)))
|
||||||
|
(module (import "test" "table-10-inf" (table 5 anyfunc)))
|
||||||
|
(module (import "test" "table-10-inf" (table 0 anyfunc)))
|
||||||
|
(module (import "spectest" "table" (table 10 anyfunc)))
|
||||||
|
(module (import "spectest" "table" (table 5 anyfunc)))
|
||||||
|
(module (import "spectest" "table" (table 0 anyfunc)))
|
||||||
|
(module (import "spectest" "table" (table 10 20 anyfunc)))
|
||||||
|
(module (import "spectest" "table" (table 5 20 anyfunc)))
|
||||||
|
(module (import "spectest" "table" (table 0 20 anyfunc)))
|
||||||
|
(module (import "spectest" "table" (table 10 25 anyfunc)))
|
||||||
|
(module (import "spectest" "table" (table 5 25 anyfunc)))
|
||||||
|
|
||||||
|
(assert_unlinkable
|
||||||
|
(module (import "test" "unknown" (table 10 anyfunc)))
|
||||||
|
"unknown import"
|
||||||
|
)
|
||||||
|
(assert_unlinkable
|
||||||
|
(module (import "spectest" "unknown" (table 10 anyfunc)))
|
||||||
|
"unknown import"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_unlinkable
|
||||||
|
(module (import "test" "table-10-inf" (table 12 anyfunc)))
|
||||||
|
"incompatible import type"
|
||||||
|
)
|
||||||
|
(assert_unlinkable
|
||||||
|
(module (import "test" "table-10-inf" (table 10 20 anyfunc)))
|
||||||
|
"incompatible import type"
|
||||||
|
)
|
||||||
|
(assert_unlinkable
|
||||||
|
(module (import "spectest" "table" (table 12 anyfunc)))
|
||||||
|
"incompatible import type"
|
||||||
|
)
|
||||||
|
(assert_unlinkable
|
||||||
|
(module (import "spectest" "table" (table 10 15 anyfunc)))
|
||||||
|
"incompatible import type"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_unlinkable
|
||||||
|
(module (import "test" "func" (table 10 anyfunc)))
|
||||||
|
"incompatible import type"
|
||||||
|
)
|
||||||
|
(assert_unlinkable
|
||||||
|
(module (import "test" "global-i32" (table 10 anyfunc)))
|
||||||
|
"incompatible import type"
|
||||||
|
)
|
||||||
|
(assert_unlinkable
|
||||||
|
(module (import "test" "memory-2-inf" (table 10 anyfunc)))
|
||||||
|
"incompatible import type"
|
||||||
|
)
|
||||||
|
(assert_unlinkable
|
||||||
|
(module (import "spectest" "print_i32" (table 10 anyfunc)))
|
||||||
|
"incompatible import type"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
;; Memories
|
||||||
|
|
||||||
|
(module
|
||||||
|
(import "spectest" "memory" (memory 1 2))
|
||||||
|
(data 0 (i32.const 10) "\10")
|
||||||
|
|
||||||
|
(func (export "load") (param i32) (result i32) (i32.load (get_local 0)))
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke "load" (i32.const 0)) (i32.const 0))
|
||||||
|
(assert_return (invoke "load" (i32.const 10)) (i32.const 16))
|
||||||
|
(assert_return (invoke "load" (i32.const 8)) (i32.const 0x100000))
|
||||||
|
(assert_trap (invoke "load" (i32.const 1000000)) "out of bounds memory access")
|
||||||
|
|
||||||
|
(module
|
||||||
|
(memory (import "spectest" "memory") 1 2)
|
||||||
|
(data 0 (i32.const 10) "\10")
|
||||||
|
|
||||||
|
(func (export "load") (param i32) (result i32) (i32.load (get_local 0)))
|
||||||
|
)
|
||||||
|
(assert_return (invoke "load" (i32.const 0)) (i32.const 0))
|
||||||
|
(assert_return (invoke "load" (i32.const 10)) (i32.const 16))
|
||||||
|
(assert_return (invoke "load" (i32.const 8)) (i32.const 0x100000))
|
||||||
|
(assert_trap (invoke "load" (i32.const 1000000)) "out of bounds memory access")
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (import "" "" (memory 1)) (import "" "" (memory 1)))
|
||||||
|
"multiple memories"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (import "" "" (memory 1)) (memory 0))
|
||||||
|
"multiple memories"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (memory 0) (memory 0))
|
||||||
|
"multiple memories"
|
||||||
|
)
|
||||||
|
|
||||||
|
(module (import "test" "memory-2-inf" (memory 2)))
|
||||||
|
(module (import "test" "memory-2-inf" (memory 1)))
|
||||||
|
(module (import "test" "memory-2-inf" (memory 0)))
|
||||||
|
(module (import "spectest" "memory" (memory 1)))
|
||||||
|
(module (import "spectest" "memory" (memory 0)))
|
||||||
|
(module (import "spectest" "memory" (memory 1 2)))
|
||||||
|
(module (import "spectest" "memory" (memory 0 2)))
|
||||||
|
(module (import "spectest" "memory" (memory 1 3)))
|
||||||
|
(module (import "spectest" "memory" (memory 0 3)))
|
||||||
|
|
||||||
|
(assert_unlinkable
|
||||||
|
(module (import "test" "unknown" (memory 1)))
|
||||||
|
"unknown import"
|
||||||
|
)
|
||||||
|
(assert_unlinkable
|
||||||
|
(module (import "spectest" "unknown" (memory 1)))
|
||||||
|
"unknown import"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_unlinkable
|
||||||
|
(module (import "test" "memory-2-inf" (memory 3)))
|
||||||
|
"incompatible import type"
|
||||||
|
)
|
||||||
|
(assert_unlinkable
|
||||||
|
(module (import "test" "memory-2-inf" (memory 2 3)))
|
||||||
|
"incompatible import type"
|
||||||
|
)
|
||||||
|
(assert_unlinkable
|
||||||
|
(module (import "spectest" "memory" (memory 2)))
|
||||||
|
"incompatible import type"
|
||||||
|
)
|
||||||
|
(assert_unlinkable
|
||||||
|
(module (import "spectest" "memory" (memory 1 1)))
|
||||||
|
"incompatible import type"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_unlinkable
|
||||||
|
(module (import "test" "func-i32" (memory 1)))
|
||||||
|
"incompatible import type"
|
||||||
|
)
|
||||||
|
(assert_unlinkable
|
||||||
|
(module (import "test" "global-i32" (memory 1)))
|
||||||
|
"incompatible import type"
|
||||||
|
)
|
||||||
|
(assert_unlinkable
|
||||||
|
(module (import "test" "table-10-inf" (memory 1)))
|
||||||
|
"incompatible import type"
|
||||||
|
)
|
||||||
|
(assert_unlinkable
|
||||||
|
(module (import "spectest" "print_i32" (memory 1)))
|
||||||
|
"incompatible import type"
|
||||||
|
)
|
||||||
|
(assert_unlinkable
|
||||||
|
(module (import "spectest" "global_i32" (memory 1)))
|
||||||
|
"incompatible import type"
|
||||||
|
)
|
||||||
|
(assert_unlinkable
|
||||||
|
(module (import "spectest" "table" (memory 1)))
|
||||||
|
"incompatible import type"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_unlinkable
|
||||||
|
(module (import "spectest" "memory" (memory 2)))
|
||||||
|
"incompatible import type"
|
||||||
|
)
|
||||||
|
(assert_unlinkable
|
||||||
|
(module (import "spectest" "memory" (memory 1 1)))
|
||||||
|
"incompatible import type"
|
||||||
|
)
|
||||||
|
|
||||||
|
(module
|
||||||
|
(import "spectest" "memory" (memory 0 3)) ;; actual has max size 2
|
||||||
|
(func (export "grow") (param i32) (result i32) (memory.grow (get_local 0)))
|
||||||
|
)
|
||||||
|
(assert_return (invoke "grow" (i32.const 0)) (i32.const 1))
|
||||||
|
(assert_return (invoke "grow" (i32.const 1)) (i32.const 1))
|
||||||
|
(assert_return (invoke "grow" (i32.const 0)) (i32.const 2))
|
||||||
|
(assert_return (invoke "grow" (i32.const 1)) (i32.const -1))
|
||||||
|
(assert_return (invoke "grow" (i32.const 0)) (i32.const 2))
|
||||||
|
|
||||||
|
|
||||||
|
;; Syntax errors
|
||||||
|
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(func) (import \"\" \"\" (func))")
|
||||||
|
"import after function"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(func) (import \"\" \"\" (global i64))")
|
||||||
|
"import after function"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(func) (import \"\" \"\" (table 0 anyfunc))")
|
||||||
|
"import after function"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(func) (import \"\" \"\" (memory 0))")
|
||||||
|
"import after function"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global i64 (i64.const 0)) (import \"\" \"\" (func))")
|
||||||
|
"import after global"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global i64 (i64.const 0)) (import \"\" \"\" (global f32))")
|
||||||
|
"import after global"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global i64 (i64.const 0)) (import \"\" \"\" (table 0 anyfunc))")
|
||||||
|
"import after global"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global i64 (i64.const 0)) (import \"\" \"\" (memory 0))")
|
||||||
|
"import after global"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(table 0 anyfunc) (import \"\" \"\" (func))")
|
||||||
|
"import after table"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(table 0 anyfunc) (import \"\" \"\" (global i32))")
|
||||||
|
"import after table"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(table 0 anyfunc) (import \"\" \"\" (table 0 anyfunc))")
|
||||||
|
"import after table"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(table 0 anyfunc) (import \"\" \"\" (memory 0))")
|
||||||
|
"import after table"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(memory 0) (import \"\" \"\" (func))")
|
||||||
|
"import after memory"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(memory 0) (import \"\" \"\" (global i32))")
|
||||||
|
"import after memory"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(memory 0) (import \"\" \"\" (table 1 3 anyfunc))")
|
||||||
|
"import after memory"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(memory 0) (import \"\" \"\" (memory 1 2))")
|
||||||
|
"import after memory"
|
||||||
|
)
|
||||||
|
|
||||||
|
;; This module is required to validate, regardless of whether it can be
|
||||||
|
;; linked. Overloading is not possible in wasm itself, but it is possible
|
||||||
|
;; in modules from which wasm can import.
|
||||||
|
(assert_unlinkable
|
||||||
|
(module
|
||||||
|
(import "not wasm" "overloaded" (func))
|
||||||
|
(import "not wasm" "overloaded" (func (param i32)))
|
||||||
|
(import "not wasm" "overloaded" (func (param i32 i32)))
|
||||||
|
(import "not wasm" "overloaded" (func (param i64)))
|
||||||
|
(import "not wasm" "overloaded" (func (param f32)))
|
||||||
|
(import "not wasm" "overloaded" (func (param f64)))
|
||||||
|
(import "not wasm" "overloaded" (func (result i32)))
|
||||||
|
(import "not wasm" "overloaded" (func (result i64)))
|
||||||
|
(import "not wasm" "overloaded" (func (result f32)))
|
||||||
|
(import "not wasm" "overloaded" (func (result f64)))
|
||||||
|
(import "not wasm" "overloaded" (global i32))
|
||||||
|
(import "not wasm" "overloaded" (global i64))
|
||||||
|
(import "not wasm" "overloaded" (global f32))
|
||||||
|
(import "not wasm" "overloaded" (global f64))
|
||||||
|
(import "not wasm" "overloaded" (table 0 anyfunc))
|
||||||
|
(import "not wasm" "overloaded" (memory 0))
|
||||||
|
)
|
||||||
|
"unknown import"
|
||||||
|
)
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
(func) (memory 0) (func (export "f"))
|
||||||
@@ -0,0 +1,350 @@
|
|||||||
|
;; Test interesting integer "expressions". These tests contain code
|
||||||
|
;; patterns which tempt common value-changing optimizations.
|
||||||
|
|
||||||
|
;; Test that x+1<y+1 is not folded to x<y.
|
||||||
|
|
||||||
|
(module
|
||||||
|
(func (export "i32.no_fold_cmp_s_offset") (param $x i32) (param $y i32) (result i32)
|
||||||
|
(i32.lt_s (i32.add (get_local $x) (i32.const 1)) (i32.add (get_local $y) (i32.const 1))))
|
||||||
|
(func (export "i32.no_fold_cmp_u_offset") (param $x i32) (param $y i32) (result i32)
|
||||||
|
(i32.lt_u (i32.add (get_local $x) (i32.const 1)) (i32.add (get_local $y) (i32.const 1))))
|
||||||
|
|
||||||
|
(func (export "i64.no_fold_cmp_s_offset") (param $x i64) (param $y i64) (result i32)
|
||||||
|
(i64.lt_s (i64.add (get_local $x) (i64.const 1)) (i64.add (get_local $y) (i64.const 1))))
|
||||||
|
(func (export "i64.no_fold_cmp_u_offset") (param $x i64) (param $y i64) (result i32)
|
||||||
|
(i64.lt_u (i64.add (get_local $x) (i64.const 1)) (i64.add (get_local $y) (i64.const 1))))
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke "i32.no_fold_cmp_s_offset" (i32.const 0x7fffffff) (i32.const 0)) (i32.const 1))
|
||||||
|
(assert_return (invoke "i32.no_fold_cmp_u_offset" (i32.const 0xffffffff) (i32.const 0)) (i32.const 1))
|
||||||
|
(assert_return (invoke "i64.no_fold_cmp_s_offset" (i64.const 0x7fffffffffffffff) (i64.const 0)) (i32.const 1))
|
||||||
|
(assert_return (invoke "i64.no_fold_cmp_u_offset" (i64.const 0xffffffffffffffff) (i64.const 0)) (i32.const 1))
|
||||||
|
|
||||||
|
;; Test that wrap(extend_s(x)) is not folded to x.
|
||||||
|
|
||||||
|
(module
|
||||||
|
(func (export "i64.no_fold_wrap_extend_s") (param $x i64) (result i64)
|
||||||
|
(i64.extend_s/i32 (i32.wrap/i64 (get_local $x))))
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke "i64.no_fold_wrap_extend_s" (i64.const 0x0010203040506070)) (i64.const 0x0000000040506070))
|
||||||
|
(assert_return (invoke "i64.no_fold_wrap_extend_s" (i64.const 0x00a0b0c0d0e0f0a0)) (i64.const 0xffffffffd0e0f0a0))
|
||||||
|
|
||||||
|
;; Test that wrap(extend_u(x)) is not folded to x.
|
||||||
|
|
||||||
|
(module
|
||||||
|
(func (export "i64.no_fold_wrap_extend_u") (param $x i64) (result i64)
|
||||||
|
(i64.extend_u/i32 (i32.wrap/i64 (get_local $x))))
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke "i64.no_fold_wrap_extend_u" (i64.const 0x0010203040506070)) (i64.const 0x0000000040506070))
|
||||||
|
|
||||||
|
;; Test that x<<n>>n is not folded to x.
|
||||||
|
|
||||||
|
(module
|
||||||
|
(func (export "i32.no_fold_shl_shr_s") (param $x i32) (result i32)
|
||||||
|
(i32.shr_s (i32.shl (get_local $x) (i32.const 1)) (i32.const 1)))
|
||||||
|
(func (export "i32.no_fold_shl_shr_u") (param $x i32) (result i32)
|
||||||
|
(i32.shr_u (i32.shl (get_local $x) (i32.const 1)) (i32.const 1)))
|
||||||
|
|
||||||
|
(func (export "i64.no_fold_shl_shr_s") (param $x i64) (result i64)
|
||||||
|
(i64.shr_s (i64.shl (get_local $x) (i64.const 1)) (i64.const 1)))
|
||||||
|
(func (export "i64.no_fold_shl_shr_u") (param $x i64) (result i64)
|
||||||
|
(i64.shr_u (i64.shl (get_local $x) (i64.const 1)) (i64.const 1)))
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke "i32.no_fold_shl_shr_s" (i32.const 0x80000000)) (i32.const 0))
|
||||||
|
(assert_return (invoke "i32.no_fold_shl_shr_u" (i32.const 0x80000000)) (i32.const 0))
|
||||||
|
(assert_return (invoke "i64.no_fold_shl_shr_s" (i64.const 0x8000000000000000)) (i64.const 0))
|
||||||
|
(assert_return (invoke "i64.no_fold_shl_shr_u" (i64.const 0x8000000000000000)) (i64.const 0))
|
||||||
|
|
||||||
|
;; Test that x>>n<<n is not folded to x.
|
||||||
|
|
||||||
|
(module
|
||||||
|
(func (export "i32.no_fold_shr_s_shl") (param $x i32) (result i32)
|
||||||
|
(i32.shl (i32.shr_s (get_local $x) (i32.const 1)) (i32.const 1)))
|
||||||
|
(func (export "i32.no_fold_shr_u_shl") (param $x i32) (result i32)
|
||||||
|
(i32.shl (i32.shr_u (get_local $x) (i32.const 1)) (i32.const 1)))
|
||||||
|
|
||||||
|
(func (export "i64.no_fold_shr_s_shl") (param $x i64) (result i64)
|
||||||
|
(i64.shl (i64.shr_s (get_local $x) (i64.const 1)) (i64.const 1)))
|
||||||
|
(func (export "i64.no_fold_shr_u_shl") (param $x i64) (result i64)
|
||||||
|
(i64.shl (i64.shr_u (get_local $x) (i64.const 1)) (i64.const 1)))
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke "i32.no_fold_shr_s_shl" (i32.const 1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "i32.no_fold_shr_u_shl" (i32.const 1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "i64.no_fold_shr_s_shl" (i64.const 1)) (i64.const 0))
|
||||||
|
(assert_return (invoke "i64.no_fold_shr_u_shl" (i64.const 1)) (i64.const 0))
|
||||||
|
|
||||||
|
;; Test that x/n*n is not folded to x.
|
||||||
|
|
||||||
|
(module
|
||||||
|
(func (export "i32.no_fold_div_s_mul") (param $x i32) (result i32)
|
||||||
|
(i32.mul (i32.div_s (get_local $x) (i32.const 6)) (i32.const 6)))
|
||||||
|
(func (export "i32.no_fold_div_u_mul") (param $x i32) (result i32)
|
||||||
|
(i32.mul (i32.div_u (get_local $x) (i32.const 6)) (i32.const 6)))
|
||||||
|
|
||||||
|
(func (export "i64.no_fold_div_s_mul") (param $x i64) (result i64)
|
||||||
|
(i64.mul (i64.div_s (get_local $x) (i64.const 6)) (i64.const 6)))
|
||||||
|
(func (export "i64.no_fold_div_u_mul") (param $x i64) (result i64)
|
||||||
|
(i64.mul (i64.div_u (get_local $x) (i64.const 6)) (i64.const 6)))
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke "i32.no_fold_div_s_mul" (i32.const 1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "i32.no_fold_div_u_mul" (i32.const 1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "i64.no_fold_div_s_mul" (i64.const 1)) (i64.const 0))
|
||||||
|
(assert_return (invoke "i64.no_fold_div_u_mul" (i64.const 1)) (i64.const 0))
|
||||||
|
|
||||||
|
;; Test that x/x is not folded to 1.
|
||||||
|
|
||||||
|
(module
|
||||||
|
(func (export "i32.no_fold_div_s_self") (param $x i32) (result i32)
|
||||||
|
(i32.div_s (get_local $x) (get_local $x)))
|
||||||
|
(func (export "i32.no_fold_div_u_self") (param $x i32) (result i32)
|
||||||
|
(i32.div_u (get_local $x) (get_local $x)))
|
||||||
|
|
||||||
|
(func (export "i64.no_fold_div_s_self") (param $x i64) (result i64)
|
||||||
|
(i64.div_s (get_local $x) (get_local $x)))
|
||||||
|
(func (export "i64.no_fold_div_u_self") (param $x i64) (result i64)
|
||||||
|
(i64.div_u (get_local $x) (get_local $x)))
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_trap (invoke "i32.no_fold_div_s_self" (i32.const 0)) "integer divide by zero")
|
||||||
|
(assert_trap (invoke "i32.no_fold_div_u_self" (i32.const 0)) "integer divide by zero")
|
||||||
|
(assert_trap (invoke "i64.no_fold_div_s_self" (i64.const 0)) "integer divide by zero")
|
||||||
|
(assert_trap (invoke "i64.no_fold_div_u_self" (i64.const 0)) "integer divide by zero")
|
||||||
|
|
||||||
|
;; Test that x%x is not folded to 0.
|
||||||
|
|
||||||
|
(module
|
||||||
|
(func (export "i32.no_fold_rem_s_self") (param $x i32) (result i32)
|
||||||
|
(i32.rem_s (get_local $x) (get_local $x)))
|
||||||
|
(func (export "i32.no_fold_rem_u_self") (param $x i32) (result i32)
|
||||||
|
(i32.rem_u (get_local $x) (get_local $x)))
|
||||||
|
|
||||||
|
(func (export "i64.no_fold_rem_s_self") (param $x i64) (result i64)
|
||||||
|
(i64.rem_s (get_local $x) (get_local $x)))
|
||||||
|
(func (export "i64.no_fold_rem_u_self") (param $x i64) (result i64)
|
||||||
|
(i64.rem_u (get_local $x) (get_local $x)))
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_trap (invoke "i32.no_fold_rem_s_self" (i32.const 0)) "integer divide by zero")
|
||||||
|
(assert_trap (invoke "i32.no_fold_rem_u_self" (i32.const 0)) "integer divide by zero")
|
||||||
|
(assert_trap (invoke "i64.no_fold_rem_s_self" (i64.const 0)) "integer divide by zero")
|
||||||
|
(assert_trap (invoke "i64.no_fold_rem_u_self" (i64.const 0)) "integer divide by zero")
|
||||||
|
|
||||||
|
;; Test that x*n/n is not folded to x.
|
||||||
|
|
||||||
|
(module
|
||||||
|
(func (export "i32.no_fold_mul_div_s") (param $x i32) (result i32)
|
||||||
|
(i32.div_s (i32.mul (get_local $x) (i32.const 6)) (i32.const 6)))
|
||||||
|
(func (export "i32.no_fold_mul_div_u") (param $x i32) (result i32)
|
||||||
|
(i32.div_u (i32.mul (get_local $x) (i32.const 6)) (i32.const 6)))
|
||||||
|
|
||||||
|
(func (export "i64.no_fold_mul_div_s") (param $x i64) (result i64)
|
||||||
|
(i64.div_s (i64.mul (get_local $x) (i64.const 6)) (i64.const 6)))
|
||||||
|
(func (export "i64.no_fold_mul_div_u") (param $x i64) (result i64)
|
||||||
|
(i64.div_u (i64.mul (get_local $x) (i64.const 6)) (i64.const 6)))
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke "i32.no_fold_mul_div_s" (i32.const 0x80000000)) (i32.const 0))
|
||||||
|
(assert_return (invoke "i32.no_fold_mul_div_u" (i32.const 0x80000000)) (i32.const 0))
|
||||||
|
(assert_return (invoke "i64.no_fold_mul_div_s" (i64.const 0x8000000000000000)) (i64.const 0))
|
||||||
|
(assert_return (invoke "i64.no_fold_mul_div_u" (i64.const 0x8000000000000000)) (i64.const 0))
|
||||||
|
|
||||||
|
;; Test that x/n where n is a known power of 2 is not folded to shr_s.
|
||||||
|
|
||||||
|
(module
|
||||||
|
(func (export "i32.no_fold_div_s_2") (param $x i32) (result i32)
|
||||||
|
(i32.div_s (get_local $x) (i32.const 2)))
|
||||||
|
|
||||||
|
(func (export "i64.no_fold_div_s_2") (param $x i64) (result i64)
|
||||||
|
(i64.div_s (get_local $x) (i64.const 2)))
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke "i32.no_fold_div_s_2" (i32.const -11)) (i32.const -5))
|
||||||
|
(assert_return (invoke "i64.no_fold_div_s_2" (i64.const -11)) (i64.const -5))
|
||||||
|
|
||||||
|
;; Test that x%n where n is a known power of 2 is not folded to and.
|
||||||
|
|
||||||
|
(module
|
||||||
|
(func (export "i32.no_fold_rem_s_2") (param $x i32) (result i32)
|
||||||
|
(i32.rem_s (get_local $x) (i32.const 2)))
|
||||||
|
|
||||||
|
(func (export "i64.no_fold_rem_s_2") (param $x i64) (result i64)
|
||||||
|
(i64.rem_s (get_local $x) (i64.const 2)))
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke "i32.no_fold_rem_s_2" (i32.const -11)) (i32.const -1))
|
||||||
|
(assert_return (invoke "i64.no_fold_rem_s_2" (i64.const -11)) (i64.const -1))
|
||||||
|
|
||||||
|
;; Test that x/0 works.
|
||||||
|
|
||||||
|
(module
|
||||||
|
(func (export "i32.div_s_0") (param $x i32) (result i32)
|
||||||
|
(i32.div_s (get_local $x) (i32.const 0)))
|
||||||
|
(func (export "i32.div_u_0") (param $x i32) (result i32)
|
||||||
|
(i32.div_u (get_local $x) (i32.const 0)))
|
||||||
|
|
||||||
|
(func (export "i64.div_s_0") (param $x i64) (result i64)
|
||||||
|
(i64.div_s (get_local $x) (i64.const 0)))
|
||||||
|
(func (export "i64.div_u_0") (param $x i64) (result i64)
|
||||||
|
(i64.div_u (get_local $x) (i64.const 0)))
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_trap (invoke "i32.div_s_0" (i32.const 71)) "integer divide by zero")
|
||||||
|
(assert_trap (invoke "i32.div_u_0" (i32.const 71)) "integer divide by zero")
|
||||||
|
(assert_trap (invoke "i64.div_s_0" (i64.const 71)) "integer divide by zero")
|
||||||
|
(assert_trap (invoke "i64.div_u_0" (i64.const 71)) "integer divide by zero")
|
||||||
|
|
||||||
|
;; Test that x/3 works.
|
||||||
|
|
||||||
|
(module
|
||||||
|
(func (export "i32.div_s_3") (param $x i32) (result i32)
|
||||||
|
(i32.div_s (get_local $x) (i32.const 3)))
|
||||||
|
(func (export "i32.div_u_3") (param $x i32) (result i32)
|
||||||
|
(i32.div_u (get_local $x) (i32.const 3)))
|
||||||
|
|
||||||
|
(func (export "i64.div_s_3") (param $x i64) (result i64)
|
||||||
|
(i64.div_s (get_local $x) (i64.const 3)))
|
||||||
|
(func (export "i64.div_u_3") (param $x i64) (result i64)
|
||||||
|
(i64.div_u (get_local $x) (i64.const 3)))
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke "i32.div_s_3" (i32.const 71)) (i32.const 23))
|
||||||
|
(assert_return (invoke "i32.div_s_3" (i32.const 0x60000000)) (i32.const 0x20000000))
|
||||||
|
(assert_return (invoke "i32.div_u_3" (i32.const 71)) (i32.const 23))
|
||||||
|
(assert_return (invoke "i32.div_u_3" (i32.const 0xc0000000)) (i32.const 0x40000000))
|
||||||
|
(assert_return (invoke "i64.div_s_3" (i64.const 71)) (i64.const 23))
|
||||||
|
(assert_return (invoke "i64.div_s_3" (i64.const 0x3000000000000000)) (i64.const 0x1000000000000000))
|
||||||
|
(assert_return (invoke "i64.div_u_3" (i64.const 71)) (i64.const 23))
|
||||||
|
(assert_return (invoke "i64.div_u_3" (i64.const 0xc000000000000000)) (i64.const 0x4000000000000000))
|
||||||
|
|
||||||
|
;; Test that x/5 works.
|
||||||
|
|
||||||
|
(module
|
||||||
|
(func (export "i32.div_s_5") (param $x i32) (result i32)
|
||||||
|
(i32.div_s (get_local $x) (i32.const 5)))
|
||||||
|
(func (export "i32.div_u_5") (param $x i32) (result i32)
|
||||||
|
(i32.div_u (get_local $x) (i32.const 5)))
|
||||||
|
|
||||||
|
(func (export "i64.div_s_5") (param $x i64) (result i64)
|
||||||
|
(i64.div_s (get_local $x) (i64.const 5)))
|
||||||
|
(func (export "i64.div_u_5") (param $x i64) (result i64)
|
||||||
|
(i64.div_u (get_local $x) (i64.const 5)))
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke "i32.div_s_5" (i32.const 71)) (i32.const 14))
|
||||||
|
(assert_return (invoke "i32.div_s_5" (i32.const 0x50000000)) (i32.const 0x10000000))
|
||||||
|
(assert_return (invoke "i32.div_u_5" (i32.const 71)) (i32.const 14))
|
||||||
|
(assert_return (invoke "i32.div_u_5" (i32.const 0xa0000000)) (i32.const 0x20000000))
|
||||||
|
(assert_return (invoke "i64.div_s_5" (i64.const 71)) (i64.const 14))
|
||||||
|
(assert_return (invoke "i64.div_s_5" (i64.const 0x5000000000000000)) (i64.const 0x1000000000000000))
|
||||||
|
(assert_return (invoke "i64.div_u_5" (i64.const 71)) (i64.const 14))
|
||||||
|
(assert_return (invoke "i64.div_u_5" (i64.const 0xa000000000000000)) (i64.const 0x2000000000000000))
|
||||||
|
|
||||||
|
;; Test that x/7 works.
|
||||||
|
|
||||||
|
(module
|
||||||
|
(func (export "i32.div_s_7") (param $x i32) (result i32)
|
||||||
|
(i32.div_s (get_local $x) (i32.const 7)))
|
||||||
|
(func (export "i32.div_u_7") (param $x i32) (result i32)
|
||||||
|
(i32.div_u (get_local $x) (i32.const 7)))
|
||||||
|
|
||||||
|
(func (export "i64.div_s_7") (param $x i64) (result i64)
|
||||||
|
(i64.div_s (get_local $x) (i64.const 7)))
|
||||||
|
(func (export "i64.div_u_7") (param $x i64) (result i64)
|
||||||
|
(i64.div_u (get_local $x) (i64.const 7)))
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke "i32.div_s_7" (i32.const 71)) (i32.const 10))
|
||||||
|
(assert_return (invoke "i32.div_s_7" (i32.const 0x70000000)) (i32.const 0x10000000))
|
||||||
|
(assert_return (invoke "i32.div_u_7" (i32.const 71)) (i32.const 10))
|
||||||
|
(assert_return (invoke "i32.div_u_7" (i32.const 0xe0000000)) (i32.const 0x20000000))
|
||||||
|
(assert_return (invoke "i64.div_s_7" (i64.const 71)) (i64.const 10))
|
||||||
|
(assert_return (invoke "i64.div_s_7" (i64.const 0x7000000000000000)) (i64.const 0x1000000000000000))
|
||||||
|
(assert_return (invoke "i64.div_u_7" (i64.const 71)) (i64.const 10))
|
||||||
|
(assert_return (invoke "i64.div_u_7" (i64.const 0xe000000000000000)) (i64.const 0x2000000000000000))
|
||||||
|
|
||||||
|
;; Test that x%3 works.
|
||||||
|
|
||||||
|
(module
|
||||||
|
(func (export "i32.rem_s_3") (param $x i32) (result i32)
|
||||||
|
(i32.rem_s (get_local $x) (i32.const 3)))
|
||||||
|
(func (export "i32.rem_u_3") (param $x i32) (result i32)
|
||||||
|
(i32.rem_u (get_local $x) (i32.const 3)))
|
||||||
|
|
||||||
|
(func (export "i64.rem_s_3") (param $x i64) (result i64)
|
||||||
|
(i64.rem_s (get_local $x) (i64.const 3)))
|
||||||
|
(func (export "i64.rem_u_3") (param $x i64) (result i64)
|
||||||
|
(i64.rem_u (get_local $x) (i64.const 3)))
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke "i32.rem_s_3" (i32.const 71)) (i32.const 2))
|
||||||
|
(assert_return (invoke "i32.rem_s_3" (i32.const 0x60000000)) (i32.const 0))
|
||||||
|
(assert_return (invoke "i32.rem_u_3" (i32.const 71)) (i32.const 2))
|
||||||
|
(assert_return (invoke "i32.rem_u_3" (i32.const 0xc0000000)) (i32.const 0))
|
||||||
|
(assert_return (invoke "i64.rem_s_3" (i64.const 71)) (i64.const 2))
|
||||||
|
(assert_return (invoke "i64.rem_s_3" (i64.const 0x3000000000000000)) (i64.const 0))
|
||||||
|
(assert_return (invoke "i64.rem_u_3" (i64.const 71)) (i64.const 2))
|
||||||
|
(assert_return (invoke "i64.rem_u_3" (i64.const 0xc000000000000000)) (i64.const 0))
|
||||||
|
|
||||||
|
;; Test that x%5 works.
|
||||||
|
|
||||||
|
(module
|
||||||
|
(func (export "i32.rem_s_5") (param $x i32) (result i32)
|
||||||
|
(i32.rem_s (get_local $x) (i32.const 5)))
|
||||||
|
(func (export "i32.rem_u_5") (param $x i32) (result i32)
|
||||||
|
(i32.rem_u (get_local $x) (i32.const 5)))
|
||||||
|
|
||||||
|
(func (export "i64.rem_s_5") (param $x i64) (result i64)
|
||||||
|
(i64.rem_s (get_local $x) (i64.const 5)))
|
||||||
|
(func (export "i64.rem_u_5") (param $x i64) (result i64)
|
||||||
|
(i64.rem_u (get_local $x) (i64.const 5)))
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke "i32.rem_s_5" (i32.const 71)) (i32.const 1))
|
||||||
|
(assert_return (invoke "i32.rem_s_5" (i32.const 0x50000000)) (i32.const 0))
|
||||||
|
(assert_return (invoke "i32.rem_u_5" (i32.const 71)) (i32.const 1))
|
||||||
|
(assert_return (invoke "i32.rem_u_5" (i32.const 0xa0000000)) (i32.const 0))
|
||||||
|
(assert_return (invoke "i64.rem_s_5" (i64.const 71)) (i64.const 1))
|
||||||
|
(assert_return (invoke "i64.rem_s_5" (i64.const 0x5000000000000000)) (i64.const 0))
|
||||||
|
(assert_return (invoke "i64.rem_u_5" (i64.const 71)) (i64.const 1))
|
||||||
|
(assert_return (invoke "i64.rem_u_5" (i64.const 0xa000000000000000)) (i64.const 0))
|
||||||
|
|
||||||
|
;; Test that x%7 works.
|
||||||
|
|
||||||
|
(module
|
||||||
|
(func (export "i32.rem_s_7") (param $x i32) (result i32)
|
||||||
|
(i32.rem_s (get_local $x) (i32.const 7)))
|
||||||
|
(func (export "i32.rem_u_7") (param $x i32) (result i32)
|
||||||
|
(i32.rem_u (get_local $x) (i32.const 7)))
|
||||||
|
|
||||||
|
(func (export "i64.rem_s_7") (param $x i64) (result i64)
|
||||||
|
(i64.rem_s (get_local $x) (i64.const 7)))
|
||||||
|
(func (export "i64.rem_u_7") (param $x i64) (result i64)
|
||||||
|
(i64.rem_u (get_local $x) (i64.const 7)))
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke "i32.rem_s_7" (i32.const 71)) (i32.const 1))
|
||||||
|
(assert_return (invoke "i32.rem_s_7" (i32.const 0x70000000)) (i32.const 0))
|
||||||
|
(assert_return (invoke "i32.rem_u_7" (i32.const 71)) (i32.const 1))
|
||||||
|
(assert_return (invoke "i32.rem_u_7" (i32.const 0xe0000000)) (i32.const 0))
|
||||||
|
(assert_return (invoke "i64.rem_s_7" (i64.const 71)) (i64.const 1))
|
||||||
|
(assert_return (invoke "i64.rem_s_7" (i64.const 0x7000000000000000)) (i64.const 0))
|
||||||
|
(assert_return (invoke "i64.rem_u_7" (i64.const 71)) (i64.const 1))
|
||||||
|
(assert_return (invoke "i64.rem_u_7" (i64.const 0xe000000000000000)) (i64.const 0))
|
||||||
|
|
||||||
|
;; Test that x/-1 is not folded to -x.
|
||||||
|
|
||||||
|
(module
|
||||||
|
(func (export "i32.no_fold_div_neg1") (param $x i32) (result i32)
|
||||||
|
(i32.div_s (get_local $x) (i32.const -1)))
|
||||||
|
|
||||||
|
(func (export "i64.no_fold_div_neg1") (param $x i64) (result i64)
|
||||||
|
(i64.div_s (get_local $x) (i64.const -1)))
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_trap (invoke "i32.no_fold_div_neg1" (i32.const 0x80000000)) "integer overflow")
|
||||||
|
(assert_trap (invoke "i64.no_fold_div_neg1" (i64.const 0x8000000000000000)) "integer overflow")
|
||||||
@@ -0,0 +1,151 @@
|
|||||||
|
(module
|
||||||
|
(func (export "i32.test") (result i32) (return (i32.const 0x0bAdD00D)))
|
||||||
|
(func (export "i32.umax") (result i32) (return (i32.const 0xffffffff)))
|
||||||
|
(func (export "i32.smax") (result i32) (return (i32.const 0x7fffffff)))
|
||||||
|
(func (export "i32.neg_smax") (result i32) (return (i32.const -0x7fffffff)))
|
||||||
|
(func (export "i32.smin") (result i32) (return (i32.const -0x80000000)))
|
||||||
|
(func (export "i32.alt_smin") (result i32) (return (i32.const 0x80000000)))
|
||||||
|
(func (export "i32.inc_smin") (result i32) (return (i32.add (i32.const -0x80000000) (i32.const 1))))
|
||||||
|
(func (export "i32.neg_zero") (result i32) (return (i32.const -0x0)))
|
||||||
|
(func (export "i32.not_octal") (result i32) (return (i32.const 010)))
|
||||||
|
(func (export "i32.unsigned_decimal") (result i32) (return (i32.const 4294967295)))
|
||||||
|
(func (export "i32.plus_sign") (result i32) (return (i32.const +42)))
|
||||||
|
|
||||||
|
(func (export "i64.test") (result i64) (return (i64.const 0x0CABBA6E0ba66a6e)))
|
||||||
|
(func (export "i64.umax") (result i64) (return (i64.const 0xffffffffffffffff)))
|
||||||
|
(func (export "i64.smax") (result i64) (return (i64.const 0x7fffffffffffffff)))
|
||||||
|
(func (export "i64.neg_smax") (result i64) (return (i64.const -0x7fffffffffffffff)))
|
||||||
|
(func (export "i64.smin") (result i64) (return (i64.const -0x8000000000000000)))
|
||||||
|
(func (export "i64.alt_smin") (result i64) (return (i64.const 0x8000000000000000)))
|
||||||
|
(func (export "i64.inc_smin") (result i64) (return (i64.add (i64.const -0x8000000000000000) (i64.const 1))))
|
||||||
|
(func (export "i64.neg_zero") (result i64) (return (i64.const -0x0)))
|
||||||
|
(func (export "i64.not_octal") (result i64) (return (i64.const 010)))
|
||||||
|
(func (export "i64.unsigned_decimal") (result i64) (return (i64.const 18446744073709551615)))
|
||||||
|
(func (export "i64.plus_sign") (result i64) (return (i64.const +42)))
|
||||||
|
|
||||||
|
(func (export "i32-dec-sep1") (result i32) (i32.const 1_000_000))
|
||||||
|
(func (export "i32-dec-sep2") (result i32) (i32.const 1_0_0_0))
|
||||||
|
(func (export "i32-hex-sep1") (result i32) (i32.const 0xa_0f_00_99))
|
||||||
|
(func (export "i32-hex-sep2") (result i32) (i32.const 0x1_a_A_0_f))
|
||||||
|
|
||||||
|
(func (export "i64-dec-sep1") (result i64) (i64.const 1_000_000))
|
||||||
|
(func (export "i64-dec-sep2") (result i64) (i64.const 1_0_0_0))
|
||||||
|
(func (export "i64-hex-sep1") (result i64) (i64.const 0xa_f00f_0000_9999))
|
||||||
|
(func (export "i64-hex-sep2") (result i64) (i64.const 0x1_a_A_0_f))
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke "i32.test") (i32.const 195940365))
|
||||||
|
(assert_return (invoke "i32.umax") (i32.const -1))
|
||||||
|
(assert_return (invoke "i32.smax") (i32.const 2147483647))
|
||||||
|
(assert_return (invoke "i32.neg_smax") (i32.const -2147483647))
|
||||||
|
(assert_return (invoke "i32.smin") (i32.const -2147483648))
|
||||||
|
(assert_return (invoke "i32.alt_smin") (i32.const -2147483648))
|
||||||
|
(assert_return (invoke "i32.inc_smin") (i32.const -2147483647))
|
||||||
|
(assert_return (invoke "i32.neg_zero") (i32.const 0))
|
||||||
|
(assert_return (invoke "i32.not_octal") (i32.const 10))
|
||||||
|
(assert_return (invoke "i32.unsigned_decimal") (i32.const -1))
|
||||||
|
(assert_return (invoke "i32.plus_sign") (i32.const 42))
|
||||||
|
|
||||||
|
(assert_return (invoke "i64.test") (i64.const 913028331277281902))
|
||||||
|
(assert_return (invoke "i64.umax") (i64.const -1))
|
||||||
|
(assert_return (invoke "i64.smax") (i64.const 9223372036854775807))
|
||||||
|
(assert_return (invoke "i64.neg_smax") (i64.const -9223372036854775807))
|
||||||
|
(assert_return (invoke "i64.smin") (i64.const -9223372036854775808))
|
||||||
|
(assert_return (invoke "i64.alt_smin") (i64.const -9223372036854775808))
|
||||||
|
(assert_return (invoke "i64.inc_smin") (i64.const -9223372036854775807))
|
||||||
|
(assert_return (invoke "i64.neg_zero") (i64.const 0))
|
||||||
|
(assert_return (invoke "i64.not_octal") (i64.const 10))
|
||||||
|
(assert_return (invoke "i64.unsigned_decimal") (i64.const -1))
|
||||||
|
(assert_return (invoke "i64.plus_sign") (i64.const 42))
|
||||||
|
|
||||||
|
(assert_return (invoke "i32-dec-sep1") (i32.const 1000000))
|
||||||
|
(assert_return (invoke "i32-dec-sep2") (i32.const 1000))
|
||||||
|
(assert_return (invoke "i32-hex-sep1") (i32.const 0xa0f0099))
|
||||||
|
(assert_return (invoke "i32-hex-sep2") (i32.const 0x1aa0f))
|
||||||
|
|
||||||
|
(assert_return (invoke "i64-dec-sep1") (i64.const 1000000))
|
||||||
|
(assert_return (invoke "i64-dec-sep2") (i64.const 1000))
|
||||||
|
(assert_return (invoke "i64-hex-sep1") (i64.const 0xaf00f00009999))
|
||||||
|
(assert_return (invoke "i64-hex-sep2") (i64.const 0x1aa0f))
|
||||||
|
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global i32 (i32.const _100))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global i32 (i32.const +_100))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global i32 (i32.const -_100))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global i32 (i32.const 99_))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global i32 (i32.const 1__000))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global i32 (i32.const _0x100))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global i32 (i32.const 0_x100))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global i32 (i32.const 0x_100))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global i32 (i32.const 0x00_))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global i32 (i32.const 0xff__ffff))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global i64 (i64.const _100))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global i64 (i64.const +_100))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global i64 (i64.const -_100))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global i64 (i64.const 99_))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global i64 (i64.const 1__000))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global i64 (i64.const _0x100))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global i64 (i64.const 0_x100))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global i64 (i64.const 0x_100))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global i64 (i64.const 0x00_))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(global i64 (i64.const 0xff__ffff))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
@@ -0,0 +1,321 @@
|
|||||||
|
(module
|
||||||
|
(func (export "block") (result i32)
|
||||||
|
(block $exit (result i32)
|
||||||
|
(br $exit (i32.const 1))
|
||||||
|
(i32.const 0)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "loop1") (result i32)
|
||||||
|
(local $i i32)
|
||||||
|
(set_local $i (i32.const 0))
|
||||||
|
(block $exit (result i32)
|
||||||
|
(loop $cont (result i32)
|
||||||
|
(set_local $i (i32.add (get_local $i) (i32.const 1)))
|
||||||
|
(if (i32.eq (get_local $i) (i32.const 5))
|
||||||
|
(then (br $exit (get_local $i)))
|
||||||
|
)
|
||||||
|
(br $cont)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "loop2") (result i32)
|
||||||
|
(local $i i32)
|
||||||
|
(set_local $i (i32.const 0))
|
||||||
|
(block $exit (result i32)
|
||||||
|
(loop $cont (result i32)
|
||||||
|
(set_local $i (i32.add (get_local $i) (i32.const 1)))
|
||||||
|
(if (i32.eq (get_local $i) (i32.const 5))
|
||||||
|
(then (br $cont))
|
||||||
|
)
|
||||||
|
(if (i32.eq (get_local $i) (i32.const 8))
|
||||||
|
(then (br $exit (get_local $i)))
|
||||||
|
)
|
||||||
|
(set_local $i (i32.add (get_local $i) (i32.const 1)))
|
||||||
|
(br $cont)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "loop3") (result i32)
|
||||||
|
(local $i i32)
|
||||||
|
(set_local $i (i32.const 0))
|
||||||
|
(block $exit (result i32)
|
||||||
|
(loop $cont (result i32)
|
||||||
|
(set_local $i (i32.add (get_local $i) (i32.const 1)))
|
||||||
|
(if (i32.eq (get_local $i) (i32.const 5))
|
||||||
|
(then (br $exit (get_local $i)))
|
||||||
|
)
|
||||||
|
(get_local $i)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "loop4") (param $max i32) (result i32)
|
||||||
|
(local $i i32)
|
||||||
|
(set_local $i (i32.const 1))
|
||||||
|
(block $exit (result i32)
|
||||||
|
(loop $cont (result i32)
|
||||||
|
(set_local $i (i32.add (get_local $i) (get_local $i)))
|
||||||
|
(if (i32.gt_u (get_local $i) (get_local $max))
|
||||||
|
(then (br $exit (get_local $i)))
|
||||||
|
)
|
||||||
|
(br $cont)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "loop5") (result i32)
|
||||||
|
(i32.add
|
||||||
|
(loop $l (result i32) (i32.const 1))
|
||||||
|
(i32.const 1)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "loop6") (result i32)
|
||||||
|
(loop (result i32)
|
||||||
|
(br_if 0 (i32.const 0))
|
||||||
|
(i32.const 3)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "if") (result i32)
|
||||||
|
(local $i i32)
|
||||||
|
(set_local $i (i32.const 0))
|
||||||
|
(block
|
||||||
|
(if $l
|
||||||
|
(i32.const 1)
|
||||||
|
(then (br $l) (set_local $i (i32.const 666)))
|
||||||
|
)
|
||||||
|
(set_local $i (i32.add (get_local $i) (i32.const 1)))
|
||||||
|
(if $l
|
||||||
|
(i32.const 1)
|
||||||
|
(then (br $l) (set_local $i (i32.const 666)))
|
||||||
|
(else (set_local $i (i32.const 888)))
|
||||||
|
)
|
||||||
|
(set_local $i (i32.add (get_local $i) (i32.const 1)))
|
||||||
|
(if $l
|
||||||
|
(i32.const 1)
|
||||||
|
(then (br $l) (set_local $i (i32.const 666)))
|
||||||
|
(else (set_local $i (i32.const 888)))
|
||||||
|
)
|
||||||
|
(set_local $i (i32.add (get_local $i) (i32.const 1)))
|
||||||
|
(if $l
|
||||||
|
(i32.const 0)
|
||||||
|
(then (set_local $i (i32.const 888)))
|
||||||
|
(else (br $l) (set_local $i (i32.const 666)))
|
||||||
|
)
|
||||||
|
(set_local $i (i32.add (get_local $i) (i32.const 1)))
|
||||||
|
(if $l
|
||||||
|
(i32.const 0)
|
||||||
|
(then (set_local $i (i32.const 888)))
|
||||||
|
(else (br $l) (set_local $i (i32.const 666)))
|
||||||
|
)
|
||||||
|
(set_local $i (i32.add (get_local $i) (i32.const 1)))
|
||||||
|
)
|
||||||
|
(get_local $i)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "if2") (result i32)
|
||||||
|
(local $i i32)
|
||||||
|
(set_local $i (i32.const 0))
|
||||||
|
(block
|
||||||
|
(if
|
||||||
|
(i32.const 1)
|
||||||
|
(then (br 0) (set_local $i (i32.const 666)))
|
||||||
|
)
|
||||||
|
(set_local $i (i32.add (get_local $i) (i32.const 1)))
|
||||||
|
(if
|
||||||
|
(i32.const 1)
|
||||||
|
(then (br 0) (set_local $i (i32.const 666)))
|
||||||
|
(else (set_local $i (i32.const 888)))
|
||||||
|
)
|
||||||
|
(set_local $i (i32.add (get_local $i) (i32.const 1)))
|
||||||
|
(if
|
||||||
|
(i32.const 1)
|
||||||
|
(then (br 0) (set_local $i (i32.const 666)))
|
||||||
|
(else (set_local $i (i32.const 888)))
|
||||||
|
)
|
||||||
|
(set_local $i (i32.add (get_local $i) (i32.const 1)))
|
||||||
|
(if
|
||||||
|
(i32.const 0)
|
||||||
|
(then (set_local $i (i32.const 888)))
|
||||||
|
(else (br 0) (set_local $i (i32.const 666)))
|
||||||
|
)
|
||||||
|
(set_local $i (i32.add (get_local $i) (i32.const 1)))
|
||||||
|
(if
|
||||||
|
(i32.const 0)
|
||||||
|
(then (set_local $i (i32.const 888)))
|
||||||
|
(else (br 0) (set_local $i (i32.const 666)))
|
||||||
|
)
|
||||||
|
(set_local $i (i32.add (get_local $i) (i32.const 1)))
|
||||||
|
)
|
||||||
|
(get_local $i)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "switch") (param i32) (result i32)
|
||||||
|
(block $ret (result i32)
|
||||||
|
(i32.mul (i32.const 10)
|
||||||
|
(block $exit (result i32)
|
||||||
|
(block $0
|
||||||
|
(block $default
|
||||||
|
(block $3
|
||||||
|
(block $2
|
||||||
|
(block $1
|
||||||
|
(br_table $0 $1 $2 $3 $default (get_local 0))
|
||||||
|
) ;; 1
|
||||||
|
) ;; 2
|
||||||
|
(br $exit (i32.const 2))
|
||||||
|
) ;; 3
|
||||||
|
(br $ret (i32.const 3))
|
||||||
|
) ;; default
|
||||||
|
) ;; 0
|
||||||
|
(i32.const 5)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "return") (param i32) (result i32)
|
||||||
|
(block $default
|
||||||
|
(block $1
|
||||||
|
(block $0
|
||||||
|
(br_table $0 $1 (get_local 0))
|
||||||
|
(br $default)
|
||||||
|
) ;; 0
|
||||||
|
(return (i32.const 0))
|
||||||
|
) ;; 1
|
||||||
|
) ;; default
|
||||||
|
(i32.const 2)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "br_if0") (result i32)
|
||||||
|
(local $i i32)
|
||||||
|
(set_local $i (i32.const 0))
|
||||||
|
(block $outer (result i32)
|
||||||
|
(block $inner
|
||||||
|
(br_if $inner (i32.const 0))
|
||||||
|
(set_local $i (i32.or (get_local $i) (i32.const 0x1)))
|
||||||
|
(br_if $inner (i32.const 1))
|
||||||
|
(set_local $i (i32.or (get_local $i) (i32.const 0x2)))
|
||||||
|
)
|
||||||
|
(drop (br_if $outer
|
||||||
|
(block (result i32)
|
||||||
|
(set_local $i (i32.or (get_local $i) (i32.const 0x4)))
|
||||||
|
(get_local $i)
|
||||||
|
)
|
||||||
|
(i32.const 0)
|
||||||
|
))
|
||||||
|
(set_local $i (i32.or (get_local $i) (i32.const 0x8)))
|
||||||
|
(drop (br_if $outer
|
||||||
|
(block (result i32)
|
||||||
|
(set_local $i (i32.or (get_local $i) (i32.const 0x10)))
|
||||||
|
(get_local $i)
|
||||||
|
)
|
||||||
|
(i32.const 1)
|
||||||
|
))
|
||||||
|
(set_local $i (i32.or (get_local $i) (i32.const 0x20))) (get_local $i)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "br_if1") (result i32)
|
||||||
|
(block $l0 (result i32)
|
||||||
|
(drop
|
||||||
|
(br_if $l0
|
||||||
|
(block $l1 (result i32) (br $l1 (i32.const 1)))
|
||||||
|
(i32.const 1)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(i32.const 1)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "br_if2") (result i32)
|
||||||
|
(block $l0 (result i32)
|
||||||
|
(if (i32.const 1)
|
||||||
|
(then (br $l0 (block $l1 (result i32) (br $l1 (i32.const 1)))))
|
||||||
|
)
|
||||||
|
(i32.const 1)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "br_if3") (result i32)
|
||||||
|
(local $i1 i32)
|
||||||
|
(drop
|
||||||
|
(i32.add
|
||||||
|
(block $l0 (result i32)
|
||||||
|
(drop (br_if $l0
|
||||||
|
(block (result i32) (set_local $i1 (i32.const 1)) (get_local $i1))
|
||||||
|
(block (result i32) (set_local $i1 (i32.const 2)) (get_local $i1))
|
||||||
|
))
|
||||||
|
(i32.const 0)
|
||||||
|
)
|
||||||
|
(i32.const 0)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(get_local $i1)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "br") (result i32)
|
||||||
|
(block $l0 (result i32)
|
||||||
|
(if (i32.const 1)
|
||||||
|
(then (br $l0 (block $l1 (result i32) (br $l1 (i32.const 1)))))
|
||||||
|
(else (block (drop (block $l1 (result i32) (br $l1 (i32.const 1))))))
|
||||||
|
)
|
||||||
|
(i32.const 1)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "shadowing") (result i32)
|
||||||
|
(block $l1 (result i32) (i32.xor (br $l1 (i32.const 1)) (i32.const 2)))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "redefinition") (result i32)
|
||||||
|
(block $l1 (result i32)
|
||||||
|
(i32.add
|
||||||
|
(block $l1 (result i32) (i32.const 2))
|
||||||
|
(block $l1 (result i32) (br $l1 (i32.const 3)))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke "block") (i32.const 1))
|
||||||
|
(assert_return (invoke "loop1") (i32.const 5))
|
||||||
|
(assert_return (invoke "loop2") (i32.const 8))
|
||||||
|
(assert_return (invoke "loop3") (i32.const 1))
|
||||||
|
(assert_return (invoke "loop4" (i32.const 8)) (i32.const 16))
|
||||||
|
(assert_return (invoke "loop5") (i32.const 2))
|
||||||
|
(assert_return (invoke "loop6") (i32.const 3))
|
||||||
|
(assert_return (invoke "if") (i32.const 5))
|
||||||
|
(assert_return (invoke "if2") (i32.const 5))
|
||||||
|
(assert_return (invoke "switch" (i32.const 0)) (i32.const 50))
|
||||||
|
(assert_return (invoke "switch" (i32.const 1)) (i32.const 20))
|
||||||
|
(assert_return (invoke "switch" (i32.const 2)) (i32.const 20))
|
||||||
|
(assert_return (invoke "switch" (i32.const 3)) (i32.const 3))
|
||||||
|
(assert_return (invoke "switch" (i32.const 4)) (i32.const 50))
|
||||||
|
(assert_return (invoke "switch" (i32.const 5)) (i32.const 50))
|
||||||
|
(assert_return (invoke "return" (i32.const 0)) (i32.const 0))
|
||||||
|
(assert_return (invoke "return" (i32.const 1)) (i32.const 2))
|
||||||
|
(assert_return (invoke "return" (i32.const 2)) (i32.const 2))
|
||||||
|
(assert_return (invoke "br_if0") (i32.const 0x1d))
|
||||||
|
(assert_return (invoke "br_if1") (i32.const 1))
|
||||||
|
(assert_return (invoke "br_if2") (i32.const 1))
|
||||||
|
(assert_return (invoke "br_if3") (i32.const 2))
|
||||||
|
(assert_return (invoke "br") (i32.const 1))
|
||||||
|
(assert_return (invoke "shadowing") (i32.const 1))
|
||||||
|
(assert_return (invoke "redefinition") (i32.const 5))
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func (block $l (f32.neg (br_if $l (i32.const 1))) (nop))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func (block $l (br_if $l (f32.const 0) (i32.const 1)))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func (block $l (br_if $l (f32.const 0) (i32.const 1)))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
@@ -0,0 +1,233 @@
|
|||||||
|
(module
|
||||||
|
(memory 1)
|
||||||
|
|
||||||
|
(type $i32_T (func (param i32 i32) (result i32)))
|
||||||
|
(type $i64_T (func (param i64 i64) (result i32)))
|
||||||
|
(type $f32_T (func (param f32 f32) (result i32)))
|
||||||
|
(type $f64_T (func (param f64 f64) (result i32)))
|
||||||
|
(table anyfunc
|
||||||
|
(elem $i32_t0 $i32_t1 $i64_t0 $i64_t1 $f32_t0 $f32_t1 $f64_t0 $f64_t1)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func $i32_t0 (type $i32_T) (i32.const -1))
|
||||||
|
(func $i32_t1 (type $i32_T) (i32.const -2))
|
||||||
|
(func $i64_t0 (type $i64_T) (i32.const -1))
|
||||||
|
(func $i64_t1 (type $i64_T) (i32.const -2))
|
||||||
|
(func $f32_t0 (type $f32_T) (i32.const -1))
|
||||||
|
(func $f32_t1 (type $f32_T) (i32.const -2))
|
||||||
|
(func $f64_t0 (type $f64_T) (i32.const -1))
|
||||||
|
(func $f64_t1 (type $f64_T) (i32.const -2))
|
||||||
|
|
||||||
|
;; The idea is: We reset the memory, then the instruction call $*_left,
|
||||||
|
;; $*_right, $*_another, $*_callee (for indirect calls), and $*_bool (when a
|
||||||
|
;; boolean value is needed). These functions all call bump, which shifts the
|
||||||
|
;; memory starting at address 8 up a byte, and then store a unique value at
|
||||||
|
;; address 8. Then we read the 4-byte value at address 8. It should contain
|
||||||
|
;; the correct sequence of unique values if the calls were evaluated in the
|
||||||
|
;; correct order.
|
||||||
|
|
||||||
|
(func $reset (i32.store (i32.const 8) (i32.const 0)))
|
||||||
|
|
||||||
|
(func $bump
|
||||||
|
(i32.store8 (i32.const 11) (i32.load8_u (i32.const 10)))
|
||||||
|
(i32.store8 (i32.const 10) (i32.load8_u (i32.const 9)))
|
||||||
|
(i32.store8 (i32.const 9) (i32.load8_u (i32.const 8)))
|
||||||
|
(i32.store8 (i32.const 8) (i32.const -3)))
|
||||||
|
|
||||||
|
(func $get (result i32) (i32.load (i32.const 8)))
|
||||||
|
|
||||||
|
(func $i32_left (result i32) (call $bump) (i32.store8 (i32.const 8) (i32.const 1)) (i32.const 0))
|
||||||
|
(func $i32_right (result i32) (call $bump) (i32.store8 (i32.const 8) (i32.const 2)) (i32.const 1))
|
||||||
|
(func $i32_another (result i32) (call $bump) (i32.store8 (i32.const 8) (i32.const 3)) (i32.const 1))
|
||||||
|
(func $i32_callee (result i32) (call $bump) (i32.store8 (i32.const 8) (i32.const 4)) (i32.const 0))
|
||||||
|
(func $i32_bool (result i32) (call $bump) (i32.store8 (i32.const 8) (i32.const 5)) (i32.const 0))
|
||||||
|
(func $i64_left (result i64) (call $bump) (i32.store8 (i32.const 8) (i32.const 1)) (i64.const 0))
|
||||||
|
(func $i64_right (result i64) (call $bump) (i32.store8 (i32.const 8) (i32.const 2)) (i64.const 1))
|
||||||
|
(func $i64_another (result i64) (call $bump) (i32.store8 (i32.const 8) (i32.const 3)) (i64.const 1))
|
||||||
|
(func $i64_callee (result i32) (call $bump) (i32.store8 (i32.const 8) (i32.const 4)) (i32.const 2))
|
||||||
|
(func $i64_bool (result i32) (call $bump) (i32.store8 (i32.const 8) (i32.const 5)) (i32.const 0))
|
||||||
|
(func $f32_left (result f32) (call $bump) (i32.store8 (i32.const 8) (i32.const 1)) (f32.const 0))
|
||||||
|
(func $f32_right (result f32) (call $bump) (i32.store8 (i32.const 8) (i32.const 2)) (f32.const 1))
|
||||||
|
(func $f32_another (result f32) (call $bump) (i32.store8 (i32.const 8) (i32.const 3)) (f32.const 1))
|
||||||
|
(func $f32_callee (result i32) (call $bump) (i32.store8 (i32.const 8) (i32.const 4)) (i32.const 4))
|
||||||
|
(func $f32_bool (result i32) (call $bump) (i32.store8 (i32.const 8) (i32.const 5)) (i32.const 0))
|
||||||
|
(func $f64_left (result f64) (call $bump) (i32.store8 (i32.const 8) (i32.const 1)) (f64.const 0))
|
||||||
|
(func $f64_right (result f64) (call $bump) (i32.store8 (i32.const 8) (i32.const 2)) (f64.const 1))
|
||||||
|
(func $f64_another (result f64) (call $bump) (i32.store8 (i32.const 8) (i32.const 3)) (f64.const 1))
|
||||||
|
(func $f64_callee (result i32) (call $bump) (i32.store8 (i32.const 8) (i32.const 4)) (i32.const 6))
|
||||||
|
(func $f64_bool (result i32) (call $bump) (i32.store8 (i32.const 8) (i32.const 5)) (i32.const 0))
|
||||||
|
(func $i32_dummy (param i32 i32))
|
||||||
|
(func $i64_dummy (param i64 i64))
|
||||||
|
(func $f32_dummy (param f32 f32))
|
||||||
|
(func $f64_dummy (param f64 f64))
|
||||||
|
|
||||||
|
(func (export "i32_add") (result i32) (call $reset) (drop (i32.add (call $i32_left) (call $i32_right))) (call $get))
|
||||||
|
(func (export "i32_sub") (result i32) (call $reset) (drop (i32.sub (call $i32_left) (call $i32_right))) (call $get))
|
||||||
|
(func (export "i32_mul") (result i32) (call $reset) (drop (i32.mul (call $i32_left) (call $i32_right))) (call $get))
|
||||||
|
(func (export "i32_div_s") (result i32) (call $reset) (drop (i32.div_s (call $i32_left) (call $i32_right))) (call $get))
|
||||||
|
(func (export "i32_div_u") (result i32) (call $reset) (drop (i32.div_u (call $i32_left) (call $i32_right))) (call $get))
|
||||||
|
(func (export "i32_rem_s") (result i32) (call $reset) (drop (i32.rem_s (call $i32_left) (call $i32_right))) (call $get))
|
||||||
|
(func (export "i32_rem_u") (result i32) (call $reset) (drop (i32.rem_u (call $i32_left) (call $i32_right))) (call $get))
|
||||||
|
(func (export "i32_and") (result i32) (call $reset) (drop (i32.and (call $i32_left) (call $i32_right))) (call $get))
|
||||||
|
(func (export "i32_or") (result i32) (call $reset) (drop (i32.or (call $i32_left) (call $i32_right))) (call $get))
|
||||||
|
(func (export "i32_xor") (result i32) (call $reset) (drop (i32.xor (call $i32_left) (call $i32_right))) (call $get))
|
||||||
|
(func (export "i32_shl") (result i32) (call $reset) (drop (i32.shl (call $i32_left) (call $i32_right))) (call $get))
|
||||||
|
(func (export "i32_shr_u") (result i32) (call $reset) (drop (i32.shr_u (call $i32_left) (call $i32_right))) (call $get))
|
||||||
|
(func (export "i32_shr_s") (result i32) (call $reset) (drop (i32.shr_s (call $i32_left) (call $i32_right))) (call $get))
|
||||||
|
(func (export "i32_eq") (result i32) (call $reset) (drop (i32.eq (call $i32_left) (call $i32_right))) (call $get))
|
||||||
|
(func (export "i32_ne") (result i32) (call $reset) (drop (i32.ne (call $i32_left) (call $i32_right))) (call $get))
|
||||||
|
(func (export "i32_lt_s") (result i32) (call $reset) (drop (i32.lt_s (call $i32_left) (call $i32_right))) (call $get))
|
||||||
|
(func (export "i32_le_s") (result i32) (call $reset) (drop (i32.le_s (call $i32_left) (call $i32_right))) (call $get))
|
||||||
|
(func (export "i32_lt_u") (result i32) (call $reset) (drop (i32.lt_u (call $i32_left) (call $i32_right))) (call $get))
|
||||||
|
(func (export "i32_le_u") (result i32) (call $reset) (drop (i32.le_u (call $i32_left) (call $i32_right))) (call $get))
|
||||||
|
(func (export "i32_gt_s") (result i32) (call $reset) (drop (i32.gt_s (call $i32_left) (call $i32_right))) (call $get))
|
||||||
|
(func (export "i32_ge_s") (result i32) (call $reset) (drop (i32.ge_s (call $i32_left) (call $i32_right))) (call $get))
|
||||||
|
(func (export "i32_gt_u") (result i32) (call $reset) (drop (i32.gt_u (call $i32_left) (call $i32_right))) (call $get))
|
||||||
|
(func (export "i32_ge_u") (result i32) (call $reset) (drop (i32.ge_u (call $i32_left) (call $i32_right))) (call $get))
|
||||||
|
(func (export "i32_store") (result i32) (call $reset) (i32.store (call $i32_left) (call $i32_right)) (call $get))
|
||||||
|
(func (export "i32_store8") (result i32) (call $reset) (i32.store8 (call $i32_left) (call $i32_right)) (call $get))
|
||||||
|
(func (export "i32_store16") (result i32) (call $reset) (i32.store16 (call $i32_left) (call $i32_right)) (call $get))
|
||||||
|
(func (export "i32_call") (result i32) (call $reset) (call $i32_dummy (call $i32_left) (call $i32_right)) (call $get))
|
||||||
|
(func (export "i32_call_indirect") (result i32) (call $reset) (drop (call_indirect (type $i32_T) (call $i32_left) (call $i32_right) (call $i32_callee))) (call $get))
|
||||||
|
(func (export "i32_select") (result i32) (call $reset) (drop (select (call $i32_left) (call $i32_right) (call $i32_bool))) (call $get))
|
||||||
|
|
||||||
|
(func (export "i64_add") (result i32) (call $reset) (drop (i64.add (call $i64_left) (call $i64_right))) (call $get))
|
||||||
|
(func (export "i64_sub") (result i32) (call $reset) (drop (i64.sub (call $i64_left) (call $i64_right))) (call $get))
|
||||||
|
(func (export "i64_mul") (result i32) (call $reset) (drop (i64.mul (call $i64_left) (call $i64_right))) (call $get))
|
||||||
|
(func (export "i64_div_s") (result i32) (call $reset) (drop (i64.div_s (call $i64_left) (call $i64_right))) (call $get))
|
||||||
|
(func (export "i64_div_u") (result i32) (call $reset) (drop (i64.div_u (call $i64_left) (call $i64_right))) (call $get))
|
||||||
|
(func (export "i64_rem_s") (result i32) (call $reset) (drop (i64.rem_s (call $i64_left) (call $i64_right))) (call $get))
|
||||||
|
(func (export "i64_rem_u") (result i32) (call $reset) (drop (i64.rem_u (call $i64_left) (call $i64_right))) (call $get))
|
||||||
|
(func (export "i64_and") (result i32) (call $reset) (drop (i64.and (call $i64_left) (call $i64_right))) (call $get))
|
||||||
|
(func (export "i64_or") (result i32) (call $reset) (drop (i64.or (call $i64_left) (call $i64_right))) (call $get))
|
||||||
|
(func (export "i64_xor") (result i32) (call $reset) (drop (i64.xor (call $i64_left) (call $i64_right))) (call $get))
|
||||||
|
(func (export "i64_shl") (result i32) (call $reset) (drop (i64.shl (call $i64_left) (call $i64_right))) (call $get))
|
||||||
|
(func (export "i64_shr_u") (result i32) (call $reset) (drop (i64.shr_u (call $i64_left) (call $i64_right))) (call $get))
|
||||||
|
(func (export "i64_shr_s") (result i32) (call $reset) (drop (i64.shr_s (call $i64_left) (call $i64_right))) (call $get))
|
||||||
|
(func (export "i64_eq") (result i32) (call $reset) (drop (i64.eq (call $i64_left) (call $i64_right))) (call $get))
|
||||||
|
(func (export "i64_ne") (result i32) (call $reset) (drop (i64.ne (call $i64_left) (call $i64_right))) (call $get))
|
||||||
|
(func (export "i64_lt_s") (result i32) (call $reset) (drop (i64.lt_s (call $i64_left) (call $i64_right))) (call $get))
|
||||||
|
(func (export "i64_le_s") (result i32) (call $reset) (drop (i64.le_s (call $i64_left) (call $i64_right))) (call $get))
|
||||||
|
(func (export "i64_lt_u") (result i32) (call $reset) (drop (i64.lt_u (call $i64_left) (call $i64_right))) (call $get))
|
||||||
|
(func (export "i64_le_u") (result i32) (call $reset) (drop (i64.le_u (call $i64_left) (call $i64_right))) (call $get))
|
||||||
|
(func (export "i64_gt_s") (result i32) (call $reset) (drop (i64.gt_s (call $i64_left) (call $i64_right))) (call $get))
|
||||||
|
(func (export "i64_ge_s") (result i32) (call $reset) (drop (i64.ge_s (call $i64_left) (call $i64_right))) (call $get))
|
||||||
|
(func (export "i64_gt_u") (result i32) (call $reset) (drop (i64.gt_u (call $i64_left) (call $i64_right))) (call $get))
|
||||||
|
(func (export "i64_ge_u") (result i32) (call $reset) (drop (i64.ge_u (call $i64_left) (call $i64_right))) (call $get))
|
||||||
|
(func (export "i64_store") (result i32) (call $reset) (i64.store (call $i32_left) (call $i64_right)) (call $get))
|
||||||
|
(func (export "i64_store8") (result i32) (call $reset) (i64.store8 (call $i32_left) (call $i64_right)) (call $get))
|
||||||
|
(func (export "i64_store16") (result i32) (call $reset) (i64.store16 (call $i32_left) (call $i64_right)) (call $get))
|
||||||
|
(func (export "i64_store32") (result i32) (call $reset) (i64.store32 (call $i32_left) (call $i64_right)) (call $get))
|
||||||
|
(func (export "i64_call") (result i32) (call $reset) (call $i64_dummy (call $i64_left) (call $i64_right)) (call $get))
|
||||||
|
(func (export "i64_call_indirect") (result i32) (call $reset) (drop (call_indirect (type $i64_T) (call $i64_left) (call $i64_right) (call $i64_callee))) (call $get))
|
||||||
|
(func (export "i64_select") (result i32) (call $reset) (drop (select (call $i64_left) (call $i64_right) (call $i64_bool))) (call $get))
|
||||||
|
|
||||||
|
(func (export "f32_add") (result i32) (call $reset) (drop (f32.add (call $f32_left) (call $f32_right))) (call $get))
|
||||||
|
(func (export "f32_sub") (result i32) (call $reset) (drop (f32.sub (call $f32_left) (call $f32_right))) (call $get))
|
||||||
|
(func (export "f32_mul") (result i32) (call $reset) (drop (f32.mul (call $f32_left) (call $f32_right))) (call $get))
|
||||||
|
(func (export "f32_div") (result i32) (call $reset) (drop (f32.div (call $f32_left) (call $f32_right))) (call $get))
|
||||||
|
(func (export "f32_copysign") (result i32) (call $reset) (drop (f32.copysign (call $f32_left) (call $f32_right))) (call $get))
|
||||||
|
(func (export "f32_eq") (result i32) (call $reset) (drop (f32.eq (call $f32_left) (call $f32_right))) (call $get))
|
||||||
|
(func (export "f32_ne") (result i32) (call $reset) (drop (f32.ne (call $f32_left) (call $f32_right))) (call $get))
|
||||||
|
(func (export "f32_lt") (result i32) (call $reset) (drop (f32.lt (call $f32_left) (call $f32_right))) (call $get))
|
||||||
|
(func (export "f32_le") (result i32) (call $reset) (drop (f32.le (call $f32_left) (call $f32_right))) (call $get))
|
||||||
|
(func (export "f32_gt") (result i32) (call $reset) (drop (f32.gt (call $f32_left) (call $f32_right))) (call $get))
|
||||||
|
(func (export "f32_ge") (result i32) (call $reset) (drop (f32.ge (call $f32_left) (call $f32_right))) (call $get))
|
||||||
|
(func (export "f32_min") (result i32) (call $reset) (drop (f32.min (call $f32_left) (call $f32_right))) (call $get))
|
||||||
|
(func (export "f32_max") (result i32) (call $reset) (drop (f32.max (call $f32_left) (call $f32_right))) (call $get))
|
||||||
|
(func (export "f32_store") (result i32) (call $reset) (f32.store (call $i32_left) (call $f32_right)) (call $get))
|
||||||
|
(func (export "f32_call") (result i32) (call $reset) (call $f32_dummy (call $f32_left) (call $f32_right)) (call $get))
|
||||||
|
(func (export "f32_call_indirect") (result i32) (call $reset) (drop (call_indirect (type $f32_T) (call $f32_left) (call $f32_right) (call $f32_callee))) (call $get))
|
||||||
|
(func (export "f32_select") (result i32) (call $reset) (drop (select (call $f32_left) (call $f32_right) (call $f32_bool))) (call $get))
|
||||||
|
|
||||||
|
(func (export "f64_add") (result i32) (call $reset) (drop (f64.add (call $f64_left) (call $f64_right))) (call $get))
|
||||||
|
(func (export "f64_sub") (result i32) (call $reset) (drop (f64.sub (call $f64_left) (call $f64_right))) (call $get))
|
||||||
|
(func (export "f64_mul") (result i32) (call $reset) (drop (f64.mul (call $f64_left) (call $f64_right))) (call $get))
|
||||||
|
(func (export "f64_div") (result i32) (call $reset) (drop (f64.div (call $f64_left) (call $f64_right))) (call $get))
|
||||||
|
(func (export "f64_copysign") (result i32) (call $reset) (drop (f64.copysign (call $f64_left) (call $f64_right))) (call $get))
|
||||||
|
(func (export "f64_eq") (result i32) (call $reset) (drop (f64.eq (call $f64_left) (call $f64_right))) (call $get))
|
||||||
|
(func (export "f64_ne") (result i32) (call $reset) (drop (f64.ne (call $f64_left) (call $f64_right))) (call $get))
|
||||||
|
(func (export "f64_lt") (result i32) (call $reset) (drop (f64.lt (call $f64_left) (call $f64_right))) (call $get))
|
||||||
|
(func (export "f64_le") (result i32) (call $reset) (drop (f64.le (call $f64_left) (call $f64_right))) (call $get))
|
||||||
|
(func (export "f64_gt") (result i32) (call $reset) (drop (f64.gt (call $f64_left) (call $f64_right))) (call $get))
|
||||||
|
(func (export "f64_ge") (result i32) (call $reset) (drop (f64.ge (call $f64_left) (call $f64_right))) (call $get))
|
||||||
|
(func (export "f64_min") (result i32) (call $reset) (drop (f64.min (call $f64_left) (call $f64_right))) (call $get))
|
||||||
|
(func (export "f64_max") (result i32) (call $reset) (drop (f64.max (call $f64_left) (call $f64_right))) (call $get))
|
||||||
|
(func (export "f64_store") (result i32) (call $reset) (f64.store (call $i32_left) (call $f64_right)) (call $get))
|
||||||
|
(func (export "f64_call") (result i32) (call $reset) (call $f64_dummy (call $f64_left) (call $f64_right)) (call $get))
|
||||||
|
(func (export "f64_call_indirect") (result i32) (call $reset) (drop (call_indirect (type $f64_T) (call $f64_left) (call $f64_right) (call $f64_callee))) (call $get))
|
||||||
|
(func (export "f64_select") (result i32) (call $reset) (drop (select (call $f64_left) (call $f64_right) (call $f64_bool))) (call $get))
|
||||||
|
|
||||||
|
(func (export "br_if") (result i32)
|
||||||
|
(block (result i32)
|
||||||
|
(call $reset)
|
||||||
|
(drop (br_if 0 (call $i32_left) (i32.and (call $i32_right) (i32.const 0))))
|
||||||
|
(call $get)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(func (export "br_table") (result i32)
|
||||||
|
(block $a (result i32)
|
||||||
|
(call $reset)
|
||||||
|
(drop
|
||||||
|
(block $b (result i32)
|
||||||
|
(br_table $a $b (call $i32_left) (call $i32_right))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(call $get)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke "i32_add") (i32.const 0x0102)) (assert_return (invoke "i64_add") (i32.const 0x0102))
|
||||||
|
(assert_return (invoke "i32_sub") (i32.const 0x0102)) (assert_return (invoke "i64_sub") (i32.const 0x0102))
|
||||||
|
(assert_return (invoke "i32_mul") (i32.const 0x0102)) (assert_return (invoke "i64_mul") (i32.const 0x0102))
|
||||||
|
(assert_return (invoke "i32_div_s") (i32.const 0x0102)) (assert_return (invoke "i64_div_s") (i32.const 0x0102))
|
||||||
|
(assert_return (invoke "i32_div_u") (i32.const 0x0102)) (assert_return (invoke "i64_div_u") (i32.const 0x0102))
|
||||||
|
(assert_return (invoke "i32_rem_s") (i32.const 0x0102)) (assert_return (invoke "i64_rem_s") (i32.const 0x0102))
|
||||||
|
(assert_return (invoke "i32_rem_u") (i32.const 0x0102)) (assert_return (invoke "i64_rem_u") (i32.const 0x0102))
|
||||||
|
(assert_return (invoke "i32_and") (i32.const 0x0102)) (assert_return (invoke "i64_and") (i32.const 0x0102))
|
||||||
|
(assert_return (invoke "i32_or") (i32.const 0x0102)) (assert_return (invoke "i64_or") (i32.const 0x0102))
|
||||||
|
(assert_return (invoke "i32_xor") (i32.const 0x0102)) (assert_return (invoke "i64_xor") (i32.const 0x0102))
|
||||||
|
(assert_return (invoke "i32_shl") (i32.const 0x0102)) (assert_return (invoke "i64_shl") (i32.const 0x0102))
|
||||||
|
(assert_return (invoke "i32_shr_u") (i32.const 0x0102)) (assert_return (invoke "i64_shr_u") (i32.const 0x0102))
|
||||||
|
(assert_return (invoke "i32_shr_s") (i32.const 0x0102)) (assert_return (invoke "i64_shr_s") (i32.const 0x0102))
|
||||||
|
(assert_return (invoke "i32_eq") (i32.const 0x0102)) (assert_return (invoke "i64_eq") (i32.const 0x0102))
|
||||||
|
(assert_return (invoke "i32_ne") (i32.const 0x0102)) (assert_return (invoke "i64_ne") (i32.const 0x0102))
|
||||||
|
(assert_return (invoke "i32_lt_s") (i32.const 0x0102)) (assert_return (invoke "i64_lt_s") (i32.const 0x0102))
|
||||||
|
(assert_return (invoke "i32_le_s") (i32.const 0x0102)) (assert_return (invoke "i64_le_s") (i32.const 0x0102))
|
||||||
|
(assert_return (invoke "i32_lt_u") (i32.const 0x0102)) (assert_return (invoke "i64_lt_u") (i32.const 0x0102))
|
||||||
|
(assert_return (invoke "i32_le_u") (i32.const 0x0102)) (assert_return (invoke "i64_le_u") (i32.const 0x0102))
|
||||||
|
(assert_return (invoke "i32_gt_s") (i32.const 0x0102)) (assert_return (invoke "i64_gt_s") (i32.const 0x0102))
|
||||||
|
(assert_return (invoke "i32_ge_s") (i32.const 0x0102)) (assert_return (invoke "i64_ge_s") (i32.const 0x0102))
|
||||||
|
(assert_return (invoke "i32_gt_u") (i32.const 0x0102)) (assert_return (invoke "i64_gt_u") (i32.const 0x0102))
|
||||||
|
(assert_return (invoke "i32_ge_u") (i32.const 0x0102)) (assert_return (invoke "i64_ge_u") (i32.const 0x0102))
|
||||||
|
(assert_return (invoke "i32_store") (i32.const 0x0102)) (assert_return (invoke "i64_store") (i32.const 0x0102))
|
||||||
|
(assert_return (invoke "i32_store8") (i32.const 0x0102)) (assert_return (invoke "i64_store8") (i32.const 0x0102))
|
||||||
|
(assert_return (invoke "i32_store16") (i32.const 0x0102)) (assert_return (invoke "i64_store16") (i32.const 0x0102))
|
||||||
|
(assert_return (invoke "i64_store32") (i32.const 0x0102))
|
||||||
|
(assert_return (invoke "i32_call") (i32.const 0x0102)) (assert_return (invoke "i64_call") (i32.const 0x0102))
|
||||||
|
(assert_return (invoke "i32_call_indirect") (i32.const 0x010204))
|
||||||
|
(assert_return (invoke "i64_call_indirect") (i32.const 0x010204))
|
||||||
|
(assert_return (invoke "i32_select") (i32.const 0x010205)) (assert_return (invoke "i64_select") (i32.const 0x010205))
|
||||||
|
|
||||||
|
(assert_return (invoke "f32_add") (i32.const 0x0102)) (assert_return (invoke "f64_add") (i32.const 0x0102))
|
||||||
|
(assert_return (invoke "f32_sub") (i32.const 0x0102)) (assert_return (invoke "f64_sub") (i32.const 0x0102))
|
||||||
|
(assert_return (invoke "f32_mul") (i32.const 0x0102)) (assert_return (invoke "f64_mul") (i32.const 0x0102))
|
||||||
|
(assert_return (invoke "f32_div") (i32.const 0x0102)) (assert_return (invoke "f64_div") (i32.const 0x0102))
|
||||||
|
(assert_return (invoke "f32_copysign") (i32.const 0x0102))(assert_return (invoke "f64_copysign") (i32.const 0x0102))
|
||||||
|
(assert_return (invoke "f32_eq") (i32.const 0x0102)) (assert_return (invoke "f64_eq") (i32.const 0x0102))
|
||||||
|
(assert_return (invoke "f32_ne") (i32.const 0x0102)) (assert_return (invoke "f64_ne") (i32.const 0x0102))
|
||||||
|
(assert_return (invoke "f32_lt") (i32.const 0x0102)) (assert_return (invoke "f64_lt") (i32.const 0x0102))
|
||||||
|
(assert_return (invoke "f32_le") (i32.const 0x0102)) (assert_return (invoke "f64_le") (i32.const 0x0102))
|
||||||
|
(assert_return (invoke "f32_gt") (i32.const 0x0102)) (assert_return (invoke "f64_gt") (i32.const 0x0102))
|
||||||
|
(assert_return (invoke "f32_ge") (i32.const 0x0102)) (assert_return (invoke "f64_ge") (i32.const 0x0102))
|
||||||
|
(assert_return (invoke "f32_min") (i32.const 0x0102)) (assert_return (invoke "f64_min") (i32.const 0x0102))
|
||||||
|
(assert_return (invoke "f32_max") (i32.const 0x0102)) (assert_return (invoke "f64_max") (i32.const 0x0102))
|
||||||
|
(assert_return (invoke "f32_store") (i32.const 0x0102)) (assert_return (invoke "f64_store") (i32.const 0x0102))
|
||||||
|
(assert_return (invoke "f32_call") (i32.const 0x0102)) (assert_return (invoke "f64_call") (i32.const 0x0102))
|
||||||
|
(assert_return (invoke "f32_call_indirect") (i32.const 0x010204))
|
||||||
|
(assert_return (invoke "f64_call_indirect") (i32.const 0x010204))
|
||||||
|
(assert_return (invoke "f32_select") (i32.const 0x010205)) (assert_return (invoke "f64_select") (i32.const 0x010205))
|
||||||
|
|
||||||
|
(assert_return (invoke "br_if") (i32.const 0x0102))
|
||||||
|
(assert_return (invoke "br_table") (i32.const 0x0102))
|
||||||
@@ -0,0 +1,321 @@
|
|||||||
|
;; Functions
|
||||||
|
|
||||||
|
(module $Mf
|
||||||
|
(func (export "call") (result i32) (call $g))
|
||||||
|
(func $g (result i32) (i32.const 2))
|
||||||
|
)
|
||||||
|
(register "Mf" $Mf)
|
||||||
|
|
||||||
|
(module $Nf
|
||||||
|
(func $f (import "Mf" "call") (result i32))
|
||||||
|
(export "Mf.call" (func $f))
|
||||||
|
(func (export "call Mf.call") (result i32) (call $f))
|
||||||
|
(func (export "call") (result i32) (call $g))
|
||||||
|
(func $g (result i32) (i32.const 3))
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke $Mf "call") (i32.const 2))
|
||||||
|
(assert_return (invoke $Nf "Mf.call") (i32.const 2))
|
||||||
|
(assert_return (invoke $Nf "call") (i32.const 3))
|
||||||
|
(assert_return (invoke $Nf "call Mf.call") (i32.const 2))
|
||||||
|
|
||||||
|
(module
|
||||||
|
(import "spectest" "print_i32" (func $f (param i32)))
|
||||||
|
(export "print" (func $f))
|
||||||
|
)
|
||||||
|
(register "reexport_f")
|
||||||
|
(assert_unlinkable
|
||||||
|
(module (import "reexport_f" "print" (func (param i64))))
|
||||||
|
"incompatible import type"
|
||||||
|
)
|
||||||
|
(assert_unlinkable
|
||||||
|
(module (import "reexport_f" "print" (func (param i32) (result i32))))
|
||||||
|
"incompatible import type"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
;; Globals
|
||||||
|
|
||||||
|
(module $Mg
|
||||||
|
(global $glob (export "glob") i32 (i32.const 42))
|
||||||
|
(func (export "get") (result i32) (get_global $glob))
|
||||||
|
)
|
||||||
|
(register "Mg" $Mg)
|
||||||
|
|
||||||
|
(module $Ng
|
||||||
|
(global $x (import "Mg" "glob") i32)
|
||||||
|
(func $f (import "Mg" "get") (result i32))
|
||||||
|
(export "Mg.glob" (global $x))
|
||||||
|
(export "Mg.get" (func $f))
|
||||||
|
(global $glob (export "glob") i32 (i32.const 43))
|
||||||
|
(func (export "get") (result i32) (get_global $glob))
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (get $Mg "glob") (i32.const 42))
|
||||||
|
(assert_return (get $Ng "Mg.glob") (i32.const 42))
|
||||||
|
(assert_return (get $Ng "glob") (i32.const 43))
|
||||||
|
(assert_return (invoke $Mg "get") (i32.const 42))
|
||||||
|
(assert_return (invoke $Ng "Mg.get") (i32.const 42))
|
||||||
|
(assert_return (invoke $Ng "get") (i32.const 43))
|
||||||
|
|
||||||
|
|
||||||
|
;; Tables
|
||||||
|
|
||||||
|
(module $Mt
|
||||||
|
(type (func (result i32)))
|
||||||
|
(type (func))
|
||||||
|
|
||||||
|
(table (export "tab") 10 anyfunc)
|
||||||
|
(elem (i32.const 2) $g $g $g $g)
|
||||||
|
(func $g (result i32) (i32.const 4))
|
||||||
|
(func (export "h") (result i32) (i32.const -4))
|
||||||
|
|
||||||
|
(func (export "call") (param i32) (result i32)
|
||||||
|
(call_indirect (type 0) (get_local 0))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(register "Mt" $Mt)
|
||||||
|
|
||||||
|
(module $Nt
|
||||||
|
(type (func))
|
||||||
|
(type (func (result i32)))
|
||||||
|
|
||||||
|
(func $f (import "Mt" "call") (param i32) (result i32))
|
||||||
|
(func $h (import "Mt" "h") (result i32))
|
||||||
|
|
||||||
|
(table anyfunc (elem $g $g $g $h $f))
|
||||||
|
(func $g (result i32) (i32.const 5))
|
||||||
|
|
||||||
|
(export "Mt.call" (func $f))
|
||||||
|
(func (export "call Mt.call") (param i32) (result i32)
|
||||||
|
(call $f (get_local 0))
|
||||||
|
)
|
||||||
|
(func (export "call") (param i32) (result i32)
|
||||||
|
(call_indirect (type 1) (get_local 0))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke $Mt "call" (i32.const 2)) (i32.const 4))
|
||||||
|
(assert_return (invoke $Nt "Mt.call" (i32.const 2)) (i32.const 4))
|
||||||
|
(assert_return (invoke $Nt "call" (i32.const 2)) (i32.const 5))
|
||||||
|
(assert_return (invoke $Nt "call Mt.call" (i32.const 2)) (i32.const 4))
|
||||||
|
|
||||||
|
(assert_trap (invoke $Mt "call" (i32.const 1)) "uninitialized")
|
||||||
|
(assert_trap (invoke $Nt "Mt.call" (i32.const 1)) "uninitialized")
|
||||||
|
(assert_return (invoke $Nt "call" (i32.const 1)) (i32.const 5))
|
||||||
|
(assert_trap (invoke $Nt "call Mt.call" (i32.const 1)) "uninitialized")
|
||||||
|
|
||||||
|
(assert_trap (invoke $Mt "call" (i32.const 0)) "uninitialized")
|
||||||
|
(assert_trap (invoke $Nt "Mt.call" (i32.const 0)) "uninitialized")
|
||||||
|
(assert_return (invoke $Nt "call" (i32.const 0)) (i32.const 5))
|
||||||
|
(assert_trap (invoke $Nt "call Mt.call" (i32.const 0)) "uninitialized")
|
||||||
|
|
||||||
|
(assert_trap (invoke $Mt "call" (i32.const 20)) "undefined")
|
||||||
|
(assert_trap (invoke $Nt "Mt.call" (i32.const 20)) "undefined")
|
||||||
|
(assert_trap (invoke $Nt "call" (i32.const 7)) "undefined")
|
||||||
|
(assert_trap (invoke $Nt "call Mt.call" (i32.const 20)) "undefined")
|
||||||
|
|
||||||
|
(assert_return (invoke $Nt "call" (i32.const 3)) (i32.const -4))
|
||||||
|
(assert_trap (invoke $Nt "call" (i32.const 4)) "indirect call")
|
||||||
|
|
||||||
|
(module $Ot
|
||||||
|
(type (func (result i32)))
|
||||||
|
|
||||||
|
(func $h (import "Mt" "h") (result i32))
|
||||||
|
(table (import "Mt" "tab") 5 anyfunc)
|
||||||
|
(elem (i32.const 1) $i $h)
|
||||||
|
(func $i (result i32) (i32.const 6))
|
||||||
|
|
||||||
|
(func (export "call") (param i32) (result i32)
|
||||||
|
(call_indirect (type 0) (get_local 0))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke $Mt "call" (i32.const 3)) (i32.const 4))
|
||||||
|
(assert_return (invoke $Nt "Mt.call" (i32.const 3)) (i32.const 4))
|
||||||
|
(assert_return (invoke $Nt "call Mt.call" (i32.const 3)) (i32.const 4))
|
||||||
|
(assert_return (invoke $Ot "call" (i32.const 3)) (i32.const 4))
|
||||||
|
|
||||||
|
(assert_return (invoke $Mt "call" (i32.const 2)) (i32.const -4))
|
||||||
|
(assert_return (invoke $Nt "Mt.call" (i32.const 2)) (i32.const -4))
|
||||||
|
(assert_return (invoke $Nt "call" (i32.const 2)) (i32.const 5))
|
||||||
|
(assert_return (invoke $Nt "call Mt.call" (i32.const 2)) (i32.const -4))
|
||||||
|
(assert_return (invoke $Ot "call" (i32.const 2)) (i32.const -4))
|
||||||
|
|
||||||
|
(assert_return (invoke $Mt "call" (i32.const 1)) (i32.const 6))
|
||||||
|
(assert_return (invoke $Nt "Mt.call" (i32.const 1)) (i32.const 6))
|
||||||
|
(assert_return (invoke $Nt "call" (i32.const 1)) (i32.const 5))
|
||||||
|
(assert_return (invoke $Nt "call Mt.call" (i32.const 1)) (i32.const 6))
|
||||||
|
(assert_return (invoke $Ot "call" (i32.const 1)) (i32.const 6))
|
||||||
|
|
||||||
|
(assert_trap (invoke $Mt "call" (i32.const 0)) "uninitialized")
|
||||||
|
(assert_trap (invoke $Nt "Mt.call" (i32.const 0)) "uninitialized")
|
||||||
|
(assert_return (invoke $Nt "call" (i32.const 0)) (i32.const 5))
|
||||||
|
(assert_trap (invoke $Nt "call Mt.call" (i32.const 0)) "uninitialized")
|
||||||
|
(assert_trap (invoke $Ot "call" (i32.const 0)) "uninitialized")
|
||||||
|
|
||||||
|
(assert_trap (invoke $Ot "call" (i32.const 20)) "undefined")
|
||||||
|
|
||||||
|
(module
|
||||||
|
(table (import "Mt" "tab") 0 anyfunc)
|
||||||
|
(elem (i32.const 9) $f)
|
||||||
|
(func $f)
|
||||||
|
)
|
||||||
|
|
||||||
|
(module $G1 (global (export "g") i32 (i32.const 5)))
|
||||||
|
(register "G1" $G1)
|
||||||
|
(module $G2
|
||||||
|
(global (import "G1" "g") i32)
|
||||||
|
(global (export "g") i32 (get_global 0))
|
||||||
|
)
|
||||||
|
(assert_return (get $G2 "g") (i32.const 5))
|
||||||
|
|
||||||
|
(assert_unlinkable
|
||||||
|
(module
|
||||||
|
(table (import "Mt" "tab") 0 anyfunc)
|
||||||
|
(elem (i32.const 10) $f)
|
||||||
|
(func $f)
|
||||||
|
)
|
||||||
|
"elements segment does not fit"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_unlinkable
|
||||||
|
(module
|
||||||
|
(table (import "Mt" "tab") 10 anyfunc)
|
||||||
|
(memory (import "Mt" "mem") 1) ;; does not exist
|
||||||
|
(func $f (result i32) (i32.const 0))
|
||||||
|
(elem (i32.const 7) $f)
|
||||||
|
(elem (i32.const 9) $f)
|
||||||
|
)
|
||||||
|
"unknown import"
|
||||||
|
)
|
||||||
|
(assert_trap (invoke $Mt "call" (i32.const 7)) "uninitialized")
|
||||||
|
|
||||||
|
(assert_unlinkable
|
||||||
|
(module
|
||||||
|
(table (import "Mt" "tab") 10 anyfunc)
|
||||||
|
(func $f (result i32) (i32.const 0))
|
||||||
|
(elem (i32.const 7) $f)
|
||||||
|
(elem (i32.const 12) $f) ;; out of bounds
|
||||||
|
)
|
||||||
|
"elements segment does not fit"
|
||||||
|
)
|
||||||
|
(assert_trap (invoke $Mt "call" (i32.const 7)) "uninitialized")
|
||||||
|
|
||||||
|
(assert_unlinkable
|
||||||
|
(module
|
||||||
|
(table (import "Mt" "tab") 10 anyfunc)
|
||||||
|
(func $f (result i32) (i32.const 0))
|
||||||
|
(elem (i32.const 7) $f)
|
||||||
|
(memory 1)
|
||||||
|
(data (i32.const 0x10000) "d") ;; out of bounds
|
||||||
|
)
|
||||||
|
"data segment does not fit"
|
||||||
|
)
|
||||||
|
(assert_trap (invoke $Mt "call" (i32.const 7)) "uninitialized")
|
||||||
|
|
||||||
|
|
||||||
|
;; Memories
|
||||||
|
|
||||||
|
(module $Mm
|
||||||
|
(memory (export "mem") 1 5)
|
||||||
|
(data (i32.const 10) "\00\01\02\03\04\05\06\07\08\09")
|
||||||
|
|
||||||
|
(func (export "load") (param $a i32) (result i32)
|
||||||
|
(i32.load8_u (get_local 0))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(register "Mm" $Mm)
|
||||||
|
|
||||||
|
(module $Nm
|
||||||
|
(func $loadM (import "Mm" "load") (param i32) (result i32))
|
||||||
|
|
||||||
|
(memory 1)
|
||||||
|
(data (i32.const 10) "\f0\f1\f2\f3\f4\f5")
|
||||||
|
|
||||||
|
(export "Mm.load" (func $loadM))
|
||||||
|
(func (export "load") (param $a i32) (result i32)
|
||||||
|
(i32.load8_u (get_local 0))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke $Mm "load" (i32.const 12)) (i32.const 2))
|
||||||
|
(assert_return (invoke $Nm "Mm.load" (i32.const 12)) (i32.const 2))
|
||||||
|
(assert_return (invoke $Nm "load" (i32.const 12)) (i32.const 0xf2))
|
||||||
|
|
||||||
|
(module $Om
|
||||||
|
(memory (import "Mm" "mem") 1)
|
||||||
|
(data (i32.const 5) "\a0\a1\a2\a3\a4\a5\a6\a7")
|
||||||
|
|
||||||
|
(func (export "load") (param $a i32) (result i32)
|
||||||
|
(i32.load8_u (get_local 0))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke $Mm "load" (i32.const 12)) (i32.const 0xa7))
|
||||||
|
(assert_return (invoke $Nm "Mm.load" (i32.const 12)) (i32.const 0xa7))
|
||||||
|
(assert_return (invoke $Nm "load" (i32.const 12)) (i32.const 0xf2))
|
||||||
|
(assert_return (invoke $Om "load" (i32.const 12)) (i32.const 0xa7))
|
||||||
|
|
||||||
|
(module
|
||||||
|
(memory (import "Mm" "mem") 0)
|
||||||
|
(data (i32.const 0xffff) "a")
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_unlinkable
|
||||||
|
(module
|
||||||
|
(memory (import "Mm" "mem") 0)
|
||||||
|
(data (i32.const 0x10000) "a")
|
||||||
|
)
|
||||||
|
"data segment does not fit"
|
||||||
|
)
|
||||||
|
|
||||||
|
(module $Pm
|
||||||
|
(memory (import "Mm" "mem") 1 8)
|
||||||
|
|
||||||
|
(func (export "grow") (param $a i32) (result i32)
|
||||||
|
(memory.grow (get_local 0))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke $Pm "grow" (i32.const 0)) (i32.const 1))
|
||||||
|
(assert_return (invoke $Pm "grow" (i32.const 2)) (i32.const 1))
|
||||||
|
(assert_return (invoke $Pm "grow" (i32.const 0)) (i32.const 3))
|
||||||
|
(assert_return (invoke $Pm "grow" (i32.const 1)) (i32.const 3))
|
||||||
|
(assert_return (invoke $Pm "grow" (i32.const 1)) (i32.const 4))
|
||||||
|
(assert_return (invoke $Pm "grow" (i32.const 0)) (i32.const 5))
|
||||||
|
(assert_return (invoke $Pm "grow" (i32.const 1)) (i32.const -1))
|
||||||
|
(assert_return (invoke $Pm "grow" (i32.const 0)) (i32.const 5))
|
||||||
|
|
||||||
|
(assert_unlinkable
|
||||||
|
(module
|
||||||
|
(func $host (import "spectest" "print"))
|
||||||
|
(memory (import "Mm" "mem") 1)
|
||||||
|
(table (import "Mm" "tab") 0 anyfunc) ;; does not exist
|
||||||
|
(data (i32.const 0) "abc")
|
||||||
|
)
|
||||||
|
"unknown import"
|
||||||
|
)
|
||||||
|
(assert_return (invoke $Mm "load" (i32.const 0)) (i32.const 0))
|
||||||
|
|
||||||
|
(assert_unlinkable
|
||||||
|
(module
|
||||||
|
(memory (import "Mm" "mem") 1)
|
||||||
|
(data (i32.const 0) "abc")
|
||||||
|
(data (i32.const 0x50000) "d") ;; out of bounds
|
||||||
|
)
|
||||||
|
"data segment does not fit"
|
||||||
|
)
|
||||||
|
(assert_return (invoke $Mm "load" (i32.const 0)) (i32.const 0))
|
||||||
|
|
||||||
|
(assert_unlinkable
|
||||||
|
(module
|
||||||
|
(memory (import "Mm" "mem") 1)
|
||||||
|
(data (i32.const 0) "abc")
|
||||||
|
(table 0 anyfunc)
|
||||||
|
(func)
|
||||||
|
(elem (i32.const 0) 0) ;; out of bounds
|
||||||
|
)
|
||||||
|
"elements segment does not fit"
|
||||||
|
)
|
||||||
|
(assert_return (invoke $Mm "load" (i32.const 0)) (i32.const 0))
|
||||||
@@ -0,0 +1,309 @@
|
|||||||
|
;; Test `loop` opcode
|
||||||
|
|
||||||
|
(module
|
||||||
|
(func $dummy)
|
||||||
|
|
||||||
|
(func (export "empty")
|
||||||
|
(loop)
|
||||||
|
(loop $l)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "singular") (result i32)
|
||||||
|
(loop (nop))
|
||||||
|
(loop (result i32) (i32.const 7))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "multi") (result i32)
|
||||||
|
(loop (call $dummy) (call $dummy) (call $dummy) (call $dummy))
|
||||||
|
(loop (result i32) (call $dummy) (call $dummy) (call $dummy) (i32.const 8))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "nested") (result i32)
|
||||||
|
(loop (result i32)
|
||||||
|
(loop (call $dummy) (block) (nop))
|
||||||
|
(loop (result i32) (call $dummy) (i32.const 9))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "deep") (result i32)
|
||||||
|
(loop (result i32) (block (result i32)
|
||||||
|
(loop (result i32) (block (result i32)
|
||||||
|
(loop (result i32) (block (result i32)
|
||||||
|
(loop (result i32) (block (result i32)
|
||||||
|
(loop (result i32) (block (result i32)
|
||||||
|
(loop (result i32) (block (result i32)
|
||||||
|
(loop (result i32) (block (result i32)
|
||||||
|
(loop (result i32) (block (result i32)
|
||||||
|
(loop (result i32) (block (result i32)
|
||||||
|
(loop (result i32) (block (result i32)
|
||||||
|
(loop (result i32) (block (result i32)
|
||||||
|
(loop (result i32) (block (result i32)
|
||||||
|
(loop (result i32) (block (result i32)
|
||||||
|
(loop (result i32) (block (result i32)
|
||||||
|
(loop (result i32) (block (result i32)
|
||||||
|
(loop (result i32) (block (result i32)
|
||||||
|
(loop (result i32) (block (result i32)
|
||||||
|
(loop (result i32) (block (result i32)
|
||||||
|
(loop (result i32) (block (result i32)
|
||||||
|
(loop (result i32) (block (result i32)
|
||||||
|
(call $dummy) (i32.const 150)
|
||||||
|
))
|
||||||
|
))
|
||||||
|
))
|
||||||
|
))
|
||||||
|
))
|
||||||
|
))
|
||||||
|
))
|
||||||
|
))
|
||||||
|
))
|
||||||
|
))
|
||||||
|
))
|
||||||
|
))
|
||||||
|
))
|
||||||
|
))
|
||||||
|
))
|
||||||
|
))
|
||||||
|
))
|
||||||
|
))
|
||||||
|
))
|
||||||
|
))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "as-unary-operand") (result i32)
|
||||||
|
(i32.ctz (loop (result i32) (call $dummy) (i32.const 13)))
|
||||||
|
)
|
||||||
|
(func (export "as-binary-operand") (result i32)
|
||||||
|
(i32.mul
|
||||||
|
(loop (result i32) (call $dummy) (i32.const 3))
|
||||||
|
(loop (result i32) (call $dummy) (i32.const 4))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(func (export "as-test-operand") (result i32)
|
||||||
|
(i32.eqz (loop (result i32) (call $dummy) (i32.const 13)))
|
||||||
|
)
|
||||||
|
(func (export "as-compare-operand") (result i32)
|
||||||
|
(f32.gt
|
||||||
|
(loop (result f32) (call $dummy) (f32.const 3))
|
||||||
|
(loop (result f32) (call $dummy) (f32.const 3))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "break-bare") (result i32)
|
||||||
|
(block (loop (br 1) (br 0) (unreachable)))
|
||||||
|
(block (loop (br_if 1 (i32.const 1)) (unreachable)))
|
||||||
|
(block (loop (br_table 1 (i32.const 0)) (unreachable)))
|
||||||
|
(block (loop (br_table 1 1 1 (i32.const 1)) (unreachable)))
|
||||||
|
(i32.const 19)
|
||||||
|
)
|
||||||
|
(func (export "break-value") (result i32)
|
||||||
|
(block (result i32)
|
||||||
|
(loop (result i32) (br 1 (i32.const 18)) (br 0) (i32.const 19))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(func (export "break-repeated") (result i32)
|
||||||
|
(block (result i32)
|
||||||
|
(loop (result i32)
|
||||||
|
(br 1 (i32.const 18))
|
||||||
|
(br 1 (i32.const 19))
|
||||||
|
(drop (br_if 1 (i32.const 20) (i32.const 0)))
|
||||||
|
(drop (br_if 1 (i32.const 20) (i32.const 1)))
|
||||||
|
(br 1 (i32.const 21))
|
||||||
|
(br_table 1 (i32.const 22) (i32.const 0))
|
||||||
|
(br_table 1 1 1 (i32.const 23) (i32.const 1))
|
||||||
|
(i32.const 21)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(func (export "break-inner") (result i32)
|
||||||
|
(local i32)
|
||||||
|
(set_local 0 (i32.const 0))
|
||||||
|
(set_local 0 (i32.add (get_local 0) (block (result i32) (loop (result i32) (block (result i32) (br 2 (i32.const 0x1)))))))
|
||||||
|
(set_local 0 (i32.add (get_local 0) (block (result i32) (loop (result i32) (loop (result i32) (br 2 (i32.const 0x2)))))))
|
||||||
|
(set_local 0 (i32.add (get_local 0) (block (result i32) (loop (result i32) (block (result i32) (loop (result i32) (br 1 (i32.const 0x4))))))))
|
||||||
|
(set_local 0 (i32.add (get_local 0) (block (result i32) (loop (result i32) (i32.ctz (br 1 (i32.const 0x8)))))))
|
||||||
|
(set_local 0 (i32.add (get_local 0) (block (result i32) (loop (result i32) (i32.ctz (loop (result i32) (br 2 (i32.const 0x10))))))))
|
||||||
|
(get_local 0)
|
||||||
|
)
|
||||||
|
(func (export "cont-inner") (result i32)
|
||||||
|
(local i32)
|
||||||
|
(set_local 0 (i32.const 0))
|
||||||
|
(set_local 0 (i32.add (get_local 0) (loop (result i32) (loop (result i32) (br 1)))))
|
||||||
|
(set_local 0 (i32.add (get_local 0) (loop (result i32) (i32.ctz (br 0)))))
|
||||||
|
(set_local 0 (i32.add (get_local 0) (loop (result i32) (i32.ctz (loop (result i32) (br 1))))))
|
||||||
|
(get_local 0)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func $fx (export "effects") (result i32)
|
||||||
|
(local i32)
|
||||||
|
(block
|
||||||
|
(loop
|
||||||
|
(set_local 0 (i32.const 1))
|
||||||
|
(set_local 0 (i32.mul (get_local 0) (i32.const 3)))
|
||||||
|
(set_local 0 (i32.sub (get_local 0) (i32.const 5)))
|
||||||
|
(set_local 0 (i32.mul (get_local 0) (i32.const 7)))
|
||||||
|
(br 1)
|
||||||
|
(set_local 0 (i32.mul (get_local 0) (i32.const 100)))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(i32.eq (get_local 0) (i32.const -14))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "while") (param i64) (result i64)
|
||||||
|
(local i64)
|
||||||
|
(set_local 1 (i64.const 1))
|
||||||
|
(block
|
||||||
|
(loop
|
||||||
|
(br_if 1 (i64.eqz (get_local 0)))
|
||||||
|
(set_local 1 (i64.mul (get_local 0) (get_local 1)))
|
||||||
|
(set_local 0 (i64.sub (get_local 0) (i64.const 1)))
|
||||||
|
(br 0)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(get_local 1)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "for") (param i64) (result i64)
|
||||||
|
(local i64 i64)
|
||||||
|
(set_local 1 (i64.const 1))
|
||||||
|
(set_local 2 (i64.const 2))
|
||||||
|
(block
|
||||||
|
(loop
|
||||||
|
(br_if 1 (i64.gt_u (get_local 2) (get_local 0)))
|
||||||
|
(set_local 1 (i64.mul (get_local 1) (get_local 2)))
|
||||||
|
(set_local 2 (i64.add (get_local 2) (i64.const 1)))
|
||||||
|
(br 0)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(get_local 1)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "nesting") (param f32 f32) (result f32)
|
||||||
|
(local f32 f32)
|
||||||
|
(block
|
||||||
|
(loop
|
||||||
|
(br_if 1 (f32.eq (get_local 0) (f32.const 0)))
|
||||||
|
(set_local 2 (get_local 1))
|
||||||
|
(block
|
||||||
|
(loop
|
||||||
|
(br_if 1 (f32.eq (get_local 2) (f32.const 0)))
|
||||||
|
(br_if 3 (f32.lt (get_local 2) (f32.const 0)))
|
||||||
|
(set_local 3 (f32.add (get_local 3) (get_local 2)))
|
||||||
|
(set_local 2 (f32.sub (get_local 2) (f32.const 2)))
|
||||||
|
(br 0)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(set_local 3 (f32.div (get_local 3) (get_local 0)))
|
||||||
|
(set_local 0 (f32.sub (get_local 0) (f32.const 1)))
|
||||||
|
(br 0)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(get_local 3)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke "empty"))
|
||||||
|
(assert_return (invoke "singular") (i32.const 7))
|
||||||
|
(assert_return (invoke "multi") (i32.const 8))
|
||||||
|
(assert_return (invoke "nested") (i32.const 9))
|
||||||
|
(assert_return (invoke "deep") (i32.const 150))
|
||||||
|
|
||||||
|
(assert_return (invoke "as-unary-operand") (i32.const 0))
|
||||||
|
(assert_return (invoke "as-binary-operand") (i32.const 12))
|
||||||
|
(assert_return (invoke "as-test-operand") (i32.const 0))
|
||||||
|
(assert_return (invoke "as-compare-operand") (i32.const 0))
|
||||||
|
|
||||||
|
(assert_return (invoke "break-bare") (i32.const 19))
|
||||||
|
(assert_return (invoke "break-value") (i32.const 18))
|
||||||
|
(assert_return (invoke "break-repeated") (i32.const 18))
|
||||||
|
(assert_return (invoke "break-inner") (i32.const 0x1f))
|
||||||
|
|
||||||
|
(assert_return (invoke "effects") (i32.const 1))
|
||||||
|
|
||||||
|
(assert_return (invoke "while" (i64.const 0)) (i64.const 1))
|
||||||
|
(assert_return (invoke "while" (i64.const 1)) (i64.const 1))
|
||||||
|
(assert_return (invoke "while" (i64.const 2)) (i64.const 2))
|
||||||
|
(assert_return (invoke "while" (i64.const 3)) (i64.const 6))
|
||||||
|
(assert_return (invoke "while" (i64.const 5)) (i64.const 120))
|
||||||
|
(assert_return (invoke "while" (i64.const 20)) (i64.const 2432902008176640000))
|
||||||
|
|
||||||
|
(assert_return (invoke "for" (i64.const 0)) (i64.const 1))
|
||||||
|
(assert_return (invoke "for" (i64.const 1)) (i64.const 1))
|
||||||
|
(assert_return (invoke "for" (i64.const 2)) (i64.const 2))
|
||||||
|
(assert_return (invoke "for" (i64.const 3)) (i64.const 6))
|
||||||
|
(assert_return (invoke "for" (i64.const 5)) (i64.const 120))
|
||||||
|
(assert_return (invoke "for" (i64.const 20)) (i64.const 2432902008176640000))
|
||||||
|
|
||||||
|
(assert_return (invoke "nesting" (f32.const 0) (f32.const 7)) (f32.const 0))
|
||||||
|
(assert_return (invoke "nesting" (f32.const 7) (f32.const 0)) (f32.const 0))
|
||||||
|
(assert_return (invoke "nesting" (f32.const 1) (f32.const 1)) (f32.const 1))
|
||||||
|
(assert_return (invoke "nesting" (f32.const 1) (f32.const 2)) (f32.const 2))
|
||||||
|
(assert_return (invoke "nesting" (f32.const 1) (f32.const 3)) (f32.const 4))
|
||||||
|
(assert_return (invoke "nesting" (f32.const 1) (f32.const 4)) (f32.const 6))
|
||||||
|
(assert_return (invoke "nesting" (f32.const 1) (f32.const 100)) (f32.const 2550))
|
||||||
|
(assert_return (invoke "nesting" (f32.const 1) (f32.const 101)) (f32.const 2601))
|
||||||
|
(assert_return (invoke "nesting" (f32.const 2) (f32.const 1)) (f32.const 1))
|
||||||
|
(assert_return (invoke "nesting" (f32.const 3) (f32.const 1)) (f32.const 1))
|
||||||
|
(assert_return (invoke "nesting" (f32.const 10) (f32.const 1)) (f32.const 1))
|
||||||
|
(assert_return (invoke "nesting" (f32.const 2) (f32.const 2)) (f32.const 3))
|
||||||
|
(assert_return (invoke "nesting" (f32.const 2) (f32.const 3)) (f32.const 4))
|
||||||
|
(assert_return (invoke "nesting" (f32.const 7) (f32.const 4)) (f32.const 10.3095235825))
|
||||||
|
(assert_return (invoke "nesting" (f32.const 7) (f32.const 100)) (f32.const 4381.54785156))
|
||||||
|
(assert_return (invoke "nesting" (f32.const 7) (f32.const 101)) (f32.const 2601))
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-empty-i32 (result i32) (loop)))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-empty-i64 (result i64) (loop)))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-empty-f32 (result f32) (loop)))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-empty-f64 (result f64) (loop)))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-value-num-vs-void
|
||||||
|
(loop (i32.const 1))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-value-empty-vs-num (result i32)
|
||||||
|
(loop (result i32))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-value-void-vs-num (result i32)
|
||||||
|
(loop (result i32) (nop))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-value-num-vs-num (result i32)
|
||||||
|
(loop (result i32) (f32.const 0))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-value-unreached-select (result i32)
|
||||||
|
(loop (result i64) (select (unreachable) (unreachable) (unreachable)))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(func loop end $l)")
|
||||||
|
"mismatching label"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(func loop $a end $l)")
|
||||||
|
"mismatching label"
|
||||||
|
)
|
||||||
@@ -0,0 +1,449 @@
|
|||||||
|
;; Test memory section structure
|
||||||
|
|
||||||
|
(module (memory 0 0))
|
||||||
|
(module (memory 0 1))
|
||||||
|
(module (memory 1 256))
|
||||||
|
(module (memory 0 65536))
|
||||||
|
|
||||||
|
(assert_invalid (module (memory 0) (memory 0)) "multiple memories")
|
||||||
|
(assert_invalid (module (memory (import "spectest" "memory") 0) (memory 0)) "multiple memories")
|
||||||
|
|
||||||
|
(module (memory (data)) (func (export "memsize") (result i32) (memory.size)))
|
||||||
|
(assert_return (invoke "memsize") (i32.const 0))
|
||||||
|
(module (memory (data "")) (func (export "memsize") (result i32) (memory.size)))
|
||||||
|
(assert_return (invoke "memsize") (i32.const 0))
|
||||||
|
(module (memory (data "x")) (func (export "memsize") (result i32) (memory.size)))
|
||||||
|
(assert_return (invoke "memsize") (i32.const 1))
|
||||||
|
|
||||||
|
(assert_invalid (module (data (i32.const 0))) "unknown memory")
|
||||||
|
(assert_invalid (module (data (i32.const 0) "")) "unknown memory")
|
||||||
|
(assert_invalid (module (data (i32.const 0) "x")) "unknown memory")
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func (drop (f32.load (i32.const 0)))))
|
||||||
|
"unknown memory"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func (f32.store (f32.const 0) (i32.const 0))))
|
||||||
|
"unknown memory"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func (drop (i32.load8_s (i32.const 0)))))
|
||||||
|
"unknown memory"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func (i32.store8 (i32.const 0) (i32.const 0))))
|
||||||
|
"unknown memory"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func (drop (memory.size))))
|
||||||
|
"unknown memory"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func (drop (memory.grow (i32.const 0)))))
|
||||||
|
"unknown memory"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (memory 1 0))
|
||||||
|
"size minimum must not be greater than maximum"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (memory 65537))
|
||||||
|
"memory size must be at most 65536 pages (4GiB)"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (memory 2147483648))
|
||||||
|
"memory size must be at most 65536 pages (4GiB)"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (memory 4294967295))
|
||||||
|
"memory size must be at most 65536 pages (4GiB)"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (memory 0 65537))
|
||||||
|
"memory size must be at most 65536 pages (4GiB)"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (memory 0 2147483648))
|
||||||
|
"memory size must be at most 65536 pages (4GiB)"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (memory 0 4294967295))
|
||||||
|
"memory size must be at most 65536 pages (4GiB)"
|
||||||
|
)
|
||||||
|
|
||||||
|
;; Test alignment annotation rules
|
||||||
|
(module (memory 0) (func (drop (i32.load8_u align=1 (i32.const 0)))))
|
||||||
|
(module (memory 0) (func (drop (i32.load16_u align=2 (i32.const 0)))))
|
||||||
|
(module (memory 0) (func (drop (i32.load align=4 (i32.const 0)))))
|
||||||
|
(module (memory 0) (func (drop (f32.load align=4 (i32.const 0)))))
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (memory 0) (func (drop (i64.load align=16 (i32.const 0)))))
|
||||||
|
"alignment must not be larger than natural"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (memory 0) (func (drop (i64.load align=32 (i32.const 0)))))
|
||||||
|
"alignment must not be larger than natural"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (memory 0) (func (drop (i32.load align=8 (i32.const 0)))))
|
||||||
|
"alignment must not be larger than natural"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (memory 0) (func (drop (i32.load16_u align=4 (i32.const 0)))))
|
||||||
|
"alignment must not be larger than natural"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (memory 0) (func (drop (i32.load8_u align=2 (i32.const 0)))))
|
||||||
|
"alignment must not be larger than natural"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (memory 0) (func (i32.store8 align=2 (i32.const 0) (i32.const 0))))
|
||||||
|
"alignment must not be larger than natural"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (memory 0) (func (i32.load16_u align=4 (i32.const 0))))
|
||||||
|
"alignment must not be larger than natural"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (memory 0) (func (i32.load8_u align=2 (i32.const 0))))
|
||||||
|
"alignment must not be larger than natural"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (memory 0) (func (i32.store8 align=2 (i32.const 0) (i32.const 0))))
|
||||||
|
"alignment must not be larger than natural"
|
||||||
|
)
|
||||||
|
|
||||||
|
(module
|
||||||
|
(memory 1)
|
||||||
|
(data (i32.const 0) "ABC\a7D") (data (i32.const 20) "WASM")
|
||||||
|
|
||||||
|
;; Data section
|
||||||
|
(func (export "data") (result i32)
|
||||||
|
(i32.and
|
||||||
|
(i32.and
|
||||||
|
(i32.and
|
||||||
|
(i32.eq (i32.load8_u (i32.const 0)) (i32.const 65))
|
||||||
|
(i32.eq (i32.load8_u (i32.const 3)) (i32.const 167))
|
||||||
|
)
|
||||||
|
(i32.and
|
||||||
|
(i32.eq (i32.load8_u (i32.const 6)) (i32.const 0))
|
||||||
|
(i32.eq (i32.load8_u (i32.const 19)) (i32.const 0))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(i32.and
|
||||||
|
(i32.and
|
||||||
|
(i32.eq (i32.load8_u (i32.const 20)) (i32.const 87))
|
||||||
|
(i32.eq (i32.load8_u (i32.const 23)) (i32.const 77))
|
||||||
|
)
|
||||||
|
(i32.and
|
||||||
|
(i32.eq (i32.load8_u (i32.const 24)) (i32.const 0))
|
||||||
|
(i32.eq (i32.load8_u (i32.const 1023)) (i32.const 0))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
;; Aligned read/write
|
||||||
|
(func (export "aligned") (result i32)
|
||||||
|
(local i32 i32 i32)
|
||||||
|
(set_local 0 (i32.const 10))
|
||||||
|
(block
|
||||||
|
(loop
|
||||||
|
(if
|
||||||
|
(i32.eq (get_local 0) (i32.const 0))
|
||||||
|
(then (br 2))
|
||||||
|
)
|
||||||
|
(set_local 2 (i32.mul (get_local 0) (i32.const 4)))
|
||||||
|
(i32.store (get_local 2) (get_local 0))
|
||||||
|
(set_local 1 (i32.load (get_local 2)))
|
||||||
|
(if
|
||||||
|
(i32.ne (get_local 0) (get_local 1))
|
||||||
|
(then (return (i32.const 0)))
|
||||||
|
)
|
||||||
|
(set_local 0 (i32.sub (get_local 0) (i32.const 1)))
|
||||||
|
(br 0)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(i32.const 1)
|
||||||
|
)
|
||||||
|
|
||||||
|
;; Unaligned read/write
|
||||||
|
(func (export "unaligned") (result i32)
|
||||||
|
(local i32 f64 f64)
|
||||||
|
(set_local 0 (i32.const 10))
|
||||||
|
(block
|
||||||
|
(loop
|
||||||
|
(if
|
||||||
|
(i32.eq (get_local 0) (i32.const 0))
|
||||||
|
(then (br 2))
|
||||||
|
)
|
||||||
|
(set_local 2 (f64.convert_s/i32 (get_local 0)))
|
||||||
|
(f64.store align=1 (get_local 0) (get_local 2))
|
||||||
|
(set_local 1 (f64.load align=1 (get_local 0)))
|
||||||
|
(if
|
||||||
|
(f64.ne (get_local 2) (get_local 1))
|
||||||
|
(then (return (i32.const 0)))
|
||||||
|
)
|
||||||
|
(set_local 0 (i32.sub (get_local 0) (i32.const 1)))
|
||||||
|
(br 0)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(i32.const 1)
|
||||||
|
)
|
||||||
|
|
||||||
|
;; Memory cast
|
||||||
|
(func (export "cast") (result f64)
|
||||||
|
(i64.store (i32.const 8) (i64.const -12345))
|
||||||
|
(if
|
||||||
|
(f64.eq
|
||||||
|
(f64.load (i32.const 8))
|
||||||
|
(f64.reinterpret/i64 (i64.const -12345))
|
||||||
|
)
|
||||||
|
(then (return (f64.const 0)))
|
||||||
|
)
|
||||||
|
(i64.store align=1 (i32.const 9) (i64.const 0))
|
||||||
|
(i32.store16 align=1 (i32.const 15) (i32.const 16453))
|
||||||
|
(f64.load align=1 (i32.const 9))
|
||||||
|
)
|
||||||
|
|
||||||
|
;; Sign and zero extending memory loads
|
||||||
|
(func (export "i32_load8_s") (param $i i32) (result i32)
|
||||||
|
(i32.store8 (i32.const 8) (get_local $i))
|
||||||
|
(i32.load8_s (i32.const 8))
|
||||||
|
)
|
||||||
|
(func (export "i32_load8_u") (param $i i32) (result i32)
|
||||||
|
(i32.store8 (i32.const 8) (get_local $i))
|
||||||
|
(i32.load8_u (i32.const 8))
|
||||||
|
)
|
||||||
|
(func (export "i32_load16_s") (param $i i32) (result i32)
|
||||||
|
(i32.store16 (i32.const 8) (get_local $i))
|
||||||
|
(i32.load16_s (i32.const 8))
|
||||||
|
)
|
||||||
|
(func (export "i32_load16_u") (param $i i32) (result i32)
|
||||||
|
(i32.store16 (i32.const 8) (get_local $i))
|
||||||
|
(i32.load16_u (i32.const 8))
|
||||||
|
)
|
||||||
|
(func (export "i64_load8_s") (param $i i64) (result i64)
|
||||||
|
(i64.store8 (i32.const 8) (get_local $i))
|
||||||
|
(i64.load8_s (i32.const 8))
|
||||||
|
)
|
||||||
|
(func (export "i64_load8_u") (param $i i64) (result i64)
|
||||||
|
(i64.store8 (i32.const 8) (get_local $i))
|
||||||
|
(i64.load8_u (i32.const 8))
|
||||||
|
)
|
||||||
|
(func (export "i64_load16_s") (param $i i64) (result i64)
|
||||||
|
(i64.store16 (i32.const 8) (get_local $i))
|
||||||
|
(i64.load16_s (i32.const 8))
|
||||||
|
)
|
||||||
|
(func (export "i64_load16_u") (param $i i64) (result i64)
|
||||||
|
(i64.store16 (i32.const 8) (get_local $i))
|
||||||
|
(i64.load16_u (i32.const 8))
|
||||||
|
)
|
||||||
|
(func (export "i64_load32_s") (param $i i64) (result i64)
|
||||||
|
(i64.store32 (i32.const 8) (get_local $i))
|
||||||
|
(i64.load32_s (i32.const 8))
|
||||||
|
)
|
||||||
|
(func (export "i64_load32_u") (param $i i64) (result i64)
|
||||||
|
(i64.store32 (i32.const 8) (get_local $i))
|
||||||
|
(i64.load32_u (i32.const 8))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke "data") (i32.const 1))
|
||||||
|
(assert_return (invoke "aligned") (i32.const 1))
|
||||||
|
(assert_return (invoke "unaligned") (i32.const 1))
|
||||||
|
(assert_return (invoke "cast") (f64.const 42.0))
|
||||||
|
|
||||||
|
(assert_return (invoke "i32_load8_s" (i32.const -1)) (i32.const -1))
|
||||||
|
(assert_return (invoke "i32_load8_u" (i32.const -1)) (i32.const 255))
|
||||||
|
(assert_return (invoke "i32_load16_s" (i32.const -1)) (i32.const -1))
|
||||||
|
(assert_return (invoke "i32_load16_u" (i32.const -1)) (i32.const 65535))
|
||||||
|
|
||||||
|
(assert_return (invoke "i32_load8_s" (i32.const 100)) (i32.const 100))
|
||||||
|
(assert_return (invoke "i32_load8_u" (i32.const 200)) (i32.const 200))
|
||||||
|
(assert_return (invoke "i32_load16_s" (i32.const 20000)) (i32.const 20000))
|
||||||
|
(assert_return (invoke "i32_load16_u" (i32.const 40000)) (i32.const 40000))
|
||||||
|
|
||||||
|
(assert_return (invoke "i32_load8_s" (i32.const 0xfedc6543)) (i32.const 0x43))
|
||||||
|
(assert_return (invoke "i32_load8_s" (i32.const 0x3456cdef)) (i32.const 0xffffffef))
|
||||||
|
(assert_return (invoke "i32_load8_u" (i32.const 0xfedc6543)) (i32.const 0x43))
|
||||||
|
(assert_return (invoke "i32_load8_u" (i32.const 0x3456cdef)) (i32.const 0xef))
|
||||||
|
(assert_return (invoke "i32_load16_s" (i32.const 0xfedc6543)) (i32.const 0x6543))
|
||||||
|
(assert_return (invoke "i32_load16_s" (i32.const 0x3456cdef)) (i32.const 0xffffcdef))
|
||||||
|
(assert_return (invoke "i32_load16_u" (i32.const 0xfedc6543)) (i32.const 0x6543))
|
||||||
|
(assert_return (invoke "i32_load16_u" (i32.const 0x3456cdef)) (i32.const 0xcdef))
|
||||||
|
|
||||||
|
(assert_return (invoke "i64_load8_s" (i64.const -1)) (i64.const -1))
|
||||||
|
(assert_return (invoke "i64_load8_u" (i64.const -1)) (i64.const 255))
|
||||||
|
(assert_return (invoke "i64_load16_s" (i64.const -1)) (i64.const -1))
|
||||||
|
(assert_return (invoke "i64_load16_u" (i64.const -1)) (i64.const 65535))
|
||||||
|
(assert_return (invoke "i64_load32_s" (i64.const -1)) (i64.const -1))
|
||||||
|
(assert_return (invoke "i64_load32_u" (i64.const -1)) (i64.const 4294967295))
|
||||||
|
|
||||||
|
(assert_return (invoke "i64_load8_s" (i64.const 100)) (i64.const 100))
|
||||||
|
(assert_return (invoke "i64_load8_u" (i64.const 200)) (i64.const 200))
|
||||||
|
(assert_return (invoke "i64_load16_s" (i64.const 20000)) (i64.const 20000))
|
||||||
|
(assert_return (invoke "i64_load16_u" (i64.const 40000)) (i64.const 40000))
|
||||||
|
(assert_return (invoke "i64_load32_s" (i64.const 20000)) (i64.const 20000))
|
||||||
|
(assert_return (invoke "i64_load32_u" (i64.const 40000)) (i64.const 40000))
|
||||||
|
|
||||||
|
(assert_return (invoke "i64_load8_s" (i64.const 0xfedcba9856346543)) (i64.const 0x43))
|
||||||
|
(assert_return (invoke "i64_load8_s" (i64.const 0x3456436598bacdef)) (i64.const 0xffffffffffffffef))
|
||||||
|
(assert_return (invoke "i64_load8_u" (i64.const 0xfedcba9856346543)) (i64.const 0x43))
|
||||||
|
(assert_return (invoke "i64_load8_u" (i64.const 0x3456436598bacdef)) (i64.const 0xef))
|
||||||
|
(assert_return (invoke "i64_load16_s" (i64.const 0xfedcba9856346543)) (i64.const 0x6543))
|
||||||
|
(assert_return (invoke "i64_load16_s" (i64.const 0x3456436598bacdef)) (i64.const 0xffffffffffffcdef))
|
||||||
|
(assert_return (invoke "i64_load16_u" (i64.const 0xfedcba9856346543)) (i64.const 0x6543))
|
||||||
|
(assert_return (invoke "i64_load16_u" (i64.const 0x3456436598bacdef)) (i64.const 0xcdef))
|
||||||
|
(assert_return (invoke "i64_load32_s" (i64.const 0xfedcba9856346543)) (i64.const 0x56346543))
|
||||||
|
(assert_return (invoke "i64_load32_s" (i64.const 0x3456436598bacdef)) (i64.const 0xffffffff98bacdef))
|
||||||
|
(assert_return (invoke "i64_load32_u" (i64.const 0xfedcba9856346543)) (i64.const 0x56346543))
|
||||||
|
(assert_return (invoke "i64_load32_u" (i64.const 0x3456436598bacdef)) (i64.const 0x98bacdef))
|
||||||
|
|
||||||
|
(assert_malformed
|
||||||
|
(module quote
|
||||||
|
"(memory 1)"
|
||||||
|
"(func (param i32) (result i32) (i32.load32 (get_local 0)))"
|
||||||
|
)
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote
|
||||||
|
"(memory 1)"
|
||||||
|
"(func (param i32) (result i32) (i32.load32_u (get_local 0)))"
|
||||||
|
)
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote
|
||||||
|
"(memory 1)"
|
||||||
|
"(func (param i32) (result i32) (i32.load32_s (get_local 0)))"
|
||||||
|
)
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote
|
||||||
|
"(memory 1)"
|
||||||
|
"(func (param i32) (result i32) (i32.load64 (get_local 0)))"
|
||||||
|
)
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote
|
||||||
|
"(memory 1)"
|
||||||
|
"(func (param i32) (result i32) (i32.load64_u (get_local 0)))"
|
||||||
|
)
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote
|
||||||
|
"(memory 1)"
|
||||||
|
"(func (param i32) (result i32) (i32.load64_s (get_local 0)))"
|
||||||
|
)
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote
|
||||||
|
"(memory 1)"
|
||||||
|
"(func (param i32) (i32.store32 (get_local 0) (i32.const 0)))"
|
||||||
|
)
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote
|
||||||
|
"(memory 1)"
|
||||||
|
"(func (param i32) (i32.store64 (get_local 0) (i64.const 0)))"
|
||||||
|
)
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_malformed
|
||||||
|
(module quote
|
||||||
|
"(memory 1)"
|
||||||
|
"(func (param i32) (result i64) (i64.load64 (get_local 0)))"
|
||||||
|
)
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote
|
||||||
|
"(memory 1)"
|
||||||
|
"(func (param i32) (result i64) (i64.load64_u (get_local 0)))"
|
||||||
|
)
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote
|
||||||
|
"(memory 1)"
|
||||||
|
"(func (param i32) (result i64) (i64.load64_s (get_local 0)))"
|
||||||
|
)
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote
|
||||||
|
"(memory 1)"
|
||||||
|
"(func (param i32) (i64.store64 (get_local 0) (i64.const 0)))"
|
||||||
|
)
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_malformed
|
||||||
|
(module quote
|
||||||
|
"(memory 1)"
|
||||||
|
"(func (param i32) (result f32) (f32.load32 (get_local 0)))"
|
||||||
|
)
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote
|
||||||
|
"(memory 1)"
|
||||||
|
"(func (param i32) (result f32) (f32.load64 (get_local 0)))"
|
||||||
|
)
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote
|
||||||
|
"(memory 1)"
|
||||||
|
"(func (param i32) (f32.store32 (get_local 0) (f32.const 0)))"
|
||||||
|
)
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote
|
||||||
|
"(memory 1)"
|
||||||
|
"(func (param i32) (f32.store64 (get_local 0) (f64.const 0)))"
|
||||||
|
)
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_malformed
|
||||||
|
(module quote
|
||||||
|
"(memory 1)"
|
||||||
|
"(func (param i32) (result f64) (f64.load32 (get_local 0)))"
|
||||||
|
)
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote
|
||||||
|
"(memory 1)"
|
||||||
|
"(func (param i32) (result f64) (f64.load64 (get_local 0)))"
|
||||||
|
)
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote
|
||||||
|
"(memory 1)"
|
||||||
|
"(func (param i32) (f64.store32 (get_local 0) (f32.const 0)))"
|
||||||
|
)
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote
|
||||||
|
"(memory 1)"
|
||||||
|
"(func (param i32) (f64.store64 (get_local 0) (f64.const 0)))"
|
||||||
|
)
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
;; Test that optimizers don't do redundant-load, store-to-load, or dead-store
|
||||||
|
;; optimizations when there are interfering stores, even of different types
|
||||||
|
;; and to non-identical addresses.
|
||||||
|
|
||||||
|
(module
|
||||||
|
(memory 1 1)
|
||||||
|
|
||||||
|
(func (export "zero_everything")
|
||||||
|
(i32.store (i32.const 0) (i32.const 0))
|
||||||
|
(i32.store (i32.const 4) (i32.const 0))
|
||||||
|
(i32.store (i32.const 8) (i32.const 0))
|
||||||
|
(i32.store (i32.const 12) (i32.const 0))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "test_store_to_load") (result i32)
|
||||||
|
(i32.store (i32.const 8) (i32.const 0))
|
||||||
|
(f32.store (i32.const 5) (f32.const -0.0))
|
||||||
|
(i32.load (i32.const 8))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "test_redundant_load") (result i32)
|
||||||
|
(local $t i32)
|
||||||
|
(local $s i32)
|
||||||
|
(set_local $t (i32.load (i32.const 8)))
|
||||||
|
(i32.store (i32.const 5) (i32.const 0x80000000))
|
||||||
|
(set_local $s (i32.load (i32.const 8)))
|
||||||
|
(i32.add (get_local $t) (get_local $s))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "test_dead_store") (result f32)
|
||||||
|
(local $t f32)
|
||||||
|
(i32.store (i32.const 8) (i32.const 0x23232323))
|
||||||
|
(set_local $t (f32.load (i32.const 11)))
|
||||||
|
(i32.store (i32.const 8) (i32.const 0))
|
||||||
|
(get_local $t)
|
||||||
|
)
|
||||||
|
|
||||||
|
;; A function named "malloc" which implementations nonetheless shouldn't
|
||||||
|
;; assume behaves like C malloc.
|
||||||
|
(func $malloc (export "malloc")
|
||||||
|
(param $size i32)
|
||||||
|
(result i32)
|
||||||
|
(i32.const 16)
|
||||||
|
)
|
||||||
|
|
||||||
|
;; Call malloc twice, but unlike C malloc, we don't get non-aliasing pointers.
|
||||||
|
(func (export "malloc_aliasing")
|
||||||
|
(result i32)
|
||||||
|
(local $x i32)
|
||||||
|
(local $y i32)
|
||||||
|
(set_local $x (call $malloc (i32.const 4)))
|
||||||
|
(set_local $y (call $malloc (i32.const 4)))
|
||||||
|
(i32.store (get_local $x) (i32.const 42))
|
||||||
|
(i32.store (get_local $y) (i32.const 43))
|
||||||
|
(i32.load (get_local $x))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke "test_store_to_load") (i32.const 0x00000080))
|
||||||
|
(invoke "zero_everything")
|
||||||
|
(assert_return (invoke "test_redundant_load") (i32.const 0x00000080))
|
||||||
|
(invoke "zero_everything")
|
||||||
|
(assert_return (invoke "test_dead_store") (f32.const 0x1.18p-144))
|
||||||
|
(invoke "zero_everything")
|
||||||
|
(assert_return (invoke "malloc_aliasing") (i32.const 43))
|
||||||
@@ -0,0 +1,270 @@
|
|||||||
|
(module
|
||||||
|
(memory 1)
|
||||||
|
|
||||||
|
(func $addr_limit (result i32)
|
||||||
|
(i32.mul (memory.size) (i32.const 0x10000))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "store") (param $i i32) (param $v i32)
|
||||||
|
(i32.store (i32.add (call $addr_limit) (get_local $i)) (get_local $v))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "load") (param $i i32) (result i32)
|
||||||
|
(i32.load (i32.add (call $addr_limit) (get_local $i)))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "memory.grow") (param i32) (result i32)
|
||||||
|
(memory.grow (get_local 0))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke "store" (i32.const -4) (i32.const 42)))
|
||||||
|
(assert_return (invoke "load" (i32.const -4)) (i32.const 42))
|
||||||
|
(assert_trap (invoke "store" (i32.const -3) (i32.const 13)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "load" (i32.const -3)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "store" (i32.const -2) (i32.const 13)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "load" (i32.const -2)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "store" (i32.const -1) (i32.const 13)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "load" (i32.const -1)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "store" (i32.const 0) (i32.const 13)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "load" (i32.const 0)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "store" (i32.const 0x80000000) (i32.const 13)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "load" (i32.const 0x80000000)) "out of bounds memory access")
|
||||||
|
(assert_return (invoke "memory.grow" (i32.const 0x10001)) (i32.const -1))
|
||||||
|
|
||||||
|
(module
|
||||||
|
(memory 1)
|
||||||
|
(data (i32.const 0) "abcdefgh")
|
||||||
|
(data (i32.const 0xfff8) "abcdefgh")
|
||||||
|
|
||||||
|
(func (export "i32.load") (param $a i32) (result i32)
|
||||||
|
(i32.load (get_local $a))
|
||||||
|
)
|
||||||
|
(func (export "i64.load") (param $a i32) (result i64)
|
||||||
|
(i64.load (get_local $a))
|
||||||
|
)
|
||||||
|
(func (export "f32.load") (param $a i32) (result f32)
|
||||||
|
(f32.load (get_local $a))
|
||||||
|
)
|
||||||
|
(func (export "f64.load") (param $a i32) (result f64)
|
||||||
|
(f64.load (get_local $a))
|
||||||
|
)
|
||||||
|
(func (export "i32.load8_s") (param $a i32) (result i32)
|
||||||
|
(i32.load8_s (get_local $a))
|
||||||
|
)
|
||||||
|
(func (export "i32.load8_u") (param $a i32) (result i32)
|
||||||
|
(i32.load8_u (get_local $a))
|
||||||
|
)
|
||||||
|
(func (export "i32.load16_s") (param $a i32) (result i32)
|
||||||
|
(i32.load16_s (get_local $a))
|
||||||
|
)
|
||||||
|
(func (export "i32.load16_u") (param $a i32) (result i32)
|
||||||
|
(i32.load16_u (get_local $a))
|
||||||
|
)
|
||||||
|
(func (export "i64.load8_s") (param $a i32) (result i64)
|
||||||
|
(i64.load8_s (get_local $a))
|
||||||
|
)
|
||||||
|
(func (export "i64.load8_u") (param $a i32) (result i64)
|
||||||
|
(i64.load8_u (get_local $a))
|
||||||
|
)
|
||||||
|
(func (export "i64.load16_s") (param $a i32) (result i64)
|
||||||
|
(i64.load16_s (get_local $a))
|
||||||
|
)
|
||||||
|
(func (export "i64.load16_u") (param $a i32) (result i64)
|
||||||
|
(i64.load16_u (get_local $a))
|
||||||
|
)
|
||||||
|
(func (export "i64.load32_s") (param $a i32) (result i64)
|
||||||
|
(i64.load32_s (get_local $a))
|
||||||
|
)
|
||||||
|
(func (export "i64.load32_u") (param $a i32) (result i64)
|
||||||
|
(i64.load32_u (get_local $a))
|
||||||
|
)
|
||||||
|
(func (export "i32.store") (param $a i32) (param $v i32)
|
||||||
|
(i32.store (get_local $a) (get_local $v))
|
||||||
|
)
|
||||||
|
(func (export "i64.store") (param $a i32) (param $v i64)
|
||||||
|
(i64.store (get_local $a) (get_local $v))
|
||||||
|
)
|
||||||
|
(func (export "f32.store") (param $a i32) (param $v f32)
|
||||||
|
(f32.store (get_local $a) (get_local $v))
|
||||||
|
)
|
||||||
|
(func (export "f64.store") (param $a i32) (param $v f64)
|
||||||
|
(f64.store (get_local $a) (get_local $v))
|
||||||
|
)
|
||||||
|
(func (export "i32.store8") (param $a i32) (param $v i32)
|
||||||
|
(i32.store8 (get_local $a) (get_local $v))
|
||||||
|
)
|
||||||
|
(func (export "i32.store16") (param $a i32) (param $v i32)
|
||||||
|
(i32.store16 (get_local $a) (get_local $v))
|
||||||
|
)
|
||||||
|
(func (export "i64.store8") (param $a i32) (param $v i64)
|
||||||
|
(i64.store8 (get_local $a) (get_local $v))
|
||||||
|
)
|
||||||
|
(func (export "i64.store16") (param $a i32) (param $v i64)
|
||||||
|
(i64.store16 (get_local $a) (get_local $v))
|
||||||
|
)
|
||||||
|
(func (export "i64.store32") (param $a i32) (param $v i64)
|
||||||
|
(i64.store32 (get_local $a) (get_local $v))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_trap (invoke "i32.store" (i32.const 0x10000) (i32.const 0)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i32.store" (i32.const 0xffff) (i32.const 0)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i32.store" (i32.const 0xfffe) (i32.const 0)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i32.store" (i32.const 0xfffd) (i32.const 0)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i32.store" (i32.const -1) (i32.const 0)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i32.store" (i32.const -2) (i32.const 0)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i32.store" (i32.const -3) (i32.const 0)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i32.store" (i32.const -4) (i32.const 0)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.store" (i32.const 0x10000) (i64.const 0)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.store" (i32.const 0xffff) (i64.const 0)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.store" (i32.const 0xfffe) (i64.const 0)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.store" (i32.const 0xfffd) (i64.const 0)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.store" (i32.const 0xfffc) (i64.const 0)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.store" (i32.const 0xfffb) (i64.const 0)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.store" (i32.const 0xfffa) (i64.const 0)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.store" (i32.const 0xfff9) (i64.const 0)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.store" (i32.const -1) (i64.const 0)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.store" (i32.const -2) (i64.const 0)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.store" (i32.const -3) (i64.const 0)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.store" (i32.const -4) (i64.const 0)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.store" (i32.const -5) (i64.const 0)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.store" (i32.const -6) (i64.const 0)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.store" (i32.const -7) (i64.const 0)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.store" (i32.const -8) (i64.const 0)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "f32.store" (i32.const 0x10000) (f32.const 0)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "f32.store" (i32.const 0xffff) (f32.const 0)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "f32.store" (i32.const 0xfffe) (f32.const 0)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "f32.store" (i32.const 0xfffd) (f32.const 0)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "f32.store" (i32.const -1) (f32.const 0)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "f32.store" (i32.const -2) (f32.const 0)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "f32.store" (i32.const -3) (f32.const 0)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "f32.store" (i32.const -4) (f32.const 0)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "f64.store" (i32.const 0x10000) (f64.const 0)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "f64.store" (i32.const 0xffff) (f64.const 0)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "f64.store" (i32.const 0xfffe) (f64.const 0)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "f64.store" (i32.const 0xfffd) (f64.const 0)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "f64.store" (i32.const 0xfffc) (f64.const 0)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "f64.store" (i32.const 0xfffb) (f64.const 0)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "f64.store" (i32.const 0xfffa) (f64.const 0)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "f64.store" (i32.const 0xfff9) (f64.const 0)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "f64.store" (i32.const -1) (f64.const 0)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "f64.store" (i32.const -2) (f64.const 0)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "f64.store" (i32.const -3) (f64.const 0)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "f64.store" (i32.const -4) (f64.const 0)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "f64.store" (i32.const -5) (f64.const 0)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "f64.store" (i32.const -6) (f64.const 0)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "f64.store" (i32.const -7) (f64.const 0)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "f64.store" (i32.const -8) (f64.const 0)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i32.store8" (i32.const 0x10000) (i32.const 0)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i32.store8" (i32.const -1) (i32.const 0)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i32.store16" (i32.const 0x10000) (i32.const 0)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i32.store16" (i32.const 0xffff) (i32.const 0)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i32.store16" (i32.const -1) (i32.const 0)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i32.store16" (i32.const -2) (i32.const 0)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.store8" (i32.const 0x10000) (i64.const 0)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.store8" (i32.const -1) (i64.const 0)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.store16" (i32.const 0x10000) (i64.const 0)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.store16" (i32.const 0xffff) (i64.const 0)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.store16" (i32.const -1) (i64.const 0)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.store16" (i32.const -2) (i64.const 0)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.store32" (i32.const 0x10000) (i64.const 0)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.store32" (i32.const 0xffff) (i64.const 0)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.store32" (i32.const 0xfffe) (i64.const 0)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.store32" (i32.const 0xfffd) (i64.const 0)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.store32" (i32.const -1) (i64.const 0)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.store32" (i32.const -2) (i64.const 0)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.store32" (i32.const -3) (i64.const 0)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.store32" (i32.const -4) (i64.const 0)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i32.load" (i32.const 0x10000)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i32.load" (i32.const 0xffff)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i32.load" (i32.const 0xfffe)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i32.load" (i32.const 0xfffd)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i32.load" (i32.const -1)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i32.load" (i32.const -2)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i32.load" (i32.const -3)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i32.load" (i32.const -4)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.load" (i32.const 0x10000)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.load" (i32.const 0xffff)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.load" (i32.const 0xfffe)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.load" (i32.const 0xfffd)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.load" (i32.const 0xfffc)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.load" (i32.const 0xfffb)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.load" (i32.const 0xfffa)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.load" (i32.const 0xfff9)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.load" (i32.const -1)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.load" (i32.const -2)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.load" (i32.const -3)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.load" (i32.const -4)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.load" (i32.const -5)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.load" (i32.const -6)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.load" (i32.const -7)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.load" (i32.const -8)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "f32.load" (i32.const 0x10000)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "f32.load" (i32.const 0xffff)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "f32.load" (i32.const 0xfffe)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "f32.load" (i32.const 0xfffd)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "f32.load" (i32.const -1)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "f32.load" (i32.const -2)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "f32.load" (i32.const -3)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "f32.load" (i32.const -4)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "f64.load" (i32.const 0x10000)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "f64.load" (i32.const 0xffff)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "f64.load" (i32.const 0xfffe)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "f64.load" (i32.const 0xfffd)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "f64.load" (i32.const 0xfffc)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "f64.load" (i32.const 0xfffb)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "f64.load" (i32.const 0xfffa)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "f64.load" (i32.const 0xfff9)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "f64.load" (i32.const -1)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "f64.load" (i32.const -2)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "f64.load" (i32.const -3)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "f64.load" (i32.const -4)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "f64.load" (i32.const -5)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "f64.load" (i32.const -6)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "f64.load" (i32.const -7)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "f64.load" (i32.const -8)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i32.load8_s" (i32.const 0x10000)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i32.load8_s" (i32.const -1)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i32.load8_u" (i32.const 0x10000)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i32.load8_u" (i32.const -1)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i32.load16_s" (i32.const 0x10000)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i32.load16_s" (i32.const 0xffff)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i32.load16_s" (i32.const -1)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i32.load16_s" (i32.const -2)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i32.load16_u" (i32.const 0x10000)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i32.load16_u" (i32.const 0xffff)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i32.load16_u" (i32.const -1)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i32.load16_u" (i32.const -2)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.load8_s" (i32.const 0x10000)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.load8_s" (i32.const -1)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.load8_u" (i32.const 0x10000)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.load8_u" (i32.const -1)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.load16_s" (i32.const 0x10000)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.load16_s" (i32.const 0xffff)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.load16_s" (i32.const -1)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.load16_s" (i32.const -2)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.load16_u" (i32.const 0x10000)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.load16_u" (i32.const 0xffff)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.load16_u" (i32.const -1)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.load16_u" (i32.const -2)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.load32_s" (i32.const 0x10000)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.load32_s" (i32.const 0xffff)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.load32_s" (i32.const 0xfffe)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.load32_s" (i32.const 0xfffd)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.load32_s" (i32.const -1)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.load32_s" (i32.const -2)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.load32_s" (i32.const -3)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.load32_s" (i32.const -4)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.load32_u" (i32.const 0x10000)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.load32_u" (i32.const 0xffff)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.load32_u" (i32.const 0xfffe)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.load32_u" (i32.const 0xfffd)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.load32_u" (i32.const -1)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.load32_u" (i32.const -2)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.load32_u" (i32.const -3)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "i64.load32_u" (i32.const -4)) "out of bounds memory access")
|
||||||
|
|
||||||
|
;; No memory was changed
|
||||||
|
(assert_return (invoke "i64.load" (i32.const 0xfff8)) (i64.const 0x6867666564636261))
|
||||||
|
(assert_return (invoke "i64.load" (i32.const 0)) (i64.const 0x6867666564636261))
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,264 @@
|
|||||||
|
;; Test `nop` operator.
|
||||||
|
|
||||||
|
(module
|
||||||
|
;; Auxiliary definitions
|
||||||
|
(func $dummy)
|
||||||
|
(func $3-ary (param i32 i32 i32) (result i32)
|
||||||
|
get_local 0 get_local 1 get_local 2 i32.sub i32.add
|
||||||
|
)
|
||||||
|
(memory 1)
|
||||||
|
|
||||||
|
(func (export "as-func-first") (result i32)
|
||||||
|
(nop) (i32.const 1)
|
||||||
|
)
|
||||||
|
(func (export "as-func-mid") (result i32)
|
||||||
|
(call $dummy) (nop) (i32.const 2)
|
||||||
|
)
|
||||||
|
(func (export "as-func-last") (result i32)
|
||||||
|
(call $dummy) (i32.const 3) (nop)
|
||||||
|
)
|
||||||
|
(func (export "as-func-everywhere") (result i32)
|
||||||
|
(nop) (nop) (call $dummy) (nop) (i32.const 4) (nop) (nop)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "as-drop-last") (param i32)
|
||||||
|
(get_local 0) (nop) (drop)
|
||||||
|
)
|
||||||
|
(func (export "as-drop-everywhere") (param i32)
|
||||||
|
(nop) (nop) (get_local 0) (nop) (nop) (drop)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "as-select-mid1") (param i32) (result i32)
|
||||||
|
(get_local 0) (nop) (get_local 0) (get_local 0) (select)
|
||||||
|
)
|
||||||
|
(func (export "as-select-mid2") (param i32) (result i32)
|
||||||
|
(get_local 0) (get_local 0) (nop) (get_local 0) (select)
|
||||||
|
)
|
||||||
|
(func (export "as-select-last") (param i32) (result i32)
|
||||||
|
(get_local 0) (get_local 0) (get_local 0) (nop) (select)
|
||||||
|
)
|
||||||
|
(func (export "as-select-everywhere") (param i32) (result i32)
|
||||||
|
(nop) (get_local 0) (nop) (nop) (get_local 0)
|
||||||
|
(nop) (nop) (get_local 0) (nop) (nop) (select)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "as-block-first") (result i32)
|
||||||
|
(block (result i32) (nop) (i32.const 2))
|
||||||
|
)
|
||||||
|
(func (export "as-block-mid") (result i32)
|
||||||
|
(block (result i32) (call $dummy) (nop) (i32.const 2))
|
||||||
|
)
|
||||||
|
(func (export "as-block-last") (result i32)
|
||||||
|
(block (result i32) (nop) (call $dummy) (i32.const 3) (nop))
|
||||||
|
)
|
||||||
|
(func (export "as-block-everywhere") (result i32)
|
||||||
|
(block (result i32)
|
||||||
|
(nop) (nop) (call $dummy) (nop) (i32.const 4) (nop) (nop)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "as-loop-first") (result i32)
|
||||||
|
(loop (result i32) (nop) (i32.const 2))
|
||||||
|
)
|
||||||
|
(func (export "as-loop-mid") (result i32)
|
||||||
|
(loop (result i32) (call $dummy) (nop) (i32.const 2))
|
||||||
|
)
|
||||||
|
(func (export "as-loop-last") (result i32)
|
||||||
|
(loop (result i32) (call $dummy) (i32.const 3) (nop))
|
||||||
|
)
|
||||||
|
(func (export "as-loop-everywhere") (result i32)
|
||||||
|
(loop (result i32)
|
||||||
|
(nop) (nop) (call $dummy) (nop) (i32.const 4) (nop) (nop)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "as-if-condition") (param i32)
|
||||||
|
(get_local 0) (nop) (if (then (call $dummy)))
|
||||||
|
)
|
||||||
|
(func (export "as-if-then") (param i32)
|
||||||
|
(if (get_local 0) (then (nop)) (else (call $dummy)))
|
||||||
|
)
|
||||||
|
(func (export "as-if-else") (param i32)
|
||||||
|
(if (get_local 0) (then (call $dummy)) (else (nop)))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "as-br-last") (param i32) (result i32)
|
||||||
|
(block (result i32) (get_local 0) (nop) (br 0))
|
||||||
|
)
|
||||||
|
(func (export "as-br-everywhere") (param i32) (result i32)
|
||||||
|
(block (result i32) (nop) (nop) (get_local 0) (nop) (nop) (br 0))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "as-br_if-mid") (param i32) (result i32)
|
||||||
|
(block (result i32) (get_local 0) (nop) (get_local 0) (br_if 0))
|
||||||
|
)
|
||||||
|
(func (export "as-br_if-last") (param i32) (result i32)
|
||||||
|
(block (result i32) (get_local 0) (get_local 0) (nop) (br_if 0))
|
||||||
|
)
|
||||||
|
(func (export "as-br_if-everywhere") (param i32) (result i32)
|
||||||
|
(block (result i32)
|
||||||
|
(nop) (nop) (get_local 0) (nop) (nop) (get_local 0) (nop) (nop)
|
||||||
|
(br_if 0)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "as-br_table-mid") (param i32) (result i32)
|
||||||
|
(block (result i32) (get_local 0) (nop) (get_local 0) (br_table 0 0))
|
||||||
|
)
|
||||||
|
(func (export "as-br_table-last") (param i32) (result i32)
|
||||||
|
(block (result i32) (get_local 0) (get_local 0) (nop) (br_table 0 0))
|
||||||
|
)
|
||||||
|
(func (export "as-br_table-everywhere") (param i32) (result i32)
|
||||||
|
(block (result i32)
|
||||||
|
(nop) (nop) (get_local 0) (nop) (nop) (get_local 0) (nop) (nop)
|
||||||
|
(br_table 0 0)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "as-return-last") (param i32) (result i32)
|
||||||
|
(get_local 0) (nop) (return)
|
||||||
|
)
|
||||||
|
(func (export "as-return-everywhere") (param i32) (result i32)
|
||||||
|
(nop) (nop) (get_local 0) (nop) (nop) (return)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "as-call-mid1") (param i32 i32 i32) (result i32)
|
||||||
|
(get_local 0) (nop) (get_local 1) (get_local 2) (call $3-ary)
|
||||||
|
)
|
||||||
|
(func (export "as-call-mid2") (param i32 i32 i32) (result i32)
|
||||||
|
(get_local 0) (get_local 1) (nop) (get_local 2) (call $3-ary)
|
||||||
|
)
|
||||||
|
(func (export "as-call-last") (param i32 i32 i32) (result i32)
|
||||||
|
(get_local 0) (get_local 1) (get_local 2) (nop) (call $3-ary)
|
||||||
|
)
|
||||||
|
(func (export "as-call-everywhere") (param i32 i32 i32) (result i32)
|
||||||
|
(nop) (nop) (get_local 0) (nop) (nop) (get_local 1)
|
||||||
|
(nop) (nop) (get_local 2) (nop) (nop) (call $3-ary)
|
||||||
|
)
|
||||||
|
|
||||||
|
;; TODO(stack): call_indirect, *_local, load*, store*
|
||||||
|
|
||||||
|
(func (export "as-unary-last") (param i32) (result i32)
|
||||||
|
(get_local 0) (nop) (i32.ctz)
|
||||||
|
)
|
||||||
|
(func (export "as-unary-everywhere") (param i32) (result i32)
|
||||||
|
(nop) (nop) (get_local 0) (nop) (nop) (i32.ctz)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "as-binary-mid") (param i32) (result i32)
|
||||||
|
(get_local 0) (nop) (get_local 0) (i32.add)
|
||||||
|
)
|
||||||
|
(func (export "as-binary-last") (param i32) (result i32)
|
||||||
|
(get_local 0) (get_local 0) (nop) (i32.add)
|
||||||
|
)
|
||||||
|
(func (export "as-binary-everywhere") (param i32) (result i32)
|
||||||
|
(nop) (get_local 0) (nop) (nop) (get_local 0) (nop) (nop) (i32.add)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "as-test-last") (param i32) (result i32)
|
||||||
|
(get_local 0) (nop) (i32.eqz)
|
||||||
|
)
|
||||||
|
(func (export "as-test-everywhere") (param i32) (result i32)
|
||||||
|
(nop) (nop) (get_local 0) (nop) (nop) i32.eqz
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "as-compare-mid") (param i32) (result i32)
|
||||||
|
(get_local 0) (nop) (get_local 0) (i32.ne)
|
||||||
|
)
|
||||||
|
(func (export "as-compare-last") (param i32) (result i32)
|
||||||
|
(get_local 0) (get_local 0) (nop) (i32.lt_u)
|
||||||
|
)
|
||||||
|
(func (export "as-compare-everywhere") (param i32) (result i32)
|
||||||
|
(nop) (get_local 0) (nop) (nop) (get_local 0) (nop) (nop) (i32.le_s)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "as-memory.grow-last") (param i32) (result i32)
|
||||||
|
(get_local 0) (nop) (memory.grow)
|
||||||
|
)
|
||||||
|
(func (export "as-memory.grow-everywhere") (param i32) (result i32)
|
||||||
|
(nop) (nop) (get_local 0) (nop) (nop) (memory.grow)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke "as-func-first") (i32.const 1))
|
||||||
|
(assert_return (invoke "as-func-mid") (i32.const 2))
|
||||||
|
(assert_return (invoke "as-func-last") (i32.const 3))
|
||||||
|
(assert_return (invoke "as-func-everywhere") (i32.const 4))
|
||||||
|
|
||||||
|
(assert_return (invoke "as-drop-last" (i32.const 0)))
|
||||||
|
(assert_return (invoke "as-drop-everywhere" (i32.const 0)))
|
||||||
|
|
||||||
|
(assert_return (invoke "as-select-mid1" (i32.const 3)) (i32.const 3))
|
||||||
|
(assert_return (invoke "as-select-mid2" (i32.const 3)) (i32.const 3))
|
||||||
|
(assert_return (invoke "as-select-last" (i32.const 3)) (i32.const 3))
|
||||||
|
(assert_return (invoke "as-select-everywhere" (i32.const 3)) (i32.const 3))
|
||||||
|
|
||||||
|
(assert_return (invoke "as-block-first") (i32.const 2))
|
||||||
|
(assert_return (invoke "as-block-mid") (i32.const 2))
|
||||||
|
(assert_return (invoke "as-block-last") (i32.const 3))
|
||||||
|
(assert_return (invoke "as-block-everywhere") (i32.const 4))
|
||||||
|
|
||||||
|
(assert_return (invoke "as-loop-first") (i32.const 2))
|
||||||
|
(assert_return (invoke "as-loop-mid") (i32.const 2))
|
||||||
|
(assert_return (invoke "as-loop-last") (i32.const 3))
|
||||||
|
(assert_return (invoke "as-loop-everywhere") (i32.const 4))
|
||||||
|
|
||||||
|
(assert_return (invoke "as-if-condition" (i32.const 0)))
|
||||||
|
(assert_return (invoke "as-if-condition" (i32.const -1)))
|
||||||
|
(assert_return (invoke "as-if-then" (i32.const 0)))
|
||||||
|
(assert_return (invoke "as-if-then" (i32.const 4)))
|
||||||
|
(assert_return (invoke "as-if-else" (i32.const 0)))
|
||||||
|
(assert_return (invoke "as-if-else" (i32.const 3)))
|
||||||
|
|
||||||
|
(assert_return (invoke "as-br-last" (i32.const 6)) (i32.const 6))
|
||||||
|
(assert_return (invoke "as-br-everywhere" (i32.const 7)) (i32.const 7))
|
||||||
|
|
||||||
|
(assert_return (invoke "as-br_if-mid" (i32.const 5)) (i32.const 5))
|
||||||
|
(assert_return (invoke "as-br_if-last" (i32.const 6)) (i32.const 6))
|
||||||
|
(assert_return (invoke "as-br_if-everywhere" (i32.const 7)) (i32.const 7))
|
||||||
|
|
||||||
|
(assert_return (invoke "as-br_table-mid" (i32.const 5)) (i32.const 5))
|
||||||
|
(assert_return (invoke "as-br_table-last" (i32.const 6)) (i32.const 6))
|
||||||
|
(assert_return (invoke "as-br_table-everywhere" (i32.const 7)) (i32.const 7))
|
||||||
|
|
||||||
|
(assert_return (invoke "as-return-last" (i32.const 6)) (i32.const 6))
|
||||||
|
(assert_return (invoke "as-return-everywhere" (i32.const 7)) (i32.const 7))
|
||||||
|
|
||||||
|
(assert_return (invoke "as-call-mid1" (i32.const 3) (i32.const 1) (i32.const 2)) (i32.const 2))
|
||||||
|
(assert_return (invoke "as-call-mid2" (i32.const 0) (i32.const 3) (i32.const 1)) (i32.const 2))
|
||||||
|
(assert_return (invoke "as-call-last" (i32.const 10) (i32.const 9) (i32.const -1)) (i32.const 20))
|
||||||
|
(assert_return (invoke "as-call-everywhere" (i32.const 2) (i32.const 1) (i32.const 5)) (i32.const -2))
|
||||||
|
|
||||||
|
(assert_return (invoke "as-unary-last" (i32.const 30)) (i32.const 1))
|
||||||
|
(assert_return (invoke "as-unary-everywhere" (i32.const 12)) (i32.const 2))
|
||||||
|
|
||||||
|
(assert_return (invoke "as-binary-mid" (i32.const 3)) (i32.const 6))
|
||||||
|
(assert_return (invoke "as-binary-last" (i32.const 3)) (i32.const 6))
|
||||||
|
(assert_return (invoke "as-binary-everywhere" (i32.const 3)) (i32.const 6))
|
||||||
|
|
||||||
|
(assert_return (invoke "as-test-last" (i32.const 0)) (i32.const 1))
|
||||||
|
(assert_return (invoke "as-test-everywhere" (i32.const 0)) (i32.const 1))
|
||||||
|
|
||||||
|
(assert_return (invoke "as-compare-mid" (i32.const 3)) (i32.const 0))
|
||||||
|
(assert_return (invoke "as-compare-last" (i32.const 3)) (i32.const 0))
|
||||||
|
(assert_return (invoke "as-compare-everywhere" (i32.const 3)) (i32.const 1))
|
||||||
|
|
||||||
|
(assert_return (invoke "as-memory.grow-last" (i32.const 2)) (i32.const 1))
|
||||||
|
(assert_return (invoke "as-memory.grow-everywhere" (i32.const 12)) (i32.const 3))
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-i32 (result i32) (nop)))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-i64 (result i64) (nop)))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-f32 (result f32) (nop)))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-f64 (result f64) (nop)))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
(module
|
||||||
|
(memory 0)
|
||||||
|
|
||||||
|
(func (export "load_at_zero") (result i32) (i32.load (i32.const 0)))
|
||||||
|
(func (export "store_at_zero") (i32.store (i32.const 0) (i32.const 2)))
|
||||||
|
|
||||||
|
(func (export "load_at_page_size") (result i32) (i32.load (i32.const 0x10000)))
|
||||||
|
(func (export "store_at_page_size") (i32.store (i32.const 0x10000) (i32.const 3)))
|
||||||
|
|
||||||
|
(func (export "grow") (param $sz i32) (result i32) (memory.grow (get_local $sz)))
|
||||||
|
(func (export "size") (result i32) (memory.size))
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke "size") (i32.const 0))
|
||||||
|
(assert_trap (invoke "store_at_zero") "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "load_at_zero") "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "store_at_page_size") "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "load_at_page_size") "out of bounds memory access")
|
||||||
|
(assert_return (invoke "grow" (i32.const 1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "size") (i32.const 1))
|
||||||
|
(assert_return (invoke "load_at_zero") (i32.const 0))
|
||||||
|
(assert_return (invoke "store_at_zero"))
|
||||||
|
(assert_return (invoke "load_at_zero") (i32.const 2))
|
||||||
|
(assert_trap (invoke "store_at_page_size") "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "load_at_page_size") "out of bounds memory access")
|
||||||
|
(assert_return (invoke "grow" (i32.const 4)) (i32.const 1))
|
||||||
|
(assert_return (invoke "size") (i32.const 5))
|
||||||
|
(assert_return (invoke "load_at_zero") (i32.const 2))
|
||||||
|
(assert_return (invoke "store_at_zero"))
|
||||||
|
(assert_return (invoke "load_at_zero") (i32.const 2))
|
||||||
|
(assert_return (invoke "load_at_page_size") (i32.const 0))
|
||||||
|
(assert_return (invoke "store_at_page_size"))
|
||||||
|
(assert_return (invoke "load_at_page_size") (i32.const 3))
|
||||||
|
|
||||||
|
|
||||||
|
(module
|
||||||
|
(memory 0)
|
||||||
|
(func (export "grow") (param i32) (result i32) (memory.grow (get_local 0)))
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke "grow" (i32.const 0)) (i32.const 0))
|
||||||
|
(assert_return (invoke "grow" (i32.const 1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "grow" (i32.const 0)) (i32.const 1))
|
||||||
|
(assert_return (invoke "grow" (i32.const 2)) (i32.const 1))
|
||||||
|
(assert_return (invoke "grow" (i32.const 800)) (i32.const 3))
|
||||||
|
(assert_return (invoke "grow" (i32.const 0x10000)) (i32.const -1))
|
||||||
|
|
||||||
|
(module
|
||||||
|
(memory 0 10)
|
||||||
|
(func (export "grow") (param i32) (result i32) (memory.grow (get_local 0)))
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke "grow" (i32.const 0)) (i32.const 0))
|
||||||
|
(assert_return (invoke "grow" (i32.const 1)) (i32.const 0))
|
||||||
|
(assert_return (invoke "grow" (i32.const 1)) (i32.const 1))
|
||||||
|
(assert_return (invoke "grow" (i32.const 2)) (i32.const 2))
|
||||||
|
(assert_return (invoke "grow" (i32.const 6)) (i32.const 4))
|
||||||
|
(assert_return (invoke "grow" (i32.const 0)) (i32.const 10))
|
||||||
|
(assert_return (invoke "grow" (i32.const 1)) (i32.const -1))
|
||||||
|
(assert_return (invoke "grow" (i32.const 0x10000)) (i32.const -1))
|
||||||
@@ -0,0 +1,295 @@
|
|||||||
|
;; Test `return` operator
|
||||||
|
|
||||||
|
(module
|
||||||
|
;; Auxiliary definition
|
||||||
|
(func $dummy)
|
||||||
|
|
||||||
|
(func (export "type-i32") (drop (i32.ctz (return))))
|
||||||
|
(func (export "type-i64") (drop (i64.ctz (return))))
|
||||||
|
(func (export "type-f32") (drop (f32.neg (return))))
|
||||||
|
(func (export "type-f64") (drop (f64.neg (return))))
|
||||||
|
|
||||||
|
(func (export "nullary") (return))
|
||||||
|
(func (export "unary") (result f64) (return (f64.const 3)))
|
||||||
|
|
||||||
|
(func (export "as-func-first") (result i32)
|
||||||
|
(return (i32.const 1)) (i32.const 2)
|
||||||
|
)
|
||||||
|
(func (export "as-func-mid") (result i32)
|
||||||
|
(call $dummy) (return (i32.const 2)) (i32.const 3)
|
||||||
|
)
|
||||||
|
(func (export "as-func-last")
|
||||||
|
(nop) (call $dummy) (return)
|
||||||
|
)
|
||||||
|
(func (export "as-func-value") (result i32)
|
||||||
|
(nop) (call $dummy) (return (i32.const 3))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "as-block-first")
|
||||||
|
(block (return) (call $dummy))
|
||||||
|
)
|
||||||
|
(func (export "as-block-mid")
|
||||||
|
(block (call $dummy) (return) (call $dummy))
|
||||||
|
)
|
||||||
|
(func (export "as-block-last")
|
||||||
|
(block (nop) (call $dummy) (return))
|
||||||
|
)
|
||||||
|
(func (export "as-block-value") (result i32)
|
||||||
|
(block (result i32) (nop) (call $dummy) (return (i32.const 2)))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "as-loop-first") (result i32)
|
||||||
|
(loop (result i32) (return (i32.const 3)) (i32.const 2))
|
||||||
|
)
|
||||||
|
(func (export "as-loop-mid") (result i32)
|
||||||
|
(loop (result i32) (call $dummy) (return (i32.const 4)) (i32.const 2))
|
||||||
|
)
|
||||||
|
(func (export "as-loop-last") (result i32)
|
||||||
|
(loop (result i32) (nop) (call $dummy) (return (i32.const 5)))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "as-br-value") (result i32)
|
||||||
|
(block (result i32) (br 0 (return (i32.const 9))))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "as-br_if-cond")
|
||||||
|
(block (br_if 0 (return)))
|
||||||
|
)
|
||||||
|
(func (export "as-br_if-value") (result i32)
|
||||||
|
(block (result i32)
|
||||||
|
(drop (br_if 0 (return (i32.const 8)) (i32.const 1))) (i32.const 7)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(func (export "as-br_if-value-cond") (result i32)
|
||||||
|
(block (result i32)
|
||||||
|
(drop (br_if 0 (i32.const 6) (return (i32.const 9)))) (i32.const 7)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "as-br_table-index") (result i64)
|
||||||
|
(block (br_table 0 0 0 (return (i64.const 9)))) (i64.const -1)
|
||||||
|
)
|
||||||
|
(func (export "as-br_table-value") (result i32)
|
||||||
|
(block (result i32)
|
||||||
|
(br_table 0 0 0 (return (i32.const 10)) (i32.const 1)) (i32.const 7)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(func (export "as-br_table-value-index") (result i32)
|
||||||
|
(block (result i32)
|
||||||
|
(br_table 0 0 (i32.const 6) (return (i32.const 11))) (i32.const 7)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "as-return-value") (result i64)
|
||||||
|
(return (return (i64.const 7)))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "as-if-cond") (result i32)
|
||||||
|
(if (result i32)
|
||||||
|
(return (i32.const 2)) (then (i32.const 0)) (else (i32.const 1))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(func (export "as-if-then") (param i32 i32) (result i32)
|
||||||
|
(if (result i32)
|
||||||
|
(get_local 0) (then (return (i32.const 3))) (else (get_local 1))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(func (export "as-if-else") (param i32 i32) (result i32)
|
||||||
|
(if (result i32)
|
||||||
|
(get_local 0) (then (get_local 1)) (else (return (i32.const 4)))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "as-select-first") (param i32 i32) (result i32)
|
||||||
|
(select (return (i32.const 5)) (get_local 0) (get_local 1))
|
||||||
|
)
|
||||||
|
(func (export "as-select-second") (param i32 i32) (result i32)
|
||||||
|
(select (get_local 0) (return (i32.const 6)) (get_local 1))
|
||||||
|
)
|
||||||
|
(func (export "as-select-cond") (result i32)
|
||||||
|
(select (i32.const 0) (i32.const 1) (return (i32.const 7)))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func $f (param i32 i32 i32) (result i32) (i32.const -1))
|
||||||
|
(func (export "as-call-first") (result i32)
|
||||||
|
(call $f (return (i32.const 12)) (i32.const 2) (i32.const 3))
|
||||||
|
)
|
||||||
|
(func (export "as-call-mid") (result i32)
|
||||||
|
(call $f (i32.const 1) (return (i32.const 13)) (i32.const 3))
|
||||||
|
)
|
||||||
|
(func (export "as-call-last") (result i32)
|
||||||
|
(call $f (i32.const 1) (i32.const 2) (return (i32.const 14)))
|
||||||
|
)
|
||||||
|
|
||||||
|
(type $sig (func (param i32 i32 i32) (result i32)))
|
||||||
|
(table anyfunc (elem $f))
|
||||||
|
(func (export "as-call_indirect-func") (result i32)
|
||||||
|
(call_indirect (type $sig)
|
||||||
|
(return (i32.const 20)) (i32.const 1) (i32.const 2) (i32.const 3)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(func (export "as-call_indirect-first") (result i32)
|
||||||
|
(call_indirect (type $sig)
|
||||||
|
(i32.const 0) (return (i32.const 21)) (i32.const 2) (i32.const 3)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(func (export "as-call_indirect-mid") (result i32)
|
||||||
|
(call_indirect (type $sig)
|
||||||
|
(i32.const 0) (i32.const 1) (return (i32.const 22)) (i32.const 3)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(func (export "as-call_indirect-last") (result i32)
|
||||||
|
(call_indirect (type $sig)
|
||||||
|
(i32.const 0) (i32.const 1) (i32.const 2) (return (i32.const 23))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "as-set_local-value") (result i32) (local f32)
|
||||||
|
(set_local 0 (return (i32.const 17))) (i32.const -1)
|
||||||
|
)
|
||||||
|
|
||||||
|
(memory 1)
|
||||||
|
(func (export "as-load-address") (result f32)
|
||||||
|
(f32.load (return (f32.const 1.7)))
|
||||||
|
)
|
||||||
|
(func (export "as-loadN-address") (result i64)
|
||||||
|
(i64.load8_s (return (i64.const 30)))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "as-store-address") (result i32)
|
||||||
|
(f64.store (return (i32.const 30)) (f64.const 7)) (i32.const -1)
|
||||||
|
)
|
||||||
|
(func (export "as-store-value") (result i32)
|
||||||
|
(i64.store (i32.const 2) (return (i32.const 31))) (i32.const -1)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "as-storeN-address") (result i32)
|
||||||
|
(i32.store8 (return (i32.const 32)) (i32.const 7)) (i32.const -1)
|
||||||
|
)
|
||||||
|
(func (export "as-storeN-value") (result i32)
|
||||||
|
(i64.store16 (i32.const 2) (return (i32.const 33))) (i32.const -1)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "as-unary-operand") (result f32)
|
||||||
|
(f32.neg (return (f32.const 3.4)))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "as-binary-left") (result i32)
|
||||||
|
(i32.add (return (i32.const 3)) (i32.const 10))
|
||||||
|
)
|
||||||
|
(func (export "as-binary-right") (result i64)
|
||||||
|
(i64.sub (i64.const 10) (return (i64.const 45)))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "as-test-operand") (result i32)
|
||||||
|
(i32.eqz (return (i32.const 44)))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "as-compare-left") (result i32)
|
||||||
|
(f64.le (return (i32.const 43)) (f64.const 10))
|
||||||
|
)
|
||||||
|
(func (export "as-compare-right") (result i32)
|
||||||
|
(f32.ne (f32.const 10) (return (i32.const 42)))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "as-convert-operand") (result i32)
|
||||||
|
(i32.wrap/i64 (return (i32.const 41)))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "as-memory.grow-size") (result i32)
|
||||||
|
(memory.grow (return (i32.const 40)))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke "type-i32"))
|
||||||
|
(assert_return (invoke "type-i64"))
|
||||||
|
(assert_return (invoke "type-f32"))
|
||||||
|
(assert_return (invoke "type-f64"))
|
||||||
|
|
||||||
|
(assert_return (invoke "nullary"))
|
||||||
|
(assert_return (invoke "unary") (f64.const 3))
|
||||||
|
|
||||||
|
(assert_return (invoke "as-func-first") (i32.const 1))
|
||||||
|
(assert_return (invoke "as-func-mid") (i32.const 2))
|
||||||
|
(assert_return (invoke "as-func-last"))
|
||||||
|
(assert_return (invoke "as-func-value") (i32.const 3))
|
||||||
|
|
||||||
|
(assert_return (invoke "as-block-first"))
|
||||||
|
(assert_return (invoke "as-block-mid"))
|
||||||
|
(assert_return (invoke "as-block-last"))
|
||||||
|
(assert_return (invoke "as-block-value") (i32.const 2))
|
||||||
|
|
||||||
|
(assert_return (invoke "as-loop-first") (i32.const 3))
|
||||||
|
(assert_return (invoke "as-loop-mid") (i32.const 4))
|
||||||
|
(assert_return (invoke "as-loop-last") (i32.const 5))
|
||||||
|
|
||||||
|
(assert_return (invoke "as-br-value") (i32.const 9))
|
||||||
|
|
||||||
|
(assert_return (invoke "as-br_if-cond"))
|
||||||
|
(assert_return (invoke "as-br_if-value") (i32.const 8))
|
||||||
|
(assert_return (invoke "as-br_if-value-cond") (i32.const 9))
|
||||||
|
|
||||||
|
(assert_return (invoke "as-br_table-index") (i64.const 9))
|
||||||
|
(assert_return (invoke "as-br_table-value") (i32.const 10))
|
||||||
|
(assert_return (invoke "as-br_table-value-index") (i32.const 11))
|
||||||
|
|
||||||
|
(assert_return (invoke "as-return-value") (i64.const 7))
|
||||||
|
|
||||||
|
(assert_return (invoke "as-if-cond") (i32.const 2))
|
||||||
|
(assert_return (invoke "as-if-then" (i32.const 1) (i32.const 6)) (i32.const 3))
|
||||||
|
(assert_return (invoke "as-if-then" (i32.const 0) (i32.const 6)) (i32.const 6))
|
||||||
|
(assert_return (invoke "as-if-else" (i32.const 0) (i32.const 6)) (i32.const 4))
|
||||||
|
(assert_return (invoke "as-if-else" (i32.const 1) (i32.const 6)) (i32.const 6))
|
||||||
|
|
||||||
|
(assert_return (invoke "as-select-first" (i32.const 0) (i32.const 6)) (i32.const 5))
|
||||||
|
(assert_return (invoke "as-select-first" (i32.const 1) (i32.const 6)) (i32.const 5))
|
||||||
|
(assert_return (invoke "as-select-second" (i32.const 0) (i32.const 6)) (i32.const 6))
|
||||||
|
(assert_return (invoke "as-select-second" (i32.const 1) (i32.const 6)) (i32.const 6))
|
||||||
|
(assert_return (invoke "as-select-cond") (i32.const 7))
|
||||||
|
|
||||||
|
(assert_return (invoke "as-call-first") (i32.const 12))
|
||||||
|
(assert_return (invoke "as-call-mid") (i32.const 13))
|
||||||
|
(assert_return (invoke "as-call-last") (i32.const 14))
|
||||||
|
|
||||||
|
(assert_return (invoke "as-call_indirect-func") (i32.const 20))
|
||||||
|
(assert_return (invoke "as-call_indirect-first") (i32.const 21))
|
||||||
|
(assert_return (invoke "as-call_indirect-mid") (i32.const 22))
|
||||||
|
(assert_return (invoke "as-call_indirect-last") (i32.const 23))
|
||||||
|
|
||||||
|
(assert_return (invoke "as-set_local-value") (i32.const 17))
|
||||||
|
|
||||||
|
(assert_return (invoke "as-load-address") (f32.const 1.7))
|
||||||
|
(assert_return (invoke "as-loadN-address") (i64.const 30))
|
||||||
|
|
||||||
|
(assert_return (invoke "as-store-address") (i32.const 30))
|
||||||
|
(assert_return (invoke "as-store-value") (i32.const 31))
|
||||||
|
(assert_return (invoke "as-storeN-address") (i32.const 32))
|
||||||
|
(assert_return (invoke "as-storeN-value") (i32.const 33))
|
||||||
|
|
||||||
|
(assert_return (invoke "as-unary-operand") (f32.const 3.4))
|
||||||
|
|
||||||
|
(assert_return (invoke "as-binary-left") (i32.const 3))
|
||||||
|
(assert_return (invoke "as-binary-right") (i64.const 45))
|
||||||
|
|
||||||
|
(assert_return (invoke "as-test-operand") (i32.const 44))
|
||||||
|
|
||||||
|
(assert_return (invoke "as-compare-left") (i32.const 43))
|
||||||
|
(assert_return (invoke "as-compare-right") (i32.const 42))
|
||||||
|
|
||||||
|
(assert_return (invoke "as-convert-operand") (i32.const 41))
|
||||||
|
|
||||||
|
(assert_return (invoke "as-memory.grow-size") (i32.const 40))
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-value-empty-vs-num (result f64) (return)))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-value-void-vs-num (result f64) (return (nop))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-value-num-vs-num (result f64) (return (i64.const 1))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
(module
|
||||||
|
(func (export "select_i32") (param $lhs i32) (param $rhs i32) (param $cond i32) (result i32)
|
||||||
|
(select (get_local $lhs) (get_local $rhs) (get_local $cond)))
|
||||||
|
|
||||||
|
(func (export "select_i64") (param $lhs i64) (param $rhs i64) (param $cond i32) (result i64)
|
||||||
|
(select (get_local $lhs) (get_local $rhs) (get_local $cond)))
|
||||||
|
|
||||||
|
(func (export "select_f32") (param $lhs f32) (param $rhs f32) (param $cond i32) (result f32)
|
||||||
|
(select (get_local $lhs) (get_local $rhs) (get_local $cond)))
|
||||||
|
|
||||||
|
(func (export "select_f64") (param $lhs f64) (param $rhs f64) (param $cond i32) (result f64)
|
||||||
|
(select (get_local $lhs) (get_local $rhs) (get_local $cond)))
|
||||||
|
|
||||||
|
;; Check that both sides of the select are evaluated
|
||||||
|
(func (export "select_trap_l") (param $cond i32) (result i32)
|
||||||
|
(select (unreachable) (i32.const 0) (get_local $cond))
|
||||||
|
)
|
||||||
|
(func (export "select_trap_r") (param $cond i32) (result i32)
|
||||||
|
(select (i32.const 0) (unreachable) (get_local $cond))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "select_unreached")
|
||||||
|
(unreachable) (select)
|
||||||
|
(unreachable) (i32.const 0) (select)
|
||||||
|
(unreachable) (i32.const 0) (i32.const 0) (select)
|
||||||
|
(unreachable) (f32.const 0) (i32.const 0) (select)
|
||||||
|
(unreachable)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke "select_i32" (i32.const 1) (i32.const 2) (i32.const 1)) (i32.const 1))
|
||||||
|
(assert_return (invoke "select_i64" (i64.const 2) (i64.const 1) (i32.const 1)) (i64.const 2))
|
||||||
|
(assert_return (invoke "select_f32" (f32.const 1) (f32.const 2) (i32.const 1)) (f32.const 1))
|
||||||
|
(assert_return (invoke "select_f64" (f64.const 1) (f64.const 2) (i32.const 1)) (f64.const 1))
|
||||||
|
|
||||||
|
(assert_return (invoke "select_i32" (i32.const 1) (i32.const 2) (i32.const 0)) (i32.const 2))
|
||||||
|
(assert_return (invoke "select_i32" (i32.const 2) (i32.const 1) (i32.const 0)) (i32.const 1))
|
||||||
|
(assert_return (invoke "select_i64" (i64.const 2) (i64.const 1) (i32.const -1)) (i64.const 2))
|
||||||
|
(assert_return (invoke "select_i64" (i64.const 2) (i64.const 1) (i32.const 0xf0f0f0f0)) (i64.const 2))
|
||||||
|
|
||||||
|
(assert_return (invoke "select_f32" (f32.const nan) (f32.const 1) (i32.const 1)) (f32.const nan))
|
||||||
|
(assert_return (invoke "select_f32" (f32.const nan:0x20304) (f32.const 1) (i32.const 1)) (f32.const nan:0x20304))
|
||||||
|
(assert_return (invoke "select_f32" (f32.const nan) (f32.const 1) (i32.const 0)) (f32.const 1))
|
||||||
|
(assert_return (invoke "select_f32" (f32.const nan:0x20304) (f32.const 1) (i32.const 0)) (f32.const 1))
|
||||||
|
(assert_return (invoke "select_f32" (f32.const 2) (f32.const nan) (i32.const 1)) (f32.const 2))
|
||||||
|
(assert_return (invoke "select_f32" (f32.const 2) (f32.const nan:0x20304) (i32.const 1)) (f32.const 2))
|
||||||
|
(assert_return (invoke "select_f32" (f32.const 2) (f32.const nan) (i32.const 0)) (f32.const nan))
|
||||||
|
(assert_return (invoke "select_f32" (f32.const 2) (f32.const nan:0x20304) (i32.const 0)) (f32.const nan:0x20304))
|
||||||
|
|
||||||
|
(assert_return (invoke "select_f64" (f64.const nan) (f64.const 1) (i32.const 1)) (f64.const nan))
|
||||||
|
(assert_return (invoke "select_f64" (f64.const nan:0x20304) (f64.const 1) (i32.const 1)) (f64.const nan:0x20304))
|
||||||
|
(assert_return (invoke "select_f64" (f64.const nan) (f64.const 1) (i32.const 0)) (f64.const 1))
|
||||||
|
(assert_return (invoke "select_f64" (f64.const nan:0x20304) (f64.const 1) (i32.const 0)) (f64.const 1))
|
||||||
|
(assert_return (invoke "select_f64" (f64.const 2) (f64.const nan) (i32.const 1)) (f64.const 2))
|
||||||
|
(assert_return (invoke "select_f64" (f64.const 2) (f64.const nan:0x20304) (i32.const 1)) (f64.const 2))
|
||||||
|
(assert_return (invoke "select_f64" (f64.const 2) (f64.const nan) (i32.const 0)) (f64.const nan))
|
||||||
|
(assert_return (invoke "select_f64" (f64.const 2) (f64.const nan:0x20304) (i32.const 0)) (f64.const nan:0x20304))
|
||||||
|
|
||||||
|
(assert_trap (invoke "select_trap_l" (i32.const 1)) "unreachable executed")
|
||||||
|
(assert_trap (invoke "select_trap_l" (i32.const 0)) "unreachable executed")
|
||||||
|
(assert_trap (invoke "select_trap_r" (i32.const 1)) "unreachable executed")
|
||||||
|
(assert_trap (invoke "select_trap_r" (i32.const 0)) "unreachable executed")
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $arity-0 (select (nop) (nop) (i32.const 1))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
@@ -0,0 +1,205 @@
|
|||||||
|
;; Test `set_local` operator
|
||||||
|
|
||||||
|
(module
|
||||||
|
;; Typing
|
||||||
|
|
||||||
|
(func (export "type-local-i32") (local i32) (set_local 0 (i32.const 0)))
|
||||||
|
(func (export "type-local-i64") (local i64) (set_local 0 (i64.const 0)))
|
||||||
|
(func (export "type-local-f32") (local f32) (set_local 0 (f32.const 0)))
|
||||||
|
(func (export "type-local-f64") (local f64) (set_local 0 (f64.const 0)))
|
||||||
|
|
||||||
|
(func (export "type-param-i32") (param i32) (set_local 0 (i32.const 10)))
|
||||||
|
(func (export "type-param-i64") (param i64) (set_local 0 (i64.const 11)))
|
||||||
|
(func (export "type-param-f32") (param f32) (set_local 0 (f32.const 11.1)))
|
||||||
|
(func (export "type-param-f64") (param f64) (set_local 0 (f64.const 12.2)))
|
||||||
|
|
||||||
|
(func (export "type-mixed") (param i64 f32 f64 i32 i32) (local f32 i64 i64 f64)
|
||||||
|
(set_local 0 (i64.const 0))
|
||||||
|
(set_local 1 (f32.const 0))
|
||||||
|
(set_local 2 (f64.const 0))
|
||||||
|
(set_local 3 (i32.const 0))
|
||||||
|
(set_local 4 (i32.const 0))
|
||||||
|
(set_local 5 (f32.const 0))
|
||||||
|
(set_local 6 (i64.const 0))
|
||||||
|
(set_local 7 (i64.const 0))
|
||||||
|
(set_local 8 (f64.const 0))
|
||||||
|
)
|
||||||
|
|
||||||
|
;; Writing
|
||||||
|
|
||||||
|
(func (export "write") (param i64 f32 f64 i32 i32) (result i64)
|
||||||
|
(local f32 i64 i64 f64)
|
||||||
|
(set_local 1 (f32.const -0.3))
|
||||||
|
(set_local 3 (i32.const 40))
|
||||||
|
(set_local 4 (i32.const -7))
|
||||||
|
(set_local 5 (f32.const 5.5))
|
||||||
|
(set_local 6 (i64.const 6))
|
||||||
|
(set_local 8 (f64.const 8))
|
||||||
|
(i64.trunc_s/f64
|
||||||
|
(f64.add
|
||||||
|
(f64.convert_u/i64 (get_local 0))
|
||||||
|
(f64.add
|
||||||
|
(f64.promote/f32 (get_local 1))
|
||||||
|
(f64.add
|
||||||
|
(get_local 2)
|
||||||
|
(f64.add
|
||||||
|
(f64.convert_u/i32 (get_local 3))
|
||||||
|
(f64.add
|
||||||
|
(f64.convert_s/i32 (get_local 4))
|
||||||
|
(f64.add
|
||||||
|
(f64.promote/f32 (get_local 5))
|
||||||
|
(f64.add
|
||||||
|
(f64.convert_u/i64 (get_local 6))
|
||||||
|
(f64.add
|
||||||
|
(f64.convert_u/i64 (get_local 7))
|
||||||
|
(get_local 8)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke "type-local-i32"))
|
||||||
|
(assert_return (invoke "type-local-i64"))
|
||||||
|
(assert_return (invoke "type-local-f32"))
|
||||||
|
(assert_return (invoke "type-local-f64"))
|
||||||
|
|
||||||
|
(assert_return (invoke "type-param-i32" (i32.const 2)))
|
||||||
|
(assert_return (invoke "type-param-i64" (i64.const 3)))
|
||||||
|
(assert_return (invoke "type-param-f32" (f32.const 4.4)))
|
||||||
|
(assert_return (invoke "type-param-f64" (f64.const 5.5)))
|
||||||
|
|
||||||
|
(assert_return
|
||||||
|
(invoke "type-mixed"
|
||||||
|
(i64.const 1) (f32.const 2.2) (f64.const 3.3) (i32.const 4) (i32.const 5)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return
|
||||||
|
(invoke "write"
|
||||||
|
(i64.const 1) (f32.const 2) (f64.const 3.3) (i32.const 4) (i32.const 5)
|
||||||
|
)
|
||||||
|
(i64.const 56)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
;; Invalid typing of access to locals
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-local-num-vs-num (result i64) (local i32)
|
||||||
|
(set_local 0 (i32.const 0))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-local-num-vs-num (local f32)
|
||||||
|
(i32.eqz (set_local 0 (f32.const 0)))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-local-num-vs-num (local f64 i64)
|
||||||
|
(f64.neg (set_local 1 (i64.const 0)))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-local-arg-void-vs-num (local i32) (set_local 0 (nop))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-local-arg-num-vs-num (local i32) (set_local 0 (f32.const 0))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-local-arg-num-vs-num (local f32) (set_local 0 (f64.const 0))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-local-arg-num-vs-num (local f64 i64) (set_local 1 (f64.const 0))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
;; Invalid typing of access to parameters
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-param-num-vs-num (param i32) (result i64) (get_local 0)))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-param-num-vs-num (param f32) (i32.eqz (get_local 0))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-param-num-vs-num (param f64 i64) (f64.neg (get_local 1))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-param-arg-void-vs-num (param i32) (set_local 0 (nop))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-param-arg-num-vs-num (param i32) (set_local 0 (f32.const 0))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-param-arg-num-vs-num (param f32) (set_local 0 (f64.const 0))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-param-arg-num-vs-num (param f64 i64) (set_local 1 (f64.const 0))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
;; Invalid local index
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $unbound-local (local i32 i64) (get_local 3)))
|
||||||
|
"unknown local"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $large-local (local i32 i64) (get_local 14324343)))
|
||||||
|
"unknown local"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $unbound-param (param i32 i64) (get_local 2)))
|
||||||
|
"unknown local"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $large-param (local i32 i64) (get_local 714324343)))
|
||||||
|
"unknown local"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $unbound-mixed (param i32) (local i32 i64) (get_local 3)))
|
||||||
|
"unknown local"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $large-mixed (param i64) (local i32 i64) (get_local 214324343)))
|
||||||
|
"unknown local"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-mixed-arg-num-vs-num (param f32) (local i32) (set_local 1 (f32.const 0))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-mixed-arg-num-vs-num (param i64 i32) (local f32) (set_local 1 (f32.const 0))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-mixed-arg-num-vs-num (param i64) (local f64 i64) (set_local 1 (i64.const 0))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,220 @@
|
|||||||
|
(module
|
||||||
|
(func (export "fac-expr") (param $n i64) (result i64)
|
||||||
|
(local $i i64)
|
||||||
|
(local $res i64)
|
||||||
|
(set_local $i (get_local $n))
|
||||||
|
(set_local $res (i64.const 1))
|
||||||
|
(block $done
|
||||||
|
(loop $loop
|
||||||
|
(if
|
||||||
|
(i64.eq (get_local $i) (i64.const 0))
|
||||||
|
(then (br $done))
|
||||||
|
(else
|
||||||
|
(set_local $res (i64.mul (get_local $i) (get_local $res)))
|
||||||
|
(set_local $i (i64.sub (get_local $i) (i64.const 1)))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(br $loop)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(get_local $res)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "fac-stack") (param $n i64) (result i64)
|
||||||
|
(local $i i64)
|
||||||
|
(local $res i64)
|
||||||
|
(get_local $n)
|
||||||
|
(set_local $i)
|
||||||
|
(i64.const 1)
|
||||||
|
(set_local $res)
|
||||||
|
(block $done
|
||||||
|
(loop $loop
|
||||||
|
(get_local $i)
|
||||||
|
(i64.const 0)
|
||||||
|
(i64.eq)
|
||||||
|
(if
|
||||||
|
(then (br $done))
|
||||||
|
(else
|
||||||
|
(get_local $i)
|
||||||
|
(get_local $res)
|
||||||
|
(i64.mul)
|
||||||
|
(set_local $res)
|
||||||
|
(get_local $i)
|
||||||
|
(i64.const 1)
|
||||||
|
(i64.sub)
|
||||||
|
(set_local $i)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(br $loop)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(get_local $res)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "fac-stack-raw") (param $n i64) (result i64)
|
||||||
|
(local $i i64)
|
||||||
|
(local $res i64)
|
||||||
|
get_local $n
|
||||||
|
set_local $i
|
||||||
|
i64.const 1
|
||||||
|
set_local $res
|
||||||
|
block $done
|
||||||
|
loop $loop
|
||||||
|
get_local $i
|
||||||
|
i64.const 0
|
||||||
|
i64.eq
|
||||||
|
if $body
|
||||||
|
br $done
|
||||||
|
else $body
|
||||||
|
get_local $i
|
||||||
|
get_local $res
|
||||||
|
i64.mul
|
||||||
|
set_local $res
|
||||||
|
get_local $i
|
||||||
|
i64.const 1
|
||||||
|
i64.sub
|
||||||
|
set_local $i
|
||||||
|
end $body
|
||||||
|
br $loop
|
||||||
|
end $loop
|
||||||
|
end $done
|
||||||
|
get_local $res
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "fac-mixed") (param $n i64) (result i64)
|
||||||
|
(local $i i64)
|
||||||
|
(local $res i64)
|
||||||
|
(set_local $i (get_local $n))
|
||||||
|
(set_local $res (i64.const 1))
|
||||||
|
(block $done
|
||||||
|
(loop $loop
|
||||||
|
(i64.eq (get_local $i) (i64.const 0))
|
||||||
|
(if
|
||||||
|
(then (br $done))
|
||||||
|
(else
|
||||||
|
(i64.mul (get_local $i) (get_local $res))
|
||||||
|
(set_local $res)
|
||||||
|
(i64.sub (get_local $i) (i64.const 1))
|
||||||
|
(set_local $i)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(br $loop)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(get_local $res)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "fac-mixed-raw") (param $n i64) (result i64)
|
||||||
|
(local $i i64)
|
||||||
|
(local $res i64)
|
||||||
|
(set_local $i (get_local $n))
|
||||||
|
(set_local $res (i64.const 1))
|
||||||
|
block $done
|
||||||
|
loop $loop
|
||||||
|
(i64.eq (get_local $i) (i64.const 0))
|
||||||
|
if
|
||||||
|
br $done
|
||||||
|
else
|
||||||
|
(i64.mul (get_local $i) (get_local $res))
|
||||||
|
set_local $res
|
||||||
|
(i64.sub (get_local $i) (i64.const 1))
|
||||||
|
set_local $i
|
||||||
|
end
|
||||||
|
br $loop
|
||||||
|
end
|
||||||
|
end
|
||||||
|
get_local $res
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke "fac-expr" (i64.const 25)) (i64.const 7034535277573963776))
|
||||||
|
(assert_return (invoke "fac-stack" (i64.const 25)) (i64.const 7034535277573963776))
|
||||||
|
(assert_return (invoke "fac-mixed" (i64.const 25)) (i64.const 7034535277573963776))
|
||||||
|
|
||||||
|
|
||||||
|
;; Syntax of flat call_indirect
|
||||||
|
|
||||||
|
(module
|
||||||
|
(type $proc (func))
|
||||||
|
(table 1 anyfunc)
|
||||||
|
|
||||||
|
(func
|
||||||
|
(block i32.const 0 call_indirect)
|
||||||
|
(loop i32.const 0 call_indirect)
|
||||||
|
(if (i32.const 0) (then i32.const 0 call_indirect))
|
||||||
|
(if (i32.const 0)
|
||||||
|
(then i32.const 0 call_indirect)
|
||||||
|
(else i32.const 0 call_indirect)
|
||||||
|
)
|
||||||
|
(block i32.const 0 call_indirect (type $proc))
|
||||||
|
(loop i32.const 0 call_indirect (type $proc))
|
||||||
|
(if (i32.const 0) (then i32.const 0 call_indirect (type $proc)))
|
||||||
|
(if (i32.const 0)
|
||||||
|
(then i32.const 0 call_indirect (type $proc))
|
||||||
|
(else i32.const 0 call_indirect (type $proc))
|
||||||
|
)
|
||||||
|
(block i32.const 0 i32.const 0 call_indirect (param i32))
|
||||||
|
(loop i32.const 0 i32.const 0 call_indirect (param i32))
|
||||||
|
(if (i32.const 0) (then i32.const 0 i32.const 0 call_indirect (param i32)))
|
||||||
|
(if (i32.const 0)
|
||||||
|
(then i32.const 0 i32.const 0 call_indirect (param i32))
|
||||||
|
(else i32.const 0 i32.const 0 call_indirect (param i32))
|
||||||
|
)
|
||||||
|
(block (result i32) i32.const 0 call_indirect (result i32)) (drop)
|
||||||
|
(loop (result i32) i32.const 0 call_indirect (result i32)) (drop)
|
||||||
|
(if (result i32) (i32.const 0)
|
||||||
|
(then i32.const 0 call_indirect (result i32))
|
||||||
|
(else i32.const 0 call_indirect (result i32))
|
||||||
|
) (drop)
|
||||||
|
(block i32.const 0 call_indirect (type $proc) (param) (result))
|
||||||
|
(loop i32.const 0 call_indirect (type $proc) (param) (result))
|
||||||
|
(if (i32.const 0)
|
||||||
|
(then i32.const 0 call_indirect (type $proc) (param) (result))
|
||||||
|
)
|
||||||
|
(if (i32.const 0)
|
||||||
|
(then i32.const 0 call_indirect (type $proc) (param) (param) (result))
|
||||||
|
(else i32.const 0 call_indirect (type $proc) (param) (result) (result))
|
||||||
|
)
|
||||||
|
|
||||||
|
block i32.const 0 call_indirect end
|
||||||
|
loop i32.const 0 call_indirect end
|
||||||
|
i32.const 0 if i32.const 0 call_indirect end
|
||||||
|
i32.const 0 if i32.const 0 call_indirect else i32.const 0 call_indirect end
|
||||||
|
block i32.const 0 call_indirect (type $proc) end
|
||||||
|
loop i32.const 0 call_indirect (type $proc) end
|
||||||
|
i32.const 0 if i32.const 0 call_indirect (type $proc) end
|
||||||
|
i32.const 0
|
||||||
|
if
|
||||||
|
i32.const 0 call_indirect (type $proc)
|
||||||
|
else
|
||||||
|
i32.const 0 call_indirect (type $proc)
|
||||||
|
end
|
||||||
|
block i32.const 0 i32.const 0 call_indirect (param i32) end
|
||||||
|
loop i32.const 0 i32.const 0 call_indirect (param i32) end
|
||||||
|
i32.const 0 if i32.const 0 i32.const 0 call_indirect (param i32) end
|
||||||
|
i32.const 0
|
||||||
|
if
|
||||||
|
i32.const 0 i32.const 0 call_indirect (param i32)
|
||||||
|
else
|
||||||
|
i32.const 0 i32.const 0 call_indirect (param i32)
|
||||||
|
end
|
||||||
|
block (result i32) i32.const 0 call_indirect (result i32) end drop
|
||||||
|
loop (result i32) i32.const 0 call_indirect (result i32) end drop
|
||||||
|
i32.const 0
|
||||||
|
if (result i32)
|
||||||
|
i32.const 0 call_indirect (result i32)
|
||||||
|
else
|
||||||
|
i32.const 0 call_indirect (result i32)
|
||||||
|
end drop
|
||||||
|
block i32.const 0 call_indirect (type $proc) (param) (result) end
|
||||||
|
loop i32.const 0 call_indirect (type $proc) (param) (result) end
|
||||||
|
i32.const 0 if i32.const 0 call_indirect (type $proc) (param) (result) end
|
||||||
|
i32.const 0
|
||||||
|
if
|
||||||
|
i32.const 0 call_indirect (type $proc) (param) (result)
|
||||||
|
else
|
||||||
|
i32.const 0 call_indirect (type $proc) (param) (param) (result) (result)
|
||||||
|
end
|
||||||
|
i32.const 0 call_indirect
|
||||||
|
)
|
||||||
|
)
|
||||||
@@ -0,0 +1,100 @@
|
|||||||
|
(assert_invalid
|
||||||
|
(module (func) (start 1))
|
||||||
|
"unknown function"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module
|
||||||
|
(func $main (result i32) (return (i32.const 0)))
|
||||||
|
(start $main)
|
||||||
|
)
|
||||||
|
"start function"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module
|
||||||
|
(func $main (param $a i32))
|
||||||
|
(start $main)
|
||||||
|
)
|
||||||
|
"start function"
|
||||||
|
)
|
||||||
|
|
||||||
|
(module
|
||||||
|
(memory (data "A"))
|
||||||
|
(func $inc
|
||||||
|
(i32.store8
|
||||||
|
(i32.const 0)
|
||||||
|
(i32.add
|
||||||
|
(i32.load8_u (i32.const 0))
|
||||||
|
(i32.const 1)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(func $get (result i32)
|
||||||
|
(return (i32.load8_u (i32.const 0)))
|
||||||
|
)
|
||||||
|
(func $main
|
||||||
|
(call $inc)
|
||||||
|
(call $inc)
|
||||||
|
(call $inc)
|
||||||
|
)
|
||||||
|
|
||||||
|
(start $main)
|
||||||
|
(export "inc" (func $inc))
|
||||||
|
(export "get" (func $get))
|
||||||
|
)
|
||||||
|
(assert_return (invoke "get") (i32.const 68))
|
||||||
|
(invoke "inc")
|
||||||
|
(assert_return (invoke "get") (i32.const 69))
|
||||||
|
(invoke "inc")
|
||||||
|
(assert_return (invoke "get") (i32.const 70))
|
||||||
|
|
||||||
|
(module
|
||||||
|
(memory (data "A"))
|
||||||
|
(func $inc
|
||||||
|
(i32.store8
|
||||||
|
(i32.const 0)
|
||||||
|
(i32.add
|
||||||
|
(i32.load8_u (i32.const 0))
|
||||||
|
(i32.const 1)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(func $get (result i32)
|
||||||
|
(return (i32.load8_u (i32.const 0)))
|
||||||
|
)
|
||||||
|
(func $main
|
||||||
|
(call $inc)
|
||||||
|
(call $inc)
|
||||||
|
(call $inc)
|
||||||
|
)
|
||||||
|
(start 2)
|
||||||
|
(export "inc" (func $inc))
|
||||||
|
(export "get" (func $get))
|
||||||
|
)
|
||||||
|
(assert_return (invoke "get") (i32.const 68))
|
||||||
|
(invoke "inc")
|
||||||
|
(assert_return (invoke "get") (i32.const 69))
|
||||||
|
(invoke "inc")
|
||||||
|
(assert_return (invoke "get") (i32.const 70))
|
||||||
|
|
||||||
|
(module
|
||||||
|
(func $print_i32 (import "spectest" "print_i32") (param i32))
|
||||||
|
(func $main (call $print_i32 (i32.const 1)))
|
||||||
|
(start 1)
|
||||||
|
)
|
||||||
|
|
||||||
|
(module
|
||||||
|
(func $print_i32 (import "spectest" "print_i32") (param i32))
|
||||||
|
(func $main (call $print_i32 (i32.const 2)))
|
||||||
|
(start $main)
|
||||||
|
)
|
||||||
|
|
||||||
|
(module
|
||||||
|
(func $print (import "spectest" "print"))
|
||||||
|
(start $print)
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_trap
|
||||||
|
(module (func $main (unreachable)) (start $main))
|
||||||
|
"unreachable"
|
||||||
|
)
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
(assert_invalid
|
||||||
|
(module (func (param i32) (result i32) (set_local 0 (i32.const 1))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func (param i64) (result i64) (set_local 0 (i64.const 1))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func (param f32) (result f32) (set_local 0 (f32.const 1))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func (param f64) (result f64) (set_local 0 (f64.const 1))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (memory 1) (func (param i32) (result i32) (i32.store (i32.const 0) (i32.const 1))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (memory 1) (func (param i64) (result i64) (i64.store (i32.const 0) (i64.const 1))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (memory 1) (func (param f32) (result f32) (f32.store (i32.const 0) (f32.const 1))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (memory 1) (func (param f64) (result f64) (f64.store (i32.const 0) (f64.const 1))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (memory 1) (func (param i32) (result i32) (i32.store8 (i32.const 0) (i32.const 1))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (memory 1) (func (param i32) (result i32) (i32.store16 (i32.const 0) (i32.const 1))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (memory 1) (func (param i64) (result i64) (i64.store8 (i32.const 0) (i64.const 1))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (memory 1) (func (param i64) (result i64) (i64.store16 (i32.const 0) (i64.const 1))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (memory 1) (func (param i64) (result i64) (i64.store32 (i32.const 0) (i64.const 1))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
@@ -0,0 +1,150 @@
|
|||||||
|
(module
|
||||||
|
;; Statement switch
|
||||||
|
(func (export "stmt") (param $i i32) (result i32)
|
||||||
|
(local $j i32)
|
||||||
|
(set_local $j (i32.const 100))
|
||||||
|
(block $switch
|
||||||
|
(block $7
|
||||||
|
(block $default
|
||||||
|
(block $6
|
||||||
|
(block $5
|
||||||
|
(block $4
|
||||||
|
(block $3
|
||||||
|
(block $2
|
||||||
|
(block $1
|
||||||
|
(block $0
|
||||||
|
(br_table $0 $1 $2 $3 $4 $5 $6 $7 $default
|
||||||
|
(get_local $i)
|
||||||
|
)
|
||||||
|
) ;; 0
|
||||||
|
(return (get_local $i))
|
||||||
|
) ;; 1
|
||||||
|
(nop)
|
||||||
|
;; fallthrough
|
||||||
|
) ;; 2
|
||||||
|
;; fallthrough
|
||||||
|
) ;; 3
|
||||||
|
(set_local $j (i32.sub (i32.const 0) (get_local $i)))
|
||||||
|
(br $switch)
|
||||||
|
) ;; 4
|
||||||
|
(br $switch)
|
||||||
|
) ;; 5
|
||||||
|
(set_local $j (i32.const 101))
|
||||||
|
(br $switch)
|
||||||
|
) ;; 6
|
||||||
|
(set_local $j (i32.const 101))
|
||||||
|
;; fallthrough
|
||||||
|
) ;; default
|
||||||
|
(set_local $j (i32.const 102))
|
||||||
|
) ;; 7
|
||||||
|
;; fallthrough
|
||||||
|
)
|
||||||
|
(return (get_local $j))
|
||||||
|
)
|
||||||
|
|
||||||
|
;; Expression switch
|
||||||
|
(func (export "expr") (param $i i64) (result i64)
|
||||||
|
(local $j i64)
|
||||||
|
(set_local $j (i64.const 100))
|
||||||
|
(return
|
||||||
|
(block $switch (result i64)
|
||||||
|
(block $7
|
||||||
|
(block $default
|
||||||
|
(block $4
|
||||||
|
(block $5
|
||||||
|
(block $6
|
||||||
|
(block $3
|
||||||
|
(block $2
|
||||||
|
(block $1
|
||||||
|
(block $0
|
||||||
|
(br_table $0 $1 $2 $3 $4 $5 $6 $7 $default
|
||||||
|
(i32.wrap/i64 (get_local $i))
|
||||||
|
)
|
||||||
|
) ;; 0
|
||||||
|
(return (get_local $i))
|
||||||
|
) ;; 1
|
||||||
|
(nop)
|
||||||
|
;; fallthrough
|
||||||
|
) ;; 2
|
||||||
|
;; fallthrough
|
||||||
|
) ;; 3
|
||||||
|
(br $switch (i64.sub (i64.const 0) (get_local $i)))
|
||||||
|
) ;; 6
|
||||||
|
(set_local $j (i64.const 101))
|
||||||
|
;; fallthrough
|
||||||
|
) ;; 4
|
||||||
|
;; fallthrough
|
||||||
|
) ;; 5
|
||||||
|
;; fallthrough
|
||||||
|
) ;; default
|
||||||
|
(br $switch (get_local $j))
|
||||||
|
) ;; 7
|
||||||
|
(i64.const -5)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
;; Argument switch
|
||||||
|
(func (export "arg") (param $i i32) (result i32)
|
||||||
|
(return
|
||||||
|
(block $2 (result i32)
|
||||||
|
(i32.add (i32.const 10)
|
||||||
|
(block $1 (result i32)
|
||||||
|
(i32.add (i32.const 100)
|
||||||
|
(block $0 (result i32)
|
||||||
|
(i32.add (i32.const 1000)
|
||||||
|
(block $default (result i32)
|
||||||
|
(br_table $0 $1 $2 $default
|
||||||
|
(i32.mul (i32.const 2) (get_local $i))
|
||||||
|
(i32.and (i32.const 3) (get_local $i))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
;; Corner cases
|
||||||
|
(func (export "corner") (result i32)
|
||||||
|
(block
|
||||||
|
(br_table 0 (i32.const 0))
|
||||||
|
)
|
||||||
|
(i32.const 1)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke "stmt" (i32.const 0)) (i32.const 0))
|
||||||
|
(assert_return (invoke "stmt" (i32.const 1)) (i32.const -1))
|
||||||
|
(assert_return (invoke "stmt" (i32.const 2)) (i32.const -2))
|
||||||
|
(assert_return (invoke "stmt" (i32.const 3)) (i32.const -3))
|
||||||
|
(assert_return (invoke "stmt" (i32.const 4)) (i32.const 100))
|
||||||
|
(assert_return (invoke "stmt" (i32.const 5)) (i32.const 101))
|
||||||
|
(assert_return (invoke "stmt" (i32.const 6)) (i32.const 102))
|
||||||
|
(assert_return (invoke "stmt" (i32.const 7)) (i32.const 100))
|
||||||
|
(assert_return (invoke "stmt" (i32.const -10)) (i32.const 102))
|
||||||
|
|
||||||
|
(assert_return (invoke "expr" (i64.const 0)) (i64.const 0))
|
||||||
|
(assert_return (invoke "expr" (i64.const 1)) (i64.const -1))
|
||||||
|
(assert_return (invoke "expr" (i64.const 2)) (i64.const -2))
|
||||||
|
(assert_return (invoke "expr" (i64.const 3)) (i64.const -3))
|
||||||
|
(assert_return (invoke "expr" (i64.const 6)) (i64.const 101))
|
||||||
|
(assert_return (invoke "expr" (i64.const 7)) (i64.const -5))
|
||||||
|
(assert_return (invoke "expr" (i64.const -10)) (i64.const 100))
|
||||||
|
|
||||||
|
(assert_return (invoke "arg" (i32.const 0)) (i32.const 110))
|
||||||
|
(assert_return (invoke "arg" (i32.const 1)) (i32.const 12))
|
||||||
|
(assert_return (invoke "arg" (i32.const 2)) (i32.const 4))
|
||||||
|
(assert_return (invoke "arg" (i32.const 3)) (i32.const 1116))
|
||||||
|
(assert_return (invoke "arg" (i32.const 4)) (i32.const 118))
|
||||||
|
(assert_return (invoke "arg" (i32.const 5)) (i32.const 20))
|
||||||
|
(assert_return (invoke "arg" (i32.const 6)) (i32.const 12))
|
||||||
|
(assert_return (invoke "arg" (i32.const 7)) (i32.const 1124))
|
||||||
|
(assert_return (invoke "arg" (i32.const 8)) (i32.const 126))
|
||||||
|
|
||||||
|
(assert_return (invoke "corner") (i32.const 1))
|
||||||
|
|
||||||
|
(assert_invalid (module (func (br_table 3 (i32.const 0)))) "unknown label")
|
||||||
@@ -0,0 +1,236 @@
|
|||||||
|
;; Test `tee_local` operator
|
||||||
|
|
||||||
|
(module
|
||||||
|
;; Typing
|
||||||
|
|
||||||
|
(func (export "type-local-i32") (result i32) (local i32) (tee_local 0 (i32.const 0)))
|
||||||
|
(func (export "type-local-i64") (result i64) (local i64) (tee_local 0 (i64.const 0)))
|
||||||
|
(func (export "type-local-f32") (result f32) (local f32) (tee_local 0 (f32.const 0)))
|
||||||
|
(func (export "type-local-f64") (result f64) (local f64) (tee_local 0 (f64.const 0)))
|
||||||
|
|
||||||
|
(func (export "type-param-i32") (param i32) (result i32) (tee_local 0 (i32.const 10)))
|
||||||
|
(func (export "type-param-i64") (param i64) (result i64) (tee_local 0 (i64.const 11)))
|
||||||
|
(func (export "type-param-f32") (param f32) (result f32) (tee_local 0 (f32.const 11.1)))
|
||||||
|
(func (export "type-param-f64") (param f64) (result f64) (tee_local 0 (f64.const 12.2)))
|
||||||
|
|
||||||
|
(func (export "type-mixed") (param i64 f32 f64 i32 i32) (local f32 i64 i64 f64)
|
||||||
|
(drop (i64.eqz (tee_local 0 (i64.const 0))))
|
||||||
|
(drop (f32.neg (tee_local 1 (f32.const 0))))
|
||||||
|
(drop (f64.neg (tee_local 2 (f64.const 0))))
|
||||||
|
(drop (i32.eqz (tee_local 3 (i32.const 0))))
|
||||||
|
(drop (i32.eqz (tee_local 4 (i32.const 0))))
|
||||||
|
(drop (f32.neg (tee_local 5 (f32.const 0))))
|
||||||
|
(drop (i64.eqz (tee_local 6 (i64.const 0))))
|
||||||
|
(drop (i64.eqz (tee_local 7 (i64.const 0))))
|
||||||
|
(drop (f64.neg (tee_local 8 (f64.const 0))))
|
||||||
|
)
|
||||||
|
|
||||||
|
;; Writing
|
||||||
|
|
||||||
|
(func (export "write") (param i64 f32 f64 i32 i32) (result i64) (local f32 i64 i64 f64)
|
||||||
|
(drop (tee_local 1 (f32.const -0.3)))
|
||||||
|
(drop (tee_local 3 (i32.const 40)))
|
||||||
|
(drop (tee_local 4 (i32.const -7)))
|
||||||
|
(drop (tee_local 5 (f32.const 5.5)))
|
||||||
|
(drop (tee_local 6 (i64.const 6)))
|
||||||
|
(drop (tee_local 8 (f64.const 8)))
|
||||||
|
(i64.trunc_s/f64
|
||||||
|
(f64.add
|
||||||
|
(f64.convert_u/i64 (get_local 0))
|
||||||
|
(f64.add
|
||||||
|
(f64.promote/f32 (get_local 1))
|
||||||
|
(f64.add
|
||||||
|
(get_local 2)
|
||||||
|
(f64.add
|
||||||
|
(f64.convert_u/i32 (get_local 3))
|
||||||
|
(f64.add
|
||||||
|
(f64.convert_s/i32 (get_local 4))
|
||||||
|
(f64.add
|
||||||
|
(f64.promote/f32 (get_local 5))
|
||||||
|
(f64.add
|
||||||
|
(f64.convert_u/i64 (get_local 6))
|
||||||
|
(f64.add
|
||||||
|
(f64.convert_u/i64 (get_local 7))
|
||||||
|
(get_local 8)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
;; Result
|
||||||
|
|
||||||
|
(func (export "result") (param i64 f32 f64 i32 i32) (result f64)
|
||||||
|
(local f32 i64 i64 f64)
|
||||||
|
(f64.add
|
||||||
|
(f64.convert_u/i64 (tee_local 0 (i64.const 1)))
|
||||||
|
(f64.add
|
||||||
|
(f64.promote/f32 (tee_local 1 (f32.const 2)))
|
||||||
|
(f64.add
|
||||||
|
(tee_local 2 (f64.const 3.3))
|
||||||
|
(f64.add
|
||||||
|
(f64.convert_u/i32 (tee_local 3 (i32.const 4)))
|
||||||
|
(f64.add
|
||||||
|
(f64.convert_s/i32 (tee_local 4 (i32.const 5)))
|
||||||
|
(f64.add
|
||||||
|
(f64.promote/f32 (tee_local 5 (f32.const 5.5)))
|
||||||
|
(f64.add
|
||||||
|
(f64.convert_u/i64 (tee_local 6 (i64.const 6)))
|
||||||
|
(f64.add
|
||||||
|
(f64.convert_u/i64 (tee_local 7 (i64.const 0)))
|
||||||
|
(tee_local 8 (f64.const 8))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return (invoke "type-local-i32") (i32.const 0))
|
||||||
|
(assert_return (invoke "type-local-i64") (i64.const 0))
|
||||||
|
(assert_return (invoke "type-local-f32") (f32.const 0))
|
||||||
|
(assert_return (invoke "type-local-f64") (f64.const 0))
|
||||||
|
|
||||||
|
(assert_return (invoke "type-param-i32" (i32.const 2)) (i32.const 10))
|
||||||
|
(assert_return (invoke "type-param-i64" (i64.const 3)) (i64.const 11))
|
||||||
|
(assert_return (invoke "type-param-f32" (f32.const 4.4)) (f32.const 11.1))
|
||||||
|
(assert_return (invoke "type-param-f64" (f64.const 5.5)) (f64.const 12.2))
|
||||||
|
|
||||||
|
(assert_return
|
||||||
|
(invoke "type-mixed"
|
||||||
|
(i64.const 1) (f32.const 2.2) (f64.const 3.3) (i32.const 4) (i32.const 5)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return
|
||||||
|
(invoke "write"
|
||||||
|
(i64.const 1) (f32.const 2) (f64.const 3.3) (i32.const 4) (i32.const 5)
|
||||||
|
)
|
||||||
|
(i64.const 56)
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_return
|
||||||
|
(invoke "result"
|
||||||
|
(i64.const -1) (f32.const -2) (f64.const -3.3) (i32.const -4) (i32.const -5)
|
||||||
|
)
|
||||||
|
(f64.const 34.8)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
;; Invalid typing of access to locals
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-local-num-vs-num (result i64) (local i32) (tee_local 0 (i32.const 0))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-local-num-vs-num (local f32) (i32.eqz (tee_local 0 (f32.const 0)))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-local-num-vs-num (local f64 i64) (f64.neg (tee_local 1 (i64.const 0)))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-local-arg-void-vs-num (local i32) (tee_local 0 (nop))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-local-arg-num-vs-num (local i32) (tee_local 0 (f32.const 0))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-local-arg-num-vs-num (local f32) (tee_local 0 (f64.const 0))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-local-arg-num-vs-num (local f64 i64) (tee_local 1 (f64.const 0))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
;; Invalid typing of access to parameters
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-param-num-vs-num (param i32) (result i64) (get_local 0)))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-param-num-vs-num (param f32) (i32.eqz (get_local 0))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-param-num-vs-num (param f64 i64) (f64.neg (get_local 1))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-param-arg-void-vs-num (param i32) (tee_local 0 (nop))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-param-arg-num-vs-num (param i32) (tee_local 0 (f32.const 0))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-param-arg-num-vs-num (param f32) (tee_local 0 (f64.const 0))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-param-arg-num-vs-num (param f64 i64) (tee_local 1 (f64.const 0))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
;; Invalid local index
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $unbound-local (local i32 i64) (get_local 3)))
|
||||||
|
"unknown local"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $large-local (local i32 i64) (get_local 14324343)))
|
||||||
|
"unknown local"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $unbound-param (param i32 i64) (get_local 2)))
|
||||||
|
"unknown local"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $large-param (local i32 i64) (get_local 714324343)))
|
||||||
|
"unknown local"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $unbound-mixed (param i32) (local i32 i64) (get_local 3)))
|
||||||
|
"unknown local"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $large-mixed (param i64) (local i32 i64) (get_local 214324343)))
|
||||||
|
"unknown local"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-mixed-arg-num-vs-num (param f32) (local i32) (tee_local 1 (f32.const 0))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-mixed-arg-num-vs-num (param i64 i32) (local f32) (tee_local 1 (f32.const 0))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-mixed-arg-num-vs-num (param i64) (local f64 i64) (tee_local 1 (i64.const 0))))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
;; Test tokenization
|
||||||
|
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(func (drop (i32.const0)))")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(func br 0drop)")
|
||||||
|
"unknown operator"
|
||||||
|
)
|
||||||
@@ -0,0 +1,91 @@
|
|||||||
|
;; Test that traps are preserved even in instructions which might otherwise
|
||||||
|
;; be dead-code-eliminated. These functions all perform an operation and
|
||||||
|
;; discard its return value.
|
||||||
|
|
||||||
|
(module
|
||||||
|
(func (export "no_dce.i32.div_s") (param $x i32) (param $y i32)
|
||||||
|
(drop (i32.div_s (get_local $x) (get_local $y))))
|
||||||
|
(func (export "no_dce.i32.div_u") (param $x i32) (param $y i32)
|
||||||
|
(drop (i32.div_u (get_local $x) (get_local $y))))
|
||||||
|
(func (export "no_dce.i64.div_s") (param $x i64) (param $y i64)
|
||||||
|
(drop (i64.div_s (get_local $x) (get_local $y))))
|
||||||
|
(func (export "no_dce.i64.div_u") (param $x i64) (param $y i64)
|
||||||
|
(drop (i64.div_u (get_local $x) (get_local $y))))
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_trap (invoke "no_dce.i32.div_s" (i32.const 1) (i32.const 0)) "integer divide by zero")
|
||||||
|
(assert_trap (invoke "no_dce.i32.div_u" (i32.const 1) (i32.const 0)) "integer divide by zero")
|
||||||
|
(assert_trap (invoke "no_dce.i64.div_s" (i64.const 1) (i64.const 0)) "integer divide by zero")
|
||||||
|
(assert_trap (invoke "no_dce.i64.div_u" (i64.const 1) (i64.const 0)) "integer divide by zero")
|
||||||
|
(assert_trap (invoke "no_dce.i32.div_s" (i32.const 0x80000000) (i32.const -1)) "integer overflow")
|
||||||
|
(assert_trap (invoke "no_dce.i64.div_s" (i64.const 0x8000000000000000) (i64.const -1)) "integer overflow")
|
||||||
|
|
||||||
|
(module
|
||||||
|
(func (export "no_dce.i32.rem_s") (param $x i32) (param $y i32)
|
||||||
|
(drop (i32.rem_s (get_local $x) (get_local $y))))
|
||||||
|
(func (export "no_dce.i32.rem_u") (param $x i32) (param $y i32)
|
||||||
|
(drop (i32.rem_u (get_local $x) (get_local $y))))
|
||||||
|
(func (export "no_dce.i64.rem_s") (param $x i64) (param $y i64)
|
||||||
|
(drop (i64.rem_s (get_local $x) (get_local $y))))
|
||||||
|
(func (export "no_dce.i64.rem_u") (param $x i64) (param $y i64)
|
||||||
|
(drop (i64.rem_u (get_local $x) (get_local $y))))
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_trap (invoke "no_dce.i32.rem_s" (i32.const 1) (i32.const 0)) "integer divide by zero")
|
||||||
|
(assert_trap (invoke "no_dce.i32.rem_u" (i32.const 1) (i32.const 0)) "integer divide by zero")
|
||||||
|
(assert_trap (invoke "no_dce.i64.rem_s" (i64.const 1) (i64.const 0)) "integer divide by zero")
|
||||||
|
(assert_trap (invoke "no_dce.i64.rem_u" (i64.const 1) (i64.const 0)) "integer divide by zero")
|
||||||
|
|
||||||
|
(module
|
||||||
|
(func (export "no_dce.i32.trunc_s_f32") (param $x f32) (drop (i32.trunc_s/f32 (get_local $x))))
|
||||||
|
(func (export "no_dce.i32.trunc_u_f32") (param $x f32) (drop (i32.trunc_u/f32 (get_local $x))))
|
||||||
|
(func (export "no_dce.i32.trunc_s_f64") (param $x f64) (drop (i32.trunc_s/f64 (get_local $x))))
|
||||||
|
(func (export "no_dce.i32.trunc_u_f64") (param $x f64) (drop (i32.trunc_u/f64 (get_local $x))))
|
||||||
|
(func (export "no_dce.i64.trunc_s_f32") (param $x f32) (drop (i64.trunc_s/f32 (get_local $x))))
|
||||||
|
(func (export "no_dce.i64.trunc_u_f32") (param $x f32) (drop (i64.trunc_u/f32 (get_local $x))))
|
||||||
|
(func (export "no_dce.i64.trunc_s_f64") (param $x f64) (drop (i64.trunc_s/f64 (get_local $x))))
|
||||||
|
(func (export "no_dce.i64.trunc_u_f64") (param $x f64) (drop (i64.trunc_u/f64 (get_local $x))))
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_trap (invoke "no_dce.i32.trunc_s_f32" (f32.const nan)) "invalid conversion to integer")
|
||||||
|
(assert_trap (invoke "no_dce.i32.trunc_u_f32" (f32.const nan)) "invalid conversion to integer")
|
||||||
|
(assert_trap (invoke "no_dce.i32.trunc_s_f64" (f64.const nan)) "invalid conversion to integer")
|
||||||
|
(assert_trap (invoke "no_dce.i32.trunc_u_f64" (f64.const nan)) "invalid conversion to integer")
|
||||||
|
(assert_trap (invoke "no_dce.i64.trunc_s_f32" (f32.const nan)) "invalid conversion to integer")
|
||||||
|
(assert_trap (invoke "no_dce.i64.trunc_u_f32" (f32.const nan)) "invalid conversion to integer")
|
||||||
|
(assert_trap (invoke "no_dce.i64.trunc_s_f64" (f64.const nan)) "invalid conversion to integer")
|
||||||
|
(assert_trap (invoke "no_dce.i64.trunc_u_f64" (f64.const nan)) "invalid conversion to integer")
|
||||||
|
|
||||||
|
(module
|
||||||
|
(memory 1)
|
||||||
|
|
||||||
|
(func (export "no_dce.i32.load") (param $i i32) (drop (i32.load (get_local $i))))
|
||||||
|
(func (export "no_dce.i32.load16_s") (param $i i32) (drop (i32.load16_s (get_local $i))))
|
||||||
|
(func (export "no_dce.i32.load16_u") (param $i i32) (drop (i32.load16_u (get_local $i))))
|
||||||
|
(func (export "no_dce.i32.load8_s") (param $i i32) (drop (i32.load8_s (get_local $i))))
|
||||||
|
(func (export "no_dce.i32.load8_u") (param $i i32) (drop (i32.load8_u (get_local $i))))
|
||||||
|
(func (export "no_dce.i64.load") (param $i i32) (drop (i64.load (get_local $i))))
|
||||||
|
(func (export "no_dce.i64.load32_s") (param $i i32) (drop (i64.load32_s (get_local $i))))
|
||||||
|
(func (export "no_dce.i64.load32_u") (param $i i32) (drop (i64.load32_u (get_local $i))))
|
||||||
|
(func (export "no_dce.i64.load16_s") (param $i i32) (drop (i64.load16_s (get_local $i))))
|
||||||
|
(func (export "no_dce.i64.load16_u") (param $i i32) (drop (i64.load16_u (get_local $i))))
|
||||||
|
(func (export "no_dce.i64.load8_s") (param $i i32) (drop (i64.load8_s (get_local $i))))
|
||||||
|
(func (export "no_dce.i64.load8_u") (param $i i32) (drop (i64.load8_u (get_local $i))))
|
||||||
|
(func (export "no_dce.f32.load") (param $i i32) (drop (f32.load (get_local $i))))
|
||||||
|
(func (export "no_dce.f64.load") (param $i i32) (drop (f64.load (get_local $i))))
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_trap (invoke "no_dce.i32.load" (i32.const 65536)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "no_dce.i32.load16_s" (i32.const 65536)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "no_dce.i32.load16_u" (i32.const 65536)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "no_dce.i32.load8_s" (i32.const 65536)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "no_dce.i32.load8_u" (i32.const 65536)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "no_dce.i64.load" (i32.const 65536)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "no_dce.i64.load32_s" (i32.const 65536)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "no_dce.i64.load32_u" (i32.const 65536)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "no_dce.i64.load16_s" (i32.const 65536)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "no_dce.i64.load16_u" (i32.const 65536)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "no_dce.i64.load8_s" (i32.const 65536)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "no_dce.i64.load8_u" (i32.const 65536)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "no_dce.f32.load" (i32.const 65536)) "out of bounds memory access")
|
||||||
|
(assert_trap (invoke "no_dce.f64.load" (i32.const 65536)) "out of bounds memory access")
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
;; Test type definitions
|
||||||
|
|
||||||
|
(module
|
||||||
|
(type (func))
|
||||||
|
(type $t (func))
|
||||||
|
|
||||||
|
(type (func (param i32)))
|
||||||
|
(type (func (param $x i32)))
|
||||||
|
(type (func (result i32)))
|
||||||
|
(type (func (param i32) (result i32)))
|
||||||
|
(type (func (param $x i32) (result i32)))
|
||||||
|
|
||||||
|
(type (func (param f32 f64)))
|
||||||
|
;; (type (func (result i64 f32)))
|
||||||
|
;; (type (func (param i32 i64) (result f32 f64)))
|
||||||
|
|
||||||
|
(type (func (param f32) (param f64)))
|
||||||
|
(type (func (param $x f32) (param f64)))
|
||||||
|
(type (func (param f32) (param $y f64)))
|
||||||
|
(type (func (param $x f32) (param $y f64)))
|
||||||
|
;; (type (func (result i64) (result f32)))
|
||||||
|
;; (type (func (param i32) (param i64) (result f32) (result f64)))
|
||||||
|
;; (type (func (param $x i32) (param $y i64) (result f32) (result f64)))
|
||||||
|
|
||||||
|
(type (func (param f32 f64) (param $x i32) (param f64 i32 i32)))
|
||||||
|
;; (type (func (result i64 i64 f32) (result f32 i32)))
|
||||||
|
;; (type
|
||||||
|
;; (func (param i32 i32) (param i64 i32) (result f32 f64) (result f64 i32))
|
||||||
|
;; )
|
||||||
|
|
||||||
|
(type (func (param) (param $x f32) (param) (param) (param f64 i32) (param)))
|
||||||
|
;; (type
|
||||||
|
;; (func (result) (result) (result i64 i64) (result) (result f32) (result))
|
||||||
|
;; )
|
||||||
|
;; (type
|
||||||
|
;; (func
|
||||||
|
;; (param i32 i32) (param i64 i32) (param) (param $x i32) (param)
|
||||||
|
;; (result) (result f32 f64) (result f64 i32) (result)
|
||||||
|
;; )
|
||||||
|
;; )
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(type (func (result i32) (param i32)))")
|
||||||
|
"result before parameter"
|
||||||
|
)
|
||||||
|
(assert_malformed
|
||||||
|
(module quote "(type (func (result $x i32)))")
|
||||||
|
"unexpected token"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (type (func (result i32 i32))))
|
||||||
|
"invalid result arity"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (type (func (result i32) (result i32))))
|
||||||
|
"invalid result arity"
|
||||||
|
)
|
||||||
@@ -0,0 +1,425 @@
|
|||||||
|
;; TODO: move all tests in this file to appropriate operator-specific files.
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-unary-operand-missing
|
||||||
|
(i32.eqz) (drop)
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-unary-operand-missing-in-block
|
||||||
|
(i32.const 0)
|
||||||
|
(block (i32.eqz) (drop))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-unary-operand-missing-in-loop
|
||||||
|
(i32.const 0)
|
||||||
|
(loop (i32.eqz) (drop))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-unary-operand-missing-in-if
|
||||||
|
(i32.const 0) (i32.const 0)
|
||||||
|
(if (then (i32.eqz) (drop)))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-unary-operand-missing-in-else
|
||||||
|
(i32.const 0) (i32.const 0)
|
||||||
|
(if (result i32) (then (i32.const 0)) (else (i32.eqz))) (drop)
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-binary-1st-operand-missing
|
||||||
|
(i32.add) (drop)
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-binary-2nd-operand-missing
|
||||||
|
(i32.const 0) (i32.add) (drop)
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-binary-1st-operand-missing-in-block
|
||||||
|
(i32.const 0) (i32.const 0)
|
||||||
|
(block (i32.add) (drop))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-binary-2nd-operand-missing-in-block
|
||||||
|
(i32.const 0)
|
||||||
|
(block (i32.const 0) (i32.add) (drop))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-binary-1st-operand-missing-in-loop
|
||||||
|
(i32.const 0) (i32.const 0)
|
||||||
|
(loop (i32.add) (drop))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-binary-2nd-operand-missing-in-loop
|
||||||
|
(i32.const 0)
|
||||||
|
(loop (i32.const 0) (i32.add) (drop))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-binary-1st-operand-missing-in-if
|
||||||
|
(i32.const 0) (i32.const 0) (i32.const 0)
|
||||||
|
(if (i32.add) (then (drop)))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-binary-2nd-operand-missing-in-if
|
||||||
|
(i32.const 0) (i32.const 0)
|
||||||
|
(if (i32.const 0) (then (i32.add)) (else (drop)))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-binary-1st-operand-missing-in-else
|
||||||
|
(i32.const 0) (i32.const 0) (i32.const 0)
|
||||||
|
(if (result i32) (then (i32.const 0)) (else (i32.add) (i32.const 0)))
|
||||||
|
(drop) (drop)
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-binary-2nd-operand-missing-in-else
|
||||||
|
(i32.const 0) (i32.const 0)
|
||||||
|
(if (result i32) (then (i32.const 0)) (else (i32.add)))
|
||||||
|
(drop)
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-if-operand-missing
|
||||||
|
(if (then))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-if-operand-missing-in-block
|
||||||
|
(i32.const 0)
|
||||||
|
(block (if (then)))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-if-operand-missing-in-loop
|
||||||
|
(i32.const 0)
|
||||||
|
(loop (if (then)))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-if-operand-missing-in-if
|
||||||
|
(i32.const 0) (i32.const 0)
|
||||||
|
(if (then (if (then))))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-if-operand-missing-in-else
|
||||||
|
(i32.const 0) (i32.const 0)
|
||||||
|
(if (result i32) (then (i32.const 0)) (else (if (then)) (i32.const 0)))
|
||||||
|
(drop)
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-br-operand-missing
|
||||||
|
(block (result i32) (br 0))
|
||||||
|
(i32.eqz) (drop)
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-br-operand-missing-in-block
|
||||||
|
(i32.const 0)
|
||||||
|
(block (result i32) (br 0))
|
||||||
|
(i32.eqz) (drop)
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-br-operand-missing-in-if
|
||||||
|
(block
|
||||||
|
(i32.const 0) (i32.const 0)
|
||||||
|
(if (result i32) (then (br 0)))
|
||||||
|
)
|
||||||
|
(i32.eqz) (drop)
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-br-operand-missing-in-else
|
||||||
|
(block
|
||||||
|
(i32.const 0) (i32.const 0)
|
||||||
|
(if (result i32) (then (i32.const 0)) (else (br 0)))
|
||||||
|
)
|
||||||
|
(i32.eqz) (drop)
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-return-operand-missing (result i32)
|
||||||
|
(return)
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-return-operand-missing-in-block (result i32)
|
||||||
|
(i32.const 0)
|
||||||
|
(block (return))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-return-operand-missing-in-loop (result i32)
|
||||||
|
(i32.const 0)
|
||||||
|
(loop (return))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-return-operand-missing-in-if (result i32)
|
||||||
|
(i32.const 0) (i32.const 0)
|
||||||
|
(if (then (return)))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-return-operand-missing-in-else (result i32)
|
||||||
|
(i32.const 0) (i32.const 0)
|
||||||
|
(if (result i32) (then (i32.const 0)) (else (return))) (drop)
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
;; TODO(stack): more of the above
|
||||||
|
|
||||||
|
;; if condition
|
||||||
|
(assert_invalid (module (func (if (f32.const 0) (then)))) "type mismatch")
|
||||||
|
|
||||||
|
;; br_if condition
|
||||||
|
(assert_invalid (module (func (block (br_if 0 (f32.const 0))))) "type mismatch")
|
||||||
|
|
||||||
|
;; br_table key
|
||||||
|
(assert_invalid
|
||||||
|
(module (func (block (br_table 0 (f32.const 0)))))
|
||||||
|
"type mismatch")
|
||||||
|
|
||||||
|
;; call params
|
||||||
|
(assert_invalid (module (func (param i32)) (func (call 0 (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid
|
||||||
|
(module
|
||||||
|
(type (func (param i32)))
|
||||||
|
(func (type 0))
|
||||||
|
(table 0 anyfunc)
|
||||||
|
(func
|
||||||
|
(call_indirect (type 0) (i32.const 0) (f32.const 0))))
|
||||||
|
"type mismatch")
|
||||||
|
|
||||||
|
;; call_indirect index
|
||||||
|
(assert_invalid
|
||||||
|
(module
|
||||||
|
(type (func))
|
||||||
|
(func (type 0))
|
||||||
|
(table 0 anyfunc)
|
||||||
|
(func (call_indirect (type 0) (f32.const 0))))
|
||||||
|
"type mismatch")
|
||||||
|
|
||||||
|
;; return
|
||||||
|
(assert_invalid (module (func (result i32) (return (f32.const 0)))) "type mismatch")
|
||||||
|
|
||||||
|
;; set_local
|
||||||
|
(assert_invalid (module (func (local i32) (set_local 0 (f32.const 0)))) "type mismatch")
|
||||||
|
|
||||||
|
;; load index
|
||||||
|
(assert_invalid (module (memory 1) (func (i32.load (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (memory 1) (func (i32.load8_s (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (memory 1) (func (i32.load8_u (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (memory 1) (func (i32.load16_s (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (memory 1) (func (i32.load16_u (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (memory 1) (func (i64.load (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (memory 1) (func (i64.load8_s (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (memory 1) (func (i64.load8_u (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (memory 1) (func (i64.load16_s (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (memory 1) (func (i64.load16_u (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (memory 1) (func (i64.load32_s (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (memory 1) (func (i64.load32_u (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (memory 1) (func (f32.load (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (memory 1) (func (f64.load (f32.const 0)))) "type mismatch")
|
||||||
|
|
||||||
|
;; store index
|
||||||
|
(assert_invalid (module (memory 1) (func (i32.store (f32.const 0) (i32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (memory 1) (func (i32.store8 (f32.const 0) (i32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (memory 1) (func (i32.store16 (f32.const 0) (i32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (memory 1) (func (i64.store (f32.const 0) (i32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (memory 1) (func (i64.store8 (f32.const 0) (i64.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (memory 1) (func (i64.store16 (f32.const 0) (i64.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (memory 1) (func (i64.store32 (f32.const 0) (i64.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (memory 1) (func (f32.store (f32.const 0) (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (memory 1) (func (f64.store (f32.const 0) (f64.const 0)))) "type mismatch")
|
||||||
|
|
||||||
|
;; store value
|
||||||
|
(assert_invalid (module (memory 1) (func (i32.store (i32.const 0) (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (memory 1) (func (i32.store8 (i32.const 0) (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (memory 1) (func (i32.store16 (i32.const 0) (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (memory 1) (func (i64.store (i32.const 0) (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (memory 1) (func (i64.store8 (i32.const 0) (f64.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (memory 1) (func (i64.store16 (i32.const 0) (f64.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (memory 1) (func (i64.store32 (i32.const 0) (f64.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (memory 1) (func (f32.store (i32.const 0) (i32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (memory 1) (func (f64.store (i32.const 0) (i64.const 0)))) "type mismatch")
|
||||||
|
|
||||||
|
;; binary
|
||||||
|
(assert_invalid (module (func (i32.add (i64.const 0) (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (i32.and (i64.const 0) (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (i32.div_s (i64.const 0) (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (i32.div_u (i64.const 0) (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (i32.mul (i64.const 0) (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (i32.or (i64.const 0) (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (i32.rem_s (i64.const 0) (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (i32.rem_u (i64.const 0) (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (i32.rotl (i64.const 0) (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (i32.rotr (i64.const 0) (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (i32.shl (i64.const 0) (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (i32.shr_s (i64.const 0) (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (i32.shr_u (i64.const 0) (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (i32.sub (i64.const 0) (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (i32.xor (i64.const 0) (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (i64.add (i32.const 0) (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (i64.and (i32.const 0) (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (i64.div_s (i32.const 0) (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (i64.div_u (i32.const 0) (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (i64.mul (i32.const 0) (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (i64.or (i32.const 0) (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (i64.rem_s (i32.const 0) (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (i64.rem_u (i32.const 0) (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (i64.rotl (i32.const 0) (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (i64.rotr (i32.const 0) (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (i64.shl (i32.const 0) (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (i64.shr_s (i32.const 0) (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (i64.shr_u (i32.const 0) (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (i64.sub (i32.const 0) (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (i64.xor (i32.const 0) (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (f32.add (i64.const 0) (f64.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (f32.copysign (i64.const 0) (f64.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (f32.div (i64.const 0) (f64.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (f32.max (i64.const 0) (f64.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (f32.min (i64.const 0) (f64.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (f32.mul (i64.const 0) (f64.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (f32.sub (i64.const 0) (f64.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (f64.add (i64.const 0) (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (f64.copysign (i64.const 0) (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (f64.div (i64.const 0) (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (f64.max (i64.const 0) (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (f64.min (i64.const 0) (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (f64.mul (i64.const 0) (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (f64.sub (i64.const 0) (f32.const 0)))) "type mismatch")
|
||||||
|
|
||||||
|
;; unary
|
||||||
|
(assert_invalid (module (func (i32.eqz (i64.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (i32.clz (i64.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (i32.ctz (i64.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (i32.popcnt (i64.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (i64.eqz (i32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (i64.clz (i32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (i64.ctz (i32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (i64.popcnt (i32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (f32.abs (i64.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (f32.ceil (i64.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (f32.floor (i64.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (f32.nearest (i64.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (f32.neg (i64.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (f32.sqrt (i64.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (f32.trunc (i64.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (f64.abs (i64.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (f64.ceil (i64.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (f64.floor (i64.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (f64.nearest (i64.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (f64.neg (i64.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (f64.sqrt (i64.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (f64.trunc (i64.const 0)))) "type mismatch")
|
||||||
|
|
||||||
|
;; compare
|
||||||
|
(assert_invalid (module (func (i32.eq (i64.const 0) (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (i32.ge_s (i64.const 0) (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (i32.ge_u (i64.const 0) (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (i32.gt_s (i64.const 0) (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (i32.gt_u (i64.const 0) (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (i32.le_s (i64.const 0) (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (i32.le_u (i64.const 0) (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (i32.lt_s (i64.const 0) (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (i32.lt_u (i64.const 0) (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (i32.ne (i64.const 0) (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (i64.eq (i32.const 0) (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (i64.ge_s (i32.const 0) (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (i64.ge_u (i32.const 0) (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (i64.gt_s (i32.const 0) (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (i64.gt_u (i32.const 0) (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (i64.le_s (i32.const 0) (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (i64.le_u (i32.const 0) (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (i64.lt_s (i32.const 0) (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (i64.lt_u (i32.const 0) (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (i64.ne (i32.const 0) (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (f32.eq (i64.const 0) (f64.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (f32.ge (i64.const 0) (f64.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (f32.gt (i64.const 0) (f64.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (f32.le (i64.const 0) (f64.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (f32.lt (i64.const 0) (f64.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (f32.ne (i64.const 0) (f64.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (f64.eq (i64.const 0) (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (f64.ge (i64.const 0) (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (f64.gt (i64.const 0) (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (f64.le (i64.const 0) (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (f64.lt (i64.const 0) (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (f64.ne (i64.const 0) (f32.const 0)))) "type mismatch")
|
||||||
|
|
||||||
|
;; convert
|
||||||
|
(assert_invalid (module (func (i32.wrap/i64 (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (i32.trunc_s/f32 (i64.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (i32.trunc_u/f32 (i64.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (i32.trunc_s/f64 (i64.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (i32.trunc_u/f64 (i64.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (i32.reinterpret/f32 (i64.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (i64.extend_s/i32 (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (i64.extend_u/i32 (f32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (i64.trunc_s/f32 (i32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (i64.trunc_u/f32 (i32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (i64.trunc_s/f64 (i32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (i64.trunc_u/f64 (i32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (i64.reinterpret/f64 (i32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (f32.convert_s/i32 (i64.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (f32.convert_u/i32 (i64.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (f32.convert_s/i64 (i32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (f32.convert_u/i64 (i32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (f32.demote/f64 (i32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (f32.reinterpret/i32 (i64.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (f64.convert_s/i32 (i64.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (f64.convert_u/i32 (i64.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (f64.convert_s/i64 (i32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (f64.convert_u/i64 (i32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (f64.promote/f32 (i32.const 0)))) "type mismatch")
|
||||||
|
(assert_invalid (module (func (f64.reinterpret/i64 (i32.const 0)))) "type mismatch")
|
||||||
|
|
||||||
|
;; memory.grow
|
||||||
|
(assert_invalid (module (memory 1) (func (memory.grow (f32.const 0)))) "type mismatch")
|
||||||
@@ -0,0 +1,290 @@
|
|||||||
|
;; Test `unreachable` operator
|
||||||
|
|
||||||
|
(module
|
||||||
|
;; Auxiliary definitions
|
||||||
|
(func $dummy)
|
||||||
|
(func $dummy3 (param i32 i32 i32))
|
||||||
|
|
||||||
|
(func (export "type-i32") (result i32) (unreachable))
|
||||||
|
(func (export "type-i64") (result i32) (unreachable))
|
||||||
|
(func (export "type-f32") (result f64) (unreachable))
|
||||||
|
(func (export "type-f64") (result f64) (unreachable))
|
||||||
|
|
||||||
|
(func (export "as-func-first") (result i32)
|
||||||
|
(unreachable) (i32.const -1)
|
||||||
|
)
|
||||||
|
(func (export "as-func-mid") (result i32)
|
||||||
|
(call $dummy) (unreachable) (i32.const -1)
|
||||||
|
)
|
||||||
|
(func (export "as-func-last")
|
||||||
|
(call $dummy) (unreachable)
|
||||||
|
)
|
||||||
|
(func (export "as-func-value") (result i32)
|
||||||
|
(call $dummy) (unreachable)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "as-block-first") (result i32)
|
||||||
|
(block (result i32) (unreachable) (i32.const 2))
|
||||||
|
)
|
||||||
|
(func (export "as-block-mid") (result i32)
|
||||||
|
(block (result i32) (call $dummy) (unreachable) (i32.const 2))
|
||||||
|
)
|
||||||
|
(func (export "as-block-last")
|
||||||
|
(block (nop) (call $dummy) (unreachable))
|
||||||
|
)
|
||||||
|
(func (export "as-block-value") (result i32)
|
||||||
|
(block (result i32) (nop) (call $dummy) (unreachable))
|
||||||
|
)
|
||||||
|
(func (export "as-block-broke") (result i32)
|
||||||
|
(block (result i32) (call $dummy) (br 0 (i32.const 1)) (unreachable))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "as-loop-first") (result i32)
|
||||||
|
(loop (result i32) (unreachable) (i32.const 2))
|
||||||
|
)
|
||||||
|
(func (export "as-loop-mid") (result i32)
|
||||||
|
(loop (result i32) (call $dummy) (unreachable) (i32.const 2))
|
||||||
|
)
|
||||||
|
(func (export "as-loop-last")
|
||||||
|
(loop (nop) (call $dummy) (unreachable))
|
||||||
|
)
|
||||||
|
(func (export "as-loop-broke") (result i32)
|
||||||
|
(block (result i32)
|
||||||
|
(loop (result i32) (call $dummy) (br 1 (i32.const 1)) (unreachable))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "as-br-value") (result i32)
|
||||||
|
(block (result i32) (br 0 (unreachable)))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "as-br_if-cond")
|
||||||
|
(block (br_if 0 (unreachable)))
|
||||||
|
)
|
||||||
|
(func (export "as-br_if-value") (result i32)
|
||||||
|
(block (result i32)
|
||||||
|
(drop (br_if 0 (unreachable) (i32.const 1))) (i32.const 7)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(func (export "as-br_if-value-cond") (result i32)
|
||||||
|
(block (result i32)
|
||||||
|
(drop (br_if 0 (i32.const 6) (unreachable))) (i32.const 7)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "as-br_table-index")
|
||||||
|
(block (br_table 0 0 0 (unreachable)))
|
||||||
|
)
|
||||||
|
(func (export "as-br_table-value") (result i32)
|
||||||
|
(block (result i32)
|
||||||
|
(br_table 0 0 0 (unreachable) (i32.const 1)) (i32.const 7)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(func (export "as-br_table-value-2") (result i32)
|
||||||
|
(block (result i32)
|
||||||
|
(block (result i32) (br_table 0 1 (unreachable) (i32.const 1)))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(func (export "as-br_table-value-index") (result i32)
|
||||||
|
(block (result i32)
|
||||||
|
(br_table 0 0 (i32.const 6) (unreachable)) (i32.const 7)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(func (export "as-br_table-value-and-index") (result i32)
|
||||||
|
(block (result i32) (br_table 0 0 (unreachable)) (i32.const 8))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "as-return-value") (result i64)
|
||||||
|
(return (unreachable))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "as-if-cond") (result i32)
|
||||||
|
(if (result i32) (unreachable) (then (i32.const 0)) (else (i32.const 1)))
|
||||||
|
)
|
||||||
|
(func (export "as-if-then") (param i32 i32) (result i32)
|
||||||
|
(if (result i32) (get_local 0) (then (unreachable)) (else (get_local 1)))
|
||||||
|
)
|
||||||
|
(func (export "as-if-else") (param i32 i32) (result i32)
|
||||||
|
(if (result i32) (get_local 0) (then (get_local 1)) (else (unreachable)))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "as-select-first") (param i32 i32) (result i32)
|
||||||
|
(select (unreachable) (get_local 0) (get_local 1))
|
||||||
|
)
|
||||||
|
(func (export "as-select-second") (param i32 i32) (result i32)
|
||||||
|
(select (get_local 0) (unreachable) (get_local 1))
|
||||||
|
)
|
||||||
|
(func (export "as-select-cond") (result i32)
|
||||||
|
(select (i32.const 0) (i32.const 1) (unreachable))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "as-call-first")
|
||||||
|
(call $dummy3 (unreachable) (i32.const 2) (i32.const 3))
|
||||||
|
)
|
||||||
|
(func (export "as-call-mid")
|
||||||
|
(call $dummy3 (i32.const 1) (unreachable) (i32.const 3))
|
||||||
|
)
|
||||||
|
(func (export "as-call-last")
|
||||||
|
(call $dummy3 (i32.const 1) (i32.const 2) (unreachable))
|
||||||
|
)
|
||||||
|
|
||||||
|
(type $sig (func (param i32 i32 i32)))
|
||||||
|
(table anyfunc (elem $dummy3))
|
||||||
|
(func (export "as-call_indirect-func")
|
||||||
|
(call_indirect (type $sig)
|
||||||
|
(unreachable) (i32.const 1) (i32.const 2) (i32.const 3)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(func (export "as-call_indirect-first")
|
||||||
|
(call_indirect (type $sig)
|
||||||
|
(i32.const 0) (unreachable) (i32.const 2) (i32.const 3)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(func (export "as-call_indirect-mid")
|
||||||
|
(call_indirect (type $sig)
|
||||||
|
(i32.const 0) (i32.const 1) (unreachable) (i32.const 3)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(func (export "as-call_indirect-last")
|
||||||
|
(call_indirect (type $sig)
|
||||||
|
(i32.const 0) (i32.const 1) (i32.const 2) (unreachable)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "as-set_local-value") (local f32)
|
||||||
|
(set_local 0 (unreachable))
|
||||||
|
)
|
||||||
|
|
||||||
|
(memory 1)
|
||||||
|
(func (export "as-load-address") (result f32)
|
||||||
|
(f32.load (unreachable))
|
||||||
|
)
|
||||||
|
(func (export "as-loadN-address") (result i64)
|
||||||
|
(i64.load8_s (unreachable))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "as-store-address")
|
||||||
|
(f64.store (unreachable) (f64.const 7))
|
||||||
|
)
|
||||||
|
(func (export "as-store-value")
|
||||||
|
(i64.store (i32.const 2) (unreachable))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "as-storeN-address")
|
||||||
|
(i32.store8 (unreachable) (i32.const 7))
|
||||||
|
)
|
||||||
|
(func (export "as-storeN-value")
|
||||||
|
(i64.store16 (i32.const 2) (unreachable))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "as-unary-operand") (result f32)
|
||||||
|
(f32.neg (unreachable))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "as-binary-left") (result i32)
|
||||||
|
(i32.add (unreachable) (i32.const 10))
|
||||||
|
)
|
||||||
|
(func (export "as-binary-right") (result i64)
|
||||||
|
(i64.sub (i64.const 10) (unreachable))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "as-test-operand") (result i32)
|
||||||
|
(i32.eqz (unreachable))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "as-compare-left") (result i32)
|
||||||
|
(f64.le (unreachable) (f64.const 10))
|
||||||
|
)
|
||||||
|
(func (export "as-compare-right") (result i32)
|
||||||
|
(f32.ne (f32.const 10) (unreachable))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "as-convert-operand") (result i32)
|
||||||
|
(i32.wrap/i64 (unreachable))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "as-memory.grow-size") (result i32)
|
||||||
|
(memory.grow (unreachable))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_trap (invoke "type-i32") "unreachable")
|
||||||
|
(assert_trap (invoke "type-i64") "unreachable")
|
||||||
|
(assert_trap (invoke "type-f32") "unreachable")
|
||||||
|
(assert_trap (invoke "type-f64") "unreachable")
|
||||||
|
|
||||||
|
(assert_trap (invoke "as-func-first") "unreachable")
|
||||||
|
(assert_trap (invoke "as-func-mid") "unreachable")
|
||||||
|
(assert_trap (invoke "as-func-last") "unreachable")
|
||||||
|
(assert_trap (invoke "as-func-value") "unreachable")
|
||||||
|
|
||||||
|
(assert_trap (invoke "as-block-first") "unreachable")
|
||||||
|
(assert_trap (invoke "as-block-mid") "unreachable")
|
||||||
|
(assert_trap (invoke "as-block-last") "unreachable")
|
||||||
|
(assert_trap (invoke "as-block-value") "unreachable")
|
||||||
|
(assert_return (invoke "as-block-broke") (i32.const 1))
|
||||||
|
|
||||||
|
(assert_trap (invoke "as-loop-first") "unreachable")
|
||||||
|
(assert_trap (invoke "as-loop-mid") "unreachable")
|
||||||
|
(assert_trap (invoke "as-loop-last") "unreachable")
|
||||||
|
(assert_return (invoke "as-loop-broke") (i32.const 1))
|
||||||
|
|
||||||
|
(assert_trap (invoke "as-br-value") "unreachable")
|
||||||
|
|
||||||
|
(assert_trap (invoke "as-br_if-cond") "unreachable")
|
||||||
|
(assert_trap (invoke "as-br_if-value") "unreachable")
|
||||||
|
(assert_trap (invoke "as-br_if-value-cond") "unreachable")
|
||||||
|
|
||||||
|
(assert_trap (invoke "as-br_table-index") "unreachable")
|
||||||
|
(assert_trap (invoke "as-br_table-value") "unreachable")
|
||||||
|
(assert_trap (invoke "as-br_table-value-2") "unreachable")
|
||||||
|
(assert_trap (invoke "as-br_table-value-index") "unreachable")
|
||||||
|
(assert_trap (invoke "as-br_table-value-and-index") "unreachable")
|
||||||
|
|
||||||
|
(assert_trap (invoke "as-return-value") "unreachable")
|
||||||
|
|
||||||
|
(assert_trap (invoke "as-if-cond") "unreachable")
|
||||||
|
(assert_trap (invoke "as-if-then" (i32.const 1) (i32.const 6)) "unreachable")
|
||||||
|
(assert_return (invoke "as-if-then" (i32.const 0) (i32.const 6)) (i32.const 6))
|
||||||
|
(assert_trap (invoke "as-if-else" (i32.const 0) (i32.const 6)) "unreachable")
|
||||||
|
(assert_return (invoke "as-if-else" (i32.const 1) (i32.const 6)) (i32.const 6))
|
||||||
|
|
||||||
|
(assert_trap (invoke "as-select-first" (i32.const 0) (i32.const 6)) "unreachable")
|
||||||
|
(assert_trap (invoke "as-select-first" (i32.const 1) (i32.const 6)) "unreachable")
|
||||||
|
(assert_trap (invoke "as-select-second" (i32.const 0) (i32.const 6)) "unreachable")
|
||||||
|
(assert_trap (invoke "as-select-second" (i32.const 1) (i32.const 6)) "unreachable")
|
||||||
|
(assert_trap (invoke "as-select-cond") "unreachable")
|
||||||
|
|
||||||
|
(assert_trap (invoke "as-call-first") "unreachable")
|
||||||
|
(assert_trap (invoke "as-call-mid") "unreachable")
|
||||||
|
(assert_trap (invoke "as-call-last") "unreachable")
|
||||||
|
|
||||||
|
(assert_trap (invoke "as-call_indirect-func") "unreachable")
|
||||||
|
(assert_trap (invoke "as-call_indirect-first") "unreachable")
|
||||||
|
(assert_trap (invoke "as-call_indirect-mid") "unreachable")
|
||||||
|
(assert_trap (invoke "as-call_indirect-last") "unreachable")
|
||||||
|
|
||||||
|
(assert_trap (invoke "as-set_local-value") "unreachable")
|
||||||
|
|
||||||
|
(assert_trap (invoke "as-load-address") "unreachable")
|
||||||
|
(assert_trap (invoke "as-loadN-address") "unreachable")
|
||||||
|
|
||||||
|
(assert_trap (invoke "as-store-address") "unreachable")
|
||||||
|
(assert_trap (invoke "as-store-value") "unreachable")
|
||||||
|
(assert_trap (invoke "as-storeN-address") "unreachable")
|
||||||
|
(assert_trap (invoke "as-storeN-value") "unreachable")
|
||||||
|
|
||||||
|
(assert_trap (invoke "as-unary-operand") "unreachable")
|
||||||
|
|
||||||
|
(assert_trap (invoke "as-binary-left") "unreachable")
|
||||||
|
(assert_trap (invoke "as-binary-right") "unreachable")
|
||||||
|
|
||||||
|
(assert_trap (invoke "as-test-operand") "unreachable")
|
||||||
|
|
||||||
|
(assert_trap (invoke "as-compare-left") "unreachable")
|
||||||
|
(assert_trap (invoke "as-compare-right") "unreachable")
|
||||||
|
|
||||||
|
(assert_trap (invoke "as-convert-operand") "unreachable")
|
||||||
|
|
||||||
|
(assert_trap (invoke "as-memory.grow-size") "unreachable")
|
||||||
|
|
||||||
@@ -0,0 +1,709 @@
|
|||||||
|
;; Failures in unreachable code.
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $local-index (unreachable) (drop (get_local 0))))
|
||||||
|
"unknown local"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $global-index (unreachable) (drop (get_global 0))))
|
||||||
|
"unknown global"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $func-index (unreachable) (call 1)))
|
||||||
|
"unknown function"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $label-index (unreachable) (br 1)))
|
||||||
|
"unknown label"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-num-vs-num
|
||||||
|
(unreachable) (drop (i64.eqz (i32.const 0))))
|
||||||
|
)
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-poly-num-vs-num (result i32)
|
||||||
|
(unreachable) (i64.const 0) (i32.const 0) (select)
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-poly-transitive-num-vs-num (result i32)
|
||||||
|
(unreachable)
|
||||||
|
(i64.const 0) (i32.const 0) (select)
|
||||||
|
(i32.const 0) (i32.const 0) (select)
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-unconsumed-const (unreachable) (i32.const 0)))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-unconsumed-result (unreachable) (i32.eqz)))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-unconsumed-result2
|
||||||
|
(unreachable) (i32.const 0) (i32.add)
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-unconsumed-poly0 (unreachable) (select)))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-unconsumed-poly1 (unreachable) (i32.const 0) (select)))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-unconsumed-poly2
|
||||||
|
(unreachable) (i32.const 0) (i32.const 0) (select)
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-unary-num-vs-void-after-break
|
||||||
|
(block (br 0) (block (drop (i32.eqz (nop)))))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-unary-num-vs-num-after-break
|
||||||
|
(block (br 0) (drop (i32.eqz (f32.const 1))))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-binary-num-vs-void-after-break
|
||||||
|
(block (br 0) (block (drop (f32.eq (i32.const 1)))))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-binary-num-vs-num-after-break
|
||||||
|
(block (br 0) (drop (f32.eq (i32.const 1) (f32.const 0))))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-block-value-num-vs-void-after-break
|
||||||
|
(block (br 0) (i32.const 1))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-block-value-num-vs-num-after-break (result i32)
|
||||||
|
(block (result i32) (i32.const 1) (br 0) (f32.const 0))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-loop-value-num-vs-void-after-break
|
||||||
|
(block (loop (br 1) (i32.const 1)))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-loop-value-num-vs-num-after-break (result i32)
|
||||||
|
(loop (result i32) (br 1 (i32.const 1)) (f32.const 0))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-func-value-num-vs-void-after-break
|
||||||
|
(br 0) (i32.const 1)
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-func-value-num-vs-num-after-break (result i32)
|
||||||
|
(br 0 (i32.const 1)) (f32.const 0)
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-unary-num-vs-void-after-return
|
||||||
|
(return) (block (drop (i32.eqz (nop))))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-unary-num-vs-num-after-return
|
||||||
|
(return) (drop (i32.eqz (f32.const 1)))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-binary-num-vs-void-after-return
|
||||||
|
(return) (block (drop (f32.eq (i32.const 1))))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-binary-num-vs-num-after-return
|
||||||
|
(return) (drop (f32.eq (i32.const 1) (f32.const 0)))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-block-value-num-vs-void-after-return
|
||||||
|
(block (return) (i32.const 1))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-block-value-num-vs-num-after-return (result i32)
|
||||||
|
(block (result i32) (i32.const 1) (return (i32.const 0)) (f32.const 0))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-loop-value-num-vs-void-after-return
|
||||||
|
(block (loop (return) (i32.const 1)))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-loop-value-num-vs-num-after-return (result i32)
|
||||||
|
(loop (result i32) (return (i32.const 1)) (f32.const 0))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-func-value-num-vs-void-after-return
|
||||||
|
(return) (i32.const 1)
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-func-value-num-vs-num-after-return (result i32)
|
||||||
|
(return (i32.const 1)) (f32.const 0)
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-unary-num-vs-void-after-unreachable
|
||||||
|
(unreachable) (block (drop (i32.eqz (nop))))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-unary-num-vs-void-in-loop-after-unreachable
|
||||||
|
(unreachable) (loop (drop (i32.eqz (nop))))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-unary-num-vs-void-in-i32-loop-after-unreachable
|
||||||
|
(unreachable) (loop (result i32) (i32.eqz (nop)))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-unary-num-vs-num-after-unreachable
|
||||||
|
(unreachable) (drop (i32.eqz (f32.const 1)))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-binary-num-vs-void-after-unreachable
|
||||||
|
(unreachable) (block (drop (f32.eq (i32.const 1))))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-binary-num-vs-num-after-unreachable
|
||||||
|
(unreachable) (drop (f32.eq (i32.const 1) (f32.const 0)))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-block-value-num-vs-void-after-unreachable
|
||||||
|
(block (unreachable) (i32.const 1))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-block-value-num-vs-num-after-unreachable (result i32)
|
||||||
|
(block (result i32) (i32.const 1) (unreachable) (f32.const 0))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-loop-value-num-vs-void-after-unreachable
|
||||||
|
(block (loop (unreachable) (i32.const 1)))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-loop-value-num-vs-num-after-unreachable (result i32)
|
||||||
|
(loop (result i32) (unreachable) (f32.const 0))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-func-value-num-vs-void-after-unreachable
|
||||||
|
(unreachable) (i32.const 1)
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-func-value-num-vs-num-after-unreachable (result i32)
|
||||||
|
(unreachable) (f32.const 0)
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-unary-num-vs-void-in-if-after-unreachable
|
||||||
|
(unreachable) (if (i32.const 0) (then (drop (i32.eqz (nop)))))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-unary-num-vs-void-in-else-after-unreachable
|
||||||
|
(unreachable) (if (i32.const 0) (then (nop)) (else (drop (i32.eqz (nop)))))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-unary-num-vs-void-in-else-after-unreachable-if
|
||||||
|
(if (i32.const 0) (then (unreachable)) (else (drop (i32.eqz (nop)))))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-unary-num-vs-void-after-nested-unreachable
|
||||||
|
(block (unreachable)) (block (drop (i32.eqz (nop))))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-unary-num-vs-num-after-nested-unreachable
|
||||||
|
(block (unreachable)) (drop (i32.eqz (f32.const 1)))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-binary-num-vs-void-after-nested-unreachable
|
||||||
|
(block (unreachable)) (block (drop (f32.eq (i32.const 1))))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-binary-num-vs-num-after-nested-unreachable
|
||||||
|
(block (unreachable)) (drop (f32.eq (i32.const 1) (f32.const 0)))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-block-value-num-vs-void-after-nested-unreachable
|
||||||
|
(block (block (unreachable)) (i32.const 1))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-block-value-num-vs-num-after-nested-unreachable
|
||||||
|
(result i32)
|
||||||
|
(block (result i32) (i32.const 1) (block (unreachable)) (f32.const 0))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-loop-value-num-vs-void-after-nested-unreachable
|
||||||
|
(block (loop (block (unreachable)) (i32.const 1)))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-loop-value-num-vs-num-after-nested-unreachable
|
||||||
|
(result i32)
|
||||||
|
(loop (result i32) (block (unreachable)) (f32.const 0))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-func-value-num-vs-void-after-nested-unreachable
|
||||||
|
(block (unreachable)) (i32.const 1)
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-func-value-num-vs-num-after-nested-unreachable
|
||||||
|
(result i32)
|
||||||
|
(block (unreachable)) (f32.const 0)
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-unary-num-vs-void-after-infinite-loop
|
||||||
|
(loop (br 0)) (block (drop (i32.eqz (nop))))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-unary-num-vs-num-after-infinite-loop
|
||||||
|
(loop (br 0)) (drop (i32.eqz (f32.const 1)))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-binary-num-vs-void-after-infinite-loop
|
||||||
|
(loop (br 0)) (block (drop (f32.eq (i32.const 1))))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-binary-num-vs-num-after-infinite-loop
|
||||||
|
(loop (br 0)) (drop (f32.eq (i32.const 1) (f32.const 0)))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-block-value-num-vs-void-after-infinite-loop
|
||||||
|
(block (loop (br 0)) (i32.const 1))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-block-value-num-vs-num-after-infinite-loop (result i32)
|
||||||
|
(block (result i32) (i32.const 1) (loop (br 0)) (f32.const 0))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-loop-value-num-vs-void-after-infinite-loop
|
||||||
|
(block (loop (loop (br 0)) (i32.const 1)))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-loop-value-num-vs-num-after-infinite-loop (result i32)
|
||||||
|
(loop (result i32) (loop (br 0)) (f32.const 0))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-func-value-num-vs-void-after-infinite-loop
|
||||||
|
(loop (br 0)) (i32.const 1)
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-func-value-num-vs-num-after-infinite-loop (result i32)
|
||||||
|
(loop (br 0)) (f32.const 0)
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-unary-num-vs-void-in-dead-body
|
||||||
|
(if (i32.const 0) (then (drop (i32.eqz (nop)))))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-unary-num-vs-num-in-dead-body
|
||||||
|
(if (i32.const 0) (then (drop (i32.eqz (f32.const 1)))))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-binary-num-vs-void-in-dead-body
|
||||||
|
(if (i32.const 0) (then (drop (f32.eq (i32.const 1)))))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-binary-num-vs-num-in-dead-body
|
||||||
|
(if (i32.const 0) (then (drop (f32.eq (i32.const 1) (f32.const 0)))))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-if-value-num-vs-void-in-dead-body
|
||||||
|
(if (i32.const 0) (then (i32.const 1)))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-if-value-num-vs-num-in-dead-body (result i32)
|
||||||
|
(if (result i32) (i32.const 0) (then (f32.const 0)))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-block-value-num-vs-void-in-dead-body
|
||||||
|
(if (i32.const 0) (then (block (i32.const 1))))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-block-value-num-vs-num-in-dead-body (result i32)
|
||||||
|
(if (result i32) (i32.const 0) (then (block (result i32) (f32.const 0))))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-block-value-num-vs-void-in-dead-body
|
||||||
|
(if (i32.const 0) (then (loop (i32.const 1))))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-block-value-num-vs-num-in-dead-body (result i32)
|
||||||
|
(if (result i32) (i32.const 0) (then (loop (result i32) (f32.const 0))))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-return-second-num-vs-num (result i32)
|
||||||
|
(return (i32.const 1)) (return (f64.const 1))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-br-second-num-vs-num (result i32)
|
||||||
|
(block (result i32) (br 0 (i32.const 1)) (br 0 (f64.const 1)))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-br_if-cond-num-vs-num-after-unreachable
|
||||||
|
(block (br_if 0 (unreachable) (f32.const 0)))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-br_if-num-vs-void-after-unreachable (result i32)
|
||||||
|
(block (result i32)
|
||||||
|
(block (unreachable) (br_if 1 (i32.const 0) (i32.const 0)))
|
||||||
|
)
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-br_if-num-vs-num-after-unreachable (result i32)
|
||||||
|
(block (result i32)
|
||||||
|
(block (result f32) (unreachable) (br_if 1 (i32.const 0) (i32.const 0)))
|
||||||
|
(drop) (i32.const 0)
|
||||||
|
)
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-br_if-num2-vs-num-after-unreachable (result i32)
|
||||||
|
(block (result i32)
|
||||||
|
(unreachable) (br_if 0 (i32.const 0) (i32.const 0)) (i32.const 0)
|
||||||
|
)
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-br_table-num-vs-num-after-unreachable
|
||||||
|
(block (br_table 0 (unreachable) (f32.const 1)))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-br_table-label-num-vs-num-after-unreachable (result i32)
|
||||||
|
(block (result i32) (unreachable) (br_table 0 (f32.const 0) (i32.const 1)))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-br_table-label-num-vs-label-void-after-unreachable
|
||||||
|
(block
|
||||||
|
(block (result f32)
|
||||||
|
(unreachable)
|
||||||
|
(br_table 0 1 0 (i32.const 1))
|
||||||
|
)
|
||||||
|
(drop)
|
||||||
|
)
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-br_table-label-num-vs-label-num-after-unreachable
|
||||||
|
(block (result f64)
|
||||||
|
(block (result f32)
|
||||||
|
(unreachable)
|
||||||
|
(br_table 0 1 1 (i32.const 1))
|
||||||
|
)
|
||||||
|
(drop)
|
||||||
|
(f64.const 0)
|
||||||
|
)
|
||||||
|
(drop)
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-block-value-nested-unreachable-num-vs-void
|
||||||
|
(block (i32.const 3) (block (unreachable)))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-block-value-nested-unreachable-void-vs-num (result i32)
|
||||||
|
(block (block (unreachable)))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-block-value-nested-unreachable-num-vs-num (result i32)
|
||||||
|
(block (result i64) (i64.const 0) (block (unreachable)))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-block-value-nested-unreachable-num2-vs-void (result i32)
|
||||||
|
(block (i32.const 3) (block (i64.const 1) (unreachable))) (i32.const 9)
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-block-value-nested-br-num-vs-void
|
||||||
|
(block (i32.const 3) (block (br 1)))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-block-value-nested-br-void-vs-num (result i32)
|
||||||
|
(block (result i32) (block (br 1 (i32.const 0))))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-block-value-nested-br-num-vs-num (result i32)
|
||||||
|
(block (result i32) (i64.const 0) (block (br 1 (i32.const 0))))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-block-value-nested2-br-num-vs-void
|
||||||
|
(block (block (i32.const 3) (block (br 2))))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-block-value-nested2-br-void-vs-num (result i32)
|
||||||
|
(block (result i32) (block (block (br 2 (i32.const 0)))))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-block-value-nested2-br-num-vs-num (result i32)
|
||||||
|
(block (result i32)
|
||||||
|
(block (result i64) (i64.const 0) (block (br 2 (i32.const 0))))
|
||||||
|
)
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-block-value-nested2-br-num2-vs-void (result i32)
|
||||||
|
(block (i32.const 3) (block (i64.const 1) (br 1))) (i32.const 9)
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-block-value-nested-return-num-vs-void
|
||||||
|
(block (i32.const 3) (block (return)))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-block-value-nested-return-void-vs-num (result i32)
|
||||||
|
(block (block (return (i32.const 0))))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-block-value-nested-return-num-vs-num (result i32)
|
||||||
|
(block (result i64) (i64.const 0) (block (return (i32.const 0))))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-block-value-nested-return-num2-vs-void (result i32)
|
||||||
|
(block (i32.const 3) (block (i64.const 1) (return (i32.const 0))))
|
||||||
|
(i32.const 9)
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-loop-value-nested-unreachable-num-vs-void
|
||||||
|
(loop (i32.const 3) (block (unreachable)))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-loop-value-nested-unreachable-void-vs-num (result i32)
|
||||||
|
(loop (block (unreachable)))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-loop-value-nested-unreachable-num-vs-num (result i32)
|
||||||
|
(loop (result i64) (i64.const 0) (block (unreachable)))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-cont-last-void-vs-empty (result i32)
|
||||||
|
(loop (br 0 (nop)))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $type-cont-last-num-vs-empty (result i32)
|
||||||
|
(loop (br 0 (i32.const 0)))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $tee-local-unreachable-value
|
||||||
|
(local i32)
|
||||||
|
(tee_local 0 (unreachable))
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module (func $br_if-unreachable (result i32)
|
||||||
|
(block (result i32)
|
||||||
|
(block
|
||||||
|
(br_if 1 (unreachable) (i32.const 0))
|
||||||
|
)
|
||||||
|
(i32.const 0)
|
||||||
|
)
|
||||||
|
))
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
|
(assert_invalid
|
||||||
|
(module
|
||||||
|
(func $type-br_if-after-unreachable (result i64)
|
||||||
|
unreachable
|
||||||
|
br_if 0
|
||||||
|
i64.extend_u/i32
|
||||||
|
)
|
||||||
|
)
|
||||||
|
"type mismatch"
|
||||||
|
)
|
||||||
@@ -0,0 +1,203 @@
|
|||||||
|
;; Test that control-flow transfer unwinds stack and it can be anything after.
|
||||||
|
|
||||||
|
(module
|
||||||
|
(func (export "func-unwind-by-unreachable")
|
||||||
|
(i32.const 3) (i64.const 1) (unreachable)
|
||||||
|
)
|
||||||
|
(func (export "func-unwind-by-br")
|
||||||
|
(i32.const 3) (i64.const 1) (br 0)
|
||||||
|
)
|
||||||
|
(func (export "func-unwind-by-br-value") (result i32)
|
||||||
|
(i32.const 3) (i64.const 1) (br 0 (i32.const 9))
|
||||||
|
)
|
||||||
|
(func (export "func-unwind-by-br_table")
|
||||||
|
(i32.const 3) (i64.const 1) (br_table 0 (i32.const 0))
|
||||||
|
)
|
||||||
|
(func (export "func-unwind-by-br_table-value") (result i32)
|
||||||
|
(i32.const 3) (i64.const 1) (br_table 0 (i32.const 9) (i32.const 0))
|
||||||
|
)
|
||||||
|
(func (export "func-unwind-by-return") (result i32)
|
||||||
|
(i32.const 3) (i64.const 1) (return (i32.const 9))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "block-unwind-by-unreachable")
|
||||||
|
(block (i32.const 3) (i64.const 1) (unreachable))
|
||||||
|
)
|
||||||
|
(func (export "block-unwind-by-br") (result i32)
|
||||||
|
(block (i32.const 3) (i64.const 1) (br 0)) (i32.const 9)
|
||||||
|
)
|
||||||
|
(func (export "block-unwind-by-br-value") (result i32)
|
||||||
|
(block (result i32) (i32.const 3) (i64.const 1) (br 0 (i32.const 9)))
|
||||||
|
)
|
||||||
|
(func (export "block-unwind-by-br_table") (result i32)
|
||||||
|
(block (i32.const 3) (i64.const 1) (br_table 0 (i32.const 0))) (i32.const 9)
|
||||||
|
)
|
||||||
|
(func (export "block-unwind-by-br_table-value") (result i32)
|
||||||
|
(block (result i32)
|
||||||
|
(i32.const 3) (i64.const 1) (br_table 0 (i32.const 9) (i32.const 0))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(func (export "block-unwind-by-return") (result i32)
|
||||||
|
(block (result i32) (i32.const 3) (i64.const 1) (return (i32.const 9)))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "block-nested-unwind-by-unreachable") (result i32)
|
||||||
|
(block (result i32) (i32.const 3) (block (i64.const 1) (unreachable)))
|
||||||
|
)
|
||||||
|
(func (export "block-nested-unwind-by-br") (result i32)
|
||||||
|
(block (i32.const 3) (block (i64.const 1) (br 1)) (drop)) (i32.const 9)
|
||||||
|
)
|
||||||
|
(func (export "block-nested-unwind-by-br-value") (result i32)
|
||||||
|
(block (result i32)
|
||||||
|
(i32.const 3) (block (i64.const 1) (br 1 (i32.const 9)))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(func (export "block-nested-unwind-by-br_table") (result i32)
|
||||||
|
(block
|
||||||
|
(i32.const 3) (block (i64.const 1) (br_table 1 (i32.const 1)))
|
||||||
|
(drop)
|
||||||
|
)
|
||||||
|
(i32.const 9)
|
||||||
|
)
|
||||||
|
(func (export "block-nested-unwind-by-br_table-value") (result i32)
|
||||||
|
(block (result i32)
|
||||||
|
(i32.const 3)
|
||||||
|
(block (i64.const 1) (br_table 1 (i32.const 9) (i32.const 1)))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(func (export "block-nested-unwind-by-return") (result i32)
|
||||||
|
(block (result i32)
|
||||||
|
(i32.const 3) (block (i64.const 1) (return (i32.const 9)))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "unary-after-unreachable") (result i32)
|
||||||
|
(f32.const 0) (unreachable) (i64.eqz)
|
||||||
|
)
|
||||||
|
(func (export "unary-after-br") (result i32)
|
||||||
|
(block (result i32) (f32.const 0) (br 0 (i32.const 9)) (i64.eqz))
|
||||||
|
)
|
||||||
|
(func (export "unary-after-br_table") (result i32)
|
||||||
|
(block (result i32)
|
||||||
|
(f32.const 0) (br_table 0 0 (i32.const 9) (i32.const 0)) (i64.eqz)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(func (export "unary-after-return") (result i32)
|
||||||
|
(f32.const 0) (return (i32.const 9)) (i64.eqz)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "binary-after-unreachable") (result i32)
|
||||||
|
(f32.const 0) (f64.const 1) (unreachable) (i64.eq)
|
||||||
|
)
|
||||||
|
(func (export "binary-after-br") (result i32)
|
||||||
|
(block (result i32)
|
||||||
|
(f32.const 0) (f64.const 1) (br 0 (i32.const 9)) (i64.eq)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(func (export "binary-after-br_table") (result i32)
|
||||||
|
(block (result i32)
|
||||||
|
(f32.const 0) (f64.const 1) (br_table 0 (i32.const 9) (i32.const 0))
|
||||||
|
(i64.eq)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(func (export "binary-after-return") (result i32)
|
||||||
|
(f32.const 0) (f64.const 1) (return (i32.const 9)) (i64.eq)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "select-after-unreachable") (result i32)
|
||||||
|
(f32.const 0) (f64.const 1) (i64.const 0) (unreachable) (select)
|
||||||
|
)
|
||||||
|
(func (export "select-after-br") (result i32)
|
||||||
|
(block (result i32)
|
||||||
|
(f32.const 0) (f64.const 1) (i64.const 0) (br 0 (i32.const 9)) (select)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(func (export "select-after-br_table") (result i32)
|
||||||
|
(block (result i32)
|
||||||
|
(f32.const 0) (f64.const 1) (i64.const 0)
|
||||||
|
(br_table 0 (i32.const 9) (i32.const 0))
|
||||||
|
(select)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(func (export "select-after-return") (result i32)
|
||||||
|
(f32.const 0) (f64.const 1) (i64.const 1) (return (i32.const 9)) (select)
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "block-value-after-unreachable") (result i32)
|
||||||
|
(block (result i32) (f32.const 0) (unreachable))
|
||||||
|
)
|
||||||
|
(func (export "block-value-after-br") (result i32)
|
||||||
|
(block (result i32) (f32.const 0) (br 0 (i32.const 9)))
|
||||||
|
)
|
||||||
|
(func (export "block-value-after-br_table") (result i32)
|
||||||
|
(block (result i32)
|
||||||
|
(f32.const 0) (br_table 0 0 (i32.const 9) (i32.const 0))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(func (export "block-value-after-return") (result i32)
|
||||||
|
(block (result i32) (f32.const 0) (return (i32.const 9)))
|
||||||
|
)
|
||||||
|
|
||||||
|
(func (export "loop-value-after-unreachable") (result i32)
|
||||||
|
(loop (result i32) (f32.const 0) (unreachable))
|
||||||
|
)
|
||||||
|
(func (export "loop-value-after-br") (result i32)
|
||||||
|
(block (result i32) (loop (result i32) (f32.const 0) (br 1 (i32.const 9))))
|
||||||
|
)
|
||||||
|
(func (export "loop-value-after-br_table") (result i32)
|
||||||
|
(block (result i32)
|
||||||
|
(loop (result i32)
|
||||||
|
(f32.const 0) (br_table 1 1 (i32.const 9) (i32.const 0))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(func (export "loop-value-after-return") (result i32)
|
||||||
|
(loop (result i32) (f32.const 0) (return (i32.const 9)))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(assert_trap (invoke "func-unwind-by-unreachable") "unreachable")
|
||||||
|
(assert_return (invoke "func-unwind-by-br"))
|
||||||
|
(assert_return (invoke "func-unwind-by-br-value") (i32.const 9))
|
||||||
|
(assert_return (invoke "func-unwind-by-br_table"))
|
||||||
|
(assert_return (invoke "func-unwind-by-br_table-value") (i32.const 9))
|
||||||
|
(assert_return (invoke "func-unwind-by-return") (i32.const 9))
|
||||||
|
|
||||||
|
(assert_trap (invoke "block-unwind-by-unreachable") "unreachable")
|
||||||
|
(assert_return (invoke "block-unwind-by-br") (i32.const 9))
|
||||||
|
(assert_return (invoke "block-unwind-by-br-value") (i32.const 9))
|
||||||
|
(assert_return (invoke "block-unwind-by-br_table") (i32.const 9))
|
||||||
|
(assert_return (invoke "block-unwind-by-br_table-value") (i32.const 9))
|
||||||
|
(assert_return (invoke "block-unwind-by-return") (i32.const 9))
|
||||||
|
|
||||||
|
(assert_trap (invoke "block-nested-unwind-by-unreachable") "unreachable")
|
||||||
|
(assert_return (invoke "block-nested-unwind-by-br") (i32.const 9))
|
||||||
|
(assert_return (invoke "block-nested-unwind-by-br-value") (i32.const 9))
|
||||||
|
(assert_return (invoke "block-nested-unwind-by-br_table") (i32.const 9))
|
||||||
|
(assert_return (invoke "block-nested-unwind-by-br_table-value") (i32.const 9))
|
||||||
|
(assert_return (invoke "block-nested-unwind-by-return") (i32.const 9))
|
||||||
|
|
||||||
|
(assert_trap (invoke "unary-after-unreachable") "unreachable")
|
||||||
|
(assert_return (invoke "unary-after-br") (i32.const 9))
|
||||||
|
(assert_return (invoke "unary-after-br_table") (i32.const 9))
|
||||||
|
(assert_return (invoke "unary-after-return") (i32.const 9))
|
||||||
|
|
||||||
|
(assert_trap (invoke "binary-after-unreachable") "unreachable")
|
||||||
|
(assert_return (invoke "binary-after-br") (i32.const 9))
|
||||||
|
(assert_return (invoke "binary-after-br_table") (i32.const 9))
|
||||||
|
(assert_return (invoke "binary-after-return") (i32.const 9))
|
||||||
|
|
||||||
|
(assert_trap (invoke "select-after-unreachable") "unreachable")
|
||||||
|
(assert_return (invoke "select-after-br") (i32.const 9))
|
||||||
|
(assert_return (invoke "select-after-br_table") (i32.const 9))
|
||||||
|
(assert_return (invoke "select-after-return") (i32.const 9))
|
||||||
|
|
||||||
|
(assert_trap (invoke "block-value-after-unreachable") "unreachable")
|
||||||
|
(assert_return (invoke "block-value-after-br") (i32.const 9))
|
||||||
|
(assert_return (invoke "block-value-after-br_table") (i32.const 9))
|
||||||
|
(assert_return (invoke "block-value-after-return") (i32.const 9))
|
||||||
|
|
||||||
|
(assert_trap (invoke "loop-value-after-unreachable") "unreachable")
|
||||||
|
(assert_return (invoke "loop-value-after-br") (i32.const 9))
|
||||||
|
(assert_return (invoke "loop-value-after-br_table") (i32.const 9))
|
||||||
|
(assert_return (invoke "loop-value-after-return") (i32.const 9))
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,176 @@
|
|||||||
|
(assert_malformed (module quote "(func (export \"\\00\\00\\fe\\ff\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\8f\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\90\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\9f\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\a0\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\bf\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\c0\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\c0\\bf\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\c1\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\c1\\bf\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\c2\\00\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\c2\\2e\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\c2\\7f\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\c2\\80\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\c2\\c0\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\c2\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\c2\\fd\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\df\\00\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\df\\7f\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\df\\c0\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\df\\fd\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\e0\\00\\a0\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\e0\\7f\\a0\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\e0\\80\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\e0\\80\\a0\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\e0\\9f\\a0\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\e0\\9f\\bf\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\e0\\a0\\00\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\e0\\a0\\7f\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\e0\\a0\\c0\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\e0\\a0\\fd\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\e0\\c0\\a0\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\e0\\fd\\a0\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\e1\\00\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\e1\\2e\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\e1\\7f\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\e1\\80\\00\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\e1\\80\\2e\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\e1\\80\\7f\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\e1\\80\\80\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\e1\\80\\c0\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\e1\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\e1\\80\\fd\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\e1\\c0\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\e1\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\e1\\fd\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\ec\\00\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\ec\\7f\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\ec\\80\\00\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\ec\\80\\7f\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\ec\\80\\c0\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\ec\\80\\fd\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\ec\\c0\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\ec\\fd\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\ed\\00\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\ed\\7f\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\ed\\80\\00\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\ed\\80\\7f\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\ed\\80\\c0\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\ed\\80\\fd\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\ed\\a0\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\ed\\a0\\bf\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\ed\\bf\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\ed\\bf\\bf\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\ed\\c0\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\ed\\fd\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\ee\\00\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\ee\\7f\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\ee\\80\\00\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\ee\\80\\7f\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\ee\\80\\c0\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\ee\\80\\fd\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\ee\\c0\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\ee\\fd\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\ef\\00\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\ef\\7f\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\ef\\80\\00\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\ef\\80\\7f\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\ef\\80\\c0\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\ef\\80\\fd\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\ef\\c0\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\ef\\fd\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f0\\00\\90\\90\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f0\\7f\\90\\90\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f0\\80\\80\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f0\\80\\90\\90\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f0\\8f\\90\\90\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f0\\8f\\bf\\bf\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f0\\90\\00\\90\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f0\\90\\7f\\90\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f0\\90\\90\\00\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f0\\90\\90\\7f\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f0\\90\\90\\c0\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f0\\90\\90\\fd\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f0\\90\\c0\\90\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f0\\90\\fd\\90\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f0\\c0\\90\\90\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f0\\fd\\90\\90\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f1\\00\\80\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f1\\23\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f1\\7f\\80\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f1\\80\\00\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f1\\80\\23\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f1\\80\\7f\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f1\\80\\80\\00\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f1\\80\\80\\23\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f1\\80\\80\\7f\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f1\\80\\80\\80\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f1\\80\\80\\c0\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f1\\80\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f1\\80\\80\\fd\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f1\\80\\c0\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f1\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f1\\80\\fd\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f1\\c0\\80\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f1\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f1\\fd\\80\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f3\\00\\80\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f3\\7f\\80\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f3\\80\\00\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f3\\80\\7f\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f3\\80\\80\\00\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f3\\80\\80\\7f\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f3\\80\\80\\c0\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f3\\80\\80\\fd\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f3\\80\\c0\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f3\\80\\fd\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f3\\c0\\80\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f3\\fd\\80\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f4\\00\\80\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f4\\7f\\80\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f4\\80\\00\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f4\\80\\7f\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f4\\80\\80\\00\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f4\\80\\80\\7f\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f4\\80\\80\\c0\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f4\\80\\80\\fd\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f4\\80\\c0\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f4\\80\\fd\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f4\\90\\80\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f4\\bf\\80\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f4\\c0\\80\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f4\\fd\\80\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f5\\80\\80\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f7\\80\\80\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f7\\bf\\bf\\bf\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f8\\23\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f8\\80\\23\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f8\\80\\80\\23\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f8\\80\\80\\80\\23\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f8\\80\\80\\80\\80\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f8\\80\\80\\80\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f8\\80\\80\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f8\\80\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f8\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\f8\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\fb\\bf\\bf\\bf\\bf\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\fc\\23\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\fc\\80\\23\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\fc\\80\\80\\23\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\fc\\80\\80\\80\\23\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\fc\\80\\80\\80\\80\\23\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\fc\\80\\80\\80\\80\\80\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\fc\\80\\80\\80\\80\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\fc\\80\\80\\80\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\fc\\80\\80\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\fc\\80\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\fc\\80\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\fc\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\fd\\bf\\bf\\bf\\bf\\bf\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\fe\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\fe\\ff\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\ff\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\ff\\fe\\00\\00\"))") "invalid UTF-8 encoding")
|
||||||
|
(assert_malformed (module quote "(func (export \"\\ff\\fe\"))") "invalid UTF-8 encoding")
|
||||||
-1
Submodule tests/spec deleted from 6241ce9e15
+59
-62
@@ -1,87 +1,84 @@
|
|||||||
cabal-version: 2.2
|
-- This file has been generated from package.yaml by hpack version 0.20.0.
|
||||||
|
--
|
||||||
|
-- see: https://github.com/sol/hpack
|
||||||
|
--
|
||||||
|
-- hash: 1b02a1858ead3517927e9405dabc17ffb37f0df038564d37e8321b18227389ec
|
||||||
|
|
||||||
name: wasm
|
name: wasm
|
||||||
version: 1.1.2
|
version: 0.1.0
|
||||||
synopsis: WebAssembly Language Toolkit and Interpreter
|
|
||||||
description:
|
|
||||||
Library for parsing and interpreting WebAssembly, including:
|
|
||||||
* WebAssembly Text Representation Parser
|
|
||||||
* WebAssembly Binary Represetnation encoder and decoder
|
|
||||||
* Spec-compatible Module validator (checked with Spec Core Test Suite)
|
|
||||||
* Spec-compatible Interpreter (checked with Spec Core Test Suite)
|
|
||||||
* Extended scripting grammar parser and executor
|
|
||||||
* WebAssembly Module building eDSL
|
|
||||||
author: Ilya Rezvov
|
author: Ilya Rezvov
|
||||||
maintainer: rezvov.ilya@gmail.com
|
maintainer: rezvov.ilya@gmail.com
|
||||||
license: MIT
|
license: MIT
|
||||||
license-file: LICENSE
|
|
||||||
build-type: Simple
|
build-type: Simple
|
||||||
category: Language
|
cabal-version: >= 1.10
|
||||||
homepage: https://github.com/SPY/haskell-wasm
|
|
||||||
bug-reports: https://github.com/SPY/haskell-wasm/issues
|
|
||||||
tested-with: GHC==8.6.5, GHC==8.8.4, GHC==8.10.4, GHC==9.2.7
|
|
||||||
extra-source-files:
|
|
||||||
README.md
|
|
||||||
src/Language/Wasm/Parser.y
|
|
||||||
src/Language/Wasm/Lexer.x
|
|
||||||
|
|
||||||
source-repository head
|
extra-source-files:
|
||||||
type: git
|
src/Language/Wasm/Lexer.x
|
||||||
location: https://github.com/SPY/haskell-wasm
|
src/Language/Wasm/Parser.y
|
||||||
|
|
||||||
library
|
library
|
||||||
|
hs-source-dirs:
|
||||||
|
src
|
||||||
|
ghc-options: -Wwarn -fwarn-incomplete-patterns -fwarn-unused-imports
|
||||||
|
build-depends:
|
||||||
|
array >=0.5 && <0.6
|
||||||
|
, base >=4.6 && <5.0
|
||||||
|
, bytestring >=0.10
|
||||||
|
, containers >=0.5 && <0.6
|
||||||
|
, mtl >=2.2 && <3.0
|
||||||
|
, text >=1.1
|
||||||
|
, transformers >=0.4 && <0.6
|
||||||
|
, utf8-string >=1.0
|
||||||
|
, cereal >= 0.5
|
||||||
|
, vector >= 0.12
|
||||||
|
, ieee754 >= 0.8
|
||||||
|
, deepseq >= 1.4
|
||||||
|
build-tools:
|
||||||
|
alex >=3.1.3
|
||||||
|
, happy >=1.9.4
|
||||||
exposed-modules:
|
exposed-modules:
|
||||||
Language.Wasm.Script
|
|
||||||
Language.Wasm.Lexer
|
Language.Wasm.Lexer
|
||||||
Language.Wasm.Structure
|
|
||||||
Language.Wasm.Interpreter
|
|
||||||
Language.Wasm.Parser
|
Language.Wasm.Parser
|
||||||
Language.Wasm.Validate
|
Language.Wasm.Structure
|
||||||
Language.Wasm.Binary
|
Language.Wasm.Binary
|
||||||
|
Language.Wasm.Validate
|
||||||
|
Language.Wasm.Interpreter
|
||||||
|
Language.Wasm.Script
|
||||||
|
Language.Wasm.FloatUtils
|
||||||
Language.Wasm.Builder
|
Language.Wasm.Builder
|
||||||
Language.Wasm
|
Language.Wasm
|
||||||
other-modules:
|
other-modules:
|
||||||
Language.Wasm.FloatUtils
|
|
||||||
Paths_wasm
|
Paths_wasm
|
||||||
autogen-modules:
|
|
||||||
Paths_wasm
|
|
||||||
hs-source-dirs: src
|
|
||||||
ghc-options: -Wwarn
|
|
||||||
-Wcompat
|
|
||||||
-Wpartial-fields
|
|
||||||
-Wincomplete-uni-patterns
|
|
||||||
-fwarn-incomplete-patterns
|
|
||||||
-fwarn-unused-imports
|
|
||||||
build-tool-depends:
|
|
||||||
alex:alex >=3.1.3 && < 3.3
|
|
||||||
, happy:happy >=1.9.4 && < 1.21
|
|
||||||
build-depends:
|
|
||||||
array >=0.5 && < 0.6
|
|
||||||
, base >=4.6 && < 5
|
|
||||||
, bytestring >=0.10 && < 0.12
|
|
||||||
, cereal >=0.5 && < 0.6
|
|
||||||
, containers >=0.5 && < 0.7
|
|
||||||
, deepseq >=1.4 && < 1.5
|
|
||||||
, ieee754 >=0.8 && < 0.9
|
|
||||||
, mtl >=2.2.1 && < 2.4
|
|
||||||
, primitive >=0.7 && < 0.8
|
|
||||||
, text >=1.1 && < 3
|
|
||||||
, transformers >=0.4 && < 0.7
|
|
||||||
, utf8-string >=1.0 && < 1.1
|
|
||||||
, vector >=0.12.2 && < 0.14
|
|
||||||
default-language: Haskell2010
|
default-language: Haskell2010
|
||||||
|
|
||||||
|
executable wasm
|
||||||
|
main-is: Main.hs
|
||||||
|
hs-source-dirs: exec
|
||||||
|
build-depends:
|
||||||
|
base >=4.6 && <5.0
|
||||||
|
, wasm ==0.1.0
|
||||||
|
, optparse-applicative >= 0.14
|
||||||
|
, bytestring >=0.10 && <0.11
|
||||||
|
, base64-bytestring >= 1.0
|
||||||
|
|
||||||
test-suite test
|
test-suite test
|
||||||
type: exitcode-stdio-1.0
|
type: exitcode-stdio-1.0
|
||||||
main-is: Test.hs
|
main-is: Test.hs
|
||||||
hs-source-dirs: tests
|
hs-source-dirs:
|
||||||
|
tests
|
||||||
build-depends:
|
build-depends:
|
||||||
base
|
base >=4.6 && <5.0
|
||||||
, bytestring
|
, bytestring >=0.10 && <0.11
|
||||||
|
, filepath >=1.3 && <1.5
|
||||||
, directory >= 1.3
|
, directory >= 1.3
|
||||||
, filepath >=1.3
|
, mtl ==2.2.1
|
||||||
, mtl
|
|
||||||
, tasty >=0.7
|
, tasty >=0.7
|
||||||
, tasty-hunit >=0.4.1
|
, tasty-hunit >=0.4.1 && <0.10
|
||||||
, text
|
, text >=1.1 && <1.3
|
||||||
, wasm
|
, wasm ==0.1.0
|
||||||
|
build-tools:
|
||||||
|
alex >=3.1.3
|
||||||
|
, happy >=1.9.4
|
||||||
|
other-modules:
|
||||||
|
Paths_wasm
|
||||||
default-language: Haskell2010
|
default-language: Haskell2010
|
||||||
|
|||||||
Reference in New Issue
Block a user