aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-02-26 19:47:21 -0500
committerAlon Zakai <alonzakai@gmail.com>2013-02-26 19:47:21 -0500
commit4e78fcaed0b84a7b5414b659d88d818d0b2f837e (patch)
tree591622b5a6f48dfbfa02b528af4a7f37b3a488ea
parentbafdc889fcfcab5715e8dae5d26c3d5ff3160498 (diff)
emit function table names in SAFE_DYNCALL mode
-rw-r--r--src/jsifier.js2
-rw-r--r--src/modules.js3
2 files changed, 4 insertions, 1 deletions
diff --git a/src/jsifier.js b/src/jsifier.js
index 0e82a547..cb234061 100644
--- a/src/jsifier.js
+++ b/src/jsifier.js
@@ -1403,7 +1403,7 @@ function JSify(data, functionsOnly, givenFunctions) {
callIdent = '(' + callIdent + ')&{{{ FTM_' + sig + ' }}}'; // the function table mask is set in emscripten.py
} else if (SAFE_DYNCALLS) {
assert(!ASM_JS, 'cannot emit safe dyncalls in asm');
- callIdent = '(tempInt=' + callIdent + ',tempInt < 0 || tempInt >= FUNCTION_TABLE.length-1 || !FUNCTION_TABLE[tempInt] ? abort("dyncall error: ' + sig + '") : tempInt)';
+ callIdent = '(tempInt=' + callIdent + ',tempInt < 0 || tempInt >= FUNCTION_TABLE.length-1 || !FUNCTION_TABLE[tempInt] ? abort("dyncall error: ' + sig + ' " + FUNCTION_TABLE_NAMES[tempInt]) : tempInt)';
}
callIdent = Functions.getTable(sig) + '[' + callIdent + ']';
}
diff --git a/src/modules.js b/src/modules.js
index 501ff22e..712d8a78 100644
--- a/src/modules.js
+++ b/src/modules.js
@@ -344,6 +344,9 @@ var Functions = {
tables[t] = Functions.getTable(t) + '.push.apply(' + Functions.getTable(t) + ', [' + indices + ']);\n';
} else {
tables[t] = 'var ' + Functions.getTable(t) + ' = [' + indices + '];\n';
+ if (SAFE_DYNCALLS) {
+ tables[t] += 'var FUNCTION_TABLE_NAMES = ' + JSON.stringify(table).replace(/\n/g, '').replace(/,0/g, ',0\n') + ';\n';
+ }
}
}
if (!generated && !ASM_JS) {