diff options
Diffstat (limited to 'emscripten.py')
-rwxr-xr-x | emscripten.py | 41 |
1 files changed, 28 insertions, 13 deletions
diff --git a/emscripten.py b/emscripten.py index 939ddbe8..d75214d5 100755 --- a/emscripten.py +++ b/emscripten.py @@ -477,7 +477,7 @@ def emscript(infile, settings, outfile, libraries=[], compiler_engine=None, if '_rand' in exported_implemented_functions or '_srand' in exported_implemented_functions: basic_vars += ['___rand_seed'] - asm_runtime_funcs = ['stackAlloc', 'stackSave', 'stackRestore', 'setThrew'] + ['setTempRet%d' % i for i in range(10)] + asm_runtime_funcs = ['stackAlloc', 'stackSave', 'stackRestore', 'setThrew'] + ['setTempRet%d' % i for i in range(10)] + ['getTempRet%d' % i for i in range(10)] # function tables function_tables = ['dynCall_' + table for table in last_forwarded_json['Functions']['tables']] function_tables_impls = [] @@ -632,6 +632,10 @@ function setTempRet%d(value) { value = value|0; tempRet%d = value; } +''' % (i, i) for i in range(10)]) + ''.join([''' +function getTempRet%d() { + return tempRet%d|0; +} ''' % (i, i) for i in range(10)])] + [PostSets.js + '\n'] + funcs_js + [''' %s @@ -644,9 +648,11 @@ function setTempRet%d(value) { if not settings.get('SIDE_MODULE'): funcs_js.append(''' -Runtime.stackAlloc = function(size) { return asm['stackAlloc'](size) }; -Runtime.stackSave = function() { return asm['stackSave']() }; -Runtime.stackRestore = function(top) { asm['stackRestore'](top) }; +Runtime.stackAlloc = asm['stackAlloc']; +Runtime.stackSave = asm['stackSave']; +Runtime.stackRestore = asm['stackRestore']; +Runtime.setTempRet0 = asm['setTempRet0']; +Runtime.getTempRet0 = asm['getTempRet0']; ''') # Set function table masks @@ -889,10 +895,15 @@ def emscript_fast(infile, settings, outfile, libraries=[], compiler_engine=None, exported_implemented_functions = set(metadata['exports']) export_bindings = settings['EXPORT_BINDINGS'] export_all = settings['EXPORT_ALL'] - for key in metadata['implementedFunctions'] + forwarded_json['Functions']['implementedFunctions'].keys(): # XXX perf + all_implemented = metadata['implementedFunctions'] + forwarded_json['Functions']['implementedFunctions'].keys() # XXX perf? + for key in all_implemented: if key in all_exported_functions or export_all or (export_bindings and key.startswith('_emscripten_bind')): exported_implemented_functions.add(key) implemented_functions = set(metadata['implementedFunctions']) + if settings['ASSERTIONS'] and settings.get('ORIGINAL_EXPORTED_FUNCTIONS'): + for requested in settings['ORIGINAL_EXPORTED_FUNCTIONS']: + if requested not in all_implemented: + logging.warning('function requested to be exported, but not implemented: "%s"', requested) # Add named globals named_globals = '\n'.join(['var %s = %s;' % (k, v) for k, v in metadata['namedGlobals'].iteritems()]) @@ -1058,7 +1069,7 @@ def emscript_fast(infile, settings, outfile, libraries=[], compiler_engine=None, if '_rand' in exported_implemented_functions or '_srand' in exported_implemented_functions: basic_vars += ['___rand_seed'] - asm_runtime_funcs = ['stackAlloc', 'stackSave', 'stackRestore', 'setThrew'] + ['setTempRet%d' % i for i in range(10)] + asm_runtime_funcs = ['stackAlloc', 'stackSave', 'stackRestore', 'setThrew', 'setTempRet0', 'getTempRet0'] # function tables function_tables = ['dynCall_' + table for table in last_forwarded_json['Functions']['tables']] function_tables_impls = [] @@ -1208,12 +1219,14 @@ function copyTempDouble(ptr) { HEAP8[tempDoublePtr+6>>0] = HEAP8[ptr+6>>0]; HEAP8[tempDoublePtr+7>>0] = HEAP8[ptr+7>>0]; } -''' + ''.join([''' -function setTempRet%d(value) { +function setTempRet0(value) { value = value|0; - tempRet%d = value; + tempRet0 = value; +} +function getTempRet0() { + return tempRet0|0; } -''' % (i, i) for i in range(10)])] + funcs_js + [''' +'''] + funcs_js + [''' %s return %s; @@ -1225,9 +1238,11 @@ function setTempRet%d(value) { if not settings.get('SIDE_MODULE'): funcs_js.append(''' -Runtime.stackAlloc = function(size) { return asm['stackAlloc'](size) }; -Runtime.stackSave = function() { return asm['stackSave']() }; -Runtime.stackRestore = function(top) { asm['stackRestore'](top) }; +Runtime.stackAlloc = asm['stackAlloc']; +Runtime.stackSave = asm['stackSave']; +Runtime.stackRestore = asm['stackRestore']; +Runtime.setTempRet0 = asm['setTempRet0']; +Runtime.getTempRet0 = asm['getTempRet0']; ''') # Set function table masks |