Skip to content
This repository has been archived by the owner on Sep 7, 2023. It is now read-only.

WebAssembly Backend #773

Draft
wants to merge 73 commits into
base: release-1.0
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
a1b9df8
(WIP) New backend compiler, new code org, new build
jeromesimeon Jan 14, 2020
d8dc92c
(WIP) Get the JavaScript extraction for the compiler back
jeromesimeon Jan 14, 2020
962e581
(WIP) Refactor OCaml code
jeromesimeon Jan 15, 2020
badf7c3
Fix to Make clean
jeromesimeon Jan 15, 2020
0b15107
Small fixes to build
jeromesimeon Jan 15, 2020
38bead8
(WIP) Switch back to new backend CodeGeneration for JS
jeromesimeon Jan 16, 2020
3e2ee3b
Remove ES5 support
jeromesimeon Jan 16, 2020
9be34fe
Somewhat properly hooks up new JavaScript backend
jeromesimeon Jan 16, 2020
4edeeb1
fix(compiler) Various adjustments to JS runtime and execution engine …
jeromesimeon Jan 17, 2020
a9ea6e8
Cleanup of JavaScript runtime for new backend
jeromesimeon Jan 17, 2020
0a3e650
(WIP) ergo-compiler package tests now work again
jeromesimeon Jan 17, 2020
f26d3fc
Some initial fixes for ergo-engine, switch to new concerto
jeromesimeon Jan 17, 2020
b3c7b22
Sanitize contract name in Cicero target
jeromesimeon Jan 18, 2020
500f980
Fix to the DateTime component of the runtime
jeromesimeon Jan 18, 2020
3338ee8
More fixes to DateTime runtime and tests
jeromesimeon Jan 18, 2020
348466f
Fix to doubleToInteger runtime
jeromesimeon Jan 18, 2020
41fa53d
Several fixes to the compiler for optional values
jeromesimeon Jan 19, 2020
a18824c
Temporary fixes to cast and unbrand for new runtime
jeromesimeon Jan 19, 2020
8f08fdb
Fixes runtime for enums, fixes tests
jeromesimeon Jan 19, 2020
871a303
Further cleanup and refactoring of JavaScript runtime
jeromesimeon Jan 20, 2020
e64b17b
Further cleanup of JavaScript code emit
jeromesimeon Jan 21, 2020
962a897
Various fixes for new compiler
jeromesimeon Jan 25, 2020
1f370f7
chore(dep) Upgrade to latest dev version of Concerto
jeromesimeon Jan 25, 2020
ec1a8fc
chore(dep) Upgrade fast stringify
jeromesimeon Jan 25, 2020
6e6bece
Remove temp config; Rename atd files
jeromesimeon Jan 26, 2020
c1afe77
proof(backend) Discharges some of the proof obligations in the backen…
jeromesimeon Jan 26, 2020
e8c8937
fix(runtime) Update to JavaScript runtime; Small refactor
jeromesimeon Jan 27, 2020
e7a94c7
fix(doc) Update makefile for documentation build
jeromesimeon Jan 27, 2020
ffc183e
fix(build) Add qcert to opam description
jeromesimeon Jan 27, 2020
e47d522
feature(compiler) Consolidate ES6 and Cicero target into a new single…
jeromesimeon Jan 27, 2020
3a348f1
refactor(compiler) Reorganization and renaming for internal types
jeromesimeon Jan 29, 2020
37cfff0
refactor(types) In ErgoCT and ErgoNNRC, always use internal in functi…
jeromesimeon Jan 29, 2020
838d7a7
refactor(nnrc) ErgoNNRC function tables are now properly represented …
jeromesimeon Jan 29, 2020
c05a49f
feature(semantic) Add eval-based semantic for ErgoNNRC
jeromesimeon Jan 29, 2020
cdb8e6c
refactor(compiler) Add ErgoImp AST with eval, breakdown ErgoNNRC->ES6…
jeromesimeon Jan 30, 2020
359e46a
feature(proof) Now with a proof of correctness for the compilation fr…
jeromesimeon Jan 31, 2020
ce98cd6
fix(build) Updates for latest master version of Q*cert
jeromesimeon Feb 18, 2020
1581e1f
chore(rebase) Fixes after rebase with master: mostly re-enable moneta…
jeromesimeon Jul 16, 2020
3016cea
chore(build) Switch to OCaml 4.09 and Qcert 2.0
jeromesimeon Jul 25, 2020
bf32c1d
chore(rebase) Adjust tests and code after rebase with master
jeromesimeon Aug 13, 2020
00fd109
fix(doc) Update DEVELOPERS for 1.0
jeromesimeon Aug 13, 2020
ceef513
fix(test) Rebuild assets and fixes tests
jeromesimeon Aug 13, 2020
9e64c94
chore(upgrade) Ergo compiler code switched to Coq 8.12
jeromesimeon Aug 13, 2020
816ff8b
WIP(Wasm) Some initial compiler extension for Wasm
jeromesimeon Jan 14, 2020
9eb7c45
feature(wasm) Add, almost, compilation path from Ergo to Wasm
jeromesimeon Jul 20, 2020
e91e7ac
fix(test) license check and some tests
jeromesimeon Jul 20, 2020
da2a1dc
fix(rebase) Adjust code after rebase with master
jeromesimeon Jul 23, 2020
8da4009
Use QCert's new Wasm backend functor
pkel Aug 2, 2020
480ef41
chore(dep) Fixes for Coq 8.12 + license check fixes
jeromesimeon Aug 13, 2020
146f698
fix(Wasm) Update to new compile call with type hierarchy
jeromesimeon Aug 14, 2020
c069bc2
fix(engine) Make calls async yet again...
jeromesimeon Aug 14, 2020
8c63e7a
feature(wasm) Some initial code for the new Ergo to Wasm compiler
jeromesimeon Aug 17, 2020
0f63761
fix(Wasm) --target wasm in the compiler now generates binary wasm for…
jeromesimeon Aug 17, 2020
47a768c
feature(engine) trigger is now just invoking main
jeromesimeon Aug 17, 2020
1d61a02
refactor(compiler) Remove unneeded dispatch/init boiler plates in ES6…
jeromesimeon Aug 17, 2020
8172ea5
refactor(engine) Updates to API calls / terminology in the engine
jeromesimeon Aug 17, 2020
066c676
feature(wasm) Gets first end to end Wasm backed with lots of hacks
jeromesimeon Aug 18, 2020
aa24e1a
Return B64 from wasm backend.
pkel Aug 18, 2020
930668a
Avoid Base64 on JS/Ocaml interop
pkel Aug 18, 2020
1dcb43c
chore(dep) Add wasm to OCaml dependencies in CI and DEVELOPERS.md
jeromesimeon Aug 18, 2020
edf2f94
fix(wasm) Various fixes to tests
jeromesimeon Aug 18, 2020
e93d6e8
fix(wasm) Various fixes to engine and tests, factor out error handlimg
jeromesimeon Aug 19, 2020
4fa6ad1
fix(build) Remove base64 from js_of_ocaml build dependencies
jeromesimeon Aug 19, 2020
dcab51c
refactor(runtime) Remove error unwrap from ES6 runtime
jeromesimeon Aug 19, 2020
f06b956
fix(dep) dependency for assemblyscript loader
jeromesimeon Aug 19, 2020
69b2b96
fix(runtime) Temporarily remove copy of WASM runtime -- until we know…
jeromesimeon Aug 19, 2020
c130eb0
fix(engine) Some initial WASM test harness
jeromesimeon Aug 19, 2020
cb24fcf
fix(wasm) More tests for WASM + engine
jeromesimeon Aug 19, 2020
2e7d3d7
fix(wasm) Update with latest Wasm compiler + volumediscount test
jeromesimeon Aug 19, 2020
fa4c660
fix(tests) Fixes broken tests
jeromesimeon Aug 19, 2020
a864a1b
fix(compiler) Fix to logic manager for ES6 compiled archives
jeromesimeon Aug 19, 2020
d53e5cd
fix(wasm) Add runtime and test for float -> integer coercion
jeromesimeon Aug 20, 2020
04c7ccf
fix(wasm) Update to latest Q*cert WASM backend/runtime + pyth test
jeromesimeon Aug 21, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
18 changes: 9 additions & 9 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,23 @@ common_steps: &common_steps
opam init --disable-sandboxing -j 1 -n -y
sed -i "s/^jobs: [0-9]*/jobs: $NJOBS/g" ~/.opam/config
eval $(opam env)
opam switch create 4.07.1 || true
opam switch set 4.07.1
opam switch create $OCAML_VERSION || true
opam switch set $OCAML_VERSION
opam repo add coq-released https://coq.inria.fr/opam/released || true
opam update || true
- run:
name: "Install OCaml deps"
command: |
opam install -y -v --jobs=2 ocamlbuild menhir base64 js_of_ocaml js_of_ocaml-ppx yojson atdgen re calendar uri
opam install -y -v --jobs=2 dune menhir base64 js_of_ocaml js_of_ocaml-ppx yojson atdgen re calendar uri wasm.1.0.1
- run:
name: "Install Coq"
command: |
opam install -y -v coq.8.8.2 coq-flocq coq-jsast
opam install -y -v coq.8.12.0 coq-flocq coq-jsast
no_output_timeout: 30m
- run:
name: "Install Q*cert"
command: |
opam install -y -v coq-qcert.1.4.1
opam install -y -v coq-qcert.2.1.0
no_output_timeout: 30m
- save_cache:
<<: *common_cache_key
Expand All @@ -64,7 +64,7 @@ common_steps: &common_steps
name: 'Build the Ergo compiler'
command: |
eval $(opam env)
make setup
make configure
make all
- run:
name: 'Testing'
Expand All @@ -73,12 +73,12 @@ common_steps: &common_steps

