aboutsummaryrefslogtreecommitdiff
path: root/src/modules.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules.js')
-rw-r--r--src/modules.js32
1 files changed, 9 insertions, 23 deletions
diff --git a/src/modules.js b/src/modules.js
index 1029b233..76e5db11 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
@@ -285,11 +285,7 @@ var Functions = {
} else {
if (!singlePhase) return 'NO_INDEX'; // Should not index functions in post
ret = this.indexedFunctions[ident];
- if (!ret) {
- ret = this.nextIndex;
- this.nextIndex += 2; // Need to have indexes be even numbers, see |polymorph| test
- this.indexedFunctions[ident] = ret;
- }
+ assert(ret);
ret = ret.toString();
}
if (SIDE_MODULE && sig) { // sig can be undefined for the GL library functions
@@ -340,7 +336,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 +369,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 +408,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]))));
}