Merge pull request #2874 from lateralusX/jlorenss/win-x64-support
authormonojenkins <jo.shields+jenkins@xamarin.com>
Wed, 13 Apr 2016 16:35:31 +0000 (17:35 +0100)
committermonojenkins <jo.shields+jenkins@xamarin.com>
Wed, 13 Apr 2016 16:35:31 +0000 (17:35 +0100)
jlorenss/win x64 support

Initial fixes needed in order to get pass on mono regression tests for windows x64 visual studio build,

--regression basic.exe basic-float.exe basic-long.exe basic-calls.exe objects.exe arrays.exe basic-math.exe exceptions.exe iltests.exe devirtualization.exe generics.exe basic-simd.exe

Before fixes there were failures in basic.exe, exceptions.exe and objects.exe for windows x64  Visual studio build.

Failures in basic.exe and exceptions.exe was due to a mix up of signal defines on windows platform in Visual Studio build  where SIGILL and SIGFPE was defined differently in different source files causing incorrect signal handler to be invoked at runtime, causing incorrect thrown .NET exception. Fix is to make sure signal.h is always included giving the same value for SIGILl and SIGFPE over all source files.

Failures in objects.exe test_0_mul_ovf_regress_36052 caused a stack overflow crash when running togehter with branch optimization mode. This was due to incorrect lowering of x64 test instruction when optimization moved over to use R8 instead of RAX and current lowering didn't handle that correctly meaning that the actual test was performed against wrong register causing a loop that caused a stack overflow error. The specific amd64 codegen , amd64_test_reg_imm, is currently only used on x64 windows platform for the stackalloc call.

46 files changed:
external/referencesource
mcs/class/Mono.Security/Makefile
mcs/class/Mono.Security/monotouch_Mono.Security.dll.sources
mcs/class/Mono.Security/xammac_Mono.Security.dll.sources
mcs/class/System/System.Security.Cryptography.X509Certificates/OSX509Certificates.cs
mcs/class/System/System.Security.Cryptography.X509Certificates/X509Certificate2ImplMono.cs
mcs/class/corlib/CommonCrypto/.gitignore
mcs/class/corlib/CommonCrypto/CommonCryptorGenerator.cs [deleted file]
mcs/class/corlib/CommonCrypto/CommonDigestGenerator.cs [deleted file]
mcs/class/corlib/CommonCrypto/Makefile [new file with mode: 0644]
mcs/class/corlib/CommonCrypto/Makefile.include [deleted file]
mcs/class/corlib/CommonCrypto/generator.cs [deleted file]
mcs/class/corlib/Makefile
mcs/class/corlib/System.IO/Directory.cs
mcs/class/corlib/System.IO/DirectoryInfo.cs
mcs/class/corlib/System.Reflection.Emit/DerivedTypes.cs
mcs/class/corlib/System.Security.Cryptography.X509Certificates/X509CertificateImpl.cs
mcs/class/corlib/System.Security.Cryptography.X509Certificates/X509CertificateImplApple.cs
mcs/class/corlib/System.Security.Cryptography.X509Certificates/X509CertificateImplMono.cs
mcs/class/corlib/System/Environment.cs
mcs/class/corlib/Test/System.IO/DirectoryTest.cs
mcs/class/corlib/Test/System.Reflection.Emit/DerivedTypesTest.cs
mcs/class/corlib/Test/System.Threading/TimerTest.cs
mcs/class/corlib/corlib.dll.sources
mcs/class/corlib/monotouch_corlib.dll.sources
mcs/class/corlib/monotouch_tv_corlib.dll.sources
mcs/class/corlib/monotouch_watch_corlib.dll.sources
mcs/class/corlib/xammac_corlib.dll.sources
mcs/tools/Makefile
mcs/tools/commoncryptogenerator/CommonCryptorGenerator.cs [new file with mode: 0644]
mcs/tools/commoncryptogenerator/CommonDigestGenerator.cs [new file with mode: 0644]
mcs/tools/commoncryptogenerator/Makefile [new file with mode: 0644]
mcs/tools/commoncryptogenerator/commoncryptogenerator.exe.sources [new file with mode: 0644]
mcs/tools/commoncryptogenerator/generator.cs [new file with mode: 0644]
mono/metadata/appdomain.c
mono/metadata/cominterop.c
mono/metadata/icall-def.h
mono/metadata/marshal.c
mono/metadata/sgen-client-mono.h
mono/mini/decompose.c
mono/mini/driver.c
mono/mini/local-propagation.c
mono/mini/mini-x86.c
mono/mini/mini-x86.h
mono/sgen/sgen-marksweep.c
mono/sgen/sgen-protocol-def.h

index 2f66da8d34b30473dac23f02b1a843d0717b9f1a..1f9f4ae3de23a100d871eae9f12da22d9353b182 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 2f66da8d34b30473dac23f02b1a843d0717b9f1a
+Subproject commit 1f9f4ae3de23a100d871eae9f12da22d9353b182
index 1fbfd14ec8efcff4e6514e1cac32c6d3794648a0..6d62eca583d7d32776d05e4ac5d33e1458cd8500 100644 (file)
@@ -8,6 +8,19 @@ LIB_REFS = bare/System
 LIB_MCS_FLAGS = -unsafe -nowarn:1030,3009
 TEST_MCS_FLAGS = $(LIB_MCS_FLAGS) -nowarn:169,219,618,672
 
+CC_PROFILE := $(filter monotouch% xammac, $(PROFILE))
+ifdef CC_PROFILE
+
+BUILT_SOURCES = \
+       ../corlib/CommonCrypto/SHA224Managed.g.cs \
+       ../corlib/CommonCrypto/MD2Managed.g.cs \
+       ../corlib/CommonCrypto/MD4Managed.g.cs
+
+../corlib/CommonCrypto/%.g.cs:
+       $(MAKE) -C ../corlib/CommonCrypto
+
+endif
+
 include ../../build/library.make
 
 $(build_lib): $(the_libdir_base)bare/System.dll
index 17f56e3c4054885b5f5cf4477cef4bed1ff63c44..36918de7763e9ed1c24609f0a67e752c39967081 100644 (file)
@@ -1,6 +1,3 @@
 #include mobile_Mono.Security.dll.sources
 ../corlib/CommonCrypto/CommonCrypto.cs
 ../corlib/CommonCrypto/RC4CommonCrypto.cs
-../corlib/CommonCrypto/MD2Managed.g.cs
-../corlib/CommonCrypto/MD4Managed.g.cs
-../corlib/CommonCrypto/SHA224Managed.g.cs
index 6c1b4dbef6fda25d7d76612c984ad0776f33ee7f..698996a1d709c630c585a43f2f5ac90021c5e65a 100644 (file)
@@ -1,7 +1,4 @@
 #include monotouch_Mono.Security.dll.sources
 ../corlib/CommonCrypto/CommonCrypto.cs
 ../corlib/CommonCrypto/RC4CommonCrypto.cs
-../corlib/CommonCrypto/MD2Managed.g.cs
-../corlib/CommonCrypto/MD4Managed.g.cs
-../corlib/CommonCrypto/SHA224Managed.g.cs
 
index 184e586471dd30c167be16eca420d930c5c12bfb..00384f45901270d01bb3ee3898854634e834e3b5 100644 (file)
@@ -101,16 +101,17 @@ namespace System.Security.Cryptography.X509Certificates {
                        }
                }
 
-               static IntPtr GetCertificate (X509Certificate certificate, out IntPtr dataPtr)
+               static IntPtr GetCertificate (X509Certificate certificate)
                {
-                       var handle = certificate.Handle;
+                       var handle = certificate.Impl.GetNativeAppleCertificate ();
                        if (handle != IntPtr.Zero) {
-                               dataPtr = IntPtr.Zero;
                                CFRetain (handle);
                                return handle;
                        }
-                       dataPtr = MakeCFData (certificate.GetRawCertData ());
-                       return SecCertificateCreateWithData (IntPtr.Zero, dataPtr);
+                       var dataPtr = MakeCFData (certificate.GetRawCertData ());
+                       handle = SecCertificateCreateWithData (IntPtr.Zero, dataPtr);
+                       CFRelease (dataPtr);
+                       return handle;
                }
                
                public static SecTrustResult TrustEvaluateSsl (XX509CertificateCollection certificates, XX509CertificateCollection anchors, string host)