version: 2
jobs:
4.07.1:
4.09.1:
docker:
- image: circleci/openjdk:8-jdk
environment:
- TERM: dumb
- OCAML_VERSION: "4.07.x"
- OCAML_VERSION: "4.09.1"
- CIRCLE_TEST_REPORTS: /tmp/circleci-test-results
- NJOBS: 2
- NPM_CONFIG_PREFIX: "~/.npm-global"
Expand All @@ -88,4 +88,4 @@ workflows:
version: 2
build-deploy:
jobs:
- 4.07.1
- 4.09.1
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,13 @@ Makefile.config
*~
.#*
*.vo
*.vos
*.vok
*.v.d
*.glob
*.aux
*.lia.cache
.Makefile.coq.d
*.ctoj
.DS_Store
_CoqProject
Expand All @@ -44,3 +48,7 @@ website/i18n/*
!website/i18n/en.json
*.sw[p]
thumbs.db

# generated by dune
*.merlin
*.install
File renamed without changes
12 changes: 6 additions & 6 deletions DEVELOPERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ Before you can build Ergo, you must install and configure the following prerequi
$ npm install -g lerna@^3.15.0
```

* [opam](https://opam.ocaml.org): the OCaml package manager, for OCaml 4.07.1. To install:
* [opam](https://opam.ocaml.org): the OCaml package manager, for OCaml 4.09.1. To install:

```sh
$ sh <(curl -sL https://raw.githubusercontent.com/ocaml/opam/master/shell/install.sh)
$ eval $(opam env)
$ opam switch create 4.07.1
$ opam switch create 4.09.1
```

#### Install development version
Expand All @@ -53,8 +53,8 @@ To rebuild the compiler from the source, you will need Coq 8.8.2 and OCaml 4.07.

```sh
$ opam repo add coq-released https://coq.inria.fr/opam/released
$ opam install ocamlbuild menhir base64 js_of_ocaml js_of_ocaml-ppx yojson atdgen re calendar uri
$ opam install coq.8.8.2 coq-qcert.1.4.1
$ opam install dune menhir base64 js_of_ocaml js_of_ocaml-ppx yojson atdgen re calendar uri wasm.1.0.1
$ opam install coq.8.8.2 coq-qcert.2.0.0
```

##### Build the Ergo Compiler and REPL
Expand All @@ -63,7 +63,7 @@ To recompile Ergo from its source, do:

```sh
$ make cleanall
$ make setup
$ make configure
$ make all
```

Expand All @@ -80,7 +80,7 @@ If successful, you should find the following binaries in the `bin/` directory:
We write unit and integration tests with Mocha and Cucumber. To run all of the tests once run:

```text
lerna run test
npm run test
```

### Writing Documentation
Expand Down
114 changes: 85 additions & 29 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,48 +20,95 @@ include Makefile.coq_modules
#
CP=cp

FILES = $(addprefix mechanization/,$(MODULES:%=%.v))
FILES = $(addprefix compiler/core/,$(MODULES:%=%.v))

## Compiler
all:
@$(MAKE) prepare
@$(MAKE) MAKEFLAGS= ergo

# Setup
setup:
@$(MAKE) npm-setup
# Stdlib

%.ctoj: %.cto
./scripts/cto2ctoj.js parse $<

compiler/lib/resources.ml: compiler/stdlib/accordproject.ctoj \
compiler/stdlib/stdlib.ergo \
compiler/stdlib/etime.ergo \
compiler/stdlib/template.ergo \
runtimes/javascript/ergo-runtime.js
echo '(* generated ocaml file *)' > compiler/lib/resources.ml
(for i in accordproject; do \
echo "let $$i = {xxx|"; \
cat compiler/stdlib/$$i.ctoj; \
echo "|xxx}"; \
done) >> compiler/lib/resources.ml
(for i in stdlib etime template; do \
echo "let $$i = {xxx|"; \
cat compiler/stdlib/$$i.ergo; \
echo "|xxx}"; \
done) >> compiler/lib/resources.ml
(for i in runtime; do \
echo "let ergo_$$i = {xxx|"; \
cat ./runtimes/javascript/ergo-$$i.js; \
echo "|xxx}"; \
done) >> compiler/lib/resources.ml
(echo `date "+let builddate = {xxx|%b %d, %Y|xxx}"`) >> compiler/lib/resources.ml

# Configure
runtimes/javascript/ergo-runtime.js: runtimes/javascript/ergo-runtime-core.js \
runtimes/javascript/ergo-runtime-tostring.js \
runtimes/javascript/ergo-runtime-date-time.js \
runtimes/javascript/ergo-runtime-log.js \
runtimes/javascript/ergo-runtime-math.js \
runtimes/javascript/ergo-runtime-uri.js
$(MAKE) -C ./runtimes/javascript

./compiler/lib/js_runtime.ml: ./runtimes/javascript/ergo_runtime.ml
cp ./runtimes/javascript/ergo_runtime.ml ./compiler/lib/js_runtime.ml

./compiler/lib/static_config.ml:
echo "(* This file is generated *)" > ./compiler/lib/static_config.ml
echo "let ergo_home = \"$(CURDIR)\"" >> ./compiler/lib/static_config.ml

prepare: ./compiler/lib/static_config.ml compiler/lib/resources.ml Makefile.coq
$(MAKE) -C ./runtimes/javascript

configure:
@echo "[Ergo] "
@echo "[Ergo] Configuring Build"
@echo "[Ergo] "
npm install
@$(MAKE) prepare

# Regenerate the npm directory
ergo:
@$(MAKE) ergo-mechanization
@$(MAKE) MAKEFLAGS= ergo-extraction-refresh
@$(MAKE) MAKEFLAGS= ergo-ocaml-extraction
@$(MAKE) MAKEFLAGS= ergo-js-extraction

ergo-mechanization: _CoqProject Makefile.coq
@echo "[Ergo] "
@echo "[Ergo] Compiling Coq Mechanization"
@echo "[Ergo] "
@$(MAKE) -f Makefile.coq

ergo-extraction:
ergo-ocaml-extraction:
@echo "[Ergo] "
@echo "[Ergo] Compiling the extracted OCaml"
@echo "[Ergo] Extracting Ergo Compiler to OCaml"
@echo "[Ergo] "
@$(MAKE) -C extraction all
@$(MAKE) -C compiler/extraction
dune build @install

ergo-extraction-refresh:
ergo-js-extraction:
@echo "[Ergo] "
@echo "[Ergo] Extracting mechanization to OCaml"
@echo "[Ergo] Extracting Ergo Compiler to JavaScript"
@echo "[Ergo] "
@$(MAKE) -C extraction all-refresh

npm-setup:
@echo "[Ergo] "
@echo "[Ergo] Setting up for Node.js build"
@echo "[Ergo] "
npm install
@$(MAKE) -C compiler/libjs

## Documentation
documentation:
$(MAKE) -C mechanization documentation
$(MAKE) -C compiler/core documentation

## Testing
test:
Expand All @@ -73,20 +120,26 @@ clean-mechanization: Makefile.coq

cleanall-mechanization:
- @$(MAKE) -f Makefile.coq cleanall
- @rm -f ./compiler/lib/js_runtime.ml ./compiler/lib/static_config.ml compiler/lib/resources.ml
- @rm -f Makefile.coq
- @rm -f Makefile.coq.conf
- @rm -f _CoqProject
- @find mechanization \( -name '*.vo' -or -name '*.v.d' -or -name '*.glob' -or -name '*.aux' \) -print0 | xargs -0 rm -f
- @find compiler/core \( -name '*.vo' -or -name '*.v.d' -or -name '*.glob' -or -name '*.aux' \) -print0 | xargs -0 rm -f

clean-ocaml-extraction:
- @$(MAKE) -C compiler/extraction clean

cleanall-ocaml-extraction:
- @$(MAKE) -C compiler/extraction cleanall
- dune clean

clean-extraction:
- @$(MAKE) -C extraction clean
clean-js-extraction:
- @$(MAKE) -C compiler/libjs clean

cleanall-extraction:
- @$(MAKE) -C extraction cleanall
cleanall-js-extraction:
- @$(MAKE) -C compiler/libjs cleanall

clean-npm:
- @rm -f package-lock.json
- @rm -rf dist

cleanall-npm: clean-npm
- @node ./scripts/external/cleanExternalModels.js
Expand All @@ -99,31 +152,34 @@ cleanall-npm: clean-npm

clean: Makefile.coq
- @$(MAKE) clean-npm
- @$(MAKE) clean-extraction
- @$(MAKE) clean-ocaml-extraction
- @$(MAKE) clean-js-extraction
- @$(MAKE) -C packages/ergo-compiler clean
- @$(MAKE) -C packages/ergo-engine clean
- @$(MAKE) -C packages/ergo-cli clean
- @$(MAKE) -C runtimes/javascript clean

cleanall: Makefile.coq
@echo "[Ergo] "
@echo "[Ergo] Cleaning up"
@echo "[Ergo] "
- @$(MAKE) cleanall-npm
- @$(MAKE) cleanall-extraction
- @$(MAKE) cleanall-ocaml-extraction
- @$(MAKE) cleanall-mechanization
- @$(MAKE) -C packages/ergo-compiler cleanall
- @$(MAKE) -C packages/ergo-engine cleanall
- @$(MAKE) -C packages/ergo-cli cleanall
- @$(MAKE) -C runtimes/javascript cleanall

##
_CoqProject: Makefile.config
@echo "[Ergo] "
@echo "[Ergo] Setting up Coq"
@echo "[Ergo] "
ifneq ($(QCERT),)
(echo "-R mechanization ErgoSpec -R $(QCERT)/coq Qcert";) > _CoqProject
(echo "-R compiler/core ErgoSpec -R $(QCERT)/compiler/core Qcert";) > _CoqProject
else
(echo "-R mechanization ErgoSpec";) > _CoqProject
(echo "-R compiler/core ErgoSpec";) > _CoqProject
endif

Makefile.coq: _CoqProject Makefile $(FILES)
Expand Down
2 changes: 1 addition & 1 deletion Makefile.config
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
#

## Qcert compiler location
#QCERT=../qcert-master
QCERT=qcert
Loading