diff options
author | Alon Zakai <alonzakai@gmail.com> | 2011-12-12 17:41:03 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2011-12-12 17:41:03 -0800 |
commit | 6df042a2ae8a85a47dcd39040204873bf01a360e (patch) | |
tree | d3fd0fef55e584d4c4e928f84c79342f647cfadc /tests | |
parent | 0281e14fd66dc36dbc5a9dc75f375deb5ae5e245 (diff) |
support for running the js optimizer, eliminator and closure compiler from emcc
Diffstat (limited to 'tests')
-rw-r--r-- | tests/runner.py | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/tests/runner.py b/tests/runner.py index 8a98b0e8..d3fffcf3 100644 --- a/tests/runner.py +++ b/tests/runner.py @@ -4952,21 +4952,23 @@ JavaScript in the final linking stage of building. assert ('Warning: Applying some potentially unsafe optimizations!' in output[1]) == (opt_level >= 3), 'unsafe warning should appear in opt >= 3' self.assertContained('hello, world!', run_js('something.js')) - # Verify optimization level in the generated code + # Verify optimization level etc. in the generated code # XXX these are quite sensitive, and will need updating when code generation changes generated = open('something.js').read() # TODO: parse out the _main function itself, not support code, if the tests below need that some day - assert ('while(1) switch(__label__)' in generated) == (opt_level <= 1), 'relooping should be in opt >= 2' + assert ('(__label__)' in generated) == (opt_level <= 1), 'relooping should be in opt >= 2' assert ('assert(STACKTOP < STACK_MAX)' in generated) == (opt_level == 0), 'assertions should be in opt == 0' - assert ('|0)/2)|0)' in generated) == (opt_level <= 2), 'corrections should be in opt <= 2' - assert 'var $i;' in generated, 'micro opts should always be on' - assert 'HEAP32[' in generated, 'typed arrays 2 should be used by default' + assert ('|0)/2)|0)' in generated or '| 0) / 2 | 0)' in generated) == (opt_level <= 2), 'corrections should be in opt <= 2' + if opt_level < 3: assert 'var $i;' in generated, 'micro opts should always be on' # TODO: find a way to check it even with closure + assert 'new Uint16Array' in generated and 'new Uint32Array' in generated, 'typed arrays 2 should be used by default' assert 'SAFE_HEAP' not in generated, 'safe heap should not be used by default' + assert ': while(' not in generated, 'when relooping we also js-optimize, so there should be no labelled whiles' + if opt_level >= 1 and opt_level < 3: assert 'HEAP8[HEAP32[' in generated, 'eliminator should create compound expressions, and fewer one-time vars' # TODO: find a way to check it even with closure + if opt_level >= 3: assert 'Module._main = ' in generated, 'closure compiler should have been run' - # TODO: -O1 plus eliminator, plus js optimizer - # emcc --typed-arrays=x .. ==> should use typed arrays. default should be 2 # emcc --llvm-opts=x .. ==> pick level of LLVM optimizations (default is 0, to be safe?) # emcc -s RELOOP=1 src.cpp ==> should pass -s to emscripten.py # When doing unsafe opts, can we run -Ox on the source, not just at the very end? + # In fact we can run safe opts at that time too, now we are a gcc replacement. Removes the entire need for llvm opts only at the end. # linking - TODO. in particular, test normal project linking, static and dynamic: get_library should not need to be told what to link! # emcc a.cpp b.cpp => one .js # emcc a.cpp b.cpp -c => two .o files @@ -5302,13 +5304,6 @@ if __name__ == '__main__': # Sanity checks - def check_engine(engine): - try: - return 'hello, world!' in run_js(path_from_root('tests', 'hello_world.js'), engine) - except Exception, e: - print 'Checking JS engine %s failed. Check ~/.emscripten. Details: %s' % (str(engine), str(e)) - return False - if not check_engine(COMPILER_ENGINE): print 'WARNING: The JavaScript shell used for compiling does not seem to work' |