@@ -129,9 +130,7 @@ namespace System.Security.Cryptography.X509Certificates {
                {
                        int certCount = certificates.Count;
                        int anchorCount = anchors != null ? anchors.Count : 0;
-                       IntPtr [] cfDataPtrs = new IntPtr [certCount];
                        IntPtr [] secCerts = new IntPtr [certCount];
-                       IntPtr [] cfDataAnchorPtrs = new IntPtr [anchorCount];
                        IntPtr [] secCertAnchors = new IntPtr [anchorCount];
                        IntPtr certArray = IntPtr.Zero;
                        IntPtr anchorArray = IntPtr.Zero;
@@ -142,13 +141,13 @@ namespace System.Security.Cryptography.X509Certificates {
 
                        try {
                                for (int i = 0; i < certCount; i++) {
-                                       secCerts [i] = GetCertificate (certificates [i], out cfDataPtrs [i]);
+                                       secCerts [i] = GetCertificate (certificates [i]);
                                        if (secCerts [i] == IntPtr.Zero)
                                                return SecTrustResult.Deny;
                                }
 
                                for (int i = 0; i < anchorCount; i++) {
-                                       secCertAnchors [i] = GetCertificate (anchors [i], out cfDataAnchorPtrs [i]);
+                                       secCertAnchors [i] = GetCertificate (anchors [i]);
                                        if (secCertAnchors [i] == IntPtr.Zero)
                                                return SecTrustResult.Deny;
                                }
@@ -170,14 +169,6 @@ namespace System.Security.Cryptography.X509Certificates {
                                code = SecTrustEvaluate (sectrust, out result);
                                return result;
                        } finally {
-                               for (int i = 0; i < certCount; i++)
-                                       if (cfDataPtrs [i] != IntPtr.Zero)
-                                               CFRelease (cfDataPtrs [i]);
-
-                               for (int i = 0; i < anchorCount; i++)
-                                       if (cfDataAnchorPtrs [i] != IntPtr.Zero)
-                                               CFRelease (cfDataAnchorPtrs [i]);
-
                                if (certArray != IntPtr.Zero)
                                        CFRelease (certArray);
 
index 87fd8a16d225230326f98043ae7f4d1de702a58a..bfb2696f97c99d3098801cd260bf07a6603c721b 100644 (file)
@@ -72,6 +72,11 @@ namespace System.Security.Cryptography.X509Certificates
                        get { return IntPtr.Zero; }
                }
 
+               public override IntPtr GetNativeAppleCertificate ()
+               {
+                       return IntPtr.Zero;
+               }
+
                internal X509Certificate2ImplMono (MX.X509Certificate cert)
                {
                        this._cert = cert;
index 1252b936471eb76b900e31855df7d32f96ee64d2..bd99fb05241810f064a23fdfe7198f084576344d 100644 (file)
@@ -1,2 +1 @@
 *.g.cs
-generator.exe
diff --git a/mcs/class/corlib/CommonCrypto/CommonCryptorGenerator.cs b/mcs/class/corlib/CommonCrypto/CommonCryptorGenerator.cs
deleted file mode 100644 (file)
index f177c17..0000000
+++ /dev/null
@@ -1,104 +0,0 @@
-//
-// CommonCrypto code generator for symmetric block cipher algorithms
-//
-// Authors:
-//     Sebastien Pouliot  <sebastien@xamarin.com>
-//
-// Copyright 2012 Xamarin Inc.
-//
-
-using System;
-using System.IO;
-
-namespace Xamarin {
-
-       public static class CommonCryptor {
-               
-               static public void Generate (string namespaceName, string typeName, string baseTypeName, string ccAlgorithmName, string feedbackSize = "8", string ctorInitializers = null)
-               {
-                       string template = @"// Generated file to bind CommonCrypto cipher algorithms - DO NOT EDIT
-//
-// Authors:
-//     Sebastien Pouliot  <sebastien@xamarin.com>
-//
-// Copyright 2012-2014 Xamarin Inc.
-
-using System;
-using System.Security.Cryptography;
-
-using Mono.Security.Cryptography;
-using Crimson.CommonCrypto;
-
-namespace %NAMESPACE% {
-
-       public sealed partial class %TYPE% : %BASE% {
-               
-               public %TYPE% ()
-               {
-                       FeedbackSizeValue = %FEEDBACKSIZE%;
-                       %CTOR_INIT%
-               }
-               
-               public override void GenerateIV ()
-               {
-                       IVValue = KeyBuilder.IV (BlockSizeValue >> 3);
-               }
-               
-               public override void GenerateKey ()
-               {
-                       KeyValue = KeyBuilder.Key (KeySizeValue >> 3);
-               }
-               
-               public override ICryptoTransform CreateDecryptor (byte[] rgbKey, byte[] rgbIV) 
-               {
-                       IntPtr decryptor = IntPtr.Zero;
-                       switch (Mode) {
-                       case CipherMode.CBC:
-                               decryptor = Cryptor.Create (CCOperation.Decrypt, CCAlgorithm.%CCALGORITHM%, CCOptions.None, rgbKey, rgbIV);
-                               return new FastCryptorTransform (decryptor, this, false, rgbIV);
-                       case CipherMode.ECB:
-                               decryptor = Cryptor.Create (CCOperation.Decrypt, CCAlgorithm.%CCALGORITHM%, CCOptions.ECBMode, rgbKey, rgbIV);
-                               return new FastCryptorTransform (decryptor, this, false, rgbIV);
-                       case CipherMode.CFB:
-#if MONOTOUCH || XAMMAC
-                               IntPtr encryptor = Cryptor.Create (CCOperation.Encrypt, CCAlgorithm.%CCALGORITHM%, CCOptions.ECBMode, rgbKey, rgbIV);
-                               decryptor = Cryptor.Create (CCOperation.Decrypt, CCAlgorithm.%CCALGORITHM%, CCOptions.ECBMode, rgbKey, rgbIV);
-                               return new CryptorTransform (decryptor, encryptor, this, false, rgbIV);
-#else
-                               throw new CryptographicException (""CFB is not supported by Crimson.CommonCrypto"");
-#endif
-                       default:
-                               throw new CryptographicException (String.Format (""{0} is not supported by the .NET framework"", Mode));
-                       }
-               }
-               
-               public override ICryptoTransform CreateEncryptor (byte[] rgbKey, byte[] rgbIV) 
-               {
-                       IntPtr encryptor = IntPtr.Zero;
-                       switch (Mode) {
-                       case CipherMode.CBC:
-                               encryptor = Cryptor.Create (CCOperation.Encrypt, CCAlgorithm.%CCALGORITHM%, CCOptions.None, rgbKey, rgbIV);
-                               return new FastCryptorTransform (encryptor, this, true, rgbIV);
-                       case CipherMode.ECB:
-                               encryptor = Cryptor.Create (CCOperation.Encrypt, CCAlgorithm.%CCALGORITHM%, CCOptions.ECBMode, rgbKey, rgbIV);
-                               return new FastCryptorTransform (encryptor, this, true, rgbIV);
-                       case CipherMode.CFB:
-#if MONOTOUCH || XAMMAC
-                               encryptor = Cryptor.Create (CCOperation.Encrypt, CCAlgorithm.%CCALGORITHM%, CCOptions.ECBMode, rgbKey, rgbIV);
-                               return new CryptorTransform (encryptor, IntPtr.Zero, this, true, rgbIV);
-#else
-                               throw new CryptographicException (""CFB is not supported by Crimson.CommonCrypto"");
-#endif
-                       default:
-                               throw new CryptographicException (String.Format (""{0} is not supported by the .NET framework"", Mode));
-                       }
-               }
-       }
-}";
-                       
-                       File.WriteAllText (typeName + ".g.cs", template.Replace ("%NAMESPACE%", namespaceName).
-                               Replace ("%TYPE%", typeName).Replace ("%BASE%", baseTypeName).Replace("%FEEDBACKSIZE%", feedbackSize).Replace ("%CTOR_INIT%", ctorInitializers).
-                               Replace ("%CCALGORITHM%", ccAlgorithmName.ToString ()));
-               }
-       }
-}
diff --git a/mcs/class/corlib/CommonCrypto/CommonDigestGenerator.cs b/mcs/class/corlib/CommonCrypto/CommonDigestGenerator.cs
deleted file mode 100644 (file)
index 1b729e3..0000000
+++ /dev/null
@@ -1,167 +0,0 @@
-//
-// CommonCrypto code generator for digest algorithms
-//
-// Authors:
-//     Sebastien Pouliot  <sebastien@xamarin.com>
-//
-// Copyright 2012-2014 Xamarin Inc.
-//
-
-using System;
-using System.IO;
-
-namespace Xamarin {
-
-       public static class CommonDigest {
-               
-#if !MONOTOUCH && !XAMMAC
-               // we do not add anything in MonoTouch, just replacing, so this is not needed
-               // however we can avoid a dependency on Mono.Security for Crimson.CommonCrypto.dll by including the base classes
-               static public void GenerateBaseClass (string namespaceName, string typeName, string baseTypeName, int hashSize,
-                       string visibilityStart = "", string visibilityEnd = "")
-               {
-                       string template = @"// Generated file to bind CommonCrypto/CommonDigest - DO NOT EDIT
-//
-// Authors:
-//     Sebastien Pouliot  <sebastien@xamarin.com>
-//
-// Copyright 2012-2014 Xamarin Inc.
-
-using System;
-using System.Security.Cryptography;
-using System.Runtime.InteropServices;
-
-namespace %NAMESPACE% {
-
-%VISIBILITY_START%
-       public
-%VISIBILITY_END%
-       abstract class %BASE% : HashAlgorithm {
-
-               protected %BASE% () 
-               {
-                       HashSizeValue = %HASHSIZE%; 
-               }
-
-               public static new %BASE% Create ()
-               {
-                       return Create (""%BASE%"");
-               }
-
-               public static new %BASE% Create (string hashName)
-               {
-                       object o = CryptoConfig.CreateFromName (hashName);
-                       return (%BASE%) o ?? new %TYPE% ();
-               }
-       }
-}";
-                       
-                       File.WriteAllText (baseTypeName + ".g.cs", template.Replace ("%NAMESPACE%", namespaceName).
-                               Replace ("%TYPE%", typeName).Replace ("%BASE%", baseTypeName).
-                               Replace ("%VISIBILITY_START%", visibilityStart).Replace ("%VISIBILITY_END%", visibilityEnd).
-                               Replace ("%HASHSIZE%", hashSize.ToString ()));
-               }
-#endif
-               static public void Generate (string namespaceName, string typeName, string baseTypeName, int contextSize,
-                       string visibilityStart = "", string visibilityEnd = "")
-               {
-                       string template = @"// Generated file to bind CommonCrypto/CommonDigest - DO NOT EDIT
-//
-// Authors:
-//     Sebastien Pouliot  <sebastien@xamarin.com>
-//
-// Copyright 2011-2014 Xamarin Inc.
-
-using System;
-using System.Security.Cryptography;
-using System.Runtime.InteropServices;
-
-using Mono.Security.Cryptography;
-
-namespace %NAMESPACE% {
-
-%VISIBILITY_START%
-       public
-%VISIBILITY_END%
-       sealed class %TYPE% : %BASE% {
-
-               IntPtr ctx;
-
-               [DllImport (""/usr/lib/libSystem.dylib"", EntryPoint=""CC_%BASE%_Init"")]
-               static extern int Init (/* CC_%BASE%_CTX */ IntPtr c);
-
-               [DllImport (""/usr/lib/libSystem.dylib"", EntryPoint=""CC_%BASE%_Update"")]
-               static extern int Update (/* CC_%BASE%_CTX */ IntPtr c, /* const void * */ IntPtr data, /* uint32_t */ uint len);
-
-               [DllImport (""/usr/lib/libSystem.dylib"", EntryPoint=""CC_%BASE%_Final"")]
-               static extern int Final (/* unsigned char * */ byte [] md, /* CC_%BASE%_CTX */ IntPtr c);
-
-               public %TYPE% ()
-               {
-                       ctx = IntPtr.Zero;
-               }
-
-               ~%TYPE% ()
-               {
-                       Dispose (false);
-               }
-
-               protected override void Dispose (bool disposing)
-               {
-                       if (ctx != IntPtr.Zero) {
-                               Marshal.FreeHGlobal (ctx);
-                               ctx = IntPtr.Zero;
-                       }
-                       base.Dispose (disposing);
-                       GC.SuppressFinalize (this);
-               }
-
-               public override void Initialize ()
-               {
-                       if (ctx == IntPtr.Zero)
-                               ctx = Marshal.AllocHGlobal (%CTX_SIZE%);
-                       
-                       int hr = Init (ctx);
-                       if (hr != 1)
-                               throw new CryptographicException (hr);
-               }
-
-               protected override void HashCore (byte[] data, int start, int length) 
-               {
-                       if (ctx == IntPtr.Zero)
-                               Initialize ();
-
-                       if (data.Length == 0)
-                               return;
-
-                       unsafe {
-                               fixed (byte* p = &data [0]) {
-                                       int hr = Update (ctx, (IntPtr) (p + start), (uint) length);
-                                       if (hr != 1)
-                                               throw new CryptographicException (hr);
-                               }
-                       }
-               }
-
-               protected override byte[] HashFinal () 
-               {
-                       if (ctx == IntPtr.Zero)
-                               Initialize ();
-                       
-                       byte[] data = new byte [HashSize >> 3];
-                       int hr = Final (data, ctx);
-                       if (hr != 1)
-                               throw new CryptographicException (hr);
-
-                       return data;
-               }
-       }
-}";
-                       
-                       File.WriteAllText (typeName + ".g.cs", template.Replace ("%NAMESPACE%", namespaceName).
-                               Replace ("%TYPE%", typeName).Replace ("%BASE%", baseTypeName).
-                               Replace ("%VISIBILITY_START%", visibilityStart).Replace ("%VISIBILITY_END%", visibilityEnd).
-                               Replace ("%CTX_SIZE%", contextSize.ToString ()));
-               }
-       }
-}
diff --git a/mcs/class/corlib/CommonCrypto/Makefile b/mcs/class/corlib/CommonCrypto/Makefile
new file mode 100644 (file)
index 0000000..36ea8d3
--- /dev/null
@@ -0,0 +1,8 @@
+thisdir = class/corlib/CommonCrypto
+SUBDIRS =
+include ../../../build/rules.make
+
+.NOTPARALLEL:
+all:
+       MONO_PATH="$(topdir)/class/lib/$(BUILD_TOOLS_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(RUNTIME) $(RUNTIME_FLAGS) $(topdir)/class/lib/$(BUILD_TOOLS_PROFILE)/commoncryptogenerator.exe
+
diff --git a/mcs/class/corlib/CommonCrypto/Makefile.include b/mcs/class/corlib/CommonCrypto/Makefile.include
deleted file mode 100644 (file)
index 25e1379..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-CommonCrypto/%.g.cs: CommonCrypto/generator.exe
-       cd CommonCrypto && mono --debug generator.exe
-
-CommonCrypto/generator.exe: CommonCrypto/generator.cs CommonCrypto/CommonDigestGenerator.cs CommonCrypto/CommonCryptorGenerator.cs
-       mcs CommonCrypto/generator.cs CommonCrypto/CommonDigestGenerator.cs CommonCrypto/CommonCryptorGenerator.cs -o $@
diff --git a/mcs/class/corlib/CommonCrypto/generator.cs b/mcs/class/corlib/CommonCrypto/generator.cs
deleted file mode 100644 (file)
index a7d13c8..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-//
-// CommonCrypto Code Generator
-//
-// Authors:
-//     Sebastien Pouliot  <sebastien@xamarin.com>
-//
-// Copyright 2012 Xamarin Inc.
-//
-
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Text;
-
-namespace Xamarin {
-       
-       class Program {
-               static void Main (string [] args)
-               {
-                       // mscorlib replacements
-                       CommonDigest.Generate ("System.Security.Cryptography", "MD5CryptoServiceProvider", "MD5", 1000);
-                       CommonDigest.Generate ("System.Security.Cryptography", "SHA1CryptoServiceProvider", "SHA1", 1000);
-                       CommonDigest.Generate ("System.Security.Cryptography", "SHA1Managed", "SHA1", 1000);
-                       CommonDigest.Generate ("System.Security.Cryptography", "SHA256Managed", "SHA256", 1000);
-                       CommonDigest.Generate ("System.Security.Cryptography", "SHA384Managed", "SHA384", 1000);
-                       CommonDigest.Generate ("System.Security.Cryptography", "SHA512Managed", "SHA512", 1000);
-                       
-                       // System.Core replacements - not yet in MT profile (4.0 - functional dupes anyway)
-                       //CommonDigest.Generate ("System.Security.Cryptography", "MD5Cng", "MD5", 1000);
-                       //CommonDigest.Generate ("System.Security.Cryptography", "SHA256Cng", "SHA256", 1000);
-                       //CommonDigest.Generate ("System.Security.Cryptography", "SHA384Cng", "SHA384", 1000);
-                       //CommonDigest.Generate ("System.Security.Cryptography", "SHA512Cng", "SHA512", 1000);
-                       //CommonDigest.Generate ("System.Security.Cryptography", "SHA256CryptoServiceProvider", "SHA256", 1000);
-                       //CommonDigest.Generate ("System.Security.Cryptography", "SHA384CryptoServiceProvider", "SHA384", 1000);
-                       //CommonDigest.Generate ("System.Security.Cryptography", "SHA512CryptoServiceProvider", "SHA512", 1000);
-                       
-                       // Mono.Security replacements
-                       CommonDigest.Generate ("Mono.Security.Cryptography", "MD2Managed", "MD2", 1000, "#if !INSIDE_CORLIB", "#endif");
-                       CommonDigest.Generate ("Mono.Security.Cryptography", "MD4Managed", "MD4", 1000, "#if !INSIDE_CORLIB", "#endif");
-                       CommonDigest.Generate ("Mono.Security.Cryptography", "SHA224Managed", "SHA224", 1000);
-
-                       // mscorlib replacements
-                       CommonCryptor.Generate ("System.Security.Cryptography", "DESCryptoServiceProvider", "DES", "DES");
-                       CommonCryptor.Generate ("System.Security.Cryptography", "TripleDESCryptoServiceProvider", "TripleDES", "TripleDES");
-                       CommonCryptor.Generate ("System.Security.Cryptography", "RC2CryptoServiceProvider", "RC2", "RC2", ctorInitializers: "LegalKeySizesValue = new[] { new KeySizes(40, 128, 8) };");
-                       // Rijndael supports block sizes that are not available in AES - as such it does not use the same generated code
-                       // but has it's own version, using AES (128 bits block size) and falling back to managed (192/256 bits block size)
-
-                       // System.Core replacements
-                       CommonCryptor.Generate ("System.Security.Cryptography", "AesManaged", "Aes", "AES128", "128");
-                       CommonCryptor.Generate ("System.Security.Cryptography", "AesCryptoServiceProvider", "Aes", "AES128");
-
-                       // Mono.Security replacements
-                       // RC4 is a stream (not a block) cipher so it can not reuse the generated code
-               }
-       }
-}
\ No newline at end of file
index 95b3bc8d33703c3e3ba1bee382763bebd35f5267..4d3f433161c2ae157c301168ba5410aa66921350 100644 (file)
@@ -1,7 +1,6 @@
 thisdir = class/corlib
 SUBDIRS =
 include ../../build/rules.make
-include CommonCrypto/Makefile.include
 export __SECURITY_BOOTSTRAP_DB=$(topdir)/class/corlib
 
 LIBRARY = corlib.dll
@@ -71,6 +70,30 @@ endif
 TEST_MCS_FLAGS += -debug -nowarn:168,219,618,672 -unsafe \
                                 -define:MONO_DATACONVERTER_STATIC_METHODS $(TEST_RESX_RESOURCES:%=-resource:%)
 
+
+CC_PROFILE := $(filter monotouch% xammac, $(PROFILE))
+ifdef CC_PROFILE
+
+BUILT_SOURCES = \
+       CommonCrypto/AesCryptoServiceProvider.g.cs \
+       CommonCrypto/MD5CryptoServiceProvider.g.cs      \
+       CommonCrypto/SHA256Managed.g.cs \
+       CommonCrypto/AesManaged.g.cs \
+       CommonCrypto/RC2CryptoServiceProvider.g.cs \
+       CommonCrypto/SHA384Managed.g.cs \
+       CommonCrypto/DESCryptoServiceProvider.g.cs \
+       CommonCrypto/SHA1CryptoServiceProvider.g.cs     \
+       CommonCrypto/SHA512Managed.g.cs \
+       CommonCrypto/MD2Managed.g.cs \
+       CommonCrypto/SHA1Managed.g.cs \
+       CommonCrypto/TripleDESCryptoServiceProvider.g.cs \
+       CommonCrypto/MD4Managed.g.cs
+
+CommonCrypto/%.g.cs:
+       $(MAKE) -C CommonCrypto
+
+endif
+
 EXTRA_DISTFILES = \
        Test/resources/MyResources.resources    \
        Test/resources/MyResources.de.resources \
index f263eeb1cc9c5673811165cf436fbfb7693285ff..3c7e87a6b7ac78ad8fbe13e42343fb67337d0698 100644 (file)
@@ -96,7 +96,7 @@ namespace System.IO
                                 info.Parent.Create ();
 
                        MonoIOError error;
-                       if (!MonoIO.CreateDirectory (path, out error)) {
+                       if (!MonoIO.CreateDirectory (info.FullName, out error)) {
                                // LAMESPEC: 1.1 and 1.2alpha allow CreateDirectory on a file path.
                                // So CreateDirectory ("/tmp/somefile") will succeed if 'somefile' is
                                // not a directory. However, 1.0 will throw an exception.
index 8289c288c20ffe228d3133c28a4c4569bf05b9d1..4f74c12bf8309441d336ed37bed907003651547f 100644 (file)
@@ -62,7 +62,7 @@ namespace System.IO {
 
                        FullPath = Path.GetFullPath (path);
                        if (simpleOriginalPath)
-                               OriginalPath = Path.GetFileName (path);
+                               OriginalPath = Path.GetFileName (FullPath);
                        else
                                OriginalPath = path;
 
index 4d8b2ee34ba918eaaca8660fbcd515c1b552b850..b7ce6e0410a767355c9db8fcf9c9f0387ffd5f50 100644 (file)
@@ -40,120 +40,21 @@ using System.Text;
 
 namespace System.Reflection.Emit
 {
-       internal enum TypeKind : int {
-               SZARRAY = 0x1d,
-               ARRAY = 0x14
-       }
-
        [StructLayout (LayoutKind.Sequential)]
-       internal abstract class DerivedType : Type
+       abstract partial class SymbolType
        {
-               internal Type elementType;
+               internal Type m_baseType;
 
                [MethodImplAttribute(MethodImplOptions.InternalCall)]
-               internal static extern void create_unmanaged_type (Type type);
+               static extern void create_unmanaged_type (Type type);
 
-               internal DerivedType (Type elementType)
+               internal SymbolType (Type elementType)
                {
-                       this.elementType = elementType;
+                       this.m_baseType = elementType;
                }
 
                internal abstract String FormatName (string elementName);
 
-               public override Type GetInterface (string name, bool ignoreCase)
-               {
-                       throw new NotSupportedException ();
-               }
-
-               public override Type[] GetInterfaces ()
-               {
-                       throw new NotSupportedException ();
-               }
-
-               public override Type GetElementType ()
-               {
-                       return elementType;
-               }
-
-               public override EventInfo GetEvent (string name, BindingFlags bindingAttr)
-               {
-                       throw new NotSupportedException ();
-               }
-
-               public override EventInfo[] GetEvents (BindingFlags bindingAttr)
-               {
-                       throw new NotSupportedException ();
-               }
-
-               public override FieldInfo GetField( string name, BindingFlags bindingAttr)
-               {
-                       throw new NotSupportedException ();
-               }
-
-               public override FieldInfo[] GetFields (BindingFlags bindingAttr)
-               {
-                       throw new NotSupportedException ();
-               }
-
-               public override MemberInfo[] GetMembers (BindingFlags bindingAttr)
-               {
-                       throw new NotSupportedException ();
-               }
-
-               protected override MethodInfo GetMethodImpl (string name, BindingFlags bindingAttr, Binder binder,
-                                                            CallingConventions callConvention, Type[] types,
-                                                            ParameterModifier[] modifiers)
-               {
-                       throw new NotSupportedException ();
-               }
-
-               public override MethodInfo[] GetMethods (BindingFlags bindingAttr)
-               {
-                       throw new NotSupportedException ();
-               }
-
-               public override Type GetNestedType (string name, BindingFlags bindingAttr)
-               {
-                       throw new NotSupportedException ();
-               }
-
-               public override Type[] GetNestedTypes (BindingFlags bindingAttr)
-               {
-                       throw new NotSupportedException ();
-               }
-
-               public override PropertyInfo[] GetProperties (BindingFlags bindingAttr)
-               {
-                       throw new NotSupportedException ();
-               }
-
-               protected override PropertyInfo GetPropertyImpl (string name, BindingFlags bindingAttr, Binder binder,
-                                                                Type returnType, Type[] types, ParameterModifier[] modifiers)
-               {
-                       throw new NotSupportedException ();
-               }
-
-               protected override ConstructorInfo GetConstructorImpl (BindingFlags bindingAttr,
-                                                                      Binder binder,
-                                                                      CallingConventions callConvention,
-                                                                      Type[] types,
-                                                                      ParameterModifier[] modifiers)
-               {
-                       throw new NotSupportedException ();
-               }
-
-
-               protected override TypeAttributes GetAttributeFlagsImpl ()
-               {
-                       /*LAMEIMPL MS just return the elementType.Attributes*/
-                       return elementType.Attributes; 
-               }
-
-               protected override bool HasElementTypeImpl ()
-               {
-                       return true;
-               }
-
                protected override bool IsArrayImpl ()
                {
                        return false;
@@ -164,60 +65,11 @@ namespace System.Reflection.Emit
                        return false;
                }
 
-               protected override bool IsCOMObjectImpl ()
-               {
-                       return false;
-               }
-
                protected override bool IsPointerImpl ()
                {
                        return false;
                }
 
-               protected override bool IsPrimitiveImpl ()
-               {
-                       return false;
-               }
-
-
-               public override ConstructorInfo[] GetConstructors (BindingFlags bindingAttr)
-               {
-                       throw new NotSupportedException ();
-               }
-
-               public override object InvokeMember (string name, BindingFlags invokeAttr,
-                                                    Binder binder, object target, object[] args,
-                                                    ParameterModifier[] modifiers,
-                                                    CultureInfo culture, string[] namedParameters)
-               {
-                       throw new NotSupportedException ();
-               }
-
-               public override InterfaceMapping GetInterfaceMap (Type interfaceType)
-               {
-                       throw new NotSupportedException ();
-               }
-
-               public override bool IsInstanceOfType (object o)
-               {
-                       return false;
-               }
-
-               public override bool IsAssignableFrom (Type c)
-               {
-                       return false;
-               }
-
-               public override bool ContainsGenericParameters {
-                       get { return elementType.ContainsGenericParameters; }
-               }
-
-               //FIXME this should be handled by System.Type
-               public override Type MakeGenericType (params Type[] typeArguments)
-               {
-                       throw new NotSupportedException ();
-               }
-
                public override Type MakeArrayType ()
                {
                        return new ArrayType (this, 0);
@@ -242,59 +94,31 @@ namespace System.Reflection.Emit
 
                public override string ToString ()
                {
-                       return FormatName (elementType.ToString ());
-               }
-
-               public override GenericParameterAttributes GenericParameterAttributes {
-                       get { throw new NotSupportedException (); }
-               }
-
-               public override StructLayoutAttribute StructLayoutAttribute {
-                       get { throw new NotSupportedException (); }
-               }
-
-               public override Assembly Assembly {
-                       get { return elementType.Assembly; }
+                       return FormatName (m_baseType.ToString ());
                }
 
                public override string AssemblyQualifiedName {
                        get {
-                               string fullName = FormatName (elementType.FullName);
+                               string fullName = FormatName (m_baseType.FullName);
                                if (fullName == null)
                                        return null;
-                               return fullName + ", " + elementType.Assembly.FullName;
+                               return fullName + ", " + m_baseType.Assembly.FullName;
                        }
                }
 
 
                public override string FullName {
                        get {
-                               return FormatName (elementType.FullName);
+                               return FormatName (m_baseType.FullName);
                        }
                }
 
                public override string Name {
                        get {
-                               return FormatName (elementType.Name);
+                               return FormatName (m_baseType.Name);
                        }
                }
-
-               public override Guid GUID {
-                       get { throw new NotSupportedException (); }
-               }
-
-               public override Module Module {
-                       get { return elementType.Module; }
-               }
        
-               public override string Namespace {
-                       get { return elementType.Namespace; }
-               }
-
-               public override RuntimeTypeHandle TypeHandle {
-                       get { throw new NotSupportedException (); }
-               }
-
                public override Type UnderlyingSystemType {
                        get {
                                create_unmanaged_type (this);
@@ -302,31 +126,15 @@ namespace System.Reflection.Emit
                        }
                }
 
-               //MemberInfo
-               public override bool IsDefined (Type attributeType, bool inherit)
-               {
-                       throw new NotSupportedException ();
-               }
-
-               public override object [] GetCustomAttributes (bool inherit)
-               {
-                       throw new NotSupportedException ();
-               }
-
-               public override object [] GetCustomAttributes (Type attributeType, bool inherit)
-               {
-                       throw new NotSupportedException ();
-               }
-
                internal override bool IsUserType {
                        get {
-                               return elementType.IsUserType;
+                               return m_baseType.IsUserType;
                        }
                }
        }
 
        [StructLayout (LayoutKind.Sequential)]
-       internal class ArrayType : DerivedType
+       internal class ArrayType : SymbolType
        {
                int rank;
 
@@ -342,7 +150,7 @@ namespace System.Reflection.Emit
 
                internal override Type InternalResolve ()
                {
-                       Type et = elementType.InternalResolve (); 
+                       Type et = m_baseType.InternalResolve (); 
                        if (rank == 0)
                                return et.MakeArrayType ();                     
                        return et.MakeArrayType (rank);
@@ -358,15 +166,6 @@ namespace System.Reflection.Emit
                        return (rank == 0) ? 1 : rank;
                }
 
-               public override Type BaseType {
-                       get { return typeof (System.Array); }
-               }
-
-               protected override TypeAttributes GetAttributeFlagsImpl ()
-               {
-                       return elementType.Attributes;
-               }
-
                internal override String FormatName (string elementName)
                {
                        if (elementName == null)
@@ -383,7 +182,7 @@ namespace System.Reflection.Emit
        }
 
        [StructLayout (LayoutKind.Sequential)]
-       internal class ByRefType : DerivedType
+       internal class ByRefType : SymbolType
        {
                internal ByRefType (Type elementType) : base (elementType)
                {
@@ -391,7 +190,7 @@ namespace System.Reflection.Emit
 
                internal override Type InternalResolve ()
                {
-                       return elementType.InternalResolve ().MakeByRefType (); 
+                       return m_baseType.InternalResolve ().MakeByRefType (); 
                }
 
                protected override bool IsByRefImpl ()
@@ -399,10 +198,6 @@ namespace System.Reflection.Emit
                        return true;
                }
 
-               public override Type BaseType {
-                       get { return typeof (Array); }
-               }
-
                internal override String FormatName (string elementName)
                {
                        if (elementName == null)
@@ -432,7 +227,7 @@ namespace System.Reflection.Emit
        }
 
        [StructLayout (LayoutKind.Sequential)]
-       internal class PointerType : DerivedType
+       internal class PointerType : SymbolType
        {
                internal PointerType (Type elementType) : base (elementType)
                {
@@ -440,7 +235,7 @@ namespace System.Reflection.Emit
 
                internal override Type InternalResolve ()
                {
-                       return elementType.InternalResolve ().MakePointerType (); 
+                       return m_baseType.InternalResolve ().MakePointerType (); 
                }
 
                protected override bool IsPointerImpl ()
@@ -448,10 +243,6 @@ namespace System.Reflection.Emit
                        return true;
                }
 
-               public override Type BaseType {
-                       get { return typeof(Array); }
-               }
-
                internal override String FormatName (string elementName)
                {
                        if (elementName == null)
index 7178bedaa547e5ace0afd2186a5cae5d30d5483e..548bc5d93c08ec546441419ce1a0499805b2da5b 100644 (file)
@@ -37,6 +37,11 @@ namespace System.Security.Cryptography.X509Certificates
                        get;
                }
 
+               /*
+                * This is used in System.dll's OSX509Certificates.cs
+                */
+               public abstract IntPtr GetNativeAppleCertificate ();
+
                protected void ThrowIfContextInvalid ()
                {
                        if (!IsValid)
index c1fbac195286e29110b1bbcbfd844d91a4b8be99..718aadc3f374ab1ba539160635b4c594da13b2ab 100644 (file)
@@ -26,6 +26,12 @@ namespace System.Security.Cryptography.X509Certificates
                        get { return handle; }
                }
 
+               public override IntPtr GetNativeAppleCertificate ()
+               {
+                       ThrowIfContextInvalid ();
+                       return handle;
+               }
+
                public override X509CertificateImpl Clone ()
                {
                        ThrowIfContextInvalid ();
index 056bf561ee5a31a719907724b41b6e11cf4ef5ab..fa152e97f919844f8b46992853d506f795542347 100644 (file)
@@ -34,7 +34,7 @@ using MX = Mono.Security.X509;
 
 namespace System.Security.Cryptography.X509Certificates
 {
-       class X509CertificateImplMono : X509CertificateImpl
+       sealed class X509CertificateImplMono : X509CertificateImpl
        {
                MX.X509Certificate x509;
 
@@ -51,6 +51,11 @@ namespace System.Security.Cryptography.X509Certificates
                        get { return IntPtr.Zero; }
                }
 
+               public override IntPtr GetNativeAppleCertificate ()
+               {
+                       return IntPtr.Zero;
+               }
+
                public override X509CertificateImpl Clone ()
                {
                        ThrowIfContextInvalid ();
index 70a4dea80df5d68f1a7de17fc2dfde0121e99606..1c17f0b76c0716362c35daf33e64de290a310b24 100644 (file)
@@ -57,7 +57,7 @@ namespace System {
                 * of icalls, do not require an increment.
                 */
 #pragma warning disable 169
-               private const int mono_corlib_version = 143;
+               private const int mono_corlib_version = 144;
 #pragma warning restore 169
 
                [ComVisible (true)]
index b17cfd62c55c5724bea9f608fbbb058f4382471f..8ef9dcf4680b0a486793b9eb69a4abc518cf75a1 100644 (file)
@@ -230,6 +230,17 @@ public class DirectoryTest
                }\r
        }\r
 \r
+       [Test]\r
+       public void CreateDirectoryRelativePath ()\r
+       {\r
+               var path = Path.Combine (TempFolder, "relativepath", "not_this_folder");\r
+               path = Path.Combine (path, "..");\r
+\r
+               var res = Directory.CreateDirectory (path);\r
+               Assert.AreEqual ("relativepath", res.ToString (), "#1");\r
+               Assert.IsTrue (Directory.Exists (Path.Combine (TempFolder, "relativepath")), "#2");\r
+       }\r
+\r
        [Test]\r
        public void Delete ()\r
        {\r
index fa37466a77ad7083c62be10b91be468b6d5b5bd9..122e5b65fc24e29f25e4fddb245904208ba8a4cf 100644 (file)
@@ -1586,6 +1586,7 @@ namespace MonoTests.System.Reflection.Emit
                        Assert.IsFalse (arr.IsGenericParameter, "#8");
                        Assert.IsFalse (arr.IsGenericType, "#9");
                        Assert.IsFalse (arr.IsGenericTypeDefinition, "#10");
+                       Assert.IsTrue (arr is TypeInfo, "#11");
                }
 
                [Test]
@@ -1664,6 +1665,7 @@ namespace MonoTests.System.Reflection.Emit
                        Assert.AreEqual ("F[]", arr.Name, "#21");
 
                        Assert.AreEqual (gparam, arr.GetElementType (), "#22");
+                       Assert.IsTrue (arr is TypeInfo, "#23");
                }
 
                [Test]
@@ -1718,6 +1720,7 @@ namespace MonoTests.System.Reflection.Emit
                        Assert.AreEqual ("enum[]", arr.Name, "#21");
 
                        Assert.AreEqual (eb, arr.GetElementType (), "#22");
+                       Assert.IsTrue (arr is TypeInfo, "#23");
                }
 
        }
index 2ed3b6003c7a440cbfb529a6dbd78b5002aa1ed2..ce1c9793fc57daeef63df5687cbea2c505ac916d 100644 (file)
@@ -103,7 +103,7 @@ namespace MonoTests.System.Threading {
                [Test] // bug #320950
                public void TestDispose2 ()
                {
-                       Timer t = new Timer (o => Callback (o), null, 10, 10);
+                       Timer t = new Timer (o => DoNothing (o), null, 10, 10);
                        t.Dispose ();
                        t.Dispose ();
                }
index 357ec961ca673f784b64536658ca4dbcba9cb499..c7f01bc6eb20ca1461ada0ce0b8511f5f1a637f4 100644 (file)
@@ -1259,6 +1259,7 @@ ReferenceSources/SecurityContext.cs
 ../../../external/referencesource/mscorlib/system/reflection/typeinfo.cs
 
 ../../../external/referencesource/mscorlib/system/reflection/emit/methodbuilder.cs
+../../../external/referencesource/mscorlib/system/reflection/emit/symboltype.cs
 
 ../../../external/referencesource/mscorlib/system/resources/__fastresourcecomparer.cs
 ../../../external/referencesource/mscorlib/system/resources/__hresults.cs
index e802a034dd64f2aa7f7a9a97dd76b0aaf3ed4294..6acc765c090d0c5e18bf7673c56328dbb30053a8 100644 (file)
@@ -3,21 +3,9 @@ CommonCrypto/CommonCrypto.cs
 CommonCrypto/CryptorTransform.cs
 CommonCrypto/FastCryptorTransform.cs
 CommonCrypto/CorlibExtras.cs
-CommonCrypto/MD5CryptoServiceProvider.g.cs
-CommonCrypto/SHA1CryptoServiceProvider.g.cs
-CommonCrypto/SHA1CryptoServiceProvider.g.cs
-CommonCrypto/SHA1Managed.g.cs
-CommonCrypto/SHA256Managed.g.cs
-CommonCrypto/SHA384Managed.g.cs
-CommonCrypto/SHA512Managed.g.cs
-CommonCrypto/TripleDESCryptoServiceProvider.g.cs
-CommonCrypto/DESCryptoServiceProvider.g.cs
-CommonCrypto/RC2CryptoServiceProvider.g.cs
 CommonCrypto/RijndaelManaged.cs
 CommonCrypto/SecRandom.cs
 CommonCrypto/RC4CommonCrypto.cs
-CommonCrypto/MD2Managed.g.cs
-CommonCrypto/MD4Managed.g.cs
 System/Environment.iOS.cs
 System/Guid.MonoTouch.cs
 System/NotSupportedException.iOS.cs
index e802a034dd64f2aa7f7a9a97dd76b0aaf3ed4294..6acc765c090d0c5e18bf7673c56328dbb30053a8 100644 (file)
@@ -3,21 +3,9 @@ CommonCrypto/CommonCrypto.cs
 CommonCrypto/CryptorTransform.cs
 CommonCrypto/FastCryptorTransform.cs
 CommonCrypto/CorlibExtras.cs
-CommonCrypto/MD5CryptoServiceProvider.g.cs
-CommonCrypto/SHA1CryptoServiceProvider.g.cs
-CommonCrypto/SHA1CryptoServiceProvider.g.cs
-CommonCrypto/SHA1Managed.g.cs
-CommonCrypto/SHA256Managed.g.cs
-CommonCrypto/SHA384Managed.g.cs
-CommonCrypto/SHA512Managed.g.cs
-CommonCrypto/TripleDESCryptoServiceProvider.g.cs
-CommonCrypto/DESCryptoServiceProvider.g.cs
-CommonCrypto/RC2CryptoServiceProvider.g.cs
 CommonCrypto/RijndaelManaged.cs
 CommonCrypto/SecRandom.cs
 CommonCrypto/RC4CommonCrypto.cs
-CommonCrypto/MD2Managed.g.cs
-CommonCrypto/MD4Managed.g.cs
 System/Environment.iOS.cs
 System/Guid.MonoTouch.cs
 System/NotSupportedException.iOS.cs
index e802a034dd64f2aa7f7a9a97dd76b0aaf3ed4294..6acc765c090d0c5e18bf7673c56328dbb30053a8 100644 (file)
@@ -3,21 +3,9 @@ CommonCrypto/CommonCrypto.cs
 CommonCrypto/CryptorTransform.cs
 CommonCrypto/FastCryptorTransform.cs
 CommonCrypto/CorlibExtras.cs
-CommonCrypto/MD5CryptoServiceProvider.g.cs
-CommonCrypto/SHA1CryptoServiceProvider.g.cs
-CommonCrypto/SHA1CryptoServiceProvider.g.cs
-CommonCrypto/SHA1Managed.g.cs
-CommonCrypto/SHA256Managed.g.cs
-CommonCrypto/SHA384Managed.g.cs
-CommonCrypto/SHA512Managed.g.cs
-CommonCrypto/TripleDESCryptoServiceProvider.g.cs
-CommonCrypto/DESCryptoServiceProvider.g.cs
-CommonCrypto/RC2CryptoServiceProvider.g.cs
 CommonCrypto/RijndaelManaged.cs
 CommonCrypto/SecRandom.cs
 CommonCrypto/RC4CommonCrypto.cs
-CommonCrypto/MD2Managed.g.cs
-CommonCrypto/MD4Managed.g.cs
 System/Environment.iOS.cs
 System/Guid.MonoTouch.cs
 System/NotSupportedException.iOS.cs
index 0dbb5163c7042ef38fd2f08e6f1fc01a3611dd6f..f321e0bc800fc1f1ecca58a541972df1fe8b7d29 100644 (file)
@@ -3,20 +3,8 @@ CommonCrypto/CommonCrypto.cs
 CommonCrypto/CryptorTransform.cs
 CommonCrypto/FastCryptorTransform.cs
 CommonCrypto/CorlibExtras.cs
-CommonCrypto/MD5CryptoServiceProvider.g.cs
-CommonCrypto/SHA1CryptoServiceProvider.g.cs
-CommonCrypto/SHA1CryptoServiceProvider.g.cs
-CommonCrypto/SHA1Managed.g.cs
-CommonCrypto/SHA256Managed.g.cs
-CommonCrypto/SHA384Managed.g.cs
-CommonCrypto/SHA512Managed.g.cs
-CommonCrypto/TripleDESCryptoServiceProvider.g.cs
-CommonCrypto/DESCryptoServiceProvider.g.cs
-CommonCrypto/RC2CryptoServiceProvider.g.cs
 CommonCrypto/RijndaelManaged.cs
 CommonCrypto/RC4CommonCrypto.cs
-CommonCrypto/MD2Managed.g.cs
-CommonCrypto/MD4Managed.g.cs
 CoreFoundation/CFHelpers.cs
 System.Security.Cryptography.X509Certificates/X509CertificateImplApple.cs
 System.Security.Cryptography.X509Certificates/X509Helper.Apple.cs
index d95558b30831328d0943d51f4ca56f88f894aad7..693318cbea7e07fdb27df8413379a15d159e7ac0 100644 (file)
@@ -49,7 +49,7 @@ net_4_5_dirs := \
        mono-symbolicate        \
        linker-analyzer
 
-build_SUBDIRS = gacutil security culevel cil-stringreplacer
+build_SUBDIRS = gacutil security culevel cil-stringreplacer commoncryptogenerator
 net_4_5_SUBDIRS = gacutil
 net_4_5_PARALLEL_SUBDIRS = $(net_4_5_dirs)
 
diff --git a/mcs/tools/commoncryptogenerator/CommonCryptorGenerator.cs b/mcs/tools/commoncryptogenerator/CommonCryptorGenerator.cs
new file mode 100644 (file)
index 0000000..f177c17
--- /dev/null
@@ -0,0 +1,104 @@
+//
+// CommonCrypto code generator for symmetric block cipher algorithms
+//
+// Authors:
+//     Sebastien Pouliot  <sebastien@xamarin.com>
+//
+// Copyright 2012 Xamarin Inc.
+//
+
+using System;
+using System.IO;
+
+namespace Xamarin {
+
+       public static class CommonCryptor {
+               
+               static public void Generate (string namespaceName, string typeName, string baseTypeName, string ccAlgorithmName, string feedbackSize = "8", string ctorInitializers = null)
+               {
+                       string template = @"// Generated file to bind CommonCrypto cipher algorithms - DO NOT EDIT
+//
+// Authors:
+//     Sebastien Pouliot  <sebastien@xamarin.com>
+//
+// Copyright 2012-2014 Xamarin Inc.
+
+using System;
+using System.Security.Cryptography;
+
+using Mono.Security.Cryptography;
+using Crimson.CommonCrypto;
+
+namespace %NAMESPACE% {
+
+       public sealed partial class %TYPE% : %BASE% {
+               
+               public %TYPE% ()
+               {
+                       FeedbackSizeValue = %FEEDBACKSIZE%;
+                       %CTOR_INIT%
+               }
+               
+               public override void GenerateIV ()
+               {
+                       IVValue = KeyBuilder.IV (BlockSizeValue >> 3);
+               }
+               
+               public override void GenerateKey ()
+               {
+                       KeyValue = KeyBuilder.Key (KeySizeValue >> 3);
+               }
+               
+               public override ICryptoTransform CreateDecryptor (byte[] rgbKey, byte[] rgbIV) 
+               {
+                       IntPtr decryptor = IntPtr.Zero;
+                       switch (Mode) {
+                       case CipherMode.CBC:
+                               decryptor = Cryptor.Create (CCOperation.Decrypt, CCAlgorithm.%CCALGORITHM%, CCOptions.None, rgbKey, rgbIV);
+                               return new FastCryptorTransform (decryptor, this, false, rgbIV);
+                       case CipherMode.ECB:
+                               decryptor = Cryptor.Create (CCOperation.Decrypt, CCAlgorithm.%CCALGORITHM%, CCOptions.ECBMode, rgbKey, rgbIV);
+                               return new FastCryptorTransform (decryptor, this, false, rgbIV);
+                       case CipherMode.CFB:
+#if MONOTOUCH || XAMMAC
+                               IntPtr encryptor = Cryptor.Create (CCOperation.Encrypt, CCAlgorithm.%CCALGORITHM%, CCOptions.ECBMode, rgbKey, rgbIV);
+                               decryptor = Cryptor.Create (CCOperation.Decrypt, CCAlgorithm.%CCALGORITHM%, CCOptions.ECBMode, rgbKey, rgbIV);
+                               return new CryptorTransform (decryptor, encryptor, this, false, rgbIV);
+#else
+                               throw new CryptographicException (""CFB is not supported by Crimson.CommonCrypto"");
+#endif
+                       default:
+                               throw new CryptographicException (String.Format (""{0} is not supported by the .NET framework"", Mode));
+                       }
+               }
+               
+               public override ICryptoTransform CreateEncryptor (byte[] rgbKey, byte[] rgbIV) 
+               {
+                       IntPtr encryptor = IntPtr.Zero;
+                       switch (Mode) {
+                       case CipherMode.CBC:
+                               encryptor = Cryptor.Create (CCOperation.Encrypt, CCAlgorithm.%CCALGORITHM%, CCOptions.None, rgbKey, rgbIV);
+                               return new FastCryptorTransform (encryptor, this, true, rgbIV);
+                       case CipherMode.ECB:
+                               encryptor = Cryptor.Create (CCOperation.Encrypt, CCAlgorithm.%CCALGORITHM%, CCOptions.ECBMode, rgbKey, rgbIV);
+                               return new FastCryptorTransform (encryptor, this, true, rgbIV);
+                       case CipherMode.CFB:
+#if MONOTOUCH || XAMMAC
+                               encryptor = Cryptor.Create (CCOperation.Encrypt, CCAlgorithm.%CCALGORITHM%, CCOptions.ECBMode, rgbKey, rgbIV);
+                               return new CryptorTransform (encryptor, IntPtr.Zero, this, true, rgbIV);
+#else
+                               throw new CryptographicException (""CFB is not supported by Crimson.CommonCrypto"");
+#endif
+                       default:
+                               throw new CryptographicException (String.Format (""{0} is not supported by the .NET framework"", Mode));
+                       }
+               }
+       }
+}";
+                       
+                       File.WriteAllText (typeName + ".g.cs", template.Replace ("%NAMESPACE%", namespaceName).
+                               Replace ("%TYPE%", typeName).Replace ("%BASE%", baseTypeName).Replace("%FEEDBACKSIZE%", feedbackSize).Replace ("%CTOR_INIT%", ctorInitializers).
+                               Replace ("%CCALGORITHM%", ccAlgorithmName.ToString ()));
+               }
+       }
+}
diff --git a/mcs/tools/commoncryptogenerator/CommonDigestGenerator.cs b/mcs/tools/commoncryptogenerator/CommonDigestGenerator.cs
new file mode 100644 (file)
index 0000000..1b729e3
--- /dev/null
@@ -0,0 +1,167 @@
+//
+// CommonCrypto code generator for digest algorithms
+//
+// Authors:
+//     Sebastien Pouliot  <sebastien@xamarin.com>
+//
+// Copyright 2012-2014 Xamarin Inc.
+//
+
+using System;
+using System.IO;
+
+namespace Xamarin {
+
+       public static class CommonDigest {
+               
+#if !MONOTOUCH && !XAMMAC
+               // we do not add anything in MonoTouch, just replacing, so this is not needed
+               // however we can avoid a dependency on Mono.Security for Crimson.CommonCrypto.dll by including the base classes
+               static public void GenerateBaseClass (string namespaceName, string typeName, string baseTypeName, int hashSize,
+                       string visibilityStart = "", string visibilityEnd = "")
+               {
+                       string template = @"// Generated file to bind CommonCrypto/CommonDigest - DO NOT EDIT
+//
+// Authors:
+//     Sebastien Pouliot  <sebastien@xamarin.com>
+//
+// Copyright 2012-2014 Xamarin Inc.
+
+using System;
+using System.Security.Cryptography;
+using System.Runtime.InteropServices;
+
+namespace %NAMESPACE% {
+
+%VISIBILITY_START%
+       public
+%VISIBILITY_END%
+       abstract class %BASE% : HashAlgorithm {
+
+               protected %BASE% () 
+               {
+                       HashSizeValue = %HASHSIZE%; 
+               }
+
+               public static new %BASE% Create ()
+               {
+                       return Create (""%BASE%"");
+               }
+
+               public static new %BASE% Create (string hashName)
+               {
+                       object o = CryptoConfig.CreateFromName (hashName);
+                       return (%BASE%) o ?? new %TYPE% ();
+               }
+       }
+}";
+                       
+                       File.WriteAllText (baseTypeName + ".g.cs", template.Replace ("%NAMESPACE%", namespaceName).
+                               Replace ("%TYPE%", typeName).Replace ("%BASE%", baseTypeName).
+                               Replace ("%VISIBILITY_START%", visibilityStart).Replace ("%VISIBILITY_END%", visibilityEnd).
+                               Replace ("%HASHSIZE%", hashSize.ToString ()));
+               }
+#endif
+               static public void Generate (string namespaceName, string typeName, string baseTypeName, int contextSize,
+                       string visibilityStart = "", string visibilityEnd = "")
+               {
+                       string template = @"// Generated file to bind CommonCrypto/CommonDigest - DO NOT EDIT
+//
+// Authors:
+//     Sebastien Pouliot  <sebastien@xamarin.com>
+//
+// Copyright 2011-2014 Xamarin Inc.
+
+using System;
+using System.Security.Cryptography;
+using System.Runtime.InteropServices;
+
+using Mono.Security.Cryptography;
+
+namespace %NAMESPACE% {
+
+%VISIBILITY_START%
+       public
+%VISIBILITY_END%
+       sealed class %TYPE% : %BASE% {
+
+               IntPtr ctx;
+
+               [DllImport (""/usr/lib/libSystem.dylib"", EntryPoint=""CC_%BASE%_Init"")]
+               static extern int Init (/* CC_%BASE%_CTX */ IntPtr c);
+
+               [DllImport (""/usr/lib/libSystem.dylib"", EntryPoint=""CC_%BASE%_Update"")]
+               static extern int Update (/* CC_%BASE%_CTX */ IntPtr c, /* const void * */ IntPtr data, /* uint32_t */ uint len);
+
+               [DllImport (""/usr/lib/libSystem.dylib"", EntryPoint=""CC_%BASE%_Final"")]
+               static extern int Final (/* unsigned char * */ byte [] md, /* CC_%BASE%_CTX */ IntPtr c);
+
+               public %TYPE% ()
+               {
+                       ctx = IntPtr.Zero;
+               }
+
+               ~%TYPE% ()
+               {
+                       Dispose (false);
+               }
+
+               protected override void Dispose (bool disposing)
+               {
+                       if (ctx != IntPtr.Zero) {
+                               Marshal.FreeHGlobal (ctx);
+                               ctx = IntPtr.Zero;
+                       }
+                       base.Dispose (disposing);
+                       GC.SuppressFinalize (this);
+               }
+
+               public override void Initialize ()
+               {
+                       if (ctx == IntPtr.Zero)
+                               ctx = Marshal.AllocHGlobal (%CTX_SIZE%);
+                       
+                       int hr = Init (ctx);
+                       if (hr != 1)
+                               throw new CryptographicException (hr);
+               }
+
+               protected override void HashCore (byte[] data, int start, int length) 
+               {
+                       if (ctx == IntPtr.Zero)
+                               Initialize ();
+
+                       if (data.Length == 0)
+                               return;
+
+                       unsafe {
+                               fixed (byte* p = &data [0]) {
+                                       int hr = Update (ctx, (IntPtr) (p + start), (uint) length);
+                                       if (hr != 1)
+                                               throw new CryptographicException (hr);
+                               }
+                       }
+               }
+
+               protected override byte[] HashFinal () 
+               {
+                       if (ctx == IntPtr.Zero)
+                               Initialize ();
+                       
+                       byte[] data = new byte [HashSize >> 3];
+                       int hr = Final (data, ctx);
+                       if (hr != 1)
+                               throw new CryptographicException (hr);
+
+                       return data;
+               }
+       }
+}";
+                       
+                       File.WriteAllText (typeName + ".g.cs", template.Replace ("%NAMESPACE%", namespaceName).
+                               Replace ("%TYPE%", typeName).Replace ("%BASE%", baseTypeName).
+                               Replace ("%VISIBILITY_START%", visibilityStart).Replace ("%VISIBILITY_END%", visibilityEnd).
+                               Replace ("%CTX_SIZE%", contextSize.ToString ()));
+               }
+       }
+}
diff --git a/mcs/tools/commoncryptogenerator/Makefile b/mcs/tools/commoncryptogenerator/Makefile
new file mode 100644 (file)
index 0000000..64c52e4
--- /dev/null
@@ -0,0 +1,11 @@
+thisdir = tools/commoncryptogenerator
+SUBDIRS =
+include ../../build/rules.make
+
+LIB_REFS = 
+LOCAL_MCS_FLAGS =
+
+PROGRAM = commoncryptogenerator.exe
+NO_INSTALL = yes
+
+include ../../build/executable.make
diff --git a/mcs/tools/commoncryptogenerator/commoncryptogenerator.exe.sources b/mcs/tools/commoncryptogenerator/commoncryptogenerator.exe.sources
new file mode 100644 (file)
index 0000000..e2ecba4
--- /dev/null
@@ -0,0 +1,3 @@
+CommonCryptorGenerator.cs
+generator.cs
+CommonDigestGenerator.cs
diff --git a/mcs/tools/commoncryptogenerator/generator.cs b/mcs/tools/commoncryptogenerator/generator.cs
new file mode 100644 (file)
index 0000000..a7d13c8
--- /dev/null
@@ -0,0 +1,57 @@
+//
+// CommonCrypto Code Generator
+//
+// Authors:
+//     Sebastien Pouliot  <sebastien@xamarin.com>
+//
+// Copyright 2012 Xamarin Inc.
+//
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Text;
+
+namespace Xamarin {
+       
+       class Program {
+               static void Main (string [] args)
+               {
+                       // mscorlib replacements
+                       CommonDigest.Generate ("System.Security.Cryptography", "MD5CryptoServiceProvider", "MD5", 1000);
+                       CommonDigest.Generate ("System.Security.Cryptography", "SHA1CryptoServiceProvider", "SHA1", 1000);
+                       CommonDigest.Generate ("System.Security.Cryptography", "SHA1Managed", "SHA1", 1000);
+                       CommonDigest.Generate ("System.Security.Cryptography", "SHA256Managed", "SHA256", 1000);
+                       CommonDigest.Generate ("System.Security.Cryptography", "SHA384Managed", "SHA384", 1000);
+                       CommonDigest.Generate ("System.Security.Cryptography", "SHA512Managed", "SHA512", 1000);
+                       
+                       // System.Core replacements - not yet in MT profile (4.0 - functional dupes anyway)
+                       //CommonDigest.Generate ("System.Security.Cryptography", "MD5Cng", "MD5", 1000);
+                       //CommonDigest.Generate ("System.Security.Cryptography", "SHA256Cng", "SHA256", 1000);
+                       //CommonDigest.Generate ("System.Security.Cryptography", "SHA384Cng", "SHA384", 1000);
+                       //CommonDigest.Generate ("System.Security.Cryptography", "SHA512Cng", "SHA512", 1000);
+                       //CommonDigest.Generate ("System.Security.Cryptography", "SHA256CryptoServiceProvider", "SHA256", 1000);
+                       //CommonDigest.Generate ("System.Security.Cryptography", "SHA384CryptoServiceProvider", "SHA384", 1000);
+                       //CommonDigest.Generate ("System.Security.Cryptography", "SHA512CryptoServiceProvider", "SHA512", 1000);
+                       
+                       // Mono.Security replacements
+                       CommonDigest.Generate ("Mono.Security.Cryptography", "MD2Managed", "MD2", 1000, "#if !INSIDE_CORLIB", "#endif");
+                       CommonDigest.Generate ("Mono.Security.Cryptography", "MD4Managed", "MD4", 1000, "#if !INSIDE_CORLIB", "#endif");
+                       CommonDigest.Generate ("Mono.Security.Cryptography", "SHA224Managed", "SHA224", 1000);
+
+                       // mscorlib replacements
+                       CommonCryptor.Generate ("System.Security.Cryptography", "DESCryptoServiceProvider", "DES", "DES");
+                       CommonCryptor.Generate ("System.Security.Cryptography", "TripleDESCryptoServiceProvider", "TripleDES", "TripleDES");
+                       CommonCryptor.Generate ("System.Security.Cryptography", "RC2CryptoServiceProvider", "RC2", "RC2", ctorInitializers: "LegalKeySizesValue = new[] { new KeySizes(40, 128, 8) };");
+                       // Rijndael supports block sizes that are not available in AES - as such it does not use the same generated code
+                       // but has it's own version, using AES (128 bits block size) and falling back to managed (192/256 bits block size)
+
+                       // System.Core replacements
+                       CommonCryptor.Generate ("System.Security.Cryptography", "AesManaged", "Aes", "AES128", "128");
+                       CommonCryptor.Generate ("System.Security.Cryptography", "AesCryptoServiceProvider", "Aes", "AES128");
+
+                       // Mono.Security replacements
+                       // RC4 is a stream (not a block) cipher so it can not reuse the generated code
+               }
+       }
+}
\ No newline at end of file
index 71bfc07952fd368df01fbf19665f8e22a7fa0121..bdc03728a98a095fd2183fec8aa251364d681839 100644 (file)
@@ -81,7 +81,7 @@
  * Changes which are already detected at runtime, like the addition
  * of icalls, do not require an increment.
  */
-#define MONO_CORLIB_VERSION 143
+#define MONO_CORLIB_VERSION 144
 
 typedef struct
 {
index 08450558d9d27e9998da65efb7ea26943303570f..3ebe507d0d185472c7aada8bed2713c8b11847df 100644 (file)
@@ -622,6 +622,7 @@ mono_cominterop_cleanup (void)
 void
 mono_mb_emit_cominterop_call (MonoMethodBuilder *mb, MonoMethodSignature *sig, MonoMethod* method)
 {
+#ifndef DISABLE_JIT
        // get function pointer from 1st arg, the COM interface pointer
        mono_mb_emit_ldarg (mb, 0);
        mono_mb_emit_icon (mb, cominterop_get_com_slot_for_method (method));
@@ -632,11 +633,13 @@ mono_mb_emit_cominterop_call (MonoMethodBuilder *mb, MonoMethodSignature *sig, M
        mono_mb_emit_calli (mb, sig);
        mono_mb_emit_byte (mb, MONO_CUSTOM_PREFIX);
        mono_mb_emit_byte (mb, CEE_MONO_RESTORE_LMF);
+#endif /* DISABLE_JIT */
 }
 
 void
 mono_cominterop_emit_ptr_to_object_conv (MonoMethodBuilder *mb, MonoType *type, MonoMarshalConv conv, MonoMarshalSpec *mspec)
 {
+#ifndef DISABLE_JIT
        switch (conv) {
        case MONO_MARSHAL_CONV_OBJECT_INTERFACE:
        case MONO_MARSHAL_CONV_OBJECT_IUNKNOWN:
@@ -708,11 +711,13 @@ mono_cominterop_emit_ptr_to_object_conv (MonoMethodBuilder *mb, MonoType *type,
        default:
                g_assert_not_reached ();
        }
+#endif /* DISABLE_JIT */
 }
 
 void
 mono_cominterop_emit_object_to_ptr_conv (MonoMethodBuilder *mb, MonoType *type, MonoMarshalConv conv, MonoMarshalSpec *mspec)
 {
+#ifndef DISABLE_JIT
        switch (conv) {
        case MONO_MARSHAL_CONV_OBJECT_INTERFACE:
        case MONO_MARSHAL_CONV_OBJECT_IDISPATCH:
@@ -800,6 +805,7 @@ mono_cominterop_emit_object_to_ptr_conv (MonoMethodBuilder *mb, MonoType *type,
        default:
                g_assert_not_reached ();
        }
+#endif /* DISABLE_JIT */
 }
 
 /**
@@ -936,6 +942,7 @@ mono_cominterop_get_native_wrapper (MonoMethod *method)
        sig = mono_method_signature (method);
        mb = mono_mb_new (method->klass, method->name, MONO_WRAPPER_COMINTEROP);
 
+#ifndef DISABLE_JIT
        /* if method klass is import, that means method
         * is really a com call. let interop system emit it.
        */
@@ -1009,6 +1016,8 @@ mono_cominterop_get_native_wrapper (MonoMethod *method)
                        imported classes is not yet implemented.");
                mono_mb_emit_exception (mb, "NotSupportedException", msg);
        }
+#endif /* DISABLE_JIT */
+
        csig = mono_metadata_signature_dup_full (method->klass->image, sig);
        csig->pinvoke = 0;
        res = mono_mb_create_and_cache (cache, method,
@@ -1048,6 +1057,7 @@ mono_cominterop_get_invoke (MonoMethod *method)
 
        mb = mono_mb_new (method->klass, method->name, MONO_WRAPPER_COMINTEROP_INVOKE);
 
+#ifndef DISABLE_JIT
        /* get real proxy object, which is a ComInteropProxy in this case*/
        mono_mb_add_local (mb, &mono_defaults.object_class->byval_arg);
        mono_mb_emit_ldarg (mb, 0);
@@ -1088,6 +1098,7 @@ mono_cominterop_get_invoke (MonoMethod *method)
        mono_marshal_emit_thread_interrupt_checkpoint (mb);
 
        mono_mb_emit_byte (mb, CEE_RET);
+#endif /* DISABLE_JIT */
 
        res = mono_mb_create_and_cache (cache, method, mb, sig, sig->param_count + 16);
        mono_mb_free (mb);
@@ -1142,6 +1153,18 @@ mono_cominterop_emit_marshal_com_interface (EmitMarshalContext *m, int argnum,
        if (!marshal_release)
                marshal_release = mono_class_get_method_from_name (mono_defaults.marshal_class, "Release", 1);
 
+#ifdef DISABLE_JIT
+       switch (action) {
+       case MARSHAL_ACTION_CONV_IN:
+               *conv_arg_type = &mono_defaults.int_class->byval_arg;
+               break;
+       case MARSHAL_ACTION_MANAGED_CONV_IN:
+               *conv_arg_type = &mono_defaults.int_class->byval_arg;
+               break;
+       default:
+               break;
+       }
+#else
        switch (action) {
        case MARSHAL_ACTION_CONV_IN: {
                guint32 pos_null = 0;
@@ -1428,6 +1451,7 @@ mono_cominterop_emit_marshal_com_interface (EmitMarshalContext *m, int argnum,
        default:
                g_assert_not_reached ();
        }
+#endif /* DISABLE_JIT */
 
        return conv_arg;
 }
@@ -2077,8 +2101,10 @@ cominterop_get_ccw_checked (MonoObject* object, MonoClass* itf, MonoError *error
                                mspecs [0] = NULL;
                        }
 
+#ifndef DISABLE_JIT
                        /* skip visiblity since we call internal methods */
                        mb->skip_visibility = TRUE;
+#endif
 
                        cominterop_setup_marshal_context (&m, adjust_method);
                        m.mb = mb;
@@ -2089,7 +2115,6 @@ cominterop_get_ccw_checked (MonoObject* object, MonoClass* itf, MonoError *error
 
                        vtable [vtable_index--] = mono_compile_method (wrapper_method);
 
-                       
                        for (param_index = sig_adjusted->param_count; param_index >= 0; param_index--)
                                if (mspecs [param_index])
                                        mono_metadata_free_marshal_spec (mspecs [param_index]);
@@ -2249,9 +2274,9 @@ cominterop_get_managed_wrapper_adjusted (MonoMethod *method)
 
        mspecs [0] = NULL;
 
-       if (!preserve_sig) {
+#ifndef DISABLE_JIT
+       if (!preserve_sig)
                hr = mono_mb_add_local (mb, &mono_defaults.int32_class->byval_arg);
-       }
        else if (!MONO_TYPE_IS_VOID (sig->ret))
                hr = mono_mb_add_local (mb, sig->ret);
 
@@ -2315,6 +2340,7 @@ cominterop_get_managed_wrapper_adjusted (MonoMethod *method)
                mono_mb_emit_ldloc (mb, hr);
 
        mono_mb_emit_byte (mb, CEE_RET);
+#endif /* DISABLE_JIT */
 
        mono_cominterop_lock ();
        res = mono_mb_create_method (mb, sig_native, sig_native->param_count + 16);     
@@ -2806,10 +2832,9 @@ mono_cominterop_emit_marshal_safearray (EmitMarshalContext *m, int argnum, MonoT
 {
        MonoMethodBuilder *mb = m->mb;
 
+#ifndef DISABLE_JIT
        switch (action) {
-
        case MARSHAL_ACTION_CONV_IN: {
-
                if (t->attrs & PARAM_ATTRIBUTE_IN) {
 
                        /* Generates IL code for the following algorithm:
@@ -2923,7 +2948,6 @@ mono_cominterop_emit_marshal_safearray (EmitMarshalContext *m, int argnum, MonoT
                break;
 
        case MARSHAL_ACTION_CONV_OUT: {
-
                if (t->attrs & PARAM_ATTRIBUTE_OUT) {
                        /* Generates IL code for the following algorithm:
 
@@ -3041,6 +3065,7 @@ mono_cominterop_emit_marshal_safearray (EmitMarshalContext *m, int argnum, MonoT
        default:
                g_assert_not_reached ();
        }
+#endif /* DISABLE_JIT */
 
        return conv_arg;
 }
index 6a5dc193331b7e1ee3c8a3fe641a474f6b76e52d..44a1320f4d11176b36a263ae427d1846aa044305 100644 (file)
@@ -502,9 +502,6 @@ ICALL(ASSEMB_2, "basic_init", mono_image_basic_init)
 #ifndef DISABLE_REFLECTION_EMIT
 ICALL_TYPE(CATTRB, "System.Reflection.Emit.CustomAttributeBuilder", CATTRB_1)
 ICALL(CATTRB_1, "GetBlob", ves_icall_System_Reflection_Emit_CustomAttributeBuilder_GetBlob)
-
-ICALL_TYPE(DERIVEDTYPE, "System.Reflection.Emit.DerivedType", DERIVEDTYPE_1)
-ICALL(DERIVEDTYPE_1, "create_unmanaged_type", mono_reflection_create_unmanaged_type)
 #endif
 
 ICALL_TYPE(DYNM, "System.Reflection.Emit.DynamicMethod", DYNM_1)
@@ -535,6 +532,11 @@ ICALL_TYPE(SIGH, "System.Reflection.Emit.SignatureHelper", SIGH_1)
 ICALL(SIGH_1, "get_signature_field", mono_reflection_sighelper_get_signature_field)
 ICALL(SIGH_2, "get_signature_local", mono_reflection_sighelper_get_signature_local)
 
+#ifndef DISABLE_REFLECTION_EMIT
+ICALL_TYPE(SYMBOLTYPE, "System.Reflection.Emit.SymbolType", SYMBOLTYPE_1)
+ICALL(SYMBOLTYPE_1, "create_unmanaged_type", mono_reflection_create_unmanaged_type)
+#endif
+
 ICALL_TYPE(TYPEB, "System.Reflection.Emit.TypeBuilder", TYPEB_1)
 ICALL(TYPEB_1, "create_generic_class", ves_icall_System_Reflection_Emit_TypeBuilder_create_generic_class)
 ICALL(TYPEB_2, "create_internal_class", mono_reflection_create_internal_class)
index a847b0f58624a0587765b4bd6e526bda2787d1d6..3d4e8146decc3263d8a87bbba9a445e391fcfb57 100644 (file)
@@ -7163,10 +7163,12 @@ emit_marshal (EmitMarshalContext *m, int argnum, MonoType *t,
                return emit_marshal_string (m, argnum, t, spec, conv_arg, conv_arg_type, action);
        case MONO_TYPE_CLASS:
        case MONO_TYPE_OBJECT:
-#ifndef DISABLE_COM
+#if !defined(DISABLE_COM) && !defined(DISABLE_JIT)
                if (spec && spec->native == MONO_NATIVE_STRUCT)
                        return emit_marshal_variant (m, argnum, t, spec, conv_arg, conv_arg_type, action);
+#endif
 
+#if !defined(DISABLE_COM)
                if (spec && (spec->native == MONO_NATIVE_IUNKNOWN ||
                        spec->native == MONO_NATIVE_IDISPATCH ||
                        spec->native == MONO_NATIVE_INTERFACE))
index 54630c6ee033853a8ac63065b70eb7cfa1f3a100..e9f9b1a81a7a5ddeaad89a7ae0ddac596f328fcc 100644 (file)
@@ -689,6 +689,11 @@ sgen_client_binary_protocol_evacuating_blocks (size_t block_size)
 {
 }
 
+static void G_GNUC_UNUSED
+sgen_client_binary_protocol_concurrent_sweep_end (long long timestamp)
+{
+}
+
 int sgen_thread_handshake (BOOL suspend);
 gboolean sgen_suspend_thread (SgenThreadInfo *info);
 gboolean sgen_resume_thread (SgenThreadInfo *info);
index 10a5bdfd5b40a943f3a0b627cd4cb91265ff7121..9546009e724697247abc5e7e3e11ff1f67c8e685 100644 (file)
@@ -933,6 +933,8 @@ mono_decompose_long_opts (MonoCompile *cfg)
                                MONO_EMIT_NEW_BIALU_IMM (cfg, OP_XOR_IMM, MONO_LVREG_LS (tree->dreg), MONO_LVREG_LS (tree->sreg1), tree->inst_ls_word);
                                MONO_EMIT_NEW_BIALU_IMM (cfg, OP_XOR_IMM, MONO_LVREG_MS (tree->dreg), MONO_LVREG_MS (tree->sreg1), tree->inst_ms_word);
                                break;
+#ifdef TARGET_POWERPC
+/* FIXME This is normally handled in cprop. Proper fix or remove if no longer needed. */
                        case OP_LSHR_UN_IMM:
                                if (tree->inst_c1 == 32) {
 
@@ -941,20 +943,12 @@ mono_decompose_long_opts (MonoCompile *cfg)
                                         * later apply the speedup to the left shift as well
                                         * See BUG# 57957.
                                         */
-                                       /* FIXME: Move this to the strength reduction pass */
                                        /* just move the upper half to the lower and zero the high word */
                                        MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, MONO_LVREG_LS (tree->dreg), MONO_LVREG_MS (tree->sreg1));
                                        MONO_EMIT_NEW_ICONST (cfg, MONO_LVREG_MS (tree->dreg), 0);
                                }
                                break;
-                       case OP_LSHL_IMM:
-                               if (tree->inst_c1 == 32) {
-                                       /* just move the lower half to the upper and zero the lower word */
-                                       MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, MONO_LVREG_MS (tree->dreg), MONO_LVREG_LS (tree->sreg1));
-                                       MONO_EMIT_NEW_ICONST (cfg, MONO_LVREG_LS (tree->dreg), 0);
-                               }
-                               break;
-
+#endif
                        case OP_LCOMPARE: {
                                MonoInst *next = mono_inst_next (tree, FILTER_IL_SEQ_POINT);
 
index e39a941023491c1b34581a32ef7f7e3db9789cd6..dd5800be728affba67579b0669a00558cdf9e00f 100644 (file)
@@ -1637,19 +1637,6 @@ mono_main (int argc, char* argv[])
                        gc_descr = mono_gc_get_description ();
                        g_print ("\tGC:            %s\n", gc_descr);
                        g_free (gc_descr);
-                       if (mini_verbose) {
-                               const char *cerror;
-                               const char *clibpath;
-                               mono_init ("mono");
-                               cerror = mono_check_corlib_version ();
-                               clibpath = mono_defaults.corlib? mono_image_get_filename (mono_defaults.corlib): "unknown";
-                               if (cerror) {
-                                       g_print ("The currently installed mscorlib doesn't match this runtime version.\n");
-                                       g_print ("The error is: %s\n", cerror);
-                                       g_print ("mscorlib.dll loaded at: %s\n", clibpath);
-                                       return 1;
-                               }
-                       }
                        return 0;
                } else if (strcmp (argv [i], "--help") == 0 || strcmp (argv [i], "-h") == 0) {
                        mini_usage ();
index f23c5ff3bb9e5c1278220b19656c554e6f85d527..32cd496f30f19b43817bfef49cfe95f27a2d5a08 100644 (file)
@@ -181,6 +181,69 @@ mono_strength_reduction_ins (MonoCompile *cfg, MonoInst *ins, const char **spec)
 #endif
                break;
        }
+#if SIZEOF_REGISTER == 4
+       case OP_LSHR_IMM: {
+               if (ins->inst_c1 == 32) {
+                       MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, MONO_LVREG_LS (ins->dreg), MONO_LVREG_MS (ins->sreg1));
+                       MONO_EMIT_NEW_BIALU_IMM (cfg, OP_ISHR_IMM, MONO_LVREG_MS (ins->dreg), MONO_LVREG_MS (ins->sreg1), 31);
+               } else if (ins->inst_c1 == 0) {
+                       MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, MONO_LVREG_LS (ins->dreg), MONO_LVREG_LS (ins->sreg1));
+                       MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, MONO_LVREG_MS (ins->dreg), MONO_LVREG_MS (ins->sreg1));
+               } else if (ins->inst_c1 > 32) {
+                       MONO_EMIT_NEW_BIALU_IMM (cfg, OP_ISHR_IMM, MONO_LVREG_LS (ins->dreg), MONO_LVREG_MS (ins->sreg1), ins->inst_c1 - 32);
+                       MONO_EMIT_NEW_BIALU_IMM (cfg, OP_ISHR_IMM, MONO_LVREG_MS (ins->dreg), MONO_LVREG_MS (ins->sreg1), 31);
+               } else {
+                       guint32 tmpreg = alloc_ireg (cfg);
+                       MONO_EMIT_NEW_BIALU_IMM (cfg, OP_ISHL_IMM, tmpreg, MONO_LVREG_MS (ins->sreg1), 32 - ins->inst_c1);
+                       MONO_EMIT_NEW_BIALU_IMM (cfg, OP_ISHR_IMM, MONO_LVREG_MS (ins->dreg), MONO_LVREG_MS (ins->sreg1), ins->inst_c1);
+                       MONO_EMIT_NEW_BIALU_IMM (cfg, OP_ISHR_UN_IMM, MONO_LVREG_LS (ins->dreg), MONO_LVREG_LS (ins->sreg1), ins->inst_c1);
+                       MONO_EMIT_NEW_BIALU (cfg, OP_IOR, MONO_LVREG_LS (ins->dreg), MONO_LVREG_LS (ins->dreg), tmpreg);
+                       allocated_vregs = TRUE;
+               }
+               break;
+       }
+       case OP_LSHR_UN_IMM: {
+               if (ins->inst_c1 == 32) {
+                       MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, MONO_LVREG_LS (ins->dreg), MONO_LVREG_MS (ins->sreg1));
+                       MONO_EMIT_NEW_ICONST (cfg, MONO_LVREG_MS (ins->dreg), 0);
+               } else if (ins->inst_c1 == 0) {
+                       MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, MONO_LVREG_LS (ins->dreg), MONO_LVREG_LS (ins->sreg1));
+                       MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, MONO_LVREG_MS (ins->dreg), MONO_LVREG_MS (ins->sreg1));
+               } else if (ins->inst_c1 > 32) {
+                       MONO_EMIT_NEW_BIALU_IMM (cfg, OP_ISHR_UN_IMM, MONO_LVREG_LS (ins->dreg), MONO_LVREG_MS (ins->sreg1), ins->inst_c1 - 32);
+                       MONO_EMIT_NEW_ICONST (cfg, MONO_LVREG_MS (ins->dreg), 0);
+               } else {
+                       guint32 tmpreg = alloc_ireg (cfg);
+                       MONO_EMIT_NEW_BIALU_IMM (cfg, OP_ISHL_IMM, tmpreg, MONO_LVREG_MS (ins->sreg1), 32 - ins->inst_c1);
+                       MONO_EMIT_NEW_BIALU_IMM (cfg, OP_ISHR_UN_IMM, MONO_LVREG_MS (ins->dreg), MONO_LVREG_MS (ins->sreg1), ins->inst_c1);
+                       MONO_EMIT_NEW_BIALU_IMM (cfg, OP_ISHR_UN_IMM, MONO_LVREG_LS (ins->dreg), MONO_LVREG_LS (ins->sreg1), ins->inst_c1);
+                       MONO_EMIT_NEW_BIALU (cfg, OP_IOR, MONO_LVREG_LS (ins->dreg), MONO_LVREG_LS (ins->dreg), tmpreg);
+                       allocated_vregs = TRUE;
+               }
+               break;
+       }
+       case OP_LSHL_IMM: {
+               if (ins->inst_c1 == 32) {
+                       /* just move the lower half to the upper and zero the lower word */
+                       MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, MONO_LVREG_MS (ins->dreg), MONO_LVREG_LS (ins->sreg1));
+                       MONO_EMIT_NEW_ICONST (cfg, MONO_LVREG_LS (ins->dreg), 0);
+               } else if (ins->inst_c1 == 0) {
+                       MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, MONO_LVREG_LS (ins->dreg), MONO_LVREG_LS (ins->sreg1));
+                       MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, MONO_LVREG_MS (ins->dreg), MONO_LVREG_MS (ins->sreg1));
+               } else if (ins->inst_c1 > 32) {
+                       MONO_EMIT_NEW_BIALU_IMM (cfg, OP_ISHL_IMM, MONO_LVREG_MS (ins->dreg), MONO_LVREG_LS (ins->sreg1), ins->inst_c1 - 32);
+                       MONO_EMIT_NEW_ICONST (cfg, MONO_LVREG_LS (ins->dreg), 0);
+               } else {
+                       guint32 tmpreg = alloc_ireg (cfg);
+                       MONO_EMIT_NEW_BIALU_IMM (cfg, OP_ISHR_UN_IMM, tmpreg, MONO_LVREG_LS (ins->sreg1), 32 - ins->inst_c1);
+                       MONO_EMIT_NEW_BIALU_IMM (cfg, OP_ISHL_IMM, MONO_LVREG_MS (ins->dreg), MONO_LVREG_MS (ins->sreg1), ins->inst_c1);
+                       MONO_EMIT_NEW_BIALU_IMM (cfg, OP_ISHL_IMM, MONO_LVREG_LS (ins->dreg), MONO_LVREG_LS (ins->sreg1), ins->inst_c1);
+                       MONO_EMIT_NEW_BIALU (cfg, OP_IOR, MONO_LVREG_MS (ins->dreg), MONO_LVREG_MS (ins->dreg), tmpreg);
+                       allocated_vregs = TRUE;
+               }
+               break;
+       }
+#endif
 
        default:
                break;
index 5e9204611d7bf37760b7aae0a19dcb1057196085..6f2685dce80d67d586da67b8058f69e8f53d66a8 100644 (file)
@@ -1010,7 +1010,9 @@ mono_arch_allocate_vars (MonoCompile *cfg)
        header = cfg->header;
        sig = mono_method_signature (cfg->method);
 
-       cinfo = get_call_info (cfg->mempool, sig);
+       if (!cfg->arch.cinfo)
+               cfg->arch.cinfo = get_call_info (cfg->mempool, sig);
+       cinfo = (CallInfo *)cfg->arch.cinfo;
 
        cfg->frame_reg = X86_EBP;
        offset = 0;
@@ -1140,8 +1142,8 @@ mono_arch_allocate_vars (MonoCompile *cfg)
                if (inst->opcode != OP_REGVAR) {
                        inst->opcode = OP_REGOFFSET;
                        inst->inst_basereg = X86_EBP;
+                       inst->inst_offset = ainfo->offset + ARGS_OFFSET;
                }
-               inst->inst_offset = ainfo->offset + ARGS_OFFSET;
        }
 
        cfg->stack_offset = offset;
@@ -1156,7 +1158,10 @@ mono_arch_create_vars (MonoCompile *cfg)
 
        sig = mono_method_signature (cfg->method);
 
-       cinfo = get_call_info (cfg->mempool, sig);
+       if (!cfg->arch.cinfo)
+               cfg->arch.cinfo = get_call_info (cfg->mempool, sig);
+       cinfo = (CallInfo *)cfg->arch.cinfo;
+
        sig_ret = mini_get_underlying_type (sig->ret);
 
        if (cinfo->ret.storage == ArgValuetypeInReg)
@@ -5128,6 +5133,8 @@ mono_arch_emit_prolog (MonoCompile *cfg)
        MonoBasicBlock *bb;
        MonoMethodSignature *sig;
        MonoInst *inst;
+       CallInfo *cinfo;
+       ArgInfo *ainfo;
        int alloc_size, pos, max_offset, i, cfa_offset;
        guint8 *code;
        gboolean need_stack_frame;
@@ -5387,11 +5394,14 @@ mono_arch_emit_prolog (MonoCompile *cfg)
        sig = mono_method_signature (method);
        pos = 0;
 
+       cinfo = (CallInfo *)cfg->arch.cinfo;
+
        for (i = 0; i < sig->param_count + sig->hasthis; ++i) {
                inst = cfg->args [pos];
+               ainfo = &cinfo->args [pos];
                if (inst->opcode == OP_REGVAR) {
                        g_assert (need_stack_frame);
-                       x86_mov_reg_membase (code, inst->dreg, X86_EBP, inst->inst_offset, 4);
+                       x86_mov_reg_membase (code, inst->dreg, X86_EBP, ainfo->offset + ARGS_OFFSET, 4);
                        if (cfg->verbose_level > 2)
                                g_print ("Argument %d assigned to register %s\n", pos, mono_arch_regname (inst->dreg));
                }
@@ -5513,7 +5523,7 @@ mono_arch_emit_epilog (MonoCompile *cfg)
        }
 
        /* Load returned vtypes into registers if needed */
-       cinfo = get_call_info (cfg->mempool, sig);
+       cinfo = (CallInfo *)cfg->arch.cinfo;
        if (cinfo->ret.storage == ArgValuetypeInReg) {
                for (quad = 0; quad < 2; quad ++) {
                        switch (cinfo->ret.pair_storage [quad]) {
index 969b679f29bbfdd161bd5a77c6c68cf7d6900cbc..0ca2bdcec44d54524c13b56004e93c1149bb4c8c 100644 (file)
@@ -165,6 +165,7 @@ typedef struct {
        gboolean need_stack_frame_inited;
        gboolean need_stack_frame;
        int sp_fp_offset, param_area_size;
+       gpointer cinfo;
        gpointer ss_tramp_var;
        gpointer bp_tramp_var;
 } MonoCompileArch;
index 5f4f149a3f4a35bc5e26a67b9120de1ede78c49f..d2e3ccdd0093dcc9e68432ef1e8f20b9198651a2 100644 (file)
@@ -99,6 +99,7 @@ struct _MSBlockInfo {
        guint16 obj_size_index;
        /* FIXME: Reduce this - it only needs a byte. */
        volatile gint32 state;
+       gint16 nused;
        unsigned int pinned : 1;
        unsigned int has_references : 1;
        unsigned int has_pinned : 1;    /* means cannot evacuate */
@@ -161,7 +162,7 @@ static int fast_block_obj_size_indexes [MS_NUM_FAST_BLOCK_OBJ_SIZE_INDEXES];
 static gboolean *evacuate_block_obj_sizes;
 static float evacuation_threshold = 0.666f;
 
-static gboolean lazy_sweep = FALSE;
+static gboolean lazy_sweep = TRUE;
 
 enum {
        SWEEP_STATE_SWEPT,
@@ -806,6 +807,7 @@ set_sweep_state (int new_, int expected)
 static gboolean ensure_block_is_checked_for_sweeping (guint32 block_index, gboolean wait, gboolean *have_checked);
 
 static SgenThreadPoolJob * volatile sweep_job;
+static SgenThreadPoolJob * volatile sweep_blocks_job;
 
 static void
 major_finish_sweep_checking (void)
@@ -1514,6 +1516,7 @@ ensure_block_is_checked_for_sweeping (guint32 block_index, gboolean wait, gboole
        for (i = 0; i < MS_NUM_MARK_WORDS; ++i)
                nused += bitcount (block->mark_words [i]);
 
+       block->nused = nused;
        if (nused)
                have_live = TRUE;
        if (nused < count)
@@ -1575,6 +1578,20 @@ ensure_block_is_checked_for_sweeping (guint32 block_index, gboolean wait, gboole
        return !!tagged_block;
 }
 
+static void
+sweep_blocks_job_func (void *thread_data_untyped, SgenThreadPoolJob *job)
+{
+       volatile gpointer *slot;
+
+       SGEN_ARRAY_LIST_FOREACH_SLOT (&allocated_blocks, slot) {
+               sweep_block (BLOCK_UNTAG (*slot));
+       } SGEN_ARRAY_LIST_END_FOREACH_SLOT;
+
+       mono_memory_write_barrier ();
+
+       sweep_blocks_job = NULL;
+}
+
 static void
 sweep_job_func (void *thread_data_untyped, SgenThreadPoolJob *job)
 {
@@ -1616,6 +1633,16 @@ sweep_job_func (void *thread_data_untyped, SgenThreadPoolJob *job)
 
        sgen_array_list_remove_nulls (&allocated_blocks);
 
+       /*
+        * Concurrently sweep all the blocks to reduce workload during minor
+        * pauses where we need certain blocks to be swept. At the start of
+        * the next major we need all blocks to be swept anyway.
+        */
+       if (concurrent_sweep && lazy_sweep) {
+               sweep_blocks_job = sgen_thread_pool_job_alloc ("sweep_blocks", sweep_blocks_job_func, sizeof (SgenThreadPoolJob));
+               sgen_thread_pool_job_enqueue (sweep_blocks_job);
+       }
+
        sweep_finish ();
 
        sweep_job = NULL;
@@ -1642,6 +1669,8 @@ sweep_finish (void)
        sgen_memgov_major_post_sweep ();
 
        set_sweep_state (SWEEP_STATE_SWEPT, SWEEP_STATE_COMPACTING);
+       if (concurrent_sweep)
+               binary_protocol_concurrent_sweep_end (sgen_timestamp ());
 }
 
 static void
@@ -1778,6 +1807,67 @@ major_finish_nursery_collection (void)
 #endif
 }
 
+static int
+block_usage_comparer (const void *bl1, const void *bl2)
+{
+       const gint16 nused1 = (*(MSBlockInfo**)bl1)->nused;
+       const gint16 nused2 = (*(MSBlockInfo**)bl2)->nused;
+
+       return nused2 - nused1;
+}
+
+static void
+sgen_evacuation_freelist_blocks (MSBlockInfo * volatile *block_list, int size_index)
+{
+       MSBlockInfo **evacuated_blocks;
+       size_t index = 0, count, num_blocks = 0, num_used = 0;
+       MSBlockInfo *info;
+       MSBlockInfo * volatile *prev;
+
+       for (info = *block_list; info != NULL; info = info->next_free) {
+               num_blocks++;
+               num_used += info->nused;
+       }
+
+       /*
+        * We have a set of blocks in the freelist which will be evacuated. Instead
+        * of evacuating all of the blocks into new ones, we traverse the freelist
+        * sorting it by the number of occupied slots, evacuating the objects from
+        * blocks with fewer used slots into fuller blocks.
+        *
+        * The number of used slots is set at the end of the previous sweep. Since
+        * we sequentially unlink slots from blocks, except for the head of the
+        * freelist, for blocks on the freelist, the number of used slots is the same
+        * as at the end of the previous sweep.
+        */
+       evacuated_blocks = (MSBlockInfo**)sgen_alloc_internal_dynamic (sizeof (MSBlockInfo*) * num_blocks, INTERNAL_MEM_TEMPORARY, TRUE);
+
+       for (info = *block_list; info != NULL; info = info->next_free) {
+               evacuated_blocks [index++] = info;
+       }
+
+       SGEN_ASSERT (0, num_blocks == index, "Why did the freelist change ?");
+
+       qsort (evacuated_blocks, num_blocks, sizeof (gpointer), block_usage_comparer);
+
+       /*
+        * Form a new freelist with the fullest blocks. These blocks will also be
+        * marked as to_space so we don't evacuate from them.
+        */
+       count = MS_BLOCK_FREE / block_obj_sizes [size_index];
+       prev = block_list;
+       for (index = 0; index < (num_used + count - 1) / count; index++) {
+               SGEN_ASSERT (0, index < num_blocks, "Why do we need more blocks for compaction than we already had ?");
+               info = evacuated_blocks [index];
+               info->is_to_space = TRUE;
+               *prev = info;
+               prev = &info->next_free;
+       }
+       *prev = NULL;
+
+       sgen_free_internal_dynamic (evacuated_blocks, sizeof (MSBlockInfo*) * num_blocks, INTERNAL_MEM_TEMPORARY);
+}
+
 static void
 major_start_major_collection (void)
 {
@@ -1796,22 +1886,38 @@ major_start_major_collection (void)
 
                binary_protocol_evacuating_blocks (block_obj_sizes [i]);
 
-               free_block_lists [0][i] = NULL;
-               free_block_lists [MS_BLOCK_FLAG_REFS][i] = NULL;
+               sgen_evacuation_freelist_blocks (&free_block_lists [0][i], i);
+               sgen_evacuation_freelist_blocks (&free_block_lists [MS_BLOCK_FLAG_REFS][i], i);
        }
 
-       if (lazy_sweep)
-               binary_protocol_sweep_begin (GENERATION_OLD, TRUE);
+       if (lazy_sweep && concurrent_sweep) {
+               /*
+                * sweep_blocks_job is created before sweep_finish, which we wait for above
+                * (major_finish_sweep_checking). After the end of sweep, if we don't have
+                * sweep_blocks_job set, it means that it has already been run.
+                */
+               SgenThreadPoolJob *job = sweep_blocks_job;
+               if (job)
+                       sgen_thread_pool_job_wait (job);
+       }
 
+       if (lazy_sweep && !concurrent_sweep)
+               binary_protocol_sweep_begin (GENERATION_OLD, TRUE);
        /* Sweep all unswept blocks and set them to MARKING */
        FOREACH_BLOCK_NO_LOCK (block) {
-               if (lazy_sweep)
+               if (lazy_sweep && !concurrent_sweep)
                        sweep_block (block);
                SGEN_ASSERT (0, block->state == BLOCK_STATE_SWEPT, "All blocks must be swept when we're pinning.");
                set_block_state (block, BLOCK_STATE_MARKING, BLOCK_STATE_SWEPT);
+               /*
+                * Swept blocks that have a null free_list are full. Evacuation is not
+                * effective on these blocks since we expect them to have high usage anyway,
+                * given that the survival rate for majors is relatively high.
+                */
+               if (evacuate_block_obj_sizes [block->obj_size_index] && !block->free_list)
+                       block->is_to_space = TRUE;
        } END_FOREACH_BLOCK_NO_LOCK;
-
-       if (lazy_sweep)
+       if (lazy_sweep && !concurrent_sweep)
                binary_protocol_sweep_end (GENERATION_OLD, TRUE);
 
        set_sweep_state (SWEEP_STATE_NEED_SWEEPING, SWEEP_STATE_SWEPT);
index 8a190ef6f494df314fa590d74a0022af78f28294..3ab36e3bf660f380b9b21cf554f0e659899eb520 100644 (file)
@@ -435,6 +435,13 @@ MATCH_INDEX (BINARY_PROTOCOL_MATCH)
 IS_VTABLE_MATCH (FALSE)
 END_PROTOCOL_ENTRY
 
+BEGIN_PROTOCOL_ENTRY1 (binary_protocol_concurrent_sweep_end, TYPE_LONGLONG, timestamp)
+DEFAULT_PRINT ()
+IS_ALWAYS_MATCH (TRUE)
+MATCH_INDEX (BINARY_PROTOCOL_MATCH)
+IS_VTABLE_MATCH (FALSE)
+END_PROTOCOL_ENTRY
+
 #undef BEGIN_PROTOCOL_ENTRY0
 #undef BEGIN_PROTOCOL_ENTRY1
 #undef BEGIN_PROTOCOL_ENTRY2