Merge pull request #2821 from lambdageek/dev/monoerror-assembly
authorAleksey Kliger (λgeek) <akliger@gmail.com>
Mon, 18 Apr 2016 22:02:47 +0000 (18:02 -0400)
committerAleksey Kliger (λgeek) <akliger@gmail.com>
Mon, 18 Apr 2016 22:02:47 +0000 (18:02 -0400)
[assembly loader] Don't raise in mono_assembly_open_full and mono_assembly_load_with_partial_name

223 files changed:
acceptance-tests/versions.py
configure.ac
external/referencesource
libgc/configure.ac
man/mono.1
mcs/build/library.make
mcs/class/Makefile
mcs/class/Mono.CompilerServices.SymbolWriter/Makefile
mcs/class/Mono.Security/Makefile
mcs/class/Mono.Security/Mono.Security.Authenticode/AuthenticodeDeformatter.cs
mcs/class/Mono.Security/Mono.Security.Cryptography/MD2Managed.cs
mcs/class/Mono.Security/Mono.Security.Cryptography/MD4Managed.cs
mcs/class/Mono.Security/Mono.Security.Cryptography/SHA224Managed.cs
mcs/class/Mono.Security/Mono.Security.Interface/CertificateValidationHelper.cs
mcs/class/Mono.Security/Mono.Security.Interface/MonoTlsProvider.cs
mcs/class/Mono.Security/monotouch_Mono.Security.dll.sources
mcs/class/Mono.Security/xammac_Mono.Security.dll.sources
mcs/class/RabbitMQ.Client/Makefile.orig [deleted file]
mcs/class/System.Net.Http/CFContentStream.cs [new file with mode: 0644]
mcs/class/System.Net.Http/CFNetworkHandler.cs [new file with mode: 0644]
mcs/class/System.Net.Http/HttpClientEx.cs [new file with mode: 0644]
mcs/class/System.Runtime.Serialization/System.Runtime.Serialization_test.dll.sources
mcs/class/System.Runtime.Serialization/Test/System.Runtime.Serialization/Exceptions.cs [new file with mode: 0644]
mcs/class/System.Security/Makefile
mcs/class/System.Web/Makefile
mcs/class/System/Makefile
mcs/class/System/Mono.Net.Security/CallbackHelpers.cs
mcs/class/System/Mono.Net.Security/ChainValidationHelper.cs
mcs/class/System/Mono.Net.Security/IMonoSslStream.cs
mcs/class/System/Mono.Net.Security/IMonoTlsProvider.cs
mcs/class/System/Mono.Net.Security/LegacySslStream.cs
mcs/class/System/Mono.Net.Security/MonoDefaultTlsProvider.cs
mcs/class/System/Mono.Net.Security/MonoSslStreamImpl.cs
mcs/class/System/Mono.Net.Security/MonoSslStreamWrapper.cs
mcs/class/System/Mono.Net.Security/MonoTlsProviderFactory.cs
mcs/class/System/Mono.Net.Security/MonoTlsProviderImpl.cs
mcs/class/System/Mono.Net.Security/MonoTlsProviderWrapper.cs
mcs/class/System/Mono.Net.Security/MonoTlsStream.cs
mcs/class/System/Mono.Net.Security/SystemCertificateValidator.cs
mcs/class/System/ReferenceSources/SSPIWrapper.cs
mcs/class/System/System.CodeDom.Compiler/Compiler.cs
mcs/class/System/System.Configuration/AppSettingsReader.cs
mcs/class/System/System.Configuration/ApplicationSettingsBase.cs
mcs/class/System/System.Configuration/ConfigurationSettings.cs
mcs/class/System/System.Configuration/CustomizableFileSettingsProvider.cs
mcs/class/System/System.Configuration/LocalFileSettingsProvider.cs
mcs/class/System/System.Diagnostics/Process.cs
mcs/class/System/System.IO/KeventWatcher.cs
mcs/class/System/System.Net.Mail/SmtpClient.cs
mcs/class/System/System.Net.Security/LocalCertificateSelectionCallback.cs
mcs/class/System/System.Net.Security/RemoteCertificateValidationCallback.cs
mcs/class/System/System.Net.Security/SslStream.cs
mcs/class/System/System.Net/HttpConnection.cs
mcs/class/System/System.Security.Authentication.ExtendedProtection.Configuration/ConfigUtil.cs
mcs/class/System/System.Security.Cryptography.X509Certificates/OSX509Certificates.cs
mcs/class/System/System.Security.Cryptography.X509Certificates/X509Certificate2ImplMono.cs
mcs/class/System/System.Security.Cryptography.X509Certificates/X509Helper2.cs
mcs/class/System/Test/System.Net.WebSockets/ClientWebSocketTest.cs
mcs/class/corlib/CommonCrypto/.gitignore
mcs/class/corlib/CommonCrypto/CommonCryptorGenerator.cs [deleted file]
mcs/class/corlib/CommonCrypto/CommonDigestGenerator.cs [deleted file]
mcs/class/corlib/CommonCrypto/Makefile [new file with mode: 0644]
mcs/class/corlib/CommonCrypto/Makefile.include [deleted file]
mcs/class/corlib/CommonCrypto/generator.cs [deleted file]
mcs/class/corlib/Makefile
mcs/class/corlib/System.Diagnostics/StackTraceHelper.cs
mcs/class/corlib/System.IO/Directory.cs
mcs/class/corlib/System.IO/DirectoryInfo.cs
mcs/class/corlib/System.IO/Path.cs
mcs/class/corlib/System.Reflection.Emit/DerivedTypes.cs
mcs/class/corlib/System.Reflection/MonoMethod.cs
mcs/class/corlib/System.Runtime.InteropServices/Marshal.cs
mcs/class/corlib/System.Security.Cryptography.X509Certificates/INativeCertificateHelper.cs [new file with mode: 0644]
mcs/class/corlib/System.Security.Cryptography.X509Certificates/X509Certificate.cs
mcs/class/corlib/System.Security.Cryptography.X509Certificates/X509CertificateImpl.cs
mcs/class/corlib/System.Security.Cryptography.X509Certificates/X509CertificateImplApple.cs
mcs/class/corlib/System.Security.Cryptography.X509Certificates/X509CertificateImplMono.cs
mcs/class/corlib/System.Security.Cryptography.X509Certificates/X509Helper.cs
mcs/class/corlib/System/Environment.cs
mcs/class/corlib/System/Exception.cs [deleted file]
mcs/class/corlib/Test/System.IO/DirectoryTest.cs
mcs/class/corlib/Test/System.Reflection.Emit/DerivedTypesTest.cs
mcs/class/corlib/Test/System.Security.Cryptography/CspParametersTest.cs
mcs/class/corlib/Test/System.Threading/TimerTest.cs
mcs/class/corlib/corlib.dll.sources
mcs/class/corlib/monotouch_corlib.dll.sources
mcs/class/corlib/monotouch_runtime_corlib.dll.sources
mcs/class/corlib/monotouch_tv_corlib.dll.sources
mcs/class/corlib/monotouch_watch_corlib.dll.sources
mcs/class/corlib/xammac_corlib.dll.sources
mcs/errors/cs0029-26.cs
mcs/mcs/context.cs
mcs/mcs/ecore.cs
mcs/mcs/expression.cs
mcs/mcs/iterators.cs
mcs/mcs/statement.cs
mcs/mcs/typemanager.cs
mcs/mcs/typespec.cs
mcs/tests/dtest-064.cs [new file with mode: 0644]
mcs/tests/gtest-optional-09.cs
mcs/tests/gtest-optional-36.cs [new file with mode: 0644]
mcs/tests/gtest-optional-37.cs [new file with mode: 0644]
mcs/tests/test-933.cs [new file with mode: 0644]
mcs/tests/test-async-85.cs [new file with mode: 0644]
mcs/tests/test-debug-17-ref.xml
mcs/tests/ver-il-net_4_x.xml
mcs/tools/Makefile
mcs/tools/commoncryptogenerator/CommonCryptorGenerator.cs [new file with mode: 0644]
mcs/tools/commoncryptogenerator/CommonDigestGenerator.cs [new file with mode: 0644]
mcs/tools/commoncryptogenerator/Makefile [new file with mode: 0644]
mcs/tools/commoncryptogenerator/commoncryptogenerator.exe.sources [new file with mode: 0644]
mcs/tools/commoncryptogenerator/generator.cs [new file with mode: 0644]
mcs/tools/compiler-tester/compiler-tester.cs
mcs/tools/mkbundle/Makefile
mcs/tools/mkbundle/mkbundle.cs
mcs/tools/mono-api-html/mono-api-html.csproj
mcs/tools/mono-symbolicate/LocationProvider.cs
mcs/tools/mono-symbolicate/Makefile
mcs/tools/mono-symbolicate/Test/symbolicate.expected
mcs/tools/mono-symbolicate/mono-symbolicate.exe.sources
mono/arch/amd64/amd64-codegen.h
mono/io-layer/processes.c
mono/metadata/appdomain.c
mono/metadata/class.c
mono/metadata/cominterop.c
mono/metadata/domain.c
mono/metadata/file-io.c
mono/metadata/icall-def.h
mono/metadata/icall.c
mono/metadata/marshal.c
mono/metadata/method-builder.c
mono/metadata/mono-perfcounters.c
mono/metadata/object-internals.h
mono/metadata/reflection.c
mono/metadata/sgen-client-mono.h
mono/metadata/sgen-mono.c
mono/metadata/sgen-os-mach.c
mono/metadata/threadpool-ms-io-epoll.c
mono/metadata/threadpool-ms-io-kqueue.c
mono/metadata/threadpool-ms-io-poll.c
mono/metadata/threadpool-ms-io.c
mono/metadata/threads.c
mono/mini/Makefile.am.in
mono/mini/aot-compiler.c
mono/mini/aot-runtime.c
mono/mini/branch-opts.c
mono/mini/cfgdump.c [new file with mode: 0644]
mono/mini/cfgdump.h [new file with mode: 0644]
mono/mini/decompose.c
mono/mini/driver.c
mono/mini/genmdesc.c
mono/mini/local-propagation.c
mono/mini/main.c
mono/mini/method-to-ir.c
mono/mini/mini-codegen.c
mono/mini/mini-darwin.c
mono/mini/mini-posix.c
mono/mini/mini-runtime.c
mono/mini/mini-x86.c
mono/mini/mini-x86.h
mono/mini/mini.c
mono/mini/mini.h
mono/mini/test_op_il_seq_point.sh
mono/mini/tramp-arm64.c
mono/profiler/proflog.c
mono/sgen/sgen-archdep.h
mono/sgen/sgen-descriptor.c
mono/sgen/sgen-gc.c
mono/sgen/sgen-marksweep.c
mono/sgen/sgen-memory-governor.c
mono/sgen/sgen-memory-governor.h
mono/sgen/sgen-pinning.c
mono/sgen/sgen-pinning.h
mono/sgen/sgen-protocol-def.h
mono/tests/Makefile.am
mono/tests/bug-29585.cs [new file with mode: 0644]
mono/tests/verifier/Makefile
mono/tests/verifier/make_access_test.sh
mono/tests/verifier/make_bad_op_test.sh
mono/tests/verifier/make_bin_test.sh
mono/tests/verifier/make_boxed_genarg_test.sh
mono/tests/verifier/make_branch_test.sh
mono/tests/verifier/make_call_test.sh
mono/tests/verifier/make_cmmp_test.sh
mono/tests/verifier/make_cpobj_test.sh
mono/tests/verifier/make_cross_nested_access_test.sh
mono/tests/verifier/make_ctor_test.sh
mono/tests/verifier/make_delegate_compat_test.sh
mono/tests/verifier/make_double_nesting_test.sh
mono/tests/verifier/make_exception_overlap_test.sh
mono/tests/verifier/make_field_store_test.sh
mono/tests/verifier/make_initobj_test.sh
mono/tests/verifier/make_ldobj_test.sh
mono/tests/verifier/make_localloc_test.sh
mono/tests/verifier/make_nested_access_test.sh
mono/tests/verifier/make_obj_store_test.sh
mono/tests/verifier/make_overlapped_test.sh
mono/tests/verifier/make_stobj_test.sh
mono/tests/verifier/make_switch_test.sh
mono/tests/verifier/make_tail_call_test.sh
mono/tests/verifier/make_tests.sh
mono/tests/verifier/make_unbox_test.sh
mono/utils/hazard-pointer.h
mono/utils/lock-free-alloc.c
mono/utils/lock-free-queue.c
mono/utils/lock-free-queue.h
mono/utils/mach-support.c
mono/utils/mono-os-semaphore.h
mono/utils/mono-proclib.c
mono/utils/mono-sigcontext.h
mono/utils/mono-signal-handler.h
mono/utils/mono-threads-mach-abort-syscall.c
mono/utils/mono-threads-mach.c
mono/utils/mono-threads-posix.c
msvc/libmono.vcxproj
msvc/mono.def
msvc/monosgen.def
scripts/ci/run-jenkins.sh
scripts/ci/run-step.sh
tools/offsets-tool/.gitignore [new file with mode: 0644]
tools/offsets-tool/Makefile [new file with mode: 0644]
tools/offsets-tool/MonoAotOffsetsDumper.cs [new file with mode: 0644]
winconfig.h

index 5fff4f18f38bbeb6b374cdfbb5fd672568fb54de..35ded0c0fcd74c3aa017682864890a6e501c885c 100755 (executable)
@@ -8,12 +8,12 @@ def find_module(submodules, 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"
@@ -23,16 +23,16 @@ submodules = json.load(open(CONFIG_FILE))
 
 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]
@@ -46,7 +46,7 @@ elif command == "set-remote-branch":
     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)
index 0341987c485a8f92e60172a01459695f365081b6..966bd50391504aa8e884de27ef4bbf2fe058645e 100644 (file)
@@ -1,7 +1,7 @@
 # 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])
@@ -92,11 +92,11 @@ case "$host" in
                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
@@ -272,8 +272,6 @@ case "$host" in
                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
@@ -2318,6 +2316,9 @@ else
                #include <winsock2.h>
                #include <ws2tcpip.h>
        ], [
+               #ifndef inet_pton
+               (void) inet_pton;
+               #endif
                inet_pton (0, NULL, NULL);
        ], [
                # Yes, we have it...
@@ -2450,7 +2451,7 @@ fi
 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
@@ -2612,7 +2613,7 @@ if test "x$enable_llvm" = "xyes"; then
    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
@@ -2647,7 +2648,7 @@ if test "x$enable_llvm" = "xyes"; then
       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
@@ -2889,6 +2890,12 @@ case "$host" in
                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;
@@ -3003,6 +3010,17 @@ if test "x$host" != "x$target"; then
                        ;;
                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;
@@ -3264,8 +3282,10 @@ case "$host" in
        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"
index 2f66da8d34b30473dac23f02b1a843d0717b9f1a..5b907267935346d2fe110d226bf3a62abcbd0dc6 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 2f66da8d34b30473dac23f02b1a843d0717b9f1a
+Subproject commit 5b907267935346d2fe110d226bf3a62abcbd0dc6
index ac992abfaf99aa62491ecd302c5e8be34881c022..7f5aa03148da79519f638f1bd93b37cdaa45c539 100644 (file)
@@ -233,10 +233,8 @@ AM_CONDITIONAL(POWERPC_DARWIN,test x$powerpc_darwin = xtrue)
 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)
index 4c0d27d949bc27da038b7323e00375fd509a35f4..22ffdeb139ec2c94ebf1a57e7b052ce317bd573f 100644 (file)
@@ -1786,6 +1786,10 @@ Enables the maximum JIT verbosity for the specified method. This is
 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.
index b420a8364d7d4c67e04dc46f5714d58910226525..895d67b6933b4e14cff75d8b31433a4323a8c197 100644 (file)
@@ -35,24 +35,11 @@ PROFILE_excludes = $(wildcard $(PROFILE)_$(LIBRARY).exclude.sources)
 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)
index 6bf570842e7757c2ba86d3e6c1a7bbe7b90ba30d..28ca14e770e9695ca2bb8ef167532d01de8f0a4c 100644 (file)
@@ -1,8 +1,6 @@
 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
@@ -10,9 +8,9 @@ resgen_dir = ../tools/resgen
 
 build_SUBDIRS :=  \
        corlib \
+       Mono.Security \
        System \
        System.XML \
-       System Mono.Security \
        Mono.Posix \
        System.Core \
        Mono.Cecil \
@@ -22,11 +20,10 @@ pcl_facade_dirs := Facades
 
 mobile_common_dirs := \
        corlib  \
+       Mono.Security \
        System  \
        System.Core     \
        System.XML      \
-       Mono.Security   \
-       System  \
        I18N            \
        System.ServiceModel.Internals   \
        SMDiagnostics   \
@@ -82,6 +79,7 @@ monotouch_tv_dirs   := $(monotouch_dirs)
 
 monotouch_runtime_dirs := \
        corlib \
+       Mono.Security \
        System \
        System.Core \
        System.XML \
@@ -92,12 +90,11 @@ monotouch_tv_runtime_dirs := $(monotouch_runtime_dirs)
 
 xammac_4_5_dirs := \
        corlib  \
+       Mono.Security \
        System  \
        Mono.Posix                      \
        System.Core     \
        System.XML      \
-       Mono.Security   \
-       System  \
        I18N            \
        System.ServiceModel.Internals   \
        SMDiagnostics   \
@@ -140,12 +137,12 @@ xammac_4_5_dirs := \
 
 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)                   \
index 467436e7e9dfca6b1040dcbe1564f125e2abe983..d30779ce7f13af8b685c1f04fa764222a1556c86 100644 (file)
@@ -4,7 +4,7 @@ include ../../build/rules.make
 
 LIBRARY = Mono.CompilerServices.SymbolWriter.dll
 LIB_REFS = System
-LIB_MCS_FLAGS = -lib:$(bare_libdir)
+LIB_MCS_FLAGS =
 
 NO_TEST = yes
 
index 30d065aa304cc991dcee3e0a1482a3ebf4784333..6d62eca583d7d32776d05e4ac5d33e1458cd8500 100644 (file)
@@ -3,11 +3,24 @@ SUBDIRS =
 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
index 1efcec91abde0a83b6cbc5f89caae1111a368937..bca6803ee34542a6c568a0aa5bcfe2d0e3560807 100644 (file)
@@ -205,6 +205,18 @@ namespace Mono.Security.Authenticode {
                                        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 ();
@@ -402,6 +414,15 @@ namespace Mono.Security.Authenticode {
                                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)))
index 13f0f5d8e65a639248892d5cedd5011cd4dd6aac..a428e0624b1ec82cef0e4912ff8e93588ca0aa5a 100644 (file)
@@ -27,6 +27,8 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
+#if !MONOTOUCH && !XAMMAC
+
 using System;
 
 namespace Mono.Security.Cryptography { 
@@ -195,3 +197,5 @@ namespace Mono.Security.Cryptography {
                }
        }
 }
+
+#endif
\ No newline at end of file
index eedc8b114b195cc46aa29415cbec47f46aea298f..adbd7fb876b841c88f77e7947e9ad8e158cfaba2 100644 (file)
@@ -27,6 +27,8 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
+#if !MONOTOUCH && !XAMMAC
+
 using System;
 
 namespace Mono.Security.Cryptography { 
@@ -282,3 +284,5 @@ namespace Mono.Security.Cryptography {
                }
        }
 }
+
+#endif
\ No newline at end of file
index 88d4fe59955af86f654d2a5f8ce3093d10720a63..a0da4344b9524c0d1e02264f88c828cd53b283ef 100644 (file)
@@ -29,6 +29,8 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
+#if !MONOTOUCH && !XAMMAC
+
 using System.Security.Cryptography;
 
 namespace Mono.Security.Cryptography {
@@ -256,3 +258,4 @@ namespace Mono.Security.Cryptography {
        }
 }
 
+#endif
\ No newline at end of file
index 561e7888db7d1dc1162964c83b88a22c485fe056..fd392b409e5a4bef6de68f174911b79f638997be 100644 (file)
@@ -145,25 +145,20 @@ namespace Mono.Security.Interface
                        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);
                }
        }
 }
index 59b148c48c633a14c1dae94a1608242405aafd39..089d8447a78993d3a4015cf4ad40b6a47cb6f6ed 100644 (file)
@@ -124,6 +124,26 @@ namespace Mono.Security.Interface
 
 #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
 
                /*
index 17f56e3c4054885b5f5cf4477cef4bed1ff63c44..36918de7763e9ed1c24609f0a67e752c39967081 100644 (file)
@@ -1,6 +1,3 @@
 #include mobile_Mono.Security.dll.sources
 ../corlib/CommonCrypto/CommonCrypto.cs
 ../corlib/CommonCrypto/RC4CommonCrypto.cs
-../corlib/CommonCrypto/MD2Managed.g.cs
-../corlib/CommonCrypto/MD4Managed.g.cs
-../corlib/CommonCrypto/SHA224Managed.g.cs
index 6c1b4dbef6fda25d7d76612c984ad0776f33ee7f..698996a1d709c630c585a43f2f5ac90021c5e65a 100644 (file)
@@ -1,7 +1,4 @@
 #include monotouch_Mono.Security.dll.sources
 ../corlib/CommonCrypto/CommonCrypto.cs
 ../corlib/CommonCrypto/RC4CommonCrypto.cs
-../corlib/CommonCrypto/MD2Managed.g.cs
-../corlib/CommonCrypto/MD4Managed.g.cs
-../corlib/CommonCrypto/SHA224Managed.g.cs
 
diff --git a/mcs/class/RabbitMQ.Client/Makefile.orig b/mcs/class/RabbitMQ.Client/Makefile.orig
deleted file mode 100644 (file)
index 84182ff..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-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
diff --git a/mcs/class/System.Net.Http/CFContentStream.cs b/mcs/class/System.Net.Http/CFContentStream.cs
new file mode 100644 (file)
index 0000000..270846c
--- /dev/null
@@ -0,0 +1,133 @@
+//
+// 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;
+               }
+       }
+}
diff --git a/mcs/class/System.Net.Http/CFNetworkHandler.cs b/mcs/class/System.Net.Http/CFNetworkHandler.cs
new file mode 100644 (file)
index 0000000..5723acb
--- /dev/null
@@ -0,0 +1,332 @@
+//
+// 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);
+               }
+       }
+}
diff --git a/mcs/class/System.Net.Http/HttpClientEx.cs b/mcs/class/System.Net.Http/HttpClientEx.cs
new file mode 100644 (file)
index 0000000..59456d6
--- /dev/null
@@ -0,0 +1,224 @@
+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);
+               }
+       }
+}
index b0c9706a1dbdd42ab798bdfcf4cfebe807e8ef57..547733453e01d33328e916ef748bc572767657f9 100644 (file)
@@ -15,6 +15,7 @@ System.Runtime.Serialization/DataContractSerializerTest_NullableWithDictionary.c
 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
diff --git a/mcs/class/System.Runtime.Serialization/Test/System.Runtime.Serialization/Exceptions.cs b/mcs/class/System.Runtime.Serialization/Test/System.Runtime.Serialization/Exceptions.cs
new file mode 100644 (file)
index 0000000..4303c6c
--- /dev/null
@@ -0,0 +1,95 @@
+//
+// 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
index 451a06e2f4c2e91d8827c10f0103166bebf7aaa0..5c009acb56608c1d391e86faea97071af7e3f33e 100644 (file)
@@ -8,7 +8,7 @@ LIB_MCS_FLAGS = -nowarn:618 \
        -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
 
index 9656cafa25b83a982e5f191d59a1db6bbd8c8100..7659f4e0498920b4845956e3bc2c9c5263374e6a 100644 (file)
@@ -252,7 +252,7 @@ LIB_MCS_FLAGS = \
 
 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 
 
index 1e19b0dd5bc02a9678e3d765cbe66b224864fa06..3adbdbf3917b8b3ab8e8be7411a7b8b0dd40c82c 100644 (file)
@@ -50,16 +50,16 @@ TXT_RESOURCE_STRINGS = ../../../external/referencesource/System/System.txt
 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
 
 #
@@ -67,7 +67,7 @@ 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
index 6ae2b9f3ca8d7d2ef1cc06fc06d4ab80a73f3fda..e79c167c01ecec86236184b3a72cbe33d752d8a7 100644 (file)
@@ -26,9 +26,6 @@
 
 #if SECURITY_DEP
 
-#if MONO_X509_ALIAS
-extern alias PrebuiltSystem;
-#endif
 #if MONO_SECURITY_ALIAS
 extern alias MonoSecurity;
 #endif
@@ -38,13 +35,6 @@ 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;
-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;
@@ -64,7 +54,7 @@ namespace Mono.Net.Security.Private
                        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)
@@ -72,7 +62,7 @@ namespace Mono.Net.Security.Private
                        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)
@@ -80,7 +70,7 @@ namespace Mono.Net.Security.Private
                        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)
@@ -96,7 +86,7 @@ namespace Mono.Net.Security.Private
                        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)
@@ -104,7 +94,7 @@ namespace Mono.Net.Security.Private
                        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)
@@ -112,7 +102,7 @@ namespace Mono.Net.Security.Private
                        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)
@@ -120,7 +110,7 @@ namespace Mono.Net.Security.Private
                        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)
@@ -128,7 +118,7 @@ namespace Mono.Net.Security.Private
                        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);
                }
 
        }
index 9a5eab25ce6f4aee6f104fb0eb41ef4479c53c2c..5d2812d2738e4c51c72af55564a3e3c95356e0c4 100644 (file)
@@ -34,9 +34,6 @@
 #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;
@@ -47,13 +44,8 @@ using 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;
@@ -257,7 +249,7 @@ namespace Mono.Net.Security
                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;
@@ -326,9 +318,9 @@ namespace Mono.Net.Security
                        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);
@@ -363,7 +355,7 @@ namespace Mono.Net.Security
 
                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;
index 50193cc2ec19c6461764e14b83677de04c00ad1f..69daf52111386fec045981afd515d03864d37d0c 100644 (file)
 // 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
index 478ed585b59c2956d8c6d0aa0fd2c115cb3405f0..50b4cd9c8c460de1aee7dd57382fe1eb0b204326 100644 (file)
 #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;
index ab0bc51897425ca78a33ef4061ab0ffb0d78b5ad..1a6672f6c5c36f634b575715a611d14148e86c0a 100644 (file)
@@ -34,9 +34,6 @@
 
 #if SECURITY_DEP
 
-#if MONO_X509_ALIAS
-extern alias PrebuiltSystem;
-#endif
 #if MONO_SECURITY_ALIAS
 extern alias MonoSecurity;
 #endif
@@ -56,9 +53,6 @@ using MonoSecurityProtocolType = Mono.Security.Protocol.Tls.SecurityProtocolType
 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;
index d6f6e5296f454a65ac7ca9f27b6d3e001087e539..7ea40e1940172a2d422936d04fe51d0431956a69 100644 (file)
 // 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;
index dfb5c8c450ac60d1be017d770bff0d34748956da..776751537bdae8df69c5134c20ade5c097c65eb5 100644 (file)
@@ -26,9 +26,6 @@
 
 #if SECURITY_DEP
 
-#if MONO_X509_ALIAS
-extern alias PrebuiltSystem;
-#endif
 #if MONO_SECURITY_ALIAS
 extern alias MonoSecurity;
 #endif
@@ -38,27 +35,6 @@ 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;
-
-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;
@@ -96,9 +72,9 @@ namespace Mono.Net.Security.Private
                        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)
@@ -106,9 +82,9 @@ namespace Mono.Net.Security.Private
                        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)
@@ -121,9 +97,9 @@ namespace Mono.Net.Security.Private
                        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)
@@ -131,9 +107,9 @@ namespace Mono.Net.Security.Private
                        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)
@@ -146,9 +122,9 @@ namespace Mono.Net.Security.Private
                        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)
@@ -156,9 +132,9 @@ namespace Mono.Net.Security.Private
                        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 ()
@@ -201,8 +177,8 @@ namespace Mono.Net.Security.Private
                        Impl.EndWrite (asyncResult);
                }
 
-               public XTransportContext TransportContext {
-                       get { return (XTransportContext)(object)Impl.TransportContext; }
+               public TransportContext TransportContext {
+                       get { return Impl.TransportContext; }
                }
 
                public bool IsAuthenticated {
@@ -225,24 +201,24 @@ namespace Mono.Net.Security.Private
                        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 {
@@ -274,8 +250,8 @@ namespace Mono.Net.Security.Private
                        Impl.SetLength (value);
                }
 
-               public XAuthenticatedStream AuthenticatedStream {
-                       get { return (XAuthenticatedStream)(Stream)Impl.AuthenticatedStream; }
+               public AuthenticatedStream AuthenticatedStream {
+                       get { return Impl.AuthenticatedStream; }
                }
 
                public int ReadTimeout {
@@ -304,8 +280,8 @@ namespace Mono.Net.Security.Private
                        get { return Impl.RemoteCertificate; }
                }
 
-               public XSslProtocols SslProtocol {
-                       get { return (XSslProtocols)Impl.SslProtocol; }
+               public SslProtocols SslProtocol {
+                       get { return Impl.SslProtocol; }
                }
 
                public MSI.MonoTlsProvider Provider {
index 92f88fe1e0559344bd8ad7bfa0c5d4ebb28c87af..0cf6d394bb7da92c8b500c4c13e2a17db3511f09 100644 (file)
@@ -26,9 +26,6 @@
 
 #if SECURITY_DEP
 
-#if MONO_X509_ALIAS
-extern alias PrebuiltSystem;
-#endif
 #if MONO_SECURITY_ALIAS
 extern alias MonoSecurity;
 #endif
@@ -38,17 +35,6 @@ using MSI = MonoSecurity::Mono.Security.Interface;
 #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;
@@ -84,9 +70,9 @@ namespace Mono.Net.Security.Private
                        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)
@@ -94,9 +80,9 @@ namespace Mono.Net.Security.Private
                        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)
@@ -111,7 +97,7 @@ namespace Mono.Net.Security.Private
 
                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)
@@ -121,7 +107,7 @@ namespace Mono.Net.Security.Private
 
                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)
@@ -134,9 +120,9 @@ namespace Mono.Net.Security.Private
                        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)
@@ -146,7 +132,7 @@ namespace Mono.Net.Security.Private
 
                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 ()
@@ -190,7 +176,7 @@ namespace Mono.Net.Security.Private
                }
 
                public TransportContext TransportContext {
-                       get { return (TransportContext)(object)Impl.TransportContext; }
+                       get { return Impl.TransportContext; }
                }
 
                public bool IsAuthenticated {
@@ -263,7 +249,7 @@ namespace Mono.Net.Security.Private
                }
 
                public AuthenticatedStream AuthenticatedStream {
-                       get { return (AuthenticatedStream)(object)Impl.AuthenticatedStream; }
+                       get { return Impl.AuthenticatedStream; }
                }
 
                public int ReadTimeout {
index 1a0c2bc584290d3356358948d9beb48938e93cb9..c4b17abcd0ee93d2c9f98af837dc3064598fd773 100644 (file)
@@ -69,7 +69,7 @@ namespace Mono.Net.Security
                                        return currentProvider;
 
                                try {
-                                       defaultProvider = CreateDefaultProvider ();
+                                       defaultProvider = GetDefaultProviderInternal ();
                                } catch (Exception ex) {
                                        throw new NotSupportedException ("TLS Support not available.", ex);
                                }
@@ -174,6 +174,8 @@ namespace Mono.Net.Security
                                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 ();
                        }
                }
 
index b0ae5d82c724627ca2360a856b159af606f23104..94f86ca7e747ce244abda4cc8846ce821256270b 100644 (file)
@@ -26,9 +26,6 @@
 
 #if SECURITY_DEP
 
-#if MONO_X509_ALIAS
-extern alias PrebuiltSystem;
-#endif
 #if MONO_SECURITY_ALIAS
 extern alias MonoSecurity;
 #endif
@@ -38,13 +35,6 @@ using MSI = MonoSecurity::Mono.Security.Interface;
 #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;
@@ -84,13 +74,13 @@ namespace Mono.Net.Security.Private
 
                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);
                }
 
@@ -102,13 +92,13 @@ namespace Mono.Net.Security.Private
 
                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);
                }
index e2ec0f5a01318b9fefbdfafab0df60f45450c8a3..15283200590899b85f606eb3a2acfc9a08c6a9bb 100644 (file)
@@ -26,9 +26,6 @@
 
 #if SECURITY_DEP
 
-#if MONO_X509_ALIAS
-extern alias PrebuiltSystem;
-#endif
 #if MONO_SECURITY_ALIAS
 extern alias MonoSecurity;
 #endif
@@ -38,13 +35,6 @@ using MSI = MonoSecurity::Mono.Security.Interface;
 #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;
@@ -86,13 +76,13 @@ namespace Mono.Net.Security.Private
 
                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);
                }
index 96f5933dfb7ba0608ad4f5827671eb23bb390d37..58479df9fba6942c75eff0c548ec913f95f84cc0 100644 (file)
 #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;
@@ -104,7 +97,7 @@ namespace Mono.Net.Security
 
                        try {
                                sslStream.AuthenticateAsClient (
-                                       request.Address.Host, (XX509CertificateCollection)(object)request.ClientCertificates,
+                                       request.Address.Host, request.ClientCertificates,
                                        (SslProtocols)ServicePointManager.SecurityProtocol,
                                        ServicePointManager.CheckCertificateRevocationList);
 
index 8cd1ca0b6fac8de068150a1b0e18f3342ce8a7c0..55969818a8b5d4299725c0e5f81129020d1f9366 100644 (file)
@@ -3,9 +3,6 @@
 #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;
@@ -16,13 +13,8 @@ using 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;
index 629617f60312967c794b5f3a526de8eed72ed531..a0cb8d5019380a67cb9c638fcb083bcdf085cf87 100644 (file)
@@ -28,9 +28,6 @@
 #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;
@@ -39,11 +36,6 @@ using MonoSecurity::Mono.Security.Interface;
 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;
@@ -73,7 +65,7 @@ namespace System.Net.Security
 
        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)
                {
@@ -226,7 +218,7 @@ namespace System.Net.Security
 
                internal static X509Certificate2 GetRemoteCertificate (SafeDeleteContext safeContext, out X509Certificate2Collection remoteCertificateStore)
                {
-                       XX509CertificateCollection monoCollection;
+                       X509CertificateCollection monoCollection;
                        if (safeContext == null || safeContext.IsInvalid) {
                                remoteCertificateStore = null;
                                return null;
index 2e739291d3412dce486ffaa9063cfa6711afdfd4..2abea7293f9ecff95358518babcdca29382258f9 100644 (file)
@@ -29,9 +29,6 @@
 //
 
 #if CONFIGURATION_DEP
-extern alias PrebuiltSystem;
-using TypeDescriptor = PrebuiltSystem.System.ComponentModel.TypeDescriptor;
-
 using System;
 using System.Collections.Generic;
 using System.ComponentModel;
index 57aa6b19880683f76b923e984e4d92e4fc3d81eb..7a0bd6ef5dff7a556ba5159e668a4887b9b1acb6 100644 (file)
 // 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;
 
index 58ebcd7a5f73ee56af0dc156aee11fcd6c1df9f1..6b12f95425b8433a45d4def40764bc34067ccb2d 100644 (file)
 // 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;
index 968532966e3d13de35882a06802f6fbbe507413c..9b2f8e9986b8768ff7ae95a95620bbb19cb9d7a1 100644 (file)
 // 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;
index 31d56ce09eb38acf77a1e3a2a9ab1466b66b1266..d74a226f1e77042ed2668b56212b96a03e6a22b8 100644 (file)
 
 #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;
@@ -42,8 +41,6 @@ using System.Security.Cryptography;
 using System.Text;
 using System.Xml;
 
-using NameValueCollection = PrebuiltSystem.System.Collections.Specialized.NameValueCollection;
-
 namespace System.Configuration
 {
        // location to store user configuration settings.
index d0ca5ab0a48b838a95eb18378f4e3209b4f89859..10664ca266bc2aef89b312b67d4e00fb82edb00e 100644 (file)
 //
 
 #if CONFIGURATION_DEP
-#if CONFIGURATION_DEP
-extern alias PrebuiltSystem;
-using NameValueCollection = PrebuiltSystem.System.Collections.Specialized.NameValueCollection;
-#endif
 
 using System;
 using System.Collections.Specialized;
index 41cf0d8c8c455930dfc4e5c8bbd84c9fa5308d74..6e929543aed5fec2f03a7c7dde270c307a54b91d 100644 (file)
@@ -74,7 +74,7 @@ namespace System.Diagnostics
 
                /* Private constructor called from other methods */
                private Process (SafeProcessHandle handle, int id) {
-                       m_processHandle = handle;
+                       SetProcessHandle (handle);
                        SetProcessId (id);
                }
 
@@ -606,13 +606,9 @@ namespace System.Diagnostics
                                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;
                }
 
@@ -771,8 +767,7 @@ namespace System.Diagnostics
                                }
                        }
 
-                       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) {
@@ -808,9 +803,6 @@ namespace System.Diagnostics
                                standardError = new StreamReader (new FileStream (stderr_read, FileAccess.Read, true, 8192), stderrEncoding, true);
                        }
 
-                       if (watchForExit)
-                               EnsureWatchingForExit ();
-
                        return true;
                }
 
index f17eb58d28dca262aeb2205bcaa41468a5183292..778671764ea91a8f8b9bcc563e60b0b68d9d0fdd 100644 (file)
@@ -300,11 +300,14 @@ namespace System.IO {
                        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;
@@ -614,14 +617,14 @@ namespace System.IO {
                                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);
                        }
                                
@@ -677,6 +680,9 @@ namespace System.IO {
                [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);
 
index 0e89b187d1a97a216d0677c1cfb612e88cfb97eb..ff881b00bcc9a6df8a457c16e23d134a2ebcef16 100644 (file)
 #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
 
index 5d0d9b75471a55d28cf32dbf9157559087bae2c9..9b77646d7b1502b669d501fcd04bd3e9197c687c 100644 (file)
 // 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;
 
index 652c91e143fc6d4e18463b192fcfae99c4f9d07b..9238428b1f3841de180dc5f09f3944336a9d82d1 100644 (file)
 // 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;
 
index 53e6d2918577369637da3f522ced844a316bb82a..59e741722b67b820861fb63af0005b004087397c 100644 (file)
@@ -27,9 +27,6 @@
 #if !MONO_FEATURE_NEW_TLS
 #if SECURITY_DEP
 
-#if MONO_X509_ALIAS
-extern alias PrebuiltSystem;
-#endif
 #if MONO_SECURITY_ALIAS
 extern alias MonoSecurity;
 #endif
@@ -39,13 +36,6 @@ using MonoSecurity::Mono.Security.Interface;
 #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;
@@ -80,7 +70,7 @@ namespace System.Net.Security
 
        internal delegate X509Certificate LocalCertSelectionCallback (
                string targetHost,
-               XX509CertificateCollection localCertificates,
+               X509CertificateCollection localCertificates,
                X509Certificate remoteCertificate,
                string[] acceptableIssuers);
 
@@ -146,9 +136,9 @@ namespace System.Net.Security
                        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)]
@@ -158,9 +148,9 @@ namespace System.Net.Security
                }
 
                // [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)
@@ -175,7 +165,7 @@ namespace System.Net.Security
 
                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)]
@@ -186,7 +176,7 @@ namespace System.Net.Security
 
                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)
@@ -206,9 +196,9 @@ namespace System.Net.Security
                        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)
