aboutsummaryrefslogtreecommitdiff
path: root/src/modules.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules.js')
-rw-r--r--src/modules.js18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/modules.js b/src/modules.js
index 9662200c..cc9ca549 100644
--- a/src/modules.js
+++ b/src/modules.js
@@ -234,7 +234,7 @@ var Types = {
preciseI64MathUsed: (PRECISE_I64_MATH == 2)
};
-var firstTableIndex = (ASM_JS ? 2*RESERVED_FUNCTION_POINTERS : 0) + 2;
+var firstTableIndex = FUNCTION_POINTER_ALIGNMENT * ((ASM_JS ? RESERVED_FUNCTION_POINTERS : 0) + 1);
var Functions = {
// All functions that will be implemented in this file. Maps id to signature
@@ -287,7 +287,7 @@ var Functions = {
ret = this.indexedFunctions[ident];
if (!ret) {
ret = this.nextIndex;
- this.nextIndex += 2; // Need to have indexes be even numbers, see |polymorph| test
+ this.nextIndex += FUNCTION_POINTER_ALIGNMENT;
this.indexedFunctions[ident] = ret;
}
ret = ret.toString();
@@ -340,7 +340,7 @@ var Functions = {
if (table[i]) {
var libName = LibraryManager.getRootIdent(table[i].substr(1));
if (libName && typeof libName == 'string') {
- table[i] = (libName.indexOf('.') < 0 ? '_' : '') + libName;
+ table[i] = (libName.indexOf('Math_') < 0 ? '_' : '') + libName;
}
}
if (ASM_JS) {
@@ -379,13 +379,11 @@ var Functions = {
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
- // 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;
- }
+ // asm function table mask must be power of two, and non-asm must be aligned
+ // 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 = ASM_JS ? (ALIASING_FUNCTION_POINTERS ? ceilPowerOfTwo(table.length) : maxTable) : ((table.length+FUNCTION_POINTER_ALIGNMENT-1)&-FUNCTION_POINTER_ALIGNMENT);
+ for (var i = table.length; i < fullSize; i++) {
+ table[i] = 0;
}
// finalize table
var indices = table.toString().replace('"', '');