aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-09-21 18:08:18 -0500
committerAlon Zakai <alonzakai@gmail.com>2013-09-23 14:33:24 -0700
commit79b2ee72ba44f674a0c1f3546d2bf1576af7e9b0 (patch)
treeb430d59ebb1e9b7b35a5c7c9183992462e462731
parentb1f12d5192a10800c4694d22ef0fcc62d4b7d2b4 (diff)
relooper input is ascii, emit it to the heap more efficiently with writeAsciiToMemory1.6.1
-rw-r--r--src/preamble.js11
-rw-r--r--src/relooper/emscripten/glue.js8
-rw-r--r--tools/shared.py2
3 files changed, 16 insertions, 5 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
diff --git a/tools/shared.py b/tools/shared.py
index d605dee9..4e1a3ebf 100644
--- a/tools/shared.py
+++ b/tools/shared.py
@@ -304,7 +304,7 @@ def find_temp_directory():
# we re-check sanity when the settings are changed)
# We also re-check sanity and clear the cache when the version changes
-EMSCRIPTEN_VERSION = '1.6.0'
+EMSCRIPTEN_VERSION = '1.6.1'
def generate_sanity():
return EMSCRIPTEN_VERSION + '|' + get_llvm_target() + '|' + LLVM_ROOT