Merge pull request #3342 from ludovic-henry/gc-domain-finalizer-sem
authorLudovic Henry <ludovic@xamarin.com>
Mon, 1 Aug 2016 16:17:09 +0000 (18:17 +0200)
committerGitHub <noreply@github.com>
Mon, 1 Aug 2016 16:17:09 +0000 (18:17 +0200)
[gc] Replace domain finalizer request cond+mutex by a semaphore

39 files changed:
man/mono.1
mcs/class/Facades/Microsoft.Win32.Registry.AccessControl/Makefile
mcs/class/Facades/System.Data.Common/Makefile
mcs/class/Facades/System.Diagnostics.StackTrace/Makefile
mcs/class/Facades/System.Diagnostics.Tracing/Makefile
mcs/class/Facades/System.Globalization.Extensions/Makefile
mcs/class/Facades/System.IO.FileSystem.AccessControl/Makefile
mcs/class/Facades/System.Net.Sockets/Makefile
mcs/class/Facades/System.Reflection.TypeExtensions/Makefile
mcs/class/Facades/System.Runtime.Serialization.Primitives/Makefile
mcs/class/Facades/System.Runtime.Serialization.Xml/Makefile
mcs/class/Facades/System.Security.Cryptography.Algorithms/Makefile
mcs/class/Facades/System.Security.Cryptography.OpenSsl/Makefile
mcs/class/Facades/System.Security.SecureString/Makefile
mcs/class/Facades/System.ServiceModel.Primitives/Makefile
mcs/class/Facades/System.ServiceProcess.ServiceController/Makefile
mcs/class/Facades/System.Text.Encoding.CodePages/Makefile
mcs/class/Facades/System.Threading.AccessControl/Makefile
mcs/class/Facades/System.Threading.Overlapped/Makefile
mcs/class/Facades/System.Xml.XPath.XDocument/Makefile
mcs/class/corlib/Mono/RuntimeMarshal.cs [new file with mode: 0644]
mcs/class/corlib/Mono/RuntimeStructs.cs
mcs/class/corlib/Mono/SafeStringMarshal.cs [new file with mode: 0644]
mcs/class/corlib/ReferenceSources/RuntimeType.cs
mcs/class/corlib/System.Reflection.Emit/AssemblyBuilder.cs
mcs/class/corlib/System.Reflection/Assembly.cs
mcs/class/corlib/System.Reflection/AssemblyName.cs
mcs/class/corlib/System.Reflection/MonoAssembly.cs
mcs/class/corlib/corlib.dll.sources
mcs/mcs/class.cs
mcs/mcs/ecore.cs
mcs/tests/gtest-lambda-37.cs [new file with mode: 0644]
mcs/tests/test-938.cs [new file with mode: 0644]
mcs/tests/ver-il-net_4_x.xml
mono/metadata/assembly.c
mono/metadata/icall-def.h
mono/metadata/icall.c
mono/mini/debugger-agent.c
mono/mini/mini-arm.c

index fa6fdc0ed13a4abc8cae34dbaa6a486a1fa4f3fd..c4589ea70c7243f74525d5669f342c983f24f39b 100644 (file)
@@ -1100,7 +1100,7 @@ a Mono process through the environment.   This is useful for example
 to force all of your Mono processes to use LLVM or SGEN without having
 to modify any launch scripts.
 .TP
-\fBMONO_ENV_OPTIONS\fR
+\fBMONO_SDB_ENV_OPTIONS\fR
 Used to pass extra options to the debugger agent in the runtime, as they were passed
 using --debugger-agent=.
 .TP
index 0b5f4acf6daad43a1597f99ada62b9ebd4f05fc2..4197137c95ee1093c968bb85209da78202287b9a 100644 (file)
@@ -14,8 +14,6 @@ SIGN_FLAGS = /delaysign /keyfile:$(KEY_FILE) /nowarn:1616,1699
 LIB_REFS = System
 LIB_MCS_FLAGS = $(SIGN_FLAGS) 
 
-PLATFORM_DEBUG_FLAGS =
-
 NO_TEST = yes
 
 include $(MCS_BUILD_DIR)/library.make
index ff6d03567897533cc1b43a22bd216a4bcecea509..fe63a8e0f7b1c2feb776fc73b0f8bef97e5c2e9b 100644 (file)
@@ -14,8 +14,6 @@ SIGN_FLAGS = /delaysign /keyfile:$(KEY_FILE) /nowarn:1616,1699
 LIB_REFS = System System.Data System.Xml
 LIB_MCS_FLAGS = $(SIGN_FLAGS)
 
-PLATFORM_DEBUG_FLAGS =
-
 NO_TEST = yes
 
 include $(MCS_BUILD_DIR)/library.make
index 25d8ac37eddd1351ee41e37670615d9b8df46531..4cc9d7f1a3bee21d447328e91d858fef184fcbc3 100644 (file)
@@ -14,8 +14,6 @@ SIGN_FLAGS = /delaysign /keyfile:$(KEY_FILE) /nowarn:1616,1699
 LIB_REFS = System
 LIB_MCS_FLAGS = $(SIGN_FLAGS) 
 
-PLATFORM_DEBUG_FLAGS =
-
 NO_TEST = yes
 
 include $(MCS_BUILD_DIR)/library.make
index 14b380da866454c7569c53a115dfa4e473422415..d74812c5e9f37df4cb06b1a044a3b67932b01081 100644 (file)
@@ -13,8 +13,6 @@ KEY_FILE = ../../msfinal.pub
 SIGN_FLAGS = /delaysign /keyfile:$(KEY_FILE) /nowarn:1616,1699
 LIB_MCS_FLAGS = $(SIGN_FLAGS) 
 
-PLATFORM_DEBUG_FLAGS =
-
 NO_TEST = yes
 
 include $(MCS_BUILD_DIR)/library.make
index d3a57fa307dbd8b7121b25630aa667270b3dc640..446a41276071919f313a88018b1ef9cb6b6aeb89 100644 (file)
@@ -14,8 +14,6 @@ SIGN_FLAGS = /delaysign /keyfile:$(KEY_FILE) /nowarn:1616,1699
 LIB_REFS = System
 LIB_MCS_FLAGS = $(SIGN_FLAGS) 
 
-PLATFORM_DEBUG_FLAGS =
-
 NO_TEST = yes
 
 include $(MCS_BUILD_DIR)/library.make
index 0198747a8a312def61d8cb153e45a6b6d038c168..9efb35542bf8ec2e85c7c8d94db0df651674a675 100644 (file)
@@ -14,8 +14,6 @@ SIGN_FLAGS = /delaysign /keyfile:$(KEY_FILE) /nowarn:1616,1699
 LIB_REFS = System
 LIB_MCS_FLAGS = $(SIGN_FLAGS) 
 
-PLATFORM_DEBUG_FLAGS =
-
 NO_TEST = yes
 
 include $(MCS_BUILD_DIR)/library.make
index bf60d5fef6be2147d79b9b70e5ab29430dc1f651..497c05462276fee5be2ca4b18564dd8e33947548 100644 (file)
@@ -14,8 +14,6 @@ SIGN_FLAGS = /delaysign /keyfile:$(KEY_FILE) /nowarn:1616,1699
 LIB_REFS = System
 LIB_MCS_FLAGS = $(SIGN_FLAGS)
 
-PLATFORM_DEBUG_FLAGS =
-
 NO_TEST = yes
 
 include $(MCS_BUILD_DIR)/library.make
index b2bb49ecfd1b431029d66f45927f36d0e712e26b..374132468e61aebb09604f1e0bac3efe928001f5 100644 (file)
@@ -14,8 +14,6 @@ SIGN_FLAGS = /delaysign /keyfile:$(KEY_FILE) /nowarn:1616,1699
 LIB_REFS = System
 LIB_MCS_FLAGS = $(SIGN_FLAGS) 
 
-PLATFORM_DEBUG_FLAGS =
-
 NO_TEST = yes
 
 include $(MCS_BUILD_DIR)/library.make
index 3a2519549fc638191e38dad30136d69222edbd3a..22a0d90aae49b611b513e31f72ce4ffeaaa5f728 100644 (file)
@@ -14,8 +14,6 @@ SIGN_FLAGS = /delaysign /keyfile:$(KEY_FILE) /nowarn:1616,1699
 LIB_REFS = System.Runtime.Serialization
 LIB_MCS_FLAGS = $(SIGN_FLAGS) 
 
-PLATFORM_DEBUG_FLAGS =
-
 NO_TEST = yes
 
 include $(MCS_BUILD_DIR)/library.make
