Binaryen - WebAssembly Compiler and Toolchain

Mar 02, 2020 • ☕️ 1 min read

Binaryen has a simple C API in a single header. It accepts input in WebAssembly-like form but also accepts a general control flow graph for compilers that prefer that.

Binaryen’s internal Intermediate Representation (IR) uses compact data structures and is designed for completely parallel codegen and optimization, using all available CPU cores. Binaryen’s IR also compiles down to WebAssembly extremely easily and quickly because it is essentially a subset of WebAssembly.

Binaryen’s optimizer has many passes that can improve code very significantly, one specific area of focus is on WebAssembly-specific optimizations that general-purpose compilers might not do.

  • Wasm minification
  • Dead code elimination
  • Local coloring to coalesce local variables
  • Precomputing expressions when possible at compile time

Binaryen also provides a set of toolchain utilities that can:

  • Parse and emit WebAssembly
  • Interpret WebAssembly as well as run the WebAssembly spec tests
  • Integrate with Emscripten to provide a complete compiler toolchain from C/C++ to WebAssembly.
  • Polyfill WebAssembly by running it in the interpreter compiled to JavaScript, if the browser does not yet have native support (useful for testing)

Some compilers built using Binaryen include:

  • asm2wasm which compiles asm.js to WebAssembly
  • AssemblyScript which compiles TypeScript to Binaryen IR
  • wasm2js which compiles WebAssembly to JS
  • Asterius which compiles Haskell to WebAssembly

Reading More

Great sites for iOS Developers

To get from good to great, I believe we have to constantly learn from others, these are those that contains valuable articles and resources that help us to make the leap.

Are you truly innovative?

Let me explain: you can’t take an existing product or process, “do some innovation” on it, and come out with a better product. Improving a product or process is not innovative. To innovate, you have to start from a completely blank slate.

This will make you a minimalist

Minimalism is when you use less things to accomplish the same goal. There are many benefits when you become a minimalist.

Client-Side Rendering (CSR)

CSR strategy has very good developer experience but the impact on SEO and user experience still concerned