Merge pull request #2088 from kasthack/system-web-ea-import
authorMarek Safar <marek.safar@gmail.com>
Thu, 24 Sep 2015 06:31:37 +0000 (08:31 +0200)
committerMarek Safar <marek.safar@gmail.com>
Thu, 24 Sep 2015 06:31:37 +0000 (08:31 +0200)
[System.Web] Reference source import

38 files changed:
configure.ac
eglib/configure.ac
mcs/class/Mono.C5/Makefile
mcs/class/Mono.Data.Sqlite/Mono.Data.Sqlite_2.0/SQLiteBase.cs
mcs/class/Mono.Data.Sqlite/Mono.Data.Sqlite_2.0/UnsafeNativeMethods.cs
mcs/class/Mono.Data.Sqlite/Test/SqliteConnectionTest.cs
mcs/class/Mono.Security/Mono.Security.Cryptography/CryptoTools.cs
mcs/class/System.Drawing/System.Drawing.Printing/PrintingServicesUnix.cs
mcs/class/System.Drawing/System.Drawing/Point.cs
mcs/class/System.Drawing/Test/System.Drawing/TestPoint.cs
mcs/class/System.Security/System.Security.Cryptography.Xml/SignedXml.cs
mcs/class/System.ServiceModel.Web/Test/System.Runtime.Serialization.Json/DataContractJsonSerializerTest.cs
mcs/class/System.ServiceModel/System.ServiceModel.Channels.Http/HttpReplyChannel.cs
mcs/class/System.ServiceModel/System.ServiceModel.Channels/ReplyChannelBase.cs
mcs/class/System.ServiceModel/System.ServiceModel.Description/ContractDescriptionGenerator.cs
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ChannelDispatcher.cs
mcs/class/System.ServiceModel/System.ServiceModel/ServiceHost.cs
mcs/class/System.ServiceModel/Test/System.ServiceModel.Description/ContractDescriptionTest.cs
mcs/class/System.Web/System.Web.UI.WebControls/CheckBox.cs
mcs/class/System.Windows.Forms/System.Windows.Forms/XplatUIX11.cs
mcs/class/System/System.Diagnostics/Stopwatch.cs
mcs/class/System/System.Net.Mail/SmtpClient.cs
mcs/class/System/System.Net/IPAddress.cs
mcs/class/System/Test/System.Net.Mail/SmtpClientTest.cs
mcs/class/System/Test/System.Net/IPAddressTest.cs
mcs/class/corlib/Test/System.Reflection/MethodInfoTest.cs
mcs/tools/security/makecert.cs
mono/metadata/icall.c
mono/metadata/sgen-mono.c
mono/mini/mini-arm.c
mono/mini/mini-arm.h
mono/profiler/decode.c
mono/profiler/proflog.h
mono/sgen/sgen-gc.c
mono/sgen/sgen-marksweep.c
mono/sgen/sgen-memory-governor.c
mono/unit-tests/Makefile.am
mono/utils/mono-context.h

index 3a0ddc1ecb8c994772485a79bd26d84919958b03..3725b6b41af10e5d1d7d3828928c050e4da4fec2 100644 (file)
@@ -13,7 +13,11 @@ AC_CANONICAL_HOST
 # The extra brackets are to foil regex-based scans.
 m4_ifdef([_A][M_PROG_TAR],[_A][M_SET_OPTION([tar-ustar])])
 
-AM_INIT_AUTOMAKE([1.9 dist-bzip2 tar-ustar no-dist-gzip foreign subdir-objects])
+AM_INIT_AUTOMAKE([1.9 dist-bzip2 tar-ustar no-dist-gzip foreign subdir-objects]
+                 m4_esyscmd([case `automake --version | head -n 1` in    # parallel-tests is default in automake 1.13+, we need to explicitly enable it
+                             *1.11*|*1.12*) echo parallel-tests;;        # for 1.11 and 1.12 but not below as those versions don't recognize the flag
+                             esac]))                                     # TODO: remove this hack once we require automake 1.11+
+
 AC_CONFIG_HEADERS([config.h])
 AM_MAINTAINER_MODE
 
index 85f9f3fe301c9c87777eb52307c4220cd932eed8..2197c6f9c96605404f19ee9bc6b0b038f94986fb 100644 (file)
@@ -182,6 +182,7 @@ fi
 AC_SUBST(G_HAVE_ISO_VARARGS)
 
 AC_CHECK_HEADERS(getopt.h sys/select.h sys/time.h sys/wait.h pwd.h langinfo.h iconv.h localcharset.h sys/types.h sys/resource.h)
+AC_CHECK_LIB([iconv], [locale_charset],[],[AC_CHECK_LIB([charset], [locale_charset],[LIBS+="-liconv -lcharset"])])
 AC_CHECK_HEADER(alloca.h, [HAVE_ALLOCA_H=1], [HAVE_ALLOCA_H=0])
 AC_SUBST(HAVE_ALLOCA_H)
 
index 19363185e8687468b4d15db041e134d3dbc794ed..71430e729329903df359647cba9950ff227dd722 100644 (file)
@@ -12,4 +12,6 @@ EXTRA_DISTFILES = \
        LICENSE.txt \
        c5.pub c5.snk c5.xml
 
+NO_INSTALL = yes
+
 include ../../build/library.make
index e698dde9d6d208f21c70257a30d4a0e639624cbf..df8a5d787ab0daefe2ea5714dc621b1342f9f8b2 100644 (file)
@@ -206,8 +206,13 @@ namespace Mono.Data.Sqlite
 #if !SQLITE_STANDARD\r
         int n = UnsafeNativeMethods.sqlite3_close_interop(db);\r
 #else\r
-      ResetConnection(db);\r
-      int n = UnsafeNativeMethods.sqlite3_close(db);\r
+        ResetConnection(db);\r
+        int n;\r
+        try {\r
+          n = UnsafeNativeMethods.sqlite3_close_v2(db);\r
+        } catch (EntryPointNotFoundException) {\r
+          n = UnsafeNativeMethods.sqlite3_close(db);\r
+        }\r
 #endif\r
         if (n > 0) throw new SqliteException(n, SQLiteLastError(db));\r
       }\r
index c5ae7c6ff2cf89e15ebc564530921fa6c3d0474b..4b440b951ed56cd07ede1b2c0f6aa3a3ebc21615 100644 (file)
@@ -135,6 +135,13 @@ namespace Mono.Data.Sqlite
     [DllImport(SQLITE_DLL)]\r
 #endif\r
     internal static extern int sqlite3_close(IntPtr db);\r
+               \r
+#if !PLATFORM_COMPACTFRAMEWORK\r
+    [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]\r
+#else\r
+    [DllImport(SQLITE_DLL)]\r
+#endif\r
+    internal static extern int sqlite3_close_v2(IntPtr db);\r
 \r
 #if !PLATFORM_COMPACTFRAMEWORK\r
     [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]\r
index d65ee3f9ae6179fd80d5d8b06ff97d596b5f5b55..9afb83a2b39676721deb8f0bb40537f0ed88b67f 100644 (file)
@@ -44,6 +44,26 @@ namespace MonoTests.Mono.Data.Sqlite
                 readonly static string _connectionString = "URI=file://" + _uri + ", version=3";
                 SqliteConnection _conn = new SqliteConnection ();
 
+               [Test]
+               public void ReleaseDatabaseFileHandles ()
+               {
+                       _conn.ConnectionString = _connectionString;
+                       _conn.Open ();
+                       
+                       SqliteCommand cmd = _conn.CreateCommand ();
+                       cmd.CommandText = "PRAGMA legacy_file_format;";
+                       cmd.ExecuteScalar ();
+                       
+                       // close connection before the command
+                       _conn.Dispose ();
+                       
+                       // then close the command
+                       cmd.Dispose ();
+                       
+                       // the locks should be released, and we should be able to delete the database
+                       File.Delete (_uri);
+               }
+
                 [Test]
                 [ExpectedException (typeof (ArgumentNullException))]
                 public void ConnectionStringTest_Null ()