@@ -218,7 +208,7 @@ namespace System.Net.Security
 
                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 {
index 885eaf3ea3df14566dcf0a32bf21e653d1314be9..b9940eb07d89585b683f2904aa1b0fb49aa84157 100644 (file)
 #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;
index 71eb71e31062c3b5704713a2573ef4caf2fda9c3..e0c3ed84318073bd271c8ffa07f2e9b7566554a9 100644 (file)
@@ -27,8 +27,6 @@
 //
 #if CONFIGURATION_DEP
 
-extern alias PrebuiltSystem;
-
 using System;
 using System.Collections;
 using System.Collections.Generic;
@@ -42,8 +40,6 @@ using System.Runtime.Serialization;
 using System.Text;
 using System.Xml;
 
-using TypeConverter = PrebuiltSystem::System.ComponentModel.TypeConverter;
-
 namespace System.Security.Authentication.ExtendedProtection.Configuration
 {
        internal static class ConfigUtil
index 184e586471dd30c167be16eca420d930c5c12bfb..695f5e822209a0964b0c604cdca50c421e48c52c 100644 (file)
 // 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;
@@ -101,16 +94,17 @@ namespace System.Security.Cryptography.X509Certificates {
                        }
                }
 
-               static IntPtr GetCertificate (X509Certificate certificate, out IntPtr dataPtr)
+               static IntPtr GetCertificate (X509Certificate certificate)
                {
-                       var handle = certificate.Handle;
+                       var handle = certificate.Impl.GetNativeAppleCertificate ();
                        if (handle != IntPtr.Zero) {
-                               dataPtr = IntPtr.Zero;
                                CFRetain (handle);
                                return handle;
                        }
-                       dataPtr = MakeCFData (certificate.GetRawCertData ());
-                       return SecCertificateCreateWithData (IntPtr.Zero, dataPtr);
+                       var dataPtr = MakeCFData (certificate.GetRawCertData ());
+                       handle = SecCertificateCreateWithData (IntPtr.Zero, dataPtr);
+                       CFRelease (dataPtr);
+                       return handle;
                }
                
                public static SecTrustResult TrustEvaluateSsl (XX509CertificateCollection certificates, XX509CertificateCollection anchors, string host)
@@ -129,9 +123,7 @@ namespace System.Security.Cryptography.X509Certificates {
                {
                        int certCount = certificates.Count;
                        int anchorCount = anchors != null ? anchors.Count : 0;
-                       IntPtr [] cfDataPtrs = new IntPtr [certCount];
                        IntPtr [] secCerts = new IntPtr [certCount];
-                       IntPtr [] cfDataAnchorPtrs = new IntPtr [anchorCount];
                        IntPtr [] secCertAnchors = new IntPtr [anchorCount];
                        IntPtr certArray = IntPtr.Zero;
                        IntPtr anchorArray = IntPtr.Zero;
@@ -142,13 +134,13 @@ namespace System.Security.Cryptography.X509Certificates {
 
                        try {
                                for (int i = 0; i < certCount; i++) {
-                                       secCerts [i] = GetCertificate (certificates [i], out cfDataPtrs [i]);
+                                       secCerts [i] = GetCertificate (certificates [i]);
                                        if (secCerts [i] == IntPtr.Zero)
                                                return SecTrustResult.Deny;
                                }
 
                                for (int i = 0; i < anchorCount; i++) {
-                                       secCertAnchors [i] = GetCertificate (anchors [i], out cfDataAnchorPtrs [i]);
+                                       secCertAnchors [i] = GetCertificate (anchors [i]);
                                        if (secCertAnchors [i] == IntPtr.Zero)
                                                return SecTrustResult.Deny;
                                }
@@ -170,14 +162,6 @@ namespace System.Security.Cryptography.X509Certificates {
                                code = SecTrustEvaluate (sectrust, out result);
                                return result;
                        } finally {
-                               for (int i = 0; i < certCount; i++)
-                                       if (cfDataPtrs [i] != IntPtr.Zero)
-                                               CFRelease (cfDataPtrs [i]);
-
-                               for (int i = 0; i < anchorCount; i++)
-                                       if (cfDataAnchorPtrs [i] != IntPtr.Zero)
-                                               CFRelease (cfDataAnchorPtrs [i]);
-
                                if (certArray != IntPtr.Zero)
                                        CFRelease (certArray);
 
index 87fd8a16d225230326f98043ae7f4d1de702a58a..bfb2696f97c99d3098801cd260bf07a6603c721b 100644 (file)
@@ -72,6 +72,11 @@ namespace System.Security.Cryptography.X509Certificates
                        get { return IntPtr.Zero; }
                }
 
+               public override IntPtr GetNativeAppleCertificate ()
+               {
+                       return IntPtr.Zero;
+               }
+
                internal X509Certificate2ImplMono (MX.X509Certificate cert)
                {
                        this._cert = cert;
index 544f67c1f4d5d52520afa18f336d3dbba126243c..2a9163a346f89ae143e7477b9215c67659f5e875 100644 (file)
 // 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);
@@ -37,13 +53,24 @@ namespace System.Security.Cryptography.X509Certificates
 
                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 ();
@@ -70,6 +97,20 @@ namespace System.Security.Cryptography.X509Certificates
                {
                        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
index 715c748d1f5fe0cb703014e012db8fce842f0993..0638cb720b3a57d67b0879d93f72fce0a3bda685 100644 (file)
@@ -17,7 +17,7 @@ namespace MonoTests.System.Net.WebSockets
        [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;
index 1252b936471eb76b900e31855df7d32f96ee64d2..bd99fb05241810f064a23fdfe7198f084576344d 100644 (file)
@@ -1,2 +1 @@
 *.g.cs
-generator.exe
diff --git a/mcs/class/corlib/CommonCrypto/CommonCryptorGenerator.cs b/mcs/class/corlib/CommonCrypto/CommonCryptorGenerator.cs
deleted file mode 100644 (file)
index f177c17..0000000
+++ /dev/null
@@ -1,104 +0,0 @@
-//
-// CommonCrypto code generator for symmetric block cipher algorithms
-//
-// Authors:
-//     Sebastien Pouliot  <sebastien@xamarin.com>
-//
-// Copyright 2012 Xamarin Inc.
-//
-
-using System;
-using System.IO;
-
-namespace Xamarin {
-
-       public static class CommonCryptor {
-               
-               static public void Generate (string namespaceName, string typeName, string baseTypeName, string ccAlgorithmName, string feedbackSize = "8", string ctorInitializers = null)
-               {
-                       string template = @"// Generated file to bind CommonCrypto cipher algorithms - DO NOT EDIT
-//
-// Authors:
-//     Sebastien Pouliot  <sebastien@xamarin.com>
-//
-// Copyright 2012-2014 Xamarin Inc.
-
-using System;
-using System.Security.Cryptography;
-
-using Mono.Security.Cryptography;
-using Crimson.CommonCrypto;
-
-namespace %NAMESPACE% {
-
-       public sealed partial class %TYPE% : %BASE% {
-               
-               public %TYPE% ()
-               {
-                       FeedbackSizeValue = %FEEDBACKSIZE%;
-                       %CTOR_INIT%
-               }
-               
-               public override void GenerateIV ()
-               {
-                       IVValue = KeyBuilder.IV (BlockSizeValue >> 3);
-               }
-               
-               public override void GenerateKey ()
-               {
-                       KeyValue = KeyBuilder.Key (KeySizeValue >> 3);
-               }
-               
-               public override ICryptoTransform CreateDecryptor (byte[] rgbKey, byte[] rgbIV) 
-               {
-                       IntPtr decryptor = IntPtr.Zero;
-                       switch (Mode) {
-                       case CipherMode.CBC:
-                               decryptor = Cryptor.Create (CCOperation.Decrypt, CCAlgorithm.%CCALGORITHM%, CCOptions.None, rgbKey, rgbIV);
-                               return new FastCryptorTransform (decryptor, this, false, rgbIV);
-                       case CipherMode.ECB:
-                               decryptor = Cryptor.Create (CCOperation.Decrypt, CCAlgorithm.%CCALGORITHM%, CCOptions.ECBMode, rgbKey, rgbIV);
-                               return new FastCryptorTransform (decryptor, this, false, rgbIV);
-                       case CipherMode.CFB:
-#if MONOTOUCH || XAMMAC
-                               IntPtr encryptor = Cryptor.Create (CCOperation.Encrypt, CCAlgorithm.%CCALGORITHM%, CCOptions.ECBMode, rgbKey, rgbIV);
-                               decryptor = Cryptor.Create (CCOperation.Decrypt, CCAlgorithm.%CCALGORITHM%, CCOptions.ECBMode, rgbKey, rgbIV);
-                               return new CryptorTransform (decryptor, encryptor, this, false, rgbIV);
-#else
-                               throw new CryptographicException (""CFB is not supported by Crimson.CommonCrypto"");
-#endif
-                       default:
-                               throw new CryptographicException (String.Format (""{0} is not supported by the .NET framework"", Mode));
-                       }
-               }
-               
-               public override ICryptoTransform CreateEncryptor (byte[] rgbKey, byte[] rgbIV) 
-               {
-                       IntPtr encryptor = IntPtr.Zero;
-                       switch (Mode) {
-                       case CipherMode.CBC:
-                               encryptor = Cryptor.Create (CCOperation.Encrypt, CCAlgorithm.%CCALGORITHM%, CCOptions.None, rgbKey, rgbIV);
-                               return new FastCryptorTransform (encryptor, this, true, rgbIV);
-                       case CipherMode.ECB:
-                               encryptor = Cryptor.Create (CCOperation.Encrypt, CCAlgorithm.%CCALGORITHM%, CCOptions.ECBMode, rgbKey, rgbIV);
-                               return new FastCryptorTransform (encryptor, this, true, rgbIV);
-                       case CipherMode.CFB:
-#if MONOTOUCH || XAMMAC
-                               encryptor = Cryptor.Create (CCOperation.Encrypt, CCAlgorithm.%CCALGORITHM%, CCOptions.ECBMode, rgbKey, rgbIV);
-                               return new CryptorTransform (encryptor, IntPtr.Zero, this, true, rgbIV);
-#else
-                               throw new CryptographicException (""CFB is not supported by Crimson.CommonCrypto"");
-#endif
-                       default:
-                               throw new CryptographicException (String.Format (""{0} is not supported by the .NET framework"", Mode));
-                       }
-               }
-       }
-}";
-                       
-                       File.WriteAllText (typeName + ".g.cs", template.Replace ("%NAMESPACE%", namespaceName).
-                               Replace ("%TYPE%", typeName).Replace ("%BASE%", baseTypeName).Replace("%FEEDBACKSIZE%", feedbackSize).Replace ("%CTOR_INIT%", ctorInitializers).
-                               Replace ("%CCALGORITHM%", ccAlgorithmName.ToString ()));
-               }
-       }
-}
diff --git a/mcs/class/corlib/CommonCrypto/CommonDigestGenerator.cs b/mcs/class/corlib/CommonCrypto/CommonDigestGenerator.cs
deleted file mode 100644 (file)
index 1b729e3..0000000
+++ /dev/null
@@ -1,167 +0,0 @@
-//
-// CommonCrypto code generator for digest algorithms
-//
-// Authors:
-//     Sebastien Pouliot  <sebastien@xamarin.com>
-//
-// Copyright 2012-2014 Xamarin Inc.
-//
-
-using System;
-using System.IO;
-
-namespace Xamarin {
-
-       public static class CommonDigest {
-               
-#if !MONOTOUCH && !XAMMAC
-               // we do not add anything in MonoTouch, just replacing, so this is not needed
-               // however we can avoid a dependency on Mono.Security for Crimson.CommonCrypto.dll by including the base classes
-               static public void GenerateBaseClass (string namespaceName, string typeName, string baseTypeName, int hashSize,
-                       string visibilityStart = "", string visibilityEnd = "")
-               {
-                       string template = @"// Generated file to bind CommonCrypto/CommonDigest - DO NOT EDIT
-//
-// Authors:
-//     Sebastien Pouliot  <sebastien@xamarin.com>
-//
-// Copyright 2012-2014 Xamarin Inc.
-
-using System;
-using System.Security.Cryptography;
-using System.Runtime.InteropServices;
-
-namespace %NAMESPACE% {
-
-%VISIBILITY_START%
-       public
-%VISIBILITY_END%
-       abstract class %BASE% : HashAlgorithm {
-
-               protected %BASE% () 
-               {
-                       HashSizeValue = %HASHSIZE%; 
-               }
-
-               public static new %BASE% Create ()
-               {
-                       return Create (""%BASE%"");
-               }
-
-               public static new %BASE% Create (string hashName)
-               {
-                       object o = CryptoConfig.CreateFromName (hashName);
-                       return (%BASE%) o ?? new %TYPE% ();
-               }
-       }
-}";
-                       
-                       File.WriteAllText (baseTypeName + ".g.cs", template.Replace ("%NAMESPACE%", namespaceName).
-                               Replace ("%TYPE%", typeName).Replace ("%BASE%", baseTypeName).
-                               Replace ("%VISIBILITY_START%", visibilityStart).Replace ("%VISIBILITY_END%", visibilityEnd).
-                               Replace ("%HASHSIZE%", hashSize.ToString ()));
-               }
-#endif
-               static public void Generate (string namespaceName, string typeName, string baseTypeName, int contextSize,
-                       string visibilityStart = "", string visibilityEnd = "")
-               {
-                       string template = @"// Generated file to bind CommonCrypto/CommonDigest - DO NOT EDIT
-//
-// Authors:
-//     Sebastien Pouliot  <sebastien@xamarin.com>
-//
-// Copyright 2011-2014 Xamarin Inc.
-
-using System;
-using System.Security.Cryptography;
-using System.Runtime.InteropServices;
-
-using Mono.Security.Cryptography;
-
-namespace %NAMESPACE% {
-
-%VISIBILITY_START%
-       public
-%VISIBILITY_END%
-       sealed class %TYPE% : %BASE% {
-
-               IntPtr ctx;
-
-               [DllImport (""/usr/lib/libSystem.dylib"", EntryPoint=""CC_%BASE%_Init"")]
-               static extern int Init (/* CC_%BASE%_CTX */ IntPtr c);
-
-               [DllImport (""/usr/lib/libSystem.dylib"", EntryPoint=""CC_%BASE%_Update"")]
-               static extern int Update (/* CC_%BASE%_CTX */ IntPtr c, /* const void * */ IntPtr data, /* uint32_t */ uint len);
-
-               [DllImport (""/usr/lib/libSystem.dylib"", EntryPoint=""CC_%BASE%_Final"")]
-               static extern int Final (/* unsigned char * */ byte [] md, /* CC_%BASE%_CTX */ IntPtr c);
-
-               public %TYPE% ()
-               {
-                       ctx = IntPtr.Zero;
-               }
-
-               ~%TYPE% ()
-               {
-                       Dispose (false);
-               }
-
-               protected override void Dispose (bool disposing)
-               {
-                       if (ctx != IntPtr.Zero) {
-                               Marshal.FreeHGlobal (ctx);
-                               ctx = IntPtr.Zero;
-                       }
-                       base.Dispose (disposing);
-                       GC.SuppressFinalize (this);
-               }
-
-               public override void Initialize ()
-               {
-                       if (ctx == IntPtr.Zero)
-                               ctx = Marshal.AllocHGlobal (%CTX_SIZE%);
-                       
-                       int hr = Init (ctx);
-                       if (hr != 1)
-                               throw new CryptographicException (hr);
-               }
-
-               protected override void HashCore (byte[] data, int start, int length) 
-               {
-                       if (ctx == IntPtr.Zero)
-                               Initialize ();
-
-                       if (data.Length == 0)
-                               return;
-
-                       unsafe {
-                               fixed (byte* p = &data [0]) {
-                                       int hr = Update (ctx, (IntPtr) (p + start), (uint) length);
-                                       if (hr != 1)
-                                               throw new CryptographicException (hr);
-                               }
-                       }
-               }
-
-               protected override byte[] HashFinal () 
-               {
-                       if (ctx == IntPtr.Zero)
-                               Initialize ();
-                       
-                       byte[] data = new byte [HashSize >> 3];
-                       int hr = Final (data, ctx);
-                       if (hr != 1)
-                               throw new CryptographicException (hr);
-
-                       return data;
-               }
-       }
-}";
-                       
-                       File.WriteAllText (typeName + ".g.cs", template.Replace ("%NAMESPACE%", namespaceName).
-                               Replace ("%TYPE%", typeName).Replace ("%BASE%", baseTypeName).
-                               Replace ("%VISIBILITY_START%", visibilityStart).Replace ("%VISIBILITY_END%", visibilityEnd).
-                               Replace ("%CTX_SIZE%", contextSize.ToString ()));
-               }
-       }
-}
diff --git a/mcs/class/corlib/CommonCrypto/Makefile b/mcs/class/corlib/CommonCrypto/Makefile
new file mode 100644 (file)
index 0000000..36ea8d3
--- /dev/null
@@ -0,0 +1,8 @@
+thisdir = class/corlib/CommonCrypto
+SUBDIRS =
+include ../../../build/rules.make
+
+.NOTPARALLEL:
+all:
+       MONO_PATH="$(topdir)/class/lib/$(BUILD_TOOLS_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(RUNTIME) $(RUNTIME_FLAGS) $(topdir)/class/lib/$(BUILD_TOOLS_PROFILE)/commoncryptogenerator.exe
+
diff --git a/mcs/class/corlib/CommonCrypto/Makefile.include b/mcs/class/corlib/CommonCrypto/Makefile.include
deleted file mode 100644 (file)
index 25e1379..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-CommonCrypto/%.g.cs: CommonCrypto/generator.exe
-       cd CommonCrypto && mono --debug generator.exe
-
-CommonCrypto/generator.exe: CommonCrypto/generator.cs CommonCrypto/CommonDigestGenerator.cs CommonCrypto/CommonCryptorGenerator.cs
-       mcs CommonCrypto/generator.cs CommonCrypto/CommonDigestGenerator.cs CommonCrypto/CommonCryptorGenerator.cs -o $@
diff --git a/mcs/class/corlib/CommonCrypto/generator.cs b/mcs/class/corlib/CommonCrypto/generator.cs
deleted file mode 100644 (file)
index a7d13c8..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-//
-// CommonCrypto Code Generator
-//
-// Authors:
-//     Sebastien Pouliot  <sebastien@xamarin.com>
-//
-// Copyright 2012 Xamarin Inc.
-//
-
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Text;
-
-namespace Xamarin {
-       
-       class Program {
-               static void Main (string [] args)
-               {
-                       // mscorlib replacements
-                       CommonDigest.Generate ("System.Security.Cryptography", "MD5CryptoServiceProvider", "MD5", 1000);
-                       CommonDigest.Generate ("System.Security.Cryptography", "SHA1CryptoServiceProvider", "SHA1", 1000);
-                       CommonDigest.Generate ("System.Security.Cryptography", "SHA1Managed", "SHA1", 1000);
-                       CommonDigest.Generate ("System.Security.Cryptography", "SHA256Managed", "SHA256", 1000);
-                       CommonDigest.Generate ("System.Security.Cryptography", "SHA384Managed", "SHA384", 1000);
-                       CommonDigest.Generate ("System.Security.Cryptography", "SHA512Managed", "SHA512", 1000);
-                       
-                       // System.Core replacements - not yet in MT profile (4.0 - functional dupes anyway)
-                       //CommonDigest.Generate ("System.Security.Cryptography", "MD5Cng", "MD5", 1000);
-                       //CommonDigest.Generate ("System.Security.Cryptography", "SHA256Cng", "SHA256", 1000);
-                       //CommonDigest.Generate ("System.Security.Cryptography", "SHA384Cng", "SHA384", 1000);
-                       //CommonDigest.Generate ("System.Security.Cryptography", "SHA512Cng", "SHA512", 1000);
-                       //CommonDigest.Generate ("System.Security.Cryptography", "SHA256CryptoServiceProvider", "SHA256", 1000);
-                       //CommonDigest.Generate ("System.Security.Cryptography", "SHA384CryptoServiceProvider", "SHA384", 1000);
-                       //CommonDigest.Generate ("System.Security.Cryptography", "SHA512CryptoServiceProvider", "SHA512", 1000);
-                       
-                       // Mono.Security replacements
-                       CommonDigest.Generate ("Mono.Security.Cryptography", "MD2Managed", "MD2", 1000, "#if !INSIDE_CORLIB", "#endif");
-                       CommonDigest.Generate ("Mono.Security.Cryptography", "MD4Managed", "MD4", 1000, "#if !INSIDE_CORLIB", "#endif");
-                       CommonDigest.Generate ("Mono.Security.Cryptography", "SHA224Managed", "SHA224", 1000);
-
-                       // mscorlib replacements
-                       CommonCryptor.Generate ("System.Security.Cryptography", "DESCryptoServiceProvider", "DES", "DES");
-                       CommonCryptor.Generate ("System.Security.Cryptography", "TripleDESCryptoServiceProvider", "TripleDES", "TripleDES");
-                       CommonCryptor.Generate ("System.Security.Cryptography", "RC2CryptoServiceProvider", "RC2", "RC2", ctorInitializers: "LegalKeySizesValue = new[] { new KeySizes(40, 128, 8) };");
-                       // Rijndael supports block sizes that are not available in AES - as such it does not use the same generated code
-                       // but has it's own version, using AES (128 bits block size) and falling back to managed (192/256 bits block size)
-
-                       // System.Core replacements
-                       CommonCryptor.Generate ("System.Security.Cryptography", "AesManaged", "Aes", "AES128", "128");
-                       CommonCryptor.Generate ("System.Security.Cryptography", "AesCryptoServiceProvider", "Aes", "AES128");
-
-                       // Mono.Security replacements
-                       // RC4 is a stream (not a block) cipher so it can not reuse the generated code
-               }
-       }
-}
\ No newline at end of file
index 95b3bc8d33703c3e3ba1bee382763bebd35f5267..3203a94e3ccab1edf51f14726503d3457264ed51 100644 (file)
@@ -1,7 +1,6 @@
 thisdir = class/corlib
 SUBDIRS =
 include ../../build/rules.make
-include CommonCrypto/Makefile.include
 export __SECURITY_BOOTSTRAP_DB=$(topdir)/class/corlib
 
 LIBRARY = corlib.dll
@@ -71,6 +70,30 @@ endif
 TEST_MCS_FLAGS += -debug -nowarn:168,219,618,672 -unsafe \
                                 -define:MONO_DATACONVERTER_STATIC_METHODS $(TEST_RESX_RESOURCES:%=-resource:%)
 
+
+CC_PROFILE := $(filter monotouch% xammac, $(PROFILE))
+ifdef CC_PROFILE
+
+BUILT_SOURCES = \
+       CommonCrypto/AesCryptoServiceProvider.g.cs \
+       CommonCrypto/MD5CryptoServiceProvider.g.cs      \
+       CommonCrypto/SHA256Managed.g.cs \
+       CommonCrypto/AesManaged.g.cs \
+       CommonCrypto/RC2CryptoServiceProvider.g.cs \
+       CommonCrypto/SHA384Managed.g.cs \
+       CommonCrypto/DESCryptoServiceProvider.g.cs \
+       CommonCrypto/SHA1CryptoServiceProvider.g.cs     \
+       CommonCrypto/SHA512Managed.g.cs \
+       CommonCrypto/MD2Managed.g.cs \
+       CommonCrypto/SHA1Managed.g.cs \
+       CommonCrypto/TripleDESCryptoServiceProvider.g.cs \
+       CommonCrypto/MD4Managed.g.cs
+
+CommonCrypto/%.g.cs:
+       $(MAKE) -C CommonCrypto
+
+endif
+
 EXTRA_DISTFILES = \
        Test/resources/MyResources.resources    \
        Test/resources/MyResources.de.resources \
@@ -166,9 +189,6 @@ EXTRA_DISTFILES += \
        $(vtsdir)/VersionTolerantSerializationTestLib/6.0/Address.cs \
        $(vtsdir)/BinarySerializationOverVersions.cs
 
-EXTRA_DISTFILES += \
-       CommonCrypto/Makefile.include
-
 #
 # Android TimeZoneInfo testing....
 #
index 3bf9995ecdbac6ba7142d72d8da834c04d2cdada..e9e0a07ebb62df9fb45addb95e9726bfdcfcc091 100644 (file)
 // 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 {
                
@@ -76,11 +81,8 @@ namespace System.Diagnostics {
                                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);
index f263eeb1cc9c5673811165cf436fbfb7693285ff..3c7e87a6b7ac78ad8fbe13e42343fb67337d0698 100644 (file)
@@ -96,7 +96,7 @@ namespace System.IO
                                 info.Parent.Create ();
 
                        MonoIOError error;
-                       if (!MonoIO.CreateDirectory (path, out error)) {
+                       if (!MonoIO.CreateDirectory (info.FullName, out error)) {
                                // LAMESPEC: 1.1 and 1.2alpha allow CreateDirectory on a file path.
                                // So CreateDirectory ("/tmp/somefile") will succeed if 'somefile' is
                                // not a directory. However, 1.0 will throw an exception.
index 8289c288c20ffe228d3133c28a4c4569bf05b9d1..4f74c12bf8309441d336ed37bed907003651547f 100644 (file)
@@ -62,7 +62,7 @@ namespace System.IO {
 
                        FullPath = Path.GetFullPath (path);
                        if (simpleOriginalPath)
-                               OriginalPath = Path.GetFileName (path);
+                               OriginalPath = Path.GetFileName (FullPath);
                        else
                                OriginalPath = path;
 
index 9ac0e97545427ada48cdaaadfddd1f60b0eef086..f053d51225e6e8a1db5babe82cd6507e70394c01 100644 (file)
@@ -488,7 +488,7 @@ namespace System.IO {
                                        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)
index 4d8b2ee34ba918eaaca8660fbcd515c1b552b850..b7ce6e0410a767355c9db8fcf9c9f0387ffd5f50 100644 (file)
@@ -40,120 +40,21 @@ using System.Text;
 
 namespace System.Reflection.Emit
 {
-       internal enum TypeKind : int {
-               SZARRAY = 0x1d,
-               ARRAY = 0x14
-       }
-
        [StructLayout (LayoutKind.Sequential)]
-       internal abstract class DerivedType : Type
+       abstract partial class SymbolType
        {
-               internal Type elementType;
+               internal Type m_baseType;
 
                [MethodImplAttribute(MethodImplOptions.InternalCall)]
-               internal static extern void create_unmanaged_type (Type type);
+               static extern void create_unmanaged_type (Type type);
 
-               internal DerivedType (Type elementType)
+               internal SymbolType (Type elementType)
                {
-                       this.elementType = elementType;
+                       this.m_baseType = elementType;
                }
 
                internal abstract String FormatName (string elementName);
 
-               public override Type GetInterface (string name, bool ignoreCase)
-               {
-                       throw new NotSupportedException ();
-               }
-
-               public override Type[] GetInterfaces ()
-               {
-                       throw new NotSupportedException ();
-               }
-
-               public override Type GetElementType ()
-               {
-                       return elementType;
-               }
-
-               public override EventInfo GetEvent (string name, BindingFlags bindingAttr)
-               {
-                       throw new NotSupportedException ();
-               }
-
-               public override EventInfo[] GetEvents (BindingFlags bindingAttr)
-               {
-                       throw new NotSupportedException ();
-               }
-
-               public override FieldInfo GetField( string name, BindingFlags bindingAttr)
-               {
-                       throw new NotSupportedException ();
-               }
-
-               public override FieldInfo[] GetFields (BindingFlags bindingAttr)
-               {
-                       throw new NotSupportedException ();
-               }
-
-               public override MemberInfo[] GetMembers (BindingFlags bindingAttr)
-               {
-                       throw new NotSupportedException ();
-               }
-
-               protected override MethodInfo GetMethodImpl (string name, BindingFlags bindingAttr, Binder binder,
-                                                            CallingConventions callConvention, Type[] types,
-                                                            ParameterModifier[] modifiers)
-               {
-                       throw new NotSupportedException ();
-               }
-
-               public override MethodInfo[] GetMethods (BindingFlags bindingAttr)
-               {
-                       throw new NotSupportedException ();
-               }
-
-               public override Type GetNestedType (string name, BindingFlags bindingAttr)
-               {
-                       throw new NotSupportedException ();
-               }
-
-               public override Type[] GetNestedTypes (BindingFlags bindingAttr)
-               {
-                       throw new NotSupportedException ();
-               }
-
-               public override PropertyInfo[] GetProperties (BindingFlags bindingAttr)
-               {
-                       throw new NotSupportedException ();
-               }
-
-               protected override PropertyInfo GetPropertyImpl (string name, BindingFlags bindingAttr, Binder binder,
-                                                                Type returnType, Type[] types, ParameterModifier[] modifiers)
-               {
-                       throw new NotSupportedException ();
-               }
-
-               protected override ConstructorInfo GetConstructorImpl (BindingFlags bindingAttr,
-                                                                      Binder binder,
-                                                                      CallingConventions callConvention,
-                                                                      Type[] types,
-                                                                      ParameterModifier[] modifiers)
-               {
-                       throw new NotSupportedException ();
-               }
-
-
-               protected override TypeAttributes GetAttributeFlagsImpl ()
-               {
-                       /*LAMEIMPL MS just return the elementType.Attributes*/
-                       return elementType.Attributes; 
-               }
-
-               protected override bool HasElementTypeImpl ()
-               {
-                       return true;
-               }
-
                protected override bool IsArrayImpl ()
                {
                        return false;
@@ -164,60 +65,11 @@ namespace System.Reflection.Emit
                        return false;
                }
 
-               protected override bool IsCOMObjectImpl ()
-               {
-                       return false;
-               }
-
                protected override bool IsPointerImpl ()
                {
                        return false;
                }
 
-               protected override bool IsPrimitiveImpl ()
-               {
-                       return false;
-               }
-
-
-               public override ConstructorInfo[] GetConstructors (BindingFlags bindingAttr)
-               {
-                       throw new NotSupportedException ();
-               }
-
-               public override object InvokeMember (string name, BindingFlags invokeAttr,
-                                                    Binder binder, object target, object[] args,
-                                                    ParameterModifier[] modifiers,
-                                                    CultureInfo culture, string[] namedParameters)
-               {
-                       throw new NotSupportedException ();
-               }
-
-               public override InterfaceMapping GetInterfaceMap (Type interfaceType)
-               {
-                       throw new NotSupportedException ();
-               }
-
-               public override bool IsInstanceOfType (object o)
-               {
-                       return false;
-               }
-
-               public override bool IsAssignableFrom (Type c)
-               {
-                       return false;
-               }
-
-               public override bool ContainsGenericParameters {
-                       get { return elementType.ContainsGenericParameters; }
-               }
-
-               //FIXME this should be handled by System.Type
-               public override Type MakeGenericType (params Type[] typeArguments)
-               {
-                       throw new NotSupportedException ();
-               }
-
                public override Type MakeArrayType ()
                {
                        return new ArrayType (this, 0);
@@ -242,59 +94,31 @@ namespace System.Reflection.Emit
 
                public override string ToString ()
                {
-                       return FormatName (elementType.ToString ());
-               }
-
-               public override GenericParameterAttributes GenericParameterAttributes {
-                       get { throw new NotSupportedException (); }
-               }
-
-               public override StructLayoutAttribute StructLayoutAttribute {
-                       get { throw new NotSupportedException (); }
-               }
-
-               public override Assembly Assembly {
-                       get { return elementType.Assembly; }
+                       return FormatName (m_baseType.ToString ());
                }
 
                public override string AssemblyQualifiedName {
                        get {
-                               string fullName = FormatName (elementType.FullName);
+                               string fullName = FormatName (m_baseType.FullName);
                                if (fullName == null)
                                        return null;
-                               return fullName + ", " + elementType.Assembly.FullName;
+                               return fullName + ", " + m_baseType.Assembly.FullName;
                        }
                }
 
 
                public override string FullName {
                        get {
-                               return FormatName (elementType.FullName);
+                               return FormatName (m_baseType.FullName);
                        }
                }
 
                public override string Name {
                        get {
-                               return FormatName (elementType.Name);
+                               return FormatName (m_baseType.Name);
                        }
                }
-
-               public override Guid GUID {
-                       get { throw new NotSupportedException (); }
-               }
-
-               public override Module Module {
-                       get { return elementType.Module; }
-               }
        
-               public override string Namespace {
-                       get { return elementType.Namespace; }
-               }
-
-               public override RuntimeTypeHandle TypeHandle {
-                       get { throw new NotSupportedException (); }
-               }
-
                public override Type UnderlyingSystemType {
                        get {
                                create_unmanaged_type (this);
@@ -302,31 +126,15 @@ namespace System.Reflection.Emit
                        }
                }
 
-               //MemberInfo
-               public override bool IsDefined (Type attributeType, bool inherit)
-               {
-                       throw new NotSupportedException ();
-               }
-
-               public override object [] GetCustomAttributes (bool inherit)
-               {
-                       throw new NotSupportedException ();
-               }
-
-               public override object [] GetCustomAttributes (Type attributeType, bool inherit)
-               {
-                       throw new NotSupportedException ();
-               }
-
                internal override bool IsUserType {
                        get {
-                               return elementType.IsUserType;
+                               return m_baseType.IsUserType;
                        }
                }
        }
 
        [StructLayout (LayoutKind.Sequential)]
-       internal class ArrayType : DerivedType
+       internal class ArrayType : SymbolType
        {
                int rank;
 
@@ -342,7 +150,7 @@ namespace System.Reflection.Emit
 
                internal override Type InternalResolve ()
                {
-                       Type et = elementType.InternalResolve (); 
+                       Type et = m_baseType.InternalResolve (); 
                        if (rank == 0)
                                return et.MakeArrayType ();                     
                        return et.MakeArrayType (rank);
@@ -358,15 +166,6 @@ namespace System.Reflection.Emit
                        return (rank == 0) ? 1 : rank;
                }
 
-               public override Type BaseType {
-                       get { return typeof (System.Array); }
-               }
-
-               protected override TypeAttributes GetAttributeFlagsImpl ()
-               {
-                       return elementType.Attributes;
-               }
-
                internal override String FormatName (string elementName)
                {
                        if (elementName == null)
@@ -383,7 +182,7 @@ namespace System.Reflection.Emit
        }
 
        [StructLayout (LayoutKind.Sequential)]
-       internal class ByRefType : DerivedType
+       internal class ByRefType : SymbolType
        {
                internal ByRefType (Type elementType) : base (elementType)
                {
@@ -391,7 +190,7 @@ namespace System.Reflection.Emit
 
                internal override Type InternalResolve ()
                {
-                       return elementType.InternalResolve ().MakeByRefType (); 
+                       return m_baseType.InternalResolve ().MakeByRefType (); 
                }
 
                protected override bool IsByRefImpl ()
@@ -399,10 +198,6 @@ namespace System.Reflection.Emit
                        return true;
                }
 
-               public override Type BaseType {
-                       get { return typeof (Array); }
-               }
-
                internal override String FormatName (string elementName)
                {
                        if (elementName == null)
@@ -432,7 +227,7 @@ namespace System.Reflection.Emit
        }
 
        [StructLayout (LayoutKind.Sequential)]
-       internal class PointerType : DerivedType
+       internal class PointerType : SymbolType
        {
                internal PointerType (Type elementType) : base (elementType)
                {
@@ -440,7 +235,7 @@ namespace System.Reflection.Emit
 
                internal override Type InternalResolve ()
                {
-                       return elementType.InternalResolve ().MakePointerType (); 
+                       return m_baseType.InternalResolve ().MakePointerType (); 
                }
 
                protected override bool IsPointerImpl ()
@@ -448,10 +243,6 @@ namespace System.Reflection.Emit
                        return true;
                }
 
-               public override Type BaseType {
-                       get { return typeof(Array); }
-               }
-
                internal override String FormatName (string elementName)
                {
                        if (elementName == null)
index 544774d1786061abd71dcd490fc36a4c8e4dbf4b..1c0e73c485f4aee2d3f7e35a2b67a4d6737f5d0f 100644 (file)
@@ -751,5 +751,20 @@ namespace System.Reflection {
                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; }
+               }
        }
 }
index 8bed0815d260a9d15a98da78b35cdbbe2a62f6ba..24f15e3f980437e7877e372bf84a63afb6220ffb 100644 (file)
@@ -412,7 +412,7 @@ namespace System.Runtime.InteropServices
                        var errorInfo = new ManagedErrorInfo(e);
                        SetErrorInfo (0, errorInfo);
 
-                       return e.hresult;
+                       return e._HResult;
 #else                  
                        return -1;
 #endif
@@ -1591,7 +1591,7 @@ namespace System.Runtime.InteropServices
                                }
                        }
 
-                       if (info is ManagedErrorInfo && ((ManagedErrorInfo) info).Exception.hresult == errorCode) {
+                       if (info is ManagedErrorInfo && ((ManagedErrorInfo) info).Exception._HResult == errorCode) {
                                return ((ManagedErrorInfo) info).Exception;
                        }
 
diff --git a/mcs/class/corlib/System.Security.Cryptography.X509Certificates/INativeCertificateHelper.cs b/mcs/class/corlib/System.Security.Cryptography.X509Certificates/INativeCertificateHelper.cs
new file mode 100644 (file)
index 0000000..2d56ac1
--- /dev/null
@@ -0,0 +1,35 @@
+//
+// 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);
+       }
+}
index 3ff0a2adeada877f4a4a3cf241de95b182e76217..135b270e508bb123f5f1226ee18710b2942347ca 100644 (file)
@@ -122,9 +122,7 @@ namespace System.Security.Cryptography.X509Certificates {
                        if (cert == null)
                                throw new ArgumentNullException ("cert");
 
-                       X509Helper.ThrowIfContextInvalid (cert.impl);
-
-                       impl = X509Helper.InitFromCertificate (cert.impl);
+                       impl = X509Helper.InitFromCertificate (cert);
                        hideDates = false;
                }
 
index 7178bedaa547e5ace0afd2186a5cae5d30d5483e..548bc5d93c08ec546441419ce1a0499805b2da5b 100644 (file)
@@ -37,6 +37,11 @@ namespace System.Security.Cryptography.X509Certificates
                        get;
                }
 
+               /*
+                * This is used in System.dll's OSX509Certificates.cs
+                */
+               public abstract IntPtr GetNativeAppleCertificate ();
+
                protected void ThrowIfContextInvalid ()
                {
                        if (!IsValid)
index c1fbac195286e29110b1bbcbfd844d91a4b8be99..718aadc3f374ab1ba539160635b4c594da13b2ab 100644 (file)
@@ -26,6 +26,12 @@ namespace System.Security.Cryptography.X509Certificates
                        get { return handle; }
                }
 
+               public override IntPtr GetNativeAppleCertificate ()
+               {
+                       ThrowIfContextInvalid ();
+                       return handle;
+               }
+
                public override X509CertificateImpl Clone ()
                {
                        ThrowIfContextInvalid ();
index 056bf561ee5a31a719907724b41b6e11cf4ef5ab..fa152e97f919844f8b46992853d506f795542347 100644 (file)
@@ -34,7 +34,7 @@ using MX = Mono.Security.X509;
 
 namespace System.Security.Cryptography.X509Certificates
 {
-       class X509CertificateImplMono : X509CertificateImpl
+       sealed class X509CertificateImplMono : X509CertificateImpl
        {
                MX.X509Certificate x509;
 
@@ -51,6 +51,11 @@ namespace System.Security.Cryptography.X509Certificates
                        get { return IntPtr.Zero; }
                }
 
+               public override IntPtr GetNativeAppleCertificate ()
+               {
+                       return IntPtr.Zero;
+               }
+
                public override X509CertificateImpl Clone ()
                {
                        ThrowIfContextInvalid ();
index dc73f5ad79d191f0497cfa62e20f0d15cf980e9d..1f3f1f83d1f9281914969e2139926fde093d3107 100644 (file)
@@ -30,6 +30,7 @@
 //
 using System;
 using System.Text;
+using System.Threading;
 using System.Runtime.InteropServices;
 #if !NET_2_1
 using System.Security.Permissions;
@@ -40,6 +41,14 @@ namespace System.Security.Cryptography.X509Certificates
 {
        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;
@@ -77,6 +86,14 @@ namespace System.Security.Cryptography.X509Certificates
                }
 #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);
@@ -134,6 +151,9 @@ namespace System.Security.Cryptography.X509Certificates
 #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 {
index 70a4dea80df5d68f1a7de17fc2dfde0121e99606..88a0a1baea92e501087f9f81a7c40bf428a3bef8 100644 (file)
@@ -57,7 +57,7 @@ namespace System {
                 * of icalls, do not require an increment.
                 */
 #pragma warning disable 169
-               private const int mono_corlib_version = 143;
+               private const int mono_corlib_version = 145;
 #pragma warning restore 169
 
                [ComVisible (true)]
@@ -985,6 +985,19 @@ namespace System {
                {
 
                }
+
+               // 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 );
+               }
        }
 }
 
diff --git a/mcs/class/corlib/System/Exception.cs b/mcs/class/corlib/System/Exception.cs
deleted file mode 100644 (file)
index 7b6b492..0000000
+++ /dev/null
@@ -1,336 +0,0 @@
-//
-// 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 "";
-               }
-       }
-}
index b17cfd62c55c5724bea9f608fbbb058f4382471f..8ef9dcf4680b0a486793b9eb69a4abc518cf75a1 100644 (file)
@@ -230,6 +230,17 @@ public class DirectoryTest
                }\r
        }\r
 \r
+       [Test]\r
+       public void CreateDirectoryRelativePath ()\r
+       {\r
+               var path = Path.Combine (TempFolder, "relativepath", "not_this_folder");\r
+               path = Path.Combine (path, "..");\r
+\r
+               var res = Directory.CreateDirectory (path);\r
+               Assert.AreEqual ("relativepath", res.ToString (), "#1");\r
+               Assert.IsTrue (Directory.Exists (Path.Combine (TempFolder, "relativepath")), "#2");\r
+       }\r
+\r
        [Test]\r
        public void Delete ()\r
        {\r
index fa37466a77ad7083c62be10b91be468b6d5b5bd9..122e5b65fc24e29f25e4fddb245904208ba8a4cf 100644 (file)
@@ -1586,6 +1586,7 @@ namespace MonoTests.System.Reflection.Emit
                        Assert.IsFalse (arr.IsGenericParameter, "#8");
                        Assert.IsFalse (arr.IsGenericType, "#9");
                        Assert.IsFalse (arr.IsGenericTypeDefinition, "#10");
+                       Assert.IsTrue (arr is TypeInfo, "#11");
                }
 
                [Test]
@@ -1664,6 +1665,7 @@ namespace MonoTests.System.Reflection.Emit
                        Assert.AreEqual ("F[]", arr.Name, "#21");
 
                        Assert.AreEqual (gparam, arr.GetElementType (), "#22");
+                       Assert.IsTrue (arr is TypeInfo, "#23");
                }
 
                [Test]
@@ -1718,6 +1720,7 @@ namespace MonoTests.System.Reflection.Emit
                        Assert.AreEqual ("enum[]", arr.Name, "#21");
 
                        Assert.AreEqual (eb, arr.GetElementType (), "#22");
+                       Assert.IsTrue (arr is TypeInfo, "#23");
                }
 
        }
index 11e81774310f6912bbf366272d4a7334cd2db67a..6cdc052f4fb97f8b2d630733e32e5a69a9b814bc 100644 (file)
@@ -39,7 +39,7 @@ namespace MonoTests.System.Security.Cryptography {
                public void Ctor () 
                {
                        var cp = new CspParameters ();
-                       Assert.AreEqual (24, cp.ProviderType);
+                       Assert.AreEqual (1, cp.ProviderType);
                }
        }
 }
index 2ed3b6003c7a440cbfb529a6dbd78b5002aa1ed2..ce1c9793fc57daeef63df5687cbea2c505ac916d 100644 (file)
@@ -103,7 +103,7 @@ namespace MonoTests.System.Threading {
                [Test] // bug #320950
                public void TestDispose2 ()
                {
-                       Timer t = new Timer (o => Callback (o), null, 10, 10);
+                       Timer t = new Timer (o => DoNothing (o), null, 10, 10);
                        t.Dispose ();
                        t.Dispose ();
                }
index 9a2b075df8837573163a5a1b72119eb1210281a2..fdca704f281fbf12cbce3fd54da84e1b067b445a 100644 (file)
@@ -100,7 +100,6 @@ System/DomainManagerInitializationFlags.cs
 System/EmptyArray.cs
 System/Environment.cs
 System/EnvironmentVariableTarget.cs
-System/Exception.cs
 System/GC.cs
 System/GCCollectionMode.cs
 System/GCNotificationStatus.cs
@@ -730,6 +729,7 @@ System.Security.Cryptography/RSAPKCS1SignatureDeformatter.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
@@ -973,6 +973,7 @@ ReferenceSources/SecurityContext.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
@@ -1258,6 +1259,7 @@ ReferenceSources/SecurityContext.cs
 ../../../external/referencesource/mscorlib/system/reflection/typeinfo.cs
 
 ../../../external/referencesource/mscorlib/system/reflection/emit/methodbuilder.cs
+../../../external/referencesource/mscorlib/system/reflection/emit/symboltype.cs
 
 ../../../external/referencesource/mscorlib/system/resources/__fastresourcecomparer.cs
 ../../../external/referencesource/mscorlib/system/resources/__hresults.cs
index e802a034dd64f2aa7f7a9a97dd76b0aaf3ed4294..6acc765c090d0c5e18bf7673c56328dbb30053a8 100644 (file)
@@ -3,21 +3,9 @@ CommonCrypto/CommonCrypto.cs
 CommonCrypto/CryptorTransform.cs
 CommonCrypto/FastCryptorTransform.cs
 CommonCrypto/CorlibExtras.cs
-CommonCrypto/MD5CryptoServiceProvider.g.cs
-CommonCrypto/SHA1CryptoServiceProvider.g.cs
-CommonCrypto/SHA1CryptoServiceProvider.g.cs
-CommonCrypto/SHA1Managed.g.cs
-CommonCrypto/SHA256Managed.g.cs
-CommonCrypto/SHA384Managed.g.cs
-CommonCrypto/SHA512Managed.g.cs
-CommonCrypto/TripleDESCryptoServiceProvider.g.cs
-CommonCrypto/DESCryptoServiceProvider.g.cs
-CommonCrypto/RC2CryptoServiceProvider.g.cs
 CommonCrypto/RijndaelManaged.cs
 CommonCrypto/SecRandom.cs
 CommonCrypto/RC4CommonCrypto.cs
-CommonCrypto/MD2Managed.g.cs
-CommonCrypto/MD4Managed.g.cs
 System/Environment.iOS.cs
 System/Guid.MonoTouch.cs
 System/NotSupportedException.iOS.cs
index e802a034dd64f2aa7f7a9a97dd76b0aaf3ed4294..6acc765c090d0c5e18bf7673c56328dbb30053a8 100644 (file)
@@ -3,21 +3,9 @@ CommonCrypto/CommonCrypto.cs
 CommonCrypto/CryptorTransform.cs
 CommonCrypto/FastCryptorTransform.cs
 CommonCrypto/CorlibExtras.cs
-CommonCrypto/MD5CryptoServiceProvider.g.cs
-CommonCrypto/SHA1CryptoServiceProvider.g.cs
-CommonCrypto/SHA1CryptoServiceProvider.g.cs
-CommonCrypto/SHA1Managed.g.cs
-CommonCrypto/SHA256Managed.g.cs
-CommonCrypto/SHA384Managed.g.cs
-CommonCrypto/SHA512Managed.g.cs
-CommonCrypto/TripleDESCryptoServiceProvider.g.cs
-CommonCrypto/DESCryptoServiceProvider.g.cs
-CommonCrypto/RC2CryptoServiceProvider.g.cs
 CommonCrypto/RijndaelManaged.cs
 CommonCrypto/SecRandom.cs
 CommonCrypto/RC4CommonCrypto.cs
-CommonCrypto/MD2Managed.g.cs
-CommonCrypto/MD4Managed.g.cs
 System/Environment.iOS.cs
 System/Guid.MonoTouch.cs
 System/NotSupportedException.iOS.cs
index e802a034dd64f2aa7f7a9a97dd76b0aaf3ed4294..6acc765c090d0c5e18bf7673c56328dbb30053a8 100644 (file)
@@ -3,21 +3,9 @@ CommonCrypto/CommonCrypto.cs
 CommonCrypto/CryptorTransform.cs
 CommonCrypto/FastCryptorTransform.cs
 CommonCrypto/CorlibExtras.cs
-CommonCrypto/MD5CryptoServiceProvider.g.cs
-CommonCrypto/SHA1CryptoServiceProvider.g.cs
-CommonCrypto/SHA1CryptoServiceProvider.g.cs
-CommonCrypto/SHA1Managed.g.cs
-CommonCrypto/SHA256Managed.g.cs
-CommonCrypto/SHA384Managed.g.cs
-CommonCrypto/SHA512Managed.g.cs
-CommonCrypto/TripleDESCryptoServiceProvider.g.cs
-CommonCrypto/DESCryptoServiceProvider.g.cs
-CommonCrypto/RC2CryptoServiceProvider.g.cs
 CommonCrypto/RijndaelManaged.cs
 CommonCrypto/SecRandom.cs
 CommonCrypto/RC4CommonCrypto.cs
-CommonCrypto/MD2Managed.g.cs
-CommonCrypto/MD4Managed.g.cs
 System/Environment.iOS.cs
 System/Guid.MonoTouch.cs
 System/NotSupportedException.iOS.cs
index e802a034dd64f2aa7f7a9a97dd76b0aaf3ed4294..6acc765c090d0c5e18bf7673c56328dbb30053a8 100644 (file)
@@ -3,21 +3,9 @@ CommonCrypto/CommonCrypto.cs
 CommonCrypto/CryptorTransform.cs
 CommonCrypto/FastCryptorTransform.cs
 CommonCrypto/CorlibExtras.cs
-CommonCrypto/MD5CryptoServiceProvider.g.cs
-CommonCrypto/SHA1CryptoServiceProvider.g.cs
-CommonCrypto/SHA1CryptoServiceProvider.g.cs
-CommonCrypto/SHA1Managed.g.cs
-CommonCrypto/SHA256Managed.g.cs
-CommonCrypto/SHA384Managed.g.cs
-CommonCrypto/SHA512Managed.g.cs
-CommonCrypto/TripleDESCryptoServiceProvider.g.cs
-CommonCrypto/DESCryptoServiceProvider.g.cs
-CommonCrypto/RC2CryptoServiceProvider.g.cs
 CommonCrypto/RijndaelManaged.cs
 CommonCrypto/SecRandom.cs
 CommonCrypto/RC4CommonCrypto.cs
-CommonCrypto/MD2Managed.g.cs
-CommonCrypto/MD4Managed.g.cs
 System/Environment.iOS.cs
 System/Guid.MonoTouch.cs
 System/NotSupportedException.iOS.cs
index 0dbb5163c7042ef38fd2f08e6f1fc01a3611dd6f..f321e0bc800fc1f1ecca58a541972df1fe8b7d29 100644 (file)
@@ -3,20 +3,8 @@ CommonCrypto/CommonCrypto.cs
 CommonCrypto/CryptorTransform.cs
 CommonCrypto/FastCryptorTransform.cs
 CommonCrypto/CorlibExtras.cs
-CommonCrypto/MD5CryptoServiceProvider.g.cs
-CommonCrypto/SHA1CryptoServiceProvider.g.cs
-CommonCrypto/SHA1CryptoServiceProvider.g.cs
-CommonCrypto/SHA1Managed.g.cs
-CommonCrypto/SHA256Managed.g.cs
-CommonCrypto/SHA384Managed.g.cs
-CommonCrypto/SHA512Managed.g.cs
-CommonCrypto/TripleDESCryptoServiceProvider.g.cs
-CommonCrypto/DESCryptoServiceProvider.g.cs
-CommonCrypto/RC2CryptoServiceProvider.g.cs
 CommonCrypto/RijndaelManaged.cs
 CommonCrypto/RC4CommonCrypto.cs
-CommonCrypto/MD2Managed.g.cs
-CommonCrypto/MD4Managed.g.cs
 CoreFoundation/CFHelpers.cs
 System.Security.Cryptography.X509Certificates/X509CertificateImplApple.cs
 System.Security.Cryptography.X509Certificates/X509Helper.Apple.cs
index 723b603c5f26ed85bd85dcfc73f9826ccc440817..9fb47abf6d486d9ba4d78811a9d0e68f420f3d13 100644 (file)
@@ -1,4 +1,4 @@
-// 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
 
index 7b5ffadf328884fdeaf5bc532468b005be5f98f2..b2399c8bd89d45c71aee3882c56bb09c8fddd2e1 100644 (file)
@@ -116,6 +116,8 @@ namespace Mono.CSharp
 
                public ExceptionStatement CurrentTryBlock { get; set; }
 
+               public TryCatch CurrentTryCatch { get; set; }
+
                public LoopStatement EnclosingLoop { get; set; }
 
                public LoopStatement EnclosingLoopOrSwitch { get; set; }
index a581906d3e9b82d7ffd04ab74c4c1f8275e7efa5..be79b14e86fc012de410ccd9af58bed2de6727f2 100644 (file)
@@ -4647,7 +4647,7 @@ namespace Mono.CSharp {
                ///     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;
@@ -4704,8 +4704,20 @@ namespace Mono.CSharp {
 
                                // 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'.
@@ -4717,15 +4729,26 @@ namespace Mono.CSharp {
                                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;
@@ -4746,7 +4769,7 @@ namespace Mono.CSharp {
                                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;
index bfba44fbb8c656079254fc346737ea8a4af5fd3e..76bcdbfa0ee7bdf8109573a1e6db43c9b9797deb 100644 (file)
@@ -7173,7 +7173,7 @@ namespace Mono.CSharp
                                                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)));
@@ -8398,11 +8398,32 @@ namespace Mono.CSharp
 
                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) {
index df43ff38e8e09f0387a6810ad441a6d56c5d8457..47919ec8ce2b5fda133bddbb93509096ba9ef671 100644 (file)
@@ -30,6 +30,7 @@ namespace Mono.CSharp
                protected T machine_initializer;
                int resume_pc;
                ExceptionStatement inside_try_block;
+               TryCatch inside_catch_block;
 
                protected YieldStatement (Expression expr, Location l)
                {
@@ -69,6 +70,7 @@ namespace Mono.CSharp
 
                        machine_initializer = bc.CurrentAnonymousMethod as T;
                        inside_try_block = bc.CurrentTryBlock;
+                       inside_catch_block = bc.CurrentTryCatch;
                        return true;
                }
 
@@ -80,7 +82,7 @@ namespace Mono.CSharp
                        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;
                        }
index 9c84398ee3e4d52c01e8a3d25fd83adff75e96e3..d0341cb3b633045c48889bfa3a3f31789df36ff0 100644 (file)
@@ -5877,7 +5877,7 @@ namespace Mono.CSharp {
                protected override bool DoFlowAnalysis (FlowAnalysisContext fc)
                {
                        var res = stmt.FlowAnalysis (fc);
-                       parent = null;
+                       parent_try_block = null;
                        return res;
                }
 
@@ -5897,14 +5897,18 @@ namespace Mono.CSharp {
                {
                        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
@@ -5930,18 +5934,14 @@ namespace Mono.CSharp {
        {
                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;
@@ -5952,10 +5952,37 @@ namespace Mono.CSharp {
                                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
@@ -5963,21 +5990,30 @@ namespace Mono.CSharp {
                                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);
                        }
@@ -5990,6 +6026,11 @@ namespace Mono.CSharp {
                        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;
                }
@@ -6936,14 +6977,6 @@ namespace Mono.CSharp {
                        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) {
@@ -6953,7 +6986,7 @@ namespace Mono.CSharp {
                                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);
@@ -7193,6 +7226,12 @@ namespace Mono.CSharp {
                        }
                }
 
+               public bool HasClauseWithAwait {
+                       get {
+                               return catch_sm != null;
+                       }
+               }
+
                public bool IsTryCatchFinally {
                        get {
                                return inside_try_finally;
@@ -7204,7 +7243,8 @@ namespace Mono.CSharp {
                        bool ok;
 
                        using (bc.Set (ResolveContext.Options.TryScope)) {
-                               parent = bc.CurrentTryBlock;
+
+                               parent_try_block = bc.CurrentTryBlock;
 
                                if (IsTryCatchFinally) {
                                        ok = Block.Resolve (bc);
@@ -7212,11 +7252,14 @@ namespace Mono.CSharp {
                                        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];
 
@@ -7275,6 +7318,8 @@ namespace Mono.CSharp {
                                }
                        }
 
+                       bc.CurrentTryCatch = prev_catch;
+
                        return base.Resolve (bc) && ok;
                }
 
@@ -7307,10 +7352,12 @@ namespace Mono.CSharp {
                                }
                        }
 
-                       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];
@@ -7362,7 +7409,7 @@ namespace Mono.CSharp {
                        }
 
                        fc.DefiniteAssignment = try_fc ?? start_fc;
-                       parent = null;
+                       parent_try_block = null;
                        return res;
                }
 
index a5a9ad15607da053892c5073fee28ecfcdd25130..b53915f6eb1c030c749d98c239553e8a7c46c76d 100644 (file)
@@ -198,6 +198,8 @@ namespace Mono.CSharp
                public readonly PredefinedType SecurityAction;
                public readonly PredefinedType Dictionary;
                public readonly PredefinedType Hashtable;
+               public readonly PredefinedType Array;
+
                public readonly TypeSpec[] SwitchUserTypes;
 
                //
@@ -266,6 +268,7 @@ namespace Mono.CSharp
                        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);
@@ -340,6 +343,7 @@ namespace Mono.CSharp
        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;
@@ -411,6 +415,9 @@ namespace Mono.CSharp
                        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));
 
index 81894f06c762ea1d6146e2e9d99905b2d3a7f4e1..fb02370dbb32cd2317827d323637b370d01e0048 100644 (file)
@@ -547,7 +547,15 @@ namespace Mono.CSharp
 
                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 ()
diff --git a/mcs/tests/dtest-064.cs b/mcs/tests/dtest-064.cs
new file mode 100644 (file)
index 0000000..da593f6
--- /dev/null
@@ -0,0 +1,46 @@
+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
index 7117ab291e7ce6b4fed42288979c4a60936c1279..9ed101f55221f9dd6473518cee7ab70a0fe27795 100644 (file)
@@ -104,10 +104,10 @@ public class Program
                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)
diff --git a/mcs/tests/gtest-optional-36.cs b/mcs/tests/gtest-optional-36.cs
new file mode 100644 (file)
index 0000000..bf9f7d1
--- /dev/null
@@ -0,0 +1,66 @@
+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;
+       }
+}
diff --git a/mcs/tests/gtest-optional-37.cs b/mcs/tests/gtest-optional-37.cs
new file mode 100644 (file)
index 0000000..f322ff6
--- /dev/null
@@ -0,0 +1,19 @@
+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
diff --git a/mcs/tests/test-933.cs b/mcs/tests/test-933.cs
new file mode 100644 (file)
index 0000000..2f076eb
--- /dev/null
@@ -0,0 +1,22 @@
+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
diff --git a/mcs/tests/test-async-85.cs b/mcs/tests/test-async-85.cs
new file mode 100644 (file)
index 0000000..36c7a1e
--- /dev/null
@@ -0,0 +1,74 @@
+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 {
+               }
+       }       
+}
index 8c966ef91e8f63f76b24bf0f422a520846f0427b..9b087dd751dae78098aa36a6d2e2a9dd66680e7f 100644 (file)
@@ -38,9 +38,9 @@
         <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" />
index 576a15ddb738d3d6612dffbf80fa5a75ce29346a..30bf5ea7293b468b679e96149f4c48a38bb0529b 100644 (file)
@@ -85,7 +85,7 @@
   <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+&lt;GetIndex_3&gt;c__AnonStorey1">
       <method name="Void &lt;&gt;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+&lt;InvokeMember_2&gt;c__AnonStorey2">
       <method name="Void &lt;&gt;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+&lt;InvokeMember_6&gt;c__AnonStorey3">
       <method name="Void &lt;&gt;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+&lt;SetIndex_3&gt;c__AnonStorey4">
       <method name="Void &lt;&gt;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 &lt;GetIndex_1&gt;m__25(System.Dynamic.GetIndexBinder, System.Object[])" attrs="145">
-        <size>93</size>
+        <size>92</size>
       </method>
       <method name="Void &lt;GetIndex_2&gt;m__26(System.Dynamic.GetIndexBinder, System.Object[])" attrs="145">
-        <size>112</size>
+        <size>111</size>
       </method>
       <method name="System.Object &lt;GetMember_1&gt;m__27(System.Dynamic.GetMemberBinder)" attrs="145">
         <size>75</size>
       </method>
       <method name="Void &lt;Invoke_1&gt;m__28(System.Dynamic.InvokeBinder, System.Object[])" attrs="145">
-        <size>102</size>
+        <size>101</size>
       </method>
       <method name="Void &lt;Invoke_2&gt;m__29(System.Dynamic.InvokeBinder, System.Object[])" attrs="145">
-        <size>74</size>
+        <size>72</size>
       </method>
       <method name="Void &lt;Invoke_4&gt;m__2A(System.Dynamic.InvokeBinder, System.Object[])" attrs="145">
         <size>128</size>
       </method>
       <method name="Void &lt;Invoke_5&gt;m__2B(System.Dynamic.InvokeBinder, System.Object[])" attrs="145">
-        <size>92</size>
+        <size>91</size>
       </method>
       <method name="Void &lt;Invoke_5&gt;m__2C(System.Object)" attrs="145">
         <size>94</size>
       </method>
       <method name="Void &lt;Invoke_6&gt;m__2D(System.Dynamic.InvokeBinder, System.Object[])" attrs="145">
-        <size>93</size>
+        <size>92</size>
       </method>
       <method name="Void &lt;InvokeMember_1&gt;m__2E(System.Dynamic.InvokeMemberBinder, System.Object[])" attrs="145">
-        <size>111</size>
+        <size>110</size>
       </method>
       <method name="Void &lt;InvokeMember_3&gt;m__2F(System.Dynamic.InvokeMemberBinder, System.Object[])" attrs="145">
-        <size>112</size>
+        <size>111</size>
       </method>
       <method name="Void &lt;InvokeMember_4&gt;m__30(System.Dynamic.InvokeMemberBinder, System.Object[])" attrs="145">
-        <size>111</size>
+        <size>110</size>
       </method>
       <method name="Void &lt;InvokeMember_7&gt;m__31(System.Dynamic.InvokeMemberBinder, System.Object[])" attrs="145">
-        <size>91</size>
+        <size>89</size>
       </method>
       <method name="Void &lt;InvokeMember_8&gt;m__32(System.Dynamic.InvokeMemberBinder, System.Object[])" attrs="145">
-        <size>112</size>
+        <size>111</size>
       </method>
       <method name="Void &lt;SetIndex_1&gt;m__33(System.Dynamic.SetIndexBinder, System.Object[], System.Object)" attrs="145">
-        <size>125</size>
+        <size>124</size>
       </method>
       <method name="Void &lt;SetIndex_2&gt;m__34(System.Dynamic.SetIndexBinder, System.Object[], System.Object)" attrs="145">
-        <size>140</size>
+        <size>139</size>
       </method>
       <method name="Void &lt;SetMember_1&gt;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 &lt;B&gt;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 &lt;a&gt;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+&lt;GenericClass&gt;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+&lt;Filter&gt;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 &lt;Main&gt;m__0()" attrs="145">
-        <size>162</size>
+        <size>159</size>
       </method>
       <method name="System.Collections.Generic.IEnumerable`1[B] &lt;Main&gt;m__1(A)" attrs="145">
-        <size>15</size>
+        <size>14</size>
       </method>
       <method name="&lt;&gt;__AnonType0`2[A,B] &lt;Main&gt;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+&lt;ContainsAll&gt;c__AnonStorey0`1[T,U]">
       <method name="Boolean &lt;&gt;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+&lt;Test&gt;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+&lt;Test2&gt;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>
index d95558b30831328d0943d51f4ca56f88f894aad7..693318cbea7e07fdb27df8413379a15d159e7ac0 100644 (file)
@@ -49,7 +49,7 @@ net_4_5_dirs := \
        mono-symbolicate        \
        linker-analyzer
 
-build_SUBDIRS = gacutil security culevel cil-stringreplacer
+build_SUBDIRS = gacutil security culevel cil-stringreplacer commoncryptogenerator
 net_4_5_SUBDIRS = gacutil
 net_4_5_PARALLEL_SUBDIRS = $(net_4_5_dirs)
 
diff --git a/mcs/tools/commoncryptogenerator/CommonCryptorGenerator.cs b/mcs/tools/commoncryptogenerator/CommonCryptorGenerator.cs
new file mode 100644 (file)
index 0000000..f177c17
--- /dev/null
@@ -0,0 +1,104 @@
+//
+// CommonCrypto code generator for symmetric block cipher algorithms
+//
+// Authors:
+//     Sebastien Pouliot  <sebastien@xamarin.com>
+//
+// Copyright 2012 Xamarin Inc.
+//
+
+using System;
+using System.IO;
+
+namespace Xamarin {
+
+       public static class CommonCryptor {
+               
+               static public void Generate (string namespaceName, string typeName, string baseTypeName, string ccAlgorithmName, string feedbackSize = "8", string ctorInitializers = null)
+               {
+                       string template = @"// Generated file to bind CommonCrypto cipher algorithms - DO NOT EDIT
+//
+// Authors:
+//     Sebastien Pouliot  <sebastien@xamarin.com>
+//
+// Copyright 2012-2014 Xamarin Inc.
+
+using System;
+using System.Security.Cryptography;
+
+using Mono.Security.Cryptography;
+using Crimson.CommonCrypto;
+
+namespace %NAMESPACE% {
+
+       public sealed partial class %TYPE% : %BASE% {
+               
+               public %TYPE% ()
+               {
+                       FeedbackSizeValue = %FEEDBACKSIZE%;
+                       %CTOR_INIT%
+               }
+               
+               public override void GenerateIV ()
+               {
+                       IVValue = KeyBuilder.IV (BlockSizeValue >> 3);
+               }
+               
+               public override void GenerateKey ()
+               {
+                       KeyValue = KeyBuilder.Key (KeySizeValue >> 3);
+               }
+               
+               public override ICryptoTransform CreateDecryptor (byte[] rgbKey, byte[] rgbIV) 
+               {
+                       IntPtr decryptor = IntPtr.Zero;
+                       switch (Mode) {
+                       case CipherMode.CBC:
+                               decryptor = Cryptor.Create (CCOperation.Decrypt, CCAlgorithm.%CCALGORITHM%, CCOptions.None, rgbKey, rgbIV);
+                               return new FastCryptorTransform (decryptor, this, false, rgbIV);
+                       case CipherMode.ECB:
+                               decryptor = Cryptor.Create (CCOperation.Decrypt, CCAlgorithm.%CCALGORITHM%, CCOptions.ECBMode, rgbKey, rgbIV);
+                               return new FastCryptorTransform (decryptor, this, false, rgbIV);
+                       case CipherMode.CFB:
+#if MONOTOUCH || XAMMAC
+                               IntPtr encryptor = Cryptor.Create (CCOperation.Encrypt, CCAlgorithm.%CCALGORITHM%, CCOptions.ECBMode, rgbKey, rgbIV);
+                               decryptor = Cryptor.Create (CCOperation.Decrypt, CCAlgorithm.%CCALGORITHM%, CCOptions.ECBMode, rgbKey, rgbIV);
+                               return new CryptorTransform (decryptor, encryptor, this, false, rgbIV);
+#else
+                               throw new CryptographicException (""CFB is not supported by Crimson.CommonCrypto"");
+#endif
+                       default:
+                               throw new CryptographicException (String.Format (""{0} is not supported by the .NET framework"", Mode));
+                       }
+               }
+               
+               public override ICryptoTransform CreateEncryptor (byte[] rgbKey, byte[] rgbIV) 
+               {
+                       IntPtr encryptor = IntPtr.Zero;
+                       switch (Mode) {
+                       case CipherMode.CBC:
+                               encryptor = Cryptor.Create (CCOperation.Encrypt, CCAlgorithm.%CCALGORITHM%, CCOptions.None, rgbKey, rgbIV);
+                               return new FastCryptorTransform (encryptor, this, true, rgbIV);
+                       case CipherMode.ECB:
+                               encryptor = Cryptor.Create (CCOperation.Encrypt, CCAlgorithm.%CCALGORITHM%, CCOptions.ECBMode, rgbKey, rgbIV);
+                               return new FastCryptorTransform (encryptor, this, true, rgbIV);
+                       case CipherMode.CFB:
+#if MONOTOUCH || XAMMAC
+                               encryptor = Cryptor.Create (CCOperation.Encrypt, CCAlgorithm.%CCALGORITHM%, CCOptions.ECBMode, rgbKey, rgbIV);
+                               return new CryptorTransform (encryptor, IntPtr.Zero, this, true, rgbIV);
+#else
+                               throw new CryptographicException (""CFB is not supported by Crimson.CommonCrypto"");
+#endif
+                       default:
+                               throw new CryptographicException (String.Format (""{0} is not supported by the .NET framework"", Mode));
+                       }
+               }
+       }
+}";
+                       
+                       File.WriteAllText (typeName + ".g.cs", template.Replace ("%NAMESPACE%", namespaceName).
+                               Replace ("%TYPE%", typeName).Replace ("%BASE%", baseTypeName).Replace("%FEEDBACKSIZE%", feedbackSize).Replace ("%CTOR_INIT%", ctorInitializers).
+                               Replace ("%CCALGORITHM%", ccAlgorithmName.ToString ()));
+               }
+       }
+}
diff --git a/mcs/tools/commoncryptogenerator/CommonDigestGenerator.cs b/mcs/tools/commoncryptogenerator/CommonDigestGenerator.cs
new file mode 100644 (file)
index 0000000..1b729e3
--- /dev/null
@@ -0,0 +1,167 @@
+//
+// CommonCrypto code generator for digest algorithms
+//
+// Authors:
+//     Sebastien Pouliot  <sebastien@xamarin.com>
+//
+// Copyright 2012-2014 Xamarin Inc.
+//
+
+using System;
+using System.IO;
+
+namespace Xamarin {
+
+       public static class CommonDigest {
+               
+#if !MONOTOUCH && !XAMMAC
+               // we do not add anything in MonoTouch, just replacing, so this is not needed
+               // however we can avoid a dependency on Mono.Security for Crimson.CommonCrypto.dll by including the base classes
+               static public void GenerateBaseClass (string namespaceName, string typeName, string baseTypeName, int hashSize,
+                       string visibilityStart = "", string visibilityEnd = "")
+               {
+                       string template = @"// Generated file to bind CommonCrypto/CommonDigest - DO NOT EDIT
+//
+// Authors:
+//     Sebastien Pouliot  <sebastien@xamarin.com>
+//
+// Copyright 2012-2014 Xamarin Inc.
+
+using System;
+using System.Security.Cryptography;
+using System.Runtime.InteropServices;
+
+namespace %NAMESPACE% {
+
+%VISIBILITY_START%
+       public
+%VISIBILITY_END%
+       abstract class %BASE% : HashAlgorithm {
+
+               protected %BASE% () 
+               {
+                       HashSizeValue = %HASHSIZE%; 
+               }
+
+               public static new %BASE% Create ()
+               {
+                       return Create (""%BASE%"");
+               }
+
+               public static new %BASE% Create (string hashName)
+               {
+                       object o = CryptoConfig.CreateFromName (hashName);
+                       return (%BASE%) o ?? new %TYPE% ();
+               }
+       }
+}";
+                       
+                       File.WriteAllText (baseTypeName + ".g.cs", template.Replace ("%NAMESPACE%", namespaceName).
+                               Replace ("%TYPE%", typeName).Replace ("%BASE%", baseTypeName).
+                               Replace ("%VISIBILITY_START%", visibilityStart).Replace ("%VISIBILITY_END%", visibilityEnd).
+                               Replace ("%HASHSIZE%", hashSize.ToString ()));
+               }
+#endif
+               static public void Generate (string namespaceName, string typeName, string baseTypeName, int contextSize,
+                       string visibilityStart = "", string visibilityEnd = "")
+               {
+                       string template = @"// Generated file to bind CommonCrypto/CommonDigest - DO NOT EDIT
+//
+// Authors:
+//     Sebastien Pouliot  <sebastien@xamarin.com>
+//
+// Copyright 2011-2014 Xamarin Inc.
+
+using System;
+using System.Security.Cryptography;
+using System.Runtime.InteropServices;
+
+using Mono.Security.Cryptography;
+
+namespace %NAMESPACE% {
+
+%VISIBILITY_START%
+       public
+%VISIBILITY_END%
+       sealed class %TYPE% : %BASE% {
+
+               IntPtr ctx;
+
+               [DllImport (""/usr/lib/libSystem.dylib"", EntryPoint=""CC_%BASE%_Init"")]
+               static extern int Init (/* CC_%BASE%_CTX */ IntPtr c);
+
+               [DllImport (""/usr/lib/libSystem.dylib"", EntryPoint=""CC_%BASE%_Update"")]
+               static extern int Update (/* CC_%BASE%_CTX */ IntPtr c, /* const void * */ IntPtr data, /* uint32_t */ uint len);
+
+               [DllImport (""/usr/lib/libSystem.dylib"", EntryPoint=""CC_%BASE%_Final"")]
+               static extern int Final (/* unsigned char * */ byte [] md, /* CC_%BASE%_CTX */ IntPtr c);
+
+               public %TYPE% ()
+               {
+                       ctx = IntPtr.Zero;
+               }
+
+               ~%TYPE% ()
+               {
+                       Dispose (false);
+               }
+
+               protected override void Dispose (bool disposing)
+               {
+                       if (ctx != IntPtr.Zero) {
+                               Marshal.FreeHGlobal (ctx);
+                               ctx = IntPtr.Zero;
+                       }
+                       base.Dispose (disposing);
+                       GC.SuppressFinalize (this);
+               }
+
+               public override void Initialize ()
+               {
+                       if (ctx == IntPtr.Zero)
+                               ctx = Marshal.AllocHGlobal (%CTX_SIZE%);
+                       
+                       int hr = Init (ctx);
+                       if (hr != 1)
+                               throw new CryptographicException (hr);
+               }
+
+               protected override void HashCore (byte[] data, int start, int length) 
+               {
+                       if (ctx == IntPtr.Zero)
+                               Initialize ();
+
+                       if (data.Length == 0)
+                               return;
+
+                       unsafe {
+                               fixed (byte* p = &data [0]) {
+                                       int hr = Update (ctx, (IntPtr) (p + start), (uint) length);
+                                       if (hr != 1)
+                                               throw new CryptographicException (hr);
+                               }
+                       }
+               }
+
+               protected override byte[] HashFinal () 
+               {
+                       if (ctx == IntPtr.Zero)
+                               Initialize ();
+                       
+                       byte[] data = new byte [HashSize >> 3];
+                       int hr = Final (data, ctx);
+                       if (hr != 1)
+                               throw new CryptographicException (hr);
+
+                       return data;
+               }
+       }
+}";
+                       
+                       File.WriteAllText (typeName + ".g.cs", template.Replace ("%NAMESPACE%", namespaceName).
+                               Replace ("%TYPE%", typeName).Replace ("%BASE%", baseTypeName).
+                               Replace ("%VISIBILITY_START%", visibilityStart).Replace ("%VISIBILITY_END%", visibilityEnd).
+                               Replace ("%CTX_SIZE%", contextSize.ToString ()));
+               }
+       }
+}
diff --git a/mcs/tools/commoncryptogenerator/Makefile b/mcs/tools/commoncryptogenerator/Makefile
new file mode 100644 (file)
index 0000000..64c52e4
--- /dev/null
@@ -0,0 +1,11 @@
+thisdir = tools/commoncryptogenerator
+SUBDIRS =
+include ../../build/rules.make
+
+LIB_REFS = 
+LOCAL_MCS_FLAGS =
+
+PROGRAM = commoncryptogenerator.exe
+NO_INSTALL = yes
+
+include ../../build/executable.make
diff --git a/mcs/tools/commoncryptogenerator/commoncryptogenerator.exe.sources b/mcs/tools/commoncryptogenerator/commoncryptogenerator.exe.sources
new file mode 100644 (file)
index 0000000..e2ecba4
--- /dev/null
@@ -0,0 +1,3 @@
+CommonCryptorGenerator.cs
+generator.cs
+CommonDigestGenerator.cs
diff --git a/mcs/tools/commoncryptogenerator/generator.cs b/mcs/tools/commoncryptogenerator/generator.cs
new file mode 100644 (file)
index 0000000..a7d13c8
--- /dev/null
@@ -0,0 +1,57 @@
+//
+// CommonCrypto Code Generator
+//
+// Authors:
+//     Sebastien Pouliot  <sebastien@xamarin.com>
+//
+// Copyright 2012 Xamarin Inc.
+//
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Text;
+
+namespace Xamarin {
+       
+       class Program {
+               static void Main (string [] args)
+               {
+                       // mscorlib replacements
+                       CommonDigest.Generate ("System.Security.Cryptography", "MD5CryptoServiceProvider", "MD5", 1000);
+                       CommonDigest.Generate ("System.Security.Cryptography", "SHA1CryptoServiceProvider", "SHA1", 1000);
+                       CommonDigest.Generate ("System.Security.Cryptography", "SHA1Managed", "SHA1", 1000);
+                       CommonDigest.Generate ("System.Security.Cryptography", "SHA256Managed", "SHA256", 1000);
+                       CommonDigest.Generate ("System.Security.Cryptography", "SHA384Managed", "SHA384", 1000);
+                       CommonDigest.Generate ("System.Security.Cryptography", "SHA512Managed", "SHA512", 1000);
+                       
+                       // System.Core replacements - not yet in MT profile (4.0 - functional dupes anyway)
+                       //CommonDigest.Generate ("System.Security.Cryptography", "MD5Cng", "MD5", 1000);
+                       //CommonDigest.Generate ("System.Security.Cryptography", "SHA256Cng", "SHA256", 1000);
+                       //CommonDigest.Generate ("System.Security.Cryptography", "SHA384Cng", "SHA384", 1000);
+                       //CommonDigest.Generate ("System.Security.Cryptography", "SHA512Cng", "SHA512", 1000);
+                       //CommonDigest.Generate ("System.Security.Cryptography", "SHA256CryptoServiceProvider", "SHA256", 1000);
+                       //CommonDigest.Generate ("System.Security.Cryptography", "SHA384CryptoServiceProvider", "SHA384", 1000);
+                       //CommonDigest.Generate ("System.Security.Cryptography", "SHA512CryptoServiceProvider", "SHA512", 1000);
+                       
+                       // Mono.Security replacements
+                       CommonDigest.Generate ("Mono.Security.Cryptography", "MD2Managed", "MD2", 1000, "#if !INSIDE_CORLIB", "#endif");
+                       CommonDigest.Generate ("Mono.Security.Cryptography", "MD4Managed", "MD4", 1000, "#if !INSIDE_CORLIB", "#endif");
+                       CommonDigest.Generate ("Mono.Security.Cryptography", "SHA224Managed", "SHA224", 1000);
+
+                       // mscorlib replacements
+                       CommonCryptor.Generate ("System.Security.Cryptography", "DESCryptoServiceProvider", "DES", "DES");
+                       CommonCryptor.Generate ("System.Security.Cryptography", "TripleDESCryptoServiceProvider", "TripleDES", "TripleDES");
+                       CommonCryptor.Generate ("System.Security.Cryptography", "RC2CryptoServiceProvider", "RC2", "RC2", ctorInitializers: "LegalKeySizesValue = new[] { new KeySizes(40, 128, 8) };");
+                       // Rijndael supports block sizes that are not available in AES - as such it does not use the same generated code
+                       // but has it's own version, using AES (128 bits block size) and falling back to managed (192/256 bits block size)
+
+                       // System.Core replacements
+                       CommonCryptor.Generate ("System.Security.Cryptography", "AesManaged", "Aes", "AES128", "128");
+                       CommonCryptor.Generate ("System.Security.Cryptography", "AesCryptoServiceProvider", "Aes", "AES128");
+
+                       // Mono.Security replacements
+                       // RC4 is a stream (not a block) cipher so it can not reuse the generated code
+               }
+       }
+}
\ No newline at end of file
index beafdfa555778472afda9b56e0d11d2fd3d52845..677403c049258a084fb8bfca2ebcbee87201c0cb 100644 (file)
@@ -1440,20 +1440,16 @@ namespace TestRunner {
                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)
index 867c1d3e2df0fd3c833b427f1927b62103831449..05faf5e8c685e1ec0ce4d295e848619f974d28c8 100644 (file)
@@ -11,7 +11,7 @@ RESOURCE_FILES = $(OTHER_RES)
 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)
 
index 57bae7e4c1d96d7e934ae63c25872c9e9dcfab5a..6395e90ff41b3499337d075e126a72376dd6f35e 100755 (executable)
@@ -7,6 +7,11 @@
 //   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;
@@ -17,8 +22,8 @@ using System.IO.Compression;
 using System.Runtime.InteropServices;
 using System.Text;
 using IKVM.Reflection;
-
-
+using System.Linq;
+using System.Diagnostics;
 using System.Threading.Tasks;
 
 class MakeBundle {
@@ -41,6 +46,9 @@ 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)
        {
@@ -56,6 +64,15 @@ class MakeBundle {
                                Help ();
                                return 1;
 
+                       case "--simple":
+                               custom_mode = false;
+                               autodeps = true;
+                               break;
+                               
+                       case "--custom":
+                               custom_mode = true;
+                               break;
+                               
                        case "-c":
                                compile_only = true;
                                break;
@@ -68,6 +85,20 @@ class MakeBundle {
                                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 (); 
@@ -95,6 +126,7 @@ class MakeBundle {
                        case "--keeptemp":
                                keeptemp = true;
                                break;
+                               
                        case "--static":
                                static_link = true;
                                break;
@@ -197,9 +229,11 @@ class MakeBundle {
                foreach (string file in assemblies)
                        if (!QueueAssembly (files, file))
                                return 1;
-                       
-               GenerateBundles (files);
-               //GenerateJitWrapper ();
+
+               if (custom_mode)
+                       GenerateBundles (files);
+               else
+                       GeneratePackage (files);
                
                return 0;
        }
@@ -264,6 +298,138 @@ class MakeBundle {
 
                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)
        {
@@ -756,25 +922,35 @@ void          mono_register_config_for_assembly (const char* assembly_name, cons
        {
                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");
        }
index 6ac0f241ade40505cf481beed3438df489100aa6..103d817f180c918f639172c7a7afb2ea49f99c23 100644 (file)
@@ -48,7 +48,7 @@
     <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" />
index 0580eeb9615db86aba1c056ff7e1256b528423e6..0ddfddd944dafad3f3d030cff1695636c6877cc4 100644 (file)
@@ -2,10 +2,9 @@ using System;
 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;
 
@@ -77,6 +76,7 @@ namespace Symbolicate
                        }
                }
 
+               static readonly Universe ikvm_reflection = new Universe ();
                Dictionary<string, AssemblyLocationProvider> assemblies;
                HashSet<string> directories;
 
@@ -94,14 +94,14 @@ namespace Symbolicate
                        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))
index 1a621f6f825d481048b2f70abf119b4d4a9c925b..57fee31f46d265e5e05e15a6bbdfd5632ed1afae 100644 (file)
@@ -4,9 +4,10 @@ include ../../build/rules.make
 
 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
 
index a426d61200eaed9a2c3e8664903605e3f015d807..a3cd72acd0ef271381ede360b4d50799ca61c8fb 100644 (file)
@@ -11,22 +11,22 @@ Stacktrace:
   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 
 
index 7f50e887c2032b2fde8f5f62f689241af91c5237..858bf2a9584a302e74674438feece12d801c80d5 100644 (file)
@@ -2,3 +2,9 @@ symbolicate.cs
 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
index fcdf30adbfd92170b52dcd45318abe2f4ec26bed..26d73ce31c49214d27052cc77e2f929f8b436829 100644 (file)
@@ -249,6 +249,21 @@ typedef union {
                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) \
@@ -257,6 +272,9 @@ typedef union {
 #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 */
@@ -298,6 +316,8 @@ typedef union {
 
 #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);                                                  \
@@ -1465,7 +1485,7 @@ typedef union {
 #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)
@@ -1710,7 +1730,7 @@ typedef union {
 #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)
index 7e46c31ba3e1564a9323022f9a0e3542b5f71fca..0157e92f5be08fc6b56f0590393d9f0030d5917f 100644 (file)
@@ -1287,7 +1287,8 @@ GetExitCodeProcess (gpointer process, guint32 *code)
                        *code = STILL_ACTIVE;
                        return TRUE;
                } else {
-                       return FALSE;
+                       *code = -1;
+                       return TRUE;
                }
        }
 
index 71bfc07952fd368df01fbf19665f8e22a7fa0121..0d8e577c9d4400e57a7b020d18b11bfc20f7b500 100644 (file)
@@ -81,7 +81,7 @@
  * Changes which are already detected at runtime, like the addition
  * of icalls, do not require an increment.
  */
-#define MONO_CORLIB_VERSION 143
+#define MONO_CORLIB_VERSION 145
 
 typedef struct
 {
@@ -320,7 +320,7 @@ mono_get_corlib_version (void)
        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));
 }
 
@@ -435,13 +435,18 @@ mono_domain_create_appdomain (char *friendly_name, char *configuration_file)
 
        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;
 }
 
 /**
@@ -938,23 +943,20 @@ mono_domain_set_options_from_config (MonoDomain *domain)
 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 *
@@ -1057,18 +1059,13 @@ mono_domain_assembly_postload_search (MonoAssemblyName *aname, MonoAssembly *req
 
        /* 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;
@@ -1163,7 +1160,7 @@ mono_domain_fire_assembly_load (MonoAssembly *assembly, gpointer user_data)
        *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);
 }
 
 /*
@@ -2309,7 +2306,7 @@ ves_icall_System_AppDomain_InternalGetProcessGuid (MonoString* newguid)
                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));
@@ -2430,9 +2427,17 @@ unload_thread_main (void *arg)
        /* 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 
index 355d09916f80dd226ad46e488f59c7a1d8e956ef..17da478b5e9c1f089d76de0bc275da6ab5e21077 100644 (file)
@@ -1130,11 +1130,11 @@ mono_class_inflate_generic_method_full_checked (MonoMethod *method, MonoClass *k
        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);
                }
index 08450558d9d27e9998da65efb7ea26943303570f..3ebe507d0d185472c7aada8bed2713c8b11847df 100644 (file)
@@ -622,6 +622,7 @@ mono_cominterop_cleanup (void)
 void
 mono_mb_emit_cominterop_call (MonoMethodBuilder *mb, MonoMethodSignature *sig, MonoMethod* method)
 {
+#ifndef DISABLE_JIT
        // get function pointer from 1st arg, the COM interface pointer
        mono_mb_emit_ldarg (mb, 0);
        mono_mb_emit_icon (mb, cominterop_get_com_slot_for_method (method));
@@ -632,11 +633,13 @@ mono_mb_emit_cominterop_call (MonoMethodBuilder *mb, MonoMethodSignature *sig, M
        mono_mb_emit_calli (mb, sig);
        mono_mb_emit_byte (mb, MONO_CUSTOM_PREFIX);
        mono_mb_emit_byte (mb, CEE_MONO_RESTORE_LMF);
+#endif /* DISABLE_JIT */
 }
 
 void
 mono_cominterop_emit_ptr_to_object_conv (MonoMethodBuilder *mb, MonoType *type, MonoMarshalConv conv, MonoMarshalSpec *mspec)
 {
+#ifndef DISABLE_JIT
        switch (conv) {
        case MONO_MARSHAL_CONV_OBJECT_INTERFACE:
        case MONO_MARSHAL_CONV_OBJECT_IUNKNOWN:
@@ -708,11 +711,13 @@ mono_cominterop_emit_ptr_to_object_conv (MonoMethodBuilder *mb, MonoType *type,
        default:
                g_assert_not_reached ();
        }
+#endif /* DISABLE_JIT */
 }
 
 void
 mono_cominterop_emit_object_to_ptr_conv (MonoMethodBuilder *mb, MonoType *type, MonoMarshalConv conv, MonoMarshalSpec *mspec)
 {
+#ifndef DISABLE_JIT
        switch (conv) {
        case MONO_MARSHAL_CONV_OBJECT_INTERFACE:
        case MONO_MARSHAL_CONV_OBJECT_IDISPATCH:
@@ -800,6 +805,7 @@ mono_cominterop_emit_object_to_ptr_conv (MonoMethodBuilder *mb, MonoType *type,
        default:
                g_assert_not_reached ();
        }
+#endif /* DISABLE_JIT */
 }
 
 /**
@@ -936,6 +942,7 @@ mono_cominterop_get_native_wrapper (MonoMethod *method)
        sig = mono_method_signature (method);
        mb = mono_mb_new (method->klass, method->name, MONO_WRAPPER_COMINTEROP);
 
+#ifndef DISABLE_JIT
        /* if method klass is import, that means method
         * is really a com call. let interop system emit it.
        */
@@ -1009,6 +1016,8 @@ mono_cominterop_get_native_wrapper (MonoMethod *method)
                        imported classes is not yet implemented.");
                mono_mb_emit_exception (mb, "NotSupportedException", msg);
        }
+#endif /* DISABLE_JIT */
+
        csig = mono_metadata_signature_dup_full (method->klass->image, sig);
        csig->pinvoke = 0;
        res = mono_mb_create_and_cache (cache, method,
@@ -1048,6 +1057,7 @@ mono_cominterop_get_invoke (MonoMethod *method)
 
        mb = mono_mb_new (method->klass, method->name, MONO_WRAPPER_COMINTEROP_INVOKE);
 
+#ifndef DISABLE_JIT
        /* get real proxy object, which is a ComInteropProxy in this case*/
        mono_mb_add_local (mb, &mono_defaults.object_class->byval_arg);
        mono_mb_emit_ldarg (mb, 0);
@@ -1088,6 +1098,7 @@ mono_cominterop_get_invoke (MonoMethod *method)
        mono_marshal_emit_thread_interrupt_checkpoint (mb);
 
        mono_mb_emit_byte (mb, CEE_RET);
+#endif /* DISABLE_JIT */
 
        res = mono_mb_create_and_cache (cache, method, mb, sig, sig->param_count + 16);
        mono_mb_free (mb);
@@ -1142,6 +1153,18 @@ mono_cominterop_emit_marshal_com_interface (EmitMarshalContext *m, int argnum,
        if (!marshal_release)
                marshal_release = mono_class_get_method_from_name (mono_defaults.marshal_class, "Release", 1);
 
+#ifdef DISABLE_JIT
+       switch (action) {
+       case MARSHAL_ACTION_CONV_IN:
+               *conv_arg_type = &mono_defaults.int_class->byval_arg;
+               break;
+       case MARSHAL_ACTION_MANAGED_CONV_IN:
+               *conv_arg_type = &mono_defaults.int_class->byval_arg;
+               break;
+       default:
+               break;
+       }
+#else
        switch (action) {
        case MARSHAL_ACTION_CONV_IN: {
                guint32 pos_null = 0;
@@ -1428,6 +1451,7 @@ mono_cominterop_emit_marshal_com_interface (EmitMarshalContext *m, int argnum,
        default:
                g_assert_not_reached ();
        }
+#endif /* DISABLE_JIT */
 
        return conv_arg;
 }
@@ -2077,8 +2101,10 @@ cominterop_get_ccw_checked (MonoObject* object, MonoClass* itf, MonoError *error
                                mspecs [0] = NULL;
                        }
 
+#ifndef DISABLE_JIT
                        /* skip visiblity since we call internal methods */
                        mb->skip_visibility = TRUE;
+#endif
 
                        cominterop_setup_marshal_context (&m, adjust_method);
                        m.mb = mb;
@@ -2089,7 +2115,6 @@ cominterop_get_ccw_checked (MonoObject* object, MonoClass* itf, MonoError *error
 
                        vtable [vtable_index--] = mono_compile_method (wrapper_method);
 
-                       
                        for (param_index = sig_adjusted->param_count; param_index >= 0; param_index--)
                                if (mspecs [param_index])
                                        mono_metadata_free_marshal_spec (mspecs [param_index]);
@@ -2249,9 +2274,9 @@ cominterop_get_managed_wrapper_adjusted (MonoMethod *method)
 
        mspecs [0] = NULL;
 
-       if (!preserve_sig) {
+#ifndef DISABLE_JIT
+       if (!preserve_sig)
                hr = mono_mb_add_local (mb, &mono_defaults.int32_class->byval_arg);
-       }
        else if (!MONO_TYPE_IS_VOID (sig->ret))
                hr = mono_mb_add_local (mb, sig->ret);
 
@@ -2315,6 +2340,7 @@ cominterop_get_managed_wrapper_adjusted (MonoMethod *method)
                mono_mb_emit_ldloc (mb, hr);
 
        mono_mb_emit_byte (mb, CEE_RET);
+#endif /* DISABLE_JIT */
 
        mono_cominterop_lock ();
        res = mono_mb_create_method (mb, sig_native, sig_native->param_count + 16);     
@@ -2806,10 +2832,9 @@ mono_cominterop_emit_marshal_safearray (EmitMarshalContext *m, int argnum, MonoT
 {
        MonoMethodBuilder *mb = m->mb;
 
+#ifndef DISABLE_JIT
        switch (action) {
-
        case MARSHAL_ACTION_CONV_IN: {
-
                if (t->attrs & PARAM_ATTRIBUTE_IN) {
 
                        /* Generates IL code for the following algorithm:
@@ -2923,7 +2948,6 @@ mono_cominterop_emit_marshal_safearray (EmitMarshalContext *m, int argnum, MonoT
                break;
 
        case MARSHAL_ACTION_CONV_OUT: {
-
                if (t->attrs & PARAM_ATTRIBUTE_OUT) {
                        /* Generates IL code for the following algorithm:
 
@@ -3041,6 +3065,7 @@ mono_cominterop_emit_marshal_safearray (EmitMarshalContext *m, int argnum, MonoT
        default:
                g_assert_not_reached ();
        }
+#endif /* DISABLE_JIT */
 
        return conv_arg;
 }
index da3b6930aafef0036aee4ecf3e6091fbc60dc6ca..0d0c20b7c6288e4102e2629d558ca1b81228863f 100644 (file)
@@ -783,7 +783,7 @@ mono_init_internal (const char *filename, const char *exe_filename, const char *
 
        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 (
index c0d0f1c11e32f01631f4ab9228bbfbd3aee26d0b..a713e4e39f8e262080bcdaf0edfde8de0e6ada42 100644 (file)
@@ -570,7 +570,7 @@ ves_icall_System_IO_MonoIO_GetCurrentDirectory (gint32 *io_error)
        }
 
        g_free (buf);
-       mono_error_raise_exception (&error);
+       mono_error_set_pending_exception (&error);
        return result;
 }
 
index 5ca728a0489c0ee158e1279b326d7646411a1c5c..60be82c6c144e9daf281083d09020dea81612acc 100644 (file)
@@ -493,18 +493,15 @@ ICALL(ASSEMN_1, "ParseName", ves_icall_System_Reflection_AssemblyName_ParseName)
 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)
@@ -535,8 +532,13 @@ ICALL_TYPE(SIGH, "System.Reflection.Emit.SignatureHelper", SIGH_1)
 ICALL(SIGH_1, "get_signature_field", mono_reflection_sighelper_get_signature_field)
 ICALL(SIGH_2, "get_signature_local", mono_reflection_sighelper_get_signature_local)
 
+#ifndef DISABLE_REFLECTION_EMIT
+ICALL_TYPE(SYMBOLTYPE, "System.Reflection.Emit.SymbolType", SYMBOLTYPE_1)
+ICALL(SYMBOLTYPE_1, "create_unmanaged_type", mono_reflection_create_unmanaged_type)
+#endif
+
 ICALL_TYPE(TYPEB, "System.Reflection.Emit.TypeBuilder", TYPEB_1)
-ICALL(TYPEB_1, "create_generic_class", 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)
@@ -576,6 +578,7 @@ ICALL(MODULE_13, "get_MetadataToken", ves_icall_reflection_get_token)
 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)
index e7d749c6ab9f8f1f89f68226a8554786f4c77c12..c342e592a4c21c6df409727bfff139047d0e0499 100644 (file)
@@ -565,7 +565,8 @@ ves_icall_System_Array_CreateInstanceImpl (MonoReflectionType *type, MonoArray *
 
        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 */
@@ -616,7 +617,8 @@ ves_icall_System_Array_CreateInstanceImpl64 (MonoReflectionType *type, MonoArray
 
        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 */
@@ -1189,8 +1191,7 @@ ves_icall_System_Object_GetType (MonoObject *obj)
 #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;
 }
 
@@ -1208,7 +1209,7 @@ ves_icall_ModuleBuilder_getToken (MonoReflectionModuleBuilder *mb, MonoObject *o
        
        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;
 }
 
@@ -1222,7 +1223,7 @@ ves_icall_ModuleBuilder_getMethodToken (MonoReflectionModuleBuilder *mb,
        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;
 }
 
@@ -1231,15 +1232,15 @@ ves_icall_ModuleBuilder_WriteToFile (MonoReflectionModuleBuilder *mb, HANDLE fil
 {
        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
@@ -1269,6 +1270,22 @@ ves_icall_System_Reflection_Emit_AssemblyBuilder_InternalAddModule (MonoReflecti
        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)
 {
@@ -1277,6 +1294,7 @@ ves_icall_System_Reflection_Emit_CustomAttributeBuilder_GetBlob (MonoReflectionA
        mono_error_set_pending_exception (&error);
        return result;
 }
+#endif
 
 static gboolean
 get_executing (MonoMethod *m, gint32 no, gint32 ilo, gboolean managed, gpointer data)
@@ -1500,7 +1518,7 @@ ves_icall_System_Type_internal_from_handle (MonoType *handle)
        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;
 }
@@ -1752,7 +1770,7 @@ ves_icall_System_Reflection_FieldInfo_internal_from_handle_type (MonoClassField
        }
 
        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;
 }
 
@@ -1769,7 +1787,7 @@ ves_icall_System_Reflection_FieldInfo_GetTypeModifiers (MonoReflectionField *fie
        }
 
        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;
 }
 
@@ -1882,7 +1900,7 @@ ves_icall_MonoField_GetParentType (MonoReflectionField *field, MonoBoolean decla
        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;
 
@@ -2176,13 +2194,15 @@ ves_icall_MonoPropertyInfo_get_property_info (const MonoReflectionProperty *prop
 
        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);
        }
@@ -2198,7 +2218,8 @@ ves_icall_MonoPropertyInfo_get_property_info (const MonoReflectionProperty *prop
                    (((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;
                }
@@ -2210,7 +2231,8 @@ ves_icall_MonoPropertyInfo_get_property_info (const MonoReflectionProperty *prop
                    (((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;
                }
@@ -2232,12 +2254,14 @@ ves_icall_MonoEventInfo_get_event_info (MonoReflectionMonoEvent *event, MonoEven
        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);
 
@@ -2246,7 +2270,8 @@ ves_icall_MonoEventInfo_get_event_info (MonoReflectionMonoEvent *event, MonoEven
 
        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;
        }
@@ -2255,7 +2280,8 @@ ves_icall_MonoEventInfo_get_event_info (MonoReflectionMonoEvent *event, MonoEven
 
        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;
        }
@@ -2264,7 +2290,8 @@ ves_icall_MonoEventInfo_get_event_info (MonoReflectionMonoEvent *event, MonoEven
 
        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;
        }
@@ -2280,7 +2307,8 @@ ves_icall_MonoEventInfo_get_event_info (MonoReflectionMonoEvent *event, MonoEven
 
                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);
                }
        }               
@@ -2414,9 +2442,11 @@ ves_icall_Type_GetInterfaceMapData (MonoReflectionType *type, MonoReflectionType
        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);
 
@@ -2431,10 +2461,12 @@ ves_icall_Type_GetInterfaceMapData (MonoReflectionType *type, MonoReflectionType
        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 ++;
@@ -2448,7 +2480,8 @@ ves_icall_Type_GetPacking (MonoReflectionType *type, guint32 *packing, guint32 *
        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;
@@ -2468,14 +2501,15 @@ ves_icall_RuntimeTypeHandle_GetElementType (MonoReflectionType *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
@@ -2488,7 +2522,7 @@ ves_icall_RuntimeTypeHandle_GetElementType (MonoReflectionType *type)
        else
                return NULL;
 
-       mono_error_raise_exception (&error);
+       mono_error_set_pending_exception (&error);
 
        return ret;
 }
@@ -2507,7 +2541,7 @@ ves_icall_RuntimeTypeHandle_GetBaseType (MonoReflectionType *type)
                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;
 }
@@ -2536,7 +2570,8 @@ ves_icall_RuntimeTypeHandle_IsComObject (MonoReflectionType *type)
        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);
 }
@@ -2557,8 +2592,7 @@ ves_icall_RuntimeTypeHandle_GetModule (MonoReflectionType *type)
        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;
 }
 
@@ -2569,8 +2603,7 @@ ves_icall_RuntimeTypeHandle_GetAssembly (MonoReflectionType *type)
        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;
 }
 
@@ -2598,7 +2631,7 @@ ves_icall_MonoType_get_DeclaringType (MonoReflectionType *type)
                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;
 }
@@ -2678,7 +2711,8 @@ ves_icall_MonoType_GetGenericArguments (MonoReflectionType *type, MonoBoolean ru
                        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);
                }
@@ -2687,7 +2721,8 @@ ves_icall_MonoType_GetGenericArguments (MonoReflectionType *type, MonoBoolean ru
                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);
                }
@@ -2737,7 +2772,7 @@ ves_icall_RuntimeTypeHandle_GetGenericTypeDefinition_impl (MonoReflectionType *t
                        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;
                }
@@ -2756,7 +2791,8 @@ ves_icall_Type_MakeGenericType (MonoReflectionType *type, MonoArray *type_array)
 
        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);
@@ -2782,7 +2818,7 @@ ves_icall_Type_MakeGenericType (MonoReflectionType *type, MonoArray *type_array)
        }
 
        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;
 }
@@ -2842,7 +2878,8 @@ ves_icall_Type_GetGenericParameterConstraints (MonoReflectionType *type)
        res = mono_array_new (domain, mono_defaults.monotype_class, count);
        for (i = 0; i < count; i++) {
                rt = mono_type_get_object_checked (domain, &param_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);
        }
@@ -2885,13 +2922,15 @@ ves_icall_MonoType_GetCorrespondingInflatedMethod (MonoReflectionType *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;
 
        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;
                }
         }
 
@@ -3065,7 +3104,8 @@ ves_icall_MonoMethod_GetGenericArguments (MonoReflectionMethod *method)
 
                        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);
                        }
@@ -3083,7 +3123,8 @@ ves_icall_MonoMethod_GetGenericArguments (MonoReflectionMethod *method)
                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);
        }
@@ -3438,12 +3479,14 @@ ves_icall_System_Enum_ToObject (MonoReflectionType *enumType, guint64 value)
        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;
@@ -3478,7 +3521,8 @@ ves_icall_System_Enum_get_value (MonoObject *eobj)
        
        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);
@@ -3498,7 +3542,8 @@ ves_icall_System_Enum_get_underlying_type (MonoReflectionType *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;
 
        etype = mono_class_enum_basetype (klass);
        if (!etype) {
@@ -3507,7 +3552,7 @@ ves_icall_System_Enum_get_underlying_type (MonoReflectionType *type)
        }
 
        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;
 }
@@ -3611,7 +3656,9 @@ ves_icall_System_Enum_GetEnumValuesAndNames (MonoReflectionType *type, MonoArray
        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."));
@@ -3763,8 +3810,8 @@ handle_parent:
        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
@@ -4363,13 +4410,15 @@ ves_icall_Type_GetNestedTypes (MonoReflectionType *type, MonoString *name, guint
        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);
@@ -4412,7 +4461,8 @@ ves_icall_Type_GetNestedTypes (MonoReflectionType *type, MonoString *name, guint
                }
 
                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);
        }
