diff options
author | Alon Zakai <azakai@mozilla.com> | 2010-12-15 20:52:08 -0800 |
---|---|---|
committer | Alon Zakai <azakai@mozilla.com> | 2010-12-15 20:52:08 -0800 |
commit | 3939368ad428f86e0d21674e13c7ff684c2cfb3c (patch) | |
tree | 42e08891cb5f259937184a62a1a9a59c36d195fe | |
parent | 8783a09b1d0a02a378406b9d879818a6c02a6358 (diff) |
misc fixes and improvements - thanks go to tuba
-rw-r--r-- | src/jsifier.js | 7 | ||||
-rw-r--r-- | src/parseTools.js | 6 | ||||
-rw-r--r-- | src/postamble.js | 2 | ||||
-rw-r--r-- | src/settings.js | 2 |
4 files changed, 9 insertions, 8 deletions
diff --git a/src/jsifier.js b/src/jsifier.js index 90b155e7..1d1b35df 100644 --- a/src/jsifier.js +++ b/src/jsifier.js @@ -349,9 +349,6 @@ function JSify(data, functionsOnly, givenTypes, givenFunctions) { if (true) { // TODO: optimize away when not needed func.JS += ' var __label__;\n'; } - if (func.hasVarArgs) { - func.JS += ' var __numArgs__ = ' + func.paramIdents.length + ';\n'; - } if (func.hasPhi) { func.JS += ' var __lastLabel__ = null;\n'; } @@ -909,8 +906,8 @@ function JSify(data, functionsOnly, givenTypes, givenFunctions) { function makeFunctionCall(ident, params, funcData) { // Special cases if (ident == '_llvm_va_start') { - // varargs - we received a pointer to the varargs as a final parameter - var data = 'arguments[__numArgs__]'; + // varargs - we received a pointer to the varargs as a final 'extra' parameter + var data = 'arguments[arguments.callee.length]'; if (SAFE_HEAP) { return 'SAFE_HEAP_STORE(' + params[0].ident + ', ' + data + ', null)'; } else { diff --git a/src/parseTools.js b/src/parseTools.js index 3f9a1481..fa8b6ac6 100644 --- a/src/parseTools.js +++ b/src/parseTools.js @@ -236,7 +236,7 @@ function parseParamTokens(params) { if (params[params.length-1].text != ',') { params.push({ text: ',' }); } - var absIndex = 0; + var anonymousIndex = 0; while (params.length > 0) { var i = 0; while (params[i].text != ',') i++; @@ -255,8 +255,9 @@ function parseParamTokens(params) { intertype: 'value', type: segment[0].text, value: null, - ident: toNiceIdent('%') + absIndex + ident: toNiceIdent('%') + anonymousIndex }); + anonymousIndex ++; } } else if (segment[1].text in PARSABLE_LLVM_FUNCTIONS) { ret.push(parseLLVMFunctionCall(segment)); @@ -277,7 +278,6 @@ function parseParamTokens(params) { // } else { // throw "what is this params token? " + JSON.stringify(segment); } - absIndex ++; } return ret; } diff --git a/src/postamble.js b/src/postamble.js index 6907814b..7be5110d 100644 --- a/src/postamble.js +++ b/src/postamble.js @@ -31,5 +31,7 @@ function run(args) { } } +#if INVOKE_RUN run(args); +#endif diff --git a/src/settings.js b/src/settings.js index 8aa9427e..98b95035 100644 --- a/src/settings.js +++ b/src/settings.js @@ -21,6 +21,8 @@ GUARD_LABELS = 0; // Whether we should throw if we encounter a bad __label__, i. GUARD_MEMORY = 1; // Whether we should check that each allocation to the stack does not // exceed it's size, whether all allocations (stack and static) are // of positive size, etc. +INVOKE_RUN = 1; // Whether we will call run(). Disable if you embed the generated + // code in your own, and will call run() yourself at the right time // Code embetterments OPTIMIZE = 0; // Optimize llvm operations into js commands |