aboutsummaryrefslogtreecommitdiff
path: root/src/modules.js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-11-28 16:21:24 -0800
committerAlon Zakai <alonzakai@gmail.com>2012-12-07 14:23:19 -0800
commit0ec22e206f7b552897dd2c303c84c70b742d0208 (patch)
tree511adfa839e3a49ddfa27c5ad1afdaae37d9d169 /src/modules.js
parent1dfc355a56d5da67bb6bcb9c821b46c62c47bb77 (diff)
only use typed function tables in asm_js mode
Diffstat (limited to 'src/modules.js')
-rw-r--r--src/modules.js15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/modules.js b/src/modules.js
index 232403e8..de84d9e4 100644
--- a/src/modules.js
+++ b/src/modules.js
@@ -251,11 +251,20 @@ var Functions = {
}
},
+ getTable: function(sig) {
+ return ASM_JS ? 'FUNCTION_TABLE_' + sig : 'FUNCTION_TABLE';
+ },
+
// Generate code for function indexing
generateIndexing: function() {
var tables = {};
+ if (ASM_JS) {
+ ['x', 'ii'].forEach(function(sig) { // add some default signatures that are used in the library
+ tables[sig] = zeros(this.nextIndex); // TODO: make them compact
+ });
+ }
for (var ident in this.indexedFunctions) {
- var sig = Functions.implementedFunctions[ident] || Functions.libraryFunctions[ident];
+ var sig = ASM_JS ? Functions.implementedFunctions[ident] || Functions.libraryFunctions[ident] : 'x';
assert(sig, ident);
if (!tables[sig]) tables[sig] = zeros(this.nextIndex); // TODO: make them compact
tables[sig][this.indexedFunctions[ident]] = ident;
@@ -274,9 +283,9 @@ var Functions = {
var indices = table.toString().replace('"', '');
if (BUILD_AS_SHARED_LIB) {
// Shared libraries reuse the parent's function table.
- ret += 'FUNCTION_TABLE.push.apply(FUNCTION_TABLE_' + t + ', [' + indices + ']);\n';
+ ret += Functions.getTable(t) + '.push.apply(' + Functions.getTable(t) + ', [' + indices + ']);\n';
} else {
- ret += 'var FUNCTION_TABLE_' + t + ' = [' + indices + '];\n';
+ ret += 'var ' + Functions.getTable(t) + ' = [' + indices + '];\n';
}
}
Functions.tables = ret;