asm.js
A Mozilla Research project to specify and develop the extremely optimizable subset of JS targeted by compilers like Emscripten, Mandreel, and LLJS.
Example
{ "use asm"; // ------------------------------------------------------------------------- // SECTION 1: globals var H32 = heap; var HU32 = heap; var log = foreignconsoleDotLog; var g_i = 0; // int global var g_f = 00; // double global // ------------------------------------------------------------------------- // SECTION 2: functions { // SECTION A: parameter type declarations x = x|0; // int parameter y = +y; // double parameter // SECTION B: function body ; // call into FFI -- must force the sign ; // call into FFI -- already know it's a double x = x+3|0; // signed addition // SECTION C: unconditional return return x+1|0>>>0/x|0>>>0; // compound expression } { g_f = +g_i; // read/write globals return; } { return; } { i = i|0; x = x|0; H32i>>2 = x; // shifted by log2(byte count) ftable_2x-2&2; // dynamic call of functions in table 2 // no return necessary when return type is void } // ------------------------------------------------------------------------- // SECTION 3: function tables var ftable_1 = f; var ftable_2 = g g2; // all of the same type // ------------------------------------------------------------------------- // SECTION 4: exports return f_export: f goop: g ;}