forked from dotnet/runtime
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
89a5e85
commit 6daf5d3
Showing
16 changed files
with
625 additions
and
381 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
src/coreclr/src/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/DiagnosticUtilities.cs
This file contains 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,47 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using Internal.TypeSystem; | ||
using Internal.TypeSystem.Ecma; | ||
|
||
namespace ILCompiler.Dataflow | ||
{ | ||
static class DiagnosticUtilities | ||
{ | ||
internal static Origin GetMethodParameterFromIndex(MethodDesc method, int parameterIndex) | ||
{ | ||
int declaredParameterIndex; | ||
if (!method.Signature.IsStatic) | ||
{ | ||
if (parameterIndex == 0) | ||
return new MethodOrigin(method); | ||
|
||
declaredParameterIndex = parameterIndex - 1; | ||
} | ||
else | ||
declaredParameterIndex = parameterIndex; | ||
|
||
return new ParameterOrigin(method, declaredParameterIndex); | ||
} | ||
|
||
internal static string GetParameterNameForErrorMessage(ParameterOrigin origin) | ||
{ | ||
return $"#{origin.Index}"; | ||
} | ||
|
||
internal static string GetMethodSignatureDisplayName(MethodDesc method) | ||
{ | ||
return method.GetDisplayName(); | ||
} | ||
|
||
internal static string GetGenericParameterDeclaringMemberDisplayName(GenericParameterOrigin origin) | ||
{ | ||
var param = (EcmaGenericParameter)origin.GenericParameter; | ||
var parent = param.Module.GetObject(param.MetadataReader.GetGenericParameter(param.Handle).Parent); | ||
if (parent is MethodDesc m) | ||
return m.GetDisplayName(); | ||
else | ||
return ((TypeDesc)parent).GetDisplayName(); | ||
} | ||
} | ||
} |
132 changes: 68 additions & 64 deletions
132
...r/src/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/DynamicallyAccessedMembersBinder.cs
Large diffs are not rendered by default.
Oops, something went wrong.
45 changes: 45 additions & 0 deletions
45
src/coreclr/src/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/EcmaExtensions.cs
This file contains 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,45 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using Internal.TypeSystem; | ||
using Internal.TypeSystem.Ecma; | ||
|
||
using MethodAttributes = System.Reflection.MethodAttributes; | ||
using FieldAttributes = System.Reflection.FieldAttributes; | ||
using TypeAttributes = System.Reflection.TypeAttributes; | ||
|
||
namespace ILCompiler.Dataflow | ||
{ | ||
static class EcmaExtensions | ||
{ | ||
public static bool IsPublic(this MethodDesc method) | ||
{ | ||
return method.GetTypicalMethodDefinition() is EcmaMethod ecmaMethod | ||
&& (ecmaMethod.Attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.Public; | ||
} | ||
|
||
public static bool IsPublic(this FieldDesc field) | ||
{ | ||
return field.GetTypicalFieldDefinition() is EcmaField ecmaField | ||
&& (ecmaField.Attributes & FieldAttributes.FieldAccessMask) == FieldAttributes.Public; | ||
} | ||
|
||
public static bool IsPrivate(this MethodDesc method) | ||
{ | ||
return method.GetTypicalMethodDefinition() is EcmaMethod ecmaMethod | ||
&& (ecmaMethod.Attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.Private; | ||
} | ||
|
||
public static bool IsPrivate(this FieldDesc field) | ||
{ | ||
return field.GetTypicalFieldDefinition() is EcmaField ecmaField | ||
&& (ecmaField.Attributes & FieldAttributes.FieldAccessMask) == FieldAttributes.Private; | ||
} | ||
|
||
public static bool IsNestedPublic(this MetadataType mdType) | ||
{ | ||
return mdType.GetTypeDefinition() is EcmaType ecmaType | ||
&& (ecmaType.Attributes & TypeAttributes.VisibilityMask) == TypeAttributes.NestedPublic; | ||
} | ||
} | ||
} |
This file contains 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 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
9 changes: 0 additions & 9 deletions
9
src/coreclr/src/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/MethodReturnType.cs
This file was deleted.
Oops, something went wrong.
74 changes: 74 additions & 0 deletions
74
src/coreclr/src/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/Origin.cs
This file contains 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,74 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using Internal.TypeSystem; | ||
using Internal.TypeSystem.Ecma; | ||
|
||
namespace ILCompiler.Dataflow | ||
{ | ||
internal abstract class Origin | ||
{ | ||
} | ||
|
||
class MethodReturnOrigin : Origin | ||
{ | ||
public MethodDesc Method { get; } | ||
|
||
public MethodReturnOrigin(MethodDesc method) | ||
{ | ||
Method = method; | ||
} | ||
|
||
public string GetDisplayName() => Method.GetDisplayName(); | ||
} | ||
|
||
class ParameterOrigin : Origin | ||
{ | ||
public MethodDesc Method { get; } | ||
public int Index { get; } | ||
|
||
public ParameterOrigin(MethodDesc method, int index) | ||
{ | ||
Method = method; | ||
Index = index; | ||
} | ||
|
||
public string GetDisplayName() => Method.GetDisplayName(); | ||
} | ||
|
||
class MethodOrigin : Origin | ||
{ | ||
public MethodDesc Method { get; } | ||
|
||
public MethodOrigin(MethodDesc method) | ||
{ | ||
Method = method; | ||
} | ||
|
||
public string GetDisplayName() => Method.GetDisplayName(); | ||
} | ||
|
||
class FieldOrigin : Origin | ||
{ | ||
public FieldDesc Field { get; } | ||
|
||
public FieldOrigin(FieldDesc field) | ||
{ | ||
Field = field; | ||
} | ||
|
||
public string GetDisplayName() => Field.GetDisplayName(); | ||
} | ||
|
||
class GenericParameterOrigin : Origin | ||
{ | ||
public GenericParameterDesc GenericParameter { get; } | ||
|
||
public string Name => GenericParameter.Name; | ||
|
||
public GenericParameterOrigin(GenericParameterDesc genericParam) | ||
{ | ||
GenericParameter = genericParam; | ||
} | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/coreclr/src/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/README.md
This file contains 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,7 @@ | ||
The dataflow analysis logic originates from IL Linker: http://github.com/mono/linker. | ||
|
||
The purpose of this logic is to analyze dynamic behavior of the compiled code to make things like reflection work. This is done by analyzing the IL and reading dataflow annotations. | ||
|
||
Let's try to keep this in sync. The ReferenceSource contains sources at the time of porting. | ||
|
||
It should be updated whenever we take fixes from IL linker. |
Oops, something went wrong.