diff options
-rwxr-xr-x | emcc | 25 | ||||
-rw-r--r-- | src/intertyper.js | 2 | ||||
-rw-r--r-- | src/jsifier.js | 5 | ||||
-rw-r--r-- | src/shell.html | 1 | ||||
-rwxr-xr-x | tests/runner.py | 8 |
5 files changed, 29 insertions, 12 deletions
@@ -74,10 +74,19 @@ emcc can be influenced by a few environment variables: EMMAKEN_COMPILER - The compiler to be used, if you don't want the default clang. ''' -import os, sys, shutil, tempfile -from subprocess import Popen, PIPE, STDOUT +import os, sys, shutil, tempfile, subprocess +from subprocess import PIPE, STDOUT from tools import shared +def execute(cmd, *args, **kw): + try: + return subprocess.Popen(cmd, *args, **kw).communicate() # let compiler frontend print directly, so colors are saved (PIPE kills that) + except: + if not isinstance(cmd, str): + cmd = ' '.join(cmd) + print >> sys.stderr, 'Invoking Process failed: <<< ' + cmd + ' >>>' + raise + # Mapping of emcc opt levels to llvm opt levels. We use llvm opt level 3 in emcc opt # levels 2 and 3 (emcc 3 is unsafe opts, so unsuitable for the only level to get # llvm opt level 3, and speed-wise emcc level 2 is already the slowest/most optimizing @@ -517,7 +526,7 @@ try: temp_files.append(output_file) args = newargs + ['-emit-llvm', '-c', input_file, '-o', output_file] if DEBUG: print >> sys.stderr, "emcc running:", call, ' '.join(args) - Popen([call] + args).communicate() # let compiler frontend print directly, so colors are saved (PIPE kills that) + execute([call] + args) # let compiler frontend print directly, so colors are saved (PIPE kills that) if not os.path.exists(output_file): print >> sys.stderr, 'emcc: compiler frontend failed to generate LLVM bitcode, halting' sys.exit(1) @@ -560,7 +569,7 @@ try: ld_args = temp_files + ['-b', specified_target] #[arg.split('-Wl,')[1] for arg in filter(lambda arg: arg.startswith('-Wl,'), sys.argv)] if DEBUG: print >> sys.stderr, 'emcc: link: ' + str(ld_args) - Popen([shared.LLVM_LD, '-disable-opt'] + ld_args).communicate() + execute([shared.LLVM_LD, '-disable-opt'] + ld_args) exit(0) ## Continue on to create JavaScript @@ -578,9 +587,9 @@ try: # dlmalloc def create_dlmalloc(): if DEBUG: print >> sys.stderr, 'emcc: building dlmalloc for cache' - Popen([shared.EMCC, shared.path_from_root('system', 'lib', 'dlmalloc.c'), '-g', '-o', in_temp('dlmalloc.o')], stdout=stdout, stderr=stderr).communicate() + execute([shared.EMCC, shared.path_from_root('system', 'lib', 'dlmalloc.c'), '-g', '-o', in_temp('dlmalloc.o')], stdout=stdout, stderr=stderr) # we include the libc++ new stuff here, so that the common case of using just new/delete is quick to link - Popen([shared.EMXX, shared.path_from_root('system', 'lib', 'libcxx', 'new.cpp'), '-g', '-o', in_temp('new.o')], stdout=stdout, stderr=stderr).communicate() + execute([shared.EMXX, shared.path_from_root('system', 'lib', 'libcxx', 'new.cpp'), '-g', '-o', in_temp('new.o')], stdout=stdout, stderr=stderr) shared.Building.link([in_temp('dlmalloc.o'), in_temp('new.o')], in_temp('dlmalloc_full.o')) return in_temp('dlmalloc_full.o') def fix_dlmalloc(): @@ -702,7 +711,7 @@ try: if AUTODEBUG: if DEBUG: print >> sys.stderr, 'emcc: autodebug' - Popen(['python', shared.AUTODEBUGGER, final, final + '.ad.ll']).communicate()[0] + execute(['python', shared.AUTODEBUGGER, final, final + '.ad.ll']) final += '.ad.ll' if DEBUG: save_intermediate('autodebug', 'll') @@ -735,7 +744,7 @@ try: shutil.copyfile(final, final + '.tr.js') final += '.tr.js' if DEBUG: print >> sys.stderr, 'emcc: applying transform: %s' % js_transform - Popen(js_transform.split(' ') + [os.path.abspath(final)]).communicate() + execute(js_transform.split(' ') + [os.path.abspath(final)]) if DEBUG: save_intermediate('transformed') # It is useful to run several js optimizer passes together, to save on unneeded unparsing/reparsing diff --git a/src/intertyper.js b/src/intertyper.js index bd7b70f9..c5a9583b 100644 --- a/src/intertyper.js +++ b/src/intertyper.js @@ -334,6 +334,8 @@ function intertyper(data, sidePass, baseLineNums) { return 'Phi'; if (tokensLength >= 3 && token0Text == 'landingpad') return 'Landingpad'; + if (token0Text == 'fence') + return '/dev/null'; } else if (item.indent === 0) { if ((tokensLength >= 1 && token0Text.substr(-1) == ':') || (tokensLength >= 3 && token1Text == '<label>')) diff --git a/src/jsifier.js b/src/jsifier.js index b54aace3..5ad1573b 100644 --- a/src/jsifier.js +++ b/src/jsifier.js @@ -921,13 +921,16 @@ function JSify(data, functionsOnly, givenFunctions) { }); var ret = ''; var first = true; + var signedIdent = makeSignOp(item.ident, item.type, 're'); // we need to standardize for purpose of comparison for (var targetLabel in targetLabels) { if (!first) { ret += 'else '; } else { first = false; } - ret += 'if (' + targetLabels[targetLabel].map(function(value) { return makeComparison(item.ident, value, item.type) }).join(' || ') + ') {\n'; + ret += 'if (' + targetLabels[targetLabel].map(function(value) { + return makeComparison(signedIdent, makeSignOp(value, item.type, 're'), item.type) + }).join(' || ') + ') {\n'; ret += ' ' + getPhiSetsForLabel(phiSets, targetLabel) + makeBranch(targetLabel, item.currLabelId || null) + '\n'; ret += '}\n'; } diff --git a/src/shell.html b/src/shell.html index a41086b9..2f34ace3 100644 --- a/src/shell.html +++ b/src/shell.html @@ -19,6 +19,7 @@ print: (function() { var element = document.getElementById('output'); return function(text) { + text = text.replace(/&/g, "&"); text = text.replace(/</g, "<"); text = text.replace(/>/g, ">"); text = text.replace('\n', '<br>', 'g'); diff --git a/tests/runner.py b/tests/runner.py index e8bcb72e..51b9e357 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -2298,18 +2298,20 @@ def process(filename): case 'b': case 'c': return p-1; - case 'd': + case 0xfffffff1: return p+1; } return p; } int main( int argc, const char *argv[] ) { - printf("*%d,%d,%d,%d,%d*\\n", switcher('a'), switcher('b'), switcher('c'), switcher('d'), switcher('e')); + unsigned int x = 0xfffffff1; + x >>= 0; // force it to be unsigned for purpose of checking our switch comparison in signed/unsigned + printf("*%d,%d,%d,%d,%d,%d*\\n", switcher('a'), switcher('b'), switcher('c'), switcher(x), switcher(-15), switcher('e')); return 0; } ''' - self.do_run(src, '*96,97,98,101,101*') + self.do_run(src, '*96,97,98,-14,-14,101*') def test_indirectbr(self): src = ''' |