Fix generic lookups and thunks#129825
Conversation
|
Tagging subscribers to this area: @agocke |
There was a problem hiding this comment.
Pull request overview
This PR extends the WebAssembly ReadyToRun (R2R) pipeline to support generic dictionary lookups and related delay-load helper paths using the “DynamicHelper” pattern already used on other architectures, including adding dedicated Wasm .S helpers and updating Crossgen2’s Wasm thunk/signature plumbing accordingly.
Changes:
- Add new Wasm dynamic helper stubs (in
.S) for generic dictionary lookup variants and supporting VM glue to allocate the corresponding portable-entrypoint stub data. - Update Wasm delay-load/import thunk generation to support generic lookups via portable entrypoints (signature updates + always generating a thunk).
- Add missing Wasm portable-entrypoint interpreter-call thunks for additional signatures (e.g.,
doublearg +i32/i64return, andS8payload).
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/coreclr/vm/wasm/helpers.cpp | Adds additional portable-entrypoint interpreter-call thunks and updates the portable-entrypoint thunk table; removes Wasm placeholder DelayLoad_Helper stubs. |
| src/coreclr/vm/wasm/dynamichelpers.S | New Wasm assembly implementations of generic dictionary lookup dynamic helpers (incl. size-check / null-test variants and small constant-offset fast paths). |
| src/coreclr/vm/wasm/dynamichelpers.cpp | Implements Wasm DelayLoad_Helper entry and creates portable-entrypoint data for generic dictionary lookup helpers on Wasm. |
| src/coreclr/vm/wasm/asmconstants.h | Introduces Wasm-specific asm constants/offsets needed by dynamichelpers.S (with debug/fre handling and static-assert hooks). |
| src/coreclr/vm/readytoruninfo.h | Adds GenericDictionaryDynamicHelperStubData_PortableEntryPoint layout used by Wasm helper stubs. |
| src/coreclr/vm/prestub.cpp | Allows resolving import sections by RVA when sectionIndex == (DWORD)-1 (used by Wasm delay-load helper), and excludes non-Wasm fixup kinds under TARGET_WASM. |
| src/coreclr/vm/jitinterface.cpp | Adds a debug assert ensuring portable-entrypoint targets have actual code under R2R (helps catch missing cases). |
| src/coreclr/vm/CMakeLists.txt | Wires new Wasm .S and .cpp sources (and asmconstants header) into the VM build. |
| src/coreclr/vm/cgensys.h | Adjusts DelayLoad_Helper declaration for Wasm to match the new calling convention/signature. |
| src/coreclr/tools/aot/ILCompiler.ReadyToRun/.../WasmImportThunkPortableEntrypoint.cs | Updates generic-lookup thunk signature shape/string to include the portable-entrypoint parameter. |
| src/coreclr/tools/aot/ILCompiler.ReadyToRun/.../DelayLoadHelperImport.cs | Always generates a Wasm import-thunk portable entrypoint (including for generic lookups). |
| eng/native/configurecompiler.cmake | Enables ASM for Browser/WASI toolchains so preprocessed Wasm .S files can be assembled by clang-based toolchains. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
Have been testing this locally and it looks good from that standpoint. Still some possibly related failures but it will take me a bit longer to isolate those. |
AndyAyersMS
left a comment
There was a problem hiding this comment.
Changes look reasonable to me, but I confess I didn't dig through all the wasm in detail. From a testing standpoint things are definitely better.
Add support for generic lookups to Wasm R2R code by following the DynamicHelper pattern we use on other platforms. This looks like a quite suitable implementation for Wasm, so I expect that this will remain for the long term.
Add support for WebAssembly .S files, as it was difficult to implement the helpers in inline assembly due to clang limitations.
Tweak Crossgen2 into generating uses of the DynamicHelper logic.
Also add support for precomputed thunks for various runtime helpers which were missing them, and add an assert that will fire even in interpreted runs for missing cases.
Fixes (most) of #129622
Fixes #129821