From: João Matos Date: Fri, 8 Jan 2016 14:03:32 +0000 (+0000) Subject: Merge pull request #2390 from schani/feature-bisector X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=commitdiff_plain;h=177d973ef7b027fe3f6b215b7d00a3bebcf2f21b;hp=121f253944a52fbe65a3f0ef00d2c3dc27578fa5;p=mono.git Merge pull request #2390 from schani/feature-bisector Automatic optimization bug bisector. --- diff --git a/data/gdb-pre7.0/mono-gdb.py b/data/gdb-pre7.0/mono-gdb.py index 1c013e38611..eda0ba36da7 100644 --- a/data/gdb-pre7.0/mono-gdb.py +++ b/data/gdb-pre7.0/mono-gdb.py @@ -53,7 +53,7 @@ def stringify_class_name(ns, name): if ns == "": return name else: - return "%s.%s".format (ns, name) + return "{}.{}".format (ns, name) class ArrayPrinter: "Print a C# array" @@ -66,7 +66,7 @@ class ArrayPrinter: def to_string(self): obj = self.val.cast (gdb.lookup_type ("MonoArray").pointer ()).dereference () length = obj ['max_length'] - return "%s [%d]".format (stringify_class_name (self.class_ns, self.class_name [0:len (self.class_name) - 2]), int (length)) + return "{} [{}]".format (stringify_class_name (self.class_ns, self.class_name [0:len (self.class_name) - 2]), int (length)) class ObjectPrinter: "Print a C# object" @@ -96,7 +96,7 @@ class ObjectPrinter: return (field.name, self.obj [field.name]) except: # Superclass - return (field.name, self.obj.cast (gdb.lookup_type ("%s".format (field.name)))) + return (field.name, self.obj.cast (gdb.lookup_type ("{}".format (field.name)))) def children(self): # FIXME: It would be easier if gdb.Value would support iteration itself @@ -109,7 +109,7 @@ class ObjectPrinter: class_name = obj ['vtable'].dereference ()['klass'].dereference ()['name'].string () if class_name [-2:len(class_name)] == "[]": return {}.__iter__ () - gdb_type = gdb.lookup_type ("struct %s_%s".format (class_ns.replace (".", "_"), class_name)) + gdb_type = gdb.lookup_type ("struct {}_{}".format (class_ns.replace (".", "_"), class_name)) return self._iterator(obj.cast (gdb_type)) except: print (sys.exc_info ()[0]) @@ -129,12 +129,12 @@ class ObjectPrinter: return ArrayPrinter (self.val,class_ns,class_name).to_string () if class_ns != "": try: - gdb_type = gdb.lookup_type ("struct %s.%s".format (class_ns, class_name)) + gdb_type = gdb.lookup_type ("struct {}.{}".format (class_ns, class_name)) except: # Maybe there is no debug info for that type - return "%s.%s".format (class_ns, class_name) + return "{}.{}".format (class_ns, class_name) #return obj.cast (gdb_type) - return "%s.%s".format (class_ns, class_name) + return "{}.{}".format (class_ns, class_name) return class_name except: print (sys.exc_info ()[0]) @@ -154,9 +154,9 @@ class MonoMethodPrinter: val = self.val.dereference () klass = val ["klass"].dereference () class_name = stringify_class_name (klass ["name_space"].string (), klass ["name"].string ()) - return "\"%s:%s ()\"".format (class_name, val ["name"].string ()) + return "\"{}:{} ()\"".format (class_name, val ["name"].string ()) # This returns more info but requires calling into the inferior - #return "\"%s\"".format (gdb.parse_and_eval ("mono_method_full_name (%s, 1)".format (str (int (self.val.cast (gdb.lookup_type ("guint64")))))).string ()) + #return "\"{}\"".format (gdb.parse_and_eval ("mono_method_full_name ({}, 1)".format (str (int (self.val.cast (gdb.lookup_type ("guint64")))))).string ()) class MonoClassPrinter: "Print a MonoClass structure" @@ -169,9 +169,9 @@ class MonoClassPrinter: return "0x0" klass = self.val.dereference () class_name = stringify_class_name (klass ["name_space"].string (), klass ["name"].string ()) - return "\"%s\"".format (class_name) + return "\"{}\"".format (class_name) # This returns more info but requires calling into the inferior - #return "\"%s\"".format (gdb.parse_and_eval ("mono_type_full_name (&((MonoClass*)%s)->byval_arg)".format (str (int ((self.val).cast (gdb.lookup_type ("guint64"))))))) + #return "\"{}\"".format (gdb.parse_and_eval ("mono_type_full_name (&((MonoClass*){})->byval_arg)".format (str (int ((self.val).cast (gdb.lookup_type ("guint64"))))))) def lookup_pretty_printer(val): t = str (val.type) @@ -217,9 +217,9 @@ class MonoSupport(object): new_size = os.stat ("xdb.s").st_size if new_size > self.s_size: sofile = "xdb.so" - gdb.execute ("shell as -o xdb.o xdb.s && ld -shared -o %s xdb.o".format (sofile)) + gdb.execute ("shell as -o xdb.o xdb.s && ld -shared -o {} xdb.o".format (sofile)) # FIXME: This prints messages which couldn't be turned off - gdb.execute ("add-symbol-file %s 0".format (sofile)) + gdb.execute ("add-symbol-file {} 0".format (sofile)) self.s_size = new_size class RunHook (gdb.Command): @@ -245,4 +245,4 @@ exec_file = gdb.current_objfile ().filename if os.stat (exec_file).st_size != os.lstat (exec_file).st_size: exec_file = os.readlink (exec_file) exec_dir = os.path.dirname (exec_file) -gdb.execute ("source %s/%s-gdbinit".format (exec_dir, os.path.basename (exec_file))) +gdb.execute ("source {}/{}-gdbinit".format (exec_dir, os.path.basename (exec_file))) diff --git a/data/gdb/mono-gdb.py b/data/gdb/mono-gdb.py index f4dcfe72c09..7d9eab5cb70 100644 --- a/data/gdb/mono-gdb.py +++ b/data/gdb/mono-gdb.py @@ -48,7 +48,7 @@ def stringify_class_name(ns, name): if ns == "": return name else: - return "%s.%s".format (ns, name) + return "{}.{}".format (ns, name) class ArrayPrinter: "Print a C# array" @@ -61,7 +61,7 @@ class ArrayPrinter: def to_string(self): obj = self.val.cast (gdb.lookup_type ("MonoArray").pointer ()).dereference () length = obj ['max_length'] - return "%s [%d]".format (stringify_class_name (self.class_ns, self.class_name [0:len(self.class_name) - 2]), int(length)) + return "{} [{}]".format (stringify_class_name (self.class_ns, self.class_name [0:len(self.class_name) - 2]), int(length)) class ObjectPrinter: "Print a C# object" @@ -91,7 +91,7 @@ class ObjectPrinter: return (field.name, self.obj [field.name]) except: # Superclass - return (field.name, self.obj.cast (gdb.lookup_type ("%s".format (field.name)))) + return (field.name, self.obj.cast (gdb.lookup_type ("{}".format (field.name)))) def children(self): # FIXME: It would be easier if gdb.Value would support iteration itself @@ -105,7 +105,7 @@ class ObjectPrinter: if class_name [-2:len(class_name)] == "[]": return {}.__iter__ () try: - gdb_type = gdb.lookup_type ("struct %s_%s".format (class_ns.replace (".", "_"), class_name)) + gdb_type = gdb.lookup_type ("struct {}_{}".format (class_ns.replace (".", "_"), class_name)) return self._iterator(obj.cast (gdb_type)) except: return {}.__iter__ () @@ -127,12 +127,12 @@ class ObjectPrinter: return ArrayPrinter (self.val,class_ns,class_name).to_string () if class_ns != "": try: - gdb_type = gdb.lookup_type ("struct %s.%s".format (class_ns, class_name)) + gdb_type = gdb.lookup_type ("struct {}.{}".format (class_ns, class_name)) except: # Maybe there is no debug info for that type - return "%s.%s".format (class_ns, class_name) + return "{}.{}".format (class_ns, class_name) #return obj.cast (gdb_type) - return "%s.%s".format (class_ns, class_name) + return "{}.{}".format (class_ns, class_name) return class_name except: print (sys.exc_info ()[0]) @@ -152,9 +152,9 @@ class MonoMethodPrinter: val = self.val.dereference () klass = val ["klass"].dereference () class_name = stringify_class_name (klass ["name_space"].string (), klass ["name"].string ()) - return "\"%s:%s ()\"".format (class_name, val ["name"].string ()) + return "\"{}:{} ()\"".format (class_name, val ["name"].string ()) # This returns more info but requires calling into the inferior - #return "\"%s\"".format (gdb.parse_and_eval ("mono_method_full_name (%s, 1)".format (str (int (self.val.cast (gdb.lookup_type ("guint64")))))).string ()) + #return "\"{}\"".format (gdb.parse_and_eval ("mono_method_full_name ({}, 1)".format (str (int (self.val.cast (gdb.lookup_type ("guint64")))))).string ()) class MonoClassPrinter: "Print a MonoClass structure" @@ -168,13 +168,13 @@ class MonoClassPrinter: klass = self.val.dereference () class_name = stringify_class_name (klass ["name_space"].string (), klass ["name"].string ()) if klass ["generic_class"].cast (gdb.lookup_type ("guint64")) != 0: - class_name = "%s<%s>".format (class_name, str (klass ["generic_class"]["context"]["class_inst"])) + class_name = "{}<{}>".format (class_name, str (klass ["generic_class"]["context"]["class_inst"])) if add_quotes: - return "\"%s\"".format (class_name) + return "\"{}\"".format (class_name) else: return class_name # This returns more info but requires calling into the inferior - #return "\"%s\"".format (gdb.parse_and_eval ("mono_type_full_name (&((MonoClass*)%s)->byval_arg)".format (str (int ((self.val).cast (gdb.lookup_type ("guint64"))))))) + #return "\"{}\"".format (gdb.parse_and_eval ("mono_type_full_name (&((MonoClass*){})->byval_arg)".format (str (int ((self.val).cast (gdb.lookup_type ("guint64"))))))) def to_string(self): try: @@ -222,7 +222,7 @@ class MonoGenericClassPrinter: method_inst_str = "" if int(method_inst.cast (gdb.lookup_type ("guint64"))) != 0: method_inst_str = str(method_inst) - return "%s, [%s], [%s]>".format (container_str, class_inst_str, method_inst_str) + return "{}, [{}], [{}]>".format (container_str, class_inst_str, method_inst_str) def to_string(self): try: @@ -252,9 +252,9 @@ class MonoTypePrinter: info = str(t ["data"]["generic_class"]) if info != "": - return "{%s, %s}".format (kind, info) + return "{{}, {}}".format (kind, info) else: - return "{%s}".format (kind) + return "{{}}".format (kind) except: #print (sys.exc_info ()[0]) #print (sys.exc_info ()[1]) @@ -283,7 +283,7 @@ class MonoMethodRgctxPrinter: if i > 0: inst_str = inst_str + ", " inst_str = inst_str + type_printer.to_string () - return "MRGCTX[%s, [%s]]".format (klass_printer.to_string(), inst_str) + return "MRGCTX[{}, [{}]]".format (klass_printer.to_string(), inst_str) class MonoVTablePrinter: "Print a MonoVTable structure" @@ -298,7 +298,7 @@ class MonoVTablePrinter: klass = vtable ["klass"] klass_printer = MonoClassPrinter (klass) - return "vtable(%s)".format (klass_printer.to_string ()) + return "vtable({})".format (klass_printer.to_string ()) def lookup_pretty_printer(val): t = str (val.type) diff --git a/external/referencesource b/external/referencesource index 8382c4605d6..e12162bb0f1 160000 --- a/external/referencesource +++ b/external/referencesource @@ -1 +1 @@ -Subproject commit 8382c4605d622d56354e7340bf872caaf36b972a +Subproject commit e12162bb0f1dfad191c58f913de7d5faf013b84b diff --git a/man/al.1 b/man/al.1 index 3e4f1827126..8bd0fc03ce5 100644 --- a/man/al.1 +++ b/man/al.1 @@ -4,7 +4,7 @@ al, al2 \- Mono Assembly Linker .SH SYNOPSIS .B al [option] [source-files] .SH DESCRIPTION -AL is the Mono assembly linkder. +AL is the Mono assembly linker. .PP This linker is used to put together assemblies from a collection of modules (.netmodule files), assembly manifest files and resources. diff --git a/man/mono.1 b/man/mono.1 index c1efea05956..29e1c26f3fa 100644 --- a/man/mono.1 +++ b/man/mono.1 @@ -124,6 +124,16 @@ This is currently an experimental feature as it is not complete. This instructs Mono to precompile code that has historically not been precompiled with AOT. .TP +.I data-outfile=FILE.dll.aotdata +.Sp +This instructs the AOT code generator to output certain data +constructs into a separate file. This can reduce the executable +images some five to twenty percent. Developers need to then ship the +resulting aotdata as a resource and register a hook to load the data +on demand by using the +.I mono_install_load_aot_data_hook +method. +.TP .I direct-pinvoke .Sp When this option is specified, P/Invoke methods are invoked directly @@ -139,7 +149,8 @@ only supported by the ARM backend. In LLVM mode, this triple is passed on to the llc compiler. .TP .I nimt-trampolines=[number] -When compiling in full aot mode, the IMT trampolines must be precreated +When compiling in full aot mthis data at startup +usingode, the IMT trampolines must be precreated in the AOT image. You can add additional method trampolines with this argument. Defaults to 128. .TP diff --git a/mcs/build/profiles/monotouch_tv.make b/mcs/build/profiles/monotouch_tv.make index 2a36da9c203..a375281243a 100644 --- a/mcs/build/profiles/monotouch_tv.make +++ b/mcs/build/profiles/monotouch_tv.make @@ -5,4 +5,5 @@ PROFILE_MCS_FLAGS += \ NO_THREAD_ABORT=1 NO_THREAD_SUSPEND_RESUME=1 +NO_MULTIPLE_APPDOMAINS=1 NO_PROCESS_START=1 diff --git a/mcs/build/profiles/monotouch_watch.make b/mcs/build/profiles/monotouch_watch.make index 8534aaf1f77..0242c20bf51 100644 --- a/mcs/build/profiles/monotouch_watch.make +++ b/mcs/build/profiles/monotouch_watch.make @@ -5,4 +5,5 @@ PROFILE_MCS_FLAGS += \ NO_THREAD_ABORT=1 NO_THREAD_SUSPEND_RESUME=1 +NO_MULTIPLE_APPDOMAINS=1 NO_PROCESS_START=1 diff --git a/mcs/class/Mono.Security.Providers.DotNet/Makefile b/mcs/class/Mono.Security.Providers.DotNet/Makefile index f18286324da..a42b8c5a7c4 100644 --- a/mcs/class/Mono.Security.Providers.DotNet/Makefile +++ b/mcs/class/Mono.Security.Providers.DotNet/Makefile @@ -10,3 +10,5 @@ EXTRA_DISTFILES = README.md include ../../build/library.make +$(the_lib): ../Mono.Security/Makefile + diff --git a/mcs/class/Mono.Security.Providers.DotNet/Mono.Security.Providers.DotNet/DotNetSslStreamImpl.cs b/mcs/class/Mono.Security.Providers.DotNet/Mono.Security.Providers.DotNet/DotNetSslStreamImpl.cs index 7453f8d196a..c6be7030cef 100644 --- a/mcs/class/Mono.Security.Providers.DotNet/Mono.Security.Providers.DotNet/DotNetSslStreamImpl.cs +++ b/mcs/class/Mono.Security.Providers.DotNet/Mono.Security.Providers.DotNet/DotNetSslStreamImpl.cs @@ -39,6 +39,7 @@ namespace Mono.Security.Providers.DotNet { class DotNetSslStreamImpl : MSI.IMonoSslStream { + DotNetTlsProvider provider; SslStream impl; internal SslStream Impl { @@ -49,10 +50,11 @@ namespace Mono.Security.Providers.DotNet } public DotNetSslStreamImpl ( - Stream innerStream, bool leaveInnerStreamOpen, + Stream innerStream, bool leaveInnerStreamOpen, DotNetTlsProvider provider, RemoteCertificateValidationCallback userCertificateValidationCallback, LocalCertificateSelectionCallback userCertificateSelectionCallback) { + this.provider = provider; impl = new SslStream ( innerStream, leaveInnerStreamOpen, userCertificateValidationCallback, @@ -282,6 +284,15 @@ namespace Mono.Security.Providers.DotNet get { return Impl.SslProtocol; } } + MSI.MonoTlsProvider MSI.IMonoSslStream.Provider { + get { return provider; } + } + + MSI.MonoTlsConnectionInfo MSI.IMonoSslStream.GetConnectionInfo () + { + return null; + } + void CheckDisposed () { if (impl == null) diff --git a/mcs/class/Mono.Security.Providers.DotNet/Mono.Security.Providers.DotNet/DotNetTlsProvider.cs b/mcs/class/Mono.Security.Providers.DotNet/Mono.Security.Providers.DotNet/DotNetTlsProvider.cs index b96f828b90f..74b2a8e71c7 100644 --- a/mcs/class/Mono.Security.Providers.DotNet/Mono.Security.Providers.DotNet/DotNetTlsProvider.cs +++ b/mcs/class/Mono.Security.Providers.DotNet/Mono.Security.Providers.DotNet/DotNetTlsProvider.cs @@ -54,6 +54,10 @@ namespace Mono.Security.Providers.DotNet get { return true; } } + public override bool SupportsConnectionInfo { + get { return false; } + } + public override bool SupportsMonoExtensions { get { return false; } } @@ -81,7 +85,7 @@ namespace Mono.Security.Providers.DotNet selection_callback = ConvertCallback (settings.ClientCertificateSelectionCallback); } - return new DotNetSslStreamImpl (innerStream, leaveInnerStreamOpen, validation_callback, selection_callback); + return new DotNetSslStreamImpl (innerStream, leaveInnerStreamOpen, this, validation_callback, selection_callback); } public override IMonoTlsContext CreateTlsContext ( diff --git a/mcs/class/Mono.Security.Providers.NewSystemSource/Makefile b/mcs/class/Mono.Security.Providers.NewSystemSource/Makefile index 3545569b96e..bf6b1112e3f 100644 --- a/mcs/class/Mono.Security.Providers.NewSystemSource/Makefile +++ b/mcs/class/Mono.Security.Providers.NewSystemSource/Makefile @@ -18,3 +18,4 @@ EXTRA_DISTFILES = README.md include ../../build/library.make +$(the_lib): ../Mono.Security/Makefile diff --git a/mcs/class/Mono.Security.Providers.OldTls/Makefile b/mcs/class/Mono.Security.Providers.OldTls/Makefile index b3b5c7a2571..5dc06c07255 100644 --- a/mcs/class/Mono.Security.Providers.OldTls/Makefile +++ b/mcs/class/Mono.Security.Providers.OldTls/Makefile @@ -8,3 +8,5 @@ LIB_MCS_FLAGS = -unsafe -nowarn:1030 -keyfile:../mono.pub -delaysign -d:SECURITY include ../../build/library.make +$(the_lib): ../Mono.Security/Makefile + diff --git a/mcs/class/Mono.Security.Providers.OldTls/Mono.Security.Providers.OldTls/OldTlsProvider.cs b/mcs/class/Mono.Security.Providers.OldTls/Mono.Security.Providers.OldTls/OldTlsProvider.cs index 9d3aa7c4210..82bd9d5437b 100644 --- a/mcs/class/Mono.Security.Providers.OldTls/Mono.Security.Providers.OldTls/OldTlsProvider.cs +++ b/mcs/class/Mono.Security.Providers.OldTls/Mono.Security.Providers.OldTls/OldTlsProvider.cs @@ -54,6 +54,10 @@ namespace Mono.Security.Providers.OldTls get { return false; } } + public override bool SupportsConnectionInfo { + get { return false; } + } + public override bool SupportsTlsContext { get { return false; } } @@ -66,8 +70,8 @@ namespace Mono.Security.Providers.OldTls Stream innerStream, bool leaveInnerStreamOpen, MonoTlsSettings settings = null) { - var impl = new MNS.LegacySslStream (innerStream, leaveInnerStreamOpen, this, settings); - return new MNS.MonoSslStreamImpl (impl); + var impl = new MNS.Private.LegacySslStream (innerStream, leaveInnerStreamOpen, this, settings); + return new MNS.Private.MonoSslStreamImpl (impl); } public override IMonoTlsContext CreateTlsContext ( diff --git a/mcs/class/Mono.Security/Makefile b/mcs/class/Mono.Security/Makefile index f9508b9c8a6..eee0c8ff36d 100644 --- a/mcs/class/Mono.Security/Makefile +++ b/mcs/class/Mono.Security/Makefile @@ -5,7 +5,7 @@ include ../../build/rules.make LIBRARY = Mono.Security.dll LOCAL_MCS_FLAGS = -lib:$(the_libdir_base)bare LIB_REFS = System -LIB_MCS_FLAGS = -unsafe -nowarn:1030 +LIB_MCS_FLAGS = -unsafe -nowarn:1030,3009 TEST_MCS_FLAGS = $(LIB_MCS_FLAGS) -nowarn:169,219,618,672 include ../../build/library.make @@ -21,4 +21,5 @@ EXTRA_DISTFILES = Mono.Security.Interface/README.md # # Update this comment to trigger a build in System +# +1 # diff --git a/mcs/class/Mono.Security/Mono.Security.Interface/CertificateValidationHelper.cs b/mcs/class/Mono.Security/Mono.Security.Interface/CertificateValidationHelper.cs index a02a3f9316a..fc901084a70 100644 --- a/mcs/class/Mono.Security/Mono.Security.Interface/CertificateValidationHelper.cs +++ b/mcs/class/Mono.Security/Mono.Security.Interface/CertificateValidationHelper.cs @@ -36,7 +36,6 @@ using Mono.Net.Security; namespace Mono.Security.Interface { - #if (!MONOTOUCH && !MONODROID) || INSIDE_SYSTEM public class ValidationResult { bool trusted; @@ -52,12 +51,11 @@ namespace Mono.Security.Interface this.policy_errors = policy_errors; } - internal ValidationResult (bool trusted, bool user_defined, int error_code) + internal ValidationResult (bool trusted, bool user_denied, int error_code) { this.trusted = trusted; this.user_denied = user_denied; this.error_code = error_code; - this.policy_errors = policy_errors; } public bool Trusted { @@ -160,5 +158,4 @@ namespace Mono.Security.Interface return GetDefaultValidator (null, settings); } } -#endif } diff --git a/mcs/class/Mono.Security/Mono.Security.Interface/IMonoSslStream.cs b/mcs/class/Mono.Security/Mono.Security.Interface/IMonoSslStream.cs index ae7a9297d12..0098be9f45a 100644 --- a/mcs/class/Mono.Security/Mono.Security.Interface/IMonoSslStream.cs +++ b/mcs/class/Mono.Security/Mono.Security.Interface/IMonoSslStream.cs @@ -183,6 +183,13 @@ namespace Mono.Security.Interface SSA.SslProtocols SslProtocol { get; } + + MonoTlsProvider Provider { + get; + } + + + MonoTlsConnectionInfo GetConnectionInfo (); } } diff --git a/mcs/class/Mono.Security/Mono.Security.Interface/MonoTlsProvider.cs b/mcs/class/Mono.Security/Mono.Security.Interface/MonoTlsProvider.cs index b1daa60e1fc..740d7953648 100644 --- a/mcs/class/Mono.Security/Mono.Security.Interface/MonoTlsProvider.cs +++ b/mcs/class/Mono.Security/Mono.Security.Interface/MonoTlsProvider.cs @@ -91,6 +91,13 @@ namespace Mono.Security.Interface get; } + /* + * Does this provider support IMonoSslStream.GetConnectionInfo() ? + */ + public abstract bool SupportsConnectionInfo { + get; + } + /* * Whether or not this TLS Provider supports Mono-specific extensions * (via @MonoTlsSettings). diff --git a/mcs/class/Mono.Security/Mono.Security.Interface/MonoTlsProviderFactory.cs b/mcs/class/Mono.Security/Mono.Security.Interface/MonoTlsProviderFactory.cs index 41ff61e243e..9548da030fe 100644 --- a/mcs/class/Mono.Security/Mono.Security.Interface/MonoTlsProviderFactory.cs +++ b/mcs/class/Mono.Security/Mono.Security.Interface/MonoTlsProviderFactory.cs @@ -25,8 +25,9 @@ // THE SOFTWARE. using System; using System.Net; -using Mono.Net.Security; +using System.Net.Security; using System.Security.Cryptography.X509Certificates; +using Mono.Net.Security; namespace Mono.Security.Interface { @@ -35,7 +36,7 @@ namespace Mono.Security.Interface * * Keep in sync with System/Mono.Net.Security/MonoTlsProviderFactory.cs. */ - public static class MonoTlsProviderFactory + public static partial class MonoTlsProviderFactory { /* * Returns the currently installed @MonoTlsProvider, falling back to the default one. @@ -97,6 +98,11 @@ namespace Mono.Security.Interface { return (HttpListener)NoReflectionHelper.CreateHttpListener (certificate, provider, settings); } + + public static IMonoSslStream GetMonoSslStream (SslStream stream) + { + return (IMonoSslStream)NoReflectionHelper.GetMonoSslStream (stream); + } } } diff --git a/mcs/class/Mono.Security/Mono.Security.Interface/MonoTlsSettings.cs b/mcs/class/Mono.Security/Mono.Security.Interface/MonoTlsSettings.cs index afa21ff1deb..7e42720d17c 100644 --- a/mcs/class/Mono.Security/Mono.Security.Interface/MonoTlsSettings.cs +++ b/mcs/class/Mono.Security/Mono.Security.Interface/MonoTlsSettings.cs @@ -94,7 +94,7 @@ namespace Mono.Security.Interface { } - volatile static MonoTlsSettings defaultSettings; + static MonoTlsSettings defaultSettings; public static MonoTlsSettings DefaultSettings { get { diff --git a/mcs/class/Mono.Security/Mono.Security.Protocol.Ntlm/Type3Message.cs b/mcs/class/Mono.Security/Mono.Security.Protocol.Ntlm/Type3Message.cs index 0855f8d6dd7..7472e719400 100644 --- a/mcs/class/Mono.Security/Mono.Security.Protocol.Ntlm/Type3Message.cs +++ b/mcs/class/Mono.Security/Mono.Security.Protocol.Ntlm/Type3Message.cs @@ -89,7 +89,7 @@ namespace Mono.Security.Protocol.Ntlm { public Type3Message (Type2Message type2) : base (3) { _type2 = type2; - _level = DefaultAuthLevel; + _level = NtlmSettings.DefaultAuthLevel; _challenge = (byte[]) type2.Nonce.Clone (); _domain = type2.TargetName; @@ -269,11 +269,13 @@ namespace Mono.Security.Protocol.Ntlm { throw new InvalidOperationException ( "Refusing to use legacy-mode LM/NTLM authentication " + "unless explicitly enabled using DefaultAuthLevel."); - + + #pragma warning disable 618 using (var legacy = new ChallengeResponse (_password, _challenge)) { lm = legacy.LM; ntlm = legacy.NT; } + #pragma warning restore 618 } else { ChallengeResponse2.Compute (_type2, _level, _username, _password, _domain, out lm, out ntlm); } diff --git a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientCertificate.cs b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientCertificate.cs index d59769b0a7e..f92ad900e84 100644 --- a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientCertificate.cs +++ b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientCertificate.cs @@ -131,6 +131,7 @@ namespace Mono.Security.Protocol.Tls.Handshake.Client private X509Certificate FindParentCertificate (X509Certificate cert) { + #pragma warning disable 618 // This certificate is the root certificate if (cert.GetName () == cert.GetIssuerName ()) return null; @@ -140,6 +141,7 @@ namespace Mono.Security.Protocol.Tls.Handshake.Client return certificate; } return null; + #pragma warning restore 618 } #endregion diff --git a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/RecordProtocol.cs b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/RecordProtocol.cs index e194013a637..30270c801c8 100644 --- a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/RecordProtocol.cs +++ b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/RecordProtocol.cs @@ -597,7 +597,7 @@ namespace Mono.Security.Protocol.Tls try { SendAlert(alert); } catch (Exception alertEx) { - ex = new IOException (string.Format ("Error while sending TLS Alert ({0}:{1}): {2}", alert.Level, alert.Description, ex), ex); + ex = new IOException (string.Format ("Error while sending TLS Alert ({0}:{1}): {2}", alert.Level, alert.Description, ex), alertEx); } } diff --git a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/ServerRecordProtocol.cs b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/ServerRecordProtocol.cs index b043f7e18cf..f8207297cb3 100644 --- a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/ServerRecordProtocol.cs +++ b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/ServerRecordProtocol.cs @@ -132,7 +132,6 @@ namespace Mono.Security.Protocol.Tls throw new TlsException(AlertDescription.UnexpectedMessage, String.Format(CultureInfo.CurrentUICulture, "Unknown server handshake message received ({0})", type.ToString())); - break; } throw new TlsException (AlertDescription.HandshakeFailiure, String.Format ("Protocol error, unexpected protocol transition from {0} to {1}", last, type)); } diff --git a/mcs/class/Mono.Security/mobile_Mono.Security.dll.sources b/mcs/class/Mono.Security/mobile_Mono.Security.dll.sources new file mode 100644 index 00000000000..dba5c340209 --- /dev/null +++ b/mcs/class/Mono.Security/mobile_Mono.Security.dll.sources @@ -0,0 +1,132 @@ +./Assembly/AssemblyInfo.cs +../../build/common/Consts.cs +../../build/common/Locale.cs +./Mono.Math/BigInteger.cs +./Mono.Math.Prime/ConfidenceFactor.cs +./Mono.Math.Prime/PrimalityTests.cs +./Mono.Math.Prime.Generator/NextPrimeFinder.cs +./Mono.Math.Prime.Generator/PrimeGeneratorBase.cs +./Mono.Math.Prime.Generator/SequentialSearchPrimeGeneratorBase.cs +./Mono.Security/ASN1.cs +./Mono.Security/ASN1Convert.cs +./Mono.Security/BitConverterLE.cs +./Mono.Security/PKCS7.cs +./Mono.Security/StrongName.cs +./Mono.Security.Authenticode/AuthenticodeBase.cs +./Mono.Security.Authenticode/AuthenticodeDeformatter.cs +./Mono.Security.Authenticode/AuthenticodeFormatter.cs +./Mono.Security.Authenticode/SoftwarePublisherCertificate.cs +./Mono.Security.Authenticode/PrivateKey.cs +./Mono.Security.Cryptography/CryptoConvert.cs +./Mono.Security.Cryptography/CryptoTools.cs +./Mono.Security.Cryptography/DHKeyGeneration.cs +./Mono.Security.Cryptography/DHParameters.cs +./Mono.Security.Cryptography/DiffieHellman.cs +./Mono.Security.Cryptography/DiffieHellmanManaged.cs +./Mono.Security.Cryptography/KeyPairPersistence.cs +./Mono.Security.Cryptography/MD2.cs +./Mono.Security.Cryptography/MD4.cs +./Mono.Security.Cryptography/PKCS1.cs +./Mono.Security.Cryptography/PKCS8.cs +./Mono.Security.Cryptography/RC4.cs +./Mono.Security.Cryptography/RSAManaged.cs +./Mono.Security.Cryptography/SHA224.cs +./Mono.Security.Cryptography/SymmetricTransform.cs +./Mono.Security.X509/PKCS12.cs +./Mono.Security.X509/X501Name.cs +./Mono.Security.X509/X509Builder.cs +./Mono.Security.X509/X509Certificate.cs +./Mono.Security.X509/X509CertificateCollection.cs +./Mono.Security.X509/X509CertificateBuilder.cs +./Mono.Security.X509/X509Chain.cs +./Mono.Security.X509/X509ChainStatusFlags.cs +./Mono.Security.X509/X509CRL.cs +./Mono.Security.X509/X509Extension.cs +./Mono.Security.X509/X509Extensions.cs +./Mono.Security.X509/X509Store.cs +./Mono.Security.X509/X509StoreManager.cs +./Mono.Security.X509/X509Stores.cs +./Mono.Security.X509/X520Attributes.cs +./Mono.Security.X509.Extensions/AuthorityKeyIdentifierExtension.cs +./Mono.Security.X509.Extensions/BasicConstraintsExtension.cs +./Mono.Security.X509.Extensions/CRLDistributionPointsExtension.cs +./Mono.Security.X509.Extensions/CertificatePoliciesExtension.cs +./Mono.Security.X509.Extensions/ExtendedKeyUsageExtension.cs +./Mono.Security.X509.Extensions/GeneralNames.cs +./Mono.Security.X509.Extensions/KeyAttributesExtension.cs +./Mono.Security.X509.Extensions/KeyUsageExtension.cs +./Mono.Security.X509.Extensions/NetscapeCertTypeExtension.cs +./Mono.Security.X509.Extensions/PrivateKeyUsagePeriodExtension.cs +./Mono.Security.X509.Extensions/SubjectAltNameExtension.cs +./Mono.Security.X509.Extensions/SubjectKeyIdentifierExtension.cs +./Mono.Security.Cryptography/TlsHMAC.cs +./Mono.Security.Cryptography/MD5SHA1.cs +./Mono.Security.Protocol.Ntlm/ChallengeResponse.cs +./Mono.Security.Protocol.Ntlm/ChallengeResponse2.cs +./Mono.Security.Protocol.Ntlm/MessageBase.cs +./Mono.Security.Protocol.Ntlm/NtlmAuthLevel.cs +./Mono.Security.Protocol.Ntlm/NtlmFlags.cs +./Mono.Security.Protocol.Ntlm/NtlmSettings.cs +./Mono.Security.Protocol.Ntlm/Type1Message.cs +./Mono.Security.Protocol.Ntlm/Type2Message.cs +./Mono.Security.Protocol.Ntlm/Type3Message.cs +./Mono.Security.Protocol.Tls/Alert.cs +./Mono.Security.Protocol.Tls/CipherAlgorithmType.cs +./Mono.Security.Protocol.Tls/CipherSuite.cs +./Mono.Security.Protocol.Tls/CipherSuiteCollection.cs +./Mono.Security.Protocol.Tls/CipherSuiteFactory.cs +./Mono.Security.Protocol.Tls/ClientContext.cs +./Mono.Security.Protocol.Tls/ClientRecordProtocol.cs +./Mono.Security.Protocol.Tls/ClientSessionCache.cs +./Mono.Security.Protocol.Tls/ContentType.cs +./Mono.Security.Protocol.Tls/Context.cs +./Mono.Security.Protocol.Tls/DebugHelper.cs +./Mono.Security.Protocol.Tls/ExchangeAlgorithmType.cs +./Mono.Security.Protocol.Tls/HandshakeState.cs +./Mono.Security.Protocol.Tls/HashAlgorithmType.cs +./Mono.Security.Protocol.Tls/HttpsClientStream.cs +./Mono.Security.Protocol.Tls/RecordProtocol.cs +./Mono.Security.Protocol.Tls/RSASslSignatureDeformatter.cs +./Mono.Security.Protocol.Tls/RSASslSignatureFormatter.cs +./Mono.Security.Protocol.Tls/SecurityCompressionType.cs +./Mono.Security.Protocol.Tls/SecurityParameters.cs +./Mono.Security.Protocol.Tls/SecurityProtocolType.cs +./Mono.Security.Protocol.Tls/ServerContext.cs +./Mono.Security.Protocol.Tls/ServerRecordProtocol.cs +./Mono.Security.Protocol.Tls/SslClientStream.cs +./Mono.Security.Protocol.Tls/SslCipherSuite.cs +./Mono.Security.Protocol.Tls/SslHandshakeHash.cs +./Mono.Security.Protocol.Tls/SslServerStream.cs +./Mono.Security.Protocol.Tls/SslStreamBase.cs +./Mono.Security.Protocol.Tls/TlsCipherSuite.cs +./Mono.Security.Protocol.Tls/TlsClientSettings.cs +./Mono.Security.Protocol.Tls/TlsException.cs +./Mono.Security.Protocol.Tls/TlsServerSettings.cs +./Mono.Security.Protocol.Tls/TlsStream.cs +./Mono.Security.Protocol.Tls.Handshake/ClientCertificateType.cs +./Mono.Security.Protocol.Tls.Handshake/HandshakeMessage.cs +./Mono.Security.Protocol.Tls.Handshake/HandshakeType.cs +./Mono.Security.Protocol.Tls.Handshake.Client/TlsClientCertificate.cs +./Mono.Security.Protocol.Tls.Handshake.Client/TlsClientCertificateVerify.cs +./Mono.Security.Protocol.Tls.Handshake.Client/TlsClientFinished.cs +./Mono.Security.Protocol.Tls.Handshake.Client/TlsClientHello.cs +./Mono.Security.Protocol.Tls.Handshake.Client/TlsClientKeyExchange.cs +./Mono.Security.Protocol.Tls.Handshake.Client/TlsServerCertificate.cs +./Mono.Security.Protocol.Tls.Handshake.Client/TlsServerCertificateRequest.cs +./Mono.Security.Protocol.Tls.Handshake.Client/TlsServerFinished.cs +./Mono.Security.Protocol.Tls.Handshake.Client/TlsServerHello.cs +./Mono.Security.Protocol.Tls.Handshake.Client/TlsServerHelloDone.cs +./Mono.Security.Protocol.Tls.Handshake.Client/TlsServerKeyExchange.cs +./Mono.Security.Protocol.Tls.Handshake.Server/TlsClientCertificate.cs +./Mono.Security.Protocol.Tls.Handshake.Server/TlsClientCertificateVerify.cs +./Mono.Security.Protocol.Tls.Handshake.Server/TlsClientFinished.cs +./Mono.Security.Protocol.Tls.Handshake.Server/TlsClientHello.cs +./Mono.Security.Protocol.Tls.Handshake.Server/TlsClientKeyExchange.cs +./Mono.Security.Protocol.Tls.Handshake.Server/TlsServerCertificate.cs +./Mono.Security.Protocol.Tls.Handshake.Server/TlsServerCertificateRequest.cs +./Mono.Security.Protocol.Tls.Handshake.Server/TlsServerFinished.cs +./Mono.Security.Protocol.Tls.Handshake.Server/TlsServerHello.cs +./Mono.Security.Protocol.Tls.Handshake.Server/TlsServerHelloDone.cs +./Mono.Security.Protocol.Tls.Handshake.Server/TlsServerKeyExchange.cs +./Mono.Xml/MiniParser.cs +./Mono.Xml/SecurityParser.cs diff --git a/mcs/class/Mono.Security/mobile_static_Mono.Security.dll.sources b/mcs/class/Mono.Security/mobile_static_Mono.Security.dll.sources new file mode 100644 index 00000000000..87eaa009cd8 --- /dev/null +++ b/mcs/class/Mono.Security/mobile_static_Mono.Security.dll.sources @@ -0,0 +1,5 @@ +#include mobile_Mono.Security.dll.sources +./Mono.Security.Cryptography/ARC4Managed.cs +./Mono.Security.Cryptography/MD2Managed.cs +./Mono.Security.Cryptography/MD4Managed.cs +./Mono.Security.Cryptography/SHA224Managed.cs diff --git a/mcs/class/Mono.Security/monodroid_Mono.Security.dll.sources b/mcs/class/Mono.Security/monodroid_Mono.Security.dll.sources index 91d7adf7113..87eaa009cd8 100644 --- a/mcs/class/Mono.Security/monodroid_Mono.Security.dll.sources +++ b/mcs/class/Mono.Security/monodroid_Mono.Security.dll.sources @@ -1,138 +1,5 @@ -./Assembly/AssemblyInfo.cs -../../build/common/Consts.cs -../../build/common/Locale.cs -./Mono.Math/BigInteger.cs -./Mono.Math.Prime/ConfidenceFactor.cs -./Mono.Math.Prime/PrimalityTests.cs -./Mono.Math.Prime.Generator/NextPrimeFinder.cs -./Mono.Math.Prime.Generator/PrimeGeneratorBase.cs -./Mono.Math.Prime.Generator/SequentialSearchPrimeGeneratorBase.cs -./Mono.Security/ASN1.cs -./Mono.Security/ASN1Convert.cs -./Mono.Security/BitConverterLE.cs -./Mono.Security/PKCS7.cs -./Mono.Security/StrongName.cs -./Mono.Security.Authenticode/AuthenticodeBase.cs -./Mono.Security.Authenticode/AuthenticodeDeformatter.cs -./Mono.Security.Authenticode/AuthenticodeFormatter.cs -./Mono.Security.Authenticode/SoftwarePublisherCertificate.cs -./Mono.Security.Authenticode/PrivateKey.cs +#include mobile_Mono.Security.dll.sources ./Mono.Security.Cryptography/ARC4Managed.cs -./Mono.Security.Cryptography/CryptoConvert.cs -./Mono.Security.Cryptography/CryptoTools.cs -./Mono.Security.Cryptography/DHKeyGeneration.cs -./Mono.Security.Cryptography/DHParameters.cs -./Mono.Security.Cryptography/DiffieHellman.cs -./Mono.Security.Cryptography/DiffieHellmanManaged.cs -./Mono.Security.Cryptography/KeyPairPersistence.cs -./Mono.Security.Cryptography/MD2.cs ./Mono.Security.Cryptography/MD2Managed.cs -./Mono.Security.Cryptography/MD4.cs ./Mono.Security.Cryptography/MD4Managed.cs -./Mono.Security.Cryptography/PKCS1.cs -./Mono.Security.Cryptography/PKCS8.cs -./Mono.Security.Cryptography/RC4.cs -./Mono.Security.Cryptography/RSAManaged.cs -./Mono.Security.Cryptography/SHA224.cs ./Mono.Security.Cryptography/SHA224Managed.cs -./Mono.Security.Cryptography/SymmetricTransform.cs -./Mono.Security.X509/PKCS12.cs -./Mono.Security.X509/X501Name.cs -./Mono.Security.X509/X509Builder.cs -./Mono.Security.X509/X509Certificate.cs -./Mono.Security.X509/X509CertificateCollection.cs -./Mono.Security.X509/X509CertificateBuilder.cs -./Mono.Security.X509/X509Chain.cs -./Mono.Security.X509/X509ChainStatusFlags.cs -./Mono.Security.X509/X509CRL.cs -./Mono.Security.X509/X509Extension.cs -./Mono.Security.X509/X509Extensions.cs -./Mono.Security.X509/X509Store.cs -./Mono.Security.X509/X509StoreManager.cs -./Mono.Security.X509/X509Stores.cs -./Mono.Security.X509/X520Attributes.cs -./Mono.Security.X509.Extensions/AuthorityKeyIdentifierExtension.cs -./Mono.Security.X509.Extensions/BasicConstraintsExtension.cs -./Mono.Security.X509.Extensions/CRLDistributionPointsExtension.cs -./Mono.Security.X509.Extensions/CertificatePoliciesExtension.cs -./Mono.Security.X509.Extensions/ExtendedKeyUsageExtension.cs -./Mono.Security.X509.Extensions/GeneralNames.cs -./Mono.Security.X509.Extensions/KeyAttributesExtension.cs -./Mono.Security.X509.Extensions/KeyUsageExtension.cs -./Mono.Security.X509.Extensions/NetscapeCertTypeExtension.cs -./Mono.Security.X509.Extensions/PrivateKeyUsagePeriodExtension.cs -./Mono.Security.X509.Extensions/SubjectAltNameExtension.cs -./Mono.Security.X509.Extensions/SubjectKeyIdentifierExtension.cs -./Mono.Security.Cryptography/TlsHMAC.cs -./Mono.Security.Cryptography/MD5SHA1.cs -./Mono.Security.Protocol.Ntlm/ChallengeResponse.cs -./Mono.Security.Protocol.Ntlm/ChallengeResponse2.cs -./Mono.Security.Protocol.Ntlm/MessageBase.cs -./Mono.Security.Protocol.Ntlm/NtlmAuthLevel.cs -./Mono.Security.Protocol.Ntlm/NtlmFlags.cs -./Mono.Security.Protocol.Ntlm/NtlmSettings.cs -./Mono.Security.Protocol.Ntlm/Type1Message.cs -./Mono.Security.Protocol.Ntlm/Type2Message.cs -./Mono.Security.Protocol.Ntlm/Type3Message.cs -./Mono.Security.Protocol.Tls/Alert.cs -./Mono.Security.Protocol.Tls/CipherAlgorithmType.cs -./Mono.Security.Protocol.Tls/CipherSuite.cs -./Mono.Security.Protocol.Tls/CipherSuiteCollection.cs -./Mono.Security.Protocol.Tls/CipherSuiteFactory.cs -./Mono.Security.Protocol.Tls/ClientContext.cs -./Mono.Security.Protocol.Tls/ClientRecordProtocol.cs -./Mono.Security.Protocol.Tls/ClientSessionCache.cs -./Mono.Security.Protocol.Tls/ContentType.cs -./Mono.Security.Protocol.Tls/Context.cs -./Mono.Security.Protocol.Tls/DebugHelper.cs -./Mono.Security.Protocol.Tls/ExchangeAlgorithmType.cs -./Mono.Security.Protocol.Tls/HandshakeState.cs -./Mono.Security.Protocol.Tls/HashAlgorithmType.cs -./Mono.Security.Protocol.Tls/HttpsClientStream.cs -./Mono.Security.Protocol.Tls/RecordProtocol.cs -./Mono.Security.Protocol.Tls/RSASslSignatureDeformatter.cs -./Mono.Security.Protocol.Tls/RSASslSignatureFormatter.cs -./Mono.Security.Protocol.Tls/SecurityCompressionType.cs -./Mono.Security.Protocol.Tls/SecurityParameters.cs -./Mono.Security.Protocol.Tls/SecurityProtocolType.cs -./Mono.Security.Protocol.Tls/ServerContext.cs -./Mono.Security.Protocol.Tls/ServerRecordProtocol.cs -./Mono.Security.Protocol.Tls/SslClientStream.cs -./Mono.Security.Protocol.Tls/SslCipherSuite.cs -./Mono.Security.Protocol.Tls/SslHandshakeHash.cs -./Mono.Security.Protocol.Tls/SslServerStream.cs -./Mono.Security.Protocol.Tls/SslStreamBase.cs -./Mono.Security.Protocol.Tls/TlsCipherSuite.cs -./Mono.Security.Protocol.Tls/TlsClientSettings.cs -./Mono.Security.Protocol.Tls/TlsException.cs -./Mono.Security.Protocol.Tls/TlsServerSettings.cs -./Mono.Security.Protocol.Tls/TlsStream.cs -./Mono.Security.Protocol.Tls.Handshake/ClientCertificateType.cs -./Mono.Security.Protocol.Tls.Handshake/HandshakeMessage.cs -./Mono.Security.Protocol.Tls.Handshake/HandshakeType.cs -./Mono.Security.Protocol.Tls.Handshake.Client/TlsClientCertificate.cs -./Mono.Security.Protocol.Tls.Handshake.Client/TlsClientCertificateVerify.cs -./Mono.Security.Protocol.Tls.Handshake.Client/TlsClientFinished.cs -./Mono.Security.Protocol.Tls.Handshake.Client/TlsClientHello.cs -./Mono.Security.Protocol.Tls.Handshake.Client/TlsClientKeyExchange.cs -./Mono.Security.Protocol.Tls.Handshake.Client/TlsServerCertificate.cs -./Mono.Security.Protocol.Tls.Handshake.Client/TlsServerCertificateRequest.cs -./Mono.Security.Protocol.Tls.Handshake.Client/TlsServerFinished.cs -./Mono.Security.Protocol.Tls.Handshake.Client/TlsServerHello.cs -./Mono.Security.Protocol.Tls.Handshake.Client/TlsServerHelloDone.cs -./Mono.Security.Protocol.Tls.Handshake.Client/TlsServerKeyExchange.cs -./Mono.Security.Protocol.Tls.Handshake.Server/TlsClientCertificate.cs -./Mono.Security.Protocol.Tls.Handshake.Server/TlsClientCertificateVerify.cs -./Mono.Security.Protocol.Tls.Handshake.Server/TlsClientFinished.cs -./Mono.Security.Protocol.Tls.Handshake.Server/TlsClientHello.cs -./Mono.Security.Protocol.Tls.Handshake.Server/TlsClientKeyExchange.cs -./Mono.Security.Protocol.Tls.Handshake.Server/TlsServerCertificate.cs -./Mono.Security.Protocol.Tls.Handshake.Server/TlsServerCertificateRequest.cs -./Mono.Security.Protocol.Tls.Handshake.Server/TlsServerFinished.cs -./Mono.Security.Protocol.Tls.Handshake.Server/TlsServerHello.cs -./Mono.Security.Protocol.Tls.Handshake.Server/TlsServerHelloDone.cs -./Mono.Security.Protocol.Tls.Handshake.Server/TlsServerKeyExchange.cs -./Mono.Xml/MiniParser.cs -./Mono.Xml/SecurityParser.cs - -./Mono.Security.Interface/CertificateValidationHelper.cs diff --git a/mcs/class/Mono.Security/monotouch_Mono.Security.dll.sources b/mcs/class/Mono.Security/monotouch_Mono.Security.dll.sources index 59a79a9684d..513dc61bd4f 100644 --- a/mcs/class/Mono.Security/monotouch_Mono.Security.dll.sources +++ b/mcs/class/Mono.Security/monotouch_Mono.Security.dll.sources @@ -1,134 +1 @@ -./Assembly/AssemblyInfo.cs -../../build/common/Consts.cs -../../build/common/Locale.cs -./Mono.Math/BigInteger.cs -./Mono.Math.Prime/ConfidenceFactor.cs -./Mono.Math.Prime/PrimalityTests.cs -./Mono.Math.Prime.Generator/NextPrimeFinder.cs -./Mono.Math.Prime.Generator/PrimeGeneratorBase.cs -./Mono.Math.Prime.Generator/SequentialSearchPrimeGeneratorBase.cs -./Mono.Security/ASN1.cs -./Mono.Security/ASN1Convert.cs -./Mono.Security/BitConverterLE.cs -./Mono.Security/PKCS7.cs -./Mono.Security/StrongName.cs -./Mono.Security.Authenticode/AuthenticodeBase.cs -./Mono.Security.Authenticode/AuthenticodeDeformatter.cs -./Mono.Security.Authenticode/AuthenticodeFormatter.cs -./Mono.Security.Authenticode/SoftwarePublisherCertificate.cs -./Mono.Security.Authenticode/PrivateKey.cs -./Mono.Security.Cryptography/CryptoConvert.cs -./Mono.Security.Cryptography/CryptoTools.cs -./Mono.Security.Cryptography/DHKeyGeneration.cs -./Mono.Security.Cryptography/DHParameters.cs -./Mono.Security.Cryptography/DiffieHellman.cs -./Mono.Security.Cryptography/DiffieHellmanManaged.cs -./Mono.Security.Cryptography/KeyPairPersistence.cs -./Mono.Security.Cryptography/MD2.cs -./Mono.Security.Cryptography/MD4.cs -./Mono.Security.Cryptography/PKCS1.cs -./Mono.Security.Cryptography/PKCS8.cs -./Mono.Security.Cryptography/RC4.cs -./Mono.Security.Cryptography/RSAManaged.cs -./Mono.Security.Cryptography/SHA224.cs -./Mono.Security.Cryptography/SymmetricTransform.cs -./Mono.Security.X509/PKCS12.cs -./Mono.Security.X509/X501Name.cs -./Mono.Security.X509/X509Builder.cs -./Mono.Security.X509/X509Certificate.cs -./Mono.Security.X509/X509CertificateCollection.cs -./Mono.Security.X509/X509CertificateBuilder.cs -./Mono.Security.X509/X509Chain.cs -./Mono.Security.X509/X509ChainStatusFlags.cs -./Mono.Security.X509/X509CRL.cs -./Mono.Security.X509/X509Extension.cs -./Mono.Security.X509/X509Extensions.cs -./Mono.Security.X509/X509Store.cs -./Mono.Security.X509/X509StoreManager.cs -./Mono.Security.X509/X509Stores.cs -./Mono.Security.X509/X520Attributes.cs -./Mono.Security.X509.Extensions/AuthorityKeyIdentifierExtension.cs -./Mono.Security.X509.Extensions/BasicConstraintsExtension.cs -./Mono.Security.X509.Extensions/CRLDistributionPointsExtension.cs -./Mono.Security.X509.Extensions/CertificatePoliciesExtension.cs -./Mono.Security.X509.Extensions/ExtendedKeyUsageExtension.cs -./Mono.Security.X509.Extensions/GeneralNames.cs -./Mono.Security.X509.Extensions/KeyAttributesExtension.cs -./Mono.Security.X509.Extensions/KeyUsageExtension.cs -./Mono.Security.X509.Extensions/NetscapeCertTypeExtension.cs -./Mono.Security.X509.Extensions/PrivateKeyUsagePeriodExtension.cs -./Mono.Security.X509.Extensions/SubjectAltNameExtension.cs -./Mono.Security.X509.Extensions/SubjectKeyIdentifierExtension.cs -./Mono.Security.Cryptography/TlsHMAC.cs -./Mono.Security.Cryptography/MD5SHA1.cs -./Mono.Security.Protocol.Ntlm/ChallengeResponse.cs -./Mono.Security.Protocol.Ntlm/ChallengeResponse2.cs -./Mono.Security.Protocol.Ntlm/MessageBase.cs -./Mono.Security.Protocol.Ntlm/NtlmAuthLevel.cs -./Mono.Security.Protocol.Ntlm/NtlmFlags.cs -./Mono.Security.Protocol.Ntlm/NtlmSettings.cs -./Mono.Security.Protocol.Ntlm/Type1Message.cs -./Mono.Security.Protocol.Ntlm/Type2Message.cs -./Mono.Security.Protocol.Ntlm/Type3Message.cs -./Mono.Security.Protocol.Tls/Alert.cs -./Mono.Security.Protocol.Tls/CipherAlgorithmType.cs -./Mono.Security.Protocol.Tls/CipherSuite.cs -./Mono.Security.Protocol.Tls/CipherSuiteCollection.cs -./Mono.Security.Protocol.Tls/CipherSuiteFactory.cs -./Mono.Security.Protocol.Tls/ClientContext.cs -./Mono.Security.Protocol.Tls/ClientRecordProtocol.cs -./Mono.Security.Protocol.Tls/ClientSessionCache.cs -./Mono.Security.Protocol.Tls/ContentType.cs -./Mono.Security.Protocol.Tls/Context.cs -./Mono.Security.Protocol.Tls/DebugHelper.cs -./Mono.Security.Protocol.Tls/ExchangeAlgorithmType.cs -./Mono.Security.Protocol.Tls/HandshakeState.cs -./Mono.Security.Protocol.Tls/HashAlgorithmType.cs -./Mono.Security.Protocol.Tls/HttpsClientStream.cs -./Mono.Security.Protocol.Tls/RecordProtocol.cs -./Mono.Security.Protocol.Tls/RSASslSignatureDeformatter.cs -./Mono.Security.Protocol.Tls/RSASslSignatureFormatter.cs -./Mono.Security.Protocol.Tls/SecurityCompressionType.cs -./Mono.Security.Protocol.Tls/SecurityParameters.cs -./Mono.Security.Protocol.Tls/SecurityProtocolType.cs -./Mono.Security.Protocol.Tls/ServerContext.cs -./Mono.Security.Protocol.Tls/ServerRecordProtocol.cs -./Mono.Security.Protocol.Tls/SslClientStream.cs -./Mono.Security.Protocol.Tls/SslCipherSuite.cs -./Mono.Security.Protocol.Tls/SslHandshakeHash.cs -./Mono.Security.Protocol.Tls/SslServerStream.cs -./Mono.Security.Protocol.Tls/SslStreamBase.cs -./Mono.Security.Protocol.Tls/TlsCipherSuite.cs -./Mono.Security.Protocol.Tls/TlsClientSettings.cs -./Mono.Security.Protocol.Tls/TlsException.cs -./Mono.Security.Protocol.Tls/TlsServerSettings.cs -./Mono.Security.Protocol.Tls/TlsStream.cs -./Mono.Security.Protocol.Tls.Handshake/ClientCertificateType.cs -./Mono.Security.Protocol.Tls.Handshake/HandshakeMessage.cs -./Mono.Security.Protocol.Tls.Handshake/HandshakeType.cs -./Mono.Security.Protocol.Tls.Handshake.Client/TlsClientCertificate.cs -./Mono.Security.Protocol.Tls.Handshake.Client/TlsClientCertificateVerify.cs -./Mono.Security.Protocol.Tls.Handshake.Client/TlsClientFinished.cs -./Mono.Security.Protocol.Tls.Handshake.Client/TlsClientHello.cs -./Mono.Security.Protocol.Tls.Handshake.Client/TlsClientKeyExchange.cs -./Mono.Security.Protocol.Tls.Handshake.Client/TlsServerCertificate.cs -./Mono.Security.Protocol.Tls.Handshake.Client/TlsServerCertificateRequest.cs -./Mono.Security.Protocol.Tls.Handshake.Client/TlsServerFinished.cs -./Mono.Security.Protocol.Tls.Handshake.Client/TlsServerHello.cs -./Mono.Security.Protocol.Tls.Handshake.Client/TlsServerHelloDone.cs -./Mono.Security.Protocol.Tls.Handshake.Client/TlsServerKeyExchange.cs -./Mono.Security.Protocol.Tls.Handshake.Server/TlsClientCertificate.cs -./Mono.Security.Protocol.Tls.Handshake.Server/TlsClientCertificateVerify.cs -./Mono.Security.Protocol.Tls.Handshake.Server/TlsClientFinished.cs -./Mono.Security.Protocol.Tls.Handshake.Server/TlsClientHello.cs -./Mono.Security.Protocol.Tls.Handshake.Server/TlsClientKeyExchange.cs -./Mono.Security.Protocol.Tls.Handshake.Server/TlsServerCertificate.cs -./Mono.Security.Protocol.Tls.Handshake.Server/TlsServerCertificateRequest.cs -./Mono.Security.Protocol.Tls.Handshake.Server/TlsServerFinished.cs -./Mono.Security.Protocol.Tls.Handshake.Server/TlsServerHello.cs -./Mono.Security.Protocol.Tls.Handshake.Server/TlsServerHelloDone.cs -./Mono.Security.Protocol.Tls.Handshake.Server/TlsServerKeyExchange.cs -./Mono.Xml/MiniParser.cs -./Mono.Xml/SecurityParser.cs - -./Mono.Security.Interface/CertificateValidationHelper.cs +#include mobile_Mono.Security.dll.sources diff --git a/mcs/class/Mono.Security/xammac_Mono.Security.dll.sources b/mcs/class/Mono.Security/xammac_Mono.Security.dll.sources index 4c67ff62a13..1379fa79d80 100644 --- a/mcs/class/Mono.Security/xammac_Mono.Security.dll.sources +++ b/mcs/class/Mono.Security/xammac_Mono.Security.dll.sources @@ -1,18 +1,2 @@ #include monotouch_Mono.Security.dll.sources -./Mono.Security.Interface/Alert.cs -./Mono.Security.Interface/CipherAlgorithmType.cs -./Mono.Security.Interface/CipherSuiteCode.cs -./Mono.Security.Interface/ExchangeAlgorithmType.cs -./Mono.Security.Interface/HashAlgorithmType.cs -./Mono.Security.Interface/IBufferOffsetSize.cs -./Mono.Security.Interface/IMonoTlsEventSink.cs -./Mono.Security.Interface/IMonoTlsContext.cs -./Mono.Security.Interface/IMonoSslStream.cs -./Mono.Security.Interface/MonoTlsConnectionInfo.cs -./Mono.Security.Interface/MonoTlsProvider.cs -./Mono.Security.Interface/MonoTlsProviderFactory.cs -./Mono.Security.Interface/MonoTlsSettings.cs -./Mono.Security.Interface/TlsException.cs -./Mono.Security.Interface/TlsProtocolCode.cs -./Mono.Security.Interface/TlsProtocols.cs diff --git a/mcs/class/System.ServiceModel.Internals/Makefile b/mcs/class/System.ServiceModel.Internals/Makefile index 24b5d2fc2e9..2ddf10ebd26 100644 --- a/mcs/class/System.ServiceModel.Internals/Makefile +++ b/mcs/class/System.ServiceModel.Internals/Makefile @@ -2,12 +2,16 @@ thisdir = class/System.ServiceModel.Internals SUBDIRS = include ../../build/rules.make +ifndef NO_MULTIPLE_APPDOMAINS +REFERENCE_SOURCES_FLAGS += -d:MONO_FEATURE_MULTIPLE_APPDOMAINS +endif + LIBRARY = System.ServiceModel.Internals.dll LIB_REFS = System System.Core System.Xml ifneq (2.1, $(FRAMEWORK_VERSION)) LIB_REFS += System.Configuration endif -LIB_MCS_FLAGS = /unsafe +LIB_MCS_FLAGS = /unsafe $(REFERENCE_SOURCES_FLAGS) TEST_MCS_FLAGS = $(LIB_MCS_FLAGS) diff --git a/mcs/class/System.ServiceModel.Web/System.ServiceModel/WebHttpBinding.cs b/mcs/class/System.ServiceModel.Web/System.ServiceModel/WebHttpBinding.cs index fc8a065f5ae..8eee88bb876 100644 --- a/mcs/class/System.ServiceModel.Web/System.ServiceModel/WebHttpBinding.cs +++ b/mcs/class/System.ServiceModel.Web/System.ServiceModel/WebHttpBinding.cs @@ -158,7 +158,7 @@ namespace System.ServiceModel } public override string Scheme { - get { return Security.Mode != WebHttpSecurityMode.None ? Uri.UriSchemeHttps : Uri.UriSchemeHttp; } + get { return Security.Mode == WebHttpSecurityMode.Transport ? Uri.UriSchemeHttps : Uri.UriSchemeHttp; } } public WebHttpSecurity Security { diff --git a/mcs/class/System.ServiceModel.Web/Test/System.ServiceModel/WebHttpBindingTest.cs b/mcs/class/System.ServiceModel.Web/Test/System.ServiceModel/WebHttpBindingTest.cs index 1c0c0077ce8..b4a016a26f4 100644 --- a/mcs/class/System.ServiceModel.Web/Test/System.ServiceModel/WebHttpBindingTest.cs +++ b/mcs/class/System.ServiceModel.Web/Test/System.ServiceModel/WebHttpBindingTest.cs @@ -32,5 +32,15 @@ namespace MonoTests.System.ServiceModel Assert.AreEqual (typeof (WebMessageEncodingBindingElement), bc [0].GetType (), "#2"); Assert.AreEqual (typeof (HttpTransportBindingElement), bc [1].GetType (), "#3"); } + + [Test] + public void DefaultSchemeBasedOnSecurityMode () + { + WebHttpBinding b = new WebHttpBinding(WebHttpSecurityMode.TransportCredentialOnly); + Assert.AreEqual("http", b.Scheme, "#1"); + + b = new WebHttpBinding(WebHttpSecurityMode.Transport); + Assert.AreEqual("https", b.Scheme, "#2"); + } } } diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels.Http/HttpListenerManager.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels.Http/HttpListenerManager.cs index b3c3fe2c85d..5ccee0a2605 100644 --- a/mcs/class/System.ServiceModel/System.ServiceModel.Channels.Http/HttpListenerManager.cs +++ b/mcs/class/System.ServiceModel/System.ServiceModel.Channels.Http/HttpListenerManager.cs @@ -48,24 +48,29 @@ namespace System.ServiceModel.Channels.Http Entries = new List (); } - public List Entries { get; private set; } + protected List Entries { get; private set; } + object entries_lock = new object (); public abstract void RegisterListener (ChannelDispatcher channel, HttpTransportBindingElement element, TimeSpan timeout); public abstract void UnregisterListener (ChannelDispatcher channel, TimeSpan timeout); protected void RegisterListenerCommon (ChannelDispatcher channel, TimeSpan timeout) { - Entries.Add (new HttpChannelListenerEntry (channel, new AutoResetEvent (false))); + lock (entries_lock) { + Entries.Add (new HttpChannelListenerEntry (channel, new AutoResetEvent (false))); - Entries.Sort (HttpChannelListenerEntry.CompareEntries); + Entries.Sort (HttpChannelListenerEntry.CompareEntries); + } } protected void UnregisterListenerCommon (ChannelDispatcher channel, TimeSpan timeout) { - var entry = Entries.First (e => e.ChannelDispatcher == channel); - Entries.Remove (entry); + lock (entries_lock) { + var entry = Entries.First (e => e.ChannelDispatcher == channel); + Entries.Remove (entry); - entry.WaitHandle.Set (); // make sure to finish pending requests. + entry.WaitHandle.Set (); // make sure to finish pending requests. + } } public void ProcessNewContext (HttpContextInfo ctxi) @@ -79,9 +84,11 @@ namespace System.ServiceModel.Channels.Http HttpChannelListenerEntry SelectChannel (HttpContextInfo ctx) { - foreach (var e in Entries) - if (e.FilterHttpContext (ctx)) - return e; + lock (entries_lock) { + foreach (var e in Entries) + if (e.FilterHttpContext (ctx)) + return e; + } return null; } @@ -90,7 +97,10 @@ namespace System.ServiceModel.Channels.Http DateTime start = DateTime.Now; context = null; - var ce = Entries.FirstOrDefault (e => e.ChannelDispatcher == channel); + HttpChannelListenerEntry ce = null; + lock (entries_lock) { + ce = Entries.FirstOrDefault (e => e.ChannelDispatcher == channel); + } if (ce == null) return false; lock (ce.RetrieverLock) { diff --git a/mcs/class/System.Web/Test/System.Web.UI.WebControls/WizardStepBaseTest.cs b/mcs/class/System.Web/Test/System.Web.UI.WebControls/WizardStepBaseTest.cs index 03f41d9dbbc..c91f3cbf402 100644 --- a/mcs/class/System.Web/Test/System.Web.UI.WebControls/WizardStepBaseTest.cs +++ b/mcs/class/System.Web/Test/System.Web.UI.WebControls/WizardStepBaseTest.cs @@ -308,7 +308,7 @@ namespace MonoTests.System.Web.UI.WebControls [Category ("NunitWeb")] public void WizardStepBase_Theme () { - WebTest.CopyResource (GetType (), "WizardTest.skin", "App_Themes/Theme1/WizardTest.skin"); + WebTest.CopyResource (GetType (), "WizardTest.skin", "App_Themes/WizardStepBase/WizardTest.skin"); WebTest t = new WebTest (); PageDelegates pd = new PageDelegates (); pd.PreInit = set_properties; @@ -328,7 +328,7 @@ namespace MonoTests.System.Web.UI.WebControls public static void set_properties (Page p) { - p.Theme = "Theme1"; + p.Theme = "WizardStepBase"; } public static void theme (Page p) diff --git a/mcs/class/System/Makefile b/mcs/class/System/Makefile index 5f52ecca391..9fcb2397d1c 100644 --- a/mcs/class/System/Makefile +++ b/mcs/class/System/Makefile @@ -44,15 +44,10 @@ endif RESOURCE_STRINGS = ../../../external/referencesource/System/System.txt # -# MOBILE_PROFILE needs SECURITY_DEP, except for XAMMAC +# MOBILE_PROFILE needs SECURITY_DEP # ifdef MOBILE_PROFILE -ifeq ($(PROFILE),xammac) -EXTERN_ALIAS_FLAGS = -d:MONO_SECURITY_ALIAS -d:MONO_X509_ALIAS -LIB_MCS_FLAGS += -d:INSIDE_SYSTEM -else LIB_MCS_FLAGS += -d:INSIDE_SYSTEM -d:SECURITY_DEP -endif else EXTERN_ALIAS_FLAGS = -d:MONO_SECURITY_ALIAS -d:MONO_X509_ALIAS FINAL_MCS_FLAGS = -r:System.Configuration.dll -d:CONFIGURATION_DEP diff --git a/mcs/class/System/Mono.Http/NtlmClient.cs b/mcs/class/System/Mono.Http/NtlmClient.cs index b40d601b4b1..00036654b1c 100644 --- a/mcs/class/System/Mono.Http/NtlmClient.cs +++ b/mcs/class/System/Mono.Http/NtlmClient.cs @@ -30,11 +30,11 @@ #if SECURITY_DEP -#if MONOTOUCH || MONODROID -using Mono.Security.Protocol.Ntlm; -#else +#if MONO_SECURITY_ALIAS extern alias MonoSecurity; using MonoSecurity::Mono.Security.Protocol.Ntlm; +#else +using Mono.Security.Protocol.Ntlm; #endif using System; diff --git a/mcs/class/System/Mono.Net.Security/ChainValidationHelper.cs b/mcs/class/System/Mono.Net.Security/ChainValidationHelper.cs index 1f37bc47589..224c4e3c315 100644 --- a/mcs/class/System/Mono.Net.Security/ChainValidationHelper.cs +++ b/mcs/class/System/Mono.Net.Security/ChainValidationHelper.cs @@ -85,37 +85,6 @@ namespace Mono.Net.Security readonly MonoTlsStream tlsStream; readonly HttpWebRequest request; - static bool is_macosx; - static bool is_mobile; -#if !MOBILE - static X509RevocationMode revocation_mode; -#endif - - static ChainValidationHelper () - { -#if MONOTOUCH - is_macosx = true; - is_mobile = true; -#elif MONODROID - is_macosx = false; - is_mobile = true; -#else - is_macosx = System.IO.File.Exists (OSX509Certificates.SecurityLibrary); - is_mobile = false; -#endif - -#if !MOBILE - revocation_mode = X509RevocationMode.NoCheck; - try { - string str = Environment.GetEnvironmentVariable ("MONO_X509_REVOCATION_MODE"); - if (String.IsNullOrEmpty (str)) - return; - revocation_mode = (X509RevocationMode)Enum.Parse (typeof(X509RevocationMode), str, true); - } catch { - } -#endif - } - internal static ICertificateValidator GetDefaultValidator (MonoTlsProvider provider, MonoTlsSettings settings) { if (settings == null) diff --git a/mcs/class/System/Mono.Net.Security/IMonoSslStream.cs b/mcs/class/System/Mono.Net.Security/IMonoSslStream.cs index 471cfae0582..50193cc2ec1 100644 --- a/mcs/class/System/Mono.Net.Security/IMonoSslStream.cs +++ b/mcs/class/System/Mono.Net.Security/IMonoSslStream.cs @@ -24,10 +24,23 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -#if SECURITY_DEP && MONO_X509_ALIAS +#if SECURITY_DEP +#if MONO_X509_ALIAS extern alias PrebuiltSystem; +#endif +#if MONO_SECURITY_ALIAS +extern alias MonoSecurity; +#endif + +#if MONO_X509_ALIAS using X509CertificateCollection = PrebuiltSystem::System.Security.Cryptography.X509Certificates.X509CertificateCollection; #endif +#if MONO_SECURITY_ALIAS +using MSI = MonoSecurity::Mono.Security.Interface; +#else +using MSI = Mono.Security.Interface; +#endif +#endif using System; using System.IO; @@ -214,6 +227,13 @@ namespace Mono.Net.Security IAsyncResult BeginWrite (byte[] buffer, int offset, int count, AsyncCallback asyncCallback, object asyncState); void EndWrite (IAsyncResult asyncResult); + +#if SECURITY_DEP + MSI.MonoTlsProvider Provider { + get; + } + + MSI.MonoTlsConnectionInfo GetConnectionInfo (); +#endif } } - diff --git a/mcs/class/System/Mono.Net.Security/LegacySslStream.cs b/mcs/class/System/Mono.Net.Security/LegacySslStream.cs index 4a7b792ea70..ab0bc518974 100644 --- a/mcs/class/System/Mono.Net.Security/LegacySslStream.cs +++ b/mcs/class/System/Mono.Net.Security/LegacySslStream.cs @@ -75,17 +75,19 @@ using System.Security.Cryptography; using System.Threading.Tasks; -namespace Mono.Net.Security +namespace Mono.Net.Security.Private { + /* + * Strictly private - do not use outside the Mono.Net.Security directory. + */ [MonoTODO ("Non-X509Certificate2 certificate is not supported")] internal class LegacySslStream : AuthenticatedStream, IMonoSslStream { #region Fields SslStreamBase ssl_stream; - MonoTlsProvider provider; - MonoTlsSettings settings; ICertificateValidator certificateValidator; + MonoTlsProvider provider; #endregion // Fields @@ -95,8 +97,7 @@ namespace Mono.Net.Security : base (innerStream, leaveInnerStreamOpen) { this.provider = provider; - this.settings = settings; - this.certificateValidator = ChainValidationHelper.GetDefaultValidator (provider, settings); + certificateValidator = ChainValidationHelper.GetDefaultValidator (provider, settings); } #endregion // Constructors @@ -586,6 +587,15 @@ namespace Mono.Net.Security get { throw new NotSupportedException (); } } + MonoTlsProvider IMonoSslStream.Provider { + get { return provider; } + } + + MonoTlsConnectionInfo IMonoSslStream.GetConnectionInfo () + { + return null; + } + #endregion } } diff --git a/mcs/class/System/Mono.Net.Security/MonoDefaultTlsProvider.cs b/mcs/class/System/Mono.Net.Security/MonoDefaultTlsProvider.cs index 4051b1502dc..c39b2144781 100644 --- a/mcs/class/System/Mono.Net.Security/MonoDefaultTlsProvider.cs +++ b/mcs/class/System/Mono.Net.Security/MonoDefaultTlsProvider.cs @@ -78,6 +78,10 @@ namespace Mono.Net.Security.Private get { return true; } } + public override bool SupportsConnectionInfo { + get { return false; } + } + public override bool SupportsMonoExtensions { get { return false; } } diff --git a/mcs/class/System/Mono.Net.Security/MonoSslStreamImpl.cs b/mcs/class/System/Mono.Net.Security/MonoSslStreamImpl.cs index 999a8868ab6..dfb5c8c450a 100644 --- a/mcs/class/System/Mono.Net.Security/MonoSslStreamImpl.cs +++ b/mcs/class/System/Mono.Net.Security/MonoSslStreamImpl.cs @@ -70,8 +70,11 @@ using System.Security.Cryptography.X509Certificates; using System.Security.Principal; using System.Security.Cryptography; -namespace Mono.Net.Security +namespace Mono.Net.Security.Private { + /* + * Strictly private - do not use outside the Mono.Net.Security directory. + */ class MonoSslStreamImpl : MSI.IMonoSslStream { IMonoSslStream impl; @@ -305,6 +308,15 @@ namespace Mono.Net.Security get { return (XSslProtocols)Impl.SslProtocol; } } + public MSI.MonoTlsProvider Provider { + get { return Impl.Provider; } + } + + public MSI.MonoTlsConnectionInfo GetConnectionInfo () + { + return Impl.GetConnectionInfo (); + } + void CheckDisposed () { if (impl == null) diff --git a/mcs/class/System/Mono.Net.Security/MonoSslStreamWrapper.cs b/mcs/class/System/Mono.Net.Security/MonoSslStreamWrapper.cs index d04383dced1..92f88fe1e05 100644 --- a/mcs/class/System/Mono.Net.Security/MonoSslStreamWrapper.cs +++ b/mcs/class/System/Mono.Net.Security/MonoSslStreamWrapper.cs @@ -296,6 +296,15 @@ namespace Mono.Net.Security.Private get { return (SslProtocols)Impl.SslProtocol; } } + public MSI.MonoTlsProvider Provider { + get { return Impl.Provider; } + } + + public MSI.MonoTlsConnectionInfo GetConnectionInfo () + { + return Impl.GetConnectionInfo (); + } + void CheckDisposed () { if (impl == null) diff --git a/mcs/class/System/Mono.Net.Security/MonoTlsProviderFactory.cs b/mcs/class/System/Mono.Net.Security/MonoTlsProviderFactory.cs index 1f066e1fcfe..85023644aee 100644 --- a/mcs/class/System/Mono.Net.Security/MonoTlsProviderFactory.cs +++ b/mcs/class/System/Mono.Net.Security/MonoTlsProviderFactory.cs @@ -50,7 +50,7 @@ namespace Mono.Net.Security * Keep in sync with Mono.Security/Mono.Security.Interface/MonoTlsProvider.cs. * */ - static class MonoTlsProviderFactory + static partial class MonoTlsProviderFactory { #region Internal API @@ -101,6 +101,7 @@ namespace Mono.Net.Security } } +#if MONO_FEATURE_NEW_SYSTEM_SOURCE || (!MONOTOUCH && !XAMMAC) static IMonoTlsProvider CreateDefaultProvider () { #if SECURITY_DEP @@ -123,6 +124,7 @@ namespace Mono.Net.Security return null; #endif } +#endif static object locker = new object (); static IMonoTlsProvider defaultProvider; diff --git a/mcs/class/System/Mono.Net.Security/NoReflectionHelper.cs b/mcs/class/System/Mono.Net.Security/NoReflectionHelper.cs index baf83f33e9f..f4ccac81cb0 100644 --- a/mcs/class/System/Mono.Net.Security/NoReflectionHelper.cs +++ b/mcs/class/System/Mono.Net.Security/NoReflectionHelper.cs @@ -38,6 +38,7 @@ using System.Security.Cryptography.X509Certificates; using System; using System.Net; +using System.Net.Security; namespace Mono.Net.Security { @@ -109,5 +110,15 @@ namespace Mono.Net.Security throw new NotSupportedException (); #endif } + + internal static object GetMonoSslStream (SslStream stream) + { + #if SECURITY_DEP + return stream.Impl; + #else + throw new NotSupportedException (); + #endif + } + } } diff --git a/mcs/class/System/Mono.Net.Security/SystemCertificateValidator.cs b/mcs/class/System/Mono.Net.Security/SystemCertificateValidator.cs index 762c74aba1a..f0a0be39e0e 100644 --- a/mcs/class/System/Mono.Net.Security/SystemCertificateValidator.cs +++ b/mcs/class/System/Mono.Net.Security/SystemCertificateValidator.cs @@ -44,7 +44,6 @@ namespace Mono.Net.Security internal static class SystemCertificateValidator { static bool is_macosx; - static bool is_mobile; #if !MOBILE static X509RevocationMode revocation_mode; #endif @@ -53,13 +52,10 @@ namespace Mono.Net.Security { #if MONOTOUCH is_macosx = true; - is_mobile = true; #elif MONODROID is_macosx = false; - is_mobile = true; #else is_macosx = System.IO.File.Exists (OSX509Certificates.SecurityLibrary); - is_mobile = false; #endif #if !MOBILE diff --git a/mcs/class/System/System.Diagnostics/Process.cs b/mcs/class/System/System.Diagnostics/Process.cs index b46bc936c1d..8c6fa0dcf4f 100644 --- a/mcs/class/System/System.Diagnostics/Process.cs +++ b/mcs/class/System/System.Diagnostics/Process.cs @@ -1288,7 +1288,8 @@ namespace System.Diagnostics { async_error.AsyncWaitHandle.WaitOne (); #endif // MONO_FEATURE_PROCESS_START - OnExited (); + if (EnableRaisingEvents) + OnExited (); return true; } diff --git a/mcs/class/System/System.Net.NetworkInformation/IPGlobalProperties.cs b/mcs/class/System/System.Net.NetworkInformation/IPGlobalProperties.cs index 9ff24cf7f10..b22a33c9ad5 100644 --- a/mcs/class/System/System.Net.NetworkInformation/IPGlobalProperties.cs +++ b/mcs/class/System/System.Net.NetworkInformation/IPGlobalProperties.cs @@ -46,7 +46,7 @@ namespace System.Net.NetworkInformation { { #if MONODROID return new AndroidIPGlobalProperties (); -#elif MONOTOUCH || XAMMAC +#elif MONOTOUCH || XAMMAC || MOBILE_STATIC return new UnixIPGlobalProperties (); #else switch (Environment.OSVersion.Platform) { diff --git a/mcs/class/System/System.Net.NetworkInformation/NetworkInterface.cs b/mcs/class/System/System.Net.NetworkInformation/NetworkInterface.cs index 2177ecf43c2..27927a81f61 100644 --- a/mcs/class/System/System.Net.NetworkInformation/NetworkInterface.cs +++ b/mcs/class/System/System.Net.NetworkInformation/NetworkInterface.cs @@ -516,7 +516,7 @@ namespace System.Net.NetworkInformation { return new LinuxNetworkInterfaceAPI (); } -#if !MONODROID +#if !MOBILE if (Environment.OSVersion.Version >= windowsVer51) return new Win32NetworkInterfaceAPI (); #endif diff --git a/mcs/class/System/System.Net.Security/SslStream.cs b/mcs/class/System/System.Net.Security/SslStream.cs index 281c6fa7016..53e6d291857 100644 --- a/mcs/class/System/System.Net.Security/SslStream.cs +++ b/mcs/class/System/System.Net.Security/SslStream.cs @@ -24,7 +24,8 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -#if SECURITY_DEP && !MONO_FEATURE_NEW_TLS +#if !MONO_FEATURE_NEW_TLS +#if SECURITY_DEP #if MONO_X509_ALIAS extern alias PrebuiltSystem; @@ -394,7 +395,24 @@ namespace System.Net.Security AuthenticatedStream MNS.IMonoSslStream.AuthenticatedStream { get { return this; } } + + MonoTlsProvider MNS.IMonoSslStream.Provider { + get { return provider; } + } + + MonoTlsConnectionInfo MNS.IMonoSslStream.GetConnectionInfo () + { + return Impl.GetConnectionInfo (); + } } } +#else // !SECURITY_DEP +namespace System.Net.Security +{ + public class SslStream + { + } +} +#endif #endif diff --git a/mcs/class/System/System.Net/EndPointListener.cs b/mcs/class/System/System.Net/EndPointListener.cs index 8080354f806..9726b91358b 100644 --- a/mcs/class/System/System.Net/EndPointListener.cs +++ b/mcs/class/System/System.Net/EndPointListener.cs @@ -29,11 +29,11 @@ #if SECURITY_DEP -#if MONOTOUCH || MONODROID -using Mono.Security.Authenticode; -#else +#if MONO_SECURITY_ALIAS extern alias MonoSecurity; using MonoSecurity::Mono.Security.Authenticode; +#else +using Mono.Security.Authenticode; #endif using System.IO; diff --git a/mcs/class/System/System.Security.Cryptography.X509Certificates/PublicKey.cs b/mcs/class/System/System.Security.Cryptography.X509Certificates/PublicKey.cs index 007db0a6ac3..15641f26421 100644 --- a/mcs/class/System/System.Security.Cryptography.X509Certificates/PublicKey.cs +++ b/mcs/class/System/System.Security.Cryptography.X509Certificates/PublicKey.cs @@ -31,15 +31,15 @@ #if SECURITY_DEP -#if MONOTOUCH || MONODROID -using Mono.Security; -using Mono.Security.Cryptography; -using MSX = Mono.Security.X509; -#else +#if MONO_SECURITY_ALIAS extern alias MonoSecurity; using MonoSecurity::Mono.Security; using MonoSecurity::Mono.Security.Cryptography; using MSX = MonoSecurity::Mono.Security.X509; +#else +using Mono.Security; +using Mono.Security.Cryptography; +using MSX = Mono.Security.X509; #endif namespace System.Security.Cryptography.X509Certificates { diff --git a/mcs/class/System/System.Security.Cryptography.X509Certificates/X500DistinguishedName.cs b/mcs/class/System/System.Security.Cryptography.X509Certificates/X500DistinguishedName.cs index f072f7759a4..0681e9eb5d7 100644 --- a/mcs/class/System/System.Security.Cryptography.X509Certificates/X500DistinguishedName.cs +++ b/mcs/class/System/System.Security.Cryptography.X509Certificates/X500DistinguishedName.cs @@ -28,13 +28,13 @@ #if SECURITY_DEP -#if MONOTOUCH || MONODROID -using Mono.Security; -using MX = Mono.Security.X509; -#else +#if MONO_SECURITY_ALIAS extern alias MonoSecurity; using MonoSecurity::Mono.Security; using MX = MonoSecurity::Mono.Security.X509; +#else +using Mono.Security; +using MX = Mono.Security.X509; #endif using System.Collections; diff --git a/mcs/class/System/System.Security.Cryptography.X509Certificates/X509BasicConstraintsExtension.cs b/mcs/class/System/System.Security.Cryptography.X509Certificates/X509BasicConstraintsExtension.cs index 1b9c70a588f..d2a9b316c4b 100644 --- a/mcs/class/System/System.Security.Cryptography.X509Certificates/X509BasicConstraintsExtension.cs +++ b/mcs/class/System/System.Security.Cryptography.X509Certificates/X509BasicConstraintsExtension.cs @@ -31,11 +31,11 @@ #if SECURITY_DEP -#if MONOTOUCH || MONODROID -using Mono.Security; -#else +#if MONO_SECURITY_ALIAS extern alias MonoSecurity; using MonoSecurity::Mono.Security; +#else +using Mono.Security; #endif using System.Text; diff --git a/mcs/class/System/System.Security.Cryptography.X509Certificates/X509Certificate2.cs b/mcs/class/System/System.Security.Cryptography.X509Certificates/X509Certificate2.cs index fd26add2fe2..afb81cb1ab7 100644 --- a/mcs/class/System/System.Security.Cryptography.X509Certificates/X509Certificate2.cs +++ b/mcs/class/System/System.Security.Cryptography.X509Certificates/X509Certificate2.cs @@ -29,16 +29,15 @@ #if SECURITY_DEP -#if MONOTOUCH || MONODROID -using Mono.Security; -using Mono.Security.Cryptography; -using MX = Mono.Security.X509; -#else +#if MONO_SECURITY_ALIAS extern alias MonoSecurity; - using MonoSecurity::Mono.Security; using MonoSecurity::Mono.Security.Cryptography; using MX = MonoSecurity::Mono.Security.X509; +#else +using Mono.Security; +using Mono.Security.Cryptography; +using MX = Mono.Security.X509; #endif #endif diff --git a/mcs/class/System/System.Security.Cryptography.X509Certificates/X509Chain.cs b/mcs/class/System/System.Security.Cryptography.X509Certificates/X509Chain.cs index 7dfb699ef34..9910f398270 100644 --- a/mcs/class/System/System.Security.Cryptography.X509Certificates/X509Chain.cs +++ b/mcs/class/System/System.Security.Cryptography.X509Certificates/X509Chain.cs @@ -30,11 +30,11 @@ #if SECURITY_DEP -#if MONOTOUCH || MONODROID -using MX = Mono.Security.X509; -#else +#if MONO_SECURITY_ALIAS extern alias MonoSecurity; using MX = MonoSecurity::Mono.Security.X509; +#else +using MX = Mono.Security.X509; #endif using System.Collections; diff --git a/mcs/class/System/System.Security.Cryptography.X509Certificates/X509EnhancedKeyUsageExtension.cs b/mcs/class/System/System.Security.Cryptography.X509Certificates/X509EnhancedKeyUsageExtension.cs index 1312a99d86b..92007a397d4 100644 --- a/mcs/class/System/System.Security.Cryptography.X509Certificates/X509EnhancedKeyUsageExtension.cs +++ b/mcs/class/System/System.Security.Cryptography.X509Certificates/X509EnhancedKeyUsageExtension.cs @@ -28,11 +28,11 @@ #if SECURITY_DEP -#if MONOTOUCH || MONODROID -using Mono.Security; -#else +#if MONO_SECURITY_ALIAS extern alias MonoSecurity; using MonoSecurity::Mono.Security; +#else +using Mono.Security; #endif using System.Text; diff --git a/mcs/class/System/System.Security.Cryptography.X509Certificates/X509ExtensionCollection.cs b/mcs/class/System/System.Security.Cryptography.X509Certificates/X509ExtensionCollection.cs index e7f098dbdf1..704b3d3749f 100644 --- a/mcs/class/System/System.Security.Cryptography.X509Certificates/X509ExtensionCollection.cs +++ b/mcs/class/System/System.Security.Cryptography.X509Certificates/X509ExtensionCollection.cs @@ -31,13 +31,13 @@ #if SECURITY_DEP -#if MONOTOUCH || MONODROID -using Mono.Security; -using MX = Mono.Security.X509; -#else +#if MONO_SECURITY_ALIAS extern alias MonoSecurity; using MonoSecurity::Mono.Security; using MX = MonoSecurity::Mono.Security.X509; +#else +using Mono.Security; +using MX = Mono.Security.X509; #endif using System.Collections; diff --git a/mcs/class/System/System.Security.Cryptography.X509Certificates/X509KeyUsageExtension.cs b/mcs/class/System/System.Security.Cryptography.X509Certificates/X509KeyUsageExtension.cs index a4b2af18ee0..15de9f7b3cc 100644 --- a/mcs/class/System/System.Security.Cryptography.X509Certificates/X509KeyUsageExtension.cs +++ b/mcs/class/System/System.Security.Cryptography.X509Certificates/X509KeyUsageExtension.cs @@ -30,11 +30,11 @@ #if SECURITY_DEP -#if MONOTOUCH || MONODROID -using Mono.Security; -#else +#if MONO_SECURITY_ALIAS extern alias MonoSecurity; using MonoSecurity::Mono.Security; +#else +using Mono.Security; #endif using System.Text; diff --git a/mcs/class/System/System.Security.Cryptography.X509Certificates/X509Store.cs b/mcs/class/System/System.Security.Cryptography.X509Certificates/X509Store.cs index 02de8cec747..42b6c6e3d44 100644 --- a/mcs/class/System/System.Security.Cryptography.X509Certificates/X509Store.cs +++ b/mcs/class/System/System.Security.Cryptography.X509Certificates/X509Store.cs @@ -29,11 +29,11 @@ #if SECURITY_DEP -#if MONOTOUCH || MONODROID -using MX = Mono.Security.X509; -#else +#if MONO_SECURITY_ALIAS extern alias MonoSecurity; using MX = MonoSecurity::Mono.Security.X509; +#else +using MX = Mono.Security.X509; #endif using System.Security.Permissions; diff --git a/mcs/class/System/System.Security.Cryptography.X509Certificates/X509SubjectKeyIdentifierExtension.cs b/mcs/class/System/System.Security.Cryptography.X509Certificates/X509SubjectKeyIdentifierExtension.cs index b5a4c23e555..89e7afb963c 100644 --- a/mcs/class/System/System.Security.Cryptography.X509Certificates/X509SubjectKeyIdentifierExtension.cs +++ b/mcs/class/System/System.Security.Cryptography.X509Certificates/X509SubjectKeyIdentifierExtension.cs @@ -30,13 +30,13 @@ #if SECURITY_DEP -#if MONOTOUCH || MONODROID -using Mono.Security; -using Mono.Security.Cryptography; -#else +#if MONO_SECURITY_ALIAS extern alias MonoSecurity; using MonoSecurity::Mono.Security; using MonoSecurity::Mono.Security.Cryptography; +#else +using Mono.Security; +using Mono.Security.Cryptography; #endif using System.Text; diff --git a/mcs/class/System/System.Security.Cryptography/AsnEncodedData.cs b/mcs/class/System/System.Security.Cryptography/AsnEncodedData.cs index 5d0cb711008..99860521102 100644 --- a/mcs/class/System/System.Security.Cryptography/AsnEncodedData.cs +++ b/mcs/class/System/System.Security.Cryptography/AsnEncodedData.cs @@ -29,13 +29,13 @@ #if SECURITY_DEP -#if MONOTOUCH || MONODROID -using Mono.Security; -using Mono.Security.Cryptography; -#else +#if MONO_SECURITY_ALIAS extern alias MonoSecurity; using MonoSecurity::Mono.Security; using MonoSecurity::Mono.Security.Cryptography; +#else +using Mono.Security; +using Mono.Security.Cryptography; #endif using System.Security.Cryptography.X509Certificates; diff --git a/mcs/class/System/Test/System.Diagnostics/ProcessTest.cs b/mcs/class/System/Test/System.Diagnostics/ProcessTest.cs index 615b0aed3e6..602a07d017a 100644 --- a/mcs/class/System/Test/System.Diagnostics/ProcessTest.cs +++ b/mcs/class/System/Test/System.Diagnostics/ProcessTest.cs @@ -836,12 +836,38 @@ namespace MonoTests.System.Diagnostics p.BeginOutputReadLine (); p.WaitForExit (); - exited.Wait (10000); + Assert.IsTrue (exited.Wait (10000)); Assert.AreEqual (1, exitedCalledCounter); Thread.Sleep (50); Assert.AreEqual (1, exitedCalledCounter); } + [Test] + [NUnit.Framework.Category ("MobileNotWorking")] + public void TestDisableEventsBeforeExitedEvent () + { + Process p = new Process (); + + p.StartInfo = GetCrossPlatformStartInfo (); + p.StartInfo.UseShellExecute = false; + p.StartInfo.RedirectStandardOutput = true; + p.StartInfo.RedirectStandardError = true; + + p.EnableRaisingEvents = false; + + var exitedCalledCounter = 0; + p.Exited += (object sender, EventArgs e) => { + exitedCalledCounter++; + }; + + p.Start (); + p.BeginErrorReadLine (); + p.BeginOutputReadLine (); + p.WaitForExit (); + + Assert.AreEqual (0, exitedCalledCounter); + } + ProcessStartInfo GetCrossPlatformStartInfo () { if (RunningOnUnix) { diff --git a/mcs/class/System/Test/System.Net.Sockets/SocketTest.cs b/mcs/class/System/Test/System.Net.Sockets/SocketTest.cs index 9ee0c544769..0d2dea47a73 100755 --- a/mcs/class/System/Test/System.Net.Sockets/SocketTest.cs +++ b/mcs/class/System/Test/System.Net.Sockets/SocketTest.cs @@ -9,6 +9,7 @@ // using System; +using System.Diagnostics; using System.Linq; using System.Collections; using System.Threading; @@ -126,7 +127,21 @@ namespace MonoTests.System.Net.Sockets ProtocolType.Tcp); conn.Connect (ep); - Socket client = server.Accept(); + Socket client = null; + var sw = Stopwatch.StartNew (); + while (sw.ElapsedMilliseconds < 100) + { + try { + client = server.Accept(); + break; + } + catch (SocketException ex) { + if (ex.SocketErrorCode == SocketError.WouldBlock) + continue; + throw; + } + } + Assert.IsNotNull (client, "Couldn't accept a client connection within 100ms."); bool client_block = client.Blocking; client.Close(); diff --git a/mcs/class/System/mobile_System.dll.sources b/mcs/class/System/mobile_System.dll.sources index 9bc7d84f730..c857dffc555 100644 --- a/mcs/class/System/mobile_System.dll.sources +++ b/mcs/class/System/mobile_System.dll.sources @@ -763,3 +763,97 @@ ReferenceSources/Win32Exception.cs ../../../external/referencesource/System/misc/WeakHashtable.cs ../../../external/referencesource/System/compmod/system/diagnostics/TextWriterTraceListener.cs + +../Mono.Security/Mono.Security.Authenticode/PrivateKey.cs +../Mono.Security/Mono.Security.Cryptography/MD5SHA1.cs +../Mono.Security/Mono.Security.Cryptography/TlsHMAC.cs +../Mono.Security/Mono.Security.Protocol.Ntlm/ChallengeResponse.cs +../Mono.Security/Mono.Security.Protocol.Ntlm/ChallengeResponse2.cs +../Mono.Security/Mono.Security.Protocol.Ntlm/MessageBase.cs +../Mono.Security/Mono.Security.Protocol.Ntlm/NtlmAuthLevel.cs +../Mono.Security/Mono.Security.Protocol.Ntlm/NtlmFlags.cs +../Mono.Security/Mono.Security.Protocol.Ntlm/NtlmSettings.cs +../Mono.Security/Mono.Security.Protocol.Ntlm/Type1Message.cs +../Mono.Security/Mono.Security.Protocol.Ntlm/Type2Message.cs +../Mono.Security/Mono.Security.Protocol.Ntlm/Type3Message.cs +../Mono.Security/Mono.Security.Protocol.Tls/Alert.cs +../Mono.Security/Mono.Security.Protocol.Tls/CipherAlgorithmType.cs +../Mono.Security/Mono.Security.Protocol.Tls/CipherSuite.cs +../Mono.Security/Mono.Security.Protocol.Tls/CipherSuiteCollection.cs +../Mono.Security/Mono.Security.Protocol.Tls/CipherSuiteFactory.cs +../Mono.Security/Mono.Security.Protocol.Tls/ClientContext.cs +../Mono.Security/Mono.Security.Protocol.Tls/ClientRecordProtocol.cs +../Mono.Security/Mono.Security.Protocol.Tls/ClientSessionCache.cs +../Mono.Security/Mono.Security.Protocol.Tls/ContentType.cs +../Mono.Security/Mono.Security.Protocol.Tls/Context.cs +../Mono.Security/Mono.Security.Protocol.Tls/DebugHelper.cs +../Mono.Security/Mono.Security.Protocol.Tls/ExchangeAlgorithmType.cs +../Mono.Security/Mono.Security.Protocol.Tls/HandshakeState.cs +../Mono.Security/Mono.Security.Protocol.Tls/HashAlgorithmType.cs +../Mono.Security/Mono.Security.Protocol.Tls/HttpsClientStream.cs +../Mono.Security/Mono.Security.Protocol.Tls/RecordProtocol.cs +../Mono.Security/Mono.Security.Protocol.Tls/RSASslSignatureDeformatter.cs +../Mono.Security/Mono.Security.Protocol.Tls/RSASslSignatureFormatter.cs +../Mono.Security/Mono.Security.Protocol.Tls/SecurityCompressionType.cs +../Mono.Security/Mono.Security.Protocol.Tls/SecurityParameters.cs +../Mono.Security/Mono.Security.Protocol.Tls/SecurityProtocolType.cs +../Mono.Security/Mono.Security.Protocol.Tls/ServerContext.cs +../Mono.Security/Mono.Security.Protocol.Tls/ServerRecordProtocol.cs +../Mono.Security/Mono.Security.Protocol.Tls/SslClientStream.cs +../Mono.Security/Mono.Security.Protocol.Tls/SslCipherSuite.cs +../Mono.Security/Mono.Security.Protocol.Tls/SslHandshakeHash.cs +../Mono.Security/Mono.Security.Protocol.Tls/SslServerStream.cs +../Mono.Security/Mono.Security.Protocol.Tls/SslStreamBase.cs +../Mono.Security/Mono.Security.Protocol.Tls/TlsCipherSuite.cs +../Mono.Security/Mono.Security.Protocol.Tls/TlsClientSettings.cs +../Mono.Security/Mono.Security.Protocol.Tls/TlsException.cs +../Mono.Security/Mono.Security.Protocol.Tls/TlsServerSettings.cs +../Mono.Security/Mono.Security.Protocol.Tls/TlsStream.cs +../Mono.Security/Mono.Security.Protocol.Tls.Handshake/ClientCertificateType.cs +../Mono.Security/Mono.Security.Protocol.Tls.Handshake/HandshakeMessage.cs +../Mono.Security/Mono.Security.Protocol.Tls.Handshake/HandshakeType.cs +../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientCertificate.cs +../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientCertificateVerify.cs +../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientFinished.cs +../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientHello.cs +../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientKeyExchange.cs +../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerCertificate.cs +../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerCertificateRequest.cs +../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerFinished.cs +../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerHello.cs +../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerHelloDone.cs +../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerKeyExchange.cs +../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Server/TlsClientCertificate.cs +../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Server/TlsClientCertificateVerify.cs +../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Server/TlsClientFinished.cs +../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Server/TlsClientHello.cs +../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Server/TlsClientKeyExchange.cs +../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Server/TlsServerCertificate.cs +../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Server/TlsServerCertificateRequest.cs +../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Server/TlsServerFinished.cs +../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Server/TlsServerHello.cs +../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Server/TlsServerHelloDone.cs +../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Server/TlsServerKeyExchange.cs +../Mono.Security/Mono.Security.X509.Extensions/AuthorityKeyIdentifierExtension.cs +../Mono.Security/Mono.Security.X509.Extensions/ExtendedKeyUsageExtension.cs +../Mono.Security/Mono.Security.X509.Extensions/GeneralNames.cs +../Mono.Security/Mono.Security.X509.Extensions/NetscapeCertTypeExtension.cs +../Mono.Security/Mono.Security.X509.Extensions/SubjectAltNameExtension.cs + +../Mono.Security/Mono.Security.Interface/Alert.cs +../Mono.Security/Mono.Security.Interface/CertificateValidationHelper.cs +../Mono.Security/Mono.Security.Interface/CipherAlgorithmType.cs +../Mono.Security/Mono.Security.Interface/CipherSuiteCode.cs +../Mono.Security/Mono.Security.Interface/ExchangeAlgorithmType.cs +../Mono.Security/Mono.Security.Interface/HashAlgorithmType.cs +../Mono.Security/Mono.Security.Interface/IBufferOffsetSize.cs +../Mono.Security/Mono.Security.Interface/IMonoTlsEventSink.cs +../Mono.Security/Mono.Security.Interface/IMonoTlsContext.cs +../Mono.Security/Mono.Security.Interface/IMonoSslStream.cs +../Mono.Security/Mono.Security.Interface/MonoTlsConnectionInfo.cs +../Mono.Security/Mono.Security.Interface/MonoTlsProvider.cs +../Mono.Security/Mono.Security.Interface/MonoTlsProviderFactory.cs +../Mono.Security/Mono.Security.Interface/MonoTlsSettings.cs +../Mono.Security/Mono.Security.Interface/TlsException.cs +../Mono.Security/Mono.Security.Interface/TlsProtocolCode.cs +../Mono.Security/Mono.Security.Interface/TlsProtocols.cs diff --git a/mcs/class/System/mobile_static_System.dll.sources b/mcs/class/System/mobile_static_System.dll.sources index 45798be42a0..8dce31d234c 100644 --- a/mcs/class/System/mobile_static_System.dll.sources +++ b/mcs/class/System/mobile_static_System.dll.sources @@ -1,88 +1,2 @@ #include mobile_System.dll.sources MonoTouch/MonoPInvokeCallbackAttribute.cs -../Mono.Security/Mono.Security.Authenticode/PrivateKey.cs -../Mono.Security/Mono.Security.Cryptography/MD5SHA1.cs -../Mono.Security/Mono.Security.Cryptography/TlsHMAC.cs -../Mono.Security/Mono.Security.Protocol.Ntlm/ChallengeResponse.cs -../Mono.Security/Mono.Security.Protocol.Ntlm/ChallengeResponse2.cs -../Mono.Security/Mono.Security.Protocol.Ntlm/MessageBase.cs -../Mono.Security/Mono.Security.Protocol.Ntlm/NtlmAuthLevel.cs -../Mono.Security/Mono.Security.Protocol.Ntlm/NtlmFlags.cs -../Mono.Security/Mono.Security.Protocol.Ntlm/NtlmSettings.cs -../Mono.Security/Mono.Security.Protocol.Ntlm/Type1Message.cs -../Mono.Security/Mono.Security.Protocol.Ntlm/Type2Message.cs -../Mono.Security/Mono.Security.Protocol.Ntlm/Type3Message.cs -../Mono.Security/Mono.Security.Protocol.Tls/Alert.cs -../Mono.Security/Mono.Security.Protocol.Tls/CipherAlgorithmType.cs -../Mono.Security/Mono.Security.Protocol.Tls/CipherSuite.cs -../Mono.Security/Mono.Security.Protocol.Tls/CipherSuiteCollection.cs -../Mono.Security/Mono.Security.Protocol.Tls/CipherSuiteFactory.cs -../Mono.Security/Mono.Security.Protocol.Tls/ClientContext.cs -../Mono.Security/Mono.Security.Protocol.Tls/ClientRecordProtocol.cs -../Mono.Security/Mono.Security.Protocol.Tls/ClientSessionCache.cs -../Mono.Security/Mono.Security.Protocol.Tls/ContentType.cs -../Mono.Security/Mono.Security.Protocol.Tls/Context.cs -../Mono.Security/Mono.Security.Protocol.Tls/DebugHelper.cs -../Mono.Security/Mono.Security.Protocol.Tls/ExchangeAlgorithmType.cs -../Mono.Security/Mono.Security.Protocol.Tls/HandshakeState.cs -../Mono.Security/Mono.Security.Protocol.Tls/HashAlgorithmType.cs -../Mono.Security/Mono.Security.Protocol.Tls/HttpsClientStream.cs -../Mono.Security/Mono.Security.Protocol.Tls/RecordProtocol.cs -../Mono.Security/Mono.Security.Protocol.Tls/RSASslSignatureDeformatter.cs -../Mono.Security/Mono.Security.Protocol.Tls/RSASslSignatureFormatter.cs -../Mono.Security/Mono.Security.Protocol.Tls/SecurityCompressionType.cs -../Mono.Security/Mono.Security.Protocol.Tls/SecurityParameters.cs -../Mono.Security/Mono.Security.Protocol.Tls/SecurityProtocolType.cs -../Mono.Security/Mono.Security.Protocol.Tls/ServerContext.cs -../Mono.Security/Mono.Security.Protocol.Tls/ServerRecordProtocol.cs -../Mono.Security/Mono.Security.Protocol.Tls/SslClientStream.cs -../Mono.Security/Mono.Security.Protocol.Tls/SslCipherSuite.cs -../Mono.Security/Mono.Security.Protocol.Tls/SslHandshakeHash.cs -../Mono.Security/Mono.Security.Protocol.Tls/SslServerStream.cs -../Mono.Security/Mono.Security.Protocol.Tls/SslStreamBase.cs -../Mono.Security/Mono.Security.Protocol.Tls/TlsCipherSuite.cs -../Mono.Security/Mono.Security.Protocol.Tls/TlsClientSettings.cs -../Mono.Security/Mono.Security.Protocol.Tls/TlsException.cs -../Mono.Security/Mono.Security.Protocol.Tls/TlsServerSettings.cs -../Mono.Security/Mono.Security.Protocol.Tls/TlsStream.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake/ClientCertificateType.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake/HandshakeMessage.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake/HandshakeType.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientCertificate.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientCertificateVerify.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientFinished.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientHello.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientKeyExchange.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerCertificate.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerCertificateRequest.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerFinished.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerHello.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerHelloDone.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerKeyExchange.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Server/TlsClientCertificate.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Server/TlsClientCertificateVerify.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Server/TlsClientFinished.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Server/TlsClientHello.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Server/TlsClientKeyExchange.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Server/TlsServerCertificate.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Server/TlsServerCertificateRequest.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Server/TlsServerFinished.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Server/TlsServerHello.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Server/TlsServerHelloDone.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Server/TlsServerKeyExchange.cs -../Mono.Security/Mono.Security.X509.Extensions/AuthorityKeyIdentifierExtension.cs -../Mono.Security/Mono.Security.X509.Extensions/ExtendedKeyUsageExtension.cs -../Mono.Security/Mono.Security.X509.Extensions/GeneralNames.cs -../Mono.Security/Mono.Security.X509.Extensions/NetscapeCertTypeExtension.cs -../Mono.Security/Mono.Security.X509.Extensions/SubjectAltNameExtension.cs - -../Mono.Security/Mono.Security.Interface/CertificateValidationHelper.cs -../Mono.Security/Mono.Security.Interface/IBufferOffsetSize.cs -../Mono.Security/Mono.Security.Interface/IMonoTlsEventSink.cs -../Mono.Security/Mono.Security.Interface/IMonoTlsContext.cs -../Mono.Security/Mono.Security.Interface/IMonoSslStream.cs -../Mono.Security/Mono.Security.Interface/MonoTlsConnectionInfo.cs -../Mono.Security/Mono.Security.Interface/MonoTlsProvider.cs -../Mono.Security/Mono.Security.Interface/MonoTlsProviderFactory.cs -../Mono.Security/Mono.Security.Interface/MonoTlsSettings.cs -../Mono.Security/Mono.Security.Interface/TlsProtocols.cs diff --git a/mcs/class/System/monodroid_System.dll.sources b/mcs/class/System/monodroid_System.dll.sources index 83fc05a3640..2abef931590 100644 --- a/mcs/class/System/monodroid_System.dll.sources +++ b/mcs/class/System/monodroid_System.dll.sources @@ -1,96 +1,3 @@ #include mobile_System.dll.sources System/AndroidPlatform.cs -../Mono.Security/Mono.Security.Authenticode/PrivateKey.cs -../Mono.Security/Mono.Security.Cryptography/MD5SHA1.cs -../Mono.Security/Mono.Security.Cryptography/TlsHMAC.cs -../Mono.Security/Mono.Security.Protocol.Ntlm/ChallengeResponse.cs -../Mono.Security/Mono.Security.Protocol.Ntlm/ChallengeResponse2.cs -../Mono.Security/Mono.Security.Protocol.Ntlm/MessageBase.cs -../Mono.Security/Mono.Security.Protocol.Ntlm/NtlmAuthLevel.cs -../Mono.Security/Mono.Security.Protocol.Ntlm/NtlmFlags.cs -../Mono.Security/Mono.Security.Protocol.Ntlm/NtlmSettings.cs -../Mono.Security/Mono.Security.Protocol.Ntlm/Type1Message.cs -../Mono.Security/Mono.Security.Protocol.Ntlm/Type2Message.cs -../Mono.Security/Mono.Security.Protocol.Ntlm/Type3Message.cs -../Mono.Security/Mono.Security.Protocol.Tls/Alert.cs -../Mono.Security/Mono.Security.Protocol.Tls/CipherAlgorithmType.cs -../Mono.Security/Mono.Security.Protocol.Tls/CipherSuite.cs -../Mono.Security/Mono.Security.Protocol.Tls/CipherSuiteCollection.cs -../Mono.Security/Mono.Security.Protocol.Tls/CipherSuiteFactory.cs -../Mono.Security/Mono.Security.Protocol.Tls/ClientContext.cs -../Mono.Security/Mono.Security.Protocol.Tls/ClientRecordProtocol.cs -../Mono.Security/Mono.Security.Protocol.Tls/ClientSessionCache.cs -../Mono.Security/Mono.Security.Protocol.Tls/ContentType.cs -../Mono.Security/Mono.Security.Protocol.Tls/Context.cs -../Mono.Security/Mono.Security.Protocol.Tls/DebugHelper.cs -../Mono.Security/Mono.Security.Protocol.Tls/ExchangeAlgorithmType.cs -../Mono.Security/Mono.Security.Protocol.Tls/HandshakeState.cs -../Mono.Security/Mono.Security.Protocol.Tls/HashAlgorithmType.cs -../Mono.Security/Mono.Security.Protocol.Tls/HttpsClientStream.cs -../Mono.Security/Mono.Security.Protocol.Tls/RecordProtocol.cs -../Mono.Security/Mono.Security.Protocol.Tls/RSASslSignatureDeformatter.cs -../Mono.Security/Mono.Security.Protocol.Tls/RSASslSignatureFormatter.cs -../Mono.Security/Mono.Security.Protocol.Tls/SecurityCompressionType.cs -../Mono.Security/Mono.Security.Protocol.Tls/SecurityParameters.cs -../Mono.Security/Mono.Security.Protocol.Tls/SecurityProtocolType.cs -../Mono.Security/Mono.Security.Protocol.Tls/ServerContext.cs -../Mono.Security/Mono.Security.Protocol.Tls/ServerRecordProtocol.cs -../Mono.Security/Mono.Security.Protocol.Tls/SslClientStream.cs -../Mono.Security/Mono.Security.Protocol.Tls/SslCipherSuite.cs -../Mono.Security/Mono.Security.Protocol.Tls/SslHandshakeHash.cs -../Mono.Security/Mono.Security.Protocol.Tls/SslServerStream.cs -../Mono.Security/Mono.Security.Protocol.Tls/SslStreamBase.cs -../Mono.Security/Mono.Security.Protocol.Tls/TlsCipherSuite.cs -../Mono.Security/Mono.Security.Protocol.Tls/TlsClientSettings.cs -../Mono.Security/Mono.Security.Protocol.Tls/TlsException.cs -../Mono.Security/Mono.Security.Protocol.Tls/TlsServerSettings.cs -../Mono.Security/Mono.Security.Protocol.Tls/TlsStream.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake/ClientCertificateType.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake/HandshakeMessage.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake/HandshakeType.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientCertificate.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientCertificateVerify.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientFinished.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientHello.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientKeyExchange.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerCertificate.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerCertificateRequest.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerFinished.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerHello.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerHelloDone.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerKeyExchange.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Server/TlsClientCertificate.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Server/TlsClientCertificateVerify.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Server/TlsClientFinished.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Server/TlsClientHello.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Server/TlsClientKeyExchange.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Server/TlsServerCertificate.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Server/TlsServerCertificateRequest.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Server/TlsServerFinished.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Server/TlsServerHello.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Server/TlsServerHelloDone.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Server/TlsServerKeyExchange.cs -../Mono.Security/Mono.Security.X509.Extensions/AuthorityKeyIdentifierExtension.cs -../Mono.Security/Mono.Security.X509.Extensions/ExtendedKeyUsageExtension.cs -../Mono.Security/Mono.Security.X509.Extensions/GeneralNames.cs -../Mono.Security/Mono.Security.X509.Extensions/NetscapeCertTypeExtension.cs -../Mono.Security/Mono.Security.X509.Extensions/SubjectAltNameExtension.cs - -../Mono.Security/Mono.Security.Interface/Alert.cs -../Mono.Security/Mono.Security.Interface/CertificateValidationHelper.cs -../Mono.Security/Mono.Security.Interface/CipherAlgorithmType.cs -../Mono.Security/Mono.Security.Interface/CipherSuiteCode.cs -../Mono.Security/Mono.Security.Interface/ExchangeAlgorithmType.cs -../Mono.Security/Mono.Security.Interface/HashAlgorithmType.cs -../Mono.Security/Mono.Security.Interface/IBufferOffsetSize.cs -../Mono.Security/Mono.Security.Interface/IMonoTlsEventSink.cs -../Mono.Security/Mono.Security.Interface/IMonoTlsContext.cs -../Mono.Security/Mono.Security.Interface/IMonoSslStream.cs -../Mono.Security/Mono.Security.Interface/MonoTlsConnectionInfo.cs -../Mono.Security/Mono.Security.Interface/MonoTlsProvider.cs -../Mono.Security/Mono.Security.Interface/MonoTlsProviderFactory.cs -../Mono.Security/Mono.Security.Interface/MonoTlsSettings.cs -../Mono.Security/Mono.Security.Interface/TlsException.cs -../Mono.Security/Mono.Security.Interface/TlsProtocolCode.cs -../Mono.Security/Mono.Security.Interface/TlsProtocols.cs diff --git a/mcs/class/System/monotouch_System.dll.sources b/mcs/class/System/monotouch_System.dll.sources index 91f1bd51de6..8dce31d234c 100644 --- a/mcs/class/System/monotouch_System.dll.sources +++ b/mcs/class/System/monotouch_System.dll.sources @@ -1,95 +1,2 @@ #include mobile_System.dll.sources MonoTouch/MonoPInvokeCallbackAttribute.cs -../Mono.Security/Mono.Security.Authenticode/PrivateKey.cs -../Mono.Security/Mono.Security.Cryptography/MD5SHA1.cs -../Mono.Security/Mono.Security.Cryptography/TlsHMAC.cs -../Mono.Security/Mono.Security.Protocol.Ntlm/ChallengeResponse.cs -../Mono.Security/Mono.Security.Protocol.Ntlm/ChallengeResponse2.cs -../Mono.Security/Mono.Security.Protocol.Ntlm/MessageBase.cs -../Mono.Security/Mono.Security.Protocol.Ntlm/NtlmAuthLevel.cs -../Mono.Security/Mono.Security.Protocol.Ntlm/NtlmFlags.cs -../Mono.Security/Mono.Security.Protocol.Ntlm/NtlmSettings.cs -../Mono.Security/Mono.Security.Protocol.Ntlm/Type1Message.cs -../Mono.Security/Mono.Security.Protocol.Ntlm/Type2Message.cs -../Mono.Security/Mono.Security.Protocol.Ntlm/Type3Message.cs -../Mono.Security/Mono.Security.Protocol.Tls/Alert.cs -../Mono.Security/Mono.Security.Protocol.Tls/CipherAlgorithmType.cs -../Mono.Security/Mono.Security.Protocol.Tls/CipherSuite.cs -../Mono.Security/Mono.Security.Protocol.Tls/CipherSuiteCollection.cs -../Mono.Security/Mono.Security.Protocol.Tls/CipherSuiteFactory.cs -../Mono.Security/Mono.Security.Protocol.Tls/ClientContext.cs -../Mono.Security/Mono.Security.Protocol.Tls/ClientRecordProtocol.cs -../Mono.Security/Mono.Security.Protocol.Tls/ClientSessionCache.cs -../Mono.Security/Mono.Security.Protocol.Tls/ContentType.cs -../Mono.Security/Mono.Security.Protocol.Tls/Context.cs -../Mono.Security/Mono.Security.Protocol.Tls/DebugHelper.cs -../Mono.Security/Mono.Security.Protocol.Tls/ExchangeAlgorithmType.cs -../Mono.Security/Mono.Security.Protocol.Tls/HandshakeState.cs -../Mono.Security/Mono.Security.Protocol.Tls/HashAlgorithmType.cs -../Mono.Security/Mono.Security.Protocol.Tls/HttpsClientStream.cs -../Mono.Security/Mono.Security.Protocol.Tls/RecordProtocol.cs -../Mono.Security/Mono.Security.Protocol.Tls/RSASslSignatureDeformatter.cs -../Mono.Security/Mono.Security.Protocol.Tls/RSASslSignatureFormatter.cs -../Mono.Security/Mono.Security.Protocol.Tls/SecurityCompressionType.cs -../Mono.Security/Mono.Security.Protocol.Tls/SecurityParameters.cs -../Mono.Security/Mono.Security.Protocol.Tls/SecurityProtocolType.cs -../Mono.Security/Mono.Security.Protocol.Tls/ServerContext.cs -../Mono.Security/Mono.Security.Protocol.Tls/ServerRecordProtocol.cs -../Mono.Security/Mono.Security.Protocol.Tls/SslClientStream.cs -../Mono.Security/Mono.Security.Protocol.Tls/SslCipherSuite.cs -../Mono.Security/Mono.Security.Protocol.Tls/SslHandshakeHash.cs -../Mono.Security/Mono.Security.Protocol.Tls/SslServerStream.cs -../Mono.Security/Mono.Security.Protocol.Tls/SslStreamBase.cs -../Mono.Security/Mono.Security.Protocol.Tls/TlsCipherSuite.cs -../Mono.Security/Mono.Security.Protocol.Tls/TlsClientSettings.cs -../Mono.Security/Mono.Security.Protocol.Tls/TlsException.cs -../Mono.Security/Mono.Security.Protocol.Tls/TlsServerSettings.cs -../Mono.Security/Mono.Security.Protocol.Tls/TlsStream.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake/ClientCertificateType.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake/HandshakeMessage.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake/HandshakeType.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientCertificate.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientCertificateVerify.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientFinished.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientHello.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientKeyExchange.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerCertificate.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerCertificateRequest.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerFinished.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerHello.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerHelloDone.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerKeyExchange.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Server/TlsClientCertificate.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Server/TlsClientCertificateVerify.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Server/TlsClientFinished.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Server/TlsClientHello.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Server/TlsClientKeyExchange.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Server/TlsServerCertificate.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Server/TlsServerCertificateRequest.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Server/TlsServerFinished.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Server/TlsServerHello.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Server/TlsServerHelloDone.cs -../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Server/TlsServerKeyExchange.cs -../Mono.Security/Mono.Security.X509.Extensions/AuthorityKeyIdentifierExtension.cs -../Mono.Security/Mono.Security.X509.Extensions/ExtendedKeyUsageExtension.cs -../Mono.Security/Mono.Security.X509.Extensions/GeneralNames.cs -../Mono.Security/Mono.Security.X509.Extensions/NetscapeCertTypeExtension.cs -../Mono.Security/Mono.Security.X509.Extensions/SubjectAltNameExtension.cs - -../Mono.Security/Mono.Security.Interface/Alert.cs -../Mono.Security/Mono.Security.Interface/CertificateValidationHelper.cs -../Mono.Security/Mono.Security.Interface/CipherAlgorithmType.cs -../Mono.Security/Mono.Security.Interface/CipherSuiteCode.cs -../Mono.Security/Mono.Security.Interface/ExchangeAlgorithmType.cs -../Mono.Security/Mono.Security.Interface/HashAlgorithmType.cs -../Mono.Security/Mono.Security.Interface/IBufferOffsetSize.cs -../Mono.Security/Mono.Security.Interface/IMonoTlsEventSink.cs -../Mono.Security/Mono.Security.Interface/IMonoTlsContext.cs -../Mono.Security/Mono.Security.Interface/IMonoSslStream.cs -../Mono.Security/Mono.Security.Interface/MonoTlsConnectionInfo.cs -../Mono.Security/Mono.Security.Interface/MonoTlsProvider.cs -../Mono.Security/Mono.Security.Interface/MonoTlsProviderFactory.cs -../Mono.Security/Mono.Security.Interface/MonoTlsSettings.cs -../Mono.Security/Mono.Security.Interface/TlsException.cs -../Mono.Security/Mono.Security.Interface/TlsProtocolCode.cs -../Mono.Security/Mono.Security.Interface/TlsProtocols.cs diff --git a/mcs/class/corlib/Makefile b/mcs/class/corlib/Makefile index 1162bf54f78..ef5490a1661 100644 --- a/mcs/class/corlib/Makefile +++ b/mcs/class/corlib/Makefile @@ -51,6 +51,11 @@ REFERENCE_SOURCES_FLAGS += -d:MONO_FEATURE_THREAD_SUSPEND_RESUME TEST_MCS_FLAGS += -d:MONO_FEATURE_THREAD_SUSPEND_RESUME endif +ifndef NO_MULTIPLE_APPDOMAINS +REFERENCE_SOURCES_FLAGS += -d:MONO_FEATURE_MULTIPLE_APPDOMAINS +TEST_MCS_FLAGS += -d:MONO_FEATURE_MULTIPLE_APPDOMAINS +endif + WARNING_ABOUT_DISABLED_WARNING=1635 LOCAL_MCS_FLAGS = -unsafe -nostdlib -nowarn:612,618,$(WARNING_ABOUT_DISABLED_WARNING) -d:INSIDE_CORLIB,MONO_CULTURE_DATA -d:LIBC $(REFERENCE_SOURCES_FLAGS) DEFAULT_REFERENCES = diff --git a/mcs/class/corlib/System.Runtime.Hosting/ApplicationActivator.cs b/mcs/class/corlib/System.Runtime.Hosting/ApplicationActivator.cs index 877d9a7e7ee..bb3ed48bced 100644 --- a/mcs/class/corlib/System.Runtime.Hosting/ApplicationActivator.cs +++ b/mcs/class/corlib/System.Runtime.Hosting/ApplicationActivator.cs @@ -33,6 +33,7 @@ using System.Security.Policy; namespace System.Runtime.Hosting { +#if MONO_FEATURE_MULTIPLE_APPDOMAINS [ComVisible (true)] [MonoTODO ("missing manifest support")] public class ApplicationActivator { @@ -91,5 +92,30 @@ namespace System.Runtime.Hosting { return ad.CreateInstance ("assemblyName", "typeName", null); } } +#else + [Obsolete ("ApplicationActivator is not supported on this platform.", true)] + public class ApplicationActivator { + + public ApplicationActivator () + { + throw new PlatformNotSupportedException ("ApplicationActivator is not supported on this platform."); + } + + public virtual ObjectHandle CreateInstance (ActivationContext activationContext) + { + throw new PlatformNotSupportedException ("ApplicationActivator is not supported on this platform."); + } + + public virtual ObjectHandle CreateInstance (ActivationContext activationContext, string[] activationCustomData) + { + throw new PlatformNotSupportedException ("ApplicationActivator is not supported on this platform."); + } + + protected static ObjectHandle CreateInstanceHelper (AppDomainSetup adSetup) + { + throw new PlatformNotSupportedException ("ApplicationActivator is not supported on this platform."); + } + } +#endif // MONO_FEATURE_MULTIPLE_APPDOMAINS } diff --git a/mcs/class/corlib/System.Security/SecurityState.cs b/mcs/class/corlib/System.Security/SecurityState.cs index 812aa8087ab..19a36f961a5 100644 --- a/mcs/class/corlib/System.Security/SecurityState.cs +++ b/mcs/class/corlib/System.Security/SecurityState.cs @@ -37,6 +37,7 @@ namespace System.Security { public abstract void EnsureState (); +#if MONO_FEATURE_MULTIPLE_APPDOMAINS public bool IsStateAvailable () { AppDomainManager adm = AppDomain.CurrentDomain.DomainManager; @@ -44,6 +45,13 @@ namespace System.Security { return false; return adm.CheckSecuritySettings (this); } +#else + [Obsolete ("SecurityState.IsStateAvailable is not supported on this platform.", true)] + public bool IsStateAvailable () + { + throw new PlatformNotSupportedException ("SecurityState.IsStateAvailable is not supported on this platform."); + } +#endif // MONO_FEATURE_MULTIPLE_APPDOMAINS } } diff --git a/mcs/class/corlib/System/AppDomain.cs b/mcs/class/corlib/System/AppDomain.cs index 22927ecd2f5..13cc078e575 100644 --- a/mcs/class/corlib/System/AppDomain.cs +++ b/mcs/class/corlib/System/AppDomain.cs @@ -983,6 +983,7 @@ namespace System { return _process_guid; } +#if MONO_FEATURE_MULTIPLE_APPDOMAINS public static AppDomain CreateDomain (string friendlyName) { return CreateDomain (friendlyName, null, null); @@ -1061,6 +1062,25 @@ namespace System { return ad; } +#else + [Obsolete ("AppDomain.CreateDomain is not supported on the current platform.", true)] + public static AppDomain CreateDomain (string friendlyName) + { + throw new PlatformNotSupportedException ("AppDomain.CreateDomain is not supported on the current platform."); + } + + [Obsolete ("AppDomain.CreateDomain is not supported on the current platform.", true)] + public static AppDomain CreateDomain (string friendlyName, Evidence securityInfo) + { + throw new PlatformNotSupportedException ("AppDomain.CreateDomain is not supported on the current platform."); + } + + [Obsolete ("AppDomain.CreateDomain is not supported on the current platform.", true)] + public static AppDomain CreateDomain (string friendlyName, Evidence securityInfo, AppDomainSetup info) + { + throw new PlatformNotSupportedException ("AppDomain.CreateDomain is not supported on the current platform."); + } +#endif // MONO_FEATURE_MULTIPLE_APPDOMAINS #if !NET_2_1 [Serializable] @@ -1098,13 +1118,23 @@ namespace System { } #endif +#if MONO_FEATURE_MULTIPLE_APPDOMAINS public static AppDomain CreateDomain (string friendlyName, Evidence securityInfo,string appBasePath, string appRelativeSearchPath, bool shadowCopyFiles) { return CreateDomain (friendlyName, securityInfo, CreateDomainSetup (appBasePath, appRelativeSearchPath, shadowCopyFiles)); } +#else + [Obsolete ("AppDomain.CreateDomain is not supported on the current platform.", true)] + public static AppDomain CreateDomain (string friendlyName, Evidence securityInfo,string appBasePath, + string appRelativeSearchPath, bool shadowCopyFiles) + { + throw new PlatformNotSupportedException ("AppDomain.CreateDomain is not supported on the current platform."); + } +#endif // MONO_FEATURE_MULTIPLE_APPDOMAINS #if !NET_2_1 +#if MONO_FEATURE_MULTIPLE_APPDOMAINS public static AppDomain CreateDomain (string friendlyName, Evidence securityInfo, AppDomainSetup info, PermissionSet grantSet, params StrongName [] fullTrustAssemblies) { @@ -1114,8 +1144,17 @@ namespace System { info.ApplicationTrust = new ApplicationTrust (grantSet, fullTrustAssemblies ?? EmptyArray.Value); return CreateDomain (friendlyName, securityInfo, info); } +#else + [Obsolete ("AppDomain.CreateDomain is not supported on the current platform.", true)] + public static AppDomain CreateDomain (string friendlyName, Evidence securityInfo, AppDomainSetup info, + PermissionSet grantSet, params StrongName [] fullTrustAssemblies) + { + throw new PlatformNotSupportedException ("AppDomain.CreateDomain is not supported on the current platform."); + } +#endif // MONO_FEATURE_MULTIPLE_APPDOMAINS #endif +#if MONO_FEATURE_MULTIPLE_APPDOMAINS static AppDomainSetup CreateDomainSetup (string appBasePath, string appRelativeSearchPath, bool shadowCopyFiles) { AppDomainSetup info = new AppDomainSetup (); @@ -1130,6 +1169,7 @@ namespace System { return info; } +#endif // MONO_FEATURE_MULTIPLE_APPDOMAINS [MethodImplAttribute (MethodImplOptions.InternalCall)] private static extern bool InternalIsFinalizingForUnload (int domain_id); @@ -1149,6 +1189,7 @@ namespace System { return Thread.GetDomainID (); } +#if MONO_FEATURE_MULTIPLE_APPDOMAINS [SecurityPermission (SecurityAction.Demand, ControlAppDomain = true)] [ReliabilityContractAttribute (Consistency.MayCorruptAppDomain, Cer.MayFail)] public static void Unload (AppDomain domain) @@ -1158,6 +1199,13 @@ namespace System { InternalUnload (domain.getDomainID()); } +#else + [Obsolete ("AppDomain.Unload is not supported on the current platform.", true)] + public static void Unload (AppDomain domain) + { + throw new PlatformNotSupportedException ("AppDomain.Unload is not supported on the current platform."); + } +#endif // MONO_FEATURE_MULTIPLE_APPDOMAINS [MethodImplAttribute (MethodImplOptions.InternalCall)] [SecurityPermission (SecurityAction.LinkDemand, ControlAppDomain = true)] @@ -1339,11 +1387,13 @@ namespace System { return null; } +#if MONO_FEATURE_MULTIPLE_APPDOMAINS private void DoDomainUnload () { if (DomainUnload != null) DomainUnload(this, null); } +#endif // MONO_FEATURE_MULTIPLE_APPDOMAINS [MethodImplAttribute(MethodImplOptions.InternalCall)] internal extern void DoUnhandledException (Exception e); @@ -1389,7 +1439,11 @@ namespace System { [method: SecurityPermission (SecurityAction.LinkDemand, ControlAppDomain = true)] public event ResolveEventHandler AssemblyResolve; +#if MONO_FEATURE_MULTIPLE_APPDOMAINS [method: SecurityPermission (SecurityAction.LinkDemand, ControlAppDomain = true)] +#else + [Obsolete ("AppDomain.DomainUnload is not supported on the current platform.", true)] +#endif // MONO_FEATURE_MULTIPLE_APPDOMAINS public event EventHandler DomainUnload; [method: SecurityPermission (SecurityAction.LinkDemand, ControlAppDomain = true)] @@ -1424,10 +1478,17 @@ namespace System { #endif #pragma warning restore 649 +#if MONO_FEATURE_MULTIPLE_APPDOMAINS // default is null public AppDomainManager DomainManager { get { return (AppDomainManager)_domain_manager; } } +#else + [Obsolete ("AppDomain.DomainManager is not supported on this platform.", true)] + public AppDomainManager DomainManager { + get { throw new PlatformNotSupportedException ("AppDomain.DomainManager is not supported on this platform."); } + } +#endif // MONO_FEATURE_MULTIPLE_APPDOMAINS #if !MOBILE public event ResolveEventHandler ReflectionOnlyAssemblyResolve; @@ -1473,6 +1534,7 @@ namespace System { // static methods +#if MONO_FEATURE_MULTIPLE_APPDOMAINS public static AppDomain CreateDomain (string friendlyName, Evidence securityInfo, string appBasePath, string appRelativeSearchPath, bool shadowCopyFiles, AppDomainInitializer adInit, string[] adInitArgs) { @@ -1483,6 +1545,14 @@ namespace System { return CreateDomain (friendlyName, securityInfo, info); } +#else + [Obsolete ("AppDomain.CreateDomain is not supported on the current platform.", true)] + public static AppDomain CreateDomain (string friendlyName, Evidence securityInfo, string appBasePath, + string appRelativeSearchPath, bool shadowCopyFiles, AppDomainInitializer adInit, string[] adInitArgs) + { + throw new PlatformNotSupportedException ("AppDomain.CreateDomain is not supported on the current platform."); + } +#endif // MONO_FEATURE_MULTIPLE_APPDOMAINS public int ExecuteAssemblyByName (string assemblyName) { diff --git a/mcs/class/corlib/System/AppDomainInitializer.cs b/mcs/class/corlib/System/AppDomainInitializer.cs index 25700d49e5c..c50f40da373 100644 --- a/mcs/class/corlib/System/AppDomainInitializer.cs +++ b/mcs/class/corlib/System/AppDomainInitializer.cs @@ -27,8 +27,12 @@ // namespace System { +#if MONO_FEATURE_MULTIPLE_APPDOMAINS [System.Runtime.InteropServices.ComVisible (true)] [Serializable] +#else + [Obsolete ("AppDomainInitializer is not supported on the current platform.", true)] +#endif public delegate void AppDomainInitializer (string[] args); } diff --git a/mcs/class/corlib/System/AppDomainManager.cs b/mcs/class/corlib/System/AppDomainManager.cs index f0a4770b71e..301fd334c70 100644 --- a/mcs/class/corlib/System/AppDomainManager.cs +++ b/mcs/class/corlib/System/AppDomainManager.cs @@ -36,6 +36,7 @@ using System.Threading; namespace System { +#if MONO_FEATURE_MULTIPLE_APPDOMAINS [ComVisible (true)] [SecurityPermission (SecurityAction.LinkDemand, Infrastructure = true)] [SecurityPermission (SecurityAction.InheritanceDemand, Infrastructure = true)] @@ -111,4 +112,55 @@ namespace System { return AppDomain.CreateDomain (friendlyName, securityInfo, appDomainInfo); } } +#else + [Obsolete ("AppDomainManager is not supported on the current platform.", true)] + public class AppDomainManager : MarshalByRefObject { + public AppDomainManager () + { + throw new PlatformNotSupportedException ("AppDomainManager is not supported on the current platform."); + } + + public virtual ApplicationActivator ApplicationActivator { + get { throw new PlatformNotSupportedException ("AppDomainManager is not supported on the current platform."); } + } + + public virtual Assembly EntryAssembly { + get { throw new PlatformNotSupportedException ("AppDomainManager is not supported on the current platform."); } + } + + public virtual HostExecutionContextManager HostExecutionContextManager { + get { throw new PlatformNotSupportedException ("AppDomainManager is not supported on the current platform."); } + } + + public virtual HostSecurityManager HostSecurityManager { + get { throw new PlatformNotSupportedException ("AppDomainManager is not supported on the current platform."); } + } + + public AppDomainManagerInitializationOptions InitializationFlags { + get { throw new PlatformNotSupportedException ("AppDomainManager is not supported on the current platform."); } + set { throw new PlatformNotSupportedException ("AppDomainManager is not supported on the current platform."); } + } + + public virtual AppDomain CreateDomain (string friendlyName, Evidence securityInfo, AppDomainSetup appDomainInfo) + { + throw new PlatformNotSupportedException ("AppDomainManager is not supported on the current platform."); + } + + public virtual void InitializeNewDomain (AppDomainSetup appDomainInfo) + { + throw new PlatformNotSupportedException ("AppDomainManager is not supported on the current platform."); + } + + public virtual bool CheckSecuritySettings (SecurityState state) + { + throw new PlatformNotSupportedException ("AppDomainManager is not supported on the current platform."); + } + + protected static AppDomain CreateDomainHelper (string friendlyName, Evidence securityInfo, AppDomainSetup appDomainInfo) + { + throw new PlatformNotSupportedException ("AppDomainManager is not supported on the current platform."); + } + } + +#endif // MONO_FEATURE_MULTIPLE_APPDOMAINS } diff --git a/mcs/class/corlib/System/AppDomainManager_2_1.cs b/mcs/class/corlib/System/AppDomainManager_2_1.cs index 572dcae8d2b..cc45ffd33de 100644 --- a/mcs/class/corlib/System/AppDomainManager_2_1.cs +++ b/mcs/class/corlib/System/AppDomainManager_2_1.cs @@ -33,6 +33,7 @@ using System.Security; namespace System { +#if MONO_FEATURE_MULTIPLE_APPDOMAINS [ComVisible (true)] public class AppDomainManager { @@ -51,6 +52,26 @@ namespace System { return (state != null); } } +#else + [Obsolete ("AppDomainManager is not supported on the current platform.", true)] + public class AppDomainManager { + + public AppDomainManager () + { + get { throw new PlatformNotSupportedException ("AppDomainManager is not supported on the current platform."); } + } + + public virtual void InitializeNewDomain (AppDomainSetup appDomainInfo) + { + get { throw new PlatformNotSupportedException ("AppDomainManager is not supported on the current platform."); } + } + + public virtual bool CheckSecuritySettings (SecurityState state) + { + get { throw new PlatformNotSupportedException ("AppDomainManager is not supported on the current platform."); } + } + } +#endif // MONO_FEATURE_MULTIPLE_APPDOMAINS } #endif diff --git a/mcs/class/corlib/System/AppDomainSetup.cs b/mcs/class/corlib/System/AppDomainSetup.cs index d689f379ff2..b3e2d510138 100644 --- a/mcs/class/corlib/System/AppDomainSetup.cs +++ b/mcs/class/corlib/System/AppDomainSetup.cs @@ -309,6 +309,7 @@ namespace System set { _activationArguments = value; } } +#if MONO_FEATURE_MULTIPLE_APPDOMAINS [MonoLimitation ("it needs to be invoked within the created domain")] public AppDomainInitializer AppDomainInitializer { get { @@ -319,6 +320,14 @@ namespace System } set { domain_initializer = value; } } +#else + [Obsolete ("AppDomainSetup.AppDomainInitializer is not supported on this platform.", true)] + public AppDomainInitializer AppDomainInitializer { + get { throw new PlatformNotSupportedException ("AppDomainSetup.AppDomainInitializer is not supported on this platform."); } + set { throw new PlatformNotSupportedException ("AppDomainSetup.AppDomainInitializer is not supported on this platform."); } + } +#endif // MONO_FEATURE_MULTIPLE_APPDOMAINS + [MonoLimitation ("it needs to be used to invoke the initializer within the created domain")] public string [] AppDomainInitializerArguments { @@ -369,7 +378,9 @@ namespace System object [] arr = (object []) bf.Deserialize (ms); _activationArguments = (ActivationArguments) arr [0]; +#if MONO_FEATURE_MULTIPLE_APPDOMAINS domain_initializer = (AppDomainInitializer) arr [1]; +#endif application_trust = (ApplicationTrust) arr [2]; serialized_non_primitives = null; diff --git a/mcs/class/corlib/Test/System.Runtime.CompilerServices/RuntimeHelpersTest.cs b/mcs/class/corlib/Test/System.Runtime.CompilerServices/RuntimeHelpersTest.cs index 593305d4a67..9234e9fc300 100644 --- a/mcs/class/corlib/Test/System.Runtime.CompilerServices/RuntimeHelpersTest.cs +++ b/mcs/class/corlib/Test/System.Runtime.CompilerServices/RuntimeHelpersTest.cs @@ -119,6 +119,16 @@ namespace MonoTests.System.Runtime.CompilerServices { RuntimeHelpers.RunClassConstructor (typeof (Thrower).TypeHandle); } + class GClass { + protected T Field; + } + + [Test] + public void RunClassConstructor_Generic () + { + RuntimeHelpers.RunClassConstructor (typeof (GClass<>).TypeHandle); + } + class Fielder { public byte [] array = new byte [1]; } diff --git a/mcs/class/corlib/Test/System.Security.Cryptography/RijndaelManagedTest.cs b/mcs/class/corlib/Test/System.Security.Cryptography/RijndaelManagedTest.cs index 2d9795ade10..b7bf46057a0 100644 --- a/mcs/class/corlib/Test/System.Security.Cryptography/RijndaelManagedTest.cs +++ b/mcs/class/corlib/Test/System.Security.Cryptography/RijndaelManagedTest.cs @@ -176,19 +176,6 @@ namespace MonoTests.System.Security.Cryptography { ); } - [Test] - [ExpectedException (typeof (CryptographicException))] - public void CreateEncryptor_KeyNull () - { - ICryptoTransform encryptor = aes.CreateEncryptor (null, aes.IV); - byte[] data = new byte[encryptor.InputBlockSize]; - byte[] encdata = encryptor.TransformFinalBlock (data, 0, data.Length); - - ICryptoTransform decryptor = aes.CreateDecryptor (aes.Key, aes.IV); - byte[] decdata = decryptor.TransformFinalBlock (encdata, 0, encdata.Length); - // null key != SymmetricAlgorithm.Key - } - [Test] public void CreateEncryptor_IvNull () { @@ -220,19 +207,6 @@ namespace MonoTests.System.Security.Cryptography { // SymmetricAlgorithm Key and IV not changed by CreateEncryptor } - [Test] - [ExpectedException (typeof (CryptographicException))] - public void CreateDecryptor_KeyNull () - { - ICryptoTransform encryptor = aes.CreateEncryptor (aes.Key, aes.IV); - byte[] data = new byte[encryptor.InputBlockSize]; - byte[] encdata = encryptor.TransformFinalBlock (data, 0, data.Length); - - ICryptoTransform decryptor = aes.CreateDecryptor (null, aes.IV); - byte[] decdata = decryptor.TransformFinalBlock (encdata, 0, encdata.Length); - // null key != SymmetricAlgorithm.Key - } - [Test] public void CreateDecryptor_IvNull () { diff --git a/mcs/class/corlib/Test/System.Security/SecurityStateTest.cs b/mcs/class/corlib/Test/System.Security/SecurityStateTest.cs index 7744e7ccb7c..86b3a1dbad2 100644 --- a/mcs/class/corlib/Test/System.Security/SecurityStateTest.cs +++ b/mcs/class/corlib/Test/System.Security/SecurityStateTest.cs @@ -44,12 +44,14 @@ namespace MonoTests.System.Security { } } +#if MONO_FEATURE_MULTIPLE_APPDOMAINS [Test] public void Defaults () { ContreteSecurityState ss = new ContreteSecurityState (); Assert.IsFalse (ss.IsStateAvailable (), "IsStateAvailable"); } +#endif // MONO_FEATURE_MULTIPLE_APPDOMAINS } } diff --git a/mcs/class/corlib/Test/System.Threading/ThreadTest.cs b/mcs/class/corlib/Test/System.Threading/ThreadTest.cs index b49fba552fa..5773a1003f6 100644 --- a/mcs/class/corlib/Test/System.Threading/ThreadTest.cs +++ b/mcs/class/corlib/Test/System.Threading/ThreadTest.cs @@ -964,6 +964,7 @@ namespace MonoTests.System.Threading } } +#if MONO_FEATURE_MULTIPLE_APPDOMAINS [Test] public void CurrentThread_Domains () { @@ -973,6 +974,7 @@ namespace MonoTests.System.Threading Assert.IsTrue (o.Run ()); AppDomain.Unload (ad); } +#endif // MONO_FEATURE_MULTIPLE_APPDOMAINS void CheckIsRunning (string s, Thread t) { diff --git a/mcs/class/corlib/Test/System/AppDomainCas.cs b/mcs/class/corlib/Test/System/AppDomainCas.cs index 6d95120f8ae..3516b040c38 100644 --- a/mcs/class/corlib/Test/System/AppDomainCas.cs +++ b/mcs/class/corlib/Test/System/AppDomainCas.cs @@ -26,6 +26,8 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // +#if MONO_FEATURE_MULTIPLE_APPDOMAINS + using NUnit.Framework; using System; @@ -404,3 +406,5 @@ namespace MonoCasTests.System { } } } + +#endif // MONO_FEATURE_MULTIPLE_APPDOMAINS diff --git a/mcs/class/corlib/Test/System/AppDomainManagerTest.cs b/mcs/class/corlib/Test/System/AppDomainManagerTest.cs index 83d198ca503..f90a9eccc61 100644 --- a/mcs/class/corlib/Test/System/AppDomainManagerTest.cs +++ b/mcs/class/corlib/Test/System/AppDomainManagerTest.cs @@ -26,6 +26,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // +#if MONO_FEATURE_MULTIPLE_APPDOMAINS using System; using System.Security; @@ -56,3 +57,4 @@ namespace MonoTests.System { } } +#endif // MONO_FEATURE_MULTIPLE_APPDOMAINS diff --git a/mcs/class/corlib/Test/System/AppDomainSetupTest.cs b/mcs/class/corlib/Test/System/AppDomainSetupTest.cs index 2e4b6e59a83..121d1c45f10 100644 --- a/mcs/class/corlib/Test/System/AppDomainSetupTest.cs +++ b/mcs/class/corlib/Test/System/AppDomainSetupTest.cs @@ -169,6 +169,7 @@ namespace MonoTests.System } } +#if MONO_FEATURE_MULTIPLE_APPDOMAINS [Test] #if MOBILE [Category ("NotWorking")] @@ -184,6 +185,7 @@ namespace MonoTests.System Assert.IsNotNull (data); Assert.IsTrue ((bool) data); } +#endif // MONO_FEATURE_MULTIPLE_APPDOMAINS static void AppDomainInitialized1 (string [] args) { @@ -199,6 +201,7 @@ namespace MonoTests.System { } +#if MONO_FEATURE_MULTIPLE_APPDOMAINS [Test] #if MOBILE [Category ("NotWorking")] @@ -211,5 +214,6 @@ namespace MonoTests.System s.AppDomainInitializer = InstanceInitializer; AppDomain.CreateDomain ("MyDomain", null, s); } +#endif // MONO_FEATURE_MULTIPLE_APPDOMAINS } } diff --git a/mcs/mcs/membercache.cs b/mcs/mcs/membercache.cs index 57e2e11e19c..6c2f543f756 100644 --- a/mcs/mcs/membercache.cs +++ b/mcs/mcs/membercache.cs @@ -1322,7 +1322,7 @@ namespace Mono.CSharp { if (a.DeclaringType.MemberDefinition != b.DeclaringType.MemberDefinition) return mc_b; - if (mc_a.Location.File != mc_a.Location.File) + if (mc_a.Location.File != mc_b.Location.File) return mc_b; return mc_b.Location.Row > mc_a.Location.Row ? mc_b : mc_a; diff --git a/mcs/tools/mdoc/Makefile b/mcs/tools/mdoc/Makefile index 9e4538fec1f..77dcbc676d8 100644 --- a/mcs/tools/mdoc/Makefile +++ b/mcs/tools/mdoc/Makefile @@ -174,7 +174,7 @@ check-monodocer-dropns-classic: $(PROGRAM) # tests the simplest --dropns case, a single class where the root namespace was dropped. -rm -Rf Test/en.actual $(MAKE) Test/DocTest-DropNS-classic.dll - $(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual Test/DocTest-DropNS-classic.dll + $(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual Test/DocTest-DropNS-classic.dll --api-style=classic $(MAKE) update-monodocer-dropns-unified diff --exclude=.svn -rup Test/en.expected-dropns-classic-v1 Test/en.actual @@ -186,12 +186,12 @@ check-monodocer-dropns-multi: $(PROGRAM) $(MAKE) Test/DocTest-DropNS-unified-multitest.dll # mdoc update for both classic and unified - $(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual $(MULTI-CLASSIC) -multiassembly - $(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual $(MULTI-UNIFIED) --dropns Test/DocTest-DropNS-unified.dll=MyFramework --dropns Test/DocTest-DropNS-unified-multitest.dll=MyFramework -multiassembly + $(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual $(MULTI-CLASSIC) --api-style=classic -multiassembly + $(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual $(MULTI-UNIFIED) --api-style=unified --dropns Test/DocTest-DropNS-unified.dll=MyFramework --dropns Test/DocTest-DropNS-unified-multitest.dll=MyFramework -multiassembly # now run it again to verify idempotency - $(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual $(MULTI-CLASSIC) -multiassembly - $(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual $(MULTI-UNIFIED) --dropns Test/DocTest-DropNS-unified.dll=MyFramework --dropns Test/DocTest-DropNS-unified-multitest.dll=MyFramework -multiassembly + $(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual $(MULTI-CLASSIC) --api-style=classic -multiassembly + $(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual $(MULTI-UNIFIED) --api-style=unified --dropns Test/DocTest-DropNS-unified.dll=MyFramework --dropns Test/DocTest-DropNS-unified-multitest.dll=MyFramework -multiassembly diff --exclude=.svn -rup Test/en.expected-dropns-multi Test/en.actual @@ -204,12 +204,12 @@ check-monodocer-dropns-multi-withexisting: $(PROGRAM) $(MAKE) Test/DocTest-DropNS-unified-multitest.dll # mdoc update to show a pre-existing set of documents - $(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual Test/DocTest-DropNS-classic.dll - $(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual Test/DocTest-DropNS-unified.dll --dropns Test/DocTest-DropNS-unified.dll=MyFramework + $(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual Test/DocTest-DropNS-classic.dll --api-style=classic + $(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual Test/DocTest-DropNS-unified.dll --api-style=unified --dropns Test/DocTest-DropNS-unified.dll=MyFramework # mdoc update for both classic and unified - $(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual $(MULTI-CLASSIC) -multiassembly - $(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual $(MULTI-UNIFIED) --dropns Test/DocTest-DropNS-unified.dll=MyFramework --dropns Test/DocTest-DropNS-unified-multitest.dll=MyFramework -multiassembly + $(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual $(MULTI-CLASSIC) --api-style=classic -multiassembly + $(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual $(MULTI-UNIFIED) --api-style=unified --dropns Test/DocTest-DropNS-unified.dll=MyFramework --dropns Test/DocTest-DropNS-unified-multitest.dll=MyFramework -multiassembly diff --exclude=.svn -rup Test/en.expected-dropns-multi-withexisting Test/en.actual @@ -218,13 +218,13 @@ check-monodocer-dropns-delete: $(PROGRAM) rm -Rf Test/DocTest-DropNS-classic-deletetest.dll rm -Rf Test/DocTest-DropNS-unified-deletetest.dll $(MAKE) Test/DocTest-DropNS-classic-deletetest.dll - $(MONO) $(PROGRAM) update --delete --exceptions=all -o Test/en.actual Test/DocTest-DropNS-classic-deletetest.dll + $(MONO) $(PROGRAM) update --delete --exceptions=all -o Test/en.actual Test/DocTest-DropNS-classic-deletetest.dll --api-style=classic $(MAKE) Test/DocTest-DropNS-unified-deletetest.dll - $(MONO) $(PROGRAM) update --delete --exceptions=all -o Test/en.actual Test/DocTest-DropNS-unified-deletetest.dll --dropns Test/DocTest-DropNS-unified-deletetest.dll=MyFramework + $(MONO) $(PROGRAM) update --delete --exceptions=all -o Test/en.actual Test/DocTest-DropNS-unified-deletetest.dll --api-style=unified --dropns Test/DocTest-DropNS-unified-deletetest.dll=MyFramework $(MAKE) Test/DocTest-DropNS-classic-deletetest-V2.dll - $(MONO) $(PROGRAM) update --delete --exceptions=all -o Test/en.actual Test/DocTest-DropNS-classic-deletetest.dll + $(MONO) $(PROGRAM) update --delete --exceptions=all -o Test/en.actual Test/DocTest-DropNS-classic-deletetest.dll --api-style=classic $(MAKE) Test/DocTest-DropNS-unified-deletetest-V2.dll - $(MONO) $(PROGRAM) update --delete --exceptions=all -o Test/en.actual Test/DocTest-DropNS-unified-deletetest.dll --dropns Test/DocTest-DropNS-unified-deletetest.dll=MyFramework + $(MONO) $(PROGRAM) update --delete --exceptions=all -o Test/en.actual Test/DocTest-DropNS-unified-deletetest.dll --api-style=unified --dropns Test/DocTest-DropNS-unified-deletetest.dll=MyFramework diff --exclude=.dvn -rup Test/en.expected-dropns-delete Test/en.actual check-monodocer-dropns-classic-withsecondary: $(PROGRAM) @@ -232,21 +232,21 @@ check-monodocer-dropns-classic-withsecondary: $(PROGRAM) -rm -Rf Test/en.actual $(MAKE) Test/DocTest-DropNS-classic.dll $(MAKE) Test/DocTest-DropNS-classic-secondary.dll - $(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual Test/DocTest-DropNS-classic.dll Test/DocTest-DropNS-classic-secondary.dll + $(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual Test/DocTest-DropNS-classic.dll Test/DocTest-DropNS-classic-secondary.dll --api-style=classic $(MAKE) update-monodocer-dropns-unified-withsecondary diff --exclude=.svn -rup Test/en.expected-dropns-classic-withsecondary Test/en.actual update-monodocer-dropns-unified: $(PROGRAM) $(MAKE) Test/DocTest-DropNS-unified.dll - $(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual Test/DocTest-DropNS-unified.dll --dropns Test/DocTest-DropNS-unified.dll=MyFramework + $(MONO) $(PROGRAM) update --debug --exceptions=all -o Test/en.actual Test/DocTest-DropNS-unified.dll --api-style=unified --dropns Test/DocTest-DropNS-unified.dll=MyFramework update-monodocer-dropns-unified-withsecondary: $(PROGRAM) $(MAKE) Test/DocTest-DropNS-unified.dll - $(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual Test/DocTest-DropNS-unified.dll Test/DocTest-DropNS-classic-secondary.dll --dropns Test/DocTest-DropNS-unified.dll=MyFramework + $(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual Test/DocTest-DropNS-unified.dll Test/DocTest-DropNS-classic-secondary.dll --api-style=unified --dropns Test/DocTest-DropNS-unified.dll=MyFramework update-monodocer-dropns-classic-secondary: $(PROGRAM) $(MAKE) Test/DocTest-DropNS-classic-secondary.dll - $(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual Test/DocTest-DropNS-classic-secondary.dll + $(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual Test/DocTest-DropNS-classic-secondary.dll --api-style=classic check-monodocer-internal-interface: $(PROGRAM) # Tests to make sure internal interfaces that are explicitly implemented are not documented diff --git a/mcs/tools/mdoc/Mono.Documentation/monodocer.cs b/mcs/tools/mdoc/Mono.Documentation/monodocer.cs index 0a031767cce..f1b9821365b 100644 --- a/mcs/tools/mdoc/Mono.Documentation/monodocer.cs +++ b/mcs/tools/mdoc/Mono.Documentation/monodocer.cs @@ -133,6 +133,8 @@ class MDocUpdater : MDocCommand List assemblies; readonly DefaultAssemblyResolver assemblyResolver = new DefaultAssemblyResolver(); + string apistyle = string.Empty; + bool isClassicRun; bool multiassembly; bool delete; bool show_exceptions; @@ -282,6 +284,9 @@ class MDocUpdater : MDocCommand { "multiassembly", "Allow types to be in multiple assemblies.", v => multiassembly = true }, + { "api-style=", + "Denotes the apistyle. Currently, only `classic` and `unified` are supported. `classic` set of assemblies should be run first, immediately followed by 'unified' assemblies with the `dropns` parameter.", + v => apistyle = v.ToLowerInvariant ()}, }; var assemblies = Parse (p, args, "update", "[OPTIONS]+ ASSEMBLIES", @@ -290,7 +295,17 @@ class MDocUpdater : MDocCommand return; if (assemblies.Count == 0) Error ("No assemblies specified."); - + + // validation for the api-style parameter + if (apistyle == "classic") + isClassicRun = true; + else if (apistyle == "unified") { + if (!droppedAssemblies.Any ()) + Error ("api-style 'unified' must also supply the 'dropns' parameter with at least one assembly and dropped namespace."); + } else if (!string.IsNullOrWhiteSpace (apistyle)) + Error ("api-style '{0}' is not currently supported", apistyle); + + foreach (var dir in assemblies .Where (a => a.Contains (Path.DirectorySeparatorChar)) .Select (a => Path.GetDirectoryName (a))) @@ -1045,7 +1060,7 @@ class MDocUpdater : MDocCommand saveDoc (); var unifiedAssemblyNode = doc.SelectSingleNode ("/Type/AssemblyInfo[@apistyle='unified']"); - var classicAssemblyNode = doc.SelectSingleNode ("/Type/AssemblyInfo[@apistyle='classic']"); + var classicAssemblyNode = doc.SelectSingleNode ("/Type/AssemblyInfo[not(@apistyle) or @apistyle='classic']"); var unifiedMembers = doc.SelectNodes ("//Member[@apistyle='unified']|//Member/AssemblyInfo[@apistyle='unified']"); var classicMembers = doc.SelectNodes ("//Member[@apistyle='classic']|//Member/AssemblyInfo[@apistyle='classic']"); bool isUnifiedRun = HasDroppedAnyNamespace (); @@ -1265,10 +1280,10 @@ class MDocUpdater : MDocCommand XmlElement mm = MakeMember(basefile, new DocsNodeInfo (null, m)); if (mm == null) continue; - if (MDocUpdater.SwitchingToMagicTypes) { + if (MDocUpdater.SwitchingToMagicTypes || MDocUpdater.HasDroppedNamespace (m)) { // this is a unified style API that obviously doesn't exist in the classic API. Let's mark // it with apistyle="unified", so that it's not displayed for classic style APIs - mm.SetAttribute ("apistyle", "unified"); + mm.AddApiStyle (ApiStyle.Unified); } members.AppendChild( mm ); @@ -1379,7 +1394,7 @@ class MDocUpdater : MDocCommand bool unifiedRun = HasDroppedNamespace (type); - var classicAssemblyInfo = member.SelectSingleNode ("AssemblyInfo[@apistyle='classic']"); + var classicAssemblyInfo = member.SelectSingleNode ("AssemblyInfo[not(@apistyle) or @apistyle='classic']"); bool nodeIsClassic = classicAssemblyInfo != null || member.HasApiStyle (ApiStyle.Classic); var unifiedAssemblyInfo = member.SelectSingleNode ("AssemblyInfo[@apistyle='unified']"); bool nodeIsUnified = unifiedAssemblyInfo != null || member.HasApiStyle (ApiStyle.Unified); @@ -1398,12 +1413,13 @@ class MDocUpdater : MDocCommand } else if (unifiedRun && nodeIsClassic) { // this is a unified run, and the member doesn't exist, but is marked as being in the classic assembly. member.RemoveApiStyle (ApiStyle.Unified); + member.AddApiStyle (ApiStyle.Classic); Warning ("Not removing '{0}' since it's still in the classic assembly.", signature); } else if (unifiedRun && !nodeIsClassic) { // unified run, and the node is not classic, which means it doesn't exist anywhere. actuallyDelete (); } else { - if (!nodeIsClassic && !nodeIsUnified) { // regular codepath (ie. not classic/unified) + if (!isClassicRun || (isClassicRun && !nodeIsClassic && !nodeIsUnified)) { // regular codepath (ie. not classic/unified) actuallyDelete (); } else { // this is a classic run Warning ("Removing classic from '{0}' ... will be removed in the unified run if not present there.", signature); @@ -1659,18 +1675,25 @@ class MDocUpdater : MDocCommand /// Adds an AssemblyInfo with AssemblyName node to an XmlElement. /// The assembly that was either added, or was already present - static XmlElement AddAssemblyNameToNode (XmlElement root, TypeDefinition type) + XmlElement AddAssemblyNameToNode (XmlElement root, TypeDefinition type) { return AddAssemblyNameToNode (root, type.Module); } /// Adds an AssemblyInfo with AssemblyName node to an XmlElement. /// The assembly that was either added, or was already present - static XmlElement AddAssemblyNameToNode (XmlElement root, ModuleDefinition module) + XmlElement AddAssemblyNameToNode (XmlElement root, ModuleDefinition module) { Func assemblyFilter = x => { var existingName = x.SelectSingleNode ("AssemblyName"); - return existingName != null && existingName.InnerText == module.Assembly.Name.Name; + + bool apiStyleMatches = true; + string currentApiStyle = x.GetAttribute ("apistyle"); + if ((HasDroppedNamespace (module) && !string.IsNullOrWhiteSpace (currentApiStyle) && currentApiStyle != "unified") || + (isClassicRun && (string.IsNullOrWhiteSpace (currentApiStyle) || currentApiStyle != "classic"))) { + apiStyleMatches = false; + } + return apiStyleMatches && (existingName == null || (existingName != null && existingName.InnerText == module.Assembly.Name.Name)); }; return AddAssemblyXmlNode ( @@ -1678,8 +1701,11 @@ class MDocUpdater : MDocCommand assemblyFilter, x => WriteElementText (x, "AssemblyName", module.Assembly.Name.Name), () => { XmlElement ass = WriteElement (root, "AssemblyInfo", forceNewElement: true); + if (MDocUpdater.HasDroppedNamespace (module)) - ass.SetAttribute ("apistyle", "unified"); + ass.AddApiStyle (ApiStyle.Unified); + if (isClassicRun) + ass.AddApiStyle (ApiStyle.Classic); return ass; }, module); } @@ -1785,8 +1811,8 @@ class MDocUpdater : MDocCommand XmlElement thisAssemblyNode = relevant.FirstOrDefault (valueMatches); if (thisAssemblyNode == null) { thisAssemblyNode = makeNewNode (); - setValue (thisAssemblyNode); } + setValue (thisAssemblyNode); if (isUnified) { thisAssemblyNode.AddApiStyle (ApiStyle.Unified); @@ -2357,7 +2383,7 @@ class MDocUpdater : MDocCommand n.ParentNode.RemoveChild(n); } - private static bool UpdateAssemblyVersions (XmlElement root, MemberReference member, bool add) + private bool UpdateAssemblyVersions (XmlElement root, MemberReference member, bool add) { TypeDefinition type = member as TypeDefinition; if (type == null) @@ -2376,8 +2402,11 @@ class MDocUpdater : MDocCommand return assembly.Name.Version.ToString(); } - private static bool UpdateAssemblyVersions(XmlElement root, AssemblyDefinition assembly, string[] assemblyVersions, bool add) + private bool UpdateAssemblyVersions(XmlElement root, AssemblyDefinition assembly, string[] assemblyVersions, bool add) { + if (multiassembly) + return false; + XmlElement av = (XmlElement) root.SelectSingleNode ("AssemblyVersions"); if (av != null) { // AssemblyVersions is not part of the spec @@ -2394,7 +2423,7 @@ class MDocUpdater : MDocCommand e = root.OwnerDocument.CreateElement("AssemblyInfo"); if (MDocUpdater.HasDroppedNamespace (assembly)) { - e.SetAttribute ("apistyle", "unified"); + e.AddApiStyle (ApiStyle.Unified); } root.AppendChild(e); @@ -2403,8 +2432,8 @@ class MDocUpdater : MDocCommand var thatNode = (XmlElement) root.SelectSingleNode (thatNodeFilter); if (MDocUpdater.HasDroppedNamespace (assembly) && thatNode != null) { // there's a classic node, we should add apistyles - e.SetAttribute ("apistyle", "unified"); - thatNode.SetAttribute ("apistyle", "classic"); + e.AddApiStyle (ApiStyle.Unified); + thatNode.AddApiStyle (ApiStyle.Classic); } return UpdateAssemblyVersionForAssemblyInfo (e, root, assemblyVersions, add); @@ -3042,6 +3071,39 @@ static class DocUtils { if (string.IsNullOrWhiteSpace (existingValue) || existingValue != styleString) { element.SetAttribute ("apistyle", styleString); } + + // Propagate the API style up to the membernode if necessary + if (element.LocalName == "AssemblyInfo" && element.ParentNode != null && element.ParentNode.LocalName == "Member") { + var member = element.ParentNode; + var unifiedAssemblyNode = member.SelectSingleNode ("AssemblyInfo[@apistyle='unified']"); + var classicAssemblyNode = member.SelectSingleNode ("AssemblyInfo[not(@apistyle) or @apistyle='classic']"); + + var parentAttribute = element.ParentNode.Attributes ["apistyle"]; + Action removeStyle = () => element.ParentNode.Attributes.Remove (parentAttribute); + Action propagateStyle = () => { + if (parentAttribute == null) { + // if it doesn't have the attribute, then add it + parentAttribute = element.OwnerDocument.CreateAttribute ("apistyle"); + parentAttribute.Value = styleString; + element.ParentNode.Attributes.Append (parentAttribute); + } + }; + + if ((style == ApiStyle.Classic && unifiedAssemblyNode != null) || (style == ApiStyle.Unified && classicAssemblyNode != null)) + removeStyle (); + else + propagateStyle (); + } + } + public static void AddApiStyle (this XmlNode node, ApiStyle style) + { + string styleString = style.ToString ().ToLowerInvariant (); + var existingAttribute = node.Attributes ["apistyle"]; + if (existingAttribute == null) { + existingAttribute = node.OwnerDocument.CreateAttribute ("apistyle"); + node.Attributes.Append (existingAttribute); + } + existingAttribute.Value = styleString; } public static void RemoveApiStyle (this XmlElement element, ApiStyle style) { diff --git a/mcs/tools/mdoc/Test/DocTest-DropNS-classic.cs b/mcs/tools/mdoc/Test/DocTest-DropNS-classic.cs index 13ae56d250c..303c58e8882 100644 --- a/mcs/tools/mdoc/Test/DocTest-DropNS-classic.cs +++ b/mcs/tools/mdoc/Test/DocTest-DropNS-classic.cs @@ -4,6 +4,8 @@ namespace MyFramework.MyNamespace { public float Hello(int value) { return 0.0f; } + public double OnlyInClassic {get;set;} + #if DELETETEST public string InBoth {get;set;} public string InBothClassic {get;set;} @@ -20,6 +22,10 @@ namespace MyFramework.MyNamespace { #endif } + #if DELETETEST + public class TypeOnlyInClassic {} + #endif + #if DELETETEST && !V2 public class WillDelete { public string Name {get;set;} diff --git a/mcs/tools/mdoc/Test/DocTest-DropNS-unified.cs b/mcs/tools/mdoc/Test/DocTest-DropNS-unified.cs index 0b74be24c58..b4fcc9ea01b 100644 --- a/mcs/tools/mdoc/Test/DocTest-DropNS-unified.cs +++ b/mcs/tools/mdoc/Test/DocTest-DropNS-unified.cs @@ -4,6 +4,8 @@ namespace MyNamespace { public float Hello(int value) { return 0.0f; } + public char OnlyInUnified {get;set;} + #if DELETETEST public string InBoth {get;set;} public string InBothUnified {get;set;} diff --git a/mcs/tools/mdoc/Test/en.expected-dropns-classic-v1/MyFramework.MyNamespace/MyClass.xml b/mcs/tools/mdoc/Test/en.expected-dropns-classic-v1/MyFramework.MyNamespace/MyClass.xml index e3cda6d9d99..77388be8815 100644 --- a/mcs/tools/mdoc/Test/en.expected-dropns-classic-v1/MyFramework.MyNamespace/MyClass.xml +++ b/mcs/tools/mdoc/Test/en.expected-dropns-classic-v1/MyFramework.MyNamespace/MyClass.xml @@ -76,5 +76,37 @@ To be added. + + + + Property + + 0.0.0.0 + + + System.Double + + + To be added. + To be added. + To be added. + + + + + + Property + + 0.0.0.0 + + + System.Char + + + To be added. + To be added. + To be added. + + diff --git a/mcs/tools/mdoc/Test/en.expected-dropns-classic-withsecondary/MyFramework.MyNamespace/MyClass.xml b/mcs/tools/mdoc/Test/en.expected-dropns-classic-withsecondary/MyFramework.MyNamespace/MyClass.xml index e3cda6d9d99..77388be8815 100644 --- a/mcs/tools/mdoc/Test/en.expected-dropns-classic-withsecondary/MyFramework.MyNamespace/MyClass.xml +++ b/mcs/tools/mdoc/Test/en.expected-dropns-classic-withsecondary/MyFramework.MyNamespace/MyClass.xml @@ -76,5 +76,37 @@ To be added. + + + + Property + + 0.0.0.0 + + + System.Double + + + To be added. + To be added. + To be added. + + + + + + Property + + 0.0.0.0 + + + System.Char + + + To be added. + To be added. + To be added. + + diff --git a/mcs/tools/mdoc/Test/en.expected-dropns-classic-withsecondary/MyFramework.MyOtherNamespace/MyOtherClass.xml b/mcs/tools/mdoc/Test/en.expected-dropns-classic-withsecondary/MyFramework.MyOtherNamespace/MyOtherClass.xml index a178fc47d6e..a920ce2f499 100644 --- a/mcs/tools/mdoc/Test/en.expected-dropns-classic-withsecondary/MyFramework.MyOtherNamespace/MyOtherClass.xml +++ b/mcs/tools/mdoc/Test/en.expected-dropns-classic-withsecondary/MyFramework.MyOtherNamespace/MyOtherClass.xml @@ -1,7 +1,7 @@ - + DocTest-DropNS-classic-secondary 0.0.0.0 diff --git a/mcs/tools/mdoc/Test/en.expected-dropns-delete/MyFramework.MyNamespace/MyClass.xml b/mcs/tools/mdoc/Test/en.expected-dropns-delete/MyFramework.MyNamespace/MyClass.xml index cb620b81f8a..1ff3447bab2 100644 --- a/mcs/tools/mdoc/Test/en.expected-dropns-delete/MyFramework.MyNamespace/MyClass.xml +++ b/mcs/tools/mdoc/Test/en.expected-dropns-delete/MyFramework.MyNamespace/MyClass.xml @@ -53,7 +53,7 @@ To be added. - + Property @@ -69,7 +69,7 @@ To be added. - + Property @@ -127,7 +127,7 @@ To be added. - + Property @@ -165,7 +165,7 @@ To be added. - + Property @@ -200,5 +200,37 @@ To be added. + + + + Property + + 0.0.0.0 + + + System.Double + + + To be added. + To be added. + To be added. + + + + + + Property + + 0.0.0.0 + + + System.Char + + + To be added. + To be added. + To be added. + + diff --git a/mcs/tools/mdoc/Test/en.expected-dropns-delete/MyFramework.MyNamespace/TypeOnlyInClassic.xml b/mcs/tools/mdoc/Test/en.expected-dropns-delete/MyFramework.MyNamespace/TypeOnlyInClassic.xml new file mode 100644 index 00000000000..7e6adf24eb3 --- /dev/null +++ b/mcs/tools/mdoc/Test/en.expected-dropns-delete/MyFramework.MyNamespace/TypeOnlyInClassic.xml @@ -0,0 +1,31 @@ + + + + + DocTest-DropNS-classic-deletetest + 0.0.0.0 + + + System.Object + + + + To be added. + To be added. + + + + + + Constructor + + 0.0.0.0 + + + + To be added. + To be added. + + + + diff --git a/mcs/tools/mdoc/Test/en.expected-dropns-multi-withexisting/MyFramework.MyNamespace/MyClass.xml b/mcs/tools/mdoc/Test/en.expected-dropns-multi-withexisting/MyFramework.MyNamespace/MyClass.xml index bca840fcedd..e73f7d55ff3 100644 --- a/mcs/tools/mdoc/Test/en.expected-dropns-multi-withexisting/MyFramework.MyNamespace/MyClass.xml +++ b/mcs/tools/mdoc/Test/en.expected-dropns-multi-withexisting/MyFramework.MyNamespace/MyClass.xml @@ -32,22 +32,16 @@ Constructor 0.0.0.0 + DocTest-DropNS-classic 0.0.0.0 - - - DocTest-DropNS-classic - 0.0.0.0 + DocTest-DropNS-unified DocTest-DropNS-classic-multitest 0.0.0.0 - - DocTest-DropNS-unified - 0.0.0.0 - DocTest-DropNS-unified-multitest 0.0.0.0 @@ -64,22 +58,16 @@ Method 0.0.0.0 + DocTest-DropNS-classic 0.0.0.0 - - - DocTest-DropNS-classic - 0.0.0.0 + DocTest-DropNS-unified DocTest-DropNS-classic-multitest 0.0.0.0 - - DocTest-DropNS-unified - 0.0.0.0 - DocTest-DropNS-unified-multitest 0.0.0.0 @@ -103,28 +91,64 @@ Property 0.0.0.0 + DocTest-DropNS-classic 0.0.0.0 + DocTest-DropNS-unified - DocTest-DropNS-classic + DocTest-DropNS-classic-multitest + 0.0.0.0 + + + DocTest-DropNS-unified-multitest 0.0.0.0 + + System.String + + + To be added. + To be added. + To be added. + + + + + + Property + + 0.0.0.0 + DocTest-DropNS-classic + DocTest-DropNS-classic-multitest 0.0.0.0 + + System.Double + + + To be added. + To be added. + To be added. + + + + + + Property - DocTest-DropNS-unified 0.0.0.0 + DocTest-DropNS-unified DocTest-DropNS-unified-multitest 0.0.0.0 - System.String + System.Char To be added. diff --git a/mcs/tools/mdoc/Test/en.expected-dropns-multi/MyFramework.MyNamespace/MyClass.xml b/mcs/tools/mdoc/Test/en.expected-dropns-multi/MyFramework.MyNamespace/MyClass.xml index ee4297658d5..72eabefc552 100644 --- a/mcs/tools/mdoc/Test/en.expected-dropns-multi/MyFramework.MyNamespace/MyClass.xml +++ b/mcs/tools/mdoc/Test/en.expected-dropns-multi/MyFramework.MyNamespace/MyClass.xml @@ -114,5 +114,47 @@ To be added. + + + + Property + + DocTest-DropNS-classic + 0.0.0.0 + + + DocTest-DropNS-classic-multitest + 0.0.0.0 + + + System.Double + + + To be added. + To be added. + To be added. + + + + + + Property + + DocTest-DropNS-unified + 0.0.0.0 + + + DocTest-DropNS-unified-multitest + 0.0.0.0 + + + System.Char + + + To be added. + To be added. + To be added. + + diff --git a/mono/cil/cil-opcodes.xml b/mono/cil/cil-opcodes.xml index 5f747c7a9b2..a86b2be3741 100644 --- a/mono/cil/cil-opcodes.xml +++ b/mono/cil/cil-opcodes.xml @@ -315,4 +315,6 @@ + + diff --git a/mono/cil/opcode.def b/mono/cil/opcode.def index 96f53eb9eef..ad89c95e46c 100644 --- a/mono/cil/opcode.def +++ b/mono/cil/opcode.def @@ -316,6 +316,7 @@ OPDEF(CEE_MONO_LDPTR_INT_REQ_FLAG, "mono_ldptr_int_req_flag", Pop0, PushI, Inlin OPDEF(CEE_MONO_LDPTR_CARD_TABLE, "mono_ldptr_card_table", Pop0, PushI, InlineNone, X, 2, 0xF0, 0x15, NEXT) OPDEF(CEE_MONO_LDPTR_NURSERY_START, "mono_ldptr_nursery_start", Pop0, PushI, InlineNone, X, 2, 0xF0, 0x16, NEXT) OPDEF(CEE_MONO_LDPTR_NURSERY_BITS, "mono_ldptr_nursery_bits", Pop0, PushI, InlineNone, X, 2, 0xF0, 0x17, NEXT) +OPDEF(CEE_MONO_CALLI_EXTRA_ARG, "mono_calli_extra_arg", VarPop, VarPush, InlineSig, X, 2, 0xF0, 0x18, CALL) #ifndef OPALIAS #define _MONO_CIL_OPALIAS_DEFINED_ #define OPALIAS(a,s,r) diff --git a/mono/metadata/debug-mono-ppdb.c b/mono/metadata/debug-mono-ppdb.c index cdd5af3f5e8..fcbfd9d817f 100644 --- a/mono/metadata/debug-mono-ppdb.c +++ b/mono/metadata/debug-mono-ppdb.c @@ -97,7 +97,7 @@ doc_free (gpointer key) MonoPPDBFile* mono_ppdb_load_file (MonoImage *image, const guint8 *raw_contents, int size) { - MonoImage *ppdb_image; + MonoImage *ppdb_image = NULL; const char *filename; char *s, *ppdb_filename; MonoImageOpenStatus status; @@ -107,7 +107,8 @@ mono_ppdb_load_file (MonoImage *image, const guint8 *raw_contents, int size) MonoPPDBFile *ppdb; if (raw_contents) { - ppdb_image = mono_image_open_from_data_internal ((char*)raw_contents, size, TRUE, &status, FALSE, TRUE, NULL); + if (size > 4 && strncmp ((char*)raw_contents, "BSJB", 4) == 0) + ppdb_image = mono_image_open_from_data_internal ((char*)raw_contents, size, TRUE, &status, FALSE, TRUE, NULL); } else { /* ppdb files drop the .exe/.dll extension */ filename = mono_image_get_filename (image); @@ -519,16 +520,39 @@ mono_ppdb_lookup_locals (MonoDebugMethodInfo *minfo) scope_idx = start_scope_idx; mono_metadata_decode_row (&tables [MONO_TABLE_LOCALSCOPE], scope_idx-1, cols, MONO_LOCALSCOPE_SIZE); locals_idx = cols [MONO_LOCALSCOPE_VARIABLELIST]; - while (scope_idx == tables [MONO_TABLE_LOCALSCOPE].rows) { + + // https://github.com/dotnet/roslyn/blob/2ae8d5fed96ab3f1164031f9b4ac827f53289159/docs/specs/PortablePdb-Metadata.md#LocalScopeTable + // + // The variableList attribute in the pdb metadata table is a contiguous array that starts at a + // given offset (locals_idx) above and + // + // """ + // continues to the smaller of: + // + // the last row of the LocalVariable table + // the next run of LocalVariables, found by inspecting the VariableList of the next row in this LocalScope table. + // """ + // this endpoint becomes locals_end_idx below + + // March to the last scope that is in this method + while (scope_idx <= tables [MONO_TABLE_LOCALSCOPE].rows) { mono_metadata_decode_row (&tables [MONO_TABLE_LOCALSCOPE], scope_idx-1, cols, MONO_LOCALSCOPE_SIZE); if (cols [MONO_LOCALSCOPE_METHOD] != method_idx) break; scope_idx ++; } + // The number of scopes is the difference in the indices + // for the first and last scopes nscopes = scope_idx - start_scope_idx; - if (scope_idx == tables [MONO_TABLE_LOCALSCOPE].rows) { - locals_end_idx = tables [MONO_TABLE_LOCALVARIABLE].rows; + + // Ends with "the last row of the LocalVariable table" + // this happens if the above loop marched one past the end + // of the rows + if (scope_idx > tables [MONO_TABLE_LOCALSCOPE].rows) { + locals_end_idx = tables [MONO_TABLE_LOCALVARIABLE].rows + 1; } else { + // Ends with "the next run of LocalVariables, + // found by inspecting the VariableList of the next row in this LocalScope table." locals_end_idx = cols [MONO_LOCALSCOPE_VARIABLELIST]; } @@ -545,7 +569,7 @@ mono_ppdb_lookup_locals (MonoDebugMethodInfo *minfo) locals_idx = cols [MONO_LOCALSCOPE_VARIABLELIST]; if (scope_idx == tables [MONO_TABLE_LOCALSCOPE].rows) { - locals_end_idx = tables [MONO_TABLE_LOCALVARIABLE].rows; + locals_end_idx = tables [MONO_TABLE_LOCALVARIABLE].rows + 1; } else { locals_end_idx = mono_metadata_decode_row_col (&tables [MONO_TABLE_LOCALSCOPE], scope_idx-1 + 1, MONO_LOCALSCOPE_VARIABLELIST); } diff --git a/mono/metadata/gc.c b/mono/metadata/gc.c index e0f12d34b55..901a985a587 100644 --- a/mono/metadata/gc.c +++ b/mono/metadata/gc.c @@ -236,7 +236,7 @@ mono_gc_run_finalize (void *obj, void *data) g_log ("mono-gc-finalizers", G_LOG_LEVEL_MESSAGE, "<%s at %p> Compiling finalizer.", o->vtable->klass->name, o); if (!domain->finalize_runtime_invoke) { - MonoMethod *invoke = mono_marshal_get_runtime_invoke (mono_class_get_method_from_name_flags (mono_defaults.object_class, "Finalize", 0, 0), TRUE, FALSE); + MonoMethod *invoke = mono_marshal_get_runtime_invoke (mono_class_get_method_from_name_flags (mono_defaults.object_class, "Finalize", 0, 0), TRUE); domain->finalize_runtime_invoke = mono_compile_method (invoke); } diff --git a/mono/metadata/icall.c b/mono/metadata/icall.c index f572212d08c..69c89e9faf1 100644 --- a/mono/metadata/icall.c +++ b/mono/metadata/icall.c @@ -879,6 +879,9 @@ ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_RunClassConstructor (Mo klass = mono_class_from_mono_type (handle); MONO_CHECK_ARG (handle, klass,); + if (klass->generic_container) + return; + vtable = mono_class_vtable_full (mono_domain_get (), klass, TRUE); /* This will call the type constructor */ diff --git a/mono/metadata/marshal.c b/mono/metadata/marshal.c index 8fcc61e3691..70e471dba2d 100644 --- a/mono/metadata/marshal.c +++ b/mono/metadata/marshal.c @@ -3010,22 +3010,6 @@ free_signature_pointer_pair (SignaturePointerPair *pair) g_free (pair); } -static MonoMethodSignature* -sig_to_rgctx_sig (MonoMethodSignature *sig) -{ - // FIXME: memory allocation - MonoMethodSignature *res; - int i; - - res = (MonoMethodSignature *)g_malloc (MONO_SIZEOF_METHOD_SIGNATURE + (sig->param_count + 1) * sizeof (MonoType*)); - memcpy (res, sig, MONO_SIZEOF_METHOD_SIGNATURE); - res->param_count = sig->param_count + 1; - for (i = 0; i < sig->param_count; ++i) - res->params [i] = sig->params [i]; - res->params [sig->param_count] = &mono_defaults.int_class->byval_arg; - return res; -} - MonoMethod * mono_marshal_get_delegate_invoke_internal (MonoMethod *method, gboolean callvirt, gboolean static_method_with_first_arg_bound, MonoMethod *target_method) { @@ -3038,7 +3022,7 @@ mono_marshal_get_delegate_invoke_internal (MonoMethod *method, gboolean callvirt SignaturePointerPair key; SignaturePointerPair *new_key; int local_i, local_len, local_delegates, local_d, local_target, local_res; - int pos0, pos1, pos2, pos3, pos4; + int pos0, pos1, pos2; char *name; MonoClass *target_class = NULL; gboolean closed_over_null = FALSE; @@ -3226,17 +3210,6 @@ mono_marshal_get_delegate_invoke_internal (MonoMethod *method, gboolean callvirt // FIXME: mono_mb_emit_exception_full (mb, "System", "NotImplementedException", ""); } else { - MonoMethodSignature *rgctx_sig; - - // FIXME: Support this for the other cases as well - mono_mb_emit_ldarg (mb, 0); - mono_mb_emit_ldflda (mb, MONO_STRUCT_OFFSET (MonoDelegate, rgctx)); - mono_mb_emit_byte (mb, CEE_LDIND_I); - pos3 = mono_mb_emit_branch (mb, CEE_BRFALSE); - - /* Rgctx case */ - rgctx_sig = sig_to_rgctx_sig (sig); - mono_mb_emit_ldloc (mb, local_target); for (i = 0; i < sig->param_count; ++i) mono_mb_emit_ldarg (mb, i + 1); @@ -3246,21 +3219,8 @@ mono_marshal_get_delegate_invoke_internal (MonoMethod *method, gboolean callvirt mono_mb_emit_ldarg (mb, 0); mono_mb_emit_ldflda (mb, MONO_STRUCT_OFFSET (MonoDelegate, method_ptr)); mono_mb_emit_byte (mb, CEE_LDIND_I); - mono_mb_emit_op (mb, CEE_CALLI, rgctx_sig); - pos4 = mono_mb_emit_branch (mb, CEE_BR); - - /* Non-rgctx case */ - mono_mb_patch_branch (mb, pos3); - mono_mb_emit_ldloc (mb, local_target); - for (i = 0; i < sig->param_count; ++i) - mono_mb_emit_ldarg (mb, i + 1); - mono_mb_emit_ldarg (mb, 0); - mono_mb_emit_ldflda (mb, MONO_STRUCT_OFFSET (MonoDelegate, method_ptr)); - mono_mb_emit_byte (mb, CEE_LDIND_I ); - mono_mb_emit_op (mb, CEE_CALLI, sig); - - mono_mb_patch_branch (mb, pos4); - + mono_mb_emit_byte (mb, MONO_CUSTOM_PREFIX); + mono_mb_emit_op (mb, CEE_MONO_CALLI_EXTRA_ARG, sig); mono_mb_emit_byte (mb, CEE_RET); } @@ -3289,16 +3249,6 @@ mono_marshal_get_delegate_invoke_internal (MonoMethod *method, gboolean callvirt mono_mb_emit_op (mb, CEE_CALL, target_method); } } else { - MonoMethodSignature *rgctx_sig; - - mono_mb_emit_ldarg (mb, 0); - mono_mb_emit_ldflda (mb, MONO_STRUCT_OFFSET (MonoDelegate, rgctx)); - mono_mb_emit_byte (mb, CEE_LDIND_I); - pos3 = mono_mb_emit_branch (mb, CEE_BRFALSE); - - /* Rgctx case */ - rgctx_sig = sig_to_rgctx_sig (invoke_sig); - if (static_method_with_first_arg_bound) { mono_mb_emit_ldloc (mb, local_target); if (!MONO_TYPE_IS_REFERENCE (invoke_sig->params[0])) @@ -3312,24 +3262,8 @@ mono_marshal_get_delegate_invoke_internal (MonoMethod *method, gboolean callvirt mono_mb_emit_ldarg (mb, 0); mono_mb_emit_ldflda (mb, MONO_STRUCT_OFFSET (MonoDelegate, method_ptr)); mono_mb_emit_byte (mb, CEE_LDIND_I); - mono_mb_emit_op (mb, CEE_CALLI, rgctx_sig); - pos4 = mono_mb_emit_branch (mb, CEE_BR); - - /* Non-rgctx case */ - mono_mb_patch_branch (mb, pos3); - if (static_method_with_first_arg_bound) { - mono_mb_emit_ldloc (mb, local_target); - if (!MONO_TYPE_IS_REFERENCE (invoke_sig->params[0])) - mono_mb_emit_op (mb, CEE_UNBOX_ANY, mono_class_from_mono_type (invoke_sig->params[0])); - } - for (i = 0; i < sig->param_count; ++i) - mono_mb_emit_ldarg (mb, i + 1); - mono_mb_emit_ldarg (mb, 0); - mono_mb_emit_ldflda (mb, MONO_STRUCT_OFFSET (MonoDelegate, method_ptr)); - mono_mb_emit_byte (mb, CEE_LDIND_I); - mono_mb_emit_op (mb, CEE_CALLI, invoke_sig); - - mono_mb_patch_branch (mb, pos4); + mono_mb_emit_byte (mb, MONO_CUSTOM_PREFIX); + mono_mb_emit_op (mb, CEE_MONO_CALLI_EXTRA_ARG, invoke_sig); } mono_mb_emit_byte (mb, CEE_RET); @@ -3385,23 +3319,21 @@ mono_marshal_get_delegate_invoke_internal (MonoMethod *method, gboolean callvirt mb->skip_visibility = 1; #endif /* DISABLE_JIT */ + info = mono_wrapper_info_create (mb, subtype); + if (ctx) { MonoMethod *def; - def = mono_mb_create_and_cache (cache, cache_key, mb, sig, sig->param_count + 16); + def = mono_mb_create_and_cache_full (cache, cache_key, mb, sig, sig->param_count + 16, info, NULL); res = cache_generic_delegate_wrapper (cache, orig_method, def, ctx); } else if (callvirt) { new_key = g_new0 (SignaturePointerPair, 1); *new_key = key; - info = mono_wrapper_info_create (mb, subtype); - res = mono_mb_create_and_cache_full (cache, new_key, mb, sig, sig->param_count + 16, info, &found); if (found) g_free (new_key); } else { - info = mono_wrapper_info_create (mb, subtype); - res = mono_mb_create_and_cache_full (cache, cache_key, mb, sig, sig->param_count + 16, info, NULL); } mono_mb_free (mb); @@ -3872,11 +3804,9 @@ emit_runtime_invoke_body (MonoMethodBuilder *mb, MonoImage *image, MonoMethod *m * it means that the compiled code for METHOD does not have to be looked up * before calling the runtime invoke wrapper. In this case, the wrapper ignores * its METHOD argument. - * If PASS_RGCTX is TRUE, the signature of the called method is changed to include a 'gpointer rgctx' as the - * last argument (after 'this'). */ MonoMethod * -mono_marshal_get_runtime_invoke (MonoMethod *method, gboolean virtual_, gboolean pass_rgctx) +mono_marshal_get_runtime_invoke (MonoMethod *method, gboolean virtual_) { MonoMethodSignature *sig, *csig, *callsig; MonoMethodBuilder *mb; @@ -3942,11 +3872,6 @@ mono_marshal_get_runtime_invoke (MonoMethod *method, gboolean virtual_, gboolean sig = mono_method_signature (method); - if (pass_rgctx) { - sig = sig_to_rgctx_sig (sig); - callsig = sig_to_rgctx_sig (callsig); - } - target_klass = get_wrapper_target_class (method->klass->image); /* Try to share wrappers for non-corlib methods with simple signatures */ @@ -4006,7 +3931,7 @@ mono_marshal_get_runtime_invoke (MonoMethod *method, gboolean virtual_, gboolean csig->call_convention = MONO_CALL_C; #endif - name = mono_signature_to_name (callsig, pass_rgctx ? (virtual_ ? "runtime_invoke_virtual_rgctx" : "runtime_invoke_rgctx") : (virtual_ ? "runtime_invoke_virtual" : "runtime_invoke")); + name = mono_signature_to_name (callsig, virtual_ ? "runtime_invoke_virtual" : "runtime_invoke"); mb = mono_mb_new (target_klass, name, MONO_WRAPPER_RUNTIME_INVOKE); g_free (name); @@ -4035,7 +3960,6 @@ mono_marshal_get_runtime_invoke (MonoMethod *method, gboolean virtual_, gboolean info = mono_wrapper_info_create (mb, WRAPPER_SUBTYPE_RUNTIME_INVOKE_NORMAL); info->d.runtime_invoke.sig = callsig; - info->d.runtime_invoke.pass_rgctx = pass_rgctx; /* Somebody may have created it before us */ if (!res) { diff --git a/mono/metadata/marshal.h b/mono/metadata/marshal.h index 2814208700e..494ff3d435e 100644 --- a/mono/metadata/marshal.h +++ b/mono/metadata/marshal.h @@ -142,7 +142,6 @@ typedef struct { MonoMethod *method; /* For WRAPPER_SUBTYPE_RUNTIME_INVOKE_NORMAL */ MonoMethodSignature *sig; - gboolean pass_rgctx; } RuntimeInvokeWrapperInfo; typedef struct { @@ -347,7 +346,7 @@ MonoMethod * mono_marshal_get_delegate_invoke_internal (MonoMethod *method, gboolean callvirt, gboolean static_method_with_first_arg_bound, MonoMethod *target_method); MonoMethod * -mono_marshal_get_runtime_invoke (MonoMethod *method, gboolean is_virtual, gboolean pass_rgctx); +mono_marshal_get_runtime_invoke (MonoMethod *method, gboolean is_virtual); MonoMethod* mono_marshal_get_runtime_invoke_dynamic (void); diff --git a/mono/metadata/object-internals.h b/mono/metadata/object-internals.h index a2d384eebf4..60cfaac692c 100644 --- a/mono/metadata/object-internals.h +++ b/mono/metadata/object-internals.h @@ -604,8 +604,9 @@ typedef struct { gpointer (*create_ftnptr) (MonoDomain *domain, gpointer addr); gpointer (*get_addr_from_ftnptr) (gpointer descr); char* (*get_runtime_build_info) (void); - gpointer (*get_vtable_trampoline) (int slot_index); - gpointer (*get_imt_trampoline) (int imt_slot_index); + gpointer (*get_vtable_trampoline) (MonoVTable *vtable, int slot_index); + gpointer (*get_imt_trampoline) (MonoVTable *vtable, int imt_slot_index); + gboolean (*imt_entry_inited) (MonoVTable *vtable, int imt_slot_index); void (*set_cast_details) (MonoClass *from, MonoClass *to); void (*debug_log) (int level, MonoString *category, MonoString *message); gboolean (*debug_log_is_enabled) (void); @@ -1547,6 +1548,9 @@ typedef gpointer (*MonoImtThunkBuilder) (MonoVTable *vtable, MonoDomain *domain, void mono_install_imt_thunk_builder (MonoImtThunkBuilder func); +void +mono_set_always_build_imt_thunks (gboolean value); + void mono_vtable_build_imt_slot (MonoVTable* vtable, int imt_slot); diff --git a/mono/metadata/object.c b/mono/metadata/object.c index a28c6f15d9d..8ba5568aa9d 100644 --- a/mono/metadata/object.c +++ b/mono/metadata/object.c @@ -528,6 +528,8 @@ static MonoTrampoline arch_create_jit_trampoline = default_trampoline; static MonoJumpTrampoline arch_create_jump_trampoline = default_jump_trampoline; static MonoDelegateTrampoline arch_create_delegate_trampoline = default_delegate_trampoline; static MonoImtThunkBuilder imt_thunk_builder; +static gboolean always_build_imt_thunks; + #if (MONO_IMT_SIZE > 32) #error "MONO_IMT_SIZE cannot be larger than 32" #endif @@ -575,6 +577,12 @@ mono_install_imt_thunk_builder (MonoImtThunkBuilder func) { imt_thunk_builder = func; } +void +mono_set_always_build_imt_thunks (gboolean value) +{ + always_build_imt_thunks = value; +} + static MonoCompileFunc default_mono_compile_method = NULL; /** @@ -1287,7 +1295,7 @@ initialize_imt_slot (MonoVTable *vtable, MonoDomain *domain, MonoImtBuilderEntry MONO_REQ_GC_NEUTRAL_MODE; if (imt_builder_entry != NULL) { - if (imt_builder_entry->children == 0 && !fail_tramp) { + if (imt_builder_entry->children == 0 && !fail_tramp && !always_build_imt_thunks) { /* No collision, return the vtable slot contents */ return vtable->vtable [imt_builder_entry->value.vtable_slot]; } else { @@ -1425,7 +1433,7 @@ build_imt_slots (MonoClass *klass, MonoVTable *vt, MonoDomain *domain, gpointer* * The IMT thunk might be called with an instance of one of the * generic virtual methods, so has to fallback to the IMT trampoline. */ - imt [i] = initialize_imt_slot (vt, domain, imt_builder [i], callbacks.get_imt_trampoline (i)); + imt [i] = initialize_imt_slot (vt, domain, imt_builder [i], callbacks.get_imt_trampoline (vt, i)); } else { imt [i] = initialize_imt_slot (vt, domain, imt_builder [i], NULL); } @@ -1497,7 +1505,7 @@ mono_vtable_build_imt_slot (MonoVTable* vtable, int imt_slot) mono_loader_lock (); /*FIXME build_imt_slots requires the loader lock.*/ mono_domain_lock (vtable->domain); /* we change the slot only if it wasn't changed from the generic imt trampoline already */ - if (imt [imt_slot] == callbacks.get_imt_trampoline (imt_slot)) + if (!callbacks.imt_entry_inited (vtable, imt_slot)) build_imt_slots (vtable->klass, vtable, vtable->domain, imt, NULL, imt_slot); mono_domain_unlock (vtable->domain); mono_loader_unlock (); @@ -1784,10 +1792,10 @@ mono_method_add_generic_virtual_invocation (MonoDomain *domain, MonoVTable *vtab int imt_slot = MONO_IMT_SIZE + displacement; /* Force the rebuild of the thunk at the next call */ - imt_trampoline = callbacks.get_imt_trampoline (imt_slot); + imt_trampoline = callbacks.get_imt_trampoline (vtable, imt_slot); *vtable_slot = imt_trampoline; } else { - vtable_trampoline = callbacks.get_vtable_trampoline ? callbacks.get_vtable_trampoline ((gpointer*)vtable_slot - (gpointer*)vtable->vtable) : NULL; + vtable_trampoline = callbacks.get_vtable_trampoline ? callbacks.get_vtable_trampoline (vtable, (gpointer*)vtable_slot - (gpointer*)vtable->vtable) : NULL; entries = get_generic_virtual_entries (domain, vtable_slot); @@ -2137,7 +2145,7 @@ mono_class_create_runtime_vtable (MonoDomain *domain, MonoClass *klass, gboolean if (callbacks.get_vtable_trampoline) { // This also covers the AOT case for (i = 0; i < klass->vtable_size; ++i) { - vt->vtable [i] = callbacks.get_vtable_trampoline (i); + vt->vtable [i] = callbacks.get_vtable_trampoline (vt, i); } } else { mono_class_setup_vtable (klass); @@ -2153,7 +2161,7 @@ mono_class_create_runtime_vtable (MonoDomain *domain, MonoClass *klass, gboolean if (imt_table_bytes) { /* Now that the vtable is full, we can actually fill up the IMT */ for (i = 0; i < MONO_IMT_SIZE; ++i) - interface_offsets [i] = callbacks.get_imt_trampoline (i); + interface_offsets [i] = callbacks.get_imt_trampoline (vt, i); } /* @@ -6027,7 +6035,7 @@ mono_runtime_capture_context (MonoDomain *domain) MonoMethod *wrapper; if (!method) return NULL; - wrapper = mono_marshal_get_runtime_invoke (method, FALSE, FALSE); + wrapper = mono_marshal_get_runtime_invoke (method, FALSE); domain->capture_context_runtime_invoke = mono_compile_method (wrapper); domain->capture_context_method = mono_compile_method (method); } diff --git a/mono/metadata/sgen-mono.c b/mono/metadata/sgen-mono.c index f6ae431afde..8d3b7c137eb 100644 --- a/mono/metadata/sgen-mono.c +++ b/mono/metadata/sgen-mono.c @@ -2980,6 +2980,12 @@ mono_gc_base_init (void) if (nursery_canaries_enabled ()) sgen_set_use_managed_allocator (FALSE); + +#if defined(HAVE_KW_THREAD) + /* This can happen with using libmonosgen.so */ + if (mono_tls_key_get_offset (TLS_KEY_SGEN_TLAB_NEXT_ADDR) == -1) + sgen_set_use_managed_allocator (FALSE); +#endif } void diff --git a/mono/mini/Makefile.am.in b/mono/mini/Makefile.am.in index ab9fe4f39f0..675891ab61c 100755 --- a/mono/mini/Makefile.am.in +++ b/mono/mini/Makefile.am.in @@ -744,7 +744,7 @@ llvmonlycheck: mono $(llvmonly_regtests) cp $(llvmonly_regtests) generics-variant-types.dll TestDriver.dll fullaot-tmp/ MONO_PATH=fullaot-tmp $(top_builddir)/runtime/mono-wrapper --aot=llvmonly fullaot-tmp/{generics-variant-types.dll,TestDriver.dll,*.exe} || exit 1 ln -s $$PWD/mono fullaot-tmp/ - for i in $(llvmonly_regtests); do echo $$i; MONO_PATH=fullaot-tmp $(top_builddir)/runtime/mono-wrapper --llvmonly fullaot-tmp/$$i --exclude '!FULLAOT' --exclude '!BITCODE' $(ARCH_FULLAOT_EXCLUDE) || exit 1; done + for i in $(llvmonly_regtests); do echo $$i; MONO_PATH=fullaot-tmp $(top_builddir)/runtime/mono-wrapper --llvmonly fullaot-tmp/$$i --exclude '!FULLAOT' --exclude '!BITCODE' || exit 1; done gccheck: gc-test.exe MONO_GC_PARAMS=stack-mark=precise MONO_GC_DEBUG=clear-at-gc ./mono-sgen gc-test.exe diff --git a/mono/mini/aot-compiler.c b/mono/mini/aot-compiler.c index f70fbb6b27b..8bad463b084 100644 --- a/mono/mini/aot-compiler.c +++ b/mono/mini/aot-compiler.c @@ -137,11 +137,20 @@ typedef struct MonoAotOptions { gboolean dump_json; } MonoAotOptions; +typedef enum { + METHOD_CAT_NORMAL, + METHOD_CAT_GSHAREDVT, + METHOD_CAT_INST, + METHOD_CAT_WRAPPER, + METHOD_CAT_NUM +} MethodCategory; + typedef struct MonoAotStats { int ccount, mcount, lmfcount, abscount, gcount, ocount, genericcount; gint64 code_size, info_size, ex_info_size, unwind_info_size, got_size, class_info_size, got_info_size, plt_size; int methods_without_got_slots, direct_calls, all_calls, llvm_count; int got_slots, offsets_size; + int method_categories [METHOD_CAT_NUM]; int got_slot_types [MONO_PATCH_INFO_NONE]; int got_slot_info_sizes [MONO_PATCH_INFO_NONE]; int jit_time, gen_time, link_time; @@ -2338,6 +2347,12 @@ emit_aot_data (MonoAotCompile *acfg, MonoAotFileTable table, const char *symbol, acfg->table_offsets [(int)table] = acfg->datafile_offset; fwrite (data,1, size, acfg->data_outfile); acfg->datafile_offset += size; + // align the data to 8 bytes. Put zeros in the file (so that every build results in consistent output). + int align = 8 - size % 8; + acfg->datafile_offset += align; + guint8 align_buf [16]; + memset (&align_buf, 0, sizeof (align_buf)); + fwrite (align_buf, align, 1, acfg->data_outfile); } else if (acfg->llvm) { mono_llvm_emit_aot_data (symbol, data, size); } else { @@ -2912,7 +2927,6 @@ encode_method_ref (MonoAotCompile *acfg, MonoMethod *method, guint8 *buf, guint8 case MONO_WRAPPER_RUNTIME_INVOKE: { g_assert (info); encode_value (info->subtype, p, &p); - encode_value (info->d.runtime_invoke.pass_rgctx, p, &p); if (info->subtype == WRAPPER_SUBTYPE_RUNTIME_INVOKE_DIRECT || info->subtype == WRAPPER_SUBTYPE_RUNTIME_INVOKE_VIRTUAL) encode_method_ref (acfg, info->d.runtime_invoke.method, p, &p); else if (info->subtype == WRAPPER_SUBTYPE_RUNTIME_INVOKE_NORMAL) @@ -3318,13 +3332,13 @@ get_runtime_invoke_sig (MonoMethodSignature *sig) mb = mono_mb_new (mono_defaults.object_class, "FOO", MONO_WRAPPER_NONE); m = mono_mb_create_method (mb, sig, 16); - return mono_marshal_get_runtime_invoke (m, FALSE, FALSE); + return mono_marshal_get_runtime_invoke (m, FALSE); } static MonoMethod* get_runtime_invoke (MonoAotCompile *acfg, MonoMethod *method, gboolean virtual_) { - return mono_marshal_get_runtime_invoke (method, virtual_, acfg->aot_opts.llvm_only && mono_method_needs_static_rgctx_invoke (method, TRUE)); + return mono_marshal_get_runtime_invoke (method, virtual_); } static gboolean @@ -3512,7 +3526,7 @@ add_wrappers (MonoAotCompile *acfg) } #endif - if (!skip && acfg->aot_opts.llvm_only && (acfg->opts & MONO_OPT_GSHAREDVT) && mini_gsharedvt_runtime_invoke_supported (sig)) + if (acfg->aot_opts.llvm_only && (acfg->opts & MONO_OPT_GSHAREDVT)) /* Supported by the gsharedvt based runtime-invoke wrapper */ skip = TRUE; @@ -3788,7 +3802,7 @@ add_wrappers (MonoAotCompile *acfg) continue; } - if (klass->rank && MONO_TYPE_IS_PRIMITIVE (&klass->element_class->byval_arg)) { + if (!acfg->aot_opts.llvm_only && klass->rank && MONO_TYPE_IS_PRIMITIVE (&klass->element_class->byval_arg)) { MonoMethod *m, *wrapper; /* Add runtime-invoke wrappers too */ @@ -6909,6 +6923,44 @@ can_encode_patch (MonoAotCompile *acfg, MonoJumpInfo *patch_info) return TRUE; } +static gboolean +is_concrete_type (MonoType *t) +{ + MonoClass *klass; + int i; + + if (t->type == MONO_TYPE_VAR || t->type == MONO_TYPE_MVAR) + return FALSE; + if (t->type == MONO_TYPE_GENERICINST) { + MonoGenericContext *orig_ctx; + MonoGenericInst *inst; + MonoType *arg; + + if (!MONO_TYPE_ISSTRUCT (t)) + return TRUE; + klass = mono_class_from_mono_type (t); + orig_ctx = &klass->generic_class->context; + + inst = orig_ctx->class_inst; + if (inst) { + for (i = 0; i < inst->type_argc; ++i) { + arg = mini_get_underlying_type (inst->type_argv [i]); + if (!is_concrete_type (arg)) + return FALSE; + } + } + inst = orig_ctx->method_inst; + if (inst) { + for (i = 0; i < inst->type_argc; ++i) { + arg = mini_get_underlying_type (inst->type_argv [i]); + if (!is_concrete_type (arg)) + return FALSE; + } + } + } + return TRUE; +} + /* LOCKING: Assumes the loader lock is held */ static void add_gsharedvt_wrappers (MonoAotCompile *acfg, MonoMethodSignature *sig, gboolean gsharedvt_in, gboolean gsharedvt_out) @@ -6953,20 +7005,23 @@ add_gsharedvt_wrappers (MonoAotCompile *acfg, MonoMethodSignature *sig, gboolean //printf ("%s\n", mono_signature_full_name (sig)); copy->ret = mini_get_underlying_type (sig->ret); - // FIXME: Add more cases - if (copy->ret->type == MONO_TYPE_VAR || copy->ret->type == MONO_TYPE_MVAR || copy->ret->type == MONO_TYPE_GENERICINST) + if (!is_concrete_type (copy->ret)) concrete = FALSE; for (i = 0; i < sig->param_count; ++i) { copy->params [i] = mini_get_underlying_type (sig->params [i]); - if (copy->params [i]->type == MONO_TYPE_VAR || copy->params [i]->type == MONO_TYPE_MVAR || copy->params [i]->type == MONO_TYPE_GENERICINST) + if (!is_concrete_type (copy->params [i])) concrete = FALSE; } if (concrete) { copy->has_type_parameters = 0; - sig = copy; if (gsharedvt_in) { - MonoMethod *wrapper = mini_get_gsharedvt_in_sig_wrapper (sig); + wrapper = mini_get_gsharedvt_in_sig_wrapper (copy); + add_extra_method (acfg, wrapper); + } + + if (gsharedvt_out) { + wrapper = mini_get_gsharedvt_out_sig_wrapper (copy); add_extra_method (acfg, wrapper); } @@ -7113,6 +7168,15 @@ compile_method (MonoAotCompile *acfg, MonoMethod *method) /* Lock for the rest of the code */ mono_acfg_lock (acfg); + if (cfg->gsharedvt) + acfg->stats.method_categories [METHOD_CAT_GSHAREDVT] ++; + else if (cfg->gshared) + acfg->stats.method_categories [METHOD_CAT_INST] ++; + else if (cfg->method->wrapper_type) + acfg->stats.method_categories [METHOD_CAT_WRAPPER] ++; + else + acfg->stats.method_categories [METHOD_CAT_NORMAL] ++; + /* * Check for methods/klasses we can't encode. */ @@ -9620,7 +9684,7 @@ static const char *preinited_jit_icalls[] = { "mono_aot_init_gshared_method_this", "mono_aot_init_gshared_method_rgctx", "mono_llvm_throw_corlib_exception", - "mono_resolve_vcall", + "mono_init_vtable_slot", "mono_helper_ldstr_mscorlib" }; @@ -10104,6 +10168,11 @@ mono_compile_assembly (MonoAssembly *ass, guint32 opts, const char *aot_options) for (i = 0; i < MONO_PATCH_INFO_NONE; ++i) if (acfg->stats.got_slot_types [i]) aot_printf (acfg, "\t%s: %d (%d)\n", get_patch_name (i), acfg->stats.got_slot_types [i], acfg->stats.got_slot_info_sizes [i]); + aot_printf (acfg, "\nMethod stats:\n"); + aot_printf (acfg, "\tNormal: %d\n", acfg->stats.method_categories [METHOD_CAT_NORMAL]); + aot_printf (acfg, "\tInstance: %d\n", acfg->stats.method_categories [METHOD_CAT_INST]); + aot_printf (acfg, "\tGSharedvt: %d\n", acfg->stats.method_categories [METHOD_CAT_GSHAREDVT]); + aot_printf (acfg, "\tWrapper: %d\n", acfg->stats.method_categories [METHOD_CAT_WRAPPER]); } aot_printf (acfg, "JIT time: %d ms, Generation time: %d ms, Assembly+Link time: %d ms.\n", acfg->stats.jit_time / 1000, acfg->stats.gen_time / 1000, acfg->stats.link_time / 1000); diff --git a/mono/mini/aot-runtime.c b/mono/mini/aot-runtime.c index 8586cf50eea..a40be9bfbde 100644 --- a/mono/mini/aot-runtime.c +++ b/mono/mini/aot-runtime.c @@ -1064,7 +1064,6 @@ decode_method_ref_with_target (MonoAotModule *module, MethodRef *ref, MonoMethod } case MONO_WRAPPER_RUNTIME_INVOKE: { int subtype = decode_value (p, &p); - int pass_rgctx = decode_value (p, &p); if (!target) return FALSE; @@ -1079,14 +1078,14 @@ decode_method_ref_with_target (MonoAotModule *module, MethodRef *ref, MonoMethod if (!m) return FALSE; - ref->method = mono_marshal_get_runtime_invoke (m, FALSE, pass_rgctx); + ref->method = mono_marshal_get_runtime_invoke (m, FALSE); } else if (subtype == WRAPPER_SUBTYPE_RUNTIME_INVOKE_VIRTUAL) { /* Virtual direct wrapper */ MonoMethod *m = decode_resolve_method_ref (module, p, &p); if (!m) return FALSE; - ref->method = mono_marshal_get_runtime_invoke (m, TRUE, pass_rgctx); + ref->method = mono_marshal_get_runtime_invoke (m, TRUE); } else { MonoMethodSignature *sig; @@ -1096,8 +1095,6 @@ decode_method_ref_with_target (MonoAotModule *module, MethodRef *ref, MonoMethod if (info->subtype != subtype) return FALSE; - if (info->d.runtime_invoke.pass_rgctx != pass_rgctx) - return FALSE; g_assert (info->d.runtime_invoke.sig); if (mono_metadata_signature_equal (sig, info->d.runtime_invoke.sig)) ref->method = target; @@ -3910,8 +3907,12 @@ find_aot_method_in_amodule (MonoAotModule *amodule, MonoMethod *method, guint32 break; } - /* Special case: wrappers of shared generic methods */ - if (m && method->wrapper_type && m->wrapper_type == m->wrapper_type && + /* + * Special case: wrappers of shared generic methods. + * This is needed because of the way mini_get_shared_method () works, + * we could end up with multiple copies of the same wrapper. + */ + if (m && method->wrapper_type && method->wrapper_type == m->wrapper_type && method->wrapper_type == MONO_WRAPPER_SYNCHRONIZED) { MonoMethod *w1 = mono_marshal_method_from_wrapper (method); MonoMethod *w2 = mono_marshal_method_from_wrapper (m); @@ -3921,6 +3922,16 @@ find_aot_method_in_amodule (MonoAotModule *amodule, MonoMethod *method, guint32 break; } } + if (m && method->wrapper_type && method->wrapper_type == m->wrapper_type && + method->wrapper_type == MONO_WRAPPER_DELEGATE_INVOKE) { + WrapperInfo *info1 = mono_marshal_get_wrapper_info (method); + WrapperInfo *info2 = mono_marshal_get_wrapper_info (m); + + if (info1 && info2 && info1->subtype == info2->subtype && method->klass == m->klass) { + index = value; + break; + } + } /* Methods decoded needlessly */ if (m) { diff --git a/mono/mini/aot-tests.cs b/mono/mini/aot-tests.cs index 6092346ea4c..a79e708282b 100644 --- a/mono/mini/aot-tests.cs +++ b/mono/mini/aot-tests.cs @@ -238,6 +238,16 @@ class Tests public static T GetValue(Nullable value) where T : struct { return value.Value; } + + [MethodImplAttribute (MethodImplOptions.NoInlining)] + public static Nullable Get(T t) where T : struct { + return t; + } + + [MethodImplAttribute (MethodImplOptions.NoInlining)] + public static Nullable GetNull() where T : struct { + return null; + } } [Category ("DYNCALL")] @@ -259,6 +269,14 @@ class Tests var res = (int)typeof (NullableMethods).GetMethod ("GetValue").MakeGenericMethod (new Type [] { typeof (int) }).Invoke (null, new object [] { v }); if (res != 42) return 3; + + NullableMethods.Get (42); + var res2 = (int?)typeof (NullableMethods).GetMethod ("Get").MakeGenericMethod (new Type [] { typeof (int) }).Invoke (null, new object [] { 42 }); + if (res2 != 42) + return 4; + res2 = (int?)typeof (NullableMethods).GetMethod ("GetNull").MakeGenericMethod (new Type [] { typeof (int) }).Invoke (null, new object [] { }); + if (res2.HasValue) + return 5; return 0; } @@ -401,4 +419,28 @@ class Tests return 2; return 0; } + + struct FpStruct { + public float a, b, c; + } + + struct LargeStruct2 { + public FpStruct x; + public int a, b, c, d, e, f, g, h; + } + + [MethodImplAttribute (MethodImplOptions.NoInlining)] + static int pass_hfa_on_stack (FpStruct s1, FpStruct s2, FpStruct s3) { + return (int)s3.c; + } + + public static int test_10_arm64_hfa_on_stack_llvm () { + var arr = new LargeStruct2 [10, 10]; + for (int i = 0; i < 10; ++i) + for (int j = 0; j < 10; ++j) + arr [i, j].x = new FpStruct (); + + var s1 = new FpStruct () { a = 1, b = 1, c = 10 }; + return pass_hfa_on_stack (s1, s1, s1); + } } diff --git a/mono/mini/iltests.il b/mono/mini/iltests.il index 35f1f8db28f..203584e1433 100644 --- a/mono/mini/iltests.il +++ b/mono/mini/iltests.il @@ -668,6 +668,27 @@ COND: ldloc.0 ret } + .method public static int32 test_5_endfinally_llvm_linking () il managed { + .maxstack 16 + + .try { + leave IL_0 + } + finally { + ldc.i4.0 + dup + brtrue L1 + pop + br L2 + L1: + pop + L2: + endfinally + } + IL_0: ldc.i4.5 + ret + } + .method public static int32 test_0_conv_ovf_i8_neg () il managed { .maxstack 16 diff --git a/mono/mini/jit-icalls.c b/mono/mini/jit-icalls.c index e7850d725a1..3beb3555f14 100644 --- a/mono/mini/jit-icalls.c +++ b/mono/mini/jit-icalls.c @@ -1331,6 +1331,9 @@ mono_fill_method_rgctx (MonoMethodRuntimeGenericContext *mrgctx, int index) * resolve_iface_call: * * Return the executable code for the iface method IMT_METHOD called on THIS. + * This function is called on a slowpath, so it doesn't need to be fast. + * This returns an ftnptr by returning the address part, and the arg in the OUT_ARG + * out parameter. */ static gpointer resolve_iface_call (MonoObject *this_obj, int imt_slot, MonoMethod *imt_method, gpointer *out_arg, gboolean caller_gsharedvt) @@ -1341,8 +1344,6 @@ resolve_iface_call (MonoObject *this_obj, int imt_slot, MonoMethod *imt_method, gpointer addr, compiled_method, aot_addr; gboolean need_rgctx_tramp = FALSE, need_unbox_tramp = FALSE; - // FIXME: Optimize this - if (!this_obj) /* The caller will handle it */ return NULL; @@ -1377,17 +1378,9 @@ resolve_iface_call (MonoObject *this_obj, int imt_slot, MonoMethod *imt_method, target, addr); } - *vtable_slot = addr; - return addr; } -gpointer -mono_resolve_iface_call (MonoObject *this_obj, int imt_slot, MonoMethod *imt_method, gpointer *out_arg) -{ - return resolve_iface_call (this_obj, imt_slot, imt_method, out_arg, FALSE); -} - gpointer mono_resolve_iface_call_gsharedvt (MonoObject *this_obj, int imt_slot, MonoMethod *imt_method, gpointer *out_arg) { @@ -1412,39 +1405,26 @@ is_generic_method_definition (MonoMethod *m) } /* - * mono_resolve_vcall: + * resolve_vcall: * - * Return the executable code for calling this_obj->vtable [slot]. + * Return the executable code for calling vt->vtable [slot]. + * This function is called on a slowpath, so it doesn't need to be fast. + * This returns an ftnptr by returning the address part, and the arg in the OUT_ARG + * out parameter. */ static gpointer -resolve_vcall (MonoObject *this_obj, int slot, MonoMethod *imt_method, gpointer *out_arg, gboolean gsharedvt) +resolve_vcall (MonoVTable *vt, int slot, MonoMethod *imt_method, gpointer *out_arg, gboolean gsharedvt) { - MonoVTable *vt; MonoMethod *m, *generic_virtual = NULL; - gpointer *vtable_slot; gpointer addr, compiled_method; gboolean need_unbox_tramp = FALSE; - // FIXME: Optimize this - - if (!this_obj) - /* The caller will handle it */ - return NULL; - - vt = this_obj->vtable; - - vtable_slot = &(vt->vtable [slot]); - /* Same as in common_call_trampoline () */ /* Avoid loading metadata or creating a generic vtable if possible */ addr = mono_aot_get_method_from_vt_slot (mono_domain_get (), vt, slot); - if (addr && !vt->klass->valuetype) { - if (mono_domain_owns_vtable_slot (mono_domain_get (), vtable_slot)) - *vtable_slot = addr; - + if (addr && !vt->klass->valuetype) return mono_create_ftnptr (mono_domain_get (), addr); - } m = mono_class_get_vtable_entry (vt->klass, slot); @@ -1484,39 +1464,166 @@ resolve_vcall (MonoObject *this_obj, int slot, MonoMethod *imt_method, gpointer addr = compiled_method = mono_compile_method (m); g_assert (addr); - addr = mini_add_method_wrappers_llvmonly (m, addr, FALSE, need_unbox_tramp, out_arg); - - // FIXME: Unify this with mono_resolve_iface_call - - *vtable_slot = addr; - - if (gsharedvt) { - /* - * The callee uses the gsharedvt calling convention, have to add an out wrapper. - */ - g_assert (out_arg); - g_assert (*out_arg); + addr = mini_add_method_wrappers_llvmonly (m, addr, gsharedvt, need_unbox_tramp, out_arg); - gpointer out_wrapper = mini_get_gsharedvt_wrapper (FALSE, NULL, mono_method_signature (imt_method), NULL, -1, FALSE); - gpointer *out_wrapper_arg = mini_create_llvmonly_ftndesc (addr, *out_arg); + if (!gsharedvt && generic_virtual) { + // FIXME: This wastes memory since add_generic_virtual_invocation ignores it in a lot of cases + MonoFtnDesc *ftndesc = mini_create_llvmonly_ftndesc (mono_domain_get (), addr, out_arg); - addr = out_wrapper; - *out_arg = out_wrapper_arg; + mono_method_add_generic_virtual_invocation (mono_domain_get (), + vt, vt->vtable + slot, + generic_virtual, ftndesc); } return addr; } gpointer -mono_resolve_vcall (MonoObject *this_obj, int slot, MonoMethod *imt_method, gpointer *out_rgctx_arg) +mono_resolve_vcall_gsharedvt (MonoObject *this_obj, int slot, MonoMethod *imt_method, gpointer *out_arg) +{ + g_assert (this_obj); + + return resolve_vcall (this_obj->vtable, slot, imt_method, out_arg, TRUE); +} + +/* + * mono_resolve_generic_virtual_call: + * + * Resolve a generic virtual call. + * This function is called on a slowpath, so it doesn't need to be fast. + */ +MonoFtnDesc* +mono_resolve_generic_virtual_call (MonoVTable *vt, int slot, MonoMethod *generic_virtual) +{ + MonoMethod *m; + gpointer addr, compiled_method; + gboolean need_unbox_tramp = FALSE; + MonoError error; + MonoGenericContext context = { NULL, NULL }; + MonoMethod *declaring; + gpointer arg = NULL; + + m = mono_class_get_vtable_entry (vt->klass, slot); + + g_assert (is_generic_method_definition (m)); + + if (m->is_inflated) + declaring = mono_method_get_declaring_generic_method (m); + else + declaring = m; + + if (m->klass->generic_class) + context.class_inst = m->klass->generic_class->context.class_inst; + else + g_assert (!m->klass->generic_container); + + g_assert (generic_virtual->is_inflated); + context.method_inst = ((MonoMethodInflated*)generic_virtual)->context.method_inst; + + m = mono_class_inflate_generic_method_checked (declaring, &context, &error); + g_assert (mono_error_ok (&error)); + + if (vt->klass->valuetype) + need_unbox_tramp = TRUE; + + // FIXME: This can throw exceptions + addr = compiled_method = mono_compile_method (m); + g_assert (addr); + + addr = mini_add_method_wrappers_llvmonly (m, addr, FALSE, need_unbox_tramp, &arg); + + /* + * This wastes memory but the memory usage is bounded since + * mono_method_add_generic_virtual_invocation () eventually builds an imt thunk for + * this vtable slot so we are not called any more for this instantiation. + */ + MonoFtnDesc *ftndesc = mini_create_llvmonly_ftndesc (mono_domain_get (), addr, arg); + + mono_method_add_generic_virtual_invocation (mono_domain_get (), + vt, vt->vtable + slot, + generic_virtual, ftndesc); + return ftndesc; +} + +/* + * mono_resolve_generic_virtual_call: + * + * Resolve a generic virtual call on interfaces. + * This function is called on a slowpath, so it doesn't need to be fast. + */ +MonoFtnDesc* +mono_resolve_generic_virtual_iface_call (MonoVTable *vt, int imt_slot, MonoMethod *generic_virtual) { - return resolve_vcall (this_obj, slot, imt_method, out_rgctx_arg, FALSE); + MonoMethod *m, *variant_iface; + gpointer addr, aot_addr, compiled_method; + gboolean need_unbox_tramp = FALSE; + gboolean need_rgctx_tramp; + gpointer arg = NULL; + gpointer *imt; + + imt = (gpointer*)vt - MONO_IMT_SIZE; + + mini_resolve_imt_method (vt, imt + imt_slot, generic_virtual, &m, &aot_addr, &need_rgctx_tramp, &variant_iface); + g_assert (!variant_iface); + + if (vt->klass->valuetype) + need_unbox_tramp = TRUE; + + // FIXME: This can throw exceptions + addr = compiled_method = mono_compile_method (m); + g_assert (addr); + + addr = mini_add_method_wrappers_llvmonly (m, addr, FALSE, need_unbox_tramp, &arg); + + /* + * This wastes memory but the memory usage is bounded since + * mono_method_add_generic_virtual_invocation () eventually builds an imt thunk for + * this vtable slot so we are not called any more for this instantiation. + */ + MonoFtnDesc *ftndesc = mini_create_llvmonly_ftndesc (mono_domain_get (), addr, arg); + + mono_method_add_generic_virtual_invocation (mono_domain_get (), + vt, imt + imt_slot, + generic_virtual, ftndesc); + return ftndesc; } +/* + * mono_init_vtable_slot: + * + * Initialize slot SLOT of VTABLE. + * Return the contents of the vtable slot. + */ gpointer -mono_resolve_vcall_gsharedvt (MonoObject *this_obj, int slot, MonoMethod *imt_method, gpointer *out_rgctx_arg) +mono_init_vtable_slot (MonoVTable *vtable, int slot) +{ + gpointer arg = NULL; + gpointer addr; + gpointer *ftnptr; + + addr = resolve_vcall (vtable, slot, NULL, &arg, FALSE); + ftnptr = mono_domain_alloc0 (vtable->domain, 2 * sizeof (gpointer)); + ftnptr [0] = addr; + ftnptr [1] = arg; + mono_memory_barrier (); + + vtable->vtable [slot] = ftnptr; + + return ftnptr; +} + +static gboolean +is_callee_gsharedvt_variable (gpointer addr) { - return resolve_vcall (this_obj, slot, imt_method, out_rgctx_arg, TRUE); + MonoJitInfo *ji; + gboolean callee_gsharedvt; + + ji = mini_jit_info_table_find (mono_domain_get (), (char *)mono_get_addr_from_ftnptr (addr), NULL); + g_assert (ji); + callee_gsharedvt = mini_jit_info_is_gsharedvt (ji); + if (callee_gsharedvt) + callee_gsharedvt = mini_is_gsharedvt_variable_signature (mono_method_signature (jinfo_get_method (ji))); + return callee_gsharedvt; } /* @@ -1532,10 +1639,18 @@ mono_init_delegate (MonoDelegate *del, MonoObject *target, MonoMethod *method) del->method = method; del->method_ptr = mono_compile_method (method); - del->method_ptr = mini_add_method_wrappers_llvmonly (method, del->method_ptr, FALSE, FALSE, &del->rgctx); - if (!del->rgctx) { - if (mono_method_needs_static_rgctx_invoke (method, FALSE)) - del->rgctx = mini_method_get_rgctx (method); + if (mono_method_needs_static_rgctx_invoke (method, FALSE)) + del->rgctx = mini_method_get_rgctx (method); + + /* + * Avoid adding gsharedvt in wrappers since they might not exist if + * this delegate is called through a gsharedvt delegate invoke wrapper. + * Instead, encode that the method is gsharedvt in del->rgctx, + * the CEE_MONO_CALLI_EXTRA_ARG implementation in the JIT depends on this. + */ + if (is_callee_gsharedvt_variable (del->method_ptr)) { + g_assert ((((mgreg_t)del->rgctx) & 1) == 0); + del->rgctx = (gpointer)(((mgreg_t)del->rgctx) | 1); } } @@ -1550,10 +1665,12 @@ mono_init_delegate_virtual (MonoDelegate *del, MonoObject *target, MonoMethod *m del->method = method; del->method_ptr = mono_compile_method (method); - del->method_ptr = mini_add_method_wrappers_llvmonly (method, del->method_ptr, FALSE, FALSE, &del->rgctx); - if (!del->rgctx) { - if (mono_method_needs_static_rgctx_invoke (method, FALSE)) - del->rgctx = mini_method_get_rgctx (method); + if (mono_method_needs_static_rgctx_invoke (method, FALSE)) + del->rgctx = mini_method_get_rgctx (method); + + if (is_callee_gsharedvt_variable (del->method_ptr)) { + g_assert ((((mgreg_t)del->rgctx) & 1) == 0); + del->rgctx = (gpointer)(((mgreg_t)del->rgctx) | 1); } } diff --git a/mono/mini/jit-icalls.h b/mono/mini/jit-icalls.h index bd7bd4ec7f9..2edf5759cd4 100644 --- a/mono/mini/jit-icalls.h +++ b/mono/mini/jit-icalls.h @@ -195,14 +195,16 @@ gpointer mono_fill_class_rgctx (MonoVTable *vtable, int index); gpointer mono_fill_method_rgctx (MonoMethodRuntimeGenericContext *mrgctx, int index); -gpointer mono_resolve_iface_call (MonoObject *this_obj, int imt_slot, MonoMethod *imt_method, gpointer *out_arg); - -gpointer mono_resolve_vcall (MonoObject *this_obj, int slot, MonoMethod *imt_method, gpointer *out_arg); - gpointer mono_resolve_iface_call_gsharedvt (MonoObject *this_obj, int imt_slot, MonoMethod *imt_method, gpointer *out_arg); gpointer mono_resolve_vcall_gsharedvt (MonoObject *this_obj, int imt_slot, MonoMethod *imt_method, gpointer *out_arg); +MonoFtnDesc* mono_resolve_generic_virtual_call (MonoVTable *vt, int slot, MonoMethod *imt_method); + +MonoFtnDesc* mono_resolve_generic_virtual_iface_call (MonoVTable *vt, int imt_slot, MonoMethod *imt_method); + +gpointer mono_init_vtable_slot (MonoVTable *vtable, int slot); + void mono_init_delegate (MonoDelegate *del, MonoObject *target, MonoMethod *method); void mono_init_delegate_virtual (MonoDelegate *del, MonoObject *target, MonoMethod *method); diff --git a/mono/mini/llvm-runtime.cpp b/mono/mini/llvm-runtime.cpp index 3af75e6352f..c747e022b38 100644 --- a/mono/mini/llvm-runtime.cpp +++ b/mono/mini/llvm-runtime.cpp @@ -8,10 +8,14 @@ extern "C" { void mono_llvm_cpp_throw_exception (void) { +#ifdef MONO_LLVM_LOADED + g_assert_not_reached (); +#else gint32 *ex = NULL; /* The generated code catches an int32* */ throw ex; +#endif } } diff --git a/mono/mini/method-to-ir.c b/mono/mini/method-to-ir.c index 4e73c57850b..40e16b8b7a2 100644 --- a/mono/mini/method-to-ir.c +++ b/mono/mini/method-to-ir.c @@ -146,10 +146,13 @@ MONO_API MonoInst* mono_emit_native_call (MonoCompile *cfg, gconstpointer func, static int inline_method (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *fsig, MonoInst **sp, guchar *ip, guint real_offset, gboolean inline_always); +static MonoInst* +emit_llvmonly_virtual_call (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *fsig, int context_used, MonoInst **sp); /* helper methods signatures */ static MonoMethodSignature *helper_sig_domain_get; static MonoMethodSignature *helper_sig_rgctx_lazy_fetch_trampoline; +static MonoMethodSignature *helper_sig_llvmonly_imt_thunk; /* * Instruction metadata @@ -354,6 +357,7 @@ mono_create_helper_signatures (void) { helper_sig_domain_get = mono_create_icall_signature ("ptr"); helper_sig_rgctx_lazy_fetch_trampoline = mono_create_icall_signature ("ptr ptr"); + helper_sig_llvmonly_imt_thunk = mono_create_icall_signature ("ptr ptr ptr"); } static MONO_NEVER_INLINE void @@ -2760,26 +2764,8 @@ mono_emit_method_call_full (MonoCompile *cfg, MonoMethod *method, MonoMethodSign if (!sig) sig = mono_method_signature (method); - if (cfg->llvm_only && (method->klass->flags & TYPE_ATTRIBUTE_INTERFACE)) { - MonoInst *icall_args [16]; - MonoInst *ins; - - // FIXME: Optimize this - - guint32 imt_slot = mono_method_get_imt_slot (method); - - icall_args [0] = this_ins; - EMIT_NEW_ICONST (cfg, icall_args [1], imt_slot); - if (imt_arg) { - icall_args [2] = imt_arg; - } else { - EMIT_NEW_AOTCONST (cfg, ins, MONO_PATCH_INFO_METHODCONST, method); - icall_args [2] = ins; - } - EMIT_NEW_PCONST (cfg, icall_args [3], NULL); - - call_target = mono_emit_jit_icall (cfg, mono_resolve_iface_call, icall_args); - } + if (cfg->llvm_only && (method->klass->flags & TYPE_ATTRIBUTE_INTERFACE)) + g_assert_not_reached (); if (rgctx_arg) { rgctx_reg = mono_alloc_preg (cfg); @@ -2813,37 +2799,8 @@ mono_emit_method_call_full (MonoCompile *cfg, MonoMethod *method, MonoMethodSign } #endif - if (cfg->llvm_only && !call_target && virtual_ && (method->flags & METHOD_ATTRIBUTE_VIRTUAL)) { - // FIXME: Vcall optimizations below - MonoInst *icall_args [16]; - MonoInst *ins; - int rgctx_reg; - - if (sig->generic_param_count) { - /* - * Generic virtual call, pass the concrete method as the imt argument. - */ - imt_arg = emit_get_rgctx_method (cfg, context_used, - method, MONO_RGCTX_INFO_METHOD); - } - - // FIXME: Optimize this - - int slot = mono_method_get_vtable_index (method); - - icall_args [0] = this_ins; - EMIT_NEW_ICONST (cfg, icall_args [1], slot); - if (imt_arg) { - icall_args [2] = imt_arg; - } else { - EMIT_NEW_PCONST (cfg, ins, NULL); - icall_args [2] = ins; - } - rgctx_reg = alloc_preg (cfg); - MONO_EMIT_NEW_PCONST (cfg, rgctx_reg, NULL); - EMIT_NEW_VARLOADA_VREG (cfg, icall_args [3], rgctx_reg, &mono_defaults.int_class->byval_arg); - call_target = mono_emit_jit_icall (cfg, mono_resolve_vcall, icall_args); - } + if (cfg->llvm_only && !call_target && virtual_ && (method->flags & METHOD_ATTRIBUTE_VIRTUAL)) + return emit_llvmonly_virtual_call (cfg, method, sig, 0, args); need_unbox_trampoline = method->klass == mono_defaults.object_class || (method->klass->flags & TYPE_ATTRIBUTE_INTERFACE); @@ -7652,6 +7609,203 @@ emit_optimized_ldloca_ir (MonoCompile *cfg, unsigned char *ip, unsigned char *en return NULL; } +static MonoInst* +emit_llvmonly_virtual_call (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *fsig, int context_used, MonoInst **sp) +{ + MonoInst *icall_args [16]; + MonoInst *call_target, *ins, *vtable_ins; + int arg_reg, this_reg, vtable_reg; + gboolean is_iface = cmethod->klass->flags & TYPE_ATTRIBUTE_INTERFACE; + gboolean is_gsharedvt = cfg->gsharedvt && mini_is_gsharedvt_variable_signature (fsig); + guint32 slot; + int offset; + + /* + * In llvm-only mode, vtables contain function descriptors instead of + * method addresses/trampolines. + */ + MONO_EMIT_NULL_CHECK (cfg, sp [0]->dreg); + + if (is_iface) + slot = mono_method_get_imt_slot (cmethod); + else + slot = mono_method_get_vtable_index (cmethod); + + this_reg = sp [0]->dreg; + + if (!fsig->generic_param_count && !is_iface && !is_gsharedvt) { + /* + * The simplest case, a normal virtual call. + */ + int slot_reg = alloc_preg (cfg); + int addr_reg = alloc_preg (cfg); + int arg_reg = alloc_preg (cfg); + MonoBasicBlock *non_null_bb; + + vtable_reg = alloc_preg (cfg); + EMIT_NEW_LOAD_MEMBASE (cfg, vtable_ins, OP_LOAD_MEMBASE, vtable_reg, this_reg, MONO_STRUCT_OFFSET (MonoObject, vtable)); + offset = MONO_STRUCT_OFFSET (MonoVTable, vtable) + (slot * SIZEOF_VOID_P); + + /* Load the vtable slot, which contains a function descriptor. */ + MONO_EMIT_NEW_LOAD_MEMBASE (cfg, slot_reg, vtable_reg, offset); + + NEW_BBLOCK (cfg, non_null_bb); + + MONO_EMIT_NEW_BIALU_IMM (cfg, OP_COMPARE_IMM, -1, slot_reg, 0); + cfg->cbb->last_ins->flags |= MONO_INST_LIKELY; + MONO_EMIT_NEW_BRANCH_BLOCK (cfg, OP_PBNE_UN, non_null_bb); + + /* Slow path */ + // FIXME: Make the wrapper use the preserveall cconv + // FIXME: Use one icall per slot for small slot numbers ? + icall_args [0] = vtable_ins; + EMIT_NEW_ICONST (cfg, icall_args [1], slot); + /* Make the icall return the vtable slot value to save some code space */ + ins = mono_emit_jit_icall (cfg, mono_init_vtable_slot, icall_args); + ins->dreg = slot_reg; + MONO_EMIT_NEW_BRANCH_BLOCK (cfg, OP_BR, non_null_bb); + + /* Fastpath */ + MONO_START_BB (cfg, non_null_bb); + /* Load the address + arg from the vtable slot */ + EMIT_NEW_LOAD_MEMBASE (cfg, call_target, OP_LOAD_MEMBASE, addr_reg, slot_reg, 0); + MONO_EMIT_NEW_LOAD_MEMBASE (cfg, arg_reg, slot_reg, SIZEOF_VOID_P); + + return emit_extra_arg_calli (cfg, fsig, sp, arg_reg, call_target); + } + + if (!fsig->generic_param_count && is_iface && !is_gsharedvt) { + /* + * A simple interface call + * + * We make a call through an imt slot to obtain the function descriptor we need to call. + * The imt slot contains a function descriptor for a runtime function + arg. + */ + int slot_reg = alloc_preg (cfg); + int addr_reg = alloc_preg (cfg); + int arg_reg = alloc_preg (cfg); + MonoInst *thunk_addr_ins, *thunk_arg_ins, *ftndesc_ins; + + vtable_reg = alloc_preg (cfg); + EMIT_NEW_LOAD_MEMBASE (cfg, vtable_ins, OP_LOAD_MEMBASE, vtable_reg, this_reg, MONO_STRUCT_OFFSET (MonoObject, vtable)); + offset = ((gint32)slot - MONO_IMT_SIZE) * SIZEOF_VOID_P; + + /* + * The slot is already initialized when the vtable is created so there is no need + * to check it here. + */ + + /* Load the imt slot, which contains a function descriptor. */ + MONO_EMIT_NEW_LOAD_MEMBASE (cfg, slot_reg, vtable_reg, offset); + + /* Load the address + arg of the imt thunk from the imt slot */ + EMIT_NEW_LOAD_MEMBASE (cfg, thunk_addr_ins, OP_LOAD_MEMBASE, addr_reg, slot_reg, 0); + EMIT_NEW_LOAD_MEMBASE (cfg, thunk_arg_ins, OP_LOAD_MEMBASE, arg_reg, slot_reg, SIZEOF_VOID_P); + /* + * IMT thunks in llvm-only mode are C functions which take an info argument + * plus the imt method and return the ftndesc to call. + */ + icall_args [0] = thunk_arg_ins; + icall_args [1] = emit_get_rgctx_method (cfg, context_used, + cmethod, MONO_RGCTX_INFO_METHOD); + ftndesc_ins = mono_emit_calli (cfg, helper_sig_llvmonly_imt_thunk, icall_args, thunk_addr_ins, NULL, NULL); + + return emit_llvmonly_calli (cfg, fsig, sp, ftndesc_ins); + } + + if (fsig->generic_param_count && !is_gsharedvt) { + /* + * This is similar to the interface case, the vtable slot points to an imt thunk which is + * dynamically extended as more instantiations are discovered. + * This handles generic virtual methods both on classes and interfaces. + */ + int slot_reg = alloc_preg (cfg); + int addr_reg = alloc_preg (cfg); + int arg_reg = alloc_preg (cfg); + int ftndesc_reg = alloc_preg (cfg); + MonoInst *thunk_addr_ins, *thunk_arg_ins, *ftndesc_ins; + MonoBasicBlock *slowpath_bb, *end_bb; + + NEW_BBLOCK (cfg, slowpath_bb); + NEW_BBLOCK (cfg, end_bb); + + vtable_reg = alloc_preg (cfg); + EMIT_NEW_LOAD_MEMBASE (cfg, vtable_ins, OP_LOAD_MEMBASE, vtable_reg, this_reg, MONO_STRUCT_OFFSET (MonoObject, vtable)); + if (is_iface) + offset = ((gint32)slot - MONO_IMT_SIZE) * SIZEOF_VOID_P; + else + offset = MONO_STRUCT_OFFSET (MonoVTable, vtable) + (slot * SIZEOF_VOID_P); + + /* Load the slot, which contains a function descriptor. */ + MONO_EMIT_NEW_LOAD_MEMBASE (cfg, slot_reg, vtable_reg, offset); + + /* These slots are not initialized, so fall back to the slow path until they are initialized */ + /* That happens when mono_method_add_generic_virtual_invocation () creates an IMT thunk */ + MONO_EMIT_NEW_BIALU_IMM (cfg, OP_COMPARE_IMM, -1, slot_reg, 0); + MONO_EMIT_NEW_BRANCH_BLOCK (cfg, OP_PBEQ, slowpath_bb); + + /* Fastpath */ + /* Same as with iface calls */ + EMIT_NEW_LOAD_MEMBASE (cfg, thunk_addr_ins, OP_LOAD_MEMBASE, addr_reg, slot_reg, 0); + EMIT_NEW_LOAD_MEMBASE (cfg, thunk_arg_ins, OP_LOAD_MEMBASE, arg_reg, slot_reg, SIZEOF_VOID_P); + icall_args [0] = thunk_arg_ins; + icall_args [1] = emit_get_rgctx_method (cfg, context_used, + cmethod, MONO_RGCTX_INFO_METHOD); + ftndesc_ins = mono_emit_calli (cfg, helper_sig_llvmonly_imt_thunk, icall_args, thunk_addr_ins, NULL, NULL); + ftndesc_ins->dreg = ftndesc_reg; + /* + * Unlike normal iface calls, these imt thunks can return NULL, i.e. when they are passed an instantiation + * they don't know about yet. Fall back to the slowpath in that case. + */ + MONO_EMIT_NEW_BIALU_IMM (cfg, OP_COMPARE_IMM, -1, ftndesc_reg, 0); + MONO_EMIT_NEW_BRANCH_BLOCK (cfg, OP_PBEQ, slowpath_bb); + + MONO_EMIT_NEW_BRANCH_BLOCK (cfg, OP_BR, end_bb); + + /* Slowpath */ + MONO_START_BB (cfg, slowpath_bb); + icall_args [0] = vtable_ins; + EMIT_NEW_ICONST (cfg, icall_args [1], slot); + icall_args [2] = emit_get_rgctx_method (cfg, context_used, + cmethod, MONO_RGCTX_INFO_METHOD); + if (is_iface) + ftndesc_ins = mono_emit_jit_icall (cfg, mono_resolve_generic_virtual_iface_call, icall_args); + else + ftndesc_ins = mono_emit_jit_icall (cfg, mono_resolve_generic_virtual_call, icall_args); + ftndesc_ins->dreg = ftndesc_reg; + MONO_EMIT_NEW_BRANCH_BLOCK (cfg, OP_BR, end_bb); + + /* Common case */ + MONO_START_BB (cfg, end_bb); + return emit_llvmonly_calli (cfg, fsig, sp, ftndesc_ins); + } + + /* + * Non-optimized cases + */ + icall_args [0] = sp [0]; + EMIT_NEW_ICONST (cfg, icall_args [1], slot); + + icall_args [2] = emit_get_rgctx_method (cfg, context_used, + cmethod, MONO_RGCTX_INFO_METHOD); + + arg_reg = alloc_preg (cfg); + MONO_EMIT_NEW_PCONST (cfg, arg_reg, NULL); + EMIT_NEW_VARLOADA_VREG (cfg, icall_args [3], arg_reg, &mono_defaults.int_class->byval_arg); + + g_assert (is_gsharedvt); + if (is_iface) + call_target = mono_emit_jit_icall (cfg, mono_resolve_iface_call_gsharedvt, icall_args); + else + call_target = mono_emit_jit_icall (cfg, mono_resolve_vcall_gsharedvt, icall_args); + + /* + * Pass the extra argument even if the callee doesn't receive it, most + * calling conventions allow this. + */ + return emit_extra_arg_calli (cfg, fsig, sp, arg_reg, call_target); +} + static gboolean is_exception_class (MonoClass *klass) { @@ -9507,7 +9661,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b */ if (cfg->gsharedvt && (mini_is_gsharedvt_signature (fsig) || cmethod->is_inflated || cmethod->klass->generic_class) && !(cmethod->klass->rank && cmethod->klass->byval_arg.type != MONO_TYPE_SZARRAY) && - (!(cfg->llvm_only && virtual_))) { + (!(cfg->llvm_only && virtual_ && (cmethod->flags & METHOD_ATTRIBUTE_VIRTUAL)))) { MonoRgctxInfoType info_type; if (virtual_) { @@ -9733,66 +9887,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b * Virtual calls in llvm-only mode. */ if (cfg->llvm_only && virtual_ && cmethod && (cmethod->flags & METHOD_ATTRIBUTE_VIRTUAL)) { - MonoInst *icall_args [16]; - MonoInst *call_target; - int arg_reg; - gboolean is_iface = cmethod->klass->flags & TYPE_ATTRIBUTE_INTERFACE; - - MONO_EMIT_NULL_CHECK (cfg, sp [0]->dreg); - - // FIXME: Optimize this - - guint32 slot; - - if (is_iface) - slot = mono_method_get_imt_slot (cmethod); - else - slot = mono_method_get_vtable_index (cmethod); - - icall_args [0] = sp [0]; - EMIT_NEW_ICONST (cfg, icall_args [1], slot); - - if (fsig->generic_param_count) { - /* virtual generic call */ - g_assert (!imt_arg); - /* Same as the virtual generic case above */ - imt_arg = emit_get_rgctx_method (cfg, context_used, - cmethod, MONO_RGCTX_INFO_METHOD); - icall_args [2] = imt_arg; - } else if (imt_arg) { - icall_args [2] = imt_arg; - } else { - EMIT_NEW_AOTCONST (cfg, ins, MONO_PATCH_INFO_METHODCONST, cmethod); - icall_args [2] = ins; - } - - // FIXME: For generic virtual calls, avoid computing the rgctx twice - - arg_reg = alloc_preg (cfg); - MONO_EMIT_NEW_PCONST (cfg, arg_reg, NULL); - EMIT_NEW_VARLOADA_VREG (cfg, icall_args [3], arg_reg, &mono_defaults.int_class->byval_arg); - - if (cfg->gsharedvt && mini_is_gsharedvt_variable_signature (fsig)) { - /* - * We handle virtual calls made from gsharedvt methods here instead - * of the gsharedvt block above. - */ - if (is_iface) - call_target = mono_emit_jit_icall (cfg, mono_resolve_iface_call_gsharedvt, icall_args); - else - call_target = mono_emit_jit_icall (cfg, mono_resolve_vcall_gsharedvt, icall_args); - } else { - if (is_iface) - call_target = mono_emit_jit_icall (cfg, mono_resolve_iface_call, icall_args); - else - call_target = mono_emit_jit_icall (cfg, mono_resolve_vcall, icall_args); - } - - /* - * Pass the extra argument even if the callee doesn't receive it, most calling - * calling conventions allow this. - */ - ins = emit_extra_arg_calli (cfg, fsig, sp, arg_reg, call_target); + ins = emit_llvmonly_virtual_call (cfg, cmethod, fsig, context_used, sp); goto call_end; } @@ -12240,8 +12335,8 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b /* * Link the finally bblock with the target, since it will * conceptually branch there. - * FIXME: Have to link the bblock containing the endfinally. */ + GET_BBLOCK (cfg, tblock, cfg->cil_start + clause->handler_offset + clause->handler_len - 1); GET_BBLOCK (cfg, target_bb, target); link_bblock (cfg, tblock, target_bb); } @@ -12634,6 +12729,109 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b ip += 2; break; } + case CEE_MONO_CALLI_EXTRA_ARG: { + MonoInst *addr; + MonoMethodSignature *fsig; + MonoInst *arg; + + /* + * This is the same as CEE_CALLI, but passes an additional argument + * to the called method in llvmonly mode. + * This is only used by delegate invoke wrappers to call the + * actual delegate method. + */ + g_assert (method->wrapper_type == MONO_WRAPPER_DELEGATE_INVOKE); + + CHECK_OPSIZE (6); + token = read32 (ip + 2); + + ins = NULL; + + cmethod = NULL; + CHECK_STACK (1); + --sp; + addr = *sp; + fsig = mini_get_signature (method, token, generic_context); + + n = fsig->param_count + fsig->hasthis + 1; + + CHECK_STACK (n); + + sp -= n; + arg = sp [n - 1]; + + if (cfg->llvm_only) { + /* + * The lowest bit of 'arg' determines whenever the callee uses the gsharedvt + * cconv. This is set by mono_init_delegate (). + */ + if (cfg->gsharedvt && mini_is_gsharedvt_variable_signature (fsig)) { + MonoInst *callee = addr; + MonoInst *call, *localloc_ins; + MonoBasicBlock *is_gsharedvt_bb, *end_bb; + int low_bit_reg = alloc_preg (cfg); + + NEW_BBLOCK (cfg, is_gsharedvt_bb); + NEW_BBLOCK (cfg, end_bb); + + MONO_EMIT_NEW_BIALU_IMM (cfg, OP_PAND_IMM, low_bit_reg, arg->dreg, 1); + MONO_EMIT_NEW_BIALU_IMM (cfg, OP_COMPARE_IMM, -1, low_bit_reg, 0); + MONO_EMIT_NEW_BRANCH_BLOCK (cfg, OP_PBNE_UN, is_gsharedvt_bb); + + /* Normal case: callee uses a normal cconv, have to add an out wrapper */ + addr = emit_get_rgctx_sig (cfg, context_used, + fsig, MONO_RGCTX_INFO_SIG_GSHAREDVT_OUT_TRAMPOLINE_CALLI); + /* + * ADDR points to a gsharedvt-out wrapper, have to pass as an extra arg. + */ + MONO_INST_NEW (cfg, ins, OP_LOCALLOC_IMM); + ins->dreg = alloc_preg (cfg); + ins->inst_imm = 2 * SIZEOF_VOID_P; + MONO_ADD_INS (cfg->cbb, ins); + localloc_ins = ins; + cfg->flags |= MONO_CFG_HAS_ALLOCA; + MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STORE_MEMBASE_REG, localloc_ins->dreg, 0, callee->dreg); + MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STORE_MEMBASE_REG, localloc_ins->dreg, SIZEOF_VOID_P, arg->dreg); + + call = emit_extra_arg_calli (cfg, fsig, sp, localloc_ins->dreg, addr); + MONO_EMIT_NEW_BRANCH_BLOCK (cfg, OP_BR, end_bb); + + /* Gsharedvt case: callee uses a gsharedvt cconv, no conversion is needed */ + MONO_START_BB (cfg, is_gsharedvt_bb); + MONO_EMIT_NEW_BIALU_IMM (cfg, OP_PXOR_IMM, arg->dreg, arg->dreg, 1); + ins = emit_extra_arg_calli (cfg, fsig, sp, arg->dreg, callee); + ins->dreg = call->dreg; + + MONO_START_BB (cfg, end_bb); + } else { + ins = emit_extra_arg_calli (cfg, fsig, sp, arg->dreg, addr); + } + } else { + /* Same as CEE_CALLI */ + if (cfg->gsharedvt && mini_is_gsharedvt_signature (fsig)) { + /* + * We pass the address to the gsharedvt trampoline in the rgctx reg + */ + MonoInst *callee = addr; + + addr = emit_get_rgctx_sig (cfg, context_used, + fsig, MONO_RGCTX_INFO_SIG_GSHAREDVT_OUT_TRAMPOLINE_CALLI); + ins = (MonoInst*)mono_emit_calli (cfg, fsig, sp, addr, NULL, callee); + } else { + ins = (MonoInst*)mono_emit_calli (cfg, fsig, sp, addr, NULL, NULL); + } + } + + if (!MONO_TYPE_IS_VOID (fsig->ret)) + *sp++ = mono_emit_widen_call_res (cfg, ins, fsig); + + CHECK_CFG_EXCEPTION; + + ip += 6; + ins_flag = 0; + constrained_class = NULL; + break; + } default: g_error ("opcode 0x%02x 0x%02x not handled", MONO_CUSTOM_PREFIX, ip [1]); break; diff --git a/mono/mini/mini-amd64.c b/mono/mini/mini-amd64.c index d90f82b4d8e..a1e877743ae 100644 --- a/mono/mini/mini-amd64.c +++ b/mono/mini/mini-amd64.c @@ -1312,7 +1312,7 @@ get_call_info (MonoMemPool *mp, MonoMethodSignature *sig) add_general (&gr, &stack_size, ainfo); break; } - if (mini_is_gsharedvt_type (ptype)) { + if (mini_is_gsharedvt_variable_type (ptype)) { /* gsharedvt arguments are passed by ref */ add_general (&gr, &stack_size, ainfo); if (ainfo->storage == ArgInIReg) @@ -2248,17 +2248,22 @@ mono_arch_get_llvm_call_info (MonoCompile *cfg, MonoMethodSignature *sig) case ArgInDoubleSSEReg: linfo->ret.storage = LLVMArgNormal; break; - case ArgValuetypeInReg: - if (sig->pinvoke) { - cfg->exception_message = g_strdup ("pinvoke + vtypes"); + case ArgValuetypeInReg: { + ainfo = &cinfo->ret; + + if (sig->pinvoke && + (ainfo->pair_storage [0] == ArgInFloatSSEReg || ainfo->pair_storage [0] == ArgInDoubleSSEReg || + ainfo->pair_storage [1] == ArgInFloatSSEReg || ainfo->pair_storage [1] == ArgInDoubleSSEReg)) { + cfg->exception_message = g_strdup ("pinvoke + vtype ret"); cfg->disable_llvm = TRUE; return linfo; } linfo->ret.storage = LLVMArgVtypeInReg; for (j = 0; j < 2; ++j) - linfo->ret.pair_storage [j] = arg_storage_to_llvm_arg_storage (cfg, cinfo->ret.pair_storage [j]); + linfo->ret.pair_storage [j] = arg_storage_to_llvm_arg_storage (cfg, ainfo->pair_storage [j]); break; + } case ArgValuetypeAddrInIReg: /* Vtype returned using a hidden argument */ linfo->ret.storage = LLVMArgVtypeRetAddr; @@ -2294,7 +2299,9 @@ mono_arch_get_llvm_call_info (MonoCompile *cfg, MonoMethodSignature *sig) linfo->args [i].storage = LLVMArgNormal; break; case ArgValuetypeInReg: - if (sig->pinvoke) { + if (sig->pinvoke && + (ainfo->pair_storage [0] == ArgInFloatSSEReg || ainfo->pair_storage [0] == ArgInDoubleSSEReg || + ainfo->pair_storage [1] == ArgInFloatSSEReg || ainfo->pair_storage [1] == ArgInDoubleSSEReg)) { cfg->exception_message = g_strdup ("pinvoke + vtypes"); cfg->disable_llvm = TRUE; return linfo; diff --git a/mono/mini/mini-generic-sharing.c b/mono/mini/mini-generic-sharing.c index 011b3c70803..187be3c426d 100644 --- a/mono/mini/mini-generic-sharing.c +++ b/mono/mini/mini-generic-sharing.c @@ -968,7 +968,7 @@ class_type_info (MonoDomain *domain, MonoClass *klass, MonoRgctxInfoType info_ty gsig = mono_method_signature (gmethod); addr = mini_add_method_wrappers_llvmonly (method, addr, TRUE, FALSE, &arg); - return mini_create_llvmonly_ftndesc (addr, arg); + return mini_create_llvmonly_ftndesc (domain, addr, arg); } ji = mini_jit_info_table_find (mono_domain_get (), (char *)mono_get_addr_from_ftnptr (addr), NULL); @@ -1048,11 +1048,39 @@ get_wrapper_shared_type (MonoType *t) case MONO_TYPE_ARRAY: case MONO_TYPE_PTR: return &mono_defaults.int_class->byval_arg; - return &mono_defaults.int_class->byval_arg; - case MONO_TYPE_GENERICINST: + case MONO_TYPE_GENERICINST: { + MonoClass *klass; + MonoGenericContext ctx; + MonoGenericContext *orig_ctx; + MonoGenericInst *inst; + MonoType *args [16]; + int i; + if (!MONO_TYPE_ISSTRUCT (t)) return &mono_defaults.int_class->byval_arg; - break; + + klass = mono_class_from_mono_type (t); + orig_ctx = &klass->generic_class->context; + + memset (&ctx, 0, sizeof (MonoGenericContext)); + + inst = orig_ctx->class_inst; + if (inst) { + g_assert (inst->type_argc < 16); + for (i = 0; i < inst->type_argc; ++i) + args [i] = get_wrapper_shared_type (inst->type_argv [i]); + ctx.class_inst = mono_metadata_get_generic_inst (inst->type_argc, args); + } + inst = orig_ctx->method_inst; + if (inst) { + g_assert (inst->type_argc < 16); + for (i = 0; i < inst->type_argc; ++i) + args [i] = get_wrapper_shared_type (inst->type_argv [i]); + ctx.method_inst = mono_metadata_get_generic_inst (inst->type_argc, args); + } + klass = mono_class_inflate_generic_class (klass->generic_class->container_class, &ctx); + return &klass->byval_arg; + } #if SIZEOF_VOID_P == 8 case MONO_TYPE_I8: return &mono_defaults.int_class->byval_arg; @@ -1075,6 +1103,8 @@ mini_get_underlying_signature (MonoMethodSignature *sig) res->ret = get_wrapper_shared_type (sig->ret); for (i = 0; i < sig->param_count; ++i) res->params [i] = get_wrapper_shared_type (sig->params [i]); + res->generic_param_count = 0; + res->is_inflated = 0; return res; } @@ -1141,6 +1171,7 @@ mini_get_gsharedvt_in_sig_wrapper (MonoMethodSignature *sig) // FIXME: Use shared signatures mb = mono_mb_new (mono_defaults.object_class, sig->hasthis ? "gsharedvt_in_sig" : "gsharedvt_in_sig_static", MONO_WRAPPER_UNKNOWN); +#ifndef DISABLE_JIT if (sig->ret->type != MONO_TYPE_VOID) retval_var = mono_mb_add_local (mb, sig->ret); @@ -1167,6 +1198,7 @@ mini_get_gsharedvt_in_sig_wrapper (MonoMethodSignature *sig) if (sig->ret->type != MONO_TYPE_VOID) mono_mb_emit_ldloc (mb, retval_var); mono_mb_emit_byte (mb, CEE_RET); +#endif info = mono_wrapper_info_create (mb, WRAPPER_SUBTYPE_GSHAREDVT_IN_SIG); info->d.gsharedvt.sig = sig; @@ -1241,6 +1273,7 @@ mini_get_gsharedvt_out_sig_wrapper (MonoMethodSignature *sig) // FIXME: Use shared signatures mb = mono_mb_new (mono_defaults.object_class, "gsharedvt_out_sig", MONO_WRAPPER_UNKNOWN); +#ifndef DISABLE_JIT if (sig->ret->type != MONO_TYPE_VOID) /* Load return address */ mono_mb_emit_ldarg (mb, sig->hasthis ? 1 : 0); @@ -1280,6 +1313,7 @@ mini_get_gsharedvt_out_sig_wrapper (MonoMethodSignature *sig) mono_mb_emit_byte (mb, stind_op); } mono_mb_emit_byte (mb, CEE_RET); +#endif info = mono_wrapper_info_create (mb, WRAPPER_SUBTYPE_GSHAREDVT_OUT_SIG); info->d.gsharedvt.sig = sig; @@ -1481,7 +1515,7 @@ instantiate_info (MonoDomain *domain, MonoRuntimeGenericContextInfoTemplate *oti addr = mini_add_method_wrappers_llvmonly (m, addr, FALSE, FALSE, &arg); /* Returns an ftndesc */ - return mini_create_llvmonly_ftndesc (addr, arg); + return mini_create_llvmonly_ftndesc (domain, addr, arg); } else { addr = mono_compile_method ((MonoMethod *)data); return mini_add_method_trampoline ((MonoMethod *)data, addr, mono_method_needs_static_rgctx_invoke ((MonoMethod *)data, FALSE), FALSE); @@ -1658,13 +1692,14 @@ instantiate_info (MonoDomain *domain, MonoRuntimeGenericContextInfoTemplate *oti /* The virtual case doesn't go through this code */ g_assert (!virtual_); + sig = mono_method_signature (jinfo_get_method (callee_ji)); gpointer out_wrapper = mini_get_gsharedvt_wrapper (FALSE, NULL, sig, gsig, -1, FALSE); - gpointer *out_wrapper_arg = mini_create_llvmonly_ftndesc (callee_ji->code_start, mini_method_get_rgctx (method)); + MonoFtnDesc *out_wrapper_arg = mini_create_llvmonly_ftndesc (domain, callee_ji->code_start, mini_method_get_rgctx (method)); /* Returns an ftndesc */ - addr = mini_create_llvmonly_ftndesc (out_wrapper, out_wrapper_arg); + addr = mini_create_llvmonly_ftndesc (domain, out_wrapper, out_wrapper_arg); } else { - addr = mini_create_llvmonly_ftndesc (addr, mini_method_get_rgctx (method)); + addr = mini_create_llvmonly_ftndesc (domain, addr, mini_method_get_rgctx (method)); } } else { addr = mini_get_gsharedvt_wrapper (FALSE, addr, sig, gsig, vcall_offset, FALSE); @@ -1707,18 +1742,18 @@ instantiate_info (MonoDomain *domain, MonoRuntimeGenericContextInfoTemplate *oti * might not exist at all in IL, so the AOT compiler cannot generate the wrappers * for it. */ - addr = mini_create_llvmonly_ftndesc (callee_ji->code_start, mini_method_get_rgctx (method)); + addr = mini_create_llvmonly_ftndesc (domain, callee_ji->code_start, mini_method_get_rgctx (method)); } else if (mini_is_gsharedvt_variable_signature (gsig)) { gpointer in_wrapper = mini_get_gsharedvt_wrapper (TRUE, callee_ji->code_start, sig, gsig, -1, FALSE); - gpointer in_wrapper_arg = mini_create_llvmonly_ftndesc (callee_ji->code_start, mini_method_get_rgctx (method)); + gpointer in_wrapper_arg = mini_create_llvmonly_ftndesc (domain, callee_ji->code_start, mini_method_get_rgctx (method)); gpointer out_wrapper = mini_get_gsharedvt_wrapper (FALSE, NULL, sig, gsig, -1, FALSE); - gpointer *out_wrapper_arg = mini_create_llvmonly_ftndesc (in_wrapper, in_wrapper_arg); + MonoFtnDesc *out_wrapper_arg = mini_create_llvmonly_ftndesc (domain, in_wrapper, in_wrapper_arg); - addr = mini_create_llvmonly_ftndesc (out_wrapper, out_wrapper_arg); + addr = mini_create_llvmonly_ftndesc (domain, out_wrapper, out_wrapper_arg); } else { - addr = mini_create_llvmonly_ftndesc (addr, mini_method_get_rgctx (method)); + addr = mini_create_llvmonly_ftndesc (domain, addr, mini_method_get_rgctx (method)); } } else if (call_sig == mono_method_signature (method)) { } else { diff --git a/mono/mini/mini-llvm-loaded.c b/mono/mini/mini-llvm-loaded.c index cecc654cc5b..baa55cc1ff1 100644 --- a/mono/mini/mini-llvm-loaded.c +++ b/mono/mini/mini-llvm-loaded.c @@ -31,6 +31,7 @@ static MonoLLVMCFGFunc mono_llvm_check_method_supported_fptr; static MonoLLVMEmitAotInfoFunc mono_llvm_emit_aot_file_info_fptr; static MonoLLVMEmitAotDataFunc mono_llvm_emit_aot_data_fptr; static MonoLLVMFreeDomainFunc mono_llvm_free_domain_info_fptr; +static void (*mono_llvm_create_vars_fptr) (MonoCompile *cfg); void mono_llvm_init (void) @@ -97,6 +98,13 @@ mono_llvm_emit_aot_data (const char *symbol, guint8 *data, int data_len) mono_llvm_emit_aot_data_fptr (symbol, data, data_len); } +void +mono_llvm_create_vars (MonoCompile *cfg) +{ + if (mono_llvm_create_vars_fptr) + mono_llvm_create_vars_fptr (cfg); +} + int mono_llvm_load (const char* bpath) { @@ -129,6 +137,8 @@ mono_llvm_load (const char* bpath) if (err) goto symbol_error; err = mono_dl_symbol (llvm_lib, "mono_llvm_emit_aot_data", (void**)&mono_llvm_emit_aot_data_fptr); if (err) goto symbol_error; + err = mono_dl_symbol (llvm_lib, "mono_llvm_create_vars", (void**)&mono_llvm_create_vars_fptr); + if (err) goto symbol_error; return TRUE; symbol_error: g_warning ("llvm symbol load failed: %s\n", err); diff --git a/mono/mini/mini-llvm.c b/mono/mini/mini-llvm.c index a9910c81f89..d36ee8f0700 100644 --- a/mono/mini/mini-llvm.c +++ b/mono/mini/mini-llvm.c @@ -1378,9 +1378,11 @@ sig_to_llvm_sig_full (EmitContext *ctx, MonoMethodSignature *sig, LLVMCallInfo * case LLVMArgAsFpArgs: { int j; + /* Emit dummy fp arguments if needed so the rest is passed on the stack */ + for (j = 0; j < ainfo->ndummy_fpargs; ++j) + param_types [pindex ++] = LLVMDoubleType (); for (j = 0; j < ainfo->nslots; ++j) - param_types [pindex + j] = ainfo->esize == 8 ? LLVMDoubleType () : LLVMFloatType (); - pindex += ainfo->nslots; + param_types [pindex ++] = ainfo->esize == 8 ? LLVMDoubleType () : LLVMFloatType (); break; } case LLVMArgVtypeAsScalar: @@ -2793,6 +2795,8 @@ emit_entry_bb (EmitContext *ctx, LLVMBuilderRef builder) LLVMValueRef args [8]; int j; + pindex += ainfo->ndummy_fpargs; + /* The argument is received as a set of int/fp arguments, store them into the real argument */ memset (args, 0, sizeof (args)); if (ainfo->storage == LLVMArgVtypeInReg) { @@ -3010,7 +3014,7 @@ process_call (EmitContext *ctx, MonoBasicBlock *bb, LLVMBuilderRef *builder_ref, gboolean vretaddr; LLVMTypeRef llvm_sig; gpointer target; - gboolean is_virtual, calli; + gboolean is_virtual, calli, preserveall; LLVMBuilderRef builder = *builder_ref; if (call->signature->call_convention != MONO_CALL_DEFAULT) @@ -3030,6 +3034,8 @@ process_call (EmitContext *ctx, MonoBasicBlock *bb, LLVMBuilderRef *builder_ref, is_virtual = (ins->opcode == OP_VOIDCALL_MEMBASE || ins->opcode == OP_CALL_MEMBASE || ins->opcode == OP_VCALL_MEMBASE || ins->opcode == OP_LCALL_MEMBASE || ins->opcode == OP_FCALL_MEMBASE || ins->opcode == OP_RCALL_MEMBASE); calli = !call->fptr_is_patch && (ins->opcode == OP_VOIDCALL_REG || ins->opcode == OP_CALL_REG || ins->opcode == OP_VCALL_REG || ins->opcode == OP_LCALL_REG || ins->opcode == OP_FCALL_REG || ins->opcode == OP_RCALL_REG); + /* Unused */ + preserveall = FALSE; /* FIXME: Avoid creating duplicate methods */ @@ -3219,6 +3225,11 @@ process_call (EmitContext *ctx, MonoBasicBlock *bb, LLVMBuilderRef *builder_ref, case LLVMArgVtypeInReg: case LLVMArgAsFpArgs: { guint32 nargs; + int j; + + for (j = 0; j < ainfo->ndummy_fpargs; ++j) + args [pindex + j] = LLVMConstNull (LLVMDoubleType ()); + pindex += ainfo->ndummy_fpargs; g_assert (addresses [reg]); emit_vtype_to_args (ctx, builder, ainfo->type, addresses [reg], ainfo, args + pindex, &nargs); @@ -3285,6 +3296,8 @@ process_call (EmitContext *ctx, MonoBasicBlock *bb, LLVMBuilderRef *builder_ref, g_assert (!(call->rgctx_arg_reg && call->imt_arg_reg)); if (!sig->pinvoke && !cfg->llvm_only) LLVMSetInstructionCallConv (lcall, LLVMMono1CallConv); + if (preserveall) + mono_llvm_set_call_preserveall_cc (lcall); if (cinfo->ret.storage == LLVMArgVtypeByRef) LLVMAddInstrAttribute (lcall, 1 + cinfo->vret_arg_pindex, LLVMStructRetAttribute); @@ -4161,7 +4174,8 @@ process_bb (EmitContext *ctx, MonoBasicBlock *bb) case OP_LCOMPARE_IMM: case OP_COMPARE_IMM: { CompRelation rel; - LLVMValueRef cmp; + LLVMValueRef cmp, args [16]; + gboolean likely = (ins->flags & MONO_INST_LIKELY) != 0; if (ins->next->opcode == OP_NOP) break; @@ -4223,6 +4237,12 @@ process_bb (EmitContext *ctx, MonoBasicBlock *bb) } else cmp = LLVMBuildICmp (builder, cond_to_llvm_cond [rel], lhs, rhs, ""); + if (likely) { + args [0] = cmp; + args [1] = LLVMConstInt (LLVMInt1Type (), 1, FALSE); + cmp = LLVMBuildCall (ctx->builder, LLVMGetNamedFunction (ctx->lmodule, "llvm.expect.i1"), args, 2, ""); + } + if (MONO_IS_COND_BRANCH_OP (ins->next)) { if (ins->next->inst_true_bb == ins->next->inst_false_bb) { /* @@ -4525,6 +4545,7 @@ process_bb (EmitContext *ctx, MonoBasicBlock *bb) case OP_ISHR_UN_IMM: case OP_LADD_IMM: case OP_LSUB_IMM: + case OP_LMUL_IMM: case OP_LREM_IMM: case OP_LAND_IMM: case OP_LOR_IMM: @@ -4570,6 +4591,7 @@ process_bb (EmitContext *ctx, MonoBasicBlock *bb) break; case OP_IMUL_IMM: case OP_MUL_IMM: + case OP_LMUL_IMM: values [ins->dreg] = LLVMBuildMul (builder, lhs, imm, dname); break; case OP_IDIV_IMM: @@ -6135,8 +6157,9 @@ mono_llvm_check_method_supported (MonoCompile *cfg) MonoExceptionClause *clause1 = &cfg->header->clauses [i]; MonoExceptionClause *clause2 = &cfg->header->clauses [j]; - if (i != j && clause1->try_offset >= clause2->try_offset && clause1->handler_offset <= clause2->handler_offset && - (clause1->flags == MONO_EXCEPTION_CLAUSE_FINALLY || clause2->flags == MONO_EXCEPTION_CLAUSE_FINALLY)) { + // FIXME: Nested try clauses fail in some cases too, i.e. #37273 + if (i != j && clause1->try_offset >= clause2->try_offset && clause1->handler_offset <= clause2->handler_offset) { + //(clause1->flags == MONO_EXCEPTION_CLAUSE_FINALLY || clause2->flags == MONO_EXCEPTION_CLAUSE_FINALLY)) { cfg->exception_message = g_strdup ("nested clauses"); cfg->disable_llvm = TRUE; break; @@ -6394,8 +6417,16 @@ mono_llvm_emit_method (MonoCompile *cfg) for (i = 0; i < sig->param_count; ++i) { LLVMArgInfo *ainfo = &linfo->args [i + sig->hasthis]; char *name; + int pindex = ainfo->pindex + ainfo->ndummy_fpargs; + int j; - values [cfg->args [i + sig->hasthis]->dreg] = LLVMGetParam (method, ainfo->pindex); + for (j = 0; j < ainfo->ndummy_fpargs; ++j) { + name = g_strdup_printf ("dummy_%d_%d", i, j); + LLVMSetValueName (LLVMGetParam (method, ainfo->pindex + j), name); + g_free (name); + } + + values [cfg->args [i + sig->hasthis]->dreg] = LLVMGetParam (method, pindex); if (ainfo->storage == LLVMArgScalarByRef) { if (names [i] && names [i][0] != '\0') name = g_strdup_printf ("p_arg_%s", names [i]); @@ -6415,7 +6446,7 @@ mono_llvm_emit_method (MonoCompile *cfg) LLVMSetValueName (values [cfg->args [i + sig->hasthis]->dreg], name); g_free (name); if (ainfo->storage == LLVMArgVtypeByVal) - LLVMAddAttribute (LLVMGetParam (method, ainfo->pindex), LLVMByValAttribute); + LLVMAddAttribute (LLVMGetParam (method, pindex), LLVMByValAttribute); if (ainfo->storage == LLVMArgVtypeByRef) { /* For OP_LDADDR */ @@ -6802,7 +6833,7 @@ mono_llvm_create_vars (MonoCompile *cfg) sig = mono_method_signature (cfg->method); if (cfg->gsharedvt && cfg->llvm_only) { if (mini_is_gsharedvt_variable_signature (sig) && sig->ret->type != MONO_TYPE_VOID) { - cfg->vret_addr = mono_compile_create_var (cfg, &mono_defaults.int_class->byval_arg, OP_ARG); + cfg->vret_addr = mono_compile_create_var (cfg, &mono_get_int32_class ()->byval_arg, OP_ARG); if (G_UNLIKELY (cfg->verbose_level > 1)) { printf ("vret_addr = "); mono_print_ins (cfg->vret_addr); @@ -7123,6 +7154,7 @@ add_intrinsics (LLVMModuleRef module) } AddFunc2 (module, "llvm.expect.i8", LLVMInt8Type (), LLVMInt8Type (), LLVMInt8Type ()); + AddFunc2 (module, "llvm.expect.i1", LLVMInt1Type (), LLVMInt1Type (), LLVMInt1Type ()); /* EH intrinsics */ { @@ -7619,16 +7651,21 @@ emit_aot_file_info (MonoLLVMModule *module) fields [tindex ++] = AddJitGlobal (module, eltype, "method_addresses"); else fields [tindex ++] = LLVMConstNull (eltype); - fields [tindex ++] = LLVMGetNamedGlobal (lmodule, "blob"); - fields [tindex ++] = LLVMGetNamedGlobal (lmodule, "class_name_table"); - fields [tindex ++] = LLVMGetNamedGlobal (lmodule, "class_info_offsets"); - fields [tindex ++] = LLVMGetNamedGlobal (lmodule, "method_info_offsets"); - fields [tindex ++] = LLVMGetNamedGlobal (lmodule, "ex_info_offsets"); - fields [tindex ++] = LLVMGetNamedGlobal (lmodule, "extra_method_info_offsets"); - fields [tindex ++] = LLVMGetNamedGlobal (lmodule, "extra_method_table"); - fields [tindex ++] = LLVMGetNamedGlobal (lmodule, "got_info_offsets"); - fields [tindex ++] = LLVMGetNamedGlobal (lmodule, "llvm_got_info_offsets"); - fields [tindex ++] = LLVMGetNamedGlobal (lmodule, "image_table"); + if (info->flags & MONO_AOT_FILE_FLAG_SEPARATE_DATA) { + for (i = 0; i < MONO_AOT_TABLE_NUM; ++i) + fields [tindex ++] = LLVMConstNull (eltype); + } else { + fields [tindex ++] = LLVMGetNamedGlobal (lmodule, "blob"); + fields [tindex ++] = LLVMGetNamedGlobal (lmodule, "class_name_table"); + fields [tindex ++] = LLVMGetNamedGlobal (lmodule, "class_info_offsets"); + fields [tindex ++] = LLVMGetNamedGlobal (lmodule, "method_info_offsets"); + fields [tindex ++] = LLVMGetNamedGlobal (lmodule, "ex_info_offsets"); + fields [tindex ++] = LLVMGetNamedGlobal (lmodule, "extra_method_info_offsets"); + fields [tindex ++] = LLVMGetNamedGlobal (lmodule, "extra_method_table"); + fields [tindex ++] = LLVMGetNamedGlobal (lmodule, "got_info_offsets"); + fields [tindex ++] = LLVMGetNamedGlobal (lmodule, "llvm_got_info_offsets"); + fields [tindex ++] = LLVMGetNamedGlobal (lmodule, "image_table"); + } /* Not needed (mem_end) */ fields [tindex ++] = LLVMConstNull (eltype); fields [tindex ++] = LLVMGetNamedGlobal (lmodule, "assembly_guid"); diff --git a/mono/mini/mini-llvm.h b/mono/mini/mini-llvm.h index bf7bdb0e4d4..b7ec0167d22 100644 --- a/mono/mini/mini-llvm.h +++ b/mono/mini/mini-llvm.h @@ -26,7 +26,7 @@ void mono_llvm_clear_exception (void); MonoObject *mono_llvm_load_exception (void); void mono_llvm_reset_exception (void); void mono_llvm_raise_exception (MonoException *e); -void mono_llvm_create_vars (MonoCompile *cfg); +void mono_llvm_create_vars (MonoCompile *cfg) MONO_LLVM_INTERNAL; gboolean mini_llvm_init (void); diff --git a/mono/mini/mini-runtime.c b/mono/mini/mini-runtime.c index f569e5c3539..deaa2e8709c 100644 --- a/mono/mini/mini-runtime.c +++ b/mono/mini/mini-runtime.c @@ -1830,6 +1830,12 @@ mono_jit_map_is_enabled (void) #endif +static void +no_gsharedvt_in_wrapper (void) +{ + g_assert_not_reached (); +} + static gpointer mono_jit_compile_method_with_opt (MonoMethod *method, guint32 opt, MonoException **ex) { @@ -1852,14 +1858,10 @@ mono_jit_compile_method_with_opt (MonoMethod *method, guint32 opt, MonoException /* Must be domain neutral since there is only one copy */ opt |= MONO_OPT_SHARED; - } - - if (method->dynamic) - opt &= ~MONO_OPT_SHARED; - - /* These methods can become invalid when a domain is unloaded */ - if (method->klass->image != mono_get_corlib () || method->is_inflated) + } else { + /* MONO_OPT_SHARED is no longer supported, we only use it for icall wrappers */ opt &= ~MONO_OPT_SHARED; + } if (opt & MONO_OPT_SHARED) target_domain = mono_get_root_domain (); @@ -1929,6 +1931,19 @@ mono_jit_compile_method_with_opt (MonoMethod *method, guint32 opt, MonoException code = mono_jit_compile_method_inner (method, target_domain, opt, ex); if (!code && mono_llvm_only) { + if (method->wrapper_type == MONO_WRAPPER_UNKNOWN) { + WrapperInfo *info = mono_marshal_get_wrapper_info (method); + + if (info->subtype == WRAPPER_SUBTYPE_GSHAREDVT_IN_SIG) { + /* + * These wrappers are only created for signatures which are in the program, but + * sometimes we load methods too eagerly and have to create them even if they + * will never be called. + */ + return no_gsharedvt_in_wrapper; + } + } + printf ("AOT method not found in llvmonly mode: %s\n", mono_method_full_name (method, 1)); g_assert_not_reached (); } @@ -2169,38 +2184,21 @@ typedef struct { MonoVTable *vtable; MonoDynCallInfo *dyn_call_info; MonoClass *ret_box_class; - gboolean needs_rgctx; MonoMethodSignature *sig; + gboolean gsharedvt_invoke; gpointer *wrapper_arg; } RuntimeInvokeInfo; -gboolean -mini_gsharedvt_runtime_invoke_supported (MonoMethodSignature *sig) -{ - gboolean supported = TRUE; - int i; - - for (i = 0; i < sig->param_count; ++i) { - MonoType *t = sig->params [i]; - - if (t->byref && t->type == MONO_TYPE_GENERICINST && mono_class_is_nullable (mono_class_from_mono_type (t))) - supported = FALSE; - } - - return supported; -} - static RuntimeInvokeInfo* -create_runtime_invoke_info (MonoDomain *domain, MonoMethod *method, gpointer compiled_method) +create_runtime_invoke_info (MonoDomain *domain, MonoMethod *method, gpointer compiled_method, gboolean callee_gsharedvt) { MonoMethod *invoke; RuntimeInvokeInfo *info; info = g_new0 (RuntimeInvokeInfo, 1); - info->needs_rgctx = mono_llvm_only && mono_method_needs_static_rgctx_invoke (method, TRUE); info->compiled_method = compiled_method; - invoke = mono_marshal_get_runtime_invoke (method, FALSE, info->needs_rgctx); + invoke = mono_marshal_get_runtime_invoke (method, FALSE); info->vtable = mono_class_vtable_full (domain, method->klass, TRUE); g_assert (info->vtable); @@ -2219,7 +2217,6 @@ create_runtime_invoke_info (MonoDomain *domain, MonoMethod *method, gpointer com if (method->string_ctor) sig = mono_marshal_get_string_ctor_signature (method); - g_assert (!info->needs_rgctx); for (i = 0; i < sig->param_count; ++i) { MonoType *t = sig->params [i]; @@ -2279,22 +2276,15 @@ create_runtime_invoke_info (MonoDomain *domain, MonoMethod *method, gpointer com if (!info->dyn_call_info) { if (mono_llvm_only) { - gboolean supported; - - supported = mini_gsharedvt_runtime_invoke_supported (sig); - - if (mono_class_is_contextbound (method->klass) || !info->compiled_method) - supported = FALSE; - #ifndef ENABLE_GSHAREDVT - supported = FALSE; + g_assert_not_reached (); #endif - - if (supported) { + if (!callee_gsharedvt) { /* Invoke a gsharedvt out wrapper instead */ MonoMethod *wrapper = mini_get_gsharedvt_out_sig_wrapper (sig); MonoMethodSignature *wrapper_sig = mini_get_gsharedvt_out_sig_wrapper_signature (sig->hasthis, sig->ret->type != MONO_TYPE_VOID, sig->param_count); + info->gsharedvt_invoke = TRUE; info->wrapper_arg = g_malloc0 (2 * sizeof (gpointer)); info->wrapper_arg [0] = info->compiled_method; info->wrapper_arg [1] = mono_method_needs_static_rgctx_invoke (method, TRUE) ? mini_method_get_rgctx (method) : NULL; @@ -2304,6 +2294,16 @@ create_runtime_invoke_info (MonoDomain *domain, MonoMethod *method, gpointer com g_free (wrapper_sig); info->compiled_method = mono_jit_compile_method (wrapper); + } else { + /* Gsharedvt methods can be invoked the same way */ + /* The out wrapper has the same signature as the compiled gsharedvt method */ + MonoMethodSignature *wrapper_sig = mini_get_gsharedvt_out_sig_wrapper_signature (sig->hasthis, sig->ret->type != MONO_TYPE_VOID, sig->param_count); + + info->gsharedvt_invoke = TRUE; + info->wrapper_arg = mono_method_needs_static_rgctx_invoke (method, TRUE) ? mini_method_get_rgctx (method) : NULL; + + invoke = mono_marshal_get_runtime_invoke_for_sig (wrapper_sig); + g_free (wrapper_sig); } } info->runtime_invoke = mono_jit_compile_method (invoke); @@ -2327,6 +2327,8 @@ mono_jit_runtime_invoke (MonoMethod *method, void *obj, void **params, MonoObjec MonoDomain *domain = mono_domain_get (); MonoJitDomainInfo *domain_info; RuntimeInvokeInfo *info, *info2; + MonoJitInfo *ji = NULL; + gboolean callee_gsharedvt = FALSE; if (obj == NULL && !(method->flags & METHOD_ATTRIBUTE_STATIC) && !method->string_ctor && (method->wrapper_type == 0)) { g_warning ("Ignoring invocation of an instance method on a NULL instance.\n"); @@ -2369,7 +2371,7 @@ mono_jit_runtime_invoke (MonoMethod *method, void *obj, void **params, MonoObjec MonoMethod *wrapper; wrapper = mono_marshal_get_array_accessor_wrapper (method); - invoke = mono_marshal_get_runtime_invoke (wrapper, FALSE, FALSE); + invoke = mono_marshal_get_runtime_invoke (wrapper, FALSE); callee = wrapper; } else { callee = NULL; @@ -2391,12 +2393,18 @@ mono_jit_runtime_invoke (MonoMethod *method, void *obj, void **params, MonoObjec } } - compiled_method = mini_add_method_trampoline (callee, compiled_method, mono_method_needs_static_rgctx_invoke (callee, TRUE), FALSE); + if (mono_llvm_only) { + ji = mini_jit_info_table_find (mono_domain_get (), (char *)mono_get_addr_from_ftnptr (compiled_method), NULL); + callee_gsharedvt = mini_jit_info_is_gsharedvt (ji); + } + + if (!callee_gsharedvt) + compiled_method = mini_add_method_trampoline (callee, compiled_method, mono_method_needs_static_rgctx_invoke (callee, TRUE), FALSE); } else { compiled_method = NULL; } - info = create_runtime_invoke_info (domain, method, compiled_method); + info = create_runtime_invoke_info (domain, method, compiled_method, callee_gsharedvt); mono_domain_lock (domain); info2 = (RuntimeInvokeInfo *)mono_conc_hashtable_insert (domain_info->runtime_invoke_hash, method, info); @@ -2431,7 +2439,6 @@ mono_jit_runtime_invoke (MonoMethod *method, void *obj, void **params, MonoObjec int i, pindex; guint8 buf [512]; guint8 retval [256]; - gpointer rgctx; if (!dyn_runtime_invoke) { invoke = mono_marshal_get_runtime_invoke_dynamic (); @@ -2439,7 +2446,7 @@ mono_jit_runtime_invoke (MonoMethod *method, void *obj, void **params, MonoObjec } /* Convert the arguments to the format expected by start_dyn_call () */ - args = (void **)g_alloca ((sig->param_count + sig->hasthis + info->needs_rgctx) * sizeof (gpointer)); + args = (void **)g_alloca ((sig->param_count + sig->hasthis) * sizeof (gpointer)); pindex = 0; if (sig->hasthis) args [pindex ++] = &obj; @@ -2454,10 +2461,6 @@ mono_jit_runtime_invoke (MonoMethod *method, void *obj, void **params, MonoObjec args [pindex ++] = params [i]; } } - if (info->needs_rgctx) { - rgctx = mini_method_get_rgctx (method); - args [pindex ++] = &rgctx; - } //printf ("M: %s\n", mono_method_full_name (method, TRUE)); @@ -2476,21 +2479,26 @@ mono_jit_runtime_invoke (MonoMethod *method, void *obj, void **params, MonoObjec runtime_invoke = (MonoObject *(*)(MonoObject *, void **, MonoObject **, void *))info->runtime_invoke; - if (info->wrapper_arg) { + if (mono_llvm_only) { MonoMethodSignature *sig = mono_method_signature (method); gpointer *args; gpointer retval_ptr; guint8 retval [256]; - gpointer param_refs [256]; + gpointer *param_refs; int i, pindex; + g_assert (info->gsharedvt_invoke); + /* * Instead of invoking the method directly, we invoke a gsharedvt out wrapper. * The advantage of this is the gsharedvt out wrappers have a reduced set of * signatures, so we only have to generate runtime invoke wrappers for these * signatures. + * This code also handles invocation of gsharedvt methods directly, no + * out wrappers are used in that case. */ args = (void **)g_alloca ((sig->param_count + sig->hasthis + 2) * sizeof (gpointer)); + param_refs = (gpointer*)g_alloca ((sig->param_count + sig->hasthis + 2) * sizeof (gpointer)); pindex = 0; /* * The runtime invoke wrappers expects pointers to primitive types, so have to @@ -2505,6 +2513,20 @@ mono_jit_runtime_invoke (MonoMethod *method, void *obj, void **params, MonoObjec for (i = 0; i < sig->param_count; ++i) { MonoType *t = sig->params [i]; + if (t->type == MONO_TYPE_GENERICINST && mono_class_is_nullable (mono_class_from_mono_type (t))) { + MonoClass *klass = mono_class_from_mono_type (t); + guint8 *nullable_buf; + int size; + + size = mono_class_value_size (klass, NULL); + nullable_buf = g_alloca (size); + g_assert (nullable_buf); + + /* The argument pointed to by params [i] is either a boxed vtype or null */ + mono_nullable_init (nullable_buf, (MonoObject*)params [i], klass); + params [i] = nullable_buf; + } + if (MONO_TYPE_IS_REFERENCE (t)) { param_refs [i] = params [i]; params [i] = &(param_refs [i]); @@ -2516,28 +2538,195 @@ mono_jit_runtime_invoke (MonoMethod *method, void *obj, void **params, MonoObjec runtime_invoke (NULL, args, exc, info->compiled_method); if (sig->ret->type != MONO_TYPE_VOID && info->ret_box_class) - return mono_value_box (domain, info->ret_box_class, retval); + return mono_value_box (domain, info->ret_box_class, retval); else return *(MonoObject**)retval; } - // FIXME: Cache this - if (info->needs_rgctx) { - MonoMethodSignature *sig = mono_method_signature (method); - gpointer rgctx; - gpointer *args; - int i, pindex; + return runtime_invoke ((MonoObject *)obj, params, exc, info->compiled_method); +} - args = (void **)g_alloca ((sig->param_count + sig->hasthis + info->needs_rgctx) * sizeof (gpointer)); - pindex = 0; - rgctx = mini_method_get_rgctx (method); - for (i = 0; i < sig->param_count; ++i) - args [pindex ++] = params [i]; - args [pindex ++] = &rgctx; - return runtime_invoke ((MonoObject *)obj, args, exc, info->compiled_method); - } else { - return runtime_invoke ((MonoObject *)obj, params, exc, info->compiled_method); +typedef struct { + MonoVTable *vtable; + int slot; +} IMTThunkInfo; + +typedef gpointer (*IMTThunkFunc) (gpointer *arg, MonoMethod *imt_method); + +/* + * mini_llvmonly_initial_imt_thunk: + * + * This function is called the first time a call is made through an IMT thunk. + * It should have the same signature as the mono_llvmonly_imt_thunk_... functions. + */ +static gpointer +mini_llvmonly_initial_imt_thunk (gpointer *arg, MonoMethod *imt_method) +{ + IMTThunkInfo *info = (IMTThunkInfo*)arg; + gpointer *imt; + gpointer *ftndesc; + IMTThunkFunc func; + + mono_vtable_build_imt_slot (info->vtable, info->slot); + + imt = (gpointer*)info->vtable; + imt -= MONO_IMT_SIZE; + + /* Return what the real IMT thunk returns */ + ftndesc = imt [info->slot]; + func = ftndesc [0]; + + if (func == (IMTThunkFunc)mini_llvmonly_initial_imt_thunk) + /* Happens when the imt slot contains only a generic virtual method */ + return NULL; + return func ((gpointer *)ftndesc [1], imt_method); +} + +/* This is called indirectly through an imt slot. */ +static gpointer +mono_llvmonly_imt_thunk (gpointer *arg, MonoMethod *imt_method) +{ + int i = 0; + + /* arg points to an array created in mono_llvmonly_get_imt_thunk () */ + while (arg [i] && arg [i] != imt_method) + i += 2; + g_assert (arg [i]); + + return arg [i + 1]; +} + +/* Optimized versions of mono_llvmonly_imt_thunk () for different table sizes */ +static gpointer +mono_llvmonly_imt_thunk_1 (gpointer *arg, MonoMethod *imt_method) +{ + //g_assert (arg [0] == imt_method); + return arg [1]; +} + +static gpointer +mono_llvmonly_imt_thunk_2 (gpointer *arg, MonoMethod *imt_method) +{ + //g_assert (arg [0] == imt_method || arg [2] == imt_method); + if (arg [0] == imt_method) + return arg [1]; + else + return arg [3]; +} + +static gpointer +mono_llvmonly_imt_thunk_3 (gpointer *arg, MonoMethod *imt_method) +{ + //g_assert (arg [0] == imt_method || arg [2] == imt_method || arg [4] == imt_method); + if (arg [0] == imt_method) + return arg [1]; + else if (arg [2] == imt_method) + return arg [3]; + else + return arg [5]; +} + +/* + * A version of the imt thunk used for generic virtual methods. + * Unlikely a normal imt thunk, its possible that IMT_METHOD is not found + * in the search table. The original JIT code had a 'fallback' trampoline it could + * call, but we can't do that, so we just return NULL, and the compiled code + * will handle it. + */ +static gpointer +mono_llvmonly_generic_virtual_imt_thunk (gpointer *arg, MonoMethod *imt_method) +{ + int i = 0; + + while (arg [i] && arg [i] != imt_method) + i += 2; + if (!arg [i]) + return NULL; + + return arg [i + 1]; +} + +static gpointer +mono_llvmonly_get_imt_thunk (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckItem **imt_entries, int count, gpointer fail_tramp) +{ + gpointer *buf; + gpointer *res; + int i, index, real_count; + gboolean virtual_generic = FALSE; + + /* + * Create an array which is passed to the imt thunk functions. + * The array contains MonoMethod-function descriptor pairs, terminated by a NULL entry. + */ + + real_count = 0; + for (i = 0; i < count; ++i) { + MonoIMTCheckItem *item = imt_entries [i]; + + if (item->is_equals) + real_count ++; + if (item->has_target_code) + virtual_generic = TRUE; + } + + /* + * Initialize all vtable entries reachable from this imt slot, so the compiled + * code doesn't have to check it. + */ + for (i = 0; i < count; ++i) { + MonoIMTCheckItem *item = imt_entries [i]; + int vt_slot; + + if (!item->is_equals || item->has_target_code) + continue; + vt_slot = item->value.vtable_slot; + mono_init_vtable_slot (vtable, vt_slot); + } + + /* Save the entries into an array */ + buf = (void **)mono_domain_alloc (domain, (real_count + 1) * 2 * sizeof (gpointer)); + index = 0; + for (i = 0; i < count; ++i) { + MonoIMTCheckItem *item = imt_entries [i]; + + if (!item->is_equals) + continue; + + g_assert (item->key); + buf [(index * 2)] = item->key; + if (item->has_target_code) + buf [(index * 2) + 1] = item->value.target_code; + else + buf [(index * 2) + 1] = vtable->vtable [item->value.vtable_slot]; + index ++; + } + buf [(index * 2)] = NULL; + buf [(index * 2) + 1] = fail_tramp; + + /* + * Return a function descriptor for a C function with 'buf' as its argument. + * It will by called by JITted code. + */ + res = (void **)mono_domain_alloc (domain, 2 * sizeof (gpointer)); + switch (real_count) { + case 1: + res [0] = mono_llvmonly_imt_thunk_1; + break; + case 2: + res [0] = mono_llvmonly_imt_thunk_2; + break; + case 3: + res [0] = mono_llvmonly_imt_thunk_3; + break; + default: + res [0] = mono_llvmonly_imt_thunk; + break; } + if (virtual_generic) + res [0] = mono_llvmonly_generic_virtual_imt_thunk; + res [1] = buf; + + return res; } MONO_SIG_HANDLER_FUNC (, mono_sigfpe_signal_handler) @@ -2742,17 +2931,25 @@ static gpointer *vtable_trampolines; static int vtable_trampolines_size; gpointer -mini_get_vtable_trampoline (int slot_index) +mini_get_vtable_trampoline (MonoVTable *vt, int slot_index) { int index = slot_index + MONO_IMT_SIZE; if (mono_llvm_only) { - /* Not used */ - if (slot_index < 0) - /* The vtable/imt construction code in object.c depends on this being non-NULL */ - return no_imt_trampoline; - else - return no_vcall_trampoline; + if (slot_index < 0) { + /* Initialize the IMT thunks to a 'trampoline' so the generated code doesn't have to initialize it */ + // FIXME: Memory management + gpointer *ftndesc = g_malloc (2 * sizeof (gpointer)); + IMTThunkInfo *info = g_new0 (IMTThunkInfo, 1); + info->vtable = vt; + info->slot = index; + ftndesc [0] = mini_llvmonly_initial_imt_thunk; + ftndesc [1] = info; + mono_memory_barrier (); + return ftndesc; + } else { + return NULL; + } } g_assert (slot_index >= - MONO_IMT_SIZE); @@ -2782,6 +2979,24 @@ mini_get_vtable_trampoline (int slot_index) return vtable_trampolines [index]; } +static gpointer +mini_get_imt_trampoline (MonoVTable *vt, int slot_index) +{ + return mini_get_vtable_trampoline (vt, slot_index - MONO_IMT_SIZE); +} + +static gboolean +mini_imt_entry_inited (MonoVTable *vt, int imt_slot_index) +{ + if (mono_llvm_only) + return FALSE; + + gpointer *imt = (gpointer*)vt; + imt -= MONO_IMT_SIZE; + + return (imt [imt_slot_index] != mini_get_imt_trampoline (vt, imt_slot_index)); +} + gpointer mono_get_delegate_virtual_invoke_impl (MonoMethodSignature *sig, MonoMethod *method) { @@ -2801,7 +3016,7 @@ mono_get_delegate_virtual_invoke_impl (MonoMethodSignature *sig, MonoMethod *met is_interface = method->klass->flags & TYPE_ATTRIBUTE_INTERFACE ? TRUE : FALSE; load_imt_reg = is_virtual_generic || is_interface; - if (is_interface && !is_virtual_generic) + if (is_interface) offset = ((gint32)mono_method_get_imt_slot (method) - MONO_IMT_SIZE) * SIZEOF_VOID_P; else offset = G_STRUCT_OFFSET (MonoVTable, vtable) + ((mono_method_get_vtable_index (method)) * (SIZEOF_VOID_P)); @@ -2846,10 +3061,63 @@ mono_get_delegate_virtual_invoke_impl (MonoMethodSignature *sig, MonoMethod *met return cache [idx]; } -static gpointer -mini_get_imt_trampoline (int slot_index) +gboolean +mini_parse_debug_option (const char *arg) { - return mini_get_vtable_trampoline (slot_index - MONO_IMT_SIZE); + if (!strcmp (arg, "handle-sigint")) + debug_options.handle_sigint = TRUE; + else if (!strcmp (arg, "keep-delegates")) + debug_options.keep_delegates = TRUE; + else if (!strcmp (arg, "reverse-pinvoke-exceptions")) + debug_options.reverse_pinvoke_exceptions = TRUE; + else if (!strcmp (arg, "collect-pagefault-stats")) + debug_options.collect_pagefault_stats = TRUE; + else if (!strcmp (arg, "break-on-unverified")) + debug_options.break_on_unverified = TRUE; + else if (!strcmp (arg, "no-gdb-backtrace")) + debug_options.no_gdb_backtrace = TRUE; + else if (!strcmp (arg, "suspend-on-sigsegv")) + debug_options.suspend_on_sigsegv = TRUE; + else if (!strcmp (arg, "suspend-on-exception")) + debug_options.suspend_on_exception = TRUE; + else if (!strcmp (arg, "suspend-on-unhandled")) + debug_options.suspend_on_unhandled = TRUE; + else if (!strcmp (arg, "dont-free-domains")) + mono_dont_free_domains = TRUE; + else if (!strcmp (arg, "dyn-runtime-invoke")) + debug_options.dyn_runtime_invoke = TRUE; + else if (!strcmp (arg, "gdb")) + debug_options.gdb = TRUE; + else if (!strcmp (arg, "explicit-null-checks")) + debug_options.explicit_null_checks = TRUE; + else if (!strcmp (arg, "gen-seq-points")) + debug_options.gen_sdb_seq_points = TRUE; + else if (!strcmp (arg, "gen-compact-seq-points")) + debug_options.gen_seq_points_compact_data = TRUE; + else if (!strcmp (arg, "single-imm-size")) + debug_options.single_imm_size = TRUE; + else if (!strcmp (arg, "init-stacks")) + debug_options.init_stacks = TRUE; + else if (!strcmp (arg, "casts")) + debug_options.better_cast_details = TRUE; + else if (!strcmp (arg, "soft-breakpoints")) + debug_options.soft_breakpoints = TRUE; + else if (!strcmp (arg, "check-pinvoke-callconv")) + debug_options.check_pinvoke_callconv = TRUE; + else if (!strcmp (arg, "arm-use-fallback-tls")) + debug_options.arm_use_fallback_tls = TRUE; + else if (!strcmp (arg, "debug-domain-unload")) + mono_enable_debug_domain_unload (TRUE); + else if (!strcmp (arg, "partial-sharing")) + mono_set_partial_sharing_supported (TRUE); + else if (!strcmp (arg, "align-small-structs")) + mono_align_small_structs = TRUE; + else if (!strcmp (arg, "native-debugger-break")) + debug_options.native_debugger_break = TRUE; + else + return FALSE; + + return TRUE; } static void @@ -2866,57 +3134,7 @@ mini_parse_debug_options (void) for (ptr = args; ptr && *ptr; ptr++) { const char *arg = *ptr; - if (!strcmp (arg, "handle-sigint")) - debug_options.handle_sigint = TRUE; - else if (!strcmp (arg, "keep-delegates")) - debug_options.keep_delegates = TRUE; - else if (!strcmp (arg, "reverse-pinvoke-exceptions")) - debug_options.reverse_pinvoke_exceptions = TRUE; - else if (!strcmp (arg, "collect-pagefault-stats")) - debug_options.collect_pagefault_stats = TRUE; - else if (!strcmp (arg, "break-on-unverified")) - debug_options.break_on_unverified = TRUE; - else if (!strcmp (arg, "no-gdb-backtrace")) - debug_options.no_gdb_backtrace = TRUE; - else if (!strcmp (arg, "suspend-on-sigsegv")) - debug_options.suspend_on_sigsegv = TRUE; - else if (!strcmp (arg, "suspend-on-exception")) - debug_options.suspend_on_exception = TRUE; - else if (!strcmp (arg, "suspend-on-unhandled")) - debug_options.suspend_on_unhandled = TRUE; - else if (!strcmp (arg, "dont-free-domains")) - mono_dont_free_domains = TRUE; - else if (!strcmp (arg, "dyn-runtime-invoke")) - debug_options.dyn_runtime_invoke = TRUE; - else if (!strcmp (arg, "gdb")) - debug_options.gdb = TRUE; - else if (!strcmp (arg, "explicit-null-checks")) - debug_options.explicit_null_checks = TRUE; - else if (!strcmp (arg, "gen-seq-points")) - debug_options.gen_sdb_seq_points = TRUE; - else if (!strcmp (arg, "gen-compact-seq-points")) - debug_options.gen_seq_points_compact_data = TRUE; - else if (!strcmp (arg, "single-imm-size")) - debug_options.single_imm_size = TRUE; - else if (!strcmp (arg, "init-stacks")) - debug_options.init_stacks = TRUE; - else if (!strcmp (arg, "casts")) - debug_options.better_cast_details = TRUE; - else if (!strcmp (arg, "soft-breakpoints")) - debug_options.soft_breakpoints = TRUE; - else if (!strcmp (arg, "check-pinvoke-callconv")) - debug_options.check_pinvoke_callconv = TRUE; - else if (!strcmp (arg, "arm-use-fallback-tls")) - debug_options.arm_use_fallback_tls = TRUE; - else if (!strcmp (arg, "debug-domain-unload")) - mono_enable_debug_domain_unload (TRUE); - else if (!strcmp (arg, "partial-sharing")) - mono_set_partial_sharing_supported (TRUE); - else if (!strcmp (arg, "align-small-structs")) - mono_align_small_structs = TRUE; - else if (!strcmp (arg, "native-debugger-break")) - debug_options.native_debugger_break = TRUE; - else { + if (!mini_parse_debug_option (arg)) { fprintf (stderr, "Invalid option for the MONO_DEBUG env variable: %s\n", arg); fprintf (stderr, "Available options: 'handle-sigint', 'keep-delegates', 'reverse-pinvoke-exceptions', 'collect-pagefault-stats', 'break-on-unverified', 'no-gdb-backtrace', 'suspend-on-sigsegv', 'suspend-on-exception', 'suspend-on-unhandled', 'dont-free-domains', 'dyn-runtime-invoke', 'gdb', 'explicit-null-checks', 'gen-seq-points', 'gen-compact-seq-points', 'single-imm-size', 'init-stacks', 'casts', 'soft-breakpoints', 'check-pinvoke-callconv', 'arm-use-fallback-tls', 'debug-domain-unload', 'partial-sharing', 'align-small-structs', 'native-debugger-break'\n"); exit (1); @@ -3202,6 +3420,7 @@ mini_init (const char *filename, const char *runtime_version) callbacks.get_vtable_trampoline = mini_get_vtable_trampoline; callbacks.get_imt_trampoline = mini_get_imt_trampoline; + callbacks.imt_entry_inited = mini_imt_entry_inited; mono_install_callbacks (&callbacks); @@ -3306,10 +3525,14 @@ mini_init (const char *filename, const char *runtime_version) mono_marshal_use_aot_wrappers (TRUE); } - if (mono_aot_only) + if (mono_llvm_only) { + mono_install_imt_thunk_builder (mono_llvmonly_get_imt_thunk); + mono_set_always_build_imt_thunks (TRUE); + } else if (mono_aot_only) { mono_install_imt_thunk_builder (mono_aot_get_imt_thunk); - else + } else { mono_install_imt_thunk_builder (mono_arch_build_imt_thunk); + } /*Init arch tls information only after the metadata side is inited to make sure we see dynamic appdomain tls keys*/ mono_arch_finish_init (); @@ -3614,10 +3837,12 @@ register_icalls (void) register_icall (mono_aot_init_gshared_method_this, "mono_aot_init_gshared_method_this", "void ptr int object", TRUE); register_icall (mono_aot_init_gshared_method_rgctx, "mono_aot_init_gshared_method_rgctx", "void ptr int ptr", TRUE); - register_icall_no_wrapper (mono_resolve_iface_call, "mono_resolve_iface_call", "ptr object int ptr ptr"); - register_icall_no_wrapper (mono_resolve_vcall, "mono_resolve_vcall", "ptr object int ptr ptr"); register_icall_no_wrapper (mono_resolve_iface_call_gsharedvt, "mono_resolve_iface_call_gsharedvt", "ptr object int ptr ptr"); register_icall_no_wrapper (mono_resolve_vcall_gsharedvt, "mono_resolve_vcall_gsharedvt", "ptr object int ptr ptr"); + register_icall_no_wrapper (mono_resolve_generic_virtual_call, "mono_resolve_generic_virtual_call", "ptr ptr int ptr"); + register_icall_no_wrapper (mono_resolve_generic_virtual_iface_call, "mono_resolve_generic_virtual_iface_call", "ptr ptr int ptr"); + /* This needs a wrapper so it can have a preserveall cconv */ + register_icall (mono_init_vtable_slot, "mono_init_vtable_slot", "ptr ptr int", FALSE); register_icall (mono_init_delegate, "mono_init_delegate", "void object object ptr", TRUE); register_icall (mono_init_delegate_virtual, "mono_init_delegate_virtual", "void object object ptr", TRUE); register_icall (mono_get_assembly_object, "mono_get_assembly_object", "object ptr", TRUE); @@ -3834,7 +4059,7 @@ mono_precompile_assembly (MonoAssembly *ass, void *user_data) } mono_compile_method (method); if (strcmp (method->name, "Finalize") == 0) { - invoke = mono_marshal_get_runtime_invoke (method, FALSE, FALSE); + invoke = mono_marshal_get_runtime_invoke (method, FALSE); mono_compile_method (invoke); } #ifndef DISABLE_REMOTING diff --git a/mono/mini/mini-trampolines.c b/mono/mini/mini-trampolines.c index 174d6f694ad..116d9778280 100644 --- a/mono/mini/mini-trampolines.c +++ b/mono/mini/mini-trampolines.c @@ -182,7 +182,8 @@ mini_resolve_imt_method (MonoVTable *vt, gpointer *vtable_slot, MonoMethod *imt_ /* We can only use the AOT compiled code if we don't require further processing */ lookup_aot = !generic_virtual & !variant_iface; - mono_vtable_build_imt_slot (vt, mono_method_get_imt_slot (imt_method)); + if (!mono_llvm_only) + mono_vtable_build_imt_slot (vt, mono_method_get_imt_slot (imt_method)); if (imt_method->is_inflated && ((MonoMethodInflated*)imt_method)->context.method_inst) { MonoError error; @@ -386,17 +387,14 @@ mini_add_method_trampoline (MonoMethod *m, gpointer compiled_method, gboolean ad * - generic sharing (ARG is the rgctx) * - gsharedvt signature wrappers (ARG is a function descriptor) */ -gpointer -mini_create_llvmonly_ftndesc (gpointer addr, gpointer arg) +MonoFtnDesc* +mini_create_llvmonly_ftndesc (MonoDomain *domain, gpointer addr, gpointer arg) { - gpointer *res; - - // FIXME: Memory management - res = g_malloc0 (2 * sizeof (gpointer)); - res [0] = addr; - res [1] = arg; + MonoFtnDesc *ftndesc = (MonoFtnDesc*)mono_domain_alloc0 (mono_domain_get (), 2 * sizeof (gpointer)); + ftndesc->addr = addr; + ftndesc->arg = arg; - return res; + return ftndesc; } /** @@ -461,7 +459,11 @@ mini_add_method_wrappers_llvmonly (MonoMethod *m, gpointer compiled_method, gboo if (ji && !ji->is_trampoline) jmethod = jinfo_get_method (ji); - if (callee_gsharedvt && mini_is_gsharedvt_variable_signature (mono_method_signature (jmethod))) { + + if (callee_gsharedvt) + callee_gsharedvt = mini_is_gsharedvt_variable_signature (mono_method_signature (jmethod)); + + if (!caller_gsharedvt && callee_gsharedvt) { MonoMethodSignature *sig, *gsig; /* Here m is a generic instance, while ji->method is the gsharedvt method implementing it */ @@ -475,21 +477,19 @@ mini_add_method_wrappers_llvmonly (MonoMethod *m, gpointer compiled_method, gboo /* * This is a gsharedvt in wrapper, it gets passed a ftndesc for the gsharedvt method as an argument. */ - *out_arg = mini_create_llvmonly_ftndesc (compiled_method, mini_method_get_rgctx (m)); + *out_arg = mini_create_llvmonly_ftndesc (mono_domain_get (), compiled_method, mini_method_get_rgctx (m)); //printf ("IN: %s\n", mono_method_full_name (m, TRUE)); } if (!(*out_arg) && mono_method_needs_static_rgctx_invoke (m, FALSE)) *out_arg = mini_method_get_rgctx (m); - if (caller_gsharedvt) { + if (caller_gsharedvt && !callee_gsharedvt) { /* * The callee uses the gsharedvt calling convention, have to add an out wrapper. */ gpointer out_wrapper = mini_get_gsharedvt_wrapper (FALSE, NULL, mono_method_signature (m), NULL, -1, FALSE); - gpointer *out_wrapper_arg = g_malloc0 (2 * sizeof (gpointer)); - out_wrapper_arg [0] = addr; - out_wrapper_arg [1] = *out_arg; + MonoFtnDesc *out_wrapper_arg = mini_create_llvmonly_ftndesc (mono_domain_get (), addr, *out_arg); addr = out_wrapper; *out_arg = out_wrapper_arg; diff --git a/mono/mini/mini.c b/mono/mini/mini.c index f766fcdb96f..82a94497d41 100644 --- a/mono/mini/mini.c +++ b/mono/mini/mini.c @@ -3498,11 +3498,6 @@ mini_method_compile (MonoMethod *method, guint32 opts, MonoDomain *domain, JitFl cfg->extend_live_ranges = TRUE; - /* Temporarily disable this when running in the debugger until we have support - * for this in the debugger. */ - /* This is no longer needed with sdb */ - //cfg->disable_omit_fp = TRUE; - /* The debugger needs all locals to be on the stack or in a global register */ cfg->disable_vreg_to_lvreg = TRUE; @@ -3510,13 +3505,10 @@ mini_method_compile (MonoMethod *method, guint32 opts, MonoDomain *domain, JitFl * may still want to view them. */ cfg->disable_deadce_vars = TRUE; - // cfg->opt |= MONO_OPT_SHARED; cfg->opt &= ~MONO_OPT_DEADCE; cfg->opt &= ~MONO_OPT_INLINE; cfg->opt &= ~MONO_OPT_COPYPROP; cfg->opt &= ~MONO_OPT_CONSPROP; - /* This is no longer needed with sdb */ - //cfg->opt &= ~MONO_OPT_GSHARED; /* This is needed for the soft debugger, which doesn't like code after the epilog */ cfg->disable_out_of_line_bblocks = TRUE; diff --git a/mono/mini/mini.h b/mono/mini/mini.h index 58d7c105ebf..400b9233e9c 100644 --- a/mono/mini/mini.h +++ b/mono/mini/mini.h @@ -807,6 +807,8 @@ typedef struct { /* Parameter index in the LLVM signature */ int pindex; MonoType *type; + /* Only if storage == LLVMArgAsFpArgs. Dummy fp args to insert before this arg */ + int ndummy_fpargs; } LLVMArgInfo; typedef struct { @@ -981,7 +983,9 @@ enum { * Set on instructions during code emission which make calls, i.e. OP_CALL, OP_THROW. * backend.pc_offset will be set to the pc offset at the end of the native call instructions. */ - MONO_INST_GC_CALLSITE = 128 + MONO_INST_GC_CALLSITE = 128, + /* On comparisons, mark the branch following the condition as likely to be taken */ + MONO_INST_LIKELY = 128, }; #define inst_c0 data.op[0].const_val @@ -1288,6 +1292,17 @@ typedef struct gboolean need_rgctx_tramp; } MonoDelegateTrampInfo; +/* + * A function descriptor, which is a function address + argument pair. + * In llvm-only mode, these are used instead of trampolines to pass + * extra arguments to runtime functions/methods. + */ +typedef struct +{ + gpointer addr; + gpointer arg; +} MonoFtnDesc; + typedef enum { #define PATCH_INFO(a,b) MONO_PATCH_INFO_ ## a, #include "patch-info.h" @@ -1894,6 +1909,7 @@ enum { #define OP_PADD_IMM OP_LADD_IMM #define OP_PSUB_IMM OP_LSUB_IMM #define OP_PAND_IMM OP_LAND_IMM +#define OP_PXOR_IMM OP_LXOR_IMM #define OP_PSUB OP_LSUB #define OP_PMUL OP_LMUL #define OP_PMUL_IMM OP_LMUL_IMM @@ -1919,6 +1935,7 @@ enum { #define OP_PADD_IMM OP_IADD_IMM #define OP_PSUB_IMM OP_ISUB_IMM #define OP_PAND_IMM OP_IAND_IMM +#define OP_PXOR_IMM OP_IXOR_IMM #define OP_PSUB OP_ISUB #define OP_PMUL OP_IMUL #define OP_PMUL_IMM OP_IMUL_IMM @@ -2212,6 +2229,7 @@ MONO_API void mono_parse_env_options (int *ref_argc, char **ref_a MonoDomain* mini_init (const char *filename, const char *runtime_version); void mini_cleanup (MonoDomain *domain); MONO_API MonoDebugOptions *mini_get_debug_options (void); +MONO_API gboolean mini_parse_debug_option (const char *option); /* helper methods */ void mini_jit_init (void); @@ -2500,7 +2518,7 @@ void mono_monitor_enter_trampoline (mgreg_t *regs, guint8 *code, Mo void mono_monitor_enter_v4_trampoline (mgreg_t *regs, guint8 *code, MonoObject *obj, guint8 *tramp); void mono_monitor_exit_trampoline (mgreg_t *regs, guint8 *code, MonoObject *obj, guint8 *tramp); gconstpointer mono_get_trampoline_func (MonoTrampolineType tramp_type); -gpointer mini_get_vtable_trampoline (int slot_index); +gpointer mini_get_vtable_trampoline (MonoVTable *vt, int slot_index); const char* mono_get_generic_trampoline_simple_name (MonoTrampolineType tramp_type); char* mono_get_generic_trampoline_name (MonoTrampolineType tramp_type); char* mono_get_rgctx_fetch_trampoline_name (int slot); @@ -2509,10 +2527,10 @@ gpointer mini_get_single_step_trampoline (void); gpointer mini_get_breakpoint_trampoline (void); gpointer mini_add_method_trampoline (MonoMethod *m, gpointer compiled_method, gboolean add_static_rgctx_tramp, gboolean add_unbox_tramp); gpointer mini_add_method_wrappers_llvmonly (MonoMethod *m, gpointer compiled_method, gboolean caller_gsharedvt, gboolean add_unbox_tramp, gpointer *out_arg); -gpointer mini_create_llvmonly_ftndesc (gpointer addr, gpointer arg); gboolean mini_jit_info_is_gsharedvt (MonoJitInfo *ji); gpointer* mini_resolve_imt_method (MonoVTable *vt, gpointer *vtable_slot, MonoMethod *imt_method, MonoMethod **impl_method, gpointer *out_aot_addr, gboolean *out_need_rgctx_tramp, MonoMethod **variant_iface); +MonoFtnDesc *mini_create_llvmonly_ftndesc (MonoDomain *domain, gpointer addr, gpointer arg); gboolean mono_running_on_valgrind (void); void* mono_global_codeman_reserve (int size); @@ -2699,7 +2717,7 @@ gboolean mono_arch_is_int_overflow (void *sigctx, void *info); void mono_arch_invalidate_method (MonoJitInfo *ji, void *func, gpointer func_arg); guint32 mono_arch_get_patch_offset (guint8 *code); gpointer*mono_arch_get_delegate_method_ptr_addr (guint8* code, mgreg_t *regs); -void mono_arch_create_vars (MonoCompile *cfg); +void mono_arch_create_vars (MonoCompile *cfg) MONO_LLVM_INTERNAL; void mono_arch_save_unwind_info (MonoCompile *cfg); void mono_arch_register_lowlevel_calls (void); gpointer mono_arch_get_unbox_trampoline (MonoMethod *m, gpointer addr); diff --git a/mono/mini/objects.cs b/mono/mini/objects.cs index 2fe402f907f..c6837933d3f 100644 --- a/mono/mini/objects.cs +++ b/mono/mini/objects.cs @@ -1708,6 +1708,25 @@ ncells ) { public static int test_42_pass_16byte_struct_split () { return pass_struct16 (null, null, null, null, null, new Struct16 () { a = 42 }); } + + public interface IComparer2 + { + Type foo (); + } + + public class AClass : IComparer2 { + public Type foo () { + return typeof(T); + } + } + + public static int test_0_delegate_to_virtual_generic_on_ifaces () { + IComparer2 c = new AClass (); + + Func f = c.foo; + return f () == typeof(string) ? 0 : 1; + } + } #if __MOBILE__ diff --git a/mono/sgen/sgen-alloc.c b/mono/sgen/sgen-alloc.c index 0832bc161fe..ca9d645e6aa 100644 --- a/mono/sgen/sgen-alloc.c +++ b/mono/sgen/sgen-alloc.c @@ -554,9 +554,6 @@ sgen_init_allocator (void) mono_tls_key_set_offset (TLS_KEY_SGEN_TLAB_NEXT_ADDR, tlab_next_addr_offset); mono_tls_key_set_offset (TLS_KEY_SGEN_TLAB_TEMP_END, tlab_temp_end_offset); - - g_assert (tlab_next_addr_offset != -1); - g_assert (tlab_temp_end_offset != -1); #endif #ifdef HEAVY_STATISTICS diff --git a/mono/utils/checked-build.c b/mono/utils/checked-build.c index 5c4fd4249e9..65bff4d26fb 100644 --- a/mono/utils/checked-build.c +++ b/mono/utils/checked-build.c @@ -432,6 +432,12 @@ check_image_set_may_reference_image_set (MonoImageSet *from, MonoImageSet *to) { gboolean seen = FALSE; + // If TO set includes corlib, the FROM set may + // implicitly reference corlib, even if it's not + // present in the set explicitly. + if (to->images[to_idx] == mono_defaults.corlib) + seen = TRUE; + // For each item in to->images, scan over from->images looking for it. for (from_idx = 0; !seen && from_idx < from->nimages; from_idx++) {