diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-09-21 18:08:18 -0500 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-09-23 14:33:24 -0700 |
commit | 79b2ee72ba44f674a0c1f3546d2bf1576af7e9b0 (patch) | |
tree | b430d59ebb1e9b7b35a5c7c9183992462e462731 /src | |
parent | b1f12d5192a10800c4694d22ef0fcc62d4b7d2b4 (diff) |
relooper input is ascii, emit it to the heap more efficiently with writeAsciiToMemory1.6.1
Diffstat (limited to 'src')
-rw-r--r-- | src/preamble.js | 11 | ||||
-rw-r--r-- | src/relooper/emscripten/glue.js | 8 |
2 files changed, 15 insertions, 4 deletions
diff --git a/src/preamble.js b/src/preamble.js index 8e70cb74..acff665f 100644 --- a/src/preamble.js +++ b/src/preamble.js @@ -908,6 +908,17 @@ function writeArrayToMemory(array, buffer) { } Module['writeArrayToMemory'] = writeArrayToMemory; +function writeAsciiToMemory(str, buffer, dontAddNull) { + for (var i = 0; i < str.length; i++) { +#if ASSERTIONS + assert(str.charCodeAt(i) === str.charCodeAt(i)&0xff); +#endif + {{{ makeSetValue('buffer', 'i', 'str.charCodeAt(i)', 'i8') }}} + } + if (!dontAddNull) {{{ makeSetValue('buffer', 'str.length', 0, 'i8') }}} +} +Module['writeAsciiToMemory'] = writeAsciiToMemory; + {{{ unSign }}} {{{ reSign }}} diff --git a/src/relooper/emscripten/glue.js b/src/relooper/emscripten/glue.js index f5b9e142..587cf529 100644 --- a/src/relooper/emscripten/glue.js +++ b/src/relooper/emscripten/glue.js @@ -19,10 +19,10 @@ RelooperGlue['addBlock'] = function(text, branchVar) { assert(this.r); assert(text.length+1 < TBUFFER_SIZE, 'buffer too small, increase RELOOPER_BUFFER_SIZE'); - writeStringToMemory(text, tbuffer); + writeAsciiToMemory(text, tbuffer); if (branchVar) { assert(branchVar.length+1 < VBUFFER_SIZE, 'buffer too small, increase RELOOPER_BUFFER_SIZE'); - writeStringToMemory(branchVar, vbuffer); + writeAsciiToMemory(branchVar, vbuffer); } var b = _rl_new_block(tbuffer, branchVar ? vbuffer : 0); _rl_relooper_add_block(this.r, b); @@ -32,14 +32,14 @@ assert(this.r); if (condition) { assert(condition.length+1 < TBUFFER_SIZE/2, 'buffer too small, increase RELOOPER_BUFFER_SIZE'); - writeStringToMemory(condition, tbuffer); + writeAsciiToMemory(condition, tbuffer); condition = tbuffer; } else { condition = 0; // allow undefined, null, etc. as inputs } if (code) { assert(code.length+1 < TBUFFER_SIZE/2, 'buffer too small, increase RELOOPER_BUFFER_SIZE'); - writeStringToMemory(code, tbuffer + TBUFFER_SIZE/2); + writeAsciiToMemory(code, tbuffer + TBUFFER_SIZE/2); code = tbuffer + TBUFFER_SIZE/2; } else { code = 0; // allow undefined, null, etc. as inputs |