- Notifications
You must be signed in to change notification settings - Fork147
A reference validator for asm.js.
License
asm-js/validator
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
A Mozilla Research project to specify and develop the extremely optimizable subset of JS targeted by compilers like Emscripten, Mandreel, and LLJS.
Discussion of the asm.js spec now takes place on Specifictionhere.
Thespec repo hosts the source forthe current asm.js Working Draft.
This repo hosts JS source code which performs asm.js validation, howeveras of this update, this code is not up to date with the latest working draft and isnot extensively tested. Patches to update it or fix bugs are welcome though.
functionmymodule(stdlib,foreign,heap){"use asm";// -------------------------------------------------------------------------// SECTION 1: globalsvarH32=newstdlib.Int32Array(heap);varHU32=newstdlib.Uint32Array(heap);varlog=foreign.consoleDotLog;varg_i=0;// int globalvarg_f=0.0;// double global// -------------------------------------------------------------------------// SECTION 2: functionsfunctionf(x,y){// SECTION A: parameter type declarationsx=x|0;// int parametery=+y;// double parameter// SECTION B: function bodylog(x|0);// call into FFI -- must force the signlog(y);// call into FFI -- already know it's a doublex=(x+3)|0;// signed addition// SECTION C: unconditional returnreturn((((x+1)|0)>>>0)/(x>>>0))|0;// compound expression}functiong(){g_f=+(g_i|0);// read/write globalsreturn;}functiong2(){return;}functionh(i,x){i=i|0;x=x|0;H32[i>>2]=x;// shifted by log2(byte count)ftable_2[(x-2)&1]();// dynamic call of functions in table 2// no return necessary when return type is void}// -------------------------------------------------------------------------// SECTION 3: function tablesvarftable_1=[f];varftable_2=[g,g2];// all of the same type// -------------------------------------------------------------------------// SECTION 4: exportsreturn{f_export:f,goop:g};}
About
A reference validator for asm.js.
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors7
Uh oh!
There was an error while loading.Please reload this page.