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

Webassembly backend #153

Merged
merged 141 commits into from
May 19, 2022
Merged

Webassembly backend #153

merged 141 commits into from
May 19, 2022

Conversation

pkel
Copy link
Collaborator

@pkel pkel commented Feb 18, 2021

I picked up the work on the Webassembly backend where I left off after my GSoC project 2020. I want to keep the other PR #147 as project report. Thus I start a new PR here.

I will continue in this order:

  1. Ensure that the runtime does not mutate values (WASM: Functional Operators #148). ✓
  2. Support all relevant Imp operators, eliminate the others (WASM: Priority list of runtime & operators #133).
  3. Run all existing tests against the new backend.
  4. Match the speed of the javascript runtime (e.g. opArrayPush will need some attention).

jeromesimeon and others added 25 commits April 28, 2022 17:01
Signed-off-by: Jerome Simeon <jeromesimeon@me.com>
Signed-off-by: Patrik Keller <patrik@keller-re.de>
I'm struggling with RuntimeOpRecDot.

make -C tests wasm

I need debugger access to the generated wasm and provided ejson argument.
This PoC demonstrates how Assemblyscript could be used to implement a
runtime for imp_ejson. The next step on this road would be to implement
a pair functions that read/write JS Ejson from/to Assemblyscript's
managed memory.
This commit adds a pair of functions that read/write JS Ejson from/to
Assemblyscript's managed memory. Executing a imp function compiled to
wasm is now easy.

Next steps:
- Test the set op implemented operators.
- Hook the new runtime into the compiler pipeline.
The runtime allows to run qcert queries compiled to wasm modules in
chrome. DevTools enable stepwise debugging. This predates the recent
effort to implement the IMP operators in Assemblyscript.
This commit removes the Imp(Wasm) runtime operators that have been
implemented before. Instead we call imported functions. These functions
are defined in an Assemblyscript module.

As a side effect, we lost support for constants and
EjsonRuntimeOperator(s).

Next steps:
- Unit test the set op implemented operators.
- Provide engine that links the compiled module with the runtime.
- Compile constants
- Support EjsonRuntimeOperator(s).
This commit add a PoC engine that executes a compiled to wasm qcert
query on NodeJS. It dynamically links the IMP runtime that we implement
in AssemblyScript and compile to a separate wasm module.
We can compile the following OQL queries:
3.14
not (true or false)
3.14 <. 4.5
pi
pi <. e
greet

And execute them on input:
{ "pi" : 3.14, "e" : 2.72, "greet" : "Hello World!" }
Before, each use of an IMP constant lead to a fresh allocation in the
AssemblyScript runtime. Additionally, strings were entirely encoded in
the AST (as function that allocate and inititalize the corresponding
string in the runtime).

Now, constants are serialized into the linear memory of the compiled
module. On first use, a corresponding value is allocated in the memory
of the AssemblyScript runtime. Repeated use of a constant uses the same
value on the runtime side.
We now use the AssemblyScript runtime. The old runtime is not needed
anymore.
- Make explicit, that be transfer bytes of an UTF8 string.
- Allocate a single, correctly sized buffer on the runtime side.
Avoids headache on Javascript/Wasm interface.
Signed-off-by: Jerome Simeon <jeromesimeon@me.com>
Signed-off-by: Jerome Simeon <jeromesimeon@me.com>
Signed-off-by: Jerome Simeon <jeromesimeon@me.com>
Signed-off-by: Jerome Simeon <jeromesimeon@me.com>
Signed-off-by: Jerome Simeon <jeromesimeon@me.com>
pkel and others added 27 commits April 28, 2022 17:03
Signed-off-by: Jerome Simeon <jeromesimeon@me.com>
Signed-off-by: Jerome Simeon <jeromesimeon@me.com>
Signed-off-by: Jerome Simeon <jeromesimeon@me.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants