diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-03-06 16:00:22 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-03-06 16:00:22 -0800 |
commit | b2adfb09ae28da6f48fe117e518e3138dec6e983 (patch) | |
tree | ff036e8dbb2ea1f1b02dfbd35e33ff367a88aa83 | |
parent | 1024a871a325039ab0fafb98b11773d06d085e24 (diff) |
loopify big memcpys in asm
-rw-r--r-- | src/parseTools.js | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/parseTools.js b/src/parseTools.js index 5d8c6258..a7d089ea 100644 --- a/src/parseTools.js +++ b/src/parseTools.js @@ -1338,14 +1338,18 @@ function makeCopyValues(dest, src, num, type, modifier, align, sep) { if (num == 0) return; if (align >= possibleAlign) { // If we can unroll the loop, do so. Also do so if we must unroll it (we do not create real loops when inlined) - if (num <= UNROLL_LOOP_MAX*possibleAlign || sep == ',' || ASM_JS) { // XXX test asm performance + if (num <= UNROLL_LOOP_MAX*possibleAlign || sep == ',') { ret.push(unroll('i' + (possibleAlign*8), Math.floor(num/possibleAlign), possibleAlign)); } else { assert(sep == ';'); - ret.push('for (var $$src = ' + src + (possibleAlign > 1 ? '>>' + log2(possibleAlign) : '') + ', ' + - '$$dest = ' + dest + (possibleAlign > 1 ? '>>' + log2(possibleAlign) : '') + ', ' + - '$$stop = $$src + ' + Math.floor(num/possibleAlign) + '; $$src < $$stop; $$src++, $$dest++) {\n' + - ' HEAP' + (possibleAlign*8) + '[$$dest] = HEAP' + (possibleAlign*8) + '[$$src]\n}'); + ret.push('var $$src = ' + src + '; ' + + 'var $$dest = ' + dest + '; ' + + 'var $$stop = ($$src + ' + num + ')|0; ' + + 'while (($$src|0) < ($$stop|0)) { ' + + ' HEAP' + (possibleAlign*8) + '[' + getHeapOffset('$$dest', 'i' + (possibleAlign*8)) + '] = HEAP' + (possibleAlign*8) + '[' + getHeapOffset('$$src', 'i' + (possibleAlign*8)) + ']; ' + + ' $$src = ($$src + ' + possibleAlign + ')|0; ' + + ' $$dest = ($$dest + ' + possibleAlign + ')|0; ' + + '}'); } src = getFastValue(src, '+', Math.floor(num/possibleAlign)*possibleAlign); dest = getFastValue(dest, '+', Math.floor(num/possibleAlign)*possibleAlign); |