From 002eef6f463de019859f002c8a795a9c41c70abd Mon Sep 17 00:00:00 2001 From: Shao Cheng Date: Thu, 30 Apr 2020 11:31:53 +0200 Subject: [PATCH 1/2] [ci skip] Use V8 lazy compilation/validation for TH runner --- asterius/src/Asterius/GHCi/Internals.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/asterius/src/Asterius/GHCi/Internals.hs b/asterius/src/Asterius/GHCi/Internals.hs index c1e11b39e5..ca4acfe58e 100644 --- a/asterius/src/Asterius/GHCi/Internals.hs +++ b/asterius/src/Asterius/GHCi/Internals.hs @@ -127,7 +127,8 @@ newGHCiJSSession = do defJSSessionOpts { nodeExtraArgs = [ "--experimental-wasm-return-call", - "--wasm-interpret-all", + "--wasm-lazy-compilation", + "--wasm-lazy-validation", "--wasm-max-mem-pages=65536" ], nodeExtraEnv = From 996509c284dfda8834125973b0bc86dad8447ea7 Mon Sep 17 00:00:00 2001 From: Shao Cheng Date: Fri, 1 May 2020 11:50:11 +0200 Subject: [PATCH 2/2] No need to run binaryen validate for TH splices --- asterius/src/Asterius/JSRun/NonMain.hs | 1 + asterius/src/Asterius/Main.hs | 8 +++++--- asterius/src/Asterius/Main/Task.hs | 4 +++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/asterius/src/Asterius/JSRun/NonMain.hs b/asterius/src/Asterius/JSRun/NonMain.hs index a2d279cd6b..a0bedd270f 100644 --- a/asterius/src/Asterius/JSRun/NonMain.hs +++ b/asterius/src/Asterius/JSRun/NonMain.hs @@ -55,6 +55,7 @@ distNonMain p extra_syms = inputHS = p, outputDirectory = takeDirectory p, outputBaseName = takeBaseName p, + validate = False, tailCalls = True, yolo = True, Asterius.Main.Task.hasMain = False, diff --git a/asterius/src/Asterius/Main.hs b/asterius/src/Asterius/Main.hs index 86ab39531e..e5b6e2d73c 100644 --- a/asterius/src/Asterius/Main.hs +++ b/asterius/src/Asterius/Main.hs @@ -86,6 +86,7 @@ parseTask args = case err_msgs of str_opt "output-directory" $ \s t -> t {outputDirectory = s}, str_opt "output-prefix" $ \s t -> t {outputBaseName = s}, bool_opt "no-main" $ \t -> t {hasMain = False}, + bool_opt "no-validate" $ \t -> t {validate = False}, bool_opt "tail-calls" $ \t -> t {tailCalls = True}, bool_opt "no-gc-sections" $ \t -> t {gcSections = False}, bool_opt "bundle" $ \t -> t {bundle = True}, @@ -317,9 +318,10 @@ ahcDistMain logger task (final_m, report) = do when (optimizeLevel task > 0 || shrinkLevel task > 0) $ do logger "[INFO] Running binaryen optimization" Binaryen.optimize m_ref - logger "[INFO] Validating binaryen IR" - pass_validation <- Binaryen.validate m_ref - when (pass_validation /= 1) $ fail "[ERROR] binaryen validation failed" + when (validate task) $ do + logger "[INFO] Validating binaryen IR" + pass_validation <- Binaryen.validate m_ref + when (pass_validation /= 1) $ fail "[ERROR] binaryen validation failed" m_bin <- Binaryen.serializeModule m_ref logger $ "[INFO] Writing WebAssembly binary to " <> show out_wasm BS.writeFile out_wasm m_bin diff --git a/asterius/src/Asterius/Main/Task.hs b/asterius/src/Asterius/Main/Task.hs index 8baddefefe..c8e4e8c39f 100644 --- a/asterius/src/Asterius/Main/Task.hs +++ b/asterius/src/Asterius/Main/Task.hs @@ -13,6 +13,7 @@ module Asterius.Main.Task outputDirectory, outputBaseName, hasMain, + validate, tailCalls, gcSections, bundle, @@ -51,7 +52,7 @@ data Task inputEntryMJS :: Maybe FilePath, outputDirectory :: FilePath, outputBaseName :: String, - hasMain, tailCalls, gcSections, bundle, debug, outputIR, run, verboseErr, yolo, consoleHistory :: Bool, + hasMain, validate, tailCalls, gcSections, bundle, debug, outputIR, run, verboseErr, yolo, consoleHistory :: Bool, extraGHCFlags :: [String], exportFunctions, extraRootSymbols :: [EntitySymbol], gcThreshold :: Int @@ -68,6 +69,7 @@ defTask = Task outputBaseName = error "Asterius.Main.parseTask: missing outputBaseName", inputEntryMJS = Nothing, hasMain = True, + validate = True, tailCalls = False, gcSections = True, bundle = False,