aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xemscripten.py15
-rw-r--r--src/jsifier.js1
-rw-r--r--src/modules.js5
3 files changed, 7 insertions, 14 deletions
diff --git a/emscripten.py b/emscripten.py
index b99c0c09..df51d840 100755
--- a/emscripten.py
+++ b/emscripten.py
@@ -288,6 +288,8 @@ def emscript(infile, settings, outfile, libraries=[], compiler_engine=None,
exported_implemented_functions.add(key)
for key, value in curr_forwarded_json['Functions']['unimplementedFunctions'].iteritems():
forwarded_json['Functions']['unimplementedFunctions'][key] = value
+ for key, value in curr_forwarded_json['Functions']['neededTables'].iteritems():
+ forwarded_json['Functions']['neededTables'][key] = value
if settings.get('ASM_JS'):
parts = pre.split('// ASM_LIBRARY FUNCTIONS\n')
@@ -322,11 +324,6 @@ def emscript(infile, settings, outfile, libraries=[], compiler_engine=None,
forwarded_json['Functions']['indexedFunctions'][indexed] = curr # make sure not to modify this python object later - we use it in indexize
if alias: i = max(table_counters.values())
forwarded_json['Functions']['nextIndex'] = i # post phase can continue to add, in getIndex
- function_table_size = forwarded_json['Functions']['nextIndex']
- i = 1
- while i < function_table_size:
- i *= 2
- function_table_size = i
def split_32(x):
x = int(x)
@@ -383,14 +380,6 @@ def emscript(infile, settings, outfile, libraries=[], compiler_engine=None,
pre_tables = last_forwarded_json['Functions']['tables']['pre']
del last_forwarded_json['Functions']['tables']['pre']
- # Find function table calls without function tables generated for them
- for funcs_js_item in funcs_js:
- for use in set(re.findall(r'{{{ FTM_[\w\d_$]+ }}}', funcs_js_item)):
- sig = use[8:len(use)-4]
- if sig not in last_forwarded_json['Functions']['tables']:
- if DEBUG: print >> sys.stderr, 'add empty function table', sig
- last_forwarded_json['Functions']['tables'][sig] = 'var FUNCTION_TABLE_' + sig + ' = [' + ','.join(['0']*function_table_size) + '];\n'
-
def make_table(sig, raw):
i = Counter.i
Counter.i += 1
diff --git a/src/jsifier.js b/src/jsifier.js
index 8270b443..3f52337f 100644
--- a/src/jsifier.js
+++ b/src/jsifier.js
@@ -1463,6 +1463,7 @@ function JSify(data, functionsOnly, givenFunctions) {
if (!byPointerForced && !funcData.setjmpTable) {
// normal asm function pointer call
callIdent = '(' + callIdent + ')&{{{ FTM_' + sig + ' }}}'; // the function table mask is set in emscripten.py
+ Functions.neededTables[sig] = 1;
} else {
// This is a call through an invoke_*, either a forced one, or a setjmp-required one
// note: no need to update argsTypes at this point
diff --git a/src/modules.js b/src/modules.js
index c5c0db88..bd453add 100644
--- a/src/modules.js
+++ b/src/modules.js
@@ -237,6 +237,8 @@ var Functions = {
indexedFunctions: {},
nextIndex: (ASM_JS ? 2*RESERVED_FUNCTION_POINTERS : 0) + 2, // Start at a non-0 (even, see below) value
+ neededTables: set('v', 'vi', 'ii', 'iii'), // signatures that appeared (initialized with library stuff
+ // we always use), and we will need a function table for
blockAddresses: {}, // maps functions to a map of block labels to label ids
@@ -286,7 +288,7 @@ var Functions = {
}
var tables = { pre: '' };
if (ASM_JS) {
- ['v', 'vi', 'ii', 'iii'].forEach(function(sig) { // add some default signatures that are used in the library
+ keys(Functions.neededTables).forEach(function(sig) { // add some default signatures that are used in the library
tables[sig] = emptyTable(sig); // TODO: make them compact
});
}
@@ -429,6 +431,7 @@ var PassManager = {
indexedFunctions: Functions.indexedFunctions,
implementedFunctions: ASM_JS ? Functions.implementedFunctions : [],
unimplementedFunctions: Functions.unimplementedFunctions,
+ neededTables: Functions.neededTables
}
}));
} else if (phase == 'post') {