diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/intertyper.js | 10 | ||||
-rw-r--r-- | src/jsifier.js | 14 | ||||
-rw-r--r-- | src/library.js | 96 | ||||
-rw-r--r-- | src/library_browser.js | 8 | ||||
-rw-r--r-- | src/library_fs.js | 8 | ||||
-rw-r--r-- | src/library_gc.js | 2 | ||||
-rw-r--r-- | src/library_gl.js | 44 | ||||
-rw-r--r-- | src/library_html5.js | 198 | ||||
-rw-r--r-- | src/library_memfs.js | 5 | ||||
-rw-r--r-- | src/library_openal.js | 4 | ||||
-rw-r--r-- | src/library_sockfs.js | 2 | ||||
-rw-r--r-- | src/parseTools.js | 6 | ||||
-rw-r--r-- | src/postamble.js | 12 | ||||
-rw-r--r-- | src/preamble.js | 254 | ||||
-rw-r--r-- | src/proxyWorker.js | 12 | ||||
-rw-r--r-- | src/relooper/Relooper.cpp | 6 | ||||
-rw-r--r-- | src/runtime.js | 4 | ||||
-rw-r--r-- | src/settings.js | 6 | ||||
-rw-r--r-- | src/shell.html | 1653 | ||||
-rw-r--r-- | src/struct_info.json | 6 |
20 files changed, 1460 insertions, 890 deletions
diff --git a/src/intertyper.js b/src/intertyper.js index 10822e48..323787ac 100644 --- a/src/intertyper.js +++ b/src/intertyper.js @@ -348,9 +348,11 @@ function intertyper(lines, sidePass, baseLineNums) { if (token1Text == 'triple') { var triple = item.tokens[3].text; triple = triple.substr(1, triple.length-2); - var expected = TARGET_LE32 ? 'le32-unknown-nacl' : 'i386-pc-linux-gnu'; + var expected = TARGET_ASMJS_UNKNOWN_EMSCRIPTEN ? 'asmjs-unknown-emscripten' : 'i386-pc-linux-gnu'; if (triple !== expected) { - warn('using an unexpected LLVM triple: ' + [triple, ' !== ', expected] + ' (are you using emcc for everything and not clang?)'); + if (!(TARGET_ASMJS_UNKNOWN_EMSCRIPTEN && triple === 'le32-unknown-nacl')) { + warn('using an unexpected LLVM triple: ' + [triple, ' !== ', expected] + ' (are you using emcc for everything and not clang?)'); + } } } return null; @@ -688,7 +690,7 @@ function intertyper(lines, sidePass, baseLineNums) { Types.hasInlineJS = true; warnOnce('inline JavaScript using asm() will cause the code to no longer fall in the asm.js subset of JavaScript, which can reduce performance - consider using emscripten_run_script'); } - assert(TARGET_LE32, 'inline js is only supported in le32'); + assert(TARGET_ASMJS_UNKNOWN_EMSCRIPTEN, 'inline js is only supported in asmjs-unknown-emscripten'); // Inline assembly is just JavaScript that we paste into the code item.intertype = 'value'; if (tokensLeft[0].text == 'sideeffect') tokensLeft.splice(0, 1); @@ -848,7 +850,7 @@ function intertyper(lines, sidePass, baseLineNums) { }).filter(function(param) { return param.value && param.value.ident != 'undef' }); return item; } - // 'phi' + // 'va_arg' function va_argHandler(item) { item.intertype = 'va_arg'; var segments = splitTokenList(item.tokens.slice(1)); diff --git a/src/jsifier.js b/src/jsifier.js index c1ca893b..503f0b71 100644 --- a/src/jsifier.js +++ b/src/jsifier.js @@ -384,7 +384,7 @@ function JSify(data, functionsOnly) { functionStubSigs[item.ident] = Functions.getSignature(item.returnType.text, item.params.map(function(arg) { return arg.type }), false); } - function addFromLibrary(ident) { + function addFromLibrary(ident, notDep) { if (ident in addedLibraryItems) return ''; addedLibraryItems[ident] = true; @@ -396,8 +396,10 @@ function JSify(data, functionsOnly) { if (('_' + ident) in Functions.implementedFunctions) return ''; if (!LibraryManager.library.hasOwnProperty(ident) && !LibraryManager.library.hasOwnProperty(ident + '__inline')) { - if (ERROR_ON_UNDEFINED_SYMBOLS) error('unresolved symbol: ' + ident); - else if (VERBOSE || (WARN_ON_UNDEFINED_SYMBOLS && !LINKABLE)) warn('unresolved symbol: ' + ident); + if (notDep) { + if (ERROR_ON_UNDEFINED_SYMBOLS) error('unresolved symbol: ' + ident); + else if (VERBOSE || (WARN_ON_UNDEFINED_SYMBOLS && !LINKABLE)) warn('unresolved symbol: ' + ident); + } // emit a stub that will fail at runtime LibraryManager.library[shortident] = new Function("Module['printErr']('missing function: " + shortident + "'); abort(-1);"); } @@ -502,7 +504,7 @@ function JSify(data, functionsOnly) { delete LibraryManager.library[shortident + '__deps']; } } - item.JS = addFromLibrary(shortident); + item.JS = addFromLibrary(shortident, true); } } @@ -1413,7 +1415,7 @@ function JSify(data, functionsOnly) { } } function va_argHandler(item) { - assert(TARGET_LE32); + assert(TARGET_ASMJS_UNKNOWN_EMSCRIPTEN); var ident = item.value.ident; var move = Runtime.STACK_ALIGN; @@ -1710,7 +1712,7 @@ function JSify(data, functionsOnly) { if ((phase == 'pre' || phase == 'glue') && !Variables.generatedGlobalBase && !BUILD_AS_SHARED_LIB) { Variables.generatedGlobalBase = true; // Globals are done, here is the rest of static memory - assert((TARGET_LE32 && Runtime.GLOBAL_BASE == 8) || (TARGET_X86 && Runtime.GLOBAL_BASE == 4)); // this is assumed in e.g. relocations for linkable modules + assert((TARGET_ASMJS_UNKNOWN_EMSCRIPTEN && Runtime.GLOBAL_BASE == 8) || (TARGET_X86 && Runtime.GLOBAL_BASE == 4)); // this is assumed in e.g. relocations for linkable modules if (!SIDE_MODULE) { print('STATIC_BASE = ' + Runtime.GLOBAL_BASE + ';\n'); print('STATICTOP = STATIC_BASE + ' + Runtime.alignMemory(Variables.nextIndexedOffset) + ';\n'); diff --git a/src/library.js b/src/library.js index c1eb2219..cd451c57 100644 --- a/src/library.js +++ b/src/library.js @@ -131,7 +131,7 @@ LibraryManager.library = { stream.position++; return 0; }, - readdir__deps: ['readdir_r', '__setErrNo', '$ERRNO_CODES'], + readdir__deps: ['readdir_r', '__setErrNo', '$ERRNO_CODES', 'malloc'], readdir: function(dirp) { // struct dirent *readdir(DIR *dirp); // http://pubs.opengroup.org/onlinepubs/007908799/xsh/readdir_r.html @@ -1021,7 +1021,7 @@ LibraryManager.library = { return -1; } }, - ttyname__deps: ['ttyname_r'], + ttyname__deps: ['ttyname_r', 'malloc'], ttyname: function(fildes) { // char *ttyname(int fildes); // http://pubs.opengroup.org/onlinepubs/000095399/functions/ttyname.html @@ -1287,7 +1287,7 @@ LibraryManager.library = { return -1; } }, - getlogin__deps: ['getlogin_r'], + getlogin__deps: ['getlogin_r', 'malloc'], getlogin: function() { // char *getlogin(void); // http://pubs.opengroup.org/onlinepubs/000095399/functions/getlogin.html @@ -1861,14 +1861,14 @@ LibraryManager.library = { // int x = 4; printf("%c\n", (char)x); var ret; if (type === 'double') { -#if TARGET_LE32 == 2 +#if TARGET_ASMJS_UNKNOWN_EMSCRIPTEN == 2 ret = {{{ makeGetValue('varargs', 'argIndex', 'double', undefined, undefined, true, 4) }}}; #else ret = {{{ makeGetValue('varargs', 'argIndex', 'double', undefined, undefined, true) }}}; #endif #if USE_TYPED_ARRAYS == 2 } else if (type == 'i64') { -#if TARGET_LE32 == 1 +#if TARGET_ASMJS_UNKNOWN_EMSCRIPTEN == 1 ret = [{{{ makeGetValue('varargs', 'argIndex', 'i32', undefined, undefined, true) }}}, {{{ makeGetValue('varargs', 'argIndex+8', 'i32', undefined, undefined, true) }}}]; argIndex += {{{ STACK_ALIGN }}}; // each 32-bit chunk is in a 64-bit block @@ -1885,7 +1885,7 @@ LibraryManager.library = { type = 'i32'; // varargs are always i32, i64, or double ret = {{{ makeGetValue('varargs', 'argIndex', 'i32', undefined, undefined, true) }}}; } -#if TARGET_LE32 == 2 +#if TARGET_ASMJS_UNKNOWN_EMSCRIPTEN == 2 argIndex += Runtime.getNativeFieldSize(type); #else argIndex += Math.max(Runtime.getNativeFieldSize(type), Runtime.getAlignSize(type, null, true)); @@ -1970,7 +1970,7 @@ LibraryManager.library = { } next = {{{ makeGetValue(0, 'textIndex+1', 'i8') }}}; } - if (precision === -1) { + if (precision < 0) { precision = 6; // Standard default. precisionSet = false; } @@ -2420,7 +2420,9 @@ LibraryManager.library = { fileno: function(stream) { // int fileno(FILE *stream); // http://pubs.opengroup.org/onlinepubs/000095399/functions/fileno.html - return FS.getStreamFromPtr(stream).fd; + stream = FS.getStreamFromPtr(stream); + if (!stream) return -1; + return stream.fd; }, ftrylockfile: function() { // int ftrylockfile(FILE *file); @@ -2695,7 +2697,7 @@ LibraryManager.library = { if (buf) _setvbuf(stream, buf, 0, 8192); // _IOFBF, BUFSIZ. else _setvbuf(stream, buf, 2, 8192); // _IONBF, BUFSIZ. }, - tmpnam__deps: ['$FS'], + tmpnam__deps: ['$FS', 'malloc'], tmpnam: function(s, dir, prefix) { // char *tmpnam(char *s); // http://pubs.opengroup.org/onlinepubs/000095399/functions/tmpnam.html @@ -2792,7 +2794,7 @@ LibraryManager.library = { function unget() { index--; }; return __scanString(format, get, unget, varargs); }, - snprintf__deps: ['_formatString'], + snprintf__deps: ['_formatString', 'malloc'], snprintf: function(s, n, format, varargs) { // int snprintf(char *restrict s, size_t n, const char *restrict format, ...); // http://pubs.opengroup.org/onlinepubs/000095399/functions/printf.html @@ -2859,7 +2861,7 @@ LibraryManager.library = { vsscanf: 'sscanf', #endif -#if TARGET_LE32 +#if TARGET_ASMJS_UNKNOWN_EMSCRIPTEN // convert va_arg into varargs vfprintf__deps: ['fprintf'], vfprintf: function(s, f, va_arg) { @@ -2903,7 +2905,7 @@ LibraryManager.library = { // sys/mman.h // ========================================================================== - mmap__deps: ['$FS'], + mmap__deps: ['$FS', 'malloc', 'memset'], mmap: function(start, num, prot, flags, fd, offset) { /* FIXME: Since mmap is normally implemented at the kernel level, * this implementation simply uses malloc underneath the call to @@ -3061,7 +3063,7 @@ LibraryManager.library = { return 0; }, - realloc__deps: ['memcpy'], + realloc__deps: ['malloc', 'memcpy', 'free'], realloc: function(ptr, size) { // Very simple, inefficient implementation - if you use a real malloc, best to use // a real realloc with it @@ -3275,7 +3277,7 @@ LibraryManager.library = { return _strtoll(ptr, null, 10); }, - qsort__deps: ['memcpy'], + qsort__deps: ['malloc', 'memcpy', 'free'], qsort: function(base, num, size, cmp) { if (num == 0 || size == 0) return; // forward calls to the JavaScript sort method @@ -3825,7 +3827,7 @@ LibraryManager.library = { }, rindex: 'strrchr', - strdup__deps: ['strlen'], + strdup__deps: ['strlen', 'malloc'], strdup: function(ptr) { var len = _strlen(ptr); var newStr = _malloc(len + 1); @@ -3834,7 +3836,7 @@ LibraryManager.library = { return newStr; }, - strndup__deps: ['strdup', 'strlen'], + strndup__deps: ['strdup', 'strlen', 'malloc'], strndup: function(ptr, size) { var len = _strlen(ptr); @@ -3942,7 +3944,7 @@ LibraryManager.library = { return ___setErrNo(ERRNO_CODES.EINVAL); } }, - strerror__deps: ['strerror_r'], + strerror__deps: ['strerror_r', 'malloc'], strerror: function(errnum) { if (!_strerror.buffer) _strerror.buffer = _malloc(256); _strerror_r(errnum, _strerror.buffer, 256); @@ -4080,6 +4082,7 @@ LibraryManager.library = { return _isgraph(chr); // no locale support yet }, // Lookup tables for glibc ctype implementation. + __ctype_b_loc__deps: ['malloc'], __ctype_b_loc: function() { // http://refspecs.freestandards.org/LSB_3.0.0/LSB-Core-generic/LSB-Core-generic/baselib---ctype-b-loc.html var me = ___ctype_b_loc; @@ -4105,6 +4108,7 @@ LibraryManager.library = { } return me.ret; }, + __ctype_tolower_loc__deps: ['malloc'], __ctype_tolower_loc: function() { // http://refspecs.freestandards.org/LSB_3.1.1/LSB-Core-generic/LSB-Core-generic/libutil---ctype-tolower-loc.html var me = ___ctype_tolower_loc; @@ -4133,6 +4137,7 @@ LibraryManager.library = { } return me.ret; }, + __ctype_toupper_loc__deps: ['malloc'], __ctype_toupper_loc: function() { // http://refspecs.freestandards.org/LSB_3.1.1/LSB-Core-generic/LSB-Core-generic/libutil---ctype-toupper-loc.html var me = ___ctype_toupper_loc; @@ -4175,7 +4180,7 @@ LibraryManager.library = { #if TARGET_X86 return makeSetValue(ptr, 0, 'varrp', 'void*'); #endif -#if TARGET_LE32 +#if TARGET_ASMJS_UNKNOWN_EMSCRIPTEN // 2-word structure: struct { void* start; void* currentOffset; } return makeSetValue(ptr, 0, 'varrp', 'void*') + ';' + makeSetValue(ptr, Runtime.QUANTUM_SIZE, 0, 'void*'); #endif @@ -4338,12 +4343,12 @@ LibraryManager.library = { __cxa_caught_exceptions: [], // Exceptions - __cxa_allocate_exception__deps: ['__cxa_exception_header_size'], + __cxa_allocate_exception__deps: ['__cxa_exception_header_size', 'malloc'], __cxa_allocate_exception: function(size) { var ptr = _malloc(size + ___cxa_exception_header_size); return ptr + ___cxa_exception_header_size; }, - __cxa_free_exception__deps: ['__cxa_exception_header_size'], + __cxa_free_exception__deps: ['__cxa_exception_header_size', 'free'], __cxa_free_exception: function(ptr) { try { return _free(ptr - ___cxa_exception_header_size); @@ -4414,7 +4419,7 @@ LibraryManager.library = { // we don't actually get the value that we allocated, but something else. Easiest // to remember that the last exception thrown is going to be the first to be caught, // so just use that value instead as it is what we're really looking for. - __cxa_begin_catch__deps: ['_ZSt18uncaught_exceptionv', '__cxa_caught_exceptions'], + __cxa_begin_catch__deps: ['_ZSt18uncaught_exceptionv', '__cxa_caught_exceptions', '__cxa_last_thrown_exception'], __cxa_begin_catch: function(ptr) { __ZSt18uncaught_exceptionv.uncaught_exception--; ___cxa_caught_exceptions.push(___cxa_last_thrown_exception); @@ -4449,14 +4454,13 @@ LibraryManager.library = { ___cxa_last_thrown_exception = 0; } }, - __cxa_get_exception_ptr__deps: ['___cxa_last_thrown_exception'], __cxa_get_exception_ptr: function(ptr) { return ptr; }, _ZSt18uncaught_exceptionv: function() { // std::uncaught_exception() return !!__ZSt18uncaught_exceptionv.uncaught_exception; }, - __cxa_uncaught_exception__deps: ['_Zst18uncaught_exceptionv'], + __cxa_uncaught_exception__deps: ['_ZSt18uncaught_exceptionv'], __cxa_uncaught_exception: function() { return !!__ZSt18uncaught_exceptionv.uncaught_exception; }, @@ -4532,7 +4536,7 @@ LibraryManager.library = { {{{ makeStructuralReturn(['thrown', 'throwntype']) }}}; }, - __resumeException__deps: [function() { Functions.libraryFunctions['__resumeException'] = 1 }], // will be called directly from compiled code + __resumeException__deps: [function() { Functions.libraryFunctions['__resumeException'] = 1 }, '__cxa_last_thrown_exception'], // will be called directly from compiled code __resumeException: function(ptr) { #if EXCEPTION_DEBUG Module.print("Resuming exception"); @@ -4582,10 +4586,11 @@ LibraryManager.library = { // Destructors for std::exception since we don't have them implemented in libcxx as we aren't using libcxxabi. // These are also needed for the dlmalloc tests. + _ZNSt9exceptionD0Ev: function() {}, _ZNSt9exceptionD1Ev: function() {}, _ZNSt9exceptionD2Ev: function() {}, - _ZNKSt9exception4whatEv__deps: ['_malloc'], + _ZNKSt9exception4whatEv__deps: ['malloc'], _ZNKSt9exception4whatEv: function() { if (!__ZNKSt9exception4whatEv.buffer) { var name = "std::exception"; @@ -6443,7 +6448,19 @@ LibraryManager.library = { // var indexes = Runtime.calculateStructAlignment({ fields: ['i32', 'i32'] }); var me = _localeconv; if (!me.ret) { - me.ret = allocate([allocate(intArrayFromString('.'), 'i8', ALLOC_NORMAL)], 'i8*', ALLOC_NORMAL); // just decimal point, for now + // These are defaults from the "C" locale + me.ret = allocate([ + allocate(intArrayFromString('.'), 'i8', ALLOC_NORMAL),0,0,0, // decimal_point + allocate(intArrayFromString(''), 'i8', ALLOC_NORMAL),0,0,0, // thousands_sep + allocate(intArrayFromString(''), 'i8', ALLOC_NORMAL),0,0,0, // grouping + allocate(intArrayFromString(''), 'i8', ALLOC_NORMAL),0,0,0, // int_curr_symbol + allocate(intArrayFromString(''), 'i8', ALLOC_NORMAL),0,0,0, // currency_symbol + allocate(intArrayFromString(''), 'i8', ALLOC_NORMAL),0,0,0, // mon_decimal_point + allocate(intArrayFromString(''), 'i8', ALLOC_NORMAL),0,0,0, // mon_thousands_sep + allocate(intArrayFromString(''), 'i8', ALLOC_NORMAL),0,0,0, // mon_grouping + allocate(intArrayFromString(''), 'i8', ALLOC_NORMAL),0,0,0, // positive_sign + allocate(intArrayFromString(''), 'i8', ALLOC_NORMAL),0,0,0 // negative_sign + ], 'i8*', ALLOC_NORMAL); // Allocate strings in lconv, still don't allocate chars } return me.ret; }, @@ -6454,6 +6471,7 @@ LibraryManager.library = { // langinfo.h // ========================================================================== + nl_langinfo__deps: ['malloc'], nl_langinfo: function(item) { // char *nl_langinfo(nl_item item); // http://pubs.opengroup.org/onlinepubs/000095399/functions/nl_langinfo.html @@ -7080,7 +7098,7 @@ LibraryManager.library = { } return addr; }, - inet_ntoa__deps: ['_inet_ntop4_raw'], + inet_ntoa__deps: ['_inet_ntop4_raw', 'malloc'], inet_ntoa: function(in_addr) { if (!_inet_ntoa.buffer) { _inet_ntoa.buffer = _malloc(1024); @@ -7442,7 +7460,7 @@ LibraryManager.library = { return _gethostbyname(hostp); }, - gethostbyname__deps: ['$DNS', '_inet_pton4_raw'], + gethostbyname__deps: ['$DNS', '_inet_pton4_raw', 'malloc'], gethostbyname: function(name) { name = Pointer_stringify(name); @@ -7475,7 +7493,7 @@ LibraryManager.library = { return 0; }, - getaddrinfo__deps: ['$Sockets', '$DNS', '_inet_pton4_raw', '_inet_ntop4_raw', '_inet_pton6_raw', '_inet_ntop6_raw', '_write_sockaddr', 'htonl'], + getaddrinfo__deps: ['$Sockets', '$DNS', '_inet_pton4_raw', '_inet_ntop4_raw', '_inet_pton6_raw', '_inet_ntop6_raw', '_write_sockaddr', 'htonl', 'malloc'], getaddrinfo: function(node, service, hint, out) { // Note getaddrinfo currently only returns a single addrinfo with ai_next defaulting to NULL. When NULL // hints are specified or ai_family set to AF_UNSPEC or ai_socktype or ai_protocol set to 0 then we @@ -7692,7 +7710,7 @@ LibraryManager.library = { // are actually negative numbers and you can't have expressions as keys in JavaScript literals. $GAI_ERRNO_MESSAGES: {}, - gai_strerror__deps: ['$GAI_ERRNO_MESSAGES'], + gai_strerror__deps: ['$GAI_ERRNO_MESSAGES', 'malloc'], gai_strerror: function(val) { var buflen = 256; @@ -7734,7 +7752,7 @@ LibraryManager.library = { list: [], map: {} }, - setprotoent__deps: ['$Protocols'], + setprotoent__deps: ['$Protocols', 'malloc'], setprotoent: function(stayopen) { // void setprotoent(int stayopen); @@ -8397,7 +8415,7 @@ LibraryManager.library = { } }, - getsockname__deps: ['$FS', '$SOCKFS', '$DNS', '$ERRNO_CODES', '__setErrNo', '_write_sockaddr', '_inet_pton_raw'], + getsockname__deps: ['$FS', '$SOCKFS', '$DNS', '$ERRNO_CODES', '__setErrNo', '_write_sockaddr'], getsockname: function (fd, addr, addrlen) { var sock = SOCKFS.getSocket(fd); if (!sock) { @@ -8415,7 +8433,7 @@ LibraryManager.library = { } }, - getpeername__deps: ['$FS', '$SOCKFS', '$DNS', '$ERRNO_CODES', '__setErrNo', '_write_sockaddr', '_inet_pton_raw'], + getpeername__deps: ['$FS', '$SOCKFS', '$DNS', '$ERRNO_CODES', '__setErrNo', '_write_sockaddr'], getpeername: function (fd, addr, addrlen) { var sock = SOCKFS.getSocket(fd); if (!sock) { @@ -8565,7 +8583,7 @@ LibraryManager.library = { } }, - recvmsg__deps: ['$FS', '$SOCKFS', '$DNS', '$ERRNO_CODES', '__setErrNo', '_inet_pton_raw', '_write_sockaddr'], + recvmsg__deps: ['$FS', '$SOCKFS', '$DNS', '$ERRNO_CODES', '__setErrNo', '_write_sockaddr'], recvmsg: function(fd, message, flags) { var sock = SOCKFS.getSocket(fd); if (!sock) { @@ -8926,7 +8944,8 @@ LibraryManager.library = { // Process all lines: lines = callstack.split('\n'); callstack = ''; - var firefoxRe = new RegExp('\\s*(.*?)@(.*):(.*)'); // Extract components of form ' Object._main@http://server.com:4324' + var newFirefoxRe = new RegExp('\\s*(.*?)@(.*?):([0-9]+):([0-9]+)'); // New FF30 with column info: extract components of form ' Object._main@http://server.com:4324:12' + var firefoxRe = new RegExp('\\s*(.*?)@(.*):(.*)(:(.*))?'); // Old FF without column info: extract components of form ' Object._main@http://server.com:4324' var chromeRe = new RegExp('\\s*at (.*?) \\\((.*):(.*):(.*)\\\)'); // Extract components of form ' at Object._main (http://server.com/file.html:4324:12)' for(l in lines) { @@ -8944,12 +8963,13 @@ LibraryManager.library = { lineno = parts[3]; column = parts[4]; } else { - parts = firefoxRe.exec(line); - if (parts && parts.length == 4) { + parts = newFirefoxRe.exec(line); + if (!parts) parts = firefoxRe.exec(line); + if (parts && parts.length >= 4) { jsSymbolName = parts[1]; file = parts[2]; lineno = parts[3]; - column = 0; // Firefox doesn't carry column information. See https://bugzilla.mozilla.org/show_bug.cgi?id=762556 + column = parts[4]|0; // Old Firefox doesn't carry column information, but in new FF30, it is present. See https://bugzilla.mozilla.org/show_bug.cgi?id=762556 } else { // Was not able to extract this line for demangling/sourcemapping purposes. Output it as-is. callstack += line + '\n'; diff --git a/src/library_browser.js b/src/library_browser.js index 46082281..b800292c 100644 --- a/src/library_browser.js +++ b/src/library_browser.js @@ -234,6 +234,10 @@ mergeInto(LibraryManager.library, { } #endif var ctx; + var errorInfo = '?'; + function onContextCreationError(event) { + errorInfo = event.statusMessage || errorInfo; + } try { if (useWebGL) { var contextAttributes = { @@ -251,10 +255,6 @@ mergeInto(LibraryManager.library, { contextAttributes.preserveDrawingBuffer = true; #endif - var errorInfo = '?'; - function onContextCreationError(event) { - errorInfo = event.statusMessage || errorInfo; - } canvas.addEventListener('webglcontextcreationerror', onContextCreationError, false); try { ['experimental-webgl', 'webgl'].some(function(webglId) { diff --git a/src/library_fs.js b/src/library_fs.js index e97ba588..1428f041 100644 --- a/src/library_fs.js +++ b/src/library_fs.js @@ -616,13 +616,13 @@ mergeInto(LibraryManager.library, { }, // helpers to create specific types of nodes create: function(path, mode) { - mode = mode !== undefined ? mode : 0666; + mode = mode !== undefined ? mode : 438 /* 0666 */; mode &= {{{ cDefine('S_IALLUGO') }}}; mode |= {{{ cDefine('S_IFREG') }}}; return FS.mknod(path, mode, 0); }, mkdir: function(path, mode) { - mode = mode !== undefined ? mode : 0777; + mode = mode !== undefined ? mode : 511 /* 0777 */; mode &= {{{ cDefine('S_IRWXUGO') }}} | {{{ cDefine('S_ISVTX') }}}; mode |= {{{ cDefine('S_IFDIR') }}}; return FS.mknod(path, mode, 0); @@ -630,7 +630,7 @@ mergeInto(LibraryManager.library, { mkdev: function(path, mode, dev) { if (typeof(dev) === 'undefined') { dev = mode; - mode = 0666; + mode = 438 /* 0666 */; } mode |= {{{ cDefine('S_IFCHR') }}}; return FS.mknod(path, mode, dev); @@ -895,7 +895,7 @@ mergeInto(LibraryManager.library, { }, open: function(path, flags, mode, fd_start, fd_end) { flags = typeof flags === 'string' ? FS.modeStringToFlags(flags) : flags; - mode = typeof mode === 'undefined' ? 0666 : mode; + mode = typeof mode === 'undefined' ? 438 /* 0666 */ : mode; if ((flags & {{{ cDefine('O_CREAT') }}})) { mode = (mode & {{{ cDefine('S_IALLUGO') }}}) | {{{ cDefine('S_IFREG') }}}; } else { diff --git a/src/library_gc.js b/src/library_gc.js index b3dae0e9..d86f2d15 100644 --- a/src/library_gc.js +++ b/src/library_gc.js @@ -1,4 +1,6 @@ +// WARNING: this is deprecated. You should just build Boehm from source, it is much faster than the toy version written in emscripten + if (GC_SUPPORT) { EXPORTED_FUNCTIONS['_calloc'] = 1; EXPORTED_FUNCTIONS['_realloc'] = 1; diff --git a/src/library_gl.js b/src/library_gl.js index 10c8cec9..7e4c5a97 100644 --- a/src/library_gl.js +++ b/src/library_gl.js @@ -1806,14 +1806,10 @@ var LibraryGL = { glGenVertexArrays__sig: 'vii', glGenVertexArrays: function (n, arrays) { #if LEGACY_GL_EMULATION - if (GL.vaoExt == null) { - _emulGlGenVertexArrays(n, arrays); - return; - } -#else -#if GL_ASSERTIONS + _emulGlGenVertexArrays(n, arrays); +#else +#if GL_ASSERTIONS assert(GL.vaoExt, 'Must have OES_vertex_array_object to use vao'); -#endif #endif for(var i = 0; i < n; i++) { @@ -1823,6 +1819,7 @@ var LibraryGL = { GL.vaos[id] = vao; {{{ makeSetValue('arrays', 'i*4', 'id', 'i32') }}}; } +#endif }, #if LEGACY_GL_EMULATION @@ -1831,21 +1828,17 @@ var LibraryGL = { glDeleteVertexArrays__sig: 'vii', glDeleteVertexArrays: function(n, vaos) { #if LEGACY_GL_EMULATION - if (GL.vaoExt == null) { - _emulGlDeleteVertexArrays(n, vaos); - return; - } -#else -#if GL_ASSERTIONS + _emulGlDeleteVertexArrays(n, vaos); +#else +#if GL_ASSERTIONS assert(GL.vaoExt, 'Must have OES_vertex_array_object to use vao'); -#endif #endif - for(var i = 0; i < n; i++) { var id = {{{ makeGetValue('vaos', 'i*4', 'i32') }}}; GL.vaoExt.deleteVertexArrayOES(GL.vaos[id]); GL.vaos[id] = null; } +#endif }, #if LEGACY_GL_EMULATION @@ -1854,17 +1847,14 @@ var LibraryGL = { glBindVertexArray__sig: 'vi', glBindVertexArray: function(vao) { #if LEGACY_GL_EMULATION - if (GL.vaoExt == null) { - _emulGlBindVertexArray(vao); - return; - } -#else + _emulGlBindVertexArray(vao); +#else #if GL_ASSERTIONS - assert(GL.vaoExt, 'Must have OES_vertex_array_object to use vao'); -#endif + assert(GL.vaoExt, 'Must have OES_vertex_array_object to use vao'); #endif GL.vaoExt.bindVertexArrayOES(GL.vaos[vao]); +#endif }, #if LEGACY_GL_EMULATION @@ -1873,18 +1863,16 @@ var LibraryGL = { glIsVertexArray__sig: 'ii', glIsVertexArray: function(array) { #if LEGACY_GL_EMULATION - if (GL.vaoExt == null) { - return _emulGlIsVertexArray(array); - } -#else + return _emulGlIsVertexArray(array); +#else #if GL_ASSERTIONS - assert(GL.vaoExt, 'Must have OES_vertex_array_object to use vao'); + assert(GL.vaoExt, 'Must have OES_vertex_array_object to use vao'); #endif -#endif var vao = GL.vaos[array]; if (!vao) return 0; return GL.vaoExt.isVertexArrayOES(vao); +#endif }, #if LEGACY_GL_EMULATION diff --git a/src/library_html5.js b/src/library_html5.js index a38c2390..b17a0d4d 100644 --- a/src/library_html5.js +++ b/src/library_html5.js @@ -13,6 +13,10 @@ var LibraryJSEvents = { visibilityChangeEvent: 0, touchEvent: 0, + // When we transition from fullscreen to windowed mode, we remember here the element that was just in fullscreen mode + // so that we can report information about that element in the event message. + previousFullscreenElement: null, + // When the C runtime exits via exit(), we unregister all event handlers added by this library to be nice and clean. // Track in this field whether we have yet registered that __ATEXIT__ handler. removeEventListenersRegistered: false, @@ -156,17 +160,17 @@ var LibraryJSEvents = { var e = event || window.event; writeStringToMemory(e.key ? e.key : "", JSEvents.keyEvent + {{{ C_STRUCTS.EmscriptenKeyboardEvent.key }}} ); writeStringToMemory(e.code ? e.code : "", JSEvents.keyEvent + {{{ C_STRUCTS.EmscriptenKeyboardEvent.code }}} ); - {{{ makeSetValue('JSEvents.keyEvent', C_STRUCTS.EmscriptenKeyboardEvent.location, 'e.location', 'i32') }}} - {{{ makeSetValue('JSEvents.keyEvent', C_STRUCTS.EmscriptenKeyboardEvent.ctrlKey, 'e.ctrlKey', 'i32') }}} - {{{ makeSetValue('JSEvents.keyEvent', C_STRUCTS.EmscriptenKeyboardEvent.shiftKey, 'e.shiftKey', 'i32') }}} - {{{ makeSetValue('JSEvents.keyEvent', C_STRUCTS.EmscriptenKeyboardEvent.altKey, 'e.altKey', 'i32') }}} - {{{ makeSetValue('JSEvents.keyEvent', C_STRUCTS.EmscriptenKeyboardEvent.metaKey, 'e.metaKey', 'i32') }}} - {{{ makeSetValue('JSEvents.keyEvent', C_STRUCTS.EmscriptenKeyboardEvent.repeat, 'e.repeat', 'i32') }}} + {{{ makeSetValue('JSEvents.keyEvent', C_STRUCTS.EmscriptenKeyboardEvent.location, 'e.location', 'i32') }}}; + {{{ makeSetValue('JSEvents.keyEvent', C_STRUCTS.EmscriptenKeyboardEvent.ctrlKey, 'e.ctrlKey', 'i32') }}}; + {{{ makeSetValue('JSEvents.keyEvent', C_STRUCTS.EmscriptenKeyboardEvent.shiftKey, 'e.shiftKey', 'i32') }}}; + {{{ makeSetValue('JSEvents.keyEvent', C_STRUCTS.EmscriptenKeyboardEvent.altKey, 'e.altKey', 'i32') }}}; + {{{ makeSetValue('JSEvents.keyEvent', C_STRUCTS.EmscriptenKeyboardEvent.metaKey, 'e.metaKey', 'i32') }}}; + {{{ makeSetValue('JSEvents.keyEvent', C_STRUCTS.EmscriptenKeyboardEvent.repeat, 'e.repeat', 'i32') }}}; writeStringToMemory(e.locale ? e.locale : "", JSEvents.keyEvent + {{{ C_STRUCTS.EmscriptenKeyboardEvent.locale }}} ); writeStringToMemory(e.char ? e.char : "", JSEvents.keyEvent + {{{ C_STRUCTS.EmscriptenKeyboardEvent.charValue }}} ); - {{{ makeSetValue('JSEvents.keyEvent', C_STRUCTS.EmscriptenKeyboardEvent.charCode, 'e.charCode', 'i32') }}} - {{{ makeSetValue('JSEvents.keyEvent', C_STRUCTS.EmscriptenKeyboardEvent.keyCode, 'e.keyCode', 'i32') }}} - {{{ makeSetValue('JSEvents.keyEvent', C_STRUCTS.EmscriptenKeyboardEvent.which, 'e.which', 'i32') }}} + {{{ makeSetValue('JSEvents.keyEvent', C_STRUCTS.EmscriptenKeyboardEvent.charCode, 'e.charCode', 'i32') }}}; + {{{ makeSetValue('JSEvents.keyEvent', C_STRUCTS.EmscriptenKeyboardEvent.keyCode, 'e.keyCode', 'i32') }}}; + {{{ makeSetValue('JSEvents.keyEvent', C_STRUCTS.EmscriptenKeyboardEvent.which, 'e.which', 'i32') }}}; var shouldCancel = Runtime.dynCall('iiii', callbackfunc, [eventTypeId, JSEvents.keyEvent, userData]); if (shouldCancel) { e.preventDefault(); @@ -188,21 +192,21 @@ var LibraryJSEvents = { fillMouseEventData: function(eventStruct, e) { var rect = Module['canvas'].getBoundingClientRect(); - {{{ makeSetValue('eventStruct', C_STRUCTS.EmscriptenMouseEvent.timestamp, 'JSEvents.tick()', 'double') }}} - {{{ makeSetValue('eventStruct', C_STRUCTS.EmscriptenMouseEvent.screenX, 'e.screenX', 'i32') }}} - {{{ makeSetValue('eventStruct', C_STRUCTS.EmscriptenMouseEvent.screenY, 'e.screenY', 'i32') }}} - {{{ makeSetValue('eventStruct', C_STRUCTS.EmscriptenMouseEvent.clientX, 'e.clientX', 'i32') }}} - {{{ makeSetValue('eventStruct', C_STRUCTS.EmscriptenMouseEvent.clientY, 'e.clientY', 'i32') }}} - {{{ makeSetValue('eventStruct', C_STRUCTS.EmscriptenMouseEvent.ctrlKey, 'e.ctrlKey', 'i32') }}} - {{{ makeSetValue('eventStruct', C_STRUCTS.EmscriptenMouseEvent.shiftKey, 'e.shiftKey', 'i32') }}} - {{{ makeSetValue('eventStruct', C_STRUCTS.EmscriptenMouseEvent.altKey, 'e.altKey', 'i32') }}} - {{{ makeSetValue('eventStruct', C_STRUCTS.EmscriptenMouseEvent.metaKey, 'e.metaKey', 'i32') }}} - {{{ makeSetValue('eventStruct', C_STRUCTS.EmscriptenMouseEvent.button, 'e.button', 'i16') }}} - {{{ makeSetValue('eventStruct', C_STRUCTS.EmscriptenMouseEvent.buttons, 'e.buttons', 'i16') }}} - {{{ makeSetValue('eventStruct', C_STRUCTS.EmscriptenMouseEvent.movementX, 'e.movementX', 'i32') }}} - {{{ makeSetValue('eventStruct', C_STRUCTS.EmscriptenMouseEvent.movementY, 'e.movementY', 'i32') }}} - {{{ makeSetValue('eventStruct', C_STRUCTS.EmscriptenMouseEvent.canvasX, 'e.clientX - rect.left', 'i32') }}} - {{{ makeSetValue('eventStruct', C_STRUCTS.EmscriptenMouseEvent.canvasY, 'e.clientY - rect.top', 'i32') }}} + {{{ makeSetValue('eventStruct', C_STRUCTS.EmscriptenMouseEvent.timestamp, 'JSEvents.tick()', 'double') }}}; + {{{ makeSetValue('eventStruct', C_STRUCTS.EmscriptenMouseEvent.screenX, 'e.screenX', 'i32') }}}; + {{{ makeSetValue('eventStruct', C_STRUCTS.EmscriptenMouseEvent.screenY, 'e.screenY', 'i32') }}}; + {{{ makeSetValue('eventStruct', C_STRUCTS.EmscriptenMouseEvent.clientX, 'e.clientX', 'i32') }}}; + {{{ makeSetValue('eventStruct', C_STRUCTS.EmscriptenMouseEvent.clientY, 'e.clientY', 'i32') }}}; + {{{ makeSetValue('eventStruct', C_STRUCTS.EmscriptenMouseEvent.ctrlKey, 'e.ctrlKey', 'i32') }}}; + {{{ makeSetValue('eventStruct', C_STRUCTS.EmscriptenMouseEvent.shiftKey, 'e.shiftKey', 'i32') }}}; + {{{ makeSetValue('eventStruct', C_STRUCTS.EmscriptenMouseEvent.altKey, 'e.altKey', 'i32') }}}; + {{{ makeSetValue('eventStruct', C_STRUCTS.EmscriptenMouseEvent.metaKey, 'e.metaKey', 'i32') }}}; + {{{ makeSetValue('eventStruct', C_STRUCTS.EmscriptenMouseEvent.button, 'e.button', 'i16') }}}; + {{{ makeSetValue('eventStruct', C_STRUCTS.EmscriptenMouseEvent.buttons, 'e.buttons', 'i16') }}}; + {{{ makeSetValue('eventStruct', C_STRUCTS.EmscriptenMouseEvent.movementX, 'e.movementX || e.mozMovementX || e.webkitMovementX', 'i32') }}}; + {{{ makeSetValue('eventStruct', C_STRUCTS.EmscriptenMouseEvent.movementY, 'e.movementY || e.mozMovementY || e.webkitMovementY', 'i32') }}}; + {{{ makeSetValue('eventStruct', |