Skip to content
This repository was 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
Changes from 1 commit
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix(Wasm) --target wasm in the compiler now generates binary wasm for…
… execution

Signed-off-by: Jerome Simeon <jeromesimeon@me.com>
  • Loading branch information
jeromesimeon authored and pkel committed Aug 20, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 0f6376161be2ebac3ef763e62eb8c8396ac7c999
6 changes: 4 additions & 2 deletions Makefile.coq_modules
Original file line number Diff line number Diff line change
@@ -72,7 +72,8 @@ MODULES = \
ErgoNNRC/Lang/ErgoNNRC \
ErgoNNRC/Lang/ErgoNNRCSugar \
ErgoImp/Lang/ErgoImp \
ErgoWasm/Lang/ErgoWasm \
ErgoWasmAst/Lang/ErgoWasmAst \
ErgoWasmBinary/Lang/ErgoWasmBinary \
Translation/CTOtoErgo \
Translation/ErgoNameResolve \
Translation/ErgoAssembly \
@@ -83,7 +84,8 @@ MODULES = \
Translation/ErgoNNRCtoErgoImp \
Translation/ErgoImptoES6 \
Translation/ErgoNNRCtoJava \
Translation/ErgoImptoWasm \
Translation/ErgoImptoWasmAst \
Translation/WasmAsttoWasmBinary \
Compiler/ErgoDriver \
Compiler/ErgoCompiler \
Tests/HelloWorld
17 changes: 10 additions & 7 deletions compiler/core/Compiler/ErgoDriver.v
Original file line number Diff line number Diff line change
@@ -38,7 +38,8 @@ Require Import ErgoSpec.ErgoC.Lang.ErgoCTypecheckContext.
Require Import ErgoSpec.ErgoC.Lang.ErgoCTypecheck.
Require Import ErgoSpec.ErgoC.Lang.ErgoCExpand.
Require Import ErgoSpec.ErgoNNRC.Lang.ErgoNNRC.
Require Import ErgoSpec.ErgoWasm.Lang.ErgoWasm.
Require Import ErgoSpec.ErgoWasmAst.Lang.ErgoWasmAst.
Require Import ErgoSpec.ErgoWasmBinary.Lang.ErgoWasmBinary.
Require Import ErgoSpec.Translation.CTOtoErgo.
Require Import ErgoSpec.Translation.ErgoAssembly.
Require Import ErgoSpec.Translation.ErgoNameResolve.
@@ -49,7 +50,8 @@ Require Import ErgoSpec.Translation.ErgoCTtoErgoNNRC.
Require Import ErgoSpec.Translation.ErgoNNRCtoErgoImp.
Require Import ErgoSpec.Translation.ErgoImptoES6.
Require Import ErgoSpec.Translation.ErgoNNRCtoJava.
Require Import ErgoSpec.Translation.ErgoImptoWasm.
Require Import ErgoSpec.Translation.ErgoImptoWasmAst.
Require Import ErgoSpec.Translation.WasmAsttoWasmBinary.

Section ErgoDriver.
Section CompilerPre.
@@ -322,10 +324,11 @@ Section ErgoDriver.
Definition ergoc_module_to_wasm
(bm:brand_model)
(contract_name:string)
(p:ergo_nnrc_module) : ErgoWasm.wasm_ast :=
ergo_imp_module_to_wasm
contract_name
(ergo_nnrc_module_to_imp p).
(p:ergo_nnrc_module) : ErgoWasmBinary.wasm :=
ergo_wasm_ast_to_ergo_wasm
(ergo_imp_module_to_wasm_ast
contract_name
(ergo_nnrc_module_to_imp p)).

