Integrate changes in shared files from dotnet/runtimelab:NativeAOT (#43075)
authorJan Kotas <jkotas@microsoft.com>
Tue, 6 Oct 2020 13:51:56 +0000 (06:51 -0700)
committerGitHub <noreply@github.com>
Tue, 6 Oct 2020 13:51:56 +0000 (06:51 -0700)
src/coreclr/src/jit/lower.cpp
src/coreclr/src/tools/Common/TypeSystem/Common/FieldDesc.cs
src/coreclr/src/tools/Common/TypeSystem/Common/MethodDesc.cs
src/coreclr/src/tools/Common/TypeSystem/Common/TypeDesc.cs
src/coreclr/src/tools/Common/TypeSystem/Common/Utilities/DebugNameFormatter.cs
src/coreclr/src/tools/Common/TypeSystem/Interop/IL/Marshaller.cs
src/coreclr/src/tools/Common/TypeSystem/Interop/InteropTypes.cs
src/coreclr/src/tools/aot/ILCompiler.DependencyAnalysisFramework/ILCompiler.DependencyAnalysisFramework.csproj
src/coreclr/src/tools/aot/ILCompiler.TypeSystem.ReadyToRun/ILCompiler.TypeSystem.ReadyToRun.csproj
src/libraries/System.Private.CoreLib/src/System/AppContext.AnyOS.cs
src/libraries/System.Private.CoreLib/src/System/Object.cs

index ecfe71a..32c4f30 100644 (file)
@@ -3507,7 +3507,7 @@ void Lowering::LowerCallStruct(GenTreeCall* call)
 #endif // FEATURE_SIMD
                 // importer has a separate mechanism to retype calls to helpers,
                 // keep it for now.
-                assert(user->TypeIs(TYP_REF));
+                assert(user->TypeIs(TYP_REF) || (user->TypeIs(TYP_I_IMPL) && comp->IsTargetAbi(CORINFO_CORERT_ABI)));
                 assert(call->IsHelperCall());
                 assert(returnType == user->TypeGet());
                 break;
index a185cf1..ad44d48 100644 (file)
@@ -23,7 +23,7 @@ namespace Internal.TypeSystem
         public override bool Equals(object o)
         {
             // Its only valid to compare two FieldDescs in the same context
-            Debug.Assert(object.ReferenceEquals(o, null) || !(o is FieldDesc) || object.ReferenceEquals(((FieldDesc)o).Context, this.Context));
+            Debug.Assert(o is not FieldDesc || object.ReferenceEquals(((FieldDesc)o).Context, this.Context));
             return object.ReferenceEquals(this, o);
         }
 
index 490a1c5..7f2d124 100644 (file)
@@ -419,7 +419,7 @@ namespace Internal.TypeSystem
         public override bool Equals(object o)
         {
             // Its only valid to compare two MethodDescs in the same context
-            Debug.Assert(object.ReferenceEquals(o, null) || !(o is MethodDesc) || object.ReferenceEquals(((MethodDesc)o).Context, this.Context));
+            Debug.Assert(o is not MethodDesc || object.ReferenceEquals(((MethodDesc)o).Context, this.Context));
             return object.ReferenceEquals(this, o);
         }
 
index adc28c9..f0dbed1 100644 (file)
@@ -24,7 +24,7 @@ namespace Internal.TypeSystem
         public override bool Equals(object o)
         {
             // Its only valid to compare two TypeDescs in the same context
-            Debug.Assert(o == null || !(o is TypeDesc) || object.ReferenceEquals(((TypeDesc)o).Context, this.Context));
+            Debug.Assert(o is not TypeDesc || object.ReferenceEquals(((TypeDesc)o).Context, this.Context));
             return object.ReferenceEquals(this, o);
         }
 
@@ -32,14 +32,14 @@ namespace Internal.TypeSystem
         public static bool operator ==(TypeDesc left, TypeDesc right)
         {
             // Its only valid to compare two TypeDescs in the same context
-            Debug.Assert(object.ReferenceEquals(left, null) || object.ReferenceEquals(right, null) || object.ReferenceEquals(left.Context, right.Context));
+            Debug.Assert(left is null || right is null || object.ReferenceEquals(left.Context, right.Context));
             return object.ReferenceEquals(left, right);
         }
 
         public static bool operator !=(TypeDesc left, TypeDesc right)
         {
             // Its only valid to compare two TypeDescs in the same context
-            Debug.Assert(object.ReferenceEquals(left, null) || object.ReferenceEquals(right, null) || object.ReferenceEquals(left.Context, right.Context));
+            Debug.Assert(left is null || right is null || object.ReferenceEquals(left.Context, right.Context));
             return !object.ReferenceEquals(left, right);
         }
 #endif
index 99431f9..e353a59 100644 (file)
@@ -80,7 +80,7 @@ namespace Internal.TypeSystem
 
         public override Void AppendName(StringBuilder sb, SignatureTypeVariable type, FormatOptions options)
         {
-            sb.Append("!");
+            sb.Append('!');
             sb.Append(type.Index.ToStringInvariant());
 
             return Void.Value;
@@ -174,7 +174,6 @@ namespace Internal.TypeSystem
             {
                 sb.Length = initialLen;
 
-                // 
                 AssemblyQualify(sb, type, options);
                 NamespaceQualify(sb, type, options);
                 sb.Append(type.DiagnosticName);
index 6dd2d23..087630d 100644 (file)
@@ -1686,25 +1686,9 @@ namespace Internal.TypeSystem.Interop
             var ctor = ManagedType.GetParameterlessConstructor();
             if (ctor == null || ((MetadataType)ManagedType).IsAbstract)
             {
-#if READYTORUN
-                // Let the runtime generate the proper MissingMemberException for this.
-                throw new NotSupportedException();
-#else
-                var emitter = _ilCodeStreams.Emitter;
-
-                MethodSignature ctorSignature = new MethodSignature(0, 0, Context.GetWellKnownType(WellKnownType.Void),
-                      new TypeDesc[] {
-                          Context.GetWellKnownType(WellKnownType.String)
-                      });
-                MethodDesc exceptionCtor = InteropTypes.GetMissingMemberException(Context).GetKnownMethod(".ctor", ctorSignature);
-
-                string name = ((MetadataType)ManagedType).Name;
-                codeStream.Emit(ILOpcode.ldstr, emitter.NewToken(String.Format("'{0}' does not have a default constructor. Subclasses of SafeHandle must have a default constructor to support marshaling a Windows HANDLE into managed code.", name)));
-                codeStream.Emit(ILOpcode.newobj, emitter.NewToken(exceptionCtor));
-                codeStream.Emit(ILOpcode.throw_);
-
-                return;
-#endif
+                ThrowHelper.ThrowMissingMethodException(ManagedType, ".ctor",
+                    new MethodSignature(MethodSignatureFlags.None, genericParameterCount: 0,
+                    ManagedType.Context.GetWellKnownType(WellKnownType.Void), TypeDesc.EmptyTypes));
             }
 
             codeStream.Emit(ILOpcode.newobj, _ilCodeStreams.Emitter.NewToken(ctor));
index d602d44..ff219c6 100644 (file)
@@ -29,11 +29,6 @@ namespace Internal.TypeSystem.Interop
             return context.SystemModule.GetKnownType("System.Runtime.InteropServices", "HandleRef");
         }
 
-        public static MetadataType GetMissingMemberException(TypeSystemContext context)
-        {
-            return context.SystemModule.GetKnownType("System", "MissingMemberException");
-        }
-
         public static MetadataType GetPInvokeMarshal(TypeSystemContext context)
         {
             return context.SystemModule.GetKnownType("System.Runtime.InteropServices", "PInvokeMarshal");
index 1b71574..291136d 100644 (file)
@@ -3,7 +3,7 @@
     <OutputType>Library</OutputType>
     <RootNamespace>ILCompiler.DependencyAnalysisFramework</RootNamespace>
     <AssemblyName>ILCompiler.DependencyAnalysisFramework</AssemblyName>
-    <TargetFramework>netstandard1.3</TargetFramework>
+    <TargetFramework>netstandard2.0</TargetFramework>
     <EnableDefaultCompileItems>false</EnableDefaultCompileItems>
     <Platforms>x64;x86</Platforms>
     <PlatformTarget>AnyCPU</PlatformTarget>
index cea2c96..88400e8 100644 (file)
@@ -4,7 +4,7 @@
     <RootNamespace>Internal.TypeSystem</RootNamespace>
     <AssemblyName>ILCompiler.TypeSystem.ReadyToRun</AssemblyName>
     <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
-    <TargetFramework>netstandard1.3</TargetFramework>
+    <TargetFramework>netstandard2.0</TargetFramework>
     <EnableDefaultCompileItems>false</EnableDefaultCompileItems>
     <Platforms>x64;x86</Platforms>
     <PlatformTarget>AnyCPU</PlatformTarget>
index f5bcb34..e497fdf 100644 (file)
@@ -11,7 +11,13 @@ namespace System
         private static string GetBaseDirectoryCore()
         {
             // Fallback path for hosts that do not set APP_CONTEXT_BASE_DIRECTORY explicitly
-            string? directory = Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location);
+#if CORERT
+            string? path = Environment.ProcessPath;
+#else
+            string? path = Assembly.GetEntryAssembly()?.Location;
+#endif
+
+            string? directory = Path.GetDirectoryName(path);
 
             if (directory == null)
                 return string.Empty;
index 924c524..fd21795 100644 (file)
@@ -28,10 +28,11 @@ namespace System
         // Allow an object to free resources before the object is reclaimed by the GC.
         // This method's virtual slot number is hardcoded in runtimes. Do not add any virtual methods ahead of this.
         [NonVersionable]
-        [SuppressMessage("Microsoft.Performance", "CA1821:RemoveEmptyFinalizers", Justification = "Base finalizer method on Object")]
+#pragma warning disable CA1821 // Remove empty Finalizers
         ~Object()
         {
         }
+#pragma warning restore CA1821
 
         // Returns a String which represents the object instance.  The default
         // for an object is to return the fully qualified name of the class.