-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Fold always false type checks #99761
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
Changes from 11 commits
7c29781
a51509a
1da6be4
8e36397
22af9c1
d1e26b3
5f01872
fc2a7cc
83d4e47
40d7553
4e24a85
f6a3819
b8b7a02
a2891f4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2874,12 +2874,22 @@ private TypeCompareState compareTypesForEquality(CORINFO_CLASS_STRUCT_* cls1, CO | |
| TypeDesc type1 = HandleToObject(cls1); | ||
| TypeDesc type2 = HandleToObject(cls2); | ||
|
|
||
| return TypeExtensions.CompareTypesForEquality(type1, type2) switch | ||
| TypeCompareState result = TypeExtensions.CompareTypesForEquality(type1, type2) switch | ||
| { | ||
| true => TypeCompareState.Must, | ||
| false => TypeCompareState.MustNot, | ||
| _ => TypeCompareState.May, | ||
| }; | ||
|
|
||
| #if !READYTORUN | ||
| if (result == TypeCompareState.May | ||
| && (canNeverHaveInstanceOfSubclassOf(type1) || canNeverHaveInstanceOfSubclassOf(type2))) | ||
|
||
| { | ||
| return TypeCompareState.MustNot; | ||
| } | ||
| #endif | ||
|
|
||
| return result; | ||
| } | ||
|
|
||
| private bool isMoreSpecificType(CORINFO_CLASS_STRUCT_* cls1, CORINFO_CLASS_STRUCT_* cls2) | ||
|
|
@@ -4284,7 +4294,7 @@ private HRESULT getPgoInstrumentationResults(CORINFO_METHOD_STRUCT_* ftnHnd, ref | |
| #pragma warning disable SA1001, SA1113, SA1115 // Commas should be spaced correctly | ||
| ComputeJitPgoInstrumentationSchema(ObjectToHandle, pgoResultsSchemas, out var nativeSchemas, _cachedMemoryStream | ||
| #if !READYTORUN | ||
| , _compilation.CanConstructType | ||
| , _compilation.CanReferenceConstructedMethodTable | ||
| #endif | ||
| ); | ||
| #pragma warning restore SA1001, SA1113, SA1115 // Commas should be spaced correctly | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -413,7 +413,8 @@ public override DictionaryLayoutNode GetLayout(TypeSystemEntity methodOrType) | |
|
|
||
| private sealed class ScannedDevirtualizationManager : DevirtualizationManager | ||
| { | ||
| private HashSet<TypeDesc> _constructedTypes = new HashSet<TypeDesc>(); | ||
| private HashSet<TypeDesc> _constructedMethodTables = new HashSet<TypeDesc>(); | ||
| private HashSet<TypeDesc> _canonConstructedMethodTables = new HashSet<TypeDesc>(); | ||
| private HashSet<TypeDesc> _canonConstructedTypes = new HashSet<TypeDesc>(); | ||
| private HashSet<TypeDesc> _unsealedTypes = new HashSet<TypeDesc>(); | ||
| private Dictionary<TypeDesc, HashSet<TypeDesc>> _implementators = new(); | ||
|
|
@@ -442,7 +443,12 @@ public ScannedDevirtualizationManager(NodeFactory factory, ImmutableArray<Depend | |
|
|
||
| if (type != null) | ||
| { | ||
| _constructedTypes.Add(type); | ||
| _constructedMethodTables.Add(type); | ||
| TypeDesc canonForm = type.ConvertToCanonForm(CanonicalFormKind.Specific); | ||
| if (canonForm != type) | ||
| { | ||
| _canonConstructedMethodTables.Add(canonForm); | ||
| } | ||
|
|
||
| if (type.IsInterface) | ||
| { | ||
|
|
@@ -687,7 +693,11 @@ protected override MethodDesc ResolveVirtualMethod(MethodDesc declMethod, DefTyp | |
| return result; | ||
| } | ||
|
|
||
| public override bool CanConstructType(TypeDesc type) => _constructedTypes.Contains(type); | ||
| public override bool CanReferenceConstructedMethodTable(TypeDesc type) | ||
| => _constructedMethodTables.Contains(type); | ||
|
|
||
| public override bool CanTypeOrCanonicalFormOfTypeBeAllocated(TypeDesc type) | ||
|
||
| => _constructedMethodTables.Contains(type) || _canonConstructedMethodTables.Contains(type); | ||
|
|
||
| public override TypeDesc[] GetImplementingClasses(TypeDesc type) | ||
| { | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -2248,14 +2248,42 @@ private void getFieldInfo(ref CORINFO_RESOLVED_TOKEN pResolvedToken, CORINFO_MET | |||||
| // and STS::AccessCheck::CanAccess. | ||||||
| } | ||||||
|
|
||||||
| private bool canNeverHaveInstanceOfSubclassOf(TypeDesc type) | ||||||
|
||||||
| private bool canNeverHaveInstanceOfSubclassOf(TypeDesc type) | |
| private bool CanNeverHaveInstanceOfSubclassOf(TypeDesc type) |
Nit: We seem to use regular naming convention in this file for methods that are not directly exposed on JIT/EE interface
Uh oh!
There was an error while loading. Please reload this page.