emscripten.py: optimize check_all_implemented. (#8453)

make it more efficient and skip it entirely when possible
This commit is contained in:
waterlike86 2019-04-20 08:39:04 +08:00 коммит произвёл Alon Zakai
Родитель d54fb43e18
Коммит c67d5dea7d
1 изменённых файлов: 13 добавлений и 11 удалений

Просмотреть файл

@ -852,8 +852,19 @@ def get_all_implemented(forwarded_json, metadata):
def check_all_implemented(all_implemented, pre):
for requested in shared.Settings.ORIGINAL_EXPORTED_FUNCTIONS:
if not is_already_implemented(requested, pre, all_implemented):
# we are not checking anyway, so just skip this
if not shared.Settings.ERROR_ON_UNDEFINED_SYMBOLS and not shared.Settings.WARN_ON_UNDEFINED_SYMBOLS:
return
# the initial list of missing functions are those we expected to export, but were not implemented in compiled code
missing = list(set(shared.Settings.ORIGINAL_EXPORTED_FUNCTIONS) - set(all_implemented))
# special-case malloc, EXPORTED by default for internal use, but we bake in a
# trivial allocator and warn at runtime if used in ASSERTIONS
if '_malloc' in missing:
missing.remove('_malloc')
for requested in missing:
in_pre = ('function ' + asstr(requested)) in pre
if not in_pre:
# could be a js library func
if shared.Settings.ERROR_ON_UNDEFINED_SYMBOLS:
exit_with_error('undefined exported function: "%s"', requested)
@ -861,15 +872,6 @@ def check_all_implemented(all_implemented, pre):
logger.warning('undefined exported function: "%s"', requested)
def is_already_implemented(requested, pre, all_implemented):
is_implemented = requested in all_implemented
# special-case malloc, EXPORTED by default for internal use, but we bake in a
# trivial allocator and warn at runtime if used in ASSERTIONS
is_exception = requested == '_malloc'
in_pre = ('function ' + asstr(requested)) in pre
return is_implemented or is_exception or in_pre
def get_exported_implemented_functions(all_exported_functions, all_implemented, metadata):
funcs = set(metadata['exports'])
export_bindings = shared.Settings.EXPORT_BINDINGS