diff options
-rw-r--r-- | AUTHORS | 2 | ||||
-rwxr-xr-x | emscripten.py | 4 | ||||
-rw-r--r-- | src/library_glut.js | 2 | ||||
-rw-r--r-- | tests/cases/switch64_ta2.ll | 44 | ||||
-rw-r--r-- | tests/cases/switch64_ta2.txt | 2 | ||||
-rw-r--r-- | tests/cases/switch64b_ta2.ll | 54 | ||||
-rw-r--r-- | tests/cases/switch64b_ta2.txt | 3 | ||||
-rw-r--r-- | tests/test_core.py | 10 | ||||
-rwxr-xr-x | tools/nativize_llvm.py | 2 |
9 files changed, 89 insertions, 34 deletions
@@ -115,3 +115,5 @@ a license to everyone to use it as detailed in LICENSE.) * Adam C. Clifton <adam@hulkamaniac.com> * Volo Zyko <volo.zyko@gmail.com> * Andre Weissflog <floooh@gmail.com> +* Alexandre Perrot <alexandre.perrot@gmail.com> +* Emerson José Silveira da Costa <emerson.costa@gmail.com> diff --git a/emscripten.py b/emscripten.py index 1a3bddd7..8ddb7375 100755 --- a/emscripten.py +++ b/emscripten.py @@ -873,6 +873,10 @@ def emscript_fast(infile, settings, outfile, libraries=[], compiler_engine=None, if key in all_exported_functions or export_all or (export_bindings and key.startswith('_emscripten_bind')): exported_implemented_functions.add(key) + # Add named globals + named_globals = '\n'.join(['var %s = %s;' % (k, v) for k, v in metadata['namedGlobals'].iteritems()]) + pre = pre.replace('// === Body ===', '// === Body ===\n' + named_globals + '\n') + #if DEBUG: outfile.write('// pre\n') outfile.write(pre) pre = None diff --git a/src/library_glut.js b/src/library_glut.js index 76a52b73..65ac10c4 100644 --- a/src/library_glut.js +++ b/src/library_glut.js @@ -122,6 +122,8 @@ var LibraryGLUT = { return keycode; // numeric TODO handle shift? if (65 <= keycode && keycode <= 90) return event['shiftKey'] ? keycode : keycode + 32; + if (96 <= keycode && keycode <= 105) + return keycode - 48; // numpad numbers if (106 <= keycode && keycode <= 111) return keycode - 106 + 42; // *,+-./ TODO handle shift? diff --git a/tests/cases/switch64_ta2.ll b/tests/cases/switch64_ta2.ll index 4d5c6273..1a6d52f3 100644 --- a/tests/cases/switch64_ta2.ll +++ b/tests/cases/switch64_ta2.ll @@ -1,12 +1,14 @@ target datalayout = "e-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-p:32:32:32-v128:32:32" target triple = "le32-unknown-nacl" -@.str = private constant [15 x i8] c"hello, world!\0A\00", align 1 ; [#uses=1] +@.str = private constant [18 x i8] c"hello, world: %d\0A\00", align 1 + +declare i32 @printf(i8*, ...) define linkonce_odr i32 @main() align 2 { - %a333 = call i32 @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0)) ; [#uses=0] - %a444 = zext i32 %a333 to i64 - %a199 = trunc i8 1 to i1 ; [#uses=1] + %a333 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([18 x i8]* @.str, i32 0, i32 0), i32 5) + %a400 = zext i32 %a333 to i64 + %a444 = udiv i64 %a400, 3 switch i64 %a444, label %label999 [ i64 1000, label %label9950 i64 1001, label %label9951 @@ -18,41 +20,35 @@ define linkonce_odr i32 @main() align 2 { i64 1007, label %label9957 i64 1008, label %label9958 i64 1009, label %label9959 - ] ; switch should ignore all code after it in the block - ; No predecessors! - %a472 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) - cleanup - %a473 = extractvalue { i8*, i32 } %a472, 0 - %a474 = extractvalue { i8*, i32 } %a472, 1 - br label %label999 + ] label9950: - %a333b = call i32 @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0)) ; [#uses=0] + %waka = phi i32 [1000, %0], [0, %label9951], [1, %label9952], [2, %label9953], [3, %label9954], [4, %label9955], [5, %label9956], [6, %label9957], [7, %label9958], [8, %label9959] + %a333b = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([18 x i8]* @.str, i32 0, i32 0), i32 %waka) br label %label999 label9951: - br label %label999 + br label %label9950 label9952: - br label %label999 + br label %label9950 label9953: - br label %label999 + br label %label9950 label9954: - br label %label999 + br label %label9950 label9955: - br label %label999 + br label %label9950 label9956: - br label %label999 + br label %label9950 label9957: - br label %label999 + br label %label9950 label9958: - br label %label999 + br label %label9950 label9959: - br label %label999 + br label %label9950 label999: ; preds = %555 + %last = phi i32 [1, %0], [2, %label9950] + %a333c = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([18 x i8]* @.str, i32 0, i32 0), i32 %last) ret i32 0 } -declare i32 @printf(i8*) -declare i32 @__gxx_personality_v0(...) - diff --git a/tests/cases/switch64_ta2.txt b/tests/cases/switch64_ta2.txt new file mode 100644 index 00000000..72084b0c --- /dev/null +++ b/tests/cases/switch64_ta2.txt @@ -0,0 +1,2 @@ +hello, world: 5 +hello, world: 1 diff --git a/tests/cases/switch64b_ta2.ll b/tests/cases/switch64b_ta2.ll new file mode 100644 index 00000000..4364725f --- /dev/null +++ b/tests/cases/switch64b_ta2.ll @@ -0,0 +1,54 @@ +target datalayout = "e-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-p:32:32:32-v128:32:32" +target triple = "le32-unknown-nacl" + +@.str = private constant [18 x i8] c"hello, world: %d\0A\00", align 1 + +declare i32 @printf(i8*, ...) + +define linkonce_odr i32 @main() align 2 { + %a333 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([18 x i8]* @.str, i32 0, i32 0), i32 5) + %a400 = zext i32 %a333 to i64 + %a444 = udiv i64 %a400, 3 + switch i64 %a444, label %label999 [ + i64 0, label %label9950 + i64 1, label %label9951 + i64 2, label %label9952 + i64 3, label %label9953 + i64 4, label %label9954 + i64 5, label %label9955 + i64 6, label %label9956 + i64 7, label %label9957 + i64 8, label %label9958 + i64 9, label %label9959 + ] + +label9950: + %waka = phi i32 [11000, %0], [10, %label9951], [11, %label9952], [12, %label9953], [13, %label9954], [14, %label9955], [15, %label9956], [16, %label9957], [17, %label9958], [18, %label9959] + %a333b = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([18 x i8]* @.str, i32 0, i32 0), i32 %waka) + br label %label999 + +label9951: + br label %label9950 +label9952: + br label %label9950 +label9953: + br label %label9950 +label9954: + br label %label9950 +label9955: + br label %label9950 +label9956: + br label %label9950 +label9957: + br label %label9950 +label9958: + br label %label9950 +label9959: + br label %label9950 + +label999: ; preds = %555 + %last = phi i32 [1, %0], [2, %label9950] + %a333c = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([18 x i8]* @.str, i32 0, i32 0), i32 %last) + ret i32 0 +} + diff --git a/tests/cases/switch64b_ta2.txt b/tests/cases/switch64b_ta2.txt new file mode 100644 index 00000000..917d42e5 --- /dev/null +++ b/tests/cases/switch64b_ta2.txt @@ -0,0 +1,3 @@ +hello, world: 5 +hello, world: 14 +hello, world: 2 diff --git a/tests/test_core.py b/tests/test_core.py index 2157eeb0..799e47f0 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -1186,7 +1186,6 @@ class T(RunnerCore): # Short name, to make it more fun to use manually on the co def test_exceptions(self): if Settings.QUANTUM_SIZE == 1: return self.skip("we don't support libcxx in q1") if self.emcc_args is None: return self.skip('need emcc to add in libcxx properly') - if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('todo in fastcomp') Settings.EXCEPTION_DEBUG = 1 @@ -1275,7 +1274,6 @@ class T(RunnerCore): # Short name, to make it more fun to use manually on the co def test_exception_2(self): if self.emcc_args is None: return self.skip('need emcc to add in libcxx properly') - if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('todo in fastcomp') Settings.DISABLE_EXCEPTION_CATCHING = 0 test_path = path_from_root('tests', 'core', 'test_exception_2') @@ -1300,7 +1298,6 @@ class T(RunnerCore): # Short name, to make it more fun to use manually on the co def test_uncaught_exception(self): if self.emcc_args is None: return self.skip('no libcxx inclusion without emcc') - if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('todo in fastcomp') Settings.DISABLE_EXCEPTION_CATCHING = 0 @@ -1339,8 +1336,6 @@ class T(RunnerCore): # Short name, to make it more fun to use manually on the co self.do_run(src, 'success') def test_typed_exceptions(self): - if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('todo in fastcomp') - Settings.DISABLE_EXCEPTION_CATCHING = 0 Settings.SAFE_HEAP = 0 # Throwing null will cause an ignorable null pointer access. src = open(path_from_root('tests', 'exceptions', 'typed.cpp'), 'r').read() @@ -1359,7 +1354,6 @@ class T(RunnerCore): # Short name, to make it more fun to use manually on the co def test_std_exception(self): if self.emcc_args is None: return self.skip('requires emcc') - if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('todo in fastcomp') Settings.DISABLE_EXCEPTION_CATCHING = 0 self.emcc_args += ['-s', 'SAFE_HEAP=0'] @@ -1369,8 +1363,6 @@ class T(RunnerCore): # Short name, to make it more fun to use manually on the co self.do_run_from_file(src, output) def test_async_exit(self): - if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('todo in fastcomp') - open('main.c', 'w').write(r''' #include <stdio.h> #include <stdlib.h> @@ -5035,7 +5027,7 @@ def process(filename): '2xi40', # pnacl limitations in ExpandGetElementPtr 'legalizer_ta2', '514_ta2', # pnacl limitation in not legalizing i104, i96, etc. 'longjmp_tiny', 'longjmp_tiny_invoke', 'longjmp_tiny_phi', 'longjmp_tiny_phi2', 'longjmp_tiny_invoke_phi', 'indirectbrphi', 'ptrtoint_blockaddr', 'quoted', # current fastcomp limitations FIXME - 'sillyfuncast', 'sillyfuncast2', 'sillybitcast', 'atomicrmw_unaligned' # TODO XXX + 'sillyfuncast2', 'sillybitcast', 'atomicrmw_unaligned' # TODO XXX ]: continue if '_ta2' in shortname and not Settings.USE_TYPED_ARRAYS == 2: print self.skip('case "%s" only relevant for ta2' % shortname) diff --git a/tools/nativize_llvm.py b/tools/nativize_llvm.py index 413c8d14..b327bdfc 100755 --- a/tools/nativize_llvm.py +++ b/tools/nativize_llvm.py @@ -23,7 +23,7 @@ libs = sys.argv[2:] # e.g.: dl for dlopen/dlclose, util for openpty/forkpty print 'bc => clean bc' Popen([LLVM_OPT, filename, '-strip-debug', '-o', filename + '.clean.bc']).communicate()[0] print 'bc => s' -for params in [[], ['-march=x86-64']]: # try x86, then x86-64 FIXME +for params in [['-march=x86'], ['-march=x86-64']]: # try x86, then x86-64 FIXME print 'params', params Popen([LLVM_COMPILER] + params + [filename + '.clean.bc', '-o', filename + '.s']).communicate()[0] print 's => o' |