diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-04-23 10:54:59 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-04-23 10:54:59 -0700 |
commit | 23ed21d54e73db3597b64b6b06ab09194717c1c4 (patch) | |
tree | 337d4579d80cc9dba5486de97804944f283c5193 | |
parent | ade7864b5d424b961313773b4487c0798e0bebed (diff) |
clear errors on calling dead functions
-rw-r--r-- | src/compiler.js | 2 | ||||
-rw-r--r-- | src/jsifier.js | 4 | ||||
-rw-r--r-- | src/parseTools.js | 9 | ||||
-rwxr-xr-x | tests/runner.py | 2 |
4 files changed, 12 insertions, 5 deletions
diff --git a/src/compiler.js b/src/compiler.js index 9c19aeb0..d74ff7cb 100644 --- a/src/compiler.js +++ b/src/compiler.js @@ -168,6 +168,8 @@ if (SAFE_HEAP >= 2) { EXPORTED_FUNCTIONS = set(EXPORTED_FUNCTIONS); EXPORTED_GLOBALS = set(EXPORTED_GLOBALS); EXCEPTION_CATCHING_WHITELIST = set(EXCEPTION_CATCHING_WHITELIST); + +if (DEAD_FUNCTIONS.length && ASSERTIONS) DEFAULT_LIBRARY_FUNCS_TO_INCLUDE.push('putchar'); // for debug output DEAD_FUNCTIONS = numberedSet(DEAD_FUNCTIONS); RUNTIME_DEBUG = LIBRARY_DEBUG || GL_DEBUG; diff --git a/src/jsifier.js b/src/jsifier.js index 9678a56d..6d8def39 100644 --- a/src/jsifier.js +++ b/src/jsifier.js @@ -1441,6 +1441,10 @@ function JSify(data, functionsOnly, givenFunctions) { if (callIdent in DEAD_FUNCTIONS) { var ret = 'abort(' + DEAD_FUNCTIONS[callIdent] + ')'; if (ASM_JS) ret = asmCoercion(ret, returnType); + if (ASSERTIONS) { + assert(DEFAULT_LIBRARY_FUNCS_TO_INCLUDE.indexOf('putchar') >= 0, 'need putchar for DEAD_FUNCTIONS + ASSERTIONS output'); + ret = '(' + makePrintChars('dead:' + callIdent, ',') + ',' + ret + ')'; + } return ret; } diff --git a/src/parseTools.js b/src/parseTools.js index fe21dfd5..8347a929 100644 --- a/src/parseTools.js +++ b/src/parseTools.js @@ -2363,13 +2363,14 @@ function getTypeFromHeap(suffix) { } } -// Generates code that prints without printf(), but just putchar (so can be directly inline) -function makePrintChars(s) { +// Generates code that prints without printf(), but just putchar (so can be directly inline in asm.js) +function makePrintChars(s, sep) { + sep = sep || ';'; var ret = ''; for (var i = 0; i < s.length; i++) { - ret += '_putchar(' + s.charCodeAt(i) + ');'; + ret += '_putchar(' + s.charCodeAt(i) + ')' + sep; } - ret += '_putchar(10);'; + ret += '_putchar(10)'; return ret; } diff --git a/tests/runner.py b/tests/runner.py index 33a2ef67..bd6fd838 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -8070,7 +8070,7 @@ def process(filename): Settings.DEAD_FUNCTIONS = [] # Run the same code with argc that uses the dead function, see abort - test(('abort', 'is not a function'), args=['a', 'b'], no_build=True) + test(('dead:_unused' if Settings.ASSERTIONS else 'abort', 'is not a function'), args=['a', 'b'], no_build=True) # Normal stuff run_all('normal', r''' |