fix memory growing for empty data segments

This commit is contained in:
Ilya Rezvov
2018-04-08 10:53:14 -07:00
parent 8b5c7fa154
commit 87758b2789
2 changed files with 3 additions and 2 deletions
+2 -1
View File
@@ -316,6 +316,7 @@ initialize inst Module {elems, datas, start} store = do
return $ st { tableInstances = tableInstances st Vector.// [(idx, table)] }
fitOrGrowMemory :: Address -> Store -> Int -> IO MemoryInstance
fitOrGrowMemory idx st 0 = return $ memInstances st ! idx
fitOrGrowMemory idx st last = do
let m@(MemoryInstance mem maxLen) = memInstances st ! idx
let len = IOVector.length mem
@@ -329,7 +330,7 @@ initialize inst Module {elems, datas, start} store = do
Nothing -> increased
Just max ->
let maxInBytes = max * pageSize in
if maxInBytes <= last
if maxInBytes < last
then error $ "Max memory length reached. Max " ++ show max ++ "(" ++ show maxInBytes ++ "b), but requested " ++ show last
else increased
+1 -1
View File
@@ -34,7 +34,7 @@ compile file = do
main :: IO ()
main = do
files <- Directory.listDirectory "tests/samples"
-- let files = ["func.wast"]
-- let files = ["memory.wast"]
scriptTestCases <- (`mapM` files) $ \file -> do
content <- LBS.readFile $ "tests/samples/" ++ file
let Right script = Parser.parseScript <$> Lexer.scanner content