aboutsummaryrefslogtreecommitdiff
path: root/src/modules.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules.js')
-rw-r--r--src/modules.js11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/modules.js b/src/modules.js
index 8e029b27..e4093078 100644
--- a/src/modules.js
+++ b/src/modules.js
@@ -301,6 +301,7 @@ var Functions = {
}
var generated = false;
var wrapped = {};
+ var maxTable = 0;
for (var t in tables) {
if (t == 'pre') continue;
generated = true;
@@ -355,13 +356,21 @@ var Functions = {
j += 10;
}
}
+ maxTable = Math.max(maxTable, table.length);
+ }
+ if (ASM_JS) maxTable = ceilPowerOfTwo(maxTable);
+ for (var t in tables) {
+ if (t == 'pre') continue;
+ var table = tables[t];
if (ASM_JS) {
// asm function table mask must be power of two
- var fullSize = ceilPowerOfTwo(table.length);
+ // if nonaliasing, then standardize function table size, to avoid aliasing pointers through the &M mask (in a small table using a big index)
+ var fullSize = ALIASING_FUNCTION_POINTERS ? ceilPowerOfTwo(table.length) : maxTable;
for (var i = table.length; i < fullSize; i++) {
table[i] = 0;
}
}
+ // finalize table
var indices = table.toString().replace('"', '');
if (BUILD_AS_SHARED_LIB) {
// Shared libraries reuse the parent's function table.