diff options
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | AUTHORS | 2 | ||||
-rwxr-xr-x | em++ | 2 | ||||
-rw-r--r-- | src/library.js | 7 | ||||
-rw-r--r-- | src/library_browser.js | 2 | ||||
-rw-r--r-- | src/library_gl.js | 49 | ||||
-rw-r--r-- | src/library_glut.js | 9 | ||||
-rw-r--r-- | src/library_openal.js | 8 | ||||
-rwxr-xr-x | third_party/lzma.js/doit.sh | 11 | ||||
-rw-r--r-- | tools/eliminator/asm-eliminator-test-output.js | 7 | ||||
-rw-r--r-- | tools/eliminator/asm-eliminator-test.js | 10 | ||||
-rw-r--r-- | tools/js-optimizer.js | 4 |
12 files changed, 85 insertions, 29 deletions
@@ -6,7 +6,7 @@ src/relooper*.js node_modules/ -# Ignore generated files +# Ignore generated files src/relooper.js src/relooper.js.raw.js src/relooper/*.o @@ -18,3 +18,4 @@ tests/freetype/objs/*.lo third_party/lzma.js/lzip/*.o third_party/lzma.js/lzma-native +third_party/lzma.js/lzma-native.exe @@ -106,4 +106,4 @@ a license to everyone to use it as detailed in LICENSE.) * Fraser Adams <fraser.adams@blueyonder.co.uk> * Michael Tirado <icetooth333@gmail.com> * Ben Noordhuis <info@bnoordhuis.nl> - +* Bob Roberts <bobroberts177@gmail.com> @@ -8,7 +8,5 @@ import os, subprocess, sys from tools import shared os.environ['EMMAKEN_CXX'] = '1' -if not os.path.exists(shared.PYTHON): - print >> sys.stderr, 'warning: PYTHON does not seem to be defined properly in ~/.emscripten (%s)' % shared.PYTHON exit(subprocess.call([shared.PYTHON, shared.EMCC] + sys.argv[1:])) diff --git a/src/library.js b/src/library.js index 501f766c..31f531e9 100644 --- a/src/library.js +++ b/src/library.js @@ -4164,6 +4164,11 @@ LibraryManager.library = { }, // ========================================================================== + // GCC/LLVM specifics + // ========================================================================== + __builtin_prefetch: function(){}, + + // ========================================================================== // LLVM specifics // ========================================================================== @@ -7330,6 +7335,7 @@ LibraryManager.library = { // we're generating fake IP addresses with lookup_name that we can // resolve later on with lookup_addr. // We do the aliasing in 172.29.*.*, giving us 65536 possibilities. + $DNS__deps: ['_inet_pton4_raw', '_inet_pton6_raw'], $DNS: { address_map: { id: 1, @@ -7337,7 +7343,6 @@ LibraryManager.library = { names: {} }, - lookup_name__deps: ['_inet_pton4_raw', '_inet_pton6_raw'], lookup_name: function (name) { // If the name is already a valid ipv4 / ipv6 address, don't generate a fake one. var res = __inet_pton4_raw(name); diff --git a/src/library_browser.js b/src/library_browser.js index b70dbc84..39a1c55d 100644 --- a/src/library_browser.js +++ b/src/library_browser.js @@ -359,7 +359,7 @@ mergeInto(LibraryManager.library, { canvas.requestFullScreen(); }, - requestAnimationFrame: function(func) { + requestAnimationFrame: function requestAnimationFrame(func) { if (typeof window === 'undefined') { // Provide fallback to setTimeout if window is undefined (e.g. in Node.js) setTimeout(func, 1000/60); } else { diff --git a/src/library_gl.js b/src/library_gl.js index 7074f844..ecb72f0f 100644 --- a/src/library_gl.js +++ b/src/library_gl.js @@ -11,6 +11,7 @@ var LibraryGL = { #endif counter: 1, // 0 is reserved as 'null' in gl + lastError: 0, buffers: [], programs: [], framebuffers: [], @@ -51,6 +52,13 @@ var LibraryGL = { Browser.moduleContextCreatedCallbacks.push(GL.initExtensions); }, + // Records a GL error condition that occurred, stored until user calls glGetError() to fetch it. As per GLES2 spec, only the first error + // is remembered, and subsequent errors are discarded until the user has cleared the stored error by a call to glGetError(). + recordError: function recordError(errorCode) { + if (!GL.lastError) { + GL.lastError = errorCode; + } + }, // Get a new ID for a texture/buffer/etc., while keeping the table dense and fast. Creation is farely rare so it is worth optimizing lookups later. getNewId: function(table) { var ret = GL.counter++; @@ -277,7 +285,7 @@ var LibraryGL = { }, #if FULL_ES2 - calcBufLength: function(size, type, stride, count) { + calcBufLength: function calcBufLength(size, type, stride, count) { if (stride > 0) { return count * stride; // XXXvlad this is not exactly correct I don't think } @@ -287,7 +295,7 @@ var LibraryGL = { usedTempBuffers: [], - preDrawHandleClientVertexAttribBindings: function(count) { + preDrawHandleClientVertexAttribBindings: function preDrawHandleClientVertexAttribBindings(count) { GL.resetBufferBinding = false; var used = GL.usedTempBuffers; @@ -321,7 +329,7 @@ var LibraryGL = { } }, - postDrawHandleClientVertexAttribBindings: function() { + postDrawHandleClientVertexAttribBindings: function postDrawHandleClientVertexAttribBindings() { if (GL.resetBufferBinding) { Module.ctx.bindBuffer(Module.ctx.ARRAY_BUFFER, GL.buffers[GL.currArrayBuffer]); } @@ -2123,9 +2131,6 @@ var LibraryGL = { glGetShaderPrecisionFormat__sig: 'v', glGetShaderPrecisionFormat: function() { throw 'glGetShaderPrecisionFormat: TODO' }, - glShaderBinary__sig: 'v', - glShaderBinary: function() { throw 'glShaderBinary: TODO' }, - glDeleteObject__sig: 'vi', glDeleteObject: function(id) { if (GL.programs[id]) { @@ -2137,11 +2142,6 @@ var LibraryGL = { } }, - glReleaseShaderCompiler__sig: 'v', - glReleaseShaderCompiler: function() { - // NOP (as allowed by GLES 2.0 spec) - }, - glGetObjectParameteriv__sig: 'viii', glGetObjectParameteriv: function(id, type, result) { if (GL.programs[id]) { @@ -4618,6 +4618,30 @@ var LibraryGL = { #endif }, + glShaderBinary__sig: 'v', + glShaderBinary: function() { + GL.recordError(0x0500/*GL_INVALID_ENUM*/); +#if GL_ASSERTIONS + Module.printErr("GL_INVALID_ENUM in glShaderBinary: WebGL does not support binary shader formats! Calls to glShaderBinary always fail."); +#endif + }, + + glReleaseShaderCompiler__sig: 'v', + glReleaseShaderCompiler: function() { + // NOP (as allowed by GLES 2.0 spec) + }, + + glGetError__sig: 'i', + glGetError: function() { + // First return any GL error generated by the emscripten library_gl.js interop layer. + if (GL.lastError) { + var error = GL.lastError; + GL.lastError = 0/*GL_NO_ERROR*/; + return error; + } else { // If there were none, return the GL error from the browser GL context. + return Module.ctx.getError(); + } + }, // signatures of simple pass-through functions, see later glActiveTexture__sig: 'vi', @@ -4651,14 +4675,13 @@ var LibraryGL = { glFlush__sig: 'v', glClearColor__sig: 'viiii', glIsEnabled__sig: 'ii', - glGetError__sig: 'i', glFrontFace__sig: 'vi', glSampleCoverage__sig: 'vi', }; // Simple pass-through functions. Starred ones have return values. [X] ones have X in the C name but not in the JS name -[[0, 'getError* finish flush'], +[[0, 'finish flush'], [1, 'clearDepth clearDepth[f] depthFunc enable disable frontFace cullFace clear lineWidth clearStencil depthMask stencilMask checkFramebufferStatus* generateMipmap activeTexture blendEquation sampleCoverage isEnabled*'], [2, 'blendFunc blendEquationSeparate depthRange depthRange[f] stencilMaskSeparate hint polygonOffset vertexAttrib1f'], [3, 'texParameteri texParameterf vertexAttrib2f stencilFunc stencilOp'], diff --git a/src/library_glut.js b/src/library_glut.js index 5e303fd2..ba4d75ab 100644 --- a/src/library_glut.js +++ b/src/library_glut.js @@ -59,6 +59,9 @@ var LibraryGLUT = { getSpecialKey: function(keycode) { var key = null; switch (keycode) { + case 8: key = 120 /* backspace */; break; + case 46: key = 111 /* delete */; break; + case 0x70 /*DOM_VK_F1*/: key = 1 /* GLUT_KEY_F1 */; break; case 0x71 /*DOM_VK_F2*/: key = 2 /* GLUT_KEY_F2 */; break; case 0x72 /*DOM_VK_F3*/: key = 3 /* GLUT_KEY_F3 */; break; @@ -228,14 +231,14 @@ var LibraryGLUT = { if (delta < 0) { button = 4; // wheel down } - + if (GLUT.mouseFunc) { event.preventDefault(); GLUT.saveModifiers(event); Runtime.dynCall('viiii', GLUT.mouseFunc, [button, 0/*GLUT_DOWN*/, Browser.mouseX, Browser.mouseY]); } }, - + // TODO add fullscreen API ala: // http://johndyer.name/native-fullscreen-javascript-api-plus-jquery-plugin/ onFullScreenEventChange: function(event) { @@ -304,7 +307,7 @@ var LibraryGLUT = { // Firefox window.addEventListener("DOMMouseScroll", GLUT.onMouseWheel, true); } - + Browser.resizeListeners.push(function(width, height) { if (GLUT.reshapeFunc) { Runtime.dynCall('vii', GLUT.reshapeFunc, [width, height]); diff --git a/src/library_openal.js b/src/library_openal.js index e8a2e223..eb152f62 100644 --- a/src/library_openal.js +++ b/src/library_openal.js @@ -8,13 +8,13 @@ var LibraryOpenAL = { QUEUE_INTERVAL: 25, QUEUE_LOOKAHEAD: 100, - updateSources: function(context) { + updateSources: function updateSources(context) { for (var i = 0; i < context.src.length; i++) { AL.updateSource(context.src[i]); } }, - updateSource: function(src) { + updateSource: function updateSource(src) { #if OPENAL_DEBUG var idx = AL.currentContext.src.indexOf(src); #endif @@ -65,7 +65,7 @@ var LibraryOpenAL = { } }, - setSourceState: function(src, state) { + setSourceState: function setSourceState(src, state) { #if OPENAL_DEBUG var idx = AL.currentContext.src.indexOf(src); #endif @@ -119,7 +119,7 @@ var LibraryOpenAL = { } }, - stopSourceQueue: function(src) { + stopSourceQueue: function stopSourceQueue(src) { for (var i = 0; i < src.queue.length; i++) { var entry = src.queue[i]; if (entry.src) { diff --git a/third_party/lzma.js/doit.sh b/third_party/lzma.js/doit.sh index 1f530651..6046022c 100755 --- a/third_party/lzma.js/doit.sh +++ b/third_party/lzma.js/doit.sh @@ -5,7 +5,14 @@ export CXX=`../../../em-config LLVM_ROOT`/clang++ echo "native" make clean DECODER_ONLY=0 make lzip -j 4 # native build -mv lzip ../lzma-native +case `uname` in + *_NT*) + mv lzip.exe ../lzma-native.exe + ;; + *) + mv lzip ../lzma-native + ;; +esac exit # just build natively, that's it @@ -18,7 +25,7 @@ echo "bitcode decoder only" make clean DECODER_ONLY=1 ../../../emmake make lzip -j 4 mv lzip lzip-decoder.bc - + cd .. echo "javascript full" diff --git a/tools/eliminator/asm-eliminator-test-output.js b/tools/eliminator/asm-eliminator-test-output.js index dda82047..434fbaf9 100644 --- a/tools/eliminator/asm-eliminator-test-output.js +++ b/tools/eliminator/asm-eliminator-test-output.js @@ -291,4 +291,11 @@ function watIf() { if ($cmp38) {} else {} } } +function select2($foundBase_0_off0) { + $foundBase_0_off0 = $foundBase_0_off0 | 0; + var $call24 = 0; + $call24 = MUST_RUN() | 0; + STACKTOP = sp; + return ($foundBase_0_off0 ? 0 : $call24) | 0; +} diff --git a/tools/eliminator/asm-eliminator-test.js b/tools/eliminator/asm-eliminator-test.js index 6f426150..7ec277d5 100644 --- a/tools/eliminator/asm-eliminator-test.js +++ b/tools/eliminator/asm-eliminator-test.js @@ -362,5 +362,13 @@ function watIf() { } } } -// EMSCRIPTEN_GENERATED_FUNCTIONS: ["asm", "__Z11printResultPiS_j", "_segment_holding", "__ZN5identC2EiPKcPci", "_vec2Length", "exc", "label", "confuusion", "tempDouble", "_org_apache_harmony_luni_util_NumberConverter_freeFormat__", "__ZN23b2EdgeAndPolygonContact8EvaluateEP10b2ManifoldRK11b2TransformS4_", "_java_nio_charset_Charset_forNameInternal___java_lang_String", "looop2", "looop3", "looop4", "looop5", "looop6", "looop7", "looop8", "multiloop", "multiloop2", "tempDouble2", "watIf"] +function select2($foundBase_0_off0) { + $foundBase_0_off0 = $foundBase_0_off0 | 0; + var $call24 = 0, $retval_0 = 0; + $call24 = MUST_RUN() | 0; + $retval_0 = $foundBase_0_off0 ? 0 : $call24; + STACKTOP = sp; + return $retval_0 | 0; +} +// EMSCRIPTEN_GENERATED_FUNCTIONS: ["asm", "__Z11printResultPiS_j", "_segment_holding", "__ZN5identC2EiPKcPci", "_vec2Length", "exc", "label", "confuusion", "tempDouble", "_org_apache_harmony_luni_util_NumberConverter_freeFormat__", "__ZN23b2EdgeAndPolygonContact8EvaluateEP10b2ManifoldRK11b2TransformS4_", "_java_nio_charset_Charset_forNameInternal___java_lang_String", "looop2", "looop3", "looop4", "looop5", "looop6", "looop7", "looop8", "multiloop", "multiloop2", "tempDouble2", "watIf", "select2"] diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js index 022bdf47..36244298 100644 --- a/tools/js-optimizer.js +++ b/tools/js-optimizer.js @@ -2485,6 +2485,10 @@ function eliminate(ast, memSafe) { } else if (type === 'return') { if (node[1]) traverseInOrder(node[1]); } else if (type === 'conditional') { + if (!callsInvalidated) { // invalidate calls, since we cannot eliminate them into a branch of an LLVM select/JS conditional that does not execute + invalidateCalls(); + callsInvalidated = true; + } traverseInOrder(node[1]); traverseInOrder(node[2]); traverseInOrder(node[3]); |