Binaryen

Binaryen's GitHub page at https://github.com/WebAssembly/binaryen describes Binaryen as a compiler and toolchain infrastructure library for WebAssembly, written in C++. It aims to make compiling to WebAssembly easy, fast, and effective. It achieves these aims by providing a simple C API, an internal IR, and an optimizer. Just as with the WABT, Binaryen provides an extensive suite of tools for developing WebAssembly tooling. The following list describes a subset of the tools that Binaryen provides:

  • wasm-shell: Tool capable of loading and interpreting WebAssembly
  • asm2wasm: Compiles asm.js code to a Wasm module
  • wasm2js: Compiles a Wasm module to JavaScript
  • wasm-merge: Combines multiple Wasm files into one
  • wasm.js: JavaScript library that includes the Binaryen interpreter, asm2wasm, the Wat parser, and other Binaryen tools
  • binaryen.js: JavaScript library that provides a JavaScript interface for the Binaryen toolchain

The wasm.js and binaryen.js tools are of particular interest for JavaScript developers interested in building WebAssembly tooling. The binaryen.js library is available as an npm package (https://www.npmjs.com/package/binaryen).

An excellent example of binaryen.js usage is AssemblyScript (https://github.com/AssemblyScript/assemblyscript). AssemblyScript is a strictly typed subset of TypeScript that generates WebAssembly modules. The library comes packaged with a CLI to quickly scaffold new projects and manage the build step. In the Compiling with LLVM section, we'll cover how to compile Wasm modules using LLVM.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset