aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-08-09 14:02:40 -0700
committerAlon Zakai <alonzakai@gmail.com>2013-08-09 14:54:31 -0700
commit4ae35bd2e1fe6e4fedffe90019f1ef6b06fa15c7 (patch)
treec11579475a9cec41270206c54ff48a21d21ae6ae
parent12700c43d60eaae9101cf307a25a211886add1c6 (diff)
use a local variable for varargs temp stack position
-rw-r--r--src/jsifier.js13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/jsifier.js b/src/jsifier.js
index b377202d..1d70fd6f 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';
@@ -1446,12 +1450,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 +1464,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');
}