From 5da850b4f747c21d7ad659b1a8011eef553f4d3e Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Fri, 6 Sep 2019 14:13:40 -0700 Subject: [PATCH 1/2] Run fpcast-emu before asyncify in the wasm backend, so that the asyncify whitelist can affect the fpcast helper functions --- emcc.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/emcc.py b/emcc.py index d82537d2438e0..d4d18814e7d4a 100755 --- a/emcc.py +++ b/emcc.py @@ -1600,6 +1600,11 @@ def parse_passes(string): passes += ['--log-execution'] passes += ['--instrument-memory'] passes += ['--legalize-js-interface'] + if shared.Settings.EMULATE_FUNCTION_POINTER_CASTS + # note that this pass must run before asyncify, as if it runs afterwards we only + # generate the byn$fpcast_emu functions after asyncify runs, and so we wouldn't + # be able to whitelist them etc. + passes += ['--fpcast-emu'] if shared.Settings.ASYNCIFY: # TODO: allow whitelist as in asyncify passes += ['--asyncify'] @@ -1647,13 +1652,12 @@ def check_human_readable_list(items): # run safe-heap as a binaryen pass if shared.Settings.SAFE_HEAP and shared.Building.is_wasm_only(): options.binaryen_passes += ['--safe-heap'] - if shared.Settings.EMULATE_FUNCTION_POINTER_CASTS: - # emulated function pointer casts is emulated in wasm using a binaryen pass + if shared.Settings.EMULATE_FUNCTION_POINTER_CASTS and not shared.Settings.WASM_BACKEND: + # emulated function pointer casts is emulated in fastcomp wasm using a binaryen pass options.binaryen_passes += ['--fpcast-emu'] - if not shared.Settings.WASM_BACKEND: - # we also need emulated function pointers for that, as we need a single flat - # table, as is standard in wasm, and not asm.js split ones. - shared.Settings.EMULATED_FUNCTION_POINTERS = 1 + # we also need emulated function pointers for that, as we need a single flat + # table, as is standard in wasm, and not asm.js split ones. + shared.Settings.EMULATED_FUNCTION_POINTERS = 1 if shared.Settings.WASM2JS: if not shared.Settings.WASM_BACKEND: From 317a55c51be3654d653898360761794cce27c3c8 Mon Sep 17 00:00:00 2001 From: "Alon Zakai (kripken)" Date: Sat, 7 Sep 2019 12:01:01 -0700 Subject: [PATCH 2/2] fix --- emcc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/emcc.py b/emcc.py index d4d18814e7d4a..d64e48f779939 100755 --- a/emcc.py +++ b/emcc.py @@ -1600,7 +1600,7 @@ def parse_passes(string): passes += ['--log-execution'] passes += ['--instrument-memory'] passes += ['--legalize-js-interface'] - if shared.Settings.EMULATE_FUNCTION_POINTER_CASTS + if shared.Settings.EMULATE_FUNCTION_POINTER_CASTS: # note that this pass must run before asyncify, as if it runs afterwards we only # generate the byn$fpcast_emu functions after asyncify runs, and so we wouldn't # be able to whitelist them etc.