aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xemcc1
-rw-r--r--src/preamble.js37
-rw-r--r--src/settings.js2
-rwxr-xr-xtests/runner.py4
-rw-r--r--tools/shared.py1
5 files changed, 22 insertions, 23 deletions
diff --git a/emcc b/emcc
index 677431b5..488f0788 100755
--- a/emcc
+++ b/emcc
@@ -191,7 +191,6 @@ Options that are modified or new in %s include:
-s DOUBLE_MODE=0
-s PRECISE_I64_MATH=0
- -s UTF_STRING_SUPPORT=0
--closure 1
--llvm-lto 1
diff --git a/src/preamble.js b/src/preamble.js
index 79e225e8..13af4326 100644
--- a/src/preamble.js
+++ b/src/preamble.js
@@ -503,30 +503,35 @@ function allocate(slab, types, allocator, ptr) {
Module['allocate'] = allocate;
function Pointer_stringify(ptr, /* optional */ length) {
-#if UTF_STRING_SUPPORT
- var utf8 = new Runtime.UTF8Processor();
- var nullTerminated = !length;
- var ret = "";
- var i = 0;
+ // Find the length, and check for UTF while doing so
+ var hasUtf = false;
var t;
+ var i = 0;
while (1) {
+ t = {{{ makeGetValue('ptr', 'i', 'i8', 0, 1) }}};
+ if (t >= 128) hasUtf = true;
+ else if (t == 0 && !length) break;
+ i++;
+ if (length && i == length) break;
+ }
+ if (!length) length = i;
+
+#if USE_TYPED_ARRAYS == 2
+ if (!hasUtf) {
+ return String.fromCharCode.apply(String, HEAPU8.subarray(ptr, ptr + length));
+ }
+#endif
+
+ var utf8 = new Runtime.UTF8Processor();
+ var ret = '';
+ for (i = 0; i < length; i++) {
#if ASSERTIONS
- assert(i < TOTAL_MEMORY);
+ assert(ptr + i < TOTAL_MEMORY);
#endif
t = {{{ makeGetValue('ptr', 'i', 'i8', 0, 1) }}};
- if (nullTerminated && t == 0) break;
ret += utf8.processCChar(t);
- i += 1;
- if (!nullTerminated && i == length) break;
}
return ret;
-#else
-#if USE_TYPED_ARRAYS == 2
- return String.fromCharCode.apply(String, HEAPU8.subarray(ptr, ptr + (length || _strlen(ptr))));
-#else
- throw 'unsupported combination';
-#endif
-#endif
}
Module['Pointer_stringify'] = Pointer_stringify;
diff --git a/src/settings.js b/src/settings.js
index c7ed7cd2..97963ac5 100644
--- a/src/settings.js
+++ b/src/settings.js
@@ -173,8 +173,6 @@ var GL_UNSAFE_OPTS = 1; // Enables some potentially-unsafe optimizations in GL e
var FULL_ES2 = 0; // Forces support for all GLES2 features, not just the WebGL-friendly subset.
var FORCE_GL_EMULATION = 0; // Forces inclusion of full GL emulation code.
-var UTF_STRING_SUPPORT = 1; // Perform utf-8 conversion between C and JS strings (adds overhead in such conversions)
-
var DISABLE_EXCEPTION_CATCHING = 0; // Disables generating code to actually catch exceptions. If the code you
// are compiling does not actually rely on catching exceptions (but the
// compiler generates code for it, maybe because of stdlibc++ stuff),
diff --git a/tests/runner.py b/tests/runner.py
index 6ba0bcd7..c1a74e9e 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -6133,8 +6133,6 @@ def process(filename):
self.do_run(src, re.sub('(^|\n)\s+', '\\1', expected), post_build=add_pre_run_and_checks)
def test_utf(self):
- if self.emcc_args and 'UTF_STRING_SUPPORT=0' in self.emcc_args: return self.skip('need utf support')
-
self.banned_js_engines = [SPIDERMONKEY_ENGINE] # only node handles utf well
Settings.EXPORTED_FUNCTIONS = ['_main', '_malloc']
@@ -8815,7 +8813,7 @@ TT = %s
# asm.js
exec('asm2 = make_run("asm2", compiler=CLANG, emcc_args=["-O2", "-s", "ASM_JS=1"])')
- exec('asm2g = make_run("asm2g", compiler=CLANG, emcc_args=["-O2", "-s", "ASM_JS=1", "-g", "-s", "ASSERTIONS=1", "-s", "UTF_STRING_SUPPORT=0"])')
+ exec('asm2g = make_run("asm2g", compiler=CLANG, emcc_args=["-O2", "-s", "ASM_JS=1", "-g", "-s", "ASSERTIONS=1"])')
# Make custom runs with various options
for compiler, quantum, embetter, typed_arrays, llvm_opts in [
diff --git a/tools/shared.py b/tools/shared.py
index 7fc0421a..81a8e053 100644
--- a/tools/shared.py
+++ b/tools/shared.py
@@ -555,7 +555,6 @@ class Settings:
# Aside from these, -O3 also runs closure compiler and llvm lto
Settings.DOUBLE_MODE = 0
Settings.PRECISE_I64_MATH = 0
- Settings.UTF_STRING_SUPPORT = 0
if noisy: print >> sys.stderr, 'Warning: Applying some potentially unsafe optimizations! (Use -O2 if this fails.)'
global Settings