Definition ergo_module_to_es6_top
(inputs:list lrergo_input)
@@ -378,7 +381,7 @@ Section ErgoDriver.
let pc := ergo_module_to_ergoct ctxt p in
let pn := eolift (fun xy => ergoct_module_to_nnrc (fst xy)) pc in
elift (fun x => (contract_name, x,
ErgoWasm.wasm_ast_to_string (ergoc_module_to_wasm bm contract_name x))) pn)
ErgoWasmBinary.wasm_to_string (ergoc_module_to_wasm bm contract_name x))) pn)
ec
in
elift (fun xyz =>
Original file line number Diff line number Diff line change
@@ -27,17 +27,17 @@ Require Import ErgoSpec.Backend.Qcert.QcertEJson.
Require Import ErgoSpec.Common.Provenance.
Require Import ErgoSpec.Common.Result.

Section ErgoWasm.
Section ErgoWasmAst.
Context {m : brand_model}.

(** WASM programs are in AST form *)
(** Same type as in Q*cert *)
Definition wasm_ast : Set := wasm_ast.
Definition wasm_ast_eval :brand_relation_t -> wasm_ast -> jbindings -> option ejson
Definition wasm_ast_eval : wasm_ast -> jbindings -> option ejson
:= @wasm_ast_eval enhanced_ejson.
Definition wasm_ast_to_string : wasm_ast -> nstring := wasm_ast_to_string.

End ErgoWasm.
End ErgoWasmAst.

Extract Constant wasm_ast => "Wasm_ast.t".
Extract Constant wasm_ast_eval => "Wasm_ast.eval".
30 changes: 30 additions & 0 deletions compiler/core/ErgoWasmBinary/Lang/ErgoWasmBinary.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
(*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*)

(** ErgoWasm is an IL for Wasm *)

(** * Abstract Syntax *)

Require Import Qcert.WasmBinary.Lang.WasmBinary.

Section ErgoWasmBinary.
(** WASM programs are in AST form *)
(** Same type as in Q*cert *)
Definition wasm : Set := wasm.
Axiom wasm_to_string : wasm -> Qcert.Utils.NativeString.nstring.

End ErgoWasmBinary.

Extract Constant wasm => "string".
Extract Constant wasm_to_string => "(fun x -> x)".
Original file line number Diff line number Diff line change
@@ -26,20 +26,20 @@ Require Import ErgoSpec.Common.Names.
Require Import ErgoSpec.Types.ErgoType.
Require Import ErgoSpec.ErgoImp.Lang.ErgoImp.
Require Import ErgoSpec.Backend.QLib.
Require Import ErgoSpec.ErgoWasm.Lang.ErgoWasm.
Require Import ErgoSpec.ErgoWasmAst.Lang.ErgoWasmAst.

Section ErgoImptoWasm.
Section ErgoImptoWasmAst.
Local Open Scope list_scope.

Context {bm:brand_model}.

Axiom ergo_imp_ejson_to_wasm_ast : brand_relation_t -> ergo_imp_module -> wasm_ast.
Definition ergo_imp_ejson_to_wasm_ast_typed := ergo_imp_ejson_to_wasm_ast brand_relation_brands.

Definition ergo_imp_module_to_wasm
Definition ergo_imp_module_to_wasm_ast
(contract_name:string)
(p:ergo_imp_module) : wasm_ast :=
ergo_imp_ejson_to_wasm_ast_typed p.
End ErgoImptoWasm.
End ErgoImptoWasmAst.

Extract Constant ergo_imp_ejson_to_wasm_ast => "Wasm_ast.ergo_imp_ejson_to_wasm_ast".
36 changes: 36 additions & 0 deletions compiler/core/Translation/WasmAsttoWasmBinary.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
(*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*)

(** Translates ErgoNNRC to JavaScript *)

Require Import String.
Require Import List.

Require Import Qcert.JavaScriptAst.JavaScriptAstRuntime.
Require Import Qcert.Driver.CompDriver.
Require Import ErgoSpec.Version.
Require Import ErgoSpec.Utils.Misc.
Require Import ErgoSpec.Common.Result.
Require Import ErgoSpec.Common.Names.
Require Import ErgoSpec.Types.ErgoType.
Require Import ErgoSpec.ErgoImp.Lang.ErgoImp.
Require Import ErgoSpec.Backend.QLib.
Require Import ErgoSpec.ErgoWasmAst.Lang.ErgoWasmAst.
Require Import ErgoSpec.ErgoWasmBinary.Lang.ErgoWasmBinary.

Section WasmAsttoWasmBinary.
Axiom ergo_wasm_ast_to_ergo_wasm : wasm_ast -> wasm.
End WasmAsttoWasmBinary.

Extract Constant ergo_wasm_ast_to_ergo_wasm => "Wasm.Encode.encode".
4 changes: 2 additions & 2 deletions compiler/lib/config.ml
Original file line number Diff line number Diff line change
@@ -43,15 +43,15 @@ let extension_of_lang lang =
| Ergo -> ".ergo"
| ES6 -> ".js"
| Java -> ".java"
| Wasm -> ".wat"
| Wasm -> ".wasm"
end

let script_lang_of_lang lang =
begin match lang with
| Ergo -> ".ergo"
| ES6 -> ".js"
| Java -> ".java"
| Wasm -> ".wat"
| Wasm -> ".wasm"
end

let script_lang_of_target s =
19,699 changes: 10,006 additions & 9,693 deletions packages/ergo-cli/extracted/ergoccore.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/ergo-cli/extracted/ergotopcore.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20,005 changes: 10,159 additions & 9,846 deletions packages/ergo-compiler/extracted/compilercore.js

Large diffs are not rendered by default.