-
Notifications
You must be signed in to change notification settings - Fork 1
Compile Targets
There are a number of compile targets available for BType:
Referenced as "js". Compiling to JavaScript is the simplest way to use BType. It is one of the targets that is directly tested for parity as part of the test suite.
When using JavaScript as a compile target, non-primitive types are compiled to POJO objects. That is, a struct with the int members foo and bar would compile to something looking like this:
function $type() {
this.foo = 0;
this.bar = 0;
}The asmjs compile target attempts to generate asm.js-compliant code while maintaining the same semantics as the js compile target. The output can be much larger because of the syntax overhead involved with asm.js.
Though the code produced by js and asmjs is both JavaScript and can be used in essentially the same ways, the asmjs version will perform much better in certain cases. Code that performs large amounts of numeric operations will generally perform many times better under asmjs than under js.
Using the llvmir compile target will generate valid LLVM intermediate representation. The output of this compile target should have the same semantics as both js and asm.js, except the code can be run "natively" without a JavaScript VM (like Node). Because LLVM IR is extremely flexible, it can be compiled to most CPU architectures, and even use the Emscripten LLVM backend.
In the future, this will likely be the way WebAssembly is supported.
At the time of writing, the LLVM IR compile target lacks some low-level features like garbage collection.