From 20e48678c8ac6e3962896aa87f6645cb1ec58922 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Fri, 29 Nov 2013 12:10:27 -0800 Subject: [PATCH] do not emit empty postsets from js compiler for fastcomp output --- emscripten.py | 10 +--------- src/jsifier.js | 12 +++++++----- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/emscripten.py b/emscripten.py index fc9bf42dc..b9abaca15 100755 --- a/emscripten.py +++ b/emscripten.py @@ -862,14 +862,6 @@ def emscript_fast(infile, settings, outfile, libraries=[], compiler_engine=None, if key in all_exported_functions or export_all or (export_bindings and key.startswith('_emscripten_bind')): exported_implemented_functions.add(key) - if settings.get('ASM_JS'): - # move postsets into the asm module - class PostSets: js = '' - def handle_post_sets(m): - PostSets.js = m.group(0) - return '\n' - pre = re.sub(r'function runPostSets[^}]+}', handle_post_sets, pre) - #if DEBUG: outfile.write('// pre\n') outfile.write(pre) pre = None @@ -1105,7 +1097,7 @@ function setTempRet%d(value) { value = value|0; tempRet%d = value; } -''' % (i, i) for i in range(10)])] + [PostSets.js + '\n'] + funcs_js + [''' +''' % (i, i) for i in range(10)])] + funcs_js + [''' %s return %s; diff --git a/src/jsifier.js b/src/jsifier.js index fb6c5ba84..0e6198c03 100644 --- a/src/jsifier.js +++ b/src/jsifier.js @@ -1747,11 +1747,13 @@ function JSify(data, functionsOnly, givenFunctions) { print('/* no memory initializer */'); // test purposes } - // Define postsets. These will be run in ATINIT, right before global initializers (which might need the postsets). We cannot - // run them now because the memory initializer might not have been applied yet. - print('function runPostSets() {\n'); - print(itemsDict.GlobalVariablePostSet.map(function(item) { return item.JS }).join('\n')); - print('}\n'); + if (phase !== 'glue') { + // Define postsets. These will be run in ATINIT, right before global initializers (which might need the postsets). We cannot + // run them now because the memory initializer might not have been applied yet. + print('function runPostSets() {\n'); + print(itemsDict.GlobalVariablePostSet.map(function(item) { return item.JS }).join('\n')); + print('}\n'); + } if (USE_TYPED_ARRAYS == 2) { if (!BUILD_AS_SHARED_LIB && !SIDE_MODULE) {