aboutsummaryrefslogtreecommitdiff
path: root/emscripten.py
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-05-06 12:21:27 -0700
committerAlon Zakai <alonzakai@gmail.com>2013-05-06 12:21:27 -0700
commit1086b716159e25b8ba480052d651d41e2f5f05cc (patch)
tree92526d6288f12705a5f3103f3526238f04cbbdd5 /emscripten.py
parent300e44e4239d8d1d8a1684582fd4638d734fa631 (diff)
make sure function table size for empty tables is the right power of two
Diffstat (limited to 'emscripten.py')
-rwxr-xr-xemscripten.py7
1 files changed, 6 insertions, 1 deletions
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