Skip to content
This repository has been archived by the owner on Nov 24, 2022. It is now read-only.

Commit

Permalink
Update toolchain (#716)
Browse files Browse the repository at this point in the history
  • Loading branch information
TerrorJack authored Jul 13, 2020
1 parent 3772150 commit 7ba89c4
Show file tree
Hide file tree
Showing 11 changed files with 68 additions and 69 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ jobs:

- name: gen-pkgs
run: |
utils/gen-pkgs.hs lts-16.4
utils/gen-pkgs.hs lts-16.5
mkdir gen-pkgs
mv cabal.config pkgs.txt gen-pkgs
Expand Down
40 changes: 19 additions & 21 deletions asterius/src/Asterius/GHCi/Internals.hs
Original file line number Diff line number Diff line change
Expand Up @@ -354,59 +354,57 @@ asteriusRunTH hsc_env _ _ q ty loc s ahc_dist_input =
rts_val <- importMJS s $ dataDir </> "rts" </> "rts.mjs"
mod_buf <- LBS.readFile $ p -<.> "wasm"
req_mod_val <- importMJS s $ p -<.> "req.mjs"
req_val <- evalJSVal s $ jsval req_mod_val <> ".default"
buf_val <- evalJSVal s $ buffer mod_buf
mod_val <- evalJSVal s $ "WebAssembly.compile(" <> jsval buf_val <> ")"
req_val <- eval @JSVal s $ toJS req_mod_val <> ".default"
mod_val <- eval @JSVal s $ "WebAssembly.compile(" <> toJS mod_buf <> ")"
i <-
evalJSVal s $
jsval rts_val
eval s $
toJS rts_val
<> ".newAsteriusInstance(Object.assign("
<> jsval req_val
<> toJS req_val
<> ",{module:"
<> jsval mod_val
<> toJS mod_val
<> "}))"
arr_buf <- evalJSVal s $ buffer (encode loc)
let runner_closure =
jsval i <> ".symbolTable."
toJS i <> ".symbolTable."
<> fromString
(CBS.unpack (entityName runner_sym))
buf_conv_closure =
jsval i <> ".symbolTable."
toJS i <> ".symbolTable."
<> fromString
(CBS.unpack (entityName buf_conv_sym))
uint8_arr = "new Uint8Array(" <> jsval arr_buf <> ")"
uint8_arr = "new Uint8Array(" <> toJS (encode loc) <> ")"
uint8_arr_sn =
jsval i
toJS i
<> ".exports.context.stablePtrManager.newJSVal("
<> uint8_arr
<> ")"
uint8_arr_closure =
jsval i <> ".exports.rts_mkJSVal(" <> uint8_arr_sn <> ")"
toJS i <> ".exports.rts_mkJSVal(" <> uint8_arr_sn <> ")"
bs_closure =
jsval i
toJS i
<> ".exports.rts_apply("
<> buf_conv_closure
<> ","
<> uint8_arr_closure
<> ")"
runner_closure' =
jsval i
toJS i
<> ".exports.rts_apply("
<> runner_closure
<> ","
<> bs_closure
<> ")"
hv_closure = fromString $ show q
applied_closure =
jsval i
toJS i
<> ".exports.rts_apply("
<> runner_closure'
<> ","
<> hv_closure
<> ")"
tid =
jsval i <> ".exports.rts_evalLazyIO(" <> applied_closure <> ")"
evalNone s tid
toJS i <> ".exports.rts_evalLazyIO(" <> applied_closure <> ")"
eval @() s tid
evaluate i
where
runner_sym = closureSymbol hsc_env "ghci" "Asterius.GHCi" $ case ty of
Expand All @@ -427,12 +425,12 @@ asteriusRunTH hsc_env _ _ q ty loc s ahc_dist_input =
asteriusRunModFinalizers :: GHC.HscEnv -> Session -> JSVal -> IO ()
asteriusRunModFinalizers hsc_env s i = do
let run_mod_fin_closure =
jsval i <> ".symbolTable."
toJS i <> ".symbolTable."
<> fromString
(CBS.unpack (entityName run_mod_fin_sym))
tid =
jsval i <> ".exports.rts_evalLazyIO(" <> run_mod_fin_closure <> ")"
evalNone s tid
toJS i <> ".exports.rts_evalLazyIO(" <> run_mod_fin_closure <> ")"
eval @() s tid
pure ()
where
run_mod_fin_sym =
Expand Down
27 changes: 14 additions & 13 deletions asterius/src/Asterius/JSRun/Main.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeApplications #-}

module Asterius.JSRun.Main
( newAsteriusInstance,
Expand All @@ -10,36 +11,36 @@ where

import Asterius.BuildInfo
import qualified Data.ByteString.Lazy as LBS
import Data.String
import Language.JavaScript.Inline.Core
import System.FilePath

newAsteriusInstance :: Session -> FilePath -> LBS.ByteString -> IO JSVal
newAsteriusInstance s req_path mod_buf = do
rts_val <- importMJS s $ dataDir </> "rts" </> "rts.mjs"
req_mod_val <- importMJS s req_path
req_val <- evalJSVal s $ jsval req_mod_val <> ".default"
buf_val <- evalJSVal s $ buffer mod_buf
mod_val <- evalJSVal s $ "WebAssembly.compile(" <> jsval buf_val <> ")"
evalJSVal s $
jsval rts_val
req_val <- eval @JSVal s $ toJS req_mod_val <> ".default"
mod_val <- eval @JSVal s $ "WebAssembly.compile(" <> toJS mod_buf <> ")"
eval s $
toJS rts_val
<> ".newAsteriusInstance(Object.assign("
<> jsval req_val
<> toJS req_val
<> ",{module:"
<> jsval mod_val
<> toJS mod_val
<> "}))"

hsMain :: String -> Session -> JSVal -> IO ()
hsMain prog_name s i =
evalNone s $
jsval i
eval s $
toJS i
<> ".exports.main().catch(err => { if (!(err.startsWith('ExitSuccess') || err.startsWith('ExitFailure '))) { "
<> jsval i
<> toJS i
<> ".fs.writeSync(2, `"
<> code prog_name
<> fromString prog_name
<> ": ${err}\n`);}})"

hsStdOut :: Session -> JSVal -> IO LBS.ByteString
hsStdOut s i = evalBuffer s $ jsval i <> ".stdio.stdout()"
hsStdOut s i = eval s $ toJS i <> ".stdio.stdout()"

hsStdErr :: Session -> JSVal -> IO LBS.ByteString
hsStdErr s i = evalBuffer s $ jsval i <> ".stdio.stderr()"
hsStdErr s i = eval s $ toJS i <> ".stdio.stderr()"
13 changes: 7 additions & 6 deletions asterius/src/Asterius/JSRun/NonMain.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeApplications #-}

module Asterius.JSRun.NonMain
( distNonMain,
Expand Down Expand Up @@ -76,16 +77,16 @@ newAsteriusInstanceNonMain s p extra_syms m = do
wasm_path = p -<.> "wasm"
rts_val <- importMJS s rts_path
req_mod_val <- importMJS s req_path
req_val <- evalJSVal s $ jsval req_mod_val <> ".default"
req_val <- eval @JSVal s $ toJS req_mod_val <> ".default"
mod_val <-
evalJSVal s $
eval @JSVal s $
"import('fs').then(fs => fs.promises.readFile("
<> fromString (show wasm_path)
<> ")).then(buf => WebAssembly.compile(buf))"
evalJSVal s $
jsval rts_val
eval s $
toJS rts_val
<> ".newAsteriusInstance(Object.assign("
<> jsval req_val
<> toJS req_val
<> ",{module:"
<> jsval mod_val
<> toJS mod_val
<> "}))"
17 changes: 8 additions & 9 deletions asterius/test/nomain.hs
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,20 @@ main = do
["base_AsteriusziTopHandler_runNonIO_closure", "NoMain_x_closure"]
m
let x_closure =
jsval i
toJS i
<> ".exports.rts_apply("
<> jsval i
<> toJS i
<> ".symbolTable.base_AsteriusziTopHandler_runNonIO_closure,"
<> jsval i
<> toJS i
<> ".symbolTable.NoMain_x_closure)"
x_tid =
"await "
<> jsval i
<> toJS i
<> ".exports.rts_evalIO("
<> x_closure
<> ")"
x_ret = jsval i <> ".exports.getTSOret(" <> x_tid <> ")"
x_sp = jsval i <> ".exports.rts_getStablePtr(" <> x_ret <> ")"
x_val' = jsval i <> ".getJSVal(" <> x_sp <> ")"
x_val = "(async () => " <> x_val' <> ")()"
x <- evalBuffer s x_val
x_ret = toJS i <> ".exports.getTSOret(" <> x_tid <> ")"
x_sp = toJS i <> ".exports.rts_getStablePtr(" <> x_ret <> ")"
x_val = toJS i <> ".getJSVal(" <> x_sp <> ")"
x <- eval s x_val
LBS.putStr x
2 changes: 1 addition & 1 deletion base.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ENV \
PATH=/root/.asterius-local-install-root/bin:/root/.asterius-snapshot-install-root/bin:/root/.asterius-compiler-bin:/root/.local/bin:/root/.nvm/versions/node/v14.5.0/bin:${PATH}

RUN \
echo 'deb [check-valid-until=no] http://snapshot.debian.org/archive/debian/20200708T084958Z sid main contrib non-free' > /etc/apt/sources.list && \
echo 'deb [check-valid-until=no] http://snapshot.debian.org/archive/debian/20200713T150707Z sid main contrib non-free' > /etc/apt/sources.list && \
apt update && \
apt full-upgrade -y && \
apt install -y \
Expand Down
2 changes: 1 addition & 1 deletion dev.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ENV \
PATH=/root/.local/bin:/root/.nvm/versions/node/v14.5.0/bin:${PATH}

RUN \
echo 'deb [check-valid-until=no] http://snapshot.debian.org/archive/debian/20200708T084958Z sid main contrib non-free' > /etc/apt/sources.list && \
echo 'deb [check-valid-until=no] http://snapshot.debian.org/archive/debian/20200713T150707Z sid main contrib non-free' > /etc/apt/sources.list && \
apt update && \
apt full-upgrade -y && \
apt install -y \
Expand Down
24 changes: 12 additions & 12 deletions ghc-toolkit/boot-libs/cabal.config
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ constraints:
authenticate-oauth ==1.6.0.1,
auto ==0.4.3.1,
auto-update ==0.1.6,
autoexporter ==1.1.17,
autoexporter ==1.1.18,
avers ==0.0.17.1,
avro ==0.5.2.0,
aws-cloudfront-signed-cookies ==0.2.0.6,
Expand Down Expand Up @@ -452,7 +452,7 @@ constraints:
cast ==0.1.0.2,
category ==0.2.5.0,
cayley-client ==0.4.13,
cborg ==0.2.3.0,
cborg ==0.2.4.0,
cborg-json ==0.2.2.0,
cereal ==0.5.8.1,
cereal-conduit ==0.8.0,
Expand Down Expand Up @@ -481,9 +481,9 @@ constraints:
cipher-des ==0.0.6,
cipher-rc4 ==0.1.4,
circle-packing ==0.1.0.6,
clash-ghc ==1.2.2,
clash-lib ==1.2.2,
clash-prelude ==1.2.2,
clash-ghc ==1.2.3,
clash-lib ==1.2.3,
clash-prelude ==1.2.3,
classy-prelude ==1.5.0,
classy-prelude-conduit ==1.5.0,
classy-prelude-yesod ==1.5.0,
Expand Down Expand Up @@ -725,7 +725,7 @@ constraints:
dynamic-state ==0.3.1,
dyre ==0.8.12,
eap ==0.9.0.2,
earcut ==0.1.0.2,
earcut ==0.1.0.4,
easy-file ==0.2.2,
echo ==0.1.3,
ecstasy ==0.2.1.0,
Expand Down Expand Up @@ -1041,7 +1041,7 @@ constraints:
hasql-pool ==0.5.2,
hasql-transaction ==1.0.0.1,
hasty-hamiltonian ==1.3.3,
haxr ==3000.11.4,
haxr ==3000.11.4.1,
hdaemonize ==0.5.6,
headroom ==0.2.2.1,
heap ==1.0.4,
Expand Down Expand Up @@ -1477,7 +1477,7 @@ constraints:
monad-coroutine ==0.9.0.4,
monad-extras ==0.6.0,
monad-journal ==0.8.1,
monad-logger ==0.3.33,
monad-logger ==0.3.34,
monad-logger-json ==0.1.0.0,
monad-logger-prefix ==0.1.11,
monad-loops ==0.4.3,
Expand Down Expand Up @@ -1758,7 +1758,7 @@ constraints:
product-profunctors ==0.10.0.1,
profiterole ==0.1,
profunctors ==5.5.2,
project-template ==0.2.0.1,
project-template ==0.2.1.0,
projectroot ==0.2.0.1,
prometheus-client ==1.0.0.1,
promises ==0.3,
Expand Down Expand Up @@ -1933,7 +1933,7 @@ constraints:
securemem ==0.1.10,
selda ==0.5.1.0,
selda-json ==0.1.1.0,
selective ==0.4.1,
selective ==0.4.1.1,
semialign ==1.1,
semialign-indexed ==1.1,
semialign-optics ==1.1,
Expand Down Expand Up @@ -2230,7 +2230,7 @@ constraints:
th-reify-many ==0.1.9,
th-strict-compat ==0.1.0.1,
th-test-utils ==1.0.2,
these ==1.1,
these ==1.1.1,
these-lens ==1,
these-optics ==1,
thread-hierarchy ==0.3.0.1,
Expand Down Expand Up @@ -2508,7 +2508,7 @@ constraints:
yesod-persistent ==1.6.0.4,
yesod-recaptcha2 ==1.0.0,
yesod-sitemap ==1.6.0,
yesod-static ==1.6.0.1,
yesod-static ==1.6.1.0,
yesod-test ==1.6.10,
yesod-websockets ==0.3.0.2,
yi-rope ==0.11,
Expand Down
4 changes: 2 additions & 2 deletions stack-profile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ build:
library-profiling: true
executable-profiling: true

resolver: lts-16.4
resolver: lts-16.5
extra-deps:
- binaryen-0.0.2.0
- url: https://github.com/tweag/inline-js/archive/9ef93df2026c11d0bbee0b96287eb41042bf437d.tar.gz
- url: https://github.com/tweag/inline-js/archive/a72686564dd9929602702c5a845d667e05e080b2.tar.gz
subdirs:
- inline-js-core
packages:
Expand Down
4 changes: 2 additions & 2 deletions stack.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
resolver: lts-16.4
resolver: lts-16.5
extra-deps:
- binaryen-0.0.2.0
- url: https://github.com/tweag/inline-js/archive/9ef93df2026c11d0bbee0b96287eb41042bf437d.tar.gz
- url: https://github.com/tweag/inline-js/archive/a72686564dd9929602702c5a845d667e05e080b2.tar.gz
subdirs:
- inline-js-core
packages:
Expand Down
2 changes: 1 addition & 1 deletion utils/gen-pkgs.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env stack
{-
stack --resolver lts-16.4 script
stack --resolver lts-16.5 script
--package Cabal
--package containers
--package pantry
Expand Down

0 comments on commit 7ba89c4

Please sign in to comment.