-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Only R2R public methods, methods that override public methods, and internal methods that aren't always inlined #75793
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
jkoritzinsky
merged 14 commits into
dotnet:main
from
jkoritzinsky:crossgen2-no-unused-pinvoke-gen
Nov 16, 2022
Merged
Changes from 1 commit
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
5ef5bbc
Only R2R blittable IL stubs that aren't inlined
jkoritzinsky c96e0d0
Crossgen2's existing support for only emitting what's used already co…
jkoritzinsky d583b6c
Only R2R methods that are either publicly exposed or (to make sure we…
jkoritzinsky 2a4a0ee
Root all virtual methods without any corresponding MethodImpl records…
jkoritzinsky 2c11c6b
Handle PrivateScope/CompilerControlled visibility that is usable from IL
jkoritzinsky 72a85d6
Root the main method of assemblies in addition to public surface area.
jkoritzinsky 484ec47
Use ToArray in one more place
jkoritzinsky 04fc951
PR feedback.
jkoritzinsky bdfd4df
Merge branch 'crossgen2-no-unused-pinvoke-gen' of github.com:jkoritzi…
jkoritzinsky 6764e20
Move ILLInker "reference source" to the Common directory so we don't …
jkoritzinsky 0f64a34
Based on feedback from @jkotas, only use the visibility policy if the…
jkoritzinsky 949aa00
Merge branch 'main' of github.com:dotnet/runtime into crossgen2-no-un…
jkoritzinsky f188ad1
Add reference to ILLink.Shared from ILCompiler.ReadyToRun to fix build
jkoritzinsky 32b44ea
Pull in the type system proxy to fix the crossgen2 build.
jkoritzinsky File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Only R2R methods that are either publicly exposed or (to make sure we…
… cover all of the methods in CoreLib used by the runtime) any embedded linker xml root files.
- Loading branch information
commit d583b6c982f5bb873752fd449a83b83b8bedf722
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
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
90 changes: 90 additions & 0 deletions
90
src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/EffectiveVisibility.cs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System; | ||
| using System.Diagnostics; | ||
| using System.Reflection; | ||
| using Internal.TypeSystem; | ||
| using Internal.TypeSystem.Ecma; | ||
|
|
||
| namespace ILCompiler | ||
| { | ||
| public enum EffectiveVisibility | ||
| { | ||
| Private, | ||
| Public, | ||
| Family, | ||
| Assembly, | ||
| FamilyAndAssembly, | ||
| FamilyOrAssembly, | ||
| } | ||
|
|
||
| public static class EffectiveVisibilityExtensions | ||
| { | ||
| private static EffectiveVisibility ToEffectiveVisibility(this TypeAttributes typeAttributes) | ||
| { | ||
| return (typeAttributes & TypeAttributes.VisibilityMask) switch | ||
| { | ||
| TypeAttributes.Public or TypeAttributes.NestedPublic => EffectiveVisibility.Public, | ||
| TypeAttributes.NotPublic => EffectiveVisibility.Assembly, | ||
| TypeAttributes.NestedPrivate => EffectiveVisibility.Private, | ||
| TypeAttributes.NestedAssembly => EffectiveVisibility.Assembly, | ||
| TypeAttributes.NestedFamily => EffectiveVisibility.Family, | ||
| TypeAttributes.NestedFamANDAssem => EffectiveVisibility.FamilyAndAssembly, | ||
| TypeAttributes.NestedFamORAssem => EffectiveVisibility.FamilyOrAssembly, | ||
| _ => throw new UnreachableException() | ||
| }; | ||
| } | ||
| private static EffectiveVisibility ToEffectiveVisibility(this MethodAttributes typeAttributes) | ||
| { | ||
| return (typeAttributes & MethodAttributes.MemberAccessMask) switch | ||
| { | ||
| MethodAttributes.Public => EffectiveVisibility.Public, | ||
| MethodAttributes.Private => EffectiveVisibility.Private, | ||
| MethodAttributes.Assembly => EffectiveVisibility.Assembly, | ||
| MethodAttributes.Family => EffectiveVisibility.Family, | ||
| MethodAttributes.FamANDAssem => EffectiveVisibility.FamilyAndAssembly, | ||
| MethodAttributes.FamORAssem => EffectiveVisibility.FamilyOrAssembly, | ||
| _ => throw new UnreachableException() | ||
| }; | ||
| } | ||
|
|
||
| private static EffectiveVisibility ConstrainToVisibility(this EffectiveVisibility visibility, EffectiveVisibility enclosingVisibility) | ||
| { | ||
| return (visibility, enclosingVisibility) switch | ||
| { | ||
| (_, _) when visibility == enclosingVisibility => visibility, | ||
| (_, EffectiveVisibility.Private) => EffectiveVisibility.Private, | ||
| (EffectiveVisibility.Private, _) => EffectiveVisibility.Private, | ||
| (EffectiveVisibility.Public, _) => enclosingVisibility, | ||
| (_, EffectiveVisibility.Public) => visibility, | ||
| (EffectiveVisibility.FamilyOrAssembly, _) => enclosingVisibility, | ||
| (_, EffectiveVisibility.FamilyOrAssembly) => visibility, | ||
| (EffectiveVisibility.Family, EffectiveVisibility.Assembly) => EffectiveVisibility.FamilyAndAssembly, | ||
| (EffectiveVisibility.Family, EffectiveVisibility.FamilyAndAssembly) => EffectiveVisibility.FamilyAndAssembly, | ||
| (EffectiveVisibility.Assembly, EffectiveVisibility.Family) => EffectiveVisibility.FamilyAndAssembly, | ||
| (EffectiveVisibility.Assembly, EffectiveVisibility.FamilyAndAssembly) => EffectiveVisibility.FamilyAndAssembly, | ||
| (EffectiveVisibility.FamilyAndAssembly, EffectiveVisibility.Family) => EffectiveVisibility.FamilyAndAssembly, | ||
| (EffectiveVisibility.FamilyAndAssembly, EffectiveVisibility.Assembly) => EffectiveVisibility.FamilyAndAssembly, | ||
| _ => throw new UnreachableException(), | ||
| }; | ||
| } | ||
|
|
||
| public static bool IsExposedOutsideOfThisAssembly(this EffectiveVisibility visibility, bool anyInternalsVisibleTo) | ||
| { | ||
| return visibility is EffectiveVisibility.Public or EffectiveVisibility.Family | ||
| || (anyInternalsVisibleTo && visibility is EffectiveVisibility.Assembly or EffectiveVisibility.FamilyOrAssembly); | ||
| } | ||
|
|
||
| public static EffectiveVisibility GetEffectiveVisibility(this EcmaMethod method) | ||
| { | ||
| EffectiveVisibility visibility = method.Attributes.ToEffectiveVisibility(); | ||
|
|
||
| for (EcmaType type = (EcmaType)method.OwningType; type is not null; type = (EcmaType)type.ContainingType) | ||
| { | ||
| visibility = visibility.ConstrainToVisibility(type.Attributes.ToEffectiveVisibility()); | ||
| } | ||
| return visibility; | ||
| } | ||
| } | ||
| } |
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should inline this logic to where it's needed (or into an extension method). It doesn't look like we need to cache this and metadata reader + handle is available as a public API on
EcmaType.