Uh oh!
There was an error while loading. Please reload this page.
Add support for the new WASM Exception Handling feature - #66435
Conversation
WASM EH uses the newly added llvm catchpad instructions instead of the old landingpad instructions. Add a --wasm-exceptions option to control whenever the old JS style or the new WASM style code is generated.
Uh oh!
There was an error while loading. Please reload this page.
vargaz
commented
Mar 10, 2022
Benchmarks: AFTER: A micro benchmark which iterated on an IEnumerable got about 60% faster. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
It is controlled by the $(WasmExceptionHandling) msbuild property. Its only used in AOT mode, the interpreter mode wouldn't benefit from it. The only file in the runtime which contains a throw or a catch is llvm-runtime.cpp, so create 2 small static libraries from this file: * libmono-wasm-eh-js - compiled to use JS style EH * libmono-wasm-eh-wasm - compiled to use WASM style EH This avoids the need to compile 2 versions of the whole runtime. Requires emscripten 3.x.
| if(CMAKE_BUILD_TYPE STREQUAL "Release") | ||
| add_custom_command(TARGET dotnet POST_BUILD COMMAND ${EMSDK_PATH}/upstream/bin/wasm-opt --strip-dwarf ${NATIVE_BIN_DIR}/dotnet.wasm -o ${NATIVE_BIN_DIR}/dotnet.wasm) | ||
| add_custom_command(TARGET dotnet POST_BUILD COMMAND ${EMSDK_PATH}/upstream/bin/wasm-opt --enable-exception-handling --strip-dwarf ${NATIVE_BIN_DIR}/dotnet.wasm -o ${NATIVE_BIN_DIR}/dotnet.wasm) |
There was a problem hiding this comment.
Does --enable-exception-handling do something also for wasm-eh-js case?
There was a problem hiding this comment.
Its needed for wasm-opt to not fail, it looks harmless otherwise.
radekdoulik
commented
Mar 10, 2022
The measurements look nice! One thing I wonder about is why the throw cases are now slower. Do you know what might be behind this? Maybe this path is not just optimized yet in v8? |
radekdoulik
commented
Mar 10, 2022
/azp run runtime-wasm |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
SamMonoRT
commented
Mar 10, 2022
Contributes to #63399 |
Co-authored-by: Aleksey Kliger (λgeek) <akliger@gmail.com>
Co-authored-by: Aleksey Kliger (λgeek) <akliger@gmail.com>
vargaz
commented
Mar 10, 2022
/azp run runtime-wasm |
|
Azure Pipelines successfully started running 1 pipeline(s). |
| <_EmccCommonFlags Include="-s EXPORT_ES6=1" Condition="'$(WasmEnableES6)' == 'true'" /> | ||
| <_EmccCommonFlags Include="-g" Condition="'$(WasmNativeStrip)' == 'false'" /> | ||
| <_EmccCommonFlags Include="-v" Condition="'$(EmccVerbose)' != 'false'" /> | ||
| <_EmccCommonFlags Include="-s DISABLE_EXCEPTION_CATCHING=0" Condition="'$(WasmExceptionHandling)' == 'false'" /> |
There was a problem hiding this comment.
| <_EmccCommonFlagsInclude="-s DISABLE_EXCEPTION_CATCHING=0"Condition="'$(WasmExceptionHandling)' == 'false'" /> | |
| <_EmccCommonFlagsInclude="-s DISABLE_EXCEPTION_CATCHING=0"Condition="'$(WasmExceptionHandling)' != 'true'" /> |
There was a problem hiding this comment.
Why is this needed ? The property is initialized to false if not set.
<WasmExceptionHandling Condition="'$(WasmExceptionHandling)' == ''">false</WasmExceptionHandling>
| - $(RunAOTCompilationAfterBuild) - Run AOT compilation even after Build. By default, it is run only for publish. | ||
| Defaults to false. | ||
| - $(WasmAotProfilePath) - Path to an AOT profile file. | ||
| - $(WasmExceptionHandling) - Enable support for the WASM Exception Handling feature. |
There was a problem hiding this comment.
This should be renamed to WasmEnableExceptionHandling.
There was a problem hiding this comment.
that sounds like there wouldn't be exception handling support if it isn't true though
There was a problem hiding this comment.
WasmEnableWasmEHFeature? WasmEnableNativeExceptionHandlingFeature?
vargaz
commented
Mar 11, 2022
The CI failures look unrelated |
vargaz
commented
Mar 11, 2022
Will merge this for now, the property can be renamed later. |
No description provided.