diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-09-03 15:57:31 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-09-03 15:57:31 -0700 |
commit | 6eaaebf4dd9c1dbd38dba929199cd3121b666c0f (patch) | |
tree | 2f61c2a85666b57fa3e03e47d6f6251623ec0ab9 /tools | |
parent | 1b458cf9c55c1ad4f74f1d3332d163e506baf4e7 (diff) |
add extCall_* methods in asm dlopen support, parallel to invoke in that they are able to access other modules, but do not catch exceptions
Diffstat (limited to 'tools')
-rw-r--r-- | tools/shared.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tools/shared.py b/tools/shared.py index aecf0799..b0b3985e 100644 --- a/tools/shared.py +++ b/tools/shared.py @@ -1443,6 +1443,27 @@ class JS: return ident.replace('%', '$').replace('@', '_') @staticmethod + def make_extcall(sig, named=True): + args = ','.join(['a' + str(i) for i in range(1, len(sig))]) + args = 'index' + (',' if args else '') + args + # C++ exceptions are numbers, and longjmp is a string 'longjmp' + ret = '''function%s(%s) { + %sModule["dynCall_%s"](%s); +}''' % ((' extCall_' + sig) if named else '', args, 'return ' if sig[0] != 'v' else '', sig, args) + + if Settings.DLOPEN_SUPPORT and Settings.ASSERTIONS: + # guard against cross-module stack leaks + ret = ret.replace(') {\n', ''') { + try { + var preStack = asm.stackSave(); +''').replace(';\n}', '''; + } finally { + assert(asm.stackSave() == preStack); + } +}''') + return ret + + @staticmethod def make_invoke(sig, named=True): args = ','.join(['a' + str(i) for i in range(1, len(sig))]) args = 'index' + (',' if args else '') + args |