diff options
Diffstat (limited to 'tools/shared.py')
-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 |