diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-12-03 18:31:38 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-12-07 14:23:22 -0800 |
commit | 1189e117b75850aa49ff6fad975d8b785e2fc4ec (patch) | |
tree | 4fb36788f752e2dd32add44c552b3f07758429ee | |
parent | 93873761b2370bc9978e7c443dcffac5cdfc91a8 (diff) |
improve asm test wrapping
-rwxr-xr-x | emcc | 10 | ||||
-rwxr-xr-x | emscripten.py | 6 |
2 files changed, 10 insertions, 6 deletions
@@ -1142,6 +1142,16 @@ try: execute(shlex.split(js_transform, posix=posix) + [os.path.abspath(final)]) if DEBUG: save_intermediate('transformed') + if shared.Settings.ASM_JS: # XXX temporary wrapping for testing purposes + unwrapped = open(final).read() + final += '.asmwrap.js' + open(final, 'w').write(''' +(function() { // prevent new Function from seeing the global scope +%s +}).apply(null, arguments); +''' % unwrapped) + if DEBUG: save_intermediate('asmwrap') + # It is useful to run several js optimizer passes together, to save on unneeded unparsing/reparsing js_optimizer_queue = [] def flush_js_optimizer_queue(): diff --git a/emscripten.py b/emscripten.py index 83ef740f..8ead6e58 100755 --- a/emscripten.py +++ b/emscripten.py @@ -267,9 +267,6 @@ def emscript(infile, settings, outfile, libraries=[]): def blockaddrsize(js): return re.sub(r'{{{ BA_([\w\d_$]+)\|([\w\d_$]+) }}}', lambda m: str(blockaddrs[m.groups(0)[0]][m.groups(0)[1]]), js) - if settings.get('ASM_JS'): - outfile.write('(function() {\n'); # prevent new Function from seeing the global scope - #if DEBUG: outfile.write('// pre\n') outfile.write(blockaddrsize(indexize(pre))) pre = None @@ -388,9 +385,6 @@ Runtime.stackRestore = function(top) { asm.stackRestore(top) }; outfile.write(indexize(post)) if DEBUG: print >> sys.stderr, ' emscript: phase 3 took %s seconds' % (time.time() - t) - if settings.get('ASM_JS'): - outfile.write('}).apply(null, arguments);\n'); - outfile.close() |