Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WASM: W-Imp intermediate representation #146

Open
pkel opened this issue Aug 20, 2020 · 0 comments
Open

WASM: W-Imp intermediate representation #146

pkel opened this issue Aug 20, 2020 · 0 comments

Comments

@pkel
Copy link
Collaborator

pkel commented Aug 20, 2020

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 functions not true because Wasm functions can return only one value.
  • Replace for(each) with something closer to Wasm's loop construct.
  • Merge EJsonOperator and EJsonRuntimeOperator into a single WasmOperator. Avoid ADT features, WasmOperator should be an enumeration.
  • Introduce wasm data model (e.g. type wasm_model = string ejson).

On a later stage:

  • Replace WasmOperator with (namespace, opname) : (string * string). We import operators from the runtime anyway and this is all information we need. Most operators will have namespace = "runtime" to call into the runtime.wasm, but certain operators might be provided by the environment (e.g. logging) or separate wasm modules.
  • Use the backward mapping (string * string) -> WasmOperator to test functional equivalence of compiled Wasm contracts linked with operators implemented in Coq/OCaml versus operators implemented in the production runtime.wasm.
  • Maybe, we can unbox immediate values such as integers and floats after avoiding polymorphic operators.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant