Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corert.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Kotas <jkotas@microsoft.com>2018-09-10 20:36:47 +0300
committerGitHub <noreply@github.com>2018-09-10 20:36:47 +0300
commitfec0225204b295a0b2b83f353ae04b6f782cd2ee (patch)
tree48482dbc7f3fe9afedca80f1ca8a792de725a374
parent89468b3c6743fc7f50d300107486b3734e823555 (diff)
parentcc2b5096c1015ef3f84607b4fad3aa0090c1129d (diff)
Merge pull request #6311 from dotnet/nmirror
Merge nmirror to master
-rw-r--r--src/ILCompiler.Compiler/src/Compiler/CompilationModuleGroup.cs4
-rw-r--r--src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/RuntimeImportMethodNode.cs17
-rw-r--r--src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/UtcNodeFactory.cs17
-rw-r--r--src/ILCompiler.Compiler/src/Compiler/MethodExtensions.cs20
-rw-r--r--src/ILCompiler.Compiler/src/Compiler/MultiFileCompilationModuleGroup.cs5
-rw-r--r--src/ILCompiler.Compiler/src/Compiler/SingleFileCompilationModuleGroup.cs5
-rw-r--r--src/ILCompiler.Compiler/src/Compiler/SingleMethodCompilationModuleGroup.cs5
-rw-r--r--src/System.Private.CoreLib/shared/System/IntPtr.cs3
-rw-r--r--src/System.Private.CoreLib/shared/System/UIntPtr.cs3
9 files changed, 74 insertions, 5 deletions
diff --git a/src/ILCompiler.Compiler/src/Compiler/CompilationModuleGroup.cs b/src/ILCompiler.Compiler/src/Compiler/CompilationModuleGroup.cs
index 92354badb..edc9b076a 100644
--- a/src/ILCompiler.Compiler/src/Compiler/CompilationModuleGroup.cs
+++ b/src/ILCompiler.Compiler/src/Compiler/CompilationModuleGroup.cs
@@ -38,6 +38,10 @@ namespace ILCompiler
/// </summary>
public abstract bool ContainsMethodDictionary(MethodDesc method);
/// <summary>
+ /// If true, "method" is imported from the set of reference assemblies
+ /// </summary>
+ public abstract bool ImportsMethod(MethodDesc method, bool unboxingStub);
+ /// <summary>
/// If true, "type" is exported by the set of input assemblies being compiled
/// </summary>
public abstract ExportForm GetExportTypeForm(TypeDesc type);
diff --git a/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/RuntimeImportMethodNode.cs b/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/RuntimeImportMethodNode.cs
index ac7adb740..796ffce38 100644
--- a/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/RuntimeImportMethodNode.cs
+++ b/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/RuntimeImportMethodNode.cs
@@ -10,7 +10,7 @@ namespace ILCompiler.DependencyAnalysis
/// <summary>
/// Represents a method that is imported from the runtime library.
/// </summary>
- public class RuntimeImportMethodNode : ExternSymbolNode, IMethodNode
+ public class RuntimeImportMethodNode : ExternSymbolNode, IMethodNode, IExportableSymbolNode
{
private MethodDesc _method;
@@ -28,6 +28,21 @@ namespace ILCompiler.DependencyAnalysis
}
}
+ public ExportForm GetExportForm(NodeFactory factory)
+ {
+ // Force non-fake exports for RuntimeImportMethods that have '*' as their module. ('*' means the method is
+ // REALLY a reference to the linked in native code)
+ if (((EcmaMethod)_method).GetRuntimeImportDllName() == "*")
+ {
+ ExportForm exportForm = factory.CompilationModuleGroup.GetExportMethodForm(_method, false);
+ if (exportForm == ExportForm.ByName)
+ return ExportForm.None; // Method symbols exported by name are naturally handled by the linker
+ return exportForm;
+ }
+
+ return ExportForm.None;
+ }
+
public override int ClassCode => -1173492615;
public override int CompareToImpl(ISortableNode other, CompilerComparer comparer)
diff --git a/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/UtcNodeFactory.cs b/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/UtcNodeFactory.cs
index 5a026e34a..80aec11b0 100644
--- a/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/UtcNodeFactory.cs
+++ b/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/UtcNodeFactory.cs
@@ -237,12 +237,21 @@ namespace ILCompiler
{
if (method.HasCustomAttribute("System.Runtime", "RuntimeImportAttribute"))
{
- return new RuntimeImportMethodNode(method);
+ RuntimeImportMethodNode runtimeImportMethod = new RuntimeImportMethodNode(method);
+
+ // If the method is imported from either the current module or the runtime, reference it directly
+ if (CompilationModuleGroup.ContainsMethodBody(method, false))
+ return runtimeImportMethod;
+ // If the method is imported from the runtime but not a managed assembly, reference it directly
+ else if (!CompilationModuleGroup.ImportsMethod(method, false))
+ return runtimeImportMethod;
+
+ // If the method is imported from a managed assembly, reference it via an import cell
}
-
- if (CompilationModuleGroup.ContainsMethodBody(method, false))
+ else
{
- return NonExternMethodSymbol(method, false);
+ if (CompilationModuleGroup.ContainsMethodBody(method, false))
+ return NonExternMethodSymbol(method, false);
}
return _importedNodeProvider.ImportedMethodCodeNode(this, method, false);
diff --git a/src/ILCompiler.Compiler/src/Compiler/MethodExtensions.cs b/src/ILCompiler.Compiler/src/Compiler/MethodExtensions.cs
index 4b72c15d8..fd274af78 100644
--- a/src/ILCompiler.Compiler/src/Compiler/MethodExtensions.cs
+++ b/src/ILCompiler.Compiler/src/Compiler/MethodExtensions.cs
@@ -30,6 +30,26 @@ namespace ILCompiler
return null;
}
+ public static string GetRuntimeImportDllName(this EcmaMethod This)
+ {
+ var decoded = This.GetDecodedCustomAttribute("System.Runtime", "RuntimeImportAttribute");
+ if (decoded == null)
+ return null;
+
+ var decodedValue = decoded.Value;
+
+ if (decodedValue.FixedArguments.Length == 2)
+ return (string)decodedValue.FixedArguments[0].Value;
+
+ foreach (var argument in decodedValue.NamedArguments)
+ {
+ if (argument.Name == "DllName")
+ return (string)argument.Value;
+ }
+
+ return null;
+ }
+
public static string GetRuntimeExportName(this EcmaMethod This)
{
var decoded = This.GetDecodedCustomAttribute("System.Runtime", "RuntimeExportAttribute");
diff --git a/src/ILCompiler.Compiler/src/Compiler/MultiFileCompilationModuleGroup.cs b/src/ILCompiler.Compiler/src/Compiler/MultiFileCompilationModuleGroup.cs
index 5afac3563..842ddefad 100644
--- a/src/ILCompiler.Compiler/src/Compiler/MultiFileCompilationModuleGroup.cs
+++ b/src/ILCompiler.Compiler/src/Compiler/MultiFileCompilationModuleGroup.cs
@@ -58,6 +58,11 @@ namespace ILCompiler
return ContainsMethodBody(method, false);
}
+ public sealed override bool ImportsMethod(MethodDesc method, bool unboxingStub)
+ {
+ return false;
+ }
+
public sealed override ExportForm GetExportTypeForm(TypeDesc type)
{
return ExportForm.None;
diff --git a/src/ILCompiler.Compiler/src/Compiler/SingleFileCompilationModuleGroup.cs b/src/ILCompiler.Compiler/src/Compiler/SingleFileCompilationModuleGroup.cs
index a305ad026..90a0043be 100644
--- a/src/ILCompiler.Compiler/src/Compiler/SingleFileCompilationModuleGroup.cs
+++ b/src/ILCompiler.Compiler/src/Compiler/SingleFileCompilationModuleGroup.cs
@@ -31,6 +31,11 @@ namespace ILCompiler
return ContainsMethodBody(method, false);
}
+ public override bool ImportsMethod(MethodDesc method, bool unboxingStub)
+ {
+ return false;
+ }
+
public override ExportForm GetExportTypeForm(TypeDesc type)
{
return ExportForm.None;
diff --git a/src/ILCompiler.Compiler/src/Compiler/SingleMethodCompilationModuleGroup.cs b/src/ILCompiler.Compiler/src/Compiler/SingleMethodCompilationModuleGroup.cs
index 9f734c1e0..9a1435217 100644
--- a/src/ILCompiler.Compiler/src/Compiler/SingleMethodCompilationModuleGroup.cs
+++ b/src/ILCompiler.Compiler/src/Compiler/SingleMethodCompilationModuleGroup.cs
@@ -50,6 +50,11 @@ namespace ILCompiler
return false;
}
+ public override bool ImportsMethod(MethodDesc method, bool unboxingStub)
+ {
+ return false;
+ }
+
public override ExportForm GetExportTypeForm(TypeDesc type)
{
return ExportForm.None;
diff --git a/src/System.Private.CoreLib/shared/System/IntPtr.cs b/src/System.Private.CoreLib/shared/System/IntPtr.cs
index f79334a96..d23742fa7 100644
--- a/src/System.Private.CoreLib/shared/System/IntPtr.cs
+++ b/src/System.Private.CoreLib/shared/System/IntPtr.cs
@@ -217,6 +217,9 @@ namespace System
[CLSCompliant(false)]
[Intrinsic]
[NonVersionable]
+#if PROJECTN
+ [System.Runtime.CompilerServices.DependencyReductionRootAttribute]
+#endif
public unsafe void* ToPointer()
{
return _value;
diff --git a/src/System.Private.CoreLib/shared/System/UIntPtr.cs b/src/System.Private.CoreLib/shared/System/UIntPtr.cs
index 9534f4f87..c57dd86a7 100644
--- a/src/System.Private.CoreLib/shared/System/UIntPtr.cs
+++ b/src/System.Private.CoreLib/shared/System/UIntPtr.cs
@@ -208,6 +208,9 @@ namespace System
[Intrinsic]
[NonVersionable]
+#if PROJECTN
+ [System.Runtime.CompilerServices.DependencyReductionRootAttribute]
+#endif
public unsafe void* ToPointer()
{
return _value;