From 26193a9ba08f456adafa0646ce655164549d14ca Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Wed, 24 Jul 2019 14:21:58 -0700 Subject: [PATCH 1/5] Remove the deprecated Asyncify from fastcomp, now that we have a stable Asyncify implementation in the wasm backend. --- emcc.py | 4 ++++ emscripten.py | 22 ---------------------- site/source/docs/porting/asyncify.rst | 2 +- tests/test_browser.py | 2 -- tests/test_core.py | 11 ++++------- 5 files changed, 9 insertions(+), 32 deletions(-) diff --git a/emcc.py b/emcc.py index 70ad55c9d597e..189a91a3a7262 100755 --- a/emcc.py +++ b/emcc.py @@ -1220,6 +1220,10 @@ def check(input_file): shared.Settings.ERROR_ON_UNDEFINED_SYMBOLS = 0 shared.Settings.WARN_ON_UNDEFINED_SYMBOLS = 0 + if shared.Settings.ASYNCIFY: + if not shared.Settings.WASM_BACKEND: + exit_with_error('ASYNCIFY has been removed from fastcomp. There is a new implementation which can be used in the upstream wasm backend.') + if shared.Settings.EMTERPRETIFY: shared.Settings.FINALIZE_ASM_JS = 0 shared.Settings.SIMPLIFY_IFS = 0 # this is just harmful for emterpreting diff --git a/emscripten.py b/emscripten.py index a1080a911da10..ec106751878d6 100644 --- a/emscripten.py +++ b/emscripten.py @@ -589,10 +589,6 @@ def create_backend_cmd(infile, temp_js): args += ['-enable-emscripten-cpp-exceptions'] if shared.Settings.DISABLE_EXCEPTION_CATCHING == 2: args += ['-emscripten-cpp-exceptions-whitelist=' + ','.join(shared.Settings.EXCEPTION_CATCHING_WHITELIST or ['fake'])] - if shared.Settings.ASYNCIFY: - args += ['-emscripten-asyncify'] - args += ['-emscripten-asyncify-functions=' + ','.join(shared.Settings.ASYNCIFY_FUNCTIONS)] - args += ['-emscripten-asyncify-whitelist=' + ','.join(shared.Settings.ASYNCIFY_WHITELIST)] if not shared.Settings.EXIT_RUNTIME: args += ['-emscripten-no-exit-runtime'] if shared.Settings.WORKAROUND_IOS_9_RIGHT_SHIFT_BUG: @@ -917,8 +913,6 @@ def get_exported_implemented_functions(all_exported_functions, all_implemented, funcs += ['emterpret'] if shared.Settings.EMTERPRETIFY_ASYNC: funcs += ['setAsyncState', 'emtStackSave', 'emtStackRestore', 'getEmtStackMax', 'setEmtStackMax'] - if shared.Settings.ASYNCIFY and need_asyncify(funcs): - funcs += ['setAsync'] return sorted(set(funcs)) @@ -1487,10 +1481,6 @@ def make_simd_types(metadata): } -def need_asyncify(exported_implemented_functions): - return '_emscripten_alloc_async_context' in exported_implemented_functions - - def asm_safe_heap(): """optimized safe heap in asm, when we can""" return shared.Settings.SAFE_HEAP and not shared.Settings.SAFE_HEAP_LOG and not shared.Settings.RELOCATABLE @@ -1610,11 +1600,6 @@ def create_basic_vars(exported_implemented_functions, forwarded_json, metadata): # wasm side modules have a specific convention for these basic_vars += ['__memory_base', '__table_base'] - # See if we need ASYNCIFY functions - # We might not need them even if ASYNCIFY is enabled - if need_asyncify(exported_implemented_functions): - basic_vars += ['___async', '___async_unwind', '___async_retval', '___async_cur_frame'] - if shared.Settings.EMTERPRETIFY: basic_vars += ['EMTSTACKTOP', 'EMT_STACK_MAX', 'eb'] @@ -1883,13 +1868,6 @@ def create_runtime_funcs_asmjs(exports): # MINIMAL_RUNTIME moves stack functions to library. funcs = [] - if need_asyncify(exports): - funcs.append(''' -function setAsync() { - ___async = 1; -} -''') - if shared.Settings.EMTERPRETIFY: funcs.append(''' function emterpret(pc) { // this will be replaced when the emterpreter code is generated; adding it here allows validation until then diff --git a/site/source/docs/porting/asyncify.rst b/site/source/docs/porting/asyncify.rst index f572c3c19b65a..d46c68411dfcf 100644 --- a/site/source/docs/porting/asyncify.rst +++ b/site/source/docs/porting/asyncify.rst @@ -23,7 +23,7 @@ for general background and details of how it works internally. The following expands on the Emscripten examples from that post. .. note:: This post talks about Asyncify using the new LLVM wasm backend. - There is also an older Asyncify implementation for the old fastcomp + There was an older Asyncify implementation for the old fastcomp backend. The two algorithms and implementations are entirely separate, so if you are using fastcomp, these docs may not be accurate - you should upgrade to the wasm backend and new Asyncify! diff --git a/tests/test_browser.py b/tests/test_browser.py index b1ebcb6ebf38d..b1bf04af917c6 100644 --- a/tests/test_browser.py +++ b/tests/test_browser.py @@ -2672,8 +2672,6 @@ def test_wget(self): self.btest(path_from_root('tests', 'test_wget.c'), expected='1', args=['-s', 'ASYNCIFY=1', '-s', 'EMTERPRETIFY=1']) print('emterpreter by itself') self.btest(path_from_root('tests', 'test_wget.c'), expected='1', args=['-s', 'EMTERPRETIFY=1', '-s', 'EMTERPRETIFY_ASYNC=1']) - else: - self.btest(path_from_root('tests', 'test_wget.c'), expected='1', args=['-s', 'ASYNCIFY=1']) def test_wget_data(self): create_test_file('test.txt', 'emscripten') diff --git a/tests/test_core.py b/tests/test_core.py index ddb7cbcadc293..e7c3472a2f7cb 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -7169,13 +7169,8 @@ def test_async(self, emterpretify=False): if self.is_wasm_backend(): self.set_setting('ASYNCIFY', 1) else: - if not emterpretify: - if self.is_emterpreter(): - self.skipTest("don't test both emterpretify and asyncify at once") - self.set_setting('ASYNCIFY', 1) - else: - self.set_setting('EMTERPRETIFY', 1) - self.set_setting('EMTERPRETIFY_ASYNC', 1) + self.set_setting('EMTERPRETIFY', 1) + self.set_setting('EMTERPRETIFY_ASYNC', 1) src = r''' #include @@ -7474,10 +7469,12 @@ def do_test_coroutine(self, additional_settings): self.do_run(src, '*leaf-0-100-1-101-1-102-2-103-3-104-5-105-8-106-13-107-21-108-34-109-*') @no_wasm_backend('ASYNCIFY coroutines are not yet supported in the LLVM wasm backend') + @no_fastcomp('ASYNCIFY has been removed from fastcomp') def test_coroutine_asyncify(self): self.do_test_coroutine({'ASYNCIFY': 1}) @no_wasm_backend('ASYNCIFY is not supported in the LLVM wasm backend') + @no_fastcomp('ASYNCIFY has been removed from fastcomp') def test_asyncify_unused(self): # test a program not using asyncify, but the pref is set self.set_setting('ASYNCIFY', 1) From a0bc3fe2b1d054f086bbfc9fb0ca32a7d6bd66e4 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Wed, 24 Jul 2019 14:51:27 -0700 Subject: [PATCH 2/5] fix test --- tests/test_core.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/test_core.py b/tests/test_core.py index e7c3472a2f7cb..dd9c77a0e1027 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -7168,9 +7168,11 @@ def test_async(self, emterpretify=False): if self.is_wasm_backend(): self.set_setting('ASYNCIFY', 1) - else: + elif emterpretify: self.set_setting('EMTERPRETIFY', 1) self.set_setting('EMTERPRETIFY_ASYNC', 1) + else: + self.skipTest('fastcomp Asyncify was removed') src = r''' #include From df0d8793a7e36dbffd13288f9976efbdd31e6aba Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Wed, 24 Jul 2019 15:46:05 -0700 Subject: [PATCH 3/5] fix --- tests/test_browser.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test_browser.py b/tests/test_browser.py index b1bf04af917c6..c15f6c4454598 100644 --- a/tests/test_browser.py +++ b/tests/test_browser.py @@ -2667,11 +2667,12 @@ def test_codemods(self): def test_wget(self): create_test_file('test.txt', 'emscripten') if not self.is_wasm_backend(): - self.btest(path_from_root('tests', 'test_wget.c'), expected='1', args=['-s', 'ASYNCIFY=1']) print('asyncify+emterpreter') self.btest(path_from_root('tests', 'test_wget.c'), expected='1', args=['-s', 'ASYNCIFY=1', '-s', 'EMTERPRETIFY=1']) print('emterpreter by itself') self.btest(path_from_root('tests', 'test_wget.c'), expected='1', args=['-s', 'EMTERPRETIFY=1', '-s', 'EMTERPRETIFY_ASYNC=1']) + else: + self.btest(path_from_root('tests', 'test_wget.c'), expected='1', args=['-s', 'ASYNCIFY=1']) def test_wget_data(self): create_test_file('test.txt', 'emscripten') From 23d5be1e9008a8f94f18ac55a8432b3d40a22abe Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Wed, 24 Jul 2019 15:48:22 -0700 Subject: [PATCH 4/5] fix --- tests/test_browser.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/tests/test_browser.py b/tests/test_browser.py index c15f6c4454598..680f2ab369e4e 100644 --- a/tests/test_browser.py +++ b/tests/test_browser.py @@ -2666,13 +2666,7 @@ def test_codemods(self): def test_wget(self): create_test_file('test.txt', 'emscripten') - if not self.is_wasm_backend(): - print('asyncify+emterpreter') - self.btest(path_from_root('tests', 'test_wget.c'), expected='1', args=['-s', 'ASYNCIFY=1', '-s', 'EMTERPRETIFY=1']) - print('emterpreter by itself') - self.btest(path_from_root('tests', 'test_wget.c'), expected='1', args=['-s', 'EMTERPRETIFY=1', '-s', 'EMTERPRETIFY_ASYNC=1']) - else: - self.btest(path_from_root('tests', 'test_wget.c'), expected='1', args=['-s', 'ASYNCIFY=1']) + self.btest(path_from_root('tests', 'test_wget.c'), expected='1', args=self.get_async_args()) def test_wget_data(self): create_test_file('test.txt', 'emscripten') From 73ebb2be44e14b0d4c0e6593f559201af366d28f Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Thu, 25 Jul 2019 09:01:28 -0700 Subject: [PATCH 5/5] changlog [ci skip] --- ChangeLog.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ChangeLog.md b/ChangeLog.md index e723ae82636ba..1208a826ed289 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -18,6 +18,11 @@ See docs/process.md for how version tagging works. Current Trunk ------------- + - Remove fastcomp's implementation of Asyncify. This has been deprecated for + a long time, since we added Emterpreter-Async, and now we have a new Asyncify + implementation in the upstream wasm backend. It is recommended to upgrade to + the upstream backend and use Asyncify there if you need it. (If you do still + need the older version, you can use 1.38.40.) v.1.38.40: 07/24/2019 ---------------------