Oracle open source WebAssembly engine GraalWasm

Recently, Oracle open source WebAssembly engine of its implementation in GraalVM in GraalWasm, the development team introduced, GraalWasm current implementation of WebAssembly MVP (minimum viable product) specification, and may be in binary format run WebAssembly program, which is by the compiler, such as Emscripten like generated by backend.

Support WebAssembly extends the capabilities GraalVM and other language support with the implementation of further expected to make it a general-purpose programming language execution platform. But now GraalWasm is still a very early stage of implementation, and in the experimental mode.

In order to achieve GraalWasm, the development team used GraalVM as to provide an effective platform for local assessment engine using GraalVM of  Truffle API , first realized the interpreter WebAssembly binaries.

WebAssembly semi-structured format which can easily restore a control structure of a program flow, so that the memory storing the code data structure may be represented as AST. The program represented by AST interpreter can be written in a very simple way, but, in spite of AST-based data structures are easier to check and operate, but they do exist disadvantages of introducing additional memory overhead.

On the other hand, based on the code bits of the code indicates that no instantiated tree node for each basic instruction, which is based on GraalVM bit code interpreter typically has a smaller memory footprint reasons of.

Since each block contains only linear WebAssembly instruction sequence, thus the best two methods is capable of binding GraalWasm interpreter methods: AST WebAssembly superimposed on the control flow instruction, such as if and loop. However, each block with a Truffle AST node, called nodes Wasm block, which reduces the memory footprint, since each block of instructions does not require a separate single node object.

Further, GraalWasm block portion of the original node is not replicated respective instruction streams, but only the pointer contained in the byte array WebAssembly binary file.

 

文本 WebAssembly、二进制 WebAssembly 与 GraalWasm AST 之间的对应关系

在此数据结构之上实现的解释器是基于 AST 的解释器和基于位码的解释器之间的混合体。在较高的控制流级别上,它在适当的基本块之间分配。在每个基本块中,解释器在迭代该基本块的操作码的解释循环内完成。这种设计使转译更容易理解,并简化了部分评估。

运行时,解释器和程序将传递到 Truffle 的局部评估引擎,然后该引擎将解释器专门用于程序,并将专门的代码传递给 GraalVM 编译器,最终为目标平台生成高效的汇编代码。

关于 GraalWasm 的更多技术细节可以查看官方博客:

开发团队还介绍了项目接下来的发展规划,其表示,GraalWasm 的动机之一是扩展 GraalVM 的 node.js 实现支持的 API 集,WebAssembly 支持的增加将使其能够实现加载 WebAssembly 二进制文件的 V8 兼容 API 功能。

下一步将是实现 WebAssembly 系统接口(WASI),这对于在 Web 上下文外部运行 WebAssembly 程序是必需的。WASI 是一组 API,用于抽象化对各种操作系统功能的访问,例如文件 API、网络套接字和时钟。

同时 GraalWasm 将专注于提高性能,初步实验和对多个 C 微基准的性能调整表明,与以最高优化水平进行编译的本地 GCC 二进制文件相比,GraalWasm 当前可实现约 0.5 倍至 0.75 倍的峰值性能。

另一方面是改善 GraalWasm 中的调试支持,并将其与 GraalVM 的其余部分集成。

Guess you like

Origin www.oschina.net/news/112519/announcing-graalwasm