-
Notifications
You must be signed in to change notification settings - Fork 10
WASM: W-Imp intermediate representation #146
Copy link
Copy link
Open
Labels
Description
The current Wasm backend is implemented in OCaml and translates from Imp to the AST used in the Webassembly reference implementation.
Doing Imp -> Wasm in OCaml was fine for quickly providing a seemingly working Webassembly backend. However, the gap between Imp and Wasm is quite big. The former was designed to resemble Javascript, the latter is much more low level. In the long run, it might be worth narrowing this gap by adding a more Wasm-like intermediate representation to Q*Cert.
My incomplete wish-list for W-Imp:
- Function-scope variables instead of block scoped variables (see WASM: Variable Scoping #145).
- Use integers for variable names instead of string .
listing free variables in blocks would allow to translate Imp blocks to Wasm functionsnot true because Wasm functions can return only one value.- Replace for(each) with something closer to Wasm's loop construct.
- Merge
EJsonOperatorandEJsonRuntimeOperatorinto a singleWasmOperator. Avoid ADT features,WasmOperatorshould be an enumeration. - Introduce wasm data model (e.g.
type wasm_model = string ejson).
On a later stage:
- Replace
WasmOperatorwith(namespace, opname) : (string * string). We import operators from the runtime anyway and this is all information we need. Most operators will havenamespace = "runtime"to call into theruntime.wasm, but certain operators might be provided by the environment (e.g. logging) or separate wasm modules. - Use the backward mapping
(string * string) -> WasmOperatorto test functional equivalence of compiled Wasm contracts linked with operators implemented in Coq/OCaml versus operators implemented in the productionruntime.wasm. - Maybe, we can unbox immediate values such as integers and floats after avoiding polymorphic operators.
Reactions are currently unavailable