diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/jsifier.js | 30 | ||||
-rw-r--r-- | src/library.js | 25 | ||||
-rw-r--r-- | src/settings.js | 6 |
3 files changed, 32 insertions, 29 deletions
diff --git a/src/jsifier.js b/src/jsifier.js index b377202d..c92526d2 100644 --- a/src/jsifier.js +++ b/src/jsifier.js @@ -658,6 +658,10 @@ function JSify(data, functionsOnly, givenFunctions) { } } + if (func.hasVarArgsCall) { + func.JS += INDENTATION + 'var tempVarArgs = 0;\n'; + } + // Prepare the stack, if we need one. If we have other stack allocations, force the stack to be set up. func.JS += INDENTATION + RuntimeGenerator.stackEnter(func.initialStack, func.otherStackAllocations) + ';\n'; @@ -1234,6 +1238,7 @@ function JSify(data, functionsOnly, givenFunctions) { + (EXCEPTION_DEBUG ? 'Module.print("Exception: " + e + ", currently at: " + (new Error().stack)); ' : '') + 'return null } })();'; } + ret = makeVarArgsCleanup(ret); if (item.assignTo) { ret = 'var ' + item.assignTo + ' = ' + ret; @@ -1446,12 +1451,13 @@ function JSify(data, functionsOnly, givenFunctions) { }); if (hasVarArgs && !useJSArgs) { + funcData.hasVarArgsCall = true; if (varargs.length === 0) { varargs = [0]; varargsTypes = ['i32']; } var offset = 0; - varargs = '(tempInt=' + RuntimeGenerator.stackAlloc(varargs.length, ',') + ',' + + varargs = '(tempVarArgs=' + RuntimeGenerator.stackAlloc(varargs.length, ',') + ',' + varargs.map(function(arg, i) { var type = varargsTypes[i]; if (type == 0) return null; @@ -1459,17 +1465,17 @@ function JSify(data, functionsOnly, givenFunctions) { var ret; assert(offset % Runtime.STACK_ALIGN == 0); // varargs must be aligned if (!varargsByVals[i]) { - ret = makeSetValue(getFastValue('tempInt', '+', offset), 0, arg, type, null, null, Runtime.STACK_ALIGN, null, ','); + ret = makeSetValue(getFastValue('tempVarArgs', '+', offset), 0, arg, type, null, null, Runtime.STACK_ALIGN, null, ','); offset += Runtime.alignMemory(Runtime.getNativeFieldSize(type), Runtime.STACK_ALIGN); } else { var size = calcAllocatedSize(removeAllPointing(type)); - ret = makeCopyValues(getFastValue('tempInt', '+', offset), arg, size, null, null, varargsByVals[i], ','); + ret = makeCopyValues(getFastValue('tempVarArgs', '+', offset), arg, size, null, null, varargsByVals[i], ','); offset += Runtime.forceAlign(size, Runtime.STACK_ALIGN); } return ret; }).filter(function(arg) { return arg !== null; - }).join(',') + ',tempInt)'; + }).join(',') + ',tempVarArgs)'; varargs = asmCoercion(varargs, 'i32'); } @@ -1557,10 +1563,24 @@ function JSify(data, functionsOnly, givenFunctions) { return ret; } + + function makeVarArgsCleanup(js) { + if (js.indexOf('(tempVarArgs=') >= 0) { + if (js[js.length-1] == ';') { + return js + ' STACKTOP=tempVarArgs;'; + } else { + assert(js.indexOf(';') < 0); + return '((' + js + '), STACKTOP=tempVarArgs)'; + } + } + return js; + } + makeFuncLineActor('getelementptr', function(item) { return finalizeLLVMFunctionCall(item) }); makeFuncLineActor('call', function(item) { if (item.standalone && LibraryManager.isStubFunction(item.ident)) return ';'; - return makeFunctionCall(item.ident, item.params, item.funcData, item.type, false, !!item.assignTo || !item.standalone) + (item.standalone ? ';' : ''); + var ret = makeFunctionCall(item.ident, item.params, item.funcData, item.type, false, !!item.assignTo || !item.standalone) + (item.standalone ? ';' : ''); + return makeVarArgsCleanup(ret); }); makeFuncLineActor('unreachable', function(item) { diff --git a/src/library.js b/src/library.js index b68a9324..6ce77268 100644 --- a/src/library.js +++ b/src/library.js @@ -2961,6 +2961,7 @@ LibraryManager.library = { _exit: function(status) { // void _exit(int status); // http://pubs.opengroup.org/onlinepubs/000095399/functions/exit.html + Module.print('exit(' + status + ') called'); Module['exit'](status); }, fork__deps: ['__setErrNo', '$ERRNO_CODES'], @@ -8216,10 +8217,8 @@ LibraryManager.library = { ECOMM: {{{ cDefine('ECOMM') }}}, EPROTO: {{{ cDefine('EPROTO') }}}, EMULTIHOP: {{{ cDefine('EMULTIHOP') }}}, - ELBIN: {{{ cDefine('ELBIN') }}}, EDOTDOT: {{{ cDefine('EDOTDOT') }}}, EBADMSG: {{{ cDefine('EBADMSG') }}}, - EFTYPE: {{{ cDefine('EFTYPE') }}}, ENOTUNIQ: {{{ cDefine('ENOTUNIQ') }}}, EBADFD: {{{ cDefine('EBADFD') }}}, EREMCHG: {{{ cDefine('EREMCHG') }}}, @@ -8229,7 +8228,6 @@ LibraryManager.library = { ELIBMAX: {{{ cDefine('ELIBMAX') }}}, ELIBEXEC: {{{ cDefine('ELIBEXEC') }}}, ENOSYS: {{{ cDefine('ENOSYS') }}}, - ENMFILE: {{{ cDefine('ENMFILE') }}}, ENOTEMPTY: {{{ cDefine('ENOTEMPTY') }}}, ENAMETOOLONG: {{{ cDefine('ENAMETOOLONG') }}}, ELOOP: {{{ cDefine('ELOOP') }}}, @@ -8261,14 +8259,11 @@ LibraryManager.library = { EISCONN: {{{ cDefine('EISCONN') }}}, ENOTCONN: {{{ cDefine('ENOTCONN') }}}, ETOOMANYREFS: {{{ cDefine('ETOOMANYREFS') }}}, - EPROCLIM: {{{ cDefine('EPROCLIM') }}}, EUSERS: {{{ cDefine('EUSERS') }}}, EDQUOT: {{{ cDefine('EDQUOT') }}}, ESTALE: {{{ cDefine('ESTALE') }}}, ENOTSUP: {{{ cDefine('ENOTSUP') }}}, ENOMEDIUM: {{{ cDefine('ENOMEDIUM') }}}, - ENOSHARE: {{{ cDefine('ENOSHARE') }}}, - ECASECLASH: {{{ cDefine('ECASECLASH') }}}, EILSEQ: {{{ cDefine('EILSEQ') }}}, EOVERFLOW: {{{ cDefine('EOVERFLOW') }}}, ECANCELED: {{{ cDefine('ECANCELED') }}}, @@ -8345,10 +8340,8 @@ LibraryManager.library = { {{{ cDefine('ECOMM') }}}: 'Communication error on send', {{{ cDefine('EPROTO') }}}: 'Protocol error', {{{ cDefine('EMULTIHOP') }}}: 'Multihop attempted', - {{{ cDefine('ELBIN') }}}: 'Inode is remote (not really error)', {{{ cDefine('EDOTDOT') }}}: 'Cross mount point (not really error)', {{{ cDefine('EBADMSG') }}}: 'Trying to read unreadable message', - {{{ cDefine('EFTYPE') }}}: 'Inappropriate file type or format', {{{ cDefine('ENOTUNIQ') }}}: 'Given log. name not unique', {{{ cDefine('EBADFD') }}}: 'f.d. invalid for this operation', {{{ cDefine('EREMCHG') }}}: 'Remote address changed', @@ -8358,7 +8351,6 @@ LibraryManager.library = { {{{ cDefine('ELIBMAX') }}}: 'Attempting to link in too many libs', {{{ cDefine('ELIBEXEC') }}}: 'Attempting to exec a shared library', {{{ cDefine('ENOSYS') }}}: 'Function not implemented', - {{{ cDefine('ENMFILE') }}}: 'No more files', {{{ cDefine('ENOTEMPTY') }}}: 'Directory not empty', {{{ cDefine('ENAMETOOLONG') }}}: 'File or path name too long', {{{ cDefine('ELOOP') }}}: 'Too many symbolic links', @@ -8386,19 +8378,16 @@ LibraryManager.library = { {{{ cDefine('EPROTONOSUPPORT') }}}: 'Unknown protocol', {{{ cDefine('ESOCKTNOSUPPORT') }}}: 'Socket type not supported', {{{ cDefine('EADDRNOTAVAIL') }}}: 'Address not available', - {{{ cDefine('ENETRESET') }}}: 'ENETRESET', + {{{ cDefine('ENETRESET') }}}: 'Connection reset by network', {{{ cDefine('EISCONN') }}}: 'Socket is already connected', {{{ cDefine('ENOTCONN') }}}: 'Socket is not connected', - {{{ cDefine('ETOOMANYREFS') }}}: 'TOOMANYREFS', - {{{ cDefine('EPROCLIM') }}}: 'EPROCLIM', - {{{ cDefine('EUSERS') }}}: 'EUSERS', - {{{ cDefine('EDQUOT') }}}: 'EDQUOT', - {{{ cDefine('ESTALE') }}}: 'ESTALE', + {{{ cDefine('ETOOMANYREFS') }}}: 'Too many references', + {{{ cDefine('EUSERS') }}}: 'Too many users', + {{{ cDefine('EDQUOT') }}}: 'Quota exceeded', + {{{ cDefine('ESTALE') }}}: 'Stale file handle', {{{ cDefine('ENOTSUP') }}}: 'Not supported', {{{ cDefine('ENOMEDIUM') }}}: 'No medium (in tape drive)', - {{{ cDefine('ENOSHARE') }}}: 'No such host or network path', - {{{ cDefine('ECASECLASH') }}}: 'Filename exists with different case', - {{{ cDefine('EILSEQ') }}}: 'EILSEQ', + {{{ cDefine('EILSEQ') }}}: 'Illegal byte sequence', {{{ cDefine('EOVERFLOW') }}}: 'Value too large for defined data type', {{{ cDefine('ECANCELED') }}}: 'Operation canceled', {{{ cDefine('ENOTRECOVERABLE') }}}: 'State not recoverable', diff --git a/src/settings.js b/src/settings.js index 21745ef8..3515091d 100644 --- a/src/settings.js +++ b/src/settings.js @@ -1391,10 +1391,8 @@ var C_DEFINES = { 'ECOMM': '70', 'EPROTO': '71', 'EMULTIHOP': '74', - 'ELBIN': '75', 'EDOTDOT': '76', 'EBADMSG': '77', - 'EFTYPE': '79', 'ENOTUNIQ': '80', 'EBADFD': '81', 'EREMCHG': '82', @@ -1404,7 +1402,6 @@ var C_DEFINES = { 'ELIBMAX': '86', 'ELIBEXEC': '87', 'ENOSYS': '88', - 'ENMFILE': '89', 'ENOTEMPTY': '90', 'ENAMETOOLONG': '91', 'ELOOP': '92', @@ -1436,14 +1433,11 @@ var C_DEFINES = { 'EISCONN': '127', 'ENOTCONN': '128', 'ETOOMANYREFS': '129', - 'EPROCLIM': '130', 'EUSERS': '131', 'EDQUOT': '132', 'ESTALE': '133', 'ENOTSUP': '134', 'ENOMEDIUM': '135', - 'ENOSHARE': '136', - 'ECASECLASH': '137', 'EILSEQ': '138', 'EOVERFLOW': '139', 'ECANCELED': '140', |