aboutsummaryrefslogtreecommitdiff
path: root/src/jsifier.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/jsifier.js')
-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');
}