index d57ce5ae55c1e69d7a444b3568960b11554979be..054038731aec8a6f15ef7c9ece468b1603ae68b9 100644 (file)
@@ -88,6 +88,10 @@ namespace Mono.Security.Cryptography {
                // block size (which isn't their real internal block size)
                public BlockProcessor (ICryptoTransform transform, int blockSize)
                {
+                       if (transform == null)
+                               throw new ArgumentNullException ("transform");
+                       if (blockSize <= 0)
+                               throw new ArgumentOutOfRangeException ("blockSize");
                        this.transform = transform;
                        this.blockSize = blockSize;
                        block = new byte [blockSize];
index 5adb549bb9b749509323df148fceb608c4799245..8e172ad3a4d57b404fd04d6528d289f3c0ccdf57 100644 (file)
@@ -843,7 +843,7 @@ namespace System.Drawing.Printing
                        if (!settings.PrintToFile) {
                                StringBuilder sb = new StringBuilder (1024);
                                int length = sb.Capacity;
-                               cupsTempFile (sb, length);
+                               cupsTempFd (sb, length);
                                name = sb.ToString ();
                                tmpfile = name;
                        }
@@ -889,7 +889,7 @@ namespace System.Drawing.Printing
                static extern void cupsFreeDests (int num_dests, IntPtr dests);
 
                [DllImport("libcups", CharSet=CharSet.Ansi)]
-               static extern IntPtr cupsTempFile (StringBuilder sb, int len);
+               static extern IntPtr cupsTempFd (StringBuilder sb, int len);
 
                [DllImport("libcups", CharSet=CharSet.Ansi)]
                static extern IntPtr cupsGetDefault ();
index 643d82c7ef8804ec80c6859f6e5c54ba3618d823..4737c4f1d455d97c26b28ffa11dc82468b0de1c4 100644 (file)
@@ -226,7 +226,7 @@ namespace System.Drawing
                public Point (int dw)
                {
                        y = dw >> 16;
-                       x = dw & 0xffff;
+                       x = unchecked ((short) (dw & 0xffff));
                }
 
                /// <summary>
index 71bb2abec8baec2a81ab03ac491173456914a45d..346ae6f1d509e20445a1db4fc8c384d4229e860f 100644 (file)
@@ -155,6 +155,15 @@ namespace MonoTests.System.Drawing{
                        Assert.AreEqual (pt_i, pt1_1, "#2");
                        Assert.AreEqual (pt_sz, pt1_1, "#3");
                }
+
+               [Test]
+               public void ConstructorNegativeLocationTest ()
+               {
+                       var pt = new Point (unchecked ((int) 0xffe0fc00));
+
+                       Assert.AreEqual (-32, pt.Y, "#1"); // (short) 0xffe0
+                       Assert.AreEqual (-1024, pt.X, "#2"); // (short) 0xfc00
+               }
                
                [Test]
                public void PropertyTest () 
index 8293e1d4f99168dd43fc2bbbb86548d640dedb99..05c2b091d98b229262f43bc1c25577656f0009a2 100644 (file)
@@ -691,6 +691,12 @@ namespace System.Security.Cryptography.Xml {
                        if (xel == null) {
                                // search an "undefined" ID
                                xel = (XmlElement) document.SelectSingleNode ("//*[@Id='" + idValue + "']");
+                               if (xel == null) {
+                                       xel = (XmlElement) document.SelectSingleNode ("//*[@ID='" + idValue + "']");
+                                       if (xel == null) {
+                                               xel = (XmlElement) document.SelectSingleNode ("//*[@id='" + idValue + "']");
+                                       }
+                               }
                        }
                        return xel;
                }
index bede256b8c947ef6598f1906468e823fff50d072..1e32b6fcdbf9810ed8c00f329635c3836f70ab1f 100644 (file)
@@ -1920,8 +1920,57 @@ namespace MonoTests.System.Runtime.Serialization.Json
                                serializer.WriteObject (ms, person2);
                        }
                }
+
+               [Test]
+               public void Bug15028()
+               {
+                       DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(Bug15028));
+                       using (MemoryStream memoryStream = new MemoryStream())
+                       {
+                               ser.WriteObject(memoryStream, new Bug15028());
+                               string output = Encoding.Default.GetString(memoryStream.ToArray());
+                               Assert.AreEqual(@"{""Int0"":1,""Int1"":1,""IntZero1"":0,""Str0"":"""",""Str1"":"""",""StrNull1"":null}", output);
+                       }
+               }
        }
        
+
+       [DataContract]
+       public class Bug15028
+       {
+               [DataMember(EmitDefaultValue = false)]
+               public string StrNull0 { get; private set; }
+
+               [DataMember(EmitDefaultValue = false)]
+               public string Str0 { get; private set; }
+
+               [DataMember(EmitDefaultValue = true)]
+               public string StrNull1 { get; private set; }
+
+               [DataMember(EmitDefaultValue = true)]
+               public string Str1 { get; private set; }
+
+               [DataMember(EmitDefaultValue = false)]
+               public int IntZero0 { get; private set; }
+
+               [DataMember(EmitDefaultValue = false)]
+               public int Int0 { get; private set; }
+
+               [DataMember(EmitDefaultValue = true)]
+               public int IntZero1 { get; private set; }
+
+               [DataMember(EmitDefaultValue = true)]
+               public int Int1 { get; private set; }
+
+               public Bug15028()
+               {
+                       Str0 = string.Empty;
+                       Str1 = string.Empty;
+                       Int0 = 1;
+                       Int1 = 1;
+               }
+       }
+
        public class CharTest
        {
                public char Foo;
index 16c38c77932c39409c4349ee2ea501d67051c820..03e7cad1f1c4f7eff0afaab6e7c41ebd1801f848 100644 (file)
@@ -92,8 +92,8 @@ namespace System.ServiceModel.Channels.Http
                        AbortConnections (timeout);
                        // FIXME: this wait is sort of hack (because it should not be required), but without it some tests are blocked.
                        // This hack even had better be moved to base.CancelAsync().
-                       if (CurrentAsyncResult != null)
-                               CurrentAsyncResult.AsyncWaitHandle.WaitOne (TimeSpan.FromMilliseconds (300));
+//                     if (CurrentAsyncResult != null)
+//                             CurrentAsyncResult.AsyncWaitHandle.WaitOne (TimeSpan.FromMilliseconds (300));
                        return base.CancelAsync (timeout);
                }
 
index d73b0866495cf0a32fe3ef8b2796ea619e8a36f2..4e47ecf0035d8fda5470806c3f5ad8686b0c21f7 100644 (file)
@@ -87,15 +87,16 @@ namespace System.ServiceModel.Channels
 
                protected override void OnClose (TimeSpan timeout)
                {
-                       if (CurrentAsyncThread != null)
+                       if (currentAsyncThreads.Count > 0)
                                if (!CancelAsync (timeout))
-                                       CurrentAsyncThread.Abort ();
+                                       foreach (Thread asyncThread in currentAsyncThreads)
+                                               asyncThread.Abort ();
                }
 
                public virtual bool CancelAsync (TimeSpan timeout)
                {
                        // FIXME: It should wait for the actual completion.
-                       return CurrentAsyncResult == null;
+                       return currentAsyncResults.Count > 0;
                        //return CurrentAsyncResult == null || CurrentAsyncResult.AsyncWaitHandle.WaitOne (timeout);
                }
 
@@ -111,18 +112,18 @@ namespace System.ServiceModel.Channels
                TryReceiveDelegate try_recv_delegate;
 
                object async_result_lock = new object ();
-               protected Thread CurrentAsyncThread { get; private set; }
-               protected IAsyncResult CurrentAsyncResult { get; private set; }
+               HashSet<Thread> currentAsyncThreads = new HashSet<Thread>();
+               HashSet<IAsyncResult> currentAsyncResults = new HashSet<IAsyncResult>();
 
                public virtual IAsyncResult BeginTryReceiveRequest (TimeSpan timeout, AsyncCallback callback, object state)
                {
-                       if (CurrentAsyncResult != null)
-                               throw new InvalidOperationException ("Another async TryReceiveRequest operation is in progress");
+                       IAsyncResult result = null;
+
                        if (try_recv_delegate == null)
                                try_recv_delegate = new TryReceiveDelegate (delegate (TimeSpan tout, out RequestContext ctx) {
                                        lock (async_result_lock) {
-                                               if (CurrentAsyncResult != null)
-                                                       CurrentAsyncThread = Thread.CurrentThread;
+                                               if (currentAsyncResults.Contains (result))
+                                                       currentAsyncThreads.Add (Thread.CurrentThread);
                                        }
                                        try {
                                                return TryReceiveRequest (tout, out ctx);
@@ -143,19 +144,19 @@ namespace System.ServiceModel.Channels
                                                //the whole app.  Ignore for now
                                        } finally {
                                                lock (async_result_lock) {
-                                                       CurrentAsyncResult = null;
-                                                       CurrentAsyncThread = null;
+                                                       currentAsyncResults.Remove (result);
+                                                       currentAsyncThreads.Remove (Thread.CurrentThread);
                                                }
                                        }
                                        ctx = null;
                                        return false;
                                        });
                        RequestContext dummy;
-                       IAsyncResult result;
                        lock (async_result_lock) {
-                               result = CurrentAsyncResult = try_recv_delegate.BeginInvoke (timeout, out dummy, callback, state);
+                               result = try_recv_delegate.BeginInvoke (timeout, out dummy, callback, state);
+                               currentAsyncResults.Add (result);
                        }
-                       // Note that at this point CurrentAsyncResult can be null here if delegate has run to completion
+                       // Note that at this point result can be missing from currentAsyncResults here if delegate has run to completion
                        return result;
                }
 
index a7665b8cab6daa0a6a334a3cf3561d08c3bfdbd5..80238d41ff89bf3ee89270260cc6cbfb82a4f12d 100644 (file)
@@ -139,6 +139,45 @@ namespace System.ServiceModel.Description
                        return ret;
                }
 
+               internal static Type GetContractAssignableToInterfaces(Type given, Type [] givenInterfaces)
+               {
+                       if ((given != null) && (givenInterfaces.Count() < 1))
+                               return null;
+                       Dictionary<Type,int> interfaceGraph = new Dictionary<Type,int> ();
+                       foreach (var smaller in givenInterfaces) {
+                               interfaceGraph [smaller] = 0;
+                               foreach (var bigger in givenInterfaces) {
+                                       if (smaller.IsAssignableFrom (bigger)) {
+                                               interfaceGraph [smaller]++;
+                                       }
+                               }
+                       }
+
+                       List<Type> possibleInterfaces = new List<Type> ();
+                       foreach (var node in interfaceGraph) {
+                               if (node.Value == 1) {
+                                       possibleInterfaces.Add(node.Key);
+                               }
+                       }
+                       // For this purpose a contract is a set of interfaces. it is necessary to find the interface representative of rest of the set. It will be assignable to all of 
+                       // the others but can only be assigned to by itself. This will give it  count of ! in its slot in the interfaceGraph. To be a valid set there can be only one with a count of one
+                       // in its slot.  More results in InvalidOperation exceptioni with ambigours error message, less means that the interface we want is the one passed in by the parameter given
+                       // and by returning null we give the callign method permission to use it..
+                       switch (possibleInterfaces.Count()) 
+                       {
+                               case 0:
+                               break;
+                               case 1:
+                               return possibleInterfaces [0];
+                               break;
+                               default:
+                               if (!given.IsInterface) 
+                                       throw new InvalidOperationException ("The contract type of " + given + " is ambiguous: can be either " + possibleInterfaces[0] + " or " + possibleInterfaces[1]);
+                               break;
+                       }
+                       return null;
+               }
+
                internal static ContractDescription GetContractInternal (Type givenContractType, Type givenServiceType, Type serviceTypeForCallback)
                {
                        if (givenContractType == null)
@@ -153,16 +192,12 @@ namespace System.ServiceModel.Description
                                exactContractType = givenContractType;
                                sca = contracts [givenContractType];
                        } else {
-                               foreach (Type t in contracts.Keys)
-                                       if (t.IsAssignableFrom(givenContractType)) {
-                                               if (t.IsAssignableFrom (exactContractType)) // exact = IDerived, t = IBase
-                                                       continue;
-                                               if (sca != null && (exactContractType == null || !exactContractType.IsAssignableFrom (t))) // t = IDerived, exact = IBase
-                                                       throw new InvalidOperationException ("The contract type of " + givenContractType + " is ambiguous: can be either " + exactContractType + " or " + t);
-                                               exactContractType = t;
-                                               sca = contracts [t];
-                                       }
+                               Type[] contractTypes = contracts.Keys.ToArray() as Type [];
+                               exactContractType = GetContractAssignableToInterfaces(givenContractType, contractTypes);
+                               if (exactContractType != null)
+                                       sca = contracts[exactContractType];
                        }
+
                        if (exactContractType == null)
                                exactContractType = givenContractType;
                        if (sca == null) {
@@ -171,6 +206,7 @@ namespace System.ServiceModel.Description
                                else
                                        return null; // no contract
                        }
+
                        string name = sca.Name ?? exactContractType.Name;
                        string ns = sca.Namespace ?? "http://tempuri.org/";
 
@@ -197,17 +233,18 @@ namespace System.ServiceModel.Description
                         */
 
                        var inherited = new Collection<ContractDescription> ();
-                       foreach (var it in cd.ContractType.GetInterfaces ()) {
+               var interfaces = cd.ContractType.GetInterfaces ();
+                       foreach (var it in interfaces ) {
                                var icd = GetContractInternal (it, givenServiceType, null);
                                if (icd != null)
                                        inherited.Add (icd);
                        }
 
                        foreach (var icd in inherited) {
-                               foreach (var od in icd.Operations)
-                                       if (!cd.Operations.Any(o => o.Name == od.Name && o.SyncMethod == od.SyncMethod && 
-                                                              o.BeginMethod == od.BeginMethod && o.InCallbackContract == od.InCallbackContract))
+                               foreach (var od in icd.Operations) {
+                                       if (!cd.Operations.Any (o => o.Name == od.Name && o.SyncMethod == od.SyncMethod && o.BeginMethod == od.BeginMethod && o.InCallbackContract == od.InCallbackContract))
                                                cd.Operations.Add (od);
+                               }
                        }
 
                        FillOperationsForInterface (cd, cd.ContractType, givenServiceType, false);
index c005094275c5a9c5020dc612fd811eeb8fa8af98..65b5c8cf38ae6913b2482b54609ecc8ee45064e4 100644 (file)
@@ -455,8 +455,11 @@ namespace System.ServiceModel.Dispatcher
                        public void CloseInput ()
                        {
                                foreach (var ch in channels.ToArray ()) {
-                                       if (ch.State == CommunicationState.Closed)
-                                               RemoveChannel (ch);
+                                       if (ch.State == CommunicationState.Closed) {
+                                               lock (channels) {
+                                                       RemoveChannel (ch);
+                                               }
+                                       }
                                        else {
                                                try {
                                                        ch.Close (close_timeout - (DateTime.Now - close_started));
index 19236d062c9681c9f91effe9d65222360fa7eaee..2fed9fb3cdb9ff644e3bc27dddc450c3aa99d8a0 100644 (file)
@@ -101,7 +101,9 @@ namespace System.ServiceModel
                        ContractDescription cd = GetExistingContract (implementedContract);
                        if (cd == null) {
                                cd = ContractDescription.GetContract (implementedContract);
-                               contracts.Add (cd.ContractType.FullName, cd);
+                               if (!contracts.ContainsKey (cd.ContractType.FullName)) {
+                                       contracts.Add (cd.ContractType.FullName, cd);
+                               }
                        }
 
                        return AddServiceEndpointCore (cd, binding, ea, listenUri);
@@ -121,7 +123,8 @@ namespace System.ServiceModel
                        contracts = new Dictionary<string,ContractDescription> ();
                        implementedContracts = contracts;
                        ServiceDescription sd;
-                       foreach (ContractDescription cd in GetServiceContractDescriptions())
+                       IEnumerable<ContractDescription>  contractDescriptions = GetServiceContractDescriptions ();
+                       foreach (ContractDescription cd in contractDescriptions)
                                contracts.Add (cd.ContractType.FullName, cd);
 
                        if (SingletonInstance != null) {
index f6c297d3c9ba9f6cdefa62f67511f99c33bd4b49..77430e87481bf6eadd81b3beda8756b3a0bccc29 100644 (file)
@@ -1009,5 +1009,82 @@ namespace MonoTests.System.ServiceModel.Description
                        [MyWebGet]
                        string Get ();
                }
+
+               public interface IA1 : IB1, IB2 
+               {
+                       void MethodA1 ();
+               }
+
+               public interface IA2 : IB1, IB2 
+               {
+                       void MethodA2 ();
+               }
+
+               [ServiceContract]
+               public interface IB1 : IC1, IC2 
+               {
+                       [OperationContract]                             
+                       void MethodB1 ();
+               }
+
+               [ServiceContract]
+               public interface IB2 : IC1, IC2 
+               {
+                       [OperationContract]                             
+                       void MethodB2 ();
+               }
+
+               public interface IC1 {}
+               public interface IC2 {}
+
+               [ServiceContract]
+               public interface IS : IA1, IA2 
+               {
+                       [OperationContract]                             
+                       void MethodS()  ;       
+               }
+
+               public class S : IS
+               {
+                       #region IS implementation
+                       public void MethodS ()
+                       {
+                               throw new NotImplementedException ();
+                       }
+                       #endregion
+                       #region IA2 implementation
+                       public void MethodA2 ()
+                       {
+                               throw new NotImplementedException ();
+                       }
+                       #endregion
+                       #region IA1 implementation
+                       public void MethodA1 ()
+                       {
+                               throw new NotImplementedException ();
+                       }
+                       #endregion
+                       #region IB2 implementation
+                       public void MethodB2 ()
+                       {
+                               throw new NotImplementedException ();
+                       }
+                       #endregion
+                       #region IB1 implementation
+                       public void MethodB1 ()
+                       {
+                               throw new NotImplementedException ();
+                       }
+                       #endregion
+
+               }
+               [Test]
+               public void DualSpreadingInheritanceTest()
+               {
+                       var cd = ContractDescription.GetContract (typeof(S));
+                       Assert.IsNotNull(cd);
+                       Assert.IsTrue (cd.Name == "IS");
+               }
+
        }
 }
index 905740a1ea9d9f4d4e896cadb7e7ceaa1e177f25..27c3a7fb9dc870f7018c9a6956ef0871173ecb54 100644 (file)
@@ -370,7 +370,11 @@ namespace System.Web.UI.WebControls
                                Page page = Page;
                                string onclick = page != null ? page.ClientScript.GetPostBackEventReference (GetPostBackOptions (), true) : String.Empty;
                                onclick = String.Concat ("setTimeout('", onclick.Replace ("\\", "\\\\").Replace ("'", "\\'"), "', 0)");
-                               w.AddAttribute (HtmlTextWriterAttribute.Onclick, BuildScriptAttribute ("onclick", onclick));
+                               if (common_attrs != null && common_attrs ["onclick"] != null) {
+                                       onclick = ClientScriptManager.EnsureEndsWithSemicolon (common_attrs ["onclick"]) + onclick;
+                                       common_attrs.Remove ("onclick");
+                               }
+                               w.AddAttribute (HtmlTextWriterAttribute.Onclick, onclick);
                        }
 
                        if (AccessKey.Length > 0)
index b0777b560268ec6dbb925063e650ee3dbb95d610..913fb8a57fb721c4148d43e6f575333e943842a6 100644 (file)
@@ -1271,7 +1271,7 @@ namespace System.Windows.Forms {
                        if ((long)nitems > 0) {
                                if (property == (IntPtr)Atom.XA_STRING) {
                                        // Xamarin-5116: PtrToStringAnsi expects to get UTF-8, but we might have
-                                       // Latin-1 instead.
+                                       // Latin-1 instead, in which case it will return null.
                                        var s = Marshal.PtrToStringAnsi (prop);
                                        if (string.IsNullOrEmpty (s)) {
                                                var sb = new StringBuilder ();
@@ -1338,7 +1338,7 @@ namespace System.Windows.Forms {
                                start = pos;
 
                                int length = 0;
-                               while (pos < value.Length) {
+                               while (pos < value.Length && length < 4) {
                                        if (!ValidHexDigit (value [pos]))
                                                break;
                                        length++;
index 4fcd04293bd595a075e7b956ea5f47ac73e24a19..d66e2d4c3207385c4b9ad88a4c63ee5db50284a1 100644 (file)
@@ -113,6 +113,8 @@ namespace System.Diagnostics
                        if (!is_running)
                                return;
                        elapsed += GetTimestamp () - started;
+                       if (elapsed < 0)
+                               elapsed = 0;
                        is_running = false;
                }
 
index 278e6e3426f83c0cf5c3b9d57cb971aa7a458f9d..4b3f468b091e0a91445b6e5ee363c2df51e07c87 100644 (file)
@@ -58,6 +58,7 @@ using System.Security.Authentication;
 using System.Threading.Tasks;
 
 namespace System.Net.Mail {
+       [Obsolete ("SmtpClient and its network of types are poorly designed, we strongly recommend you use https://github.com/jstedfast/MailKit and https://github.com/jstedfast/MimeKit instead")]
        public class SmtpClient
        : IDisposable
        {
@@ -581,10 +582,13 @@ namespace System.Net.Mail {
                        
                        // FIXME: parse the list of extensions so we don't bother wasting
                        // our time trying commands if they aren't supported.
-                       status = SendCommand ("EHLO " + Dns.GetHostName ());
+                       
+                       // Get the FQDN of the local machine
+                       string fqdn = Dns.GetHostEntry (Dns.GetHostName ()).HostName;
+                       status = SendCommand ("EHLO " + fqdn);
                        
                        if (IsError (status)) {
-                               status = SendCommand ("HELO " + Dns.GetHostName ());
+                               status = SendCommand ("HELO " + fqdn);
                                
                                if (IsError (status))
                                        throw new SmtpException (status.StatusCode, status.Description);
@@ -601,10 +605,10 @@ namespace System.Net.Mail {
                                ResetExtensions();
                                writer = new StreamWriter (stream);
                                reader = new StreamReader (stream);
-                               status = SendCommand ("EHLO " + Dns.GetHostName ());
+                               status = SendCommand ("EHLO " + fqdn);
                        
                                if (IsError (status)) {
-                                       status = SendCommand ("HELO " + Dns.GetHostName ());
+                                       status = SendCommand ("HELO " + fqdn);
                                
                                        if (IsError (status))
                                                throw new SmtpException (status.StatusCode, status.Description);
@@ -742,7 +746,7 @@ namespace System.Net.Mail {
 
                static void SendMailAsyncCompletedHandler (TaskCompletionSource<object> source, AsyncCompletedEventArgs e, SendCompletedEventHandler handler, SmtpClient client)
                {
-                       if ((object) handler != e.UserState)
+                       if (source != e.UserState)
                                return;
 
                        client.SendCompleted -= handler;
index 89fb47563b59af70715583545fe050662c7fea2f..04bf42eb87ba4edc50fdde571452482fe4b81cad 100644 (file)
@@ -257,7 +257,7 @@ namespace System.Net {
                                        if (i == (ips.Length - 1)) {
                                                if (i != 0  && val >= (256 << ((3 - i) * 8)))
                                                        return null;
-                                               else if (val > 0x3fffffffe) // this is the last number that parses correctly with MS
+                                               else if (val > 0xffffffff)
                                                        return null;
                                                i = 3;
                                        } else if (val >= 0x100)
@@ -378,8 +378,47 @@ namespace System.Net {
                                return m_Family;
                        }
                }
-               
-               
+
+#if NET_4_5
+
+               public IPAddress MapToIPv4 ()
+               {
+                       if (AddressFamily == AddressFamily.InterNetwork)
+                               return this;
+                       if (AddressFamily != AddressFamily.InterNetworkV6)
+                               throw new Exception ("Only AddressFamily.InterNetworkV6 can be converted to IPv4");
+
+                       //Test for 0000 0000 0000 0000 0000 FFFF xxxx xxxx
+                       for (int i = 0; i < 5; i++) {
+                               if (m_Numbers [i] != 0x0000)
+                                       throw new Exception ("Address does not have the ::FFFF prefix");
+                       }
+                       if (m_Numbers [5] != 0xFFFF)
+                               throw new Exception ("Address does not have the ::FFFF prefix");
+
+                       //We've got an IPv4 address
+                       byte [] ipv4Bytes = new byte [4];
+                       Buffer.BlockCopy (m_Numbers, 12, ipv4Bytes, 0, 4);
+                       return new IPAddress (ipv4Bytes);
+               }
+
+               public IPAddress MapToIPv6 ()
+               {
+                       if (AddressFamily == AddressFamily.InterNetworkV6)
+                               return this;
+                       if (AddressFamily != AddressFamily.InterNetwork)
+                               throw new Exception ("Only AddressFamily.InterNetworkV4 can be converted to IPv6");
+
+                       byte [] ipv4Bytes = GetAddressBytes ();
+                       byte [] ipv6Bytes = new byte [16] {
+                               0,0, 0,0, 0,0, 0,0, 0,0, 0xFF,0xFF,
+                               ipv4Bytes [0], ipv4Bytes [1], ipv4Bytes [2], ipv4Bytes [3]
+                       };
+                       return new IPAddress (ipv6Bytes);
+               }
+
+#endif
+
                /// <summary>
                ///   Used to tell whether an address is a loopback.
                ///   All IP addresses of the form 127.X.Y.Z, where X, Y, and Z are in 
index 0d1d124835d0abb745e346751e34c6e8dd0b12d2..641b787988ea5e4894c2ee87db5739ea97813fd9 100644 (file)
@@ -389,5 +389,23 @@ namespace MonoTests.System.Net.Mail
                        Assert.AreEqual ("<bar@example.com>", server.rcpt_to);
                }
 
+               [Test]
+               public void Deliver_Async ()
+               {
+                       var server = new SmtpServer ();
+                       var client = new SmtpClient ("localhost", server.EndPoint.Port);
+                       var msg = new MailMessage ("foo@example.com", "bar@example.com", "hello", "howdydoo\r\n");
+
+                       Thread t = new Thread (server.Run);
+                       t.Start ();
+                       var task = client.SendMailAsync (msg);
+                       t.Join ();
+
+                       Assert.AreEqual ("<foo@example.com>", server.mail_from);
+                       Assert.AreEqual ("<bar@example.com>", server.rcpt_to);
+
+                       Assert.IsTrue (task.IsCompleted, "task");
+               }
+
        }
 }
index 39866f384b6993f4f824505b373a9980f32936c5..db5d86eef2e765c21bb923d81842d834f2ec128c 100644 (file)
@@ -160,7 +160,6 @@ public class IPAddressTest
                "20.65535", "20.0.255.255",
                "0313.027035210", "203.92.58.136", // bug #411920
                "0313.0134.035210", "203.92.58.136", // too
-               "7848198702", "211.202.2.46", // too
                "1434328179", "85.126.28.115", // too
                "3397943208", "202.136.127.168", // too
        };
@@ -186,9 +185,12 @@ public class IPAddressTest
                "12.",
                "12.1.2.",
                "12...",
-               "  "
+               "  ",
+               "7848198702",
        };
 
+       static byte [] ipv4MappedIPv6Prefix = new byte [] { 0,0, 0,0, 0,0, 0,0, 0,0, 0xFF,0xFF };
+
        [Test]
        public void PublicFields ()
        {
@@ -639,6 +641,56 @@ public class IPAddressTest
                        }
                }
        }
+
+#if NET_4_5
+
+       [Test]
+       public void MapToIPv6 ()
+       {
+               for (int i = 0; i < ipv4ParseOk.Length / 2; i++) {
+                       IPAddress v4 = IPAddress.Parse (ipv4ParseOk [i * 2]);
+                       byte [] v4bytes = v4.GetAddressBytes ();
+                       IPAddress v6 = v4.MapToIPv6 ();
+                       byte [] v6bytes = v6.GetAddressBytes ();
+                       IPAddress v4back = v6.MapToIPv4 ();
+
+                       Assert.IsTrue (StartsWith (v6bytes, ipv4MappedIPv6Prefix), "MapToIPv6 #" + i + ".1");
+                       Assert.IsTrue (v6bytes [12] == v4bytes [0], "MapToIPv6 #" + i + ".2");
+                       Assert.IsTrue (v6bytes [13] == v4bytes [1], "MapToIPv6 #" + i + ".3");
+                       Assert.IsTrue (v6bytes [14] == v4bytes [2], "MapToIPv6 #" + i + ".4");
+                       Assert.IsTrue (v6bytes [15] == v4bytes [3], "MapToIPv6 #" + i + ".5");
+                       Assert.IsTrue (v4.Equals (v4back), "MapToIPv4 #" + i);
+               }
+
+               //TODO: Test using MapToIPv4/6 with anything other than IPv4/6 addresses.
+               //Currently it is not possible to do with the IPAddress implementation.
+       }
+
+       static bool StartsWith (byte [] a, byte [] b)
+       {
+               if (a.Length < b.Length)
+                       return false;
+               for (int i = 0; i < b.Length; i++)
+               {
+                       if (a [i] != b [i])
+                               return false;
+               }
+               return true;
+       }
+
+#endif
+
+       [Test]
+       public void EqualsFromBytes ()
+       {
+               for (int i = 0; i < ipv4ParseOk.Length / 2; i++) {
+                       IPAddress ip = IPAddress.Parse (ipv4ParseOk [i * 2]);
+                       IPAddress ipFromBytes = new IPAddress (ip.GetAddressBytes ());
+                       Assert.IsTrue (ip.Equals (ipFromBytes), "EqualsFromBytes #" + i);
+               }
+
+       }
+
 }
 }
 
index 3650cadc47f3124e3e96f6489ea309d5d16b24ec..3c6e3da2ffb6f74955c01a9e2cca04d2fdeaf55b 100644 (file)
@@ -361,14 +361,20 @@ namespace MonoTests.System.Reflection
 
                        IList<LocalVariableInfo> locals = mb.LocalVariables;
 
-                       // This might break with different compilers etc.
-                       Assert.AreEqual (2, locals.Count, "#3");
-
-                       Assert.IsTrue ((locals [0].LocalType == typeof (byte[])) || (locals [1].LocalType == typeof (byte[])), "#4");
-                       if (locals [0].LocalType == typeof (byte[]))
-                               Assert.AreEqual (false, locals [0].IsPinned, "#5");
-                       else
-                               Assert.AreEqual (false, locals [1].IsPinned, "#6");
+                       bool foundPinnedBytePointer = false;
+                       unsafe {
+                               foreach (LocalVariableInfo lvi in locals) {
+                                       if (lvi.LocalType == typeof (byte[]))
+                                               // This is optimized out by CSC in .NET 4.6
+                                               Assert.IsFalse (lvi.IsPinned, "#3-1");
+
+                                       if (/* mcs */ lvi.LocalType == typeof (byte*) || /* csc */ lvi.LocalType == typeof (byte).MakeByRefType ()) {
+                                               foundPinnedBytePointer = true;
+                                               Assert.IsTrue (lvi.IsPinned, "#3-2");
+                                       }
+                               }
+                       }
+                       Assert.IsTrue (foundPinnedBytePointer, "#4");
                }
 
                public int return_parameter_test ()
@@ -802,21 +808,44 @@ namespace MonoTests.System.Reflection
                        var type = typeof (GenericClass<>).GetMethod("Method").GetMethodBody().LocalVariables[0].LocalType;
                        Assert.AreEqual (typeofT, type);
                        Assert.AreEqual (typeof (GenericClass<>), type.DeclaringType);
+               
+                       bool foundTypeOfK = false;
+                       bool foundExpectedType = false;
+           
+                       MethodBody mb = typeof (GenericClass<>).GetMethod("Method2").GetMethodBody();
+                       foreach (LocalVariableInfo lvi in mb.LocalVariables) {
+                               if (lvi.LocalType == typeofK) {
+                                       foundTypeOfK = true;
+                                       Assert.AreEqual (typeof (GenericClass<>), lvi.LocalType.DeclaringType, "#1-1");
+                               } else if (lvi.LocalType == typeofT) {
+                                       foundExpectedType = true;
+                                       Assert.AreEqual (typeof (GenericClass<>), lvi.LocalType.DeclaringType, "#1-2");
+                               }
+                       }
 
-                       type = typeof (GenericClass<>).GetMethod("Method2").GetMethodBody().LocalVariables[0].LocalType;
-                       Assert.AreEqual (typeofT, type);
-                       Assert.AreEqual (typeof (GenericClass<>), type.DeclaringType);
-
-                       type = typeof (GenericClass<>).GetMethod("Method2").GetMethodBody().LocalVariables[1].LocalType;
-                       Assert.AreEqual (typeofK, type);
-                       Assert.AreEqual (typeof (GenericClass<>), type.DeclaringType);
-
-                       type = typeof (GenericClass<int>).GetMethod("Method2").GetMethodBody().LocalVariables[0].LocalType;
-                       Assert.AreEqual (typeof (int), type);
-
-                       type = typeof (GenericClass<int>).GetMethod("Method2").GetMethodBody().LocalVariables[1].LocalType;
-                       Assert.AreEqual (typeofK, type);
-                       Assert.AreEqual (typeof (GenericClass<>), type.DeclaringType);
+                       Assert.IsTrue (foundTypeOfK, "#1-3");
+                       if (mb.LocalVariables.Count < 2)
+                               Assert.Ignore ("Code built in release mode - 'T var0' optmized out");
+                       else
+                               Assert.IsTrue (foundExpectedType, "#1-4");
+           
+                       foundTypeOfK = false;
+                       foundExpectedType = false;
+                       mb = typeof (GenericClass<int>).GetMethod("Method2").GetMethodBody();
+                       foreach (LocalVariableInfo lvi in mb.LocalVariables) {
+                               if (lvi.LocalType == typeofK) {
+                                       foundTypeOfK = true;
+                                       Assert.AreEqual (typeof (GenericClass<>), lvi.LocalType.DeclaringType, "#2-1");
+                               } else if (lvi.LocalType == typeof (int)) {
+                                       foundExpectedType = true;
+                               }
+                       }
+           
+                       Assert.IsTrue (foundTypeOfK, "#2-3");
+                       if (mb.LocalVariables.Count < 2)
+                               Assert.Ignore ("Code built in release mode - 'int var0' optmized out");
+                       else
+                               Assert.IsTrue (foundExpectedType, "#2-4");
                }
 #endif
        }
index 99baefdd8b75df074ceaff4f1170f692230f1283..05d662c03981c979db50a7345cf556c49dc040e5 100644 (file)
@@ -105,7 +105,7 @@ namespace Mono.Tools {
                        RSA subjectKey = (RSA)RSA.Create ();
 
                        bool selfSigned = false;
-                       string hashName = "SHA1";
+                       string hashName = "SHA512";
 
                        CspParameters subjectParams = new CspParameters ();
                        CspParameters issuerParams = new CspParameters ();
@@ -150,11 +150,18 @@ namespace Mono.Tools {
                                                case "-a":
                                                        // hash algorithm
                                                        switch (args [i++].ToLower ()) {
+                                                               case "sha512":
+                                                                       hashName = "SHA512";
+                                                                       break;
+                                                               case "sha256":
+                                                                       hashName = "SHA256";
+                                                                       break;
                                                                case "sha1":
+                                                                       Console.WriteLine ("WARNING: SHA1 is not safe for this usage.");
                                                                        hashName = "SHA1";
                                                                        break;
                                                                case "md5":
-                                                                       Console.WriteLine ("WARNING: MD5 is no more safe for this usage.");
+                                                                       Console.WriteLine ("WARNING: MD5 is no safe for this usage.");
                                                                        hashName = "MD5";
                                                                        break;
                                                                default:
index 7e7d4e0953e77b7a9fabadefe2cdaa8f54a9476c..e47f958817170c1c735f20615cdd3d391d5a78a4 100644 (file)
@@ -6168,7 +6168,7 @@ ves_icall_System_Text_EncodingHelper_InternalCodePage (gint32 *int_code_page)
        p = encodings [0];
        code = 0;
        for (i = 0; p != 0; ){
-               if ((gssize) p < 7){
+               if ((gsize) p < 7){
                        code = (gssize) p;
                        p = encodings [++i];
                        continue;
index fb0e6592a118447dbde0c9576bd855b8540b3549..bb06f7eec0273cf41821d64e82c7c4c77bebffb6 100644 (file)
@@ -362,7 +362,7 @@ get_array_fill_vtable (void)
        if (!array_fill_vtable) {
                static MonoClass klass;
                static char _vtable[sizeof(MonoVTable)+8];
-               MonoVTable* vtable = (MonoVTable*) ALIGN_TO(_vtable, 8);
+               MonoVTable* vtable = (MonoVTable*) ALIGN_TO((mword)_vtable, 8);
                gsize bmap;
 
                MonoDomain *domain = mono_get_root_domain ();
@@ -2338,6 +2338,8 @@ sgen_client_scan_thread_data (void *start_nursery, void *end_nursery, gboolean p
 
        FOREACH_THREAD (info) {
                int skip_reason = 0;
+               void *aligned_stack_start = (void*)(mword) ALIGN_TO ((mword)info->client_info.stack_start, SIZEOF_VOID_P);
+
                if (info->client_info.skip) {
                        SGEN_LOG (3, "Skipping dead thread %p, range: %p-%p, size: %zd", info, info->client_info.stack_start, info->client_info.stack_end, (char*)info->client_info.stack_end - (char*)info->client_info.stack_start);
                        skip_reason = 1;
@@ -2357,13 +2359,13 @@ sgen_client_scan_thread_data (void *start_nursery, void *end_nursery, gboolean p
                g_assert (info->client_info.suspend_done);
                SGEN_LOG (3, "Scanning thread %p, range: %p-%p, size: %zd, pinned=%zd", info, info->client_info.stack_start, info->client_info.stack_end, (char*)info->client_info.stack_end - (char*)info->client_info.stack_start, sgen_get_pinned_count ());
                if (mono_gc_get_gc_callbacks ()->thread_mark_func && !conservative_stack_mark) {
-                       mono_gc_get_gc_callbacks ()->thread_mark_func (info->client_info.runtime_data, info->client_info.stack_start, info->client_info.stack_end, precise, &ctx);
+                       mono_gc_get_gc_callbacks ()->thread_mark_func (info->client_info.runtime_data, aligned_stack_start, info->client_info.stack_end, precise, &ctx);
                } else if (!precise) {
                        if (!conservative_stack_mark) {
                                fprintf (stderr, "Precise stack mark not supported - disabling.\n");
                                conservative_stack_mark = TRUE;
                        }
-                       sgen_conservatively_pin_objects_from (info->client_info.stack_start, info->client_info.stack_end, start_nursery, end_nursery, PIN_TYPE_STACK);
+                       sgen_conservatively_pin_objects_from (aligned_stack_start, info->client_info.stack_end, start_nursery, end_nursery, PIN_TYPE_STACK);
                }
 
                if (!precise) {
index e92a280219623d591227daf9742c2b3c1ae58e0d..2a0dfcfbeb572ae3c033b58f012f61672c173bc2 100644 (file)
@@ -932,6 +932,7 @@ mono_arch_init (void)
 #if defined(ENABLE_GSHAREDVT)
        mono_aot_register_jit_icall ("mono_arm_start_gsharedvt_call", mono_arm_start_gsharedvt_call);
 #endif
+       mono_aot_register_jit_icall ("mono_arm_unaligned_stack", mono_arm_unaligned_stack);
 
 #if defined(__ARM_EABI__)
        eabi_supported = TRUE;
@@ -6028,6 +6029,7 @@ mono_arch_register_lowlevel_calls (void)
        /* The signature doesn't matter */
        mono_register_jit_icall (mono_arm_throw_exception, "mono_arm_throw_exception", mono_create_icall_signature ("void"), TRUE);
        mono_register_jit_icall (mono_arm_throw_exception_by_token, "mono_arm_throw_exception_by_token", mono_create_icall_signature ("void"), TRUE);
+       mono_register_jit_icall (mono_arm_unaligned_stack, "mono_arm_unaligned_stack", mono_create_icall_signature ("void"), TRUE);
 
 #ifndef MONO_CROSS_COMPILE
        if (mono_arm_have_tls_get ()) {
@@ -6136,6 +6138,12 @@ mono_arch_patch_code_new (MonoCompile *cfg, MonoDomain *domain, guint8 *code, Mo
        }
 }
 
+void
+mono_arm_unaligned_stack (MonoMethod *method)
+{
+       g_assert_not_reached ();
+}
+
 #ifndef DISABLE_JIT
 
 /*
@@ -6292,6 +6300,27 @@ mono_arch_emit_prolog (MonoCompile *cfg)
                        max_offset += ((guint8 *)ins_get_spec (ins->opcode))[MONO_INST_LEN];
        }
 
+       /* stack alignment check */
+       /*
+       {
+               guint8 *buf [16];
+               ARM_MOV_REG_REG (code, ARMREG_LR, ARMREG_SP);
+               code = mono_arm_emit_load_imm (code, ARMREG_IP, MONO_ARCH_FRAME_ALIGNMENT -1);
+               ARM_AND_REG_REG (code, ARMREG_LR, ARMREG_LR, ARMREG_IP);
+               ARM_CMP_REG_IMM (code, ARMREG_LR, 0, 0);
+               buf [0] = code;
+               ARM_B_COND (code, ARMCOND_EQ, 0);
+               if (cfg->compile_aot)
+                       ARM_MOV_REG_IMM8 (code, ARMREG_R0, 0);
+               else
+                       code = mono_arm_emit_load_imm (code, ARMREG_R0, (guint32)cfg->method);
+               mono_add_patch_info (cfg, code - cfg->native_code, MONO_PATCH_INFO_INTERNAL_METHOD, "mono_arm_unaligned_stack");
+               code = emit_call_seq (cfg, code);
+               code = emit_call_reg (code, ARMREG_LR);
+               arm_patch (buf [0], code);
+       }
+       */
+
        /* store runtime generic context */
        if (cfg->rgctx_var) {
                MonoInst *ins = cfg->rgctx_var;
index 5135fcbb94808cdea4d403716a883cdd7b2326fd..35ce0fa9810091435f04dfc784c951abbcf0141a 100644 (file)
@@ -359,4 +359,7 @@ mono_arm_is_hard_float (void);
 gboolean
 mono_arm_have_tls_get (void);
 
+void
+mono_arm_unaligned_stack (MonoMethod *method);
+
 #endif /* __MONO_MINI_ARM_H__ */
index 0df2d3cd1af74d33f445fa11a8beaef0d820a95e..4ee385504bea1c339957a3080e005c3bfaf02b41 100644 (file)
@@ -2183,6 +2183,28 @@ coverage_add_coverage (CoverageCoverage *coverage)
 #define OBJ_ADDR(diff) ((obj_base + diff) << 3)
 #define LOG_TIME(base,diff) /*fprintf("outfile, time %llu + %llu near offset %d\n", base, diff, p - ctx->buf)*/
 
+
+/* Stats */
+#define BUFFER_HEADER_SIZE 48
+
+typedef struct {
+       int count, min_size, max_size, bytes;
+} EventStat;
+
+static int buffer_count;
+static EventStat stats [256];
+
+static void
+record_event_stats (int type, int size)
+{
+       ++stats [type].count;
+       if (!stats [type].min_size)
+               stats [type].min_size = size;
+       stats [type].min_size = MIN (stats [type].min_size, size);
+       stats [type].max_size = MAX (stats [type].max_size, size);
+       stats [type].bytes += size;
+}
+
 static int
 decode_buffer (ProfContext *ctx)
 {
@@ -2224,6 +2246,9 @@ decode_buffer (ProfContext *ctx)
        thread = load_thread (ctx, thread_id);
        if (!load_data (ctx, len))
                return 0;
+
+       ++buffer_count;
+
        if (!startup_time) {
                startup_time = time_base;
                if (use_time_filter) {
@@ -2238,6 +2263,8 @@ decode_buffer (ProfContext *ctx)
        p = ctx->buf;
        end = p + len;
        while (p < end) {
+               unsigned char *start = p;
+               unsigned char event = *p;
                switch (*p & 0xf) {
                case TYPE_GC: {
                        int subtype = *p & 0xf0;
@@ -3010,6 +3037,7 @@ decode_buffer (ProfContext *ctx)
                        fprintf (outfile, "unhandled profiler event: 0x%x at file offset: %llu + %lld (len: %d\n)\n", *p, (unsigned long long) file_offset, (long long) (p - ctx->buf), len);
                        exit (1);
                }
+               record_event_stats (event, p - start);
        }
        thread->last_time = time_base;
        for (i = 0; i < thread->stack_id; ++i)
@@ -3699,6 +3727,73 @@ dump_coverage (void)
        }
 }
 
+#define DUMP_EVENT_STAT(EVENT,SUBTYPE) dump_event (#EVENT, #SUBTYPE, EVENT, SUBTYPE);
+
+static void
+dump_event (const char *event_name, const char *subtype_name, int event, int subtype)
+{
+       int idx = event | subtype;
+       EventStat evt = stats [idx];
+       if (!evt.count)
+               return;
+
+       fprintf (outfile, "\t%16s\t%26s\tcount %6d\tmin %3d\tmax %6d\tbytes %d\n", event_name, subtype_name, evt.count, evt.min_size, evt.max_size, evt.bytes);
+}
+
+static void
+dump_stats (void)
+{
+       fprintf (outfile, "\nMlpd statistics\n");
+       fprintf (outfile, "\tBuffer count %d\toverhead %d (%d bytes per header)\n", buffer_count, buffer_count * BUFFER_HEADER_SIZE, BUFFER_HEADER_SIZE);
+       fprintf (outfile, "\nEvent details:\n");
+
+       DUMP_EVENT_STAT (TYPE_ALLOC, TYPE_ALLOC_NO_BT);
+       DUMP_EVENT_STAT (TYPE_ALLOC, TYPE_ALLOC_BT);
+
+       DUMP_EVENT_STAT (TYPE_GC, TYPE_GC_EVENT);
+       DUMP_EVENT_STAT (TYPE_GC, TYPE_GC_RESIZE);
+       DUMP_EVENT_STAT (TYPE_GC, TYPE_GC_MOVE);
+       DUMP_EVENT_STAT (TYPE_GC, TYPE_GC_HANDLE_CREATED);
+       DUMP_EVENT_STAT (TYPE_GC, TYPE_GC_HANDLE_DESTROYED);
+       DUMP_EVENT_STAT (TYPE_GC, TYPE_GC_HANDLE_CREATED_BT);
+       DUMP_EVENT_STAT (TYPE_GC, TYPE_GC_HANDLE_DESTROYED_BT);
+
+       DUMP_EVENT_STAT (TYPE_METADATA, TYPE_END_LOAD);
+       DUMP_EVENT_STAT (TYPE_METADATA, TYPE_END_UNLOAD);
+
+       DUMP_EVENT_STAT (TYPE_METHOD, TYPE_LEAVE);
+       DUMP_EVENT_STAT (TYPE_METHOD, TYPE_ENTER);
+       DUMP_EVENT_STAT (TYPE_METHOD, TYPE_EXC_LEAVE);
+       DUMP_EVENT_STAT (TYPE_METHOD, TYPE_JIT);
+
+       DUMP_EVENT_STAT (TYPE_EXCEPTION, TYPE_THROW);
+       DUMP_EVENT_STAT (TYPE_EXCEPTION, TYPE_CLAUSE);
+       DUMP_EVENT_STAT (TYPE_EXCEPTION, TYPE_EXCEPTION_BT);
+
+       DUMP_EVENT_STAT (TYPE_MONITOR, TYPE_MONITOR_NO_BT);
+       DUMP_EVENT_STAT (TYPE_MONITOR, TYPE_MONITOR_BT);
+
+       DUMP_EVENT_STAT (TYPE_HEAP, TYPE_HEAP_START);
+       DUMP_EVENT_STAT (TYPE_HEAP, TYPE_HEAP_END);
+       DUMP_EVENT_STAT (TYPE_HEAP, TYPE_HEAP_OBJECT);
+       DUMP_EVENT_STAT (TYPE_HEAP, TYPE_HEAP_ROOT);
+
+       DUMP_EVENT_STAT (TYPE_SAMPLE, TYPE_SAMPLE_HIT);
+       DUMP_EVENT_STAT (TYPE_SAMPLE, TYPE_SAMPLE_USYM);
+       DUMP_EVENT_STAT (TYPE_SAMPLE, TYPE_SAMPLE_UBIN);
+       DUMP_EVENT_STAT (TYPE_SAMPLE, TYPE_SAMPLE_COUNTERS_DESC);
+       DUMP_EVENT_STAT (TYPE_SAMPLE, TYPE_SAMPLE_COUNTERS);
+
+       DUMP_EVENT_STAT (TYPE_RUNTIME, TYPE_JITHELPER);
+
+       DUMP_EVENT_STAT (TYPE_COVERAGE, TYPE_COVERAGE_ASSEMBLY);
+       DUMP_EVENT_STAT (TYPE_COVERAGE, TYPE_COVERAGE_METHOD);
+       DUMP_EVENT_STAT (TYPE_COVERAGE, TYPE_COVERAGE_STATEMENT);
+       DUMP_EVENT_STAT (TYPE_COVERAGE, TYPE_COVERAGE_CLASS);
+}
+
+
+
 static void
 flush_context (ProfContext *ctx)
 {
@@ -3808,6 +3903,11 @@ print_reports (ProfContext *ctx, const char *reps, int parse_only)
                                dump_coverage ();
                        continue;
                }
+               if ((opt = match_option (p, "stats")) != p) {
+                       if (!parse_only)
+                               dump_stats ();
+                       continue;
+               }
                return 0;
        }
        return 1;
index 548d86b5065448c0981f2d64fa1fbdb92e883795..f1c8af5bf8b3c384ae5e800d1da53535b22683bb 100644 (file)
@@ -72,9 +72,11 @@ enum {
        TYPE_CLAUSE       = 1 << 4,
        TYPE_EXCEPTION_BT = 1 << 7,
        /* extended type for TYPE_ALLOC */
-       TYPE_ALLOC_BT  = 1 << 4,
+       TYPE_ALLOC_NO_BT  = 0 << 4,
+       TYPE_ALLOC_BT     = 1 << 4,
        /* extended type for TYPE_MONITOR */
-       TYPE_MONITOR_BT  = 1 << 7,
+       TYPE_MONITOR_NO_BT  = 0 << 7,
+       TYPE_MONITOR_BT     = 1 << 7,
        /* extended type for TYPE_SAMPLE */
        TYPE_SAMPLE_HIT           = 0 << 4,
        TYPE_SAMPLE_USYM          = 1 << 4,
index b3ee2ca50129ca82dc98efe8f5d0fe460fd11cec..18960bbc1ca447786f2f24d84b13de226316ca37 100644 (file)
@@ -822,6 +822,8 @@ sgen_conservatively_pin_objects_from (void **start, void **end, void *start_nurs
 {
        int count = 0;
 
+       SGEN_ASSERT (0, ((mword)start & (SIZEOF_VOID_P - 1)) == 0, "Why are we scanning for references in unaligned memory ?");
+
 #if defined(VALGRIND_MAKE_MEM_DEFINED_IF_ADDRESSABLE) && !defined(_WIN64)
        VALGRIND_MAKE_MEM_DEFINED_IF_ADDRESSABLE (start, (char*)end - (char*)start);
 #endif
index 0cd42f7a79f405233430a80d78083265c5021c9c..55f40aba76e646cf0f18e0f0fbc4627b8c259d5a 100644 (file)
@@ -559,17 +559,14 @@ ms_alloc_block (int size_index, gboolean pinned, gboolean has_references)
        add_free_block (free_blocks, size_index, info);
 
        /*
-        * This is the only place where the `allocated_blocks` array can potentially grow.
-        * We need to make sure concurrent sweep isn't running when that happens, so in that
-        * specific case we just wait for sweep to finish.
+        * Adding to the allocated_blocks array is racy with the removal of nulls when
+        * sweeping. We wait for sweep to finish to avoid that.
         *
         * The memory barrier here and in `sweep_job_func()` are required because we need
         * `allocated_blocks` synchronized between this and the sweep thread.
         */
-       if (sgen_pointer_queue_will_grow (&allocated_blocks)) {
-               major_finish_sweep_checking ();
-               mono_memory_barrier ();
-       }
+       major_finish_sweep_checking ();
+       mono_memory_barrier ();
 
        sgen_pointer_queue_add (&allocated_blocks, BLOCK_TAG (info));
 
@@ -746,8 +743,6 @@ major_alloc_degraded (GCVTable vtable, size_t size)
 {
        GCObject *obj;
 
-       major_finish_sweep_checking ();
-
        obj = alloc_obj (vtable, size, FALSE, SGEN_VTABLE_HAS_REFERENCES (vtable));
        if (G_LIKELY (obj)) {
                HEAVY_STAT (++stat_objects_alloced_degraded);
index 614441747dd0f64ba755454ee3d73b64815d657e..e655347e4a22c51cdbbd15b4c0a7e7bb776fd6f5 100644 (file)
@@ -178,6 +178,7 @@ sgen_memgov_collection_end (int generation, GGTimingInfo* info, int info_count)
                if (info[i].generation != -1)
                        sgen_client_log_timing (&info [i], last_major_num_sections, last_los_memory_usage);
        }
+       last_major_num_sections = major_collector.get_num_major_sections ();
 }
 
 /*
index a19e543e091ab29f1f1eb075812f21e0cae6cb15..10e0da01b2e9a24119c0b45f6eef17afe506e58d 100644 (file)
@@ -7,8 +7,6 @@ if PLATFORM_DARWIN
 test_ldflags = -framework CoreFoundation -framework Foundation
 endif
 
-AUTOMAKE_OPTIONS = parallel-tests
-
 if !CROSS_COMPILE
 if !HOST_WIN32
 if SUPPORT_BOEHM
@@ -44,10 +42,12 @@ TESTS = test-sgen-qsort test-memfuncs test-mono-linked-list-set test-conc-hashta
 .NOTPARALLEL:
 
 check-local:
-       if grep -q "# FAIL:  0\|tests passed" test-suite.log; then successbool=True && failures=0; else successbool=False && failures=1; fi; \
-       echo "<?xml version='1.0' encoding='utf-8'?><test-results failures='$$failures' total='1' not-run='0' name='unit-tests.dummy' date='$$(date +%F)' time='$$(date +%T)'><test-suite name='MonoTests.unit-tests' success='$$successbool' time='0'><results><test-case name='MonoTests.unit-tests.100percentsuccess' executed='True' success='$$successbool' time='0'>" > TestResult-unit-tests.xml; \
-       if [ $$failures -ne 0 ]; then echo "<failure><message>"'<![CDATA[' >> TestResult-unit-tests.xml && cat test-suite.log >> TestResult-unit-tests.xml && echo "]]></message><stack-trace></stack-trace></failure>" >> TestResult-unit-tests.xml; fi; \
-       echo "</test-case></results></test-suite></test-results>" >> TestResult-unit-tests.xml
+       if [ -e test-suite.log ]; then \
+               if grep -q "# FAIL:  0\|tests passed" test-suite.log; then successbool=True && failures=0; else successbool=False && failures=1; fi; \
+               echo "<?xml version='1.0' encoding='utf-8'?><test-results failures='$$failures' total='1' not-run='0' name='unit-tests.dummy' date='$$(date +%F)' time='$$(date +%T)'><test-suite name='MonoTests.unit-tests' success='$$successbool' time='0'><results><test-case name='MonoTests.unit-tests.100percentsuccess' executed='True' success='$$successbool' time='0'>" > TestResult-unit-tests.xml; \
+               if [ $$failures -ne 0 ]; then echo "<failure><message>"'<![CDATA[' >> TestResult-unit-tests.xml && cat test-suite.log >> TestResult-unit-tests.xml && echo "]]></message><stack-trace></stack-trace></failure>" >> TestResult-unit-tests.xml; fi; \
+               echo "</test-case></results></test-suite></test-results>" >> TestResult-unit-tests.xml; \
+       fi;
 
 endif SUPPORT_BOEHM
 endif !HOST_WIN32
index dc53e857aae60158bae7474d76c8a662dcdd8465..6faaedf14aa57923cb1ad81259136ab09f2ecb39 100644 (file)
 #include <signal.h>
 #endif
 
-#if defined (HOST_WATCHOS) || defined (HOST_APPLETVOS)
-#include <libunwind.h>
-#endif
-
 /*
  * General notes about mono-context.
  * Each arch defines a MonoContext struct with all GPR regs + IP/PC.
@@ -256,26 +252,6 @@ typedef struct {
 #if defined(HOST_WATCHOS)
 
 #define MONO_CONTEXT_GET_CURRENT(ctx) do { \
-       unw_context_t uctx; \
-       unw_cursor_t c; \
-       unw_word_t data; \
-       g_assert (unw_getcontext (&uctx) == 0); \
-       g_assert (unw_init_local (&c, &uctx) == 0); \
-       for (int reg = 0; reg < 13; ++reg) { \
-               unw_get_reg (&c, (unw_regnum_t) UNW_ARM_R0 + reg, &data); \
-               ctx.regs[reg] = data; \
-       } \
-       unw_get_reg (&c, UNW_ARM_SP, &data); \
-       ctx.regs[ARMREG_SP] = data; \
-       unw_get_reg (&c, UNW_ARM_LR, &data); \
-       ctx.regs[ARMREG_LR] = data; \
-       unw_get_reg (&c, UNW_ARM_IP, &data); \
-       ctx.regs[ARMREG_PC] = data; \
-       ctx.pc = ctx.regs[ARMREG_PC]; \
-       for (int reg = 0; reg < 16; ++reg) { \
-               unw_get_reg (&c, (unw_regnum_t) UNW_ARM_D0 + reg, &data); \
-               ctx.fregs[reg] = data; \
-       } \
 } while (0);
 
 #else