aboutsummaryrefslogtreecommitdiff
path: root/emcc
diff options
context:
space:
mode:
Diffstat (limited to 'emcc')
-rwxr-xr-xemcc12
1 files changed, 11 insertions, 1 deletions
diff --git a/emcc b/emcc
index 4ad0706a..51ad3cf2 100755
--- a/emcc
+++ b/emcc
@@ -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 = []