diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/js-optimizer.js | 6 | ||||
-rw-r--r-- | tools/js_optimizer.py | 24 | ||||
-rw-r--r-- | tools/shared.py | 2 | ||||
-rw-r--r-- | tools/test-js-optimizer-asm-pre-output.js | 3 | ||||
-rw-r--r-- | tools/test-js-optimizer-asm-pre.js | 3 |
5 files changed, 25 insertions, 13 deletions
diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js index 6987511c..71a59921 100644 --- a/tools/js-optimizer.js +++ b/tools/js-optimizer.js @@ -562,7 +562,8 @@ function simplifyExpressionsPre(ast) { } else if (type === 'binary' && node[1] === '^') { // LLVM represents bitwise not as xor with -1. Translate it back to an actual bitwise not. if (node[3][0] === 'unary-prefix' && node[3][1] === '-' && node[3][2][0] === 'num' && - node[3][2][1] === 1) { + node[3][2][1] === 1 && + !(node[2][0] == 'unary-prefix' && node[2][1] == '~')) { // avoid creating ~~~ which is confusing for asm given the role of ~~ return ['unary-prefix', '~', node[2]]; } } else if (type === 'binary' && node[1] === '>>' && node[3][0] === 'num' && @@ -636,7 +637,8 @@ function simplifyExpressionsPre(ast) { if (node[0] === 'seq' && node[1][0] === 'assign' && node[1][2][0] === 'sub' && node[1][2][1][0] === 'name' && (node[1][2][1][1] === 'HEAP32' || node[1][2][1][1] === 'HEAPF32') && node[1][2][2][0] === 'binary' && node[1][2][2][2][0] === 'name' && node[1][2][2][2][1] === 'tempDoublePtr' && - node[1][3][0] === 'sub' && node[1][3][1][0] === 'name' && (node[1][3][1][1] === 'HEAP32' || node[1][3][1][1] === 'HEAPF32')) { + node[1][3][0] === 'sub' && node[1][3][1][0] === 'name' && (node[1][3][1][1] === 'HEAP32' || node[1][3][1][1] === 'HEAPF32') && + node[2][0] !== 'seq') { // avoid (x, y, z) which can be used for tempDoublePtr on doubles for alignment fixes if (node[1][2][1][1] === 'HEAP32') { node[1][3][1][1] = 'HEAPF32'; return ['unary-prefix', '+', node[1][3]]; diff --git a/tools/js_optimizer.py b/tools/js_optimizer.py index a4e1ca6c..4e7d5474 100644 --- a/tools/js_optimizer.py +++ b/tools/js_optimizer.py @@ -102,16 +102,20 @@ start_asm_marker = '// EMSCRIPTEN_START_ASM\n' end_asm_marker = '// EMSCRIPTEN_END_ASM\n' def run_on_chunk(command): - filename = command[2] # XXX hackish - #print >> sys.stderr, 'running js optimizer command', ' '.join(command), '""""', open(filename).read() - output = subprocess.Popen(command, stdout=subprocess.PIPE).communicate()[0] - assert len(output) > 0 and not output.startswith('Assertion failed'), 'Error in js optimizer: ' + output - filename = temp_files.get(os.path.basename(filename) + '.jo.js').name - f = open(filename, 'w') - f.write(output) - f.close() - if DEBUG and not shared.WINDOWS: print >> sys.stderr, '.' # Skip debug progress indicator on Windows, since it doesn't buffer well with multiple threads printing to console. - return filename + try: + filename = command[2] # XXX hackish + #print >> sys.stderr, 'running js optimizer command', ' '.join(command), '""""', open(filename).read() + output = subprocess.Popen(command, stdout=subprocess.PIPE).communicate()[0] + assert len(output) > 0 and not output.startswith('Assertion failed'), 'Error in js optimizer: ' + output + filename = temp_files.get(os.path.basename(filename) + '.jo.js').name + f = open(filename, 'w') + f.write(output) + f.close() + if DEBUG and not shared.WINDOWS: print >> sys.stderr, '.' # Skip debug progress indicator on Windows, since it doesn't buffer well with multiple threads printing to console. + return filename + except KeyboardInterrupt: + # avoid throwing keyboard interrupts from a child process + raise Exception() def run_on_js(filename, passes, js_engine, jcache, source_map=False, extra_info=None): if isinstance(jcache, bool) and jcache: jcache = shared.JCache diff --git a/tools/shared.py b/tools/shared.py index 0351a736..007c2ee8 100644 --- a/tools/shared.py +++ b/tools/shared.py @@ -726,7 +726,7 @@ class Building: env['HOST_CXXFLAGS'] = "-W" #if set to nothing, CXXFLAGS is used, which we don't want env['PKG_CONFIG_LIBDIR'] = path_from_root('system', 'local', 'lib', 'pkgconfig') + os.path.pathsep + path_from_root('system', 'lib', 'pkgconfig') env['PKG_CONFIG_PATH'] = os.environ.get ('EM_PKG_CONFIG_PATH') or '' - env['EMSCRIPTEN'] = '1' + env['EMSCRIPTEN'] = path_from_root() return env @staticmethod diff --git a/tools/test-js-optimizer-asm-pre-output.js b/tools/test-js-optimizer-asm-pre-output.js index b7afab26..8a5803d6 100644 --- a/tools/test-js-optimizer-asm-pre-output.js +++ b/tools/test-js-optimizer-asm-pre-output.js @@ -66,6 +66,7 @@ function b($this, $__n) { HEAP32[$4] = ~HEAP32[$5]; HEAP32[$4] = ~HEAP32[$5]; HEAP32[$4] = ~HEAP32[$5]; + h(~~g ^ -1); return; } function rett() { @@ -156,6 +157,8 @@ function tempDoublePtr($45, $14, $28, $42) { unelim2 = 127 + $14 | 0; func(); HEAP32[4] = unelim2; + barrier(); + $f163 = (HEAP32[tempDoublePtr >> 2] = HEAP32[$f165 >> 2], HEAP32[tempDoublePtr + 4 >> 2] = HEAP32[$f165 + 4 >> 2], +HEAPF64[tempDoublePtr >> 3]); } function boxx($this, $aabb, $xf, $childIndex) { $this = $this | 0; diff --git a/tools/test-js-optimizer-asm-pre.js b/tools/test-js-optimizer-asm-pre.js index b762a60e..5c004342 100644 --- a/tools/test-js-optimizer-asm-pre.js +++ b/tools/test-js-optimizer-asm-pre.js @@ -70,6 +70,7 @@ function b($this, $__n) { HEAP32[$4] = HEAP32[$5]^-1; // Rewrite to ~ and eliminate the |0. HEAP32[$4] = ((HEAP32[$5]|0)^-1)|0; + h((~~g) ^ -1); // do NOT convert this, as it would lead to ~~~ which is confusing in asm, given the role of ~~ return; } function rett() { @@ -166,6 +167,8 @@ function tempDoublePtr($45, $14, $28, $42) { unelim2 = (HEAP32[tempDoublePtr >> 2] = 127 + $14, +HEAPF32[tempDoublePtr >> 2]); func(); HEAPF32[4] = unelim2; + barrier(); + $f163 = (HEAP32[tempDoublePtr >> 2] = HEAP32[$f165 >> 2], HEAP32[tempDoublePtr + 4 >> 2] = HEAP32[$f165 + 4 >> 2], +HEAPF64[tempDoublePtr >> 3]); } function boxx($this, $aabb, $xf, $childIndex) { $this = $this | 0; |