diff options
author | Alon Zakai <alonzakai@gmail.com> | 2014-06-09 12:51:05 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2014-06-09 14:07:38 -0700 |
commit | 3781d44edc506c16c811bf921d61dcc8563e920d (patch) | |
tree | 875c60cb0e2d663972aa06e251964c2b851ef9b6 | |
parent | 3cd726cc454bb50f3077d89a2f4cddf6a14632f2 (diff) |
apply library synonyms using wrapper functions, to avoid needing hacks in the compiler ; 1.19.21.19.2
-rw-r--r-- | emscripten-version.txt | 2 | ||||
-rw-r--r-- | src/modules.js | 25 |
2 files changed, 26 insertions, 1 deletions
diff --git a/emscripten-version.txt b/emscripten-version.txt index de59d0c6..5f079d01 100644 --- a/emscripten-version.txt +++ b/emscripten-version.txt @@ -1,2 +1,2 @@ -1.19.1 +1.19.2 diff --git a/src/modules.js b/src/modules.js index fd5c23cd..56f4c827 100644 --- a/src/modules.js +++ b/src/modules.js @@ -443,6 +443,31 @@ var LibraryManager = { } } + // apply synonyms. these are typically not speed-sensitive, and doing it this way makes it possible to not include hacks in the compiler + // (and makes it simpler to switch between SDL verisons, fastcomp and non-fastcomp, etc.). + var lib = LibraryManager.library; + libloop: for (var x in lib) { + if (x.lastIndexOf('__') > 0) continue; // ignore __deps, __* + if (lib[x + '__asm']) continue; // ignore asm library functions, those need to be fully optimized + if (typeof lib[x] === 'string') { + var target = x; + while (typeof lib[target] === 'string') { + if (lib[target].indexOf('(') >= 0) continue libloop; + target = lib[target]; + } + if (typeof lib[target] === 'undefined' || typeof lib[target] === 'function') { + if (target.indexOf('Math_') < 0) { + lib[x] = new Function('return _' + target + '.apply(null, arguments)'); + if (!lib[x + '__deps']) lib[x + '__deps'] = []; + lib[x + '__deps'].push(target); + } else { + lib[x] = new Function('return ' + target + '.apply(null, arguments)'); + } + continue; + } + } + } + /* // export code for CallHandlers.h printErr('============================'); |