Commit 404cc93b authored by Camil Staps's avatar Camil Staps 🚀

Merge branch 'drop-wabt-dependency' into 'master'

Drop wabt dependency: use SpiderMonkey to convert wat to wasm

See merge request !100
parents 91fe7ce3 628c34bd
Pipeline #20588 passed with stages
in 19 minutes and 55 seconds
......@@ -19,23 +19,12 @@ RUN \
RUN apt-get install -y -qq --no-install-recommends curl unzip libnspr4 &&\
mkdir /tmp/jsshell &&\
cd /tmp/jsshell &&\
curl "http://ftp.mozilla.org/pub/firefox/nightly/latest-oak/jsshell-linux-x86_64.zip" -o jsshell.zip &&\
curl "http://ftp.mozilla.org/pub/firefox/nightly/latest-mozilla-central/jsshell-linux-x86_64.zip" -o jsshell.zip &&\
unzip "jsshell.zip" &&\
cp js /usr/bin &&\
cd - &&\
rm -r /tmp/jsshell
# Wabt, to convert WebAssembly text to binary
# TODO: when SpiderMonkey's function for this is updated this dependency can be removed
RUN apt-get install -y -qq --no-install-recommends cmake python file &&\
git clone --recurse-submodules https://github.com/webassembly/wabt /tmp/wabt &&\
mkdir /tmp/wabt/build &&\
cd /tmp/wabt/build &&\
cmake .. &&\
make wat2wasm &&\
cp wat2wasm /usr/bin &&\
rm -rf /tmp/wabt
RUN install_clean_nightly.sh base lib-argenv lib-directory lib-dynamics lib-graphcopy lib-platform lib-stdlib
RUN git clone https://gitlab.science.ru.nl/cstaps/clean-tools /tmp/clean-tools &&\
......
WAT2WASM?=wat2wasm
JS?=js
WASM:=abc_interpreter.wasm util.wasm
all: $(WASM) abc_instructions.js
%.wasm: %.wat
$(WAT2WASM) $< -o $@
$(JS) ../tools/wat2wasm.js $< -o $@
abc_interpreter.wat: .FORCE
$(MAKE) -C ../tools interpretergenwasm
......
......@@ -27,7 +27,7 @@ import interpretergen
| EEnd
| ECall !Label !ExprList
| E.u: EIf` !(Expr TWord) !(Expr u) !(Expr u) & typename u
| E.u: ESelect !(Expr u) !(Expr u) !(Expr TWord) & typename u
| Ei64_const !Int
......@@ -94,8 +94,7 @@ where
EEnd -> ")"
ECall l as -> "(call $"+++l+++print_args (starts_with 0 "clean_" l) as+++")"
EIf` c t e -> "(if (result "+++type t+++")"+++i64_to_cond c
+++"(then"+++toString t+++")(else"+++toString e+++"))"
ESelect t e c -> "(select"+++toString t+++toString e+++toString c+++")"
Ei64_const i -> "(i64.const "+++toString i+++")"
......@@ -212,7 +211,7 @@ type e = case type` e of
where
type` :: !(Expr t) -> Maybe String
type` e = case e of
EIf` _ t e -> either t e
ESelect t e _ -> either t e
Ei64_const _ -> Just "i64"
......@@ -532,7 +531,7 @@ if_i64_or_i32_expr :: !(Expr t) !(Expr t) -> Expr t
if_i64_or_i32_expr a _ = a
if_expr :: !(Expr TWord) !(Expr t) !(Expr t) -> Expr t | typename t
if_expr c t e = EIf` c t e
if_expr c t e = ESelect t e c
begin_instruction :: !String !Target -> Target
begin_instruction name t = {t & instrs=[name:t.instrs], output=[]}
......
if (scriptArgs.length!=3 || scriptArgs[1]!='-o')
crash('Usage: js wat2wasm.js INFILE -o OUTFILE');
var infile=scriptArgs[0];
var outfile=scriptArgs[2];
var wat=read(infile);
var wasm=wasmTextToBinary(wat);
os.file.writeTypedArrayToFile(outfile, wasm);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment