-Subproject commit 2f66da8d34b30473dac23f02b1a843d0717b9f1a
+Subproject commit 1f9f4ae3de23a100d871eae9f12da22d9353b182
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
#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
#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
}
}
- 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)
{
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;
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;
}
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);
get { return IntPtr.Zero; }
}
+ public override IntPtr GetNativeAppleCertificate ()
+ {
+ return IntPtr.Zero;
+ }
+
internal X509Certificate2ImplMono (MX.X509Certificate cert)
{
this._cert = cert;
+++ /dev/null
-//
-// 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 ()));
- }
- }
-}
+++ /dev/null
-//
-// 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 ()));
- }
- }
-}
--- /dev/null
+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
+
+++ /dev/null
-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 $@
+++ /dev/null
-//
-// 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
thisdir = class/corlib
SUBDIRS =
include ../../build/rules.make
-include CommonCrypto/Makefile.include
export __SECURITY_BOOTSTRAP_DB=$(topdir)/class/corlib
LIBRARY = corlib.dll
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 \
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.
FullPath = Path.GetFullPath (path);
if (simpleOriginalPath)
- OriginalPath = Path.GetFileName (path);
+ OriginalPath = Path.GetFileName (FullPath);
else
OriginalPath = path;
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;
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);
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);
}
}
- //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;
internal override Type InternalResolve ()
{
- Type et = elementType.InternalResolve ();
+ Type et = m_baseType.InternalResolve ();
if (rank == 0)
return et.MakeArrayType ();
return et.MakeArrayType (rank);
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)
}
[StructLayout (LayoutKind.Sequential)]
- internal class ByRefType : DerivedType
+ internal class ByRefType : SymbolType
{
internal ByRefType (Type elementType) : base (elementType)
{
internal override Type InternalResolve ()
{
- return elementType.InternalResolve ().MakeByRefType ();
+ return m_baseType.InternalResolve ().MakeByRefType ();
}
protected override bool IsByRefImpl ()
return true;
}
- public override Type BaseType {
- get { return typeof (Array); }
- }
-
internal override String FormatName (string elementName)
{
if (elementName == null)
}
[StructLayout (LayoutKind.Sequential)]
- internal class PointerType : DerivedType
+ internal class PointerType : SymbolType
{
internal PointerType (Type elementType) : base (elementType)
{
internal override Type InternalResolve ()
{
- return elementType.InternalResolve ().MakePointerType ();
+ return m_baseType.InternalResolve ().MakePointerType ();
}
protected override bool IsPointerImpl ()
return true;
}
- public override Type BaseType {
- get { return typeof(Array); }
- }
-
internal override String FormatName (string elementName)
{
if (elementName == null)
get;
}
+ /*
+ * This is used in System.dll's OSX509Certificates.cs
+ */
+ public abstract IntPtr GetNativeAppleCertificate ();
+
protected void ThrowIfContextInvalid ()
{
if (!IsValid)
get { return handle; }
}
+ public override IntPtr GetNativeAppleCertificate ()
+ {
+ ThrowIfContextInvalid ();
+ return handle;
+ }
+
public override X509CertificateImpl Clone ()
{
ThrowIfContextInvalid ();
namespace System.Security.Cryptography.X509Certificates
{
- class X509CertificateImplMono : X509CertificateImpl
+ sealed class X509CertificateImplMono : X509CertificateImpl
{
MX.X509Certificate x509;
get { return IntPtr.Zero; }
}
+ public override IntPtr GetNativeAppleCertificate ()
+ {
+ return IntPtr.Zero;
+ }
+
public override X509CertificateImpl Clone ()
{
ThrowIfContextInvalid ();
* 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)]
}\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
Assert.IsFalse (arr.IsGenericParameter, "#8");
Assert.IsFalse (arr.IsGenericType, "#9");
Assert.IsFalse (arr.IsGenericTypeDefinition, "#10");
+ Assert.IsTrue (arr is TypeInfo, "#11");
}
[Test]
Assert.AreEqual ("F[]", arr.Name, "#21");
Assert.AreEqual (gparam, arr.GetElementType (), "#22");
+ Assert.IsTrue (arr is TypeInfo, "#23");
}
[Test]
Assert.AreEqual ("enum[]", arr.Name, "#21");
Assert.AreEqual (eb, arr.GetElementType (), "#22");
+ Assert.IsTrue (arr is TypeInfo, "#23");
}
}
[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 ();
}
../../../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
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
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
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
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
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)
--- /dev/null
+//
+// 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 ()));
+ }
+ }
+}
--- /dev/null
+//
+// 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 ()));
+ }
+ }
+}
--- /dev/null
+thisdir = tools/commoncryptogenerator
+SUBDIRS =
+include ../../build/rules.make
+
+LIB_REFS =
+LOCAL_MCS_FLAGS =
+
+PROGRAM = commoncryptogenerator.exe
+NO_INSTALL = yes
+
+include ../../build/executable.make
--- /dev/null
+CommonCryptorGenerator.cs
+generator.cs
+CommonDigestGenerator.cs
--- /dev/null
+//
+// 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
* 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
{
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));
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:
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:
default:
g_assert_not_reached ();
}
+#endif /* DISABLE_JIT */
}
/**
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.
*/
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,
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);
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);
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;
default:
g_assert_not_reached ();
}
+#endif /* DISABLE_JIT */
return conv_arg;
}
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;
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]);
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);
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);
{
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:
break;
case MARSHAL_ACTION_CONV_OUT: {
-
if (t->attrs & PARAM_ATTRIBUTE_OUT) {
/* Generates IL code for the following algorithm:
default:
g_assert_not_reached ();
}
+#endif /* DISABLE_JIT */
return conv_arg;
}
#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)
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)
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))
{
}
+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);
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) {
* 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);
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 ();
#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;
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;
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;
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)
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;
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));
}
}
/* 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]) {
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;
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 */
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,
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)
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)
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)
{
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;
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
#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)
{
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);
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