index dc0a84d022933675423cf9435280d42f3c277367..1314e94f39d484616a65c08ba57297e6246479c9 100644 (file)
@@ -18,8 +18,6 @@ ifeq (2.1, $(FRAMEWORK_VERSION))
 LIB_MCS_FLAGS += /d:NO_CODEDOM
 endif
 
-PLATFORM_DEBUG_FLAGS =
-
 NO_TEST = yes
 
 include $(MCS_BUILD_DIR)/library.make
index 389a11cf6cf8d9fa9e39ee2c4fb4774bc2492247..e65ee83c7ab30a2f44656292ed9f44752a5c7e76 100644 (file)
@@ -14,8 +14,6 @@ SIGN_FLAGS = /delaysign /keyfile:$(KEY_FILE) /nowarn:1616,1699
 LIB_REFS = System System.Core
 LIB_MCS_FLAGS = $(SIGN_FLAGS)
 
-PLATFORM_DEBUG_FLAGS =
-
 NO_TEST = yes
 
 include $(MCS_BUILD_DIR)/library.make
index aa30bc935a1fa9edc82dcdfbb086c835ce394ef4..16bae2df174a282a1cf8fa44b26fca8819a1ad21 100644 (file)
@@ -14,8 +14,6 @@ SIGN_FLAGS = /delaysign /keyfile:$(KEY_FILE) /nowarn:1616,1699
 LIB_REFS = System.Core
 LIB_MCS_FLAGS = $(SIGN_FLAGS)
 
-PLATFORM_DEBUG_FLAGS =
-
 NO_TEST = yes
 
 include $(MCS_BUILD_DIR)/library.make
index b33d20dc20261912e900021303cca36c3d41bda3..0569f621974fbf469b5148d5f814caefbeb7aea6 100644 (file)
@@ -14,8 +14,6 @@ SIGN_FLAGS = /delaysign /keyfile:$(KEY_FILE) /nowarn:1616,1699
 LIB_REFS = System
 LIB_MCS_FLAGS = $(SIGN_FLAGS) 
 
-PLATFORM_DEBUG_FLAGS =
-
 NO_TEST = yes
 
 include $(MCS_BUILD_DIR)/library.make
index b89ba3525c8652877cf796a1b56edf2c72a59ed2..3c12456831dcfa7317f2aff4f559a6628a26463a 100644 (file)
@@ -19,8 +19,6 @@ endif
 
 LIB_MCS_FLAGS = $(SIGN_FLAGS) 
 
-PLATFORM_DEBUG_FLAGS =
-
 NO_TEST = yes
 
 include $(MCS_BUILD_DIR)/library.make
index 5fa4c609b0ba9bf81b857a8c688e79cfb7f3ae6f..fe6edb861f243350862241c72bc293d517f30973 100644 (file)
@@ -21,8 +21,6 @@ endif
 
 LIB_MCS_FLAGS = $(SIGN_FLAGS)
 
-PLATFORM_DEBUG_FLAGS =
-
 NO_TEST = yes
 
 include $(MCS_BUILD_DIR)/library.make
index 7430a65175bafb63ac8b52e73c0071d905119781..3c678ee54f79b3d041ffb587dd4ab90c7ed5edd9 100644 (file)
@@ -14,8 +14,6 @@ SIGN_FLAGS = /delaysign /keyfile:$(KEY_FILE) /nowarn:1616,1699
 LIB_REFS = System
 LIB_MCS_FLAGS = $(SIGN_FLAGS)
 
-PLATFORM_DEBUG_FLAGS =
-
 NO_TEST = yes
 
 include $(MCS_BUILD_DIR)/library.make
index b0c9264a03b466ee7b50290b3c4b12b5fb140b92..a5de66c999827fa2f60998ed9448505878d30238 100644 (file)
@@ -14,8 +14,6 @@ SIGN_FLAGS = /delaysign /keyfile:$(KEY_FILE) /nowarn:1616,1699
 LIB_REFS = System
 LIB_MCS_FLAGS = $(SIGN_FLAGS) 
 
-PLATFORM_DEBUG_FLAGS =
-
 NO_TEST = yes
 
 include $(MCS_BUILD_DIR)/library.make
index 061c46b236be0470d5f3818dc7a59b00709e404c..a36686196bb6166454cc863758e702ab05ac4fe9 100644 (file)
@@ -14,8 +14,6 @@ SIGN_FLAGS = /delaysign /keyfile:$(KEY_FILE) /nowarn:1616,1699
 LIB_REFS = System
 LIB_MCS_FLAGS = $(SIGN_FLAGS) -unsafe
 
-PLATFORM_DEBUG_FLAGS =
-
 NO_TEST = yes
 
 include $(MCS_BUILD_DIR)/library.make
index 16a26f2c55db1e21bbb3c17affae841887e4c8d8..36a3de971bd933879a05d8aed0bb6e52e3262dca 100644 (file)
@@ -14,8 +14,6 @@ SIGN_FLAGS = /delaysign /keyfile:$(KEY_FILE) /nowarn:1616,1699
 LIB_REFS = System System.Xml System.Xml.Linq
 LIB_MCS_FLAGS = $(SIGN_FLAGS)
 
-PLATFORM_DEBUG_FLAGS =
-
 NO_TEST = yes
 
 include $(MCS_BUILD_DIR)/library.make
diff --git a/mcs/class/corlib/Mono/RuntimeMarshal.cs b/mcs/class/corlib/Mono/RuntimeMarshal.cs
new file mode 100644 (file)
index 0000000..38da4e2
--- /dev/null
@@ -0,0 +1,65 @@
+using System;
+using System.Runtime.InteropServices;
+using System.Runtime.CompilerServices;
+
+namespace Mono {
+       internal static class RuntimeMarshal {
+               internal static string PtrToUtf8String (IntPtr ptr)
+               {
+                       unsafe {
+                               return new String ((sbyte*)ptr);
+                       }
+               }
+
+               internal static SafeStringMarshal MarshalString (string str)
+               {
+                       return new SafeStringMarshal (str);
+               }
+
+               static int DecodeBlobSize (IntPtr in_ptr, out IntPtr out_ptr)
+               {
+                       uint size;
+                       unsafe {
+                               byte *ptr = (byte*)in_ptr;
+       
+                               if ((*ptr & 0x80) == 0) {
+                                       size = (uint)(ptr [0] & 0x7f);
+                                       ptr++;
+                               } else if ((*ptr & 0x40) == 0){
+                                       size = (uint)(((ptr [0] & 0x3f) << 8) + ptr [1]);
+                                       ptr += 2;
+                               } else {
+                                       size = (uint)(((ptr [0] & 0x1f) << 24) +
+                                               (ptr [1] << 16) +
+                                               (ptr [2] << 8) +
+                                               ptr [3]);
+                                       ptr += 4;
+                               }
+                               out_ptr = (IntPtr)ptr;
+                       }
+
+                       return (int)size;
+               }
+
+               internal static byte[] DecodeBlobArray (IntPtr ptr)
+               {
+                       IntPtr out_ptr;
+                       int size = DecodeBlobSize (ptr, out out_ptr);
+                       byte[] res = new byte [size];
+                       Marshal.Copy (out_ptr, res, 0, size);
+                       return res;
+               }
+
+               internal static int AsciHexDigitValue (int c)
+               {
+                       if (c >= '0' && c <= '9')
+                               return c - '0';
+                       if (c >= 'a' && c <= 'f')
+                               return c - 'a' + 10;
+                       return c - 'A' + 10;
+               }
+
+               [MethodImpl (MethodImplOptions.InternalCall)]
+               internal static extern void FreeAssemblyName (ref MonoAssemblyName name);
+       }
+}
index 20cd93fdaecfa0c70be0f1ae84d492588b1b41aa..ae4550632088f8f90a6bb408a699180857c097b5 100644 (file)
@@ -45,5 +45,20 @@ namespace Mono {
                }
        }
 
+       //Maps to metadata-internals.h:: MonoAssemblyName
+       internal unsafe struct MonoAssemblyName
+       {
+               const int MONO_PUBLIC_KEY_TOKEN_LENGTH = 17;
+
+               internal IntPtr name;
+               internal IntPtr culture;
+               internal IntPtr hash_value;
+               internal IntPtr public_key;
+               internal fixed byte public_key_token [MONO_PUBLIC_KEY_TOKEN_LENGTH];
+               internal uint hash_alg;
+               internal uint hash_len;
+               internal uint flags;
+               internal ushort major, minor, build, revision;
+               internal ushort arch;
+       }
 }
-       
diff --git a/mcs/class/corlib/Mono/SafeStringMarshal.cs b/mcs/class/corlib/Mono/SafeStringMarshal.cs
new file mode 100644 (file)
index 0000000..c18f0d3
--- /dev/null
@@ -0,0 +1,46 @@
+//
+// Safe wrapper for a string and its UTF8 encoding
+//
+// Authors:
+//   Aleksey Kliger <aleksey@xamarin.com>
+//   Rodrigo Kumpera <kumpera@xamarin.com>
+//
+// Copyright 2016 Dot net foundation.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+using System;
+using System.Runtime.CompilerServices;
+
+namespace Mono  {
+       internal struct SafeStringMarshal : IDisposable {
+               readonly string str;
+               IntPtr marshaled_string;
+
+               [MethodImplAttribute(MethodImplOptions.InternalCall)]
+               public extern static IntPtr StringToUtf8 (string str);
+
+               [MethodImplAttribute(MethodImplOptions.InternalCall)]
+               public extern static void GFree (IntPtr ptr);
+
+               public SafeStringMarshal (string str) {
+                       this.str = str;
+                       this.marshaled_string = IntPtr.Zero;
+               }
+
+               public IntPtr Value {
+                       get {
+                               if (marshaled_string == IntPtr.Zero && str != null)
+                                       marshaled_string = StringToUtf8 (str);
+                               return marshaled_string;
+                       }
+               }
+
+               public void Dispose () {
+                       if (marshaled_string != IntPtr.Zero) {
+                               GFree (marshaled_string);
+                               marshaled_string = IntPtr.Zero;
+                       }
+               }
+       }
+}
index 189ad1dc7fd9ce7f2ffb617ae904c662f898cef1..8a49451936e5fd80e95e17913a2a3025084c5f7d 100644 (file)
@@ -472,12 +472,13 @@ namespace System
                static extern Type MakeGenericType (Type gt, Type [] types);
 
                [MethodImplAttribute(MethodImplOptions.InternalCall)]
