diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-10-02 17:31:10 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-10-02 17:31:10 -0700 |
commit | e578be3b375c26c0453070cedf89c42e3ac314a8 (patch) | |
tree | f64e860b214067da86f288689092710af8a028d8 | |
parent | ec58cc4c637b6fef6f4580b92c753e745c301bbe (diff) |
align function tables in non-asm mode
-rw-r--r-- | src/modules.js | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/modules.js b/src/modules.js index d9888c24..5b7c06d5 100644 --- a/src/modules.js +++ b/src/modules.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('"', ''); |