diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/analyzer.js | 3 | ||||
-rw-r--r-- | src/compiler.js | 2 | ||||
-rw-r--r-- | src/jsifier.js | 17 | ||||
-rw-r--r-- | src/library.js | 12 | ||||
-rw-r--r-- | src/library_browser.js | 2 | ||||
-rw-r--r-- | src/library_glut.js | 2 | ||||
-rw-r--r-- | src/library_openal.js | 28 | ||||
-rw-r--r-- | src/parseTools.js | 2 | ||||
-rw-r--r-- | src/postamble.js | 20 | ||||
-rw-r--r-- | src/settings.js | 6 | ||||
-rw-r--r-- | src/utility.js | 7 |
11 files changed, 53 insertions, 48 deletions
diff --git a/src/analyzer.js b/src/analyzer.js index 92b7d8cf..b1991c3f 100644 --- a/src/analyzer.js +++ b/src/analyzer.js @@ -979,6 +979,9 @@ function analyzer(data, sidePass) { if (variable.origin === 'alloca') { variable.allocatedNum = item.allocatedNum; } + if (variable.origin === 'call') { + variable.type = getReturnType(variable.type); + } } }); diff --git a/src/compiler.js b/src/compiler.js index bb72c7dd..7cf43f09 100644 --- a/src/compiler.js +++ b/src/compiler.js @@ -178,7 +178,7 @@ assert(!(USE_TYPED_ARRAYS === 2 && QUANTUM_SIZE !== 4), 'For USE_TYPED_ARRAYS == if (ASM_JS) { assert(!ALLOW_MEMORY_GROWTH, 'Cannot grow asm.js heap'); assert((TOTAL_MEMORY&(TOTAL_MEMORY-1)) == 0, 'asm.js heap must be power of 2'); - assert(DISABLE_EXCEPTION_CATCHING == 1, 'asm.js does not support C++ exceptions yet'); + assert(DISABLE_EXCEPTION_CATCHING == 1, 'asm.js does not support C++ exceptions yet, you must compile with -s DISABLE_EXCEPTION_CATCHING=1'); } assert(!(!NAMED_GLOBALS && BUILD_AS_SHARED_LIB)); // shared libraries must have named globals diff --git a/src/jsifier.js b/src/jsifier.js index 7db2ee70..c55072b4 100644 --- a/src/jsifier.js +++ b/src/jsifier.js @@ -495,10 +495,10 @@ function JSify(data, functionsOnly, givenFunctions) { EXPORTED_FUNCTIONS[ident] = 1; delete Functions.libraryFunctions[ident.substr(1)]; } - } else { - if (EXPORT_ALL || (ident in EXPORTED_FUNCTIONS)) { - contentText += '\nModule["' + ident + '"] = ' + ident + ';'; - } + } + if ((!ASM_JS || phase == 'pre') && + (EXPORT_ALL || (ident in EXPORTED_FUNCTIONS))) { + contentText += '\nModule["' + ident + '"] = ' + ident + ';'; } return depsText + contentText; } @@ -515,7 +515,7 @@ function JSify(data, functionsOnly, givenFunctions) { if (!(item.ident in DEAD_FUNCTIONS) && !UNRESOLVED_AS_DEAD) { item.JS = 'var ' + item.ident + '; // stub for ' + item.ident; if (ASM_JS) { - throw 'Unresolved symbol: ' + item.ident + ', this must be corrected for asm.js validation to succeed. Consider adding it to DEAD_FUNCTIONS.'; + error('Unresolved symbol: ' + item.ident + ', this must be corrected for asm.js validation to succeed. Consider adding it to DEAD_FUNCTIONS.'); } else if (WARN_ON_UNDEFINED_SYMBOLS) { warn('Unresolved symbol: ' + item.ident); } @@ -1167,6 +1167,11 @@ function JSify(data, functionsOnly, givenFunctions) { return ret + ';'; }); makeFuncLineActor('resume', function(item) { + if (item.ident == 0) { + // No exception to resume, so we can just bail. + // This is related to issue #917 and http://llvm.org/PR15518 + return (EXCEPTION_DEBUG ? 'Module.print("no exception to resume")' : '') + ';'; + } // If there is no current exception, set this one as it (during a resume, the current exception can be wiped out) var ptr = makeStructuralAccess(item.ident, 0); return (EXCEPTION_DEBUG ? 'Module.print("Resuming exception");' : '') + @@ -1566,6 +1571,8 @@ function JSify(data, functionsOnly, givenFunctions) { } } + if (abortExecution) throw 'Aborting compilation due to previous warnings'; + if (phase == 'pre' || phase == 'funcs') { PassManager.serialize(); return; diff --git a/src/library.js b/src/library.js index aebad63b..f8ea67ba 100644 --- a/src/library.js +++ b/src/library.js @@ -2061,24 +2061,19 @@ LibraryManager.library = { // void _exit(int status); // http://pubs.opengroup.org/onlinepubs/000095399/functions/exit.html -#if CATCH_EXIT_CODE function ExitStatus() { this.name = "ExitStatus"; this.message = "Program terminated with exit(" + status + ")"; this.status = status; + Module.print('Exit Status: ' + status); }; ExitStatus.prototype = new Error(); ExitStatus.prototype.constructor = ExitStatus; -#endif exitRuntime(); ABORT = true; -#if CATCH_EXIT_CODE throw new ExitStatus(); -#else - throw 'exit(' + status + ') called, at ' + new Error().stack; -#endif }, fork__deps: ['__setErrNo', '$ERRNO_CODES'], fork: function() { @@ -3717,6 +3712,11 @@ LibraryManager.library = { __exit(status); }, + _ZSt9terminatev__deps: ['exit'], + _ZSt9terminatev: function() { + _exit(-1234); + }, + atexit: function(func, arg) { __ATEXIT__.unshift({ func: func, arg: arg }); }, diff --git a/src/library_browser.js b/src/library_browser.js index e61f84b5..b1e4190b 100644 --- a/src/library_browser.js +++ b/src/library_browser.js @@ -637,7 +637,7 @@ mergeInto(LibraryManager.library, { Browser.mainLoop.scheduler(); if (simulateInfiniteLoop) { - throw 'emscripten_set_main_loop simulating infinite loop by throwing so we get right into the JS event loop'; + throw 'SimulateInfiniteLoop'; } }, diff --git a/src/library_glut.js b/src/library_glut.js index bb4dfefa..49380367 100644 --- a/src/library_glut.js +++ b/src/library_glut.js @@ -433,7 +433,7 @@ var LibraryGLUT = { glutMainLoop: function() { _glutReshapeWindow(Module['canvas'].width, Module['canvas'].height); _glutPostRedisplay(); - throw 'GLUT mainloop called, simulating infinite loop by throwing so we get right into the JS event loop'; + throw 'SimulateInfiniteLoop'; }, }; diff --git a/src/library_openal.js b/src/library_openal.js index 719d8cf8..df1d15db 100644 --- a/src/library_openal.js +++ b/src/library_openal.js @@ -57,7 +57,6 @@ var LibraryOpenAL = { } if (ctx) { - ctx.listener.panningModel = "equalpower"; AL.contexts.push({ctx: ctx, err: 0, src: [], buf: []}); return AL.contexts.length; } else { @@ -73,6 +72,12 @@ var LibraryOpenAL = { } }, + alcGetError__deps: ['alGetError'], + alcGetError: function(device) { + // We have only one audio device, so just return alGetError. + return _alGetError(); + }, + alDeleteSources: function(count, sources) { if (!AL.currentContext) { @@ -97,14 +102,9 @@ var LibraryOpenAL = { for (var i = 0; i < count; ++i) { var gain = AL.currentContext.ctx.createGain(); var panner = AL.currentContext.ctx.createPanner(); - if (typeof(webkitAudioContext) == 'function') { - gain.connect(panner); - panner.connect(AL.currentContext.ctx.destination); - } else { - // Work around a Firefox bug (bug 849916) - gain.connect(AL.currentContext.ctx.destination); - } - gain.gain.value = 1; // work around a Firefox bug (bug 850970) + panner.panningModel = "equalpower"; + gain.connect(panner); + panner.connect(AL.currentContext.ctx.destination); AL.currentContext.src.push({ loop: false, buffer: null, @@ -404,8 +404,7 @@ var LibraryOpenAL = { src.buffer = AL.currentContext.src[source - 1].buffer; src.connect(AL.currentContext.src[source - 1].gain); src.start(0, offset); - // Work around Firefox bug 851338 - AL.currentContext.src[source - 1].playTime = AL.currentContext.ctx.currentTime || 0; + AL.currentContext.src[source - 1].playTime = AL.currentContext.ctx.currentTime; AL.currentContext.src[source - 1].paused = false; AL.currentContext.src[source - 1]['src'] = src; }, @@ -445,8 +444,7 @@ var LibraryOpenAL = { if ("src" in AL.currentContext.src[source - 1] && !AL.currentContext.src[source - 1].paused) { AL.currentContext.src[source - 1].paused = true; - // Work around Firefox bug 851338 - AL.currentContext.src[source - 1].pausedTime = AL.currentContext.ctx.currentTime || 0; + AL.currentContext.src[source - 1].pausedTime = AL.currentContext.ctx.currentTime; AL.currentContext.src[source - 1]["src"].stop(0); delete AL.currentContext.src[source - 1].src; } @@ -572,10 +570,6 @@ var LibraryOpenAL = { alcGetProcAddress: function(device, fname) { return 0; }, - - alcGetError: function(device) { - return 0; - }, }; autoAddDeps(LibraryOpenAL, '$AL'); diff --git a/src/parseTools.js b/src/parseTools.js index 9fddacbb..d0d3e89f 100644 --- a/src/parseTools.js +++ b/src/parseTools.js @@ -999,7 +999,7 @@ function getHeapOffset(offset, type, forceAsm) { offset = '(' + offset + ')'; if (shifts != 0) { if (CHECK_HEAP_ALIGN) { - return '(CHECK_ALIGN_' + sz + '(' + offset + ')>>' + shifts + ')'; + return '(CHECK_ALIGN_' + sz + '(' + offset + '|0)>>' + shifts + ')'; } else { return '(' + offset + '>>' + shifts + ')'; } diff --git a/src/postamble.js b/src/postamble.js index 00205abc..dd4f4f37 100644 --- a/src/postamble.js +++ b/src/postamble.js @@ -23,18 +23,21 @@ Module.callMain = function callMain(args) { var ret; -#if CATCH_EXIT_CODE var initialStackTop = STACKTOP; try { ret = Module['_main'](argc, argv, 0); } - catch(e) { if (e.name == "ExitStatus") return e.status; throw e; } - finally { + catch(e) { + if (e.name == 'ExitStatus') { + return e.status; + } else if (e == 'SimulateInfiniteLoop') { + Module['noExitRuntime'] = true; + } else { + throw e; + } + } finally { STACKTOP = initialStackTop; } -#else - ret = Module['_main'](argc, argv, 0); -#endif #if BENCHMARK Module.realPrint('main() took ' + (Date.now() - start) + ' milliseconds'); @@ -121,10 +124,7 @@ if (Module['noInitialRun']) { } if (shouldRunNow) { - var ret = run(); -#if CATCH_EXIT_CODE - Module.print('Exit Status: ' + ret); -#endif + run(); } // {{POST_RUN_ADDITIONS}} diff --git a/src/settings.js b/src/settings.js index 97963ac5..9ed87bd6 100644 --- a/src/settings.js +++ b/src/settings.js @@ -113,12 +113,6 @@ var INLINING_LIMIT = 0; // A limit on inlining. If 0, we will inline normally i // we will prevent inlining of functions of this size or larger // in closure. 50 is a reasonable setting if you do not want // inlining -var CATCH_EXIT_CODE = 0; // If set, causes exit() to throw an exception object which is caught - // in a try..catch block and results in the exit status being - // returned from run(). If zero (the default), the program is just - // terminated with an error message, that is, the exception thrown - // by exit() is not handled in any way (in particular, the stack - // position will not be reset). // Generated code debugging options var SAFE_HEAP = 0; // Check each write to the heap, for example, this will give a clear diff --git a/src/utility.js b/src/utility.js index 19444675..b67e6c21 100644 --- a/src/utility.js +++ b/src/utility.js @@ -85,6 +85,13 @@ function warnOnce(a, msg) { } } +var abortExecution = false; + +function error(msg) { + abortExecution = true; + printErr('Error: ' + msg); +} + function dedup(items, ident) { var seen = {}; if (ident) { |