-               internal extern IntPtr GetMethodsByName_native (string name, BindingFlags bindingAttr, bool ignoreCase);
+               internal extern IntPtr GetMethodsByName_native (IntPtr namePtr, BindingFlags bindingAttr, bool ignoreCase);
 
                internal RuntimeMethodInfo[] GetMethodsByName (string name, BindingFlags bindingAttr, bool ignoreCase, RuntimeType reflectedType)
                {
                        var refh = new RuntimeTypeHandle (reflectedType);
-                       using (var h = new Mono.SafeGPtrArrayHandle (GetMethodsByName_native (name, bindingAttr, ignoreCase))) {
+                       using (var namePtr = new Mono.SafeStringMarshal (name))
+                       using (var h = new Mono.SafeGPtrArrayHandle (GetMethodsByName_native (namePtr.Value, bindingAttr, ignoreCase))) {
                                var n = h.Length;
                                var a = new RuntimeMethodInfo [n];
                                for (int i = 0; i < n; i++) {
@@ -489,7 +490,7 @@ namespace System
                }
 
                [MethodImplAttribute(MethodImplOptions.InternalCall)]
-               extern IntPtr GetPropertiesByName_native (string name, BindingFlags bindingAttr, bool icase);           
+               extern IntPtr GetPropertiesByName_native (IntPtr name, BindingFlags bindingAttr, bool icase);           
 
                [MethodImplAttribute(MethodImplOptions.InternalCall)]
                extern IntPtr GetConstructors_native (BindingFlags bindingAttr);
@@ -511,7 +512,8 @@ namespace System
                RuntimePropertyInfo[] GetPropertiesByName (string name, BindingFlags bindingAttr, bool icase, RuntimeType reflectedType)
                {
                        var refh = new RuntimeTypeHandle (reflectedType);
-                       using (var h = new Mono.SafeGPtrArrayHandle (GetPropertiesByName_native (name, bindingAttr, icase))) {
+                       using (var namePtr = new Mono.SafeStringMarshal (name))
+                       using (var h = new Mono.SafeGPtrArrayHandle (GetPropertiesByName_native (namePtr.Value, bindingAttr, icase))) {
                                var n = h.Length;
                                var a = new RuntimePropertyInfo [n];
                                for (int i = 0; i < n; i++) {
@@ -669,15 +671,16 @@ namespace System
                extern int GetGenericParameterPosition ();
 
                [MethodImplAttribute(MethodImplOptions.InternalCall)]
-               extern IntPtr GetEvents_native (string name, BindingFlags bindingAttr);
+               extern IntPtr GetEvents_native (IntPtr name, BindingFlags bindingAttr);
 
                [MethodImplAttribute(MethodImplOptions.InternalCall)]
-               extern IntPtr GetFields_native (string name, BindingFlags bindingAttr);
+               extern IntPtr GetFields_native (IntPtr name, BindingFlags bindingAttr);
 
                RuntimeFieldInfo[] GetFields_internal (string name, BindingFlags bindingAttr, RuntimeType reflectedType)
                {
                        var refh = new RuntimeTypeHandle (reflectedType);
-                       using (var h = new Mono.SafeGPtrArrayHandle (GetFields_native (name, bindingAttr))) {
+                       using (var namePtr = new Mono.SafeStringMarshal (name))
+                       using (var h = new Mono.SafeGPtrArrayHandle (GetFields_native (namePtr.Value, bindingAttr))) {
                                int n = h.Length;
                                var a = new RuntimeFieldInfo[n];
                                for (int i = 0; i < n; i++) {
@@ -691,7 +694,8 @@ namespace System
                RuntimeEventInfo[] GetEvents_internal (string name, BindingFlags bindingAttr, RuntimeType reflectedType)
                {
                        var refh = new RuntimeTypeHandle (reflectedType);
-                       using (var h = new Mono.SafeGPtrArrayHandle (GetEvents_native (name, bindingAttr))) {
+                       using (var namePtr = new Mono.SafeStringMarshal (name))
+                       using (var h = new Mono.SafeGPtrArrayHandle (GetEvents_native (namePtr.Value, bindingAttr))) {
                                int n = h.Length;
                                var a = new RuntimeEventInfo[n];
                                for (int i = 0; i < n; i++) {
@@ -706,7 +710,24 @@ namespace System
                public extern override Type[] GetInterfaces();
 
                [MethodImplAttribute(MethodImplOptions.InternalCall)]
-               extern RuntimeType[] GetNestedTypes_internal (string name, BindingFlags bindingAttr);           
+               extern IntPtr GetNestedTypes_native (IntPtr name, BindingFlags bindingAttr);
+
+               RuntimeType[] GetNestedTypes_internal (string displayName, BindingFlags bindingAttr)
+               {
+                       string internalName = null;
+                       if (displayName != null)
+                               internalName = TypeIdentifiers.FromDisplay (displayName).InternalName;
+                       using (var namePtr = new Mono.SafeStringMarshal (internalName))
+                       using (var h = new Mono.SafeGPtrArrayHandle (GetNestedTypes_native (namePtr.Value, bindingAttr))) {
+                               int n = h.Length;
+                               var a = new RuntimeType [n];
+                               for (int i = 0; i < n; i++) {
+                                       var th = new RuntimeTypeHandle (h[i]);
+                                       a[i] = (RuntimeType) Type.GetTypeFromHandle (th);
+                               }
+                               return a;
+                       }
+               }
 
                public override string AssemblyQualifiedName {
                        get {
index 6a6fcd36f5abe114d6eaa3751587690b41811a6c..0a189e1faa7e70b7a2db00d32532f5ee80005c82 100644 (file)
@@ -1114,8 +1114,7 @@ namespace System.Reflection.Emit
 
                public override AssemblyName GetName (bool copiedName)
                {
-                       AssemblyName aname = new AssemblyName ();
-                       FillName (this, aname);
+                       var aname = AssemblyName.Create (this, false);
 
                        if (sn != null) {
                                aname.SetPublicKey (sn.PublicKey);
index c90059d3a87432239118d0ab5d144e5bcac1a03e..174d5da5813c72bd9f6b960af06813128db67a7d 100644 (file)
@@ -88,7 +88,7 @@ namespace System.Reflection {
 
                // Note: changes to fields must be reflected in _MonoReflectionAssembly struct (object-internals.h)
 #pragma warning disable 649
-               private IntPtr _mono_assembly;
+               internal IntPtr _mono_assembly;
 #pragma warning restore 649
 
                private ResolveEventHolder resolve_event_holder;
@@ -425,9 +425,6 @@ namespace System.Reflection {
                [MethodImplAttribute (MethodImplOptions.InternalCall)]
                internal extern static void InternalGetAssemblyName (string assemblyFile, AssemblyName aname);
 
-               [MethodImplAttribute (MethodImplOptions.InternalCall)]
-               static extern internal void FillName (Assembly ass, AssemblyName aname);
-
                public virtual AssemblyName GetName (Boolean copiedName)
                {
                        throw new NotImplementedException ();
index 42006c3e80f99ce9594cecccc582d21a1b0fc395..7ce7241cc98c8851f6893ca193722e3c679c5f90 100644 (file)
@@ -40,6 +40,7 @@ using System.Runtime.InteropServices;
 using System.Runtime.CompilerServices;
 using System.IO;
 
+using Mono;
 using Mono.Security;
 using Mono.Security.Cryptography;
 
@@ -84,17 +85,29 @@ namespace System.Reflection {
                }
 
                [MethodImpl (MethodImplOptions.InternalCall)]
-               static extern bool ParseName (AssemblyName aname, string assemblyName);
-               
+               static extern bool ParseAssemblyName (IntPtr name, out MonoAssemblyName aname, out bool is_version_definited, out bool is_token_defined);
+
                public AssemblyName (string assemblyName)
                {
                        if (assemblyName == null)
                                throw new ArgumentNullException ("assemblyName");
                        if (assemblyName.Length < 1)
                                throw new ArgumentException ("assemblyName cannot have zero length.");
-                               
-                       if (!ParseName (this, assemblyName))
-                               throw new FileLoadException ("The assembly name is invalid.");
+
+                       using (var name = RuntimeMarshal.MarshalString (assemblyName)) {
+                               MonoAssemblyName nativeName;
+                               bool isVersionDefined, isTokenDefined;
+                               //ParseName free the name if it fails.
+                               if (!ParseAssemblyName (name.Value, out nativeName, out isVersionDefined, out isTokenDefined))
+                                       throw new FileLoadException ("The assembly name is invalid.");
+                               try {
+                                       unsafe {
+                                               this.FillName (&nativeName, null, isVersionDefined, false, isTokenDefined);
+                                       }
+                               } finally {
+                                       RuntimeMarshal.FreeAssemblyName (ref nativeName);
+                               }
+                       }
                }
                
                [MonoLimitation ("Not used, as the values are too limited;  Mono supports more")]
@@ -449,5 +462,63 @@ namespace System.Reflection {
                                contentType = value;
                        }
                }
+
+               [MethodImplAttribute (MethodImplOptions.InternalCall)]
+               static extern unsafe MonoAssemblyName* GetNativeName (IntPtr assembly_ptr);
+
+               internal unsafe void FillName (MonoAssemblyName *native, string codeBase, bool addVersion, bool addPublickey, bool defaultToken)
+               {
+                       this.name = RuntimeMarshal.PtrToUtf8String (native->name);
+
+                       this.major = native->major;
+                       this.minor = native->minor;
+                       this.build = native->build;
+                       this.revision = native->revision;
+
+                       this.flags = (AssemblyNameFlags)native->flags;
+
+                       this.hashalg = (AssemblyHashAlgorithm)native->hash_alg;
+
+                       this.versioncompat = AssemblyVersionCompatibility.SameMachine;
+                       this.processor_architecture = (ProcessorArchitecture)native->arch;
+
+                       if (addVersion)
+                               this.version = new Version (this.major, this.minor, this.build, this.revision);
+
+                       this.codebase = codeBase;
+
+                       if (native->culture != IntPtr.Zero)
+                               this.cultureinfo = CultureInfo.CreateCulture ( RuntimeMarshal.PtrToUtf8String (native->culture), false);
+
+                       if (native->public_key != IntPtr.Zero) {
+                               this.publicKey = RuntimeMarshal.DecodeBlobArray (native->public_key);
+                               this.flags |= AssemblyNameFlags.PublicKey;
+                       } else if (addPublickey) {
+                               this.publicKey = EmptyArray<byte>.Value;
+                               this.flags |= AssemblyNameFlags.PublicKey;
+                       }
+
+                       // MonoAssemblyName keeps the public key token as an hexadecimal string
+                       if (native->public_key_token [0] != 0) {
+                               byte[] keyToken = new byte [8];
+                               for (int i = 0, j = 0; i < 8; ++i) {
+                                       keyToken [i] = (byte)(RuntimeMarshal.AsciHexDigitValue (native->public_key_token [j++]) << 4);
+                                       keyToken [i] |= (byte)RuntimeMarshal.AsciHexDigitValue (native->public_key_token [j++]);
+                               }
+                               this.keyToken = keyToken;
+                       } else if (defaultToken) {
+                               this.keyToken = EmptyArray<byte>.Value;
+                       }
+               }
+
+               internal static AssemblyName Create (Assembly assembly, bool fillCodebase)
+               {
+                       AssemblyName aname = new AssemblyName ();
+                       unsafe {
+                               MonoAssemblyName *native = GetNativeName (assembly._mono_assembly);
+                               aname.FillName (native, fillCodebase ? assembly.CodeBase : null, true, true, true);
+                       }
+                       return aname;
+               }
        }
 }
index c433bc93dc8866598b839801f6ccb0effbaea6b3..a62b86a63ef2a8665c2315a5f8ae03c3c85ae092 100644 (file)
@@ -41,6 +41,8 @@ using System.Security;
 using System.Security.Policy;
 using System.Security.Permissions;
 
+using Mono;
+
 namespace System.Reflection {
 
        abstract class RuntimeAssembly : Assembly
@@ -162,12 +164,8 @@ namespace System.Reflection {
                                var _ = CodeBase; // this will ensure the Demand is made
                        }
 #endif
-
-                       AssemblyName aname = new AssemblyName ();
-                       FillName (this, aname);
-                       return aname;
+                       return AssemblyName.Create (this, true);
                }
-
        }
 
        [ComVisible (true)]
index b36d3d446bc4cea25a3674a2ca7ffe6724df5484..6406b39c7dac0c0aaaf3cda71452b044c5c8527f 100644 (file)
@@ -23,9 +23,11 @@ Mono.Globalization.Unicode/SortKeyBuffer.cs
 Mono.Globalization.Unicode/Normalization.cs
 Mono.Globalization.Unicode/NormalizationTableUtil.cs
 Mono/Runtime.cs
-Mono/RuntimeStructs.cs
 Mono/RuntimeHandles.cs
+Mono/RuntimeMarshal.cs
+Mono/RuntimeStructs.cs
 Mono/SafeGPtrArrayHandle.cs
+Mono/SafeStringMarshal.cs
 Mono/DataConverter.cs
 Mono.Interop/ComInteropProxy.cs
 Mono.Interop/IDispatch.cs
index ceeff52fcfe7475c13f120cce8e6ec060224912c..96ac0c8db4c24aacc9f18f573adfff3d885d54da 100644 (file)
@@ -1853,7 +1853,7 @@ namespace Mono.CSharp
                                        return base_type;
                        }
 
-                       if (iface_exprs != null) {
+                       if (iface_exprs != null && this is Interface) {
                                foreach (var iface in iface_exprs) {
                                        // the interface might not have been resolved, prevents a crash, see #442144
                                        if (iface == null)
index f15d1a8d12dc03e3cc09b5eceec98220851233cb..e0e5b6f4748d3a4f4da983f54eb16973b1859dd8 100644 (file)
@@ -4467,6 +4467,10 @@ namespace Mono.CSharp {
                {
                        TypeSpec argument_type = a.Type;
 
+                       //
+                       // Exactly matching Expression phase
+                       //
+
                        //
                        // If argument is an anonymous function
                        //
@@ -4528,17 +4532,20 @@ namespace Mono.CSharp {
 
                                if (q != p) {
                                        //
-                                       // An inferred return type X exists for E in the context of that parameter list, and 
-                                       // the conversion from X to Y1 is better than the conversion from X to Y2
+                                       // An inferred return type X exists for E in the context of the parameter list, and
+                                       // an identity conversion exists from X to the return type of D
                                        //
-                                       argument_type = am.InferReturnType (ec, null, orig_q);
-                                       if (argument_type == null) {
-                                               // TODO: Can this be hit?
-                                               return 1;
-                                       }
+                                       var inferred_type = am.InferReturnType (ec, null, orig_q);
+                                       if (inferred_type != null) {
+                                               if (inferred_type.BuiltinType == BuiltinTypeSpec.Type.Dynamic)
+                                                       inferred_type = ec.BuiltinTypes.Object;
+
+                                               if (inferred_type == p)
+                                                       return 1;
 
-                                       if (argument_type.BuiltinType == BuiltinTypeSpec.Type.Dynamic)
-                                               argument_type = ec.BuiltinTypes.Object;
+                                               if (inferred_type == q)
+                                                       return 2;
+                                       }
                                }
                        }
 
diff --git a/mcs/tests/gtest-lambda-37.cs b/mcs/tests/gtest-lambda-37.cs
new file mode 100644 (file)
index 0000000..ffc669e
--- /dev/null
@@ -0,0 +1,38 @@
+using System;
+
+public class MainClass 
+{
+       static long? X<T> (T a1, Func<T, T?> a2) where T : struct
+       {
+               return 0;
+       }
+
+       static int? X<T> (T a1, Func<T, int?> a2)
+       {
+               return 0;
+       }
+
+       static double? X<T> (T a1, Func<T, double?> a2)
+       {
+               return null;
+       }
+
+       public static void Main ()
+       {
+               int? sum = X<int> (1, i => {
+                       if (i > 0)
+                               return i;
+
+                       return null;
+               });
+
+
+               int? sum2 = X (1, i => {
+                       if (i > 0)
+                               return i;
+
+                       return null;
+               });
+
+       }
+}
diff --git a/mcs/tests/test-938.cs b/mcs/tests/test-938.cs
new file mode 100644 (file)
index 0000000..17bf81e
--- /dev/null
@@ -0,0 +1,13 @@
+namespace Example
+{
+       public class A : A.InnerInterface
+       {
+               public interface InnerInterface
+               {
+               }
+
+               public static void Main ()
+               {
+               } 
+       }
+}
\ No newline at end of file
index a9191e25edb43fd5e6d0c3d5fe504eef993cca99..79e1b18bf10b992f0e7b5578a81fb54ac33b8a94 100644 (file)
       </method>
     </type>
   </test>
+  <test name="gtest-lambda-37.cs">
+    <type name="MainClass">
+      <method name="System.Nullable`1[System.Int64] X[T](T, System.Func`2[T,System.Nullable`1[T]])" attrs="145">
+        <size>16</size>
+      </method>
+      <method name="System.Nullable`1[System.Int32] X[T](T, System.Func`2[T,System.Nullable`1[System.Int32]])" attrs="145">
+        <size>15</size>
+      </method>
+      <method name="System.Nullable`1[System.Double] X[T](T, System.Func`2[T,System.Nullable`1[System.Double]])" attrs="145">
+        <size>18</size>
+      </method>
+      <method name="Void Main()" attrs="150">
+        <size>74</size>
+      </method>
+      <method name="System.Nullable`1[System.Int32] &lt;Main&gt;m__0(Int32)" attrs="145">
+        <size>37</size>
+      </method>
+      <method name="System.Nullable`1[System.Int32] &lt;Main&gt;m__1(Int32)" attrs="145">
+        <size>37</size>
+      </method>
+      <method name="Void .ctor()" attrs="6278">
+        <size>7</size>
+      </method>
+    </type>
+  </test>
   <test name="gtest-linq-01.cs">
     <type name="from.C">
       <method name="Void Main()" attrs="150">
       </method>
     </type>
   </test>
+  <test name="test-938.cs">
+    <type name="Example.A">
+      <method name="Void Main()" attrs="150">
+        <size>2</size>
+      </method>
+      <method name="Void .ctor()" attrs="6278">
+        <size>7</size>
+      </method>
+    </type>
+  </test>
   <test name="test-94.cs">
     <type name="Base">
       <method name="Int32 IVehicle.Start()" attrs="481">
index d59d688c9aef2e19d3488905b241e225f2fdb8a1..4bad7dc5ed6d85719bd7426b3e906655c833c127 100644 (file)
@@ -1999,6 +1999,7 @@ mono_assembly_name_free (MonoAssemblyName *aname)
        g_free ((void *) aname->name);
        g_free ((void *) aname->culture);
        g_free ((void *) aname->hash_value);
+       g_free ((guint8*) aname->public_key);
 }
 
 static gboolean
index 757ed8c5be79f0dbc270a476f5eb2c9c359d997a..d529af28d6c79fc479268620d7795659c05b27d8 100644 (file)
@@ -68,6 +68,13 @@ ICALL(RTCLASS_1, "GetTypeFromClass", ves_icall_Mono_RuntimeClassHandle_GetTypeFr
 ICALL_TYPE(RTPTRARRAY, "Mono.RuntimeGPtrArrayHandle", RTPTRARRAY_1)
 ICALL(RTPTRARRAY_1, "GPtrArrayFree", ves_icall_Mono_RuntimeGPtrArrayHandle_GPtrArrayFree)
 
+ICALL_TYPE(RTMARSHAL, "Mono.RuntimeMarshal", RTMARSHAL_1)
+ICALL(RTMARSHAL_1, "FreeAssemblyName", ves_icall_Mono_RuntimeMarshal_FreeAssemblyName)
+
+ICALL_TYPE(SAFESTRMARSHAL, "Mono.SafeStringMarshal", SAFESTRMARSHAL_1)
+ICALL(SAFESTRMARSHAL_1, "GFree", ves_icall_Mono_SafeStringMarshal_GFree)
+ICALL(SAFESTRMARSHAL_2, "StringToUtf8", ves_icall_Mono_SafeStringMarshal_StringToUtf8)
+
 #ifndef PLATFORM_RO_FS
 ICALL_TYPE(KPAIR, "Mono.Security.Cryptography.KeyPairPersistence", KPAIR_1)
 ICALL(KPAIR_1, "_CanSecure", ves_icall_Mono_Security_Cryptography_KeyPairPersistence_CanSecure)
@@ -460,8 +467,7 @@ ICALL(OBJ_1, "GetType", ves_icall_System_Object_GetType)
 ICALL(OBJ_2, "InternalGetHashCode", mono_object_hash)
 ICALL(OBJ_3, "MemberwiseClone", ves_icall_System_Object_MemberwiseClone)
 
-ICALL_TYPE(ASSEM, "System.Reflection.Assembly", ASSEM_1)
-ICALL(ASSEM_1, "FillName", ves_icall_System_Reflection_Assembly_FillName)
+ICALL_TYPE(ASSEM, "System.Reflection.Assembly", ASSEM_1a)
 ICALL(ASSEM_1a, "GetAotId", ves_icall_System_Reflection_Assembly_GetAotId)
 ICALL(ASSEM_2, "GetCallingAssembly", ves_icall_System_Reflection_Assembly_GetCallingAssembly)
 ICALL(ASSEM_3, "GetEntryAssembly", ves_icall_System_Reflection_Assembly_GetEntryAssembly)
@@ -490,8 +496,9 @@ ICALL(ASSEM_24, "get_global_assembly_cache", ves_icall_System_Reflection_Assembl
 ICALL(ASSEM_25, "get_location", ves_icall_System_Reflection_Assembly_get_location)
 ICALL(ASSEM_26, "load_with_partial_name", ves_icall_System_Reflection_Assembly_load_with_partial_name)
 
-ICALL_TYPE(ASSEMN, "System.Reflection.AssemblyName", ASSEMN_1)
-ICALL(ASSEMN_1, "ParseName", ves_icall_System_Reflection_AssemblyName_ParseName)
+ICALL_TYPE(ASSEMN, "System.Reflection.AssemblyName", ASSEMN_0)
+ICALL(ASSEMN_0, "GetNativeName", ves_icall_System_Reflection_AssemblyName_GetNativeName)
+ICALL(ASSEMN_3, "ParseAssemblyName", ves_icall_System_Reflection_AssemblyName_ParseAssemblyName)
 ICALL(ASSEMN_2, "get_public_token", mono_digest_get_public_token)
 
 ICALL_TYPE(CATTR_DATA, "System.Reflection.CustomAttributeData", CATTR_DATA_1)
@@ -752,7 +759,7 @@ ICALL(RT_9, "GetGenericParameterPosition", ves_icall_RuntimeType_GetGenericParam
 ICALL(RT_10, "GetInterfaceMapData", ves_icall_RuntimeType_GetInterfaceMapData)
 ICALL(RT_11, "GetInterfaces", ves_icall_RuntimeType_GetInterfaces)
 ICALL(RT_12, "GetMethodsByName_native", ves_icall_RuntimeType_GetMethodsByName_native)
-ICALL(RT_13, "GetNestedTypes_internal", ves_icall_RuntimeType_GetNestedTypes)
+ICALL(RT_13, "GetNestedTypes_native", ves_icall_RuntimeType_GetNestedTypes_native)
 ICALL(RT_14, "GetPacking", ves_icall_RuntimeType_GetPacking)
 ICALL(RT_15, "GetPropertiesByName_native", ves_icall_RuntimeType_GetPropertiesByName_native)
 ICALL(RT_16, "GetTypeCodeImplInternal", ves_icall_type_GetTypeCodeInternal)
index 587fd8c1c129ebef17fd779112b96696c87631a9..2e3240354898d39ce5f3facc3d931fe501e45420 100644 (file)
@@ -1541,6 +1541,21 @@ ves_icall_Mono_RuntimeGPtrArrayHandle_GPtrArrayFree (GPtrArray *ptr_array)
        g_ptr_array_free (ptr_array, TRUE);
 }
 
+ICALL_EXPORT void
+ves_icall_Mono_SafeStringMarshal_GFree (void *c_str)
+{
+       g_free (c_str);
+}
+
+ICALL_EXPORT char*
+ves_icall_Mono_SafeStringMarshal_StringToUtf8 (MonoString *s)
+{
+       MonoError error;
+       char *res = mono_string_to_utf8_checked (s, &error);
+       mono_error_set_pending_exception (&error);
+       return res;
+}
+
 /* System.TypeCode */
 typedef enum {
        TYPECODE_EMPTY,
@@ -3790,29 +3805,29 @@ enum {
 };
 
 ICALL_EXPORT GPtrArray*
-ves_icall_RuntimeType_GetFields_native (MonoReflectionType *type, MonoString *name, guint32 bflags)
+ves_icall_RuntimeType_GetFields_native (MonoReflectionType *type, char *utf8_name, guint32 bflags)
 {
        MonoError error;
-       MonoDomain *domain; 
        MonoClass *startklass, *klass;
        int match;
        gpointer iter;
-       char *utf8_name = NULL;
        int (*compare_func) (const char *s1, const char *s2) = NULL;    
        MonoClassField *field;
 
-       domain = ((MonoObject *)type)->vtable->domain;
        if (type->type->byref) {
                return g_ptr_array_new ();
        }
 
+       mono_error_init (&error);
+
+       compare_func = (bflags & BFLAGS_IgnoreCase) ? mono_utf8_strcasecmp : strcmp;
+
        klass = startklass = mono_class_from_mono_type (type->type);
 
        GPtrArray *ptr_array = g_ptr_array_sized_new (16);
        
 handle_parent: 
        if (mono_class_has_failure (klass)) {
-               mono_error_init (&error);
                mono_error_set_for_class_failure (&error, klass);
                goto fail;
        }
@@ -3846,25 +3861,14 @@ handle_parent:
                if (!match)
                        continue;
 
-               if (name != NULL) {
-                       if (utf8_name == NULL) {
-                               utf8_name = mono_string_to_utf8_checked (name, &error);
-                               if (!is_ok (&error))
-                                       goto fail;
-                               compare_func = (bflags & BFLAGS_IgnoreCase) ? mono_utf8_strcasecmp : strcmp;
-                       }
-
-                       if (compare_func (mono_field_get_name (field), utf8_name))
+               if (utf8_name != NULL && compare_func (mono_field_get_name (field), utf8_name))
                                continue;
-               }
 
                g_ptr_array_add (ptr_array, field);
        }
        if (!(bflags & BFLAGS_DeclaredOnly) && (klass = klass->parent))
                goto handle_parent;
 
-       if (utf8_name != NULL)
-               g_free (utf8_name);
        return ptr_array;
 
 fail:
@@ -3998,28 +4002,18 @@ loader_error:
 }
 
 ICALL_EXPORT GPtrArray*
-ves_icall_RuntimeType_GetMethodsByName_native (MonoReflectionType *type, MonoString *name, guint32 bflags, MonoBoolean ignore_case)
+ves_icall_RuntimeType_GetMethodsByName_native (MonoReflectionType *type, const char *mname, guint32 bflags, MonoBoolean ignore_case)
 {
        MonoError error;
-       MonoDomain *domain; 
-       const char *mname = NULL;
        GPtrArray *method_array;
        MonoClass *klass;
 
        klass = mono_class_from_mono_type (type->type);
-       domain = ((MonoObject *)type)->vtable->domain;
        if (type->type->byref) {
                return g_ptr_array_new ();
        }
 
-       if (name) {
-               mname = mono_string_to_utf8_checked (name, &error);
-               if (mono_error_set_pending_exception (&error))
-                   return NULL;
-       }
-
        method_array = mono_class_get_methods_by_name (klass, mname, bflags, ignore_case, FALSE, &error);
-       g_free ((char*)mname);
        mono_error_set_pending_exception (&error);
        return method_array;
 }
@@ -4146,7 +4140,7 @@ property_accessor_nonpublic (MonoMethod* accessor, gboolean start_klass)
 }
 
 ICALL_EXPORT GPtrArray*
-ves_icall_RuntimeType_GetPropertiesByName_native (MonoReflectionType *type, MonoString *name, guint32 bflags, MonoBoolean ignore_case)
+ves_icall_RuntimeType_GetPropertiesByName_native (MonoReflectionType *type, gchar *propname, guint32 bflags, MonoBoolean ignore_case)
 {
        MonoError error;
        MonoClass *startklass, *klass;
@@ -4154,7 +4148,6 @@ ves_icall_RuntimeType_GetPropertiesByName_native (MonoReflectionType *type, Mono
        MonoProperty *prop;
        int match;
        guint32 flags;
-       gchar *propname = NULL;
        int (*compare_func) (const char *s1, const char *s2) = NULL;
        gpointer iter;
        GHashTable *properties = NULL;
@@ -4168,12 +4161,7 @@ ves_icall_RuntimeType_GetPropertiesByName_native (MonoReflectionType *type, Mono
        
        klass = startklass = mono_class_from_mono_type (type->type);
 
-       if (name != NULL) {
-               propname = mono_string_to_utf8_checked (name, &error);
-               if (mono_error_set_pending_exception (&error))
-                       return NULL;
-               compare_func = (ignore_case) ? mono_utf8_strcasecmp : strcmp;
-       }
+       compare_func = (ignore_case) ? mono_utf8_strcasecmp : strcmp;
 
        res_array = g_ptr_array_sized_new (8); /*This the average for ASP.NET types*/
 
@@ -4181,8 +4169,10 @@ ves_icall_RuntimeType_GetPropertiesByName_native (MonoReflectionType *type, Mono
 handle_parent:
        mono_class_setup_methods (klass);
        mono_class_setup_vtable (klass);
-       if (mono_class_has_failure (klass))
+       if (mono_class_has_failure (klass)) {
+               mono_error_set_for_class_failure (&error, klass);
                goto loader_error;
+       }
 
        iter = NULL;
        while ((prop = mono_class_get_properties (klass, &iter))) {
@@ -4220,10 +4210,8 @@ handle_parent:
                        continue;
                match = 0;
 
-               if (name != NULL) {
-                       if (compare_func (propname, prop->name))
-                               continue;
-               }
+               if (propname != NULL && compare_func (propname, prop->name))
+                       continue;
                
                if (g_hash_table_lookup (properties, prop))
                        continue;
@@ -4236,19 +4224,13 @@ handle_parent:
                goto handle_parent;
 
        g_hash_table_destroy (properties);
-       g_free (propname);
 
        return res_array;
 
 
 loader_error:
-       if (mono_class_has_failure (klass))
-               mono_error_set_for_class_failure (&error, klass);
-
        if (properties)
                g_hash_table_destroy (properties);
-       if (name)
-               g_free (propname);
        g_ptr_array_free (res_array, TRUE);
 
        mono_error_set_pending_exception (&error);
@@ -4272,7 +4254,7 @@ event_equal (MonoEvent *event1, MonoEvent *event2)
 }
 
 ICALL_EXPORT GPtrArray*
-ves_icall_RuntimeType_GetEvents_native (MonoReflectionType *type, MonoString *name, guint32 bflags)
+ves_icall_RuntimeType_GetEvents_native (MonoReflectionType *type, char *utf8_name, guint32 bflags)
 {
        MonoError error;
        MonoClass *startklass, *klass;
@@ -4280,7 +4262,6 @@ ves_icall_RuntimeType_GetEvents_native (MonoReflectionType *type, MonoString *na
        MonoEvent *event;
        int match;
        gpointer iter;
-       char *utf8_name = NULL;
        int (*compare_func) (const char *s1, const char *s2) = NULL;    
        GHashTable *events = NULL;
        GPtrArray *res_array;
@@ -4291,6 +4272,8 @@ ves_icall_RuntimeType_GetEvents_native (MonoReflectionType *type, MonoString *na
 
        mono_error_init (&error);
 
+       compare_func = (bflags & BFLAGS_IgnoreCase) ? mono_utf8_strcasecmp : strcmp;
+
        res_array = g_ptr_array_sized_new (4);
 
        klass = startklass = mono_class_from_mono_type (type->type);
@@ -4299,8 +4282,10 @@ ves_icall_RuntimeType_GetEvents_native (MonoReflectionType *type, MonoString *na
 handle_parent:
        mono_class_setup_methods (klass);
        mono_class_setup_vtable (klass);
-       if (mono_class_has_failure (klass))
-               goto loader_error;
+       if (mono_class_has_failure (klass)) {
+               mono_error_set_for_class_failure (&error, klass);
+               goto failure;
+       }
 
        iter = NULL;
        while ((event = mono_class_get_events (klass, &iter))) {
@@ -4341,17 +4326,8 @@ handle_parent:
                if (!match)
                        continue;
 
-               if (name != NULL) {
-                       if (utf8_name == NULL) {
-                               utf8_name = mono_string_to_utf8_checked (name, &error);
-                               if (!is_ok (&error))
-                                       goto failure;
-                               compare_func = (bflags & BFLAGS_IgnoreCase) ? mono_utf8_strcasecmp : strcmp;
-                       }
-
-                       if (compare_func (event->name, utf8_name))
-                               continue;
-               }               
+               if (utf8_name != NULL && compare_func (event->name, utf8_name))
+                       continue;
 
                if (g_hash_table_lookup (events, event))
                        continue;
@@ -4365,21 +4341,11 @@ handle_parent:
 
        g_hash_table_destroy (events);
 
-       if (utf8_name != NULL)
-               g_free (utf8_name);
-
        return res_array;
 
-loader_error:
-       if (mono_class_has_failure (klass))
-               mono_error_set_for_class_failure (&error, klass);
-
 failure:
-       
        if (events != NULL)
                g_hash_table_destroy (events);
-       if (utf8_name != NULL)
-               g_free (utf8_name);
 
        g_ptr_array_free (res_array, TRUE);
 
@@ -4387,28 +4353,19 @@ failure:
        return NULL;
 }
 
-ICALL_EXPORT MonoArray*
-ves_icall_RuntimeType_GetNestedTypes (MonoReflectionType *type, MonoString *name, guint32 bflags)
+ICALL_EXPORT GPtrArray *
+ves_icall_RuntimeType_GetNestedTypes_native (MonoReflectionType *type, char *str, guint32 bflags)
 {
-       MonoError error;
-       MonoReflectionType *rt;
-       MonoDomain *domain; 
        MonoClass *klass;
-       MonoArray *res = NULL;
-       int i, match;
+       int match;
        MonoClass *nested;
        gpointer iter;
-       char *str = NULL;
-       MonoPtrArray tmp_array;
-
-       mono_error_init (&error);
+       GPtrArray *res_array;
 
-       domain = ((MonoObject *)type)->vtable->domain;
        if (type->type->byref) {
-               MonoArray *result = mono_array_new_cached (domain, mono_defaults.runtimetype_class, 0, &error);
-               mono_error_set_pending_exception (&error);
-               return result;
+               return g_ptr_array_new ();
        }
+
        klass = mono_class_from_mono_type (type->type);
 
        /*
@@ -4423,7 +4380,8 @@ ves_icall_RuntimeType_GetNestedTypes (MonoReflectionType *type, MonoString *name
        if (klass->generic_class)
                klass = klass->generic_class->container_class;
 
-       mono_ptr_array_init (tmp_array, 1, MONO_ROOT_SOURCE_REFLECTION, "temporary reflection nested types list");
+       res_array = g_ptr_array_new ();
+       
        iter = NULL;
        while ((nested = mono_class_get_nested_types (klass, &iter))) {
                match = 0;
@@ -4437,39 +4395,13 @@ ves_icall_RuntimeType_GetNestedTypes (MonoReflectionType *type, MonoString *name
                if (!match)
                        continue;
 
-               if (name != NULL) {
-                       if (str == NULL) {
-                               str = mono_string_to_utf8_checked (name, &error);
-                               if (!is_ok (&error))
-                                       goto leave;
-                               mono_identifier_unescape_type_name_chars (str);
-                       }
-
-                       if (strcmp (nested->name, str))
+               if (str != NULL && strcmp (nested->name, str))
                                continue;
-               }
-
-               rt = mono_type_get_object_checked (domain, &nested->byval_arg, &error);
-               if (!is_ok (&error))
-                       goto leave;
 
-               mono_ptr_array_append (tmp_array, (MonoObject*) rt);
+               g_ptr_array_add (res_array, &nested->byval_arg);
        }
 
-       res = mono_array_new_cached (domain, mono_defaults.runtimetype_class, mono_ptr_array_size (tmp_array), &error);
-       if (!is_ok (&error))
-               goto leave;
-
-       for (i = 0; i < mono_ptr_array_size (tmp_array); ++i)
-               mono_array_setref (res, i, mono_ptr_array_get (tmp_array, i));
-
-leave:
-       mono_ptr_array_destroy (tmp_array);
-
-       g_free (str);
-
-       mono_error_set_pending_exception (&error);
-       return res;
+       return res_array;
 }
 
 ICALL_EXPORT MonoReflectionType*
@@ -5555,29 +5487,10 @@ ves_icall_System_Reflection_Assembly_get_fullName (MonoReflectionAssembly *assem
        return res;
 }
 
-ICALL_EXPORT void
-ves_icall_System_Reflection_Assembly_FillName (MonoReflectionAssembly *assembly, MonoReflectionAssemblyName *aname)
+ICALL_EXPORT MonoAssemblyName *
+ves_icall_System_Reflection_AssemblyName_GetNativeName (MonoAssembly *mass)
 {
-       MonoError error;
-       gchar *absolute, *dirname;
-       MonoAssembly *mass = assembly->assembly;
-
-       /* XXX this is duplicated code to compute the codebase URI, unify it */
-       if (g_path_is_absolute (mass->image->name)) {
-               absolute = g_strdup (mass->image->name);
-               dirname = g_path_get_dirname (absolute);
-       } else {
-               absolute = g_build_filename (mass->basedir, mass->image->name, NULL);
-               dirname = g_strdup (mass->basedir);
-       }
-
-       replace_shadow_path (mono_object_domain (assembly), dirname, &absolute);
-       g_free (dirname);
-
-       fill_reflection_assembly_name (mono_object_domain (assembly), aname, &mass->aname, absolute, TRUE, TRUE, TRUE, &error);
-       mono_error_set_pending_exception (&error);
-
-       g_free (absolute);
+       return &mass->aname;
 }
 
 ICALL_EXPORT void
@@ -5843,35 +5756,18 @@ ves_icall_System_Reflection_Assembly_GetTypes (MonoReflectionAssembly *assembly,
        return res;
 }
 
-ICALL_EXPORT gboolean
-ves_icall_System_Reflection_AssemblyName_ParseName (MonoReflectionAssemblyName *name, MonoString *assname)
+ICALL_EXPORT void
+ves_icall_Mono_RuntimeMarshal_FreeAssemblyName (MonoAssemblyName *aname)
 {
-       MonoError error;
-       MonoAssemblyName aname;
-       MonoDomain *domain = mono_object_domain (name);
-       char *val;
-       gboolean is_version_defined;
-       gboolean is_token_defined;
-
-       aname.public_key = NULL;
-       val = mono_string_to_utf8_checked (assname, &error);
-       if (mono_error_set_pending_exception (&error))
-               return FALSE;
-
-       if (!mono_assembly_name_parse_full (val, &aname, TRUE, &is_version_defined, &is_token_defined)) {
-               g_free ((guint8*) aname.public_key);
-               g_free (val);
-               return FALSE;
-       }
-       
-       fill_reflection_assembly_name (domain, name, &aname, "", is_version_defined, FALSE, is_token_defined, &error);
-       mono_error_set_pending_exception (&error);
+       mono_assembly_name_free (aname);
+}
 
-       mono_assembly_name_free (&aname);
-       g_free ((guint8*) aname.public_key);
-       g_free (val);
+ICALL_EXPORT gboolean
+ves_icall_System_Reflection_AssemblyName_ParseAssemblyName (const char *name, MonoAssemblyName *aname, gboolean *is_version_definited, gboolean *is_token_defined)
+{
+       *is_version_definited = *is_token_defined = FALSE;
 
-       return TRUE;
+       return mono_assembly_name_parse_full (name, aname, TRUE, is_version_definited, is_token_defined);
 }
 
 ICALL_EXPORT MonoReflectionType*
index 09faef99896bc0d3e56cd6f64ed73786a8612069..c84da624146e3fa8d14c8ba5758fd49301595972 100644 (file)
@@ -4328,6 +4328,7 @@ set_bp_in_method (MonoDomain *domain, MonoMethod *method, MonoSeqPointInfo *seq_
                MonoError oerror;
 
                /* Might be AOTed code */
+               mono_class_init (method->klass);
                code = mono_aot_get_method_checked (domain, method, &oerror);
                g_assert (code);
                mono_error_assert_ok (&oerror);
index a708eb3eb22b244fef50931de958816f2d0f4ece..fc2964ad2bebb005419de6bdc28d9b8dc6e60c2e 100644 (file)
@@ -1898,6 +1898,9 @@ mono_arch_allocate_vars (MonoCompile *cfg)
                ins->inst_basereg = cfg->frame_reg;
                ins->inst_offset = offset;
                offset += size;
+       }
+       if (cfg->arch.ss_trigger_page_var) {
+               MonoInst *ins;
 
                ins = cfg->arch.ss_trigger_page_var;
                size = 4;
@@ -1922,6 +1925,9 @@ mono_arch_allocate_vars (MonoCompile *cfg)
                ins->inst_basereg = cfg->frame_reg;
                ins->inst_offset = offset;
                offset += size;
+       }
+       if (cfg->arch.seq_point_bp_method_var) {
+               MonoInst *ins;
 
                ins = cfg->arch.seq_point_bp_method_var;
                size = 4;
@@ -2102,6 +2108,18 @@ mono_arch_create_vars (MonoCompile *cfg)
        }
 
        if (cfg->gen_sdb_seq_points) {
+               if (cfg->compile_aot) {
+                       MonoInst *ins = mono_compile_create_var (cfg, &mono_defaults.int_class->byval_arg, OP_LOCAL);
+                       ins->flags |= MONO_INST_VOLATILE;
+                       cfg->arch.seq_point_info_var = ins;
+
+                       if (!cfg->soft_breakpoints) {
+                               /* Allocate a separate variable for this to save 1 load per seq point */
+                               ins = mono_compile_create_var (cfg, &mono_defaults.int_class->byval_arg, OP_LOCAL);
+                               ins->flags |= MONO_INST_VOLATILE;
+                               cfg->arch.ss_trigger_page_var = ins;
+                       }
+               }
                if (cfg->soft_breakpoints) {
                        MonoInst *ins;
 
@@ -2112,17 +2130,6 @@ mono_arch_create_vars (MonoCompile *cfg)
                        ins = mono_compile_create_var (cfg, &mono_defaults.int_class->byval_arg, OP_LOCAL);
                        ins->flags |= MONO_INST_VOLATILE;
                        cfg->arch.seq_point_bp_method_var = ins;
-
-                       g_assert (!cfg->compile_aot);
-               } else if (cfg->compile_aot) {
-                       MonoInst *ins = mono_compile_create_var (cfg, &mono_defaults.int_class->byval_arg, OP_LOCAL);
-                       ins->flags |= MONO_INST_VOLATILE;
-                       cfg->arch.seq_point_info_var = ins;
-
-                       /* Allocate a separate variable for this to save 1 load per seq point */
-                       ins = mono_compile_create_var (cfg, &mono_defaults.int_class->byval_arg, OP_LOCAL);
-                       ins->flags |= MONO_INST_VOLATILE;
-                       cfg->arch.ss_trigger_page_var = ins;
                }
        }
 }
@@ -4590,9 +4597,11 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
                        MonoInst *var;
                        int dreg = ARMREG_LR;
 
+#if 0
                        if (cfg->soft_breakpoints) {
                                g_assert (!cfg->compile_aot);
                        }
+#endif
 
                        /*
                         * For AOT, we use one got slot per method, which will point to a
@@ -4649,20 +4658,7 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
 
                        mono_add_seq_point (cfg, bb, ins, code - cfg->native_code);
 
-                       if (cfg->soft_breakpoints) {
-                               /* Load the address of the breakpoint method into ip. */
-                               var = bp_method_var;
-                               g_assert (var);
-                               g_assert (var->opcode == OP_REGOFFSET);
-                               g_assert (arm_is_imm12 (var->inst_offset));
-                               ARM_LDR_IMM (code, dreg, var->inst_basereg, var->inst_offset);
-
-                               /*
-                                * A placeholder for a possible breakpoint inserted by
-                                * mono_arch_set_breakpoint ().
-                                */
-                               ARM_NOP (code);
-                       } else if (cfg->compile_aot) {
+                       if (cfg->compile_aot) {
                                guint32 offset = code - cfg->native_code;
                                guint32 val;
 
@@ -4685,7 +4681,23 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
                                /* What is faster, a branch or a load ? */
                                ARM_CMP_REG_IMM (code, dreg, 0, 0);
                                /* The breakpoint instruction */
-                               ARM_LDR_IMM_COND (code, dreg, dreg, 0, ARMCOND_NE);
+                               if (cfg->soft_breakpoints)
+                                       ARM_BLX_REG_COND (code, ARMCOND_NE, dreg);
+                               else
+                                       ARM_LDR_IMM_COND (code, dreg, dreg, 0, ARMCOND_NE);
+                       } else if (cfg->soft_breakpoints) {
+                               /* Load the address of the breakpoint method into ip. */
+                               var = bp_method_var;
+                               g_assert (var);
+                               g_assert (var->opcode == OP_REGOFFSET);
+                               g_assert (arm_is_imm12 (var->inst_offset));
+                               ARM_LDR_IMM (code, dreg, var->inst_basereg, var->inst_offset);
+
+                               /*
+                                * A placeholder for a possible breakpoint inserted by
+                                * mono_arch_set_breakpoint ().
+                                */
+                               ARM_NOP (code);
                        } else {
                                /* 
                                 * A placeholder for a possible breakpoint inserted by
@@ -7184,17 +7196,16 @@ mono_arch_set_breakpoint (MonoJitInfo *ji, guint8 *ip)
        guint32 native_offset = ip - (guint8*)ji->code_start;
        MonoDebugOptions *opt = mini_get_debug_options ();
 
-       if (opt->soft_breakpoints) {
-               g_assert (!ji->from_aot);
-               code += 4;
-               ARM_BLX_REG (code, ARMREG_LR);
-               mono_arch_flush_icache (code - 4, 4);
-       } else if (ji->from_aot) {
+       if (ji->from_aot) {
                SeqPointInfo *info = mono_arch_get_seq_point_info (mono_domain_get (), ji->code_start);
 
                g_assert (native_offset % 4 == 0);
                g_assert (info->bp_addrs [native_offset / 4] == 0);
-               info->bp_addrs [native_offset / 4] = bp_trigger_page;
+               info->bp_addrs [native_offset / 4] = opt->soft_breakpoints ? breakpoint_tramp : bp_trigger_page;
+       } else if (opt->soft_breakpoints) {
+               code += 4;
+               ARM_BLX_REG (code, ARMREG_LR);
+               mono_arch_flush_icache (code - 4, 4);
        } else {
                int dreg = ARMREG_LR;
 
@@ -7230,18 +7241,17 @@ mono_arch_clear_breakpoint (MonoJitInfo *ji, guint8 *ip)
        guint8 *code = ip;
        int i;
 
-       if (opt->soft_breakpoints) {
-               g_assert (!ji->from_aot);
-               code += 4;
-               ARM_NOP (code);
-               mono_arch_flush_icache (code - 4, 4);
-       } else if (ji->from_aot) {
+       if (ji->from_aot) {
                guint32 native_offset = ip - (guint8*)ji->code_start;
                SeqPointInfo *info = mono_arch_get_seq_point_info (mono_domain_get (), ji->code_start);
 
                g_assert (native_offset % 4 == 0);
-               g_assert (info->bp_addrs [native_offset / 4] == bp_trigger_page);
+               g_assert (info->bp_addrs [native_offset / 4] == (opt->soft_breakpoints ? breakpoint_tramp : bp_trigger_page));
                info->bp_addrs [native_offset / 4] = 0;
+       } else if (opt->soft_breakpoints) {
+               code += 4;
+               ARM_NOP (code);
+               mono_arch_flush_icache (code - 4, 4);
        } else {
                for (i = 0; i < 4; ++i)
                        ARM_NOP (code);