aboutsummaryrefslogtreecommitdiff
path: root/emscripten.py
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-05-15 11:16:53 -0700
committerAlon Zakai <alonzakai@gmail.com>2013-05-15 11:16:53 -0700
commitede562fea850fb0e3e9c9e84cc25603e7587c02b (patch)
tree258e4931e91f19cc89fee2af4a39e4262e04de28 /emscripten.py
parent02411b6a6acb646d43b22ba2ee22b061e944e206 (diff)
option to alias function pointer indexes across types
Diffstat (limited to 'emscripten.py')
-rwxr-xr-xemscripten.py23
1 files changed, 18 insertions, 5 deletions
diff --git a/emscripten.py b/emscripten.py
index 35edc515..b99c0c09 100755
--- a/emscripten.py
+++ b/emscripten.py
@@ -302,13 +302,26 @@ def emscript(infile, settings, outfile, libraries=[], compiler_engine=None,
# calculations on merged forwarded data
forwarded_json['Functions']['indexedFunctions'] = {}
- i = 2
+ i = 2 # universal counter
if settings['ASM_JS']: i += 2*settings['RESERVED_FUNCTION_POINTERS']
+ table_counters = {} # table-specific counters
+ alias = settings['ASM_JS'] and settings['ALIASING_FUNCTION_POINTERS']
+ sig = None
for indexed in indexed_functions:
- #print >> sys.stderr, 'function indexing', indexed, i
- 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
+ if alias:
+ sig = forwarded_json['Functions']['implementedFunctions'].get(indexed) or forwarded_json['Functions']['unimplementedFunctions'].get(indexed)
+ assert sig, indexed
+ if sig not in table_counters:
+ table_counters[sig] = 2
+ curr = table_counters[sig]
+ table_counters[sig] += 2
+ else:
+ curr = i
+ i += 2
+ #print >> sys.stderr, 'function indexing', indexed, curr, sig
+ forwarded_json['Functions']['indexedFunctions'][indexed] = curr # make sure not to modify this python object later - we use it in indexize
+ if alias: i = max(table_counters.values())
+ forwarded_json['Functions']['nextIndex'] = i # post phase can continue to add, in getIndex
function_table_size = forwarded_json['Functions']['nextIndex']
i = 1
while i < function_table_size: