diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-12-01 14:19:52 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-12-07 14:23:22 -0800 |
commit | 74c843c55f0238bd75a919fdd5b2dc2f57f48fe2 (patch) | |
tree | f10d06d0da4c5cd88ec6f2c2fc93af2b349a4c39 /emscripten.py | |
parent | 61e57490b2f55f57291f8d28a79805d5bd84f176 (diff) |
i64Math in asm
Diffstat (limited to 'emscripten.py')
-rwxr-xr-x | emscripten.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/emscripten.py b/emscripten.py index c0c40da7..7c064850 100755 --- a/emscripten.py +++ b/emscripten.py @@ -291,11 +291,19 @@ def emscript(infile, settings, outfile, libraries=[]): function_tables_defs = '\n'.join([table for table in last_forwarded_json['Functions']['tables'].itervalues()]) if settings.get('ASM_JS'): + asm_setup = '' fundamentals = ['buffer', 'Int8Array', 'Int16Array', 'Int32Array', 'Uint8Array', 'Uint16Array', 'Uint32Array', 'Float32Array', 'Float64Array'] basics = ['abort', 'assert', 'STACKTOP', 'STACK_MAX', 'tempDoublePtr', 'ABORT'] if not settings['NAMED_GLOBALS']: basics += ['GLOBAL_BASE'] - #if forwarded_json['Types']['preciseI64MathUsed']: - # basics += ['i64Math'] + if forwarded_json['Types']['preciseI64MathUsed']: + basics += ['i64Math_' + op for op in ['add', 'subtract', 'multiply', 'divide', 'modulo']] + asm_setup += ''' +var i64Math_add = function(a, b, c, d) { i64Math.add(a, b, c, d) }; +var i64Math_subtract = function(a, b, c, d) { i64Math.subtract(a, b, c, d) }; +var i64Math_multiply = function(a, b, c, d) { i64Math.multiply(a, b, c, d) }; +var i64Math_divide = function(a, b, c, d) { i64Math.divide(a, b, c, d) }; +var i64Math_modulo = function(a, b, c, d) { i64Math.modulo(a, b, c, d) }; +''' asm_runtime_funcs = ['stackAlloc', 'stackSave', 'stackRestore'] # function tables function_tables = ['dynCall_' + table for table in last_forwarded_json['Functions']['tables']] @@ -329,6 +337,7 @@ def emscript(infile, settings, outfile, libraries=[]): receiving = ';\n'.join(['var ' + s + ' = Module["' + s + '"] = asm.' + s for s in exported_implemented_functions + function_tables]) # finalize funcs_js = ''' +%s var asmPre = (function(env, buffer) { 'use asm'; var HEAP8 = new env.Int8Array(buffer); @@ -339,7 +348,7 @@ var asmPre = (function(env, buffer) { var HEAPU32 = new env.Uint32Array(buffer); var HEAPF32 = new env.Float32Array(buffer); var HEAPF64 = new env.Float64Array(buffer); -''' + asm_globals + ''' +''' % (asm_setup,) + asm_globals + ''' function stackAlloc(size) { var ret = STACKTOP; STACKTOP = (STACKTOP + size)|0; |