Quantcast
Channel: Hacker News 50
Viewing all articles
Browse latest Browse all 9433

LLVM.js: LLVM Itself Compiled to JavaScript via Emscripten - Badass JavaScript

$
0
0

Comments:"LLVM.js: LLVM Itself Compiled to JavaScript via Emscripten - Badass JavaScript"

URL:http://badassjs.com/post/39573969361/llvm-js-llvm-itself-compiled-to-javascript-via


Whoa, now this is a cool idea.  The Emscripten guys are back at it again compiling LLVM itself to JavaScript to run in the browser.  Now you can compile and run LLVM IR assembly directly in the browser using LLVM.js.

Emscripten, for those that don’t know is an LLVM bytecode to JavaScript compiler.  LLVM is a compiler backend for many languages like C and C++ via the Clang compiler, Objective-C and several others.  Those compilers generate LLVM bytecode which LLVM normally compiles to native machine code, but Emscripten replaces that output with JavaScript instead, enabling programs written in any language supporting LLVM to be run wherever JavaScript runs.

LLVM.js takes Emscripten a step further by compiling LLVM itself to JavaScript, using Emscripten (which uses LLVM).  Whoa!  This means that you can now compile and run LLVM assembly directly in JavaScript without installing the native LLVM tools.  If language compilers supporting LLVM such as Clang were also compiled to JavaScript, you could compile and run C/C++ code directly in JavaScript as well.

This is a very cool demo.  I’m not sure how practical it really is to wait until runtime to compile your code rather than precompiling it, but it could be useful to avoid having to install the LLVM tools, or for platforms where the LLVM compiler cannot run (such as mobile operating systems).

Check out the code on Github, and try your hand at LLVM assembly on the demo page.


Viewing all articles
Browse latest Browse all 9433

Trending Articles