aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-08-29 11:30:11 -0700
committerAlon Zakai <alonzakai@gmail.com>2013-09-03 14:41:30 -0700
commite33179a36b1d6867e0a5c59a8e5a9e04b1b8459f (patch)
tree0fce39c7f1c35638ca07cc21f0d4eb2579bef650
parent02c15ea091feacdd0c40a291346a3e1d7cad7e3b (diff)
fix asm validation of side modules
-rwxr-xr-xemscripten.py7
-rw-r--r--tests/test_core.py5
-rw-r--r--tools/jsrun.py1
3 files changed, 11 insertions, 2 deletions
diff --git a/emscripten.py b/emscripten.py
index 0a13d7ad..4940dc3b 100755
--- a/emscripten.py
+++ b/emscripten.py
@@ -444,6 +444,11 @@ def emscript(infile, settings, outfile, libraries=[], compiler_engine=None,
forwarded_json['Functions']['libraryFunctions'].get('llvm_ctlz_i32'):
basic_vars += ['cttz_i8', 'ctlz_i8']
+ if settings.get('DLOPEN_SUPPORT'):
+ for sig in last_forwarded_json['Functions']['tables'].iterkeys():
+ basic_vars.append('F_BASE_%s' % sig)
+ asm_setup += ' var F_BASE_%s = %s;\n' % (sig, 'FUNCTION_TABLE_OFFSET' if settings.get('SIDE_MODULE') else '0') + '\n'
+
asm_runtime_funcs = ['stackAlloc', 'stackSave', 'stackRestore', 'setThrew'] + ['setTempRet%d' % i for i in range(10)]
# function tables
def asm_coerce(value, sig):
@@ -635,8 +640,6 @@ Runtime.stackRestore = function(top) { asm['stackRestore'](top) };
Runtime.registerFunctions(asm, %(max_mask)d+1, %(sigs)s, Module);
Module.SYMBOL_TABLE = SYMBOL_TABLE;
''' % { 'max_mask': max_mask, 'sigs': str(map(str, last_forwarded_json['Functions']['tables'].keys())) })
- for sig in last_forwarded_json['Functions']['tables'].iterkeys():
- funcs_js.append(' var F_BASE_%s = %s;\n' % (sig, 'FUNCTION_TABLE_OFFSET' if settings.get('SIDE_MODULE') else '0'))
else:
function_tables_defs = '\n'.join([table for table in last_forwarded_json['Functions']['tables'].itervalues()])
diff --git a/tests/test_core.py b/tests/test_core.py
index ce976975..285ba08e 100644
--- a/tests/test_core.py
+++ b/tests/test_core.py
@@ -5754,6 +5754,11 @@ def process(filename):
output_nicerizer=lambda x, err: x.replace('\n', '*'),
post_build=add_pre_run_and_checks)
+ if Settings.ASM_JS and os.path.exists(SPIDERMONKEY_ENGINE[0]):
+ out = run_js('liblib.so', engine=SPIDERMONKEY_ENGINE, full_output=True, stderr=STDOUT)
+ assert 'asm' in out
+ self.validate_asmjs(out)
+
def test_dlfcn_data_and_fptr(self):
if Settings.ASM_JS: return self.skip('this is not a valid case - libraries should not be able to access their parents globals willy nilly')
if not self.can_dlfcn(): return
diff --git a/tools/jsrun.py b/tools/jsrun.py
index 91038f6e..6f77ce51 100644
--- a/tools/jsrun.py
+++ b/tools/jsrun.py
@@ -10,6 +10,7 @@ def timeout_run(proc, timeout, note='unnamed process', full_output=False):
proc.kill() # XXX bug: killing emscripten.py does not kill it's child process!
raise Exception("Timed out: " + note)
out = proc.communicate()
+ out = map(lambda o: '' if o is None else o, out)
return '\n'.join(out) if full_output else out[0]
def run_js(filename, engine=None, args=[], check_timeout=False, stdin=None, stdout=PIPE, stderr=None, cwd=None, full_output=False):