aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-03-06 15:52:52 -0800
committerAlon Zakai <alonzakai@gmail.com>2013-03-06 15:52:52 -0800
commit1024a871a325039ab0fafb98b11773d06d085e24 (patch)
tree2ebc1734c5acdb6526f04719a1b93af37cb468fa
parent76ffb6f4a67562db321ead1eb25b849fc6fe60d9 (diff)
loopify big memsets in asm
-rw-r--r--src/parseTools.js11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/parseTools.js b/src/parseTools.js
index 7f4f3a18..5d8c6258 100644
--- a/src/parseTools.js
+++ b/src/parseTools.js
@@ -1283,12 +1283,15 @@ function makeSetValues(ptr, pos, value, type, num, align) {
[4, 2, 1].forEach(function(possibleAlign) {
if (num == 0) return;
if (align >= possibleAlign) {
- if (num <= UNROLL_LOOP_MAX*possibleAlign || ASM_JS) { // XXX test asm performance
+ if (num <= UNROLL_LOOP_MAX*possibleAlign) {
ret.push(unroll('i' + (possibleAlign*8), Math.floor(num/possibleAlign), possibleAlign, values[possibleAlign]));
} else {
- ret.push('for (var $$dest = ' + getFastValue(ptr, '+', pos) + (possibleAlign > 1 ? '>>' + log2(possibleAlign) : '') + ', ' +
- '$$stop = $$dest + ' + Math.floor(num/possibleAlign) + '; $$dest < $$stop; $$dest++) {\n' +
- ' HEAP' + (possibleAlign*8) + '[$$dest] = ' + values[possibleAlign] + '\n}');
+ ret.push('var $$dest = ' + getFastValue(ptr, '+', pos) + '; ' +
+ 'var $$stop = ($$dest + ' + num + ')|0; ' +
+ 'while (($$dest|0) < ($$stop|0)) {' +
+ ' HEAP' + (possibleAlign*8) + '[$$dest' + (possibleAlign > 1 ? '>>' + log2(possibleAlign) : '') + '] = ' + values[possibleAlign] + '; ' +
+ ' $$dest = ($$dest + ' + possibleAlign + ')|0; ' +
+ '}');
}
pos = getFastValue(pos, '+', Math.floor(num/possibleAlign)*possibleAlign);
num %= possibleAlign;