GraalWasm is a WebAssembly engine implemented in GraalVM. It can run WebAssembly programs in the binary format, generated with compiler backends such as Emscripten.
“Supporting WebAssembly expands the set of languages GraalVM can execute with a whole other set of languages to the ones supported by GraalVM and further step towards making it a universal platform for programming language execution,” the developers behind the project wrote in a blog post.
In GraalWasm, an AST is superimposed on top of the WebAssembly’s control-flow instructions, such as ‘if’ and ‘loop,’ but each block is represented with a single Truffle AST Node called a Wasm block node reducing the memory footprint. Also, GraalWasm block nodes contain pointers into the byte array of the WebAssembly binary instead of copying the parts of the original instruction stream.
The interpreter implemented on top of this data structure is a hybrid between AST-based interpretation and bitcode-based interpretation.
Within each basic block, interpretation is done inside an interpretation loop that iterates of the opcodes of that basic block. This design made the interpreter easier to comprehend, and simplified its partial evaluation, according to the company.
“An immediate next step will be the implementation of the WebAssembly System Interface (WASI), which is necessary to run WebAssembly programs outside of the web context,” the developers said.
“Yet another future step is improving the debugging support in GraalWasm, and integrating it with the rest of GraalVM. In particular, we will work on extracting the symbol and source map information that some compilers embed into WebAssembly binaries, with the goal of allowing our GraalVM tooling to map the code locations and the raw memory layout to the constructs from the original source code,” they added.
The project is currently in an experimental phase and the team is working to make the project more stable and efficient.