aboutsummaryrefslogtreecommitdiff
path: root/src/modules.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules.js')
-rw-r--r--src/modules.js28
1 files changed, 9 insertions, 19 deletions
diff --git a/src/modules.js b/src/modules.js
index 1029b233..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) {
@@ -373,27 +373,17 @@ var Functions = {
}
}
}
- if (table.length > 20) {
- // add some newlines in the table, for readability
- var j = 10;
- while (j+10 < table.length) {
- table[j] += '\n';
- 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
- // 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('"', '');
@@ -422,7 +412,7 @@ var LibraryManager = {
load: function() {
if (this.library) return;
- var libraries = ['library.js', 'library_path.js', 'library_fs.js', 'library_memfs.js', 'library_sockfs.js', 'library_tty.js', 'library_browser.js', 'library_sdl.js', 'library_gl.js', 'library_glut.js', 'library_xlib.js', 'library_egl.js', 'library_gc.js', 'library_jansson.js', 'library_openal.js', 'library_glfw.js'].concat(additionalLibraries);
+ var libraries = ['library.js', 'library_path.js', 'library_fs.js', 'library_idbfs.js', 'library_memfs.js', 'library_nodefs.js', 'library_sockfs.js', 'library_tty.js', 'library_browser.js', 'library_sdl.js', 'library_gl.js', 'library_glut.js', 'library_xlib.js', 'library_egl.js', 'library_gc.js', 'library_jansson.js', 'library_openal.js', 'library_glfw.js'].concat(additionalLibraries);
for (var i = 0; i < libraries.length; i++) {
eval(processMacros(preprocess(read(libraries[i]))));
}