[netcore] Cleanups. (mono/mono#17661)
authorZoltan Varga <vargaz@gmail.com>
Fri, 1 Nov 2019 16:52:45 +0000 (12:52 -0400)
committerAleksey Kliger (λgeek) <alklig@microsoft.com>
Fri, 1 Nov 2019 16:52:45 +0000 (12:52 -0400)
* [netcore] Remove the type_info field from RuntimeType, extend the TypeCache structure instead.

* [netcore] Remove some linker exclusions which are not needed.

Commit migrated from https://github.com/mono/mono/commit/e9d68e9485611d47c3ad17f3b4d178089e68cab0

src/mono/mono/metadata/domain.c
src/mono/mono/metadata/object-internals.h
src/mono/mono/metadata/object.c
src/mono/netcore/System.Private.CoreLib/src/LinkerDescriptor/System.Private.CoreLib.xml
src/mono/netcore/System.Private.CoreLib/src/System/RuntimeType.Mono.cs

index 62c1614..5552c32 100644 (file)
@@ -701,8 +701,10 @@ mono_init_internal (const char *filename, const char *exe_filename, const char *
        mono_defaults.multicastdelegate_class = mono_class_load_from_name (
                mono_defaults.corlib, "System", "MulticastDelegate");
 
+#ifndef ENABLE_NETCORE
        mono_defaults.manualresetevent_class = mono_class_load_from_name (
                mono_defaults.corlib, "System.Threading", "ManualResetEvent");
+#endif
 
        mono_defaults.typehandle_class = mono_class_load_from_name (
                 mono_defaults.corlib, "System", "RuntimeTypeHandle");
index 9847514..dba12ee 100644 (file)
@@ -438,14 +438,6 @@ struct _MonoReflectionType {
 /* Safely access System.Type from native code */
 TYPED_HANDLE_DECL (MonoReflectionType);
 
-/* This corresponds to System.RuntimeType */
-typedef struct {
-       MonoReflectionType type;
-       MonoObject *type_info;
-} MonoReflectionMonoType;
-
-TYPED_HANDLE_DECL (MonoReflectionMonoType);
-
 typedef struct {
        MonoObject  object;
        MonoReflectionType *class_to_proxy;     
@@ -1126,16 +1118,6 @@ typedef struct {
 } MonoEventInfo;
 
 typedef struct {
-       MonoString *name;
-       MonoString *name_space;
-       MonoReflectionType *etype;
-       MonoReflectionType *nested_in;
-       MonoReflectionAssembly *assembly;
-       guint32 rank;
-       MonoBoolean isprimitive;
-} MonoTypeInfo;
-
-typedef struct {
        MonoObject *member;
        gint32 code_pos;
 } MonoReflectionILTokenInfo;
index dfbdb0e..a22b9be 100644 (file)
@@ -8125,6 +8125,8 @@ mono_raise_exception_with_context (MonoException *ex, MonoContext *ctx)
        eh_callbacks.mono_raise_exception_with_ctx (ex, ctx);
 }
 
+#ifndef ENABLE_NETCORE
+
 /**
  * mono_wait_handle_new:
  * \param domain Domain where the object will be created
@@ -8173,6 +8175,8 @@ mono_wait_handle_get_handle (MonoWaitHandle *handle)
        return sh->handle;
 }
 
+#endif /* ENABLE_NETCORE */
+
 /*
  * Returns the MonoMethod to call to Capture the ExecutionContext.
  */
@@ -8223,6 +8227,8 @@ mono_runtime_capture_context (MonoDomain *domain, MonoError *error)
 #endif
 }
 
+#ifndef ENABLE_NETCORE
+
 /**
  * mono_async_result_new:
  * \param domain domain where the object will be created.
@@ -8269,7 +8275,6 @@ mono_message_invoke (MonoThreadInfo* mono_thread_info_current_var,
                     MonoObject* target, MonoMethodMessage* msg,
                     MonoObject** exc, MonoArray** out_args, MonoError* error);
 
-#ifndef ENABLE_NETCORE
 MonoObjectHandle
 ves_icall_System_Runtime_Remoting_Messaging_AsyncResult_Invoke (MonoAsyncResultHandle aresh, MonoError* error)
 {
@@ -8342,7 +8347,7 @@ ves_icall_System_Runtime_Remoting_Messaging_AsyncResult_Invoke (MonoAsyncResultH
        }
        return res;
 }
-#endif
+#endif /* ENABLE_NETCORE */
 
 gboolean
 mono_message_init (MonoDomain *domain,
index d11dd5e..5736380 100644 (file)
@@ -3,7 +3,8 @@
        <assembly fullname="System.Private.CoreLib">
        
                <!-- domain.c: mono_defaults.appdomain_class -->
-               <type fullname="Mono.MonoDomain" preserve="fields">
+               <type fullname="Mono.MonoDomain">
+                       <field name="_mono_app_domain"/>
                        <!-- appdomain.c: mono_domain_try_type_resolve -->
                        <method name="DoTypeResolve" />
                        <!-- appdomain.c: mono_domain_try_type_builder_resolve -->
                        <method signature="System.Void .ctor()" />
                </type>
                
-               <!-- threadpool.c: mono_thread_pool_init (assert) -->
-               <type fullname="System.MonoAsyncCall" preserve="fields" >
-                       <!-- threadpool.c mono_object_new_checked in mono_threadpool_begin_invoke -->
-                       <method signature="System.Void .ctor()" />
-               </type>
                <!-- mono-mlist.c (managed list): used in threadpool.c and gc.c -->
                <type fullname="System.MonoListItem" preserve="fields" />
                
                <type fullname="System.RuntimeMethodHandle" preserve="fields" />
 
                <!-- domain.c: mono_defaults.runtimetype_class -->
-               <type fullname="System.RuntimeType" preserve="fields" />
+               <!-- under mono, this has no runtime visible fields -->
+               <type fullname="System.RuntimeType" preserve="nothing" />
 
                <!-- domain.c: mono_defaults.typehandle_class -->
                <type fullname="System.RuntimeTypeHandle" preserve="fields" />
                
                <!-- domain.c: mono_defaults.systemtype_class -->
                <type fullname="System.Type">
+                       <field name="_impl"/>
                        <!-- marshal.c (mono_marshal_get_synchronized_wrapper) -->
                        <method name="GetTypeFromHandle" />
                        <!-- sre.c (mono_reflection_type_get_underlying_system_type) -->
                        <method name=".ctor" />
                </type>
 
-               <!-- icalls - but (at least parts of them) are used thru interfaces at runtime and cannot be linked out -->
-               <type fullname="System.Globalization.DateTimeFormatInfo" preserve="fields" />
-               <type fullname="System.Globalization.CompareInfo" preserve="fields" />
-               <type fullname="System.Globalization.CultureInfo" preserve="fields" />
-               <type fullname="System.Globalization.NumberFormatInfo" preserve="fields" />
-               <type fullname="System.Globalization.RegionInfo" preserve="fields" />
-               <type fullname="System.Globalization.SortKey" preserve="fields" />
-
                <type fullname="System.IO.FileNotFoundException">
                        <!-- mini.c (mono_jit_compiler_method_inner) mono_exception_from_name_msg -->
                        <method signature="System.Void .ctor(System.String)" />
                        <method signature="System.Void .ctor(System.String)" />
                </type>
 
-               <!-- appdomain.c: ves_icall_System_AppDomain_GetAssemblies -->
+               <!-- appdomain.c (ves_icall_System_Runtime_Loader_AssemblyLoadContext_InternalGetLoadedAssemblies) -->
                <type fullname="System.Reflection.Assembly" preserve="fields"/>
 
                <type fullname="System.Reflection.AssemblyName" preserve="fields" />
                        <method signature="System.Void .ctor(System.Object)" />
                </type>
 
-               <!-- icall.c | object-internal.h: MonoReflectionDllImportAttribute structure -->
-               <type fullname="System.Runtime.InteropServices.DllImportAttribute" preserve="fields"/> 
                <!-- marshal.c: emit_marshal_custom (DISABLE_JIT is not defined for the AOT compiler, only the ARM runtimes) -->
                <type fullname="System.Runtime.InteropServices.ICustomMarshaler" />
 
                <type fullname="System.Runtime.InteropServices.MarshalDirectiveException">
                        <method signature="System.Void .ctor(System.String)" />
                </type>
-
-               <!-- exception.c (mono_get_exception_serialization) -->
-               <type fullname="System.Runtime.Serialization.SerializationException">
-                       <!-- mono_exception_from_name_msg -->
-                       <method signature="System.Void .ctor(System.String)" />
-               </type>
-
-               <!-- domain.c: mono_defaults.executioncontext_class -->
-               <type fullname="System.Threading.ExecutionContext">
-                       <!-- security-manager.c: mono_get_context_capture_method (can likely be removed) -->
-                       <method name="Capture" />
-               </type>
-
-               <!-- aot-runtime.c: mono_aot_get_method -->
-               <type fullname="System.Threading.Interlocked">
-                       <method name="CompareExchange" />
-                       <method name="Exchange" />
-               </type>
                
                <!-- domain.c: mono_defaults.monitor_class -->
                <!-- monitor.c / method-to-ir.c: Enter and Exit are only string comparison (safe to link) -->
                        <method name="Exit" />
                </type>
 
-               <!-- domain.c: mono_defaults.manualresetevent_class -->
-               <type fullname="System.Threading.ManualResetEvent" >
-                       <!-- runtime access fields and setter from inherited WaitHandle -->
-                       <method signature="System.Void .ctor(System.Boolean)" />
-               </type>
-
                <!-- exception.c (mono_get_exception_synchronization_lock) -->
                <type fullname="System.Threading.SynchronizationLockException">
                        <!-- mono_exception_from_name_msg -->
                </type>
 
                <!-- domain.c: mono_defaults.thread_class -->
+               <!-- FIXME: -->
                <type fullname="System.Threading.Thread" preserve="fields">
                        <method name="get_CurrentContext" />
                </type>
                        <!-- mono_exception_from_name_msg -->
                        <method signature="System.Void .ctor(System.String)" />
                </type>
-               
-               <!-- object-internals.h: defines MonoWaitHandle, threadpool.c: gets the handle from the structure -->
-               <type fullname="System.Threading.WaitHandle" preserve="fields">
-                       <!-- object.c: mono_wait_handle_new -->
-                       <method name="set_Handle" />
-                       <!-- object.c: mono_wait_handle_get_handle -->
-                       <field name="safe_wait_handle" />
-               </type>
 
                <!-- marshal-ilgen.c (emit_native_icall_wrapper_ilgen) -->
                <type fullname="Mono.RuntimeStructs/MonoError" />
index 190a333..faa2a31 100644 (file)
@@ -1843,11 +1843,6 @@ namespace System
         }
 
         #endregion
-        
-        
-#region keep in sync with object-internals.h
-               MonoTypeInfo type_info;
-#endregion
 
         TypeCache cache;
 
@@ -1864,6 +1859,11 @@ namespace System
         {
             public Enum.EnumInfo EnumInfo;
             public TypeCode TypeCode;
+            // this is the displayed form: special characters
+            // ,+*&*[]\ in the identifier portions of the names
+            // have been escaped with a leading backslash (\)
+            public string full_name;
+            public RuntimeConstructorInfo default_ctor;
         }
 
 
@@ -1874,19 +1874,15 @@ namespace System
 
                internal RuntimeConstructorInfo GetDefaultConstructor ()
                {
-                       RuntimeConstructorInfo ctor = null;
-
-                       if (type_info == null)
-                               type_info = new MonoTypeInfo ();
-                       else
-                               ctor = type_info.default_ctor;
+                       var cache = Cache;
+                       RuntimeConstructorInfo ctor = cache.default_ctor;
 
                        if (ctor == null) {
                                var ctors = GetConstructors (BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.DeclaredOnly);
 
                                for (int i = 0; i < ctors.Length; ++i) {
                                        if (ctors [i].GetParametersCount () == 0) {
-                                               type_info.default_ctor = ctor = (RuntimeConstructorInfo) ctors [i];
+                                               cache.default_ctor = ctor = (RuntimeConstructorInfo) ctors [i];
                                                break;
                                        }
                                }
@@ -2490,11 +2486,9 @@ namespace System
                                        return null;
 
                                string fullName;
-                               // This doesn't need locking
-                               if (type_info == null)
-                                       type_info = new MonoTypeInfo ();
-                               if ((fullName = type_info.full_name) == null)
-                                       fullName = type_info.full_name = getFullName (true, false);
+                               var cache = Cache;
+                               if ((fullName = cache.full_name) == null)
+                                       fullName = cache.full_name = getFullName (true, false);
 
                                return fullName;
                        }
@@ -2564,14 +2558,4 @@ namespace System
             return new StructLayoutAttribute (layoutKind) { Pack = pack, Size = size, CharSet = charSet };
         }
     }
-    
-    // Contains information about the type which is expensive to compute
-    [StructLayout (LayoutKind.Sequential)]
-    internal class MonoTypeInfo {
-        // this is the displayed form: special characters
-        // ,+*&*[]\ in the identifier portions of the names
-        // have been escaped with a leading backslash (\)
-        public string full_name;
-        public RuntimeConstructorInfo default_ctor;
-    }
 }