aboutsummaryrefslogtreecommitdiff
path: root/src/jsifier.js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-01-10 11:19:58 -0800
committerAlon Zakai <alonzakai@gmail.com>2012-01-10 11:19:58 -0800
commit5beb9b6b1909da1c527ac5cd9601fdba82f39ad5 (patch)
tree4e8d90635ca073a3bf7670e1054d7ef8bb87cab7 /src/jsifier.js
parent66a79e74a4d01f6cfc6fb8e289a00896e397d12f (diff)
optimize varargs calls by avoiding calling allocate there
Diffstat (limited to 'src/jsifier.js')
-rw-r--r--src/jsifier.js13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/jsifier.js b/src/jsifier.js
index 3f41c179..501ed3f9 100644
--- a/src/jsifier.js
+++ b/src/jsifier.js
@@ -1063,7 +1063,18 @@ function JSify(data, functionsOnly, givenFunctions) {
varargs = [0];
varargsTypes = ['i32'];
}
- varargs = makePointer('[' + varargs + ']', 0, 'ALLOC_STACK', varargsTypes);
+ var offset = 0;
+ varargs = '(tempInt=' + RuntimeGenerator.stackAlloc(varargs.length, ',') + ',' +
+ varargs.map(function(arg, i) {
+ var type = varargsTypes[i];
+ if (type == 0) return null;
+ if (I64_MODE == 1 && type == 'i64') type = 'i32'; // We have [i64, 0, 0, 0, i32, 0, 0, 0] in the layout at this point
+ var ret = makeSetValue(getFastValue('tempInt', '+', offset), 0, arg, type, null, null, QUANTUM_SIZE);
+ offset += Runtime.getNativeFieldSize(type);
+ return ret;
+ }).filter(function(arg) {
+ return arg !== null;
+ }).join(',') + ',tempInt)';
}
args = args.concat(varargs);