@@ -4422,10 +4472,12 @@ ves_icall_Type_GetNestedTypes (MonoReflectionType *type, MonoString *name, guint
        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;
 }
 
@@ -4805,7 +4857,8 @@ ves_icall_System_Reflection_Assembly_GetReferencedAssemblies (MonoReflectionAsse
 
                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])));
 
@@ -4818,7 +4871,8 @@ ves_icall_System_Reflection_Assembly_GetReferencedAssemblies (MonoReflectionAsse
                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);
 
@@ -4829,7 +4883,8 @@ ves_icall_System_Reflection_Assembly_GetReferencedAssemblies (MonoReflectionAsse
                        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);
                }
@@ -4916,7 +4971,8 @@ ves_icall_System_Reflection_Assembly_GetManifestResourceInternal (MonoReflection
 
        
        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);
@@ -5073,13 +5129,16 @@ ves_icall_System_Reflection_Assembly_GetModulesInternal (MonoReflectionAssembly
        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;
                }
@@ -5088,7 +5147,8 @@ ves_icall_System_Reflection_Assembly_GetModulesInternal (MonoReflectionAssembly
                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 {
@@ -5099,7 +5159,8 @@ ves_icall_System_Reflection_Assembly_GetModulesInternal (MonoReflectionAssembly
                                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);
                }
        }
@@ -5124,7 +5185,7 @@ ves_icall_GetCurrentMethod (void)
                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;
 }
 
@@ -5184,7 +5245,7 @@ ves_icall_System_Reflection_MethodBase_GetMethodFromHandleInternalType (MonoMeth
        } 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;
 }
 
@@ -5291,7 +5352,7 @@ vell_icall_MonoType_get_core_clr_security_level (MonoReflectionType *rfield)
        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);
 }
 
@@ -5606,7 +5667,8 @@ ves_icall_System_Reflection_Assembly_GetTypes (MonoReflectionAssembly *assembly,
        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) {
@@ -5617,7 +5679,9 @@ ves_icall_System_Reflection_Assembly_GetTypes (MonoReflectionAssembly *assembly,
                                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) {
@@ -5819,7 +5883,8 @@ ves_icall_System_Reflection_Module_InternalGetTypes (MonoReflectionModule *modul
                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);
@@ -6072,7 +6137,7 @@ ves_icall_System_Reflection_Module_ResolveMemberToken (MonoImage *image, guint32
                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;
                }
@@ -6084,7 +6149,7 @@ ves_icall_System_Reflection_Module_ResolveMemberToken (MonoImage *image, guint32
                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
@@ -6094,7 +6159,7 @@ ves_icall_System_Reflection_Module_ResolveMemberToken (MonoImage *image, guint32
                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
@@ -6105,7 +6170,7 @@ ves_icall_System_Reflection_Module_ResolveMemberToken (MonoImage *image, guint32
                        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
@@ -6115,7 +6180,7 @@ ves_icall_System_Reflection_Module_ResolveMemberToken (MonoImage *image, guint32
                        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
@@ -6188,7 +6253,7 @@ ves_icall_ModuleBuilder_create_modified_type (MonoReflectionTypeBuilder *tb, Mon
                        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 '*':
@@ -6226,7 +6291,7 @@ ves_icall_ModuleBuilder_create_modified_type (MonoReflectionTypeBuilder *tb, Mon
        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;
 }
@@ -6269,7 +6334,7 @@ ves_icall_Type_make_array_type (MonoReflectionType *type, int rank)
 
        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);
@@ -6277,7 +6342,7 @@ ves_icall_Type_make_array_type (MonoReflectionType *type, int rank)
                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;
 }
@@ -6291,12 +6356,15 @@ ves_icall_Type_make_byref_type (MonoReflectionType *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;
+
        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;
 }
@@ -6310,14 +6378,16 @@ ves_icall_Type_MakePointerType (MonoReflectionType *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;
        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;
 }
@@ -6333,7 +6403,8 @@ ves_icall_System_Delegate_CreateDelegate_internal (MonoReflectionType *type, Mon
        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 */
@@ -6355,7 +6426,8 @@ ves_icall_System_Delegate_CreateDelegate_internal (MonoReflectionType *type, Mon
        }
 
        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 */
@@ -6381,7 +6453,9 @@ ves_icall_System_Delegate_AllocDelegateLike_internal (MonoDelegate *delegate)
        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;
@@ -6393,7 +6467,7 @@ ves_icall_System_Delegate_GetVirtualMethod_internal (MonoDelegate *delegate)
        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;
 }
 
@@ -6503,7 +6577,9 @@ ves_icall_Remoting_RealProxy_GetTransparentProxy (MonoObject *this_obj, MonoStri
        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);
@@ -6537,7 +6613,7 @@ ves_icall_Remoting_RealProxy_InternalGetProxyType (MonoTransparentProxy *tp)
 {
        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;
 }
@@ -6568,7 +6644,7 @@ ves_icall_System_Environment_get_MachineName (void)
        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);
@@ -6734,7 +6810,9 @@ ves_icall_System_Environment_GetEnvironmentVariableNames (void)
                                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++;
                        }
@@ -6878,7 +6956,7 @@ ves_icall_System_Environment_GetWindowsFolderPath (int folder)
                        ++ 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
@@ -6930,7 +7008,9 @@ ves_icall_System_Environment_GetLogicalDrives (void)
                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);
@@ -7098,7 +7178,8 @@ ves_icall_Remoting_RemotingServices_GetVirtualMethod (
        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;
@@ -7134,7 +7215,7 @@ ves_icall_Remoting_RemotingServices_GetVirtualMethod (
                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;
 }
 
@@ -7176,7 +7257,8 @@ ves_icall_System_Runtime_Activation_ActivationServices_AllocateUninitializedClas
        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"));
@@ -7420,14 +7502,15 @@ ves_icall_System_Activator_CreateInstanceInternal (MonoReflectionType *type)
        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;
 }
 
@@ -7488,7 +7571,6 @@ ves_icall_MonoMethod_get_base_method (MonoReflectionMethod *m, gboolean definiti
                        */
                        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);
@@ -7558,7 +7640,7 @@ ves_icall_MonoMethod_get_base_method (MonoReflectionMethod *m, gboolean definiti
                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;
 }
 
@@ -7757,7 +7839,7 @@ ves_icall_System_Runtime_InteropServices_Marshal_Prelink (MonoReflectionMethod *
        MonoError error;
 
        prelink_method (method->method, &error);
-       mono_error_raise_exception (&error);
+       mono_error_set_pending_exception (&error);
 }
 
 ICALL_EXPORT void
@@ -7769,11 +7851,13 @@ ves_icall_System_Runtime_InteropServices_Marshal_PrelinkAll (MonoReflectionType
        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;
        }
 }
 
@@ -7868,7 +7952,7 @@ ves_icall_ParameterInfo_GetTypeModifiers (MonoReflectionParameter *param, MonoBo
                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;
 }
 
@@ -7897,7 +7981,7 @@ ves_icall_MonoPropertyInfo_GetTypeModifiers (MonoReflectionProperty *property, M
        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;
 }
 
@@ -7960,7 +8044,8 @@ custom_attrs_defined_internal (MonoObject *obj, MonoReflectionType *attr_type)
        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)) {
@@ -7984,7 +8069,8 @@ custom_attrs_get_by_type (MonoObject *obj, MonoReflectionType *attr_type)
 
        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);
@@ -8034,7 +8120,8 @@ ves_icall_System_ComponentModel_Win32Exception_W32ErrorMessage (guint32 code)
                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;
