Repository navigation
Conversation
… from virtual function pointer lookups A non-generic method on a non-generic interface is a single global slot, so reporting it from recordWasmVirtualFunctionPointerLookup roots its implementation on every instantiation of every implementing type. In a composite image those implementations reference further instantiations, which are then compiled in full. Skip such slots and leave their implementations to the runtime. Generic interfaces and generic virtual methods keep their dependencies. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
Azure Pipelines: Successfully started running 3 pipeline(s). 12 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
Tagging subscribers to this area: @dotnet/crossgen-contrib |
Contributor
|
Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara |
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Wasm JIT calls
CORINFO_HELP_VIRTUAL_FUNC_PTRfor virtual and interface lookups instead of using a VirtualEntry cell, so #136769 addedrecordWasmVirtualFunctionPointerLookup, which adds the cell's dependencies (VirtualMethodUse, GVM dependencies and the cross-module compile dependency) for each lookup that survives lowering. This change narrows that notification.Cause
A non-generic method on a non-generic interface is a single global slot. One
IEnumerable.GetEnumerator,IEnumerator.MoveNext/get_Current,IDisposable.Dispose,ICollection.*orIList.*lookup anywhere marks the slot used, and the implementation is then rooted on every instantiation of every implementing type:List<X>,ImmutableArray<X>, LINQ iterators over value types, and so on. Those implementations reference further instantiations, and in a composite image every method of each new generic instantiation is compiled (AllMethodsOnType), so the closure keeps growing.Rule
In
recordWasmVirtualFunctionPointerLookup, skip the VirtualEntry dependencies when the method's owning type is a non-generic interface and the method itself is not generic. Those implementations are left to the runtime, as they were before #136769. Lookups through generic interfaces (for exampleIList<T>,IEnumerable<T>), generic virtual methods (including GVMs on non-generic interfaces) and class virtuals keep their dependencies. There is no JIT or JIT-EE change.Size
CI-shaped browser composite (MicroBenchmarks plus its whole closure, built with the SDK browser publish crossgen2 options, framework from the same snapshot, crossgen2 from current
main):mainThe intended wins from #136769 are kept:
SZArrayHelper.get_Item/get_Count/Contains/GetEnumerator<int>andList<int>'sIEnumerable<T>.GetEnumeratorare still compiled.Browser
System.Private.CoreLib.wasm(./build.sh clr.nativecorelib -os browser -c Release):mainTests
NonGVM.csgains Test14:Test14A<int>explicitly implements both a non-genericITest14and a genericITest14<int>, reached only through those interfaces via a non-generic derived class (so no type handle fixup roots all of its methods). On Wasm,ITest14<T>.Test14GenericMethodis compiled andITest14.Test14Methodis not. On other targets both are compiled. The new Wasm assertion fails without the crossgen2 change.ITest3WithDim<int>'sITest3Base.Test3MethodDIM, reached only through the non-genericITest3Base) is no longer precompiled on Wasm. Its assertion moved from the sharedAssertNonGVMImplementationsCompiledhelper to the non-Wasm test.R2R modes exercised: single-assembly non-composite with
--generate-unboxing-stubs(NonGVM, GVM), composite with CoreLib unrooted (ArrayInterfaceMethods), plus the rest ofILCompiler.ReadyToRun.Tests../build.sh clr+libs -os browser -c Release):dotnet build src/coreclr/tools/aot/ILCompiler.ReadyToRun.Tests/ILCompiler.ReadyToRun.Tests.csproj -c Release -p:TargetOS=browser -p:TargetArchitecture=wasmthendotnet test artifacts/bin/ILCompiler.ReadyToRun.Tests/Release/Release_CLR/browser-wasm/ILCompiler.ReadyToRun.Tests.dll: passed, 284 passed, 0 failed, 42 skipped../build.sh clr+libs -c Release):dotnet build src/coreclr/tools/aot/ILCompiler.ReadyToRun.Tests/ILCompiler.ReadyToRun.Tests.csproj -c Releasethendotnet test artifacts/bin/ILCompiler.ReadyToRun.Tests/Release/Release_CLR/osx-arm64/ILCompiler.ReadyToRun.Tests.dll: passed, 310 passed, 0 failed, 18 skipped.@davidwrighton, could you review this? It narrows the dependencies added in #136769.
Note
This PR description was generated with the help of GitHub Copilot.