RReverser's

Ingvar Stepanyan

JavaScript developer, speaker and reverse engineer. D2D programmer. Sometimes human.


Started work on ES6 -> asm.js conversion

View on GitHub

I know this sounds crazy, but I always wondered why do we always give out such a speedup technique as asm.js (it speeds up code in all the modern browsers!) to developers from other languages if we can use it for own code in JavaScript as well?

The answer is that handwriting asm.js is tricky due to limited set of operations and complex rules for satisfying asm.js. So I decided to start this side project. It's goal is to compile statically typed ES6 (Flow-flavoured) module into asm.js while preserving ES6 module interface. So it's still a subset of JavaScript, but much more suitable for hand-writing.

You don't need to use C/C++ -> Emscripten -> asm.js for heavy calculation anymore - just create module, drop Babel with this plugin and you're ready to go!

Currently supported:

  • ES6 import and named export
  • automatic var, let, const extraction and conversion
  • automatic function layout
  • function parameter annotations
  • function return type annotation
  • assignment with automatic type conversion
  • Flow type cast into asm.js type cast
  • automatic asm.js imports for stdlib and foreign references
  • automatic program layout
  • automatic wrapping into asm.js module with initialize for passing own heap

TODO:

  • bug fixing
  • global variable support
  • string support (literals are already converted to IDs, need to support operations)
  • better asm.js<->normal code communication
  • limited object and array support
  • sky is the limit!
comments powered by Disqus