diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-03-15 14:34:13 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-03-15 14:34:13 -0700 |
commit | 27d1a249622d33ab8aff2814d13569507336873b (patch) | |
tree | c568136b2cf95d897d128b362720602a3b401244 | |
parent | fefd5caa31c4d701df7bf5c1bc48028e212f4694 (diff) |
add option to disable utf support, and test that in asm2g
-rw-r--r-- | src/preamble.js | 8 | ||||
-rw-r--r-- | src/settings.js | 17 | ||||
-rwxr-xr-x | tests/runner.py | 4 |
3 files changed, 21 insertions, 8 deletions
diff --git a/src/preamble.js b/src/preamble.js index 6c0b0e93..6f3a969c 100644 --- a/src/preamble.js +++ b/src/preamble.js @@ -503,6 +503,7 @@ 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 = typeof(length) == "undefined"; var ret = ""; @@ -519,6 +520,13 @@ function Pointer_stringify(ptr, /* optional */ length) { 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 101c403c..36f53c3c 100644 --- a/src/settings.js +++ b/src/settings.js @@ -171,6 +171,8 @@ 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), @@ -230,13 +232,14 @@ var EXPORTED_FUNCTIONS = ['_main']; // Functions that are explicitly exported. T // the generated code even after running closure compiler (on "Module"). // Note the necessary prefix of "_". -var DEFAULT_LIBRARY_FUNCS_TO_INCLUDE = ['memcpy', 'memset', 'malloc', 'free', '$Browser']; // JS library functions (C functions implemented in JS) - // that we include by default. If you want to make sure - // something is included by the JS compiler, add it here. - // For example, if you do not use some emscripten_* - // C API call from C, but you want to call it from JS, - // add it here (and in EXPORTED FUNCTIONS with prefix - // "_", for closure). +// JS library functions (C functions implemented in JS) +// that we include by default. If you want to make sure +// something is included by the JS compiler, add it here. +// For example, if you do not use some emscripten_* +// C API call from C, but you want to call it from JS, +// add it here (and in EXPORTED FUNCTIONS with prefix +// "_", for closure). +var DEFAULT_LIBRARY_FUNCS_TO_INCLUDE = ['memcpy', 'memset', 'malloc', 'free', 'strlen', '$Browser']; var LIBRARY_DEPS_TO_AUTOEXPORT = ['memcpy']; // This list is also used to determine // auto-exporting of library dependencies (i.e., functions that diff --git a/tests/runner.py b/tests/runner.py index 2ffc55ec..7f46dbfb 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -6077,6 +6077,8 @@ 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'] @@ -8751,7 +8753,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"])') + exec('asm2g = make_run("asm2g", compiler=CLANG, emcc_args=["-O2", "-s", "ASM_JS=1", "-g", "-s", "ASSERTIONS=1", "-s", "UTF_STRING_SUPPORT=0"])') # Make custom runs with various options for compiler, quantum, embetter, typed_arrays, llvm_opts in [ |