Repository navigation
[Crossgen2] Omit constrained type from imports of resolved constrained calls - #138262
Draft
jtschuster wants to merge 2 commits into
Draft
jtschuster wants to merge 2 commits into
jtschuster wants to merge 2 commits into
Conversation
When crossgen2 resolves a constrained call at compile time to a method body in the version bubble, encode the call target import with that method's own token and no constrained type. The runtime cannot resolve the call differently, and decoding the constraint eagerly loaded the exact constrained type and its instantiation arguments (for example Enumerator<Marker> for a foreach Dispose call), which could load application assemblies during early startup on Wasm. Fixes dotnet#138199 Co-authored-by: copilot-swe-agent[bot] <[email protected]>
|
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 |
Open
3 tasks
…onstrainedType Co-authored-by: copilot-swe-agent[bot] <[email protected]>
This branch has not been deployed
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.
Fixes #138199
As suggested in #138199 (comment): when Crossgen2 resolves a constrained call to a specific method body, the method-entry imports for that call no longer need the constrained type.
Before this change,
MethodFixupSignatureswapped the interface MemberRef for the resolved MethodDef but still encoded the exact constrained owner (e.g.Enumerator`1<Marker>). Decoding the import at runtime then eagerly loadedMarker's assembly.Changes
CorInfoImpl.ReadyToRun.cs:ceeInfoGetCallInfonow reportsresolvedConstraint. A newComputeCallTargetMethodWithTokenhelper builds theMethodWithTokenfrom the resolved method's own token, with no constrained type, when all of the following hold:Otherwise it falls back to
ComputeMethodWithToken. BothCORINFO_CALLentrypoint paths ingetCallInfouse it: the deferred Wasm path and the regularMethodEntrypointpath.New regression test
ResolvedConstrainedCallImportsOmitConstrainedTypein ILCompiler.ReadyToRun.Tests. It fails without the fix.Testing
ILCompiler.ReadyToRun.Tests, no failures:
Debug Crossgen2 compiled composite CoreLib plus the repro with no asserts.
src/tests with
--runcrossgen2tests(linux-x64) passed:readytorunLoader(includingclassloader/StaticVirtualMethodsandclassloader/DefaultInterfaceMethods)JIT.Generics_roThe only two failures came from the local environment:
R2RTestandhostpolicyweren't built.