index a847b0f58624a0587765b4bd6e526bda2787d1d6..00ddf5da912dcca1830770965bf33e3bb80d2e89 100644 (file)
@@ -1216,7 +1216,8 @@ guint
 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) {
@@ -1312,7 +1313,7 @@ emit_ptr_to_object_conv (MonoMethodBuilder *mb, MonoType *type, MonoMarshalConv
                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 */
@@ -1550,16 +1551,23 @@ emit_ptr_to_object_conv (MonoMethodBuilder *mb, MonoType *type, MonoMarshalConv
 }
 
 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
@@ -1572,6 +1580,7 @@ conv_to_icall (MonoMarshalConv conv)
        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:
@@ -1595,16 +1604,20 @@ conv_to_icall (MonoMarshalConv conv)
        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;
@@ -1623,6 +1636,7 @@ static void
 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:
@@ -1657,8 +1671,8 @@ emit_object_to_ptr_conv (MonoMethodBuilder *mb, MonoType *type, MonoMarshalConv
                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:
@@ -1667,8 +1681,8 @@ emit_object_to_ptr_conv (MonoMethodBuilder *mb, MonoType *type, MonoMarshalConv
                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: {
@@ -1678,7 +1692,7 @@ emit_object_to_ptr_conv (MonoMethodBuilder *mb, MonoType *type, MonoMarshalConv
                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: {
@@ -1940,8 +1954,9 @@ emit_struct_conv_full (MonoMethodBuilder *mb, MonoClass *klass, gboolean to_obje
                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);
@@ -5109,7 +5124,7 @@ emit_marshal_string (EmitMarshalContext *m, int argnum, MonoType *t,
                        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);
                }
@@ -5150,10 +5165,11 @@ emit_marshal_string (EmitMarshalContext *m, int argnum, MonoType *t,
                        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;
                }
 
@@ -5184,7 +5200,7 @@ emit_marshal_string (EmitMarshalContext *m, int argnum, MonoType *t,
                }
 
                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 */
@@ -5215,27 +5231,28 @@ emit_marshal_string (EmitMarshalContext *m, int argnum, MonoType *t,
                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;
 
@@ -5514,7 +5531,7 @@ emit_marshal_object (EmitMarshalContext *m, int argnum, MonoType *t,
                                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) {
@@ -5544,7 +5561,7 @@ emit_marshal_object (EmitMarshalContext *m, int argnum, MonoType *t,
                        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);
@@ -5646,7 +5663,7 @@ emit_marshal_object (EmitMarshalContext *m, int argnum, MonoType *t,
                                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) {
@@ -5662,7 +5679,7 @@ emit_marshal_object (EmitMarshalContext *m, int argnum, MonoType *t,
                                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;
@@ -5745,7 +5762,7 @@ emit_marshal_object (EmitMarshalContext *m, int argnum, MonoType *t,
                        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 */
@@ -5795,7 +5812,7 @@ emit_marshal_object (EmitMarshalContext *m, int argnum, MonoType *t,
                        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;
                }
@@ -5869,10 +5886,11 @@ emit_marshal_object (EmitMarshalContext *m, int argnum, MonoType *t,
        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;
                        }
                }
@@ -5931,7 +5949,7 @@ emit_marshal_object (EmitMarshalContext *m, int argnum, MonoType *t,
 
        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;
                }
@@ -6148,7 +6166,7 @@ emit_marshal_array (EmitMarshalContext *m, int argnum, MonoType *t,
                        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;
@@ -6228,12 +6246,13 @@ emit_marshal_array (EmitMarshalContext *m, int argnum, MonoType *t,
                        /* 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);
@@ -6297,7 +6316,7 @@ emit_marshal_array (EmitMarshalContext *m, int argnum, MonoType *t,
                                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);
                        }
                }
 
@@ -6357,7 +6376,7 @@ emit_marshal_array (EmitMarshalContext *m, int argnum, MonoType *t,
                                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 */
@@ -6419,7 +6438,7 @@ emit_marshal_array (EmitMarshalContext *m, int argnum, MonoType *t,
                        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;
@@ -6594,7 +6613,7 @@ emit_marshal_array (EmitMarshalContext *m, int argnum, MonoType *t,
                        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 {
@@ -6702,6 +6721,7 @@ emit_marshal_array (EmitMarshalContext *m, int argnum, MonoType *t,
 
                /* Emit marshalling code */
                if (is_string) {
+                       int stind_op;
                        g_assert (conv != MONO_MARSHAL_CONV_INVALID);
 
                        /* dest */
@@ -6713,8 +6733,8 @@ emit_marshal_array (EmitMarshalContext *m, int argnum, MonoType *t,
 
                        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.");
@@ -6799,6 +6819,7 @@ emit_marshal_array (EmitMarshalContext *m, int argnum, MonoType *t,
 
                /* Emit marshalling code */
                if (is_string) {
+                       int stind_op;
                        g_assert (conv != MONO_MARSHAL_CONV_INVALID);
 
                        /* dest */
@@ -6810,8 +6831,8 @@ emit_marshal_array (EmitMarshalContext *m, int argnum, MonoType *t,
 
                        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.");
@@ -7163,10 +7184,12 @@ emit_marshal (EmitMarshalContext *m, int argnum, MonoType *t,
                return emit_marshal_string (m, argnum, t, spec, conv_arg, conv_arg_type, action);
        case MONO_TYPE_CLASS:
        case MONO_TYPE_OBJECT:
-#ifndef DISABLE_COM
+#if !defined(DISABLE_COM) && !defined(DISABLE_JIT)
                if (spec && spec->native == MONO_NATIVE_STRUCT)
                        return emit_marshal_variant (m, argnum, t, spec, conv_arg, conv_arg_type, action);
+#endif
 
+#if !defined(DISABLE_COM)
                if (spec && (spec->native == MONO_NATIVE_IUNKNOWN ||
                        spec->native == MONO_NATIVE_IDISPATCH ||
                        spec->native == MONO_NATIVE_INTERFACE))
index 4f6eb93ba60da7444c0b6b873b002bb1f5dd9dab..09e6027f4a0d53b7f5c2d50eed49cc7c59b1479b 100644 (file)
@@ -185,9 +185,11 @@ mono_mb_create_method (MonoMethodBuilder *mb, MonoMethodSignature *signature, in
 #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)
index 445df5c8334ef7931c3c373c82a5168d71d8842b..e7148a823f68f457bcaebb95496b4d1114a35f7c 100644 (file)
@@ -502,7 +502,12 @@ mono_determine_physical_ram_available_size (void)
        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;
        }
index 4a316f33cc1da1bf8920ab2a73cb3b729bfe394a..17d5eea26ef0a572d6a7ff0ad8c2676f88629860 100644 (file)
@@ -201,23 +201,24 @@ typedef struct {
 
 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 {
@@ -1347,7 +1348,7 @@ void        mono_reflection_create_internal_class (MonoReflectionTypeBuilder *tb
 
 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);
 
@@ -1392,7 +1393,7 @@ gboolean
 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);
index d477f51c245565a438cfa64ce3d1e469e98a2a1c..61a8a597d407c0722d61299cc1f83d1980b0435c 100644 (file)
@@ -195,7 +195,7 @@ static guint32 mono_image_get_inflated_method_token (MonoDynamicImage *assembly,
 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); \
@@ -2062,7 +2062,8 @@ field_encode_signature (MonoDynamicImage *assembly, MonoReflectionFieldBuilder *
        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);
@@ -3318,7 +3319,8 @@ mono_reflection_method_on_tb_inst_get_handle (MonoReflectionMethodOnTypeBuilderI
 
        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);
@@ -3555,8 +3557,10 @@ create_generic_typespec (MonoDynamicImage *assembly, MonoReflectionTypeBuilder *
        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);
@@ -3649,16 +3653,18 @@ fail:
 }
 
 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
@@ -3682,7 +3688,8 @@ mono_image_get_generic_field_token (MonoDynamicImage *assembly, MonoReflectionFi
        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 */
@@ -5581,7 +5588,8 @@ mono_image_create_token (MonoDynamicImage *assembly, MonoObject *obj,
                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);
@@ -6854,13 +6862,13 @@ register_module (MonoDomain *domain, MonoReflectionModuleBuilder *res, MonoDynam
        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;
@@ -6872,10 +6880,10 @@ mono_image_module_basic_init (MonoReflectionModuleBuilder *moduleb)
                 */
                /*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);
 
@@ -6897,6 +6905,15 @@ mono_image_module_basic_init (MonoReflectionModuleBuilder *moduleb)
                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
@@ -6957,7 +6974,7 @@ mono_module_get_object   (MonoDomain *domain, MonoImage *image)
        MonoError error;
        MonoReflectionModule *result;
        result = mono_module_get_object_checked (domain, image, &error);
-       mono_error_raise_exception (&error);
+       mono_error_cleanup (&error);
        return result;
 }
 
@@ -7009,7 +7026,7 @@ mono_module_file_get_object (MonoDomain *domain, MonoImage *image, int table_ind
        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;
 }
 
@@ -7143,7 +7160,7 @@ mono_type_get_object (MonoDomain *domain, MonoType *type)
 {
        MonoError error;
        MonoReflectionType *ret = mono_type_get_object_checked (domain, type, &error);
-       mono_error_raise_exception (&error);
+       mono_error_cleanup (&error);
 
        return ret;
 }
@@ -7281,7 +7298,7 @@ mono_method_get_object (MonoDomain *domain, MonoMethod *method, MonoClass *refcl
        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;
 }
 
@@ -7403,7 +7420,7 @@ mono_field_get_object (MonoDomain *domain, MonoClass *klass, MonoClassField *fie
        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;
 }
 
@@ -7469,7 +7486,7 @@ mono_property_get_object (MonoDomain *domain, MonoClass *klass, MonoProperty *pr
        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;
 }
 
@@ -7514,7 +7531,7 @@ mono_event_get_object (MonoDomain *domain, MonoClass *klass, MonoEvent *event)
        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;
 }
 
@@ -7776,7 +7793,7 @@ mono_method_body_get_object (MonoDomain *domain, MonoMethod *method)
 {
        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;
 }
 
@@ -9378,7 +9395,6 @@ create_custom_attr (MonoImage *image, MonoMethod *method, const guchar *data, gu
        void *params_buf [32];
        void **params = NULL;
        MonoMethodSignature *sig;
-       MonoObject *exc = NULL;
 
        mono_error_init (error);
 
@@ -9426,11 +9442,14 @@ create_custom_attr (MonoImage *image, MonoMethod *method, const guchar *data, gu
        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;
@@ -9529,8 +9548,6 @@ fail:
        free_param_data (method->signature, params);
        if (params != params_buf)
                mono_gc_free_fixed (params);
-       if (exc)
-               mono_raise_exception ((MonoException*)exc);
        return NULL;
 }
        
@@ -9673,34 +9690,35 @@ fail:
        *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)
@@ -9710,8 +9728,8 @@ mono_reflection_resolve_custom_attribute_data (MonoReflectionMethod *ref_method,
                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);
        }
@@ -9721,20 +9739,20 @@ mono_reflection_resolve_custom_attribute_data (MonoReflectionMethod *ref_method,
                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);
@@ -9742,10 +9760,18 @@ mono_reflection_resolve_custom_attribute_data (MonoReflectionMethod *ref_method,
 
        *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*
@@ -9851,7 +9877,7 @@ mono_custom_attrs_from_index (MonoImage *image, guint32 idx)
 {
        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;
 }
 /**
@@ -9972,7 +9998,7 @@ mono_custom_attrs_from_class (MonoClass *klass)
 {
        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;
 }
 
@@ -10006,7 +10032,7 @@ mono_custom_attrs_from_assembly (MonoAssembly *assembly)
 {
        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;
 }
 
@@ -10043,7 +10069,7 @@ mono_custom_attrs_from_property (MonoClass *klass, MonoProperty *property)
 {
        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;
 }
 
@@ -10067,7 +10093,7 @@ mono_custom_attrs_from_event (MonoClass *klass, MonoEvent *event)
 {
        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;
 }
 
@@ -10091,7 +10117,7 @@ mono_custom_attrs_from_field (MonoClass *klass, MonoClassField *field)
 {
        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;
 }
 
@@ -10125,7 +10151,7 @@ mono_custom_attrs_from_param (MonoMethod *method, guint32 param)
 {
        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;
 }
 
@@ -10225,7 +10251,7 @@ mono_custom_attrs_get_attr (MonoCustomAttrInfo *ainfo, MonoClass *attr_klass)
 {
        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;
 }
 
@@ -10465,7 +10491,7 @@ mono_reflection_get_custom_attrs_data (MonoObject *obj)
        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;
 }
 
@@ -10870,8 +10896,9 @@ is_sre_generic_instance (MonoClass *klass)
 }
 
 static void
-init_type_builder_generics (MonoObject *type)
+init_type_builder_generics (MonoObject *type, MonoError *error)
 {
+       mono_error_init (error);
 }
 
 #endif /* !DISABLE_REFLECTION_EMIT */
@@ -11271,7 +11298,7 @@ mono_reflection_get_custom_attrs_blob (MonoReflectionAssembly *assembly, MonoObj
 {
        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;
 }
 
@@ -11540,25 +11567,30 @@ mono_reflection_setup_generic_class (MonoReflectionTypeBuilder *tb)
 {
 }
 
-/*
+/**
  * 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));
 
@@ -11572,8 +11604,8 @@ mono_reflection_create_generic_class (MonoReflectionTypeBuilder *tb)
 
        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 */
@@ -11585,6 +11617,7 @@ mono_reflection_create_generic_class (MonoReflectionTypeBuilder *tb)
        }
 
        klass->generic_container->context.class_inst = mono_get_shared_generic_inst (klass->generic_container);
+       return TRUE;
 }
 
 /**
@@ -11778,9 +11811,9 @@ mono_reflection_marshal_as_attribute_from_marshal_spec (MonoDomain *domain, Mono
 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;
@@ -11789,7 +11822,7 @@ reflection_methodbuilder_to_mono_method (MonoClass *klass,
        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
@@ -11833,10 +11866,10 @@ reflection_methodbuilder_to_mono_method (MonoClass *klass,
 
                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;
 
@@ -11889,16 +11922,16 @@ reflection_methodbuilder_to_mono_method (MonoClass *klass,
                                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;
@@ -11921,8 +11954,8 @@ reflection_methodbuilder_to_mono_method (MonoClass *klass,
                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;
                }
@@ -12003,8 +12036,8 @@ reflection_methodbuilder_to_mono_method (MonoClass *klass,
                                }
 
                                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)
@@ -12025,11 +12058,12 @@ reflection_methodbuilder_to_mono_method (MonoClass *klass,
                                        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;
                                        }
                                }
                        }
@@ -12063,7 +12097,8 @@ ctorbuilder_to_mono_method (MonoClass *klass, MonoReflectionCtorBuilder* mb, Mon
        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 */
@@ -12092,7 +12127,8 @@ methodbuilder_to_mono_method (MonoClass *klass, MonoReflectionMethodBuilder* mb,
        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 */
@@ -12188,8 +12224,12 @@ mono_reflection_bind_generic_parameters (MonoReflectionType *type, int type_argc
        }
 
        /* 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)) {
@@ -12231,10 +12271,9 @@ mono_class_bind_generic_parameters (MonoClass *klass, int type_argc, MonoType **
        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;
@@ -12243,6 +12282,8 @@ mono_reflection_bind_generic_method_parameters (MonoReflectionMethod *rmethod, M
        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
@@ -12251,13 +12292,12 @@ mono_reflection_bind_generic_method_parameters (MonoReflectionMethod *rmethod, M
                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;
@@ -12278,10 +12318,10 @@ mono_reflection_bind_generic_method_parameters (MonoReflectionMethod *rmethod, M
        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);
@@ -12290,8 +12330,8 @@ mono_reflection_bind_generic_method_parameters (MonoReflectionMethod *rmethod, M
        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*/
@@ -12306,14 +12346,25 @@ mono_reflection_bind_generic_method_parameters (MonoReflectionMethod *rmethod, M
                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 *
@@ -13400,10 +13451,9 @@ mono_reflection_initialize_generic_parameter (MonoReflectionGenericParam *gparam
 }
 
 
-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;
@@ -13411,8 +13461,10 @@ mono_reflection_sighelper_get_signature_local (MonoReflectionSigHelper *sig)
        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);
 
@@ -13421,8 +13473,8 @@ mono_reflection_sighelper_get_signature_local (MonoReflectionSigHelper *sig)
        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;
                }
        }
 
@@ -13433,30 +13485,39 @@ mono_reflection_sighelper_get_signature_local (MonoReflectionSigHelper *sig)
        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;
        }
 
@@ -13468,10 +13529,18 @@ mono_reflection_sighelper_get_signature_field (MonoReflectionSigHelper *sig)
        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;
@@ -13599,7 +13668,10 @@ reflection_create_dynamic_method (MonoReflectionDynamicMethod *mb, MonoError *er
                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);
@@ -13622,8 +13694,6 @@ reflection_create_dynamic_method (MonoReflectionDynamicMethod *mb, MonoError *er
        }
        g_slist_free (mb->referenced_by);
 
-       g_free (rmb.refs);
-
        /* ilgen is no longer needed */
        mb->ilgen = NULL;
 
@@ -14109,10 +14179,11 @@ mono_reflection_setup_generic_class (MonoReflectionTypeBuilder *tb)
        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
@@ -14227,8 +14298,9 @@ mono_reflection_create_dynamic_method (MonoReflectionDynamicMethod *mb)
 }
 
 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;
 }
 
index 54630c6ee033853a8ac63065b70eb7cfa1f3a100..e9f9b1a81a7a5ddeaad89a7ae0ddac596f328fcc 100644 (file)
@@ -689,6 +689,11 @@ sgen_client_binary_protocol_evacuating_blocks (size_t block_size)
 {
 }
 
+static void G_GNUC_UNUSED
+sgen_client_binary_protocol_concurrent_sweep_end (long long timestamp)
+{
+}
+
 int sgen_thread_handshake (BOOL suspend);
 gboolean sgen_suspend_thread (SgenThreadInfo *info);
 gboolean sgen_resume_thread (SgenThreadInfo *info);
index cadd83f30fd0d1f37a30312a54e32b9f213d1401..bbd97e955df2a69003dafb75b8333c0bb505859b 100644 (file)
@@ -1242,16 +1242,14 @@ create_allocator (int atype, gboolean slowpath)
                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) {
@@ -1350,14 +1348,6 @@ create_allocator (int atype, gboolean slowpath)
                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);
        }
 
        /*
@@ -2738,13 +2728,11 @@ sgen_client_log_timing (GGTimingInfo *info, mword last_major_num_sections, mword
        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
index 10ac567111ec81b022d058662e3dbde0ec612375..1c45e375af5dffb372cc6b0338189ecee7e96d82 100644 (file)
 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
@@ -51,11 +55,15 @@ sgen_suspend_thread (SgenThreadInfo *info)
        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;
 
@@ -117,7 +125,9 @@ sgen_thread_handshake (BOOL suspend)
                        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;
                }
index bf619214c8557f19a08553296a81a69719ee3d1c..462fa98df8143115552eeb48bc32c6e21813a529 100644 (file)
@@ -47,13 +47,6 @@ epoll_init (gint wakeup_pipe_fd)
        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)
 {
@@ -127,7 +120,6 @@ epoll_event_wait (void (*callback) (gint fd, gint events, gpointer user_data), g
 
 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,
index 093d3399dc947736f20140470c3ef08cfa306aa0..e162c3cc9be24eec2bc8dfe1558449bedb9ac314 100644 (file)
@@ -43,13 +43,6 @@ kqueue_init (gint wakeup_pipe_fd)
        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)
 {
@@ -124,7 +117,6 @@ kqueue_event_wait (void (*callback) (gint fd, gint events, gpointer user_data),
 
 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,
index 4adae56791b40af7ffab900966b10c267a908000..4d4cceb090269f97b4f53ecad27601c128da93a6 100644 (file)
@@ -28,12 +28,6 @@ poll_init (gint wakeup_pipe_fd)
        return TRUE;
 }
 
-static void
-poll_cleanup (void)
-{
-       g_free (poll_fds);
-}
-
 static void
 poll_register_fd (gint fd, gint events, gboolean is_new)
 {
@@ -236,7 +230,6 @@ poll_event_wait (void (*callback) (gint fd, gint events, gpointer user_data), gp
 
 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,
index b479fb1bd35a20946061e8a5c812a2fa716afc81..2851c7547b8b859f8b296c56cba264bf842ca4c7 100644 (file)
@@ -32,7 +32,6 @@
 
 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);
@@ -551,24 +550,6 @@ cleanup (void)
        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
index 856f0abf8797153ac0049e640442c89ba8097713..b8d8ae5de713d94a86501f4e77931f31d6043165 100644 (file)
@@ -455,7 +455,7 @@ static void thread_cleanup (MonoInternalThread *thread)
        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 ()) {
@@ -730,7 +730,7 @@ static guint32 WINAPI start_wrapper_internal(void *data)
        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 */
@@ -1634,7 +1634,8 @@ gint32 ves_icall_System_Threading_WaitHandle_WaitAll_internal(MonoArray *mono_ha
 
        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 */
@@ -1681,7 +1682,8 @@ gint32 ves_icall_System_Threading_WaitHandle_WaitAny_internal(MonoArray *mono_ha
                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;
        }
 }
 
@@ -1705,7 +1707,8 @@ gint32 ves_icall_System_Threading_WaitHandle_WaitOne_internal(HANDLE handle, gin
        
        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
@@ -1727,7 +1730,8 @@ ves_icall_System_Threading_WaitHandle_SignalAndWait_Internal (HANDLE toSignal, H
        
        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)
index 39752cdf079a71d5d6a9aa85705aadc32b0e2141..ce3c864090f6279345a817fbd51bb370d4d85b29 100755 (executable)
@@ -406,6 +406,8 @@ common_sources = \
        seq-points.h    \
        ir-emit.h               \
        method-to-ir.c          \
+       cfgdump.h               \
+       cfgdump.c               \
        decompose.c             \
        mini.h                  \
        version.h               \
index f65b3a6ee68a58a0b22aae2c31695b1d46471843..0217ba5b29cc92e9e8c223b86a9a72570a0c850f 100644 (file)
@@ -10463,8 +10463,10 @@ mono_compile_assembly (MonoAssembly *ass, guint32 opts, const char *aot_options)
        }
 
 #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)
index 2d789a2f1767d43ecfcbce86822b9ad78132ea56..d3f3cf2e952c82b946e69b7a834082609d318d2e 100644 (file)
@@ -5222,7 +5222,9 @@ get_new_trampoline_from_page (int tramp_type)
                /* 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;
index 7b2bedd56470c901f27cba63a015a2309c382c16..ca8289b81c8313619b3f5c3e5fec193c4a503298 100644 (file)
@@ -249,7 +249,8 @@ mono_replace_ins (MonoCompile *cfg, MonoBasicBlock *bb, MonoInst *ins, MonoInst
                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]);
diff --git a/mono/mini/cfgdump.c b/mono/mini/cfgdump.c
new file mode 100644 (file)
index 0000000..7b9cfd3
--- /dev/null
@@ -0,0 +1,556 @@
+/*
+ * 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) */
diff --git a/mono/mini/cfgdump.h b/mono/mini/cfgdump.h
new file mode 100644 (file)
index 0000000..ef58553
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * 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__ */
index 10a5bdfd5b40a943f3a0b627cd4cb91265ff7121..9546009e724697247abc5e7e3e11ff1f67c8e685 100644 (file)
@@ -933,6 +933,8 @@ mono_decompose_long_opts (MonoCompile *cfg)
                                MONO_EMIT_NEW_BIALU_IMM (cfg, OP_XOR_IMM, MONO_LVREG_LS (tree->dreg), MONO_LVREG_LS (tree->sreg1), tree->inst_ls_word);
                                MONO_EMIT_NEW_BIALU_IMM (cfg, OP_XOR_IMM, MONO_LVREG_MS (tree->dreg), MONO_LVREG_MS (tree->sreg1), tree->inst_ms_word);
                                break;
+#ifdef TARGET_POWERPC
+/* FIXME This is normally handled in cprop. Proper fix or remove if no longer needed. */
                        case OP_LSHR_UN_IMM:
                                if (tree->inst_c1 == 32) {
 
@@ -941,20 +943,12 @@ mono_decompose_long_opts (MonoCompile *cfg)
                                         * later apply the speedup to the left shift as well
                                         * See BUG# 57957.
                                         */
-                                       /* FIXME: Move this to the strength reduction pass */
                                        /* just move the upper half to the lower and zero the high word */
                                        MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, MONO_LVREG_LS (tree->dreg), MONO_LVREG_MS (tree->sreg1));
                                        MONO_EMIT_NEW_ICONST (cfg, MONO_LVREG_MS (tree->dreg), 0);
                                }
                                break;
-                       case OP_LSHL_IMM:
-                               if (tree->inst_c1 == 32) {
-                                       /* just move the lower half to the upper and zero the lower word */
-                                       MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, MONO_LVREG_MS (tree->dreg), MONO_LVREG_LS (tree->sreg1));
-                                       MONO_EMIT_NEW_ICONST (cfg, MONO_LVREG_LS (tree->dreg), 0);
-                               }
-                               break;
-
+#endif
                        case OP_LCOMPARE: {
                                MonoInst *next = mono_inst_next (tree, FILTER_IL_SEQ_POINT);
 
index f1c27d7dc404fe214ff5d13837dfd7677988ea65..2bbd9f48dd4d50b49a9a29d939bda2fb2c849b3b 100644 (file)
@@ -1637,19 +1637,6 @@ mono_main (int argc, char* argv[])
                        gc_descr = mono_gc_get_description ();
                        g_print ("\tGC:            %s\n", gc_descr);
                        g_free (gc_descr);
-                       if (mini_verbose) {
-                               const char *cerror;
-                               const char *clibpath;
-                               mono_init ("mono");
-                               cerror = mono_check_corlib_version ();
-                               clibpath = mono_defaults.corlib? mono_image_get_filename (mono_defaults.corlib): "unknown";
-                               if (cerror) {
-                                       g_print ("The currently installed mscorlib doesn't match this runtime version.\n");
-                                       g_print ("The error is: %s\n", cerror);
-                                       g_print ("mscorlib.dll loaded at: %s\n", clibpath);
-                                       return 1;
-                               }
-                       }
                        return 0;
                } else if (strcmp (argv [i], "--help") == 0 || strcmp (argv [i], "-h") == 0) {
                        mini_usage ();
@@ -1995,7 +1982,7 @@ mono_main (int argc, char* argv[])
 
        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);
@@ -2377,83 +2364,154 @@ mono_set_crash_chaining (gboolean chain_crashes)
        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);
+}
+
index 7118e19c8cec06cd9fb7588d5e7c89f2e9564706..21f87eb5819d7a47a4e0ca63cf739666226b79bb 100644 (file)
@@ -203,6 +203,7 @@ load_file (const char *name) {
                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;
 }
index f23c5ff3bb9e5c1278220b19656c554e6f85d527..32cd496f30f19b43817bfef49cfe95f27a2d5a08 100644 (file)
@@ -181,6 +181,69 @@ mono_strength_reduction_ins (MonoCompile *cfg, MonoInst *ins, const char **spec)
 #endif
                break;
        }
+#if SIZEOF_REGISTER == 4
+       case OP_LSHR_IMM: {
+               if (ins->inst_c1 == 32) {
+                       MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, MONO_LVREG_LS (ins->dreg), MONO_LVREG_MS (ins->sreg1));
+                       MONO_EMIT_NEW_BIALU_IMM (cfg, OP_ISHR_IMM, MONO_LVREG_MS (ins->dreg), MONO_LVREG_MS (ins->sreg1), 31);
+               } else if (ins->inst_c1 == 0) {
+                       MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, MONO_LVREG_LS (ins->dreg), MONO_LVREG_LS (ins->sreg1));
+                       MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, MONO_LVREG_MS (ins->dreg), MONO_LVREG_MS (ins->sreg1));
+               } else if (ins->inst_c1 > 32) {
+                       MONO_EMIT_NEW_BIALU_IMM (cfg, OP_ISHR_IMM, MONO_LVREG_LS (ins->dreg), MONO_LVREG_MS (ins->sreg1), ins->inst_c1 - 32);
+                       MONO_EMIT_NEW_BIALU_IMM (cfg, OP_ISHR_IMM, MONO_LVREG_MS (ins->dreg), MONO_LVREG_MS (ins->sreg1), 31);
+               } else {
+                       guint32 tmpreg = alloc_ireg (cfg);
+                       MONO_EMIT_NEW_BIALU_IMM (cfg, OP_ISHL_IMM, tmpreg, MONO_LVREG_MS (ins->sreg1), 32 - ins->inst_c1);
+                       MONO_EMIT_NEW_BIALU_IMM (cfg, OP_ISHR_IMM, MONO_LVREG_MS (ins->dreg), MONO_LVREG_MS (ins->sreg1), ins->inst_c1);
+                       MONO_EMIT_NEW_BIALU_IMM (cfg, OP_ISHR_UN_IMM, MONO_LVREG_LS (ins->dreg), MONO_LVREG_LS (ins->sreg1), ins->inst_c1);
+                       MONO_EMIT_NEW_BIALU (cfg, OP_IOR, MONO_LVREG_LS (ins->dreg), MONO_LVREG_LS (ins->dreg), tmpreg);
+                       allocated_vregs = TRUE;
+               }
+               break;
+       }
+       case OP_LSHR_UN_IMM: {
+               if (ins->inst_c1 == 32) {
+                       MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, MONO_LVREG_LS (ins->dreg), MONO_LVREG_MS (ins->sreg1));
+                       MONO_EMIT_NEW_ICONST (cfg, MONO_LVREG_MS (ins->dreg), 0);
+               } else if (ins->inst_c1 == 0) {
+                       MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, MONO_LVREG_LS (ins->dreg), MONO_LVREG_LS (ins->sreg1));
+                       MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, MONO_LVREG_MS (ins->dreg), MONO_LVREG_MS (ins->sreg1));
+               } else if (ins->inst_c1 > 32) {
+                       MONO_EMIT_NEW_BIALU_IMM (cfg, OP_ISHR_UN_IMM, MONO_LVREG_LS (ins->dreg), MONO_LVREG_MS (ins->sreg1), ins->inst_c1 - 32);
+                       MONO_EMIT_NEW_ICONST (cfg, MONO_LVREG_MS (ins->dreg), 0);
+               } else {
+                       guint32 tmpreg = alloc_ireg (cfg);
+                       MONO_EMIT_NEW_BIALU_IMM (cfg, OP_ISHL_IMM, tmpreg, MONO_LVREG_MS (ins->sreg1), 32 - ins->inst_c1);
+                       MONO_EMIT_NEW_BIALU_IMM (cfg, OP_ISHR_UN_IMM, MONO_LVREG_MS (ins->dreg), MONO_LVREG_MS (ins->sreg1), ins->inst_c1);
+                       MONO_EMIT_NEW_BIALU_IMM (cfg, OP_ISHR_UN_IMM, MONO_LVREG_LS (ins->dreg), MONO_LVREG_LS (ins->sreg1), ins->inst_c1);
+                       MONO_EMIT_NEW_BIALU (cfg, OP_IOR, MONO_LVREG_LS (ins->dreg), MONO_LVREG_LS (ins->dreg), tmpreg);
+                       allocated_vregs = TRUE;
+               }
+               break;
+       }
+       case OP_LSHL_IMM: {
+               if (ins->inst_c1 == 32) {
+                       /* just move the lower half to the upper and zero the lower word */
+                       MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, MONO_LVREG_MS (ins->dreg), MONO_LVREG_LS (ins->sreg1));
+                       MONO_EMIT_NEW_ICONST (cfg, MONO_LVREG_LS (ins->dreg), 0);
+               } else if (ins->inst_c1 == 0) {
+                       MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, MONO_LVREG_LS (ins->dreg), MONO_LVREG_LS (ins->sreg1));
+                       MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, MONO_LVREG_MS (ins->dreg), MONO_LVREG_MS (ins->sreg1));
+               } else if (ins->inst_c1 > 32) {
+                       MONO_EMIT_NEW_BIALU_IMM (cfg, OP_ISHL_IMM, MONO_LVREG_MS (ins->dreg), MONO_LVREG_LS (ins->sreg1), ins->inst_c1 - 32);
+                       MONO_EMIT_NEW_ICONST (cfg, MONO_LVREG_LS (ins->dreg), 0);
+               } else {
+                       guint32 tmpreg = alloc_ireg (cfg);
+                       MONO_EMIT_NEW_BIALU_IMM (cfg, OP_ISHR_UN_IMM, tmpreg, MONO_LVREG_LS (ins->sreg1), 32 - ins->inst_c1);
+                       MONO_EMIT_NEW_BIALU_IMM (cfg, OP_ISHL_IMM, MONO_LVREG_MS (ins->dreg), MONO_LVREG_MS (ins->sreg1), ins->inst_c1);
+                       MONO_EMIT_NEW_BIALU_IMM (cfg, OP_ISHL_IMM, MONO_LVREG_LS (ins->dreg), MONO_LVREG_LS (ins->sreg1), ins->inst_c1);
+                       MONO_EMIT_NEW_BIALU (cfg, OP_IOR, MONO_LVREG_MS (ins->dreg), MONO_LVREG_MS (ins->dreg), tmpreg);
+                       allocated_vregs = TRUE;
+               }
+               break;
+       }
+#endif
 
        default:
                break;
index 4ef344ecdd9b0f1b5e005e5e9a1f6b258744dadb..de8ab61e3d5b64550e733981fcce690c013d7860 100644 (file)
@@ -1,10 +1,18 @@
 #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
 
 /*
@@ -20,6 +28,114 @@ mono_main_with_options (int argc, char *argv [])
        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>
@@ -27,11 +143,13 @@ mono_main_with_options (int argc, char *argv [])
 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++)
@@ -40,6 +158,11 @@ main (void)
 
        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);
 }
 
@@ -49,7 +172,8 @@ int
 main (int argc, char* argv[])
 {
        mono_build_date = build_date;
-       
+
+       probe_embedded (argv [0], &argc, &argv);
        return mono_main_with_options (argc, argv);
 }
 
index 587d08254e5f2143e2555a1d3bc579ddb2bb42e5..8bf63dcfbfe1b221dbc800d6924d91ea3a40e20e 100644 (file)
@@ -4230,7 +4230,7 @@ handle_alloc (MonoCompile *cfg, MonoClass *klass, gboolean for_box, int context_
                                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);
                }
@@ -4267,7 +4267,7 @@ handle_alloc (MonoCompile *cfg, MonoClass *klass, gboolean for_box, int context_
                                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);
index 83170902e4ee113fe059ea27ab3cf26949af8f3d..db26f1b5c523fb34ec53fe186b302ffbcbd4c2d3 100644 (file)
@@ -455,15 +455,24 @@ mono_print_ji (const MonoJumpInfo *ji)
 
 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) {
@@ -477,16 +486,16 @@ mono_print_ins_index (int i, MonoInst *ins)
                /* 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:
@@ -500,39 +509,38 @@ mono_print_ins_index (int i, MonoInst *ins)
                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]) {
@@ -540,44 +548,44 @@ mono_print_ins_index (int i, MonoInst *ins)
                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:
@@ -591,20 +599,20 @@ mono_print_ins_index (int i, MonoInst *ins)
        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:
@@ -629,22 +637,22 @@ mono_print_ins_index (int i, MonoInst *ins)
                         * 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;
@@ -656,7 +664,7 @@ mono_print_ins_index (int i, MonoInst *ins)
                        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);
                }
@@ -669,7 +677,7 @@ mono_print_ins_index (int i, MonoInst *ins)
                        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);
                }
@@ -677,7 +685,7 @@ mono_print_ins_index (int i, MonoInst *ins)
        }
        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:
@@ -700,27 +708,27 @@ mono_print_ins_index (int i, MonoInst *ins)
        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
index 4f8fbcf65853f668acdb0cc1be9140ae552f395a..a52f5eb80d06aef3137d018ac67b0940961f8460 100644 (file)
 #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
 
@@ -215,9 +77,6 @@ void* dlopen(const char* path, int mode);
 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
@@ -326,7 +185,9 @@ mono_thread_state_init_from_handle (MonoThreadUnwindState *tctx, MonoThreadInfo
        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;
 
index d5787acf13b6dff1e2468d5002302a1aca978a16..8e6646cc77c99efc1c45680045bef393c5bbc337 100644 (file)
@@ -517,7 +517,11 @@ clock_init (void)
 {
        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);
 }
 
@@ -526,7 +530,11 @@ clock_cleanup (void)
 {
        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);
 }
 
@@ -536,7 +544,11 @@ clock_get_time_ns (void)
        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;
@@ -553,10 +565,11 @@ clock_sleep_ns_abs (guint64 ns_abs)
 
        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
index 795bab9e41d319ebb23ec690c14ee6cf6c288980..2aba264d1f0747a3bf419415731ebe775a94bc61 100644 (file)
@@ -3397,7 +3397,7 @@ register_jit_stats (void)
        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);
index 5e9204611d7bf37760b7aae0a19dcb1057196085..6f2685dce80d67d586da67b8058f69e8f53d66a8 100644 (file)
@@ -1010,7 +1010,9 @@ mono_arch_allocate_vars (MonoCompile *cfg)
        header = cfg->header;
        sig = mono_method_signature (cfg->method);
 
-       cinfo = get_call_info (cfg->mempool, sig);
+       if (!cfg->arch.cinfo)
+               cfg->arch.cinfo = get_call_info (cfg->mempool, sig);
+       cinfo = (CallInfo *)cfg->arch.cinfo;
 
        cfg->frame_reg = X86_EBP;
        offset = 0;
@@ -1140,8 +1142,8 @@ mono_arch_allocate_vars (MonoCompile *cfg)
                if (inst->opcode != OP_REGVAR) {
                        inst->opcode = OP_REGOFFSET;
                        inst->inst_basereg = X86_EBP;
+                       inst->inst_offset = ainfo->offset + ARGS_OFFSET;
                }
-               inst->inst_offset = ainfo->offset + ARGS_OFFSET;
        }
 
        cfg->stack_offset = offset;
@@ -1156,7 +1158,10 @@ mono_arch_create_vars (MonoCompile *cfg)
 
        sig = mono_method_signature (cfg->method);
 
-       cinfo = get_call_info (cfg->mempool, sig);
+       if (!cfg->arch.cinfo)
+               cfg->arch.cinfo = get_call_info (cfg->mempool, sig);
+       cinfo = (CallInfo *)cfg->arch.cinfo;
+
        sig_ret = mini_get_underlying_type (sig->ret);
 
        if (cinfo->ret.storage == ArgValuetypeInReg)
@@ -5128,6 +5133,8 @@ mono_arch_emit_prolog (MonoCompile *cfg)
        MonoBasicBlock *bb;
        MonoMethodSignature *sig;
        MonoInst *inst;
+       CallInfo *cinfo;
+       ArgInfo *ainfo;
        int alloc_size, pos, max_offset, i, cfa_offset;
        guint8 *code;
        gboolean need_stack_frame;
@@ -5387,11 +5394,14 @@ mono_arch_emit_prolog (MonoCompile *cfg)
        sig = mono_method_signature (method);
        pos = 0;
 
+       cinfo = (CallInfo *)cfg->arch.cinfo;
+
        for (i = 0; i < sig->param_count + sig->hasthis; ++i) {
                inst = cfg->args [pos];
+               ainfo = &cinfo->args [pos];
                if (inst->opcode == OP_REGVAR) {
                        g_assert (need_stack_frame);
-                       x86_mov_reg_membase (code, inst->dreg, X86_EBP, inst->inst_offset, 4);
+                       x86_mov_reg_membase (code, inst->dreg, X86_EBP, ainfo->offset + ARGS_OFFSET, 4);
                        if (cfg->verbose_level > 2)
                                g_print ("Argument %d assigned to register %s\n", pos, mono_arch_regname (inst->dreg));
                }
@@ -5513,7 +5523,7 @@ mono_arch_emit_epilog (MonoCompile *cfg)
        }
 
        /* Load returned vtypes into registers if needed */
-       cinfo = get_call_info (cfg->mempool, sig);
+       cinfo = (CallInfo *)cfg->arch.cinfo;
        if (cinfo->ret.storage == ArgValuetypeInReg) {
                for (quad = 0; quad < 2; quad ++) {
                        switch (cinfo->ret.pair_storage [quad]) {
index 969b679f29bbfdd161bd5a77c6c68cf7d6900cbc..0ca2bdcec44d54524c13b56004e93c1149bb4c8c 100644 (file)
@@ -165,6 +165,7 @@ typedef struct {
        gboolean need_stack_frame_inited;
        gboolean need_stack_frame;
        int sp_fp_offset, param_area_size;
+       gpointer cinfo;
        gpointer ss_tramp_var;
        gpointer bp_tramp_var;
 } MonoCompileArch;
index 1865ee98caf79114bc364c1e41b8e4ba40a4f3b6..94062ec4b84ef71dcc6d6b01c97042e268f4f217 100644 (file)
@@ -3722,7 +3722,11 @@ mini_method_compile (MonoMethod *method, guint32 opts, MonoDomain *domain, JitFl
         */
        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) {
@@ -3784,42 +3788,59 @@ mini_method_compile (MonoMethod *method, guint32 opts, MonoDomain *domain, JitFl
         * 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) {
                /* 
@@ -3837,6 +3858,7 @@ mini_method_compile (MonoMethod *method, guint32 opts, MonoDomain *domain, JitFl
        }
 
        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) {
@@ -3866,6 +3888,7 @@ mini_method_compile (MonoMethod *method, guint32 opts, MonoDomain *domain, JitFl
                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) {
@@ -3886,6 +3909,7 @@ mini_method_compile (MonoMethod *method, guint32 opts, MonoDomain *domain, JitFl
                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
                }
        }
@@ -3894,28 +3918,42 @@ mini_method_compile (MonoMethod *method, guint32 opts, MonoDomain *domain, JitFl
        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 */
@@ -3933,8 +3971,10 @@ mini_method_compile (MonoMethod *method, guint32 opts, MonoDomain *domain, JitFl
                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
@@ -3989,6 +4029,7 @@ mini_method_compile (MonoMethod *method, guint32 opts, MonoDomain *domain, JitFl
                                }
                        }
                        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");
                }
        }
 
@@ -3999,6 +4040,7 @@ mini_method_compile (MonoMethod *method, guint32 opts, MonoDomain *domain, JitFl
        /* 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;
        }
@@ -4009,12 +4051,14 @@ mini_method_compile (MonoMethod *method, guint32 opts, MonoDomain *domain, JitFl
        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");
                }
        }
 
@@ -4060,6 +4104,7 @@ mini_method_compile (MonoMethod *method, guint32 opts, MonoDomain *domain, JitFl
 #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;
        }
@@ -4129,6 +4174,8 @@ mini_method_compile (MonoMethod *method, guint32 opts, MonoDomain *domain, JitFl
        if (MONO_METHOD_COMPILE_END_ENABLED ())
                MONO_PROBE_METHOD_COMPILE_END (method, TRUE);
 
+       mono_cfg_dump_close_group (cfg);
+
        return cfg;
 }
 
index 23f048881db7d08408bf81b82a47158b15d003e8..3159149307040796ecef73de4c5a6fc3ae92d7e5 100644 (file)
@@ -40,6 +40,7 @@
 #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"
@@ -1843,6 +1844,9 @@ typedef struct {
        /* 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;
@@ -2282,11 +2286,19 @@ mono_bb_last_inst (MonoBasicBlock *bb, int filter)
 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);
@@ -2342,6 +2354,7 @@ void      mono_blockset_print               (MonoCompile *cfg, MonoBitSet *set,
 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);
index eb42a0279c1faf464a2b0840c7a8b611d95a4a2b..45d32b99c05e54b64969afac9b9c51d6047a07b8 100755 (executable)
@@ -6,7 +6,12 @@ USE_AOT=$2
 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
@@ -16,7 +21,7 @@ tmp_file () {
 }
 
 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.
@@ -42,15 +47,19 @@ get_method () {
 }
 
 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 () {
index 1f44713976548f2ab5152b5f8716b182d2e2f225..4bd7ac33474b3f31f592213448c9774f3f3cbfe5 100644 (file)
@@ -669,6 +669,13 @@ mono_arch_create_specific_trampoline (gpointer arg1, MonoTrampolineType tramp_ty
        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)
 {
index 3d9079f45f73bcea0397a83985bbd5dc445a68de..47002dd5b5b6b75b9d98efe86c63016a930149ea 100644 (file)
@@ -3516,7 +3516,7 @@ count_queue (MonoLockFreeQueue *queue)
 
        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;
@@ -4352,7 +4352,7 @@ handle_writer_queue_entry (MonoProfiler *prof)
 
                dump_buffer (prof, entry->buffer);
 
-               free (entry);
+               mono_thread_hazardous_try_free (entry, free);
 
                return TRUE;
        }
@@ -4364,7 +4364,6 @@ static void *
 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");
@@ -4489,7 +4488,7 @@ create_profiler (const char *filename, GPtrArray *filters)
 #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);
index b4c058f13a4e61dc048136b4bc5bf5d3b1dfaf9c..c72ed326b00afbb28d565e48b113352bed1965d1 100644 (file)
@@ -78,7 +78,7 @@
 
 /* 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
index 852a4a63329d2fdd134ebfb7c5e762fdd901c000..6ddea6d621301348aa2035c5f227994d8f695631 100644 (file)
@@ -186,7 +186,7 @@ mono_gc_make_descr_for_array (int vector, gsize *elem_bitmap, int numbits, size_
                }
                /* 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 */
index e6b8d672dce53fbb73037cc2c4dbfe39bca1a9a7..5ec907371f38451a493b5de735ff26c44620c6cf 100644 (file)
@@ -696,6 +696,8 @@ pin_objects_from_nursery_pin_queue (gboolean do_scan_objects, ScanCopyContext ct
                        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;
@@ -1411,6 +1413,8 @@ job_mod_union_preclean (void *worker_data_untyped, SgenThreadPoolJob *job)
 
        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
@@ -3008,6 +3012,7 @@ sgen_gc_init (void)
 
        alloc_nursery ();
 
+       sgen_pinning_init ();
        sgen_cement_init (cement_enabled);
 
        if ((env = g_getenv (MONO_GC_DEBUG_NAME))) {
index 9f4cbfc129dbb205f60d61eda9fb83d6bbec9f0b..d2e3ccdd0093dcc9e68432ef1e8f20b9198651a2 100644 (file)
@@ -99,6 +99,7 @@ struct _MSBlockInfo {
        guint16 obj_size_index;
        /* FIXME: Reduce this - it only needs a byte. */
        volatile gint32 state;
+       gint16 nused;
        unsigned int pinned : 1;
        unsigned int has_references : 1;
        unsigned int has_pinned : 1;    /* means cannot evacuate */
@@ -161,7 +162,7 @@ static int fast_block_obj_size_indexes [MS_NUM_FAST_BLOCK_OBJ_SIZE_INDEXES];
 static gboolean *evacuate_block_obj_sizes;
 static float evacuation_threshold = 0.666f;
 
-static gboolean lazy_sweep = FALSE;
+static gboolean lazy_sweep = TRUE;
 
 enum {
        SWEEP_STATE_SWEPT,
@@ -806,6 +807,7 @@ set_sweep_state (int new_, int expected)
 static gboolean ensure_block_is_checked_for_sweeping (guint32 block_index, gboolean wait, gboolean *have_checked);
 
 static SgenThreadPoolJob * volatile sweep_job;
+static SgenThreadPoolJob * volatile sweep_blocks_job;
 
 static void
 major_finish_sweep_checking (void)
@@ -1514,6 +1516,7 @@ ensure_block_is_checked_for_sweeping (guint32 block_index, gboolean wait, gboole
        for (i = 0; i < MS_NUM_MARK_WORDS; ++i)
                nused += bitcount (block->mark_words [i]);
 
+       block->nused = nused;
        if (nused)
                have_live = TRUE;
        if (nused < count)
@@ -1575,6 +1578,20 @@ ensure_block_is_checked_for_sweeping (guint32 block_index, gboolean wait, gboole
        return !!tagged_block;
 }
 
+static void
+sweep_blocks_job_func (void *thread_data_untyped, SgenThreadPoolJob *job)
+{
+       volatile gpointer *slot;
+
+       SGEN_ARRAY_LIST_FOREACH_SLOT (&allocated_blocks, slot) {
+               sweep_block (BLOCK_UNTAG (*slot));
+       } SGEN_ARRAY_LIST_END_FOREACH_SLOT;
+
+       mono_memory_write_barrier ();
+
+       sweep_blocks_job = NULL;
+}
+
 static void
 sweep_job_func (void *thread_data_untyped, SgenThreadPoolJob *job)
 {
@@ -1616,6 +1633,16 @@ sweep_job_func (void *thread_data_untyped, SgenThreadPoolJob *job)
 
        sgen_array_list_remove_nulls (&allocated_blocks);
 
+       /*
+        * Concurrently sweep all the blocks to reduce workload during minor
+        * pauses where we need certain blocks to be swept. At the start of
+        * the next major we need all blocks to be swept anyway.
+        */
+       if (concurrent_sweep && lazy_sweep) {
+               sweep_blocks_job = sgen_thread_pool_job_alloc ("sweep_blocks", sweep_blocks_job_func, sizeof (SgenThreadPoolJob));
+               sgen_thread_pool_job_enqueue (sweep_blocks_job);
+       }
+
        sweep_finish ();
 
        sweep_job = NULL;
@@ -1639,7 +1666,11 @@ sweep_finish (void)
                }
        }
 
+       sgen_memgov_major_post_sweep ();
+
        set_sweep_state (SWEEP_STATE_SWEPT, SWEEP_STATE_COMPACTING);
+       if (concurrent_sweep)
+               binary_protocol_concurrent_sweep_end (sgen_timestamp ());
 }
 
 static void
@@ -1776,6 +1807,67 @@ major_finish_nursery_collection (void)
 #endif
 }
 
+static int
+block_usage_comparer (const void *bl1, const void *bl2)
+{
+       const gint16 nused1 = (*(MSBlockInfo**)bl1)->nused;
+       const gint16 nused2 = (*(MSBlockInfo**)bl2)->nused;
+
+       return nused2 - nused1;
+}
+
+static void
+sgen_evacuation_freelist_blocks (MSBlockInfo * volatile *block_list, int size_index)
+{
+       MSBlockInfo **evacuated_blocks;
+       size_t index = 0, count, num_blocks = 0, num_used = 0;
+       MSBlockInfo *info;
+       MSBlockInfo * volatile *prev;
+
+       for (info = *block_list; info != NULL; info = info->next_free) {
+               num_blocks++;
+               num_used += info->nused;
+       }
+
+       /*
+        * We have a set of blocks in the freelist which will be evacuated. Instead
+        * of evacuating all of the blocks into new ones, we traverse the freelist
+        * sorting it by the number of occupied slots, evacuating the objects from
+        * blocks with fewer used slots into fuller blocks.
+        *
+        * The number of used slots is set at the end of the previous sweep. Since
+        * we sequentially unlink slots from blocks, except for the head of the
+        * freelist, for blocks on the freelist, the number of used slots is the same
+        * as at the end of the previous sweep.
+        */
+       evacuated_blocks = (MSBlockInfo**)sgen_alloc_internal_dynamic (sizeof (MSBlockInfo*) * num_blocks, INTERNAL_MEM_TEMPORARY, TRUE);
+
+       for (info = *block_list; info != NULL; info = info->next_free) {
+               evacuated_blocks [index++] = info;
+       }
+
+       SGEN_ASSERT (0, num_blocks == index, "Why did the freelist change ?");
+
+       qsort (evacuated_blocks, num_blocks, sizeof (gpointer), block_usage_comparer);
+
+       /*
+        * Form a new freelist with the fullest blocks. These blocks will also be
+        * marked as to_space so we don't evacuate from them.
+        */
+       count = MS_BLOCK_FREE / block_obj_sizes [size_index];
+       prev = block_list;
+       for (index = 0; index < (num_used + count - 1) / count; index++) {
+               SGEN_ASSERT (0, index < num_blocks, "Why do we need more blocks for compaction than we already had ?");
+               info = evacuated_blocks [index];
+               info->is_to_space = TRUE;
+               *prev = info;
+               prev = &info->next_free;
+       }
+       *prev = NULL;
+
+       sgen_free_internal_dynamic (evacuated_blocks, sizeof (MSBlockInfo*) * num_blocks, INTERNAL_MEM_TEMPORARY);
+}
+
 static void
 major_start_major_collection (void)
 {
@@ -1794,22 +1886,38 @@ major_start_major_collection (void)
 
                binary_protocol_evacuating_blocks (block_obj_sizes [i]);
 
-               free_block_lists [0][i] = NULL;
-               free_block_lists [MS_BLOCK_FLAG_REFS][i] = NULL;
+               sgen_evacuation_freelist_blocks (&free_block_lists [0][i], i);
+               sgen_evacuation_freelist_blocks (&free_block_lists [MS_BLOCK_FLAG_REFS][i], i);
        }
 
-       if (lazy_sweep)
-               binary_protocol_sweep_begin (GENERATION_OLD, TRUE);
+       if (lazy_sweep && concurrent_sweep) {
+               /*
+                * sweep_blocks_job is created before sweep_finish, which we wait for above
+                * (major_finish_sweep_checking). After the end of sweep, if we don't have
+                * sweep_blocks_job set, it means that it has already been run.
+                */
+               SgenThreadPoolJob *job = sweep_blocks_job;
+               if (job)
+                       sgen_thread_pool_job_wait (job);
+       }
 
+       if (lazy_sweep && !concurrent_sweep)
+               binary_protocol_sweep_begin (GENERATION_OLD, TRUE);
        /* Sweep all unswept blocks and set them to MARKING */
        FOREACH_BLOCK_NO_LOCK (block) {
-               if (lazy_sweep)
+               if (lazy_sweep && !concurrent_sweep)
                        sweep_block (block);
                SGEN_ASSERT (0, block->state == BLOCK_STATE_SWEPT, "All blocks must be swept when we're pinning.");
                set_block_state (block, BLOCK_STATE_MARKING, BLOCK_STATE_SWEPT);
+               /*
+                * Swept blocks that have a null free_list are full. Evacuation is not
+                * effective on these blocks since we expect them to have high usage anyway,
+                * given that the survival rate for majors is relatively high.
+                */
+               if (evacuate_block_obj_sizes [block->obj_size_index] && !block->free_list)
+                       block->is_to_space = TRUE;
        } END_FOREACH_BLOCK_NO_LOCK;
-
-       if (lazy_sweep)
+       if (lazy_sweep && !concurrent_sweep)
                binary_protocol_sweep_end (GENERATION_OLD, TRUE);
 
        set_sweep_state (SWEEP_STATE_NEED_SWEEPING, SWEEP_STATE_SWEPT);
index 398c36e2ab24f9588638699b7c33bd548854b1f7..7415ce3bff1b3ce63468582f8e1d4cc888e0fc3c 100644 (file)
@@ -178,6 +178,17 @@ sgen_memgov_major_pre_sweep (void)
        }
 }
 
+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)
 {
@@ -213,7 +224,7 @@ sgen_memgov_collection_end (int generation, GGTimingInfo* info, int info_count)
                if (info[i].generation != -1)
                        sgen_client_log_timing (&info [i], last_major_num_sections, last_los_memory_usage);
        }
-       last_major_num_sections = major_collector.get_num_major_sections ();
+       last_los_memory_usage = los_memory_usage;
 }
 
 /*
index 4ce17f5993b05a3dabffb71822d5a5042661ca16..9bcd55b4d80ad157417567512f7363438029f468 100644 (file)
@@ -17,6 +17,7 @@ void sgen_memgov_minor_collection_start (void);
 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);
 
index eedd1f0343a93e720cac0838ec29ff70e8bd773e..cfe3db1acd0167bd08d1c7e285b6313736460ec3 100644 (file)
 
 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
@@ -37,6 +51,27 @@ sgen_finish_pinning (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
index 00eb20dd819830f40a45a620981e812426673df2..2ae2594fa85e1c762898e60d43e6caafaf0ed40a 100644 (file)
@@ -18,10 +18,13 @@ enum {
        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);
index 8a190ef6f494df314fa590d74a0022af78f28294..3ab36e3bf660f380b9b21cf554f0e659899eb520 100644 (file)
@@ -435,6 +435,13 @@ MATCH_INDEX (BINARY_PROTOCOL_MATCH)
 IS_VTABLE_MATCH (FALSE)
 END_PROTOCOL_ENTRY
 
+BEGIN_PROTOCOL_ENTRY1 (binary_protocol_concurrent_sweep_end, TYPE_LONGLONG, timestamp)
+DEFAULT_PRINT ()
+IS_ALWAYS_MATCH (TRUE)
+MATCH_INDEX (BINARY_PROTOCOL_MATCH)
+IS_VTABLE_MATCH (FALSE)
+END_PROTOCOL_ENTRY
+
 #undef BEGIN_PROTOCOL_ENTRY0
 #undef BEGIN_PROTOCOL_ENTRY1
 #undef BEGIN_PROTOCOL_ENTRY2
index 965b148ec74a6989ce25b6817e334af0b3f0f36a..03bae54e17a22799cc20b98346b97d18dac1af84 100644 (file)
@@ -435,7 +435,8 @@ BASE_TEST_CS_SRC=           \
        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)     \
diff --git a/mono/tests/bug-29585.cs b/mono/tests/bug-29585.cs
new file mode 100644 (file)
index 0000000..a1289fa
--- /dev/null
@@ -0,0 +1,54 @@
+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
index c170df2714ec8499ac96e8391aaa2f1b8a583a01..b61302fec3a7ab135a8e1d1c19702d42ba60f44e 100644 (file)
@@ -1,19 +1,19 @@
 
 %.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
@@ -42,7 +42,7 @@ run-test: compile-stamp
                then \
                        RES=3; \
                fi; \
-               if [ "$$FIRST" == "unverifiable" ] || [ "$FIRST" == "typeunverifiable" ]; \
+               if [ "$$FIRST" == "unverifiable" ] || [ "$$FIRST" == "typeunverifiable" ]; \
                then \
                        RES=2; \
                fi; \
@@ -56,37 +56,37 @@ run-test: compile-stamp
                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
 
index bbbf83024848d1e285df2c10417a0125de7f4df8..72be8020ee54eb6d2d34905f68915604e0f0b700 100755 (executable)
@@ -13,7 +13,7 @@ TEST_MEMBER_ACCESS=$5
 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
@@ -21,7 +21,7 @@ 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"
@@ -87,4 +87,4 @@ $SED -e "s/SUPER_TYPE/${TEST_SUPER_TYPE}/g" -e "s/VALIDITY/${TEST_VALIDITY}/g" -
                ret
        }
 }
-//EOF
\ No newline at end of file
+//EOF
index 73b79622f5b77461de8f3b3764aa7f87a692368e..4356497ea37651a6a257db532d0607c03b1017e5 100755 (executable)
@@ -11,7 +11,7 @@ TEST_BYTE_0=$3
 TEST_BYTE_1=$4
 
 
-if [ "$TEST_BYTE_1" == "" ] ; then
+if [ "x$TEST_BYTE_1" = "x" ] ; then
        TEST_BYTE_1="0";
 fi
 
index 5ebbbb99416c577541df95516d369ae1137f9e3c..019b453beb181e8a35fb69838eae9bca94dd06c3 100755 (executable)
@@ -12,7 +12,7 @@ TEST_TYPE2=$5
 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=""
@@ -50,4 +50,4 @@ $SED -e "s/INIT/${TEST_INIT}/g" -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/TYPE1/$
        ldc.i4.0
        ret
 }
-//EOF
\ No newline at end of file
+//EOF
index 9522718a1c712f2e2d3417a8c7e756ca6a72c702..32428322b688a18ebd061db69c66814d75aa8634 100755 (executable)
@@ -11,7 +11,7 @@ TEST_OP=$3
 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
 
index 5ae54d3cafff22dcadeadfb4ba441fd7bc11e0e5..9ea87a414cfec29ca8edbf1d2964a82ff7eb7bde 100755 (executable)
@@ -11,7 +11,7 @@ TEST_POS=$3
 TEST_OP=$4
 TEST_FIN=$5
 
-if [ "$TEST_FIN" == "" ]; then
+if [ "x$TEST_FIN" = "x" ]; then
        TEST_FIN="finally";
 fi
 
index 884333b2accd748873009ebb8d6765c31824e362..08605a0f9cf29fca1648d502bb1e73b3d6839df4 100755 (executable)
@@ -12,7 +12,7 @@ TEST_LOAD_ARGS=$4
 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
index 9e8894a709eb9ce5637d6cb040e5c37b59ad7e90..2687f0dfe687b95c2adf7b5a67b38d5de4cb7c9b 100755 (executable)
@@ -14,7 +14,7 @@ TEST_BEFORE_OP=$6
 
 echo $TEST_OP | grep unbox > /dev/null;
 
-if [ "$?" == "0" ]; then
+if [ $? -eq 0 ]; then
        TEST_CODE="
        ldloc.0
        box $TEST_TYPE";
index 008d485bedfb405f73a80212d3b7e52366041a33..5110b563ff63b3ca8c0b4f0cf2afcf2bf49c57e1 100755 (executable)
@@ -15,7 +15,7 @@ TEST_EXTRA_OPS=$6
 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"
@@ -24,9 +24,9 @@ fi
 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
index e34c2fbe360238f2b8b8f28bf086f67327a50fee..b94b7e960bf38c25add04f1ed2177ab46c1e9c6e 100755 (executable)
@@ -14,7 +14,7 @@ TEST_EXTENDS=$6
 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
@@ -22,7 +22,7 @@ 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 ()"
index 81febde0c3046a92dd2316c866233f8d3b756ff8..6325f6167971059efb0444b3b09071e0ca490f70 100755 (executable)
@@ -13,7 +13,7 @@ TEST_TARGET_TYPE=$4
 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=""
index a12b82c373a3279f9c89a3ed90403f7ee7f0d48c..31b8581fbe7f68025fde4127eb10511e796ab093 100755 (executable)
@@ -26,7 +26,7 @@ fi
 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
@@ -47,7 +47,7 @@ MANAGED_METHOD="
        }
 "
 
-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=""
index 68bc551cf9fef66fbd3d9c291fb70dec22dc6daf..f6271e2fb9599ab7706dca36622187cf145fd1fc 100755 (executable)
@@ -16,7 +16,7 @@ TEST_NESTED_EXTENDS=$8
 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
@@ -24,7 +24,7 @@ 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
@@ -32,7 +32,7 @@ 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 ()"
index 284fadfd7e6d81c92e8bfb7c4ef7dc0887bbe103..0647eed5b19b73bad74a5401a8d7469b508a0dc7 100755 (executable)
@@ -12,7 +12,7 @@ TEST_BLOCK_2=$4
 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
@@ -35,7 +35,7 @@ else
        FILTER_BLOCK="";
 fi
 
-if [ "$TEST_WITH_FINALLY_BLOCK" == "yes" ]; then
+if [ "$TEST_WITH_FINALLY_BLOCK" = "yes" ]; then
        FINALLY_BLOCK="
 FINALLY_BLOCK_1:
        nop
index a50a5f4385c692cdc1fdf7068b681172c4cb40c9..8d72117ffc2918268a9c31695a832234e63e1f5f 100755 (executable)
@@ -11,7 +11,7 @@ TEST_OP=$3
 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";
index 3382ff99d6e279d332f4f7e4e5b312ca3a35330d..5b1e064afaa1862cffca7723282e622fcd79131f 100755 (executable)
@@ -14,7 +14,7 @@ ZZ=`echo $TEST_TYPE1 | grep "\&"`
 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"
index c314cf297020215183136ba7073d23d29d2d9091..4a2f84a1ed6bd0796a57d3071e6bc7127ebf404d 100755 (executable)
@@ -13,7 +13,7 @@ ZZ=`echo $TEST_TYPE1 | grep "\&"`
 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"
index 8a5016a7fd1d9b05af28ec1c5f38dd24f09d037c..e53849cf18cdf7ef5c216834689978a169786f81 100755 (executable)
@@ -16,14 +16,14 @@ TRY_END="
                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 {"
@@ -34,7 +34,7 @@ elif [ "$TEST_BLOCK" == "filter" ]; then
        } {
                leave END
        }"
-elif [ "$TEST_BLOCK" == "handler" ]; then
+elif [ "$TEST_BLOCK" = "handler" ]; then
        TRY_MIDDLE="
                leave END
        } filter {
@@ -45,14 +45,14 @@ elif [ "$TEST_BLOCK" == "handler" ]; then
        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 {"
index d096e85256619db690df7a107f9561fe4fbc7fe1..5fd41668a68d9a3de2ddd20729a57698a6822095 100755 (executable)
@@ -12,7 +12,7 @@ TEST_CLASS_ACCESS=$4
 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
@@ -108,4 +108,4 @@ $SED -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/OPCODE/${TEST_OP}/g" -e "s/CONSTRU
        ldc.i4.0
        ret
 }
-//EOF
\ No newline at end of file
+//EOF
index f0d53366c87aead38e91afaadbbe1f8353553b04..6390c65695cdd7145260c10e6adae930871ced95 100755 (executable)
@@ -18,7 +18,7 @@ echo $TEST_FILE
 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";
index baa46d38ae6d56e4973925cadeb8f8089763783c..239e27dc3b94c1fc0637879f4b3a655bbc46f86c 100755 (executable)
@@ -12,7 +12,7 @@ TEST_POS_1=$4
 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
 
index 1bf078b35dd01625e2ca7b2c5a77be047a346a5e..d1859623b24e494a819f8769bf3e8fb7998d4b4f 100755 (executable)
@@ -16,7 +16,7 @@ ZZ=`echo $TEST_TYPE2 | grep "\&"`
 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"
index 1767aa4816631a4d8c28061df434dab841a41e45..face162ef8ee56ef18209a364c00119c1f8c2f43 100755 (executable)
@@ -12,7 +12,7 @@ TEST_EXTRA=$4
 TEST_OP=$5
 TEST_FIN=$6
 
-if [ "$TEST_FIN" == "" ]; then
+if [ "x$TEST_FIN" = "x" ]; then
        TEST_FIN="finally";
 fi
 
index de58fa79f35f1a48a4231b067adf06ebb88a9061..82bdccdf81dedc4cb923d7e986e153440d03388d 100755 (executable)
@@ -12,7 +12,7 @@ TEST_LOAD_OP=$4
 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"
index 270c2677b865aa6ed8f5c8ef218186c33b2ba785..25dd54a92576e995e679a27356d15ee6c9f19bea 100755 (executable)
@@ -25,7 +25,7 @@ done
 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";
@@ -92,7 +92,7 @@ done
 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";
@@ -112,7 +112,7 @@ done
 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";
@@ -503,9 +503,9 @@ function fix () {
                A=$1;
        fi
 
-       if [ "$A" == "bool&" ]; then
+       if [ "$A" = "bool&" ]; then
                A="int8&";
-       elif [ "$A" == "char&" ]; then
+       elif [ "$A" = "char&" ]; then
                A="int16&";
        fi
 
@@ -522,11 +522,11 @@ do
                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"
@@ -545,7 +545,7 @@ do
                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"
@@ -561,7 +561,7 @@ do
        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"
@@ -791,17 +791,17 @@ do
        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"
@@ -1335,7 +1335,7 @@ do
        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
@@ -1892,7 +1892,7 @@ function create_nesting_test_same_result () {
       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
@@ -1910,9 +1910,9 @@ function create_nesting_test_only_first_ok () {
       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"
@@ -2065,7 +2065,7 @@ function create_nesting_test_strips_result_static () {
     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
@@ -2188,9 +2188,9 @@ function fix_ldobj () {
                A=$1;
        fi
 
-       if [ "$A" == "bool" ]; then
+       if [ "$A" = "bool" ]; then
                A="int8";
-       elif [ "$A" == "char" ]; then
+       elif [ "$A" = "char" ]; then
                A="int16";
        fi
 
@@ -2207,7 +2207,7 @@ do
        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}"
@@ -2564,7 +2564,7 @@ I=1
 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}"
@@ -2577,7 +2577,7 @@ I=1
 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}";
@@ -3223,30 +3223,34 @@ done
 
 # 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
@@ -3268,7 +3272,7 @@ done
 ./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
@@ -3302,9 +3306,9 @@ EXTRA="ldloc.0\n\tbrfalse END"
 ./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
@@ -3314,24 +3318,27 @@ done
 
 # 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
 
 
@@ -3349,25 +3356,28 @@ 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)
@@ -4893,33 +4903,38 @@ done
 ./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
 
 
@@ -5148,5 +5163,3 @@ done
 
 ./make_generic_argument_constraints_test.sh type_mixed_3 valid "" "(IfaceA)"
 ./make_generic_argument_constraints_test.sh type_mixed_4 valid "" "class (IfaceA)"
-
-
index b71063657cbc3083f621f7d0d5cddd78c7348391..744e931a2a9ad8a213c411c8de4509647c75d7d4 100755 (executable)
@@ -12,7 +12,7 @@ TEST_TYPE2=$4
 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
 
index 3cb2c0aeba33817f0aad3b33bdb9c906913e6fb9..0102c103f7629785b1eb8c231a88f86269dbc56c 100644 (file)
@@ -10,6 +10,7 @@
 #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
 
@@ -29,7 +30,7 @@ typedef enum {
        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);
index e879d910f1c2e60fe32934c079f98eb840b24169..3be8342a49873dbc9e2796d44a76a81d5a9302e3 100644 (file)
@@ -277,7 +277,7 @@ desc_put_partial (gpointer _desc)
 
        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);
 }
 
index 464419960de18f73df442a23632400e78c5799ad..2e06b63f526258de4e6f2004e3fd397d8f523611 100644 (file)
@@ -61,6 +61,9 @@
 #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)
 {
@@ -77,17 +80,30 @@ 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
@@ -96,6 +112,10 @@ mono_lock_free_queue_node_free (MonoLockFreeQueueNode *node)
        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)
 {
@@ -158,7 +178,7 @@ static void
 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;
@@ -183,7 +203,7 @@ get_dummy (MonoLockFreeQueue *q)
 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
@@ -208,6 +228,11 @@ try_reenqueue_dummy (MonoLockFreeQueue *q)
        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)
 {
index 6ae52471e5b4967467b88eb319fabf67944216f9..300b4556ef251f3fb64274a8a4fe7c0d6d592059 100644 (file)
@@ -58,8 +58,8 @@ typedef struct {
 
 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);
 
index 19e745f630c0c54eb46f030dfb5c3e62e7b7de20..314b30d972c2b18c065f33f6978a050b64bb10f0 100644 (file)
@@ -27,7 +27,7 @@ mono_mach_get_threads (thread_act_array_t *threads, guint32 *count)
 
        do {
                ret = task_threads (current_task (), threads, count);
-       } while (ret != KERN_SUCCESS);
+       } while (ret == KERN_ABORTED);
 
        return ret;
 }
index 7ab1b9df7876d24e2bf88fe0858c177491512bcf..16e3d463b8b7377ab0dfb6ec22b8adcc15b76f66 100644 (file)
@@ -131,10 +131,13 @@ static inline int
 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;
 }
 
index c53af96454a79e84a98239ad450d0e9f8658154d..7a4a02e39a3f7fea5ca4a441251215d75d406bf8 100644 (file)
@@ -27,6 +27,7 @@
 #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
@@ -355,22 +356,35 @@ get_process_stat_item (int pid, int pos, int sum, MonoProcessError *error)
        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);
@@ -381,7 +395,11 @@ get_process_stat_item (int pid, int pos, int sum, MonoProcessError *error)
                
                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;
@@ -494,16 +512,25 @@ get_pid_status_item (int pid, const char *item, MonoProcessError *error, int mul
        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);
index 15106129b7212e85ba809c4a9a13b16332e0d18e..3c2f79b58c37e99ac92e90325b6f603118182aaa 100644 (file)
@@ -201,6 +201,10 @@ typedef struct ucontext {
        #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])
@@ -351,6 +355,27 @@ typedef struct ucontext {
        #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)
index 9e0b072a1a5e7b6659f2c9f8f83a3e0618a6db6d..68fa0ad5f62312b1e11de46d1b92e073f9eeab03 100644 (file)
                              "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
index 056a88f150a1cd72b8b5a1fb9d771ae8495c8845..559d2fa63c94525e4c36384bb02213e3ac3155a4 100644 (file)
@@ -49,11 +49,16 @@ mono_threads_core_abort_syscall (MonoThreadInfo *info)
 {
        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
@@ -66,7 +71,11 @@ mono_threads_core_abort_syscall (MonoThreadInfo *info)
        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
index 6f2ddfa78af52357be210b50a2a43c3a73526b52..6c2b07e468f5686872fb4a9db872be7f30dacdd2 100644 (file)
@@ -60,7 +60,11 @@ mono_threads_core_begin_async_suspend (MonoThreadInfo *info, gboolean interrupt_
 
        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;
@@ -68,7 +72,10 @@ mono_threads_core_begin_async_suspend (MonoThreadInfo *info, gboolean interrupt_
        /* 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;
@@ -81,7 +88,10 @@ mono_threads_core_begin_async_suspend (MonoThreadInfo *info, gboolean interrupt_
                        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;
@@ -112,7 +122,10 @@ mono_threads_core_begin_async_resume (MonoThreadInfo *info)
                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;
 
@@ -122,12 +135,17 @@ mono_threads_core_begin_async_resume (MonoThreadInfo *info)
 
                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;
index 7fe86b96273e80ded338c90b945f0dd256646806..395fdb5bdab19dacdf2de564c7e8fa534cd9b936 100644 (file)
@@ -296,6 +296,16 @@ mono_threads_core_set_name (MonoNativeThreadId tid, const char *name)
                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, "");
index bcf1f7a7ab5ae07a4f706b54f8fb1166974ecc91..68a0ff55687fc5461ebddaa4d7ee5243583dc12e 100644 (file)
     <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
index 17580cece36a95c448fc92237e82bee5f6b1cddb..487513f2c369be8282e3c4a4be25b3af208c821e 100644 (file)
@@ -496,7 +496,7 @@ mono_load_remote_field_new
 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
@@ -659,6 +659,7 @@ mono_pagesize
 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
index e4ca56dd9c680869385e9777e64d7618cca228e3..d686ca0d90942115580eb285e3023703273a11f9 100644 (file)
@@ -498,7 +498,7 @@ mono_load_remote_field_new
 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
@@ -661,6 +661,7 @@ mono_pagesize
 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
index 2507bc9777f73cc10e4a5ab25b4c6b85450f5eb9..81945bfc56e397dffa4f02476da4351f7c5b4024 100755 (executable)
@@ -9,11 +9,23 @@ if [[ ${label} == 'osx-amd64' ]]; then EXTRA_CONF_FLAGS="--with-libgdiplus=/Libr
 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* ]];
index 4ea5fbc4c3a3e3593a5fc7c84782901ea32fe587..115ee123566373f97dc378dac92fd986d3c2d286 100755 (executable)
@@ -1,6 +1,6 @@
 #!/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
 
diff --git a/tools/offsets-tool/.gitignore b/tools/offsets-tool/.gitignore
new file mode 100644 (file)
index 0000000..61a0f8d
--- /dev/null
@@ -0,0 +1,5 @@
+.stamp-clone
+CppSharp
+*.exe
+*.h
+*.exe.mdb
diff --git a/tools/offsets-tool/Makefile b/tools/offsets-tool/Makefile
new file mode 100644 (file)
index 0000000..abf2ff9
--- /dev/null
@@ -0,0 +1,39 @@
+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
diff --git a/tools/offsets-tool/MonoAotOffsetsDumper.cs b/tools/offsets-tool/MonoAotOffsetsDumper.cs
new file mode 100644 (file)
index 0000000..a5320ba
--- /dev/null
@@ -0,0 +1,822 @@
+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);
+            }
+        }
+    }
+}
index 1a9a35eb18ae5136db406fb8c8770e462c39d4e3..2a49fea8b19401abb058883d9ad6fe8b3a2b6d86 100644 (file)
  /* 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 */