diff options
-rwxr-xr-x | emcc | 9 | ||||
-rw-r--r-- | tests/test_core.py | 18 | ||||
-rw-r--r-- | tests/test_other.py | 6 | ||||
-rw-r--r-- | tests/test_sanity.py | 8 | ||||
-rw-r--r-- | tools/shared.py | 2 |
5 files changed, 24 insertions, 19 deletions
@@ -129,14 +129,14 @@ Most normal gcc/g++ options will work, for example: Options that are modified or new in %s include: -O0 No optimizations (default) -O1 Simple optimizations, including asm.js, LLVM -O1 - optimizations, and no runtime assertions + optimizations, relooping, and no runtime assertions or C++ exception catching (to re-enable C++ exception catching, use -s DISABLE_EXCEPTION_CATCHING=0 ). (For details on the affects of different opt levels, see apply_opt_level() in tools/shared.py and also src/settings.js.) - -O2 As -O1, plus the relooper (loop recreation), + -O2 As -O1, plus various js-level optimizatios, LLVM -O3 optimizations, and -s ALIASING_FUNCTION_POINTERS=1 @@ -258,6 +258,9 @@ Options that are modified or new in %s include: try adjusting JAVA_HEAP_SIZE in the environment (for example, to 4096m for 4GB). + Note: Closure is only run if js opts are being + done (-O2 or above, or --js-opts 1). + --js-transform <cmd> <cmd> will be called on the generated code before it is optimized. This lets you modify the JavaScript, for example adding some code @@ -933,7 +936,7 @@ try: if default_cxx_std: newargs = newargs + [default_cxx_std] - if js_opts is None: js_opts = opt_level >= 1 + if js_opts is None: js_opts = opt_level >= 2 if llvm_opts is None: llvm_opts = LLVM_OPT_LEVEL[opt_level] if llvm_lto is None and opt_level >= 3: llvm_lto = 3 if opt_level == 0: debug_level = 4 diff --git a/tests/test_core.py b/tests/test_core.py index c1bfce6f..03fd4d56 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -1073,7 +1073,6 @@ Succeeded! self.do_run(open(path_from_root('tests', 'cube2md5.cpp')).read(), open(path_from_root('tests', 'cube2md5.ok')).read()) def test_cube2hash(self): - try: old_chunk_size = os.environ.get('EMSCRIPT_MAX_CHUNK_SIZE') or '' os.environ['EMSCRIPT_MAX_CHUNK_SIZE'] = '1' # test splitting out each function to a chunk in emscripten.py (21 functions here) @@ -1091,6 +1090,17 @@ Succeeded! finally: os.environ['EMSCRIPT_MAX_CHUNK_SIZE'] = old_chunk_size + assert 'asm1' in test_modes + if self.run_name == 'asm1': + assert Settings.RELOOP + generated = open('src.cpp.o.js').read() + main = generated[generated.find('function _main'):] + main = main[:main.find('\n}')] + num_vars = 0 + for v in re.findall('var [^;]+;', main): + num_vars += v.count(',') + 1 + assert num_vars == 10, 'no variable elimination should have been run, but seeing %d' % num_vars + def test_unaligned(self): if Settings.QUANTUM_SIZE == 1: return self.skip('No meaning to unaligned addresses in q1') @@ -8606,12 +8616,6 @@ void*:16 assert ' & 255]()' not in original, 'big function table does not exist' assert ' & 255]()' in final, 'big function table exists' - assert 'asm1' in test_modes - if self.run_name == 'asm1': - assert not Settings.RELOOP - Settings.RELOOP = 1 # check for mixing of relooping with asm1 - self.do_run(path_from_root('tests', 'cubescript'), '*\nTemp is 33\n9\n5\nhello, everyone\n*', main_file='command.cpp') - def test_gcc_unmangler(self): Settings.NAMED_GLOBALS = 1 # test coverage for this diff --git a/tests/test_other.py b/tests/test_other.py index afad1927..81221229 100644 --- a/tests/test_other.py +++ b/tests/test_other.py @@ -125,8 +125,6 @@ Options that are modified or new in %s include: (['-o', 'something.js', '-O0'], 0, None, 0, 0), (['-o', 'something.js', '-O1'], 1, None, 0, 0), (['-o', 'something.js', '-O1', '-g'], 1, None, 0, 0), # no closure since debug - (['-o', 'something.js', '-O1', '--closure', '1'], 1, None, 1, 0), - (['-o', 'something.js', '-O1', '--closure', '1', '-s', 'ASM_JS=0'], 1, None, 1, 0), (['-o', 'something.js', '-O2'], 2, None, 0, 1), (['-o', 'something.js', '-O2', '-g'], 2, None, 0, 0), (['-o', 'something.js', '-Os'], 2, None, 0, 1), @@ -169,9 +167,9 @@ Options that are modified or new in %s include: # closure has not been run, we can do some additional checks. TODO: figure out how to do these even with closure assert '._main = ' not in generated, 'closure compiler should not have been run' if keep_debug: - assert ('(label)' in generated or '(label | 0)' in generated) == (opt_level <= 1), 'relooping should be in opt >= 2' + assert ('(label)' in generated or '(label | 0)' in generated) == (opt_level <= 0), 'relooping should be in opt >= 1' assert ('assert(STACKTOP < STACK_MAX' in generated) == (opt_level == 0), 'assertions should be in opt == 0' - assert 'var $i;' in generated or 'var $i_0' in generated or 'var $storemerge3;' in generated or 'var $storemerge4;' in generated or 'var $i_04;' in generated or 'var $original = 0' in generated, 'micro opts should always be on' + assert 'var $i;' in generated or 'var $i_0' in generated or 'var $storemerge3;' in generated or 'var $storemerge4;' in generated or '$i_04' in generated or '$i_05' in generated or 'var $original = 0' in generated, 'micro opts should always be on' if opt_level >= 2 and '-g' in params: assert re.search('HEAP8\[\$?\w+ ?\+ ?\(+\$?\w+ ?', generated) or re.search('HEAP8\[HEAP32\[', generated), 'eliminator should create compound expressions, and fewer one-time vars' # also in -O1, but easier to test in -O2 assert ('_puts(' in generated) == (opt_level >= 1), 'with opt >= 1, llvm opts are run and they should optimize printf to puts' diff --git a/tests/test_sanity.py b/tests/test_sanity.py index aa3f1242..a0fff252 100644 --- a/tests/test_sanity.py +++ b/tests/test_sanity.py @@ -429,12 +429,12 @@ fi stdout=PIPE, stderr=PIPE).communicate() self.assertContained('hello, world!', run_js('a.out.js')) output = '\n'.join(output) - assert ('bootstrapping relooper succeeded' in output) == (i == 2), 'only bootstrap on first O2: ' + output - assert os.path.exists(RELOOPER) == (i >= 2), 'have relooper on O2: ' + output + assert ('bootstrapping relooper succeeded' in output) == (i == 1), 'only bootstrap on first O2: ' + output + assert os.path.exists(RELOOPER) == (i >= 1), 'have relooper on O2: ' + output src = open('a.out.js').read() main = src.split('function _main()')[1].split('\n}\n')[0] - assert ('while (1) {' in main or 'while(1){' in main or '} while ($' in main or '}while($' in main) == (i >= 2), 'reloop code on O2: ' + main - assert ('switch' not in main) == (i >= 2), 'reloop code on O2: ' + main + assert ('while (1) {' in main or 'while(1){' in main or 'while(1) {' in main or '} while ($' in main or '}while($' in main) == (i >= 1), 'reloop code on O2: ' + main + assert ('switch' not in main) == (i >= 1), 'reloop code on O2: ' + main def test_jcache(self): PRE_LOAD_MSG = 'loading pre from jcache' diff --git a/tools/shared.py b/tools/shared.py index 1862af14..63397f98 100644 --- a/tools/shared.py +++ b/tools/shared.py @@ -758,8 +758,8 @@ class Settings2(type): self.attrs['ASM_JS'] = 1 self.attrs['ASSERTIONS'] = 0 self.attrs['DISABLE_EXCEPTION_CATCHING'] = 1 - if opt_level >= 2: self.attrs['RELOOP'] = 1 + if opt_level >= 2: self.attrs['ALIASING_FUNCTION_POINTERS'] = 1 if opt_level >= 3: # Aside from these, -O3 also runs closure compiler and llvm lto |