From 1086b716159e25b8ba480052d651d41e2f5f05cc Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Mon, 6 May 2013 12:21:27 -0700 Subject: make sure function table size for empty tables is the right power of two --- emscripten.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'emscripten.py') diff --git a/emscripten.py b/emscripten.py index 7352b293..35edc515 100755 --- a/emscripten.py +++ b/emscripten.py @@ -309,6 +309,11 @@ def emscript(infile, settings, outfile, libraries=[], compiler_engine=None, forwarded_json['Functions']['indexedFunctions'][indexed] = i # make sure not to modify this python object later - we use it in indexize i += 2 forwarded_json['Functions']['nextIndex'] = i + function_table_size = forwarded_json['Functions']['nextIndex'] + i = 1 + while i < function_table_size: + i *= 2 + function_table_size = i def split_32(x): x = int(x) @@ -371,7 +376,7 @@ def emscript(infile, settings, outfile, libraries=[], compiler_engine=None, sig = use[8:len(use)-4] if sig not in last_forwarded_json['Functions']['tables']: if DEBUG: print >> sys.stderr, 'add empty function table', sig - last_forwarded_json['Functions']['tables'][sig] = 'var FUNCTION_TABLE_' + sig + ' = [' + ','.join(['0']*forwarded_json['Functions']['nextIndex']) + '];\n' + last_forwarded_json['Functions']['tables'][sig] = 'var FUNCTION_TABLE_' + sig + ' = [' + ','.join(['0']*function_table_size) + '];\n' def make_table(sig, raw): i = Counter.i -- cgit v1.2.3-18-g5258