diff options
author | Alon Zakai <alonzakai@gmail.com> | 2014-01-16 18:36:08 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2014-01-17 10:01:04 -0800 |
commit | 620ff9a94d98e34d4f394a683e6035596d6ac3ac (patch) | |
tree | 58a49098a4fd5d2873e08b61c0481a021a62bf37 /emcc | |
parent | e138af189b10854ba16cbc99843a171c59c6d331 (diff) |
optimize memory initializer if it is large
Diffstat (limited to 'emcc')
-rwxr-xr-x | emcc | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -1913,7 +1913,7 @@ try: shared.try_delete(memfile) def repl(m): # handle chunking of the memory initializer - s = m.groups(0)[0][1:-1] + s = m.groups(0)[0] open(memfile, 'wb').write(''.join(map(lambda x: chr(int(x or '0')), s.split(',')))) if DEBUG: # Copy into temp dir as well, so can be run there too @@ -1924,6 +1924,7 @@ try: src = re.sub(shared.JS.memory_initializer_pattern, repl, open(final).read(), count=1) open(final + '.mem.js', 'w').write(src) final += '.mem.js' + src = None js_transform_tempfiles[-1] = final # simple text substitution preserves comment line number mappings if DEBUG: if os.path.exists(memfile): @@ -1931,6 +1932,15 @@ try: logging.debug('wrote memory initialization to %s' % memfile) else: logging.debug('did not see memory initialization') + elif shared.Settings.USE_TYPED_ARRAYS == 2 and not shared.Settings.MAIN_MODULE and not shared.Settings.SIDE_MODULE: + # not writing a binary init, but we can at least optimize them by splitting them up + src = open(final).read() + src = shared.JS.optimize_initializer(src) + if src is not None: + logging.debug('optimizing memory initialization') + open(final + '.mem.js', 'w').write(src) + final += '.mem.js' + src = None # It is useful to run several js optimizer passes together, to save on unneeded unparsing/reparsing js_optimizer_queue = [] |