diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-02-01 21:32:13 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-02-01 21:32:13 -0800 |
commit | b0ffa2f8f59c7c14f47deaf63e47a2d19725cc75 (patch) | |
tree | 86e76cb2c1d413077f3fd8716696a5da6b7e9d8f | |
parent | 5aacaae25eb261c6029e8b3df111328fa0bf8166 (diff) |
semi polyfill for Math.imul
-rwxr-xr-x | emscripten.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/emscripten.py b/emscripten.py index 2ceb5e13..af762a21 100755 --- a/emscripten.py +++ b/emscripten.py @@ -321,12 +321,14 @@ def emscript(infile, settings, outfile, libraries=[]): infos = [make_table(sig, raw) for sig, raw in last_forwarded_json['Functions']['tables'].iteritems()] function_tables_defs = '\n'.join([info[0] for info in infos] + [info[1] for info in infos]) + asm_setup = '' maths = ['Math.' + func for func in ['floor', 'abs', 'sqrt', 'pow', 'cos', 'sin', 'tan', 'acos', 'asin', 'atan', 'atan2', 'exp', 'log', 'ceil']] if settings['USE_MATH_IMUL']: maths += ['Math.imul'] + asm_setup += 'if (!Math.imul) Math.imul = function(x, y) { return (x*y)|0 }; // # not a real polyfill since semantics not identical, but close and fairly fast\n' fundamentals = ['Math', 'Int8Array', 'Int16Array', 'Int32Array', 'Uint8Array', 'Uint16Array', 'Uint32Array', 'Float32Array', 'Float64Array'] math_envs = ['Runtime.bitshift64', 'Math.min'] # TODO: move min to maths - asm_setup = '\n'.join(['var %s = %s;' % (f.replace('.', '_'), f) for f in math_envs]) + asm_setup += '\n'.join(['var %s = %s;' % (f.replace('.', '_'), f) for f in math_envs]) basic_funcs = ['abort', 'assert', 'asmPrintInt', 'asmPrintFloat', 'copyTempDouble', 'copyTempFloat'] + [m.replace('.', '_') for m in math_envs] if settings['SAFE_HEAP']: basic_funcs += ['SAFE_HEAP_LOAD', 'SAFE_HEAP_STORE', 'SAFE_HEAP_CLEAR'] basic_vars = ['STACKTOP', 'STACK_MAX', 'tempDoublePtr', 'ABORT'] |