aboutsummaryrefslogtreecommitdiff
path: root/emscripten.py
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-12-07 16:19:54 -0800
committerAlon Zakai <alonzakai@gmail.com>2012-12-07 16:19:54 -0800
commit153638d05a56434ede6803c31566d97813f92c76 (patch)
tree10b872e0220192023e1a96b863e536784cb5527e /emscripten.py
parent3954f1d108105bcdd5411fe19abb8f068b22bd24 (diff)
set asm function table sizes to power of two, and add proper masking
Diffstat (limited to 'emscripten.py')
-rwxr-xr-xemscripten.py8
1 files changed, 8 insertions, 0 deletions
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)))