From 71c35cabf913684bb58c0a42648ce7727c138be1 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Wed, 9 Jan 2013 12:43:58 -0800 Subject: [PATCH 001/250] fix test_emcc_caching --- tests/runner.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/runner.py b/tests/runner.py index 9c903f20e15d3..879c279b78c00 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -11016,8 +11016,8 @@ def test_emcc_caching(self): # Building a file that doesn't need cached stuff should not trigger cache generation output = self.do([EMCC, path_from_root('tests', 'hello_world.cpp')]) - assert INCLUDING_MESSAGE.replace('X', 'dlmalloc') not in output - assert BUILDING_MESSAGE.replace('X', 'dlmalloc') not in output + assert INCLUDING_MESSAGE.replace('X', 'libc') not in output + assert BUILDING_MESSAGE.replace('X', 'libc') not in output self.assertContained('hello, world!', run_js('a.out.js')) assert not os.path.exists(EMCC_CACHE) try_delete('a.out.js') @@ -11029,7 +11029,7 @@ def test_emcc_caching(self): ll_name2 = os.path.join(TEMP_DIR, 'emscripten_temp', 'emcc-3-ll.ll') # Building a file that *does* need dlmalloc *should* trigger cache generation, but only the first time - for filename, libname in [('hello_malloc.cpp', 'dlmalloc'), ('hello_libcxx.cpp', 'libcxx')]: + for filename, libname in [('hello_malloc.cpp', 'libc'), ('hello_libcxx.cpp', 'libcxx')]: for i in range(3): print filename, libname, i self.clear() @@ -11041,10 +11041,10 @@ def test_emcc_caching(self): output = self.do([EMCC, '-O' + str(i), '--closure', '0', '-s', 'RELOOP=0', '--llvm-lto', '0', path_from_root('tests', filename)]) #print output assert INCLUDING_MESSAGE.replace('X', libname) in output - if libname == 'dlmalloc': + if libname == 'libc': assert INCLUDING_MESSAGE.replace('X', 'libcxx') not in output # we don't need libcxx in this code else: - assert INCLUDING_MESSAGE.replace('X', 'dlmalloc') in output # libcxx always forces inclusion of dlmalloc + assert INCLUDING_MESSAGE.replace('X', 'libc') in output # libcxx always forces inclusion of libc assert (BUILDING_MESSAGE.replace('X', libname) in output) == (i == 0), 'Must only build the first time' self.assertContained('hello, world!', run_js('a.out.js')) assert os.path.exists(EMCC_CACHE) From c6652bf70fe86f52a03c6bc950d46e9d79733393 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Wed, 9 Jan 2013 14:44:09 -0800 Subject: [PATCH 002/250] gitignore --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 63f7119527513..31814a09b17cb 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,6 @@ src/relooper*.js # Ignore generated files src/relooper.js src/relooper.js.raw.js +src/relooper/*.o +src/relooper/*.out + From b4cdf27a95360f76bb9bcb96142749ecc39282ba Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Wed, 9 Jan 2013 15:47:16 -0800 Subject: [PATCH 003/250] let test runner output processor handle stdout and err separately --- tests/runner.py | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/tests/runner.py b/tests/runner.py index 879c279b78c00..66100b8f7a953 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -263,7 +263,7 @@ def build(self, src, dirname, filename, output_processor=None, main_file=None, a if output_processor is not None: output_processor(open(filename + '.o.js').read()) - def run_generated_code(self, engine, filename, args=[], check_timeout=True): + def run_generated_code(self, engine, filename, args=[], check_timeout=True, output_nicerizer=None): stdout = os.path.join(self.get_dir(), 'stdout') # use files, as PIPE can get too full and hang us stderr = os.path.join(self.get_dir(), 'stderr') try: @@ -274,7 +274,12 @@ def run_generated_code(self, engine, filename, args=[], check_timeout=True): run_js(filename, engine, args, check_timeout, stdout=open(stdout, 'w'), stderr=open(stderr, 'w')) if cwd is not None: os.chdir(cwd) - ret = open(stdout, 'r').read() + open(stderr, 'r').read() + out = open(stdout, 'r').read() + err = open(stderr, 'r').read() + if output_nicerizer: + ret = output_nicerizer(out, err) + else: + ret = out + err assert 'strict warning:' not in ret, 'We should pass all strict mode checks: ' + ret return ret @@ -451,9 +456,7 @@ def do_run(self, src, expected_output, args=[], output_nicerizer=None, output_pr js_engines = filter(lambda engine: engine not in self.banned_js_engines, js_engines) if len(js_engines) == 0: return self.skip('No JS engine present to run this test with. Check %s and the paths therein.' % EM_CONFIG) for engine in js_engines: - js_output = self.run_generated_code(engine, filename + '.o.js', args) - if output_nicerizer is not None: - js_output = output_nicerizer(js_output) + js_output = self.run_generated_code(engine, filename + '.o.js', args, output_nicerizer=output_nicerizer) self.assertContained(expected_output, js_output.replace('\r\n', '\n')) self.assertNotContained('ERROR', js_output) @@ -3920,7 +3923,7 @@ def test_memcpy(self): return 0; } ''' - def check(result): + def check(result, err): return hashlib.sha1(result).hexdigest() self.do_run(src, '6c9cdfe937383b79e52ca7a2cce83a21d9f5422c', output_nicerizer = check) @@ -4233,7 +4236,7 @@ def process(filename): open(filename, 'w').write(src) ''' self.do_run(src, 'Sort with main comparison: 5 4 3 2 1 *Sort with lib comparison: 1 2 3 4 5 *', - output_nicerizer=lambda x: x.replace('\n', '*'), + output_nicerizer=lambda x, err: x.replace('\n', '*'), post_build=add_pre_run_and_checks) def test_dlfcn_data_and_fptr(self): @@ -4337,7 +4340,7 @@ def process(filename): open(filename, 'w').write(src) ''' self.do_run(src, 'In func: 13*First calling main_fptr from lib.*Second calling lib_fptr from main.*parent_func called from child*parent_func called from child*Var: 42*', - output_nicerizer=lambda x: x.replace('\n', '*'), + output_nicerizer=lambda x, err: x.replace('\n', '*'), post_build=add_pre_run_and_checks) def test_dlfcn_alias(self): @@ -4392,7 +4395,7 @@ def process(filename): open(filename, 'w').write(src) ''' self.do_run(src, 'Parent global: 123.*Parent global: 456.*', - output_nicerizer=lambda x: x.replace('\n', '*'), + output_nicerizer=lambda x, err: x.replace('\n', '*'), post_build=add_pre_run_and_checks, extra_emscripten_args=['-H', 'libc/fcntl.h,libc/sys/unistd.h,poll.h,libc/math.h,libc/time.h,libc/langinfo.h']) Settings.INCLUDE_FULL_LIBRARY = 0 @@ -6438,7 +6441,7 @@ def test_lua(self): self.do_ll_run(path_from_root('tests', 'lua', 'lua.ll'), 'hello lua world!\n17\n1\n2\n3\n4\n7', args=['-e', '''print("hello lua world!");print(17);for x = 1,4 do print(x) end;print(10-3)'''], - output_nicerizer=lambda string: string.replace('\n\n', '\n').replace('\n\n', '\n'), + output_nicerizer=lambda string, err: (string + err).replace('\n\n', '\n').replace('\n\n', '\n'), extra_emscripten_args=['-H', 'libc/fcntl.h,libc/sys/unistd.h,poll.h,libc/math.h,libc/langinfo.h,libc/time.h']) finally: del os.environ['EMCC_LEAVE_INPUTS_RAW'] @@ -6649,7 +6652,7 @@ def process(filename): # We use doubles in JS, so we get slightly different values than native code. So we # check our output by comparing the average pixel difference - def image_compare(output): + def image_compare(output, err): # Get the image generated by JS, from the JSON.stringify'd array m = re.search('\[[\d, -]*\]', output) try: @@ -7642,7 +7645,7 @@ def test_pgo(self): } ''' - def check(output): + def check(output, err): # TODO: check the line # if self.emcc_args is None or self.emcc_args == []: # LLVM full opts optimize out some corrections assert re.search('^Overflow\|.*src.cpp:6 : 60 hits, %20 failures$', output, re.M), 'no indication of Overflow corrections: ' + output From a48941b07c88f2aee0be9adbdabd9b4b045f7b65 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Wed, 9 Jan 2013 15:59:58 -0800 Subject: [PATCH 004/250] modernize lua .ll and simplify test to not need EMCC_KEEP_INPUTS_RAW which is hackish --- tests/lua/lua.ll | 15 ++++++++------- tests/runner.py | 31 +++++++++++++------------------ 2 files changed, 21 insertions(+), 25 deletions(-) diff --git a/tests/lua/lua.ll b/tests/lua/lua.ll index 81c7bc2770e94..cffaa3a29a852 100644 --- a/tests/lua/lua.ll +++ b/tests/lua/lua.ll @@ -13914,7 +13914,7 @@ define hidden void @_Z10luaD_throwP9lua_Statei(%struct.lua_State* %L, i32 %errco %10 = getelementptr inbounds %struct.lua_State* %9, i32 0, i32 25, !dbg !9995 ; [#uses=1] %11 = load %struct.lua_longjmp** %10, align 4, !dbg !9995 ; [#uses=1] %12 = getelementptr inbounds %struct.lua_longjmp* %11, i32 0, i32 2, !dbg !9995 ; [#uses=1] - volatile store i32 %8, i32* %12, align 4, !dbg !9995 + store i32 %8, i32* %12, align 4, !dbg !9995 %13 = call i8* @__cxa_allocate_exception(i32 4) nounwind, !dbg !9997 ; [#uses=2] %14 = bitcast i8* %13 to %struct.lua_longjmp**, !dbg !9997 ; [#uses=1] %15 = load %struct.lua_State** %1, align 4, !dbg !9997 ; [#uses=1] @@ -14032,7 +14032,7 @@ define hidden i32 @_Z20luaD_rawrunprotectedP9lua_StatePFvS0_PvES1_(%struct.lua_S call void @llvm.dbg.declare(metadata !743, metadata !10030), !dbg !10031 call void @llvm.dbg.declare(metadata !743, metadata !10032), !dbg !10034 %5 = getelementptr inbounds %struct.lua_longjmp* %lj, i32 0, i32 2, !dbg !10035 ; [#uses=1] - volatile store i32 0, i32* %5, align 4, !dbg !10035 + store i32 0, i32* %5, align 4, !dbg !10035 %6 = load %struct.lua_State** %1, align 4, !dbg !10036 ; [#uses=1] %7 = getelementptr inbounds %struct.lua_State* %6, i32 0, i32 25, !dbg !10036 ; [#uses=1] %8 = load %struct.lua_longjmp** %7, align 4, !dbg !10036 ; [#uses=1] @@ -14044,8 +14044,9 @@ define hidden i32 @_Z20luaD_rawrunprotectedP9lua_StatePFvS0_PvES1_(%struct.lua_S %12 = load void (%struct.lua_State*, i8*)** %2, align 4, !dbg !10038 ; [#uses=1] %13 = load %struct.lua_State** %1, align 4, !dbg !10038 ; [#uses=1] %14 = load i8** %3, align 4, !dbg !10038 ; [#uses=1] - invoke void %12(%struct.lua_State* %13, i8* %14) - to label %15 unwind label %24, !dbg !10038 + call void %12(%struct.lua_State* %13, i8* %14) + ; to label %15 unwind label %24, !dbg !10038 + %15 = load i8** %3 ;