From 153638d05a56434ede6803c31566d97813f92c76 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Fri, 7 Dec 2012 16:19:54 -0800 Subject: set asm function table sizes to power of two, and add proper masking --- emscripten.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'emscripten.py') diff --git a/emscripten.py b/emscripten.py index 3222e12f..5ad06bbc 100755 --- a/emscripten.py +++ b/emscripten.py @@ -390,6 +390,14 @@ Runtime.stackAlloc = function(size) { return asm.stackAlloc(size) }; Runtime.stackSave = function() { return asm.stackSave() }; Runtime.stackRestore = function(top) { asm.stackRestore(top) }; ''' % (function_tables_defs.replace('\n', '\n ') + '\n' + '\n'.join(function_tables_impls), exports, sending, receiving) + + # Set function table masks + def function_table_maskize(js): + masks = {} + for sig, table in last_forwarded_json['Functions']['tables'].iteritems(): + masks[sig] = str(table.count(',')) + return re.sub(r'{{{ FTM_([vdi]+) }}}', lambda m: masks[m.groups(0)[0]], js) + funcs_js = function_table_maskize(funcs_js) else: outfile.write(function_tables_defs) outfile.write(blockaddrsize(indexize(funcs_js))) -- cgit v1.2.3-18-g5258