[assembly loader] Don't raise in mono_assembly_open_full and mono_assembly_load_with_partial_name
if item["name"] == name:
return item
- print "Not found"
+ print("Not found")
sys.exit(1)
if len(sys.argv) < 2:
- print "Usage: versions.py <command>"
+ print("Usage: versions.py <command>")
sys.exit(1)
CONFIG_FILE = "SUBMODULES.json"
if command == "get-rev":
mod = find_module(submodules, sys.argv[2])
- print mod["rev"]
+ print(mod["rev"])
elif command == "get-url":
mod = find_module(submodules, sys.argv[2])
- print mod["url"]
+ print(mod["url"])
elif command == "get-dir":
mod = find_module(submodules, sys.argv[2])
- print mod["directory"]
+ print(mod["directory"])
elif command == "get-remote-branch":
mod = find_module(submodules, sys.argv[2])
- print mod["remote-branch"]
+ print(mod["remote-branch"])
elif command == "set-rev":
mod = find_module(submodules, sys.argv[2])
mod["rev"] = sys.argv[3]
mod["remote-branch"] = sys.argv[3]
json.dump(submodules, open(CONFIG_FILE, "w"), indent = 2)
elif command == "cat":
- print json.dumps(submodules, indent = 2)
+ print(json.dumps(submodules, indent = 2))
else:
- print "Unknown command "" + command + ""."
+ print("Unknown command "" + command + "".")
sys.exit(1)
# Process this file with autoconf to produce a configure script.
#AC_PREREQ([2.62])
-AC_INIT(mono, [4.5.0],
+AC_INIT(mono, [4.5.1],
[http://bugzilla.xamarin.com/enter_bug.cgi?classification=Mono])
AC_CONFIG_SRCDIR([README.md])
host_win32=yes
mono_cv_clang=no
if test "x$cross_compiling" = "xno"; then
- if test "x$host" == "x$build" -a "x$host" == "x$target"; then
+ if test "x$host" = "x$build" -a "x$host" = "x$target"; then
target_win32=yes
fi
else
- if test "x$host" == "x$target"; then
+ if test "x$host" = "x$target"; then
target_win32=yes
fi
fi
need_link_unlink=yes
libmono_cflags="-D_REENTRANT"
libgc_threads=pthreads
- # This doesn't seem to work on solaris/x86, but the configure test runs
- with_tls=pthread
has_dtrace=yes
use_sigposix=yes
enable_solaris_tar_check=yes
#include <winsock2.h>
#include <ws2tcpip.h>
], [
+ #ifndef inet_pton
+ (void) inet_pton;
+ #endif
inet_pton (0, NULL, NULL);
], [
# Yes, we have it...
AC_ARG_ENABLE(bcl-opt, [ --disable-bcl-opt BCL is compiled with no optimizations (allows accurate BCL debugging)], test_bcl_opt=$enableval, test_bcl_opt=yes)
AC_ARG_ENABLE(perf-events, [ --enable-perf-events Enable using `perf` for profiling on Linux], test_perf_events=$enableval, test_perf_events=no)
-if test "x$test_perf_events" == "xyes"; then
+if test "x$test_perf_events" = "xyes"; then
AC_DEFINE(ENABLE_PERF_EVENTS, 1, [Enable using `perf` for profiling on Linux])
AC_SUBST(ENABLE_PERF_EVENTS)
fi
AC_MSG_CHECKING(LLVM version)
AC_MSG_RESULT($llvm_version $llvm_api_version)
if echo $llvm_version | grep -q 'mono'; then
- if test "x$enable_llvm_version_check" == "xyes"; then
+ if test "x$enable_llvm_version_check" = "xyes"; then
if test "$llvm_version" != "$expected_llvm_version"; then
AC_MSG_ERROR([Expected llvm version $expected_llvm_version, but llvm-config --version returned $llvm_version"])
fi
llvm_jit_libs=""
fi
LLVM_LIBS=`$LLVM_CONFIG --libs analysis core bitwriter $llvm_jit_libs`
- if test "x$LLVM_LIBS" == "x"; then
+ if test "x$LLVM_LIBS" = "x"; then
echo "$LLVM_CONFIG --libs failed."
exit 1
fi
AOT_SUPPORTED="yes"
CPPFLAGS="$CPPFLAGS -D__ARM_EABI__"
;;
+ arm*-netbsd*-eabi*)
+ TARGET=ARM;
+ arch_target=arm;
+ ACCESS_UNALIGNED="no"
+ CPPFLAGS="$CPPFLAGS -D__ARM_EABI__"
+ ;;
# TODO: make proper support for NaCl host.
# arm*-*nacl)
# TARGET=ARM;
;;
esac
;;
+ arm*-netbsd*-eabi*)
+ TARGET=ARM;
+ arch_target=arm;
+ AC_DEFINE(TARGET_ARM, 1, [...])
+ ACCESS_UNALIGNED="no"
+ CPPFLAGS="$CPPFLAGS -D__ARM_EABI__"
+ # Can't use tls, since it depends on the runtime detection of tls offsets
+ # in mono-compiler.h
+ with_tls=pthread
+ target_mach=no
+ ;;
i686*-linux-*)
TARGET=X86;
arch_target=x86;
GTKX11="libgtk-x11-2.0.dylib"
;;
*-*-*netbsd*)
- LIBC="libc.so.12"
- INTL="libintl.so.0"
+ LIBC="libc.so"
+ INTL="libintl.so"
+ SQLITE="libsqlite.so"
+ SQLITE3="libsqlite3.so"
;;
*-*-kfreebsd*-gnu)
LIBC="libc.so.0.1"
-Subproject commit 2f66da8d34b30473dac23f02b1a843d0717b9f1a
+Subproject commit 5b907267935346d2fe110d226bf3a62abcbd0dc6
AC_MSG_CHECKING(for __sync_bool_compare_and_swap)
AC_TRY_COMPILE([],[
volatile unsigned int foo = 0;
-int main(int argc, char** argv) {
- unsigned int r1 = __sync_bool_compare_and_swap(&foo, 0, 1);
- return 0;
-}
+unsigned int r1 = __sync_bool_compare_and_swap(&foo, 0, 1);
+return 0;
], [
AC_MSG_RESULT(yes)
AC_DEFINE(HAS___SYNC_BOOL_COMPARE_AND_SWAP)
very helpfull to diagnose a miscompilation problems of a specific
method.
.TP
+\fBMONO_JIT_DUMP_METHOD\fR
+Enables sending of the JITs intermediate representation for a specified
+method to the IdealGraphVisualizer tool.
+.TP
\fBMONO_VERBOSE_HWCAP\fR
If set, makes the JIT output information about detected CPU features
(such as SSE, CMOV, FCMOV, etc) to stdout.
sourcefile = $(depsdir)/$(PROFILE)_$(LIBRARY).sources
library_CLEAN_FILES += $(sourcefile)
-ifdef EXTENSION_MODULE
-EXTENSION_include = $(wildcard $(topdir)/../../mono-extensions/mcs/$(thisdir)/$(PROFILE)_$(LIBRARY).sources)
-else
-EXTENSION_include = $(wildcard $(PROFILE)_opt_$(LIBRARY).sources)
-endif
-
-
-ifdef EXTENSION_MODULE
-EXTENSION_exclude = $(wildcard $(topdir)/../../mono-extensions/mcs/$(thisdir)/$(PROFILE)_$(LIBRARY).exclude.sources)
-else
-EXTENSION_exclude = $(wildcard $(PROFILE)_opt_$(LIBRARY).exclude.sources)
-endif
-
# Note, gensources.sh can create a $(sourcefile).makefrag if it sees any '#include's
# We don't include it in the dependencies since it isn't always created
-$(sourcefile): $(PROFILE_sources) $(PROFILE_excludes) $(topdir)/build/gensources.sh $(EXTENSION_include)
+$(sourcefile): $(PROFILE_sources) $(PROFILE_excludes) $(topdir)/build/gensources.sh
@echo Creating the per profile list $@ ...
- $(SHELL) $(topdir)/build/gensources.sh $@ '$(PROFILE_sources)' '$(PROFILE_excludes)' '$(EXTENSION_include)' '$(EXTENSION_exclude)'
+ $(SHELL) $(topdir)/build/gensources.sh $@ '$(PROFILE_sources)' '$(PROFILE_excludes)'
endif
PLATFORM_excludes := $(wildcard $(LIBRARY).$(PLATFORM)-excludes)
thisdir = class
-# Note that Mono.Security and System.Security aren't listed.
-# We may have to add those if 'mcs' starts using them.
-basic_SUBDIRS := corlib System System.XML System Mono.Security System.Core
+basic_SUBDIRS := corlib Mono.Security System System.XML System.Core
# resgen is corlib specific so we need to wait until corlib is build
# and build it just a step before first dll needs it
build_SUBDIRS := \
corlib \
+ Mono.Security \
System \
System.XML \
- System Mono.Security \
Mono.Posix \
System.Core \
Mono.Cecil \
mobile_common_dirs := \
corlib \
+ Mono.Security \
System \
System.Core \
System.XML \
- Mono.Security \
- System \
I18N \
System.ServiceModel.Internals \
SMDiagnostics \
monotouch_runtime_dirs := \
corlib \
+ Mono.Security \
System \
System.Core \
System.XML \
xammac_4_5_dirs := \
corlib \
+ Mono.Security \
System \
Mono.Posix \
System.Core \
System.XML \
- Mono.Security \
- System \
I18N \
System.ServiceModel.Internals \
SMDiagnostics \
net_4_x_dirs := \
corlib \
+ Mono.Security \
System \
System.XML \
Mono.CompilerServices.SymbolWriter \
Mono.Posix \
System.Core \
- Mono.Security \
System.Security \
System.Configuration \
$(resgen_dir) \
LIBRARY = Mono.CompilerServices.SymbolWriter.dll
LIB_REFS = System
-LIB_MCS_FLAGS = -lib:$(bare_libdir)
+LIB_MCS_FLAGS =
NO_TEST = yes
include ../../build/rules.make
LIBRARY = Mono.Security.dll
-LOCAL_MCS_FLAGS = -lib:$(the_libdir_base)bare
+LOCAL_MCS_FLAGS =
LIB_REFS = bare/System
LIB_MCS_FLAGS = -unsafe -nowarn:1030,3009
TEST_MCS_FLAGS = $(LIB_MCS_FLAGS) -nowarn:169,219,618,672
+CC_PROFILE := $(filter monotouch% xammac, $(PROFILE))
+ifdef CC_PROFILE
+
+BUILT_SOURCES = \
+ ../corlib/CommonCrypto/SHA224Managed.g.cs \
+ ../corlib/CommonCrypto/MD2Managed.g.cs \
+ ../corlib/CommonCrypto/MD4Managed.g.cs
+
+../corlib/CommonCrypto/%.g.cs:
+ $(MAKE) -C ../corlib/CommonCrypto
+
+endif
+
include ../../build/library.make
$(build_lib): $(the_libdir_base)bare/System.dll
ha = SHA1.Create ();
hash = GetHash (ha);
break;
+ case 32:
+ ha = SHA256.Create ();
+ hash = GetHash (ha);
+ break;
+ case 48:
+ ha = SHA384.Create ();
+ hash = GetHash (ha);
+ break;
+ case 64:
+ ha = SHA512.Create ();
+ hash = GetHash (ha);
+ break;
default:
reason = 5;
Close ();
case 20:
hashName = "SHA1";
break;
+ case 32:
+ hashName = "SHA256";
+ break;
+ case 48:
+ hashName = "SHA384";
+ break;
+ case 64:
+ hashName = "SHA512";
+ break;
}
HashAlgorithm ha = HashAlgorithm.Create (hashName);
if (!messageDigest.CompareValue (ha.ComputeHash (signature)))
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+#if !MONOTOUCH && !XAMMAC
+
using System;
namespace Mono.Security.Cryptography {
}
}
}
+
+#endif
\ No newline at end of file
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+#if !MONOTOUCH && !XAMMAC
+
using System;
namespace Mono.Security.Cryptography {
}
}
}
+
+#endif
\ No newline at end of file
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+#if !MONOTOUCH && !XAMMAC
+
using System.Security.Cryptography;
namespace Mono.Security.Cryptography {
}
}
+#endif
\ No newline at end of file
get { return supportsTrustAnchors; }
}
- static ICertificateValidator2 GetDefaultValidator (MonoTlsProvider provider, MonoTlsSettings settings)
- {
- return (ICertificateValidator2)NoReflectionHelper.GetDefaultCertificateValidator (provider, settings);
- }
-
/*
* Internal API, intended to be used by MonoTlsProvider implementations.
*/
- internal static ICertificateValidator2 GetValidator (MonoTlsProvider provider, MonoTlsSettings settings)
+ internal static ICertificateValidator2 GetDefaultValidator (MonoTlsSettings settings, MonoTlsProvider provider)
{
- return GetDefaultValidator (provider, settings);
+ return (ICertificateValidator2)NoReflectionHelper.GetDefaultCertificateValidator (provider, settings);
}
/*
* Use this overloaded version in user code.
*/
- public static ICertificateValidator GetValidator (MonoTlsSettings settings)
+ public static ICertificateValidator GetValidator (MonoTlsSettings settings, MonoTlsProvider provider = null)
{
- return GetDefaultValidator (null, settings);
+ return GetDefaultValidator (settings, provider);
}
}
}
#endregion
+#region Native Certificate Implementation
+
+ internal virtual bool HasNativeCertificates {
+ get { return false; }
+ }
+
+ internal virtual X509Certificate2Impl GetNativeCertificate (
+ byte[] data, string password, X509KeyStorageFlags flags)
+ {
+ throw new InvalidOperationException ();
+ }
+
+ internal virtual X509Certificate2Impl GetNativeCertificate (
+ X509Certificate certificate)
+ {
+ throw new InvalidOperationException ();
+ }
+
+#endregion
+
#region Certificate Validation
/*
#include mobile_Mono.Security.dll.sources
../corlib/CommonCrypto/CommonCrypto.cs
../corlib/CommonCrypto/RC4CommonCrypto.cs
-../corlib/CommonCrypto/MD2Managed.g.cs
-../corlib/CommonCrypto/MD4Managed.g.cs
-../corlib/CommonCrypto/SHA224Managed.g.cs
#include monotouch_Mono.Security.dll.sources
../corlib/CommonCrypto/CommonCrypto.cs
../corlib/CommonCrypto/RC4CommonCrypto.cs
-../corlib/CommonCrypto/MD2Managed.g.cs
-../corlib/CommonCrypto/MD4Managed.g.cs
-../corlib/CommonCrypto/SHA224Managed.g.cs
+++ /dev/null
-NAME=rabbitmq-dotnet-client
-NAME_VSN=${NAME}-${RABBIT_VSN}
-
-RELEASE_DIR=releases/${NAME}/v${RABBIT_VSN}
-
-STAGE_RELEASE_DIR=charlotte:/home/rabbitmq/stage-extras/releases/${NAME}
-LIVE_RELEASE_DIR=charlotte:/home/rabbitmq/live-extras/releases/${NAME}
-
-RSYNC_CMD=rsync -irvl --delete-after
-
-TMPXMLZIP=${NAME_VSN}-tmp-xmldoc.zip
-
-ifeq "$(RABBIT_VSN)" ""
-rabbit-vsn:
- @echo "RABBIT_VSN is not set"
- @false
-else
-rabbit-vsn:
-endif
-
-deploy-stage: rabbit-vsn ensure-deliverables
- ${RSYNC_CMD} --exclude=${TMPXMLZIP} releases/${NAME}/ ${STAGE_RELEASE_DIR}
-
-deploy-live: rabbit-vsn ensure-deliverables
- ${RSYNC_CMD} --exclude=${TMPXMLZIP} releases/${NAME}/ ${LIVE_RELEASE_DIR}
-
-ensure-deliverables: rabbit-vsn
- file ${RELEASE_DIR}/${NAME_VSN}.zip
- file ${RELEASE_DIR}/${NAME_VSN}-api-guide.pdf
- file ${RELEASE_DIR}/${NAME_VSN}-user-guide.pdf
- file ${RELEASE_DIR}/${NAME_VSN}-wcf-service-model.pdf
- file ${RELEASE_DIR}/${NAME_VSN}-net-2.0.zip
- file ${RELEASE_DIR}/${NAME_VSN}-net-2.0-htmldoc.zip
- file ${RELEASE_DIR}/${NAME_VSN}-net-2.0-htmldoc
- file ${RELEASE_DIR}/${NAME_VSN}-net-3.0-wcf.zip
- file ${RELEASE_DIR}/${NAME_VSN}-net-3.0-wcf-htmldoc.zip
- file ${RELEASE_DIR}/${NAME_VSN}-net-3.0-wcf-htmldoc
-
-ensure-prerequisites: rabbit-vsn
- dpkg -p htmldoc plotutils transfig graphviz > /dev/null
-
-ensure-release-dir: rabbit-vsn
- touch ${RELEASE_DIR}/
-
-ensure-docs: rabbit-vsn
- file ${RELEASE_DIR}/${NAME_VSN}-net-2.0-htmldoc.zip
- file ${RELEASE_DIR}/${TMPXMLZIP}
-
-doc: rabbit-vsn ensure-prerequisites ensure-release-dir ensure-docs
- rm -rf build/tmpdoc build/doc
- mkdir -p build/tmpdoc/html build/tmpdoc/xml
- unzip -j ${RELEASE_DIR}/${NAME_VSN}-net-2.0-htmldoc.zip -d build/tmpdoc/html
- unzip -j ${RELEASE_DIR}/${NAME_VSN}-tmp-xmldoc.zip -d build/tmpdoc/xml
- cd docs && ./api-guide.sh && \
- mv api-guide.pdf ../${RELEASE_DIR}/${NAME_VSN}-api-guide.pdf
- $(MAKE) -C docs
- mv build/doc/userguide/user-guide.pdf ${RELEASE_DIR}/${NAME_VSN}-user-guide.pdf
- cp docs/"RabbitMQ Service Model.pdf" \
- ${RELEASE_DIR}/${NAME_VSN}-wcf-service-model.pdf
- cd ${RELEASE_DIR} && \
- rm -rf ${NAME_VSN}-net-2.0-htmldoc && \
- unzip ${NAME_VSN}-net-2.0-htmldoc.zip && \
- rm -rf unzip ${NAME_VSN}-net-3.0-wcf-htmldoc && \
- unzip ${NAME_VSN}-net-3.0-wcf-htmldoc.zip
--- /dev/null
+//
+// CFContentStream.cs
+//
+// Authors:
+// Marek Safar <marek.safar@gmail.com>
+//
+// Copyright (C) 2013 Xamarin Inc (http://www.xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System.Threading;
+using System.Threading.Tasks;
+using System.IO;
+using System.Net;
+
+#if XAMCORE_4_0
+using CFNetwork;
+#elif XAMCORE_2_0
+using CoreServices;
+#else
+using MonoTouch.CoreServices;
+#endif
+
+namespace System.Net.Http
+{
+ class BufferData
+ {
+ public byte[] Buffer;
+ public int Length;
+ }
+
+ class CFContentStream : HttpContent
+ {
+ readonly CFHTTPStream http_stream;
+ BufferData data;
+ Mutex data_mutex;
+ AutoResetEvent data_event;
+ AutoResetEvent data_read_event;
+
+ // The requirements are:
+ // * We must read at least one byte from the stream every time
+ // we get a HasBytesAvailable event.
+ // * SerializeToStreamAsync is executed on a separate thread,
+ // so reads must somehow be synchronized with that thread.
+ //
+ // Current implementation:
+ // * We read data in ReadStreamData (on the same thread
+ // we got the HasBytesAvailable event, i.e. inside the
+ // HasBytesAvailable event handler).
+ // * Data is stored in a class-level buffer.
+ // * SerializeToStreamAsync blocks while waiting for
+ // data from ReadStreamData.
+ // * ReadStreamData will only read more data once SerializeToStreamAsync
+ // has consumed any existing data. This means we'll be
+ // blocking in the HasBytesAvailable event handler until
+ // any previously read data has been processed (this prevents
+ // any unbound memory growth).
+
+ public CFContentStream (CFHTTPStream stream)
+ {
+ this.http_stream = stream;
+ data = new BufferData () {
+ Buffer = new byte [4096],
+ };
+ data_event = new AutoResetEvent (false);
+ data_read_event = new AutoResetEvent (true);
+ data_mutex = new Mutex ();
+ }
+
+ public void ReadStreamData ()
+ {
+ data_read_event.WaitOne (); // make sure there's no pending data.
+
+ data_mutex.WaitOne ();
+ data.Length = (int) http_stream.Read (data.Buffer, 0, data.Buffer.Length);
+ data_mutex.ReleaseMutex ();
+
+ data_event.Set ();
+ }
+
+ public void Close ()
+ {
+ data_read_event.WaitOne (); // make sure there's no pending data
+
+ data_mutex.WaitOne ();
+ data = null;
+ data_mutex.ReleaseMutex ();
+
+ data_event.Set ();
+ }
+
+ protected internal override async Task SerializeToStreamAsync (Stream stream, TransportContext context)
+ {
+ while (data_event.WaitOne ()) {
+ data_mutex.WaitOne ();
+ if (data == null || data.Length <= 0) {
+ data_mutex.ReleaseMutex ();
+ data_read_event.Set ();
+ break;
+ }
+
+ await stream.WriteAsync (data.Buffer, 0, data.Length).ConfigureAwait (false);
+ data_mutex.ReleaseMutex ();
+
+ data_read_event.Set ();
+ }
+ }
+
+ protected internal override bool TryComputeLength (out long length)
+ {
+ length = 0;
+ return false;
+ }
+ }
+}
--- /dev/null
+//
+// CFNetworkHandler.cs
+//
+// Authors:
+// Marek Safar <marek.safar@gmail.com>
+//
+// Copyright (C) 2013 Xamarin Inc (http://www.xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System.Threading;
+using System.Net.Http.Headers;
+using System.Threading.Tasks;
+using System.IO;
+using System.Collections.Generic;
+using System.Net;
+
+#if XAMCORE_4_0
+using CFNetwork;
+using CoreFoundation;
+using CF=CoreFoundation;
+#elif XAMCORE_2_0
+using CoreServices;
+using CoreFoundation;
+using CF=CoreFoundation;
+#else
+using MonoTouch.CoreServices;
+using MonoTouch.CoreFoundation;
+using CF=MonoTouch.CoreFoundation;
+#endif
+
+namespace System.Net.Http
+{
+ public class CFNetworkHandler : HttpMessageHandler
+ {
+ class StreamBucket
+ {
+ public TaskCompletionSource<HttpResponseMessage> Response;
+ public HttpRequestMessage Request;
+ public CancellationTokenRegistration CancellationTokenRegistration;
+ public CFContentStream ContentStream;
+
+ public void Close ()
+ {
+ CancellationTokenRegistration.Dispose ();
+ ContentStream.Close ();
+ }
+ }
+
+ bool allowAutoRedirect;
+ bool sentRequest;
+ bool useSystemProxy;
+ CookieContainer cookies;
+
+ Dictionary<IntPtr, StreamBucket> streamBuckets;
+
+ public CFNetworkHandler ()
+ {
+ allowAutoRedirect = true;
+ streamBuckets = new Dictionary<IntPtr, StreamBucket> ();
+ }
+
+ void EnsureModifiability ()
+ {
+ if (sentRequest)
+ throw new InvalidOperationException (
+ "This instance has already started one or more requests. " +
+ "Properties can only be modified before sending the first request.");
+ }
+
+ public bool AllowAutoRedirect {
+ get {
+ return allowAutoRedirect;
+ }
+ set {
+ EnsureModifiability ();
+ allowAutoRedirect = value;
+ }
+ }
+
+ public CookieContainer CookieContainer {
+ get {
+ return cookies;
+ }
+ set {
+ EnsureModifiability ();
+ cookies = value;
+ }
+ }
+
+ public bool UseSystemProxy {
+ get {
+ return useSystemProxy;
+ }
+ set {
+ EnsureModifiability ();
+ useSystemProxy = value;
+ }
+ }
+
+ // TODO: Add more properties
+
+ protected override void Dispose (bool disposing)
+ {
+ // TODO: CloseStream remaining stream buckets if there are any
+
+ base.Dispose (disposing);
+ }
+
+ CFHTTPMessage CreateWebRequestAsync (HttpRequestMessage request)
+ {
+ var req = CFHTTPMessage.CreateRequest (request.RequestUri, request.Method.Method, request.Version);
+
+ // TODO:
+/*
+ if (wr.ProtocolVersion == HttpVersion.Version10) {
+ wr.KeepAlive = request.Headers.ConnectionKeepAlive;
+ } else {
+ wr.KeepAlive = request.Headers.ConnectionClose != true;
+ }
+
+ if (useDefaultCredentials) {
+ wr.UseDefaultCredentials = true;
+ } else {
+ wr.Credentials = credentials;
+ }
+
+ if (useProxy) {
+ wr.Proxy = proxy;
+ }
+*/
+ if (cookies != null) {
+ string cookieHeader = cookies.GetCookieHeader (request.RequestUri);
+ if (cookieHeader != "")
+ req.SetHeaderFieldValue ("Cookie", cookieHeader);
+ }
+
+ foreach (var header in request.Headers) {
+ foreach (var value in header.Value) {
+ req.SetHeaderFieldValue (header.Key, value);
+ }
+ }
+
+ if (request.Content != null) {
+ foreach (var header in request.Content.Headers) {
+ foreach (var value in header.Value) {
+ req.SetHeaderFieldValue (header.Key, value);
+ }
+ }
+ }
+
+ return req;
+ }
+
+ protected internal override async Task<HttpResponseMessage> SendAsync (HttpRequestMessage request, CancellationToken cancellationToken)
+ {
+ sentRequest = true;
+
+ CFHTTPStream stream;
+ using (var message = CreateWebRequestAsync (request))
+ {
+ if (request.Content != null) {
+ var data = await request.Content.ReadAsByteArrayAsync ().ConfigureAwait (false);
+ message.SetBody (data);
+ }
+
+ stream = CFHTTPStream.CreateForHTTPRequest (message);
+ }
+
+ if (useSystemProxy) {
+ var proxies = CF.CFNetwork.GetSystemProxySettings ();
+ if (proxies.HTTPEnable) {
+ stream.SetProxy (proxies);
+ }
+ }
+
+ stream.ShouldAutoredirect = allowAutoRedirect;
+ stream.HasBytesAvailableEvent += HandleHasBytesAvailableEvent;
+ stream.ErrorEvent += HandleErrorEvent;
+ stream.ClosedEvent += HandleClosedEvent;
+
+ var response = new TaskCompletionSource<HttpResponseMessage> ();
+
+ if (cancellationToken.IsCancellationRequested) {
+ response.SetCanceled ();
+ return await response.Task;
+ }
+
+ var bucket = new StreamBucket () {
+ Request = request,
+ Response = response,
+ };
+
+ streamBuckets.Add (stream.Handle, bucket);
+
+ //
+ // Always schedule stream events handling on main-loop. Due to ConfigureAwait (false) we may end up
+ // on any thread-pool thread which may not have run-loop running
+ //
+#if XAMCORE_2_0
+ stream.EnableEvents (CF.CFRunLoop.Main, CF.CFRunLoop.ModeCommon);
+#else
+ stream.EnableEvents (CF.CFRunLoop.Main, CF.CFRunLoop.CFRunLoopCommonModes);
+#endif
+
+ stream.Open ();
+
+ bucket.CancellationTokenRegistration = cancellationToken.Register (() => {
+ StreamBucket bucket2;
+ if (!streamBuckets.TryGetValue (stream.Handle, out bucket2))
+ return;
+
+ bucket2.Response.TrySetCanceled ();
+ CloseStream (stream);
+ });
+
+ return await response.Task;
+ }
+
+ void HandleErrorEvent (object sender, CFStream.StreamEventArgs e)
+ {
+ var stream = (CFHTTPStream)sender;
+
+ StreamBucket bucket;
+ if (!streamBuckets.TryGetValue (stream.Handle, out bucket))
+ return;
+
+ bucket.Response.TrySetException (stream.GetError ());
+ CloseStream (stream);
+ }
+
+ void HandleClosedEvent (object sender, CFStream.StreamEventArgs e)
+ {
+ var stream = (CFHTTPStream)sender;
+ CloseStream (stream);
+ }
+
+ void CloseStream (CFHTTPStream stream)
+ {
+ StreamBucket bucket;
+ if (streamBuckets.TryGetValue (stream.Handle, out bucket)) {
+ bucket.Close ();
+ streamBuckets.Remove (stream.Handle);
+ }
+
+ stream.Close ();
+ }
+
+ void HandleHasBytesAvailableEvent (object sender, CFStream.StreamEventArgs e)
+ {
+ var stream = (CFHTTPStream) sender;
+
+ StreamBucket bucket;
+ if (!streamBuckets.TryGetValue (stream.Handle, out bucket))
+ return;
+
+ if (bucket.Response.Task.IsCompleted) {
+ bucket.ContentStream.ReadStreamData ();
+ return;
+ }
+
+ var header = stream.GetResponseHeader ();
+
+ // Is this possible?
+ if (!header.IsHeaderComplete)
+ throw new NotImplementedException ();
+
+ bucket.ContentStream = new CFContentStream (stream);
+
+ var response_msg = new HttpResponseMessage (header.ResponseStatusCode);
+ response_msg.RequestMessage = bucket.Request;
+ response_msg.ReasonPhrase = header.ResponseStatusLine;
+ response_msg.Content = bucket.ContentStream;
+
+ var fields = header.GetAllHeaderFields ();
+ if (fields != null) {
+ foreach (var entry in fields) {
+ if (entry.Key == null)
+ continue;
+
+ var key = entry.Key.ToString ();
+ var value = entry.Value == null ? string.Empty : entry.Value.ToString ();
+ HttpHeaders item_headers;
+ if (HttpHeaders.GetKnownHeaderKind (key) == Headers.HttpHeaderKind.Content) {
+ item_headers = response_msg.Content.Headers;
+ } else {
+ item_headers = response_msg.Headers;
+
+ if (cookies != null && (key == "Set-Cookie" || key == "Set-Cookie2"))
+ AddCookie (value, bucket.Request.RequestUri, key);
+ }
+
+ item_headers.TryAddWithoutValidation (key, value);
+ }
+ }
+
+ bucket.Response.TrySetResult (response_msg);
+
+ bucket.ContentStream.ReadStreamData ();
+ }
+
+ void AddCookie (string value, Uri uri, string header)
+ {
+ CookieCollection cookies1 = null;
+ try {
+ cookies1 = cookies.CookieCutter (uri, header, value, false);
+ } catch {
+ }
+
+ if (cookies1 != null && cookies1.Count != 0)
+ cookies.Add (cookies1);
+ }
+ }
+}
--- /dev/null
+using System;
+using System.IO;
+using System.Net;
+#if XAMCORE_2_0
+using CoreFoundation;
+using Foundation;
+using ObjCRuntime;
+#elif MONOMAC
+using MonoMac.CoreFoundation;
+using MonoMac.Foundation;
+using MonoMac.ObjCRuntime;
+#else
+using MonoTouch.CoreFoundation;
+using MonoTouch.Foundation;
+using MonoTouch.ObjCRuntime;
+#endif
+
+#if SYSTEM_NET_HTTP && !MONOMAC
+namespace System.Net.Http {
+
+ public partial class HttpClient {
+
+ public HttpClient ()
+ : this (GetDefaultHandler (), true)
+ {
+ }
+
+ // note: the linker will re-write this to only reference the selected handler
+ // but we want this to work "as expected" even if the application is not being linked
+ static HttpMessageHandler GetDefaultHandler ()
+ {
+ return RuntimeOptions.GetHttpMessageHandler ();
+ }
+ }
+#else
+// due to historical reasons (around CFNetwork) Xamarin.Mac includes this inside it's profile assembly
+// and not a custom System.Net.Http assembly
+namespace Foundation {
+#endif
+
+ partial class NSUrlSessionHandler {
+
+ bool allowAutoRedirect;
+ ICredentials credentials;
+ bool sentRequest;
+
+ public bool AllowAutoRedirect {
+ get {
+ return allowAutoRedirect;
+ }
+ set {
+ EnsureModifiability ();
+ allowAutoRedirect = value;
+ }
+ }
+
+ public ICredentials Credentials {
+ get {
+ return credentials;
+ }
+ set {
+ EnsureModifiability ();
+ credentials = value;
+ }
+ }
+
+ internal void EnsureModifiability ()
+ {
+ if (sentRequest)
+ throw new InvalidOperationException (
+ "This instance has already started one or more requests. " +
+ "Properties can only be modified before sending the first request.");
+ }
+
+ // almost identical to ModernHttpClient version but it uses the constants from monotouch.dll | Xamarin.[iOS|WatchOS|TVOS].dll
+ static Exception createExceptionForNSError(NSError error)
+ {
+ var webExceptionStatus = WebExceptionStatus.UnknownError;
+
+ var innerException = new NSErrorException(error);
+
+ // errors that exists in both share the same error code, so we can use a single switch/case
+ // this also ease watchOS integration as if does not expose CFNetwork but (I would not be
+ // surprised if it)could return some of it's error codes
+#if MONOTOUCH_WATCH
+ if (error.Domain == NSError.NSUrlErrorDomain) {
+#else
+ if ((error.Domain == NSError.NSUrlErrorDomain) || (error.Domain == NSError.CFNetworkErrorDomain)) {
+#endif
+ // Parse the enum into a web exception status or exception. Some
+ // of these values don't necessarily translate completely to
+ // what WebExceptionStatus supports, so made some best guesses
+ // here. For your reading pleasure, compare these:
+ //
+ // Apple docs: https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Miscellaneous/Foundation_Constants/index.html#//apple_ref/doc/constant_group/URL_Loading_System_Error_Codes
+ // .NET docs: http://msdn.microsoft.com/en-us/library/system.net.webexceptionstatus(v=vs.110).aspx
+ switch ((NSUrlError) (long) error.Code) {
+ case NSUrlError.Cancelled:
+ case NSUrlError.UserCancelledAuthentication:
+#if !MONOTOUCH_WATCH
+ case (NSUrlError) NSNetServicesStatus.CancelledError:
+#endif
+ // No more processing is required so just return.
+ return new OperationCanceledException(error.LocalizedDescription, innerException);
+ case NSUrlError.BadURL:
+ case NSUrlError.UnsupportedURL:
+ case NSUrlError.CannotConnectToHost:
+ case NSUrlError.ResourceUnavailable:
+ case NSUrlError.NotConnectedToInternet:
+ case NSUrlError.UserAuthenticationRequired:
+ case NSUrlError.InternationalRoamingOff:
+ case NSUrlError.CallIsActive:
+ case NSUrlError.DataNotAllowed:
+#if !MONOTOUCH_WATCH
+ case (NSUrlError) CFNetworkErrors.Socks5BadCredentials:
+ case (NSUrlError) CFNetworkErrors.Socks5UnsupportedNegotiationMethod:
+ case (NSUrlError) CFNetworkErrors.Socks5NoAcceptableMethod:
+ case (NSUrlError) CFNetworkErrors.HttpAuthenticationTypeUnsupported:
+ case (NSUrlError) CFNetworkErrors.HttpBadCredentials:
+ case (NSUrlError) CFNetworkErrors.HttpBadURL:
+#endif
+ webExceptionStatus = WebExceptionStatus.ConnectFailure;
+ break;
+ case NSUrlError.TimedOut:
+#if !MONOTOUCH_WATCH
+ case (NSUrlError) CFNetworkErrors.NetServiceTimeout:
+#endif
+ webExceptionStatus = WebExceptionStatus.Timeout;
+ break;
+ case NSUrlError.CannotFindHost:
+ case NSUrlError.DNSLookupFailed:
+#if !MONOTOUCH_WATCH
+ case (NSUrlError) CFNetworkErrors.HostNotFound:
+ case (NSUrlError) CFNetworkErrors.NetServiceDnsServiceFailure:
+#endif
+ webExceptionStatus = WebExceptionStatus.NameResolutionFailure;
+ break;
+ case NSUrlError.DataLengthExceedsMaximum:
+ webExceptionStatus = WebExceptionStatus.MessageLengthLimitExceeded;
+ break;
+ case NSUrlError.NetworkConnectionLost:
+#if !MONOTOUCH_WATCH
+ case (NSUrlError) CFNetworkErrors.HttpConnectionLost:
+#endif
+ webExceptionStatus = WebExceptionStatus.ConnectionClosed;
+ break;
+ case NSUrlError.HTTPTooManyRedirects:
+ case NSUrlError.RedirectToNonExistentLocation:
+#if !MONOTOUCH_WATCH
+ case (NSUrlError) CFNetworkErrors.HttpRedirectionLoopDetected:
+#endif
+ webExceptionStatus = WebExceptionStatus.ProtocolError;
+ break;
+ case NSUrlError.RequestBodyStreamExhausted:
+#if !MONOTOUCH_WATCH
+ case (NSUrlError) CFNetworkErrors.SocksUnknownClientVersion:
+ case (NSUrlError) CFNetworkErrors.SocksUnsupportedServerVersion:
+ case (NSUrlError) CFNetworkErrors.HttpParseFailure:
+#endif
+ webExceptionStatus = WebExceptionStatus.SendFailure;
+ break;
+ case NSUrlError.BadServerResponse:
+ case NSUrlError.ZeroByteResource:
+ case NSUrlError.CannotDecodeRawData:
+ case NSUrlError.CannotDecodeContentData:
+ case NSUrlError.CannotParseResponse:
+ case NSUrlError.FileDoesNotExist:
+ case NSUrlError.FileIsDirectory:
+ case NSUrlError.NoPermissionsToReadFile:
+ case NSUrlError.CannotLoadFromNetwork:
+ case NSUrlError.CannotCreateFile:
+ case NSUrlError.CannotOpenFile:
+ case NSUrlError.CannotCloseFile:
+ case NSUrlError.CannotWriteToFile:
+ case NSUrlError.CannotRemoveFile:
+ case NSUrlError.CannotMoveFile:
+ case NSUrlError.DownloadDecodingFailedMidStream:
+ case NSUrlError.DownloadDecodingFailedToComplete:
+#if !MONOTOUCH_WATCH
+ case (NSUrlError) CFNetworkErrors.Socks4RequestFailed:
+ case (NSUrlError) CFNetworkErrors.Socks4IdentdFailed:
+ case (NSUrlError) CFNetworkErrors.Socks4IdConflict:
+ case (NSUrlError) CFNetworkErrors.Socks4UnknownStatusCode:
+ case (NSUrlError) CFNetworkErrors.Socks5BadState:
+ case (NSUrlError) CFNetworkErrors.Socks5BadResponseAddr:
+ case (NSUrlError) CFNetworkErrors.CannotParseCookieFile:
+ case (NSUrlError) CFNetworkErrors.NetServiceUnknown:
+ case (NSUrlError) CFNetworkErrors.NetServiceCollision:
+ case (NSUrlError) CFNetworkErrors.NetServiceNotFound:
+ case (NSUrlError) CFNetworkErrors.NetServiceInProgress:
+ case (NSUrlError) CFNetworkErrors.NetServiceBadArgument:
+ case (NSUrlError) CFNetworkErrors.NetServiceInvalid:
+#endif
+ webExceptionStatus = WebExceptionStatus.ReceiveFailure;
+ break;
+ case NSUrlError.SecureConnectionFailed:
+ webExceptionStatus = WebExceptionStatus.SecureChannelFailure;
+ break;
+ case NSUrlError.ServerCertificateHasBadDate:
+ case NSUrlError.ServerCertificateHasUnknownRoot:
+ case NSUrlError.ServerCertificateNotYetValid:
+ case NSUrlError.ServerCertificateUntrusted:
+ case NSUrlError.ClientCertificateRejected:
+ case NSUrlError.ClientCertificateRequired:
+ webExceptionStatus = WebExceptionStatus.TrustFailure;
+ break;
+#if !MONOTOUCH_WATCH
+ case (NSUrlError) CFNetworkErrors.HttpProxyConnectionFailure:
+ case (NSUrlError) CFNetworkErrors.HttpBadProxyCredentials:
+ case (NSUrlError) CFNetworkErrors.PacFileError:
+ case (NSUrlError) CFNetworkErrors.PacFileAuth:
+ case (NSUrlError) CFNetworkErrors.HttpsProxyConnectionFailure:
+ case (NSUrlError) CFNetworkErrors.HttpsProxyFailureUnexpectedResponseToConnectMethod:
+ webExceptionStatus = WebExceptionStatus.RequestProhibitedByProxy;
+ break;
+#endif
+ }
+ }
+
+ // Always create a WebException so that it can be handled by the client.
+ return new WebException(error.LocalizedDescription, innerException); //, webExceptionStatus, response: null);
+ }
+ }
+}
System.Runtime.Serialization/DataContractSerializerTest_InvalidCharacters.cs
System.Runtime.Serialization/DataContractSerializerTest_ISerializable.cs
System.Runtime.Serialization/DataContractSerializerTest.cs
+System.Runtime.Serialization/Exceptions.cs
System.Runtime.Serialization/KnownTypeAttributeTest.cs
System.Runtime.Serialization/XmlObjectSerializerTest.cs
System.Runtime.Serialization/XsdDataContractExporterTest.cs
--- /dev/null
+//
+// Exceptions
+//
+// Authors:
+// Andi McClure (andi.mcclure@xamarin.com)
+//
+// Copyright 2016 Xamarin Inc. (http://www.xamarin.com)
+//
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.IO;
+using System.Runtime.Serialization;
+using System.Runtime.Serialization.Formatters.Binary;
+using NUnit.Framework;
+
+namespace MonoTests.System.Runtime.Serialization
+{
+ [TestFixture]
+ public class Exceptions
+ {
+ [Serializable]
+ public class SerializableException : Exception
+ {
+ public string Data;
+
+ public SerializableException (string data) {
+ Data = data;
+
+ SerializeObjectState += HandleSerialization;
+ }
+
+ private static void HandleSerialization (object exception, SafeSerializationEventArgs eventArgs) {
+ eventArgs.AddSerializedState (new SerializableExceptionState (exception));
+ }
+
+ [Serializable]
+ private class SerializableExceptionState : ISafeSerializationData {
+ private string Data;
+
+ public SerializableExceptionState (object _exception) {
+ SerializableException exception = (SerializableException)_exception;
+
+ Data = exception.Data;
+ }
+
+ public void CompleteDeserialization (object _exception) {
+ SerializableException exception = (SerializableException)_exception;
+ exception.SerializeObjectState += HandleSerialization;
+
+ exception.Data = Data;
+ }
+ }
+ }
+
+ // Effectively tests SerializeObjectState handler support on System.Exception
+ [Test]
+ public void Exception_SerializeObjectState () {
+ SerializableException exception = new SerializableException ("success");
+ SerializableException deserializedException;
+ BinaryFormatter binaryFormatter = new BinaryFormatter ();
+
+ using (MemoryStream memoryStream = new MemoryStream ())
+ {
+ binaryFormatter.Serialize (memoryStream, exception);
+ memoryStream.Flush ();
+
+ memoryStream.Seek (0, SeekOrigin.Begin);
+
+ deserializedException = (SerializableException)binaryFormatter.Deserialize (memoryStream);
+ }
+
+ Assert.AreEqual ("success", deserializedException.Data);
+ }
+ }
+}
\ No newline at end of file
-d:SECURITY_DEP \
-nowarn:414
-LOCAL_MCS_FLAGS = -lib:$(secxml_libdir) -lib:$(bare_libdir)
+LOCAL_MCS_FLAGS =
TEST_MCS_FLAGS = $(LIB_MCS_FLAGS) -nowarn:168,169,183,219,414
ifneq (plainweb/,$(intermediate))
LIB_REFS += System.Web.Services plaindesign/System.Design
-LIB_MCS_FLAGS += -define:WEBSERVICES_DEP -lib:$(the_libdir_base)plaindesign
+LIB_MCS_FLAGS += -define:WEBSERVICES_DEP
all-local: System.Web/UplevelHelper.cs resources/TranslationResources.resources
ifdef MOBILE_PROFILE
LIB_MCS_FLAGS += -d:INSIDE_SYSTEM -d:SECURITY_DEP
else
-EXTERN_ALIAS_FLAGS = -d:MONO_SECURITY_ALIAS -d:MONO_X509_ALIAS
+EXTERN_ALIAS_FLAGS = -d:MONO_SECURITY_ALIAS
endif
#
# Flags used to build the secxml version of System.
#
ifeq (secxml/, $(intermediate))
-LOCAL_MCS_FLAGS = -lib:$(bare_libdir)
+LOCAL_MCS_FLAGS =
LIB_REFS += bare/System.Xml MonoSecurity=Mono.Security
-LIB_MCS_FLAGS += -d:SECURITY_DEP -d:XML_DEP -r:PrebuiltSystem=$(bare_libdir)/System.dll $(EXTERN_ALIAS_FLAGS)
+LIB_MCS_FLAGS += -d:SECURITY_DEP -d:XML_DEP $(EXTERN_ALIAS_FLAGS)
endif
#
#
ifndef intermediate
LIB_REFS += System.Xml MonoSecurity=Mono.Security
-LIB_MCS_FLAGS += -d:SECURITY_DEP -d:XML_DEP -r:PrebuiltSystem=$(secxml_libdir)/System.dll $(EXTERN_ALIAS_FLAGS)
+LIB_MCS_FLAGS += -d:SECURITY_DEP -d:XML_DEP $(EXTERN_ALIAS_FLAGS)
ifndef MOBILE_PROFILE
LIB_REFS += System.Configuration
#if SECURITY_DEP
-#if MONO_X509_ALIAS
-extern alias PrebuiltSystem;
-#endif
#if MONO_SECURITY_ALIAS
extern alias MonoSecurity;
#endif
#else
using MSI = Mono.Security.Interface;
#endif
-#if MONO_X509_ALIAS
-using XX509CertificateCollection = PrebuiltSystem::System.Security.Cryptography.X509Certificates.X509CertificateCollection;
-using XX509Chain = PrebuiltSystem::System.Security.Cryptography.X509Certificates.X509Chain;
-#else
-using XX509CertificateCollection = System.Security.Cryptography.X509Certificates.X509CertificateCollection;
-using XX509Chain = System.Security.Cryptography.X509Certificates.X509Chain;
-#endif
using System;
using System.IO;
if (callback == null)
return null;
- return (h, c, ch, e) => callback (h, c, (X509Chain)(object)ch, (SslPolicyErrors)e);
+ return (h, c, ch, e) => callback (h, c, ch, (SslPolicyErrors)e);
}
internal static MSI.MonoLocalCertificateSelectionCallback PublicToMono (LocalCertificateSelectionCallback callback)
if (callback == null)
return null;
- return (t, lc, rc, ai) => callback (null, t, (XX509CertificateCollection)(object)lc, rc, ai);
+ return (t, lc, rc, ai) => callback (null, t, lc, rc, ai);
}
internal static MSI.MonoRemoteCertificateValidationCallback InternalToMono (RemoteCertValidationCallback callback)
if (callback == null)
return null;
- return (h, c, ch, e) => callback (h, c, (X509Chain)(object)ch, (SslPolicyErrors)e);
+ return (h, c, ch, e) => callback (h, c, ch, (SslPolicyErrors)e);
}
internal static RemoteCertificateValidationCallback InternalToPublic (string hostname, RemoteCertValidationCallback callback)
if (callback == null)
return null;
- return (t, lc, rc, ai) => callback (t, (XX509CertificateCollection)(object)lc, rc, ai);
+ return (t, lc, rc, ai) => callback (t, lc, rc, ai);
}
internal static RemoteCertificateValidationCallback MonoToPublic (MSI.MonoRemoteCertificateValidationCallback callback)
if (callback == null)
return null;
- return (t, c, ch, e) => callback (null, c, (XX509Chain)(object)ch, (MSI.MonoSslPolicyErrors)e);
+ return (t, c, ch, e) => callback (null, c, ch, (MSI.MonoSslPolicyErrors)e);
}
internal static LocalCertificateSelectionCallback MonoToPublic (MSI.MonoLocalCertificateSelectionCallback callback)
if (callback == null)
return null;
- return (s, t, lc, rc, ai) => callback (t, (XX509CertificateCollection)(object)lc, rc, ai);
+ return (s, t, lc, rc, ai) => callback (t, lc, rc, ai);
}
internal static RemoteCertValidationCallback MonoToInternal (MSI.MonoRemoteCertificateValidationCallback callback)
if (callback == null)
return null;
- return (h, c, ch, e) => callback (h, c, (XX509Chain)(object)ch, (MSI.MonoSslPolicyErrors)e);
+ return (h, c, ch, e) => callback (h, c, ch, (MSI.MonoSslPolicyErrors)e);
}
internal static LocalCertSelectionCallback MonoToInternal (MSI.MonoLocalCertificateSelectionCallback callback)
if (callback == null)
return null;
- return (t, lc, rc, ai) => callback (t, (XX509CertificateCollection)(object)lc, rc, ai);
+ return (t, lc, rc, ai) => callback (t, lc, rc, ai);
}
}
#if MONO_SECURITY_ALIAS
extern alias MonoSecurity;
#endif
-#if MONO_X509_ALIAS
-extern alias PrebuiltSystem;
-#endif
#if MONO_SECURITY_ALIAS
using MonoSecurity::Mono.Security.Interface;
using MSX = Mono.Security.X509;
using Mono.Security.X509.Extensions;
#endif
-#if MONO_X509_ALIAS
-using XX509CertificateCollection = PrebuiltSystem::System.Security.Cryptography.X509Certificates.X509CertificateCollection;
-using XX509Chain = PrebuiltSystem::System.Security.Cryptography.X509Certificates.X509Chain;
-#else
using XX509CertificateCollection = System.Security.Cryptography.X509Certificates.X509CertificateCollection;
using XX509Chain = System.Security.Cryptography.X509Certificates.X509Chain;
-#endif
using System;
using System.Net;
public ValidationResult ValidateCertificate (string host, bool serverMode, X509Certificate leaf, XX509Chain xchain)
{
try {
- var chain = (X509Chain)(object)xchain;
+ var chain = xchain;
var result = ValidateChain (host, serverMode, leaf, chain, null, 0);
if (tlsStream != null)
tlsStream.CertificateValidationFailed = result == null || !result.Trusted || result.UserDenied;
bool providerValidated = false;
if (provider != null && provider.HasCustomSystemCertificateValidator) {
var xerrors = (MonoSslPolicyErrors)errors;
- var xchain = (XX509Chain)(object)chain;
+ var xchain = chain;
providerValidated = provider.InvokeSystemCertificateValidator (this, host, server, certs, wantsChain, ref xchain, out result, ref xerrors, ref status11);
- chain = (X509Chain)(object)xchain;
+ chain = xchain;
errors = (SslPolicyErrors)xerrors;
} else if (wantsChain) {
chain = SystemCertificateValidator.CreateX509Chain (certs);
public bool InvokeSystemValidator (string targetHost, bool serverMode, XX509CertificateCollection certificates, XX509Chain xchain, ref MonoSslPolicyErrors xerrors, ref int status11)
{
- X509Chain chain = (X509Chain)(object)xchain;
+ X509Chain chain = xchain;
var errors = (SslPolicyErrors)xerrors;
var result = SystemCertificateValidator.Evaluate (settings, targetHost, certificates, chain, ref errors, ref status11);
xerrors = (MonoSslPolicyErrors)errors;
// THE SOFTWARE.
#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
#if MONO_SECURITY_ALIAS
extern alias MonoSecurity;
#endif
-#if MONO_X509_ALIAS
-extern alias PrebuiltSystem;
-#endif
#if MONO_SECURITY_ALIAS
using MonoSecurity::Mono.Security.Interface;
#else
using Mono.Security.Interface;
#endif
-#if MONO_X509_ALIAS
-using XX509CertificateCollection = PrebuiltSystem::System.Security.Cryptography.X509Certificates.X509CertificateCollection;
-#else
using XX509CertificateCollection = System.Security.Cryptography.X509Certificates.X509CertificateCollection;
#endif
-#endif
using System;
using System.IO;
#if SECURITY_DEP
-#if MONO_X509_ALIAS
-extern alias PrebuiltSystem;
-#endif
#if MONO_SECURITY_ALIAS
extern alias MonoSecurity;
#endif
using Mono.Security.Protocol.Tls;
using Mono.Security.Interface;
#endif
-#if MONO_X509_ALIAS
-using X509CertificateCollection = PrebuiltSystem::System.Security.Cryptography.X509Certificates.X509CertificateCollection;
-#endif
using CipherAlgorithmType = System.Security.Authentication.CipherAlgorithmType;
using HashAlgorithmType = System.Security.Authentication.HashAlgorithmType;
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#if SECURITY_DEP
-#if MONO_X509_ALIAS
-extern alias PrebuiltSystem;
-#endif
#if MONO_SECURITY_ALIAS
extern alias MonoSecurity;
#endif
-#if MONO_X509_ALIAS
-using XHttpWebRequest = PrebuiltSystem::System.Net.HttpWebRequest;
-using XSslProtocols = PrebuiltSystem::System.Security.Authentication.SslProtocols;
-using XX509CertificateCollection = PrebuiltSystem::System.Security.Cryptography.X509Certificates.X509CertificateCollection;
-#else
using XHttpWebRequest = System.Net.HttpWebRequest;
using XSslProtocols = System.Security.Authentication.SslProtocols;
using XX509CertificateCollection = System.Security.Cryptography.X509Certificates.X509CertificateCollection;
-#endif
#if MONO_SECURITY_ALIAS
using MonoSecurity::Mono.Security.Interface;
#if SECURITY_DEP
-#if MONO_X509_ALIAS
-extern alias PrebuiltSystem;
-#endif
#if MONO_SECURITY_ALIAS
extern alias MonoSecurity;
#endif
#else
using MSI = Mono.Security.Interface;
#endif
-#if MONO_X509_ALIAS
-using XX509CertificateCollection = PrebuiltSystem::System.Security.Cryptography.X509Certificates.X509CertificateCollection;
-
-using XTransportContext = PrebuiltSystem::System.Net.TransportContext;
-using XAuthenticatedStream = PrebuiltSystem::System.Net.Security.AuthenticatedStream;
-
-using XCipherAlgorithmType = PrebuiltSystem::System.Security.Authentication.CipherAlgorithmType;
-using XHashAlgorithmType = PrebuiltSystem::System.Security.Authentication.HashAlgorithmType;
-using XExchangeAlgorithmType = PrebuiltSystem::System.Security.Authentication.ExchangeAlgorithmType;
-using XSslProtocols = PrebuiltSystem::System.Security.Authentication.SslProtocols;
-#else
-using XX509CertificateCollection = System.Security.Cryptography.X509Certificates.X509CertificateCollection;
-
-using XTransportContext = System.Net.TransportContext;
-using XAuthenticatedStream = System.Net.Security.AuthenticatedStream;
-
-using XCipherAlgorithmType = System.Security.Authentication.CipherAlgorithmType;
-using XHashAlgorithmType = System.Security.Authentication.HashAlgorithmType;
-using XExchangeAlgorithmType = System.Security.Authentication.ExchangeAlgorithmType;
-using XSslProtocols = System.Security.Authentication.SslProtocols;
-#endif
using System;
using System.IO;
Impl.AuthenticateAsClient (targetHost);
}
- public void AuthenticateAsClient (string targetHost, XX509CertificateCollection clientCertificates, XSslProtocols enabledSslProtocols, bool checkCertificateRevocation)
+ public void AuthenticateAsClient (string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
{
- Impl.AuthenticateAsClient (targetHost, clientCertificates, (SslProtocols)enabledSslProtocols, checkCertificateRevocation);
+ Impl.AuthenticateAsClient (targetHost, clientCertificates, enabledSslProtocols, checkCertificateRevocation);
}
public IAsyncResult BeginAuthenticateAsClient (string targetHost, AsyncCallback asyncCallback, object asyncState)
return Impl.BeginAuthenticateAsClient (targetHost, asyncCallback, asyncState);
}
- public IAsyncResult BeginAuthenticateAsClient (string targetHost, XX509CertificateCollection clientCertificates, XSslProtocols enabledSslProtocols, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState)
+ public IAsyncResult BeginAuthenticateAsClient (string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState)
{
- return Impl.BeginAuthenticateAsClient (targetHost, clientCertificates, (SslProtocols)enabledSslProtocols, checkCertificateRevocation, asyncCallback, asyncState);
+ return Impl.BeginAuthenticateAsClient (targetHost, clientCertificates, enabledSslProtocols, checkCertificateRevocation, asyncCallback, asyncState);
}
public void EndAuthenticateAsClient (IAsyncResult asyncResult)
Impl.AuthenticateAsServer (serverCertificate);
}
- public void AuthenticateAsServer (X509Certificate serverCertificate, bool clientCertificateRequired, XSslProtocols enabledSslProtocols, bool checkCertificateRevocation)
+ public void AuthenticateAsServer (X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
{
- Impl.AuthenticateAsServer (serverCertificate, clientCertificateRequired, (SslProtocols)enabledSslProtocols, checkCertificateRevocation);
+ Impl.AuthenticateAsServer (serverCertificate, clientCertificateRequired, enabledSslProtocols, checkCertificateRevocation);
}
public IAsyncResult BeginAuthenticateAsServer (X509Certificate serverCertificate, AsyncCallback asyncCallback, object asyncState)
return Impl.BeginAuthenticateAsServer (serverCertificate, asyncCallback, asyncState);
}
- public IAsyncResult BeginAuthenticateAsServer (X509Certificate serverCertificate, bool clientCertificateRequired, XSslProtocols enabledSslProtocols, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState)
+ public IAsyncResult BeginAuthenticateAsServer (X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState)
{
- return Impl.BeginAuthenticateAsServer (serverCertificate, clientCertificateRequired, (SslProtocols)enabledSslProtocols, checkCertificateRevocation, asyncCallback, asyncState);
+ return Impl.BeginAuthenticateAsServer (serverCertificate, clientCertificateRequired, enabledSslProtocols, checkCertificateRevocation, asyncCallback, asyncState);
}
public void EndAuthenticateAsServer (IAsyncResult asyncResult)
return Impl.AuthenticateAsClientAsync (targetHost);
}
- public Task AuthenticateAsClientAsync (string targetHost, XX509CertificateCollection clientCertificates, XSslProtocols enabledSslProtocols, bool checkCertificateRevocation)
+ public Task AuthenticateAsClientAsync (string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
{
- return Impl.AuthenticateAsClientAsync (targetHost, clientCertificates, (SslProtocols)enabledSslProtocols, checkCertificateRevocation);
+ return Impl.AuthenticateAsClientAsync (targetHost, clientCertificates, enabledSslProtocols, checkCertificateRevocation);
}
public Task AuthenticateAsServerAsync (X509Certificate serverCertificate)
return Impl.AuthenticateAsServerAsync (serverCertificate);
}
- public Task AuthenticateAsServerAsync (X509Certificate serverCertificate, bool clientCertificateRequired, XSslProtocols enabledSslProtocols, bool checkCertificateRevocation)
+ public Task AuthenticateAsServerAsync (X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
{
- return Impl.AuthenticateAsServerAsync (serverCertificate, clientCertificateRequired, (SslProtocols)enabledSslProtocols, checkCertificateRevocation);
+ return Impl.AuthenticateAsServerAsync (serverCertificate, clientCertificateRequired, enabledSslProtocols, checkCertificateRevocation);
}
public void Flush ()
Impl.EndWrite (asyncResult);
}
- public XTransportContext TransportContext {
- get { return (XTransportContext)(object)Impl.TransportContext; }
+ public TransportContext TransportContext {
+ get { return Impl.TransportContext; }
}
public bool IsAuthenticated {
get { return Impl.IsServer; }
}
- public XCipherAlgorithmType CipherAlgorithm {
- get { return (XCipherAlgorithmType)Impl.CipherAlgorithm; }
+ public CipherAlgorithmType CipherAlgorithm {
+ get { return Impl.CipherAlgorithm; }
}
public int CipherStrength {
get { return Impl.CipherStrength; }
}
- public XHashAlgorithmType HashAlgorithm {
- get { return (XHashAlgorithmType)Impl.HashAlgorithm; }
+ public HashAlgorithmType HashAlgorithm {
+ get { return Impl.HashAlgorithm; }
}
public int HashStrength {
get { return Impl.HashStrength; }
}
- public XExchangeAlgorithmType KeyExchangeAlgorithm {
- get { return (XExchangeAlgorithmType)Impl.KeyExchangeAlgorithm; }
+ public ExchangeAlgorithmType KeyExchangeAlgorithm {
+ get { return Impl.KeyExchangeAlgorithm; }
}
public int KeyExchangeStrength {
Impl.SetLength (value);
}
- public XAuthenticatedStream AuthenticatedStream {
- get { return (XAuthenticatedStream)(Stream)Impl.AuthenticatedStream; }
+ public AuthenticatedStream AuthenticatedStream {
+ get { return Impl.AuthenticatedStream; }
}
public int ReadTimeout {
get { return Impl.RemoteCertificate; }
}
- public XSslProtocols SslProtocol {
- get { return (XSslProtocols)Impl.SslProtocol; }
+ public SslProtocols SslProtocol {
+ get { return Impl.SslProtocol; }
}
public MSI.MonoTlsProvider Provider {
#if SECURITY_DEP
-#if MONO_X509_ALIAS
-extern alias PrebuiltSystem;
-#endif
#if MONO_SECURITY_ALIAS
extern alias MonoSecurity;
#endif
#else
using MSI = Mono.Security.Interface;
#endif
-#if MONO_X509_ALIAS
-using XSslProtocols = PrebuiltSystem::System.Security.Authentication.SslProtocols;
-using XX509CertificateCollection = PrebuiltSystem::System.Security.Cryptography.X509Certificates.X509CertificateCollection;
-#else
-using XSslProtocols = System.Security.Authentication.SslProtocols;
-using XX509CertificateCollection = System.Security.Cryptography.X509Certificates.X509CertificateCollection;
-#endif
-
-using CipherAlgorithmType = System.Security.Authentication.CipherAlgorithmType;
-using HashAlgorithmType = System.Security.Authentication.HashAlgorithmType;
-using ExchangeAlgorithmType = System.Security.Authentication.ExchangeAlgorithmType;
using System;
using System.IO;
Impl.AuthenticateAsClient (targetHost);
}
- public void AuthenticateAsClient (string targetHost, XX509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
+ public void AuthenticateAsClient (string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
{
- Impl.AuthenticateAsClient (targetHost, (XX509CertificateCollection)(object)clientCertificates, (XSslProtocols)enabledSslProtocols, checkCertificateRevocation);
+ Impl.AuthenticateAsClient (targetHost, clientCertificates, enabledSslProtocols, checkCertificateRevocation);
}
public IAsyncResult BeginAuthenticateAsClient (string targetHost, AsyncCallback asyncCallback, object asyncState)
return Impl.BeginAuthenticateAsClient (targetHost, asyncCallback, asyncState);
}
- public IAsyncResult BeginAuthenticateAsClient (string targetHost, XX509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState)
+ public IAsyncResult BeginAuthenticateAsClient (string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState)
{
- return Impl.BeginAuthenticateAsClient (targetHost, (XX509CertificateCollection)(object)clientCertificates, (XSslProtocols)enabledSslProtocols, checkCertificateRevocation, asyncCallback, asyncState);
+ return Impl.BeginAuthenticateAsClient (targetHost, clientCertificates, enabledSslProtocols, checkCertificateRevocation, asyncCallback, asyncState);
}
public void EndAuthenticateAsClient (IAsyncResult asyncResult)
public void AuthenticateAsServer (X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
{
- Impl.AuthenticateAsServer (serverCertificate, clientCertificateRequired, (XSslProtocols)enabledSslProtocols, checkCertificateRevocation);
+ Impl.AuthenticateAsServer (serverCertificate, clientCertificateRequired, enabledSslProtocols, checkCertificateRevocation);
}
public IAsyncResult BeginAuthenticateAsServer (X509Certificate serverCertificate, AsyncCallback asyncCallback, object asyncState)
public IAsyncResult BeginAuthenticateAsServer (X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState)
{
- return Impl.BeginAuthenticateAsServer (serverCertificate, clientCertificateRequired, (XSslProtocols)enabledSslProtocols, checkCertificateRevocation, asyncCallback, asyncState);
+ return Impl.BeginAuthenticateAsServer (serverCertificate, clientCertificateRequired, enabledSslProtocols, checkCertificateRevocation, asyncCallback, asyncState);
}
public void EndAuthenticateAsServer (IAsyncResult asyncResult)
return Impl.AuthenticateAsClientAsync (targetHost);
}
- public Task AuthenticateAsClientAsync (string targetHost, XX509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
+ public Task AuthenticateAsClientAsync (string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
{
- return Impl.AuthenticateAsClientAsync (targetHost, clientCertificates, (XSslProtocols)enabledSslProtocols, checkCertificateRevocation);
+ return Impl.AuthenticateAsClientAsync (targetHost, clientCertificates, enabledSslProtocols, checkCertificateRevocation);
}
public Task AuthenticateAsServerAsync (X509Certificate serverCertificate)
public Task AuthenticateAsServerAsync (X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
{
- return Impl.AuthenticateAsServerAsync (serverCertificate, clientCertificateRequired, (XSslProtocols)enabledSslProtocols, checkCertificateRevocation);
+ return Impl.AuthenticateAsServerAsync (serverCertificate, clientCertificateRequired, enabledSslProtocols, checkCertificateRevocation);
}
public void Flush ()
}
public TransportContext TransportContext {
- get { return (TransportContext)(object)Impl.TransportContext; }
+ get { return Impl.TransportContext; }
}
public bool IsAuthenticated {
}
public AuthenticatedStream AuthenticatedStream {
- get { return (AuthenticatedStream)(object)Impl.AuthenticatedStream; }
+ get { return Impl.AuthenticatedStream; }
}
public int ReadTimeout {
return currentProvider;
try {
- defaultProvider = CreateDefaultProvider ();
+ defaultProvider = GetDefaultProviderInternal ();
} catch (Exception ex) {
throw new NotSupportedException ("TLS Support not available.", ex);
}
providerRegistration = new Dictionary<string,string> ();
providerRegistration.Add ("newtls", "Mono.Security.Providers.NewTls.NewTlsProvider, Mono.Security.Providers.NewTls, Version=4.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756");
providerRegistration.Add ("oldtls", "Mono.Security.Providers.OldTls.OldTlsProvider, Mono.Security.Providers.OldTls, Version=4.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756");
+ providerRegistration.Add ("boringtls", "Xamarin.BoringTls.BoringTlsProvider, Xamarin.BoringTls, Version=4.0.0.0, Culture=neutral, PublicKeyToken=672c06b0b8f05406");
+ X509Helper2.Initialize ();
}
}
#if SECURITY_DEP
-#if MONO_X509_ALIAS
-extern alias PrebuiltSystem;
-#endif
#if MONO_SECURITY_ALIAS
extern alias MonoSecurity;
#endif
#else
using MSI = Mono.Security.Interface;
#endif
-#if MONO_X509_ALIAS
-using XHttpWebRequest = PrebuiltSystem::System.Net.HttpWebRequest;
-using XX509CertificateCollection = PrebuiltSystem::System.Security.Cryptography.X509Certificates.X509CertificateCollection;
-#else
-using XHttpWebRequest = System.Net.HttpWebRequest;
-using XX509CertificateCollection = System.Security.Cryptography.X509Certificates.X509CertificateCollection;
-#endif
using System;
using System.IO;
MSI.IMonoTlsContext IMonoTlsProvider.CreateTlsContext (
string hostname, bool serverMode, MSI.TlsProtocols protocolFlags,
- X509Certificate serverCertificate, XX509CertificateCollection clientCertificates,
+ X509Certificate serverCertificate, X509CertificateCollection clientCertificates,
bool remoteCertRequired, bool checkCertName, bool checkCertRevocationStatus,
MSI.MonoEncryptionPolicy encryptionPolicy, MSI.MonoTlsSettings settings)
{
return CreateTlsContextImpl (
hostname, serverMode, protocolFlags,
- serverCertificate, (X509CertificateCollection)(object)clientCertificates,
+ serverCertificate, clientCertificates,
remoteCertRequired, encryptionPolicy, settings);
}
internal override MSI.IMonoTlsContext CreateTlsContext (
string hostname, bool serverMode, MSI.TlsProtocols protocolFlags,
- X509Certificate serverCertificate, XX509CertificateCollection clientCertificates,
+ X509Certificate serverCertificate, X509CertificateCollection clientCertificates,
bool remoteCertRequired, MSI.MonoEncryptionPolicy encryptionPolicy,
MSI.MonoTlsSettings settings)
{
return CreateTlsContextImpl (
hostname, serverMode, (MSI.TlsProtocols)protocolFlags,
- serverCertificate, (X509CertificateCollection)(object)clientCertificates,
+ serverCertificate, clientCertificates,
remoteCertRequired, (MSI.MonoEncryptionPolicy)encryptionPolicy,
settings);
}
#if SECURITY_DEP
-#if MONO_X509_ALIAS
-extern alias PrebuiltSystem;
-#endif
#if MONO_SECURITY_ALIAS
extern alias MonoSecurity;
#endif
#else
using MSI = Mono.Security.Interface;
#endif
-#if MONO_X509_ALIAS
-using XHttpWebRequest = PrebuiltSystem::System.Net.HttpWebRequest;
-using XX509CertificateCollection = PrebuiltSystem::System.Security.Cryptography.X509Certificates.X509CertificateCollection;
-#else
-using XHttpWebRequest = System.Net.HttpWebRequest;
-using XX509CertificateCollection = System.Security.Cryptography.X509Certificates.X509CertificateCollection;
-#endif
using System;
using System.IO;
public MSI.IMonoTlsContext CreateTlsContext (
string hostname, bool serverMode, MSI.TlsProtocols protocolFlags,
- X509Certificate serverCertificate, XX509CertificateCollection clientCertificates,
+ X509Certificate serverCertificate, X509CertificateCollection clientCertificates,
bool remoteCertRequired, bool checkCertName, bool checkCertRevocationStatus,
MSI.MonoEncryptionPolicy encryptionPolicy, MSI.MonoTlsSettings settings)
{
return provider.CreateTlsContext (
hostname, serverMode, protocolFlags,
- serverCertificate, (XX509CertificateCollection)(object)clientCertificates,
+ serverCertificate, clientCertificates,
remoteCertRequired, (MSI.MonoEncryptionPolicy)encryptionPolicy,
settings);
}
#if MONO_SECURITY_ALIAS
extern alias MonoSecurity;
#endif
-#if MONO_X509_ALIAS
-extern alias PrebuiltSystem;
-#endif
#if MONO_SECURITY_ALIAS
using MonoSecurity::Mono.Security.Interface;
#else
using Mono.Security.Interface;
#endif
-#if MONO_X509_ALIAS
-using XX509CertificateCollection = PrebuiltSystem::System.Security.Cryptography.X509Certificates.X509CertificateCollection;
-#else
using XX509CertificateCollection = System.Security.Cryptography.X509Certificates.X509CertificateCollection;
#endif
-#endif
using System;
using System.IO;
try {
sslStream.AuthenticateAsClient (
- request.Address.Host, (XX509CertificateCollection)(object)request.ClientCertificates,
+ request.Address.Host, request.ClientCertificates,
(SslProtocols)ServicePointManager.SecurityProtocol,
ServicePointManager.CheckCertificateRevocationList);
#if MONO_SECURITY_ALIAS
extern alias MonoSecurity;
#endif
-#if MONO_X509_ALIAS
-extern alias PrebuiltSystem;
-#endif
#if MONO_SECURITY_ALIAS
using MonoSecurity::Mono.Security.Interface;
using MSX = Mono.Security.X509;
using Mono.Security.X509.Extensions;
#endif
-#if MONO_X509_ALIAS
-using XX509CertificateCollection = PrebuiltSystem::System.Security.Cryptography.X509Certificates.X509CertificateCollection;
-using XX509Chain = PrebuiltSystem::System.Security.Cryptography.X509Certificates.X509Chain;
-#else
using XX509CertificateCollection = System.Security.Cryptography.X509Certificates.X509CertificateCollection;
using XX509Chain = System.Security.Cryptography.X509Certificates.X509Chain;
-#endif
using System;
using System.Net;
#if MONO_SECURITY_ALIAS
extern alias MonoSecurity;
#endif
-#if MONO_X509_ALIAS
-extern alias PrebuiltSystem;
-#endif
#if MONO_SECURITY_ALIAS
using MX = MonoSecurity::Mono.Security.X509;
using MX = Mono.Security.X509;
using Mono.Security.Interface;
#endif
-#if MONO_X509_ALIAS
-using XX509CertificateCollection = PrebuiltSystem::System.Security.Cryptography.X509Certificates.X509CertificateCollection;
-#else
-using XX509CertificateCollection = System.Security.Cryptography.X509Certificates.X509CertificateCollection;
-#endif
using System.Runtime.InteropServices;
using System.Security.Authentication.ExtendedProtection;
internal static class GlobalSSPI
{
- internal static SSPIInterface Create (string hostname, bool serverMode, SchProtocols protocolFlags, X509Certificate serverCertificate, XX509CertificateCollection clientCertificates,
+ internal static SSPIInterface Create (string hostname, bool serverMode, SchProtocols protocolFlags, X509Certificate serverCertificate, X509CertificateCollection clientCertificates,
bool remoteCertRequired, bool checkCertName, bool checkCertRevocationStatus, EncryptionPolicy encryptionPolicy,
LocalCertSelectionCallback certSelectionDelegate, RemoteCertValidationCallback remoteValidationCallback, SSPIConfiguration userConfig)
{
internal static X509Certificate2 GetRemoteCertificate (SafeDeleteContext safeContext, out X509Certificate2Collection remoteCertificateStore)
{
- XX509CertificateCollection monoCollection;
+ X509CertificateCollection monoCollection;
if (safeContext == null || safeContext.IsInvalid) {
remoteCertificateStore = null;
return null;
//
#if CONFIGURATION_DEP
-extern alias PrebuiltSystem;
-using TypeDescriptor = PrebuiltSystem.System.ComponentModel.TypeDescriptor;
-
using System;
using System.Collections.Generic;
using System.ComponentModel;
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if CONFIGURATION_DEP
-extern alias PrebuiltSystem;
-using NameValueCollection = PrebuiltSystem.System.Collections.Specialized.NameValueCollection;
-#endif
-
using System.Reflection;
using System.Collections.Specialized;
// Copyright (C) 2005, 2006 Novell, Inc (http://www.novell.com)
//
-#if CONFIGURATION_DEP
-extern alias PrebuiltSystem;
-using NameValueCollection = PrebuiltSystem.System.Collections.Specialized.NameValueCollection;
-#endif
#if CONFIGURATION_DEP
using System.IO;
using System.Xml.Serialization;
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if CONFIGURATION_DEP
-extern alias PrebuiltSystem;
-using NameValueCollection = PrebuiltSystem.System.Collections.Specialized.NameValueCollection;
-#endif
-
using System;
using System.Collections;
using System.Collections.Specialized;
#if CONFIGURATION_DEP
-extern alias PrebuiltSystem;
-
using System;
using System.Collections;
using System.Collections.Generic;
+using System.Collections.Specialized;
using System.Configuration;
using System.Globalization;
using System.IO;
using System.Text;
using System.Xml;
-using NameValueCollection = PrebuiltSystem.System.Collections.Specialized.NameValueCollection;
-
namespace System.Configuration
{
// location to store user configuration settings.
//
#if CONFIGURATION_DEP
-#if CONFIGURATION_DEP
-extern alias PrebuiltSystem;
-using NameValueCollection = PrebuiltSystem.System.Collections.Specialized.NameValueCollection;
-#endif
using System;
using System.Collections.Specialized;
/* Private constructor called from other methods */
private Process (SafeProcessHandle handle, int id) {
- m_processHandle = handle;
+ SetProcessHandle (handle);
SetProcessId (id);
}
throw new Win32Exception (-proc_info.pid);
}
- m_processHandle = new SafeProcessHandle (proc_info.process_handle, true);
- haveProcessHandle = true;
+ SetProcessHandle (new SafeProcessHandle (proc_info.process_handle, true));
SetProcessId (proc_info.pid);
- if (watchForExit)
- EnsureWatchingForExit ();
-
return ret;
}
}
}
- m_processHandle = new SafeProcessHandle (proc_info.process_handle, true);
- haveProcessHandle = true;
+ SetProcessHandle (new SafeProcessHandle (proc_info.process_handle, true));
SetProcessId (proc_info.pid);
if (startInfo.RedirectStandardInput) {
standardError = new StreamReader (new FileStream (stderr_read, FileAccess.Read, true, 8192), stderrEncoding, true);
}
- if (watchForExit)
- EnsureWatchingForExit ();
-
return true;
}
else
fullPathNoLastSlash = fsw.FullPath;
- // GetFilenameFromFd() returns the *realpath* which can be different than fsw.FullPath because symlinks.
+ // realpath() returns the *realpath* which can be different than fsw.FullPath because symlinks.
// If so, introduce a fixup step.
- int fd = open (fullPathNoLastSlash, O_EVTONLY, 0);
- var resolvedFullPath = GetFilenameFromFd (fd);
- close (fd);
+ var sb = new StringBuilder (__DARWIN_MAXPATHLEN);
+ if (realpath(fsw.FullPath, sb) == IntPtr.Zero) {
+ var errMsg = String.Format ("realpath({0}) failed, error code = '{1}'", fsw.FullPath, Marshal.GetLastWin32Error ());
+ throw new IOException (errMsg);
+ }
+ var resolvedFullPath = sb.ToString();
if (resolvedFullPath != fullPathNoLastSlash)
fixupPath = resolvedFullPath;
return;
// e.Name
- string name = path.Substring (fullPathNoLastSlash.Length + 1);
+ string name = (path.Length > fullPathNoLastSlash.Length) ? path.Substring (fullPathNoLastSlash.Length + 1) : String.Empty;
// only post events that match filter pattern. check both old and new paths for renames
if (!fsw.Pattern.IsMatch (path) && (newPath == null || !fsw.Pattern.IsMatch (newPath)))
return;
if (action == FileAction.RenamedNewName) {
- string newName = newPath.Substring (fullPathNoLastSlash.Length + 1);
+ string newName = (newPath.Length > fullPathNoLastSlash.Length) ? newPath.Substring (fullPathNoLastSlash.Length + 1) : String.Empty;
renamed = new RenamedEventArgs (WatcherChangeTypes.Renamed, fsw.Path, newName, name);
}
[DllImport ("libc", CharSet=CharSet.Auto, SetLastError=true)]
static extern int fcntl (int file_names_by_descriptor, int cmd, StringBuilder sb);
+ [DllImport ("libc", CharSet=CharSet.Auto, SetLastError=true)]
+ static extern IntPtr realpath (string pathname, StringBuilder sb);
+
[DllImport ("libc", SetLastError=true)]
extern static int open (string path, int flags, int mode_t);
#if MONO_SECURITY_ALIAS
extern alias MonoSecurity;
#endif
-#if MONO_X509_ALIAS
-extern alias PrebuiltSystem;
-#endif
#if MONO_SECURITY_ALIAS
using MSI = MonoSecurity::Mono.Security.Interface;
#else
using MSI = Mono.Security.Interface;
#endif
-#if MONO_X509_ALIAS
-using X509CertificateCollection = PrebuiltSystem::System.Security.Cryptography.X509Certificates.X509CertificateCollection;
-#else
-using X509CertificateCollection = System.Security.Cryptography.X509Certificates.X509CertificateCollection;
-#endif
using System.Security.Cryptography.X509Certificates;
#endif
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if SECURITY_DEP && !MONO_FEATURE_NEW_TLS
-#if MONO_X509_ALIAS
-extern alias PrebuiltSystem;
-using X509CertificateCollection = PrebuiltSystem::System.Security.Cryptography.X509Certificates.X509CertificateCollection;
-#endif
using System.Security.Cryptography.X509Certificates;
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if !MONO_FEATURE_NEW_TLS
-#if MONO_X509_ALIAS
-extern alias PrebuiltSystem;
-using X509CertificateCollection = PrebuiltSystem::System.Security.Cryptography.X509Certificates.X509CertificateCollection;
-#endif
using System.Security.Cryptography.X509Certificates;
#if !MONO_FEATURE_NEW_TLS
#if SECURITY_DEP
-#if MONO_X509_ALIAS
-extern alias PrebuiltSystem;
-#endif
#if MONO_SECURITY_ALIAS
extern alias MonoSecurity;
#endif
#else
using Mono.Security.Interface;
#endif
-#if MONO_X509_ALIAS
-using XSslProtocols = PrebuiltSystem::System.Security.Authentication.SslProtocols;
-using XX509CertificateCollection = PrebuiltSystem::System.Security.Cryptography.X509Certificates.X509CertificateCollection;
-#else
-using XSslProtocols = System.Security.Authentication.SslProtocols;
-using XX509CertificateCollection = System.Security.Cryptography.X509Certificates.X509CertificateCollection;
-#endif
using CipherAlgorithmType = System.Security.Authentication.CipherAlgorithmType;
using HashAlgorithmType = System.Security.Authentication.HashAlgorithmType;
internal delegate X509Certificate LocalCertSelectionCallback (
string targetHost,
- XX509CertificateCollection localCertificates,
+ X509CertificateCollection localCertificates,
X509Certificate remoteCertificate,
string[] acceptableIssuers);
Impl.AuthenticateAsClient (targetHost);
}
- public virtual void AuthenticateAsClient (string targetHost, XX509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
+ public virtual void AuthenticateAsClient (string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
{
- Impl.AuthenticateAsClient (targetHost, (XX509CertificateCollection)(object)clientCertificates, (XSslProtocols)enabledSslProtocols, checkCertificateRevocation);
+ Impl.AuthenticateAsClient (targetHost, clientCertificates, enabledSslProtocols, checkCertificateRevocation);
}
// [HostProtection (ExternalThreading=true)]
}
// [HostProtection (ExternalThreading=true)]
- public virtual IAsyncResult BeginAuthenticateAsClient (string targetHost, XX509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState)
+ public virtual IAsyncResult BeginAuthenticateAsClient (string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState)
{
- return Impl.BeginAuthenticateAsClient (targetHost, (XX509CertificateCollection)(object)clientCertificates, (XSslProtocols)enabledSslProtocols, checkCertificateRevocation, asyncCallback, asyncState);
+ return Impl.BeginAuthenticateAsClient (targetHost, clientCertificates, enabledSslProtocols, checkCertificateRevocation, asyncCallback, asyncState);
}
public virtual void EndAuthenticateAsClient (IAsyncResult asyncResult)
public virtual void AuthenticateAsServer (X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
{
- Impl.AuthenticateAsServer (serverCertificate, clientCertificateRequired, (XSslProtocols)enabledSslProtocols, checkCertificateRevocation);
+ Impl.AuthenticateAsServer (serverCertificate, clientCertificateRequired, enabledSslProtocols, checkCertificateRevocation);
}
// [HostProtection (ExternalThreading=true)]
public virtual IAsyncResult BeginAuthenticateAsServer (X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState)
{
- return Impl.BeginAuthenticateAsServer (serverCertificate, clientCertificateRequired, (XSslProtocols)enabledSslProtocols, checkCertificateRevocation, asyncCallback, asyncState);
+ return Impl.BeginAuthenticateAsServer (serverCertificate, clientCertificateRequired, enabledSslProtocols, checkCertificateRevocation, asyncCallback, asyncState);
}
public virtual void EndAuthenticateAsServer (IAsyncResult asyncResult)
return Impl.AuthenticateAsClientAsync (targetHost);
}
- public virtual Task AuthenticateAsClientAsync (string targetHost, XX509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
+ public virtual Task AuthenticateAsClientAsync (string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
{
- return Impl.AuthenticateAsClientAsync (targetHost, clientCertificates, (XSslProtocols)enabledSslProtocols, checkCertificateRevocation);
+ return Impl.AuthenticateAsClientAsync (targetHost, clientCertificates, enabledSslProtocols, checkCertificateRevocation);
}
public virtual Task AuthenticateAsServerAsync (X509Certificate serverCertificate)
public virtual Task AuthenticateAsServerAsync (X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
{
- return Impl.AuthenticateAsServerAsync (serverCertificate, clientCertificateRequired, (XSslProtocols)enabledSslProtocols, checkCertificateRevocation);
+ return Impl.AuthenticateAsServerAsync (serverCertificate, clientCertificateRequired, enabledSslProtocols, checkCertificateRevocation);
}
public override bool IsAuthenticated {
#if MONO_SECURITY_ALIAS
extern alias MonoSecurity;
#endif
-#if MONO_X509_ALIAS
-extern alias PrebuiltSystem;
-#endif
#if MONO_SECURITY_ALIAS
using MSI = MonoSecurity::Mono.Security.Interface;
#else
using MSI = Mono.Security.Interface;
#endif
-#if MONO_X509_ALIAS
-using XX509CertificateCollection = PrebuiltSystem::System.Security.Cryptography.X509Certificates.X509CertificateCollection;
-#else
-using XX509CertificateCollection = System.Security.Cryptography.X509Certificates.X509CertificateCollection;
-#endif
using System.IO;
using System.Net.Sockets;
//
#if CONFIGURATION_DEP
-extern alias PrebuiltSystem;
-
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Xml;
-using TypeConverter = PrebuiltSystem::System.ComponentModel.TypeConverter;
-
namespace System.Security.Authentication.ExtendedProtection.Configuration
{
internal static class ConfigUtil
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if SECURITY_DEP
-#if MONO_X509_ALIAS
-extern alias PrebuiltSystem;
-#endif
-#if MONO_X509_ALIAS
-using XX509CertificateCollection = PrebuiltSystem::System.Security.Cryptography.X509Certificates.X509CertificateCollection;
-#else
using XX509CertificateCollection = System.Security.Cryptography.X509Certificates.X509CertificateCollection;
-#endif
using System;
using System.Runtime.InteropServices;
}
}
- static IntPtr GetCertificate (X509Certificate certificate, out IntPtr dataPtr)
+ static IntPtr GetCertificate (X509Certificate certificate)
{
- var handle = certificate.Handle;
+ var handle = certificate.Impl.GetNativeAppleCertificate ();
if (handle != IntPtr.Zero) {
- dataPtr = IntPtr.Zero;
CFRetain (handle);
return handle;
}
- dataPtr = MakeCFData (certificate.GetRawCertData ());
- return SecCertificateCreateWithData (IntPtr.Zero, dataPtr);
+ var dataPtr = MakeCFData (certificate.GetRawCertData ());
+ handle = SecCertificateCreateWithData (IntPtr.Zero, dataPtr);
+ CFRelease (dataPtr);
+ return handle;
}
public static SecTrustResult TrustEvaluateSsl (XX509CertificateCollection certificates, XX509CertificateCollection anchors, string host)
{
int certCount = certificates.Count;
int anchorCount = anchors != null ? anchors.Count : 0;
- IntPtr [] cfDataPtrs = new IntPtr [certCount];
IntPtr [] secCerts = new IntPtr [certCount];
- IntPtr [] cfDataAnchorPtrs = new IntPtr [anchorCount];
IntPtr [] secCertAnchors = new IntPtr [anchorCount];
IntPtr certArray = IntPtr.Zero;
IntPtr anchorArray = IntPtr.Zero;
try {
for (int i = 0; i < certCount; i++) {
- secCerts [i] = GetCertificate (certificates [i], out cfDataPtrs [i]);
+ secCerts [i] = GetCertificate (certificates [i]);
if (secCerts [i] == IntPtr.Zero)
return SecTrustResult.Deny;
}
for (int i = 0; i < anchorCount; i++) {
- secCertAnchors [i] = GetCertificate (anchors [i], out cfDataAnchorPtrs [i]);
+ secCertAnchors [i] = GetCertificate (anchors [i]);
if (secCertAnchors [i] == IntPtr.Zero)
return SecTrustResult.Deny;
}
code = SecTrustEvaluate (sectrust, out result);
return result;
} finally {
- for (int i = 0; i < certCount; i++)
- if (cfDataPtrs [i] != IntPtr.Zero)
- CFRelease (cfDataPtrs [i]);
-
- for (int i = 0; i < anchorCount; i++)
- if (cfDataAnchorPtrs [i] != IntPtr.Zero)
- CFRelease (cfDataAnchorPtrs [i]);
-
if (certArray != IntPtr.Zero)
CFRelease (certArray);
get { return IntPtr.Zero; }
}
+ public override IntPtr GetNativeAppleCertificate ()
+ {
+ return IntPtr.Zero;
+ }
+
internal X509Certificate2ImplMono (MX.X509Certificate cert)
{
this._cert = cert;
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+
#if SECURITY_DEP
+#if MONO_SECURITY_ALIAS
+extern alias MonoSecurity;
+#endif
+
+#if MONO_SECURITY_ALIAS
+using MonoSecurity::Mono.Security.Interface;
+#else
+using Mono.Security.Interface;
+#endif
+
namespace System.Security.Cryptography.X509Certificates
{
internal static class X509Helper2
{
+ internal static void Initialize ()
+ {
+ X509Helper.InstallNativeHelper (new MyNativeHelper ());
+ }
+
internal static void ThrowIfContextInvalid (X509CertificateImpl impl)
{
X509Helper.ThrowIfContextInvalid (impl);
internal static X509Certificate2Impl Import (byte[] rawData, string password, X509KeyStorageFlags keyStorageFlags)
{
- var impl = new X509Certificate2ImplMono ();
- impl.Import (rawData, password, keyStorageFlags);
- return impl;
+ var provider = MonoTlsProviderFactory.GetProvider ();
+ if (provider.HasNativeCertificates) {
+ var impl = provider.GetNativeCertificate (rawData, password, keyStorageFlags);
+ return impl;
+ } else {
+ var impl = new X509Certificate2ImplMono ();
+ impl.Import (rawData, password, keyStorageFlags);
+ return impl;
+ }
}
internal static X509Certificate2Impl Import (X509Certificate cert)
{
+ var provider = MonoTlsProviderFactory.GetProvider ();
+ if (provider.HasNativeCertificates) {
+ var impl = provider.GetNativeCertificate (cert);
+ return impl;
+ }
var impl2 = cert.Impl as X509Certificate2Impl;
if (impl2 != null)
return (X509Certificate2Impl)impl2.Clone ();
{
return new CryptographicException (Locale.GetText ("Chain instance is empty."));
}
+
+ class MyNativeHelper : INativeCertificateHelper
+ {
+ public X509CertificateImpl Import (
+ byte[] data, string password, X509KeyStorageFlags flags)
+ {
+ return X509Helper2.Import (data, password, flags);
+ }
+
+ public X509CertificateImpl Import (X509Certificate cert)
+ {
+ return X509Helper2.Import (cert);
+ }
+ }
}
}
#endif
[TestFixture]
public class ClientWebSocketTest
{
- const string EchoServerUrl = "ws://echo.websocket.org";
+ const string EchoServerUrl = "ws://corefx-net.cloudapp.net/WebSocket/EchoWebSocket.ashx";
int Port = NetworkHelpers.FindFreePort ();
HttpListener listener;
ClientWebSocket socket;
+++ /dev/null
-//
-// CommonCrypto code generator for symmetric block cipher algorithms
-//
-// Authors:
-// Sebastien Pouliot <sebastien@xamarin.com>
-//
-// Copyright 2012 Xamarin Inc.
-//
-
-using System;
-using System.IO;
-
-namespace Xamarin {
-
- public static class CommonCryptor {
-
- static public void Generate (string namespaceName, string typeName, string baseTypeName, string ccAlgorithmName, string feedbackSize = "8", string ctorInitializers = null)
- {
- string template = @"// Generated file to bind CommonCrypto cipher algorithms - DO NOT EDIT
-//
-// Authors:
-// Sebastien Pouliot <sebastien@xamarin.com>
-//
-// Copyright 2012-2014 Xamarin Inc.
-
-using System;
-using System.Security.Cryptography;
-
-using Mono.Security.Cryptography;
-using Crimson.CommonCrypto;
-
-namespace %NAMESPACE% {
-
- public sealed partial class %TYPE% : %BASE% {
-
- public %TYPE% ()
- {
- FeedbackSizeValue = %FEEDBACKSIZE%;
- %CTOR_INIT%
- }
-
- public override void GenerateIV ()
- {
- IVValue = KeyBuilder.IV (BlockSizeValue >> 3);
- }
-
- public override void GenerateKey ()
- {
- KeyValue = KeyBuilder.Key (KeySizeValue >> 3);
- }
-
- public override ICryptoTransform CreateDecryptor (byte[] rgbKey, byte[] rgbIV)
- {
- IntPtr decryptor = IntPtr.Zero;
- switch (Mode) {
- case CipherMode.CBC:
- decryptor = Cryptor.Create (CCOperation.Decrypt, CCAlgorithm.%CCALGORITHM%, CCOptions.None, rgbKey, rgbIV);
- return new FastCryptorTransform (decryptor, this, false, rgbIV);
- case CipherMode.ECB:
- decryptor = Cryptor.Create (CCOperation.Decrypt, CCAlgorithm.%CCALGORITHM%, CCOptions.ECBMode, rgbKey, rgbIV);
- return new FastCryptorTransform (decryptor, this, false, rgbIV);
- case CipherMode.CFB:
-#if MONOTOUCH || XAMMAC
- IntPtr encryptor = Cryptor.Create (CCOperation.Encrypt, CCAlgorithm.%CCALGORITHM%, CCOptions.ECBMode, rgbKey, rgbIV);
- decryptor = Cryptor.Create (CCOperation.Decrypt, CCAlgorithm.%CCALGORITHM%, CCOptions.ECBMode, rgbKey, rgbIV);
- return new CryptorTransform (decryptor, encryptor, this, false, rgbIV);
-#else
- throw new CryptographicException (""CFB is not supported by Crimson.CommonCrypto"");
-#endif
- default:
- throw new CryptographicException (String.Format (""{0} is not supported by the .NET framework"", Mode));
- }
- }
-
- public override ICryptoTransform CreateEncryptor (byte[] rgbKey, byte[] rgbIV)
- {
- IntPtr encryptor = IntPtr.Zero;
- switch (Mode) {
- case CipherMode.CBC:
- encryptor = Cryptor.Create (CCOperation.Encrypt, CCAlgorithm.%CCALGORITHM%, CCOptions.None, rgbKey, rgbIV);
- return new FastCryptorTransform (encryptor, this, true, rgbIV);
- case CipherMode.ECB:
- encryptor = Cryptor.Create (CCOperation.Encrypt, CCAlgorithm.%CCALGORITHM%, CCOptions.ECBMode, rgbKey, rgbIV);
- return new FastCryptorTransform (encryptor, this, true, rgbIV);
- case CipherMode.CFB:
-#if MONOTOUCH || XAMMAC
- encryptor = Cryptor.Create (CCOperation.Encrypt, CCAlgorithm.%CCALGORITHM%, CCOptions.ECBMode, rgbKey, rgbIV);
- return new CryptorTransform (encryptor, IntPtr.Zero, this, true, rgbIV);
-#else
- throw new CryptographicException (""CFB is not supported by Crimson.CommonCrypto"");
-#endif
- default:
- throw new CryptographicException (String.Format (""{0} is not supported by the .NET framework"", Mode));
- }
- }
- }
-}";
-
- File.WriteAllText (typeName + ".g.cs", template.Replace ("%NAMESPACE%", namespaceName).
- Replace ("%TYPE%", typeName).Replace ("%BASE%", baseTypeName).Replace("%FEEDBACKSIZE%", feedbackSize).Replace ("%CTOR_INIT%", ctorInitializers).
- Replace ("%CCALGORITHM%", ccAlgorithmName.ToString ()));
- }
- }
-}
+++ /dev/null
-//
-// CommonCrypto code generator for digest algorithms
-//
-// Authors:
-// Sebastien Pouliot <sebastien@xamarin.com>
-//
-// Copyright 2012-2014 Xamarin Inc.
-//
-
-using System;
-using System.IO;
-
-namespace Xamarin {
-
- public static class CommonDigest {
-
-#if !MONOTOUCH && !XAMMAC
- // we do not add anything in MonoTouch, just replacing, so this is not needed
- // however we can avoid a dependency on Mono.Security for Crimson.CommonCrypto.dll by including the base classes
- static public void GenerateBaseClass (string namespaceName, string typeName, string baseTypeName, int hashSize,
- string visibilityStart = "", string visibilityEnd = "")
- {
- string template = @"// Generated file to bind CommonCrypto/CommonDigest - DO NOT EDIT
-//
-// Authors:
-// Sebastien Pouliot <sebastien@xamarin.com>
-//
-// Copyright 2012-2014 Xamarin Inc.
-
-using System;
-using System.Security.Cryptography;
-using System.Runtime.InteropServices;
-
-namespace %NAMESPACE% {
-
-%VISIBILITY_START%
- public
-%VISIBILITY_END%
- abstract class %BASE% : HashAlgorithm {
-
- protected %BASE% ()
- {
- HashSizeValue = %HASHSIZE%;
- }
-
- public static new %BASE% Create ()
- {
- return Create (""%BASE%"");
- }
-
- public static new %BASE% Create (string hashName)
- {
- object o = CryptoConfig.CreateFromName (hashName);
- return (%BASE%) o ?? new %TYPE% ();
- }
- }
-}";
-
- File.WriteAllText (baseTypeName + ".g.cs", template.Replace ("%NAMESPACE%", namespaceName).
- Replace ("%TYPE%", typeName).Replace ("%BASE%", baseTypeName).
- Replace ("%VISIBILITY_START%", visibilityStart).Replace ("%VISIBILITY_END%", visibilityEnd).
- Replace ("%HASHSIZE%", hashSize.ToString ()));
- }
-#endif
- static public void Generate (string namespaceName, string typeName, string baseTypeName, int contextSize,
- string visibilityStart = "", string visibilityEnd = "")
- {
- string template = @"// Generated file to bind CommonCrypto/CommonDigest - DO NOT EDIT
-//
-// Authors:
-// Sebastien Pouliot <sebastien@xamarin.com>
-//
-// Copyright 2011-2014 Xamarin Inc.
-
-using System;
-using System.Security.Cryptography;
-using System.Runtime.InteropServices;
-
-using Mono.Security.Cryptography;
-
-namespace %NAMESPACE% {
-
-%VISIBILITY_START%
- public
-%VISIBILITY_END%
- sealed class %TYPE% : %BASE% {
-
- IntPtr ctx;
-
- [DllImport (""/usr/lib/libSystem.dylib"", EntryPoint=""CC_%BASE%_Init"")]
- static extern int Init (/* CC_%BASE%_CTX */ IntPtr c);
-
- [DllImport (""/usr/lib/libSystem.dylib"", EntryPoint=""CC_%BASE%_Update"")]
- static extern int Update (/* CC_%BASE%_CTX */ IntPtr c, /* const void * */ IntPtr data, /* uint32_t */ uint len);
-
- [DllImport (""/usr/lib/libSystem.dylib"", EntryPoint=""CC_%BASE%_Final"")]
- static extern int Final (/* unsigned char * */ byte [] md, /* CC_%BASE%_CTX */ IntPtr c);
-
- public %TYPE% ()
- {
- ctx = IntPtr.Zero;
- }
-
- ~%TYPE% ()
- {
- Dispose (false);
- }
-
- protected override void Dispose (bool disposing)
- {
- if (ctx != IntPtr.Zero) {
- Marshal.FreeHGlobal (ctx);
- ctx = IntPtr.Zero;
- }
- base.Dispose (disposing);
- GC.SuppressFinalize (this);
- }
-
- public override void Initialize ()
- {
- if (ctx == IntPtr.Zero)
- ctx = Marshal.AllocHGlobal (%CTX_SIZE%);
-
- int hr = Init (ctx);
- if (hr != 1)
- throw new CryptographicException (hr);
- }
-
- protected override void HashCore (byte[] data, int start, int length)
- {
- if (ctx == IntPtr.Zero)
- Initialize ();
-
- if (data.Length == 0)
- return;
-
- unsafe {
- fixed (byte* p = &data [0]) {
- int hr = Update (ctx, (IntPtr) (p + start), (uint) length);
- if (hr != 1)
- throw new CryptographicException (hr);
- }
- }
- }
-
- protected override byte[] HashFinal ()
- {
- if (ctx == IntPtr.Zero)
- Initialize ();
-
- byte[] data = new byte [HashSize >> 3];
- int hr = Final (data, ctx);
- if (hr != 1)
- throw new CryptographicException (hr);
-
- return data;
- }
- }
-}";
-
- File.WriteAllText (typeName + ".g.cs", template.Replace ("%NAMESPACE%", namespaceName).
- Replace ("%TYPE%", typeName).Replace ("%BASE%", baseTypeName).
- Replace ("%VISIBILITY_START%", visibilityStart).Replace ("%VISIBILITY_END%", visibilityEnd).
- Replace ("%CTX_SIZE%", contextSize.ToString ()));
- }
- }
-}
--- /dev/null
+thisdir = class/corlib/CommonCrypto
+SUBDIRS =
+include ../../../build/rules.make
+
+.NOTPARALLEL:
+all:
+ MONO_PATH="$(topdir)/class/lib/$(BUILD_TOOLS_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(RUNTIME) $(RUNTIME_FLAGS) $(topdir)/class/lib/$(BUILD_TOOLS_PROFILE)/commoncryptogenerator.exe
+
+++ /dev/null
-CommonCrypto/%.g.cs: CommonCrypto/generator.exe
- cd CommonCrypto && mono --debug generator.exe
-
-CommonCrypto/generator.exe: CommonCrypto/generator.cs CommonCrypto/CommonDigestGenerator.cs CommonCrypto/CommonCryptorGenerator.cs
- mcs CommonCrypto/generator.cs CommonCrypto/CommonDigestGenerator.cs CommonCrypto/CommonCryptorGenerator.cs -o $@
+++ /dev/null
-//
-// CommonCrypto Code Generator
-//
-// Authors:
-// Sebastien Pouliot <sebastien@xamarin.com>
-//
-// Copyright 2012 Xamarin Inc.
-//
-
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Text;
-
-namespace Xamarin {
-
- class Program {
- static void Main (string [] args)
- {
- // mscorlib replacements
- CommonDigest.Generate ("System.Security.Cryptography", "MD5CryptoServiceProvider", "MD5", 1000);
- CommonDigest.Generate ("System.Security.Cryptography", "SHA1CryptoServiceProvider", "SHA1", 1000);
- CommonDigest.Generate ("System.Security.Cryptography", "SHA1Managed", "SHA1", 1000);
- CommonDigest.Generate ("System.Security.Cryptography", "SHA256Managed", "SHA256", 1000);
- CommonDigest.Generate ("System.Security.Cryptography", "SHA384Managed", "SHA384", 1000);
- CommonDigest.Generate ("System.Security.Cryptography", "SHA512Managed", "SHA512", 1000);
-
- // System.Core replacements - not yet in MT profile (4.0 - functional dupes anyway)
- //CommonDigest.Generate ("System.Security.Cryptography", "MD5Cng", "MD5", 1000);
- //CommonDigest.Generate ("System.Security.Cryptography", "SHA256Cng", "SHA256", 1000);
- //CommonDigest.Generate ("System.Security.Cryptography", "SHA384Cng", "SHA384", 1000);
- //CommonDigest.Generate ("System.Security.Cryptography", "SHA512Cng", "SHA512", 1000);
- //CommonDigest.Generate ("System.Security.Cryptography", "SHA256CryptoServiceProvider", "SHA256", 1000);
- //CommonDigest.Generate ("System.Security.Cryptography", "SHA384CryptoServiceProvider", "SHA384", 1000);
- //CommonDigest.Generate ("System.Security.Cryptography", "SHA512CryptoServiceProvider", "SHA512", 1000);
-
- // Mono.Security replacements
- CommonDigest.Generate ("Mono.Security.Cryptography", "MD2Managed", "MD2", 1000, "#if !INSIDE_CORLIB", "#endif");
- CommonDigest.Generate ("Mono.Security.Cryptography", "MD4Managed", "MD4", 1000, "#if !INSIDE_CORLIB", "#endif");
- CommonDigest.Generate ("Mono.Security.Cryptography", "SHA224Managed", "SHA224", 1000);
-
- // mscorlib replacements
- CommonCryptor.Generate ("System.Security.Cryptography", "DESCryptoServiceProvider", "DES", "DES");
- CommonCryptor.Generate ("System.Security.Cryptography", "TripleDESCryptoServiceProvider", "TripleDES", "TripleDES");
- CommonCryptor.Generate ("System.Security.Cryptography", "RC2CryptoServiceProvider", "RC2", "RC2", ctorInitializers: "LegalKeySizesValue = new[] { new KeySizes(40, 128, 8) };");
- // Rijndael supports block sizes that are not available in AES - as such it does not use the same generated code
- // but has it's own version, using AES (128 bits block size) and falling back to managed (192/256 bits block size)
-
- // System.Core replacements
- CommonCryptor.Generate ("System.Security.Cryptography", "AesManaged", "Aes", "AES128", "128");
- CommonCryptor.Generate ("System.Security.Cryptography", "AesCryptoServiceProvider", "Aes", "AES128");
-
- // Mono.Security replacements
- // RC4 is a stream (not a block) cipher so it can not reuse the generated code
- }
- }
-}
\ No newline at end of file
thisdir = class/corlib
SUBDIRS =
include ../../build/rules.make
-include CommonCrypto/Makefile.include
export __SECURITY_BOOTSTRAP_DB=$(topdir)/class/corlib
LIBRARY = corlib.dll
TEST_MCS_FLAGS += -debug -nowarn:168,219,618,672 -unsafe \
-define:MONO_DATACONVERTER_STATIC_METHODS $(TEST_RESX_RESOURCES:%=-resource:%)
+
+CC_PROFILE := $(filter monotouch% xammac, $(PROFILE))
+ifdef CC_PROFILE
+
+BUILT_SOURCES = \
+ CommonCrypto/AesCryptoServiceProvider.g.cs \
+ CommonCrypto/MD5CryptoServiceProvider.g.cs \
+ CommonCrypto/SHA256Managed.g.cs \
+ CommonCrypto/AesManaged.g.cs \
+ CommonCrypto/RC2CryptoServiceProvider.g.cs \
+ CommonCrypto/SHA384Managed.g.cs \
+ CommonCrypto/DESCryptoServiceProvider.g.cs \
+ CommonCrypto/SHA1CryptoServiceProvider.g.cs \
+ CommonCrypto/SHA512Managed.g.cs \
+ CommonCrypto/MD2Managed.g.cs \
+ CommonCrypto/SHA1Managed.g.cs \
+ CommonCrypto/TripleDESCryptoServiceProvider.g.cs \
+ CommonCrypto/MD4Managed.g.cs
+
+CommonCrypto/%.g.cs:
+ $(MAKE) -C CommonCrypto
+
+endif
+
EXTRA_DISTFILES = \
Test/resources/MyResources.resources \
Test/resources/MyResources.de.resources \
$(vtsdir)/VersionTolerantSerializationTestLib/6.0/Address.cs \
$(vtsdir)/BinarySerializationOverVersions.cs
-EXTRA_DISTFILES += \
- CommonCrypto/Makefile.include
-
#
# Android TimeZoneInfo testing....
#
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-using System.Text;
-using System.Reflection;
-
namespace System.Diagnostics {
+ using System.Text;
+#if INSIDE_CORLIB
+ using System.Reflection;
+#else
+ using IKVM.Reflection;
+ using IKVM.Reflection.Reader;
+ using Type = IKVM.Reflection.Type;
+#endif
// This class exists so tools such as mono-symbolicate can use it directly.
class StackTraceHelper {
if (pt.IsGenericType && ! pt.IsGenericTypeDefinition)
pt = pt.GetGenericTypeDefinition ();
- if (pt.IsClass && !String.IsNullOrEmpty (pt.Namespace)) {
- sb.Append (pt.Namespace);
- sb.Append (".");
- }
- sb.Append (pt.Name);
+ sb.Append (pt.ToString());
+
if (p [i].Name != null) {
sb.Append (" ");
sb.Append (p [i].Name);
info.Parent.Create ();
MonoIOError error;
- if (!MonoIO.CreateDirectory (path, out error)) {
+ if (!MonoIO.CreateDirectory (info.FullName, out error)) {
// LAMESPEC: 1.1 and 1.2alpha allow CreateDirectory on a file path.
// So CreateDirectory ("/tmp/somefile") will succeed if 'somefile' is
// not a directory. However, 1.0 will throw an exception.
FullPath = Path.GetFullPath (path);
if (simpleOriginalPath)
- OriginalPath = Path.GetFileName (path);
+ OriginalPath = Path.GetFileName (FullPath);
else
OriginalPath = path;
f = new FileStream (path, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.Read,
8192, false, (FileOptions) 1);
} catch (IOException ex){
- if (ex.hresult != MonoIO.FileAlreadyExistsHResult || count ++ > 65536)
+ if (ex._HResult != MonoIO.FileAlreadyExistsHResult || count ++ > 65536)
throw;
} catch (UnauthorizedAccessException ex) {
if (count ++ > 65536)
namespace System.Reflection.Emit
{
- internal enum TypeKind : int {
- SZARRAY = 0x1d,
- ARRAY = 0x14
- }
-
[StructLayout (LayoutKind.Sequential)]
- internal abstract class DerivedType : Type
+ abstract partial class SymbolType
{
- internal Type elementType;
+ internal Type m_baseType;
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- internal static extern void create_unmanaged_type (Type type);
+ static extern void create_unmanaged_type (Type type);
- internal DerivedType (Type elementType)
+ internal SymbolType (Type elementType)
{
- this.elementType = elementType;
+ this.m_baseType = elementType;
}
internal abstract String FormatName (string elementName);
- public override Type GetInterface (string name, bool ignoreCase)
- {
- throw new NotSupportedException ();
- }
-
- public override Type[] GetInterfaces ()
- {
- throw new NotSupportedException ();
- }
-
- public override Type GetElementType ()
- {
- return elementType;
- }
-
- public override EventInfo GetEvent (string name, BindingFlags bindingAttr)
- {
- throw new NotSupportedException ();
- }
-
- public override EventInfo[] GetEvents (BindingFlags bindingAttr)
- {
- throw new NotSupportedException ();
- }
-
- public override FieldInfo GetField( string name, BindingFlags bindingAttr)
- {
- throw new NotSupportedException ();
- }
-
- public override FieldInfo[] GetFields (BindingFlags bindingAttr)
- {
- throw new NotSupportedException ();
- }
-
- public override MemberInfo[] GetMembers (BindingFlags bindingAttr)
- {
- throw new NotSupportedException ();
- }
-
- protected override MethodInfo GetMethodImpl (string name, BindingFlags bindingAttr, Binder binder,
- CallingConventions callConvention, Type[] types,
- ParameterModifier[] modifiers)
- {
- throw new NotSupportedException ();
- }
-
- public override MethodInfo[] GetMethods (BindingFlags bindingAttr)
- {
- throw new NotSupportedException ();
- }
-
- public override Type GetNestedType (string name, BindingFlags bindingAttr)
- {
- throw new NotSupportedException ();
- }
-
- public override Type[] GetNestedTypes (BindingFlags bindingAttr)
- {
- throw new NotSupportedException ();
- }
-
- public override PropertyInfo[] GetProperties (BindingFlags bindingAttr)
- {
- throw new NotSupportedException ();
- }
-
- protected override PropertyInfo GetPropertyImpl (string name, BindingFlags bindingAttr, Binder binder,
- Type returnType, Type[] types, ParameterModifier[] modifiers)
- {
- throw new NotSupportedException ();
- }
-
- protected override ConstructorInfo GetConstructorImpl (BindingFlags bindingAttr,
- Binder binder,
- CallingConventions callConvention,
- Type[] types,
- ParameterModifier[] modifiers)
- {
- throw new NotSupportedException ();
- }
-
-
- protected override TypeAttributes GetAttributeFlagsImpl ()
- {
- /*LAMEIMPL MS just return the elementType.Attributes*/
- return elementType.Attributes;
- }
-
- protected override bool HasElementTypeImpl ()
- {
- return true;
- }
-
protected override bool IsArrayImpl ()
{
return false;
return false;
}
- protected override bool IsCOMObjectImpl ()
- {
- return false;
- }
-
protected override bool IsPointerImpl ()
{
return false;
}
- protected override bool IsPrimitiveImpl ()
- {
- return false;
- }
-
-
- public override ConstructorInfo[] GetConstructors (BindingFlags bindingAttr)
- {
- throw new NotSupportedException ();
- }
-
- public override object InvokeMember (string name, BindingFlags invokeAttr,
- Binder binder, object target, object[] args,
- ParameterModifier[] modifiers,
- CultureInfo culture, string[] namedParameters)
- {
- throw new NotSupportedException ();
- }
-
- public override InterfaceMapping GetInterfaceMap (Type interfaceType)
- {
- throw new NotSupportedException ();
- }
-
- public override bool IsInstanceOfType (object o)
- {
- return false;
- }
-
- public override bool IsAssignableFrom (Type c)
- {
- return false;
- }
-
- public override bool ContainsGenericParameters {
- get { return elementType.ContainsGenericParameters; }
- }
-
- //FIXME this should be handled by System.Type
- public override Type MakeGenericType (params Type[] typeArguments)
- {
- throw new NotSupportedException ();
- }
-
public override Type MakeArrayType ()
{
return new ArrayType (this, 0);
public override string ToString ()
{
- return FormatName (elementType.ToString ());
- }
-
- public override GenericParameterAttributes GenericParameterAttributes {
- get { throw new NotSupportedException (); }
- }
-
- public override StructLayoutAttribute StructLayoutAttribute {
- get { throw new NotSupportedException (); }
- }
-
- public override Assembly Assembly {
- get { return elementType.Assembly; }
+ return FormatName (m_baseType.ToString ());
}
public override string AssemblyQualifiedName {
get {
- string fullName = FormatName (elementType.FullName);
+ string fullName = FormatName (m_baseType.FullName);
if (fullName == null)
return null;
- return fullName + ", " + elementType.Assembly.FullName;
+ return fullName + ", " + m_baseType.Assembly.FullName;
}
}
public override string FullName {
get {
- return FormatName (elementType.FullName);
+ return FormatName (m_baseType.FullName);
}
}
public override string Name {
get {
- return FormatName (elementType.Name);
+ return FormatName (m_baseType.Name);
}
}
-
- public override Guid GUID {
- get { throw new NotSupportedException (); }
- }
-
- public override Module Module {
- get { return elementType.Module; }
- }
- public override string Namespace {
- get { return elementType.Namespace; }
- }
-
- public override RuntimeTypeHandle TypeHandle {
- get { throw new NotSupportedException (); }
- }
-
public override Type UnderlyingSystemType {
get {
create_unmanaged_type (this);
}
}
- //MemberInfo
- public override bool IsDefined (Type attributeType, bool inherit)
- {
- throw new NotSupportedException ();
- }
-
- public override object [] GetCustomAttributes (bool inherit)
- {
- throw new NotSupportedException ();
- }
-
- public override object [] GetCustomAttributes (Type attributeType, bool inherit)
- {
- throw new NotSupportedException ();
- }
-
internal override bool IsUserType {
get {
- return elementType.IsUserType;
+ return m_baseType.IsUserType;
}
}
}
[StructLayout (LayoutKind.Sequential)]
- internal class ArrayType : DerivedType
+ internal class ArrayType : SymbolType
{
int rank;
internal override Type InternalResolve ()
{
- Type et = elementType.InternalResolve ();
+ Type et = m_baseType.InternalResolve ();
if (rank == 0)
return et.MakeArrayType ();
return et.MakeArrayType (rank);
return (rank == 0) ? 1 : rank;
}
- public override Type BaseType {
- get { return typeof (System.Array); }
- }
-
- protected override TypeAttributes GetAttributeFlagsImpl ()
- {
- return elementType.Attributes;
- }
-
internal override String FormatName (string elementName)
{
if (elementName == null)
}
[StructLayout (LayoutKind.Sequential)]
- internal class ByRefType : DerivedType
+ internal class ByRefType : SymbolType
{
internal ByRefType (Type elementType) : base (elementType)
{
internal override Type InternalResolve ()
{
- return elementType.InternalResolve ().MakeByRefType ();
+ return m_baseType.InternalResolve ().MakeByRefType ();
}
protected override bool IsByRefImpl ()
return true;
}
- public override Type BaseType {
- get { return typeof (Array); }
- }
-
internal override String FormatName (string elementName)
{
if (elementName == null)
}
[StructLayout (LayoutKind.Sequential)]
- internal class PointerType : DerivedType
+ internal class PointerType : SymbolType
{
internal PointerType (Type elementType) : base (elementType)
{
internal override Type InternalResolve ()
{
- return elementType.InternalResolve ().MakePointerType ();
+ return m_baseType.InternalResolve ().MakePointerType ();
}
protected override bool IsPointerImpl ()
return true;
}
- public override Type BaseType {
- get { return typeof(Array); }
- }
-
internal override String FormatName (string elementName)
{
if (elementName == null)
public override IList<CustomAttributeData> GetCustomAttributesData () {
return CustomAttributeData.GetCustomAttributes (this);
}
+
+ [MethodImplAttribute(MethodImplOptions.InternalCall)]
+ public extern int get_core_clr_security_level ();
+
+ public override bool IsSecurityTransparent {
+ get { return get_core_clr_security_level () == 0; }
+ }
+
+ public override bool IsSecurityCritical {
+ get { return get_core_clr_security_level () > 0; }
+ }
+
+ public override bool IsSecuritySafeCritical {
+ get { return get_core_clr_security_level () == 1; }
+ }
}
}
var errorInfo = new ManagedErrorInfo(e);
SetErrorInfo (0, errorInfo);
- return e.hresult;
+ return e._HResult;
#else
return -1;
#endif
}
}
- if (info is ManagedErrorInfo && ((ManagedErrorInfo) info).Exception.hresult == errorCode) {
+ if (info is ManagedErrorInfo && ((ManagedErrorInfo) info).Exception._HResult == errorCode) {
return ((ManagedErrorInfo) info).Exception;
}
--- /dev/null
+//
+// INativeCertificateHelper.cs
+//
+// Author:
+// Martin Baulig <martin.baulig@xamarin.com>
+//
+// Copyright (c) 2016 Xamarin, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+namespace System.Security.Cryptography.X509Certificates
+{
+ internal interface INativeCertificateHelper
+ {
+ X509CertificateImpl Import (byte[] data, string password, X509KeyStorageFlags flags);
+
+ X509CertificateImpl Import (X509Certificate cert);
+ }
+}
if (cert == null)
throw new ArgumentNullException ("cert");
- X509Helper.ThrowIfContextInvalid (cert.impl);
-
- impl = X509Helper.InitFromCertificate (cert.impl);
+ impl = X509Helper.InitFromCertificate (cert);
hideDates = false;
}
get;
}
+ /*
+ * This is used in System.dll's OSX509Certificates.cs
+ */
+ public abstract IntPtr GetNativeAppleCertificate ();
+
protected void ThrowIfContextInvalid ()
{
if (!IsValid)
get { return handle; }
}
+ public override IntPtr GetNativeAppleCertificate ()
+ {
+ ThrowIfContextInvalid ();
+ return handle;
+ }
+
public override X509CertificateImpl Clone ()
{
ThrowIfContextInvalid ();
namespace System.Security.Cryptography.X509Certificates
{
- class X509CertificateImplMono : X509CertificateImpl
+ sealed class X509CertificateImplMono : X509CertificateImpl
{
MX.X509Certificate x509;
get { return IntPtr.Zero; }
}
+ public override IntPtr GetNativeAppleCertificate ()
+ {
+ return IntPtr.Zero;
+ }
+
public override X509CertificateImpl Clone ()
{
ThrowIfContextInvalid ();
//
using System;
using System.Text;
+using System.Threading;
using System.Runtime.InteropServices;
#if !NET_2_1
using System.Security.Permissions;
{
static partial class X509Helper
{
+ static INativeCertificateHelper nativeHelper;
+
+ internal static void InstallNativeHelper (INativeCertificateHelper helper)
+ {
+ if (nativeHelper == null)
+ Interlocked.CompareExchange (ref nativeHelper, helper, null);
+ }
+
#if !NET_2_1
// typedef struct _CERT_CONTEXT {
// DWORD dwCertEncodingType;
}
#endif
+ public static X509CertificateImpl InitFromCertificate (X509Certificate cert)
+ {
+ if (nativeHelper != null)
+ return nativeHelper.Import (cert);
+
+ return InitFromCertificate (cert.Impl);
+ }
+
public static X509CertificateImpl InitFromCertificate (X509CertificateImpl impl)
{
ThrowIfContextInvalid (impl);
#if !MONOTOUCH && !XAMMAC
public static X509CertificateImpl Import (byte[] rawData, string password, X509KeyStorageFlags keyStorageFlags)
{
+ if (nativeHelper != null)
+ return nativeHelper.Import (rawData, password, keyStorageFlags);
+
MX.X509Certificate x509;
if (password == null) {
try {
* of icalls, do not require an increment.
*/
#pragma warning disable 169
- private const int mono_corlib_version = 143;
+ private const int mono_corlib_version = 145;
#pragma warning restore 169
[ComVisible (true)]
{
}
+
+ // Copied from referencesource Environment
+ internal static String GetStackTrace(Exception e, bool needFileInfo)
+ {
+ System.Diagnostics.StackTrace st;
+ if (e == null)
+ st = new System.Diagnostics.StackTrace(needFileInfo);
+ else
+ st = new System.Diagnostics.StackTrace(e, needFileInfo);
+
+ // Do not include a trailing newline for backwards compatibility
+ return st.ToString( System.Diagnostics.StackTrace.TraceFormat.Normal );
+ }
}
}
+++ /dev/null
-//
-// System.Exception.cs
-//
-// Author:
-// Miguel de Icaza (miguel@ximian.com)
-// Patrik Torstensson
-//
-// (C) Ximian, Inc. http://www.ximian.com
-// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System.Collections;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Reflection;
-using System.Text;
-using System.Runtime.InteropServices;
-using System.Runtime.CompilerServices;
-using System.Runtime.Serialization;
-using System.Security.Permissions;
-
-namespace System
-{
- [Serializable]
- [ComVisible(true)]
- [ComDefaultInterface (typeof (_Exception))]
- [ClassInterface (ClassInterfaceType.None)]
- [StructLayout (LayoutKind.Sequential)]
-#if MOBILE
- public class Exception : ISerializable
-#else
- public class Exception : ISerializable, _Exception
-#endif
- {
-#pragma warning disable 169, 649
- #region Sync with object-internals.h
- /* Stores the IPs and the generic sharing infos
- (vtable/MRGCTX) of the frames. */
- IntPtr [] trace_ips;
- Exception inner_exception;
- internal string _message;
- string help_link;
- string class_name;
- string stack_trace;
- // formerly known as remote_stack_trace (see #425512):
- string _remoteStackTraceString;
- int remote_stack_index;
- internal int hresult = -2146233088;
- string source;
- IDictionary _data;
- internal StackTrace[] captured_traces;
- IntPtr[] native_trace_ips;
- object dynamic_methods;
- #endregion
-#pragma warning restore 169, 649
-
- /* Don't add fields here, the runtime depends on the layout of subclasses */
-
- public Exception ()
- {
- }
-
- public Exception (string message)
- {
- this._message = message;
- }
-
- protected Exception (SerializationInfo info, StreamingContext context)
- {
- if (info == null)
- throw new ArgumentNullException ("info");
-
- class_name = info.GetString ("ClassName");
- _message = info.GetString ("Message");
- help_link = info.GetString ("HelpURL");
- stack_trace = info.GetString ("StackTraceString");
- _remoteStackTraceString = info.GetString ("RemoteStackTraceString");
- remote_stack_index = info.GetInt32 ("RemoteStackIndex");
- hresult = info.GetInt32 ("HResult");
- source = info.GetString ("Source");
- inner_exception = (Exception) info.GetValue ("InnerException", typeof (Exception));
-
- try {
- _data = (IDictionary) info.GetValue ("Data", typeof (IDictionary));
- } catch (SerializationException) {
- // member did not exist in .NET 1.x
- }
- }
-
- public Exception (string message, Exception innerException)
- {
- inner_exception = innerException;
- this._message = message;
- }
-
- public Exception InnerException {
- get { return inner_exception; }
- }
-
- public virtual string HelpLink {
- get { return help_link; }
- set { help_link = value; }
- }
-
- public int HResult {
- get { return hresult; }
- protected set { hresult = value; }
- }
-
- internal void SetErrorCode(int hr)
- {
- HResult = hr;
- }
-
- internal void SetMessage (string s)
- {
- _message = s;
- }
-
- internal void SetStackTrace (string s)
- {
- stack_trace = s;
- }
-
- string ClassName {
- get {
- if (class_name == null)
- class_name = GetType ().ToString ();
- return class_name;
- }
- }
-
- public virtual string Message {
- get {
- if (_message == null)
- _message = string.Format (Locale.GetText ("Exception of type '{0}' was thrown."),
- ClassName);
-
- return _message;
- }
- }
-
- [MonoTODO]
- protected event EventHandler<SafeSerializationEventArgs> SerializeObjectState {
- add {
- }
- remove {
- }
- }
-
- public virtual string Source {
- get {
- if (source == null) {
- StackTrace st = new StackTrace (this, true);
- if (st.FrameCount > 0) {
- StackFrame sf = st.GetFrame (0);
- if (st != null) {
- MethodBase method = sf.GetMethod ();
- if (method != null) {
- source = method.DeclaringType.Assembly.UnprotectedGetName ().Name;
- }
- }
- }
- }
-
- // source can be null
- return source;
- }
-
- set {
- source = value;
- }
- }
-
- public virtual string StackTrace {
- get {
- if (stack_trace != null)
- return stack_trace;
-
- if (trace_ips == null)
- /* Not thrown yet */
- return null;
-
- StackTrace st = new StackTrace (this, 0, true);
- return stack_trace = st.ToString ();
- }
- }
-
- public MethodBase TargetSite {
- get {
- StackTrace st = new StackTrace (this, true);
- if (st.FrameCount > 0)
- return st.GetFrame (0).GetMethod ();
-
- return null;
- }
- }
-
- public virtual IDictionary Data {
- get {
- if (_data == null) {
- // default to empty dictionary
- _data = new Dictionary<object, object> ();
- }
- return _data;
- }
- }
-
- public virtual Exception GetBaseException ()
- {
- Exception inner = inner_exception;
-
- while (inner != null)
- {
- if (inner.InnerException != null)
- inner = inner.InnerException;
- else
- return inner;
- }
-
- return this;
- }
-
- [SecurityPermission (SecurityAction.LinkDemand, SerializationFormatter = true)]
- public virtual void GetObjectData (SerializationInfo info, StreamingContext context)
- {
- if (info == null)
- throw new ArgumentNullException ("info");
-
- info.AddValue ("ClassName", ClassName);
- info.AddValue ("Message", _message);
- info.AddValue ("InnerException", inner_exception, typeof (Exception));
- info.AddValue ("HelpURL", help_link);
- info.AddValue ("StackTraceString", StackTrace);
- info.AddValue ("RemoteStackTraceString", _remoteStackTraceString);
- info.AddValue ("RemoteStackIndex", remote_stack_index);
- info.AddValue ("HResult", hresult);
- info.AddValue ("Source", Source);
- info.AddValue ("ExceptionMethod", null);
- info.AddValue ("Data", _data, typeof (IDictionary));
- }
-
- public override string ToString ()
- {
- System.Text.StringBuilder result = new System.Text.StringBuilder (ClassName);
- result.Append (": ").Append (Message);
-
- if (null != _remoteStackTraceString)
- result.Append (_remoteStackTraceString);
-
- if (inner_exception != null)
- {
- result.Append (" ---> ").Append (inner_exception.ToString ());
- result.Append (Environment.NewLine);
- result.Append (Locale.GetText (" --- End of inner exception stack trace ---"));
- }
-
- if (StackTrace != null)
- result.Append (Environment.NewLine).Append (StackTrace);
- return result.ToString();
- }
-
- internal Exception FixRemotingException ()
- {
- string message = (0 == remote_stack_index) ?
- Locale.GetText ("{0}{0}Server stack trace: {0}{1}{0}{0}Exception rethrown at [{2}]: {0}") :
- Locale.GetText ("{1}{0}{0}Exception rethrown at [{2}]: {0}");
- string tmp = String.Format (message, Environment.NewLine, StackTrace, remote_stack_index);
-
- _remoteStackTraceString = tmp;
- remote_stack_index++;
-
- stack_trace = null;
-
- return this;
- }
-
- // For ExceptionDispatchInfo
- internal void RestoreExceptionDispatchInfo (System.Runtime.ExceptionServices.ExceptionDispatchInfo exceptionDispatchInfo)
- {
- captured_traces = (StackTrace[]) exceptionDispatchInfo.BinaryStackTraceArray;
- trace_ips = null;
- stack_trace = null;
- }
-
- //
- // The documentation states that this is available in 1.x,
- // but it was not available (MemberRefing this would fail)
- // and it states the signature is `override sealed', but the
- // correct value is `newslot'
- //
- public new Type GetType ()
- {
- return base.GetType ();
- }
-
- internal enum ExceptionMessageKind
- {
- ThreadAbort = 1,
- ThreadInterrupted = 2,
- OutOfMemory = 3
- }
-
- internal static String GetMessageFromNativeResources (ExceptionMessageKind kind)
- {
- switch (kind) {
- case ExceptionMessageKind.ThreadAbort:
- return "";
- case ExceptionMessageKind.ThreadInterrupted:
- return "";
- case ExceptionMessageKind.OutOfMemory:
- return "Out of memory";
- }
- return "";
- }
- }
-}
}\r
}\r
\r
+ [Test]\r
+ public void CreateDirectoryRelativePath ()\r
+ {\r
+ var path = Path.Combine (TempFolder, "relativepath", "not_this_folder");\r
+ path = Path.Combine (path, "..");\r
+\r
+ var res = Directory.CreateDirectory (path);\r
+ Assert.AreEqual ("relativepath", res.ToString (), "#1");\r
+ Assert.IsTrue (Directory.Exists (Path.Combine (TempFolder, "relativepath")), "#2");\r
+ }\r
+\r
[Test]\r
public void Delete ()\r
{\r
Assert.IsFalse (arr.IsGenericParameter, "#8");
Assert.IsFalse (arr.IsGenericType, "#9");
Assert.IsFalse (arr.IsGenericTypeDefinition, "#10");
+ Assert.IsTrue (arr is TypeInfo, "#11");
}
[Test]
Assert.AreEqual ("F[]", arr.Name, "#21");
Assert.AreEqual (gparam, arr.GetElementType (), "#22");
+ Assert.IsTrue (arr is TypeInfo, "#23");
}
[Test]
Assert.AreEqual ("enum[]", arr.Name, "#21");
Assert.AreEqual (eb, arr.GetElementType (), "#22");
+ Assert.IsTrue (arr is TypeInfo, "#23");
}
}
public void Ctor ()
{
var cp = new CspParameters ();
- Assert.AreEqual (24, cp.ProviderType);
+ Assert.AreEqual (1, cp.ProviderType);
}
}
}
[Test] // bug #320950
public void TestDispose2 ()
{
- Timer t = new Timer (o => Callback (o), null, 10, 10);
+ Timer t = new Timer (o => DoNothing (o), null, 10, 10);
t.Dispose ();
t.Dispose ();
}
System/EmptyArray.cs
System/Environment.cs
System/EnvironmentVariableTarget.cs
-System/Exception.cs
System/GC.cs
System/GCCollectionMode.cs
System/GCNotificationStatus.cs
System.Security.Cryptography/RSAPKCS1SignatureFormatter.cs
System.Security.Cryptography/SHA1CryptoServiceProvider.cs
System.Security.Cryptography/TripleDESCryptoServiceProvider.cs
+System.Security.Cryptography.X509Certificates/INativeCertificateHelper.cs
System.Security.Cryptography.X509Certificates/X509Certificate.cs
System.Security.Cryptography.X509Certificates/X509Certificate20.cs
System.Security.Cryptography.X509Certificates/X509CertificateImpl.cs
../../../external/referencesource/mscorlib/system/entrypointnotfoundexception.cs
../../../external/referencesource/mscorlib/system/eventargs.cs
../../../external/referencesource/mscorlib/system/eventhandler.cs
+../../../external/referencesource/mscorlib/system/exception.cs
../../../external/referencesource/mscorlib/system/executionengineexception.cs
../../../external/referencesource/mscorlib/system/fieldaccessexception.cs
../../../external/referencesource/mscorlib/system/flagsattribute.cs
../../../external/referencesource/mscorlib/system/reflection/typeinfo.cs
../../../external/referencesource/mscorlib/system/reflection/emit/methodbuilder.cs
+../../../external/referencesource/mscorlib/system/reflection/emit/symboltype.cs
../../../external/referencesource/mscorlib/system/resources/__fastresourcecomparer.cs
../../../external/referencesource/mscorlib/system/resources/__hresults.cs
CommonCrypto/CryptorTransform.cs
CommonCrypto/FastCryptorTransform.cs
CommonCrypto/CorlibExtras.cs
-CommonCrypto/MD5CryptoServiceProvider.g.cs
-CommonCrypto/SHA1CryptoServiceProvider.g.cs
-CommonCrypto/SHA1CryptoServiceProvider.g.cs
-CommonCrypto/SHA1Managed.g.cs
-CommonCrypto/SHA256Managed.g.cs
-CommonCrypto/SHA384Managed.g.cs
-CommonCrypto/SHA512Managed.g.cs
-CommonCrypto/TripleDESCryptoServiceProvider.g.cs
-CommonCrypto/DESCryptoServiceProvider.g.cs
-CommonCrypto/RC2CryptoServiceProvider.g.cs
CommonCrypto/RijndaelManaged.cs
CommonCrypto/SecRandom.cs
CommonCrypto/RC4CommonCrypto.cs
-CommonCrypto/MD2Managed.g.cs
-CommonCrypto/MD4Managed.g.cs
System/Environment.iOS.cs
System/Guid.MonoTouch.cs
System/NotSupportedException.iOS.cs
CommonCrypto/CryptorTransform.cs
CommonCrypto/FastCryptorTransform.cs
CommonCrypto/CorlibExtras.cs
-CommonCrypto/MD5CryptoServiceProvider.g.cs
-CommonCrypto/SHA1CryptoServiceProvider.g.cs
-CommonCrypto/SHA1CryptoServiceProvider.g.cs
-CommonCrypto/SHA1Managed.g.cs
-CommonCrypto/SHA256Managed.g.cs
-CommonCrypto/SHA384Managed.g.cs
-CommonCrypto/SHA512Managed.g.cs
-CommonCrypto/TripleDESCryptoServiceProvider.g.cs
-CommonCrypto/DESCryptoServiceProvider.g.cs
-CommonCrypto/RC2CryptoServiceProvider.g.cs
CommonCrypto/RijndaelManaged.cs
CommonCrypto/SecRandom.cs
CommonCrypto/RC4CommonCrypto.cs
-CommonCrypto/MD2Managed.g.cs
-CommonCrypto/MD4Managed.g.cs
System/Environment.iOS.cs
System/Guid.MonoTouch.cs
System/NotSupportedException.iOS.cs
CommonCrypto/CryptorTransform.cs
CommonCrypto/FastCryptorTransform.cs
CommonCrypto/CorlibExtras.cs
-CommonCrypto/MD5CryptoServiceProvider.g.cs
-CommonCrypto/SHA1CryptoServiceProvider.g.cs
-CommonCrypto/SHA1CryptoServiceProvider.g.cs
-CommonCrypto/SHA1Managed.g.cs
-CommonCrypto/SHA256Managed.g.cs
-CommonCrypto/SHA384Managed.g.cs
-CommonCrypto/SHA512Managed.g.cs
-CommonCrypto/TripleDESCryptoServiceProvider.g.cs
-CommonCrypto/DESCryptoServiceProvider.g.cs
-CommonCrypto/RC2CryptoServiceProvider.g.cs
CommonCrypto/RijndaelManaged.cs
CommonCrypto/SecRandom.cs
CommonCrypto/RC4CommonCrypto.cs
-CommonCrypto/MD2Managed.g.cs
-CommonCrypto/MD4Managed.g.cs
System/Environment.iOS.cs
System/Guid.MonoTouch.cs
System/NotSupportedException.iOS.cs
CommonCrypto/CryptorTransform.cs
CommonCrypto/FastCryptorTransform.cs
CommonCrypto/CorlibExtras.cs
-CommonCrypto/MD5CryptoServiceProvider.g.cs
-CommonCrypto/SHA1CryptoServiceProvider.g.cs
-CommonCrypto/SHA1CryptoServiceProvider.g.cs
-CommonCrypto/SHA1Managed.g.cs
-CommonCrypto/SHA256Managed.g.cs
-CommonCrypto/SHA384Managed.g.cs
-CommonCrypto/SHA512Managed.g.cs
-CommonCrypto/TripleDESCryptoServiceProvider.g.cs
-CommonCrypto/DESCryptoServiceProvider.g.cs
-CommonCrypto/RC2CryptoServiceProvider.g.cs
CommonCrypto/RijndaelManaged.cs
CommonCrypto/SecRandom.cs
CommonCrypto/RC4CommonCrypto.cs
-CommonCrypto/MD2Managed.g.cs
-CommonCrypto/MD4Managed.g.cs
System/Environment.iOS.cs
System/Guid.MonoTouch.cs
System/NotSupportedException.iOS.cs
CommonCrypto/CryptorTransform.cs
CommonCrypto/FastCryptorTransform.cs
CommonCrypto/CorlibExtras.cs
-CommonCrypto/MD5CryptoServiceProvider.g.cs
-CommonCrypto/SHA1CryptoServiceProvider.g.cs
-CommonCrypto/SHA1CryptoServiceProvider.g.cs
-CommonCrypto/SHA1Managed.g.cs
-CommonCrypto/SHA256Managed.g.cs
-CommonCrypto/SHA384Managed.g.cs
-CommonCrypto/SHA512Managed.g.cs
-CommonCrypto/TripleDESCryptoServiceProvider.g.cs
-CommonCrypto/DESCryptoServiceProvider.g.cs
-CommonCrypto/RC2CryptoServiceProvider.g.cs
CommonCrypto/RijndaelManaged.cs
CommonCrypto/RC4CommonCrypto.cs
-CommonCrypto/MD2Managed.g.cs
-CommonCrypto/MD4Managed.g.cs
CoreFoundation/CFHelpers.cs
System.Security.Cryptography.X509Certificates/X509CertificateImplApple.cs
System.Security.Cryptography.X509Certificates/X509Helper.Apple.cs
-// CS0029: Cannot implicitly convert type `B [cs0029-26, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]' to `B [CS0029-26-lib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=36f3ae7e947792e3]'
+// CS0029: Cannot implicitly convert type `B [cs0029-26, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null -- *PATH*/cs0029-26.cs]' to `B [CS0029-26-lib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=36f3ae7e947792e3 -- *PATH*/CS0029-26-lib.dll]'
// Line: 16
// Compiler options: -r:R1=CS0029-26-lib.dll
public ExceptionStatement CurrentTryBlock { get; set; }
+ public TryCatch CurrentTryCatch { get; set; }
+
public LoopStatement EnclosingLoop { get; set; }
public LoopStatement EnclosingLoopOrSwitch { get; set; }
/// false if candidate ain't better
/// true if candidate is better than the current best match
/// </remarks>
- static bool BetterFunction (ResolveContext ec, Arguments args, MemberSpec candidate, AParametersCollection cparam, bool candidate_params,
+ bool BetterFunction (ResolveContext ec, Arguments args, MemberSpec candidate, AParametersCollection cparam, bool candidate_params,
MemberSpec best, AParametersCollection bparam, bool best_params)
{
AParametersCollection candidate_pd = ((IParametersMember) candidate).Parameters;
// for each argument, the conversion to 'ct' should be no worse than
// the conversion to 'bt'.
- if (result == 2)
- return false;
+ if (result == 2) {
+ //
+ // No optional parameters tie breaking rules for delegates overload resolution
+ //
+ if ((this.restrictions & Restrictions.CovariantDelegate) != 0)
+ return false;
+
+ better_at_least_one = false;
+
+ ++j;
+ while (j < args_count && !args [j++].IsDefaultArgument) ;
+
+ break;
+ }
// for at least one argument, the conversion to 'ct' should be better than
// the conversion to 'bt'.
return true;
//
- // Tie-breaking rules are applied only for equivalent parameter types
+ // LAMESPEC: Tie-breaking rules for not equivalent parameter types
//
if (!are_equivalent) {
//
- // LAMESPEC: A candidate with less default parameters is still better when there
+ // A candidate with no default parameters is still better when there
// is no better expression conversion
//
- if (candidate_pd.Count < best_pd.Count && !candidate_params && best_pd.FixedParameters [j].HasDefaultValue) {
- return true;
+ if (candidate_pd.Count < best_pd.Count) {
+ if (!candidate_params && !candidate_pd.FixedParameters [j - j].HasDefaultValue) {
+ return true;
+ }
+ } else if (candidate_pd.Count == best_pd.Count) {
+ if (candidate_params)
+ return false;
+
+ if (!candidate_pd.FixedParameters [j - 1].HasDefaultValue && best_pd.FixedParameters [j - 1].HasDefaultValue)
+ return true;
+
+ if (candidate_pd.FixedParameters [j - 1].HasDefaultValue && best_pd.HasParams)
+ return true;
}
return false;
var cand_param = candidate_pd.FixedParameters [j];
var best_param = best_pd.FixedParameters [j];
- if (cand_param.HasDefaultValue != best_param.HasDefaultValue)
+ if (cand_param.HasDefaultValue != best_param.HasDefaultValue && (!candidate_pd.HasParams || !best_pd.HasParams))
return cand_param.HasDefaultValue;
defaults_ambiguity = true;
args.Insert (0, new Argument (inst.Resolve (ec), mod));
}
} else { // is SimpleName
- if (ec.IsStatic) {
+ if (ec.IsStatic || ec.HasAny (ResolveContext.Options.FieldInitializerScope | ResolveContext.Options.BaseInitializer)) {
args.Insert (0, new Argument (new TypeOf (ec.CurrentType, loc).Resolve (ec), Argument.AType.DynamicTypeName));
} else {
args.Insert (0, new Argument (new This (loc).Resolve (ec)));
public override void Emit (EmitContext ec)
{
+ if (EmitOptimizedEmpty (ec))
+ return;
+
var await_field = EmitToFieldSource (ec);
if (await_field != null)
await_field.Emit (ec);
}
+ bool EmitOptimizedEmpty (EmitContext ec)
+ {
+ if (arguments.Count != 1 || dimensions != 1)
+ return false;
+
+ var c = arguments [0] as Constant;
+ if (c == null || !c.IsZeroInteger)
+ return false;
+
+ var m = ec.Module.PredefinedMembers.ArrayEmpty.Get ();
+ if (m == null || ec.CurrentType.MemberDefinition.DeclaringAssembly == m.DeclaringType.MemberDefinition.DeclaringAssembly)
+ return false;
+
+ m = m.MakeGenericMethod (ec.MemberContext, array_element_type);
+ ec.Emit (OpCodes.Call, m);
+ return true;
+ }
+
protected sealed override FieldExpr EmitToFieldSource (EmitContext ec)
{
if (first_emit != null) {
protected T machine_initializer;
int resume_pc;
ExceptionStatement inside_try_block;
+ TryCatch inside_catch_block;
protected YieldStatement (Expression expr, Location l)
{
machine_initializer = bc.CurrentAnonymousMethod as T;
inside_try_block = bc.CurrentTryBlock;
+ inside_catch_block = bc.CurrentTryCatch;
return true;
}
if (inside_try_block == null) {
resume_pc = machine_initializer.AddResumePoint (this);
} else {
- resume_pc = inside_try_block.AddResumePoint (this, resume_pc, machine_initializer);
+ resume_pc = inside_try_block.AddResumePoint (this, resume_pc, machine_initializer, inside_catch_block);
unwind_protect = true;
inside_try_block = null;
}
protected override bool DoFlowAnalysis (FlowAnalysisContext fc)
{
var res = stmt.FlowAnalysis (fc);
- parent = null;
+ parent_try_block = null;
return res;
}
{
bool ok;
- parent = bc.CurrentTryBlock;
+ parent_try_block = bc.CurrentTryBlock;
bc.CurrentTryBlock = this;
- using (bc.Set (ResolveContext.Options.TryScope)) {
+ if (stmt is TryCatch) {
ok = stmt.Resolve (bc);
+ } else {
+ using (bc.Set (ResolveContext.Options.TryScope)) {
+ ok = stmt.Resolve (bc);
+ }
}
- bc.CurrentTryBlock = parent;
+ bc.CurrentTryBlock = parent_try_block;
//
// Finally block inside iterator is called from MoveNext and
{
protected List<ResumableStatement> resume_points;
protected int first_resume_pc;
- protected ExceptionStatement parent;
+ protected ExceptionStatement parent_try_block;
+ protected int first_catch_resume_pc = -1;
protected ExceptionStatement (Location loc)
{
this.loc = loc;
}
- protected virtual void EmitBeginException (EmitContext ec)
- {
- ec.BeginExceptionBlock ();
- }
-
protected virtual void EmitTryBodyPrepare (EmitContext ec)
{
StateMachineInitializer state_machine = null;
ec.Emit (OpCodes.Stloc, state_machine.CurrentPC);
}
- EmitBeginException (ec);
+ //
+ // The resume points in catch section when this is try-catch-finally
+ //
+ if (IsRewrittenTryCatchFinally ()) {
+ ec.BeginExceptionBlock ();
+
+ if (first_catch_resume_pc >= 0) {
- if (resume_points != null) {
- ec.MarkLabel (resume_point);
+ ec.MarkLabel (resume_point);
+
+ // For normal control flow, we want to fall-through the Switch
+ // So, we use CurrentPC rather than the $PC field, and initialize it to an outside value above
+ ec.Emit (OpCodes.Ldloc, state_machine.CurrentPC);
+ ec.EmitInt (first_resume_pc + first_catch_resume_pc);
+ ec.Emit (OpCodes.Sub);
+
+ var labels = new Label [resume_points.Count - first_catch_resume_pc];
+ for (int i = 0; i < labels.Length; ++i)
+ labels [i] = resume_points [i + first_catch_resume_pc].PrepareForEmit (ec);
+ ec.Emit (OpCodes.Switch, labels);
+ }
+ }
+
+ ec.BeginExceptionBlock ();
+
+ //
+ // The resume points for try section
+ //
+ if (resume_points != null && first_catch_resume_pc != 0) {
+ if (first_catch_resume_pc < 0)
+ ec.MarkLabel (resume_point);
// For normal control flow, we want to fall-through the Switch
// So, we use CurrentPC rather than the $PC field, and initialize it to an outside value above
ec.EmitInt (first_resume_pc);
ec.Emit (OpCodes.Sub);
- Label[] labels = new Label[resume_points.Count];
- for (int i = 0; i < resume_points.Count; ++i)
+ var labels = new Label[resume_points.Count - System.Math.Max (first_catch_resume_pc, 0)];
+ for (int i = 0; i < labels.Length; ++i)
labels[i] = resume_points[i].PrepareForEmit (ec);
ec.Emit (OpCodes.Switch, labels);
}
}
- public virtual int AddResumePoint (ResumableStatement stmt, int pc, StateMachineInitializer stateMachine)
+ bool IsRewrittenTryCatchFinally ()
{
- if (parent != null) {
- // TODO: MOVE to virtual TryCatch
- var tc = this as TryCatch;
- var s = tc != null && tc.IsTryCatchFinally ? stmt : this;
+ var tf = this as TryFinally;
+ if (tf == null)
+ return false;
+
+ var tc = tf.Statement as TryCatch;
+ if (tc == null)
+ return false;
- pc = parent.AddResumePoint (s, pc, stateMachine);
+ return tf.FinallyBlock.HasAwait || tc.HasClauseWithAwait;
+ }
+
+ public int AddResumePoint (ResumableStatement stmt, int pc, StateMachineInitializer stateMachine, TryCatch catchBlock)
+ {
+ if (parent_try_block != null) {
+ pc = parent_try_block.AddResumePoint (this, pc, stateMachine, catchBlock);
} else {
pc = stateMachine.AddResumePoint (this);
}
if (pc != first_resume_pc + resume_points.Count)
throw new InternalErrorException ("missed an intervening AddResumePoint?");
+ var tf = this as TryFinally;
+ if (tf != null && tf.Statement == catchBlock && first_catch_resume_pc < 0) {
+ first_catch_resume_pc = resume_points.Count;
+ }
+
resume_points.Add (stmt);
return pc;
}
return ok;
}
- protected override void EmitBeginException (EmitContext ec)
- {
- if (fini.HasAwait && stmt is TryCatch)
- ec.BeginExceptionBlock ();
-
- base.EmitBeginException (ec);
- }
-
protected override void EmitTryBody (EmitContext ec)
{
if (fini.HasAwait) {
ec.TryFinallyUnwind.Add (this);
stmt.Emit (ec);
- if (stmt is TryCatch)
+ if (first_catch_resume_pc < 0 && stmt is TryCatch)
ec.EndExceptionBlock ();
ec.TryFinallyUnwind.Remove (this);
}
}
+ public bool HasClauseWithAwait {
+ get {
+ return catch_sm != null;
+ }
+ }
+
public bool IsTryCatchFinally {
get {
return inside_try_finally;
bool ok;
using (bc.Set (ResolveContext.Options.TryScope)) {
- parent = bc.CurrentTryBlock;
+
+ parent_try_block = bc.CurrentTryBlock;
if (IsTryCatchFinally) {
ok = Block.Resolve (bc);
using (bc.Set (ResolveContext.Options.TryWithCatchScope)) {
bc.CurrentTryBlock = this;
ok = Block.Resolve (bc);
- bc.CurrentTryBlock = parent;
+ bc.CurrentTryBlock = parent_try_block;
}
}
}
+ var prev_catch = bc.CurrentTryCatch;
+ bc.CurrentTryCatch = this;
+
for (int i = 0; i < clauses.Count; ++i) {
var c = clauses[i];
}
}
+ bc.CurrentTryCatch = prev_catch;
+
return base.Resolve (bc) && ok;
}
}
}
- if (!inside_try_finally)
+ if (state_variable == null) {
+ if (!inside_try_finally)
+ ec.EndExceptionBlock ();
+ } else {
ec.EndExceptionBlock ();
- if (state_variable != null) {
ec.Emit (OpCodes.Ldloc, state_variable);
var labels = new Label [catch_sm.Count + 1];
}
fc.DefiniteAssignment = try_fc ?? start_fc;
- parent = null;
+ parent_try_block = null;
return res;
}
public readonly PredefinedType SecurityAction;
public readonly PredefinedType Dictionary;
public readonly PredefinedType Hashtable;
+ public readonly PredefinedType Array;
+
public readonly TypeSpec[] SwitchUserTypes;
//
SecurityAction = new PredefinedType (module, MemberKind.Enum, "System.Security.Permissions", "SecurityAction");
Dictionary = new PredefinedType (module, MemberKind.Class, "System.Collections.Generic", "Dictionary", 2);
Hashtable = new PredefinedType (module, MemberKind.Class, "System.Collections", "Hashtable");
+ Array = new PredefinedType (module, MemberKind.Class, "System", "Array");
Expression = new PredefinedType (module, MemberKind.Class, "System.Linq.Expressions", "Expression");
ExpressionGeneric = new PredefinedType (module, MemberKind.Class, "System.Linq.Expressions", "Expression", 1);
class PredefinedMembers
{
public readonly PredefinedMember<MethodSpec> ActivatorCreateInstance;
+ public readonly PredefinedMember<MethodSpec> ArrayEmpty;
public readonly PredefinedMember<MethodSpec> AsyncTaskMethodBuilderCreate;
public readonly PredefinedMember<MethodSpec> AsyncTaskMethodBuilderStart;
public readonly PredefinedMember<MethodSpec> AsyncTaskMethodBuilderSetResult;
ActivatorCreateInstance = new PredefinedMember<MethodSpec> (module, types.Activator,
MemberFilter.Method ("CreateInstance", 1, ParametersCompiled.EmptyReadOnlyParameters, null));
+ ArrayEmpty = new PredefinedMember<MethodSpec> (module, types.Array,
+ MemberFilter.Method ("Empty", 1, ParametersCompiled.EmptyReadOnlyParameters, null));
+
AsyncTaskMethodBuilderCreate = new PredefinedMember<MethodSpec> (module, types.AsyncTaskMethodBuilder,
MemberFilter.Method ("Create", 0, ParametersCompiled.EmptyReadOnlyParameters, types.AsyncTaskMethodBuilder.TypeSpec));
public string GetSignatureForErrorIncludingAssemblyName ()
{
- return string.Format ("{0} [{1}]", GetSignatureForError (), MemberDefinition.DeclaringAssembly.FullName);
+ var imported = MemberDefinition.DeclaringAssembly as ImportedAssemblyDefinition;
+
+ var location = imported != null ?
+ System.IO.Path.GetFullPath (imported.Location) :
+ ((MemberCore)MemberDefinition).Location.NameFullPath;
+
+ return string.Format ("{0} [{1} -- {2}]", GetSignatureForError (),
+ MemberDefinition.DeclaringAssembly.FullName,
+ location);
}
protected virtual string GetTypeNameSignature ()
--- /dev/null
+using System;
+
+public class A
+{
+ public A (Action action)
+ {
+ }
+}
+
+public class B : A
+{
+ public B ()
+ : base (() => {
+ dynamic d = 1;
+ Test (d);
+ })
+ {
+ }
+
+ static decimal Test (dynamic arg)
+ {
+ return 3m;
+ }
+}
+
+public class B2
+{
+ public Action a = () => {
+ dynamic d = 1;
+ Test (d);
+ };
+
+ static decimal Test (dynamic arg)
+ {
+ return 3m;
+ }
+}
+
+class M
+{
+ static void Main ()
+ {
+ new B ();
+ new B2 ();
+ }
+}
\ No newline at end of file
if (Test_5 () != 0)
return 5;
- if (Test_6 () != 0)
+ if (Test_6 () != 1)
return 6;
- if (Test_7 (false) != 0)
+ if (Test_7 (false) != 1)
return 7;
if (Test_8 (typeof (bool)) != 0)
--- /dev/null
+using System;
+
+public class Program
+{
+ static int Arg (uint a, long b)
+ {
+ return 2;
+ }
+
+ static int Arg (int a, ulong b, int c = 9)
+ {
+ return 3;
+ }
+
+ static int Arg_2 (uint a, long b, params int[] arg)
+ {
+ return 2;
+ }
+
+ static int Arg_2 (int a, ulong b, int c = 0)
+ {
+ return 3;
+ }
+
+ static int Arg_3 (int a, long b, params int[] arg)
+ {
+ return 2;
+ }
+
+ static int Arg_3 (uint a, ulong b, int c = 0, int d = 1, params int[] oo)
+ {
+ return 3;
+ }
+
+ public static int Main ()
+ {
+ if (Arg (0, 0) != 2)
+ return 1;
+
+ if (Arg (0, 0, 0) != 3)
+ return 2;
+
+ if (Arg_2 (0, 0) != 3)
+ return 3;
+
+ if (Arg_2 (0, 0, 0, 0) != 2)
+ return 4;
+
+ if (Arg_3 (0, 0) != 2)
+ return 5;
+
+ if (Arg_3 (0, 0, 0) != 2)
+ return 6;
+
+ if (Arg_3 (0, 0, 0, 0) != 2)
+ return 7;
+
+ if (Arg_3 (0, 0, 0, 0, 0) != 2)
+ return 8;
+
+ if (Arg_3 (0, 0, 0, 0, 0) != 2)
+ return 9;
+
+ return 0;
+ }
+}
--- /dev/null
+using System;
+
+class Test1
+{
+ static object Foo (int arg = 1, int arg2 = 2)
+ {
+ return null;
+ }
+
+ static object Foo (object arg, object arg2)
+ {
+ return null;
+ }
+
+ public static void Main ()
+ {
+ Func<int, int, object> o = Foo;
+ }
+}
\ No newline at end of file
--- /dev/null
+using System;
+
+class X
+{
+ static int Foo (params X[] p)
+ {
+ return 1;
+ }
+
+ static int Foo (object p)
+ {
+ return 0;
+ }
+
+ static int Main ()
+ {
+ if (Foo ((X[]) null) != 1)
+ return 1;
+
+ return 0;
+ }
+}
\ No newline at end of file
--- /dev/null
+using System;
+using System.Threading.Tasks;
+
+class Program
+{
+ static int count;
+
+ static int Main ()
+ {
+ Test (false).Wait ();
+ Console.WriteLine (count);
+ if (count != 110011)
+ return 1;
+
+ count = 0;
+ Test (true).Wait ();
+ Console.WriteLine (count);
+ if (count != 111101)
+ return 2;
+
+ count = 0;
+ Test2 (false).Wait ();
+ Console.WriteLine (count);
+ if (count != 11)
+ return 3;
+
+ count = 0;
+ Test2 (true).Wait ();
+ Console.WriteLine (count);
+ if (count != 1101)
+ return 4;
+
+ return 0;
+ }
+
+ static async Task Test (bool throwTest)
+ {
+ try {
+ count += 1;
+ await Task.Delay (10);
+
+ if (throwTest)
+ throw new ApplicationException ();
+
+ count += 10;
+ } catch (ApplicationException) {
+ count += 100;
+ await Task.Delay (10);
+ count += 1000;
+ } finally {
+ count += 10000;
+ await Task.Delay (10);
+ count += 100000;
+ }
+ }
+
+ static async Task Test2 (bool throwTest)
+ {
+ try {
+ count += 1;
+ await Task.Delay (10);
+
+ if (throwTest)
+ throw new ApplicationException ();
+
+ count += 10;
+ } catch (ApplicationException) {
+ count += 100;
+ await Task.Delay (10);
+ count += 1000;
+ } finally {
+ }
+ }
+}
<entry il="0x0" row="20" col="2" file_ref="1" hidden="false" />
<entry il="0x1" row="21" col="3" file_ref="1" hidden="false" />
<entry il="0x11" row="21" col="59" file_ref="1" hidden="false" />
- <entry il="0x1c" row="21" col="53" file_ref="1" hidden="false" />
- <entry il="0x2c" row="21" col="47" file_ref="1" hidden="false" />
- <entry il="0x32" row="22" col="2" file_ref="1" hidden="false" />
+ <entry il="0x1b" row="21" col="53" file_ref="1" hidden="false" />
+ <entry il="0x2a" row="21" col="47" file_ref="1" hidden="false" />
+ <entry il="0x30" row="22" col="2" file_ref="1" hidden="false" />
</sequencepoints>
<locals>
<entry name="e" il_index="0" scope_ref="0" />
<test name="dtest-003.cs">
<type name="AssertDynamicObject">
<method name="System.Dynamic.DynamicMetaObject GetFakeMetaObject(System.Object)" attrs="129">
- <size>130</size>
+ <size>129</size>
</method>
<method name="System.Dynamic.DynamicMetaObject BindBinaryOperation(System.Dynamic.BinaryOperationBinder, System.Dynamic.DynamicMetaObject)" attrs="198">
<size>70</size>
</type>
<type name="Tester+<GetIndex_3>c__AnonStorey1">
<method name="Void <>m__0(System.Dynamic.GetIndexBinder, System.Object[])" attrs="131">
- <size>93</size>
+ <size>92</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
</type>
<type name="Tester+<InvokeMember_2>c__AnonStorey2">
<method name="Void <>m__0(System.Dynamic.InvokeMemberBinder, System.Object[])" attrs="131">
- <size>110</size>
+ <size>109</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
</type>
<type name="Tester+<InvokeMember_6>c__AnonStorey3">
<method name="Void <>m__0(System.Dynamic.InvokeMemberBinder, System.Object[])" attrs="131">
- <size>120</size>
+ <size>119</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
</type>
<type name="Tester+<SetIndex_3>c__AnonStorey4">
<method name="Void <>m__0(System.Dynamic.SetIndexBinder, System.Object[], System.Object)" attrs="131">
- <size>120</size>
+ <size>119</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
<size>67</size>
</method>
<method name="Void <GetIndex_1>m__25(System.Dynamic.GetIndexBinder, System.Object[])" attrs="145">
- <size>93</size>
+ <size>92</size>
</method>
<method name="Void <GetIndex_2>m__26(System.Dynamic.GetIndexBinder, System.Object[])" attrs="145">
- <size>112</size>
+ <size>111</size>
</method>
<method name="System.Object <GetMember_1>m__27(System.Dynamic.GetMemberBinder)" attrs="145">
<size>75</size>
</method>
<method name="Void <Invoke_1>m__28(System.Dynamic.InvokeBinder, System.Object[])" attrs="145">
- <size>102</size>
+ <size>101</size>
</method>
<method name="Void <Invoke_2>m__29(System.Dynamic.InvokeBinder, System.Object[])" attrs="145">
- <size>74</size>
+ <size>72</size>
</method>
<method name="Void <Invoke_4>m__2A(System.Dynamic.InvokeBinder, System.Object[])" attrs="145">
<size>128</size>
</method>
<method name="Void <Invoke_5>m__2B(System.Dynamic.InvokeBinder, System.Object[])" attrs="145">
- <size>92</size>
+ <size>91</size>
</method>
<method name="Void <Invoke_5>m__2C(System.Object)" attrs="145">
<size>94</size>
</method>
<method name="Void <Invoke_6>m__2D(System.Dynamic.InvokeBinder, System.Object[])" attrs="145">
- <size>93</size>
+ <size>92</size>
</method>
<method name="Void <InvokeMember_1>m__2E(System.Dynamic.InvokeMemberBinder, System.Object[])" attrs="145">
- <size>111</size>
+ <size>110</size>
</method>
<method name="Void <InvokeMember_3>m__2F(System.Dynamic.InvokeMemberBinder, System.Object[])" attrs="145">
- <size>112</size>
+ <size>111</size>
</method>
<method name="Void <InvokeMember_4>m__30(System.Dynamic.InvokeMemberBinder, System.Object[])" attrs="145">
- <size>111</size>
+ <size>110</size>
</method>
<method name="Void <InvokeMember_7>m__31(System.Dynamic.InvokeMemberBinder, System.Object[])" attrs="145">
- <size>91</size>
+ <size>89</size>
</method>
<method name="Void <InvokeMember_8>m__32(System.Dynamic.InvokeMemberBinder, System.Object[])" attrs="145">
- <size>112</size>
+ <size>111</size>
</method>
<method name="Void <SetIndex_1>m__33(System.Dynamic.SetIndexBinder, System.Object[], System.Object)" attrs="145">
- <size>125</size>
+ <size>124</size>
</method>
<method name="Void <SetIndex_2>m__34(System.Dynamic.SetIndexBinder, System.Object[], System.Object)" attrs="145">
- <size>140</size>
+ <size>139</size>
</method>
<method name="Void <SetMember_1>m__35(System.Dynamic.SetMemberBinder, System.Object)" attrs="145">
<size>102</size>
<test name="dtest-044.cs">
<type name="C">
<method name="Int32 Main()" attrs="150">
- <size>868</size>
+ <size>867</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
</method>
</type>
</test>
+ <test name="dtest-064.cs">
+ <type name="A">
+ <method name="Void .ctor(Action)" attrs="6278">
+ <size>8</size>
+ </method>
+ </type>
+ <type name="B">
+ <method name="System.Decimal Test(System.Object)" attrs="145">
+ <size>15</size>
+ </method>
+ <method name="Void <B>m__0()" attrs="145">
+ <size>113</size>
+ </method>
+ <method name="Void .ctor()" attrs="6278">
+ <size>37</size>
+ </method>
+ </type>
+ <type name="B2">
+ <method name="System.Decimal Test(System.Object)" attrs="145">
+ <size>15</size>
+ </method>
+ <method name="Void <a>m__0()" attrs="145">
+ <size>113</size>
+ </method>
+ <method name="Void .ctor()" attrs="6278">
+ <size>42</size>
+ </method>
+ </type>
+ <type name="M">
+ <method name="Void Main()" attrs="145">
+ <size>14</size>
+ </method>
+ <method name="Void .ctor()" attrs="6278">
+ <size>7</size>
+ </method>
+ </type>
+ </test>
<test name="dtest-anontype-01.cs">
<type name="C">
<method name="Void Main()" attrs="150">
<size>2</size>
</method>
<method name="Void Main()" attrs="150">
- <size>383</size>
+ <size>381</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
<size>23</size>
</method>
<method name="Int32 Main()" attrs="150">
- <size>213</size>
+ <size>212</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
<size>84</size>
</method>
<method name="Void .ctor()" attrs="6278">
- <size>20</size>
+ <size>19</size>
</method>
<method name="Void .ctor(E[])" attrs="6278">
<size>15</size>
</type>
<type name="ExtensibleTester`1[U]">
<method name="Void Direct()" attrs="134">
- <size>25</size>
+ <size>24</size>
</method>
<method name="Void .ctor(U)" attrs="6278">
<size>15</size>
</type>
<type name="Crash">
<method name="Void Main()" attrs="150">
- <size>15</size>
+ <size>14</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
</type>
<type name="Tests">
<method name="Void Main()" attrs="150">
- <size>22</size>
+ <size>21</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
</type>
<type name="Tests">
<method name="Void Main()" attrs="150">
- <size>39</size>
+ <size>38</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
<test name="gtest-340.cs">
<type name="Tests">
<method name="T[] FindAll[T](T[], System.Predicate`1[T])" attrs="150">
- <size>15</size>
+ <size>14</size>
</method>
<method name="Boolean ProtectedOnly(System.Reflection.MemberInfo)" attrs="129">
<size>10</size>
<size>16</size>
</method>
<method name="Int32 Main()" attrs="150">
- <size>25</size>
+ <size>24</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
<size>2</size>
</method>
<method name="Int32 Main()" attrs="150">
- <size>189</size>
+ <size>187</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
</type>
<type name="TestIssue.Program">
<method name="Int32 Main()" attrs="150">
- <size>32</size>
+ <size>31</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
</type>
<type name="Base">
<method name="System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()" attrs="481">
- <size>20</size>
+ <size>19</size>
</method>
</type>
</test>
<size>10</size>
</method>
<method name="Int32 Main()" attrs="150">
- <size>51</size>
+ <size>50</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
<size>7</size>
</method>
<method name="Int32 Main()" attrs="150">
- <size>37</size>
+ <size>36</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
<size>25</size>
</method>
<method name="Int32 Main()" attrs="150">
- <size>27</size>
+ <size>26</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
<test name="gtest-495.cs">
<type name="Repro">
<method name="Void Main()" attrs="150">
- <size>13</size>
+ <size>12</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
<size>2</size>
</method>
<method name="Void Test()" attrs="134">
- <size>38</size>
+ <size>37</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
</type>
<type name="C">
<method name="Int32 Main()" attrs="150">
- <size>80</size>
+ <size>78</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
<size>2</size>
</method>
<method name="Void Main()" attrs="150">
- <size>51</size>
+ <size>48</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
</type>
<type name="X2">
<method name="Void Main()" attrs="150">
- <size>24</size>
+ <size>22</size>
</method>
<method name="Void Foo[T1,T2](T2[])" attrs="145">
<size>9</size>
<size>42</size>
</method>
<method name="System.Linq.Expressions.Expression`1[System.Func`1[System.Func`1[System.Boolean]]] GetEvent()" attrs="134">
- <size>41</size>
+ <size>40</size>
</method>
<method name="Void set_MyTypeProperty(MyType)" attrs="2182">
<size>9</size>
<size>244</size>
</method>
<method name="Void ArrayIndexTest_5()" attrs="129">
- <size>109</size>
+ <size>108</size>
</method>
<method name="Void ArrayIndexTest_6()" attrs="129">
<size>123</size>
</method>
<method name="Void ArrayIndexTest_7()" attrs="129">
- <size>127</size>
+ <size>126</size>
</method>
<method name="Void ArrayLengthTest()" attrs="129">
- <size>100</size>
+ <size>99</size>
</method>
<method name="Void ArrayLengthTest_2()" attrs="129">
<size>92</size>
<size>196</size>
</method>
<method name="Void CallTest_4()" attrs="129">
- <size>110</size>
+ <size>108</size>
</method>
<method name="Void CallTest_5()" attrs="129">
<size>100</size>
</method>
<method name="Void CallTest_6()" attrs="129">
- <size>71</size>
+ <size>70</size>
</method>
<method name="Void CallTest_7()" attrs="129">
<size>125</size>
<size>184</size>
</method>
<method name="Void ConditionTest_5()" attrs="129">
- <size>108</size>
+ <size>107</size>
</method>
<method name="Void ConstantTest()" attrs="129">
- <size>60</size>
+ <size>59</size>
</method>
<method name="Void ConstantTest_2()" attrs="129">
- <size>63</size>
+ <size>62</size>
</method>
<method name="Void ConstantTest_3()" attrs="129">
- <size>55</size>
+ <size>54</size>
</method>
<method name="Void ConstantTest_4()" attrs="129">
- <size>45</size>
+ <size>44</size>
</method>
<method name="Void ConstantTest_5()" attrs="129">
- <size>60</size>
+ <size>59</size>
</method>
<method name="Void ConstantTest_6()" attrs="129">
- <size>68</size>
+ <size>67</size>
</method>
<method name="Void ConstantTest_7()" attrs="129">
- <size>63</size>
+ <size>62</size>
</method>
<method name="Void ConstantTest_8()" attrs="129">
- <size>73</size>
+ <size>72</size>
</method>
<method name="Void ConstantTest_9()" attrs="129">
- <size>73</size>
+ <size>72</size>
</method>
<method name="Void ConstantTest_10()" attrs="129">
- <size>73</size>
+ <size>72</size>
</method>
<method name="Void ConstantTest_11()" attrs="129">
- <size>60</size>
+ <size>59</size>
</method>
<method name="Void ConstantTest_13()" attrs="129">
- <size>60</size>
+ <size>59</size>
</method>
<method name="Void ConstantTest_14()" attrs="129">
- <size>73</size>
+ <size>72</size>
</method>
<method name="Void ConstantTest_15()" attrs="129">
- <size>63</size>
+ <size>62</size>
</method>
<method name="Void ConvertTest()" attrs="129">
<size>83</size>
<size>119</size>
</method>
<method name="Void ConvertTest_9()" attrs="129">
- <size>98</size>
+ <size>97</size>
</method>
<method name="Void ConvertTest_10()" attrs="129">
<size>181</size>
<size>102</size>
</method>
<method name="Void ConvertTest_12()" attrs="129">
- <size>141</size>
+ <size>140</size>
</method>
<method name="Void ConvertTest_13()" attrs="129">
<size>87</size>
<size>170</size>
</method>
<method name="Void InvokeTest()" attrs="129">
- <size>91</size>
+ <size>90</size>
</method>
<method name="Void InvokeTest_2()" attrs="129">
<size>139</size>
</method>
<method name="Void LambdaTest()" attrs="129">
- <size>90</size>
+ <size>89</size>
</method>
<method name="Void LeftShiftTest()" attrs="129">
<size>156</size>
<size>170</size>
</method>
<method name="Void ListInitTest()" attrs="129">
- <size>405</size>
+ <size>404</size>
</method>
<method name="Void ListInitTest_2()" attrs="129">
<size>293</size>
</method>
<method name="Void MemberAccessTest()" attrs="129">
- <size>133</size>
+ <size>132</size>
</method>
<method name="Void MemberAccessTest_2()" attrs="129">
- <size>64</size>
+ <size>63</size>
</method>
<method name="Void MemberAccessTest_3()" attrs="129">
- <size>114</size>
+ <size>113</size>
</method>
<method name="Void MemberAccessTest_4()" attrs="129">
- <size>92</size>
+ <size>91</size>
</method>
<method name="Void MemberAccessTest_5()" attrs="129">
<size>40</size>
</method>
<method name="Void MemberAccessTest_6()" attrs="129">
- <size>105</size>
+ <size>104</size>
</method>
<method name="Void MemberAccessTest_7()" attrs="129">
<size>110</size>
</method>
<method name="Void MemberAccessTest_8()" attrs="129">
- <size>64</size>
+ <size>63</size>
</method>
<method name="Void MemberAccessTest_9()" attrs="129">
- <size>92</size>
+ <size>91</size>
</method>
<method name="Void MemberInitTest()" attrs="129">
- <size>303</size>
+ <size>302</size>
</method>
<method name="Void MemberInitTest_2()" attrs="129">
- <size>251</size>
+ <size>250</size>
</method>
<method name="Void MemberInitTest_3()" attrs="129">
<size>125</size>
</method>
<method name="Void MemberInitTest_4()" attrs="129">
- <size>67</size>
+ <size>65</size>
</method>
<method name="Void MemberInitTest_5()" attrs="129">
- <size>119</size>
+ <size>117</size>
</method>
<method name="Void ModuloTest()" attrs="129">
<size>101</size>
<size>89</size>
</method>
<method name="Void NewArrayInitTest()" attrs="129">
- <size>93</size>
+ <size>92</size>
</method>
<method name="Void NewArrayInitTest_2()" attrs="129">
- <size>65</size>
+ <size>62</size>
</method>
<method name="Void NewArrayInitTest_3()" attrs="129">
<size>137</size>
</method>
<method name="Void NewArrayInitTest_4()" attrs="129">
- <size>121</size>
+ <size>120</size>
</method>
<method name="Void NewArrayInitTest_5()" attrs="129">
- <size>159</size>
+ <size>158</size>
</method>
<method name="Void NewArrayInitTest_6()" attrs="129">
- <size>104</size>
+ <size>103</size>
</method>
<method name="Void NewArrayBoundsTest()" attrs="129">
- <size>124</size>
+ <size>123</size>
</method>
<method name="Void NewArrayBoundsTest_2()" attrs="129">
- <size>124</size>
+ <size>123</size>
</method>
<method name="Void NewArrayBoundsTest_3()" attrs="129">
- <size>86</size>
+ <size>85</size>
</method>
<method name="Void NewArrayBoundsTest_4()" attrs="129">
- <size>83</size>
+ <size>82</size>
</method>
<method name="Void NewTest()" attrs="129">
- <size>94</size>
+ <size>93</size>
</method>
<method name="Void NewTest_2()" attrs="129">
- <size>62</size>
+ <size>61</size>
</method>
<method name="Void NewTest_3()" attrs="129">
- <size>99</size>
+ <size>98</size>
</method>
<method name="Void NewTest_4()" attrs="129">
<size>253</size>
</method>
<method name="Void NewTest_5()" attrs="129">
- <size>376</size>
+ <size>375</size>
</method>
<method name="Void NewTest_6()" attrs="129">
- <size>183</size>
+ <size>182</size>
</method>
<method name="Void NewTest_7()" attrs="129">
- <size>54</size>
+ <size>53</size>
</method>
<method name="Void NotTest()" attrs="129">
<size>71</size>
<size>74</size>
</method>
<method name="Void ParameterTest_2()" attrs="129">
- <size>76</size>
+ <size>74</size>
</method>
<method name="Void ParameterTest_3()" attrs="129">
<size>74</size>
<size>101</size>
</method>
<method name="Void QuoteTest()" attrs="129">
- <size>86</size>
+ <size>84</size>
</method>
<method name="Void QuoteTest_2()" attrs="129">
- <size>100</size>
+ <size>99</size>
</method>
<method name="Void RightShiftTest()" attrs="129">
<size>153</size>
<size>81</size>
</method>
<method name="Void TypeIsTest_5()" attrs="129">
- <size>75</size>
+ <size>74</size>
</method>
<method name="Void TypeIsTest_6()" attrs="129">
<size>112</size>
<size>12</size>
</method>
<method name="Void NewTest_8()" attrs="129">
- <size>64</size>
+ <size>63</size>
</method>
<method name="Void CallTest_10()" attrs="129">
- <size>137</size>
+ <size>136</size>
</method>
</type>
</test>
<size>2</size>
</method>
<method name="System.String Param(System.String)" attrs="145">
- <size>122</size>
+ <size>121</size>
</method>
<method name="Int32 Main()" attrs="150">
<size>173</size>
</type>
<type name="C">
<method name="Int32 Main()" attrs="150">
- <size>495</size>
+ <size>490</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
<size>48</size>
</method>
<method name="Int32 Main()" attrs="150">
- <size>358</size>
+ <size>357</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
<test name="gtest-etree-06.cs">
<type name="Test">
<method name="Int32 Main()" attrs="150">
- <size>53</size>
+ <size>52</size>
</method>
<method name="Int32 Value()" attrs="145">
<size>10</size>
<size>2</size>
</method>
<method name="Int32 TestInstance()" attrs="129">
- <size>337</size>
+ <size>336</size>
</method>
<method name="Int32 Main()" attrs="150">
- <size>580</size>
+ <size>577</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
<size>11</size>
</method>
<method name="Int32 Goo(Boolean)" attrs="134">
- <size>231</size>
+ <size>228</size>
</method>
<method name="Int32 Main()" attrs="150">
<size>22</size>
<test name="gtest-etree-09.cs">
<type name="Mono.C">
<method name="Int32 Main()" attrs="150">
- <size>296</size>
+ <size>294</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
</type>
<type name="Foo`1[T]">
<method name="Boolean ContainsAll[U](System.Collections.Generic.IEnumerable`1[U])" attrs="134">
- <size>200</size>
+ <size>199</size>
</method>
</type>
</test>
</type>
<type name="Test">
<method name="Void Invalid(Int32)" attrs="134">
- <size>125</size>
+ <size>124</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
<size>19</size>
</method>
<method name="Boolean MoveNext()" attrs="486">
- <size>148</size>
+ <size>147</size>
</method>
<method name="Void Dispose()" attrs="486">
<size>15</size>
<size>33</size>
</method>
<method name="T Value[T]()" attrs="145">
- <size>86</size>
+ <size>85</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
</type>
<type name="FieldInfoBug.GenericClass`1[T]">
<method name="Void .ctor(String)" attrs="6278">
- <size>59</size>
+ <size>58</size>
</method>
</type>
<type name="FieldInfoBug.GenericClass`1+<GenericClass>c__AnonStorey0[T]">
</type>
<type name="NotifyingPropertyTest">
<method name="Void CreateDependent_NotifierNull()" attrs="134">
- <size>59</size>
+ <size>57</size>
</method>
<method name="Void CreateDependent_DependentsNull()" attrs="134">
- <size>84</size>
+ <size>83</size>
</method>
<method name="Void Main()" attrs="150">
<size>2</size>
</type>
<type name="A`1+B`1[TA,TB]">
<method name="Void foo()" attrs="150">
- <size>40</size>
+ <size>39</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
<size>8</size>
</method>
<method name="Int32 Main()" attrs="150">
- <size>1210</size>
+ <size>1204</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>19</size>
<test name="gtest-etree-28.cs">
<type name="Repro">
<method name="Void UseField()" attrs="129">
- <size>70</size>
+ <size>69</size>
</method>
<method name="Void TakeExpression(System.Linq.Expressions.Expression`1[System.Action])" attrs="129">
<size>2</size>
<test name="gtest-exmethod-20.cs">
<type name="Outer.Inner.Test">
<method name="Void M(I)" attrs="145">
- <size>14</size>
+ <size>13</size>
</method>
<method name="Void Main()" attrs="150">
<size>2</size>
<test name="gtest-exmethod-27.cs">
<type name="Bar.Program">
<method name="Void Main()" attrs="150">
- <size>18</size>
+ <size>17</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
</type>
<type name="A">
<method name="Void Main()" attrs="150">
- <size>13</size>
+ <size>12</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
<size>23</size>
</method>
<method name="Int32 Main()" attrs="150">
- <size>88</size>
+ <size>87</size>
</method>
<method name="Boolean Foo(Int32[])" attrs="145">
<size>52</size>
<test name="gtest-friend-14.cs">
<type name="Test">
<method name="Int32 Main()" attrs="150">
- <size>21</size>
+ <size>20</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
</type>
<type name="C`1[T]">
<method name="System.Collections.IEnumerator GetEnumerator()" attrs="134">
- <size>20</size>
+ <size>19</size>
</method>
</type>
<type name="C`1+<Filter>c__Iterator0[T]">
<size>10</size>
</method>
<method name="Int32 Main()" attrs="150">
- <size>53</size>
+ <size>52</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
<test name="gtest-linq-01.cs">
<type name="from.C">
<method name="Void Main()" attrs="150">
- <size>2181</size>
+ <size>2179</size>
</method>
<method name="Void Foo(Int32, Boolean)" attrs="129">
<size>16</size>
</type>
<type name="NameCollisionTest.C">
<method name="Void Main()" attrs="150">
- <size>79</size>
+ <size>78</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
</type>
<type name="C">
<method name="Void <Main>m__0()" attrs="145">
- <size>162</size>
+ <size>159</size>
</method>
<method name="System.Collections.Generic.IEnumerable`1[B] <Main>m__1(A)" attrs="145">
- <size>15</size>
+ <size>14</size>
</method>
<method name="<>__AnonType0`2[A,B] <Main>m__2(A, B)" attrs="145">
<size>16</size>
<size>10</size>
</method>
<method name="Int32 Main()" attrs="150">
- <size>192</size>
+ <size>190</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
<size>10</size>
</method>
<method name="Int32 Main()" attrs="145">
- <size>42</size>
+ <size>41</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
</method>
</type>
</test>
+ <test name="gtest-optional-36.cs">
+ <type name="Program">
+ <method name="Int32 Arg(UInt32, Int64)" attrs="145">
+ <size>10</size>
+ </method>
+ <method name="Int32 Arg(Int32, UInt64, Int32)" attrs="145">
+ <size>10</size>
+ </method>
+ <method name="Int32 Arg_2(UInt32, Int64, Int32[])" attrs="145">
+ <size>10</size>
+ </method>
+ <method name="Int32 Arg_2(Int32, UInt64, Int32)" attrs="145">
+ <size>10</size>
+ </method>
+ <method name="Int32 Arg_3(Int32, Int64, Int32[])" attrs="145">
+ <size>10</size>
+ </method>
+ <method name="Int32 Arg_3(UInt32, UInt64, Int32, Int32, Int32[])" attrs="145">
+ <size>10</size>
+ </method>
+ <method name="Int32 Main()" attrs="150">
+ <size>237</size>
+ </method>
+ <method name="Void .ctor()" attrs="6278">
+ <size>7</size>
+ </method>
+ </type>
+ </test>
+ <test name="gtest-optional-37.cs">
+ <type name="Test1">
+ <method name="System.Object Foo(Int32, Int32)" attrs="145">
+ <size>10</size>
+ </method>
+ <method name="System.Object Foo(System.Object, System.Object)" attrs="145">
+ <size>10</size>
+ </method>
+ <method name="Void Main()" attrs="150">
+ <size>32</size>
+ </method>
+ <method name="Void .ctor()" attrs="6278">
+ <size>7</size>
+ </method>
+ </type>
+ </test>
<test name="gtest-partial-01.cs">
<type name="B`1[U]">
<method name="Void .ctor()" attrs="6278">
<test name="gtest-variance-13.cs">
<type name="A">
<method name="Void Test()" attrs="150">
- <size>18</size>
+ <size>17</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
<test name="gtest-variance-19.cs">
<type name="Test">
<method name="Void Bla[T,U]()" attrs="145">
- <size>13</size>
+ <size>12</size>
</method>
<method name="Void Main()" attrs="150">
<size>7</size>
<size>9</size>
</method>
<method name="Int32 Main()" attrs="150">
- <size>94</size>
+ <size>93</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
<test name="test-232.cs">
<type name="CtorInfoTest">
<method name="Void Main(System.String[])" attrs="150">
- <size>978</size>
+ <size>977</size>
</method>
<method name="Void Assert(System.Object, System.Object)" attrs="145">
<size>43</size>
</type>
<type name="UnsupportedClassVersionError">
<method name="Void .ctor(String)" attrs="6275">
- <size>15</size>
+ <size>14</size>
</method>
</type>
</test>
</type>
<type name="ChildClass">
<method name="Void .ctor()" attrs="6278">
- <size>13</size>
+ <size>12</size>
</method>
</type>
<type name="M">
<size>2</size>
</method>
<method name="Void Main()" attrs="150">
- <size>243</size>
+ <size>242</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
</type>
<type name="SimpleAttribute">
<method name="Int64[] get_ArrayValue()" attrs="2182">
- <size>15</size>
+ <size>14</size>
</method>
<method name="Void set_ArrayValue(Int64[])" attrs="2182">
<size>2</size>
</type>
<type name="X+Derived+Nested">
<method name="Void G()" attrs="134">
- <size>22</size>
+ <size>21</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
<size>41</size>
</method>
<method name="Void Main(System.String[])" attrs="150">
- <size>259</size>
+ <size>257</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
<test name="test-555.cs">
<type name="Test">
<method name="Int32 Main()" attrs="150">
- <size>361</size>
+ <size>360</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
<size>60</size>
</method>
<method name="Int32 Main()" attrs="150">
- <size>165</size>
+ <size>164</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
<test name="test-772.cs">
<type name="Test">
<method name="Void Main()" attrs="150">
- <size>15</size>
+ <size>14</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
<size>7</size>
</method>
<method name="System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()" attrs="481">
- <size>20</size>
+ <size>19</size>
</method>
</type>
</test>
<size>12</size>
</method>
<method name="Void TestCallOnly()" attrs="129">
- <size>66</size>
+ <size>65</size>
</method>
<method name="Void SomeMethod()" attrs="486">
<size>2</size>
<test name="test-850.cs">
<type name="C">
<method name="Int32 Main()" attrs="150">
- <size>39</size>
+ <size>38</size>
</method>
<method name="Int32 F(System.String, System.String[])" attrs="145">
<size>10</size>
<size>20</size>
</method>
<method name="Int32 Main()" attrs="150">
- <size>71</size>
+ <size>70</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
<size>2</size>
</method>
<method name="Int32 Main()" attrs="150">
- <size>288</size>
+ <size>284</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
</method>
</type>
</test>
+ <test name="test-933.cs">
+ <type name="X">
+ <method name="Int32 Foo(X[])" attrs="145">
+ <size>10</size>
+ </method>
+ <method name="Int32 Foo(System.Object)" attrs="145">
+ <size>10</size>
+ </method>
+ <method name="Int32 Main()" attrs="145">
+ <size>29</size>
+ </method>
+ <method name="Void .ctor()" attrs="6278">
+ <size>7</size>
+ </method>
+ </type>
+ </test>
<test name="test-94.cs">
<type name="Base">
<method name="Int32 IVehicle.Start()" attrs="481">
<size>10</size>
</method>
<method name="Int32 Main()" attrs="150">
- <size>95</size>
+ <size>94</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
</type>
<type name="Foo`1+<ContainsAll>c__AnonStorey0`1[T,U]">
<method name="Boolean <>m__0()" attrs="131">
- <size>210</size>
+ <size>209</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
</type>
<type name="AwaitNS.MemberAccess">
<method name="Void M()" attrs="145">
- <size>13</size>
+ <size>12</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
</type>
<type name="O">
<method name="Void Main()" attrs="150">
- <size>23</size>
+ <size>22</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
</method>
</type>
</test>
+ <test name="test-async-85.cs">
+ <type name="Program">
+ <method name="Int32 Main()" attrs="145">
+ <size>197</size>
+ </method>
+ <method name="System.Threading.Tasks.Task Test(Boolean)" attrs="145">
+ <size>41</size>
+ </method>
+ <method name="System.Threading.Tasks.Task Test2(Boolean)" attrs="145">
+ <size>41</size>
+ </method>
+ <method name="Void .ctor()" attrs="6278">
+ <size>7</size>
+ </method>
+ </type>
+ <type name="Program+<Test>c__async0">
+ <method name="Void MoveNext()" attrs="486">
+ <size>543</size>
+ </method>
+ <method name="Void SetStateMachine(System.Runtime.CompilerServices.IAsyncStateMachine)" attrs="486">
+ <size>13</size>
+ </method>
+ </type>
+ <type name="Program+<Test2>c__async1">
+ <method name="Void MoveNext()" attrs="486">
+ <size>398</size>
+ </method>
+ <method name="Void SetStateMachine(System.Runtime.CompilerServices.IAsyncStateMachine)" attrs="486">
+ <size>13</size>
+ </method>
+ </type>
+ </test>
<test name="test-cls-00.cs">
<type name="CLSCLass_6">
<method name="Void add_Disposed(Delegate)" attrs="2182">
<size>76</size>
</method>
<method name="Void Test_2()" attrs="129">
- <size>51</size>
+ <size>49</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
<size>14</size>
</method>
<method name="Boolean MoveNext()" attrs="486">
- <size>168</size>
+ <size>167</size>
</method>
<method name="Void Dispose()" attrs="486">
<size>15</size>
<size>477</size>
</method>
<method name="Int32 TestReferenceType()" attrs="145">
- <size>229</size>
+ <size>227</size>
</method>
<method name="Int32 TestGeneric[T](T)" attrs="145">
<size>118</size>
mono-symbolicate \
linker-analyzer
-build_SUBDIRS = gacutil security culevel cil-stringreplacer
+build_SUBDIRS = gacutil security culevel cil-stringreplacer commoncryptogenerator
net_4_5_SUBDIRS = gacutil
net_4_5_PARALLEL_SUBDIRS = $(net_4_5_dirs)
--- /dev/null
+//
+// CommonCrypto code generator for symmetric block cipher algorithms
+//
+// Authors:
+// Sebastien Pouliot <sebastien@xamarin.com>
+//
+// Copyright 2012 Xamarin Inc.
+//
+
+using System;
+using System.IO;
+
+namespace Xamarin {
+
+ public static class CommonCryptor {
+
+ static public void Generate (string namespaceName, string typeName, string baseTypeName, string ccAlgorithmName, string feedbackSize = "8", string ctorInitializers = null)
+ {
+ string template = @"// Generated file to bind CommonCrypto cipher algorithms - DO NOT EDIT
+//
+// Authors:
+// Sebastien Pouliot <sebastien@xamarin.com>
+//
+// Copyright 2012-2014 Xamarin Inc.
+
+using System;
+using System.Security.Cryptography;
+
+using Mono.Security.Cryptography;
+using Crimson.CommonCrypto;
+
+namespace %NAMESPACE% {
+
+ public sealed partial class %TYPE% : %BASE% {
+
+ public %TYPE% ()
+ {
+ FeedbackSizeValue = %FEEDBACKSIZE%;
+ %CTOR_INIT%
+ }
+
+ public override void GenerateIV ()
+ {
+ IVValue = KeyBuilder.IV (BlockSizeValue >> 3);
+ }
+
+ public override void GenerateKey ()
+ {
+ KeyValue = KeyBuilder.Key (KeySizeValue >> 3);
+ }
+
+ public override ICryptoTransform CreateDecryptor (byte[] rgbKey, byte[] rgbIV)
+ {
+ IntPtr decryptor = IntPtr.Zero;
+ switch (Mode) {
+ case CipherMode.CBC:
+ decryptor = Cryptor.Create (CCOperation.Decrypt, CCAlgorithm.%CCALGORITHM%, CCOptions.None, rgbKey, rgbIV);
+ return new FastCryptorTransform (decryptor, this, false, rgbIV);
+ case CipherMode.ECB:
+ decryptor = Cryptor.Create (CCOperation.Decrypt, CCAlgorithm.%CCALGORITHM%, CCOptions.ECBMode, rgbKey, rgbIV);
+ return new FastCryptorTransform (decryptor, this, false, rgbIV);
+ case CipherMode.CFB:
+#if MONOTOUCH || XAMMAC
+ IntPtr encryptor = Cryptor.Create (CCOperation.Encrypt, CCAlgorithm.%CCALGORITHM%, CCOptions.ECBMode, rgbKey, rgbIV);
+ decryptor = Cryptor.Create (CCOperation.Decrypt, CCAlgorithm.%CCALGORITHM%, CCOptions.ECBMode, rgbKey, rgbIV);
+ return new CryptorTransform (decryptor, encryptor, this, false, rgbIV);
+#else
+ throw new CryptographicException (""CFB is not supported by Crimson.CommonCrypto"");
+#endif
+ default:
+ throw new CryptographicException (String.Format (""{0} is not supported by the .NET framework"", Mode));
+ }
+ }
+
+ public override ICryptoTransform CreateEncryptor (byte[] rgbKey, byte[] rgbIV)
+ {
+ IntPtr encryptor = IntPtr.Zero;
+ switch (Mode) {
+ case CipherMode.CBC:
+ encryptor = Cryptor.Create (CCOperation.Encrypt, CCAlgorithm.%CCALGORITHM%, CCOptions.None, rgbKey, rgbIV);
+ return new FastCryptorTransform (encryptor, this, true, rgbIV);
+ case CipherMode.ECB:
+ encryptor = Cryptor.Create (CCOperation.Encrypt, CCAlgorithm.%CCALGORITHM%, CCOptions.ECBMode, rgbKey, rgbIV);
+ return new FastCryptorTransform (encryptor, this, true, rgbIV);
+ case CipherMode.CFB:
+#if MONOTOUCH || XAMMAC
+ encryptor = Cryptor.Create (CCOperation.Encrypt, CCAlgorithm.%CCALGORITHM%, CCOptions.ECBMode, rgbKey, rgbIV);
+ return new CryptorTransform (encryptor, IntPtr.Zero, this, true, rgbIV);
+#else
+ throw new CryptographicException (""CFB is not supported by Crimson.CommonCrypto"");
+#endif
+ default:
+ throw new CryptographicException (String.Format (""{0} is not supported by the .NET framework"", Mode));
+ }
+ }
+ }
+}";
+
+ File.WriteAllText (typeName + ".g.cs", template.Replace ("%NAMESPACE%", namespaceName).
+ Replace ("%TYPE%", typeName).Replace ("%BASE%", baseTypeName).Replace("%FEEDBACKSIZE%", feedbackSize).Replace ("%CTOR_INIT%", ctorInitializers).
+ Replace ("%CCALGORITHM%", ccAlgorithmName.ToString ()));
+ }
+ }
+}
--- /dev/null
+//
+// CommonCrypto code generator for digest algorithms
+//
+// Authors:
+// Sebastien Pouliot <sebastien@xamarin.com>
+//
+// Copyright 2012-2014 Xamarin Inc.
+//
+
+using System;
+using System.IO;
+
+namespace Xamarin {
+
+ public static class CommonDigest {
+
+#if !MONOTOUCH && !XAMMAC
+ // we do not add anything in MonoTouch, just replacing, so this is not needed
+ // however we can avoid a dependency on Mono.Security for Crimson.CommonCrypto.dll by including the base classes
+ static public void GenerateBaseClass (string namespaceName, string typeName, string baseTypeName, int hashSize,
+ string visibilityStart = "", string visibilityEnd = "")
+ {
+ string template = @"// Generated file to bind CommonCrypto/CommonDigest - DO NOT EDIT
+//
+// Authors:
+// Sebastien Pouliot <sebastien@xamarin.com>
+//
+// Copyright 2012-2014 Xamarin Inc.
+
+using System;
+using System.Security.Cryptography;
+using System.Runtime.InteropServices;
+
+namespace %NAMESPACE% {
+
+%VISIBILITY_START%
+ public
+%VISIBILITY_END%
+ abstract class %BASE% : HashAlgorithm {
+
+ protected %BASE% ()
+ {
+ HashSizeValue = %HASHSIZE%;
+ }
+
+ public static new %BASE% Create ()
+ {
+ return Create (""%BASE%"");
+ }
+
+ public static new %BASE% Create (string hashName)
+ {
+ object o = CryptoConfig.CreateFromName (hashName);
+ return (%BASE%) o ?? new %TYPE% ();
+ }
+ }
+}";
+
+ File.WriteAllText (baseTypeName + ".g.cs", template.Replace ("%NAMESPACE%", namespaceName).
+ Replace ("%TYPE%", typeName).Replace ("%BASE%", baseTypeName).
+ Replace ("%VISIBILITY_START%", visibilityStart).Replace ("%VISIBILITY_END%", visibilityEnd).
+ Replace ("%HASHSIZE%", hashSize.ToString ()));
+ }
+#endif
+ static public void Generate (string namespaceName, string typeName, string baseTypeName, int contextSize,
+ string visibilityStart = "", string visibilityEnd = "")
+ {
+ string template = @"// Generated file to bind CommonCrypto/CommonDigest - DO NOT EDIT
+//
+// Authors:
+// Sebastien Pouliot <sebastien@xamarin.com>
+//
+// Copyright 2011-2014 Xamarin Inc.
+
+using System;
+using System.Security.Cryptography;
+using System.Runtime.InteropServices;
+
+using Mono.Security.Cryptography;
+
+namespace %NAMESPACE% {
+
+%VISIBILITY_START%
+ public
+%VISIBILITY_END%
+ sealed class %TYPE% : %BASE% {
+
+ IntPtr ctx;
+
+ [DllImport (""/usr/lib/libSystem.dylib"", EntryPoint=""CC_%BASE%_Init"")]
+ static extern int Init (/* CC_%BASE%_CTX */ IntPtr c);
+
+ [DllImport (""/usr/lib/libSystem.dylib"", EntryPoint=""CC_%BASE%_Update"")]
+ static extern int Update (/* CC_%BASE%_CTX */ IntPtr c, /* const void * */ IntPtr data, /* uint32_t */ uint len);
+
+ [DllImport (""/usr/lib/libSystem.dylib"", EntryPoint=""CC_%BASE%_Final"")]
+ static extern int Final (/* unsigned char * */ byte [] md, /* CC_%BASE%_CTX */ IntPtr c);
+
+ public %TYPE% ()
+ {
+ ctx = IntPtr.Zero;
+ }
+
+ ~%TYPE% ()
+ {
+ Dispose (false);
+ }
+
+ protected override void Dispose (bool disposing)
+ {
+ if (ctx != IntPtr.Zero) {
+ Marshal.FreeHGlobal (ctx);
+ ctx = IntPtr.Zero;
+ }
+ base.Dispose (disposing);
+ GC.SuppressFinalize (this);
+ }
+
+ public override void Initialize ()
+ {
+ if (ctx == IntPtr.Zero)
+ ctx = Marshal.AllocHGlobal (%CTX_SIZE%);
+
+ int hr = Init (ctx);
+ if (hr != 1)
+ throw new CryptographicException (hr);
+ }
+
+ protected override void HashCore (byte[] data, int start, int length)
+ {
+ if (ctx == IntPtr.Zero)
+ Initialize ();
+
+ if (data.Length == 0)
+ return;
+
+ unsafe {
+ fixed (byte* p = &data [0]) {
+ int hr = Update (ctx, (IntPtr) (p + start), (uint) length);
+ if (hr != 1)
+ throw new CryptographicException (hr);
+ }
+ }
+ }
+
+ protected override byte[] HashFinal ()
+ {
+ if (ctx == IntPtr.Zero)
+ Initialize ();
+
+ byte[] data = new byte [HashSize >> 3];
+ int hr = Final (data, ctx);
+ if (hr != 1)
+ throw new CryptographicException (hr);
+
+ return data;
+ }
+ }
+}";
+
+ File.WriteAllText (typeName + ".g.cs", template.Replace ("%NAMESPACE%", namespaceName).
+ Replace ("%TYPE%", typeName).Replace ("%BASE%", baseTypeName).
+ Replace ("%VISIBILITY_START%", visibilityStart).Replace ("%VISIBILITY_END%", visibilityEnd).
+ Replace ("%CTX_SIZE%", contextSize.ToString ()));
+ }
+ }
+}
--- /dev/null
+thisdir = tools/commoncryptogenerator
+SUBDIRS =
+include ../../build/rules.make
+
+LIB_REFS =
+LOCAL_MCS_FLAGS =
+
+PROGRAM = commoncryptogenerator.exe
+NO_INSTALL = yes
+
+include ../../build/executable.make
--- /dev/null
+CommonCryptorGenerator.cs
+generator.cs
+CommonDigestGenerator.cs
--- /dev/null
+//
+// CommonCrypto Code Generator
+//
+// Authors:
+// Sebastien Pouliot <sebastien@xamarin.com>
+//
+// Copyright 2012 Xamarin Inc.
+//
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Text;
+
+namespace Xamarin {
+
+ class Program {
+ static void Main (string [] args)
+ {
+ // mscorlib replacements
+ CommonDigest.Generate ("System.Security.Cryptography", "MD5CryptoServiceProvider", "MD5", 1000);
+ CommonDigest.Generate ("System.Security.Cryptography", "SHA1CryptoServiceProvider", "SHA1", 1000);
+ CommonDigest.Generate ("System.Security.Cryptography", "SHA1Managed", "SHA1", 1000);
+ CommonDigest.Generate ("System.Security.Cryptography", "SHA256Managed", "SHA256", 1000);
+ CommonDigest.Generate ("System.Security.Cryptography", "SHA384Managed", "SHA384", 1000);
+ CommonDigest.Generate ("System.Security.Cryptography", "SHA512Managed", "SHA512", 1000);
+
+ // System.Core replacements - not yet in MT profile (4.0 - functional dupes anyway)
+ //CommonDigest.Generate ("System.Security.Cryptography", "MD5Cng", "MD5", 1000);
+ //CommonDigest.Generate ("System.Security.Cryptography", "SHA256Cng", "SHA256", 1000);
+ //CommonDigest.Generate ("System.Security.Cryptography", "SHA384Cng", "SHA384", 1000);
+ //CommonDigest.Generate ("System.Security.Cryptography", "SHA512Cng", "SHA512", 1000);
+ //CommonDigest.Generate ("System.Security.Cryptography", "SHA256CryptoServiceProvider", "SHA256", 1000);
+ //CommonDigest.Generate ("System.Security.Cryptography", "SHA384CryptoServiceProvider", "SHA384", 1000);
+ //CommonDigest.Generate ("System.Security.Cryptography", "SHA512CryptoServiceProvider", "SHA512", 1000);
+
+ // Mono.Security replacements
+ CommonDigest.Generate ("Mono.Security.Cryptography", "MD2Managed", "MD2", 1000, "#if !INSIDE_CORLIB", "#endif");
+ CommonDigest.Generate ("Mono.Security.Cryptography", "MD4Managed", "MD4", 1000, "#if !INSIDE_CORLIB", "#endif");
+ CommonDigest.Generate ("Mono.Security.Cryptography", "SHA224Managed", "SHA224", 1000);
+
+ // mscorlib replacements
+ CommonCryptor.Generate ("System.Security.Cryptography", "DESCryptoServiceProvider", "DES", "DES");
+ CommonCryptor.Generate ("System.Security.Cryptography", "TripleDESCryptoServiceProvider", "TripleDES", "TripleDES");
+ CommonCryptor.Generate ("System.Security.Cryptography", "RC2CryptoServiceProvider", "RC2", "RC2", ctorInitializers: "LegalKeySizesValue = new[] { new KeySizes(40, 128, 8) };");
+ // Rijndael supports block sizes that are not available in AES - as such it does not use the same generated code
+ // but has it's own version, using AES (128 bits block size) and falling back to managed (192/256 bits block size)
+
+ // System.Core replacements
+ CommonCryptor.Generate ("System.Security.Cryptography", "AesManaged", "Aes", "AES128", "128");
+ CommonCryptor.Generate ("System.Security.Cryptography", "AesCryptoServiceProvider", "Aes", "AES128");
+
+ // Mono.Security replacements
+ // RC4 is a stream (not a block) cipher so it can not reuse the generated code
+ }
+ }
+}
\ No newline at end of file
static bool TryToMatchErrorMessage (string actual, string expected)
{
actual = actual.Replace ("\\", "/");
- var path_mask_start = expected.IndexOf ("*PATH*");
+ var path_mask_start = expected.IndexOf ("*PATH*", StringComparison.Ordinal);
if (path_mask_start > 0 && actual.Length > path_mask_start) {
- var path_mask_continue = expected.Substring (path_mask_start + 6);
- var expected_continue = actual.IndexOf (path_mask_continue, path_mask_start);
- if (expected_continue > 0) {
- var path = actual.Substring (path_mask_start, expected_continue - path_mask_start);
- if (actual == expected.Replace ("*PATH*", path))
- return true;
-
- throw new ApplicationException (expected.Replace ("*PATH*", path));
+ var parts = expected.Split (new [] { "*PATH*" }, StringSplitOptions.None);
+ foreach (var part in parts) {
+ if (!actual.Contains (part))
+ return false;
}
}
- return false;
+ return true;
}
bool HandleFailure (string file, CompilerError status)
LOCAL_MCS_FLAGS= $(OTHER_RES:%=-resource:%)
LOCAL_MCS_FLAGS += -d:STATIC,NO_SYMBOL_WRITER,NO_AUTHENTICODE
-LIB_REFS = System.Xml System
+LIB_REFS = System.Xml System System.Core
EXTRA_DISTFILES = $(RESOURCE_FILES)
// Miguel de Icaza
//
// (C) Novell, Inc 2004
+// (C) 2016 Xamarin Inc
+//
+// Missing features:
+// * Implement --cross, --local-targets, --list-targets, --no-auto-fetch
+// * concatenate target with package to form native binary
//
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Text;
using IKVM.Reflection;
-
-
+using System.Linq;
+using System.Diagnostics;
using System.Threading.Tasks;
class MakeBundle {
static bool skip_scan;
static string ctor_func;
static bool quiet;
+ static bool custom_mode = true;
+ static string embedded_options = null;
+ static string runtime = null;
static int Main (string [] args)
{
Help ();
return 1;
+ case "--simple":
+ custom_mode = false;
+ autodeps = true;
+ break;
+
+ case "--custom":
+ custom_mode = true;
+ break;
+
case "-c":
compile_only = true;
break;
output = args [++i];
break;
+ case "--options":
+ if (i+1 == top){
+ Help ();
+ return 1;
+ }
+ embedded_options = args [++i];
+ break;
+ case "--runtime":
+ if (i+1 == top){
+ Help ();
+ return 1;
+ }
+ runtime = args [++i];
+ break;
case "-oo":
if (i+1 == top){
Help ();
case "--keeptemp":
keeptemp = true;
break;
+
case "--static":
static_link = true;
break;
foreach (string file in assemblies)
if (!QueueAssembly (files, file))
return 1;
-
- GenerateBundles (files);
- //GenerateJitWrapper ();
+
+ if (custom_mode)
+ GenerateBundles (files);
+ else
+ GeneratePackage (files);
return 0;
}
ts.WriteLine ();
}
+
+ class PackageMaker {
+ Dictionary<string, Tuple<long,int>> locations = new Dictionary<string, Tuple<long,int>> ();
+ const int align = 4096;
+ Stream package;
+
+ public PackageMaker (string output)
+ {
+ package = File.Create (output, 128*1024);
+ if (IsUnix){
+ File.SetAttributes (output, unchecked ((FileAttributes) 0x80000000));
+ }
+ }
+
+ public int AddFile (string fname)
+ {
+ using (Stream fileStream = File.OpenRead (fname)){
+ var ret = fileStream.Length;
+
+ Console.WriteLine ("At {0:x} with input {1}", package.Position, fileStream.Length);
+ fileStream.CopyTo (package);
+ package.Position = package.Position + (align - (package.Position % align));
+
+ return (int) ret;
+ }
+ }
+
+ public void Add (string entry, string fname)
+ {
+ var p = package.Position;
+ var size = AddFile (fname);
+
+ locations [entry] = Tuple.Create(p, size);
+ }
+
+ public void AddString (string entry, string text)
+ {
+ var bytes = Encoding.UTF8.GetBytes (text);
+ locations [entry] = Tuple.Create (package.Position, bytes.Length);
+ package.Write (bytes, 0, bytes.Length);
+ package.Position = package.Position + (align - (package.Position % align));
+ }
+
+ public void Dump ()
+ {
+ foreach (var floc in locations.Keys){
+ Console.WriteLine ($"{floc} at {locations[floc]:x}");
+ }
+ }
+
+ public void WriteIndex ()
+ {
+ var indexStart = package.Position;
+ var binary = new BinaryWriter (package);
+
+ binary.Write (locations.Count);
+ foreach (var entry in from entry in locations orderby entry.Value.Item1 ascending select entry){
+ var bytes = Encoding.UTF8.GetBytes (entry.Key);
+ binary.Write (bytes.Length+1);
+ binary.Write (bytes);
+ binary.Write ((byte) 0);
+ binary.Write (entry.Value.Item1);
+ binary.Write (entry.Value.Item2);
+ }
+ binary.Write (indexStart);
+ binary.Write (Encoding.UTF8.GetBytes ("xmonkeysloveplay"));
+ binary.Flush ();
+ }
+
+ public void Close ()
+ {
+ WriteIndex ();
+ package.Close ();
+ package = null;
+ }
+ }
+
+ static bool MaybeAddFile (PackageMaker maker, string code, string file)
+ {
+ if (file == null)
+ return true;
+
+ if (!File.Exists (file)){
+ Console.Error.WriteLine ("The file {0} does not exist", file);
+ return false;
+ }
+ maker.Add (code, file);
+ return true;
+ }
+
+ static bool GeneratePackage (List<string> files)
+ {
+ if (runtime == null){
+ if (IsUnix)
+ runtime = Process.GetCurrentProcess().MainModule.FileName;
+ else {
+ Console.Error.WriteLine ("You must specify at least one runtime with --runtime or --cross");
+ Environment.Exit (1);
+ }
+ }
+ if (!File.Exists (runtime)){
+ Console.Error.WriteLine ($"The specified runtime at {runtime} does not exist");
+ Environment.Exit (1);
+ }
+
+ if (ctor_func != null){
+ Console.Error.WriteLine ("--static-ctor not supported with package bundling, you must use native compilation for this");
+ return false;
+ }
+
+ var maker = new PackageMaker (output);
+ maker.AddFile (runtime);
+
+ foreach (var url in files){
+ string fname = LocateFile (new Uri (url).LocalPath);
+ string aname = Path.GetFileName (fname);
+
+ maker.Add ("assembly:" + aname, fname);
+ if (File.Exists (fname + ".config"))
+ maker.Add ("config:" + aname, fname + ".config");
+ }
+ if (!MaybeAddFile (maker, "systemconfig:", config_file) || !MaybeAddFile (maker, "machineconfig:", machine_config_file))
+ return false;
+
+ if (config_dir != null)
+ maker.Add ("config_dir:", config_dir);
+ if (embedded_options != null)
+ maker.AddString ("options:", embedded_options);
+ maker.Dump ();
+ maker.Close ();
+ return true;
+ }
static void GenerateBundles (List<string> files)
{
{
Console.WriteLine ("Usage is: mkbundle [options] assembly1 [assembly2...]\n\n" +
"Options:\n" +
- " -c Produce stub only, do not compile\n" +
+ " --config F Bundle system config file `F'\n" +
+ " --config-dir D Set MONO_CFG_DIR to `D'\n" +
+ " --deps Turns on automatic dependency embedding (default on simple)\n" +
+ " -L path Adds `path' to the search path for assemblies\n" +
+ " --machine-config F Use the given file as the machine.config for the application.\n" +
" -o out Specifies output filename\n" +
+ " --nodeps Turns off automatic dependency embedding (default on custom)\n" +
+ " --skip-scan Skip scanning assemblies that could not be loaded (but still embed them).\n" +
+ "\n" +
+ "--simple Simple mode does not require a C toolchain and can cross compile\n" +
+ " --cross TARGET Generates a binary for the given TARGET\n"+
+ " --local-targets Lists locally available targets\n" +
+ " --list-targets [SERVER] Lists available targets on the remote server\n" +
+ " --no-auto-fetch Prevents the tool from auto-fetching a TARGET\n" +
+ " --options OPTIONS Embed the specified Mono command line options on target\n" +
+ " --runtime RUNTIME Manually specifies the Mono runtime to use\n" +
+ "\n" +
+ "--custom Builds a custom launcher, options for --custom\n" +
+ " -c Produce stub only, do not compile\n" +
" -oo obj Specifies output filename for helper object file\n" +
- " -L path Adds `path' to the search path for assemblies\n" +
- " --nodeps Turns off automatic dependency embedding (default)\n" +
- " --deps Turns on automatic dependency embedding\n" +
" --dos2unix[=true|false]\n" +
" When no value provided, or when `true` specified\n" +
" `dos2unix` will be invoked to convert paths on Windows.\n" +
" When `--dos2unix=false` used, dos2unix is NEVER used.\n" +
" --keeptemp Keeps the temporary files\n" +
- " --config F Bundle system config file `F'\n" +
- " --config-dir D Set MONO_CFG_DIR to `D'\n" +
- " --machine-config F Use the given file as the machine.config for the application.\n" +
" --static Statically link to mono libs\n" +
" --nomain Don't include a main() function, for libraries\n" +
- " --custom-main C Link the specified compilation unit (.c or .obj) with entry point/init code\n" +
+ " --custom-main C Link the specified compilation unit (.c or .obj) with entry point/init code\n" +
" -z Compress the assemblies before embedding.\n" +
- " --skip-scan Skip scanning assemblies that could not be loaded (but still embed them).\n" +
" --static-ctor ctor Add a constructor call to the supplied function.\n" +
" You need zlib development headers and libraries.\n");
}
<Compile Include="AssemblyComparer.cs" />
<Compile Include="ClassComparer.cs" />
<Compile Include="ApiDiff.cs" />
- <Compile Include="..\..\..\class\Mono.Options\Mono.Options\Options.cs">
+ <Compile Include="..\..\class\Mono.Options\Mono.Options\Options.cs">
<Link>Options.cs</Link>
</Compile>
<Compile Include="ApiChange.cs" />
using System.IO;
using System.Linq;
using System.Text;
-using System.Reflection;
+using IKVM.Reflection;
using System.Diagnostics;
using System.Collections.Generic;
-using Mono.Cecil;
using Mono.CompilerServices.SymbolWriter;
using System.Runtime.InteropServices;
}
}
+ static readonly Universe ikvm_reflection = new Universe ();
Dictionary<string, AssemblyLocationProvider> assemblies;
HashSet<string> directories;
if (!File.Exists (assemblyPath))
throw new ArgumentException ("assemblyPath does not exist: "+ assemblyPath);
- var assembly = Assembly.ReflectionOnlyLoadFrom (assemblyPath);
+ var assembly = ikvm_reflection.LoadFile (assemblyPath);
MonoSymbolFile symbolFile = null;
var symbolPath = assemblyPath + ".mdb";
if (!File.Exists (symbolPath))
Debug.WriteLine (".mdb file was not found for " + assemblyPath);
else
- symbolFile = MonoSymbolFile.ReadSymbolFile (assemblyPath + ".mdb");
+ symbolFile = MonoSymbolFile.ReadSymbolFile (symbolPath);
var seqPointDataPath = assemblyPath + ".msym";
if (!File.Exists (seqPointDataPath))
PROGRAM = mono-symbolicate.exe
-LOCAL_MCS_FLAGS =
+LOCAL_MCS_FLAGS = \
+ /D:NO_AUTHENTICODE
-LIB_REFS = Mono.Cecil Mono.CompilerServices.SymbolWriter System.Xml System.Core System
+LIB_REFS = Mono.CompilerServices.SymbolWriter System.Xml System.Core System
include ../../build/executable.make
at StackTraceDumper.Catch (System.Action action) in StackTraceDumper.cs:54
System.Exception: Stacktrace with 3 frames
- at StackTraceDumper.ThrowException (System.String message, Int32 i) in StackTraceDumper.cs:78
+ at StackTraceDumper.ThrowException (System.String message, System.Int32 i) in StackTraceDumper.cs:78
at StackTraceDumper.<Main>m__1 () in StackTraceDumper.cs:18
at StackTraceDumper.Catch (System.Action action) in StackTraceDumper.cs:54
Stacktrace:
- at StackTraceDumper.ThrowException (System.String message, Int32 i) in StackTraceDumper.cs:78
+ at StackTraceDumper.ThrowException (System.String message, System.Int32 i) in StackTraceDumper.cs:78
at StackTraceDumper.<Main>m__1 () in StackTraceDumper.cs:18
at StackTraceDumper.Catch (System.Action action) in StackTraceDumper.cs:54
System.Exception: Stacktrace with 4 frames
- at StackTraceDumper.ThrowException (System.String message, Int32 i) in StackTraceDumper.cs:78
- at StackTraceDumper.ThrowException (System.String message, Int32 i) in StackTraceDumper.cs:76
+ at StackTraceDumper.ThrowException (System.String message, System.Int32 i) in StackTraceDumper.cs:78
+ at StackTraceDumper.ThrowException (System.String message, System.Int32 i) in StackTraceDumper.cs:76
at StackTraceDumper.<Main>m__2 () in StackTraceDumper.cs:20
at StackTraceDumper.Catch (System.Action action) in StackTraceDumper.cs:54
Stacktrace:
- at StackTraceDumper.ThrowException (System.String message, Int32 i) in StackTraceDumper.cs:78
- at StackTraceDumper.ThrowException (System.String message, Int32 i) in StackTraceDumper.cs:76
+ at StackTraceDumper.ThrowException (System.String message, System.Int32 i) in StackTraceDumper.cs:78
+ at StackTraceDumper.ThrowException (System.String message, System.Int32 i) in StackTraceDumper.cs:76
at StackTraceDumper.<Main>m__2 () in StackTraceDumper.cs:20
at StackTraceDumper.Catch (System.Action action) in StackTraceDumper.cs:54
LocationProvider.cs
SeqPointInfo.cs
../../class/corlib/System.Diagnostics/StackTraceHelper.cs
+../../../external/ikvm/reflect/*.cs
+../../../external/ikvm/reflect/Impl/*.cs
+../../../external/ikvm/reflect/Emit/*.cs
+../../../external/ikvm/reflect/Metadata/*.cs
+../../../external/ikvm/reflect/Reader/*.cs
+../../../external/ikvm/reflect/Writer/*.cs
x86_reg_emit ((inst), (dreg), (reg)); \
} while (0)
+#define amd64_test_reg_imm_size_body(inst,reg,imm,size) \
+ do { \
+ amd64_codegen_pre(inst); \
+ amd64_emit_rex ((inst),(size),0,0,(reg)); \
+ if ((reg) == AMD64_RAX) { \
+ *(inst)++ = (unsigned char)0xa9; \
+ } \
+ else { \
+ *(inst)++ = (unsigned char)0xf7; \
+ x86_reg_emit((inst), 0, (reg)); \
+ } \
+ x86_imm_emit32((inst), (imm)); \
+ amd64_codegen_post(inst); \
+ } while (0)
+
#if defined(__default_codegen__)
#define amd64_alu_reg_imm_size(inst,opc,reg,imm,size) \
#define amd64_alu_reg_reg_size(inst,opc,dreg,reg,size) \
amd64_alu_reg_reg_size_body((inst), (opc), (dreg), (reg), (size))
+#define amd64_test_reg_imm_size(inst, reg, imm, size) \
+ amd64_test_reg_imm_size_body(inst, reg, imm, size)
+
#elif defined(__native_client_codegen__)
/* NaCl modules may not directly update RSP or RBP other than direct copies */
/* between them. Instead the lower 4 bytes are updated and then added to R15 */
#define amd64_alu_reg_reg(inst,opc,dreg,reg) amd64_alu_reg_reg_size ((inst),(opc),(dreg),(reg),8)
+#define amd64_test_reg_imm(inst,reg,imm) amd64_test_reg_imm_size(inst,reg,imm,8)
+
#define amd64_alu_reg_membase_size(inst,opc,reg,basereg,disp,size) \
do { \
amd64_codegen_pre(inst); \
#define amd64_alu_reg8_reg8_size(inst,opc,dreg,reg,is_dreg_h,is_reg_h,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),(dreg),0,(reg)); x86_alu_reg8_reg8((inst),(opc),((dreg)&0x7),((reg)&0x7),(is_dreg_h),(is_reg_h)); amd64_codegen_post(inst); } while (0)
#define amd64_alu_reg_mem_size(inst,opc,reg,mem,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(reg)); x86_alu_reg_mem((inst),(opc),((reg)&0x7),(mem)); amd64_codegen_post(inst); } while (0)
//#define amd64_alu_reg_membase_size(inst,opc,reg,basereg,disp,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),(reg),0,(basereg)); x86_alu_reg_membase((inst),(opc),((reg)&0x7),((basereg)&0x7),(disp)); amd64_codegen_post(inst); } while (0)
-#define amd64_test_reg_imm_size(inst,reg,imm,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(reg)); x86_test_reg_imm((inst),((reg)&0x7),(imm)); amd64_codegen_post(inst); } while (0)
+//#define amd64_test_reg_imm_size(inst,reg,imm,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(reg)); x86_test_reg_imm((inst),((reg)&0x7),(imm)); amd64_codegen_post(inst); } while (0)
#define amd64_test_mem_imm_size(inst,mem,imm,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,0); x86_test_mem_imm((inst),(mem),(imm)); amd64_codegen_post(inst); } while (0)
#define amd64_test_membase_imm_size(inst,basereg,disp,imm,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),0,0,(basereg)); x86_test_membase_imm((inst),((basereg)&0x7),(disp),(imm)); amd64_codegen_post(inst); } while (0)
#define amd64_test_reg_reg_size(inst,dreg,reg,size) do { amd64_codegen_pre(inst); amd64_emit_rex ((inst),(size),(dreg),0,(reg)); x86_test_reg_reg((inst),((dreg)&0x7),((reg)&0x7)); amd64_codegen_post(inst); } while (0)
#define amd64_alu_reg8_reg8(inst,opc,dreg,reg,is_dreg_h,is_reg_h) amd64_alu_reg8_reg8_size(inst,opc,dreg,reg,is_dreg_h,is_reg_h,8)
#define amd64_alu_reg_mem(inst,opc,reg,mem) amd64_alu_reg_mem_size(inst,opc,reg,mem,8)
#define amd64_alu_reg_membase(inst,opc,reg,basereg,disp) amd64_alu_reg_membase_size(inst,opc,reg,basereg,disp,8)
-#define amd64_test_reg_imm(inst,reg,imm) amd64_test_reg_imm_size(inst,reg,imm,8)
+//#define amd64_test_reg_imm(inst,reg,imm) amd64_test_reg_imm_size(inst,reg,imm,8)
#define amd64_test_mem_imm(inst,mem,imm) amd64_test_mem_imm_size(inst,mem,imm,8)
#define amd64_test_membase_imm(inst,basereg,disp,imm) amd64_test_membase_imm_size(inst,basereg,disp,imm,8)
#define amd64_test_reg_reg(inst,dreg,reg) amd64_test_reg_reg_size(inst,dreg,reg,8)
*code = STILL_ACTIVE;
return TRUE;
} else {
- return FALSE;
+ *code = -1;
+ return TRUE;
}
}
* Changes which are already detected at runtime, like the addition
* of icalls, do not require an increment.
*/
-#define MONO_CORLIB_VERSION 143
+#define MONO_CORLIB_VERSION 145
typedef struct
{
if (! (field->type->attrs & FIELD_ATTRIBUTE_STATIC))
return -1;
value = mono_field_get_value_object_checked (mono_domain_get (), field, NULL, &error);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
+ mono_error_assert_ok (&error);
return *(gint32*)((gchar*)value + sizeof (MonoObject));
}
klass = mono_class_load_from_name (mono_defaults.corlib, "System", "AppDomainSetup");
setup = (MonoAppDomainSetup *) mono_object_new_checked (mono_domain_get (), klass, &error);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
+ if (!is_ok (&error))
+ goto fail;
setup->configuration_file = configuration_file != NULL ? mono_string_new (mono_domain_get (), configuration_file) : NULL;
ad = mono_domain_create_appdomain_internal (friendly_name, setup, &error);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
+ if (!is_ok (&error))
+ goto fail;
return mono_domain_from_appdomain (ad);
+fail:
+ mono_error_cleanup (&error);
+ return NULL;
}
/**
MonoAppDomain *
ves_icall_System_AppDomain_createDomain (MonoString *friendly_name, MonoAppDomainSetup *setup)
{
+ MonoError error;
+ MonoAppDomain *ad = NULL;
#ifdef DISABLE_APPDOMAINS
- mono_set_pending_exception (mono_get_exception_not_supported ("AppDomain creation is not supported on this runtime."));
- return NULL;
+ mono_error_set_not_supported (&error, "AppDomain creation is not supported on this runtime.");
#else
- MonoError error;
char *fname;
- MonoAppDomain *ad;
fname = mono_string_to_utf8 (friendly_name);
ad = mono_domain_create_appdomain_internal (fname, setup, &error);
g_free (fname);
-
- mono_error_raise_exception (&error);
-
- return ad;
#endif
+ mono_error_set_pending_exception (&error);
+ return ad;
}
MonoArray *
/* FIXME: We invoke managed code here, so there is a potential for deadlocks */
str = mono_string_new (domain, aname_str);
+ g_free (aname_str);
if (!str) {
- g_free (aname_str);
return NULL;
}
assembly = mono_try_assembly_resolve (domain, str, requesting, refonly, &error);
- if (!mono_error_ok (&error)) {
- g_free (aname_str);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
- }
-
- g_free (aname_str);
+ mono_error_cleanup (&error);
if (assembly)
return assembly->assembly;
*params = ref_assembly;
mono_runtime_invoke_checked (assembly_load_method, domain->domain, params, &error);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
+ mono_error_cleanup (&error);
}
/*
MonoError error;
MonoString *res = NULL;
res = mono_string_new_utf16_checked (mono_domain_get (), process_guid, sizeof(process_guid)/2, &error);
- mono_error_raise_exception (&error);
+ mono_error_set_pending_exception (&error);
return res;
}
memcpy (process_guid, mono_string_chars(newguid), sizeof(process_guid));
/* Have to attach to the runtime so shutdown can wait for this thread */
/* Force it to be attached to avoid racing during shutdown. */
thread = mono_thread_attach_full (mono_get_root_domain (), TRUE, &error);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
+ if (!is_ok (&error)) {
+ data->failure_reason = g_strdup (mono_error_get_message (&error));
+ mono_error_cleanup (&error);
+ goto failure;
+ }
mono_thread_set_name_internal (thread->internal_thread, mono_string_new (mono_get_root_domain (), "Domain unloader"), TRUE, &error);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
+ if (!is_ok (&error)) {
+ data->failure_reason = g_strdup (mono_error_get_message (&error));
+ mono_error_cleanup (&error);
+ goto failure;
+ }
/*
* FIXME: Abort our parent thread last, so we can return a failure
result->sre_method = FALSE;
result->signature = NULL;
- if (!context->method_inst) {
+ if (iresult->context.method_inst) {
/* Set the generic_container of the result to the generic_container of method */
MonoGenericContainer *generic_container = mono_method_get_generic_container (method);
- if (generic_container) {
+ if (generic_container && iresult->context.method_inst == generic_container->context.method_inst) {
result->is_generic = 1;
mono_method_set_generic_container (result, generic_container);
}
void
mono_mb_emit_cominterop_call (MonoMethodBuilder *mb, MonoMethodSignature *sig, MonoMethod* method)
{
+#ifndef DISABLE_JIT
// get function pointer from 1st arg, the COM interface pointer
mono_mb_emit_ldarg (mb, 0);
mono_mb_emit_icon (mb, cominterop_get_com_slot_for_method (method));
mono_mb_emit_calli (mb, sig);
mono_mb_emit_byte (mb, MONO_CUSTOM_PREFIX);
mono_mb_emit_byte (mb, CEE_MONO_RESTORE_LMF);
+#endif /* DISABLE_JIT */
}
void
mono_cominterop_emit_ptr_to_object_conv (MonoMethodBuilder *mb, MonoType *type, MonoMarshalConv conv, MonoMarshalSpec *mspec)
{
+#ifndef DISABLE_JIT
switch (conv) {
case MONO_MARSHAL_CONV_OBJECT_INTERFACE:
case MONO_MARSHAL_CONV_OBJECT_IUNKNOWN:
default:
g_assert_not_reached ();
}
+#endif /* DISABLE_JIT */
}
void
mono_cominterop_emit_object_to_ptr_conv (MonoMethodBuilder *mb, MonoType *type, MonoMarshalConv conv, MonoMarshalSpec *mspec)
{
+#ifndef DISABLE_JIT
switch (conv) {
case MONO_MARSHAL_CONV_OBJECT_INTERFACE:
case MONO_MARSHAL_CONV_OBJECT_IDISPATCH:
default:
g_assert_not_reached ();
}
+#endif /* DISABLE_JIT */
}
/**
sig = mono_method_signature (method);
mb = mono_mb_new (method->klass, method->name, MONO_WRAPPER_COMINTEROP);
+#ifndef DISABLE_JIT
/* if method klass is import, that means method
* is really a com call. let interop system emit it.
*/
imported classes is not yet implemented.");
mono_mb_emit_exception (mb, "NotSupportedException", msg);
}
+#endif /* DISABLE_JIT */
+
csig = mono_metadata_signature_dup_full (method->klass->image, sig);
csig->pinvoke = 0;
res = mono_mb_create_and_cache (cache, method,
mb = mono_mb_new (method->klass, method->name, MONO_WRAPPER_COMINTEROP_INVOKE);
+#ifndef DISABLE_JIT
/* get real proxy object, which is a ComInteropProxy in this case*/
mono_mb_add_local (mb, &mono_defaults.object_class->byval_arg);
mono_mb_emit_ldarg (mb, 0);
mono_marshal_emit_thread_interrupt_checkpoint (mb);
mono_mb_emit_byte (mb, CEE_RET);
+#endif /* DISABLE_JIT */
res = mono_mb_create_and_cache (cache, method, mb, sig, sig->param_count + 16);
mono_mb_free (mb);
if (!marshal_release)
marshal_release = mono_class_get_method_from_name (mono_defaults.marshal_class, "Release", 1);
+#ifdef DISABLE_JIT
+ switch (action) {
+ case MARSHAL_ACTION_CONV_IN:
+ *conv_arg_type = &mono_defaults.int_class->byval_arg;
+ break;
+ case MARSHAL_ACTION_MANAGED_CONV_IN:
+ *conv_arg_type = &mono_defaults.int_class->byval_arg;
+ break;
+ default:
+ break;
+ }
+#else
switch (action) {
case MARSHAL_ACTION_CONV_IN: {
guint32 pos_null = 0;
default:
g_assert_not_reached ();
}
+#endif /* DISABLE_JIT */
return conv_arg;
}
mspecs [0] = NULL;
}
+#ifndef DISABLE_JIT
/* skip visiblity since we call internal methods */
mb->skip_visibility = TRUE;
+#endif
cominterop_setup_marshal_context (&m, adjust_method);
m.mb = mb;
vtable [vtable_index--] = mono_compile_method (wrapper_method);
-
for (param_index = sig_adjusted->param_count; param_index >= 0; param_index--)
if (mspecs [param_index])
mono_metadata_free_marshal_spec (mspecs [param_index]);
mspecs [0] = NULL;
- if (!preserve_sig) {
+#ifndef DISABLE_JIT
+ if (!preserve_sig)
hr = mono_mb_add_local (mb, &mono_defaults.int32_class->byval_arg);
- }
else if (!MONO_TYPE_IS_VOID (sig->ret))
hr = mono_mb_add_local (mb, sig->ret);
mono_mb_emit_ldloc (mb, hr);
mono_mb_emit_byte (mb, CEE_RET);
+#endif /* DISABLE_JIT */
mono_cominterop_lock ();
res = mono_mb_create_method (mb, sig_native, sig_native->param_count + 16);
{
MonoMethodBuilder *mb = m->mb;
+#ifndef DISABLE_JIT
switch (action) {
-
case MARSHAL_ACTION_CONV_IN: {
-
if (t->attrs & PARAM_ATTRIBUTE_IN) {
/* Generates IL code for the following algorithm:
break;
case MARSHAL_ACTION_CONV_OUT: {
-
if (t->attrs & PARAM_ATTRIBUTE_OUT) {
/* Generates IL code for the following algorithm:
default:
g_assert_not_reached ();
}
+#endif /* DISABLE_JIT */
return conv_arg;
}
mono_assembly_load_friends (ass);
- mono_defaults.handleref_class = mono_class_load_from_name (
+ mono_defaults.handleref_class = mono_class_try_load_from_name (
mono_defaults.corlib, "System.Runtime.InteropServices", "HandleRef");
mono_defaults.attribute_class = mono_class_load_from_name (
}
g_free (buf);
- mono_error_raise_exception (&error);
+ mono_error_set_pending_exception (&error);
return result;
}
ICALL(ASSEMN_2, "get_public_token", mono_digest_get_public_token)
ICALL_TYPE(CATTR_DATA, "System.Reflection.CustomAttributeData", CATTR_DATA_1)
-ICALL(CATTR_DATA_1, "ResolveArgumentsInternal", mono_reflection_resolve_custom_attribute_data)
+ICALL(CATTR_DATA_1, "ResolveArgumentsInternal", ves_icall_System_Reflection_CustomAttributeData_ResolveArgumentsInternal)
ICALL_TYPE(ASSEMB, "System.Reflection.Emit.AssemblyBuilder", ASSEMB_1)
ICALL(ASSEMB_1, "InternalAddModule", ves_icall_System_Reflection_Emit_AssemblyBuilder_InternalAddModule)
ICALL(ASSEMB_2, "basic_init", mono_image_basic_init)
+#ifndef DISABLE_REFLECTION_EMIT
ICALL_TYPE(CATTRB, "System.Reflection.Emit.CustomAttributeBuilder", CATTRB_1)
ICALL(CATTRB_1, "GetBlob", ves_icall_System_Reflection_Emit_CustomAttributeBuilder_GetBlob)
-
-#ifndef DISABLE_REFLECTION_EMIT
-ICALL_TYPE(DERIVEDTYPE, "System.Reflection.Emit.DerivedType", DERIVEDTYPE_1)
-ICALL(DERIVEDTYPE_1, "create_unmanaged_type", mono_reflection_create_unmanaged_type)
#endif
ICALL_TYPE(DYNM, "System.Reflection.Emit.DynamicMethod", DYNM_1)
ICALL(SIGH_1, "get_signature_field", mono_reflection_sighelper_get_signature_field)
ICALL(SIGH_2, "get_signature_local", mono_reflection_sighelper_get_signature_local)
+#ifndef DISABLE_REFLECTION_EMIT
+ICALL_TYPE(SYMBOLTYPE, "System.Reflection.Emit.SymbolType", SYMBOLTYPE_1)
+ICALL(SYMBOLTYPE_1, "create_unmanaged_type", mono_reflection_create_unmanaged_type)
+#endif
+
ICALL_TYPE(TYPEB, "System.Reflection.Emit.TypeBuilder", TYPEB_1)
-ICALL(TYPEB_1, "create_generic_class", mono_reflection_create_generic_class)
+ICALL(TYPEB_1, "create_generic_class", ves_icall_System_Reflection_Emit_TypeBuilder_create_generic_class)
ICALL(TYPEB_2, "create_internal_class", mono_reflection_create_internal_class)
ICALL(TYPEB_3, "create_runtime_class", mono_reflection_create_runtime_class)
ICALL(TYPEB_4, "get_IsGenericParameter", ves_icall_TypeBuilder_get_IsGenericParameter)
ICALL_TYPE(MCMETH, "System.Reflection.MonoCMethod", MCMETH_1)
ICALL(MCMETH_1, "GetGenericMethodDefinition_impl", ves_icall_MonoMethod_GetGenericMethodDefinition)
ICALL(MCMETH_2, "InternalInvoke", ves_icall_InternalInvoke)
+ICALL(MCMETH_3, "get_core_clr_security_level", ves_icall_MonoMethod_get_core_clr_security_level)
ICALL_TYPE(MEVIN, "System.Reflection.MonoEventInfo", MEVIN_1)
ICALL(MEVIN_1, "get_event_info", ves_icall_MonoEventInfo_get_event_info)
klass = mono_class_from_mono_type (type->type);
mono_class_init_checked (klass, &error);
- mono_error_raise_exception (&error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
if (bounds && (mono_array_length (bounds) == 1) && (mono_array_get (bounds, gint32, 0) != 0))
/* vectors are not the same as one dimensional arrays with no-zero bounds */
klass = mono_class_from_mono_type (type->type);
mono_class_init_checked (klass, &error);
- mono_error_raise_exception (&error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
if (bounds && (mono_array_length (bounds) == 1) && (mono_array_get (bounds, gint64, 0) != 0))
/* vectors are not the same as one dimensional arrays with no-zero bounds */
#endif
ret = mono_type_get_object_checked (mono_object_domain (obj), &obj->vtable->klass->byval_arg, &error);
- mono_error_raise_exception (&error);
-
+ mono_error_set_pending_exception (&error);
return ret;
}
MonoError error;
gint32 result = mono_image_create_token (mb->dynamic_image, obj, create_open_instance, TRUE, &error);
- mono_error_raise_exception (&error);
+ mono_error_set_pending_exception (&error);
return result;
}
MonoError error;
gint32 result = mono_image_create_method_token (
mb->dynamic_image, (MonoObject *) method, opt_param_types, &error);
- mono_error_raise_exception (&error);
+ mono_error_set_pending_exception (&error);
return result;
}
{
MonoError error;
mono_image_create_pefile (mb, file, &error);
- mono_error_raise_exception (&error);
+ mono_error_set_pending_exception (&error);
}
ICALL_EXPORT void
ves_icall_ModuleBuilder_build_metadata (MonoReflectionModuleBuilder *mb)
{
MonoError error;
- if (!mono_image_build_metadata (mb, &error))
- mono_error_raise_exception (&error);
+ mono_image_build_metadata (mb, &error);
+ mono_error_set_pending_exception (&error);
}
ICALL_EXPORT void
return result;
}
+/**
+ * ves_icall_System_Reflection_Emit_TypeBuilder_create_generic_class:
+ * @tb: a TypeBuilder object
+ *
+ * (icall)
+ * Creates the generic class after all generic parameters have been added.
+ */
+ICALL_EXPORT void
+ves_icall_System_Reflection_Emit_TypeBuilder_create_generic_class (MonoReflectionTypeBuilder *tb)
+{
+ MonoError error;
+ (void) mono_reflection_create_generic_class (tb, &error);
+ mono_error_set_pending_exception (&error);
+}
+
+#ifndef DISABLE_REFLECTION_EMIT
ICALL_EXPORT MonoArray*
ves_icall_System_Reflection_Emit_CustomAttributeBuilder_GetBlob (MonoReflectionAssembly *assembly, MonoObject *ctor, MonoArray *ctorArgs, MonoArray *properties, MonoArray *propValues, MonoArray *fields, MonoArray* fieldValues)
{
mono_error_set_pending_exception (&error);
return result;
}
+#endif
static gboolean
get_executing (MonoMethod *m, gint32 no, gint32 ilo, gboolean managed, gpointer data)
MonoDomain *domain = mono_domain_get ();
ret = mono_type_get_object_checked (domain, handle, &error);
- mono_error_raise_exception (&error);
+ mono_error_set_pending_exception (&error);
return ret;
}
}
MonoReflectionField *result = mono_field_get_object_checked (mono_domain_get (), klass, handle, &error);
- mono_error_raise_exception (&error);
+ mono_error_set_pending_exception (&error);
return result;
}
}
res = type_array_from_modifiers (field->field->parent->image, type, optional, &error);
- mono_error_raise_exception (&error);
+ mono_error_set_pending_exception (&error);
return res;
}
parent = declaring? field->field->parent: field->klass;
ret = mono_type_get_object_checked (mono_object_domain (field), &parent->byval_arg, &error);
- mono_error_raise_exception (&error);
+ mono_error_set_pending_exception (&error);
return ret;
if ((req_info & PInfo_ReflectedType) != 0) {
rt = mono_type_get_object_checked (domain, &property->klass->byval_arg, &error);
- mono_error_raise_exception (&error);
+ if (mono_error_set_pending_exception (&error))
+ return;
MONO_STRUCT_SETREF (info, parent, rt);
}
if ((req_info & PInfo_DeclaringType) != 0) {
rt = mono_type_get_object_checked (domain, &pproperty->parent->byval_arg, &error);
- mono_error_raise_exception (&error);
+ if (mono_error_set_pending_exception (&error))
+ return;
MONO_STRUCT_SETREF (info, declaring_type, rt);
}
(((pproperty->get->flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK) != METHOD_ATTRIBUTE_PRIVATE) ||
pproperty->get->klass == property->klass)) {
rm = mono_method_get_object_checked (domain, pproperty->get, property->klass, &error);
- mono_error_raise_exception (&error);
+ if (mono_error_set_pending_exception (&error))
+ return;
} else {
rm = NULL;
}
(((pproperty->set->flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK) != METHOD_ATTRIBUTE_PRIVATE) ||
pproperty->set->klass == property->klass)) {
rm = mono_method_get_object_checked (domain, pproperty->set, property->klass, &error);
- mono_error_raise_exception (&error);
+ if (mono_error_set_pending_exception (&error))
+ return;
} else {
rm = NULL;
}
MonoDomain *domain = mono_object_domain (event);
rt = mono_type_get_object_checked (domain, &event->klass->byval_arg, &error);
- mono_error_raise_exception (&error);
+ if (mono_error_set_pending_exception (&error))
+ return;
MONO_STRUCT_SETREF (info, reflected_type, rt);
rt = mono_type_get_object_checked (domain, &event->event->parent->byval_arg, &error);
- mono_error_raise_exception (&error);
+ if (mono_error_set_pending_exception (&error))
+ return;
MONO_STRUCT_SETREF (info, declaring_type, rt);
if (event->event->add) {
rm = mono_method_get_object_checked (domain, event->event->add, NULL, &error);
- mono_error_raise_exception (&error);
+ if (mono_error_set_pending_exception (&error))
+ return;
} else {
rm = NULL;
}
if (event->event->remove) {
rm = mono_method_get_object_checked (domain, event->event->remove, NULL, &error);
- mono_error_raise_exception (&error);
+ if (mono_error_set_pending_exception (&error))
+ return;
} else {
rm = NULL;
}
if (event->event->raise) {
rm = mono_method_get_object_checked (domain, event->event->raise, NULL, &error);
- mono_error_raise_exception (&error);
+ if (mono_error_set_pending_exception (&error))
+ return;
} else {
rm = NULL;
}
for (i = 0; i < n; i++) {
rm = mono_method_get_object_checked (domain, event->event->other [i], NULL, &error);
- mono_error_raise_exception (&error);
+ if (mono_error_set_pending_exception (&error))
+ return;
mono_array_setref (info->other_methods, i, rm);
}
}
MonoError error;
mono_class_init_checked (klass, &error);
- mono_error_raise_exception (&error);
+ if (mono_error_set_pending_exception (&error))
+ return;
mono_class_init_checked (iclass, &error);
- mono_error_raise_exception (&error);
+ if (mono_error_set_pending_exception (&error))
+ return;
mono_class_setup_vtable (klass);
iter = NULL;
while ((method = mono_class_get_methods (iclass, &iter))) {
member = mono_method_get_object_checked (domain, method, iclass, &error);
- mono_error_raise_exception (&error);
+ if (mono_error_set_pending_exception (&error))
+ return;
mono_array_setref (*methods, i, member);
member = mono_method_get_object_checked (domain, klass->vtable [i + ioffset], klass, &error);
- mono_error_raise_exception (&error);
+ if (mono_error_set_pending_exception (&error))
+ return;
mono_array_setref (*targets, i, member);
i ++;
MonoClass *klass = mono_class_from_mono_type (type->type);
mono_class_init_checked (klass, &error);
- mono_error_raise_exception (&error);
+ if (mono_error_set_pending_exception (&error))
+ return;
if (image_is_dynamic (klass->image)) {
MonoReflectionTypeBuilder *tb = (MonoReflectionTypeBuilder*)type;
if (!type->type->byref && type->type->type == MONO_TYPE_SZARRAY) {
ret = mono_type_get_object_checked (mono_object_domain (type), &type->type->data.klass->byval_arg, &error);
- mono_error_raise_exception (&error);
-
+ mono_error_set_pending_exception (&error);
return ret;
}
klass = mono_class_from_mono_type (type->type);
mono_class_init_checked (klass, &error);
- mono_error_raise_exception (&error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
+
// GetElementType should only return a type for:
// Array Pointer PassedByRef
else
return NULL;
- mono_error_raise_exception (&error);
+ mono_error_set_pending_exception (&error);
return ret;
}
return NULL;
ret = mono_type_get_object_checked (mono_object_domain (type), &klass->parent->byval_arg, &error);
- mono_error_raise_exception (&error);
+ mono_error_set_pending_exception (&error);
return ret;
}
MonoError error;
MonoClass *klass = mono_class_from_mono_type (type->type);
mono_class_init_checked (klass, &error);
- mono_error_raise_exception (&error);
+ if (mono_error_set_pending_exception (&error))
+ return FALSE;
return mono_class_is_com_object (klass);
}
MonoReflectionModule *result = NULL;
MonoClass *klass = mono_class_from_mono_type (type->type);
result = mono_module_get_object_checked (mono_object_domain (type), klass->image, &error);
- if (!mono_error_ok (&error))
- mono_error_set_pending_exception (&error);
+ mono_error_set_pending_exception (&error);
return result;
}
MonoDomain *domain = mono_domain_get ();
MonoClass *klass = mono_class_from_mono_type (type->type);
MonoReflectionAssembly *result = mono_assembly_get_object_checked (domain, klass->image->assembly, &error);
- if (!result)
- mono_error_set_pending_exception (&error);
+ mono_error_set_pending_exception (&error);
return result;
}
return NULL;
ret = mono_type_get_object_checked (domain, &klass->byval_arg, &error);
- mono_error_raise_exception (&error);
+ mono_error_set_pending_exception (&error);
return ret;
}
pklass = mono_class_from_generic_parameter_internal (mono_generic_container_get_param (container, i));
rt = mono_type_get_object_checked (domain, &pklass->byval_arg, &error);
- mono_error_raise_exception (&error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
mono_array_setref (res, i, rt);
}
res = create_type_array (domain, runtimeTypeArray, inst->type_argc);
for (i = 0; i < inst->type_argc; ++i) {
rt = mono_type_get_object_checked (domain, inst->type_argv [i], &error);
- mono_error_raise_exception (&error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
mono_array_setref (res, i, rt);
}
return (MonoReflectionType *)tb;
else {
ret = mono_type_get_object_checked (mono_object_domain (type), &generic_class->byval_arg, &error);
- mono_error_raise_exception (&error);
+ mono_error_set_pending_exception (&error);
return ret;
}
g_assert (IS_MONOTYPE (type));
mono_class_init_checked (mono_class_from_mono_type (type->type), &error);
- mono_error_raise_exception (&error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
count = mono_array_length (type_array);
types = g_new0 (MonoType *, count);
}
ret = mono_type_get_object_checked (mono_object_domain (type), geninst, &error);
- mono_error_raise_exception (&error);
+ mono_error_set_pending_exception (&error);
return ret;
}
res = mono_array_new (domain, mono_defaults.monotype_class, count);
for (i = 0; i < count; i++) {
rt = mono_type_get_object_checked (domain, ¶m_info->constraints [i]->byval_arg, &error);
- mono_error_raise_exception (&error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
mono_array_setref (res, i, rt);
}
klass = mono_class_from_mono_type (type->type);
mono_class_init_checked (klass, &error);
- mono_error_raise_exception (&error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
iter = NULL;
while ((method = mono_class_get_methods (klass, &iter))) {
if (method->token == generic->method->token) {
ret = mono_method_get_object_checked (domain, method, klass, &error);
- mono_error_raise_exception (&error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
}
}
for (i = 0; i < count; i++) {
rt = mono_type_get_object_checked (domain, inst->type_argv [i], &error);
- mono_error_raise_exception (&error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
mono_array_setref (res, i, rt);
}
MonoClass *pklass = mono_class_from_generic_parameter_internal (param);
rt = mono_type_get_object_checked (domain, &pklass->byval_arg, &error);
- mono_error_raise_exception (&error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
mono_array_setref (res, i, rt);
}
enumc = mono_class_from_mono_type (enumType->type);
mono_class_init_checked (enumc, &error);
- mono_error_raise_exception (&error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
etype = mono_class_enum_basetype (enumc);
res = mono_object_new_checked (domain, enumc, &error);
- mono_error_raise_exception (&error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
write_enum_value ((char *)res + sizeof (MonoObject), etype->type, value);
return res;
enumc = mono_class_from_mono_type (mono_class_enum_basetype (eobj->vtable->klass));
res = mono_object_new_checked (mono_object_domain (eobj), enumc, &error);
- mono_error_raise_exception (&error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
dst = (char *)res + sizeof (MonoObject);
src = (char *)eobj + sizeof (MonoObject);
size = mono_class_value_size (enumc, NULL);
klass = mono_class_from_mono_type (type->type);
mono_class_init_checked (klass, &error);
- mono_error_raise_exception (&error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
etype = mono_class_enum_basetype (klass);
if (!etype) {
}
ret = mono_type_get_object_checked (mono_object_domain (type), etype, &error);
- mono_error_raise_exception (&error);
+ mono_error_set_pending_exception (&error);
return ret;
}
gboolean sorted = TRUE;
mono_class_init_checked (enumc, &error);
- mono_error_raise_exception (&error);
+ if (mono_error_set_pending_exception (&error))
+ return FALSE;
+
if (!enumc->enumtype) {
mono_set_pending_exception (mono_get_exception_argument ("enumType", "Type provided must be an Enum."));
return res;
fail:
mono_ptr_array_destroy (tmp_array);
- mono_error_raise_exception (&error);
- g_assert_not_reached ();
+ mono_error_set_pending_exception (&error);
+ return NULL;
}
static gboolean
MonoReflectionType *rt;
MonoDomain *domain;
MonoClass *klass;
- MonoArray *res;
+ MonoArray *res = NULL;
int i, match;
MonoClass *nested;
gpointer iter;
char *str = NULL;
MonoPtrArray tmp_array;
+ mono_error_init (&error);
+
domain = ((MonoObject *)type)->vtable->domain;
if (type->type->byref)
return mono_array_new (domain, mono_defaults.monotype_class, 0);
}
rt = mono_type_get_object_checked (domain, &nested->byval_arg, &error);
- mono_error_raise_exception (&error);
+ if (!is_ok (&error))
+ goto leave;
mono_ptr_array_append (tmp_array, (MonoObject*) rt);
}
for (i = 0; i < mono_ptr_array_size (tmp_array); ++i)
mono_array_setref (res, i, mono_ptr_array_get (tmp_array, i));
+leave:
mono_ptr_array_destroy (tmp_array);
g_free (str);
+ mono_error_set_pending_exception (&error);
return res;
}
aname = (MonoReflectionAssemblyName *) mono_object_new_checked (
domain, mono_class_get_assembly_name_class (), &error);
- mono_error_raise_exception (&error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
MONO_OBJECT_SETREF (aname, name, mono_string_new (domain, mono_metadata_string_heap (image, cols [MONO_ASSEMBLYREF_NAME])));
aname->hashalg = ASSEMBLY_HASH_SHA1; /* SHA1 (default) */
version = create_version (domain, aname->major, aname->minor, aname->build, aname->revision, &error);
- mono_error_raise_exception (&error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
MONO_OBJECT_SETREF (aname, version, version);
args [1] = &assembly_ref;
o = mono_runtime_invoke_checked (create_culture, NULL, args, &error);
- mono_error_raise_exception (&error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
MONO_OBJECT_SETREF (aname, cultureInfo, o);
}
MonoReflectionModule *rm = mono_module_get_object_checked (mono_domain_get (), module, &error);
- mono_error_raise_exception (&error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
mono_gc_wbarrier_generic_store (ref_module, (MonoObject*) rm);
return (void*)mono_image_get_resource (module, cols [MONO_MANIFEST_OFFSET], (guint32*)size);
res = mono_array_new (domain, klass, 1 + real_module_count + file_count);
MonoReflectionModule *image_obj = mono_module_get_object_checked (domain, image, &error);
- mono_error_raise_exception (&error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
+
mono_array_setref (res, 0, image_obj);
j = 1;
for (i = 0; i < module_count; ++i)
if (modules [i]) {
MonoReflectionModule *rm = mono_module_get_object_checked (domain, modules[i], &error);
- mono_error_raise_exception (&error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
mono_array_setref (res, j, rm);
++j;
}
mono_metadata_decode_row (table, i, cols, MONO_FILE_SIZE);
if (cols [MONO_FILE_FLAGS] && FILE_CONTAINS_NO_METADATA) {
MonoReflectionModule *rm = mono_module_file_get_object_checked (domain, image, i, &error);
- mono_error_raise_exception (&error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
mono_array_setref (res, j, rm);
}
else {
return NULL;
}
MonoReflectionModule *rm = mono_module_get_object_checked (domain, m, &error);
- mono_error_raise_exception (&error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
mono_array_setref (res, j, rm);
}
}
m = ((MonoMethodInflated*)m)->declaring;
res = mono_method_get_object_checked (mono_domain_get (), m, NULL, &error);
- mono_error_raise_exception (&error);
+ mono_error_set_pending_exception (&error);
return res;
}
} else
klass = method->klass;
res = mono_method_get_object_checked (mono_domain_get (), method, klass, &error);
- mono_error_raise_exception (&error);
+ mono_error_set_pending_exception (&error);
return res;
}
MonoClass *klass = mono_class_from_mono_type (rfield->type);
mono_class_init_checked (klass, &error);
- mono_error_raise_exception (&error);
+ mono_error_set_pending_exception (&error);
return mono_security_core_clr_class_level (klass);
}
image = assembly->assembly->image;
table = &image->tables [MONO_TABLE_FILE];
res = mono_module_get_types (domain, image, &exceptions, exportedOnly, &error);
- mono_error_raise_exception (&error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
/* Append data from all modules in the assembly */
for (i = 0; i < table->rows; ++i) {
MonoArray *res2;
res2 = mono_module_get_types (domain, loaded_image, &ex2, exportedOnly, &error);
- mono_error_raise_exception (&error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
+
/* Append the new types to the end of the array */
if (mono_array_length (res2) > 0) {
MonoArray *res;
res = mono_module_get_types (mono_object_domain (module), module->image, &exceptions, FALSE, &error);
- mono_error_raise_exception (&error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
for (i = 0; i < mono_array_length (exceptions); ++i) {
MonoException *ex = mono_array_get (exceptions, MonoException *, i);
MonoType *t = ves_icall_System_Reflection_Module_ResolveTypeToken (image, token, type_args, method_args, error);
if (t) {
ret = (MonoObject*) mono_type_get_object_checked (mono_domain_get (), t, &merror);
- mono_error_raise_exception (&merror);
+ mono_error_set_pending_exception (&merror);
return ret;
}
MonoMethod *m = ves_icall_System_Reflection_Module_ResolveMethodToken (image, token, type_args, method_args, error);
if (m) {
ret = (MonoObject*)mono_method_get_object_checked (mono_domain_get (), m, m->klass, &merror);
- mono_error_raise_exception (&merror);
+ mono_error_set_pending_exception (&merror);
return ret;
} else
MonoClassField *f = ves_icall_System_Reflection_Module_ResolveFieldToken (image, token, type_args, method_args, error);
if (f) {
ret =(MonoObject*)mono_field_get_object_checked (mono_domain_get (), f->parent, f, &merror);
- mono_error_raise_exception (&merror);
+ mono_error_set_pending_exception (&merror);
return ret;
}
else
MonoMethod *m = ves_icall_System_Reflection_Module_ResolveMethodToken (image, token, type_args, method_args, error);
if (m) {
ret = (MonoObject*)mono_method_get_object_checked (mono_domain_get (), m, m->klass, &merror);
- mono_error_raise_exception (&merror);
+ mono_error_set_pending_exception (&merror);
return ret;
} else
MonoClassField *f = ves_icall_System_Reflection_Module_ResolveFieldToken (image, token, type_args, method_args, error);
if (f) {
ret = (MonoObject*)mono_field_get_object_checked (mono_domain_get (), f->parent, f, &merror);
- mono_error_raise_exception (&merror);
+ mono_error_set_pending_exception (&merror);
return ret;
}
else
g_free (str);
ret = mono_type_get_object_checked (mono_object_domain (tb), &klass->this_arg, &error);
- mono_error_raise_exception (&error);
+ mono_error_set_pending_exception (&error);
return ret;
case '*':
g_free (str);
ret = mono_type_get_object_checked (mono_object_domain (tb), &klass->byval_arg, &error);
- mono_error_raise_exception (&error);
+ mono_error_set_pending_exception (&error);
return ret;
}
klass = mono_class_from_mono_type (type->type);
check_for_invalid_type (klass, &error);
- mono_error_raise_exception (&error);
+ mono_error_set_pending_exception (&error);
if (rank == 0) //single dimentional array
aklass = mono_array_class_get (klass, 1);
aklass = mono_bounded_array_class_get (klass, rank, TRUE);
ret = mono_type_get_object_checked (mono_object_domain (type), &aklass->byval_arg, &error);
- mono_error_raise_exception (&error);
+ mono_error_set_pending_exception (&error);
return ret;
}
klass = mono_class_from_mono_type (type->type);
mono_class_init_checked (klass, &error);
- mono_error_raise_exception (&error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
+
check_for_invalid_type (klass, &error);
- mono_error_raise_exception (&error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
ret = mono_type_get_object_checked (mono_object_domain (type), &klass->this_arg, &error);
- mono_error_raise_exception (&error);
+ mono_error_set_pending_exception (&error);
return ret;
}
klass = mono_class_from_mono_type (type->type);
mono_class_init_checked (klass, &error);
- mono_error_raise_exception (&error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
check_for_invalid_type (klass, &error);
- mono_error_raise_exception (&error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
pklass = mono_ptr_class_get (type->type);
ret = mono_type_get_object_checked (mono_object_domain (type), &pklass->byval_arg, &error);
- mono_error_raise_exception (&error);
+ mono_error_set_pending_exception (&error);
return ret;
}
MonoMethod *method = info->method;
mono_class_init_checked (delegate_class, &error);
- mono_error_raise_exception (&error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
if (!(delegate_class->parent == mono_defaults.multicastdelegate_class)) {
/* FIXME improve this exception message */
}
delegate = mono_object_new_checked (mono_object_domain (type), delegate_class, &error);
- mono_error_raise_exception (&error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
if (method_is_dynamic (method)) {
/* Creating a trampoline would leak memory */
g_assert (mono_class_has_parent (mono_object_class (delegate), mono_defaults.multicastdelegate_class));
ret = (MonoMulticastDelegate*) mono_object_new_checked (mono_object_domain (delegate), mono_object_class (delegate), &error);
- mono_error_raise_exception (&error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
+
ret->delegate.invoke_impl = mono_runtime_create_delegate_trampoline (mono_object_class (delegate));
return ret;
MonoReflectionMethod *ret = NULL;
MonoError error;
ret = mono_method_get_object_checked (mono_domain_get (), mono_object_get_virtual_method (delegate->target, delegate->method), mono_object_class (delegate->target), &error);
- mono_error_raise_exception (&error);
+ mono_error_set_pending_exception (&error);
return ret;
}
MonoClass *klass;
res = mono_object_new_checked (domain, mono_defaults.transparent_proxy_class, &error);
- mono_error_raise_exception (&error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
+
tp = (MonoTransparentProxy*) res;
MONO_OBJECT_SETREF (tp, rp, rp);
{
MonoError error;
MonoReflectionType *ret = mono_type_get_object_checked (mono_object_domain (tp), &tp->remote_class->proxy_class->byval_arg, &error);
- mono_error_raise_exception (&error);
+ mono_error_set_pending_exception (&error);
return ret;
}
if (GetComputerName (buf, (PDWORD) &len)) {
MonoError error;
result = mono_string_new_utf16_checked (mono_domain_get (), buf, len, &error);
- mono_error_raise_exception (&error);
+ mono_error_set_pending_exception (&error);
}
g_free (buf);
g_assert(equal_str);
MonoError error;
str = mono_string_new_utf16_checked (domain, env_string, equal_str-env_string, &error);
- mono_error_raise_exception (&error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
+
mono_array_setref (names, n, str);
n++;
}
++ len;
MonoError error;
MonoString *res = mono_string_new_utf16_checked (mono_domain_get (), path, len, &error);
- mono_error_raise_exception (&error);
+ mono_error_set_pending_exception (&error);
return res;
}
#else
u16 = dname;
while (*u16) { u16++; len ++; }
drivestr = mono_string_new_utf16_checked (domain, dname, len, &error);
- mono_error_raise_exception (&error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
+
mono_array_setref (result, ndrives++, drivestr);
while (*dname++);
} while (*dname);
method = rmethod->method;
klass = mono_class_from_mono_type (rtype->type);
mono_class_init_checked (klass, &error);
- mono_error_raise_exception (&error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
if (MONO_CLASS_IS_INTERFACE (klass))
return NULL;
return NULL;
ret = mono_method_get_object_checked (mono_domain_get (), res, NULL, &error);
- mono_error_raise_exception (&error);
+ mono_error_set_pending_exception (&error);
return ret;
}
domain = mono_object_domain (type);
klass = mono_class_from_mono_type (type->type);
mono_class_init_checked (klass, &error);
- mono_error_raise_exception (&error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
if (MONO_CLASS_IS_INTERFACE (klass) || (klass->flags & TYPE_ATTRIBUTE_ABSTRACT)) {
mono_set_pending_exception (mono_get_exception_argument ("type", "Type cannot be instantiated"));
domain = mono_object_domain (type);
klass = mono_class_from_mono_type (type->type);
mono_class_init_checked (klass, &error);
- mono_error_raise_exception (&error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
if (mono_class_is_nullable (klass))
/* No arguments -> null */
return NULL;
result = mono_object_new_checked (domain, klass, &error);
- mono_error_raise_exception (&error);
+ mono_error_set_pending_exception (&error);
return result;
}
*/
MonoGenericContext *parent_inst = NULL;
if (mono_class_is_open_constructed_type (mono_class_get_type (parent))) {
- MonoError error;
parent = mono_class_inflate_generic_class_checked (parent, generic_inst, &error);
if (!mono_error_ok (&error)) {
mono_error_set_pending_exception (&error);
return m;
ret = mono_method_get_object_checked (mono_domain_get (), result, NULL, &error);
- mono_error_raise_exception (&error);
+ mono_error_set_pending_exception (&error);
return ret;
}
MonoError error;
prelink_method (method->method, &error);
- mono_error_raise_exception (&error);
+ mono_error_set_pending_exception (&error);
}
ICALL_EXPORT void
gpointer iter = NULL;
mono_class_init_checked (klass, &error);
- mono_error_raise_exception (&error);
+ if (mono_error_set_pending_exception (&error))
+ return;
while ((m = mono_class_get_methods (klass, &iter))) {
prelink_method (m, &error);
- mono_error_raise_exception (&error);
+ if (mono_error_set_pending_exception (&error))
+ return;
}
}
type = sig->params [pos];
res = type_array_from_modifiers (image, type, optional, &error);
- mono_error_raise_exception (&error);
+ mono_error_set_pending_exception (&error);
return res;
}
if (!type)
return NULL;
res = type_array_from_modifiers (image, type, optional, &error);
- mono_error_raise_exception (&error);
+ mono_error_set_pending_exception (&error);
return res;
}
gboolean found;
mono_class_init_checked (attr_class, &error);
- mono_error_raise_exception (&error);
+ if (mono_error_set_pending_exception (&error))
+ return FALSE;
cinfo = mono_reflection_get_custom_attrs_info_checked (obj, &error);
if (!is_ok (&error)) {
if (attr_class) {
mono_class_init_checked (attr_class, &error);
- mono_error_raise_exception (&error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
}
res = mono_reflection_get_custom_attrs_by_type (obj, attr_class, &error);
message = mono_string_new (mono_domain_get (), "Error looking up error string");
} else {
message = mono_string_new_utf16_checked (mono_domain_get (), buf, ret, &error);
- mono_error_raise_exception (&error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
}
return message;
mono_type_to_stind (MonoType *type)
{
if (type->byref)
- return CEE_STIND_I;
+ return MONO_TYPE_IS_REFERENCE (type) ? CEE_STIND_REF : CEE_STIND_I;
+
handle_enum:
switch (type->type) {
mono_mb_emit_ldloc (mb, 1);
mono_mb_emit_icon (mb, mspec->data.array_data.num_elem);
mono_mb_emit_op (mb, CEE_NEWARR, eklass);
- mono_mb_emit_byte (mb, CEE_STIND_I);
+ mono_mb_emit_byte (mb, CEE_STIND_REF);
if (eklass->blittable) {
/* copy the elements */
}
static gpointer
-conv_to_icall (MonoMarshalConv conv)
+conv_to_icall (MonoMarshalConv conv, int *ind_store_type)
{
+ int dummy;
+ if (!ind_store_type)
+ ind_store_type = &dummy;
+ *ind_store_type = CEE_STIND_I;
switch (conv) {
case MONO_MARSHAL_CONV_STR_LPWSTR:
return mono_marshal_string_to_utf16;
case MONO_MARSHAL_CONV_LPWSTR_STR:
+ *ind_store_type = CEE_STIND_REF;
return mono_string_from_utf16;
case MONO_MARSHAL_CONV_LPTSTR_STR:
+ *ind_store_type = CEE_STIND_REF;
return mono_string_new_wrapper;
case MONO_MARSHAL_CONV_LPSTR_STR:
+ *ind_store_type = CEE_STIND_REF;
return mono_string_new_wrapper;
case MONO_MARSHAL_CONV_STR_LPTSTR:
#ifdef TARGET_WIN32
case MONO_MARSHAL_CONV_STR_BSTR:
return mono_string_to_bstr;
case MONO_MARSHAL_CONV_BSTR_STR:
+ *ind_store_type = CEE_STIND_REF;
return mono_string_from_bstr;
case MONO_MARSHAL_CONV_STR_TBSTR:
case MONO_MARSHAL_CONV_STR_ANSIBSTR:
case MONO_MARSHAL_CONV_DEL_FTN:
return mono_delegate_to_ftnptr;
case MONO_MARSHAL_CONV_FTN_DEL:
+ *ind_store_type = CEE_STIND_REF;
return mono_ftnptr_to_delegate;
case MONO_MARSHAL_CONV_LPSTR_SB:
+ *ind_store_type = CEE_STIND_REF;
return mono_string_utf8_to_builder;
case MONO_MARSHAL_CONV_LPTSTR_SB:
+ *ind_store_type = CEE_STIND_REF;
#ifdef TARGET_WIN32
return mono_string_utf16_to_builder;
#else
return mono_string_utf8_to_builder;
#endif
case MONO_MARSHAL_CONV_LPWSTR_SB:
+ *ind_store_type = CEE_STIND_REF;
return mono_string_utf16_to_builder;
case MONO_MARSHAL_FREE_ARRAY:
return mono_marshal_free_array;
emit_object_to_ptr_conv (MonoMethodBuilder *mb, MonoType *type, MonoMarshalConv conv, MonoMarshalSpec *mspec)
{
int pos;
+ int stind_op;
switch (conv) {
case MONO_MARSHAL_CONV_BOOL_I4:
mono_mb_emit_ldloc (mb, 1);
mono_mb_emit_ldloc (mb, 0);
mono_mb_emit_byte (mb, CEE_LDIND_REF);
- mono_mb_emit_icall (mb, conv_to_icall (conv));
- mono_mb_emit_byte (mb, CEE_STIND_I);
+ mono_mb_emit_icall (mb, conv_to_icall (conv, &stind_op));
+ mono_mb_emit_byte (mb, stind_op);
break;
}
case MONO_MARSHAL_CONV_ARRAY_SAVEARRAY:
mono_mb_emit_ldloc (mb, 1);
mono_mb_emit_ldloc (mb, 0);
mono_mb_emit_byte (mb, CEE_LDIND_REF);
- mono_mb_emit_icall (mb, conv_to_icall (conv));
- mono_mb_emit_byte (mb, CEE_STIND_I);
+ mono_mb_emit_icall (mb, conv_to_icall (conv, &stind_op));
+ mono_mb_emit_byte (mb, stind_op);
break;
case MONO_MARSHAL_CONV_STR_BYVALSTR:
case MONO_MARSHAL_CONV_STR_BYVALWSTR: {
mono_mb_emit_ldloc (mb, 0);
mono_mb_emit_byte (mb, CEE_LDIND_REF); /* src String */
mono_mb_emit_icon (mb, mspec->data.array_data.num_elem);
- mono_mb_emit_icall (mb, conv_to_icall (conv));
+ mono_mb_emit_icall (mb, conv_to_icall (conv, NULL));
break;
}
case MONO_MARSHAL_CONV_ARRAY_BYVALARRAY: {
case MONO_MARSHAL_CONV_NONE: {
int t;
- if (ftype->byref || ftype->type == MONO_TYPE_I ||
- ftype->type == MONO_TYPE_U) {
+ //XXX a byref field!?!? that's not allowed! and worse, it might miss a WB
+ g_assert (!ftype->byref);
+ if (ftype->type == MONO_TYPE_I || ftype->type == MONO_TYPE_U) {
mono_mb_emit_ldloc (mb, 1);
mono_mb_emit_ldloc (mb, 0);
mono_mb_emit_byte (mb, CEE_LDIND_I);
char *msg = g_strdup_printf ("string marshalling conversion %d not implemented", encoding);
mono_mb_emit_exception_marshal_directive (mb, msg);
} else {
- mono_mb_emit_icall (mb, conv_to_icall (conv));
+ mono_mb_emit_icall (mb, conv_to_icall (conv, NULL));
mono_mb_emit_stloc (mb, conv_arg);
}
mono_mb_emit_icall (mb, mono_string_new_len_wrapper);
mono_mb_emit_byte (mb, CEE_STIND_REF);
} else if (t->byref && (t->attrs & PARAM_ATTRIBUTE_OUT || !(t->attrs & PARAM_ATTRIBUTE_IN))) {
+ int stind_op;
mono_mb_emit_ldarg (mb, argnum);
mono_mb_emit_ldloc (mb, conv_arg);
- mono_mb_emit_icall (mb, conv_to_icall (conv));
- mono_mb_emit_byte (mb, CEE_STIND_REF);
+ mono_mb_emit_icall (mb, conv_to_icall (conv, &stind_op));
+ mono_mb_emit_byte (mb, stind_op);
need_free = TRUE;
}
}
mono_mb_emit_ldloc (mb, 0);
- mono_mb_emit_icall (mb, conv_to_icall (conv));
+ mono_mb_emit_icall (mb, conv_to_icall (conv, NULL));
mono_mb_emit_stloc (mb, 3);
/* free the string */
mono_mb_emit_ldarg (mb, argnum);
if (t->byref)
mono_mb_emit_byte (mb, CEE_LDIND_I);
- mono_mb_emit_icall (mb, conv_to_icall (conv));
+ mono_mb_emit_icall (mb, conv_to_icall (conv, NULL));
mono_mb_emit_stloc (mb, conv_arg);
break;
case MARSHAL_ACTION_MANAGED_CONV_OUT:
if (t->byref) {
if (conv_arg) {
+ int stind_op;
mono_mb_emit_ldarg (mb, argnum);
mono_mb_emit_ldloc (mb, conv_arg);
- mono_mb_emit_icall (mb, conv_to_icall (conv));
- mono_mb_emit_byte (mb, CEE_STIND_I);
+ mono_mb_emit_icall (mb, conv_to_icall (conv, &stind_op));
+ mono_mb_emit_byte (mb, stind_op);
}
}
break;
case MARSHAL_ACTION_MANAGED_CONV_RESULT:
- if (conv_to_icall (conv) == mono_marshal_string_to_utf16)
+ if (conv_to_icall (conv, NULL) == mono_marshal_string_to_utf16)
/* We need to make a copy so the caller is able to free it */
mono_mb_emit_icall (mb, mono_marshal_string_to_utf16_copy);
else
- mono_mb_emit_icall (mb, conv_to_icall (conv));
+ mono_mb_emit_icall (mb, conv_to_icall (conv, NULL));
mono_mb_emit_stloc (mb, 3);
break;
mono_mb_emit_stloc (mb, conv_arg);
} else {
mono_mb_emit_ldarg (mb, argnum);
- mono_mb_emit_icall (mb, conv_to_icall (MONO_MARSHAL_CONV_DEL_FTN));
+ mono_mb_emit_icall (mb, conv_to_icall (MONO_MARSHAL_CONV_DEL_FTN, NULL));
mono_mb_emit_stloc (mb, conv_arg);
}
} else if (klass == mono_defaults.stringbuilder_class) {
if (t->byref)
mono_mb_emit_byte (mb, CEE_LDIND_I);
- mono_mb_emit_icall (mb, conv_to_icall (conv));
+ mono_mb_emit_icall (mb, conv_to_icall (conv, NULL));
mono_mb_emit_stloc (mb, conv_arg);
} else if (klass->blittable) {
mono_mb_emit_byte (mb, CEE_LDNULL);
mono_mb_emit_ldarg (mb, argnum);
mono_mb_emit_ldloc (mb, conv_arg);
- mono_mb_emit_icall (mb, conv_to_icall (conv));
+ mono_mb_emit_icall (mb, conv_to_icall (conv, NULL));
}
if (need_free) {
mono_mb_emit_byte (mb, MONO_CUSTOM_PREFIX);
mono_mb_emit_op (mb, CEE_MONO_CLASSCONST, klass);
mono_mb_emit_ldloc (mb, conv_arg);
- mono_mb_emit_icall (mb, conv_to_icall (MONO_MARSHAL_CONV_FTN_DEL));
+ mono_mb_emit_icall (mb, conv_to_icall (MONO_MARSHAL_CONV_FTN_DEL, NULL));
mono_mb_emit_byte (mb, CEE_STIND_REF);
}
break;
mono_mb_emit_byte (mb, MONO_CUSTOM_PREFIX);
mono_mb_emit_op (mb, CEE_MONO_CLASSCONST, klass);
mono_mb_emit_ldloc (mb, 0);
- mono_mb_emit_icall (mb, conv_to_icall (MONO_MARSHAL_CONV_FTN_DEL));
+ mono_mb_emit_icall (mb, conv_to_icall (MONO_MARSHAL_CONV_FTN_DEL, NULL));
mono_mb_emit_stloc (mb, 3);
} else {
/* set src */
mono_mb_emit_ldarg (mb, argnum);
if (t->byref)
mono_mb_emit_byte (mb, CEE_LDIND_I);
- mono_mb_emit_icall (mb, conv_to_icall (MONO_MARSHAL_CONV_FTN_DEL));
+ mono_mb_emit_icall (mb, conv_to_icall (MONO_MARSHAL_CONV_FTN_DEL, NULL));
mono_mb_emit_stloc (mb, conv_arg);
break;
}
case MARSHAL_ACTION_MANAGED_CONV_OUT:
if (klass->delegate) {
if (t->byref) {
+ int stind_op;
mono_mb_emit_ldarg (mb, argnum);
mono_mb_emit_ldloc (mb, conv_arg);
- mono_mb_emit_icall (mb, conv_to_icall (MONO_MARSHAL_CONV_DEL_FTN));
- mono_mb_emit_byte (mb, CEE_STIND_I);
+ mono_mb_emit_icall (mb, conv_to_icall (MONO_MARSHAL_CONV_DEL_FTN, &stind_op));
+ mono_mb_emit_byte (mb, stind_op);
break;
}
}
case MARSHAL_ACTION_MANAGED_CONV_RESULT:
if (klass->delegate) {
- mono_mb_emit_icall (mb, conv_to_icall (MONO_MARSHAL_CONV_DEL_FTN));
+ mono_mb_emit_icall (mb, conv_to_icall (MONO_MARSHAL_CONV_DEL_FTN, NULL));
mono_mb_emit_stloc (mb, 3);
break;
}
mono_mb_emit_ldarg (mb, argnum);
if (t->byref)
mono_mb_emit_byte (mb, CEE_LDIND_I);
- mono_mb_emit_icall (mb, conv_to_icall (MONO_MARSHAL_CONV_ARRAY_LPARRAY));
+ mono_mb_emit_icall (mb, conv_to_icall (MONO_MARSHAL_CONV_ARRAY_LPARRAY, NULL));
mono_mb_emit_stloc (mb, conv_arg);
} else {
MonoClass *eklass;
/* Emit marshalling code */
if (is_string) {
+ int stind_op;
mono_mb_emit_ldloc (mb, dest_ptr);
mono_mb_emit_ldloc (mb, src_var);
mono_mb_emit_ldloc (mb, index_var);
mono_mb_emit_byte (mb, CEE_LDELEM_REF);
- mono_mb_emit_icall (mb, conv_to_icall (conv));
- mono_mb_emit_byte (mb, CEE_STIND_I);
+ mono_mb_emit_icall (mb, conv_to_icall (conv, &stind_op));
+ mono_mb_emit_byte (mb, stind_op);
} else {
/* set the src_ptr */
mono_mb_emit_ldloc (mb, src_var);
mono_mb_emit_byte (mb, CEE_CONV_OVF_I);
mono_mb_emit_op (mb, CEE_NEWARR, klass->element_class);
/* Store into argument */
- mono_mb_emit_byte (mb, CEE_STIND_I);
+ mono_mb_emit_byte (mb, CEE_STIND_REF);
}
}
mono_mb_emit_ldloc (mb, src_ptr);
mono_mb_emit_byte (mb, CEE_LDIND_I);
- mono_mb_emit_icall (mb, conv_to_icall (conv));
+ mono_mb_emit_icall (mb, conv_to_icall (conv, NULL));
if (need_free) {
/* src */
if (t->byref)
mono_mb_emit_byte (mb, CEE_LDIND_REF);
mono_mb_emit_ldloc (mb, conv_arg);
- mono_mb_emit_icall (mb, conv_to_icall (MONO_MARSHAL_FREE_LPARRAY));
+ mono_mb_emit_icall (mb, conv_to_icall (MONO_MARSHAL_FREE_LPARRAY, NULL));
}
break;
mono_mb_emit_ldloc (mb, src_ptr);
mono_mb_emit_byte (mb, CEE_LDIND_I);
- mono_mb_emit_icall (mb, conv_to_icall (conv));
+ mono_mb_emit_icall (mb, conv_to_icall (conv, NULL));
mono_mb_emit_byte (mb, CEE_STELEM_REF);
}
else {
/* Emit marshalling code */
if (is_string) {
+ int stind_op;
g_assert (conv != MONO_MARSHAL_CONV_INVALID);
/* dest */
mono_mb_emit_byte (mb, CEE_LDELEM_REF);
- mono_mb_emit_icall (mb, conv_to_icall (conv));
- mono_mb_emit_byte (mb, CEE_STIND_I);
+ mono_mb_emit_icall (mb, conv_to_icall (conv, &stind_op));
+ mono_mb_emit_byte (mb, stind_op);
}
else {
char *msg = g_strdup ("Marshalling of non-string and non-blittable arrays to managed code is not implemented.");
/* Emit marshalling code */
if (is_string) {
+ int stind_op;
g_assert (conv != MONO_MARSHAL_CONV_INVALID);
/* dest */
mono_mb_emit_byte (mb, CEE_LDELEM_REF);
- mono_mb_emit_icall (mb, conv_to_icall (conv));
- mono_mb_emit_byte (mb, CEE_STIND_I);
+ mono_mb_emit_icall (mb, conv_to_icall (conv, &stind_op));
+ mono_mb_emit_byte (mb, stind_op);
}
else {
char *msg = g_strdup ("Marshalling of non-string arrays to managed code is not implemented.");
return emit_marshal_string (m, argnum, t, spec, conv_arg, conv_arg_type, action);
case MONO_TYPE_CLASS:
case MONO_TYPE_OBJECT:
-#ifndef DISABLE_COM
+#if !defined(DISABLE_COM) && !defined(DISABLE_JIT)
if (spec && spec->native == MONO_NATIVE_STRUCT)
return emit_marshal_variant (m, argnum, t, spec, conv_arg, conv_arg_type, action);
+#endif
+#if !defined(DISABLE_COM)
if (spec && (spec->native == MONO_NATIVE_IUNKNOWN ||
spec->native == MONO_NATIVE_IDISPATCH ||
spec->native == MONO_NATIVE_INTERFACE))
#endif
}
+#ifndef DISABLE_JIT
/* Free the locals list so mono_mb_free () doesn't free the types twice */
g_list_free (mb->locals_list);
mb->locals_list = NULL;
+#endif
method->signature = signature;
if (!signature->hasthis)
mach_port_t host = mach_host_self();
vm_size_t page_size;
vm_statistics_data_t vmstat;
- if (KERN_SUCCESS != host_statistics(host, HOST_VM_INFO, (host_info_t)&vmstat, &count)) {
+ kern_return_t ret;
+ do {
+ ret = host_statistics(host, HOST_VM_INFO, (host_info_t)&vmstat, &count);
+ } while (ret == KERN_ABORTED);
+
+ if (ret != KERN_SUCCESS) {
g_warning ("Mono was unable to retrieve memory usage!");
return 0;
}
struct _MonoException {
MonoObject object;
+ MonoString *class_name;
+ MonoString *message;
+ MonoObject *_data;
+ MonoObject *inner_ex;
+ MonoString *help_link;
/* Stores the IPs and the generic sharing infos
(vtable/MRGCTX) of the frames. */
MonoArray *trace_ips;
- MonoObject *inner_ex;
- MonoString *message;
- MonoString *help_link;
- MonoString *class_name;
MonoString *stack_trace;
MonoString *remote_stack_trace;
gint32 remote_stack_index;
+ /* Dynamic methods referenced by the stack trace */
+ MonoObject *dynamic_methods;
gint32 hresult;
MonoString *source;
- MonoObject *_data;
+ MonoObject *serialization_manager;
MonoObject *captured_traces;
MonoArray *native_trace_ips;
- /* Dynamic methods referenced by the stack trace */
- MonoObject *dynamic_methods;
};
typedef struct {
void mono_reflection_setup_generic_class (MonoReflectionTypeBuilder *tb);
-void mono_reflection_create_generic_class (MonoReflectionTypeBuilder *tb);
+gboolean mono_reflection_create_generic_class (MonoReflectionTypeBuilder *tb, MonoError *error);
MonoReflectionType* mono_reflection_create_runtime_class (MonoReflectionTypeBuilder *tb);
mono_reflection_is_valid_dynamic_token (MonoDynamicImage *image, guint32 token);
void
-mono_reflection_resolve_custom_attribute_data (MonoReflectionMethod *method, MonoReflectionAssembly *assembly, gpointer data, guint32 data_length, MonoArray **ctor_args, MonoArray ** named_args);
+ves_icall_System_Reflection_CustomAttributeData_ResolveArgumentsInternal (MonoReflectionMethod *method, MonoReflectionAssembly *assembly, gpointer data, guint32 data_length, MonoArray **ctor_args, MonoArray ** named_args);
MonoType*
mono_reflection_type_get_handle (MonoReflectionType *ref, MonoError *error);
static MonoMethod * inflate_method (MonoReflectionType *type, MonoObject *obj, MonoError *error);
static guint32 create_typespec (MonoDynamicImage *assembly, MonoType *type);
-static void init_type_builder_generics (MonoObject *type);
+static void init_type_builder_generics (MonoObject *type, MonoError *error);
#define RESOLVE_TYPE(type, error) do { \
type = (MonoObject *)mono_reflection_type_resolve_user_types ((MonoReflectionType*)type, error); \
MonoType *type;
MonoClass *klass;
- init_type_builder_generics (fb->type);
+ init_type_builder_generics (fb->type, error);
+ return_val_if_nok (error, 0);
type = mono_reflection_type_get_handle ((MonoReflectionType*)fb->type, error);
return_val_if_nok (error, 0);
mono_error_init (error);
- init_type_builder_generics ((MonoObject*)m->inst);
+ init_type_builder_generics ((MonoObject*)m->inst, error);
+ return_val_if_nok (error, NULL);
method = inflate_method (m->inst, (MonoObject*)m->mb, error);
return_val_if_nok (error, NULL);
g_assert (tb->generic_params);
klass = mono_class_from_mono_type (type);
- if (tb->generic_container)
- mono_reflection_create_generic_class (tb);
+ if (tb->generic_container) {
+ if (!mono_reflection_create_generic_class (tb, error))
+ goto fail;
+ }
sigbuffer_add_value (&buf, MONO_TYPE_GENERICINST);
g_assert (klass->generic_container);
}
static void
-init_type_builder_generics (MonoObject *type)
+init_type_builder_generics (MonoObject *type, MonoError *error)
{
MonoReflectionTypeBuilder *tb;
+ mono_error_init (error);
+
if (!is_sre_type_builder(mono_object_class (type)))
return;
tb = (MonoReflectionTypeBuilder *)type;
if (tb && tb->generic_container)
- mono_reflection_create_generic_class (tb);
+ mono_reflection_create_generic_class (tb, error);
}
static guint32
mono_class_from_mono_type (typeb);
/*FIXME this is one more layer of ugliness due how types are created.*/
- init_type_builder_generics (fb->type);
+ init_type_builder_generics (fb->type, error);
+ return_val_if_nok (error, 0);
/* fb->type does not include the custom modifiers */
/* FIXME: We should do this in one place when a fieldbuilder is created */
MonoReflectionTypeBuilder *tb = (MonoReflectionTypeBuilder *)obj;
if (create_open_instance && tb->generic_params) {
MonoType *type;
- init_type_builder_generics (obj);
+ init_type_builder_generics (obj, error);
+ return_val_if_nok (error, 0);
type = mono_reflection_type_get_handle ((MonoReflectionType *)obj, error);
return_val_if_nok (error, 0);
token = mono_image_typedef_or_ref_full (assembly, type, TRUE);
CACHE_OBJECT (MonoReflectionModuleBuilder *, module, res, NULL);
}
-void
-mono_image_module_basic_init (MonoReflectionModuleBuilder *moduleb)
+static gboolean
+image_module_basic_init (MonoReflectionModuleBuilder *moduleb, MonoError *error)
{
MonoDynamicImage *image = moduleb->dynamic_image;
MonoReflectionAssemblyBuilder *ab = moduleb->assemblyb;
+ mono_error_init (error);
if (!image) {
- MonoError error;
int module_count;
MonoImage **new_modules;
MonoImage *ass;
*/
/*image = (MonoDynamicImage*)ab->dynamic_assembly->assembly.image; */
name = mono_string_to_utf8 (ab->name);
- fqname = mono_string_to_utf8_checked (moduleb->module.fqname, &error);
- if (!mono_error_ok (&error)) {
+ fqname = mono_string_to_utf8_checked (moduleb->module.fqname, error);
+ if (!is_ok (error)) {
g_free (name);
- mono_error_raise_exception (&error);
+ return FALSE;
}
image = create_dynamic_mono_image (ab->dynamic_assembly, name, fqname);
ass->modules = new_modules;
ass->module_count ++;
}
+ return TRUE;
+}
+
+void
+mono_image_module_basic_init (MonoReflectionModuleBuilder *moduleb)
+{
+ MonoError error;
+ (void) image_module_basic_init (moduleb, &error);
+ mono_error_set_pending_exception (&error);
}
void
MonoError error;
MonoReflectionModule *result;
result = mono_module_get_object_checked (domain, image, &error);
- mono_error_raise_exception (&error);
+ mono_error_cleanup (&error);
return result;
}
MonoError error;
MonoReflectionModule *result;
result = mono_module_file_get_object_checked (domain, image, table_index, &error);
- mono_error_cleanup (&error); /* FIXME new API that doesn't swallow the error */
+ mono_error_cleanup (&error);
return result;
}
{
MonoError error;
MonoReflectionType *ret = mono_type_get_object_checked (domain, type, &error);
- mono_error_raise_exception (&error);
+ mono_error_cleanup (&error);
return ret;
}
MonoError error;
MonoReflectionMethod *ret = NULL;
ret = mono_method_get_object_checked (domain, method, refclass, &error);
- mono_error_raise_exception (&error);
+ mono_error_cleanup (&error);
return ret;
}
MonoError error;
MonoReflectionField *result;
result = mono_field_get_object_checked (domain, klass, field, &error);
- mono_error_raise_exception (&error);
+ mono_error_cleanup (&error);
return result;
}
MonoError error;
MonoReflectionProperty *result;
result = mono_property_get_object_checked (domain, klass, property, &error);
- mono_error_raise_exception (&error);
+ mono_error_cleanup (&error);
return result;
}
MonoError error;
MonoReflectionEvent *result;
result = mono_event_get_object_checked (domain, klass, event, &error);
- mono_error_raise_exception (&error);
+ mono_error_cleanup (&error);
return result;
}
{
MonoError error;
MonoReflectionMethodBody *result = mono_method_body_get_object_checked (domain, method, &error);
- mono_error_cleanup (&error); /* FIXME better API that doesn't swallow the error */
+ mono_error_cleanup (&error);
return result;
}
void *params_buf [32];
void **params = NULL;
MonoMethodSignature *sig;
- MonoObject *exc = NULL;
mono_error_init (error);
attr = mono_object_new_checked (mono_domain_get (), method->klass, error);
if (!mono_error_ok (error)) goto fail;
+ MonoObject *exc = NULL;
mono_runtime_try_invoke (method, attr, params, &exc, error);
if (!mono_error_ok (error))
goto fail;
- if (exc)
+ if (exc) {
+ mono_error_set_exception_instance (error, (MonoException*)exc);
goto fail;
+ }
num_named = read16 (named);
named += 2;
free_param_data (method->signature, params);
if (params != params_buf)
mono_gc_free_fixed (params);
- if (exc)
- mono_raise_exception ((MonoException*)exc);
return NULL;
}
*named_arg_info = NULL;
}
-void
-mono_reflection_resolve_custom_attribute_data (MonoReflectionMethod *ref_method, MonoReflectionAssembly *assembly, gpointer data, guint32 len, MonoArray **ctor_args, MonoArray **named_args)
+static gboolean
+reflection_resolve_custom_attribute_data (MonoReflectionMethod *ref_method, MonoReflectionAssembly *assembly, gpointer data, guint32 len, MonoArray **ctor_args, MonoArray **named_args, MonoError *error)
{
MonoDomain *domain;
MonoArray *typedargs, *namedargs;
MonoImage *image;
MonoMethod *method;
CattrNamedArg *arginfo = NULL;
- MonoError error;
int i;
- mono_error_init (&error);
+ mono_error_init (error);
*ctor_args = NULL;
*named_args = NULL;
if (len == 0)
- return;
+ return TRUE;
image = assembly->assembly->image;
method = ref_method->method;
domain = mono_object_domain (ref_method);
- if (!mono_class_init (method->klass))
- mono_raise_exception (mono_class_get_exception_for_failure (method->klass));
+ if (!mono_class_init (method->klass)) {
+ mono_error_set_exception_instance (error, mono_class_get_exception_for_failure (method->klass));
+ goto leave;
+ }
- mono_reflection_create_custom_attr_data_args (image, method, (const guchar *)data, len, &typedargs, &namedargs, &arginfo, &error);
- if (!mono_error_ok (&error))
+ mono_reflection_create_custom_attr_data_args (image, method, (const guchar *)data, len, &typedargs, &namedargs, &arginfo, error);
+ if (!is_ok (error))
goto leave;
if (!typedargs || !namedargs)
MonoObject *obj = mono_array_get (typedargs, MonoObject*, i);
MonoObject *typedarg;
- typedarg = create_cattr_typed_arg (mono_method_signature (method)->params [i], obj, &error);
- if (!is_ok (&error))
+ typedarg = create_cattr_typed_arg (mono_method_signature (method)->params [i], obj, error);
+ if (!is_ok (error))
goto leave;
mono_array_setref (typedargs, i, typedarg);
}
MonoObject *typedarg, *namedarg, *minfo;
if (arginfo [i].prop) {
- minfo = (MonoObject*)mono_property_get_object_checked (domain, NULL, arginfo [i].prop, &error);
+ minfo = (MonoObject*)mono_property_get_object_checked (domain, NULL, arginfo [i].prop, error);
if (!minfo)
goto leave;
} else {
- minfo = (MonoObject*)mono_field_get_object_checked (domain, NULL, arginfo [i].field, &error);
- if (!mono_error_ok (&error))
+ minfo = (MonoObject*)mono_field_get_object_checked (domain, NULL, arginfo [i].field, error);
+ if (!is_ok (error))
goto leave;
}
- typedarg = create_cattr_typed_arg (arginfo [i].type, obj, &error);
- if (!is_ok (&error))
+ typedarg = create_cattr_typed_arg (arginfo [i].type, obj, error);
+ if (!is_ok (error))
goto leave;
- namedarg = create_cattr_named_arg (minfo, typedarg, &error);
- if (!is_ok (&error))
+ namedarg = create_cattr_named_arg (minfo, typedarg, error);
+ if (!is_ok (error))
goto leave;
mono_array_setref (namedargs, i, namedarg);
*ctor_args = typedargs;
*named_args = namedargs;
+
leave:
g_free (arginfo);
- mono_error_raise_exception (&error);
+ return mono_error_ok (error);
+}
+void
+ves_icall_System_Reflection_CustomAttributeData_ResolveArgumentsInternal (MonoReflectionMethod *ref_method, MonoReflectionAssembly *assembly, gpointer data, guint32 len, MonoArray **ctor_args, MonoArray **named_args)
+{
+ MonoError error;
+ (void) reflection_resolve_custom_attribute_data (ref_method, assembly, data, len, ctor_args, named_args, &error);
+ mono_error_set_pending_exception (&error);
}
static MonoObject*
{
MonoError error;
MonoCustomAttrInfo *result = mono_custom_attrs_from_index_checked (image, idx, &error);
- mono_error_cleanup (&error); /* FIXME a better public API that doesn't swallow the error. */
+ mono_error_cleanup (&error);
return result;
}
/**
{
MonoError error;
MonoCustomAttrInfo *result = mono_custom_attrs_from_class_checked (klass, &error);
- mono_error_cleanup (&error); /* FIXME want a better API that doesn't swallow the error */
+ mono_error_cleanup (&error);
return result;
}
{
MonoError error;
MonoCustomAttrInfo *result = mono_custom_attrs_from_assembly_checked (assembly, &error);
- mono_error_cleanup (&error); /* FIXME want a better API that doesn't swallow the error */
+ mono_error_cleanup (&error);
return result;
}
{
MonoError error;
MonoCustomAttrInfo * result = mono_custom_attrs_from_property_checked (klass, property, &error);
- mono_error_cleanup (&error); /* FIXME want a better API that doesn't swallow the error */
+ mono_error_cleanup (&error);
return result;
}
{
MonoError error;
MonoCustomAttrInfo * result = mono_custom_attrs_from_event_checked (klass, event, &error);
- mono_error_cleanup (&error); /* FIXME want a better API that doesn't swallow the error */
+ mono_error_cleanup (&error);
return result;
}
{
MonoError error;
MonoCustomAttrInfo * result = mono_custom_attrs_from_field_checked (klass, field, &error);
- mono_error_cleanup (&error); /* FIXME want a better API that doesn't swallow the error */
+ mono_error_cleanup (&error);
return result;
}
{
MonoError error;
MonoCustomAttrInfo *result = mono_custom_attrs_from_param_checked (method, param, &error);
- mono_error_cleanup (&error); /* FIXME want a better API that doesn't swallow the error */
+ mono_error_cleanup (&error);
return result;
}
{
MonoError error;
MonoObject *res = mono_custom_attrs_get_attr_checked (ainfo, attr_klass, &error);
- g_assert (mono_error_ok (&error)); /*FIXME proper error handling*/
+ mono_error_assert_ok (&error); /*FIXME proper error handling*/
return res;
}
MonoError error;
MonoArray* result;
result = mono_reflection_get_custom_attrs_data_checked (obj, &error);
- mono_error_cleanup (&error); /* FIXME new API that doesn't swallow the error */
+ mono_error_cleanup (&error);
return result;
}
}
static void
-init_type_builder_generics (MonoObject *type)
+init_type_builder_generics (MonoObject *type, MonoError *error)
{
+ mono_error_init (error);
}
#endif /* !DISABLE_REFLECTION_EMIT */
{
MonoError error;
MonoArray *result = mono_reflection_get_custom_attrs_blob_checked (assembly, ctor, ctorArgs, properties, propValues, fields, fieldValues, &error);
- mono_error_cleanup (&error); /* FIXME better API that doesn't swallow the error */
+ mono_error_cleanup (&error);
return result;
}
{
}
-/*
+/**
* mono_reflection_create_generic_class:
* @tb: a TypeBuilder object
+ * @error: set on error
*
* Creates the generic class after all generic parameters have been added.
+ * On success returns TRUE, on failure returns FALSE and sets @error.
+ *
*/
-void
-mono_reflection_create_generic_class (MonoReflectionTypeBuilder *tb)
+gboolean
+mono_reflection_create_generic_class (MonoReflectionTypeBuilder *tb, MonoError *error)
{
- MonoError error;
+
MonoClass *klass;
int count, i;
+ mono_error_init (error);
+
klass = mono_class_from_mono_type (tb->type.type);
count = tb->generic_params ? mono_array_length (tb->generic_params) : 0;
if (klass->generic_container || (count == 0))
- return;
+ return TRUE;
g_assert (tb->generic_container && (tb->generic_container->owner.klass == klass));
for (i = 0; i < count; i++) {
MonoReflectionGenericParam *gparam = (MonoReflectionGenericParam *)mono_array_get (tb->generic_params, gpointer, i);
- MonoType *param_type = mono_reflection_type_get_handle ((MonoReflectionType*)gparam, &error);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
+ MonoType *param_type = mono_reflection_type_get_handle ((MonoReflectionType*)gparam, error);
+ return_val_if_nok (error, FALSE);
MonoGenericParamFull *param = (MonoGenericParamFull *) param_type->data.generic_param;
klass->generic_container->type_params [i] = *param;
/*Make sure we are a diferent type instance */
}
klass->generic_container->context.class_inst = mono_get_shared_generic_inst (klass->generic_container);
+ return TRUE;
}
/**
static MonoMethod*
reflection_methodbuilder_to_mono_method (MonoClass *klass,
ReflectionMethodBuilder *rmb,
- MonoMethodSignature *sig)
+ MonoMethodSignature *sig,
+ MonoError *error)
{
- MonoError error;
MonoMethod *m;
MonoMethodWrapper *wrapperm;
MonoMarshalSpec **specs;
gboolean dynamic;
int i;
- mono_error_init (&error);
+ mono_error_init (error);
/*
* Methods created using a MethodBuilder should have their memory allocated
* inside the image mempool, while dynamic methods should have their memory
method_aux = image_g_new0 (image, MonoReflectionMethodAux, 1);
- method_aux->dllentry = rmb->dllentry ? mono_string_to_utf8_image (image, rmb->dllentry, &error) : image_strdup (image, m->name);
- g_assert (mono_error_ok (&error));
- method_aux->dll = mono_string_to_utf8_image (image, rmb->dll, &error);
- g_assert (mono_error_ok (&error));
+ method_aux->dllentry = rmb->dllentry ? mono_string_to_utf8_image (image, rmb->dllentry, error) : image_strdup (image, m->name);
+ mono_error_assert_ok (error);
+ method_aux->dll = mono_string_to_utf8_image (image, rmb->dll, error);
+ mono_error_assert_ok (error);
((MonoMethodPInvoke*)m)->piflags = (rmb->native_cc << 8) | (rmb->charset ? (rmb->charset - 1) * 2 : 0) | rmb->extra_flags;
mono_array_get (rmb->ilgen->locals, MonoReflectionLocalBuilder*, i);
header->locals [i] = image_g_new0 (image, MonoType, 1);
- MonoType *type = mono_reflection_type_get_handle ((MonoReflectionType*)lb->type, &error);
- mono_error_assert_ok (&error);
+ MonoType *type = mono_reflection_type_get_handle ((MonoReflectionType*)lb->type, error);
+ mono_error_assert_ok (error);
memcpy (header->locals [i], type, MONO_SIZEOF_TYPE);
}
header->num_clauses = num_clauses;
if (num_clauses) {
header->clauses = method_encode_clauses (image, (MonoDynamicImage*)klass->image,
- rmb->ilgen, num_clauses, &error);
- mono_error_assert_ok (&error);
+ rmb->ilgen, num_clauses, error);
+ mono_error_assert_ok (error);
}
wrapperm->header = header;
for (i = 0; i < count; i++) {
MonoReflectionGenericParam *gp =
mono_array_get (rmb->generic_params, MonoReflectionGenericParam*, i);
- MonoType *gp_type = mono_reflection_type_get_handle ((MonoReflectionType*)gp, &error);
- mono_error_assert_ok (&error);
+ MonoType *gp_type = mono_reflection_type_get_handle ((MonoReflectionType*)gp, error);
+ mono_error_assert_ok (error);
MonoGenericParamFull *param = (MonoGenericParamFull *) gp_type->data.generic_param;
container->type_params [i] = *param;
}
}
if (pb->name) {
- method_aux->param_names [i] = mono_string_to_utf8_image (image, pb->name, &error);
- g_assert (mono_error_ok (&error));
+ method_aux->param_names [i] = mono_string_to_utf8_image (image, pb->name, error);
+ mono_error_assert_ok (error);
}
if (pb->cattrs) {
if (!method_aux->param_cattr)
if (specs == NULL)
specs = image_g_new0 (image, MonoMarshalSpec*, sig->param_count + 1);
specs [pb->position] =
- mono_marshal_spec_from_builder (image, klass->image->assembly, pb->marshal_info, &error);
- if (!is_ok (&error)) {
+ mono_marshal_spec_from_builder (image, klass->image->assembly, pb->marshal_info, error);
+ if (!is_ok (error)) {
mono_loader_unlock ();
image_g_free (image, specs);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
+ /* FIXME: if image is NULL, this leaks all the other stuff we alloc'd in this function */
+ return NULL;
}
}
}
if (!reflection_methodbuilder_from_ctor_builder (&rmb, mb, error))
return NULL;
- mb->mhandle = reflection_methodbuilder_to_mono_method (klass, &rmb, sig);
+ mb->mhandle = reflection_methodbuilder_to_mono_method (klass, &rmb, sig, error);
+ return_val_if_nok (error, NULL);
mono_save_custom_attrs (klass->image, mb->mhandle, mb->cattrs);
/* If we are in a generic class, we might be called multiple times from inflate_method */
if (!reflection_methodbuilder_from_method_builder (&rmb, mb, error))
return NULL;
- mb->mhandle = reflection_methodbuilder_to_mono_method (klass, &rmb, sig);
+ mb->mhandle = reflection_methodbuilder_to_mono_method (klass, &rmb, sig, error);
+ return_val_if_nok (error, NULL);
mono_save_custom_attrs (klass->image, mb->mhandle, mb->cattrs);
/* If we are in a generic class, we might be called multiple times from inflate_method */
}
/* FIXME: fix the CreateGenericParameters protocol to avoid the two stage setup of TypeBuilders */
- if (tb && tb->generic_container)
- mono_reflection_create_generic_class (tb);
+ if (tb && tb->generic_container) {
+ if (!mono_reflection_create_generic_class (tb, error)) {
+ mono_loader_unlock ();
+ return NULL;
+ }
+ }
MonoType *t = mono_reflection_type_get_handle (type, error);
if (!is_ok (error)) {
return mono_generic_class_get_class (gclass);
}
-MonoReflectionMethod*
-mono_reflection_bind_generic_method_parameters (MonoReflectionMethod *rmethod, MonoArray *types)
+static MonoReflectionMethod*
+reflection_bind_generic_method_parameters (MonoReflectionMethod *rmethod, MonoArray *types, MonoError *error)
{
- MonoError error;
MonoClass *klass;
MonoMethod *method, *inflated;
MonoMethodInflated *imethod;
MonoType **type_argv;
int count, i;
+ mono_error_init (error);
+
/*FIXME but this no longer should happen*/
if (!strcmp (rmethod->object.vtable->klass->name, "MethodBuilder")) {
#ifndef DISABLE_REFLECTION_EMIT
MonoClass *klass;
mb = (MonoReflectionMethodBuilder *) rmethod;
- tb = mono_reflection_type_get_handle ((MonoReflectionType*)mb->type, &error);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
+ tb = mono_reflection_type_get_handle ((MonoReflectionType*)mb->type, error);
+ return_val_if_nok (error, NULL);
klass = mono_class_from_mono_type (tb);
- method = methodbuilder_to_mono_method (klass, mb, &error);
- if (!method)
- mono_error_raise_exception (&error); /* FIXME don't raise here */
+ method = methodbuilder_to_mono_method (klass, mb, error);
+ return_val_if_nok (error, NULL);
#else
g_assert_not_reached ();
method = NULL;
type_argv = g_new0 (MonoType *, count);
for (i = 0; i < count; i++) {
MonoReflectionType *garg = (MonoReflectionType *)mono_array_get (types, gpointer, i);
- type_argv [i] = mono_reflection_type_get_handle (garg, &error);
- if (!is_ok (&error)) {
+ type_argv [i] = mono_reflection_type_get_handle (garg, error);
+ if (!is_ok (error)) {
g_free (type_argv);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
+ return NULL;
}
}
ginst = mono_metadata_get_generic_inst (count, type_argv);
tmp_context.class_inst = klass->generic_class ? klass->generic_class->context.class_inst : NULL;
tmp_context.method_inst = ginst;
- inflated = mono_class_inflate_generic_method_checked (method, &tmp_context, &error);
- g_assert (mono_error_ok (&error)); /* FIXME don't swallow the error */
+ inflated = mono_class_inflate_generic_method_checked (method, &tmp_context, error);
+ mono_error_assert_ok (error);
imethod = (MonoMethodInflated *) inflated;
/*FIXME but I think this is no longer necessary*/
mono_image_unlock ((MonoImage*)image);
}
- if (!mono_verifier_is_method_valid_generic_instantiation (inflated))
- mono_raise_exception (mono_get_exception_argument ("typeArguments", "Invalid generic arguments"));
+ if (!mono_verifier_is_method_valid_generic_instantiation (inflated)) {
+ mono_error_set_argument (error, "typeArguments", "Invalid generic arguments");
+ return NULL;
+ }
- MonoReflectionMethod *ret = mono_method_get_object_checked (mono_object_domain (rmethod), inflated, NULL, &error);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
+ MonoReflectionMethod *ret = mono_method_get_object_checked (mono_object_domain (rmethod), inflated, NULL, error);
return ret;
}
+MonoReflectionMethod*
+mono_reflection_bind_generic_method_parameters (MonoReflectionMethod *rmethod, MonoArray *types)
+{
+ MonoError error;
+ MonoReflectionMethod *result = reflection_bind_generic_method_parameters (rmethod, types, &error);
+ mono_error_set_pending_exception (&error);
+ return result;
+}
+
+
#ifndef DISABLE_REFLECTION_EMIT
static MonoMethod *
}
-MonoArray *
-mono_reflection_sighelper_get_signature_local (MonoReflectionSigHelper *sig)
+static MonoArray *
+reflection_sighelper_get_signature_local (MonoReflectionSigHelper *sig, MonoError *error)
{
- MonoError error;
MonoReflectionModuleBuilder *module = sig->module;
MonoDynamicImage *assembly = module != NULL ? module->dynamic_image : NULL;
guint32 na = sig->arguments ? mono_array_length (sig->arguments) : 0;
MonoArray *result;
SigBuffer buf;
- check_array_for_usertypes (sig->arguments, &error);
- mono_error_raise_exception (&error); /* FIXME: don't raise here */
+ mono_error_init (error);
+
+ check_array_for_usertypes (sig->arguments, error);
+ return_val_if_nok (error, NULL);
sigbuffer_init (&buf, 32);
if (assembly != NULL){
for (i = 0; i < na; ++i) {
MonoReflectionType *type = mono_array_get (sig->arguments, MonoReflectionType*, i);
- encode_reflection_type (assembly, type, &buf, &error);
- if (!is_ok (&error)) goto fail;
+ encode_reflection_type (assembly, type, &buf, error);
+ if (!is_ok (error)) goto fail;
}
}
return result;
fail:
sigbuffer_free (&buf);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
return NULL;
}
MonoArray *
-mono_reflection_sighelper_get_signature_field (MonoReflectionSigHelper *sig)
+mono_reflection_sighelper_get_signature_local (MonoReflectionSigHelper *sig)
{
MonoError error;
+ MonoArray *result = reflection_sighelper_get_signature_local (sig, &error);
+ mono_error_set_pending_exception (&error);
+ return result;
+}
+
+static MonoArray *
+reflection_sighelper_get_signature_field (MonoReflectionSigHelper *sig, MonoError *error)
+{
MonoDynamicImage *assembly = sig->module->dynamic_image;
guint32 na = sig->arguments ? mono_array_length (sig->arguments) : 0;
guint32 buflen, i;
MonoArray *result;
SigBuffer buf;
- check_array_for_usertypes (sig->arguments, &error);
- mono_error_raise_exception (&error); /* FIXME: don't raise here */
+ mono_error_init (error);
+
+ check_array_for_usertypes (sig->arguments, error);
+ return_val_if_nok (error, NULL);
sigbuffer_init (&buf, 32);
sigbuffer_add_value (&buf, 0x06);
for (i = 0; i < na; ++i) {
MonoReflectionType *type = mono_array_get (sig->arguments, MonoReflectionType*, i);
- encode_reflection_type (assembly, type, &buf, &error);
- if (!is_ok (&error))
+ encode_reflection_type (assembly, type, &buf, error);
+ if (!is_ok (error))
goto fail;
}
return result;
fail:
sigbuffer_free (&buf);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
return NULL;
}
+MonoArray *
+mono_reflection_sighelper_get_signature_field (MonoReflectionSigHelper *sig)
+{
+ MonoError error;
+ MonoArray *result = reflection_sighelper_get_signature_field (sig, &error);
+ mono_error_set_pending_exception (&error);
+ return result;
+}
+
typedef struct {
MonoMethod *handle;
MonoDomain *domain;
klass = mono_defaults.object_class;
}
- mb->mhandle = handle = reflection_methodbuilder_to_mono_method (klass, &rmb, sig);
+ mb->mhandle = handle = reflection_methodbuilder_to_mono_method (klass, &rmb, sig, error);
+ g_free (rmb.refs);
+ return_val_if_nok (error, FALSE);
+
release_data = g_new (DynamicMethodReleaseData, 1);
release_data->handle = handle;
release_data->domain = mono_object_get_domain ((MonoObject*)mb);
}
g_slist_free (mb->referenced_by);
- g_free (rmb.refs);
-
/* ilgen is no longer needed */
mb->ilgen = NULL;
g_assert_not_reached ();
}
-void
-mono_reflection_create_generic_class (MonoReflectionTypeBuilder *tb)
+gboolean
+mono_reflection_create_generic_class (MonoReflectionTypeBuilder *tb, MonoError *error)
{
g_assert_not_reached ();
+ return FALSE;
}
void
}
gpointer
-mono_reflection_lookup_dynamic_token (MonoImage *image, guint32 token, gboolean valid_token, MonoClass **handle_class, MonoGenericContext *context)
+mono_reflection_lookup_dynamic_token (MonoImage *image, guint32 token, gboolean valid_token, MonoClass **handle_class, MonoGenericContext *context, MonoError *error)
{
+ mono_error_init (error);
return NULL;
}
{
}
+static void G_GNUC_UNUSED
+sgen_client_binary_protocol_concurrent_sweep_end (long long timestamp)
+{
+}
+
int sgen_thread_handshake (BOOL suspend);
gboolean sgen_suspend_thread (SgenThreadInfo *info);
gboolean sgen_resume_thread (SgenThreadInfo *info);
g_assert_not_reached ();
}
- if (atype != ATYPE_SMALL) {
- /* size += ALLOC_ALIGN - 1; */
- mono_mb_emit_ldloc (mb, size_var);
- mono_mb_emit_icon (mb, SGEN_ALLOC_ALIGN - 1);
- mono_mb_emit_byte (mb, CEE_ADD);
- /* size &= ~(ALLOC_ALIGN - 1); */
- mono_mb_emit_icon (mb, ~(SGEN_ALLOC_ALIGN - 1));
- mono_mb_emit_byte (mb, CEE_AND);
- mono_mb_emit_stloc (mb, size_var);
- }
+ /* size += ALLOC_ALIGN - 1; */
+ mono_mb_emit_ldloc (mb, size_var);
+ mono_mb_emit_icon (mb, SGEN_ALLOC_ALIGN - 1);
+ mono_mb_emit_byte (mb, CEE_ADD);
+ /* size &= ~(ALLOC_ALIGN - 1); */
+ mono_mb_emit_icon (mb, ~(SGEN_ALLOC_ALIGN - 1));
+ mono_mb_emit_byte (mb, CEE_AND);
+ mono_mb_emit_stloc (mb, size_var);
/* if (size > MAX_SMALL_OBJ_SIZE) goto slowpath */
if (atype != ATYPE_SMALL) {
mono_mb_emit_byte (mb, MONO_CEE_ADD);
mono_mb_emit_ldarg (mb, 1);
mono_mb_emit_byte (mb, MONO_CEE_STIND_I4);
- /* s->chars [len] = 0; */
- mono_mb_emit_ldloc (mb, p_var);
- mono_mb_emit_ldloc (mb, size_var);
- mono_mb_emit_icon (mb, 2);
- mono_mb_emit_byte (mb, MONO_CEE_SUB);
- mono_mb_emit_byte (mb, MONO_CEE_ADD);
- mono_mb_emit_icon (mb, 0);
- mono_mb_emit_byte (mb, MONO_CEE_STIND_I2);
}
/*
if (!info->is_overflow)
sprintf (full_timing_buff, "total %.2fms, bridge %.2fms", info->stw_time / 10000.0f, (int)info->bridge_time / 10000.0f);
if (info->generation == GENERATION_OLD)
- mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_GC, "GC_MAJOR%s: (%s) pause %.2fms, %s major %dK/%dK los %dK/%dK",
+ mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_GC, "GC_MAJOR%s: (%s) pause %.2fms, %s los %dK/%dK",
info->is_overflow ? "_OVERFLOW" : "",
info->reason ? info->reason : "",
(int)info->total_time / 10000.0f,
full_timing_buff,
- major_collector->section_size * num_major_sections / 1024,
- major_collector->section_size * last_major_num_sections / 1024,
los_memory_usage / 1024,
last_los_memory_usage / 1024);
else
gboolean
sgen_resume_thread (SgenThreadInfo *info)
{
- return thread_resume (info->client_info.info.native_handle) == KERN_SUCCESS;
+ kern_return_t ret;
+ do {
+ ret = thread_resume (info->client_info.info.native_handle);
+ } while (ret == KERN_ABORTED);
+ return ret == KERN_SUCCESS;
}
gboolean
state = (thread_state_t) alloca (mono_mach_arch_get_thread_state_size ());
mctx = (mcontext_t) alloca (mono_mach_arch_get_mcontext_size ());
- ret = thread_suspend (info->client_info.info.native_handle);
+ do {
+ ret = thread_suspend (info->client_info.info.native_handle);
+ } while (ret == KERN_ABORTED);
if (ret != KERN_SUCCESS)
return FALSE;
- ret = mono_mach_arch_get_thread_state (info->client_info.info.native_handle, state, &num_state);
+ do {
+ ret = mono_mach_arch_get_thread_state (info->client_info.info.native_handle, state, &num_state);
+ } while (ret == KERN_ABORTED);
if (ret != KERN_SUCCESS)
return FALSE;
if (!sgen_suspend_thread (info))
continue;
} else {
- ret = thread_resume (info->client_info.info.native_handle);
+ do {
+ ret = thread_resume (info->client_info.info.native_handle);
+ } while (ret == KERN_ABORTED);
if (ret != KERN_SUCCESS)
continue;
}
return TRUE;
}
-static void
-epoll_cleanup (void)
-{
- g_free (epoll_events);
- close (epoll_fd);
-}
-
static void
epoll_register_fd (gint fd, gint events, gboolean is_new)
{
static ThreadPoolIOBackend backend_epoll = {
.init = epoll_init,
- .cleanup = epoll_cleanup,
.register_fd = epoll_register_fd,
.remove_fd = epoll_remove_fd,
.event_wait = epoll_event_wait,
return TRUE;
}
-static void
-kqueue_cleanup (void)
-{
- g_free (kqueue_events);
- close (kqueue_fd);
-}
-
static void
kqueue_register_fd (gint fd, gint events, gboolean is_new)
{
static ThreadPoolIOBackend backend_kqueue = {
.init = kqueue_init,
- .cleanup = kqueue_cleanup,
.register_fd = kqueue_register_fd,
.remove_fd = kqueue_remove_fd,
.event_wait = kqueue_event_wait,
return TRUE;
}
-static void
-poll_cleanup (void)
-{
- g_free (poll_fds);
-}
-
static void
poll_register_fd (gint fd, gint events, gboolean is_new)
{
static ThreadPoolIOBackend backend_poll = {
.init = poll_init,
- .cleanup = poll_cleanup,
.register_fd = poll_register_fd,
.remove_fd = poll_remove_fd,
.event_wait = poll_event_wait,
typedef struct {
gboolean (*init) (gint wakeup_pipe_fd);
- void (*cleanup) (void);
void (*register_fd) (gint fd, gint events, gboolean is_new);
void (*remove_fd) (gint fd);
gint (*event_wait) (void (*callback) (gint fd, gint events, gpointer user_data), gpointer user_data);
selector_thread_wakeup ();
while (io_selector_running)
mono_thread_info_usleep (1000);
-
- mono_coop_mutex_destroy (&threadpool_io->updates_lock);
- mono_coop_cond_destroy (&threadpool_io->updates_cond);
-
- threadpool_io->backend.cleanup ();
-
-#if !defined(HOST_WIN32)
- close (threadpool_io->wakeup_pipes [0]);
- close (threadpool_io->wakeup_pipes [1]);
-#else
- closesocket (threadpool_io->wakeup_pipes [0]);
- closesocket (threadpool_io->wakeup_pipes [1]);
-#endif
-
- g_assert (threadpool_io);
- g_free (threadpool_io);
- threadpool_io = NULL;
- g_assert (!threadpool_io);
}
void
mono_release_type_locks (thread);
/* Can happen when we attach the profiler helper thread in order to heapshot. */
- if (!mono_thread_info_lookup (thread->tid)->tools_thread)
+ if (!mono_thread_info_lookup (MONO_UINT_TO_NATIVE_THREAD_ID (thread->tid))->tools_thread)
mono_profiler_thread_end (thread->tid);
if (thread == mono_thread_internal_current ()) {
if (internal->name && (internal->flags & MONO_THREAD_FLAG_NAME_SET)) {
char *tname = g_utf16_to_utf8 (internal->name, internal->name_len, NULL, NULL, NULL);
mono_profiler_thread_name (internal->tid, tname);
- mono_thread_info_set_name (internal->tid, tname);
+ mono_thread_info_set_name (MONO_UINT_TO_NATIVE_THREAD_ID (internal->tid), tname);
g_free (tname);
}
/* start_func is set only for unmanaged start functions */
g_free(handles);
- return ret;
+ /* WAIT_FAILED in waithandle.cs is different from WAIT_FAILED in Win32 API */
+ return ret == WAIT_FAILED ? 0x7fffffff : ret;
}
/* FIXME: exitContext isnt documented */
return ret - WAIT_ABANDONED_0;
}
else {
- return ret;
+ /* WAIT_FAILED in waithandle.cs is different from WAIT_FAILED in Win32 API */
+ return ret == WAIT_FAILED ? 0x7fffffff : ret;
}
}
mono_thread_clr_state (thread, ThreadState_WaitSleepJoin);
- return ret;
+ /* WAIT_FAILED in waithandle.cs is different from WAIT_FAILED in Win32 API */
+ return ret == WAIT_FAILED ? 0x7fffffff : ret;
}
gint32
mono_thread_clr_state (thread, ThreadState_WaitSleepJoin);
- return ret;
+ /* WAIT_FAILED in waithandle.cs is different from WAIT_FAILED in Win32 API */
+ return ret == WAIT_FAILED ? 0x7fffffff : ret;
}
HANDLE ves_icall_System_Threading_Mutex_CreateMutex_internal (MonoBoolean owned, MonoString *name, MonoBoolean *created)
seq-points.h \
ir-emit.h \
method-to-ir.c \
+ cfgdump.h \
+ cfgdump.c \
decompose.c \
mini.h \
version.h \
}
#if defined(MONO_ARCH_GSHAREDVT_SUPPORTED)
- acfg->opts |= MONO_OPT_GSHAREDVT;
- opts |= MONO_OPT_GSHAREDVT;
+ if (acfg->aot_opts.llvm_only || mono_aot_mode_is_full (&acfg->aot_opts)) {
+ acfg->opts |= MONO_OPT_GSHAREDVT;
+ opts |= MONO_OPT_GSHAREDVT;
+ }
#endif
if (opts & MONO_OPT_GSHAREDVT)
/* allocate two contiguous pages of memory: the first page will contain the data (like a local constant pool)
* while the second will contain the trampolines.
*/
- ret = vm_allocate (mach_task_self (), &addr, psize * 2, VM_FLAGS_ANYWHERE);
+ do {
+ ret = vm_allocate (mach_task_self (), &addr, psize * 2, VM_FLAGS_ANYWHERE);
+ } while (ret == KERN_ABORTED);
if (ret != KERN_SUCCESS) {
g_error ("Cannot allocate memory for trampolines: %d", ret);
break;
bb->has_array_access |= first_bb->has_array_access;
/* Delete the links between the original bb and its successors */
- tmp_bblocks = bb->out_bb;
+ tmp_bblocks = mono_mempool_alloc0 (cfg->mempool, sizeof (MonoBasicBlock*) * bb->out_count);
+ memcpy (tmp_bblocks, bb->out_bb, sizeof (MonoBasicBlock*) * bb->out_count);
count = bb->out_count;
for (i = 0; i < count; ++i)
mono_unlink_bblock (cfg, bb, tmp_bblocks [i]);
--- /dev/null
+/*
+ * Copyright (C) 2016 Xamarin Inc
+ * Licensed under the MIT license. See LICENSE file in the project root for full license information.
+ */
+
+/* inspired by BinaryGraphPrinter.java of Graal */
+
+#include "mini.h"
+
+#if !defined(DISABLE_LOGGING) && !defined(DISABLE_JIT) && !defined(HOST_WIN32)
+
+#include <glib.h>
+#include <mono/metadata/class-internals.h>
+
+#include <sys/socket.h>
+#include <sys/types.h>
+#include <netinet/in.h>
+#include <netdb.h>
+#include <string.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <errno.h>
+#include <arpa/inet.h>
+#include <errno.h>
+
+#if 0
+#define CFG_DEBUG
+#endif
+
+
+#ifdef CFG_DEBUG
+
+#ifdef HAVE_C99_SUPPORT
+#define cfg_debug(format, ...) g_debug(format, __VA_ARGS__)
+#else
+#define cfg_debug(...) g_debug(__VA_ARGS__)
+#endif
+
+#else
+
+#ifdef HAVE_C99_SUPPORT
+#define cfg_debug(format, ...) do {} while (0)
+#else
+#define cfg_debug(...) do {} while (0)
+#endif
+
+#endif
+
+static ConstantPoolEntry*
+create_cp_entry (MonoCompile *cfg, void *data, pool_type pt)
+{
+ ConstantPoolEntry *entry = (ConstantPoolEntry *) mono_mempool_alloc0 (cfg->mempool, sizeof (ConstantPoolEntry));
+ entry->pt = pt;
+ entry->data = data;
+ return entry;
+}
+
+static void write_pool (MonoCompile *cfg, ConstantPoolEntry *entry);
+
+static int
+create_socket (const char *hostname, const int port)
+{
+ int sockfd = 0;
+ struct sockaddr_in serv_addr;
+
+ if ((sockfd = socket (AF_INET, SOCK_STREAM, 0)) < 0) {
+ g_warning ("cfg_dump: could not create socket");
+ return -1;
+ }
+
+ serv_addr.sin_family = AF_INET;
+ serv_addr.sin_port = htons (port);
+ serv_addr.sin_addr.s_addr = inet_addr (hostname);
+
+ if (connect (sockfd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) < 0) {
+ g_warning ("cfg_dump: Connect Failed: %s", strerror (errno));
+ return -2;
+ }
+
+ return sockfd;
+}
+
+static void
+write_byte (MonoCompile *cfg, unsigned char b)
+{
+ write (cfg->gdump_ctx->fd, &b, 1);
+}
+
+static void
+write_short (MonoCompile *cfg, short s)
+{
+ short swap = htons (s);
+ write (cfg->gdump_ctx->fd, &swap, 2);
+}
+
+static void
+write_int (MonoCompile *cfg, int v)
+{
+ int swap = htonl (v);
+ write (cfg->gdump_ctx->fd, &swap, 4);
+}
+
+static void
+write_string (MonoCompile *cfg, const char *str)
+{
+ size_t len = strnlen (str, 0x2000);
+ write_int (cfg, (int) len);
+
+ gunichar2 *u = u8to16 (str);
+ for (int i = 0; i < len; i++)
+ write_short (cfg, u[i]);
+}
+
+static void
+add_pool_entry (MonoCompile *cfg, ConstantPoolEntry *entry)
+{
+ int *cp_id= (int *) mono_mempool_alloc0 (cfg->mempool, sizeof (int));
+ *cp_id = cfg->gdump_ctx->next_cp_id;
+ g_hash_table_insert (cfg->gdump_ctx->constant_pool, entry, cp_id);
+ write_byte (cfg, POOL_NEW);
+ write_short (cfg, cfg->gdump_ctx->next_cp_id++);
+ switch (entry->pt) {
+ case PT_STRING:
+ write_byte (cfg, POOL_STRING);
+ write_string (cfg, (char *) entry->data);
+ break;
+ case PT_METHOD: {
+ MonoMethod *method = (MonoMethod *) entry->data;
+ write_byte (cfg, POOL_METHOD);
+ write_pool (cfg, create_cp_entry (cfg, (void *) method->klass, PT_KLASS));
+ write_pool (cfg, create_cp_entry (cfg, (void *) method->name, PT_STRING));
+ write_pool (cfg, create_cp_entry (cfg, (void *) method->signature, PT_SIGNATURE));
+ write_int (cfg, (int) method->flags);
+ write_int (cfg, -1); // don't transmit bytecode.
+ break;
+ }
+ case PT_KLASS: {
+ MonoClass *klass = (MonoClass *) entry->data;
+ write_byte (cfg, POOL_KLASS);
+ write_string (cfg, klass->name);
+ write_byte (cfg, KLASS);
+ break;
+ }
+ case PT_SIGNATURE: {
+ write_byte (cfg, POOL_SIGNATURE);
+ MonoMethodSignature *sig = (MonoMethodSignature *) entry->data;
+ write_short (cfg, sig->param_count);
+ for (int i = 0; i < sig->param_count; i++) {
+ GString *sbuf = g_string_new (NULL);
+ mono_type_get_desc (sbuf, sig->params [i], TRUE);
+ write_pool (cfg, create_cp_entry (cfg, (void *) sbuf->str, PT_STRING));
+ g_string_free (sbuf, TRUE);
+ }
+ GString *sbuf = g_string_new (NULL);
+ mono_type_get_desc (sbuf, sig->ret, TRUE);
+ write_pool (cfg, create_cp_entry (cfg, (void *) sbuf->str, PT_STRING));
+ g_string_free (sbuf, TRUE);
+ break;
+ }
+ case PT_OPTYPE: {
+ MonoInst *insn = (MonoInst *) entry->data;
+ write_byte (cfg, POOL_NODE_CLASS);
+
+ write_string (cfg, mono_inst_name (insn->opcode));
+ GString *insndesc = mono_print_ins_index_strbuf (-1, insn);
+ int len = strnlen (insndesc->str, 0x2000);
+#define CUTOFF 40
+ if (len > CUTOFF) {
+ insndesc->str[CUTOFF] = '\0';
+ insndesc->str[CUTOFF - 1] = '.';
+ insndesc->str[CUTOFF - 2] = '.';
+ }
+ write_string (cfg, insndesc->str);
+ if (len > CUTOFF)
+ insndesc->str[CUTOFF] = ' ';
+ g_string_free (insndesc, TRUE);
+
+ // one predecessor
+ write_short (cfg, 1);
+ write_byte (cfg, 0);
+ write_pool (cfg, create_cp_entry (cfg, (void *) "predecessor", PT_STRING));
+ write_pool (cfg, create_cp_entry (cfg, (void *) NULL, PT_INPUTTYPE));
+
+ // make NUM_SUCCESSOR successor edges, not everyone will be used.
+#define NUM_SUCCESSOR 5
+ write_short (cfg, NUM_SUCCESSOR);
+ for (int i = 0; i < NUM_SUCCESSOR; i++) {
+ char *str = g_strdup ("successor1");
+ str[9] = '0' + i;
+ write_byte (cfg, 0);
+ write_pool (cfg, create_cp_entry (cfg, (void *) str, PT_STRING));
+ }
+
+ break;
+ }
+ case PT_INPUTTYPE: {
+ write_byte (cfg, POOL_ENUM);
+ write_pool (cfg, create_cp_entry (cfg, (void *) NULL, PT_ENUMKLASS));
+ write_int (cfg, 0);
+ break;
+ }
+ case PT_ENUMKLASS: {
+ write_byte (cfg, POOL_KLASS);
+ write_string (cfg, "InputType");
+ write_byte (cfg, ENUM_KLASS);
+ write_int (cfg, 1);
+ write_pool (cfg, create_cp_entry (cfg, (void *) "fixed", PT_STRING));
+ break;
+ }
+ }
+}
+
+static void
+write_pool (MonoCompile *cfg, ConstantPoolEntry *entry)
+{
+ if (!entry || !entry->data) {
+ write_byte (cfg, POOL_NULL);
+ return;
+ }
+
+ short *cp_index = (short *) g_hash_table_lookup (cfg->gdump_ctx->constant_pool, entry);
+ if (cp_index == NULL)
+ add_pool_entry (cfg, entry);
+ else {
+ switch (entry->pt) {
+ case PT_STRING: write_byte (cfg, POOL_STRING); break;
+ case PT_METHOD: write_byte (cfg, POOL_METHOD); break;
+ case PT_ENUMKLASS: write_byte (cfg, POOL_KLASS); break;
+ case PT_KLASS: write_byte (cfg, POOL_KLASS); break;
+ case PT_SIGNATURE: write_byte (cfg, POOL_SIGNATURE); break;
+ case PT_OPTYPE: write_byte (cfg, POOL_NODE_CLASS); break;
+ case PT_INPUTTYPE: write_byte (cfg, POOL_ENUM); break;
+ }
+ write_short (cfg, *cp_index);
+ }
+}
+
+void
+mono_cfg_dump_begin_group (MonoCompile *cfg)
+{
+ if (cfg->gdump_ctx == NULL)
+ return;
+ write_byte (cfg, BEGIN_GROUP);
+ char *title = (char *) mono_mempool_alloc0 (cfg->mempool, 0x2000);
+ sprintf (title, "%s::%s", cfg->method->klass->name, cfg->method->name);
+ write_pool (cfg, create_cp_entry (cfg, (void *) title, PT_STRING));
+ write_pool (cfg, create_cp_entry (cfg, (void *) cfg->method->name, PT_STRING));
+ write_pool (cfg, create_cp_entry (cfg, (void *) cfg->method, PT_METHOD));
+ write_int (cfg, 0); // TODO: real bytecode index.
+}
+
+void
+mono_cfg_dump_close_group (MonoCompile *cfg)
+{
+ if (cfg->gdump_ctx == NULL)
+ return;
+ write_byte (cfg, CLOSE_GROUP);
+ cfg->gdump_ctx = NULL;
+}
+
+static int
+label_instructions (MonoCompile *cfg)
+{
+ MonoBasicBlock *bb;
+ int instruction_count = 0;
+
+ for (bb = cfg->bb_entry; bb; bb = bb->next_bb) {
+ cfg_debug ("bb: %d (in: %d, out: %d)", bb->block_num, bb->in_count, bb->out_count);
+ MonoInst *insn;
+ for (insn = bb->code; insn; insn = insn->next) {
+ instruction_count++;
+ void *id = g_hash_table_lookup (cfg->gdump_ctx->insn2id, insn);
+ if (id != NULL) // already in the table.
+ continue;
+ int *new_id = (int *) mono_mempool_alloc0 (cfg->mempool, sizeof (int));
+ *new_id = cfg->gdump_ctx->next_insn_id++;
+ g_hash_table_insert (cfg->gdump_ctx->insn2id, insn, new_id);
+#ifdef CFG_DEBUG
+ GString *insndesc = mono_print_ins_index_strbuf (-1, insn);
+ cfg_debug ("> insn%002d: %s", *new_id, insndesc->str);
+ g_string_free (insndesc, TRUE);
+#endif
+ }
+ }
+ return instruction_count;
+}
+
+static void
+write_instructions (MonoCompile *cfg, int instruction_count)
+{
+ MonoBasicBlock *bb;
+ write_int (cfg, instruction_count);
+ for (bb = cfg->bb_entry; bb; bb = bb->next_bb) {
+ MonoInst *insn;
+ cfg_debug ("== bb: %d (in: %d, out: %d) ==", bb->block_num, bb->in_count, bb->out_count);
+ for (insn = bb->code; insn; insn = insn->next) {
+ int i;
+ int *id = (int *) g_hash_table_lookup (cfg->gdump_ctx->insn2id, insn);
+ g_assert (id);
+ write_int (cfg, *id);
+
+ // hardcoded node class: only one input and NUM_SUCCESSOR successors
+ write_pool (cfg, create_cp_entry (cfg, (void *) insn, PT_OPTYPE));
+ write_byte (cfg, cfg->bb_entry->code != insn);
+
+ // properties
+ write_short (cfg, 2);
+
+ // property #1
+ GString *insndesc = mono_print_ins_index_strbuf (-1, insn);
+ cfg_debug ("dumping node [%2d]: %s", *id, insndesc->str);
+ write_pool (cfg, create_cp_entry (cfg, (void *) "fullname", PT_STRING));
+ write_byte (cfg, PROPERTY_POOL);
+ write_pool (cfg, create_cp_entry (cfg, (void *) insndesc->str, PT_STRING));
+ g_string_free (insndesc, TRUE);
+
+ // property #2
+ write_pool (cfg, create_cp_entry (cfg, (void *) "category", PT_STRING));
+ write_byte (cfg, PROPERTY_POOL);
+ if (bb->in_count > 1 && bb->code == insn)
+ write_pool (cfg, create_cp_entry (cfg, (void *) "merge", PT_STRING));
+ else if (bb->code == insn)
+ write_pool (cfg, create_cp_entry (cfg, (void *) "begin", PT_STRING));
+ else if (MONO_IS_COND_BRANCH_OP (insn))
+ write_pool (cfg, create_cp_entry (cfg, (void *) "controlSplit", PT_STRING));
+ else if (MONO_IS_PHI (insn))
+ write_pool (cfg, create_cp_entry (cfg, (void *) "phi", PT_STRING));
+ else if (!MONO_INS_HAS_NO_SIDE_EFFECT (insn))
+ write_pool (cfg, create_cp_entry (cfg, (void *) "state", PT_STRING));
+ else
+ write_pool (cfg, create_cp_entry (cfg, (void *) "fixed", PT_STRING));
+ // end of properties
+ write_int (cfg, -1); // never set predecessor.
+
+ int *next_id;
+ if (insn->next != NULL) {
+ next_id = (int *) g_hash_table_lookup (cfg->gdump_ctx->insn2id, insn->next);
+ g_assert (next_id);
+ cfg_debug ("\tsuccessor' : [%2d]", *next_id);
+ write_int (cfg, *next_id);
+ for (i = 1; i < NUM_SUCCESSOR; i++)
+ write_int (cfg, -1);
+ } else {
+ g_assert (bb->out_count < NUM_SUCCESSOR);
+ for (i = 0; (i < bb->out_count) && (i < NUM_SUCCESSOR); i++) {
+ if (bb->out_bb[i]->code == NULL)
+ write_int (cfg, -1);
+ else {
+ next_id = (int *) g_hash_table_lookup (cfg->gdump_ctx->insn2id, bb->out_bb[i]->code);
+ if (next_id)
+ cfg_debug ("\tsuccessor'': [%2d]", *next_id);
+ write_int (cfg, next_id ? *next_id : -1);
+ }
+ }
+ for (; i < NUM_SUCCESSOR; i++)
+ write_int (cfg, -1);
+ }
+ }
+ }
+}
+
+static void
+write_blocks (MonoCompile *cfg)
+{
+ int block_size = 0;
+ MonoBasicBlock *bb;
+ for (bb = cfg->bb_entry; bb; bb = bb->next_bb)
+ block_size++;
+ write_int (cfg, block_size);
+
+ for (bb = cfg->bb_entry; bb; bb = bb->next_bb) {
+ int insn_size = 0;
+ MonoInst *insn = NULL;
+
+ write_int (cfg, bb->block_num);
+
+ for (insn = bb->code; insn; insn = insn->next)
+ insn_size++;
+ write_int (cfg, insn_size);
+
+ for (insn = bb->code; insn; insn = insn->next) {
+ int *id = (int *) g_hash_table_lookup (cfg->gdump_ctx->insn2id, insn);
+ g_assert (id);
+ write_int (cfg, *id);
+ }
+
+ write_int (cfg, bb->out_count);
+ for (int i = 0; i < bb->out_count; i++)
+ write_int (cfg, bb->out_bb[i]->block_num);
+ }
+}
+
+static guint
+instruction_hash (MonoInst *insn)
+{
+ guint res = 0;
+ res = insn->opcode << 0x00;
+ res ^= insn->type << 0x04;
+ res ^= insn->flags << 0x08;
+ res ^= insn->dreg << 0x0c;
+ res ^= insn->sreg1 << 0x10;
+ res ^= insn->sreg2 << 0x14;
+ res ^= insn->sreg3 << 0x18;
+ res ^= (guint) insn->next;
+ res ^= (guint) insn->prev;
+ res ^= (guint) insn;
+ return res;
+}
+
+static gboolean
+instruction_equal (gconstpointer v1, gconstpointer v2)
+{
+ MonoInst *i1 = (MonoInst *) v1;
+ MonoInst *i2 = (MonoInst *) v2;
+
+ if (i1->opcode != i2->opcode || i1->type != i2->type || i1->flags != i2->flags)
+ return FALSE;
+ if (i1->dreg != i2->dreg || i1->sreg1 != i2->sreg1 || i1->sreg2 != i2->sreg2 || i1->sreg3 != i2->sreg3)
+ return FALSE;
+ if (i1->next != i2->next || i1->prev != i2->prev)
+ return FALSE;
+ return TRUE;
+}
+
+static guint
+constant_pool_hash (ConstantPoolEntry *entry)
+{
+ switch (entry->pt) {
+ case PT_STRING:
+ return g_str_hash (entry->data);
+ case PT_METHOD: {
+ MonoMethod *method = (MonoMethod *) entry->data;
+ return g_str_hash (method->name) ^ g_str_hash (method->klass);
+ }
+ case PT_KLASS:
+ return g_str_hash (((MonoClass *) entry->data)->name);
+ case PT_OPTYPE:
+ return instruction_hash ((MonoInst *) entry->data);
+ case PT_SIGNATURE: {
+ MonoMethodSignature *sig = (MonoMethodSignature *) entry->data;
+ guint ret = (guint) sig->ret;
+ for (int i = 0; i < sig->param_count; i++) {
+ ret ^= (guint) sig->params [i] << (i + 1);
+ }
+ return ret;
+ }
+ case PT_INPUTTYPE: // TODO: singleton.
+ case PT_ENUMKLASS:
+ return (guint) entry->data;
+ }
+ g_assert (FALSE);
+ return FALSE;
+}
+
+static gboolean
+constant_pool_equal (gconstpointer v1, gconstpointer v2)
+{
+ ConstantPoolEntry *e1 = (ConstantPoolEntry *) v1;
+ ConstantPoolEntry *e2 = (ConstantPoolEntry *) v2;
+ if (e1->pt != e2->pt)
+ return FALSE;
+
+ switch (e1->pt) {
+ case PT_STRING:
+ return g_str_equal (e1->data, e2->data);
+ case PT_OPTYPE:
+ return instruction_equal (e1->data, e2->data);
+ case PT_METHOD: // TODO: implement proper equal.
+ case PT_KLASS:
+ case PT_SIGNATURE:
+ return constant_pool_hash (e1) == constant_pool_hash (e2);
+ case PT_INPUTTYPE: // TODO: singleton.
+ case PT_ENUMKLASS:
+ return TRUE;
+ }
+ g_assert (FALSE);
+ return FALSE;
+}
+
+
+static gboolean cfg_dump_method_inited = FALSE;
+static const char *cfg_dump_method_name;
+
+void mono_cfg_dump_create_context (MonoCompile *cfg)
+{
+ cfg->gdump_ctx = NULL;
+
+ if (!cfg_dump_method_inited) {
+ cfg_dump_method_name = g_getenv ("MONO_JIT_DUMP_METHOD");
+ cfg_dump_method_inited = TRUE;
+ }
+ if (!cfg_dump_method_name)
+ return;
+ const char *name = cfg_dump_method_name;
+
+ if ((strchr (name, '.') > name) || strchr (name, ':')) {
+ MonoMethodDesc *desc = mono_method_desc_new (name, TRUE);
+ gboolean failed = !mono_method_desc_full_match (desc, cfg->method);
+ mono_method_desc_free (desc);
+ if (failed)
+ return;
+ } else
+ if (strcmp (cfg->method->name, name) != 0)
+ return;
+
+ g_debug ("cfg_dump: create context for \"%s::%s\"", cfg->method->klass->name, cfg->method->name);
+ int fd = create_socket (DEFAULT_HOST, DEFAULT_PORT);
+ if (fd < 0) {
+ g_warning ("cfg_dump: couldn't create socket: %s::%d", DEFAULT_HOST, DEFAULT_PORT);
+ return;
+ }
+
+ MonoGraphDumper *ctx = (MonoGraphDumper *) mono_mempool_alloc0 (cfg->mempool, sizeof (MonoGraphDumper));
+ ctx->fd = fd;
+ ctx->constant_pool = g_hash_table_new ((GHashFunc) constant_pool_hash, constant_pool_equal);
+ ctx->insn2id = g_hash_table_new ((GHashFunc) instruction_hash, instruction_equal);
+ ctx->next_cp_id = 1;
+ ctx->next_insn_id = 0;
+
+ cfg->gdump_ctx = ctx;
+}
+
+void
+mono_cfg_dump_ir (MonoCompile *cfg, const char *phase_name)
+{
+ if (cfg->gdump_ctx == NULL)
+ return;
+ cfg_debug ("=== DUMPING PASS \"%s\" ===", phase_name);
+ write_byte (cfg, BEGIN_GRAPH);
+ write_pool (cfg, create_cp_entry (cfg, (void *) phase_name, PT_STRING));
+
+ int instruction_count = label_instructions (cfg);
+ write_instructions (cfg, instruction_count);
+ write_blocks (cfg);
+}
+#else /* !defined(DISABLE_LOGGING) && !defined(DISABLE_JIT) && !defined(HOST_WIN32) */
+void
+mono_cfg_dump_create_context (MonoCompile *cfg)
+{
+}
+
+void
+mono_cfg_dump_begin_group (MonoCompile *cfg)
+{
+}
+
+void
+mono_cfg_dump_close_group (MonoCompile *cfg)
+{
+}
+
+void
+mono_cfg_dump_ir (MonoCompile *cfg, const char *phase_name)
+{
+}
+#endif /* !defined(DISABLE_LOGGING) && !defined(DISABLE_JIT) && !defined(HOST_WIN32) */
--- /dev/null
+/*
+ * Copyright (C) 2016 Xamarin Inc
+ * Licensed under the MIT license. See LICENSE file in the project root for full license information.
+ */
+
+#ifndef __MINI_CFGDUMP_H__
+#define __MINI_CFGDUMP_H__
+#include <glib.h>
+
+#define CONSTANT_POOL_MAX_SIZE 8000
+
+#define BEGIN_GROUP 0x00
+#define BEGIN_GRAPH 0x01
+#define CLOSE_GROUP 0x02
+
+#define POOL_NEW 0x00
+#define POOL_STRING 0x01
+#define POOL_ENUM 0x02
+#define POOL_KLASS 0x03
+#define POOL_METHOD 0x04
+#define POOL_NULL 0x05
+#define POOL_NODE_CLASS 0x06
+#define POOL_FIELD 0x07
+#define POOL_SIGNATURE 0x08
+
+#define PROPERTY_POOL 0x00
+#define PROPERTY_INT 0x01
+#define PROPERTY_LONG 0x02
+#define PROPERTY_DOUBLE 0x03
+#define PROPERTY_FLOAT 0x04
+#define PROPERTY_TRUE 0x05
+#define PROPERTY_FALSE 0x06
+#define PROPERTY_ARRAY 0x07
+#define PROPERTY_SUBGRAPH 0x08
+
+#define KLASS 0x00
+#define ENUM_KLASS 0x01
+
+
+#define DEFAULT_PORT 4445
+#define DEFAULT_HOST "127.0.0.1"
+
+typedef enum {
+ PT_STRING,
+ PT_METHOD,
+ PT_KLASS,
+ PT_OPTYPE,
+ PT_INPUTTYPE,
+ PT_ENUMKLASS,
+ PT_SIGNATURE
+} pool_type;
+
+struct _MonoGraphDumper {
+ int fd;
+ GHashTable *constant_pool;
+ short next_cp_id;
+ GHashTable *insn2id;
+ int next_insn_id;
+};
+
+typedef struct _MonoGraphDumper MonoGraphDumper;
+
+struct _ConstantPoolEntry {
+ pool_type pt;
+ void *data;
+};
+
+typedef struct _ConstantPoolEntry ConstantPoolEntry;
+#endif /* __MINI_CFGDUMP_H__ */
MONO_EMIT_NEW_BIALU_IMM (cfg, OP_XOR_IMM, MONO_LVREG_LS (tree->dreg), MONO_LVREG_LS (tree->sreg1), tree->inst_ls_word);
MONO_EMIT_NEW_BIALU_IMM (cfg, OP_XOR_IMM, MONO_LVREG_MS (tree->dreg), MONO_LVREG_MS (tree->sreg1), tree->inst_ms_word);
break;
+#ifdef TARGET_POWERPC
+/* FIXME This is normally handled in cprop. Proper fix or remove if no longer needed. */
case OP_LSHR_UN_IMM:
if (tree->inst_c1 == 32) {
* later apply the speedup to the left shift as well
* See BUG# 57957.
*/
- /* FIXME: Move this to the strength reduction pass */
/* just move the upper half to the lower and zero the high word */
MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, MONO_LVREG_LS (tree->dreg), MONO_LVREG_MS (tree->sreg1));
MONO_EMIT_NEW_ICONST (cfg, MONO_LVREG_MS (tree->dreg), 0);
}
break;
- case OP_LSHL_IMM:
- if (tree->inst_c1 == 32) {
- /* just move the lower half to the upper and zero the lower word */
- MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, MONO_LVREG_MS (tree->dreg), MONO_LVREG_LS (tree->sreg1));
- MONO_EMIT_NEW_ICONST (cfg, MONO_LVREG_LS (tree->dreg), 0);
- }
- break;
-
+#endif
case OP_LCOMPARE: {
MonoInst *next = mono_inst_next (tree, FILTER_IL_SEQ_POINT);
gc_descr = mono_gc_get_description ();
g_print ("\tGC: %s\n", gc_descr);
g_free (gc_descr);
- if (mini_verbose) {
- const char *cerror;
- const char *clibpath;
- mono_init ("mono");
- cerror = mono_check_corlib_version ();
- clibpath = mono_defaults.corlib? mono_image_get_filename (mono_defaults.corlib): "unknown";
- if (cerror) {
- g_print ("The currently installed mscorlib doesn't match this runtime version.\n");
- g_print ("The error is: %s\n", cerror);
- g_print ("mscorlib.dll loaded at: %s\n", clibpath);
- return 1;
- }
- }
return 0;
} else if (strcmp (argv [i], "--help") == 0 || strcmp (argv [i], "-h") == 0) {
mini_usage ();
if (enable_profile) {
mono_profiler_load (profile_options);
- mono_profiler_thread_name (mono_native_thread_id_get (), "Main");
+ mono_profiler_thread_name (MONO_NATIVE_THREAD_ID_TO_UINT (mono_native_thread_id_get ()), "Main");
}
mono_attach_parse_options (attach_options);
mono_do_crash_chaining = chain_crashes;
}
-void
-mono_parse_env_options (int *ref_argc, char **ref_argv [])
+/**
+ * mono_parse_options_from:
+ * @options: string containing strings
+ * @ref_argc: pointer to the argc variable that might be updated
+ * @ref_argv: pointer to the argv string vector variable that might be updated
+ *
+ * This function parses the contents of the `MONO_ENV_OPTIONS`
+ * environment variable as if they were parsed by a command shell
+ * splitting the contents by spaces into different elements of the
+ * @argv vector. This method supports quoting with both the " and '
+ * characters. Inside quoting, spaces and tabs are significant,
+ * otherwise, they are considered argument separators.
+ *
+ * The \ character can be used to escape the next character which will
+ * be added to the current element verbatim. Typically this is used
+ * inside quotes. If the quotes are not balanced, this method
+ *
+ * If the environment variable is empty, no changes are made
+ * to the values pointed by @ref_argc and @ref_argv.
+ *
+ * Otherwise the @ref_argv is modified to point to a new array that contains
+ * all the previous elements contained in the vector, plus the values parsed.
+ * The @argc is updated to match the new number of parameters.
+ *
+ * Returns: The value NULL is returned on success, otherwise a g_strdup allocated
+ * string is returned (this is an alias to malloc under normal circumstances) that
+ * contains the error message that happened during parsing.
+ */
+char *
+mono_parse_options_from (const char *options, int *ref_argc, char **ref_argv [])
{
int argc = *ref_argc;
char **argv = *ref_argv;
-
- const char *env_options = g_getenv ("MONO_ENV_OPTIONS");
- if (env_options != NULL){
- GPtrArray *array = g_ptr_array_new ();
- GString *buffer = g_string_new ("");
- const char *p;
- unsigned i;
- gboolean in_quotes = FALSE;
- char quote_char = '\0';
-
- for (p = env_options; *p; p++){
- switch (*p){
- case ' ': case '\t':
- if (!in_quotes) {
- if (buffer->len != 0){
- g_ptr_array_add (array, g_strdup (buffer->str));
- g_string_truncate (buffer, 0);
- }
- } else {
- g_string_append_c (buffer, *p);
- }
- break;
- case '\\':
- if (p [1]){
- g_string_append_c (buffer, p [1]);
- p++;
- }
- break;
- case '\'':
- case '"':
- if (in_quotes) {
- if (quote_char == *p)
- in_quotes = FALSE;
- else
- g_string_append_c (buffer, *p);
- } else {
- in_quotes = TRUE;
- quote_char = *p;
+ GPtrArray *array = g_ptr_array_new ();
+ GString *buffer = g_string_new ("");
+ const char *p;
+ unsigned i;
+ gboolean in_quotes = FALSE;
+ char quote_char = '\0';
+
+ if (options == NULL)
+ return NULL;
+
+ for (p = options; *p; p++){
+ switch (*p){
+ case ' ': case '\t':
+ if (!in_quotes) {
+ if (buffer->len != 0){
+ g_ptr_array_add (array, g_strdup (buffer->str));
+ g_string_truncate (buffer, 0);
}
- break;
- default:
+ } else {
g_string_append_c (buffer, *p);
- break;
}
+ break;
+ case '\\':
+ if (p [1]){
+ g_string_append_c (buffer, p [1]);
+ p++;
+ }
+ break;
+ case '\'':
+ case '"':
+ if (in_quotes) {
+ if (quote_char == *p)
+ in_quotes = FALSE;
+ else
+ g_string_append_c (buffer, *p);
+ } else {
+ in_quotes = TRUE;
+ quote_char = *p;
+ }
+ break;
+ default:
+ g_string_append_c (buffer, *p);
+ break;
}
- if (in_quotes) {
- fprintf (stderr, "Unmatched quotes in value of MONO_ENV_OPTIONS: [%s]\n", env_options);
- exit (1);
- }
-
- if (buffer->len != 0)
- g_ptr_array_add (array, g_strdup (buffer->str));
- g_string_free (buffer, TRUE);
+ }
+ if (in_quotes)
+ return g_strdup_printf ("Unmatched quotes in value: [%s]\n", options);
+
+ if (buffer->len != 0)
+ g_ptr_array_add (array, g_strdup (buffer->str));
+ g_string_free (buffer, TRUE);
- if (array->len > 0){
- int new_argc = array->len + argc;
- char **new_argv = g_new (char *, new_argc + 1);
- int j;
+ if (array->len > 0){
+ int new_argc = array->len + argc;
+ char **new_argv = g_new (char *, new_argc + 1);
+ int j;
- new_argv [0] = argv [0];
-
- /* First the environment variable settings, to allow the command line options to override */
- for (i = 0; i < array->len; i++)
- new_argv [i+1] = (char *)g_ptr_array_index (array, i);
- i++;
- for (j = 1; j < argc; j++)
- new_argv [i++] = argv [j];
- new_argv [i] = NULL;
-
- *ref_argc = new_argc;
- *ref_argv = new_argv;
- }
- g_ptr_array_free (array, TRUE);
+ new_argv [0] = argv [0];
+
+ /* First the environment variable settings, to allow the command line options to override */
+ for (i = 0; i < array->len; i++)
+ new_argv [i+1] = (char *)g_ptr_array_index (array, i);
+ i++;
+ for (j = 1; j < argc; j++)
+ new_argv [i++] = argv [j];
+ new_argv [i] = NULL;
+
+ *ref_argc = new_argc;
+ *ref_argv = new_argv;
}
+ g_ptr_array_free (array, TRUE);
+ return NULL;
}
+
+/**
+ * mono_parse_env_options:
+ * @ref_argc: pointer to the argc variable that might be updated
+ * @ref_argv: pointer to the argv string vector variable that might be updated
+ *
+ * This function parses the contents of the `MONO_ENV_OPTIONS`
+ * environment variable as if they were parsed by a command shell
+ * splitting the contents by spaces into different elements of the
+ * @argv vector. This method supports quoting with both the " and '
+ * characters. Inside quoting, spaces and tabs are significant,
+ * otherwise, they are considered argument separators.
+ *
+ * The \ character can be used to escape the next character which will
+ * be added to the current element verbatim. Typically this is used
+ * inside quotes. If the quotes are not balanced, this method
+ *
+ * If the environment variable is empty, no changes are made
+ * to the values pointed by @ref_argc and @ref_argv.
+ *
+ * Otherwise the @ref_argv is modified to point to a new array that contains
+ * all the previous elements contained in the vector, plus the values parsed.
+ * The @argc is updated to match the new number of parameters.
+ *
+ * If there is an error parsing, this method will terminate the process by
+ * calling exit(1).
+ *
+ * An alternative to this method that allows an arbitrary string to be parsed
+ * and does not exit on error is the `api:mono_parse_options_from`.
+ */
+void
+mono_parse_env_options (int *ref_argc, char **ref_argv [])
+{
+ char *ret;
+
+ const char *env_options = g_getenv ("MONO_ENV_OPTIONS");
+ if (env_options == NULL)
+ return;
+ ret = mono_parse_options_from (env_options, ref_argc, ref_argv);
+ if (ret == NULL)
+ return;
+ fprintf (stderr, "%s", ret);
+ exit (1);
+}
+
if (is_template && !desc->name)
g_error ("Template without name at line %d in %s\n", line, name);
}
+ g_string_free (comment,TRUE);
fclose (f);
return 0;
}
#endif
break;
}
+#if SIZEOF_REGISTER == 4
+ case OP_LSHR_IMM: {
+ if (ins->inst_c1 == 32) {
+ MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, MONO_LVREG_LS (ins->dreg), MONO_LVREG_MS (ins->sreg1));
+ MONO_EMIT_NEW_BIALU_IMM (cfg, OP_ISHR_IMM, MONO_LVREG_MS (ins->dreg), MONO_LVREG_MS (ins->sreg1), 31);
+ } else if (ins->inst_c1 == 0) {
+ MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, MONO_LVREG_LS (ins->dreg), MONO_LVREG_LS (ins->sreg1));
+ MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, MONO_LVREG_MS (ins->dreg), MONO_LVREG_MS (ins->sreg1));
+ } else if (ins->inst_c1 > 32) {
+ MONO_EMIT_NEW_BIALU_IMM (cfg, OP_ISHR_IMM, MONO_LVREG_LS (ins->dreg), MONO_LVREG_MS (ins->sreg1), ins->inst_c1 - 32);
+ MONO_EMIT_NEW_BIALU_IMM (cfg, OP_ISHR_IMM, MONO_LVREG_MS (ins->dreg), MONO_LVREG_MS (ins->sreg1), 31);
+ } else {
+ guint32 tmpreg = alloc_ireg (cfg);
+ MONO_EMIT_NEW_BIALU_IMM (cfg, OP_ISHL_IMM, tmpreg, MONO_LVREG_MS (ins->sreg1), 32 - ins->inst_c1);
+ MONO_EMIT_NEW_BIALU_IMM (cfg, OP_ISHR_IMM, MONO_LVREG_MS (ins->dreg), MONO_LVREG_MS (ins->sreg1), ins->inst_c1);
+ MONO_EMIT_NEW_BIALU_IMM (cfg, OP_ISHR_UN_IMM, MONO_LVREG_LS (ins->dreg), MONO_LVREG_LS (ins->sreg1), ins->inst_c1);
+ MONO_EMIT_NEW_BIALU (cfg, OP_IOR, MONO_LVREG_LS (ins->dreg), MONO_LVREG_LS (ins->dreg), tmpreg);
+ allocated_vregs = TRUE;
+ }
+ break;
+ }
+ case OP_LSHR_UN_IMM: {
+ if (ins->inst_c1 == 32) {
+ MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, MONO_LVREG_LS (ins->dreg), MONO_LVREG_MS (ins->sreg1));
+ MONO_EMIT_NEW_ICONST (cfg, MONO_LVREG_MS (ins->dreg), 0);
+ } else if (ins->inst_c1 == 0) {
+ MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, MONO_LVREG_LS (ins->dreg), MONO_LVREG_LS (ins->sreg1));
+ MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, MONO_LVREG_MS (ins->dreg), MONO_LVREG_MS (ins->sreg1));
+ } else if (ins->inst_c1 > 32) {
+ MONO_EMIT_NEW_BIALU_IMM (cfg, OP_ISHR_UN_IMM, MONO_LVREG_LS (ins->dreg), MONO_LVREG_MS (ins->sreg1), ins->inst_c1 - 32);
+ MONO_EMIT_NEW_ICONST (cfg, MONO_LVREG_MS (ins->dreg), 0);
+ } else {
+ guint32 tmpreg = alloc_ireg (cfg);
+ MONO_EMIT_NEW_BIALU_IMM (cfg, OP_ISHL_IMM, tmpreg, MONO_LVREG_MS (ins->sreg1), 32 - ins->inst_c1);
+ MONO_EMIT_NEW_BIALU_IMM (cfg, OP_ISHR_UN_IMM, MONO_LVREG_MS (ins->dreg), MONO_LVREG_MS (ins->sreg1), ins->inst_c1);
+ MONO_EMIT_NEW_BIALU_IMM (cfg, OP_ISHR_UN_IMM, MONO_LVREG_LS (ins->dreg), MONO_LVREG_LS (ins->sreg1), ins->inst_c1);
+ MONO_EMIT_NEW_BIALU (cfg, OP_IOR, MONO_LVREG_LS (ins->dreg), MONO_LVREG_LS (ins->dreg), tmpreg);
+ allocated_vregs = TRUE;
+ }
+ break;
+ }
+ case OP_LSHL_IMM: {
+ if (ins->inst_c1 == 32) {
+ /* just move the lower half to the upper and zero the lower word */
+ MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, MONO_LVREG_MS (ins->dreg), MONO_LVREG_LS (ins->sreg1));
+ MONO_EMIT_NEW_ICONST (cfg, MONO_LVREG_LS (ins->dreg), 0);
+ } else if (ins->inst_c1 == 0) {
+ MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, MONO_LVREG_LS (ins->dreg), MONO_LVREG_LS (ins->sreg1));
+ MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, MONO_LVREG_MS (ins->dreg), MONO_LVREG_MS (ins->sreg1));
+ } else if (ins->inst_c1 > 32) {
+ MONO_EMIT_NEW_BIALU_IMM (cfg, OP_ISHL_IMM, MONO_LVREG_MS (ins->dreg), MONO_LVREG_LS (ins->sreg1), ins->inst_c1 - 32);
+ MONO_EMIT_NEW_ICONST (cfg, MONO_LVREG_LS (ins->dreg), 0);
+ } else {
+ guint32 tmpreg = alloc_ireg (cfg);
+ MONO_EMIT_NEW_BIALU_IMM (cfg, OP_ISHR_UN_IMM, tmpreg, MONO_LVREG_LS (ins->sreg1), 32 - ins->inst_c1);
+ MONO_EMIT_NEW_BIALU_IMM (cfg, OP_ISHL_IMM, MONO_LVREG_MS (ins->dreg), MONO_LVREG_MS (ins->sreg1), ins->inst_c1);
+ MONO_EMIT_NEW_BIALU_IMM (cfg, OP_ISHL_IMM, MONO_LVREG_LS (ins->dreg), MONO_LVREG_LS (ins->sreg1), ins->inst_c1);
+ MONO_EMIT_NEW_BIALU (cfg, OP_IOR, MONO_LVREG_MS (ins->dreg), MONO_LVREG_MS (ins->dreg), tmpreg);
+ allocated_vregs = TRUE;
+ }
+ break;
+ }
+#endif
default:
break;
#include <config.h>
+#include <fcntl.h>
+#include <mono/metadata/assembly.h>
+#include <mono/utils/mono-mmap.h>
#include "mini.h"
-#ifndef HOST_WIN32
-#ifndef BUILDVER_INCLUDED
-#include "buildver-boehm.h"
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
#endif
+#ifdef HOST_WIN32
+# include <io.h>
+#else
+# ifndef BUILDVER_INCLUDED
+# include "buildver-boehm.h"
+# endif
#endif
/*
return mono_main (argc, argv);
}
+#define STREAM_INT(x) (*(uint32_t*)x)
+#define STREAM_LONG(x) (*(uint64_t*)x)
+
+static gboolean
+probe_embedded (const char *program, int *ref_argc, char **ref_argv [])
+{
+ MonoBundledAssembly last = { NULL, 0, 0 };
+ char sigbuffer [16+sizeof (uint64_t)];
+ gboolean status = FALSE;
+ uint64_t directory_location;
+ off_t sigstart, baseline = 0;
+ uint64_t directory_size;
+ char *directory, *p;
+ int items, i;
+ unsigned char *mapaddress = NULL;
+ void *maphandle = NULL;
+ GArray *assemblies;
+ char *entry_point = NULL;
+ char **new_argv;
+ int j;
+
+ int fd = open (program, O_RDONLY);
+ if (fd == -1)
+ return FALSE;
+ if ((sigstart = lseek (fd, -(16+sizeof(uint64_t)), SEEK_END)) == -1)
+ goto doclose;
+ if (read (fd, sigbuffer, sizeof (sigbuffer)) == -1)
+ goto doclose;
+ if (memcmp (sigbuffer+sizeof(uint64_t), "xmonkeysloveplay", 16) != 0)
+ goto doclose;
+ directory_location = GUINT64_FROM_LE ((*(uint64_t *) &sigbuffer [0]));
+ if (lseek (fd, directory_location, SEEK_SET) == -1)
+ goto doclose;
+ directory_size = sigstart-directory_location;
+ directory = g_malloc (directory_size);
+ if (directory == NULL)
+ goto doclose;
+ if (read (fd, directory, directory_size) == -1)
+ goto dofree;
+
+ items = STREAM_INT (directory);
+ p = directory+4;
+
+ assemblies = g_array_new (0, 0, sizeof (MonoBundledAssembly*));
+ for (i = 0; i < items; i++){
+ char *kind;
+ int strsize = STREAM_INT (p);
+ uint64_t offset, item_size;
+ kind = p+4;
+ p += 4 + strsize;
+ offset = STREAM_LONG(p);
+ p += 8;
+ item_size = STREAM_INT (p);
+ p += 4;
+
+ if (mapaddress == NULL){
+ mapaddress = mono_file_map (directory_location-offset, MONO_MMAP_READ | MONO_MMAP_PRIVATE, fd, offset, &maphandle);
+ if (mapaddress == NULL){
+ perror ("Error mapping file");
+ exit (1);
+ }
+ baseline = offset;
+ }
+ if (strncmp (kind, "assembly:", strlen ("assembly:")) == 0){
+ char *aname = kind + strlen ("assembly:");
+ MonoBundledAssembly mba = { aname, mapaddress + offset - baseline, item_size }, *ptr;
+ ptr = g_new (MonoBundledAssembly, 1);
+ memcpy (ptr, &mba, sizeof (MonoBundledAssembly));
+ g_array_append_val (assemblies, ptr);
+ if (entry_point == NULL)
+ entry_point = aname;
+ } else if (strncmp (kind, "config:", strlen ("config:")) == 0){
+ printf ("c-Found: %s %llx\n", kind, offset);
+ char *config = kind + strlen ("config:");
+ char *aname = g_strdup (config);
+ aname [strlen(aname)-strlen(".config")] = 0;
+ mono_register_config_for_assembly (aname, config);
+ } else if (strncmp (kind, "system_config:", strlen ("system_config:")) == 0){
+ printf ("TODO s-Found: %s %llx\n", kind, offset);
+ } else if (strncmp (kind, "options:", strlen ("options:")) == 0){
+ mono_parse_options_from (kind + strlen("options:"), ref_argc, ref_argv);
+ } else if (strncmp (kind, "config_dir:", strlen ("config_dir:")) == 0){
+ printf ("TODO Found: %s %llx\n", kind, offset);
+ } else {
+ fprintf (stderr, "Unknown stream on embedded package: %s\n", kind);
+ exit (1);
+ }
+ }
+ g_array_append_val (assemblies, last);
+
+ mono_register_bundled_assemblies ((const MonoBundledAssembly **) assemblies->data);
+ new_argv = g_new (char *, (*ref_argc)+1);
+ for (j = 0; j < *ref_argc; j++)
+ new_argv [j] = (*ref_argv)[j];
+ new_argv [j] = entry_point;
+ *ref_argv = new_argv;
+ (*ref_argc)++;
+
+ return TRUE;
+
+dofree:
+ g_free (directory);
+doclose:
+ if (!status)
+ close (fd);
+ return status;
+}
+
#ifdef HOST_WIN32
#include <shellapi.h>
int
main (void)
{
+ TCHAR szFileName[MAX_PATH];
int argc;
gunichar2** argvw;
gchar** argv;
int i;
-
+ DWORD count;
+
argvw = CommandLineToArgvW (GetCommandLine (), &argc);
argv = g_new0 (gchar*, argc + 1);
for (i = 0; i < argc; i++)
LocalFree (argvw);
+ if ((count = GetModuleFileName (NULL, szFileName, MAX_PATH)) != 0){
+ char *entry = g_utf16_to_utf8 (szFileName, count, NULL, NULL, NULL);
+ probe_embedded (entry, &argc, &argv);
+ }
+
return mono_main_with_options (argc, argv);
}
main (int argc, char* argv[])
{
mono_build_date = build_date;
-
+
+ probe_embedded (argv [0], &argc, &argv);
return mono_main_with_options (argc, argv);
}
if (size < sizeof (MonoObject))
g_error ("Invalid size %d for class %s", size, mono_type_get_full_name (klass));
- EMIT_NEW_ICONST (cfg, iargs [1], mono_gc_get_aligned_size_for_allocator (size));
+ EMIT_NEW_ICONST (cfg, iargs [1], size);
}
return mono_emit_method_call (cfg, managed_alloc, iargs, NULL);
}
g_error ("Invalid size %d for class %s", size, mono_type_get_full_name (klass));
EMIT_NEW_VTABLECONST (cfg, iargs [0], vtable);
- EMIT_NEW_ICONST (cfg, iargs [1], mono_gc_get_aligned_size_for_allocator (size));
+ EMIT_NEW_ICONST (cfg, iargs [1], size);
return mono_emit_method_call (cfg, managed_alloc, iargs, NULL);
}
alloc_ftn = mono_class_get_allocation_ftn (vtable, for_box, &pass_lw);
void
mono_print_ins_index (int i, MonoInst *ins)
+{
+ GString *buf = mono_print_ins_index_strbuf (i, ins);
+ printf ("%s\n", buf->str);
+ g_string_free (buf, TRUE);
+}
+
+GString *
+mono_print_ins_index_strbuf (int i, MonoInst *ins)
{
const char *spec = ins_get_spec (ins->opcode);
+ GString *sbuf = g_string_new (NULL);
int num_sregs, j;
int sregs [MONO_MAX_SRC_REGS];
if (i != -1)
- printf ("\t%-2d %s", i, mono_inst_name (ins->opcode));
+ g_string_append_printf (sbuf, "\t%-2d %s", i, mono_inst_name (ins->opcode));
else
- printf (" %s", mono_inst_name (ins->opcode));
+ g_string_append_printf (sbuf, " %s", mono_inst_name (ins->opcode));
if (spec == MONO_ARCH_CPU_SPEC) {
gboolean dest_base = FALSE;
switch (ins->opcode) {
/* This is a lowered opcode */
if (ins->dreg != -1) {
if (dest_base)
- printf (" [R%d + 0x%lx] <-", ins->dreg, (long)ins->inst_offset);
+ g_string_append_printf (sbuf, " [R%d + 0x%lx] <-", ins->dreg, (long)ins->inst_offset);
else
- printf (" R%d <-", ins->dreg);
+ g_string_append_printf (sbuf, " R%d <-", ins->dreg);
}
if (ins->sreg1 != -1)
- printf (" R%d", ins->sreg1);
+ g_string_append_printf (sbuf, " R%d", ins->sreg1);
if (ins->sreg2 != -1)
- printf (" R%d", ins->sreg2);
+ g_string_append_printf (sbuf, " R%d", ins->sreg2);
if (ins->sreg3 != -1)
- printf (" R%d", ins->sreg3);
+ g_string_append_printf (sbuf, " R%d", ins->sreg3);
switch (ins->opcode) {
case OP_LBNE_UN:
case OP_LBLE:
case OP_LBLE_UN:
if (!ins->inst_false_bb)
- printf (" [B%d]", ins->inst_true_bb->block_num);
+ g_string_append_printf (sbuf, " [B%d]", ins->inst_true_bb->block_num);
else
- printf (" [B%dB%d]", ins->inst_true_bb->block_num, ins->inst_false_bb->block_num);
+ g_string_append_printf (sbuf, " [B%dB%d]", ins->inst_true_bb->block_num, ins->inst_false_bb->block_num);
break;
case OP_PHI:
case OP_VPHI:
case OP_XPHI:
case OP_FPHI: {
int i;
- printf (" [%d (", (int)ins->inst_c0);
+ g_string_append_printf (sbuf, " [%d (", (int)ins->inst_c0);
for (i = 0; i < ins->inst_phi_args [0]; i++) {
if (i)
- printf (", ");
- printf ("R%d", ins->inst_phi_args [i + 1]);
+ g_string_append_printf (sbuf, ", ");
+ g_string_append_printf (sbuf, "R%d", ins->inst_phi_args [i + 1]);
}
- printf (")]");
+ g_string_append_printf (sbuf, ")]");
break;
}
case OP_LDADDR:
case OP_OUTARG_VTRETADDR:
- printf (" R%d", ((MonoInst*)ins->inst_p0)->dreg);
+ g_string_append_printf (sbuf, " R%d", ((MonoInst*)ins->inst_p0)->dreg);
break;
case OP_REGOFFSET:
case OP_GSHAREDVT_ARG_REGOFFSET:
- printf (" + 0x%lx", (long)ins->inst_offset);
+ g_string_append_printf (sbuf, " + 0x%lx", (long)ins->inst_offset);
break;
default:
break;
}
- printf ("\n");
//g_error ("Unknown opcode: %s\n", mono_inst_name (ins->opcode));
- return;
+ return sbuf;
}
if (spec [MONO_INST_DEST]) {
if (is_soft_reg (ins->dreg, bank)) {
if (spec [MONO_INST_DEST] == 'b') {
if (ins->inst_offset == 0)
- printf (" [R%d] <-", ins->dreg);
+ g_string_append_printf (sbuf, " [R%d] <-", ins->dreg);
else
- printf (" [R%d + 0x%lx] <-", ins->dreg, (long)ins->inst_offset);
+ g_string_append_printf (sbuf, " [R%d + 0x%lx] <-", ins->dreg, (long)ins->inst_offset);
}
else
- printf (" R%d <-", ins->dreg);
+ g_string_append_printf (sbuf, " R%d <-", ins->dreg);
} else if (spec [MONO_INST_DEST] == 'b') {
if (ins->inst_offset == 0)
- printf (" [%s] <-", mono_arch_regname (ins->dreg));
+ g_string_append_printf (sbuf, " [%s] <-", mono_arch_regname (ins->dreg));
else
- printf (" [%s + 0x%lx] <-", mono_arch_regname (ins->dreg), (long)ins->inst_offset);
+ g_string_append_printf (sbuf, " [%s + 0x%lx] <-", mono_arch_regname (ins->dreg), (long)ins->inst_offset);
} else
- printf (" %s <-", mono_regname_full (ins->dreg, bank));
+ g_string_append_printf (sbuf, " %s <-", mono_regname_full (ins->dreg, bank));
}
if (spec [MONO_INST_SRC1]) {
int bank = sreg1_bank (spec);
if (is_soft_reg (ins->sreg1, bank)) {
if (spec [MONO_INST_SRC1] == 'b')
- printf (" [R%d + 0x%lx]", ins->sreg1, (long)ins->inst_offset);
+ g_string_append_printf (sbuf, " [R%d + 0x%lx]", ins->sreg1, (long)ins->inst_offset);
else
- printf (" R%d", ins->sreg1);
+ g_string_append_printf (sbuf, " R%d", ins->sreg1);
} else if (spec [MONO_INST_SRC1] == 'b')
- printf (" [%s + 0x%lx]", mono_arch_regname (ins->sreg1), (long)ins->inst_offset);
+ g_string_append_printf (sbuf, " [%s + 0x%lx]", mono_arch_regname (ins->sreg1), (long)ins->inst_offset);
else
- printf (" %s", mono_regname_full (ins->sreg1, bank));
+ g_string_append_printf (sbuf, " %s", mono_regname_full (ins->sreg1, bank));
}
num_sregs = mono_inst_get_src_registers (ins, sregs);
for (j = 1; j < num_sregs; ++j) {
int bank = sreg_bank (j, spec);
if (is_soft_reg (sregs [j], bank))
- printf (" R%d", sregs [j]);
+ g_string_append_printf (sbuf, " R%d", sregs [j]);
else
- printf (" %s", mono_regname_full (sregs [j], bank));
+ g_string_append_printf (sbuf, " %s", mono_regname_full (sregs [j], bank));
}
switch (ins->opcode) {
case OP_ICONST:
- printf (" [%d]", (int)ins->inst_c0);
+ g_string_append_printf (sbuf, " [%d]", (int)ins->inst_c0);
break;
#if defined(TARGET_X86) || defined(TARGET_AMD64)
case OP_X86_PUSH_IMM:
case OP_IXOR_IMM:
case OP_SUB_IMM:
case OP_STORE_MEMBASE_IMM:
- printf (" [%d]", (int)ins->inst_imm);
+ g_string_append_printf (sbuf, " [%d]", (int)ins->inst_imm);
break;
case OP_ADD_IMM:
case OP_LADD_IMM:
- printf (" [%d]", (int)(gssize)ins->inst_p1);
+ g_string_append_printf (sbuf, " [%d]", (int)(gssize)ins->inst_p1);
break;
case OP_I8CONST:
- printf (" [%lld]", (long long)ins->inst_l);
+ g_string_append_printf (sbuf, " [%lld]", (long long)ins->inst_l);
break;
case OP_R8CONST:
- printf (" [%f]", *(double*)ins->inst_p0);
+ g_string_append_printf (sbuf, " [%f]", *(double*)ins->inst_p0);
break;
case OP_R4CONST:
- printf (" [%f]", *(float*)ins->inst_p0);
+ g_string_append_printf (sbuf, " [%f]", *(float*)ins->inst_p0);
break;
case OP_CALL:
case OP_CALL_MEMBASE:
* JIT passes them to backends.
*/
if (ins->dreg != -1)
- printf (" R%d <-", ins->dreg);
+ g_string_append_printf (sbuf, " R%d <-", ins->dreg);
}
if (call->method) {
char *full_name = mono_method_full_name (call->method, TRUE);
- printf (" [%s]", full_name);
+ g_string_append_printf (sbuf, " [%s]", full_name);
g_free (full_name);
} else if (call->fptr_is_patch) {
MonoJumpInfo *ji = (MonoJumpInfo*)call->fptr;
- printf (" ");
+ g_string_append_printf (sbuf, " ");
mono_print_ji (ji);
} else if (call->fptr) {
MonoJitICallInfo *info = mono_find_jit_icall_by_addr (call->fptr);
if (info)
- printf (" [%s]", info->name);
+ g_string_append_printf (sbuf, " [%s]", info->name);
}
list = call->out_ireg_args;
hreg = regpair >> 24;
reg = regpair & 0xffffff;
- printf (" [%s <- R%d]", mono_arch_regname (hreg), reg);
+ g_string_append_printf (sbuf, " [%s <- R%d]", mono_arch_regname (hreg), reg);
list = g_slist_next (list);
}
hreg = regpair >> 24;
reg = regpair & 0xffffff;
- printf (" [%s <- R%d]", mono_arch_fregname (hreg), reg);
+ g_string_append_printf (sbuf, " [%s <- R%d]", mono_arch_fregname (hreg), reg);
list = g_slist_next (list);
}
}
case OP_BR:
case OP_CALL_HANDLER:
- printf (" [B%d]", ins->inst_target_bb->block_num);
+ g_string_append_printf (sbuf, " [B%d]", ins->inst_target_bb->block_num);
break;
case OP_IBNE_UN:
case OP_IBEQ:
case OP_LBLE:
case OP_LBLE_UN:
if (!ins->inst_false_bb)
- printf (" [B%d]", ins->inst_true_bb->block_num);
+ g_string_append_printf (sbuf, " [B%d]", ins->inst_true_bb->block_num);
else
- printf (" [B%dB%d]", ins->inst_true_bb->block_num, ins->inst_false_bb->block_num);
+ g_string_append_printf (sbuf, " [B%dB%d]", ins->inst_true_bb->block_num, ins->inst_false_bb->block_num);
break;
case OP_LIVERANGE_START:
case OP_LIVERANGE_END:
case OP_GC_LIVENESS_DEF:
case OP_GC_LIVENESS_USE:
- printf (" R%d", (int)ins->inst_c1);
+ g_string_append_printf (sbuf, " R%d", (int)ins->inst_c1);
break;
case OP_IL_SEQ_POINT:
case OP_SEQ_POINT:
- printf (" il: 0x%x%s", (int)ins->inst_imm, ins->flags & MONO_INST_NONEMPTY_STACK ? ", nonempty-stack" : "");
+ g_string_append_printf (sbuf, " il: 0x%x%s", (int)ins->inst_imm, ins->flags & MONO_INST_NONEMPTY_STACK ? ", nonempty-stack" : "");
break;
default:
break;
}
if (spec [MONO_INST_CLOB])
- printf (" clobbers: %c", spec [MONO_INST_CLOB]);
- printf ("\n");
+ g_string_append_printf (sbuf, " clobbers: %c", spec [MONO_INST_CLOB]);
+ return sbuf;
}
static void
#include <dlfcn.h>
#include <AvailabilityMacros.h>
-#if defined (TARGET_OSX) && (MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_5)
-#define NEEDS_EXCEPTION_THREAD
-#endif
-
-#ifdef NEEDS_EXCEPTION_THREAD
-
-/*
- * This code disables the CrashReporter of MacOS X by installing
- * a dummy Mach exception handler.
- */
-
-/*
- * http://darwinsource.opendarwin.org/10.4.3/xnu-792.6.22/osfmk/man/exc_server.html
- */
-extern boolean_t exc_server (mach_msg_header_t *request_msg, mach_msg_header_t *reply_msg);
-
-/*
- * The exception message
- */
-typedef struct {
- mach_msg_base_t msg; /* common mach message header */
- char payload [1024]; /* opaque */
-} mach_exception_msg_t;
-
-/* The exception port */
-static mach_port_t mach_exception_port = VM_MAP_NULL;
-
-kern_return_t
-catch_exception_raise (
- mach_port_t exception_port,
- mach_port_t thread,
- mach_port_t task,
- exception_type_t exception,
- exception_data_t code,
- mach_msg_type_number_t code_count);
-
-/*
- * Implicitly called by exc_server. Must be public.
- *
- * http://darwinsource.opendarwin.org/10.4.3/xnu-792.6.22/osfmk/man/catch_exception_raise.html
- */
-kern_return_t
-catch_exception_raise (
- mach_port_t exception_port,
- mach_port_t thread,
- mach_port_t task,
- exception_type_t exception,
- exception_data_t code,
- mach_msg_type_number_t code_count)
-{
- /* consume the exception */
- return KERN_FAILURE;
-}
-
-/*
- * Exception thread handler.
- */
-static
-void *
-mach_exception_thread (void *arg)
-{
- for (;;) {
- mach_exception_msg_t request;
- mach_exception_msg_t reply;
- mach_msg_return_t result;
-
- /* receive from "mach_exception_port" */
- result = mach_msg (&request.msg.header,
- MACH_RCV_MSG | MACH_RCV_LARGE,
- 0,
- sizeof (request),
- mach_exception_port,
- MACH_MSG_TIMEOUT_NONE,
- MACH_PORT_NULL);
-
- g_assert (result == MACH_MSG_SUCCESS);
-
- /* dispatch to catch_exception_raise () */
- exc_server (&request.msg.header, &reply.msg.header);
-
- /* send back to sender */
- result = mach_msg (&reply.msg.header,
- MACH_SEND_MSG,
- reply.msg.header.msgh_size,
- 0,
- MACH_PORT_NULL,
- MACH_MSG_TIMEOUT_NONE,
- MACH_PORT_NULL);
-
- /*
- If we try to abort the thread while delivering an exception. The port will be gone since the kernel
- setup a send once port to deliver the resume message and thread_abort will consume it.
- */
- g_assert (result == MACH_MSG_SUCCESS || result == MACH_SEND_INVALID_DEST);
- }
- return NULL;
-}
-
-static void
-macosx_register_exception_handler (void)
-{
- mach_port_t task;
- pthread_attr_t attr;
- pthread_t thread;
-
- if (mach_exception_port != VM_MAP_NULL)
- return;
-
- task = mach_task_self ();
-
- /* create the "mach_exception_port" with send & receive rights */
- g_assert (mach_port_allocate (task, MACH_PORT_RIGHT_RECEIVE,
- &mach_exception_port) == KERN_SUCCESS);
- g_assert (mach_port_insert_right (task, mach_exception_port, mach_exception_port,
- MACH_MSG_TYPE_MAKE_SEND) == KERN_SUCCESS);
-
- /* create the exception handler thread */
- g_assert (!pthread_attr_init (&attr));
- g_assert (!pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED));
- g_assert (!pthread_create (&thread, &attr, mach_exception_thread, NULL));
- pthread_attr_destroy (&attr);
-
- /*
- * register "mach_exception_port" as a receiver for the
- * EXC_BAD_ACCESS exception
- *
- * http://darwinsource.opendarwin.org/10.4.3/xnu-792.6.22/osfmk/man/task_set_exception_ports.html
- */
- g_assert (task_set_exception_ports (task, EXC_MASK_BAD_ACCESS,
- mach_exception_port,
- EXCEPTION_DEFAULT,
- MACHINE_THREAD_STATE) == KERN_SUCCESS);
-
- mono_gc_register_mach_exception_thread (thread);
-}
-
-#endif
-
/* This is #define'd by Boehm GC to _GC_dlopen. */
#undef dlopen
void
mono_runtime_install_handlers (void)
{
-#ifdef NEEDS_EXCEPTION_THREAD
- macosx_register_exception_handler ();
-#endif
mono_runtime_posix_install_handlers ();
/* Snow Leopard has a horrible bug: http://openradar.appspot.com/7209349
state = (thread_state_t) alloca (mono_mach_arch_get_thread_state_size ());
mctx = (mcontext_t) alloca (mono_mach_arch_get_mcontext_size ());
- ret = mono_mach_arch_get_thread_state (info->native_handle, state, &num_state);
+ do {
+ ret = mono_mach_arch_get_thread_state (info->native_handle, state, &num_state);
+ } while (ret == KERN_ABORTED);
if (ret != KERN_SUCCESS)
return FALSE;
{
kern_return_t ret;
- if ((ret = host_get_clock_service (mach_host_self (), SYSTEM_CLOCK, &sampling_clock_service)) != KERN_SUCCESS)
+ do {
+ ret = host_get_clock_service (mach_host_self (), SYSTEM_CLOCK, &sampling_clock_service);
+ } while (ret == KERN_ABORTED);
+
+ if (ret != KERN_SUCCESS)
g_error ("%s: host_get_clock_service () returned %d", __func__, ret);
}
{
kern_return_t ret;
- if ((ret = mach_port_deallocate (mach_task_self (), sampling_clock_service)) != KERN_SUCCESS)
+ do {
+ ret = mach_port_deallocate (mach_task_self (), sampling_clock_service);
+ } while (ret == KERN_ABORTED);
+
+ if (ret != KERN_SUCCESS)
g_error ("%s: mach_port_deallocate () returned %d", __func__, ret);
}
kern_return_t ret;
mach_timespec_t mach_ts;
- if ((ret = clock_get_time (sampling_clock_service, &mach_ts)) != KERN_SUCCESS)
+ do {
+ ret = clock_get_time (sampling_clock_service, &mach_ts);
+ } while (ret == KERN_ABORTED);
+
+ if (ret != KERN_SUCCESS)
g_error ("%s: clock_get_time () returned %d", __func__, ret);
return ((guint64) mach_ts.tv_sec * 1000000000) + (guint64) mach_ts.tv_nsec;
do {
ret = clock_sleep (sampling_clock_service, TIME_ABSOLUTE, then, &remain_unused);
-
- if (ret != KERN_SUCCESS && ret != KERN_ABORTED)
- g_error ("%s: clock_sleep () returned %d", __func__, ret);
} while (ret == KERN_ABORTED);
+
+ if (ret != KERN_SUCCESS)
+ g_error ("%s: clock_sleep () returned %d", __func__, ret);
+
}
#else
mono_counters_register ("Methods from AOT", MONO_COUNTER_JIT | MONO_COUNTER_INT, &mono_jit_stats.methods_aot);
mono_counters_register ("Methods JITted using mono JIT", MONO_COUNTER_JIT | MONO_COUNTER_INT, &mono_jit_stats.methods_without_llvm);
mono_counters_register ("Methods JITted using LLVM", MONO_COUNTER_JIT | MONO_COUNTER_INT, &mono_jit_stats.methods_with_llvm);
- mono_counters_register ("JIT/method-to-IR (sec)", MONO_COUNTER_JIT | MONO_COUNTER_DOUBLE, &mono_jit_stats.jit_method_to_ir);
+ mono_counters_register ("JIT/method_to_ir (sec)", MONO_COUNTER_JIT | MONO_COUNTER_DOUBLE, &mono_jit_stats.jit_method_to_ir);
mono_counters_register ("JIT/liveness_handle_exception_clauses (sec)", MONO_COUNTER_JIT | MONO_COUNTER_DOUBLE, &mono_jit_stats.jit_liveness_handle_exception_clauses);
mono_counters_register ("JIT/handle_out_of_line_bblock (sec)", MONO_COUNTER_JIT | MONO_COUNTER_DOUBLE, &mono_jit_stats.jit_handle_out_of_line_bblock);
mono_counters_register ("JIT/decompose_long_opts (sec)", MONO_COUNTER_JIT | MONO_COUNTER_DOUBLE, &mono_jit_stats.jit_decompose_long_opts);
header = cfg->header;
sig = mono_method_signature (cfg->method);
- cinfo = get_call_info (cfg->mempool, sig);
+ if (!cfg->arch.cinfo)
+ cfg->arch.cinfo = get_call_info (cfg->mempool, sig);
+ cinfo = (CallInfo *)cfg->arch.cinfo;
cfg->frame_reg = X86_EBP;
offset = 0;
if (inst->opcode != OP_REGVAR) {
inst->opcode = OP_REGOFFSET;
inst->inst_basereg = X86_EBP;
+ inst->inst_offset = ainfo->offset + ARGS_OFFSET;
}
- inst->inst_offset = ainfo->offset + ARGS_OFFSET;
}
cfg->stack_offset = offset;
sig = mono_method_signature (cfg->method);
- cinfo = get_call_info (cfg->mempool, sig);
+ if (!cfg->arch.cinfo)
+ cfg->arch.cinfo = get_call_info (cfg->mempool, sig);
+ cinfo = (CallInfo *)cfg->arch.cinfo;
+
sig_ret = mini_get_underlying_type (sig->ret);
if (cinfo->ret.storage == ArgValuetypeInReg)
MonoBasicBlock *bb;
MonoMethodSignature *sig;
MonoInst *inst;
+ CallInfo *cinfo;
+ ArgInfo *ainfo;
int alloc_size, pos, max_offset, i, cfa_offset;
guint8 *code;
gboolean need_stack_frame;
sig = mono_method_signature (method);
pos = 0;
+ cinfo = (CallInfo *)cfg->arch.cinfo;
+
for (i = 0; i < sig->param_count + sig->hasthis; ++i) {
inst = cfg->args [pos];
+ ainfo = &cinfo->args [pos];
if (inst->opcode == OP_REGVAR) {
g_assert (need_stack_frame);
- x86_mov_reg_membase (code, inst->dreg, X86_EBP, inst->inst_offset, 4);
+ x86_mov_reg_membase (code, inst->dreg, X86_EBP, ainfo->offset + ARGS_OFFSET, 4);
if (cfg->verbose_level > 2)
g_print ("Argument %d assigned to register %s\n", pos, mono_arch_regname (inst->dreg));
}
}
/* Load returned vtypes into registers if needed */
- cinfo = get_call_info (cfg->mempool, sig);
+ cinfo = (CallInfo *)cfg->arch.cinfo;
if (cinfo->ret.storage == ArgValuetypeInReg) {
for (quad = 0; quad < 2; quad ++) {
switch (cinfo->ret.pair_storage [quad]) {
gboolean need_stack_frame_inited;
gboolean need_stack_frame;
int sp_fp_offset, param_area_size;
+ gpointer cinfo;
gpointer ss_tramp_var;
gpointer bp_tramp_var;
} MonoCompileArch;
*/
mono_compile_create_vars (cfg);
+ mono_cfg_dump_create_context (cfg);
+ mono_cfg_dump_begin_group (cfg);
+
MONO_TIME_TRACK (mono_jit_stats.jit_method_to_ir, i = mono_method_to_ir (cfg, method_to_compile, NULL, NULL, NULL, NULL, 0, FALSE));
+ mono_cfg_dump_ir (cfg, "method-to-ir");
if (i < 0) {
if (try_generic_shared && cfg->exception_type == MONO_EXCEPTION_GENERIC_SHARING_FAILED) {
* SSA will ignore variables marked VOLATILE.
*/
MONO_TIME_TRACK (mono_jit_stats.jit_liveness_handle_exception_clauses, mono_liveness_handle_exception_clauses (cfg));
+ mono_cfg_dump_ir (cfg, "liveness_handle_exception_clauses");
MONO_TIME_TRACK (mono_jit_stats.jit_handle_out_of_line_bblock, mono_handle_out_of_line_bblock (cfg));
+ mono_cfg_dump_ir (cfg, "handle_out_of_line_bblock");
/*g_print ("numblocks = %d\n", cfg->num_bblocks);*/
if (!COMPILE_LLVM (cfg)) {
MONO_TIME_TRACK (mono_jit_stats.jit_decompose_long_opts, mono_decompose_long_opts (cfg));
+ mono_cfg_dump_ir (cfg, "decompose_long_opts");
}
/* Should be done before branch opts */
- if (cfg->opt & (MONO_OPT_CONSPROP | MONO_OPT_COPYPROP))
+ if (cfg->opt & (MONO_OPT_CONSPROP | MONO_OPT_COPYPROP)) {
MONO_TIME_TRACK (mono_jit_stats.jit_local_cprop, mono_local_cprop (cfg));
+ mono_cfg_dump_ir (cfg, "local_cprop");
+ }
/*
* Should be done after cprop which can do strength reduction on
* some of these ops, after propagating immediates.
*/
- if (cfg->has_emulated_ops)
+ if (cfg->has_emulated_ops) {
MONO_TIME_TRACK (mono_jit_stats.jit_local_emulate_ops, mono_local_emulate_ops (cfg));
+ mono_cfg_dump_ir (cfg, "local_emulate_ops");
+ }
- if (cfg->opt & MONO_OPT_BRANCH)
+ if (cfg->opt & MONO_OPT_BRANCH) {
MONO_TIME_TRACK (mono_jit_stats.jit_optimize_branches, mono_optimize_branches (cfg));
+ mono_cfg_dump_ir (cfg, "optimize_branches");
+ }
/* This must be done _before_ global reg alloc and _after_ decompose */
MONO_TIME_TRACK (mono_jit_stats.jit_handle_global_vregs, mono_handle_global_vregs (cfg));
- if (cfg->opt & MONO_OPT_DEADCE)
+ mono_cfg_dump_ir (cfg, "handle_global_vregs");
+ if (cfg->opt & MONO_OPT_DEADCE) {
MONO_TIME_TRACK (mono_jit_stats.jit_local_deadce, mono_local_deadce (cfg));
- if (cfg->opt & MONO_OPT_ALIAS_ANALYSIS)
+ mono_cfg_dump_ir (cfg, "local_deadce");
+ }
+ if (cfg->opt & MONO_OPT_ALIAS_ANALYSIS) {
MONO_TIME_TRACK (mono_jit_stats.jit_local_alias_analysis, mono_local_alias_analysis (cfg));
+ mono_cfg_dump_ir (cfg, "local_alias_analysis");
+ }
/* Disable this for LLVM to make the IR easier to handle */
- if (!COMPILE_LLVM (cfg))
+ if (!COMPILE_LLVM (cfg)) {
MONO_TIME_TRACK (mono_jit_stats.jit_if_conversion, mono_if_conversion (cfg));
+ mono_cfg_dump_ir (cfg, "if_conversion");
+ }
mono_threads_safepoint ();
MONO_TIME_TRACK (mono_jit_stats.jit_bb_ordering, mono_bb_ordering (cfg));
+ mono_cfg_dump_ir (cfg, "bb_ordering");
if (((cfg->num_varinfo > 2000) || (cfg->num_bblocks > 1000)) && !cfg->compile_aot) {
/*
}
MONO_TIME_TRACK (mono_jit_stats.jit_insert_safepoints, mono_insert_safepoints (cfg));
+ mono_cfg_dump_ir (cfg, "insert_safepoints");
/* after method_to_ir */
if (parts == 1) {
if (!(cfg->comp_done & MONO_COMP_SSA) && !cfg->disable_ssa) {
#ifndef DISABLE_SSA
MONO_TIME_TRACK (mono_jit_stats.jit_ssa_compute, mono_ssa_compute (cfg));
+ mono_cfg_dump_ir (cfg, "ssa_compute");
#endif
if (cfg->verbose_level >= 2) {
if (cfg->comp_done & MONO_COMP_SSA && !COMPILE_LLVM (cfg)) {
#ifndef DISABLE_SSA
MONO_TIME_TRACK (mono_jit_stats.jit_ssa_cprop, mono_ssa_cprop (cfg));
+ mono_cfg_dump_ir (cfg, "ssa_cprop");
#endif
}
}
if (cfg->comp_done & MONO_COMP_SSA && !COMPILE_LLVM (cfg)) {
//mono_ssa_strength_reduction (cfg);
- if (cfg->opt & MONO_OPT_DEADCE)
+ if (cfg->opt & MONO_OPT_DEADCE) {
MONO_TIME_TRACK (mono_jit_stats.jit_ssa_deadce, mono_ssa_deadce (cfg));
+ mono_cfg_dump_ir (cfg, "ssa_deadce");
+ }
- if ((cfg->flags & (MONO_CFG_HAS_LDELEMA|MONO_CFG_HAS_CHECK_THIS)) && (cfg->opt & MONO_OPT_ABCREM))
+ if ((cfg->flags & (MONO_CFG_HAS_LDELEMA|MONO_CFG_HAS_CHECK_THIS)) && (cfg->opt & MONO_OPT_ABCREM)) {
MONO_TIME_TRACK (mono_jit_stats.jit_perform_abc_removal, mono_perform_abc_removal (cfg));
+ mono_cfg_dump_ir (cfg, "perform_abc_removal");
+ }
MONO_TIME_TRACK (mono_jit_stats.jit_ssa_remove, mono_ssa_remove (cfg));
+ mono_cfg_dump_ir (cfg, "ssa_remove");
MONO_TIME_TRACK (mono_jit_stats.jit_local_cprop2, mono_local_cprop (cfg));
+ mono_cfg_dump_ir (cfg, "local_cprop2");
MONO_TIME_TRACK (mono_jit_stats.jit_handle_global_vregs2, mono_handle_global_vregs (cfg));
- if (cfg->opt & MONO_OPT_DEADCE)
+ mono_cfg_dump_ir (cfg, "handle_global_vregs2");
+ if (cfg->opt & MONO_OPT_DEADCE) {
MONO_TIME_TRACK (mono_jit_stats.jit_local_deadce2, mono_local_deadce (cfg));
+ mono_cfg_dump_ir (cfg, "local_deadce2");
+ }
- if (cfg->opt & MONO_OPT_BRANCH)
+ if (cfg->opt & MONO_OPT_BRANCH) {
MONO_TIME_TRACK (mono_jit_stats.jit_optimize_branches2, mono_optimize_branches (cfg));
+ mono_cfg_dump_ir (cfg, "optimize_branches2");
+ }
}
#endif
if (cfg->comp_done & MONO_COMP_SSA && COMPILE_LLVM (cfg)) {
mono_ssa_loop_invariant_code_motion (cfg);
+ mono_cfg_dump_ir (cfg, "loop_invariant_code_motion");
/* This removes MONO_INST_FAULT flags too so perform it unconditionally */
- if (cfg->opt & MONO_OPT_ABCREM)
+ if (cfg->opt & MONO_OPT_ABCREM) {
mono_perform_abc_removal (cfg);
+ mono_cfg_dump_ir (cfg, "abc_removal");
+ }
}
/* after SSA removal */
mono_decompose_soft_float (cfg);
#endif
MONO_TIME_TRACK (mono_jit_stats.jit_decompose_vtype_opts, mono_decompose_vtype_opts (cfg));
- if (cfg->flags & MONO_CFG_HAS_ARRAY_ACCESS)
+ if (cfg->flags & MONO_CFG_HAS_ARRAY_ACCESS) {
MONO_TIME_TRACK (mono_jit_stats.jit_decompose_array_access_opts, mono_decompose_array_access_opts (cfg));
+ mono_cfg_dump_ir (cfg, "decompose_array_access_opts");
+ }
if (cfg->got_var) {
#ifndef MONO_ARCH_GOT_REG
}
}
MONO_TIME_TRACK (mono_jit_stats.jit_linear_scan, mono_linear_scan (cfg, vars, regs, &cfg->used_int_regs));
+ mono_cfg_dump_ir (cfg, "linear_scan");
}
}
/* variables are allocated after decompose, since decompose could create temps */
if (!COMPILE_LLVM (cfg)) {
MONO_TIME_TRACK (mono_jit_stats.jit_arch_allocate_vars, mono_arch_allocate_vars (cfg));
+ mono_cfg_dump_ir (cfg, "arch_allocate_vars");
if (cfg->exception_type)
return cfg;
}
if (!COMPILE_LLVM (cfg)) {
gboolean need_local_opts;
MONO_TIME_TRACK (mono_jit_stats.jit_spill_global_vars, mono_spill_global_vars (cfg, &need_local_opts));
+ mono_cfg_dump_ir (cfg, "spill_global_vars");
if (need_local_opts || cfg->compile_aot) {
/* To optimize code created by spill_global_vars */
MONO_TIME_TRACK (mono_jit_stats.jit_local_cprop3, mono_local_cprop (cfg));
if (cfg->opt & MONO_OPT_DEADCE)
MONO_TIME_TRACK (mono_jit_stats.jit_local_deadce3, mono_local_deadce (cfg));
+ mono_cfg_dump_ir (cfg, "needs_local_opts");
}
}
#endif
} else {
MONO_TIME_TRACK (mono_jit_stats.jit_codegen, mono_codegen (cfg));
+ mono_cfg_dump_ir (cfg, "codegen");
if (cfg->exception_type)
return cfg;
}
if (MONO_METHOD_COMPILE_END_ENABLED ())
MONO_PROBE_METHOD_COMPILE_END (method, TRUE);
+ mono_cfg_dump_close_group (cfg);
+
return cfg;
}
#include "regalloc.h"
#include "mini-unwind.h"
#include "jit.h"
+#include "cfgdump.h"
#include "mono/metadata/class-internals.h"
#include "mono/metadata/domain-internals.h"
/* Error handling */
MonoError error;
+ /* pointer to context datastructure used for graph dumping */
+ MonoGraphDumper *gdump_ctx;
+
/* Stats */
int stat_allocate_var;
int stat_locals_stack_size;
MONO_API int mono_main (int argc, char* argv[]);
MONO_API void mono_set_defaults (int verbose_level, guint32 opts);
MONO_API void mono_parse_env_options (int *ref_argc, char **ref_argv []);
+MONO_API char *mono_parse_options_from (const char *options, int *ref_argc, char **ref_argv []);
+
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);
+/* graph dumping */
+void mono_cfg_dump_create_context (MonoCompile *cfg);
+void mono_cfg_dump_begin_group (MonoCompile *cfg);
+void mono_cfg_dump_close_group (MonoCompile *cfg);
+void mono_cfg_dump_ir (MonoCompile *cfg, const char *phase_name);
+
/* helper methods */
void mini_jit_init (void);
void mini_jit_cleanup (void);
const char*mono_ji_type_to_string (MonoJumpInfoType type);
void mono_print_ji (const MonoJumpInfo *ji);
void mono_print_ins_index (int i, MonoInst *ins);
+GString *mono_print_ins_index_strbuf (int i, MonoInst *ins);
void mono_print_ins (MonoInst *ins);
void mono_print_bb (MonoBasicBlock *bb, const char *msg);
void mono_print_code (MonoCompile *cfg, const char *msg);
TMP_FILE_PREFIX=$(basename $0).tmp
BASEDIR=$(dirname $0)
-MONO_PATH=$BASEDIR/../../mcs/class/lib/net_4_x:$BASEDIR
+case "$(uname -s)" in
+ CYGWIN*) PLATFORM_PATH_SEPARATOR=';';;
+ *) PLATFORM_PATH_SEPARATOR=':';;
+esac
+
+MONO_PATH=$BASEDIR/../../mcs/class/lib/net_4_x$PLATFORM_PATH_SEPARATOR$BASEDIR
RUNTIME=$BASEDIR/../../runtime/mono-wrapper
trap "rm -rf ${TMP_FILE_PREFIX}*" EXIT
}
clean_aot () {
- rm -rf *.exe.so *.exe.dylib *.exe.dylib.dSYM
+ rm -rf *.exe.so *.exe.dylib *.exe.dylib.dSYM *.exe.dll
}
# The test compares the generated native code size between a compilation with and without seq points.
}
diff_methods () {
- TMP_FILE=$(tmp_file)
- echo "$(MONO_DEBUG=single-imm-size get_methods $1 $2 $3 $4)" >$TMP_FILE
- diff <(cat $TMP_FILE) <(echo "$(MONO_DEBUG=gen-compact-seq-points,single-imm-size get_methods $1 $2 $3 $4)")
+ TMP_FILE1=$(tmp_file)
+ TMP_FILE2=$(tmp_file)
+ echo "$(MONO_DEBUG=single-imm-size get_methods $1 $2 $3 $4)" >$TMP_FILE1
+ echo "$(MONO_DEBUG=gen-compact-seq-points,single-imm-size get_methods $1 $2 $3 $4)" >$TMP_FILE2
+ diff $TMP_FILE1 $TMP_FILE2
}
diff_method () {
- TMP_FILE=$(tmp_file)
- echo "$(MONO_DEBUG=single-imm-size get_method $1 $2 $3 $4 $5)" >$TMP_FILE
- sdiff -w 150 <(cat $TMP_FILE) <(echo "$(MONO_DEBUG=gen-compact-seq-points,single-imm-size get_method $1 $2 $3 $4 $5 | grep -Ev il_seq_point)")
+ TMP_FILE1=$(tmp_file)
+ TMP_FILE2=$(tmp_file)
+ echo "$(MONO_DEBUG=single-imm-size get_method $1 $2 $3 $4 $5)" >$TMP_FILE1
+ echo "$(MONO_DEBUG=gen-compact-seq-points,single-imm-size get_method $1 $2 $3 $4 $5 | grep -Ev il_seq_point)" >$TMP_FILE2
+ sdiff -w 150 $TMP_FILE1 $TMP_FILE2
}
get_method_name () {
return NULL;
}
+gpointer
+mono_arch_create_handler_block_trampoline (MonoTrampInfo **info, gboolean aot)
+{
+ g_assert_not_reached ();
+ return NULL;
+}
+
gpointer
mono_arch_get_unbox_trampoline (MonoMethod *m, gpointer addr)
{
while ((node = mono_lock_free_queue_dequeue (queue))) {
count++;
- mono_lock_free_queue_node_free (node);
+ mono_thread_hazardous_try_free (node, free);
}
return count;
dump_buffer (prof, entry->buffer);
- free (entry);
+ mono_thread_hazardous_try_free (entry, free);
return TRUE;
}
writer_thread (void *arg)
{
MonoProfiler *prof = (MonoProfiler *)arg;
- WriterQueueEntry *entry;
mono_threads_attach_tools_thread ();
mono_thread_info_set_name (mono_native_thread_id_get (), "Profiler writer");
#endif
mono_lock_free_queue_init (&prof->writer_queue);
- mono_os_sem_init (&prof->writer_queue_sem, 1);
+ mono_os_sem_init (&prof->writer_queue_sem, 0);
mono_os_mutex_init (&prof->method_table_mutex);
prof->method_table = mono_conc_hashtable_new (NULL, NULL);
/* MS_BLOCK_SIZE must be a multiple of the system pagesize, which for some
architectures is 64k. */
-#if defined(TARGET_POWERPC64)
+#if defined(TARGET_POWERPC) || defined(TARGET_POWERPC64)
#define ARCH_MIN_MS_BLOCK_SIZE (64*1024)
#define ARCH_MIN_MS_BLOCK_SIZE_SHIFT 16
#endif
}
/* Note: we also handle structs with just ref fields */
if (num_set * sizeof (gpointer) == elem_size) {
- return desc | VECTOR_SUBTYPE_REFS | ((gssize)(-1) << 16);
+ return desc | VECTOR_SUBTYPE_REFS | ((gsize)(-1) << 16);
}
/* FIXME: try run-len first */
/* Note: we can't skip the object header here, because it's not present */
definitely_pinned [count] = obj_to_pin;
count++;
}
+ if (concurrent_collection_in_progress)
+ sgen_pinning_register_pinned_in_nursery (obj_to_pin);
next_pin_queue_entry:
last = addr;
major_collector.scan_card_table (CARDTABLE_SCAN_MOD_UNION_PRECLEAN, ctx);
sgen_los_scan_card_table (CARDTABLE_SCAN_MOD_UNION_PRECLEAN, ctx);
+
+ sgen_scan_pin_queue_objects (ctx);
}
static void
alloc_nursery ();
+ sgen_pinning_init ();
sgen_cement_init (cement_enabled);
if ((env = g_getenv (MONO_GC_DEBUG_NAME))) {
guint16 obj_size_index;
/* FIXME: Reduce this - it only needs a byte. */
volatile gint32 state;
+ gint16 nused;
unsigned int pinned : 1;
unsigned int has_references : 1;
unsigned int has_pinned : 1; /* means cannot evacuate */
static gboolean *evacuate_block_obj_sizes;
static float evacuation_threshold = 0.666f;
-static gboolean lazy_sweep = FALSE;
+static gboolean lazy_sweep = TRUE;
enum {
SWEEP_STATE_SWEPT,
static gboolean ensure_block_is_checked_for_sweeping (guint32 block_index, gboolean wait, gboolean *have_checked);
static SgenThreadPoolJob * volatile sweep_job;
+static SgenThreadPoolJob * volatile sweep_blocks_job;
static void
major_finish_sweep_checking (void)
for (i = 0; i < MS_NUM_MARK_WORDS; ++i)
nused += bitcount (block->mark_words [i]);
+ block->nused = nused;
if (nused)
have_live = TRUE;
if (nused < count)
return !!tagged_block;
}
+static void
+sweep_blocks_job_func (void *thread_data_untyped, SgenThreadPoolJob *job)
+{
+ volatile gpointer *slot;
+
+ SGEN_ARRAY_LIST_FOREACH_SLOT (&allocated_blocks, slot) {
+ sweep_block (BLOCK_UNTAG (*slot));
+ } SGEN_ARRAY_LIST_END_FOREACH_SLOT;
+
+ mono_memory_write_barrier ();
+
+ sweep_blocks_job = NULL;
+}
+
static void
sweep_job_func (void *thread_data_untyped, SgenThreadPoolJob *job)
{
sgen_array_list_remove_nulls (&allocated_blocks);
+ /*
+ * Concurrently sweep all the blocks to reduce workload during minor
+ * pauses where we need certain blocks to be swept. At the start of
+ * the next major we need all blocks to be swept anyway.
+ */
+ if (concurrent_sweep && lazy_sweep) {
+ sweep_blocks_job = sgen_thread_pool_job_alloc ("sweep_blocks", sweep_blocks_job_func, sizeof (SgenThreadPoolJob));
+ sgen_thread_pool_job_enqueue (sweep_blocks_job);
+ }
+
sweep_finish ();
sweep_job = NULL;
}
}
+ sgen_memgov_major_post_sweep ();
+
set_sweep_state (SWEEP_STATE_SWEPT, SWEEP_STATE_COMPACTING);
+ if (concurrent_sweep)
+ binary_protocol_concurrent_sweep_end (sgen_timestamp ());
}
static void
#endif
}
+static int
+block_usage_comparer (const void *bl1, const void *bl2)
+{
+ const gint16 nused1 = (*(MSBlockInfo**)bl1)->nused;
+ const gint16 nused2 = (*(MSBlockInfo**)bl2)->nused;
+
+ return nused2 - nused1;
+}
+
+static void
+sgen_evacuation_freelist_blocks (MSBlockInfo * volatile *block_list, int size_index)
+{
+ MSBlockInfo **evacuated_blocks;
+ size_t index = 0, count, num_blocks = 0, num_used = 0;
+ MSBlockInfo *info;
+ MSBlockInfo * volatile *prev;
+
+ for (info = *block_list; info != NULL; info = info->next_free) {
+ num_blocks++;
+ num_used += info->nused;
+ }
+
+ /*
+ * We have a set of blocks in the freelist which will be evacuated. Instead
+ * of evacuating all of the blocks into new ones, we traverse the freelist
+ * sorting it by the number of occupied slots, evacuating the objects from
+ * blocks with fewer used slots into fuller blocks.
+ *
+ * The number of used slots is set at the end of the previous sweep. Since
+ * we sequentially unlink slots from blocks, except for the head of the
+ * freelist, for blocks on the freelist, the number of used slots is the same
+ * as at the end of the previous sweep.
+ */
+ evacuated_blocks = (MSBlockInfo**)sgen_alloc_internal_dynamic (sizeof (MSBlockInfo*) * num_blocks, INTERNAL_MEM_TEMPORARY, TRUE);
+
+ for (info = *block_list; info != NULL; info = info->next_free) {
+ evacuated_blocks [index++] = info;
+ }
+
+ SGEN_ASSERT (0, num_blocks == index, "Why did the freelist change ?");
+
+ qsort (evacuated_blocks, num_blocks, sizeof (gpointer), block_usage_comparer);
+
+ /*
+ * Form a new freelist with the fullest blocks. These blocks will also be
+ * marked as to_space so we don't evacuate from them.
+ */
+ count = MS_BLOCK_FREE / block_obj_sizes [size_index];
+ prev = block_list;
+ for (index = 0; index < (num_used + count - 1) / count; index++) {
+ SGEN_ASSERT (0, index < num_blocks, "Why do we need more blocks for compaction than we already had ?");
+ info = evacuated_blocks [index];
+ info->is_to_space = TRUE;
+ *prev = info;
+ prev = &info->next_free;
+ }
+ *prev = NULL;
+
+ sgen_free_internal_dynamic (evacuated_blocks, sizeof (MSBlockInfo*) * num_blocks, INTERNAL_MEM_TEMPORARY);
+}
+
static void
major_start_major_collection (void)
{
binary_protocol_evacuating_blocks (block_obj_sizes [i]);
- free_block_lists [0][i] = NULL;
- free_block_lists [MS_BLOCK_FLAG_REFS][i] = NULL;
+ sgen_evacuation_freelist_blocks (&free_block_lists [0][i], i);
+ sgen_evacuation_freelist_blocks (&free_block_lists [MS_BLOCK_FLAG_REFS][i], i);
}
- if (lazy_sweep)
- binary_protocol_sweep_begin (GENERATION_OLD, TRUE);
+ if (lazy_sweep && concurrent_sweep) {
+ /*
+ * sweep_blocks_job is created before sweep_finish, which we wait for above
+ * (major_finish_sweep_checking). After the end of sweep, if we don't have
+ * sweep_blocks_job set, it means that it has already been run.
+ */
+ SgenThreadPoolJob *job = sweep_blocks_job;
+ if (job)
+ sgen_thread_pool_job_wait (job);
+ }
+ if (lazy_sweep && !concurrent_sweep)
+ binary_protocol_sweep_begin (GENERATION_OLD, TRUE);
/* Sweep all unswept blocks and set them to MARKING */
FOREACH_BLOCK_NO_LOCK (block) {
- if (lazy_sweep)
+ if (lazy_sweep && !concurrent_sweep)
sweep_block (block);
SGEN_ASSERT (0, block->state == BLOCK_STATE_SWEPT, "All blocks must be swept when we're pinning.");
set_block_state (block, BLOCK_STATE_MARKING, BLOCK_STATE_SWEPT);
+ /*
+ * Swept blocks that have a null free_list are full. Evacuation is not
+ * effective on these blocks since we expect them to have high usage anyway,
+ * given that the survival rate for majors is relatively high.
+ */
+ if (evacuate_block_obj_sizes [block->obj_size_index] && !block->free_list)
+ block->is_to_space = TRUE;
} END_FOREACH_BLOCK_NO_LOCK;
-
- if (lazy_sweep)
+ if (lazy_sweep && !concurrent_sweep)
binary_protocol_sweep_end (GENERATION_OLD, TRUE);
set_sweep_state (SWEEP_STATE_NEED_SWEEPING, SWEEP_STATE_SWEPT);
}
}
+void
+sgen_memgov_major_post_sweep (void)
+{
+ mword num_major_sections = major_collector.get_num_major_sections ();
+
+ mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_GC, "GC_MAJOR_SWEEP: major %dK/%dK",
+ num_major_sections * major_collector.section_size / 1024,
+ last_major_num_sections * major_collector.section_size / 1024);
+ last_major_num_sections = num_major_sections;
+}
+
void
sgen_memgov_major_collection_start (void)
{
if (info[i].generation != -1)
sgen_client_log_timing (&info [i], last_major_num_sections, last_los_memory_usage);
}
- last_major_num_sections = major_collector.get_num_major_sections ();
+ last_los_memory_usage = los_memory_usage;
}
/*
void sgen_memgov_minor_collection_end (void);
void sgen_memgov_major_pre_sweep (void);
+void sgen_memgov_major_post_sweep (void);
void sgen_memgov_major_collection_start (void);
void sgen_memgov_major_collection_end (gboolean forced);
static SgenPointerQueue pin_queue;
static size_t last_num_pinned = 0;
+/*
+ * While we hold the pin_queue_mutex, all objects in pin_queue_objs will
+ * stay pinned, which means they can't move, therefore they can be scanned.
+ */
+static SgenPointerQueue pin_queue_objs;
+static MonoCoopMutex pin_queue_mutex;
#define PIN_HASH_SIZE 1024
static void *pin_hash_filter [PIN_HASH_SIZE];
+void
+sgen_pinning_init (void)
+{
+ mono_coop_mutex_init (&pin_queue_mutex);
+}
+
void
sgen_init_pinning (void)
{
+ mono_coop_mutex_lock (&pin_queue_mutex);
memset (pin_hash_filter, 0, sizeof (pin_hash_filter));
pin_queue.mem_type = INTERNAL_MEM_PIN_QUEUE;
+ sgen_pointer_queue_clear (&pin_queue_objs);
}
void
{
last_num_pinned = pin_queue.next_slot;
sgen_pointer_queue_clear (&pin_queue);
+ mono_coop_mutex_unlock (&pin_queue_mutex);
+}
+
+void
+sgen_pinning_register_pinned_in_nursery (GCObject *obj)
+{
+ sgen_pointer_queue_add (&pin_queue_objs, obj);
+}
+
+void
+sgen_scan_pin_queue_objects (ScanCopyContext ctx)
+{
+ int i;
+ ScanObjectFunc scan_func = ctx.ops->scan_object;
+
+ mono_coop_mutex_lock (&pin_queue_mutex);
+ for (i = 0; i < pin_queue_objs.next_slot; ++i) {
+ GCObject *obj = (GCObject *)pin_queue_objs.data [i];
+ scan_func (obj, sgen_obj_get_descriptor_safe (obj), ctx.queue);
+ }
+ mono_coop_mutex_unlock (&pin_queue_mutex);
}
void
PIN_TYPE_MAX
};
+void sgen_pinning_init (void);
void sgen_pin_stage_ptr (void *ptr);
void sgen_optimize_pin_queue (void);
void sgen_init_pinning (void);
void sgen_finish_pinning (void);
+void sgen_pinning_register_pinned_in_nursery (GCObject *obj);
+void sgen_scan_pin_queue_objects (ScanCopyContext ctx);
void sgen_pin_queue_clear_discarded_entries (GCMemSection *section, size_t max_pin_slot);
size_t sgen_get_pinned_count (void);
void sgen_pinning_setup_section (GCMemSection *section);
IS_VTABLE_MATCH (FALSE)
END_PROTOCOL_ENTRY
+BEGIN_PROTOCOL_ENTRY1 (binary_protocol_concurrent_sweep_end, TYPE_LONGLONG, timestamp)
+DEFAULT_PRINT ()
+IS_ALWAYS_MATCH (TRUE)
+MATCH_INDEX (BINARY_PROTOCOL_MATCH)
+IS_VTABLE_MATCH (FALSE)
+END_PROTOCOL_ENTRY
+
#undef BEGIN_PROTOCOL_ENTRY0
#undef BEGIN_PROTOCOL_ENTRY1
#undef BEGIN_PROTOCOL_ENTRY2
pinvoke_ppcs.cs \
pinvoke_ppci.cs \
pinvoke_ppcf.cs \
- pinvoke_ppcd.cs
+ pinvoke_ppcd.cs \
+ bug-29585.cs
TEST_CS_SRC_DIST= \
$(BASE_TEST_CS_SRC) \
--- /dev/null
+namespace TestCase
+{
+ using System;
+ using System.Linq;
+ using System.Reflection;
+
+
+ public class MainClass
+ {
+ public static int Main()
+ {
+ return new GenericDerived<Param>().FindMethod();
+ }
+ }
+
+
+ interface Param
+ {
+ }
+
+
+ class GenericDerived<T> :
+ Abstract<GenericDerived<T>>
+ {
+ public int FindMethod()
+ {
+ return FindGenericMethod<T>();
+ }
+ }
+
+
+ abstract class Abstract<TDerived>
+ where TDerived : Abstract<TDerived>
+ {
+ protected virtual int FindGenericMethod<T>()
+ {
+ var method = typeof(TDerived)
+ .GetMethods(BindingFlags.Instance | BindingFlags.NonPublic)
+ .FirstOrDefault(x => x.Name == "FindGenericMethod" && x.IsGenericMethod);
+
+ Console.WriteLine("TDerived = {0}", typeof(TDerived));
+ Console.WriteLine("method = {0}", method);
+ Console.WriteLine("method.DeclaringType = {0}", method.DeclaringType);
+ Console.WriteLine("method.IsGenericMethod = {0}", method.IsGenericMethod);
+ Console.WriteLine("method.IsGenericMethodDefinition = {0}", method.IsGenericMethodDefinition);
+
+ if (!method.IsGenericMethod)
+ return 1;
+ if (!method.IsGenericMethodDefinition)
+ return 2;
+ return 0;
+ }
+ }
+}
\ No newline at end of file
%.exe: %.cil
- ilasm2 -out:$@ $<
+ ilasm -out:$@ $<
BatchCompiler.exe: BatchCompiler.cs
- gmcs -r:../../../mcs/class/lib/net_2_0/ilasm.exe BatchCompiler.cs
+ mcs -r:../../../mcs/class/lib/net_4_x/ilasm.exe BatchCompiler.cs
test_lib.dll: test_lib.cs
- gmcs test_lib.cs -target:library
+ mcs test_lib.cs -target:library
compile-stamp: generate-stamp BatchCompiler.exe test_lib.dll
for i in *.cs; do \
EXE="`echo $$i | cut -d. -f1`.exe"; \
DLL="`echo $$i | cut -d. -f1`.dll"; \
if ! [ -f $$EXE ] && ! [ -f $$DLL ]; then \
- gmcs /unsafe $$i; \
+ mcs /unsafe $$i; \
fi \
done
#MONO_PATH=../../../mcs/class/lib/net_2_0/ mono BatchCompiler.exe
then \
RES=3; \
fi; \
- if [ "$$FIRST" == "unverifiable" ] || [ "$FIRST" == "typeunverifiable" ]; \
+ if [ "$$FIRST" == "unverifiable" ] || [ "$$FIRST" == "typeunverifiable" ]; \
then \
RES=2; \
fi; \
fi; \
if [ "$$FIRST" == "strict" ]; \
then \
- #in strict more it must fail under strict check and pass under non-strict check \
+ echo "#in strict more it must fail under strict check and pass under non-strict check" >/dev/null; \
../../metadata/pedump --verify partial-md,error,warn,cls,code $$TEST.exe >/dev/null 2>/dev/null; \
R1=$$?; \
../../metadata/pedump --verify partial-md,error,warn,cls,code,non-strict $$TEST.exe >/dev/null 2>/dev/null; \
R2=$$?; \
if [ $$R1 != 2 ] && [ $$R1 != 3 ]; then \
echo "$$TEST is strict but did not fail under strict check, got $${R1} but expected 2 or 3"; \
- fi \
- #non-strict result \
+ fi; \
+ echo "#non-strict result" >/dev/null; \
if [ $$R2 != 0 ]; then \
echo "$$TEST is strict but did not pass under non-strict check, got $${R2} but expected 0"; \
- fi \
+ fi; \
elif [ "$$FIRST" == "typeunverifiable" ]; then \
- #in type unverifiable more it must fail under verifiable mode but it's ok under valid mode \
+ echo "#in type unverifiable more it must fail under verifiable mode but it's ok under valid mode" >/dev/null; \
../../metadata/pedump --verify partial-md,error,warn,cls,code $$TEST.exe >/dev/null 2>/dev/null; \
R1=$$?; \
../../metadata/pedump --verify partial-md,error,warn,cls,code,valid-only $$TEST.exe >/dev/null 2>/dev/null; \
R2=$$?; \
if [ $$R1 != 3 ]; then \
echo "$$TEST is type unverifiable but did not fail under verifiable check, got $${R1} but expected 3"; \
- fi \
- #type unverifiable result \
+ fi; \
+ echo "#type unverifiable result" >/dev/null; \
if [ $$R2 != 0 ]; then \
echo "$$TEST is type unverifiable but did not pass under non-strict check, got $${R2} but expected 0"; \
- fi \
+ fi; \
elif [ $$RES != 99 ]; then \
../../metadata/pedump --verify partial-md,error,warn,cls,code $$TEST.exe >/dev/null 2>/dev/null; \
R=$$?; \
if [ $$R != $$RES ]; then \
echo "$$TEST failed expected $$RES but got $$R"; \
- fi \
+ fi; \
fi; \
done
TEST_EXTENDS=$6
TEST_USE_SUB_CLASS=$7
-if [ "$TEST_EXTENDS" == "yes" ]; then
+if [ "$TEST_EXTENDS" = "yes" ]; then
TEST_EXTENDS="extends Class"
TEST_SUPER_TYPE="Class"
else
TEST_SUPER_TYPE="object"
fi
-if [ "$TEST_USE_SUB_CLASS" == "yes" ]; then
+if [ "$TEST_USE_SUB_CLASS" = "yes" ]; then
TEST_VAR_TYPE="ExampleClass"
else
TEST_VAR_TYPE="Class"
ret
}
}
-//EOF
\ No newline at end of file
+//EOF
TEST_BYTE_1=$4
-if [ "$TEST_BYTE_1" == "" ] ; then
+if [ "x$TEST_BYTE_1" = "x" ] ; then
TEST_BYTE_1="0";
fi
TEST_INIT_EXP=$6
TEST_INIT_VAL=$7
-if [ "$TEST_INIT_VAL" == "yes" ]; then
+if [ "$TEST_INIT_VAL" = "yes" ]; then
TEST_INIT="$TEST_INIT_EXP\n\t\stloc.1"
else
TEST_INIT=""
ldc.i4.0
ret
}
-//EOF
\ No newline at end of file
+//EOF
TEST_BEFORE_OP=$4
TEST_CONSTRAINT_TYPE=$5
-if [ "$TEST_CONSTRAINT_TYPE" == "" ]; then
+if [ "x$TEST_CONSTRAINT_TYPE" = "x" ]; then
TEST_CONSTRAINT_TYPE="IFace";
fi
TEST_OP=$4
TEST_FIN=$5
-if [ "$TEST_FIN" == "" ]; then
+if [ "x$TEST_FIN" = "x" ]; then
TEST_FIN="finally";
fi
TEST_INSTANCE_METHOD=$5
TEST_EXTRA_STUFF=$6
-if [ "$TEST_INSTANCE_METHOD" == "instance" ]; then
+if [ "$TEST_INSTANCE_METHOD" = "instance" ]; then
MEMBER_TEST_OP=$TEST_OP
MEMBER_TEST_LOAD_ARGS=$TEST_LOAD_ARGS
MEMBER_TEST_EXTRA_STUFF=$6
echo $TEST_OP | grep unbox > /dev/null;
-if [ "$?" == "0" ]; then
+if [ $? -eq 0 ]; then
TEST_CODE="
ldloc.0
box $TEST_TYPE";
ZZ=`echo $TEST_TYPE1 | grep "\&"`
T1_REF=$?
-if [ "$T1_REF" == "0" ]; then
+if [ $T1_REF -eq 0 ]; then
T1_NO_REF=`echo $TEST_TYPE1 | cut -d '\' -f 1`
INIT_LOCS=", $T1_NO_REF V_2"
INIT_IL="ldloca.s 2\n\tstloc.0"
ZZ=`echo $TEST_TYPE2 | grep "\&"`
T2_REF=$?
-if [ "$T2_REF" == "0" ]; then
+if [ $T2_REF -eq 0 ]; then
T2_NO_REF=`echo $TEST_TYPE2 | cut -d '\' -f 1`
- if [ "$T1_REF" == "0" ]; then
+ if [ $T1_REF -eq 0 ]; then
INIT_LOCS="$INIT_LOCS , $T2_NO_REF V_3"
INIT_IL="$INIT_IL \n\tldloca.s 3\n\tstloc.1"
else
TEST_LOAD_BASE=$7
-if [ "$TEST_EXTENDS" == "yes" ]; then
+if [ "$TEST_EXTENDS" = "yes" ]; then
TEST_EXTENDS="extends Owner\/Nested"
TEST_CONSTRUCTOR="call instance void Owner\/Nested::.ctor()"
else
TEST_CONSTRUCTOR="call instance void object::.ctor()"
fi
-if [ "$TEST_LOAD_BASE" == "yes" ]; then
+if [ "$TEST_LOAD_BASE" = "yes" ]; then
TEST_LOAD_REF="ldarg.0"
else
TEST_LOAD_REF="call class Owner\/Nested Owner::Create ()"
TARGET_TYPE="Test"
TEST_OTHER_CODE="call instance void TestClass::'.ctor'()"
-if [ "$TEST_TARGET_TYPE" == "other" ]; then
+if [ "$TEST_TARGET_TYPE" = "other" ]; then
TARGET_TYPE="TestSubClass"
TEST_OTHER_CODE=$TEST_CODE
TEST_CODE=""
RET_2_LOCAL="$TEST_RET_TYPE2"
RET_2_OP="ldloc 0"
-if [ "$TEST_RET_TYPE2" == "void" ]; then
+if [ "$TEST_RET_TYPE2" = "void" ]; then
RET_2_LOCAL="int32"
RET_2_OP="nop"
fi
}
"
-if [ "$TEST_USE_NATIVE" == "pinvoke" ]; then
+if [ "$TEST_USE_NATIVE" = "pinvoke" ]; then
LDFTN="ldftn $TCONV_2 ${TEST_RET_TYPE2} Driver::NativeMethod(${TEST_PARAM_TYPE2})"
CALLVIRT="nop"
MANAGED_METHOD=""
TEST_LOAD_BASE=$9
-if [ "$TEST_BASE_EXTENDS" == "yes" ]; then
+if [ "$TEST_BASE_EXTENDS" = "yes" ]; then
TEST_BASE_EXTENDS="extends Root"
TEST_BASE_CONSTRUCTOR="call instance void Root::.ctor()"
else
TEST_BASE_CONSTRUCTOR="call instance void object::.ctor()"
fi
-if [ "$TEST_NESTED_EXTENDS" == "yes" ]; then
+if [ "$TEST_NESTED_EXTENDS" = "yes" ]; then
TEST_NESTED_EXTENDS="extends Root\/Nested"
TEST_NESTED_CONSTRUCTOR="call instance void Root\/Nested::.ctor()"
else
TEST_NESTED_CONSTRUCTOR="call instance void object::.ctor()"
fi
-if [ "$TEST_LOAD_BASE" == "yes" ]; then
+if [ "$TEST_LOAD_BASE" = "yes" ]; then
TEST_LOAD_REF="ldarg.0"
else
TEST_LOAD_REF="call class Root\/Nested Root::Create ()"
TEST_WITH_FILTER_BLOCK=$5
TEST_WITH_FINALLY_BLOCK=$6
-if [ "$TEST_WITH_FILTER_BLOCK" == "yes" ]; then
+if [ "$TEST_WITH_FILTER_BLOCK" = "yes" ]; then
FILTER_BLOCK="
FILTER_BLOCK_3:
nop
FILTER_BLOCK="";
fi
-if [ "$TEST_WITH_FINALLY_BLOCK" == "yes" ]; then
+if [ "$TEST_WITH_FINALLY_BLOCK" = "yes" ]; then
FINALLY_BLOCK="
FINALLY_BLOCK_1:
nop
TEST_TYPE1=$4
TEST_TYPE2=$5
TEST_EMIT_CSTOR=$6
-if [ "${TEST_EMIT_CSTOR}" == "yes" ]; then
+if [ "${TEST_EMIT_CSTOR}" = "yes" ]; then
TEST_CSTOR="newobj instance void ${TEST_TYPE2}::.ctor()";
else
TEST_CSTOR="ldloc.0";
T1_REF=$?
LOCAL_INIT="";
-if [ "$T1_REF" == "0" ]; then
+if [ $T1_REF -eq 0 ]; then
T1_NO_REF=`echo $TEST_TYPE1 | cut -d '\' -f 1`
INIT_LOCS=", $T1_NO_REF V_0"
INIT_IL="ldloca.s 1\n\tstloc.0"
T1_REF=$?
LOCAL_INIT="";
-if [ "$T1_REF" == "0" ]; then
+if [ $T1_REF -eq 0 ]; then
T1_NO_REF=`echo $TEST_TYPE1 | cut -d '\' -f 1`
INIT_LOCS=", $T1_NO_REF V_0"
INIT_IL="ldloca.s 1\n\tstloc.0"
leave END
}"
-if [ "$TEST_BLOCK" == "catch" ]; then
+if [ "$TEST_BLOCK" = "catch" ]; then
TRY_MIDDLE="
leave END
} catch [mscorlib]System.NullReferenceException {"
TRY_END="
leave END
}"
-elif [ "$TEST_BLOCK" == "filter" ]; then
+elif [ "$TEST_BLOCK" = "filter" ]; then
TRY_MIDDLE="
leave END
} filter {"
} {
leave END
}"
-elif [ "$TEST_BLOCK" == "handler" ]; then
+elif [ "$TEST_BLOCK" = "handler" ]; then
TRY_MIDDLE="
leave END
} filter {
TRY_END="
leave END
}"
-elif [ "$TEST_BLOCK" == "finally" ]; then
+elif [ "$TEST_BLOCK" = "finally" ]; then
TRY_MIDDLE="
leave END
} finally {"
TRY_END="
endfinally
}"
-elif [ "$TEST_BLOCK" == "fault" ]; then
+elif [ "$TEST_BLOCK" = "fault" ]; then
TRY_MIDDLE="
leave END
} fault {"
TEST_MEMBER_ACCESS=$5
TEST_EXTENDS=$6
-if [ "$TEST_EXTENDS" == "yes" ]; then
+if [ "$TEST_EXTENDS" = "yes" ]; then
TEST_EXTENDS="extends Owner"
TEST_CONSTRUCTOR="call instance void Owner::.ctor()"
else
ldc.i4.0
ret
}
-//EOF
\ No newline at end of file
+//EOF
TEST_TYPE1=`echo $TEST_TYPE1 | $SED -s 's/&/\\\&/'`
TEST_TYPE2=`echo $TEST_TYPE2 | $SED -s 's/&/\\\&/'`
-if [ "$TEST_CREATE_FIELD" == "no" ]; then
+if [ "$TEST_CREATE_FIELD" = "no" ]; then
CLASS_FIELDS="";
else
CLASS_FIELDS=".field public ${TEST_TYPE1} fld\n .field public static ${TEST_TYPE1} sfld";
TEST_POS_2=$5
TEST_TYPE_0=$6
-if [ "$TEST_TYPE_0" == "" ] ; then
+if [ "x$TEST_TYPE_0" = "x" ] ; then
TEST_TYPE_0="int32";
fi
T2_REF=$?
LOCAL_INIT="";
-if [ "$T2_REF" == "0" ]; then
+if [ $T2_REF -eq 0 ]; then
T2_NO_REF=`echo $TEST_TYPE2 | cut -d '\' -f 1`
INIT_LOCS=", $T2_NO_REF V_2"
INIT_IL="ldloca.s 2\n\tstloc.1"
TEST_OP=$5
TEST_FIN=$6
-if [ "$TEST_FIN" == "" ]; then
+if [ "x$TEST_FIN" = "x" ]; then
TEST_FIN="finally";
fi
TEST_TYPE=$5
TEST_RET_TYPE=$6
-if [ "$TEST_RET_TYPE" == "" ]; then
+if [ "x$TEST_RET_TYPE" = "x" ]; then
TEST_RET_TYPE="void"
else
LD_RET_CODE="ldloc.0"
I=1
for OP in add div mul rem sub
do
- if [ "$OP" == "div" ] || [ "$OP" == "rem" ]; then
+ if [ "$OP" = "div" ] || [ "$OP" = "rem" ]; then
INIT="yes";
else
INIT="no";
I=1
for OP in div mul rem
do
- if [ "$OP" == "div" ] || [ "$OP" == "div" ]; then
+ if [ "$OP" = "div" ] || [ "$OP" = "div" ]; then
INIT="yes";
else
INIT="no";
I=1
for OP in div mul rem add
do
- if [ "$OP" == "div" ] || [ "$OP" == "div" ]; then
+ if [ "$OP" = "div" ] || [ "$OP" = "div" ]; then
INIT="yes";
else
INIT="no";
A=$1;
fi
- if [ "$A" == "bool&" ]; then
+ if [ "$A" = "bool&" ]; then
A="int8&";
- elif [ "$A" == "char&" ]; then
+ elif [ "$A" = "char&" ]; then
A="int16&";
fi
do
TA="$(fix $TYPE1)"
TB="$(fix $TYPE2)"
- if [ "$TA" == "$TB" ]; then
+ if [ "$TA" = "$TB" ]; then
./make_store_test.sh ref_coercion_${I} valid "$OP" "$TYPE1" "$TYPE2"
- elif [ "$TA" == "int32&" ] && [ "$TB" == "int&" ]; then
+ elif [ "$TA" = "int32&" ] && [ "$TB" = "int&" ]; then
./make_store_test.sh ref_coercion_${I} valid "$OP" "$TYPE1" "$TYPE2"
- elif [ "$TA" == "int&" ] && [ "$TB" == "int32&" ]; then
+ elif [ "$TA" = "int&" ] && [ "$TB" = "int32&" ]; then
./make_store_test.sh ref_coercion_${I} valid "$OP" "$TYPE1" "$TYPE2"
else
./make_store_test.sh ref_coercion_${I} unverifiable "$OP" "$TYPE1" "$TYPE2"
do
TA="$(fix $TYPE1)"
TB="$(fix $TYPE2)"
- if [ "$TA" == "$TB" ]; then
+ if [ "$TA" = "$TB" ]; then
./make_store_test.sh ref_coercion_${I} valid "$OP" "$TYPE1" "$TYPE2"
else
./make_store_test.sh ref_coercion_${I} unverifiable "$OP" "$TYPE1" "$TYPE2"
do
for TYPE2 in 'class ClassA&' 'class ClassB&' 'class InterfaceA&' 'class InterfaceB&' 'class ValueType&'
do
- if [ "$TYPE1" == "$TYPE2" ]; then
+ if [ "$TYPE1" = "$TYPE2" ]; then
./make_store_test.sh ref_coercion_${I} valid "$OP" "$TYPE1" "$TYPE2"
else
./make_store_test.sh ref_coercion_${I} unverifiable "$OP" "$TYPE1" "$TYPE2"
ZZ=`echo $TYPE2 | grep "*";`
T2_PTR=$?
- if (($T1_PTR == 0 || $T2_PTR == 0)); then
+ if [ $T1_PTR -eq 0 ] || [ $T2_PTR -eq 0 ]; then
./make_stack_merge_test.sh stack_merge_${I} unverifiable "$TYPE1" "$TYPE2"
- elif [ "$TYPE1" == "$TYPE2" ]; then
+ elif [ "$TYPE1" = "$TYPE2" ]; then
./make_stack_merge_test.sh stack_merge_${I} valid "$TYPE1" "$TYPE2"
- elif [ "$TYPE1" == "int32" ] && [ "$TYPE2" == "native int" ]; then
+ elif [ "$TYPE1" = "int32" ] && [ "$TYPE2" = "native int" ]; then
./make_stack_merge_test.sh stack_merge_${I} valid "$TYPE1" "$TYPE2"
- elif [ "$TYPE1" == "native int" ] && [ "$TYPE2" == "int32" ]; then
+ elif [ "$TYPE1" = "native int" ] && [ "$TYPE2" = "int32" ]; then
./make_stack_merge_test.sh stack_merge_${I} valid "$TYPE1" "$TYPE2"
- elif [ "$TYPE1" == "int32&" ] && [ "$TYPE2" == "native int&" ]; then
+ elif [ "$TYPE1" = "int32&" ] && [ "$TYPE2" = "native int&" ]; then
./make_stack_merge_test.sh stack_merge_${I} valid "$TYPE1" "$TYPE2"
- elif [ "$TYPE1" == "native int&" ] && [ "$TYPE2" == "int32&" ]; then
+ elif [ "$TYPE1" = "native int&" ] && [ "$TYPE2" = "int32&" ]; then
./make_stack_merge_test.sh stack_merge_${I} valid "$TYPE1" "$TYPE2"
else
./make_stack_merge_test.sh stack_merge_${I} unverifiable "$TYPE1" "$TYPE2"
MAX_PARAM_RESULT="unverifiable"
POPS="pop\npop\npop\npop\npop\npop\npop\npop\n"
- if [ "$OP" == "ldloc" ]; then
+ if [ "$OP" = "ldloc" ]; then
MAX_PARAM_RESULT="invalid"
LOCALS_1=$ARGS_1
do
for LOAD in yes no
do
- if ! ( [ "$NESTED" == "no" ] && [ "$LOAD" == "yes" ] ) ; then
+ if ! ( [ "$NESTED" = "no" ] && [ "$LOAD" = "yes" ] ) ; then
./make_double_nesting_test.sh double_nesting_access_check_${K}_$I $2 "$OP" $3 $4 $5 "$BASE" "$NESTED" "$LOAD"
K=`expr $K + 1`
fi
do
for LOAD in yes no
do
- if ! ( [ "$NESTED" == "no" ] && [ "$LOAD" == "yes" ] ) ; then
+ if ! ( [ "$NESTED" = "no" ] && [ "$LOAD" = "yes" ] ) ; then
EXPECT=unverifiable
- if [ "$FIRST" == "$K" ]; then
+ if [ "$FIRST" = "$K" ]; then
EXPECT=valid
fi
./make_double_nesting_test.sh double_nesting_access_check_${K}_$I $EXPECT "$OP" $2 $3 $4 "$BASE" "$NESTED" "$LOAD"
for NESTED in yes no
do
EXPECT=unverifiable
- if [ "$NESTED" == "yes" ]; then
+ if [ "$NESTED" = "yes" ]; then
EXPECT=valid
fi
./make_double_nesting_test.sh double_nesting_access_check_${K}_$I $EXPECT "$OP" $2 $3 $4 "$BASE" "$NESTED" yes
A=$1;
fi
- if [ "$A" == "bool" ]; then
+ if [ "$A" = "bool" ]; then
A="int8";
- elif [ "$A" == "char" ]; then
+ elif [ "$A" = "char" ]; then
A="int16";
fi
do
TYPE1="$(fix_ldobj $T1)"
TYPE2="$(fix_ldobj $T2)"
- if [ "$TYPE1" == "$TYPE2" ] ; then
+ if [ "$TYPE1" = "$TYPE2" ] ; then
./make_ldobj_test.sh ldobj_${I} valid "${T1}\&" "${T2}"
else
./make_ldobj_test.sh ldobj_${I} unverifiable "${T1}\&" "${T2}"
for TYPE1 in "int8" "bool" "int16" "char" "int32" "int64" "float64" "native int" "object" "string" "class Class" "valuetype MyStruct" "int32[]" "int32[,]" "int32*" "method int32 *(int32)" "class Template\`1<object>"
do
./make_store_indirect_test.sh indirect_store_bad_addr_r4_${I} unverifiable "stind.r4" "${TYPE1}\&" "float32"
- if [ "$TYPE1" == "float64" ]; then
+ if [ "$TYPE1" = "float64" ]; then
./make_store_indirect_test.sh indirect_store_good_val_r4_${I} valid "stind.r4" "float32\&" "${TYPE1}"
else
./make_store_indirect_test.sh indirect_store_bad_val_r4_${I} unverifiable "stind.r4" "float32\&" "${TYPE1}"
for TYPE1 in "int8" "bool" "int16" "char" "int32" "int64" "float32" "native int" "object" "string" "class Class" "valuetype MyStruct" "int32[]" "int32[,]" "int32*" "method int32 *(int32)" "class Template\`1<object>"
do
./make_store_indirect_test.sh indirect_store_bad_addr_r8_${I} unverifiable "stind.r8" "${TYPE1}\&" "float64"
- if [ "$TYPE1" == "float32" ]; then
+ if [ "$TYPE1" = "float32" ]; then
./make_store_indirect_test.sh indirect_store_good_val_r8_${I} valid "stind.r8" "float64\&" "${TYPE1}";
else
./make_store_indirect_test.sh indirect_store_bad_val_r8_${I} unverifiable "stind.r8" "float64\&" "${TYPE1}";
# Exception block branch tests (see 2.19)
-for I in {1..2};
+I=1; while [ $I -le 2 ]
do
./make_rethrow_test.sh rethrow_from_catch_${I} invalid ${I}
+ I=$((I + 1))
done
-for I in {3..10};
+I=3; while [ $I -le 10 ]
do
./make_rethrow_test.sh rethrow_from_catch_${I} valid ${I}
+ I=$((I + 1))
done
# endfinally / endfault
-for I in {1..7};
+I=1; while [ $I -le 7 ]
do
./make_endfinally_test.sh endfinally_block_${I} invalid finally ${I}
./make_endfinally_test.sh endfault_block_${I} invalid fault ${I}
+ I=$((I + 1))
done
-for I in {8..9};
+I=8; while [ $I -le 9 ]
do
./make_endfinally_test.sh endfinally_block_${I} valid finally ${I}
./make_endfinally_test.sh endfault_block_${I} valid fault ${I}
+ I=$((I + 1))
done
#stack can have stuff and endfinally or endfault will just empty it
./make_endfilter_test.sh endfilter_inside_protected_block_3 invalid 3 "ldc.i4.1\n\t\tendfilter"
./make_endfilter_test.sh endfilter_inside_protected_block_5 strict 5 "ldc.i4.1\n\t\tendfilter"
-for I in {2,4,6};
+for I in 2 4 6;
do
./make_endfilter_test.sh endfilter_inside_protected_block_${I} unverifiable ${I} "ldc.i4.1\n\t\tendfilter"
done
./make_leave_test.sh "filter_block_test_1" valid "1" "leave END" "$EXTRA"
#but not ok to leave finally or filter
-for I in {2..3};
-do
+I=2; while [ $I -le 3 ]; do
./make_leave_test.sh "filter_block_test_${I}" unverifiable "${I}" "leave END" "${EXTRA}_${I}"
+ I=$((I + 1))
done
#neither is to branch to invalid regions of code
# br.X
#valid tests
-for I in {1..6}; do
+I=1; while [ $I -le 6 ]; do
./make_branch_test.sh branch_inside_same_block_${I} valid ${I} "br BLOCK_${I}";
./make_branch_test.sh branch_inside_same_block_${I}_s valid ${I} "br.s BLOCK_${I}";
+ I=$((I + 1))
done
#branching outside of the protected block
-for I in {2..6}; do
+I=2; while [ $I -le 6 ]; do
./make_branch_test.sh branch_outside_protected_block_${I} unverifiable ${I} "br END";
+ I=$((I + 1))
done
#branching to a protected block from the outside
-for I in {2..6}; do
- if [ "$I" == "4" ]; then
+I=2; while [ $I -le 6 ]; do
+ if [ $I -eq 4 ]; then
./make_branch_test.sh branch_inside_protected_block_from_outside_${I}_finally invalid 1 "br BLOCK_${I}" "finally";
./make_branch_test.sh branch_inside_protected_block_from_outside_${I}_fault invalid 1 "br BLOCK_${I}" "fault";
else
./make_branch_test.sh branch_inside_protected_block_from_outside_${I} unverifiable 1 "br BLOCK_${I}";
fi
+ I=$((I + 1))
done
#TODO test the encoding of the switch table
# switch
#valid tests
-for I in {1..6}; do
+I=1; while [ $I -le 6 ]; do
./make_switch_test.sh switch_inside_same_block_${I} valid ${I} "ldloc.0" "switch (BLOCK_${I}, BLOCK_${I}_B)";
+ I=$((I + 1))
done
./make_switch_test.sh switch_with_native_int_on_stack valid 1 "ldloc.1" "switch (BLOCK_1, BLOCK_1_B)";
#branching outside of the protected block
-for I in {2..6}; do
+I=2; while [ $I -le 6 ]; do
./make_switch_test.sh switch_outside_protected_block_${I} unverifiable ${I} "ldloc.0" "switch (END, BLOCK_1, BLOCK_1_B)";
+ I=$((I + 1))
done
#branching to a protected block from the outside
-for I in {2..6}; do
- if [ "$I" == "4" ]; then
+I=2; while [ $I -le 6 ]; do
+ if [ $I -eq 4 ]; then
./make_switch_test.sh switch_inside_protected_block_from_outside_${I}_finally invalid 1 "ldloc.0" "switch (BLOCK_${I}, BLOCK_${I}_B)" "finally";
./make_switch_test.sh switch_inside_protected_block_from_outside_${I}_fault invalid 1 "ldloc.0" "switch (BLOCK_${I}, BLOCK_${I}_B)" "fault";
else
./make_switch_test.sh switch_inside_protected_block_from_outside_${I} unverifiable 1 "ldloc.0" "switch (BLOCK_${I}, BLOCK_${I}_B)";
fi
+ I=$((I + 1))
done
#TODO branching out of range (FIX ilasm first)
./make_overlapped_test.sh ref_only_overlapping_5 invalid 0 0 8 int32
#invalid opcodes
-for I in {166..178}
+I=166; while [ $I -le 178 ]
do
./make_bad_op_test.sh bad_op_$I invalid $I
+ I=$((I + 1))
done
-for I in {187..193}
+I=187; while [ $I -le 193 ]
do
./make_bad_op_test.sh bad_op_$I invalid $I
+ I=$((I + 1))
done
-for I in {196..207}
+I=196; while [ $I -le 207 ]
do
./make_bad_op_test.sh bad_op_$I invalid $I
+ I=$((I + 1))
done
-for I in {225..253}
+I=225; while [ $I -le 253 ]
do
./make_bad_op_test.sh bad_op_$I invalid $I
+ I=$((I + 1))
done
./make_bad_op_test.sh bad_op_xff invalid 255
-for I in {35..255}
+I=35; while [ $I -le 255 ]
do
./make_bad_op_test.sh bad_op_with_prefix_$I invalid 0xFE $I
+ I=$((I + 1))
done
./make_generic_argument_constraints_test.sh type_mixed_3 valid "" "(IfaceA)"
./make_generic_argument_constraints_test.sh type_mixed_4 valid "" "class (IfaceA)"
-
-
TEST_POST_OP=$5
TEST_NO_BOX=$6
TEST_BOX="box ${TEST_TYPE1}";
-if [ "${TEST_NO_BOX}" == "yes" ]; then
+if [ "x${TEST_NO_BOX}" = "xyes" ]; then
TEST_BOX="";
fi
#include <glib.h>
#include <mono/utils/mono-compiler.h>
#include <mono/utils/mono-membar.h>
+#include <mono/utils/mono-publib.h>
#define HAZARD_POINTER_COUNT 3
HAZARD_FREE_ASYNC_CTX,
} HazardFreeContext;
-gboolean mono_thread_hazardous_try_free (gpointer p, MonoHazardousFreeFunc free_func);
+MONO_API gboolean mono_thread_hazardous_try_free (gpointer p, MonoHazardousFreeFunc free_func);
void mono_thread_hazardous_queue_free (gpointer p, MonoHazardousFreeFunc free_func);
void mono_thread_hazardous_try_free_all (void);
g_assert (desc->anchor.data.state != STATE_FULL);
- mono_lock_free_queue_node_free (&desc->node);
+ mono_lock_free_queue_node_unpoison (&desc->node);
mono_lock_free_queue_enqueue (&desc->heap->sc->partial, &desc->node);
}
#define END_MARKER ((MonoLockFreeQueueNode *volatile)-2)
#define FREE_NEXT ((MonoLockFreeQueueNode *volatile)-3)
+/*
+ * Initialize a lock-free queue in-place at @q.
+ */
void
mono_lock_free_queue_init (MonoLockFreeQueue *q)
{
q->has_dummy = 1;
}
+/*
+ * Initialize @node's state. If @poison is TRUE, @node may not be enqueued to a
+ * queue - @mono_lock_free_queue_node_unpoison must be called first; otherwise,
+ * the node can be enqueued right away.
+ *
+ * The poisoning feature is mainly intended for ensuring correctness in complex
+ * lock-free code that uses the queue. For example, in some code that reuses
+ * nodes, nodes can be poisoned when they're dequeued, and then unpoisoned and
+ * enqueued in their hazard free callback.
+ */
void
-mono_lock_free_queue_node_init (MonoLockFreeQueueNode *node, gboolean to_be_freed)
+mono_lock_free_queue_node_init (MonoLockFreeQueueNode *node, gboolean poison)
{
- node->next = to_be_freed ? INVALID_NEXT : FREE_NEXT;
+ node->next = poison ? INVALID_NEXT : FREE_NEXT;
#ifdef QUEUE_DEBUG
node->in_queue = FALSE;
#endif
}
+/*
+ * Unpoisons @node so that it may be enqueued.
+ */
void
-mono_lock_free_queue_node_free (MonoLockFreeQueueNode *node)
+mono_lock_free_queue_node_unpoison (MonoLockFreeQueueNode *node)
{
g_assert (node->next == INVALID_NEXT);
#ifdef QUEUE_DEBUG
node->next = FREE_NEXT;
}
+/*
+ * Enqueue @node to @q. @node must have been initialized by a prior call to
+ * @mono_lock_free_queue_node_init, and must not be in a poisoned state.
+ */
void
mono_lock_free_queue_enqueue (MonoLockFreeQueue *q, MonoLockFreeQueueNode *node)
{
free_dummy (gpointer _dummy)
{
MonoLockFreeQueueDummy *dummy = (MonoLockFreeQueueDummy *) _dummy;
- mono_lock_free_queue_node_free (&dummy->node);
+ mono_lock_free_queue_node_unpoison (&dummy->node);
g_assert (dummy->in_use);
mono_memory_write_barrier ();
dummy->in_use = 0;
static gboolean
is_dummy (MonoLockFreeQueue *q, MonoLockFreeQueueNode *n)
{
- return n >= &q->dummies [0].node && n < &q->dummies [MONO_LOCK_FREE_QUEUE_NUM_DUMMIES].node;
+ return n >= &q->dummies [0].node && n <= &q->dummies [MONO_LOCK_FREE_QUEUE_NUM_DUMMIES-1].node;
}
static gboolean
return TRUE;
}
+/*
+ * Dequeues a node from @q. Returns NULL if no nodes are available. The returned
+ * node is hazardous and must be freed with @mono_thread_hazardous_try_free or
+ * @mono_thread_hazardous_queue_free - it must not be freed directly.
+ */
MonoLockFreeQueueNode*
mono_lock_free_queue_dequeue (MonoLockFreeQueue *q)
{
MONO_API void mono_lock_free_queue_init (MonoLockFreeQueue *q);
-MONO_API void mono_lock_free_queue_node_init (MonoLockFreeQueueNode *node, gboolean to_be_freed);
-MONO_API void mono_lock_free_queue_node_free (MonoLockFreeQueueNode *node);
+MONO_API void mono_lock_free_queue_node_init (MonoLockFreeQueueNode *node, gboolean poison);
+MONO_API void mono_lock_free_queue_node_unpoison (MonoLockFreeQueueNode *node);
MONO_API void mono_lock_free_queue_enqueue (MonoLockFreeQueue *q, MonoLockFreeQueueNode *node);
do {
ret = task_threads (current_task (), threads, count);
- } while (ret != KERN_SUCCESS);
+ } while (ret == KERN_ABORTED);
return ret;
}
mono_os_sem_post (MonoSemType *sem)
{
int res;
-
+retry:
res = semaphore_signal (*sem);
g_assert (res != KERN_INVALID_ARGUMENT);
+ if (res == KERN_ABORTED)
+ goto retry;
+
return res != KERN_SUCCESS ? -1 : 0;
}
#if defined(_POSIX_VERSION)
#include <sys/errno.h>
#include <sys/param.h>
+#include <errno.h>
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
mach_msg_type_number_t t_info_count = TASK_BASIC_INFO_COUNT, th_count;
thread_array_t th_array;
size_t i;
+ kern_return_t ret;
if (pid == getpid ()) {
/* task_for_pid () doesn't work on ios, even for the current process */
task = mach_task_self ();
} else {
- if (task_for_pid (mach_task_self (), pid, &task) != KERN_SUCCESS)
+ do {
+ ret = task_for_pid (mach_task_self (), pid, &task);
+ } while (ret == KERN_ABORTED);
+
+ if (ret != KERN_SUCCESS)
RET_ERROR (MONO_PROCESS_ERROR_NOT_FOUND);
}
- if (task_info (task, TASK_BASIC_INFO, (task_info_t)&t_info, &t_info_count) != KERN_SUCCESS) {
+ do {
+ ret = task_info (task, TASK_BASIC_INFO, (task_info_t)&t_info, &t_info_count);
+ } while (ret == KERN_ABORTED);
+
+ if (ret != KERN_SUCCESS) {
if (pid != getpid ())
mach_port_deallocate (mach_task_self (), task);
RET_ERROR (MONO_PROCESS_ERROR_OTHER);
}
+
+ do {
+ ret = task_threads (task, &th_array, &th_count);
+ } while (ret == KERN_ABORTED);
- if (task_threads(task, &th_array, &th_count) != KERN_SUCCESS) {
+ if (ret != KERN_SUCCESS) {
if (pid != getpid ())
mach_port_deallocate (mach_task_self (), task);
RET_ERROR (MONO_PROCESS_ERROR_OTHER);
struct thread_basic_info th_info;
mach_msg_type_number_t th_info_count = THREAD_BASIC_INFO_COUNT;
- if (thread_info(th_array[i], THREAD_BASIC_INFO, (thread_info_t)&th_info, &th_info_count) == KERN_SUCCESS) {
+ do {
+ ret = thread_info(th_array[i], THREAD_BASIC_INFO, (thread_info_t)&th_info, &th_info_count);
+ } while (ret == KERN_ABORTED);
+
+ if (ret == KERN_SUCCESS) {
thread_user_time = th_info.user_time.seconds + th_info.user_time.microseconds / 1e6;
thread_system_time = th_info.system_time.seconds + th_info.system_time.microseconds / 1e6;
//thread_percent = (double)th_info.cpu_usage / TH_USAGE_SCALE;
task_t task;
struct task_basic_info t_info;
mach_msg_type_number_t th_count = TASK_BASIC_INFO_COUNT;
+ kern_return_t mach_ret;
if (pid == getpid ()) {
/* task_for_pid () doesn't work on ios, even for the current process */
task = mach_task_self ();
} else {
- if (task_for_pid (mach_task_self (), pid, &task) != KERN_SUCCESS)
+ do {
+ mach_ret = task_for_pid (mach_task_self (), pid, &task);
+ } while (mach_ret == KERN_ABORTED);
+
+ if (mach_ret != KERN_SUCCESS)
RET_ERROR (MONO_PROCESS_ERROR_NOT_FOUND);
}
-
- if (task_info (task, TASK_BASIC_INFO, (task_info_t)&t_info, &th_count) != KERN_SUCCESS) {
+
+ do {
+ mach_ret = task_info (task, TASK_BASIC_INFO, (task_info_t)&t_info, &th_count);
+ } while (mach_ret == KERN_ABORTED);
+
+ if (mach_ret != KERN_SUCCESS) {
if (pid != getpid ())
mach_port_deallocate (mach_task_self (), task);
RET_ERROR (MONO_PROCESS_ERROR_OTHER);
#define UCONTEXT_REG_RSI(ctx) (((ucontext_t*)(ctx))->uc_mcontext.__gregs [_REG_RSI])
#define UCONTEXT_REG_RDI(ctx) (((ucontext_t*)(ctx))->uc_mcontext.__gregs [_REG_RDI])
#define UCONTEXT_REG_RIP(ctx) (((ucontext_t*)(ctx))->uc_mcontext.__gregs [_REG_RIP])
+ #define UCONTEXT_REG_R8(ctx) (((ucontext_t*)(ctx))->uc_mcontext.__gregs [_REG_R8])
+ #define UCONTEXT_REG_R9(ctx) (((ucontext_t*)(ctx))->uc_mcontext.__gregs [_REG_R9])
+ #define UCONTEXT_REG_R10(ctx) (((ucontext_t*)(ctx))->uc_mcontext.__gregs [_REG_R10])
+ #define UCONTEXT_REG_R11(ctx) (((ucontext_t*)(ctx))->uc_mcontext.__gregs [_REG_R11])
#define UCONTEXT_REG_R12(ctx) (((ucontext_t*)(ctx))->uc_mcontext.__gregs [_REG_R12])
#define UCONTEXT_REG_R13(ctx) (((ucontext_t*)(ctx))->uc_mcontext.__gregs [_REG_R13])
#define UCONTEXT_REG_R14(ctx) (((ucontext_t*)(ctx))->uc_mcontext.__gregs [_REG_R14])
#define UCONTEXT_REG_R11(ctx) (((arm_ucontext*)(ctx))->sig_ctx.arm_fp)
#define UCONTEXT_REG_R12(ctx) (((arm_ucontext*)(ctx))->sig_ctx.arm_ip)
#define UCONTEXT_REG_CPSR(ctx) (((arm_ucontext*)(ctx))->sig_ctx.arm_cpsr)
+#elif defined(__NetBSD__)
+ typedef ucontext_t arm_ucontext;
+
+ #define UCONTEXT_REG_PC(ctx) (((ucontext_t*)(ctx))->uc_mcontext.__gregs[_REG_PC])
+ #define UCONTEXT_REG_SP(ctx) (((ucontext_t*)(ctx))->uc_mcontext.__gregs[_REG_SP])
+ #define UCONTEXT_REG_LR(ctx) (((ucontext_t*)(ctx))->uc_mcontext.__gregs[_REG_LR])
+ #define UCONTEXT_REG_R0(ctx) (((ucontext_t*)(ctx))->uc_mcontext.__gregs[_REG_R0])
+ #define UCONTEXT_REG_R1(ctx) (((ucontext_t*)(ctx))->uc_mcontext.__gregs[_REG_R1])
+ #define UCONTEXT_REG_R2(ctx) (((ucontext_t*)(ctx))->uc_mcontext.__gregs[_REG_R2])
+ #define UCONTEXT_REG_R3(ctx) (((ucontext_t*)(ctx))->uc_mcontext.__gregs[_REG_R3])
+ #define UCONTEXT_REG_R4(ctx) (((ucontext_t*)(ctx))->uc_mcontext.__gregs[_REG_R4])
+ #define UCONTEXT_REG_R5(ctx) (((ucontext_t*)(ctx))->uc_mcontext.__gregs[_REG_R5])
+ #define UCONTEXT_REG_R6(ctx) (((ucontext_t*)(ctx))->uc_mcontext.__gregs[_REG_R6])
+ #define UCONTEXT_REG_R7(ctx) (((ucontext_t*)(ctx))->uc_mcontext.__gregs[_REG_R7])
+ #define UCONTEXT_REG_R8(ctx) (((ucontext_t*)(ctx))->uc_mcontext.__gregs[_REG_R8])
+ #define UCONTEXT_REG_R9(ctx) (((ucontext_t*)(ctx))->uc_mcontext.__gregs[_REG_R9])
+ #define UCONTEXT_REG_R10(ctx) (((ucontext_t*)(ctx))->uc_mcontext.__gregs[_REG_R10])
+ #define UCONTEXT_REG_R11(ctx) (((ucontext_t*)(ctx))->uc_mcontext.__gregs[_REG_R11])
+ #define UCONTEXT_REG_R12(ctx) (((ucontext_t*)(ctx))->uc_mcontext.__gregs[_REG_R12])
+ #define UCONTEXT_REG_CPSR(ctx) (((ucontext_t*)(ctx))->uc_mcontext.__gregs[_REG_CPSR])
+ #define UCONTEXT_REG_VFPREGS(ctx) (((ucontext_t*)(ctx))->uc_mcontext.__gregs[_REG_VFPREGS])
#endif
#elif defined(TARGET_ARM64)
"mov r0, r0\n\t" \
"mov r0, r0\n\t" \
"mov r0, r0\n\t" \
- "mov r0, r0\n\t"); \
- asm volatile ( \
- "bx %0" \
- : : "r" (__krait_ ## name)); \
+ "mov r0, r0\n\t" \
+ "b __krait_" # name \
+ "\n\t"); \
} \
- static void __krait_ ## name arglist
+ static __attribute__((used)) void __krait_ ## name arglist
#endif
-
/* Don't use this */
#ifndef MONO_SIGNAL_HANDLER_FUNC
#define MONO_SIGNAL_HANDLER_FUNC(access, name, arglist) access void name arglist
{
kern_return_t ret;
- ret = thread_suspend (info->native_handle);
+ do {
+ ret = thread_suspend (info->native_handle);
+ } while (ret == KERN_ABORTED);
+
if (ret != KERN_SUCCESS)
return;
- ret = thread_abort_safely (info->native_handle);
+ do {
+ ret = thread_abort_safely (info->native_handle);
+ } while (ret == KERN_ABORTED);
/*
* We are doing thread_abort when thread_abort_safely returns KERN_SUCCESS because
if (ret == KERN_SUCCESS)
ret = thread_abort (info->native_handle);
- g_assert (thread_resume (info->native_handle) == KERN_SUCCESS);
+ do {
+ ret = thread_resume (info->native_handle);
+ } while (ret == KERN_ABORTED);
+
+ g_assert (ret == KERN_SUCCESS);
}
gboolean
g_assert (info);
- ret = thread_suspend (info->native_handle);
+
+ do {
+ ret = thread_suspend (info->native_handle);
+ } while (ret == KERN_ABORTED);
+
THREADS_SUSPEND_DEBUG ("SUSPEND %p -> %d\n", (void*)info->native_handle, ret);
if (ret != KERN_SUCCESS)
return FALSE;
/* We're in the middle of a self-suspend, resume and register */
if (!mono_threads_transition_finish_async_suspend (info)) {
mono_threads_add_to_pending_operation_set (info);
- g_assert (thread_resume (info->native_handle) == KERN_SUCCESS);
+ do {
+ ret = thread_resume (info->native_handle);
+ } while (ret == KERN_ABORTED);
+ g_assert (ret == KERN_SUCCESS);
THREADS_SUSPEND_DEBUG ("FAILSAFE RESUME/1 %p -> %d\n", (void*)info->native_handle, 0);
//XXX interrupt_kernel doesn't make sense in this case as the target is not in a syscall
return TRUE;
thread_abort (info->native_handle);
} else {
mono_threads_transition_async_suspend_compensation (info);
- g_assert (thread_resume (info->native_handle) == KERN_SUCCESS);
+ do {
+ ret = thread_resume (info->native_handle);
+ } while (ret == KERN_ABORTED);
+ g_assert (ret == KERN_SUCCESS);
THREADS_SUSPEND_DEBUG ("FAILSAFE RESUME/2 %p -> %d\n", (void*)info->native_handle, 0);
}
return res;
state = (thread_state_t) alloca (mono_mach_arch_get_thread_state_size ());
mctx = (mcontext_t) alloca (mono_mach_arch_get_mcontext_size ());
- ret = mono_mach_arch_get_thread_state (info->native_handle, state, &num_state);
+ do {
+ ret = mono_mach_arch_get_thread_state (info->native_handle, state, &num_state);
+ } while (ret == KERN_ABORTED);
+
if (ret != KERN_SUCCESS)
return FALSE;
mono_mach_arch_mcontext_to_thread_state (mctx, state);
- ret = mono_mach_arch_set_thread_state (info->native_handle, state, num_state);
+ do {
+ ret = mono_mach_arch_set_thread_state (info->native_handle, state, num_state);
+ } while (ret == KERN_ABORTED);
+
if (ret != KERN_SUCCESS)
return FALSE;
}
- ret = thread_resume (info->native_handle);
+ do {
+ ret = thread_resume (info->native_handle);
+ } while (ret == KERN_ABORTED);
THREADS_SUSPEND_DEBUG ("RESUME %p -> %d\n", (void*)info->native_handle, ret);
return ret == KERN_SUCCESS;
n [62] = '\0';
pthread_setname_np (n);
}
+#elif defined (__NetBSD__)
+ if (!name) {
+ pthread_setname_np (tid, "%s", (void*)"");
+ } else {
+ char n [PTHREAD_MAX_NAMELEN_NP];
+
+ strncpy (n, name, PTHREAD_MAX_NAMELEN_NP);
+ n [PTHREAD_MAX_NAMELEN_NP - 1] = '\0';
+ pthread_setname_np (tid, "%s", (void*)n);
+ }
#elif defined (HAVE_PTHREAD_SETNAME_NP)
if (!name) {
pthread_setname_np (tid, "");
<ClInclude Include="..\mono\mini\seq-points.h" />\r
<ClInclude Include="..\mono\mini\version.h" />\r
<ClInclude Include="..\mono\mini\optflags-def.h" />\r
+ <ClInclude Include="..\mono\mini\cfgdump.h" />\r
+ <ClCompile Include="..\mono\mini\cfgdump.c" />\r
<ClInclude Include="..\mono\mini\jit-icalls.h " />\r
<ClCompile Include="..\mono\mini\jit-icalls.c " />\r
<ClCompile Include="..\mono\mini\seq-points.c" />\r
mono_lock_free_queue_dequeue
mono_lock_free_queue_enqueue
mono_lock_free_queue_init
-mono_lock_free_queue_node_free
+mono_lock_free_queue_node_unpoison
mono_lock_free_queue_node_init
mono_locks_dump
mono_lookup_icall_symbol
mono_param_get_objects
mono_parse_default_optimizations
mono_parse_env_options
+mono_parse_options_from
mono_path_canonicalize
mono_path_resolve_symlinks
mono_pe_file_open
mono_lock_free_queue_dequeue
mono_lock_free_queue_enqueue
mono_lock_free_queue_init
-mono_lock_free_queue_node_free
+mono_lock_free_queue_node_unpoison
mono_lock_free_queue_node_init
mono_locks_dump
mono_lookup_icall_symbol
mono_param_get_objects
mono_parse_default_optimizations
mono_parse_env_options
+mono_parse_options_from
mono_path_canonicalize
mono_path_resolve_symlinks
mono_pe_file_open
if [[ ${label} == 'w32' ]]; then PLATFORM=Win32; EXTRA_CONF_FLAGS="--host=i686-pc-mingw32"; export MONO_EXECUTABLE="`cygpath -u ${WORKSPACE}\\\msvc\\\Win32\\\bin\\\Release_SGen\\\mono-sgen.exe`";fi
if [[ ${label} == 'w64' ]]; then PLATFORM=x64; EXTRA_CONF_FLAGS="--host=i686-pc-mingw32"; export MONO_EXECUTABLE="`cygpath -u ${WORKSPACE}\\\msvc\\\x64\\\bin\\\Release_SGen\\\mono-sgen.exe`"; fi
-${TESTCMD} --label=configure --timeout=60m --fatal ./autogen.sh --with-monodroid --with-monotouch --with-monotouch_watch --with-monotouch_tv --with-xammac --with-mobile_static $EXTRA_CONF_FLAGS
+if [[ ${label} != w* ]] && [[ ${label} != 'debian-ppc64el' ]] && [[ ${label} != 'centos-s390x' ]];
+ then
+ EXTRA_CONF_FLAGS="$EXTRA_CONF_FLAGS --with-monodroid --with-monotouch --with-monotouch_watch --with-monotouch_tv --with-xammac --with-mobile_static"
+ # only enable the mobile profiles and mobile_static on the main architectures
+fi
+
+if [ -x "/usr/bin/dpkg-architecture" ];
+ then
+ EXTRA_CONF_FLAGS="$EXTRA_CONF_FLAGS --host=`/usr/bin/dpkg-architecture -qDEB_HOST_GNU_TYPE`"
+ #force build arch = dpkg arch, sometimes misdetected
+fi
+
+${TESTCMD} --label=configure --timeout=60m --fatal ./autogen.sh $EXTRA_CONF_FLAGS
if [[ ${label} == w* ]];
then
- ${TESTCMD} --label=make-msvc --timeout=60m --fatal "/cygdrive/c/Program\ Files\ \(x86\)/MSBuild/12.0/Bin/MSBuild.exe" /p:Platform=${PLATFORM} /p:Configuration=Release msvc/mono.sln
- ${TESTCMD} --label=make-msvc-sgen --timeout=60m --fatal "/cygdrive/c/Program\ Files\ \(x86\)/MSBuild/12.0/Bin/MSBuild.exe" /p:Platform=${PLATFORM} /p:Configuration=Release_SGen msvc/mono.sln
+ ${TESTCMD} --label=make-msvc --timeout=60m --fatal /cygdrive/c/Program\ Files\ \(x86\)/MSBuild/12.0/Bin/MSBuild.exe /p:Platform=${PLATFORM} /p:Configuration=Release msvc/mono.sln
+ ${TESTCMD} --label=make-msvc-sgen --timeout=60m --fatal /cygdrive/c/Program\ Files\ \(x86\)/MSBuild/12.0/Bin/MSBuild.exe /p:Platform=${PLATFORM} /p:Configuration=Release_SGen msvc/mono.sln
fi
${TESTCMD} --label=make --timeout=300m --fatal make -w V=1
if [[ -n "${ghprbPullId}" ]] && [[ ${label} == w* ]];
#!/bin/bash -e
TIMEOUTCMD=`dirname "${BASH_SOURCE[0]}"`/babysitter
-if ! ${TIMEOUTCMD} -h >/dev/null 2>&1; then
+if [[ "$OSTYPE" == "cygwin" ]] || ! ${TIMEOUTCMD} -h >/dev/null 2>&1; then
TIMEOUTCMD=timeout # fall back to timeout if babysitter doesn't work (e.g. python not installed or wrong version)
fi
--- /dev/null
+.stamp-clone
+CppSharp
+*.exe
+*.h
+*.exe.mdb
--- /dev/null
+CPPSHARP_DIR = CppSharp
+
+CPPSHARP_REFS = -r:$(CPPSHARP_DIR)/CppSharp.dll \
+ -r:$(CPPSHARP_DIR)/CppSharp.AST.dll \
+ -r:$(CPPSHARP_DIR)/CppSharp.Parser.CSharp.dll \
+ -r:$(CPPSHARP_DIR)/CppSharp.Generator.dll
+
+SRC_ROOT = ../..
+
+MONO_OPTIONS_SRC = $(SRC_ROOT)/mono/mcs/class/Mono.Options/Mono.Options/Options.cs
+
+.stamp-clone:
+ @if [ ! -d $(CPPSHARP_DIR) ]; then \
+ git clone git@github.com:xamarin/CppSharpBinaries.git $(CPPSHARP_DIR); \
+ touch $@; \
+ fi
+
+MonoAotOffsetsDumper.exe: .stamp-clone MonoAotOffsetsDumper.cs $(MONO_OPTIONS_SRC)
+ mcs MonoAotOffsetsDumper.cs /debug /nowarn:0436 $(MONO_OPTIONS_SRC) $(CPPSHARP_REFS)
+
+.PHONY: clean
+clean:
+ rm MonoAotOffsetsDumper.exe
+
+dump: MonoAotOffsetsDumper.exe
+ MONO_PATH=$(CPPSHARP_DIR) mono MonoAotOffsetsDumper.exe
+
+update:
+ @if [ -f object-offsets.h ]; then rm object-offsets.h; fi;
+ @for f in *.h; do \
+ echo "Processing $$f.."; \
+ echo "#include \"$$f\"" >> object-offsets1.h; \
+ done
+ @cp *.h ../mono/metadata
+
+gen-proj:
+ $(CPPSHARP_DIR)/premake5 vs2012
+
+all: MonoAotOffsetsDumper.exe
\ No newline at end of file
--- /dev/null
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text.RegularExpressions;
+using CppSharp.AST;
+using CppSharp.AST.Extensions;
+using CppSharp.Parser;
+
+namespace CppSharp
+{
+ /**
+ * This tool dumps the offsets of structures used in the Mono VM needed
+ * by the AOT compiler for cross-compiling code to target platforms
+ * different than the host the compiler is being invoked on.
+ *
+ * It takes two arguments: the path to your clone of the Mono repo and
+ * the path to the root of Android NDK.
+ */
+ static class MonoAotOffsetsDumper
+ {
+ static string MonoDir = @"";
+
+ static List<string> Abis = new List<string> ();
+ static string OutputDir;
+
+ static string MonodroidDir = @"";
+ static string MaccoreDir = @"";
+
+ public enum TargetPlatform
+ {
+ Android,
+ iOS,
+ WatchOS,
+ }
+
+ public class Target
+ {
+ public Target()
+ {
+ Defines = new List<string>();
+ Arguments = new List<string>();
+ }
+
+ public Target(Target target)
+ {
+ Platform = target.Platform;
+ Triple = target.Triple;
+ Build = target.Build;
+ Defines = target.Defines;
+ Arguments = target.Arguments;
+ }
+
+ public TargetPlatform Platform;
+ public string Triple;
+ public string Build;
+ public List<string> Defines;
+ public List<string> Arguments;
+ };
+
+ public static List<Target> Targets = new List<Target>();
+
+ public static IEnumerable<Target> AndroidTargets
+ {
+ get { return Targets.Where ((t) => t.Platform == TargetPlatform.Android); }
+ }
+
+ public static IEnumerable<Target> DarwinTargets
+ {
+ get
+ {
+ return Targets.Where ((t) => t.Platform == TargetPlatform.iOS ||
+ t.Platform == TargetPlatform.WatchOS);
+ }
+ }
+
+ public static IEnumerable<Target> iOSTargets
+ {
+ get
+ {
+ return Targets.Where ((t) => t.Platform == TargetPlatform.iOS);
+ }
+ }
+
+ public static void SetupAndroidTargets()
+ {
+ Targets.Add (new Target {
+ Platform = TargetPlatform.Android,
+ Triple = "i686-none-linux-android",
+ Build = "mono-x86",
+ Defines = { "TARGET_X86" }
+ });
+
+ Targets.Add (new Target {
+ Platform = TargetPlatform.Android,
+ Triple = "x86_64-none-linux-android",
+ Build = "mono-x86_64",
+ Defines = { "TARGET_AMD64" }
+ });
+
+ Targets.Add (new Target {
+ Platform = TargetPlatform.Android,
+ Triple = "armv5-none-linux-androideabi",
+ Build = "mono-armv6",
+ Defines = { "TARGET_ARM", "ARM_FPU_VFP", "HAVE_ARMV5" }
+ });
+
+ Targets.Add (new Target {
+ Platform = TargetPlatform.Android,
+ Triple = "armv7-none-linux-androideabi",
+ Build = "mono-armv7",
+ Defines = { "TARGET_ARM", "ARM_FPU_VFP", "HAVE_ARMV5", "HAVE_ARMV6",
+ "HAVE_ARMV7"
+ }
+ });
+
+ Targets.Add (new Target {
+ Platform = TargetPlatform.Android,
+ Triple = "aarch64-v8a-linux-android",
+ Build = "mono-aarch64",
+ Defines = { "TARGET_ARM64" }
+ });
+
+ /*Targets.Add(new Target {
+ Platform = TargetPlatform.Android,
+ Triple = "mipsel-none-linux-android",
+ Build = "mono-mips",
+ Defines = { "TARGET_MIPS", "__mips__" }
+ });*/
+
+ foreach (var target in AndroidTargets)
+ target.Defines.AddRange (new string[] { "PLATFORM_ANDROID",
+ "TARGET_ANDROID", "MONO_CROSS_COMPILE", "USE_MONO_CTX"
+ });
+ }
+
+ public static void SetupiOSTargets()
+ {
+ Targets.Add(new Target {
+ Platform = TargetPlatform.iOS,
+ Triple = "arm-apple-darwin10",
+ Build = "target7",
+ Defines = { "TARGET_ARM", "ARM_FPU_VFP", "HAVE_ARMV5" }
+ });
+
+ Targets.Add(new Target {
+ Platform = TargetPlatform.iOS,
+ Triple = "aarch64-apple-darwin10",
+ Build = "target64",
+ Defines = { "TARGET_ARM64" }
+ });
+
+ foreach (var target in iOSTargets) {
+ target.Defines.AddRange (new string[] { "PLATFORM_DARWIN",
+ "TARGET_IOS", "TARGET_MACH", "MONO_CROSS_COMPILE", "USE_MONO_CTX",
+ "_XOPEN_SOURCE"
+ });
+ }
+
+ Targets.Add(new Target {
+ Platform = TargetPlatform.WatchOS,
+ Triple = "armv7k-apple-darwin",
+ Build = "targetwatch",
+ Defines = { "TARGET_ARM", "ARM_FPU_VFP", "HAVE_ARMV5" }
+ });
+
+ foreach (var target in DarwinTargets) {
+ target.Defines.AddRange (new string[] { "PLATFORM_DARWIN",
+ "TARGET_IOS", "TARGET_MACH", "MONO_CROSS_COMPILE", "USE_MONO_CTX",
+ "_XOPEN_SOURCE"
+ });
+ }
+ }
+
+ static bool GetParentSubDirectoryPath(string parent, out string subdir)
+ {
+ var directory = Directory.GetParent(Directory.GetCurrentDirectory());
+
+ while (directory != null) {
+ var path = Path.Combine(directory.FullName, parent);
+
+ if (Directory.Exists (path)) {
+ subdir = path;
+ return true;
+ }
+
+ directory = directory.Parent;
+ }
+
+ subdir = null;
+ return false;
+ }
+
+ public static void Main(string[] args)
+ {
+ ParseCommandLineArgs(args);
+
+ string monodroidDir;
+ if (!Directory.Exists (MonodroidDir) &&
+ GetParentSubDirectoryPath ("monodroid", out monodroidDir)) {
+ MonodroidDir = Path.Combine (monodroidDir);
+ }
+
+ if (Directory.Exists (MonodroidDir))
+ SetupAndroidTargets();
+
+ string maccoreDir;
+ if (!Directory.Exists (MaccoreDir) &&
+ GetParentSubDirectoryPath ("maccore", out maccoreDir)) {
+ MaccoreDir = Path.Combine (maccoreDir);
+ }
+
+ if (Directory.Exists(MaccoreDir))
+ SetupiOSTargets();
+
+ foreach (var target in Targets)
+ {
+ if (Abis.Any() && !Abis.Any (target.Triple.Contains))
+ continue;
+
+ Console.WriteLine();
+ Console.WriteLine("Processing triple: {0}", target.Triple);
+
+ var options = new DriverOptions();
+
+ var log = new TextDiagnosticPrinter();
+ var driver = new Driver(options, log);
+
+ Setup(driver, target);
+ driver.Setup();
+
+ BuildParseOptions(driver, target);
+ if (!driver.ParseCode())
+ return;
+
+ Dump(driver.ASTContext, driver.TargetInfo, target);
+ }
+ }
+
+ static void BuildParseOptions(Driver driver, Target target)
+ {
+ foreach (var header in driver.Options.Headers)
+ {
+ var source = driver.Project.AddFile(header);
+ source.Options = driver.BuildParseOptions(source);
+
+ if (header.Contains ("mini"))
+ continue;
+
+ source.Options.addDefines ("HAVE_SGEN_GC");
+ source.Options.addDefines ("HAVE_MOVING_COLLECTOR");
+ }
+ }
+
+ static string GetAndroidNdkPath()
+ {
+ // Find the Android NDK's path from Monodroid's config.
+ var configFile = Path.Combine(MonodroidDir, "env.config");
+ if (!File.Exists(configFile))
+ throw new Exception("Expected a valid Monodroid environment config file at " + configFile);
+
+ var config = File.ReadAllText(configFile);
+ var match = Regex.Match(config, @"ANDROID_NDK_PATH\s*:=\s(.*)");
+ return match.Groups[1].Value.Trim();
+ }
+
+ static void ParseCommandLineArgs(string[] args)
+ {
+ var showHelp = false;
+
+ var options = new Mono.Options.OptionSet () {
+ { "abi=", "ABI triple to generate", v => Abis.Add(v) },
+ { "o|out=", "output directory", v => OutputDir = v },
+ { "maccore=", "include directory", v => MaccoreDir = v },
+ { "monodroid=", "include directory", v => MonodroidDir = v },
+ { "mono=", "include directory", v => MonoDir = v },
+ { "h|help", "show this message and exit", v => showHelp = v != null },
+ };
+
+ try {
+ options.Parse (args);
+ }
+ catch (Mono.Options.OptionException e) {
+ Console.WriteLine (e.Message);
+ Environment.Exit(0);
+ }
+
+ if (showHelp)
+ {
+ // Print usage and exit.
+ Console.WriteLine("{0} [--abi=triple] [--out=dir] "
+ + "[--monodroid/maccore=dir] [--mono=dir]",
+ AppDomain.CurrentDomain.FriendlyName);
+ Environment.Exit(0);
+ }
+ }
+
+ static void Setup(Driver driver, Target target)
+ {
+ var options = driver.Options;
+ options.DryRun = true;
+ options.Verbose = false;
+ options.LibraryName = "Mono";
+ options.MicrosoftMode = false;
+ options.addArguments("-xc");
+ options.addArguments("-std=gnu99");
+ options.addDefines("CPPSHARP");
+
+ foreach (var define in target.Defines)
+ options.addDefines(define);
+
+ SetupToolchainPaths(driver, target);
+
+ SetupMono(options, target);
+ }
+
+ static void SetupMono(DriverOptions options, Target target)
+ {
+ string targetPath;
+ switch (target.Platform) {
+ case TargetPlatform.Android:
+ targetPath = Path.Combine (MonodroidDir, "builds");
+ break;
+ case TargetPlatform.WatchOS:
+ case TargetPlatform.iOS:
+ targetPath = Path.Combine (MaccoreDir, "builds");
+ break;
+ default:
+ throw new ArgumentOutOfRangeException ();
+ }
+
+ if (!Directory.Exists (MonoDir)) {
+ MonoDir = Path.GetFullPath (Path.Combine (targetPath, "../../mono"));
+ }
+
+ var targetBuild = Path.Combine(targetPath, target.Build);
+
+ if (!Directory.Exists(targetBuild))
+ throw new Exception(string.Format("Could not find the target build directory: {0}", targetBuild));
+
+ var includeDirs = new[]
+ {
+ targetBuild,
+ Path.Combine(targetBuild, "eglib", "src"),
+ MonoDir,
+ Path.Combine(MonoDir, "mono"),
+ Path.Combine(MonoDir, "mono", "mini"),
+ Path.Combine(MonoDir, "eglib", "src")
+ };
+
+ foreach (var inc in includeDirs)
+ options.addIncludeDirs(inc);
+
+ var filesToParse = new[]
+ {
+ Path.Combine(MonoDir, "mono", "metadata", "metadata-cross-helpers.c"),
+ Path.Combine(MonoDir, "mono", "mini", "mini-cross-helpers.c"),
+ };
+
+ foreach (var file in filesToParse)
+ options.Headers.Add(file);
+ }
+
+ static void SetupMSVC(Driver driver, string triple)
+ {
+ var options = driver.Options;
+
+ options.Abi = Parser.AST.CppAbi.Microsoft;
+ options.MicrosoftMode = true;
+
+ var systemIncludeDirs = new[]
+ {
+ @"C:\Program Files (x86)\Windows Kits\8.1\Include\um",
+ @"C:\Program Files (x86)\Windows Kits\8.1\Include\shared"
+ };
+
+ foreach (var inc in systemIncludeDirs)
+ options.addSystemIncludeDirs(inc);
+
+ options.addDefines("HOST_WIN32");
+ }
+
+ static void SetupToolchainPaths(Driver driver, Target target)
+ {
+ switch (target.Platform) {
+ case TargetPlatform.Android:
+ SetupAndroidNDK(driver, target);
+ break;
+ case TargetPlatform.iOS:
+ case TargetPlatform.WatchOS:
+ SetupXcode(driver, target);
+ break;
+ default:
+ throw new ArgumentOutOfRangeException ();
+ }
+ }
+
+ static string GetArchFromTriple(string triple)
+ {
+ if (triple.Contains("mips"))
+ return "mips";
+
+ if (triple.Contains("arm64") || triple.Contains("aarch64"))
+ return "arm64";
+
+ if (triple.Contains("arm"))
+ return "arm";
+
+ if (triple.Contains("i686"))
+ return "x86";
+
+ if (triple.Contains("x86_64"))
+ return "x86_64";
+
+ throw new Exception("Unknown architecture from triple: " + triple);
+ }
+
+ static string GetXcodeToolchainPath()
+ {
+ var toolchains = Directory.EnumerateDirectories("/Applications", "Xcode*")
+ .ToList();
+ toolchains.Sort();
+
+ var toolchainPath = toolchains.LastOrDefault();
+ if (toolchainPath == null)
+ throw new Exception("Could not find a valid Xcode SDK");
+
+ return toolchainPath;
+ }
+
+ static string GetXcodeBuiltinIncludesFolder()
+ {
+ var toolchainPath = GetXcodeToolchainPath();
+
+ var toolchains = Directory.EnumerateDirectories(Path.Combine(toolchainPath,
+ "Contents/Developer/Toolchains")).ToList();
+ toolchains.Sort();
+
+ toolchainPath = toolchains.LastOrDefault();
+ if (toolchainPath == null)
+ throw new Exception("Could not find a valid Xcode toolchain");
+
+ var includePaths = Directory.EnumerateDirectories(Path.Combine(toolchainPath,
+ "usr/lib/clang")).ToList();
+ var includePath = includePaths.LastOrDefault();
+
+ if (includePath == null)
+ throw new Exception("Could not find a valid Clang include folder");
+
+ return Path.Combine(includePath, "include");
+ }
+
+ static string GetXcodeiOSIncludesFolder()
+ {
+ var toolchainPath = GetXcodeToolchainPath();
+
+ var sdkPaths = Directory.EnumerateDirectories(Path.Combine(toolchainPath,
+ "Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs")).ToList();
+ var sdkPath = sdkPaths.LastOrDefault();
+
+ if (sdkPath == null)
+ throw new Exception("Could not find a valid iPhone SDK");
+
+ return Path.Combine(sdkPath, "usr/include");
+ }
+
+ static string GetXcodeWatchOSIncludesFolder()
+ {
+ var toolchainPath = GetXcodeToolchainPath();
+
+ var sdkPaths = Directory.EnumerateDirectories(Path.Combine(toolchainPath,
+ "Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs")).ToList();
+ var sdkPath = sdkPaths.LastOrDefault();
+
+ if (sdkPath == null)
+ throw new Exception("Could not find a valid WatchOS SDK");
+
+ return Path.Combine(sdkPath, "usr/include");
+ }
+
+ static void SetupXcode(Driver driver, Target target)
+ {
+ var options = driver.Options;
+
+ var builtinsPath = GetXcodeBuiltinIncludesFolder();
+ string includePath;
+
+ switch (target.Platform) {
+ case TargetPlatform.iOS:
+ includePath = GetXcodeiOSIncludesFolder();
+ break;
+ case TargetPlatform.WatchOS:
+ includePath = GetXcodeWatchOSIncludesFolder();
+ break;
+ default:
+ throw new ArgumentOutOfRangeException ();
+ }
+
+ options.addSystemIncludeDirs(builtinsPath);
+ options.addSystemIncludeDirs(includePath);
+
+ options.NoBuiltinIncludes = true;
+ options.NoStandardIncludes = true;
+ options.TargetTriple = target.Triple;
+ }
+
+ static string GetAndroidHostToolchainPath()
+ {
+ var androidNdkPath = GetAndroidNdkPath ();
+ var toolchains = Directory.EnumerateDirectories(
+ Path.Combine(androidNdkPath, "toolchains"), "llvm*").ToList();
+ toolchains.Sort();
+
+ var toolchainPath = toolchains.LastOrDefault();
+ if (toolchainPath == null)
+ throw new Exception("Could not find a valid NDK host toolchain");
+
+ toolchains = Directory.EnumerateDirectories(Path.Combine(toolchainPath,
+ "prebuilt")).ToList();
+ toolchains.Sort();
+
+ toolchainPath = toolchains.LastOrDefault();
+ if (toolchainPath == null)
+ throw new Exception("Could not find a valid NDK host toolchain");
+
+ return toolchainPath;
+ }
+
+ static string GetAndroidBuiltinIncludesFolder()
+ {
+ var toolchainPath = GetAndroidHostToolchainPath();
+
+ string clangToolchainPath = Path.Combine(toolchainPath, "lib64", "clang");
+ if (!Directory.Exists (clangToolchainPath))
+ clangToolchainPath = Path.Combine(toolchainPath, "lib", "clang");
+
+ string includePath = null;
+ if (Directory.Exists (clangToolchainPath)) {
+ var includePaths = Directory.EnumerateDirectories(clangToolchainPath).ToList();
+ includePath = includePaths.LastOrDefault();
+ }
+ if (includePath == null)
+ throw new Exception("Could not find a valid Clang include folder");
+
+ return Path.Combine(includePath, "include");
+ }
+
+ static void SetupAndroidNDK(Driver driver, Target target)
+ {
+ var options = driver.Options;
+
+ var builtinsPath = GetAndroidBuiltinIncludesFolder();
+ options.addSystemIncludeDirs(builtinsPath);
+
+ var androidNdkRoot = GetAndroidNdkPath ();
+ const int androidNdkApiLevel = 21;
+
+ var toolchainPath = Path.Combine(androidNdkRoot, "platforms",
+ "android-" + androidNdkApiLevel, "arch-" + GetArchFromTriple(target.Triple),
+ "usr", "include");
+ options.addSystemIncludeDirs(toolchainPath);
+
+ options.NoBuiltinIncludes = true;
+ options.NoStandardIncludes = true;
+ options.TargetTriple = target.Triple;
+ }
+
+ static uint GetTypeAlign(ParserTargetInfo target, ParserIntType type)
+ {
+ switch (type)
+ {
+ case ParserIntType.SignedChar:
+ case ParserIntType.UnsignedChar:
+ return target.CharAlign;
+ case ParserIntType.SignedShort:
+ case ParserIntType.UnsignedShort:
+ return target.ShortAlign;
+ case ParserIntType.SignedInt:
+ case ParserIntType.UnsignedInt:
+ return target.IntAlign;
+ case ParserIntType.SignedLong:
+ case ParserIntType.UnsignedLong:
+ return target.LongAlign;
+ case ParserIntType.SignedLongLong:
+ case ParserIntType.UnsignedLongLong:
+ return target.LongLongAlign;
+ default:
+ throw new Exception("Type has no alignment");
+ }
+ }
+
+ static uint GetTypeSize(ParserTargetInfo target, ParserIntType type)
+ {
+ switch (type)
+ {
+ case ParserIntType.SignedChar:
+ case ParserIntType.UnsignedChar:
+ return target.CharWidth;
+ case ParserIntType.SignedShort:
+ case ParserIntType.UnsignedShort:
+ return target.ShortWidth;
+ case ParserIntType.SignedInt:
+ case ParserIntType.UnsignedInt:
+ return target.IntWidth;
+ case ParserIntType.SignedLong:
+ case ParserIntType.UnsignedLong:
+ return target.LongWidth;
+ case ParserIntType.SignedLongLong:
+ case ParserIntType.UnsignedLongLong:
+ return target.LongLongWidth;
+ default:
+ throw new Exception("Type has no size");
+ }
+ }
+
+ static string GetTargetPlatformDefine(TargetPlatform target)
+ {
+ switch (target) {
+ case TargetPlatform.Android:
+ return "TARGET_ANDROID";
+ case TargetPlatform.iOS:
+ return "TARGET_IOS";
+ case TargetPlatform.WatchOS:
+ return "TARGET_WATCHOS";
+ default:
+ throw new ArgumentOutOfRangeException ();
+ }
+ }
+
+ static void Dump(ASTContext ctx, ParserTargetInfo targetInfo, Target target)
+ {
+ var targetFile = target.Triple;
+
+ if (!string.IsNullOrEmpty (OutputDir))
+ targetFile = Path.Combine (OutputDir, targetFile);
+
+ targetFile += ".h";
+
+ using (var writer = new StreamWriter(targetFile))
+ //using (var writer = Console.Out)
+ {
+ writer.WriteLine("#ifndef USED_CROSS_COMPILER_OFFSETS");
+ writer.WriteLine("#ifdef {0}", target.Defines[0]);
+ writer.WriteLine ("#ifdef {0}", GetTargetPlatformDefine (target.Platform));
+ writer.WriteLine("#ifndef HAVE_BOEHM_GC");
+ writer.WriteLine("#define HAS_CROSS_COMPILER_OFFSETS");
+ writer.WriteLine("#if defined (USE_CROSS_COMPILE_OFFSETS) || defined (MONO_CROSS_COMPILE)");
+ writer.WriteLine("#if !defined (DISABLE_METADATA_OFFSETS)");
+ writer.WriteLine("#define USED_CROSS_COMPILER_OFFSETS");
+
+ DumpAligns(writer, targetInfo);
+ DumpSizes(writer, targetInfo);
+ DumpMetadataOffsets(writer, ctx, target);
+
+ writer.WriteLine("#endif //disable metadata check");
+
+ DumpJITOffsets(writer, ctx);
+
+ writer.WriteLine("#endif //cross compiler checks");
+ writer.WriteLine("#endif //gc check");
+ writer.WriteLine("#endif //os check");
+ writer.WriteLine("#endif //arch check");
+ writer.WriteLine("#endif //USED_CROSS_COMPILER_OFFSETS check");
+ }
+
+ Console.WriteLine("Generated offsets file: {0}", targetFile);
+ }
+
+ static void DumpAligns(TextWriter writer, ParserTargetInfo target)
+ {
+ var aligns = new[]
+ {
+ new { Name = "gint8", Align = target.CharAlign},
+ new { Name = "gint16", Align = target.ShortAlign},
+ new { Name = "gint32", Align = target.IntAlign},
+ new { Name = "gint64", Align = GetTypeAlign(target, target.Int64Type)},
+ new { Name = "float", Align = target.FloatAlign},
+ new { Name = "double", Align = target.DoubleAlign},
+ new { Name = "gpointer", Align = GetTypeAlign(target, target.IntPtrType)},
+ };
+
+ // Write the alignment info for the basic types.
+ foreach (var align in aligns)
+ writer.WriteLine("DECL_ALIGN2({0},{1})", align.Name, align.Align / 8);
+ }
+
+ static void DumpSizes(TextWriter writer, ParserTargetInfo target)
+ {
+ var sizes = new[]
+ {
+ new { Name = "gint8", Size = target.CharWidth},
+ new { Name = "gint16", Size = target.ShortWidth},
+ new { Name = "gint32", Size = target.IntWidth},
+ new { Name = "gint64", Size = GetTypeSize(target, target.Int64Type)},
+ new { Name = "float", Size = target.FloatWidth},
+ new { Name = "double", Size = target.DoubleWidth},
+ new { Name = "gpointer", Size = GetTypeSize(target, target.IntPtrType)},
+ };
+
+ // Write the size info for the basic types.
+ foreach (var size in sizes)
+ writer.WriteLine("DECL_SIZE2({0},{1})", size.Name, size.Size / 8);
+ }
+
+ static Class GetClassFromTypedef(ITypedDecl typedef)
+ {
+ var type = typedef.Type.Desugar() as TagType;
+ if (type == null)
+ return null;
+
+ var @class = type.Declaration as Class;
+
+ return @class.IsIncomplete ?
+ (@class.CompleteDeclaration as Class) : @class;
+ }
+
+ static void DumpClasses(TextWriter writer, ASTContext ctx, IEnumerable<string> types,
+ bool optional = false)
+ {
+ foreach (var @struct in types)
+ {
+ var @class = ctx.FindCompleteClass(@struct);
+ if (@class == null)
+ @class = ctx.FindCompleteClass("_" + @struct);
+
+ if (@class == null)
+ {
+ var typedef = ctx.FindTypedef(@struct).FirstOrDefault(
+ decl => !decl.IsIncomplete);
+
+ if (typedef != null)
+ @class = GetClassFromTypedef(typedef);
+ }
+
+ if (@class == null && optional)
+ continue;
+
+ if (@class == null)
+ throw new Exception("Expected to find struct definition for " + @struct);
+
+ DumpStruct(writer, @class);
+ }
+ }
+
+ static void DumpMetadataOffsets(TextWriter writer, ASTContext ctx, Target target)
+ {
+ var types = new List<string>
+ {
+ "MonoObject",
+ "MonoClass",
+ "MonoVTable",
+ "MonoDelegate",
+ "MonoInternalThread",
+ "MonoMulticastDelegate",
+ "MonoTransparentProxy",
+ "MonoRealProxy",
+ "MonoRemoteClass",
+ "MonoArray",
+ "MonoArrayBounds",
+ "MonoSafeHandle",
+ "MonoHandleRef",
+ "MonoComInteropProxy",
+ "MonoString",
+ "MonoException",
+ "MonoTypedRef",
+ "MonoThreadsSync",
+ "SgenThreadInfo"
+ };
+
+ DumpClasses(writer, ctx, types);
+ }
+
+ static void DumpJITOffsets(TextWriter writer, ASTContext ctx)
+ {
+ writer.WriteLine("#ifndef DISABLE_JIT_OFFSETS");
+ writer.WriteLine("#define USED_CROSS_COMPILER_OFFSETS");
+
+ var types = new[]
+ {
+ "MonoLMF",
+ "MonoMethodRuntimeGenericContext",
+ "MonoJitTlsData",
+ "MonoGSharedVtMethodRuntimeInfo",
+ "MonoContinuation",
+ "MonoContext",
+ "MonoDelegateTrampInfo",
+ };
+
+ DumpClasses(writer, ctx, types);
+
+ var optionalTypes = new[]
+ {
+ "GSharedVtCallInfo",
+ "SeqPointInfo",
+ "DynCallArgs",
+ "MonoLMFTramp",
+ };
+
+ DumpClasses(writer, ctx, optionalTypes, optional: true);
+
+ writer.WriteLine("#endif //disable jit check");
+ }
+
+ static void DumpStruct(TextWriter writer, Class @class)
+ {
+ var name = @class.Name;
+ if (name.StartsWith ("_", StringComparison.Ordinal))
+ name = name.Substring (1);
+
+ foreach (var field in @class.Fields)
+ {
+ if (field.IsBitField) continue;
+
+ if (name == "SgenThreadInfo" && field.Name == "regs")
+ continue;
+
+ writer.WriteLine("DECL_OFFSET2({0},{1},{2})", name, field.Name,
+ field.Offset / 8);
+ }
+ }
+ }
+}
/* Have signal */
#define HAVE_SIGNAL 1
+ /* Define to 1 if you have the <signal.h> header file. */
+#define HAVE_SIGNAL_H 1
+
/* Have signbit */
/* #undef HAVE_SIGNBIT */