From 8e58bcdaad3a8819a875332c9d24b0b052c1c7cd Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Thu, 15 Jan 2015 18:39:06 -0800 Subject: [PATCH 1/4] add an option to the test runner to execute N random tests --- tests/runner.py | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/tests/runner.py b/tests/runner.py index a4ddf91f7b127..08725500a4fcc 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -16,7 +16,7 @@ ''' from subprocess import Popen, PIPE, STDOUT -import os, unittest, tempfile, shutil, time, inspect, sys, math, glob, re, difflib, webbrowser, hashlib, threading, platform, BaseHTTPServer, SimpleHTTPServer, multiprocessing, functools, stat, string +import os, unittest, tempfile, shutil, time, inspect, sys, math, glob, re, difflib, webbrowser, hashlib, threading, platform, BaseHTTPServer, SimpleHTTPServer, multiprocessing, functools, stat, string, random # Setup @@ -874,6 +874,30 @@ def get_bullet_library(runner_core, use_cmake): ''' time.sleep(2) + # If we asked to run random tests, do that + first = sys.argv[1] + if first.startswith('random'): + num = 1 + first = first[6:] + if len(first) > 0: + num = int(first) + for m in modules: + if hasattr(m, 'default'): + sys.argv = [sys.argv[0]] + print + for i in range(num): + tests = filter(lambda t: t.startswith('test_'), dir(getattr(m, 'default'))) + test = random.choice(tests) + mode = random.choice(test_modes) + print '* ' + mode + '.' + test + sys.argv.append(mode + '.' + test) + + std = 0.5/math.sqrt(num) + + print + print 'running those %d randomly-selected tests. if they all pass, then there is a greater than 95%% chance that at least %.2f%% of the test suite will pass ' % (num, 100.0-100.0*std) + print + # Filter and load tests from the discovered modules loader = unittest.TestLoader() names = sys.argv[1:] From b8281225915fe5da3a3d093f8e101c58f3029915 Mon Sep 17 00:00:00 2001 From: Pepijn Van Eeckhoudt Date: Fri, 16 Jan 2015 13:53:22 +0100 Subject: [PATCH 2/4] Correct GL enableExtensionsByDefault check --- AUTHORS | 1 + src/library_gl.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/AUTHORS b/AUTHORS index 69f84c6ca8588..3921355376656 100644 --- a/AUTHORS +++ b/AUTHORS @@ -171,4 +171,5 @@ a license to everyone to use it as detailed in LICENSE.) * Petr Babicka * Akira Takahashi * Victor Costan +* Pepijn Van Eeckhoudt (copyright owned by Luciad NV) diff --git a/src/library_gl.js b/src/library_gl.js index 99e7c85cd33c7..63926d37c16cd 100644 --- a/src/library_gl.js +++ b/src/library_gl.js @@ -762,7 +762,7 @@ var LibraryGL = { // Store the created context object so that we can access the context given a canvas without having to pass the parameters again. if (ctx.canvas) ctx.canvas.GLctxObject = context; GL.contexts[handle] = context; - if (typeof webGLContextAttributes['webGLContextAttributes'] === 'undefined' || webGLContextAttributes.enableExtensionsByDefault) { + if (typeof webGLContextAttributes['enableExtensionsByDefault'] === 'undefined' || webGLContextAttributes.enableExtensionsByDefault) { GL.initExtensions(context); } return handle; From 5d66b59df4c2365d55932784e1472974537007f3 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Fri, 16 Jan 2015 11:31:59 -0800 Subject: [PATCH 3/4] handle dangerous sub-ifs aside from the final child, when deciding which if braces can be removed --- tests/optimizer/asmLastOpts-output.js | 13 +++++++++++++ tests/optimizer/asmLastOpts.js | 25 +++++++++++++++++++++++++ tools/optimizer/simple_ast.h | 11 ++++------- 3 files changed, 42 insertions(+), 7 deletions(-) diff --git a/tests/optimizer/asmLastOpts-output.js b/tests/optimizer/asmLastOpts-output.js index 4bf7595e3df09..11f2ccd140805 100644 --- a/tests/optimizer/asmLastOpts-output.js +++ b/tests/optimizer/asmLastOpts-output.js @@ -6,5 +6,18 @@ function test() { if (HEAP32[i5 >> 2] | 0) { if ((_fread(i4 | 0, 1, 257, HEAP32[i5 >> 2] | 0) | 0) != 257) if ((HEAPU8[i4 >> 0] | 0 | 0) != (HEAP32[84328] | 0)) if (_memcmp(i4 + 1 | 0, HEAP32[i20 >> 2] | 0, 256) | 0) if ((_fread(HEAP32[i16 >> 2] | 0, 256, 256, HEAP32[i5 >> 2] | 0) | 0) != 256) i31 = 9; } else i31 = 9; + moar(); + if ((c[21902] | 0) != 0 & (Vb | 0) == 29) { + if ((Ib | 0) == 60) if (!(cq(39080, 448, c[F >> 2] | 0, c[M >> 2] | 0, 0, 0) | 0)) x = 373; else { + Mb = 52; + Nb = 0; + Ob = 0; + return; + } + } else x = 373; + yet(); + if (a) if (b) { + if (c) d(); + } else e(); else f(); } diff --git a/tests/optimizer/asmLastOpts.js b/tests/optimizer/asmLastOpts.js index 7b05a264a6535..f08575aca0bba 100644 --- a/tests/optimizer/asmLastOpts.js +++ b/tests/optimizer/asmLastOpts.js @@ -32,6 +32,31 @@ function test() { } else { i31 = 9; } + moar(); + if ((c[21902] | 0) != 0 & (Vb | 0) == 29) { + if ((Ib | 0) == 60) { + if (!(cq(39080, 448, c[F >> 2] | 0, c[M >> 2] | 0, 0, 0) | 0)) { + x = 373; + } else { + Mb = 52; + Nb = 0; + Ob = 0; + return; + } + } + } else x = 373; + yet(); + if (a) { + if (b) { + if (c) { + d(); + } + } else { + e(); + } + } else { + f(); + } } // EMSCRIPTEN_GENERATED_FUNCTIONS: ["test"] diff --git a/tools/optimizer/simple_ast.h b/tools/optimizer/simple_ast.h index 9650586eb7deb..63fe84f558547 100644 --- a/tools/optimizer/simple_ast.h +++ b/tools/optimizer/simple_ast.h @@ -1121,21 +1121,18 @@ struct JSPrinter { // also need to recurse for if () { if () { } else { if () } else // (note that this is only a problem if the if body has a single element in it, not a block or such, as then // the block would be braced) + // this analysis is a little conservative - it assumes any child if could be confused with us, which implies + // all other braces vanished (the worst case for us, we are not saved by other braces). bool needBraces = false; bool hasElse = ifHasElse(node); if (hasElse) { Ref child = node[2]; while (child[0] == IF) { - Ref last = ifHasElse(child) ? child[3] : child[2]; - if (last[0] == IF) { - child = last; - continue; - } - // we are at the top, the one dangerous to be confused with us if (!ifHasElse(child)) { needBraces = true; + break; } - break; + child = child[3]; // continue into the else } } if (needBraces) { From 926738ffe075bc7b78b52bacbe9ffabc0c53ccbe Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Fri, 16 Jan 2015 11:39:08 -0800 Subject: [PATCH 4/4] 1.29.3 --- emscripten-version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/emscripten-version.txt b/emscripten-version.txt index 6be5a23ede62e..fb1348a3e919f 100644 --- a/emscripten-version.txt +++ b/emscripten-version.txt @@ -1,2 +1,2 @@ -1.29.2 +1.29.3