Merge pull request #5428 from kumpera/wasm-support-p2
authorRodrigo Kumpera <kumpera@users.noreply.github.com>
Fri, 8 Sep 2017 18:55:38 +0000 (14:55 -0400)
committerGitHub <noreply@github.com>
Fri, 8 Sep 2017 18:55:38 +0000 (14:55 -0400)
Mono Wasm support

163 files changed:
CODEOWNERS
Makefile.am
configure.ac
external/api-snapshot
external/binary-reference-assemblies
external/cecil
external/linker
external/nunit-lite
external/roslyn-binaries
man/mcs.1
man/mkbundle.1
man/mono.1
mcs/build/tests.make
mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/Tds70.cs
mcs/class/Mono.Data.Tds/Test/bug-4786.cs
mcs/class/Mono.Debugger.Soft/Test/dtest-excfilter.il
mcs/class/Mono.Debugger.Soft/Test/dtest.cs
mcs/class/Mono.Profiler.Log/Mono.Profiler.Log/LogProcessor.cs
mcs/class/Mono.Security/Mono.Security-net_4_x.csproj
mcs/class/Mono.Security/Mono.Security.Interface/BufferOffsetSize.cs [deleted file]
mcs/class/Mono.Security/Mono.Security.Interface/IBufferOffsetSize.cs [deleted file]
mcs/class/Mono.Security/Mono.Security.Interface/IMonoTlsEventSink.cs [deleted file]
mcs/class/Mono.Security/Mono.Security.Interface/MonoTlsProvider.cs
mcs/class/Mono.Security/Mono.Security.Interface/MonoTlsSettings.cs
mcs/class/Mono.Security/Mono.Security.Interface/SecretParameters.cs [deleted file]
mcs/class/Mono.Security/Mono.Security.Interface/SecureBuffer.cs [deleted file]
mcs/class/Mono.Security/Mono.Security.Interface/TlsBuffer.cs [deleted file]
mcs/class/Mono.Security/Mono.Security.Interface/TlsMultiBuffer.cs [deleted file]
mcs/class/Mono.Security/Mono.Security.dll.sources
mcs/class/PEAPI/Metadata.cs
mcs/class/System.Drawing/Test/System.Drawing.Imaging/tests-ms.sh [deleted file]
mcs/class/System.Drawing/Test/System.Drawing.Imaging/tests.sh [deleted file]
mcs/class/System.Drawing/Test/System.Drawing/README [deleted file]
mcs/class/System.Drawing/Test/System.Drawing/tests-ms.sh [deleted file]
mcs/class/System.Drawing/Test/System.Drawing/tests.sh [deleted file]
mcs/class/System.Net.Http/System.Net.Http_test.dll.sources
mcs/class/System.Net.Http/Test/System.Net.Http/HttpClientTest.cs
mcs/class/System.Runtime.Remoting/System.Runtime.Remoting_test.dll.sources
mcs/class/System.Runtime.Remoting/Test/ActivationTests.cs
mcs/class/System.Runtime.Remoting/Test/GenericTest.cs
mcs/class/System.Runtime.Remoting/Test/HttpBugTests.cs
mcs/class/System.Runtime.Remoting/Test/RemotingServicesTest.cs
mcs/class/System.Runtime.Remoting/Test/System.Runtime.Remoting.Channels.Tcp/TcpChannelTest.cs
mcs/class/System.ServiceModel.Web/Test/System.ServiceModel.Activation/WebScriptServiceHostFactoryTest.cs
mcs/class/System.ServiceModel/System.ServiceModel.PeerResolvers/CustomPeerResolverService.cs
mcs/class/System.ServiceModel/Test/FeatureBased/TestFixtureBase.cs
mcs/class/System.ServiceModel/Test/System.ServiceModel.PeerResolvers/CustomPeerResolverServiceTest.cs
mcs/class/System.Windows.Forms/Test/System.Windows.Forms/tests-ms.sh [deleted file]
mcs/class/System.Windows.Forms/Test/System.Windows.Forms/tests-ms2.sh [deleted file]
mcs/class/System.Windows.Forms/Test/System.Windows.Forms/tests.sh [deleted file]
mcs/class/System.Windows.Forms/Test/System.Windows.Forms/tests2.sh [deleted file]
mcs/class/System/Mono.AppleTls/AppleTlsContext.cs
mcs/class/System/Mono.AppleTls/AppleTlsProvider.cs
mcs/class/System/Mono.Btls/MonoBtlsContext.cs
mcs/class/System/Mono.Btls/MonoBtlsProvider.cs
mcs/class/System/Mono.Btls/MonoBtlsSsl.cs
mcs/class/System/Mono.Btls/MonoBtlsSslRenegotiateMode.cs [new file with mode: 0644]
mcs/class/System/Mono.Net.Security/AsyncProtocolRequest.cs
mcs/class/System/Mono.Net.Security/LegacyTlsProvider.cs
mcs/class/System/Mono.Net.Security/MobileAuthenticatedStream.cs
mcs/class/System/Mono.Net.Security/MobileTlsContext.cs
mcs/class/System/Mono.Net.Security/MonoTlsProviderFactory.cs
mcs/class/System/System-bare-net_4_x.csproj
mcs/class/System/System-net_4_x.csproj
mcs/class/System/System-secxml-net_4_x.csproj
mcs/class/System/System.Net.Sockets/Socket.cs
mcs/class/System/Test/System.Net.Sockets/SocketTest.cs
mcs/class/System/Test/System.Net.Sockets/TcpClientTest.cs
mcs/class/System/Test/System.Net.Sockets/UdpClientTest.cs
mcs/class/System/Test/System.Net/HttpListenerPrefixCollectionTest.cs
mcs/class/System/common.sources
mcs/class/corlib/System/Delegate.cs
mcs/class/corlib/Test/System.Runtime.Remoting/RemotingServicesTest.cs [deleted file]
mcs/class/corlib/testing_aot_full_corlib_test.dll.exclude.sources
mcs/class/reference-assemblies/Makefile
mcs/class/test-helpers/NetworkHelpers.cs
mcs/ilasm/Driver.cs
mcs/ilasm/codegen/CodeGen.cs
mcs/ilasm/codegen/TypeDef.cs
mcs/ilasm/ilasm.csproj
mcs/ilasm/parser/ILParser.jay
mcs/ilasm/scanner/ILTables.cs
mcs/mcs/settings.cs
mcs/mcs/tuples.cs
mcs/tests/test-tuple-06.cs [new file with mode: 0644]
mcs/tests/ver-il-net_4_x.xml
mcs/tools/mkbundle/mkbundle.cs
mcs/tools/nunit-lite/NUnitLite/nunitlite.dll.sources
mono/arch/s390x/s390x-codegen.h
mono/btls/btls-ssl.c
mono/btls/btls-ssl.h
mono/eglib/gfile-unix.c
mono/eglib/gstr.c
mono/metadata/boehm-gc.c
mono/metadata/class-internals.h
mono/metadata/class.c
mono/metadata/cominterop.c
mono/metadata/cominterop.h
mono/metadata/domain.c
mono/metadata/gc.c
mono/metadata/icall-def.h
mono/metadata/image.c
mono/metadata/loader.c
mono/metadata/marshal.c
mono/metadata/metadata.c
mono/metadata/monitor.c
mono/metadata/mono-perfcounters-def.h
mono/metadata/mono-perfcounters.c
mono/metadata/null-gc-handles.c
mono/metadata/object.c
mono/metadata/sgen-client-mono.h
mono/metadata/sgen-mono.c
mono/metadata/threads.c
mono/metadata/w32file-unix.c
mono/metadata/w32socket-internals.h
mono/metadata/w32socket.c
mono/metadata/w32socket.h
mono/mini/cpu-amd64.md
mono/mini/cpu-s390x.md
mono/mini/debugger-agent.c
mono/mini/llvm-jit.cpp
mono/mini/method-to-ir.c
mono/mini/mini-amd64.c
mono/mini/mini-amd64.h
mono/mini/mini-exceptions.c
mono/mini/mini-generic-sharing.c
mono/mini/mini-llvm-cpp.cpp
mono/mini/mini-llvm-cpp.h
mono/mini/mini-llvm.c
mono/mini/mini-ops.h
mono/mini/mini-runtime.c
mono/mini/mini-s390x.c
mono/mini/mini-s390x.h
mono/mini/mini-trampolines.c
mono/mini/mini.c
mono/mini/tramp-amd64.c
mono/mini/tramp-s390x.c
mono/mini/unaligned.cs
mono/profiler/log-args.c
mono/sgen/sgen-gc.c
mono/sgen/sgen-gc.h
mono/sgen/sgen-gchandles.c
mono/sgen/sgen-thread-pool.c
mono/tests/Makefile.am
mono/tests/delegate-disposed-hashcode.cs [new file with mode: 0644]
mono/tests/libtest.c
mono/utils/mono-counters.c
mono/utils/mono-hwcap-s390x.c
mono/utils/mono-hwcap-vars.h
mono/utils/mono-threads-state-machine.c
mono/utils/mono-threads.h
mono/utils/strenc.c
mono/utils/unlocked.h
packaging/MacSDK/fsharp.py
packaging/MacSDK/packaging/mdk_blacklist.sh
packaging/MacSDK/patches/fsharp-fix-mdb-support.patch [deleted file]
packaging/MacSDK/patches/fsharp-metadata-table-size-fix.patch [new file with mode: 0644]
packaging/MacSDK/patches/fsharp-portable-pdb.patch [new file with mode: 0644]
scripts/ci/clang-thread-sanitizer-blacklist
scripts/ci/collect-coverage.sh [new file with mode: 0755]
scripts/ci/run-jenkins.sh
scripts/ci/run-test-default.sh
support/supportw.c

index 66819f702843902ff1b3fb8a220eecc382daf9f3..d72a176cb795514a1423bb2f986c4757abccc6f1 100644 (file)
@@ -1,30 +1,44 @@
 # Mono Code Owners File
 #
-# GitHub uses this file to determine who to ping for reviews on pull requests.
-# If you're the primary maintainer of an area of Mono and you don't mind
-# reviewing pull requests, please add yourself to this file. You may want to
-# avoid adding entries for commonly changed or automatically generated files
-# (e.g. stuff in external/, or various generated *.csproj files) so as not to
-# get spammed with emails.
+# GitHub uses this file to determine who to assign for reviews
+# on pull requests. Please keep this file alphabetically sorted.
 #
-# Note that if two patterns match a file, the later pattern takes precedence.
-#
-# Please keep this file alphabetically sorted.
-#
-# Reference:
+# References:
 #
 # https://github.com/blog/2392-introducing-code-owners
 # https://help.github.com/articles/about-codeowners
 
+
+# These owners will be the default owners for everything in the repo.
+* @luhenry @marek-safar
+
+# Order is important. The last matching pattern has the most precedence.
+
 /acceptance-tests @akoeplinger
 /acceptance-tests/profiler-stress* @alexrp
 
+/data @marek-safar @akoeplinger
+/data/gdb @vargaz
+/data/lldb @lewurm @vargaz
+
 /docs @luhenry @marek-safar
 /docs/sources/mono-api-profiler.html @alexrp
 
+/external @marek-safar @luhenry
+/external/binary-reference-assemblies @marek-safar @akoeplinger
+/external/bockbuild @akoeplinger @alexischr
+/external/boringssl @baulig
+/external/nuget-buildtasks @radical @akoeplinger
+
+/libgc @BrzVlad @vargaz
+
+/llvm @vargaz
+
 /man @marek-safar @miguel
 /man/mprof-report.1 @alexrp
 
+/mcs @marek-safar
+
 /mcs/build @marek-safar @akoeplinger
 
 /mcs/class @marek-safar @akoeplinger
 /mcs/class/System/Mono.Btls @baulig
 /mcs/class/System/Mono.Net.Security @baulig
 /mcs/class/System/Mono.Security.Interface @baulig
-/mcs/class/System.Data @egorbo
+/mcs/class/System.Data* @egorbo
 
 /mcs/errors @marek-safar
+/mcs/ilasm @marek-safar
+/mcs/jay @marek-safar
 /mcs/mcs @marek-safar
 /mcs/tests @marek-safar
+/mcs/tools @marek-safar @akoeplinger
 
+/mono @luhenry
+
+/mono/btls @baulig
+/mono/dis @lambdageek @vargaz
 /mono/eglib @kumpera @vargaz @luhenry
 
 /mono/metadata @vargaz @kumpera
@@ -63,6 +84,7 @@
 /mono/mini/*type-check* @lewurm
 /mono/mini/interp/* @lewurm
 /mono/mini/*profiler* @alexrp
+/mono/mini/debugger-agent.c @DavidKarlas
 
 /mono/profiler @alexrp @kumpera
 
 /mono/utils/mono-mem* @alexrp
 /mono/utils/mono-threads* @luhenry @kumpera
 
+/msvc @ntherning
 /msvc/*profiler* @alexrp
 /msvc/scripts @akoeplinger
 
 /packaging/ @alexischr @akoeplinger
 /packaging/MacSDK/msbuild.py @radical @akoeplinger
 
+/runtime @akoeplinger @marek-safar
+
+/samples @luhenry
 /samples/profiler @alexrp
 /samples/size @alexrp
 
 /scripts/ci @akoeplinger
 /scripts/ci/run-test-profiler-stress-tests.sh @alexrp
 
+/support @luhenry @vargaz
+
 /tools @kumpera
 /tools/checker @tritao
 /tools/crash-bisector @kumpera
index 8cb099618a19551ee5e4f95c45d0f55e43db84ff..c322d249127837da530f6c936ee1f98df0ed6540 100644 (file)
@@ -109,23 +109,6 @@ monotouch-do-clean:
 
 endif
 
-win32getdeps:
-       wget http://www.go-mono.com/archive/pkgconfig-0.11-20020310.zip
-       wget http://www.go-mono.com/archive/glib-2.0.4-20020703.zip 
-       wget http://www.go-mono.com/archive/glib-dev-2.0.4-20020703.zip 
-       wget http://www.go-mono.com/archive/libiconv-1.7.zip 
-       wget http://www.go-mono.com/archive/libiconv-dev-1.7.zip 
-       wget http://www.go-mono.com/archive/libintl-0.10.40-20020101.zip
-       unzip -n -d / pkgconfig-0.11-20020310.zip
-       unzip -n -d / glib-2.0.4-20020703.zip
-       unzip -n -d / glib-dev-2.0.4-20020703.zip
-       unzip -n -d / libiconv-1.7.zip
-       unzip -n -d / libiconv-dev-1.7.zip
-       unzip -n -d / libintl-0.10.40-20020101.zip
-
-win32setup:
-       makensis /DMILESTONE=$(VERSION) /DSOURCE_INSTALL_DIR=$(SOURCE_INSTALL_DIR) /DBUILDNUM=$(BUILDNUM) monowiz.win32.nsi
-
 update-csproj:
        -rm msvc/scripts/order 
        -rm msvc/scripts/order.xml
index 72892380d5a2f68df5f549410f52c5de3654e0b5..bad8ecc8e3c8d08b5978acdf663d81535eb076be 100644 (file)
@@ -40,8 +40,8 @@ MONO_VERSION_BUILD=`echo $VERSION | cut -d . -f 3`
 # This can be reset to 0 when Mono's version number is bumped
 # since it's part of the corlib version (the prefix '1' in the full
 # version number is to ensure the number isn't treated as octal in C)
-MONO_CORLIB_COUNTER=0
-MONO_CORLIB_VERSION=`printf "1%02d%02d%02d%03d" $MONO_VERSION_MAJOR $MONO_VERSION_MINOR $MONO_VERSION_BUILD $MONO_CORLIB_COUNTER`
+MONO_CORLIB_COUNTER=1
+MONO_CORLIB_VERSION=`printf "1%02d%02d%02d%03d" $MONO_VERSION_MAJOR $MONO_VERSION_MINOR 0 $MONO_CORLIB_COUNTER`
 
 AC_DEFINE_UNQUOTED(MONO_CORLIB_VERSION,$MONO_CORLIB_VERSION,[Version of the corlib-runtime interface])
 AC_SUBST(MONO_CORLIB_VERSION)
@@ -1513,6 +1513,8 @@ if test x$host_win32 = xno; then
                AC_CHECK_FUNCS(getpwuid_r)
        fi
 
+       AC_FUNC_STRERROR_R()
+
        dnl ****************************************************************
        dnl *** Check for sched_setaffinity from glibc versions before   ***
        dnl *** 2.3.4. The older versions of the function only take 2    ***
@@ -4380,7 +4382,7 @@ AC_SUBST(mono_build_root)
 mono_runtime=mono/mini/mono
 AC_SUBST(mono_runtime)
 
-CSC_LOCATION=`cd $srcdir && pwd`/external/roslyn-binaries/Microsoft.Net.Compilers/Microsoft.Net.Compilers.2.3.1/tools/csc.exe
+CSC_LOCATION=`cd $srcdir && pwd`/external/roslyn-binaries/Microsoft.Net.Compilers/Microsoft.Net.Compilers.2.3.2/tools/csc.exe
 
 if test $csc_compiler = mcs; then
   CSC=$mcs_topdir/class/lib/build/mcs.exe
index bf03a7c5cf6b692fa662f1568ad66de35166b8ea..08ec62bbd349c042a40f959f242db7a54412e916 160000 (submodule)
@@ -1 +1 @@
-Subproject commit bf03a7c5cf6b692fa662f1568ad66de35166b8ea
+Subproject commit 08ec62bbd349c042a40f959f242db7a54412e916
index 142cbeb62ffabf1dd9c1414d8dd76f93bcbed0c2..9c5cc7f051a0bba2e41341a5baebfc4d2c2133ef 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 142cbeb62ffabf1dd9c1414d8dd76f93bcbed0c2
+Subproject commit 9c5cc7f051a0bba2e41341a5baebfc4d2c2133ef
index 14e17dfbebf5651b5ce70c7fb317e388f8a3a271..bc11f472954694ebd92ae4956f110c1036a7c2e0 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 14e17dfbebf5651b5ce70c7fb317e388f8a3a271
+Subproject commit bc11f472954694ebd92ae4956f110c1036a7c2e0
index 305e0f60533d164676099c918fa4dd09c718017b..99354bf5c13b8055209cb082cddc50c8047ab088 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 305e0f60533d164676099c918fa4dd09c718017b
+Subproject commit 99354bf5c13b8055209cb082cddc50c8047ab088
index 690603bea98aae69fca9a65130d88591bc6cabee..764656cdafdb3acd25df8cb52a4e0ea14760fccd 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 690603bea98aae69fca9a65130d88591bc6cabee
+Subproject commit 764656cdafdb3acd25df8cb52a4e0ea14760fccd
index 9d196fb777776880b2f3c31602aa167394ae2f6b..1904c7d0682a878e2d25b4d49f3475d12fbb9cc6 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 9d196fb777776880b2f3c31602aa167394ae2f6b
+Subproject commit 1904c7d0682a878e2d25b4d49f3475d12fbb9cc6
index 644b85a6e4f123c8987dae19825eeb2f34778196..607cea480479125836e6824cf147a81f08b63af4 100644 (file)
--- a/man/mcs.1
+++ b/man/mcs.1
@@ -4,26 +4,27 @@
 ..
 .TH mcs 1 "6 January 2001"
 .SH NAME 
-mcs \- Mono C# Compiler
+mcs \- Turbo C# Compiler
 .SH SYNOPSIS
 .B mcs 
 [option] [source-files]
 .SH DESCRIPTION
-mcs is the Mono C# compiler, an implementation of the ECMA-334
-language specification.  You can pass one or more options to drive the
-compiler, and a set of source files.  Extra options or arguments can
-be provided in a response file.  Response files are referenced by
-prepending the @ symbol to the response file name.
+mcs is the Turbo C# compiler (also known as the Mono C# compiler), it
+is an implementation of the ECMA-334 language specification.  You can
+pass one or more options to drive the compiler, and a set of source
+files.  Extra options or arguments can be provided in a response file.
+Response files are referenced by prepending the @ symbol to the
+response file name.
 .PP
 The 
 .I mcs
 compiler is used to compile against the latest Mono Base Class Library
 version and fully implements C# 1.0, 2.0, 3.0, 4.0, 5.0 and 6.0
-specifications.
+specifications with partial support for C# 7.0.
 .PP
 See the section on packages for more information.
 .PP
-The Mono C# compiler accepts the same command line options that the
+The Turbo C# compiler accepts the same command line options that the
 Microsoft C# compiler does.  Those options can start with a slash or a
 dash (/checked is the same as -checked).  Additionally some GNU-like
 options are supported, those begin with "--".  All MCS-specific flags
@@ -37,13 +38,13 @@ for partial compilation.  To achieve the benefits of partial
 compilation, you should compile programs into their own assemblies,
 and later reference them with the "-r" flag.
 .PP
-The Mono C# compiler generates images (.exe files) that contain CIL
+The Turbo C# compiler generates images (.exe files) that contain CIL
 byte code that can be executed by any system that implements a Common
 Language Infrastructure virtual machine such as the Microsoft .NET
 runtime engine on Windows or the Mono runtime engine on Unix systems.
 Executables are not bound to a specific CPU or operating system.
 .PP
-The Mono C# compiler by default only references three assemblies:
+The Turbo C# compiler by default only references three assemblies:
 mscorlib.dll, System.dll and System.Xml.dll.   If you want to
 reference extra libraries you must manually specify them using the
 -pkg: command line option or the -r: command line option.
@@ -53,7 +54,7 @@ use the -pkg:dotnet command line option.
 .SH OPTIONS
 .TP
 .I \-\-about
-Displays information about the Mono C# compiler
+Displays information about the Turbo C# compiler
 .TP
 .I \-\-addmodule:MODULE1[,MODULE2]
 Includes the specified modules in the resulting assembly.  Modules are
index 8a738a56f8384e332e678ccc94640c1dbf102d19..adcc3adff0cc13aa51b8dd2ec5f3669c7340d19a 100644 (file)
@@ -177,7 +177,9 @@ same as for the compiler -lib: or -L flags.
 Embeds the dynamic library file pointed to by `PATH' and optionally
 give it the name `LIB' into the bundled executable.   This is used to
 ship native library dependencies that are unpacked at startup and
-loaded from the runtime.
+loaded from the runtime. Multiple libraries should be specified in
+dependency order, where later ones on the command line depend on
+earlier ones.
 .TP
 .I "--lists-targets"
 Lists all of the available local cross compilation targets available
index 7bacf5bcb0d41a5a6703097885a3dc06542d5c84..7d2f14c151e5a42709de29d68df5022822d01667 100644 (file)
@@ -908,52 +908,8 @@ your profiler.
 For a sample of how to write your own custom profiler look in the
 Mono source tree for in the samples/profiler.c.
 .SH CODE COVERAGE
-Mono ships with a code coverage module.  This module is activated by
-using the Mono --profile=cov option.  The format is:
-\fB--profile=cov[:assembly-name[/namespace]] test-suite.exe\fR
-.PP
-By default code coverage will default to all the assemblies loaded,
-you can limit this by specifying the assembly name, for example to
-perform code coverage in the routines of your program use, for example
-the following command line limits the code coverage to routines in the
-"demo" assembly:
-.nf
-
-       mono --profile=cov:demo demo.exe
-
-.fi
-.PP
-Notice that the 
-.I assembly-name
-does not include the extension.
-.PP
-You can further restrict the code coverage output by specifying a
-namespace:
-.nf
-
-       mono --profile=cov:demo/My.Utilities demo.exe
-
-.fi
-.PP
-Which will only perform code coverage in the given assembly and
-namespace.  
-.PP
-Typical output looks like this:
-.nf
-
-       Not covered: Class:.ctor ()
-       Not covered: Class:A ()
-       Not covered: Driver:.ctor ()
-       Not covered: Driver:method ()
-       Partial coverage: Driver:Main ()
-               offset 0x000a
-
-.fi
-.PP
-The offsets displayed are IL offsets.
-.PP
-A more powerful coverage tool is available in the module `monocov'.
-See the monocov(1) man page for details.
+Mono ships with a code coverage module in the \f[I]log\f[] profiler.
+Check the `coverage' option on the mprof-report(1) page for more details.
 .SH AOT PROFILING
 You can improve startup performance by using the AOT profiler.
 .PP
@@ -2049,7 +2005,7 @@ http://www.mono-project.com/community/help/mailing-lists/
 http://www.mono-project.com
 .SH SEE ALSO
 .PP
-certmgr(1), cert-sync(1), csharp(1), gacutil(1), mcs(1), mdb(1), monocov(1), monodis(1),
+certmgr(1), cert-sync(1), csharp(1), gacutil(1), mcs(1), mdb(1), monodis(1),
 mono-config(5), mprof-report(1), pdb2mdb(1), xsp(1), mod_mono(8).
 .PP
 For more information on AOT:
index 8ffa784a23aeff1661c912461451be8e75a5445e..5a8bc7d0e481fc39c498d5a72fd1e9748f5897fa 100644 (file)
@@ -212,9 +212,9 @@ run-xunit-test: run-xunit-test-local
 xunit-test-local: $(xunit_test_lib)
 run-xunit-test-local: run-xunit-test-lib
 
-# ln -s is a HACK for xunit runner to require xunit.execution.desktop.dll file in local folder on .net only
+# cp -rf is a HACK for xunit runner to require xunit.execution.desktop.dll file in local folder on .net only
 run-xunit-test-lib: xunit-test-local
-       @ln -fs $(XTEST_HARNESS_PATH)/xunit.execution.desktop.dll xunit.execution.desktop.dll
+       @cp -rf $(XTEST_HARNESS_PATH)/xunit.execution.desktop.dll xunit.execution.desktop.dll
        ok=:; \
        PATH="$(TEST_RUNTIME_WRAPPERS_PATH):$(PATH)" $(TEST_RUNTIME) $(RUNTIME_FLAGS) $(AOT_RUN_FLAGS) $(XTEST_HARNESS) $(xunit_test_lib) $(XTEST_HARNESS_FLAGS) $(XTEST_TRAIT) || ok=false; \
        $$ok
index 725248a8fc06fac676c14e34288ccaa2c06e402a..57545f65e104f8cf3e545699273209c4f878df2a 100644 (file)
@@ -151,7 +151,7 @@ namespace Mono.Data.Tds.Protocol
                                        p.Precision = (p.Precision !=0  ? p.Precision : (byte) Precision);
                                                                                
                                parms.Append (p.Prepare ());
-                               if (p.Direction == TdsParameterDirection.Output)
+                               if (p.Direction == TdsParameterDirection.Output || p.Direction == TdsParameterDirection.InputOutput)
                                        parms.Append (" output");
                        }
                        return parms.ToString ();
index 91f8a06fc1a16b114f8a00c0b024fa95fcadb853..ed44567b40d019b14b7198a20c623f98a82449b1 100644 (file)
@@ -51,13 +51,10 @@ namespace MonoTests.Mono.Data.Tds
        //require at this point: a listener on port 1433...
 
        try{
-               Socket Listener = new Socket(AddressFamily.InterNetwork, 
-                                         SocketType.Stream,
-                                         ProtocolType.Tcp);
                IPAddress hostIP =Dns.GetHostEntry("localhost").AddressList[0];
-               IPEndPoint ep = new IPEndPoint(hostIP, 1433);
-               Listener.Bind(ep); 
-               Listener.Listen(1);
+        IPEndPoint ep = new IPEndPoint(hostIP, 1433);
+        TcpListener Listener = new TcpListener (ep);
+        Listener.Start ();
        } catch (Exception){
                //ignore
        }
@@ -103,6 +100,7 @@ namespace MonoTests.Mono.Data.Tds
 
        pool.ReleaseConnection(tds);
 
+       Listener.Stop ();
        //exit
     }
   }
index 3d435fda1e11aa741a7c93873e2c592c15a3f644..43f15d0023539197ffb364ac4072e52a7b0d7b32 100644 (file)
 
                        leave end
                } filter {
+                   castclass [mscorlib]System.Exception
                        call int32 class ExceptionFilterTest::Filter([mscorlib]System.Exception)
                        endfilter
                } {
+                   castclass [mscorlib]System.Exception
                        call void class ExceptionFilterTest::Handler([mscorlib]System.Exception)
                        leave end
                }
index 671293df18574599f9d98298adaabbb04fed78b2..94316e7e9644e47a94a5d9b28932a0377d822191 100644 (file)
@@ -3385,8 +3385,8 @@ public class DebuggerTests
                Assert.AreEqual (0, frames [0].Location.ILOffset);
 
                Assert.AreEqual (test_method.Name, frames [1].Location.Method.Name);
-               Assert.AreEqual (37, frames [1].Location.LineNumber);
-               Assert.AreEqual (0x0b, frames [1].Location.ILOffset);
+               Assert.AreEqual (38, frames [1].Location.LineNumber);
+               Assert.AreEqual (0x10, frames [1].Location.ILOffset);
 
                Assert.AreEqual (test_method.Name, frames [2].Location.Method.Name);
                Assert.AreEqual (33, frames [2].Location.LineNumber);
index 5afdbbeb4eb237e0dc0d0c3ac1bf45558dd991b3..7e8111b6c29cd941988d7aa6d2cf24bc9bea11d7 100644 (file)
@@ -102,73 +102,86 @@ namespace Mono.Profiler.Log {
                        var extType = (LogEventType) (type & 0xf0);
 
                        _time = ReadTime ();
+                       LogEvent ev = null;
 
                        switch (basicType) {
                        case LogEventType.Allocation:
                                switch (extType) {
                                case LogEventType.AllocationBacktrace:
                                case LogEventType.AllocationNoBacktrace:
-                                       return new AllocationEvent {
+                                       ev = new AllocationEvent {
                                                ClassPointer = ReadPointer (),
                                                ObjectPointer = ReadObject (),
                                                ObjectSize = (long) Reader.ReadULeb128 (),
                                                Backtrace = ReadBacktrace (extType == LogEventType.AllocationBacktrace),
                                        };
+                                       break;
                                default:
                                        throw new LogException ($"Invalid extended event type ({extType}).");
                                }
+                               break;
                        case LogEventType.GC:
                                switch (extType) {
                                case LogEventType.GCEvent:
-                                       return new GCEvent {
+                                       ev = new GCEvent {
                                                Type = (LogGCEvent) Reader.ReadByte (),
                                                Generation = Reader.ReadByte (),
                                        };
+                                       break;
                                case LogEventType.GCResize:
-                                       return new GCResizeEvent {
+                                       ev = new GCResizeEvent {
                                                NewSize = (long) Reader.ReadULeb128 (),
                                        };
+                                       break;
                                case LogEventType.GCMove: {
                                        var list = new long [(int) Reader.ReadULeb128 ()];
 
                                        for (var i = 0; i < list.Length; i++)
                                                list [i] = ReadObject ();
 
-                                       return new GCMoveEvent {
+                                       ev = new GCMoveEvent {
                                                OldObjectPointers = list.Where ((_, i) => i % 2 == 0).ToArray (),
                                                NewObjectPointers = list.Where ((_, i) => i % 2 != 0).ToArray (),
                                        };
+                                       break;
                                }
                                case LogEventType.GCHandleCreationNoBacktrace:
                                case LogEventType.GCHandleCreationBacktrace:
-                                       return new GCHandleCreationEvent {
+                                       ev = new GCHandleCreationEvent {
                                                Type = (LogGCHandleType) Reader.ReadULeb128 (),
                                                Handle = (long) Reader.ReadULeb128 (),
                                                ObjectPointer = ReadObject (),
                                                Backtrace = ReadBacktrace (extType == LogEventType.GCHandleCreationBacktrace),
                                        };
+                                       break;
                                case LogEventType.GCHandleDeletionNoBacktrace:
                                case LogEventType.GCHandleDeletionBacktrace:
-                                       return new GCHandleDeletionEvent {
+                                       ev = new GCHandleDeletionEvent {
                                                Type = (LogGCHandleType) Reader.ReadULeb128 (),
                                                Handle = (long) Reader.ReadULeb128 (),
                                                Backtrace = ReadBacktrace (extType == LogEventType.GCHandleDeletionBacktrace),
                                        };
+                                       break;
                                case LogEventType.GCFinalizeBegin:
-                                       return new GCFinalizeBeginEvent ();
+                                       ev = new GCFinalizeBeginEvent ();
+                                       break;
                                case LogEventType.GCFinalizeEnd:
-                                       return new GCFinalizeEndEvent ();
+                                       ev = new GCFinalizeEndEvent ();
+                                       break;
                                case LogEventType.GCFinalizeObjectBegin:
-                                       return new GCFinalizeObjectBeginEvent {
+                                       ev = new GCFinalizeObjectBeginEvent {
                                                ObjectPointer = ReadObject (),
                                        };
+                                       break;
                                case LogEventType.GCFinalizeObjectEnd:
-                                       return new GCFinalizeObjectEndEvent {
+                                       ev = new GCFinalizeObjectEndEvent {
                                                ObjectPointer = ReadObject (),
                                        };
+                                       break;
                                default:
                                        throw new LogException ($"Invalid extended event type ({extType}).");
                                }
+                               break;
                        case LogEventType.Metadata: {
                                var load = false;
                                var unload = false;
@@ -191,150 +204,169 @@ namespace Mono.Profiler.Log {
                                switch (metadataType) {
                                case LogMetadataType.Class:
                                        if (load) {
-                                               return new ClassLoadEvent {
+                                               ev = new ClassLoadEvent {
                                                        ClassPointer = ReadPointer (),
                                                        ImagePointer = ReadPointer (),
                                                        Name = Reader.ReadCString (),
                                                };
                                        } else
                                                throw new LogException ("Invalid class metadata event.");
+                                       break;
                                case LogMetadataType.Image:
                                        if (load) {
-                                               return new ImageLoadEvent {
+                                               ev = new ImageLoadEvent {
                                                        ImagePointer = ReadPointer (),
                                                        Name = Reader.ReadCString (),
                                                };
                                        } else if (unload) {
-                                               return new ImageUnloadEvent {
+                                               ev = new ImageUnloadEvent {
                                                        ImagePointer = ReadPointer (),
                                                        Name = Reader.ReadCString (),
                                                };
                                        } else
                                                throw new LogException ("Invalid image metadata event.");
+                                       break;
                                case LogMetadataType.Assembly:
                                        if (load) {
-                                               return new AssemblyLoadEvent {
+                                               ev = new AssemblyLoadEvent {
                                                        AssemblyPointer = ReadPointer (),
                                                        ImagePointer = ReadPointer (),
                                                        Name = Reader.ReadCString (),
                                                };
                                        } else if (unload) {
-                                               return new AssemblyUnloadEvent {
+                                               ev = new AssemblyUnloadEvent {
                                                        AssemblyPointer = ReadPointer (),
                                                        ImagePointer = ReadPointer (),
                                                        Name = Reader.ReadCString (),
                                                };
                                        } else
                                                throw new LogException ("Invalid assembly metadata event.");
+                                       break;
                                case LogMetadataType.AppDomain:
                                        if (load) {
-                                               return new AppDomainLoadEvent {
+                                               ev = new AppDomainLoadEvent {
                                                        AppDomainId = ReadPointer (),
                                                };
                                        } else if (unload) {
-                                               return new AppDomainUnloadEvent {
+                                               ev = new AppDomainUnloadEvent {
                                                        AppDomainId = ReadPointer (),
                                                };
                                        } else {
-                                               return new AppDomainNameEvent {
+                                               ev = new AppDomainNameEvent {
                                                        AppDomainId = ReadPointer (),
                                                        Name = Reader.ReadCString (),
                                                };
                                        }
+                                       break;
                                case LogMetadataType.Thread:
                                        if (load) {
-                                               return new ThreadStartEvent {
+                                               ev = new ThreadStartEvent {
                                                        ThreadId = ReadPointer (),
                                                };
                                        } else if (unload) {
-                                               return new ThreadEndEvent {
+                                               ev = new ThreadEndEvent {
                                                        ThreadId = ReadPointer (),
                                                };
                                        } else {
-                                               return new ThreadNameEvent {
+                                               ev = new ThreadNameEvent {
                                                        ThreadId = ReadPointer (),
                                                        Name = Reader.ReadCString (),
                                                };
                                        }
+                                       break;
                                case LogMetadataType.Context:
                                        if (load) {
-                                               return new ContextLoadEvent {
+                                               ev = new ContextLoadEvent {
                                                        ContextId = ReadPointer (),
                                                        AppDomainId = ReadPointer (),
                                                };
                                        } else if (unload) {
-                                               return new ContextUnloadEvent {
+                                               ev = new ContextUnloadEvent {
                                                        ContextId = ReadPointer (),
                                                        AppDomainId = ReadPointer (),
                                                };
                                        } else
                                                throw new LogException ("Invalid context metadata event.");
+                                       break;
                                default:
                                        throw new LogException ($"Invalid metadata type ({metadataType}).");
                                }
+                               break;
                        }
                        case LogEventType.Method:
                                switch (extType) {
                                case LogEventType.MethodLeave:
-                                       return new LeaveEvent {
+                                       ev = new LeaveEvent {
                                                MethodPointer = ReadMethod (),
                                        };
+                                       break;
                                case LogEventType.MethodEnter:
-                                       return new EnterEvent {
+                                       ev = new EnterEvent {
                                                MethodPointer = ReadMethod (),
                                        };
+                                       break;
                                case LogEventType.MethodLeaveExceptional:
-                                       return new ExceptionalLeaveEvent {
+                                       ev = new ExceptionalLeaveEvent {
                                                MethodPointer = ReadMethod (),
                                        };
+                                       break;
                                case LogEventType.MethodJit:
-                                       return new JitEvent {
+                                       ev = new JitEvent {
                                                MethodPointer = ReadMethod (),
                                                CodePointer = ReadPointer (),
                                                CodeSize = (long) Reader.ReadULeb128 (),
                                                Name = Reader.ReadCString (),
                                        };
+                                       break;
                                default:
                                        throw new LogException ($"Invalid extended event type ({extType}).");
                                }
+                               break;
                        case LogEventType.Exception:
                                switch (extType) {
                                case LogEventType.ExceptionThrowNoBacktrace:
                                case LogEventType.ExceptionThrowBacktrace:
-                                       return new ThrowEvent {
+                                       ev = new ThrowEvent {
                                                ObjectPointer = ReadObject (),
                                                Backtrace = ReadBacktrace (extType == LogEventType.ExceptionThrowBacktrace),
                                        };
+                                       break;
                                case LogEventType.ExceptionClause:
-                                       return new ExceptionClauseEvent {
+                                       ev = new ExceptionClauseEvent {
                                                Type = (LogExceptionClause) Reader.ReadByte (),
                                                Index = (long) Reader.ReadULeb128 (),
                                                MethodPointer = ReadMethod (),
                                                ObjectPointer = ReadObject (),
                                        };
+                                       break;
                                default:
                                        throw new LogException ($"Invalid extended event type ({extType}).");
                                }
+                               break;
                        case LogEventType.Monitor:
                                switch (extType) {
                                case LogEventType.MonitorNoBacktrace:
                                case LogEventType.MonitorBacktrace:
-                                       return new MonitorEvent {
+                                       ev = new MonitorEvent {
                                                Event = (LogMonitorEvent) Reader.ReadByte (),
                                                ObjectPointer = ReadObject (),
                                                Backtrace = ReadBacktrace (extType == LogEventType.MonitorBacktrace),
                                        };
+                                       break;
                                default:
                                        throw new LogException ($"Invalid extended event type ({extType}).");
                                }
+                               break;
                        case LogEventType.Heap:
                                switch (extType) {
                                case LogEventType.HeapBegin:
-                                       return new HeapBeginEvent ();
+                                       ev = new HeapBeginEvent ();
+                                       break;
                                case LogEventType.HeapEnd:
-                                       return new HeapEndEvent ();
+                                       ev = new HeapEndEvent ();
+                                       break;
                                case LogEventType.HeapObject: {
-                                       var ev = new HeapObjectEvent {
+                                       HeapObjectEvent hoe = new HeapObjectEvent {
                                                ObjectPointer = ReadObject (),
                                                ClassPointer = ReadPointer (),
                                                ObjectSize = (long) Reader.ReadULeb128 (),
@@ -349,17 +381,18 @@ namespace Mono.Profiler.Log {
                                                };
                                        }
 
-                                       ev.References = list;
+                                       hoe.References = list;
+                                       ev = hoe;
 
-                                       return ev;
+                                       break;
                                }
+
                                case LogEventType.HeapRoots: {
                                        // TODO: This entire event makes no sense.
-
-                                       var ev = new HeapRootsEvent ();
+                                       var hre = new HeapRootsEvent ();
                                        var list = new HeapRootsEvent.HeapRoot [(int) Reader.ReadULeb128 ()];
 
-                                       ev.MaxGenerationCollectionCount = (long) Reader.ReadULeb128 ();
+                                       hre.MaxGenerationCollectionCount = (long) Reader.ReadULeb128 ();
 
                                        for (var i = 0; i < list.Length; i++) {
                                                list [i] = new HeapRootsEvent.HeapRoot {
@@ -369,36 +402,41 @@ namespace Mono.Profiler.Log {
                                                };
                                        }
 
-                                       ev.Roots = list;
+                                       hre.Roots = list;
+                                       ev = hre;
 
-                                       return ev;
+                                       break;
                                }
                                default:
                                        throw new LogException ($"Invalid extended event type ({extType}).");
                                }
+                               break;
                        case LogEventType.Sample:
                                switch (extType) {
                                case LogEventType.SampleHit:
-                                       return new SampleHitEvent {
+                                       ev = new SampleHitEvent {
                                                ThreadId = ReadPointer (),
                                                UnmanagedBacktrace = ReadBacktrace (true, false),
                                                ManagedBacktrace = ReadBacktrace (true),
                                        };
+                                       break;
                                case LogEventType.SampleUnmanagedSymbol:
-                                       return new UnmanagedSymbolEvent {
+                                       ev = new UnmanagedSymbolEvent {
                                                CodePointer = ReadPointer (),
                                                CodeSize = (long) Reader.ReadULeb128 (),
                                                Name = Reader.ReadCString (),
                                        };
+                                       break;
                                case LogEventType.SampleUnmanagedBinary:
-                                       return new UnmanagedBinaryEvent {
+                                       ev = new UnmanagedBinaryEvent {
                                                SegmentPointer = ReadPointer (),
                                                SegmentOffset = (long) Reader.ReadULeb128 (),
                                                SegmentSize = (long) Reader.ReadULeb128 (),
                                                FileName = Reader.ReadCString (),
                                        };
+                                       break;
                                case LogEventType.SampleCounterDescriptions: {
-                                       var ev = new CounterDescriptionsEvent ();
+                                       var cde = new CounterDescriptionsEvent ();
                                        var list = new CounterDescriptionsEvent.CounterDescription [(int) Reader.ReadULeb128 ()];
 
                                        for (var i = 0; i < list.Length; i++) {
@@ -415,12 +453,13 @@ namespace Mono.Profiler.Log {
                                                };
                                        }
 
-                                       ev.Descriptions = list;
+                                       cde.Descriptions = list;
+                                       ev = cde;
 
-                                       return ev;
+                                       break;
                                }
                                case LogEventType.SampleCounters: {
-                                       var ev = new CounterSamplesEvent ();
+                                       var cse = new CounterSamplesEvent ();
                                        var list = new List<CounterSamplesEvent.CounterSample> ();
 
                                        while (true) {
@@ -461,40 +500,51 @@ namespace Mono.Profiler.Log {
                                                });
                                        }
 
-                                       ev.Samples = list;
+                                       cse.Samples = list;
+                                       ev = cse;
 
-                                       return ev;
+                                       break;
                                }
                                default:
                                        throw new LogException ($"Invalid extended event type ({extType}).");
                                }
+                               break;
                        case LogEventType.Runtime:
                                switch (extType) {
                                case LogEventType.RuntimeJitHelper: {
                                        var helperType = (LogJitHelper) Reader.ReadByte ();
 
-                                       return new JitHelperEvent {
+                                       ev = new JitHelperEvent {
                                                Type = helperType,
                                                BufferPointer = ReadPointer (),
                                                BufferSize = (long) Reader.ReadULeb128 (),
                                                Name = helperType == LogJitHelper.SpecificTrampoline ? Reader.ReadCString () : string.Empty,
                                        };
+                                       break;
                                }
                                default:
                                        throw new LogException ($"Invalid extended event type ({extType}).");
                                }
+                               break;
                        case LogEventType.Meta:
                                switch (extType) {
                                case LogEventType.MetaSynchronizationPoint:
-                                       return new SynchronizationPointEvent {
+                                       ev = new SynchronizationPointEvent {
                                                Type = (LogSynchronizationPoint) Reader.ReadByte (),
                                        };
+                                       break;
                                default:
                                        throw new LogException ($"Invalid extended event type ({extType}).");
                                }
+                               break;
                        default:
                                throw new LogException ($"Invalid basic event type ({basicType}).");
                        }
+
+                       ev.Timestamp = _time;
+                       ev.Buffer = _bufferHeader;
+
+                       return ev;
                }
 
                long ReadPointer ()
index 3aed1008318cb46e5a3c11fda95fe2bf9de252fb..7a9b42a261f5a4765df4a1cb0f88cf08b610dde1 100644 (file)
     <Compile Include=".\Mono.Security.Cryptography\SymmetricTransform.cs" />\r
     <Compile Include=".\Mono.Security.Cryptography\TlsHMAC.cs" />\r
     <Compile Include=".\Mono.Security.Interface\Alert.cs" />\r
-    <Compile Include=".\Mono.Security.Interface\BufferOffsetSize.cs" />\r
     <Compile Include=".\Mono.Security.Interface\CertificateValidationHelper.cs" />\r
     <Compile Include=".\Mono.Security.Interface\CipherAlgorithmType.cs" />\r
     <Compile Include=".\Mono.Security.Interface\CipherSuiteCode.cs" />\r
     <Compile Include=".\Mono.Security.Interface\ExchangeAlgorithmType.cs" />\r
     <Compile Include=".\Mono.Security.Interface\HashAlgorithmType.cs" />\r
-    <Compile Include=".\Mono.Security.Interface\IBufferOffsetSize.cs" />\r
     <Compile Include=".\Mono.Security.Interface\IMonoSslStream.cs" />\r
-    <Compile Include=".\Mono.Security.Interface\IMonoTlsEventSink.cs" />\r
     <Compile Include=".\Mono.Security.Interface\MonoTlsConnectionInfo.cs" />\r
     <Compile Include=".\Mono.Security.Interface\MonoTlsProvider.cs" />\r
     <Compile Include=".\Mono.Security.Interface\MonoTlsProviderFactory.cs" />\r
     <Compile Include=".\Mono.Security.Interface\MonoTlsSettings.cs" />\r
-    <Compile Include=".\Mono.Security.Interface\SecretParameters.cs" />\r
-    <Compile Include=".\Mono.Security.Interface\SecureBuffer.cs" />\r
-    <Compile Include=".\Mono.Security.Interface\TlsBuffer.cs" />\r
     <Compile Include=".\Mono.Security.Interface\TlsException.cs" />\r
-    <Compile Include=".\Mono.Security.Interface\TlsMultiBuffer.cs" />\r
     <Compile Include=".\Mono.Security.Interface\TlsProtocolCode.cs" />\r
     <Compile Include=".\Mono.Security.Interface\TlsProtocols.cs" />\r
     <Compile Include=".\Mono.Security.Protocol.Ntlm\ChallengeResponse.cs" />\r
diff --git a/mcs/class/Mono.Security/Mono.Security.Interface/BufferOffsetSize.cs b/mcs/class/Mono.Security/Mono.Security.Interface/BufferOffsetSize.cs
deleted file mode 100644 (file)
index 7138962..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-//
-// BufferOffsetSize.cs
-//
-// Author:
-//       Martin Baulig <martin.baulig@xamarin.com>
-//
-// Copyright (c) 2014-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;
-
-namespace Mono.Security.Interface
-{
-       public class BufferOffsetSize : SecretParameters, IBufferOffsetSize
-       {
-               public byte[] Buffer {
-                       get;
-                       private set;
-               }
-
-               public int Offset {
-                       get;
-                       internal set;
-               }
-
-               public int Size {
-                       get { return EndOffset - Offset; }
-               }
-
-               public int EndOffset {
-                       get;
-                       internal set;
-               }
-
-               public BufferOffsetSize (byte[] buffer, int offset, int size)
-               {
-                       Buffer = buffer;
-                       Offset = offset;
-                       EndOffset = offset + size;
-               }
-
-               public BufferOffsetSize (byte[] buffer)
-                       : this (buffer, 0, buffer.Length)
-               {
-               }
-
-               public BufferOffsetSize (int size)
-                       : this (new byte [size])
-               {
-               }
-
-               public byte[] GetBuffer ()
-               {
-                       var copy = new byte [Size];
-                       Array.Copy (Buffer, Offset, copy, 0, Size);
-                       return copy;
-               }
-
-               public void TruncateTo (int newSize)
-               {
-                       if (newSize > Size)
-                               throw new ArgumentException ("newSize");
-                       EndOffset = Offset + newSize;
-               }
-
-               protected void SetBuffer (byte[] buffer, int offset, int size)
-               {
-                       Buffer = buffer;
-                       Offset = offset;
-                       EndOffset = offset + size;
-               }
-
-               protected override void Clear ()
-               {
-                       Buffer = null;
-                       Offset = EndOffset = 0;
-               }
-       }
-}
-
diff --git a/mcs/class/Mono.Security/Mono.Security.Interface/IBufferOffsetSize.cs b/mcs/class/Mono.Security/Mono.Security.Interface/IBufferOffsetSize.cs
deleted file mode 100644 (file)
index 93b422c..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-//
-// IBufferOffsetSize.cs
-//
-// Author:
-//       Martin Baulig <martin.baulig@xamarin.com>
-//
-// Copyright (c) 2015 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 Mono.Security.Interface
-{
-       public interface IBufferOffsetSize
-       {
-               byte[] Buffer {
-                       get;
-               }
-
-               int Offset {
-                       get;
-               }
-
-               int Size {
-                       get;
-               }
-       }
-}
-
diff --git a/mcs/class/Mono.Security/Mono.Security.Interface/IMonoTlsEventSink.cs b/mcs/class/Mono.Security/Mono.Security.Interface/IMonoTlsEventSink.cs
deleted file mode 100644 (file)
index 3772930..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-//
-// IMonoTlsEventSink.cs
-//
-// Author:
-//       Martin Baulig <martin.baulig@xamarin.com>
-//
-// Copyright (c) 2015 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.
-using System;
-
-namespace Mono.Security.Interface
-{
-       public interface IMonoTlsEventSink
-       {
-               void Error (Exception exception);
-
-               void ReceivedCloseNotify ();
-       }
-}
-
index 05f507a852eb93b0436aec44faf77e6ce190d270..5a03262e229f281a0ce751f4a28c6ed160902969 100644 (file)
@@ -163,5 +163,14 @@ namespace Mono.Security.Interface
                        X509CertificateCollection certificates, bool wantsChain, ref X509Chain chain,
                        ref MonoSslPolicyErrors errors, ref int status11);
 #endregion
+
+#region Misc
+
+               internal abstract bool SupportsCleanShutdown {
+                       get;
+               }
+
+#endregion
+
        }
 }
index 6a1bf86ed1fae893c05082843b554ae1db4fae7b..ee7e216cc2103ee31a529f16105bfeb6f7ab09c9 100644 (file)
@@ -86,6 +86,13 @@ namespace Mono.Security.Interface
                        get; set;
                }
 
+               /*
+                * This is only supported if MonoTlsProvider.SupportsCleanShutdown is true.
+                */
+               internal bool SendCloseNotify {
+                       get; set;
+               }
+
                /*
                 * If you set this here, then it will override 'ServicePointManager.SecurityProtocol'.
                 */
@@ -173,6 +180,7 @@ namespace Mono.Security.Interface
                        EnabledProtocols = other.EnabledProtocols;
                        EnabledCiphers = other.EnabledCiphers;
                        CertificateValidationTime = other.CertificateValidationTime;
+                       SendCloseNotify = other.SendCloseNotify;
                        if (other.TrustAnchors != null)
                                TrustAnchors = new X509CertificateCollection (other.TrustAnchors);
                        if (other.CertificateSearchPaths != null) {
diff --git a/mcs/class/Mono.Security/Mono.Security.Interface/SecretParameters.cs b/mcs/class/Mono.Security/Mono.Security.Interface/SecretParameters.cs
deleted file mode 100644 (file)
index a225ba6..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-//
-// SecretParameters.cs
-//
-// Author:
-//       Martin Baulig <martin.baulig@xamarin.com>
-//
-// Copyright (c) 2014-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;
-
-namespace Mono.Security.Interface
-{
-       public abstract class SecretParameters : IDisposable
-       {
-               protected abstract void Clear ();
-
-               bool disposed;
-
-               protected void CheckDisposed ()
-               {
-                       if (disposed)
-                               throw new ObjectDisposedException (GetType ().Name);
-               }
-
-               protected static void Clear (byte[] array)
-               {
-                       Array.Clear (array, 0, array.Length);
-               }
-
-               public void Dispose ()
-               {
-                       Dispose (true);
-                       GC.SuppressFinalize (this);
-               }
-
-               void Dispose (bool disposing)
-               {
-                       if (!disposed) {
-                               disposed = true;
-                               Clear ();
-                       }
-               }
-
-               ~SecretParameters ()
-               {
-                       Dispose (false);
-               }
-       }
-}
-
diff --git a/mcs/class/Mono.Security/Mono.Security.Interface/SecureBuffer.cs b/mcs/class/Mono.Security/Mono.Security.Interface/SecureBuffer.cs
deleted file mode 100644 (file)
index fc05f7a..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-//
-// SecureBuffer.cs
-//
-// Author:
-//       Martin Baulig <martin.baulig@xamarin.com>
-//
-// Copyright (c) 2014-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;
-
-namespace Mono.Security.Interface
-{
-       public class SecureBuffer : SecretParameters, IBufferOffsetSize
-       {
-               byte[] buffer;
-
-               public byte[] Buffer {
-                       get {
-                               CheckDisposed ();
-                               return buffer;
-                       }
-               }
-
-               public int Size {
-                       get {
-                               CheckDisposed ();
-                               return buffer != null ? buffer.Length : 0;
-                       }
-               }
-
-               int IBufferOffsetSize.Offset {
-                       get { return 0; }
-               }
-
-               public SecureBuffer (int size)
-               {
-                       buffer = new byte [size];
-               }
-
-               public SecureBuffer (byte[] buffer)
-               {
-                       this.buffer = buffer;
-               }
-
-               public byte[] StealBuffer ()
-               {
-                       CheckDisposed ();
-                       var retval = this.buffer;
-                       this.buffer = null;
-                       return retval;
-               }
-
-               public static SecureBuffer CreateCopy (byte[] buffer)
-               {
-                       var copy = new byte [buffer.Length];
-                       Array.Copy (buffer, copy, buffer.Length);
-                       return new SecureBuffer (copy);
-               }
-
-               protected override void Clear ()
-               {
-                       if (buffer != null) {
-                               Array.Clear (buffer, 0, buffer.Length);
-                               buffer = null;
-                       }
-               }
-       }
-}
-
diff --git a/mcs/class/Mono.Security/Mono.Security.Interface/TlsBuffer.cs b/mcs/class/Mono.Security/Mono.Security.Interface/TlsBuffer.cs
deleted file mode 100644 (file)
index be3c007..0000000
+++ /dev/null
@@ -1,334 +0,0 @@
-//
-// TlsBuffer.cs
-//
-// Author:
-//       Martin Baulig <martin.baulig@xamarin.com>
-//
-// Copyright (c) 2014-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;
-
-namespace Mono.Security.Interface
-{
-       public class TlsBuffer : SecretParameters
-       {
-               public int Position {
-                       get; set;
-               }
-
-               public int Remaining {
-                       get { return Size - (Position - Offset); }
-               }
-
-               public byte[] Buffer {
-                       get { return innerBuffer.Buffer; }
-               }
-
-               public int Offset {
-                       get { return innerBuffer.Offset; }
-               }
-
-               public int Size {
-                       get { return innerBuffer.Size; }
-               }
-
-               public int EndOffset {
-                       get { return Offset + Size; }
-               }
-
-               IBufferOffsetSize innerBuffer;
-
-               protected TlsBuffer ()
-                       : this (null, 0, 0)
-               {
-               }
-
-               public TlsBuffer (IBufferOffsetSize bos)
-               {
-                       innerBuffer = bos;
-                       Position = bos.Offset;
-               }
-
-               public TlsBuffer (byte[] buffer, int offset, int size)
-                       : this (new BufferOffsetSize (buffer, offset, size))
-               {
-               }
-
-               public TlsBuffer (byte[] buffer)
-                       : this (buffer, 0, buffer.Length)
-               {
-               }
-
-               public TlsBuffer (int size)
-                       : this (new byte [size], 0, size)
-               {
-               }
-
-               public byte ReadByte ()
-               {
-                       if (Position >= EndOffset)
-                               throw new TlsException (AlertDescription.DecodeError, "Buffer overflow");
-                       return Buffer [Position++];
-               }
-
-               public short ReadInt16 ()
-               {
-                       if (Position + 1 >= EndOffset)
-                               throw new TlsException (AlertDescription.DecodeError, "Buffer overflow");
-                       var retval = (short)(Buffer [Position] << 8 | Buffer [Position + 1]);
-                       Position += 2;
-                       return retval;
-               }
-
-               public int ReadInt24 ()
-               {
-                       if (Position + 2 >= EndOffset)
-                               throw new TlsException (AlertDescription.DecodeError, "Buffer overflow");
-                       var retval = ((Buffer [Position] << 16) | (Buffer [Position+1] << 8) | Buffer [Position+2]);
-                       Position += 3;
-                       return retval;
-               }
-
-               public int ReadInt32 ()
-               {
-                       if (Position + 3 >= EndOffset)
-                               throw new TlsException (AlertDescription.DecodeError, "Buffer overflow");
-                       var retval = ((Buffer [Position] << 24) | (Buffer [Position+1] << 16) | (Buffer [Position+2] << 8) | Buffer [Position+3]);
-                       Position += 4;
-                       return retval;
-               }
-
-               public TlsBuffer ReadBuffer (int length)
-               {
-                       if (Position + length > EndOffset)
-                               throw new TlsException (AlertDescription.DecodeError, "Buffer overflow");
-                       var retval = new TlsBuffer (Buffer, Position, length);
-                       Position += length;
-                       return retval;
-               }
-
-               public IBufferOffsetSize GetRemaining ()
-               {
-                       return new BufferOffsetSize (Buffer, Position, Remaining);
-               }
-
-               protected virtual void MakeRoomInternal (int size)
-               {
-                       if (Position + size > EndOffset)
-                               throw new TlsException (AlertDescription.DecodeError, "Buffer overflow");
-               }
-
-               public void Write (byte value)
-               {
-                       MakeRoomInternal (1);
-                       Buffer [Position++] = value;
-               }
-
-               public void Write (short value)
-               {
-                       MakeRoomInternal (2);
-                       WriteInt16 (Buffer, Position, value);
-                       Position += 2;
-               }
-
-               public static void WriteInt16 (byte[] buffer, int offset, short value)
-               {
-                       buffer[offset] = ((byte)(value >> 8));
-                       buffer[offset+1] = ((byte)value);
-               }
-
-               public void Write (int value)
-               {
-                       MakeRoomInternal (4);
-                       WriteInt32 (Buffer, Position, value);
-                       Position += 4;
-               }
-
-               public void WriteInt24 (int value)
-               {
-                       MakeRoomInternal (3);
-                       WriteInt24 (Buffer, Position, value);
-                       Position += 3;
-               }
-
-               #pragma warning disable 3001
-               public void Write (ulong value)
-               #pragma warning restore 3001
-               {
-                       MakeRoomInternal (8);
-                       WriteInt64 (Buffer, Position, value);
-                       Position += 8;
-               }
-
-               public static void WriteInt24 (byte[] buffer, int offset, int value)
-               {
-                       buffer[offset] = ((byte)(value >> 16));
-                       buffer[offset+1] = ((byte)(value >> 8));
-                       buffer[offset+2] = ((byte)value);
-               }
-
-               public static void WriteInt32 (byte[] buffer, int offset, int value)
-               {
-                       buffer[offset] = ((byte)(value >> 24));
-                       buffer[offset+1] = ((byte)(value >> 16));
-                       buffer[offset+2] = ((byte)(value >> 8));
-                       buffer[offset+3] = ((byte)value);
-               }
-
-               #pragma warning disable 3001
-               public static void WriteInt64 (byte[] buffer, int offset, ulong value)
-               #pragma warning restore 3001
-               {
-                       buffer[offset] = (byte) (value >> 56);
-                       buffer[offset+1] = (byte) (value >> 48);
-                       buffer[offset+2] = (byte) (value >> 40);
-                       buffer[offset+3] = (byte) (value >> 32);
-                       buffer[offset+4] = (byte) (value >> 24);
-                       buffer[offset+5] = (byte) (value >> 16);
-                       buffer[offset+6] = (byte) (value >> 8);
-                       buffer[offset+7] = (byte) value;
-               }
-
-               public void Write (byte[] buffer)
-               {
-                       Write (buffer, 0, buffer.Length);
-               }
-
-               public void Write (byte[] buffer, int offset, int size)
-               {
-                       MakeRoomInternal (size);
-                       Array.Copy (buffer, offset, Buffer, Position, size);
-                       Position += size;
-               }
-
-               public void Write (IBufferOffsetSize buffer)
-               {
-                       Write (buffer.Buffer, buffer.Offset, buffer.Size);
-               }
-
-               public SecureBuffer ReadSecureBuffer (int count)
-               {
-                       return new SecureBuffer (ReadBytes (count));
-               }
-
-               public byte[] ReadBytes (int count)
-               {
-                       if (Position + count > EndOffset)
-                               throw new TlsException (AlertDescription.DecodeError, "Buffer overflow");
-                       var retval = new byte [count];
-                       Array.Copy (Buffer, Position, retval, 0, count);
-                       Position += count;
-                       return retval;
-               }
-
-               internal static bool Compare (SecureBuffer buffer1, SecureBuffer buffer2)
-               {
-                       if (buffer1 == null || buffer2 == null)
-                               return false;
-
-                       if (buffer1.Size != buffer2.Size)
-                               return false;
-
-                       for (int i = 0; i < buffer1.Size; i++) {
-                               if (buffer1.Buffer [i] != buffer2.Buffer [i])
-                                       return false;
-                       }
-                       return true;
-               }
-
-               public static bool Compare (IBufferOffsetSize buffer1, IBufferOffsetSize buffer2)
-               {
-                       if (buffer1 == null || buffer2 == null)
-                               return false;
-
-                       if (buffer1.Size != buffer2.Size)
-                               return false;
-
-                       for (int i = 0; i < buffer1.Size; i++) {
-                               if (buffer1.Buffer [buffer1.Offset + i] != buffer2.Buffer [buffer2.Offset + i])
-                                       return false;
-                       }
-                       return true;
-               }
-
-               public static bool Compare (byte[] buffer1, byte[] buffer2)
-               {
-                       if (buffer1 == null || buffer2 == null)
-                               return false;
-
-                       return Compare (buffer1, 0, buffer1.Length, buffer2, 0, buffer2.Length);
-               }
-
-               public static bool Compare (byte[] buffer1, int offset1, int size1, byte[] buffer2, int offset2, int size2)
-               {
-                       if (buffer1 == null || buffer2 == null)
-                               return false;
-
-                       if (size1 != size2)
-                               return false;
-
-                       for (int i = 0; i < size1; i++) {
-                               if (buffer1 [offset1 + i] != buffer2 [offset2 + i])
-                                       return false;
-                       }
-                       return true;
-
-               }
-
-               public static int ConstantTimeCompare (byte[] buffer1, int offset1, int size1, byte[] buffer2, int offset2, int size2)
-               {
-                       int status = 0;
-                       int effectiveSize;
-                       if (size1 < size2) {
-                               status--;
-                               effectiveSize = size1;
-                       } else if (size2 < size1) {
-                               status--;
-                               effectiveSize = size2;
-                       } else {
-                               effectiveSize = size1;
-                       }
-
-                       for (int i = 0; i < effectiveSize; i++) {
-                               if (buffer1 [offset1 + i] != buffer2 [offset2 + i])
-                                       status--;
-                       }
-
-                       return status;
-               }
-
-               protected void SetBuffer (byte[] buffer, int offset, int size)
-               {
-                       innerBuffer = new BufferOffsetSize (buffer, offset, size);
-               }
-
-               protected override void Clear ()
-               {
-                       var disposable = innerBuffer as IDisposable;
-                       if (disposable != null)
-                               disposable.Dispose ();
-                       innerBuffer = null;
-                       Position = 0;
-               }
-
-               public static readonly byte[] EmptyArray = new byte [0];
-       }
-}
-
diff --git a/mcs/class/Mono.Security/Mono.Security.Interface/TlsMultiBuffer.cs b/mcs/class/Mono.Security/Mono.Security.Interface/TlsMultiBuffer.cs
deleted file mode 100644 (file)
index de2975a..0000000
+++ /dev/null
@@ -1,119 +0,0 @@
-//
-// TlsMultiBuffer.cs
-//
-// Author:
-//       Martin Baulig <martin.baulig@xamarin.com>
-//
-// Copyright (c) 2014-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;
-
-namespace Mono.Security.Interface
-{
-       public class TlsMultiBuffer
-       {
-               MemoryChunk first, last;
-
-               private class MemoryChunk : BufferOffsetSize
-               {
-                       public MemoryChunk next;
-
-                       public MemoryChunk (byte[] buffer, int offset, int size)
-                               : base (buffer, offset, size)
-                       {
-                       }
-               }
-
-               public bool IsEmpty {
-                       get { return first == null; }
-               }
-
-               public bool IsSingle {
-                       get { return first != null && first.next == null; }
-               }
-
-               public void Add (TlsBuffer buffer)
-               {
-                       Add (buffer.Buffer, buffer.Offset, buffer.Size);
-               }
-
-               public void Add (byte[] buffer)
-               {
-                       Add (buffer, 0, buffer.Length);
-               }
-
-               public void Add (byte[] buffer, int offset, int size)
-               {
-                       var chunk = new MemoryChunk (buffer, offset, size);
-                       if (last == null)
-                               first = last = chunk;
-                       else {
-                               last.next = chunk;
-                               last = chunk;
-                       }
-               }
-
-               public BufferOffsetSize[] GetBufferArray ()
-               {
-                       int count = 0;
-                       for (var ptr = first; ptr != null; ptr = ptr.next)
-                               count++;
-                       var array = new BufferOffsetSize [count];
-                       count = 0;
-                       for (var ptr = first; ptr != null; ptr = ptr.next)
-                               array [count++] = ptr;
-                       return array;
-               }
-
-               public void Clear ()
-               {
-                       for (var ptr = first; ptr != null; ptr = ptr.next)
-                               ptr.Dispose ();
-                       first = last = null;
-               }
-
-               public BufferOffsetSize GetBuffer ()
-               {
-                       int totalSize = 0;
-                       for (var ptr = first; ptr != null; ptr = ptr.next)
-                               totalSize += ptr.Size;
-
-                       var outBuffer = new BufferOffsetSize (new byte [totalSize]);
-                       int offset = 0;
-                       for (var ptr = first; ptr != null; ptr = ptr.next) {
-                               Buffer.BlockCopy (ptr.Buffer, ptr.Offset, outBuffer.Buffer, offset, ptr.Size);
-                               offset += ptr.Size;
-                       }
-                       return outBuffer;
-               }
-
-               public BufferOffsetSize StealBuffer ()
-               {
-                       if (IsSingle) {
-                               var retval = first;
-                               first = last = null;
-                               return retval;
-                       }
-
-                       return GetBuffer ();
-               }
-       }
-}
-
index a270d5f75de9269a2f679b553f1b76a7b5256bbd..a3572f49478bec3f7628fa58c6d9dc8da9d7735c 100644 (file)
 ./Mono.Security.Interface/CipherSuiteCode.cs
 ./Mono.Security.Interface/ExchangeAlgorithmType.cs
 ./Mono.Security.Interface/HashAlgorithmType.cs
-./Mono.Security.Interface/IBufferOffsetSize.cs
-./Mono.Security.Interface/IMonoTlsEventSink.cs
 ./Mono.Security.Interface/IMonoSslStream.cs
 ./Mono.Security.Interface/MonoTlsConnectionInfo.cs
 ./Mono.Security.Interface/MonoTlsProvider.cs
 ./Mono.Security.Interface/TlsProtocolCode.cs
 ./Mono.Security.Interface/TlsProtocols.cs
 
-./Mono.Security.Interface/BufferOffsetSize.cs
-./Mono.Security.Interface/SecretParameters.cs
-./Mono.Security.Interface/SecureBuffer.cs
-./Mono.Security.Interface/TlsBuffer.cs
-./Mono.Security.Interface/TlsMultiBuffer.cs
index 35693efd7fcb650878edbc15e1b15dec0ebed94b..eca297380bcdc92386e6067a43e5b686447f67dd 100644 (file)
@@ -92,7 +92,9 @@ namespace PEAPI {
        /// </summary>
        public enum ImplAttr { IL, Native, Runtime = 0x03, Unmanaged = 0x04,
                ForwardRef = 0x10, PreserveSig = 0x0080, InternalCall = 0x1000, 
-               Synchronised = 0x0020, Synchronized = 0x0020, NoInLining = 0x0008, NoOptimization = 0x0040, Optil = 0x0002}
+               Synchronised = 0x0020, Synchronized = 0x0020, NoInLining = 0x0008, NoOptimization = 0x0040, Optil = 0x0002,
+               AggressiveInlining = 0x0100
+       }
 
        /// <summary>
        /// Storage location for initial field data
@@ -1639,6 +1641,7 @@ namespace PEAPI {
        public class ClassDef : Class {
 
                Class superType;
+               bool setSuperType;
                ArrayList fields = new ArrayList();
                ArrayList methods = new ArrayList();
                ArrayList events;
@@ -1654,9 +1657,6 @@ namespace PEAPI {
                                MetaData md) : base(nsName, name, md) 
                {
                        metaData = md;
-                       if (! ((nsName == "" && name == "<Module>") || (nsName == "System" && name == "Object")) ) {
-                               superType = metaData.mscorlib.GetSpecialSystemClass(PrimitiveType.Object);
-                       }
                        flags = (uint)attrSet;
                        tabIx = MDTable.TypeDef;
                }
@@ -1664,6 +1664,7 @@ namespace PEAPI {
                internal void SetSuper(Class sClass) 
                {
                        superType = sClass;
+                       setSuperType = true;
                        if (! (sClass is GenericTypeInst))
                                typeIndexChecked = false;
                }
@@ -1675,12 +1676,13 @@ namespace PEAPI {
                        else  
                                superType = metaData.mscorlib.ValueType();
 
+                       setSuperType = true;
                        typeIndex = PrimitiveType.ValueType.GetTypeIndex ();
                }
 
                public void SpecialNoSuper() 
                {
-                       superType = null;
+                       setSuperType = true;
                }
 
                /// <summary>
@@ -1922,8 +1924,13 @@ namespace PEAPI {
 
                internal sealed override void BuildTables(MetaData md) 
                {
-                       if (done) return;
-                       if ((flags & (uint)TypeAttr.Interface) != 0) { superType = null; }
+                       if (done) 
+                               return;
+                       
+                       if ((flags & (uint)TypeAttr.Interface) != 0) {
+                               superType = null;
+                               setSuperType = true;
+                       }
                        // Console.WriteLine("Building tables for " + name);
                        if (layout != null) md.AddToTable(MDTable.ClassLayout,layout);
                        // Console.WriteLine("adding methods " + methods.Count);
@@ -1956,6 +1963,10 @@ namespace PEAPI {
                                                        ((Property)properties[0]).Row,MDTable.Property));
                        }
                        // Console.WriteLine("End of building tables");
+
+                       if (!setSuperType)
+                               superType = metaData.mscorlib.GetSpecialSystemClass(PrimitiveType.Object);
+
                        done = true;
                }
 
@@ -5050,7 +5061,7 @@ namespace PEAPI {
                private byte heapSizes = 0;
                MetaDataElement entryPoint;
                BinaryWriter output;
-               public MSCorLib mscorlib;
+               MSCorLib _mscorlib;
                private TypeSpec[] systemTypeSpecs = new TypeSpec[PrimitiveType.NumSystemTypes];
                long mdStart;
                private ArrayList cattr_list;
@@ -5075,9 +5086,15 @@ namespace PEAPI {
                        for (int i=0; i < lgeCIx.Length; i++) {
                                lgeCIx[i] = false;
                        }
-                       mscorlib = new MSCorLib(this);
                }
 
+               public MSCorLib mscorlib {
+                       get {
+                               return _mscorlib ?? (_mscorlib = new MSCorLib (this));
+                       }
+               }
+
+
                internal TypeSpec GetPrimitiveTypeSpec(int ix) 
                {
                        return systemTypeSpecs[ix];
diff --git a/mcs/class/System.Drawing/Test/System.Drawing.Imaging/tests-ms.sh b/mcs/class/System.Drawing/Test/System.Drawing.Imaging/tests-ms.sh
deleted file mode 100755 (executable)
index 98b2c00..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/bin/sh\r
-\r
-if [ $# -eq 0 ]; then\r
-       echo "You should give a list of test names such as: "\r
-       echo "$0 System.Drawing.TestStringFormat"\r
-       echo "or"\r
-       echo "$0 all"   \r
-       exit 1\r
-fi\r
-\r
-export MSNet=Yes\r
-cp ../../System.Drawing_test.dll .\r
-topdir=../../../..\r
-NUNITCONSOLE=$topdir/class/lib/nunit-console.exe\r
-MONO_PATH=$topdir/nunit20:$topdir/class/lib:.\r
-\r
-for i in $@; do\r
-       if [ "$i" = "all" ]; then\r
-               fixture=""\r
-       else\r
-               fixture="/fixture:MonoTests.${i}"\r
-       fi\r
-       MONO_PATH=$MONO_PATH \\r
-               ${NUNITCONSOLE} System.Drawing_test.dll $fixture\r
-done\r
-\r
-\r
-\r
diff --git a/mcs/class/System.Drawing/Test/System.Drawing.Imaging/tests.sh b/mcs/class/System.Drawing/Test/System.Drawing.Imaging/tests.sh
deleted file mode 100755 (executable)
index 511cfcd..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/bin/sh
-
-if [ $# -eq 0 ]; then
-       echo "You should give a list of test names such as: "
-       echo "$0 System.Drawing.TestStringFormat"
-       echo "or"
-       echo "$0 all"
-       exit 1
-fi
-
-cp ../../System.Drawing_test_default.dll .
-
-topdir=../../../..
-NUNITCONSOLE=$topdir/class/lib/default/nunit-console.exe
-MONO_PATH=$topdir/nunit20:$topdir/class/lib/default:.
-
-
-for i in $@; do
-       if [ "$i" = "all" ]; then
-               fixture=""
-       else
-               fixture="/fixture:MonoTests.${i}"
-       fi
-       MONO_PATH=$MONO_PATH \
-               mono --debug ${NUNITCONSOLE} System.Drawing_test_default.dll $fixture
-done
-
-
-
diff --git a/mcs/class/System.Drawing/Test/System.Drawing/README b/mcs/class/System.Drawing/Test/System.Drawing/README
deleted file mode 100644 (file)
index 957903d..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-README
-
-* To run the tests using the Mono rutime
-
-cd mcs/class/System.Drawing
-make run-test
-
-* test-ms.sh runs the test using the MS .Net runtime and stores the bimaps 
-created by tests in the directory called MsNet.
-
-
-
diff --git a/mcs/class/System.Drawing/Test/System.Drawing/tests-ms.sh b/mcs/class/System.Drawing/Test/System.Drawing/tests-ms.sh
deleted file mode 100755 (executable)
index 6e17f27..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/bin/sh\r
-\r
-if [ $# -eq 0 ]; then\r
-       echo "You should give a list of test names such as: "\r
-       echo "$0 System.Drawing.TestStringFormat"\r
-       echo "or"\r
-       echo "$0 all"   \r
-       exit 1\r
-fi\r
-\r
-export MSNet=Yes\r
-cp ../../System.Drawing_test_default.dll .\r
-topdir=../../../..\r
-NUNITCONSOLE=$topdir/class/lib/default/nunit-console.exe\r
-MONO_PATH=$topdir/nunit20:$topdir/class/lib:.\r
-\r
-for i in $@; do\r
-       if [ "$i" = "all" ]; then\r
-               fixture=""\r
-       else\r
-               fixture="/fixture:MonoTests.${i}"\r
-       fi\r
-       MONO_PATH=$MONO_PATH \\r
-               ${NUNITCONSOLE} System.Drawing_test_default.dll $fixture\r
-done\r
-\r
-\r
-\r
diff --git a/mcs/class/System.Drawing/Test/System.Drawing/tests.sh b/mcs/class/System.Drawing/Test/System.Drawing/tests.sh
deleted file mode 100755 (executable)
index 511cfcd..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/bin/sh
-
-if [ $# -eq 0 ]; then
-       echo "You should give a list of test names such as: "
-       echo "$0 System.Drawing.TestStringFormat"
-       echo "or"
-       echo "$0 all"
-       exit 1
-fi
-
-cp ../../System.Drawing_test_default.dll .
-
-topdir=../../../..
-NUNITCONSOLE=$topdir/class/lib/default/nunit-console.exe
-MONO_PATH=$topdir/nunit20:$topdir/class/lib/default:.
-
-
-for i in $@; do
-       if [ "$i" = "all" ]; then
-               fixture=""
-       else
-               fixture="/fixture:MonoTests.${i}"
-       fi
-       MONO_PATH=$MONO_PATH \
-               mono --debug ${NUNITCONSOLE} System.Drawing_test_default.dll $fixture
-done
-
-
-
index 9aa6dcb02e43db6d6ae467e091f454c8f6021df9..a623a96cef487e799d3c2721cbedae73a58ad5ab 100644 (file)
@@ -1,3 +1,4 @@
+../../test-helpers/NetworkHelpers.cs
 System.Net.Http/DelegatingHandlerTest.cs
 System.Net.Http/ByteArrayContentTest.cs
 System.Net.Http/FormUrlEncodedContentTest.cs
index 72508c4883349ae19ada77271c939bfe18c04264..8344c26cc68687b585f7be3a8ef3dd08c2f36328 100644 (file)
@@ -38,6 +38,8 @@ using System.Net;
 using System.Linq;
 using System.IO;
 
+using MonoTests.Helpers;
+
 namespace MonoTests.System.Net.Http
 {
        [TestFixture]
@@ -175,22 +177,6 @@ namespace MonoTests.System.Net.Http
 
                const int WaitTimeout = 5000;
 
-               string TestHost, LocalServer;
-               int port;
-
-               [SetUp]
-               public void SetupFixture ()
-               {
-                       if (Environment.OSVersion.Platform == PlatformID.Win32NT) {
-                               port = 810;
-                       } else {
-                               port = 8810;
-                       }
-
-                       TestHost = "localhost:" + port;
-                       LocalServer = string.Format ("http://{0}/", TestHost);
-               }
-
                [Test]
                public void Ctor_Default ()
                {
@@ -410,6 +396,7 @@ namespace MonoTests.System.Net.Http
                public void Send_Complete_Default ()
                {
                        bool? failed = null;
+                       var port = NetworkHelpers.FindFreePort ();
                        var listener = CreateListener (l => {
                                try {
                                        var request = l.Request;
@@ -419,7 +406,7 @@ namespace MonoTests.System.Net.Http
                                        Assert.IsNull (request.ContentType, "#3");
                                        Assert.AreEqual (0, request.Cookies.Count, "#4");
                                        Assert.IsFalse (request.HasEntityBody, "#5");
-                                       Assert.AreEqual (TestHost, request.Headers["Host"], "#6b");
+                                       Assert.AreEqual ($"localhost:{port}", request.Headers["Host"], "#6b");
                                        Assert.AreEqual ("GET", request.HttpMethod, "#7");
                                        Assert.IsFalse (request.IsAuthenticated, "#8");
                                        Assert.IsTrue (request.IsLocal, "#9");
@@ -435,11 +422,11 @@ namespace MonoTests.System.Net.Http
                                } catch {
                                        failed = true;
                                }
-                       });
+                       }, port);
 
                        try {
                                var client = new HttpClient ();
-                               var request = new HttpRequestMessage (HttpMethod.Get, LocalServer);
+                               var request = new HttpRequestMessage (HttpMethod.Get, $"http://localhost:{port}/");
                                var response = client.SendAsync (request, HttpCompletionOption.ResponseHeadersRead).Result;
 
                                Assert.AreEqual ("", response.Content.ReadAsStringAsync ().Result, "#100");
@@ -458,6 +445,7 @@ namespace MonoTests.System.Net.Http
                {
                        bool? failed = null;
                        
+                       var port = NetworkHelpers.FindFreePort ();
                        var listener = CreateListener (l => {
                                try {
                                        var request = l.Request;
@@ -468,7 +456,7 @@ namespace MonoTests.System.Net.Http
                                        Assert.AreEqual (0, request.Cookies.Count, "#4");
                                        Assert.IsFalse (request.HasEntityBody, "#5");
                                        Assert.AreEqual (1, request.Headers.Count, "#6");
-                                       Assert.AreEqual (TestHost, request.Headers["Host"], "#6a");
+                                       Assert.AreEqual ($"localhost:{port}", request.Headers["Host"], "#6a");
                                        Assert.AreEqual ("GET", request.HttpMethod, "#7");
                                        Assert.IsFalse (request.IsAuthenticated, "#8");
                                        Assert.IsTrue (request.IsLocal, "#9");
@@ -484,11 +472,11 @@ namespace MonoTests.System.Net.Http
                                } catch {
                                        failed = true;
                                }
-                       });
+                       }, port);
 
                        try {
                                var client = new HttpClient ();
-                               var request = new HttpRequestMessage (HttpMethod.Get, LocalServer);
+                               var request = new HttpRequestMessage (HttpMethod.Get, $"http://localhost:{port}/");
                                request.Version = HttpVersion.Version10;
                                var response = client.SendAsync (request, HttpCompletionOption.ResponseHeadersRead).Result;
 
@@ -508,6 +496,7 @@ namespace MonoTests.System.Net.Http
                {
                        bool? failed = null;
                        
+                       var port = NetworkHelpers.FindFreePort ();
                        var listener = CreateListener (l => {
                                var request = l.Request;
                                
@@ -519,7 +508,7 @@ namespace MonoTests.System.Net.Http
                                        Assert.AreEqual (new Cookie ("mycookie", "vv"), request.Cookies[0], "#4a");
                                        Assert.IsFalse (request.HasEntityBody, "#5");
                                        Assert.AreEqual (4, request.Headers.Count, "#6");
-                                       Assert.AreEqual (TestHost, request.Headers["Host"], "#6a");
+                                       Assert.AreEqual ($"localhost:{port}", request.Headers["Host"], "#6a");
                                        Assert.AreEqual ("gzip", request.Headers["Accept-Encoding"], "#6b");
                                        Assert.AreEqual ("mycookie=vv", request.Headers["Cookie"], "#6c");
                                        Assert.AreEqual ("GET", request.HttpMethod, "#7");
@@ -537,7 +526,7 @@ namespace MonoTests.System.Net.Http
                                } catch {
                                        failed = true;
                                }
-                       });
+                       }, port);
 
                        try {
                                var chandler = new HttpClientHandler ();
@@ -546,14 +535,14 @@ namespace MonoTests.System.Net.Http
                                chandler.MaxAutomaticRedirections = 33;
                                chandler.MaxRequestContentBufferSize = 5555;
                                chandler.PreAuthenticate = true;
-                               chandler.CookieContainer.Add (new Uri (LocalServer), new Cookie ( "mycookie", "vv"));
+                               chandler.CookieContainer.Add (new Uri ($"http://localhost:{port}/"), new Cookie ( "mycookie", "vv"));
                                chandler.UseCookies = true;
                                chandler.UseDefaultCredentials = true;
                                chandler.Proxy = new WebProxy ("ee");
                                chandler.UseProxy = true;
 
                                var client = new HttpClient (chandler);
-                               var request = new HttpRequestMessage (HttpMethod.Get, LocalServer);
+                               var request = new HttpRequestMessage (HttpMethod.Get, $"http://localhost:{port}/");
                                request.Version = HttpVersion.Version10;
                                request.Headers.Add ("Keep-Alive", "false");
                                var response = client.SendAsync (request, HttpCompletionOption.ResponseHeadersRead).Result;
@@ -575,6 +564,7 @@ namespace MonoTests.System.Net.Http
                {
                        bool? failed = null;
                        
+                       var port = NetworkHelpers.FindFreePort ();
                        var listener = CreateListener (l => {
                                var request = l.Request;
                                try {
@@ -595,11 +585,11 @@ namespace MonoTests.System.Net.Http
                                } catch {
                                        failed = true;
                                }
-                       });
+                       }, port);
 
                        try {
                                var client = new HttpClient ();
-                               var request = new HttpRequestMessage (HttpMethod.Get, LocalServer);
+                               var request = new HttpRequestMessage (HttpMethod.Get, $"http://localhost:{port}/");
                                Assert.IsTrue (request.Headers.TryAddWithoutValidation ("aa", "vv"), "#0");
                                var response = client.SendAsync (request, HttpCompletionOption.ResponseHeadersRead).Result;
 
@@ -642,6 +632,7 @@ namespace MonoTests.System.Net.Http
                {
                        bool? failed = null;
 
+                       var port = NetworkHelpers.FindFreePort ();
                        var listener = CreateListener (l => {
                                var request = l.Request;
 
@@ -651,14 +642,14 @@ namespace MonoTests.System.Net.Http
                                } catch {
                                        failed = true;
                                }
-                       });
+                       }, port);
 
                        try {
                                var client = new HttpClient ();
 
                                client.DefaultRequestHeaders.Add("User-Agent", "MLK Android Phone 1.1.9");
 
-                               var request = new HttpRequestMessage (HttpMethod.Get, LocalServer);
+                               var request = new HttpRequestMessage (HttpMethod.Get, $"http://localhost:{port}/");
 
                                var response = client.SendAsync (request, HttpCompletionOption.ResponseHeadersRead).Result;
 
@@ -678,6 +669,7 @@ namespace MonoTests.System.Net.Http
                public void Send_Complete_CustomHeaders_Host ()
                {
                        bool? failed = null;
+                       var port = NetworkHelpers.FindFreePort ();
                        var listener = CreateListener (l => {
                                var request = l.Request;
 
@@ -687,14 +679,14 @@ namespace MonoTests.System.Net.Http
                                } catch {
                                        failed = true;
                                }
-                       });
+                       }, port);
 
                        try {
                                var client = new HttpClient ();
 
                                client.DefaultRequestHeaders.Add("Host", "customhost");
 
-                               var request = new HttpRequestMessage (HttpMethod.Get, LocalServer);
+                               var request = new HttpRequestMessage (HttpMethod.Get, $"http://localhost:{port}/");
 
                                var response = client.SendAsync (request, HttpCompletionOption.ResponseHeadersRead).Result;
 
@@ -715,22 +707,26 @@ namespace MonoTests.System.Net.Http
                {
                        bool? failed = null;
 
+                       var port = NetworkHelpers.FindFreePort ();
                        var listener = CreateListener (l => {
                                var request = l.Request;
 
                                try {
-                                       Assert.AreEqual (1, request.Headers.Count, "#1");
+                                       Assert.AreEqual (2, request.Headers.Count, "#1");
+                                       Assert.AreEqual ("keep-alive", request.Headers ["Connection"], "#2");
                                        failed = false;
-                               } catch {
+                               } catch (Exception ex){
+                                       Console.WriteLine (ex);
+                                       Console.WriteLine (String.Join ("#", l.Request.Headers.AllKeys));
                                        failed = true;
                                }
-                       });
+                       }, port);
 
                        try {
                                var client = new HttpClient ();
                                client.DefaultRequestHeaders.TransferEncodingChunked = true;
 
-                               client.GetAsync (LocalServer).Wait ();
+                               client.GetAsync ($"http://localhost:{port}/").Wait ();
 
                                Assert.AreEqual (false, failed, "#102");
                        } finally {
@@ -747,15 +743,16 @@ namespace MonoTests.System.Net.Http
                {
                        bool? failed = null;
 
+                       var port = NetworkHelpers.FindFreePort ();
                        var listener = CreateListener (l => {
                                failed = true;
-                       });
+                       }, port);
 
                        try {
                                var client = new HttpClient ();
                                client.DefaultRequestHeaders.TransferEncoding.Add (new TransferCodingHeaderValue ("chunked2"));
 
-                               var request = new HttpRequestMessage (HttpMethod.Get, LocalServer);
+                               var request = new HttpRequestMessage (HttpMethod.Get, $"http://localhost:{port}/");
 
                                try {
                                        client.SendAsync (request, HttpCompletionOption.ResponseHeadersRead).Wait ();
@@ -776,15 +773,16 @@ namespace MonoTests.System.Net.Http
 #endif
                public void Send_Complete_Content ()
                {
+                       var port = NetworkHelpers.FindFreePort ();
                        var listener = CreateListener (l => {
                                var request = l.Request;
                                l.Response.OutputStream.WriteByte (55);
                                l.Response.OutputStream.WriteByte (75);
-                       });
+                       }, port);
 
                        try {
                                var client = new HttpClient ();
-                               var request = new HttpRequestMessage (HttpMethod.Get, LocalServer);
+                               var request = new HttpRequestMessage (HttpMethod.Get, $"http://localhost:{port}/");
                                Assert.IsTrue (request.Headers.TryAddWithoutValidation ("aa", "vv"), "#0");
                                var response = client.SendAsync (request, HttpCompletionOption.ResponseHeadersRead).Result;
 
@@ -806,16 +804,17 @@ namespace MonoTests.System.Net.Http
 #endif
                public void Send_Complete_Content_MaxResponseContentBufferSize ()
                {
+                       var port = NetworkHelpers.FindFreePort ();
                        var listener = CreateListener (l => {
                                var request = l.Request;
                                var b = new byte[4000];
                                l.Response.OutputStream.Write (b, 0, b.Length);
-                       });
+                       }, port);
 
                        try {
                                var client = new HttpClient ();
                                client.MaxResponseContentBufferSize = 1000;
-                               var request = new HttpRequestMessage (HttpMethod.Get, LocalServer);
+                               var request = new HttpRequestMessage (HttpMethod.Get, $"http://localhost:{port}/");
                                var response = client.SendAsync (request, HttpCompletionOption.ResponseHeadersRead).Result;
 
                                Assert.AreEqual (4000, response.Content.ReadAsStringAsync ().Result.Length, "#100");
@@ -831,16 +830,17 @@ namespace MonoTests.System.Net.Http
 #endif
                public void Send_Complete_Content_MaxResponseContentBufferSize_Error ()
                {
+                       var port = NetworkHelpers.FindFreePort ();
                        var listener = CreateListener (l => {
                                var request = l.Request;
                                var b = new byte[4000];
                                l.Response.OutputStream.Write (b, 0, b.Length);
-                       });
+                       }, port);
 
                        try {
                                var client = new HttpClient ();
                                client.MaxResponseContentBufferSize = 1000;
-                               var request = new HttpRequestMessage (HttpMethod.Get, LocalServer);
+                               var request = new HttpRequestMessage (HttpMethod.Get, $"http://localhost:{port}/");
 
                                try {
                                        client.SendAsync (request, HttpCompletionOption.ResponseContentRead).Wait (WaitTimeout);
@@ -858,34 +858,60 @@ namespace MonoTests.System.Net.Http
 #if FEATURE_NO_BSD_SOCKETS
                [ExpectedException (typeof (PlatformNotSupportedException))]
 #endif
-               public void Send_Complete_NoContent ()
+               public void Send_Complete_NoContent_Post ()
+               {
+                       Send_Complete_NoContent (HttpMethod.Post);
+               }
+
+               [Test]
+#if FEATURE_NO_BSD_SOCKETS
+               [ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
+               public void Send_Complete_NoContent_Put ()
                {
-                       foreach (var method in new HttpMethod[] { HttpMethod.Post, HttpMethod.Put, HttpMethod.Delete }) {
-                               bool? failed = null;
-                               var listener = CreateListener (l => {
-                                       try {
-                                               var request = l.Request;
-
-                                               Assert.AreEqual (2, request.Headers.Count, "#1");
-                                               Assert.AreEqual ("0", request.Headers ["Content-Length"], "#1b");
-                                               Assert.AreEqual (method.Method, request.HttpMethod, "#2");
-                                               failed = false;
-                                       } catch {
-                                               failed = true;
-                                       }
-                               });
+                       Send_Complete_NoContent (HttpMethod.Put);
+               }
+
+               [Test]
+#if FEATURE_NO_BSD_SOCKETS
+               [ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
+               public void Send_Complete_NoContent_Delete ()
+               {
+                       Send_Complete_NoContent (HttpMethod.Delete);
+               }
 
+               void Send_Complete_NoContent (HttpMethod method)
+               {
+                       bool? failed = null;
+                       var port = NetworkHelpers.FindFreePort ();
+                       var listener = CreateListener (l => {
                                try {
-                                       var client = new HttpClient ();
-                                       var request = new HttpRequestMessage (method, LocalServer);
-                                       var response = client.SendAsync (request, HttpCompletionOption.ResponseHeadersRead).Result;
+                                       var request = l.Request;
 
-                                       Assert.AreEqual ("", response.Content.ReadAsStringAsync ().Result, "#100");
-                                       Assert.AreEqual (HttpStatusCode.OK, response.StatusCode, "#101");
-                                       Assert.AreEqual (false, failed, "#102");
-                               } finally {
-                                       listener.Close ();
+                                       Assert.AreEqual (3, request.Headers.Count, "#1");
+                                       Assert.AreEqual ("0", request.Headers ["Content-Length"], "#1b");
+                                       Assert.AreEqual ("keep-alive", request.Headers ["Connection"], "#1c");
+                                       Assert.AreEqual (method.Method, request.HttpMethod, "#2");
+                                       failed = false;
+                               } catch (Exception ex){
+                                       Console.WriteLine (ex);
+                                       Console.WriteLine (String.Join ("#", l.Request.Headers.AllKeys));
+                                       
+                                       failed = true;
                                }
+                       }, port);
+
+                       try {
+                               var client = new HttpClient ();
+                               var request = new HttpRequestMessage (method, $"http://localhost:{port}/");
+                               var response = client.SendAsync (request, HttpCompletionOption.ResponseHeadersRead).Result;
+
+                               Assert.AreEqual ("", response.Content.ReadAsStringAsync ().Result, "#100");
+                               Assert.AreEqual (HttpStatusCode.OK, response.StatusCode, "#101");
+                               Assert.AreEqual (false, failed, "#102");
+                       } finally {
+                               listener.Close ();
                        }
                }
 
@@ -895,14 +921,15 @@ namespace MonoTests.System.Net.Http
 #endif
                public void Send_Complete_Error ()
                {
+                       var port = NetworkHelpers.FindFreePort ();
                        var listener = CreateListener (l => {
                                var response = l.Response;
                                response.StatusCode = 500;
-                       });
+                       }, port);
 
                        try {
                                var client = new HttpClient ();
-                               var request = new HttpRequestMessage (HttpMethod.Get, LocalServer);
+                               var request = new HttpRequestMessage (HttpMethod.Get, $"http://localhost:{port}/");
                                var response = client.SendAsync (request, HttpCompletionOption.ResponseHeadersRead).Result;
 
                                Assert.AreEqual ("", response.Content.ReadAsStringAsync ().Result, "#100");
@@ -918,14 +945,15 @@ namespace MonoTests.System.Net.Http
 #endif
                public void Send_Content_Get ()
                {
+                       var port = NetworkHelpers.FindFreePort ();
                        var listener = CreateListener (l => {
                                var request = l.Request;
                                l.Response.OutputStream.WriteByte (72);
-                       });
+                       }, port);
 
                        try {
                                var client = new HttpClient ();
-                               var r = new HttpRequestMessage (HttpMethod.Get, LocalServer);
+                               var r = new HttpRequestMessage (HttpMethod.Get, $"http://localhost:{port}/");
                                var response = client.SendAsync (r).Result;
 
                                Assert.AreEqual ("H", response.Content.ReadAsStringAsync ().Result);
@@ -940,6 +968,7 @@ namespace MonoTests.System.Net.Http
 #endif
                public void Send_Content_BomEncoding ()
                {
+                       var port = NetworkHelpers.FindFreePort ();
                        var listener = CreateListener (l => {
                                var request = l.Request;
 
@@ -948,11 +977,11 @@ namespace MonoTests.System.Net.Http
                                str.WriteByte (0xBB);
                                str.WriteByte (0xBF);
                                str.WriteByte (71);
-                       });
+                       }, port);
 
                        try {
                                var client = new HttpClient ();
-                               var r = new HttpRequestMessage (HttpMethod.Get, LocalServer);
+                               var r = new HttpRequestMessage (HttpMethod.Get, $"http://localhost:{port}/");
                                var response = client.SendAsync (r).Result;
 
                                Assert.AreEqual ("G", response.Content.ReadAsStringAsync ().Result);
@@ -968,16 +997,17 @@ namespace MonoTests.System.Net.Http
                public void Send_Content_Put ()
                {
                        bool passed = false;
+                       var port = NetworkHelpers.FindFreePort ();
                        var listener = CreateListener (l => {
                                var request = l.Request;
                                passed = 7 == request.ContentLength64;
                                passed &= request.ContentType == "text/plain; charset=utf-8";
                                passed &= request.InputStream.ReadByte () == 'm';
-                       });
+                       }, port);
 
                        try {
                                var client = new HttpClient ();
-                               var r = new HttpRequestMessage (HttpMethod.Put, LocalServer);
+                               var r = new HttpRequestMessage (HttpMethod.Put, $"http://localhost:{port}/");
                                r.Content = new StringContent ("my text");
                                var response = client.SendAsync (r).Result;
 
@@ -996,15 +1026,16 @@ namespace MonoTests.System.Net.Http
                public void Send_Content_Put_CustomStream ()
                {
                        bool passed = false;
+                       var port = NetworkHelpers.FindFreePort ();
                        var listener = CreateListener (l => {
                                var request = l.Request;
                                passed = 44 == request.ContentLength64;
                                passed &= request.ContentType == null;
-                       });
+                       }, port);
 
                        try {
                                var client = new HttpClient ();
-                               var r = new HttpRequestMessage (HttpMethod.Put, LocalServer);
+                               var r = new HttpRequestMessage (HttpMethod.Put, $"http://localhost:{port}/");
                                r.Content = new StreamContent (new CustomStream ());
                                var response = client.SendAsync (r).Result;
 
@@ -1100,6 +1131,7 @@ namespace MonoTests.System.Net.Http
                public void Post_TransferEncodingChunked ()
                {
                        bool? failed = null;
+                       var port = NetworkHelpers.FindFreePort ();
                        var listener = CreateListener (l => {
                                try {
                                        var request = l.Request;
@@ -1109,7 +1141,7 @@ namespace MonoTests.System.Net.Http
                                        Assert.IsNull (request.ContentType, "#3");
                                        Assert.AreEqual (0, request.Cookies.Count, "#4");
                                        Assert.IsTrue (request.HasEntityBody, "#5");
-                                       Assert.AreEqual (TestHost, request.Headers ["Host"], "#6b");
+                                       Assert.AreEqual ($"localhost:{port}", request.Headers ["Host"], "#6b");
                                        Assert.AreEqual ("POST", request.HttpMethod, "#7");
                                        Assert.IsFalse (request.IsAuthenticated, "#8");
                                        Assert.IsTrue (request.IsLocal, "#9");
@@ -1128,7 +1160,7 @@ namespace MonoTests.System.Net.Http
                                        failed = true;
                                        Console.WriteLine (e);
                                }
-                       });
+                       }, port);
 
                        try {
                                var client = new HttpClient ();
@@ -1137,7 +1169,7 @@ namespace MonoTests.System.Net.Http
 
                                var imageContent = new StreamContent (new MemoryStream ());
 
-                               var response = client.PostAsync (LocalServer, imageContent).Result;
+                               var response = client.PostAsync ($"http://localhost:{port}/", imageContent).Result;
 
                                Assert.AreEqual(HttpStatusCode.OK, response.StatusCode, "#101");
                                Assert.AreEqual(false, failed, "#102");
@@ -1153,6 +1185,7 @@ namespace MonoTests.System.Net.Http
                public void Post_StreamCaching ()
                {
                        bool? failed = null;
+                       var port = NetworkHelpers.FindFreePort ();
                        var listener = CreateListener (l => {
                                try {
                                        var request = l.Request;
@@ -1162,7 +1195,7 @@ namespace MonoTests.System.Net.Http
                                        Assert.IsNull (request.ContentType, "#3");
                                        Assert.AreEqual (0, request.Cookies.Count, "#4");
                                        Assert.IsFalse (request.HasEntityBody, "#5");
-                                       Assert.AreEqual (TestHost, request.Headers ["Host"], "#6b");
+                                       Assert.AreEqual ($"localhost:{port}", request.Headers ["Host"], "#6b");
                                        Assert.AreEqual ("POST", request.HttpMethod, "#7");
                                        Assert.IsFalse (request.IsAuthenticated, "#8");
                                        Assert.IsTrue (request.IsLocal, "#9");
@@ -1181,14 +1214,14 @@ namespace MonoTests.System.Net.Http
                                        failed = true;
                                        Console.WriteLine (e);
                                }
-                       });
+                       }, port);
 
                        try {
                                var client = new HttpClient ();
 
                                var imageContent = new StreamContent (new MemoryStream ());
 
-                               var response = client.PostAsync (LocalServer, imageContent).Result;
+                               var response = client.PostAsync ($"http://localhost:{port}/", imageContent).Result;
 
                                Assert.AreEqual(HttpStatusCode.OK, response.StatusCode, "#101");
                                Assert.AreEqual(false, failed, "#102");
@@ -1214,13 +1247,14 @@ namespace MonoTests.System.Net.Http
                                response.OutputStream.WriteByte (0x6f);
                        };
 
-                       var listener = CreateListener (context); // creates a default request handler
+                       var port = NetworkHelpers.FindFreePort ();
+                       var listener = CreateListener (context, port); // creates a default request handler
                        AddListenerContext (listener, context);  // add another request handler for the second request
 
                        try {
                                var client = new HttpClient ();
-                               var t1 = client.GetStringAsync (LocalServer);
-                               var t2 = client.GetStringAsync (LocalServer);
+                               var t1 = client.GetStringAsync ($"http://localhost:{port}/");
+                               var t2 = client.GetStringAsync ($"http://localhost:{port}/");
                                Assert.IsTrue (Task.WaitAll (new [] { t1, t2 }, WaitTimeout));
                                Assert.AreEqual ("hello", t1.Result, "#1");
                                Assert.AreEqual ("hello", t2.Result, "#2");
@@ -1236,16 +1270,17 @@ namespace MonoTests.System.Net.Http
 #endif
                public void GetByteArray_ServerError ()
                {
+                       var port = NetworkHelpers.FindFreePort ();
                        var listener = CreateListener (l => {
                                var response = l.Response;
                                response.StatusCode = 500;
                                l.Response.OutputStream.WriteByte (72);
-                       });
+                       }, port);
 
                        try {
                                var client = new HttpClient ();
                                try {
-                                       client.GetByteArrayAsync (LocalServer).Wait (WaitTimeout);
+                                       client.GetByteArrayAsync ($"http://localhost:{port}/").Wait (WaitTimeout);
                                        Assert.Fail ("#1");
                                } catch (AggregateException e) {
                                        Assert.IsTrue (e.InnerException is HttpRequestException , "#2");
@@ -1261,13 +1296,14 @@ namespace MonoTests.System.Net.Http
 #endif
                public void DisallowAutoRedirect ()
                {
+                       var port = NetworkHelpers.FindFreePort ();
                        var listener = CreateListener (l => {
                                var request = l.Request;
                                var response = l.Response;
                                
                                response.StatusCode = (int)HttpStatusCode.Moved;
                                response.RedirectLocation = "http://xamarin.com/";
-                       });
+                       }, port);
 
                        try {
                                var chandler = new HttpClientHandler ();
@@ -1275,7 +1311,7 @@ namespace MonoTests.System.Net.Http
                                var client = new HttpClient (chandler);
 
                                try {
-                                       client.GetStringAsync (LocalServer).Wait (WaitTimeout);
+                                       client.GetStringAsync ($"http://localhost:{port}/").Wait (WaitTimeout);
                                        Assert.Fail ("#1");
                                } catch (AggregateException e) {
                                        Assert.IsTrue (e.InnerException is HttpRequestException, "#2");
@@ -1292,13 +1328,16 @@ namespace MonoTests.System.Net.Http
 #endif
                public void RequestUriAfterRedirect ()
                {
+                       var port = NetworkHelpers.FindFreePort ();
+                       var redirectPort = NetworkHelpers.FindFreePort ();
+
                        var listener = CreateListener (l => {
                                var request = l.Request;
                                var response = l.Response;
 
                                response.StatusCode = (int)HttpStatusCode.Moved;
-                               response.RedirectLocation = "http://localhost:8811/";
-                       });
+                               response.RedirectLocation = $"http://localhost:{redirectPort}/";
+                       }, port);
 
                        var listener2 = CreateListener (l => {
                                var response = l.Response;
@@ -1309,17 +1348,17 @@ namespace MonoTests.System.Net.Http
                                response.OutputStream.WriteByte (0x6c);
                                response.OutputStream.WriteByte (0x6c);
                                response.OutputStream.WriteByte (0x6f);
-                       }, 8811);
+                       }, redirectPort);
 
                        try {
                                var chandler = new HttpClientHandler ();
                                chandler.AllowAutoRedirect = true;
                                var client = new HttpClient (chandler);
 
-                               var r = client.GetAsync (LocalServer);
+                               var r = client.GetAsync ($"http://localhost:{port}/");
                                Assert.IsTrue (r.Wait (WaitTimeout), "#1");
                                var resp = r.Result;
-                               Assert.AreEqual ("http://localhost:8811/", resp.RequestMessage.RequestUri.AbsoluteUri, "#2");
+                               Assert.AreEqual ($"http://localhost:{redirectPort}/", resp.RequestMessage.RequestUri.AbsoluteUri, "#2");
                                Assert.AreEqual ("hello", resp.Content.ReadAsStringAsync ().Result, "#3");
                        } finally {
                                listener.Abort ();
@@ -1342,14 +1381,15 @@ namespace MonoTests.System.Net.Http
                        chandler.AllowAutoRedirect = true;
                        var client = new HttpClient (chandler, true);
 
+                       var port = NetworkHelpers.FindFreePort ();
                        var listener = CreateListener (l => {
                                var response = l.Response;
                                response.StatusCode = 200;
                                response.OutputStream.WriteByte (55);
-                       });
+                       }, port);
 
                        try {
-                               client.GetStringAsync (LocalServer).Wait (WaitTimeout);
+                               client.GetStringAsync ($"http://localhost:{port}/").Wait (WaitTimeout);
                                try {
                                        chandler.AllowAutoRedirect = false;
                                        Assert.Fail ("#1");
@@ -1388,11 +1428,6 @@ namespace MonoTests.System.Net.Http
                        ch.AllowAutoRedirect = false;
                }
 
-               HttpListener CreateListener (Action<HttpListenerContext> contextAssert)
-               {
-                       return CreateListener (contextAssert, port);
-               }
-
                HttpListener CreateListener (Action<HttpListenerContext> contextAssert, int port)
                {
                        var l = new HttpListener ();
index 8aae7d9e602904bd3c5b2c4e181e210051db3ffb..4d942c11997937f3fd968b944ce6a2f830b4adca 100644 (file)
@@ -1,4 +1,5 @@
 ../../test-helpers/NunitHelpers.cs
+../../test-helpers/NetworkHelpers.cs
 System.Runtime.Remoting.Channels.Tcp/TcpChannelTest.cs
 ServerObject.cs
 ContextsTest.cs
index b70409344f9eb48f580153c3399e6796b87dd082..5ea68f21d5a931d59a6cd9c381e9a8eb9e20e9d0 100644 (file)
@@ -14,6 +14,8 @@ using System.Runtime.Remoting.Channels.Tcp;
 using System.Runtime.Remoting.Channels.Http;
 using NUnit.Framework;
 
+using MonoTests.Helpers;
+
 namespace MonoTests.Remoting
 {
        [TestFixture]
@@ -40,12 +42,14 @@ namespace MonoTests.Remoting
                                AppDomain domain = BaseCallTest.CreateDomain ("testdomain_activation");
                                server = (ActivationServer) domain.CreateInstanceAndUnwrap(GetType().Assembly.FullName,"MonoTests.Remoting.ActivationServer");
                                
-                               RemotingConfiguration.RegisterActivatedClientType (typeof(CaObject1), "tcp://localhost:9433");
-                               RemotingConfiguration.RegisterActivatedClientType (typeof(CaObject2), "http://localhost:9434");
-                               RemotingConfiguration.RegisterWellKnownClientType (typeof(WkObjectSinglecall1), "tcp://localhost:9433/wkoSingleCall1");
-                               RemotingConfiguration.RegisterWellKnownClientType (typeof(WkObjectSingleton1), "tcp://localhost:9433/wkoSingleton1");
-                               RemotingConfiguration.RegisterWellKnownClientType (typeof(WkObjectSinglecall2), "http://localhost:9434/wkoSingleCall2");
-                               RemotingConfiguration.RegisterWellKnownClientType (typeof(WkObjectSingleton2), "http://localhost:9434/wkoSingleton2");
+                               var tcpUrlPrefix = $"tcp://localhost:{server.TcpPort}";
+                               var httpUrlPrefix = $"http://localhost:{server.HttpPort}";
+                               RemotingConfiguration.RegisterActivatedClientType (typeof(CaObject1), tcpUrlPrefix);
+                               RemotingConfiguration.RegisterActivatedClientType (typeof(CaObject2), httpUrlPrefix);
+                               RemotingConfiguration.RegisterWellKnownClientType (typeof(WkObjectSinglecall1), tcpUrlPrefix + "/wkoSingleCall1");
+                               RemotingConfiguration.RegisterWellKnownClientType (typeof(WkObjectSingleton1), tcpUrlPrefix + "/wkoSingleton1");
+                               RemotingConfiguration.RegisterWellKnownClientType (typeof(WkObjectSinglecall2), httpUrlPrefix + "/wkoSingleCall2");
+                               RemotingConfiguration.RegisterWellKnownClientType (typeof(WkObjectSingleton2), httpUrlPrefix + "/wkoSingleton2");
                        }
                        catch (Exception ex)
                        {
@@ -163,8 +167,10 @@ namespace MonoTests.Remoting
                
                public ActivationServer ()
                {
-                       tcp =  new TcpChannel (9433);
-                       http =  new HttpChannel (9434);
+                       TcpPort = NetworkHelpers.FindFreePort ();
+                       HttpPort = NetworkHelpers.FindFreePort ();
+                       tcp =  new TcpChannel (TcpPort);
+                       http =  new HttpChannel (HttpPort);
                        
                        ChannelServices.RegisterChannel (tcp);
                        ChannelServices.RegisterChannel (http);
@@ -182,6 +188,9 @@ namespace MonoTests.Remoting
                        ChannelServices.UnregisterChannel (tcp);
                        ChannelServices.UnregisterChannel (http);
                }
+
+               public int TcpPort { get; private set; }
+               public int HttpPort { get; private set; }
        }
        
        public class BaseObject: MarshalByRefObject
index 519686785c9002b058abc5909165ca4a223aa928..a8a9a7bfead8a0783b18a9a827bcfd2743d36827 100644 (file)
@@ -16,6 +16,8 @@ using System.Runtime.Remoting.Channels.Ipc;
 using System.Threading;
 using NUnit.Framework;
 
+using MonoTests.Helpers;
+
 namespace MonoTests.Remoting
 {
        public interface INested
@@ -166,15 +168,16 @@ namespace MonoTests.Remoting
                [Test]
                public void TestTcpChannel ()
                {
+                       var port = NetworkHelpers.FindFreePort ();
                        IDictionary props = new Hashtable ();
                        props ["name"] = Guid.NewGuid ().ToString("N");
-                       props ["port"] = 18191;
+                       props ["port"] = port;
                        TcpChannel chan = new TcpChannel (props, null, null);
                        ChannelServices.RegisterChannel (chan);
                        
                        try {
                                Register <Server<object>> ("gentcptest.rem");
-                               RunTests (Connect <Server<object>> ("tcp://localhost:18191/gentcptest.rem"));
+                               RunTests (Connect <Server<object>> ($"tcp://localhost:{port}/gentcptest.rem"));
                        } finally {
                                ChannelServices.UnregisterChannel (chan);
                        }
index c809f96c9401173bd5de5f7a6817026bd9291f24..553c58a580bfbd286c6e19f7d70d3e494236316c 100644 (file)
@@ -7,6 +7,8 @@ using System.Runtime.Remoting.Channels;
 using System.Runtime.Remoting.Channels.Http;
 using NUnit.Framework;
 
+using MonoTests.Helpers;
+
 namespace MonoTests.Remoting.Http
 {
        //Test for Bug 324362 - SoapFormatter cannot deserialize the same MBR twice
@@ -67,13 +69,14 @@ namespace MonoTests.Remoting.Http
                [Test]
                public void Main ()
                {
-                       channel = new HttpChannel (3344);
+                       var port = NetworkHelpers.FindFreePort ();
+                       channel = new HttpChannel (port);
                        ChannelServices.RegisterChannel (channel);
                        RemotingConfiguration.RegisterWellKnownServiceType
                                (typeof (Bug321420),"Server.soap", WellKnownObjectMode.Singleton);
                        
                        Bug321420 s = (Bug321420) Activator.GetObject (typeof
-                               (Bug321420), "http://localhost:3344/Server.soap");
+                               (Bug321420), $"http://localhost:{port}/Server.soap");
                        
                        // this works: s.Method ("a", "b");
                        s.Method ("a", "a");
@@ -98,7 +101,7 @@ namespace MonoTests.Remoting.Http
                public void Main ()
                {
                        Foo foo = (Foo) Activator.GetObject (typeof (Foo),
-                               "http://localhost:4321/Test");
+                               $"http://localhost:{server.HttpPort}/Test");
 
                        Bar bar = foo.Login ();
                        if (bar != null)
@@ -142,7 +145,8 @@ namespace MonoTests.Remoting.Http
                        
                        public void Start ()
                        {
-                               c = new HttpChannel (4321);
+                               HttpPort = NetworkHelpers.FindFreePort ();
+                               c = new HttpChannel (HttpPort);
                                ChannelServices.RegisterChannel (c);
                                
                                Type t = typeof(Foo);
@@ -155,6 +159,8 @@ namespace MonoTests.Remoting.Http
                                c.StopListening (null);
                                ChannelServices.UnregisterChannel (c);
                        }
+
+                       public int HttpPort { get; private set; }
                }
        }
        
@@ -172,7 +178,7 @@ namespace MonoTests.Remoting.Http
                        ChannelServices.RegisterChannel (channel);
                        MarshalByRefObject obj = (MarshalByRefObject) RemotingServices.Connect (
                                typeof (IFactorial),
-                               "http://localhost:60000/MyEndPoint");
+                               $"http://localhost:{server.HttpPort}/MyEndPoint");
                        IFactorial cal = (IFactorial) obj;
                        Assert.AreEqual (cal.CalculateFactorial (4), 24);
                }
@@ -209,7 +215,8 @@ namespace MonoTests.Remoting.Http
                        
                        public void Start ()
                        {
-                               c = new HttpChannel (60000);
+                               HttpPort = NetworkHelpers.FindFreePort ();
+                               c = new HttpChannel (HttpPort);
                                ChannelServices.RegisterChannel (c);
                                
                                Type t = typeof(Calculator);
@@ -222,6 +229,8 @@ namespace MonoTests.Remoting.Http
                                c.StopListening (null);
                                ChannelServices.UnregisterChannel (c);
                        }
+
+                       public int HttpPort { get; private set; }
                }
                
                public class Calculator : MarshalByRefObject, IFactorial
index 02c6a532c00ce24d94a757b312892a2df1920c86..0dd58aa38cbbaef1f10eb1ec19e6134aa6074baf 100644 (file)
@@ -18,6 +18,8 @@ using System.Runtime.Remoting.Proxies;
 using System.Runtime.Remoting.Channels;\r
 using System.Runtime.Remoting.Channels.Tcp;\r
 \r
+using MonoTests.Helpers;\r
+\r
 namespace MonoTests.System.Runtime.Remoting.RemotingServicesInternal\r
 {\r
        // We need our own proxy to intercept messages to remote object\r
@@ -286,17 +288,18 @@ namespace MonoTests.Remoting
                [Test]\r
                public void Connect ()\r
                {\r
+                       var port = NetworkHelpers.FindFreePort ();\r
                        MarshalObject objMarshal = NewMarshalObject ();\r
 \r
                        IDictionary props = new Hashtable ();\r
                        props ["name"] = objMarshal.Uri;\r
-                       props ["port"] = 1236;\r
+                       props ["port"] = port;\r
                        TcpChannel chn = new TcpChannel (props, null, null);\r
                        ChannelServices.RegisterChannel (chn);\r
 \r
                        try {\r
                                RemotingServices.Marshal (objMarshal, objMarshal.Uri);\r
-                               MarshalObject objRem = (MarshalObject) RemotingServices.Connect (typeof (MarshalObject), "tcp://localhost:1236/" + objMarshal.Uri);\r
+                               MarshalObject objRem = (MarshalObject) RemotingServices.Connect (typeof (MarshalObject), $"tcp://localhost:{port}/" + objMarshal.Uri);\r
                                Assert.IsTrue (RemotingServices.IsTransparentProxy (objRem), "#A08");\r
                        } finally {\r
                                ChannelServices.UnregisterChannel (chn);\r
@@ -308,17 +311,18 @@ namespace MonoTests.Remoting
                [Test]\r
                public void MarshalThrowException ()\r
                {\r
+                       var port = NetworkHelpers.FindFreePort ();\r
                        MarshalObject objMarshal = NewMarshalObject ();\r
 \r
                        IDictionary props = new Hashtable ();\r
                        props ["name"] = objMarshal.Uri;\r
-                       props ["port"] = 1237;\r
+                       props ["port"] = port;\r
                        TcpChannel chn = new TcpChannel (props, null, null);\r
                        ChannelServices.RegisterChannel (chn);\r
 \r
                        try {\r
                                RemotingServices.Marshal (objMarshal, objMarshal.Uri);\r
-                               MarshalObject objRem = (MarshalObject) RemotingServices.Connect (typeof (MarshalObject), "tcp://localhost:1237/" + objMarshal.Uri);\r
+                               MarshalObject objRem = (MarshalObject) RemotingServices.Connect (typeof (MarshalObject), $"tcp://localhost:{port}/" + objMarshal.Uri);\r
                                // This line should throw a RemotingException\r
                                // It is forbidden to export an object which is not\r
                                // a real object\r
@@ -341,14 +345,15 @@ namespace MonoTests.Remoting
                [Test]\r
                public void ExecuteMessage ()\r
                {\r
-                       TcpChannel chn = new TcpChannel (1235);\r
+                       var port = NetworkHelpers.FindFreePort ();\r
+                       TcpChannel chn = new TcpChannel (port);\r
                        ChannelServices.RegisterChannel (chn);\r
                        try {\r
                                MarshalObject objMarshal = NewMarshalObject ();\r
                                RemotingConfiguration.RegisterWellKnownServiceType (typeof (MarshalObject), objMarshal.Uri, WellKnownObjectMode.SingleCall);\r
 \r
                                // use a proxy to catch the Message\r
-                               MyProxy proxy = new MyProxy (typeof (MarshalObject), (MarshalObject) Activator.GetObject (typeof (MarshalObject), "tcp://localhost:1235/" + objMarshal.Uri));\r
+                               MyProxy proxy = new MyProxy (typeof (MarshalObject), (MarshalObject) Activator.GetObject (typeof (MarshalObject), $"tcp://localhost:{port}/" + objMarshal.Uri));\r
 \r
                                MarshalObject objRem = (MarshalObject) proxy.GetTransparentProxy ();\r
 \r
@@ -373,12 +378,13 @@ namespace MonoTests.Remoting
                [Test]\r
                public void IsOneWay ()\r
                {\r
-                       TcpChannel chn = new TcpChannel (1238);\r
+                       var port = NetworkHelpers.FindFreePort ();\r
+                       TcpChannel chn = new TcpChannel (port);\r
                        ChannelServices.RegisterChannel (chn);\r
                        try {\r
                                RemotingConfiguration.RegisterWellKnownServiceType (typeof (MarshalObject), "MarshalObject.rem", WellKnownObjectMode.Singleton);\r
 \r
-                               MarshalObject objRem = (MarshalObject) Activator.GetObject (typeof (MarshalObject), "tcp://localhost:1238/MarshalObject.rem");\r
+                               MarshalObject objRem = (MarshalObject) Activator.GetObject (typeof (MarshalObject), $"tcp://localhost:{port}/MarshalObject.rem");\r
 \r
                                Assert.IsTrue (RemotingServices.IsTransparentProxy (objRem), "#A10.1");\r
 \r
@@ -396,13 +402,14 @@ namespace MonoTests.Remoting
                [Test]\r
                public void GetObjRefForProxy ()\r
                {\r
-                       TcpChannel chn = new TcpChannel (1239);\r
+                       var port = NetworkHelpers.FindFreePort ();\r
+                       TcpChannel chn = new TcpChannel (port);\r
                        ChannelServices.RegisterChannel (chn);\r
                        try {\r
                                // Register le factory as a SAO\r
                                RemotingConfiguration.RegisterWellKnownServiceType (typeof (MarshalObjectFactory), "MonoTests.System.Runtime.Remoting.RemotingServicesTest.Factory.soap", WellKnownObjectMode.Singleton);\r
 \r
-                               MarshalObjectFactory objFactory = (MarshalObjectFactory) Activator.GetObject (typeof (MarshalObjectFactory), "tcp://localhost:1239/MonoTests.System.Runtime.Remoting.RemotingServicesTest.Factory.soap");\r
+                               MarshalObjectFactory objFactory = (MarshalObjectFactory) Activator.GetObject (typeof (MarshalObjectFactory), $"tcp://localhost:{port}/MonoTests.System.Runtime.Remoting.RemotingServicesTest.Factory.soap");\r
 \r
                                // Get a new "CAO"\r
                                MarshalObject objRem = objFactory.GetNewMarshalObject ();\r
@@ -419,12 +426,13 @@ namespace MonoTests.Remoting
                [Test]\r
                public void GetRealProxy ()\r
                {\r
-                       TcpChannel chn = new TcpChannel (1241);\r
+                       var port = NetworkHelpers.FindFreePort ();\r
+                       TcpChannel chn = new TcpChannel (port);\r
                        ChannelServices.RegisterChannel (chn);\r
                        try {\r
                                RemotingConfiguration.RegisterWellKnownServiceType (typeof (MarshalObject), "MonoTests.System.Runtime.Remoting.RemotingServicesTest.MarshalObject.soap", WellKnownObjectMode.Singleton);\r
 \r
-                               MyProxy proxy = new MyProxy (typeof (MarshalObject), (MarshalByRefObject) Activator.GetObject (typeof (MarshalObject), "tcp://localhost:1241/MonoTests.System.Runtime.Remoting.RemotingServicesTest.MarshalObject.soap"));\r
+                               MyProxy proxy = new MyProxy (typeof (MarshalObject), (MarshalByRefObject) Activator.GetObject (typeof (MarshalObject), $"tcp://localhost:{port}/MonoTests.System.Runtime.Remoting.RemotingServicesTest.MarshalObject.soap"));\r
                                MarshalObject objRem = (MarshalObject) proxy.GetTransparentProxy ();\r
 \r
                                RealProxy rp = RemotingServices.GetRealProxy (objRem);\r
@@ -440,14 +448,15 @@ namespace MonoTests.Remoting
                [Test]\r
                public void SetObjectUriForMarshal ()\r
                {\r
-                       TcpChannel chn = new TcpChannel (1242);\r
+                       var port = NetworkHelpers.FindFreePort ();\r
+                       TcpChannel chn = new TcpChannel (port);\r
                        ChannelServices.RegisterChannel (chn);\r
                        try {\r
                                MarshalObject objRem = NewMarshalObject ();\r
                                RemotingServices.SetObjectUriForMarshal (objRem, objRem.Uri);\r
                                RemotingServices.Marshal (objRem);\r
 \r
-                               objRem = (MarshalObject) Activator.GetObject (typeof (MarshalObject), "tcp://localhost:1242/" + objRem.Uri);\r
+                               objRem = (MarshalObject) Activator.GetObject (typeof (MarshalObject), $"tcp://localhost:{port}/" + objRem.Uri);\r
                                Assert.IsNotNull (objRem, "#A14");\r
                        } finally {\r
                                ChannelServices.UnregisterChannel (chn);\r
@@ -459,7 +468,8 @@ namespace MonoTests.Remoting
                [Test]\r
                public void GetServeurTypeForUri ()\r
                {\r
-                       TcpChannel chn = new TcpChannel (1243);\r
+                       var port = NetworkHelpers.FindFreePort ();\r
+                       TcpChannel chn = new TcpChannel (port);\r
                        Type type = typeof (MarshalObject);\r
                        ChannelServices.RegisterChannel (chn);\r
                        try {\r
@@ -480,12 +490,13 @@ namespace MonoTests.Remoting
                [Category ("NotWorking")]\r
                public void IsObjectOutOf ()\r
                {\r
-                       TcpChannel chn = new TcpChannel (1245);\r
+                       var port = NetworkHelpers.FindFreePort ();\r
+                       TcpChannel chn = new TcpChannel (port);\r
                        ChannelServices.RegisterChannel (chn);\r
                        try {\r
                                RemotingConfiguration.RegisterWellKnownServiceType (typeof (MarshalObject), "MarshalObject2.rem", WellKnownObjectMode.Singleton);\r
 \r
-                               MarshalObject objRem = (MarshalObject) Activator.GetObject (typeof (MarshalObject), "tcp://localhost:1245/MarshalObject2.rem");\r
+                               MarshalObject objRem = (MarshalObject) Activator.GetObject (typeof (MarshalObject), $"tcp://localhost:{port}/MarshalObject2.rem");\r
 \r
                                Assert.IsTrue (RemotingServices.IsObjectOutOfAppDomain (objRem), "#A16");\r
                                Assert.IsTrue (RemotingServices.IsObjectOutOfContext (objRem), "#A17");\r
@@ -501,14 +512,15 @@ namespace MonoTests.Remoting
                [Test]\r
                public void ApplicationNameTest ()\r
                {\r
+                       var port = NetworkHelpers.FindFreePort ();\r
                        RemotingConfiguration.ApplicationName = "app";\r
-                       TcpChannel chn = new TcpChannel (1246);\r
+                       TcpChannel chn = new TcpChannel (port);\r
                        ChannelServices.RegisterChannel (chn);\r
                        try {\r
                                RemotingConfiguration.RegisterWellKnownServiceType (typeof (MarshalObject), "obj3.rem", WellKnownObjectMode.Singleton);\r
 \r
-                               MarshalObject objRem = (MarshalObject) Activator.GetObject (typeof (MarshalObject), "tcp://localhost:1246/app/obj3.rem");\r
-                               MarshalObject objRem2 = (MarshalObject) Activator.GetObject (typeof (MarshalObject), "tcp://localhost:1246/obj3.rem");\r
+                               MarshalObject objRem = (MarshalObject) Activator.GetObject (typeof (MarshalObject), $"tcp://localhost:{port}/app/obj3.rem");\r
+                               MarshalObject objRem2 = (MarshalObject) Activator.GetObject (typeof (MarshalObject), $"tcp://localhost:{port}/obj3.rem");\r
 \r
                                Assert.IsTrue (RemotingServices.IsTransparentProxy (objRem), "#AN1");\r
                                Assert.IsTrue (RemotingServices.IsTransparentProxy (objRem2), "#AN2");\r
@@ -528,13 +540,14 @@ namespace MonoTests.Remoting
                [Test]\r
                public void GetObjectWithChannelDataTest ()\r
                {\r
-                       TcpChannel chn = new TcpChannel (1247);\r
+                       var port = NetworkHelpers.FindFreePort ();\r
+                       TcpChannel chn = new TcpChannel (port);\r
                        ChannelServices.RegisterChannel (chn);\r
                        try {\r
                                RemotingConfiguration.RegisterWellKnownServiceType (typeof (MarshalObject), "getobjectwithchanneldata.rem", WellKnownObjectMode.Singleton);\r
 \r
                                string channelData = "test";\r
-                               Assert.IsNotNull (Activator.GetObject (typeof (MarshalObject), "tcp://localhost:1247/getobjectwithchanneldata.rem", channelData), "#01");\r
+                               Assert.IsNotNull (Activator.GetObject (typeof (MarshalObject), $"tcp://localhost:{port}/getobjectwithchanneldata.rem", channelData), "#01");\r
                        } finally {\r
                                ChannelServices.UnregisterChannel (chn);\r
                        }\r
@@ -544,28 +557,29 @@ namespace MonoTests.Remoting
                [Ignore ("We cannot test RemotingConfiguration.Configure() because it keeps channels registered. If we really need to test it, do it as a standalone case")]\r
                public void ConnectProxyCast ()\r
                {\r
+                       var port = NetworkHelpers.FindFreePort ();\r
                        object o;\r
                        RemotingConfiguration.Configure (null);\r
 \r
-                       o = RemotingServices.Connect (typeof (MarshalByRefObject), "tcp://localhost:3434/ff1.rem");\r
+                       o = RemotingServices.Connect (typeof (MarshalByRefObject), $"tcp://localhost:{port}/ff1.rem");\r
                        Assert.IsInstanceOfType (typeof (DD), o, "#m1");\r
                        Assert.IsInstanceOfType (typeof (A), o, "#m2");\r
                        Assert.IsInstanceOfType (typeof (B), o, "#m3");\r
                        AssertHelper.IsNotInstanceOfType (typeof (CC), !(o is CC), "#m4");\r
 \r
-                       o = RemotingServices.Connect (typeof (A), "tcp://localhost:3434/ff3.rem");\r
+                       o = RemotingServices.Connect (typeof (A), $"tcp://localhost:{port}/ff3.rem");\r
                        Assert.IsInstanceOfType (typeof (DD), o, "#a1");\r
                        Assert.IsInstanceOfType (typeof (A), o, "#a2");\r
                        Assert.IsInstanceOfType (typeof (B), o, "#a3");\r
                        AssertHelper.IsNotInstanceOfType (typeof (CC), o, "#a4");\r
 \r
-                       o = RemotingServices.Connect (typeof (DD), "tcp://localhost:3434/ff4.rem");\r
+                       o = RemotingServices.Connect (typeof (DD), $"tcp://localhost:{port}/ff4.rem");\r
                        Assert.IsInstanceOfType (typeof (DD), o, "#d1");\r
                        Assert.IsInstanceOfType (typeof (A), o, "#d2");\r
                        Assert.IsInstanceOfType (typeof (B), o, "#d3");\r
                        AssertHelper.IsNotInstanceOfType (typeof (CC), o, "#d4");\r
 \r
-                       o = RemotingServices.Connect (typeof (CC), "tcp://localhost:3434/ff5.rem");\r
+                       o = RemotingServices.Connect (typeof (CC), $"tcp://localhost:{port}/ff5.rem");\r
                        AssertHelper.IsNotInstanceOfType (typeof (DD), o, "#c1");\r
                        Assert.IsInstanceOfType (typeof (A), o, "#c2");\r
                        Assert.IsInstanceOfType (typeof (B), o, "#c3");\r
index 9074921c78d8db75d25d7451ece48a1269789ce7..c49df5bd0dcaeae2ef63c099fcb389b4269e57be 100644 (file)
@@ -35,6 +35,8 @@ using System.Runtime.Remoting.Channels.Tcp;
 
 using NUnit.Framework;
 
+using MonoTests.Helpers;
+
 namespace MonoTests.Remoting
 {
        [TestFixture]
@@ -50,9 +52,10 @@ namespace MonoTests.Remoting
 
                        MarshalObject marshal = new MarshalObject ();
 
+                       var port = NetworkHelpers.FindFreePort ();
                        IDictionary props = new Hashtable ();
                        props ["name"] = "marshal channel";
-                       props ["port"] = 1236;
+                       props ["port"] = port;
                        props ["bindTo"] = IPAddress.Loopback.ToString ();
                        chn = new TcpChannel (props, null, null);
 
@@ -62,11 +65,11 @@ namespace MonoTests.Remoting
                        urls = chn.GetUrlsForUri (SERVICE_URI);
                        Assert.IsNotNull (urls, "#A2");
                        Assert.AreEqual (1, urls.Length, "#A3");
-                       Assert.AreEqual ("tcp://" + IPAddress.Loopback.ToString () + ":1236/" + SERVICE_URI, urls [0], "#A6");
+                       Assert.AreEqual ($"tcp://{IPAddress.Loopback.ToString ()}:{port}/{SERVICE_URI}", urls [0], "#A6");
                        ds = chn.ChannelData as ChannelDataStore;
                        Assert.IsNotNull (ds, "#A4");
                        Assert.AreEqual (1, ds.ChannelUris.Length, "#A5");
-                       Assert.AreEqual ("tcp://" + IPAddress.Loopback.ToString () + ":1236", ds.ChannelUris [0], "#A6");
+                       Assert.AreEqual ($"tcp://{IPAddress.Loopback.ToString ()}:{port}", ds.ChannelUris [0], "#A6");
 
                        ChannelServices.UnregisterChannel (chn);
                        
index e2af0ca1f761eb9c27ac566b3c08da078fafced2..8f7365939eb24ea37011586c01c62268b64325d3 100644 (file)
@@ -7,6 +7,8 @@ using System.ServiceModel.Channels;
 using System.ServiceModel.Web;
 using NUnit.Framework;
 
+using MonoTests.Helpers;
+
 namespace MonoTests.System.ServiceModel.Activation
 {
        class MyHostFactory : WebScriptServiceHostFactory
@@ -23,8 +25,9 @@ namespace MonoTests.System.ServiceModel.Activation
                [Test]
                public void CreateServiceHost ()
                {
+                       var port = NetworkHelpers.FindFreePort ();
                        var f = new MyHostFactory ();
-                       var host = f.DoCreateServiceHost (typeof (TestService), new Uri [] {new Uri ("http://localhost:37564")});
+                       var host = f.DoCreateServiceHost (typeof (TestService), new Uri [] {new Uri ($"http://localhost:{port}")});
                        Assert.IsFalse (host is WebServiceHost, "#1");
                        host.Open ();
                        host.Close ();
@@ -34,8 +37,9 @@ namespace MonoTests.System.ServiceModel.Activation
                [ExpectedException (typeof (NotSupportedException))]
                public void ResponseWrappedIsInvalid ()
                {
+                       var port = NetworkHelpers.FindFreePort ();
                        var f = new MyHostFactory ();
-                       var host = f.DoCreateServiceHost (typeof (TestService2), new Uri [] {new Uri ("http://localhost:37564")});
+                       var host = f.DoCreateServiceHost (typeof (TestService2), new Uri [] {new Uri ($"http://localhost:{port}")});
                        host.Open (); // should raise an error here.
                }
 
@@ -43,8 +47,9 @@ namespace MonoTests.System.ServiceModel.Activation
                [ExpectedException (typeof (InvalidOperationException))]
                public void MultipleContract ()
                {
+                       var port = NetworkHelpers.FindFreePort ();
                        var f = new MyHostFactory ();
-                       var host = f.DoCreateServiceHost (typeof (TestServiceMultiple), new Uri [] {new Uri ("http://localhost:37564")});
+                       var host = f.DoCreateServiceHost (typeof (TestServiceMultiple), new Uri [] {new Uri ($"http://localhost:{port}")});
                        host.Open ();
                }
 
index 8807873a86dd9053847ae65a81cdace19f47b589..6a225a25f52682fee5feb016c243a28910d82777 100644 (file)
@@ -45,11 +45,16 @@ namespace System.ServiceModel.PeerResolvers
        public class CustomPeerResolverService : IPeerResolverContract
        {
                static ServiceHost localhost;
+               static int port;
 
                static void SetupCustomPeerResolverServiceHost ()
                {
+                       string customPort = Environment.GetEnvironmentVariable ("MONO_CUSTOMPEERRESOLVERSERVICE_PORT");
+                       if (customPort == null || !int.TryParse (customPort, out port))
+                               port = 8931;
+
                        // launch peer resolver service locally only when it does not seem to be running ...
-                       var t = new TcpListener (8931);
+                       var t = new TcpListener (port);
                        try {
                                t.Start ();
                                t.Stop ();
@@ -59,7 +64,7 @@ namespace System.ServiceModel.PeerResolvers
                        Console.WriteLine ("WARNING: it is running peer resolver service locally. This means, the node registration is valid only within this application domain...");
                        var host = new ServiceHost (new LocalPeerResolverService (TextWriter.Null));
                        host.Description.Behaviors.Find<ServiceBehaviorAttribute> ().InstanceContextMode = InstanceContextMode.Single;
-                       host.AddServiceEndpoint (typeof (ICustomPeerResolverContract), new BasicHttpBinding (), "http://localhost:8931");
+                       host.AddServiceEndpoint (typeof (ICustomPeerResolverContract), new BasicHttpBinding (), $"http://localhost:{port}");
                        localhost = host;
                        host.Open ();
                }
@@ -70,7 +75,7 @@ namespace System.ServiceModel.PeerResolvers
 
                public CustomPeerResolverService ()
                {
-                       client = ChannelFactory<ICustomPeerResolverClient>.CreateChannel (new BasicHttpBinding (), new EndpointAddress ("http://localhost:8931"));
+                       client = ChannelFactory<ICustomPeerResolverClient>.CreateChannel (new BasicHttpBinding (), new EndpointAddress ($"http://localhost:{port}"));
 
                        refresh_interval = new TimeSpan (0, 10, 0);
                        cleanup_interval = new TimeSpan (0, 1, 0);
index 211627b39c6f8ea78cc26519c8941362fb3ac6c1..80513455ec1ab771029d2573cc94f12ab9bfae9f 100644 (file)
@@ -14,14 +14,17 @@ using MonoTests.stand_alone.WebHarness;
 using System.ServiceModel.Dispatcher;
 using System.Collections.ObjectModel;
 
+using MonoTests.Helpers;
+
 namespace MonoTests.Features
 {
        public class Configuration
        {
                static Configuration() {
+                       var port = NetworkHelpers.FindFreePort ();
                        onlyServers = Boolean.Parse (ConfigurationManager.AppSettings ["onlyServers"]  ?? "false");
                        onlyClients = Boolean.Parse (ConfigurationManager.AppSettings ["onlyClients"]  ?? "false");
-                       endpointBase = ConfigurationManager.AppSettings ["endpointBase"] ?? "http://localhost:9999/";
+                       endpointBase = ConfigurationManager.AppSettings ["endpointBase"] ?? $"http://localhost:{port}/";
                        if (!endpointBase.EndsWith ("/"))
                                endpointBase = endpointBase + '/';
                        logMessages = Boolean.Parse (ConfigurationManager.AppSettings ["logMessages"] ?? "false");
index 593ded1b011ad12caddc022a8e01259000a4d0e3..398a29a9847548b896a73d94688ac5327cd58ed7 100644 (file)
@@ -16,6 +16,8 @@ using System.Text;
 
 using NUnit.Framework;
 
+using MonoTests.Helpers;
+
 namespace MonoTests.System.ServiceModel.PeerResolvers
 {
        [TestFixture]
@@ -26,6 +28,8 @@ namespace MonoTests.System.ServiceModel.PeerResolvers
                [SetUp]
                protected void SetUp ()
                {
+                       var port = NetworkHelpers.FindFreePort ();
+                       Environment.SetEnvironmentVariable ("MONO_CUSTOMPEERRESOLVERSERVICE_PORT", port.ToString ());
                        cprs = new CustomPeerResolverService ();
                }
 
diff --git a/mcs/class/System.Windows.Forms/Test/System.Windows.Forms/tests-ms.sh b/mcs/class/System.Windows.Forms/Test/System.Windows.Forms/tests-ms.sh
deleted file mode 100755 (executable)
index d30fb69..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/bin/sh
-
-if [ $# -eq 0 ]; then
-       echo "You should give a list of test names such as: "
-       echo "$0 System.Windows.Forms.ListViewItemTest"
-       echo "or"
-       echo "$0 all"   
-       exit 1
-fi
-
-export MSNet=Yes
-cp ../../System.Windows.Forms_test_default.dll .
-topdir=../../../..
-NUNITCONSOLE=$topdir/class/lib/default/nunit-console.exe
-MONO_PATH=$topdir/nunit20:$topdir/class/lib:.
-
-for i in $@; do
-       if [ "$i" = "all" ]; then
-               fixture=""
-       else
-               fixture="/fixture:MonoTests.${i}"
-       fi
-       MONO_PATH=$MONO_PATH \
-               ${NUNITCONSOLE} System.Windows.Forms_test_default.dll $fixture
-done
-
-
-
diff --git a/mcs/class/System.Windows.Forms/Test/System.Windows.Forms/tests-ms2.sh b/mcs/class/System.Windows.Forms/Test/System.Windows.Forms/tests-ms2.sh
deleted file mode 100644 (file)
index 4e5dd14..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-#!/bin/sh
-
-if [ $# -eq 0 ]; then
-       echo "You should give a list of test names such as: "
-       echo "$0 System.Windows.Forms.ListViewItemTest"
-       echo "or"
-       echo "$0 all"
-       exit 1
-fi
-
-export MSNet=Yes
-cp ../../System.Windows.Forms_test_NET_2_0.dll .
-topdir=../../../..
-NUNITCONSOLE=$topdir/class/lib/net_2_0/nunit-console.exe
-MONO_PATH=$topdir/nunit20:$topdir/class/lib/net_2_0:.
-
-for i in $@; do
-       if [ "$i" = "all" ]; then
-               fixture=""
-       else
-               fixture="/fixture:MonoTests.${i}"
-       fi
-       MONO_PATH=$MONO_PATH \
-               ${NUNITCONSOLE} System.Windows.Forms_test_NET_2_0.dll $fixture
-done
\ No newline at end of file
diff --git a/mcs/class/System.Windows.Forms/Test/System.Windows.Forms/tests.sh b/mcs/class/System.Windows.Forms/Test/System.Windows.Forms/tests.sh
deleted file mode 100755 (executable)
index d440326..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/bin/sh
-
-if [ $# -eq 0 ]; then
-       echo "You should give a list of test names such as: "
-       echo "$0 System.Windows.Forms.ListViewItemTest"
-       echo "or"
-       echo "$0 all"
-       exit 1
-fi
-
-cp ../../System.Windows.Forms_test_default.dll .
-
-topdir=../../../..
-NUNITCONSOLE=$topdir/class/lib/default/nunit-console.exe
-MONO_PATH=$topdir/nunit20:$topdir/class/lib/default:.
-
-
-for i in $@; do
-       if [ "$i" = "all" ]; then
-               fixture=""
-       else
-               fixture="/fixture:MonoTests.${i}"
-       fi
-       MONO_PATH=$MONO_PATH \
-               mono --debug ${NUNITCONSOLE} System.Windows.Forms_test_default.dll $fixture
-done
-
-
-
diff --git a/mcs/class/System.Windows.Forms/Test/System.Windows.Forms/tests2.sh b/mcs/class/System.Windows.Forms/Test/System.Windows.Forms/tests2.sh
deleted file mode 100644 (file)
index 6a01dcb..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-#!/bin/bash
-
-function usage {
-if [ $# -eq 0 ]; then
-       echo <<EOF '
-       Usage:  '$0' [--nunit] [--prefix] [--monooption] [--test] all|Fixture
-
-       --nunit            : path to nunit, if you want to use a different one than the default 2.0
-       --prefix           : prefix to use to pass options to nunit. Default is /, newer nunits use - instead
-       --monooption   : Options to pass on to mono, like --debug, --trace, etc.
-       --test             : Specific test to run, if the nunit you''re using supports it
-       all            : run all tests
-       Fixture        : Fixture is the name of the test you want to run. The MonoTests.System.Windows.Forms
-                                        namespace will be prepended automatically, so you don''t need to add it. You can
-                                        specify as many fixtures as you want, they will be run one after the other.
-
-       Example:
-               '$0' --debug --trace=N:MonoTests.System.Windows.Forms all
-               Runs all tests with debug and trace flags, roughly equivalent to:
-               "mono --debug --trace=N:MonoTests.System.Windows.Forms nunit.exe System.Windows.Forms_test_net_2_0.dll"
-'
-EOF
-       exit 1
-fi
-}
-
-cp ../../System.Windows.Forms_test_net_2_0.dll .
-
-topdir=../../../..
-NUNITCONSOLE=$topdir/class/lib/net_2_0/nunit-console.exe
-MONO_PATH=$topdir/nunit20:$topdir/class/lib/net_2_0:.
-
-opts=""
-test=""
-prefix="/"
-ns="MonoTests."
-
-for i in $@; do
-       case $i in
-               --prefix*)
-                       prefix=${i:9}
-                       shift
-               ;;
-               --nunit*)
-                       NUNITCONSOLE="${i:8}/nunit-console.exe"
-                       MONO_PATH="${i:8}:."
-                       shift
-               ;;
-               --test*)
-                       test="-run=${i:7}"
-                       shift
-               ;;
-               -labels)
-                       NUNITCONSOLE="${NUNITCONSOLE} ${prefix}labels"
-                       shift
-               ;;
-               -defns)
-                       ns="MonoTests.System.Windows.Forms."
-                       shift
-               ;;
-               --*)
-                       opts="$opts $i"
-                       shift
-          ;;
-          *) continue ;;
-       esac
-done
-
-if [ $# -eq 0 ]; then
-       usage
-       exit 1
-fi
-
-
-for i in $@; do
-       case $i in
-               all) fixture="" ;;
-               *) fixture="${prefix}fixture:${ns}${i}" ;;
-       esac
-       echo "MONO_PATH=$MONO_PATH mono $opts ${NUNITCONSOLE} System.Windows.Forms_test_net_2_0.dll $fixture $test"
-       MONO_PATH=$MONO_PATH mono $opts ${NUNITCONSOLE} System.Windows.Forms_test_net_2_0.dll $fixture $test
-done
index 1d53227f5e9777b78de91c2287cea8b2c5c8edf9..0cc69e47648db2ed9fc45b7bc8af47bd83713b5d 100644 (file)
@@ -95,12 +95,6 @@ namespace Mono.AppleTls
                        get { return !disposed && context != IntPtr.Zero; }
                }
 
-               [System.Diagnostics.Conditional ("APPLE_TLS_DEBUG")]
-               protected new void Debug (string message, params object[] args)
-               {
-                       Console.Error.WriteLine ("MobileTlsStream({0}): {1}", Parent.ID, string.Format (message, args));
-               }
-
                void CheckStatusAndThrow (SslStatus status, params SslStatus[] acceptable)
                {
                        var last = Interlocked.Exchange (ref lastException, null);
@@ -299,11 +293,6 @@ namespace Mono.AppleTls
                        else
                                MaxProtocol = SslProtocol.Tls_1_0;
 
-#if APPLE_TLS_DEBUG
-                       foreach (var c in GetSupportedCiphers ())
-                               Debug ("  {0} SslCipherSuite.{1} {2:x} {3}", IsServer ? "Server" : "Client", c, (int)c, (CipherSuiteCode)c);
-#endif
-
                        if (Settings != null && Settings.EnabledCiphers != null) {
                                SslCipherSuite [] ciphers = new SslCipherSuite [Settings.EnabledCiphers.Length];
                                for (int i = 0 ; i < Settings.EnabledCiphers.Length; ++i)
@@ -786,7 +775,7 @@ namespace Mono.AppleTls
                [DllImport (SecurityLibrary)]
                extern unsafe static /* OSStatus */ SslStatus SSLRead (/* SSLContextRef */ IntPtr context, /* const void* */ byte* data, /* size_t */ IntPtr dataLength, /* size_t* */ out IntPtr processed);
 
-               public override unsafe int Read (byte[] buffer, int offset, int count, out bool wantMore)
+               public override unsafe (int ret, bool wantMore) Read (byte[] buffer, int offset, int count)
                {
                        if (Interlocked.Exchange (ref pendingIO, 1) == 1)
                                throw new InvalidOperationException ();
@@ -810,13 +799,12 @@ namespace Mono.AppleTls
                                         * when the first inner Read() returns 0.  MobileAuthenticatedStream.InnerRead() attempts
                                         * to distinguish between a graceful close and abnormal termination of connection.
                                         */
-                                       wantMore = false;
-                                       return 0;
+                                       return (0, false);
                                }
 
                                CheckStatusAndThrow (status, SslStatus.WouldBlock, SslStatus.ClosedGraceful);
-                               wantMore = status == SslStatus.WouldBlock;
-                               return (int)processed;
+                               var wantMore = status == SslStatus.WouldBlock;
+                               return ((int)processed, wantMore);
                        } catch (Exception ex) {
                                Debug ("Read error: {0}", ex);
                                throw;
@@ -828,7 +816,7 @@ namespace Mono.AppleTls
                [DllImport (SecurityLibrary)]
                extern unsafe static /* OSStatus */ SslStatus SSLWrite (/* SSLContextRef */ IntPtr context, /* const void* */ byte* data, /* size_t */ IntPtr dataLength, /* size_t* */ out IntPtr processed);
 
-               public override unsafe int Write (byte[] buffer, int offset, int count, out bool wantMore)
+               public override unsafe (int ret, bool wantMore) Write (byte[] buffer, int offset, int count)
                {
                        if (Interlocked.Exchange (ref pendingIO, 1) == 1)
                                throw new InvalidOperationException ();
@@ -848,8 +836,8 @@ namespace Mono.AppleTls
 
                                CheckStatusAndThrow (status, SslStatus.WouldBlock);
 
-                               wantMore = status == SslStatus.WouldBlock;
-                               return (int)processed;
+                               var wantMore = status == SslStatus.WouldBlock;
+                               return ((int)processed, wantMore);
                        } finally {
                                pendingIO = 0;
                        }
@@ -860,24 +848,7 @@ namespace Mono.AppleTls
 
                public override void Shutdown ()
                {
-                       if (Interlocked.Exchange (ref pendingIO, 1) == 1)
-                               throw new InvalidOperationException ();
-
-                       Debug ("Shutdown");
-
-                       lastException = null;
-
-                       try {
-                               if (closed || disposed)
-                                       return;
-
-                               var status = SSLClose (Handle);
-                               Debug ("Shutdown done: {0}", status);
-                               CheckStatusAndThrow (status);
-                       } finally {
-                               closed = true;
-                               pendingIO = 0;
-                       }
+                       closed = true;
                }
 
                #endregion
index 4fdabfd3ae3d22b8658a5a86dd5db672cc0edcd1..9582f6aceb74a6d3c23d1dbafdb3b77f2e520530 100644 (file)
@@ -65,6 +65,10 @@ namespace Mono.AppleTls
                        get { return true; }
                }
 
+               internal override bool SupportsCleanShutdown {
+                       get { return false; }
+               }
+
                public override SslProtocols SupportedProtocols {
                        get { return SslProtocols.Tls12 | SslProtocols.Tls11 | SslProtocols.Tls; }
                }
index 08c2678a2276f6554da8f4b50d6127550b7b84bc..559db4aca5d4f8288686b51369d6324a1114f5fd 100644 (file)
@@ -300,7 +300,7 @@ namespace Mono.Btls
                        throw new NotImplementedException ();
                }
 
-               public override int Read (byte[] buffer, int offset, int size, out bool wantMore)
+               public override (int ret, bool wantMore) Read (byte[] buffer, int offset, int size)
                {
                        Debug ("Read: {0} {1} {2}", buffer.Length, offset, size);
 
@@ -313,27 +313,23 @@ namespace Mono.Btls
                                var status = ssl.Read (data, ref size);
                                Debug ("Read done: {0} {1}", status, size);
 
-                               if (status == MonoBtlsSslError.WantRead) {
-                                       wantMore = true;
-                                       return 0;
-                               } else if (status == MonoBtlsSslError.ZeroReturn) {
-                                       wantMore = false;
-                                       return size;
-                               } else if (status != MonoBtlsSslError.None) {
+                               if (status == MonoBtlsSslError.WantRead)
+                                       return (0, true);
+                               if (status == MonoBtlsSslError.ZeroReturn)
+                                       return (size, false);
+                               if (status != MonoBtlsSslError.None)
                                        throw GetException (status);
-                               }
 
                                if (size > 0)
                                        Marshal.Copy (data, buffer, offset, size);
 
-                               wantMore = false;
-                               return size;
+                               return (size, false);
                        } finally {
                                Marshal.FreeHGlobal (data);
                        }
                }
 
-               public override int Write (byte[] buffer, int offset, int size, out bool wantMore)
+               public override (int ret, bool wantMore) Write (byte[] buffer, int offset, int size)
                {
                        Debug ("Write: {0} {1} {2}", buffer.Length, offset, size);
 
@@ -347,15 +343,12 @@ namespace Mono.Btls
                                var status = ssl.Write (data, ref size);
                                Debug ("Write done: {0} {1}", status, size);
 
-                               if (status == MonoBtlsSslError.WantWrite) {
-                                       wantMore = true;
-                                       return 0;
-                               } else if (status != MonoBtlsSslError.None) {
+                               if (status == MonoBtlsSslError.WantWrite)
+                                       return (0, true);
+                               if (status != MonoBtlsSslError.None)
                                        throw GetException (status);
-                               }
 
-                               wantMore = false;
-                               return size;
+                               return (size, false);
                        } finally {
                                Marshal.FreeHGlobal (data);
                        }
@@ -364,7 +357,8 @@ namespace Mono.Btls
                public override void Shutdown ()
                {
                        Debug ("Shutdown!");
-//                     ssl.SetQuietShutdown ();
+                       if (Settings == null || !Settings.SendCloseNotify)
+                               ssl.SetQuietShutdown ();
                        ssl.Shutdown ();
                }
 
index bd979345e0debc693cfe43b9c5db0c7ca096277e..0db248b991264239131aac70f934d6557e2c1fd0 100644 (file)
@@ -75,6 +75,10 @@ namespace Mono.Btls
                        get { return true; }
                }
 
+               internal override bool SupportsCleanShutdown {
+                       get { return true; }
+               }
+
                public override SslProtocols SupportedProtocols {
                        get { return SslProtocols.Tls12 | SslProtocols.Tls11 | SslProtocols.Tls; }
                }
index e5fac698c0e18c35c32040e2d4d2679a4ed6c130..d268020257e9ccc5b7eee64e8c0cc22b25eb5072 100644 (file)
@@ -130,6 +130,12 @@ namespace Mono.Btls
                [DllImport (BTLS_DYLIB)]
                extern static IntPtr mono_btls_ssl_get_server_name (IntPtr handle);
 
+               [DllImport (BTLS_DYLIB)]
+               extern static void mono_btls_ssl_set_renegotiate_mode (IntPtr handle, int mode);
+
+               [DllImport (BTLS_DYLIB)]
+               extern static int mono_btls_ssl_renegotiate_pending (IntPtr handle);
+
                static BoringSslHandle Create_internal (MonoBtlsSslCtx ctx)
                {
                        var handle = mono_btls_ssl_new (ctx.Handle.DangerousGetHandle ());
@@ -448,6 +454,17 @@ namespace Mono.Btls
                        if (!Handle.IsInvalid)
                                mono_btls_ssl_close (Handle.DangerousGetHandle ());
                }
+
+               public void SetRenegotiateMode (MonoBtlsSslRenegotiateMode mode)
+               {
+                       CheckThrow ();
+                       mono_btls_ssl_set_renegotiate_mode (Handle.DangerousGetHandle (), (int)mode);
+               }
+
+               public bool RenegotiatePending ()
+               {
+                       return mono_btls_ssl_renegotiate_pending (Handle.DangerousGetHandle ()) != 0;
+               }
        }
 }
 #endif
diff --git a/mcs/class/System/Mono.Btls/MonoBtlsSslRenegotiateMode.cs b/mcs/class/System/Mono.Btls/MonoBtlsSslRenegotiateMode.cs
new file mode 100644 (file)
index 0000000..897c0f8
--- /dev/null
@@ -0,0 +1,39 @@
+//
+// MonoBtlsSslRenegotiateMode.cs
+//
+// Author:
+//       Martin Baulig <mabaul@microsoft.com>
+//
+// Copyright (c) 2017 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.
+#if SECURITY_DEP && MONO_FEATURE_BTLS
+using System;
+namespace Mono.Btls
+{
+       [Flags]
+       enum MonoBtlsSslRenegotiateMode
+       {
+               NEVER = 0,
+               ONCE,
+               FREELY,
+               IGNORE
+       }
+}
+#endif
index 3c537a7e42798b46ee80b02477db30759666c7fa..8ed25908b0f0d38b61d55e10a12103cf3949383c 100644 (file)
@@ -158,7 +158,7 @@ namespace Mono.Net.Security
                        RunSynchronously = sync;
                }
 
-               [SD.Conditional ("MARTIN_DEBUG")]
+               [SD.Conditional ("MONO_TLS_DEBUG")]
                protected void Debug (string message, params object[] args)
                {
                        Parent.Debug ("{0}({1}:{2}): {3}", Name, Parent.ID, ID, string.Format (message, args));
@@ -226,6 +226,7 @@ namespace Mono.Net.Security
 
                                if (Interlocked.Exchange (ref WriteRequested, 0) != 0) {
                                        // Flush the write queue.
+                                       Debug ("ProcessOperation - flushing write queue");
                                        await Parent.InnerWrite (RunSynchronously, cancellationToken);
                                }
 
index a67b1ff069e9c67c83a61f73e65c04165ad54af6..d5d66c2f5eedd5e28a0b57a6007102630e024cad 100644 (file)
@@ -68,6 +68,10 @@ namespace Mono.Net.Security
                        get { return false; }
                }
 
+               internal override bool SupportsCleanShutdown {
+                       get { return false; }
+               }
+
                public override SslProtocols SupportedProtocols {
                        get { return SslProtocols.Tls; }
                }
index a5ffde26c34a9eee183cedd3a2b439f972a52a7c..95ecb8fd64a2d1e8a4a59296eba02dd660a86bea 100644 (file)
@@ -384,10 +384,10 @@ namespace Mono.Net.Security
                static int nextId;
                internal readonly int ID = ++nextId;
 
-               [SD.Conditional ("MARTIN_DEBUG")]
+               [SD.Conditional ("MONO_TLS_DEBUG")]
                protected internal void Debug (string message, params object[] args)
                {
-                       Console.Error.WriteLine ("MobileAuthenticatedStream({0}): {1}", ID, string.Format (message, args));
+                       MonoTlsProviderFactory.Debug ("MobileAuthenticatedStream({0}): {1}", ID, string.Format (message, args));
                }
 
 #region Called back from native code via SslConnection
@@ -612,11 +612,16 @@ namespace Mono.Net.Security
                                 * SSLHandshake() will return repeatedly with 'SslStatus.WouldBlock', we then need
                                 * to take care of I/O and call it again.
                                */
+                               var newStatus = AsyncOperationStatus.Continue;
                                if (xobileTlsContext.ProcessHandshake ()) {
                                        xobileTlsContext.FinishHandshake ();
-                                       return AsyncOperationStatus.Complete;
+                                       newStatus = AsyncOperationStatus.Complete;
                                }
-                               return AsyncOperationStatus.Continue;
+
+                               if (lastException != null)
+                                       lastException.Throw ();
+
+                               return newStatus;
                        }
                }
 
@@ -624,8 +629,10 @@ namespace Mono.Net.Security
                {
                        lock (ioLock) {
                                // This operates on the internal buffer and will never block.
-                               var ret = xobileTlsContext.Read (userBuffer.Buffer, userBuffer.Offset, userBuffer.Size, out bool wantMore);
-                               return (ret, wantMore);
+                               var ret = xobileTlsContext.Read (userBuffer.Buffer, userBuffer.Offset, userBuffer.Size);
+                               if (lastException != null)
+                                       lastException.Throw ();
+                               return ret;
                        }
                }
 
@@ -633,8 +640,10 @@ namespace Mono.Net.Security
                {
                        lock (ioLock) {
                                // This operates on the internal buffer and will never block.
-                               var ret = xobileTlsContext.Write (userBuffer.Buffer, userBuffer.Offset, userBuffer.Size, out bool wantMore);
-                               return (ret, wantMore);
+                               var ret = xobileTlsContext.Write (userBuffer.Buffer, userBuffer.Offset, userBuffer.Size);
+                               if (lastException != null)
+                                       lastException.Throw ();
+                               return ret;
                        }
                }
 
index b4ba1c014cabf7cb5e47d7410d46d19e5aa10106..74410976a85098a4b786d38618d220da78b78863 100644 (file)
@@ -78,10 +78,10 @@ namespace Mono.Net.Security
                        get { return parent.Provider; }
                }
 
-               [SD.Conditional ("MARTIN_DEBUG")]
+               [SD.Conditional ("MONO_TLS_DEBUG")]
                protected void Debug (string message, params object[] args)
                {
-                       Console.Error.WriteLine ("{0}: {1}", GetType ().Name, string.Format (message, args));
+                       parent.Debug ("{0}: {1}", GetType ().Name, string.Format (message, args));
                }
 
                public abstract bool HasContext {
@@ -165,9 +165,9 @@ namespace Mono.Net.Security
 
                public abstract void Flush ();
 
-               public abstract int Read (byte[] buffer, int offset, int count, out bool wantMore);
+               public abstract (int ret, bool wantMore) Read (byte[] buffer, int offset, int count);
 
-               public abstract int Write (byte[] buffer, int offset, int count, out bool wantMore);
+               public abstract (int ret, bool wantMore) Write (byte[] buffer, int offset, int count);
 
                public abstract void Shutdown ();
 
index 660e3b41bb6b5e5ca366a52dfbba32ad5810830e..dcc640ad30fea939f1212247233e18284e40705a 100644 (file)
@@ -38,6 +38,7 @@ using System.Security.Cryptography.X509Certificates;
 
 using System;
 using System.Net;
+using System.Diagnostics;
 using System.Collections.Generic;
 using System.Runtime.CompilerServices;
 
@@ -192,6 +193,22 @@ namespace Mono.Net.Security
                        }
                }
 
+               static bool enableDebug;
+
+               [Conditional ("MONO_TLS_DEBUG")]
+               static void InitializeDebug ()
+               {
+                       if (Environment.GetEnvironmentVariable ("MONO_TLS_DEBUG") != null)
+                               enableDebug = true;
+               }
+
+               [Conditional ("MONO_TLS_DEBUG")]
+               internal static void Debug (string message, params object[] args)
+               {
+                       if (enableDebug)
+                               Console.Error.WriteLine (message, args);
+               }
+
 #endregion
 
                internal static readonly Guid AppleTlsId = new Guid ("981af8af-a3a3-419a-9f01-a518e3a17c1c");
@@ -203,6 +220,9 @@ namespace Mono.Net.Security
                        lock (locker) {
                                if (providerRegistration != null)
                                        return;
+
+                               InitializeDebug ();
+
                                providerRegistration = new Dictionary<string,Tuple<Guid,string>> ();
                                providerCache = new Dictionary<Guid,MSI.MonoTlsProvider> ();
 
index 238d4e93b2ddf02c3d97c9872bad2740d5760cd9..e72ecbccdb1cef30a05d346c09c69c9ae6fb71e1 100644 (file)
     <Compile Include="Mono.Btls\MonoBtlsSsl.cs" />\r
     <Compile Include="Mono.Btls\MonoBtlsSslCtx.cs" />\r
     <Compile Include="Mono.Btls\MonoBtlsSslError.cs" />\r
+    <Compile Include="Mono.Btls\MonoBtlsSslRenegotiateMode.cs" />\r
     <Compile Include="Mono.Btls\MonoBtlsStream.cs" />\r
     <Compile Include="Mono.Btls\MonoBtlsUtils.cs" />\r
     <Compile Include="Mono.Btls\MonoBtlsX509.cs" />\r
index a5674f117fd22a2d8d918f7360c0c7982e1dd237..1ce421563e9f0a4eba99cc4ef492ed73a11398c0 100644 (file)
     <Compile Include="Mono.Btls\MonoBtlsSsl.cs" />\r
     <Compile Include="Mono.Btls\MonoBtlsSslCtx.cs" />\r
     <Compile Include="Mono.Btls\MonoBtlsSslError.cs" />\r
+    <Compile Include="Mono.Btls\MonoBtlsSslRenegotiateMode.cs" />\r
     <Compile Include="Mono.Btls\MonoBtlsStream.cs" />\r
     <Compile Include="Mono.Btls\MonoBtlsUtils.cs" />\r
     <Compile Include="Mono.Btls\MonoBtlsX509.cs" />\r
index ba3f462a940ec3e8f9666a2b1a3ca80674e4071a..70ecd84110e69c3934c2580792b428b58f0629d6 100644 (file)
     <Compile Include="Mono.Btls\MonoBtlsSsl.cs" />\r
     <Compile Include="Mono.Btls\MonoBtlsSslCtx.cs" />\r
     <Compile Include="Mono.Btls\MonoBtlsSslError.cs" />\r
+    <Compile Include="Mono.Btls\MonoBtlsSslRenegotiateMode.cs" />\r
     <Compile Include="Mono.Btls\MonoBtlsStream.cs" />\r
     <Compile Include="Mono.Btls\MonoBtlsUtils.cs" />\r
     <Compile Include="Mono.Btls\MonoBtlsX509.cs" />\r
index ae92b8d730bb51f7ad2493ae02351ccd90cbfb36..4a889e4dd2709692107c9acee71d19ca0b670551 100644 (file)
@@ -1290,7 +1290,12 @@ namespace System.Net.Sockets
                        ThrowIfBufferOutOfRange (buffer, offset, size);
 
                        int nativeError;
-                       int ret = Receive_internal (m_Handle, buffer, offset, size, socketFlags, out nativeError, is_blocking);
+                       int ret;
+                       unsafe {
+                               fixed (byte* pbuffer = buffer) {
+                                       ret = Receive_internal (m_Handle, &pbuffer[offset], size, socketFlags, out nativeError, is_blocking);
+                               }
+                       }
 
                        errorCode = (SocketError) nativeError;
                        if (errorCode != SocketError.Success && errorCode != SocketError.WouldBlock && errorCode != SocketError.InProgress) {
@@ -1315,25 +1320,27 @@ namespace System.Net.Sockets
                        int nativeError;
                        int ret;
 
-                       /* Only example I can find of sending a byte array reference directly into an internal
-                        * call is in System.Runtime.Remoting/System.Runtime.Remoting.Channels.Ipc.Win32/NamedPipeSocket.cs,
-                        * so taking a lead from that... */
-                       WSABUF[] bufarray = new WSABUF[numsegments];
                        GCHandle[] gch = new GCHandle[numsegments];
+                       try {
+                               unsafe {
+                                       fixed (WSABUF* bufarray = new WSABUF[numsegments]) {
+                                               for (int i = 0; i < numsegments; i++) {
+                                                       ArraySegment<byte> segment = buffers[i];
 
-                       for (int i = 0; i < numsegments; i++) {
-                               ArraySegment<byte> segment = buffers[i];
+                                                       if (segment.Offset < 0 || segment.Count < 0 || segment.Count > segment.Array.Length - segment.Offset)
+                                                               throw new ArgumentOutOfRangeException ("segment");
 
-                               if (segment.Offset < 0 || segment.Count < 0 || segment.Count > segment.Array.Length - segment.Offset)
-                                       throw new ArgumentOutOfRangeException ("segment");
+                                                       try {} finally {
+                                                               gch[i] = GCHandle.Alloc (segment.Array, GCHandleType.Pinned);
+                                                       }
 
-                               gch[i] = GCHandle.Alloc (segment.Array, GCHandleType.Pinned);
-                               bufarray[i].len = segment.Count;
-                               bufarray[i].buf = Marshal.UnsafeAddrOfPinnedArrayElement (segment.Array, segment.Offset);
-                       }
+                                                       bufarray[i].len = segment.Count;
+                                                       bufarray[i].buf = Marshal.UnsafeAddrOfPinnedArrayElement (segment.Array, segment.Offset);
+                                               }
 
-                       try {
-                               ret = Receive_internal (m_Handle, bufarray, socketFlags, out nativeError, is_blocking);
+                                               ret = Receive_internal (m_Handle, bufarray, numsegments, socketFlags, out nativeError, is_blocking);
+                                       }
+                               }
                        } finally {
                                for (int i = 0; i < numsegments; i++) {
                                        if (gch[i].IsAllocated)
@@ -1422,7 +1429,11 @@ namespace System.Net.Sockets
                        int total = 0;
 
                        try {
-                               total = Receive_internal (sockares.socket.m_Handle, sockares.Buffer, sockares.Offset, sockares.Size, sockares.SockFlags, out sockares.error, sockares.socket.is_blocking);
+                               unsafe {
+                                       fixed (byte* pbuffer = sockares.Buffer) {
+                                               total = Receive_internal (sockares.socket.m_Handle, &pbuffer[sockares.Offset], sockares.Size, sockares.SockFlags, out sockares.error, sockares.socket.is_blocking);
+                                       }
+                               }
                        } catch (Exception e) {
                                sockares.Complete (e);
                                return;
@@ -1488,31 +1499,31 @@ namespace System.Net.Sockets
                        return sockares.Total;
                }
 
-               static int Receive_internal (SafeSocketHandle safeHandle, WSABUF[] bufarray, SocketFlags flags, out int error, bool blocking)
+               static unsafe int Receive_internal (SafeSocketHandle safeHandle, WSABUF* bufarray, int count, SocketFlags flags, out int error, bool blocking)
                {
                        try {
                                safeHandle.RegisterForBlockingSyscall ();
-                               return Receive_internal (safeHandle.DangerousGetHandle (), bufarray, flags, out error, blocking);
+                               return Receive_internal (safeHandle.DangerousGetHandle (), bufarray, count, flags, out error, blocking);
                        } finally {
                                safeHandle.UnRegisterForBlockingSyscall ();
                        }
                }
 
                [MethodImplAttribute (MethodImplOptions.InternalCall)]
-               extern static int Receive_internal (IntPtr sock, WSABUF[] bufarray, SocketFlags flags, out int error, bool blocking);
+               extern static unsafe int Receive_internal (IntPtr sock, WSABUF* bufarray, int count, SocketFlags flags, out int error, bool blocking);
 
-               static int Receive_internal (SafeSocketHandle safeHandle, byte[] buffer, int offset, int count, SocketFlags flags, out int error, bool blocking)
+               static unsafe int Receive_internal (SafeSocketHandle safeHandle, byte* buffer, int count, SocketFlags flags, out int error, bool blocking)
                {
                        try {
                                safeHandle.RegisterForBlockingSyscall ();
-                               return Receive_internal (safeHandle.DangerousGetHandle (), buffer, offset, count, flags, out error, blocking);
+                               return Receive_internal (safeHandle.DangerousGetHandle (), buffer, count, flags, out error, blocking);
                        } finally {
                                safeHandle.UnRegisterForBlockingSyscall ();
                        }
                }
 
                [MethodImplAttribute(MethodImplOptions.InternalCall)]
-               extern static int Receive_internal(IntPtr sock, byte[] buffer, int offset, int count, SocketFlags flags, out int error, bool blocking);
+               extern static unsafe int Receive_internal(IntPtr sock, byte* buffer, int count, SocketFlags flags, out int error, bool blocking);
 
 #endregion
 
@@ -1541,7 +1552,12 @@ namespace System.Net.Sockets
                        SocketAddress sockaddr = remoteEP.Serialize();
 
                        int nativeError;
-                       int cnt = ReceiveFrom_internal (m_Handle, buffer, offset, size, socketFlags, ref sockaddr, out nativeError, is_blocking);
+                       int cnt;
+                       unsafe {
+                               fixed (byte* pbuffer = buffer) {
+                                       cnt = ReceiveFrom_internal (m_Handle, &pbuffer[offset], size, socketFlags, ref sockaddr, out nativeError, is_blocking);
+                               }
+                       }
 
                        errorCode = (SocketError) nativeError;
                        if (errorCode != SocketError.Success) {
@@ -1672,18 +1688,18 @@ namespace System.Net.Sockets
 
 
 
-               static int ReceiveFrom_internal (SafeSocketHandle safeHandle, byte[] buffer, int offset, int count, SocketFlags flags, ref SocketAddress sockaddr, out int error, bool blocking)
+               static unsafe int ReceiveFrom_internal (SafeSocketHandle safeHandle, byte* buffer, int count, SocketFlags flags, ref SocketAddress sockaddr, out int error, bool blocking)
                {
                        try {
                                safeHandle.RegisterForBlockingSyscall ();
-                               return ReceiveFrom_internal (safeHandle.DangerousGetHandle (), buffer, offset, count, flags, ref sockaddr, out error, blocking);
+                               return ReceiveFrom_internal (safeHandle.DangerousGetHandle (), buffer, count, flags, ref sockaddr, out error, blocking);
                        } finally {
                                safeHandle.UnRegisterForBlockingSyscall ();
                        }
                }
 
                [MethodImplAttribute(MethodImplOptions.InternalCall)]
-               extern static int ReceiveFrom_internal(IntPtr sock, byte[] buffer, int offset, int count, SocketFlags flags, ref SocketAddress sockaddr, out int error, bool blocking);
+               extern static unsafe int ReceiveFrom_internal(IntPtr sock, byte* buffer, int count, SocketFlags flags, ref SocketAddress sockaddr, out int error, bool blocking);
 
 #endregion
 
@@ -1757,8 +1773,12 @@ namespace System.Net.Sockets
                        int nativeError;
                        int sent = 0;
                        do {
-                               sent += Send_internal (
-m_Handle, buffer, offset + sent, size - sent, socketFlags, out nativeError, is_blocking);
+                               unsafe {
+                                       fixed (byte *pbuffer = buffer) {
+                                               sent += Send_internal (m_Handle, &pbuffer[offset + sent], size - sent, socketFlags, out nativeError, is_blocking);
+                                       }
+                               }
+
                                errorCode = (SocketError)nativeError;
                                if (errorCode != SocketError.Success && errorCode != SocketError.WouldBlock && errorCode != SocketError.InProgress) {
                                        is_connected = false;
@@ -1786,28 +1806,32 @@ m_Handle, buffer, offset + sent, size - sent, socketFlags, out nativeError, is_b
                        int nativeError;
                        int ret;
 
-                       WSABUF[] bufarray = new WSABUF[numsegments];
                        GCHandle[] gch = new GCHandle[numsegments];
+                       try {
+                               unsafe {
+                                       fixed (WSABUF* bufarray = new WSABUF[numsegments]) {
+                                               for(int i = 0; i < numsegments; i++) {
+                                                       ArraySegment<byte> segment = buffers[i];
 
-                       for(int i = 0; i < numsegments; i++) {
-                               ArraySegment<byte> segment = buffers[i];
+                                                       if (segment.Offset < 0 || segment.Count < 0 || segment.Count > segment.Array.Length - segment.Offset)
+                                                               throw new ArgumentOutOfRangeException ("segment");
 
-                               if (segment.Offset < 0 || segment.Count < 0 || segment.Count > segment.Array.Length - segment.Offset)
-                                       throw new ArgumentOutOfRangeException ("segment");
+                                                       try {} finally {
+                                                               gch[i] = GCHandle.Alloc (segment.Array, GCHandleType.Pinned);
+                                                       }
 
-                               gch[i] = GCHandle.Alloc (segment.Array, GCHandleType.Pinned);
-                               bufarray[i].len = segment.Count;
-                               bufarray[i].buf = Marshal.UnsafeAddrOfPinnedArrayElement (segment.Array, segment.Offset);
-                       }
+                                                       bufarray[i].len = segment.Count;
+                                                       bufarray[i].buf = Marshal.UnsafeAddrOfPinnedArrayElement (segment.Array, segment.Offset);
+                                               }
 
-                       try {
-                               ret = Send_internal (m_Handle, bufarray, socketFlags, out nativeError, is_blocking);
-                       } finally {
-                               for(int i = 0; i < numsegments; i++) {
-                                       if (gch[i].IsAllocated) {
-                                               gch[i].Free ();
+                                               ret = Send_internal (m_Handle, bufarray, numsegments, socketFlags, out nativeError, is_blocking);
                                        }
                                }
+                       } finally {
+                               for (int i = 0; i < numsegments; i++) {
+                                       if (gch[i].IsAllocated)
+                                               gch[i].Free();
+                               }
                        }
 
                        errorCode = (SocketError)nativeError;
@@ -1890,7 +1914,11 @@ m_Handle, buffer, offset + sent, size - sent, socketFlags, out nativeError, is_b
                        int total = 0;
 
                        try {
-                               total = Socket.Send_internal (sockares.socket.m_Handle, sockares.Buffer, sockares.Offset, sockares.Size, sockares.SockFlags, out sockares.error, false);
+                               unsafe {
+                                       fixed (byte *pbuffer = sockares.Buffer) {
+                                               total = Socket.Send_internal (sockares.socket.m_Handle, &pbuffer[sockares.Offset], sockares.Size, sockares.SockFlags, out sockares.error, false);
+                                       }
+                               }
                        } catch (Exception e) {
                                sockares.Complete (e);
                                return;
@@ -1978,31 +2006,31 @@ m_Handle, buffer, offset + sent, size - sent, socketFlags, out nativeError, is_b
                        return sockares.Total;
                }
 
-               static int Send_internal (SafeSocketHandle safeHandle, WSABUF[] bufarray, SocketFlags flags, out int error, bool blocking)
+               static unsafe int Send_internal (SafeSocketHandle safeHandle, WSABUF* bufarray, int count, SocketFlags flags, out int error, bool blocking)
                {
                        try {
                                safeHandle.RegisterForBlockingSyscall ();
-                               return Send_internal (safeHandle.DangerousGetHandle (), bufarray, flags, out error, blocking);
+                               return Send_internal (safeHandle.DangerousGetHandle (), bufarray, count, flags, out error, blocking);
                        } finally {
                                safeHandle.UnRegisterForBlockingSyscall ();
                        }
                }
 
                [MethodImplAttribute (MethodImplOptions.InternalCall)]
-               extern static int Send_internal (IntPtr sock, WSABUF[] bufarray, SocketFlags flags, out int error, bool blocking);
+               extern static unsafe int Send_internal (IntPtr sock, WSABUF* bufarray, int count, SocketFlags flags, out int error, bool blocking);
 
-               static int Send_internal (SafeSocketHandle safeHandle, byte[] buf, int offset, int count, SocketFlags flags, out int error, bool blocking)
+               static unsafe int Send_internal (SafeSocketHandle safeHandle, byte* buffer, int count, SocketFlags flags, out int error, bool blocking)
                {
                        try {
                                safeHandle.RegisterForBlockingSyscall ();
-                               return Send_internal (safeHandle.DangerousGetHandle (), buf, offset, count, flags, out error, blocking);
+                               return Send_internal (safeHandle.DangerousGetHandle (), buffer, count, flags, out error, blocking);
                        } finally {
                                safeHandle.UnRegisterForBlockingSyscall ();
                        }
                }
 
                [MethodImplAttribute(MethodImplOptions.InternalCall)]
-               extern static int Send_internal(IntPtr sock, byte[] buf, int offset, int count, SocketFlags flags, out int error, bool blocking);
+               extern static unsafe int Send_internal(IntPtr sock, byte* buffer, int count, SocketFlags flags, out int error, bool blocking);
 
 #endregion
 
@@ -2018,7 +2046,12 @@ m_Handle, buffer, offset + sent, size - sent, socketFlags, out nativeError, is_b
                                throw new ArgumentNullException("remoteEP");
 
                        int error;
-                       int ret = SendTo_internal (m_Handle, buffer, offset, size, socketFlags, remoteEP.Serialize (), out error, is_blocking);
+                       int ret;
+                       unsafe {
+                               fixed (byte *pbuffer = buffer) {
+                                       ret = SendTo_internal (m_Handle, &pbuffer[offset], size, socketFlags, remoteEP.Serialize (), out error, is_blocking);
+                               }
+                       }
 
                        SocketError err = (SocketError) error;
                        if (err != 0) {
@@ -2134,18 +2167,18 @@ m_Handle, buffer, offset + sent, size - sent, socketFlags, out nativeError, is_b
                        return sockares.Total;
                }
 
-               static int SendTo_internal (SafeSocketHandle safeHandle, byte[] buffer, int offset, int count, SocketFlags flags, SocketAddress sa, out int error, bool blocking)
+               static unsafe int SendTo_internal (SafeSocketHandle safeHandle, byte* buffer, int count, SocketFlags flags, SocketAddress sa, out int error, bool blocking)
                {
                        try {
                                safeHandle.RegisterForBlockingSyscall ();
-                               return SendTo_internal (safeHandle.DangerousGetHandle (), buffer, offset, count, flags, sa, out error, blocking);
+                               return SendTo_internal (safeHandle.DangerousGetHandle (), buffer, count, flags, sa, out error, blocking);
                        } finally {
                                safeHandle.UnRegisterForBlockingSyscall ();
                        }
                }
 
                [MethodImplAttribute(MethodImplOptions.InternalCall)]
-               extern static int SendTo_internal (IntPtr sock, byte[] buffer, int offset, int count, SocketFlags flags, SocketAddress sa, out int error, bool blocking);
+               extern static unsafe int SendTo_internal (IntPtr sock, byte* buffer, int count, SocketFlags flags, SocketAddress sa, out int error, bool blocking);
 
 #endregion
 
index 9a24b95e1b1642201544691b3af094e39acc17af..5925388413a4c49a8efbbb9481ea70e1be8af759 100755 (executable)
@@ -30,9 +30,7 @@ namespace MonoTests.System.Net.Sockets
        [TestFixture]
        public class SocketTest
        {
-               // note: also used in SocketCas tests
                public const string BogusAddress = "192.168.244.244";
-               public const int BogusPort = 23483;
 
                [Test]
 #if FEATURE_NO_BSD_SOCKETS
@@ -94,7 +92,7 @@ namespace MonoTests.System.Net.Sockets
                public void BogusEndConnect ()
                {
                        IPAddress ipOne = IPAddress.Parse (BogusAddress);
-                       IPEndPoint ipEP = new IPEndPoint (ipOne, BogusPort);
+                       IPEndPoint ipEP = new IPEndPoint (ipOne, NetworkHelpers.FindFreePort ());
                        Socket sock = new Socket (ipEP.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
                        IAsyncResult ar = sock.BeginConnect (ipEP, null, null);
 
@@ -501,8 +499,7 @@ namespace MonoTests.System.Net.Sockets
                        Socket sock = new Socket (AddressFamily.InterNetwork,
                                                  SocketType.Stream,
                                                  ProtocolType.Tcp);
-                       IPEndPoint ep = new IPEndPoint (IPAddress.Loopback,
-                                                       BogusPort);
+                       IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
                        
                        SocketError_event.Reset ();
 
@@ -745,8 +742,7 @@ namespace MonoTests.System.Net.Sockets
                        Socket sock = new Socket (AddressFamily.InterNetwork,
                                                  SocketType.Stream,
                                                  ProtocolType.Tcp);
-                       IPEndPoint ep = new IPEndPoint (IPAddress.Loopback,
-                                                       BogusPort);
+                       IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
                        
                        Assert.AreEqual (false, sock.IsBound, "IsBoundTcp #1");
                        
@@ -780,8 +776,7 @@ namespace MonoTests.System.Net.Sockets
                        Socket sock = new Socket (AddressFamily.InterNetwork,
                                                  SocketType.Dgram,
                                                  ProtocolType.Udp);
-                       IPEndPoint ep = new IPEndPoint (IPAddress.Loopback,
-                                                       BogusPort);
+                       IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
                        
                        Assert.AreEqual (false, sock.IsBound, "IsBoundUdp #1");
                        
@@ -1739,13 +1734,14 @@ namespace MonoTests.System.Net.Sockets
                [Test]
                public void BeginConnectAddressPortNull ()
                {
+                       var port = NetworkHelpers.FindFreePort ();
                        Socket sock = new Socket (AddressFamily.InterNetwork,
                                                  SocketType.Stream,
                                                  ProtocolType.Tcp);
                        IPAddress ip = null;
 
                        try {
-                               sock.BeginConnect (ip, 1244, BCCallback,
+                               sock.BeginConnect (ip, port, BCCallback,
                                                   sock);
                                Assert.Fail ("BeginConnectAddressPortNull #1");
                        } catch (ArgumentNullException) {
@@ -1782,6 +1778,7 @@ namespace MonoTests.System.Net.Sockets
                [ExpectedException (typeof(ObjectDisposedException))]
                public void BeginConnectAddressPortClosed ()
                {
+                       var port = NetworkHelpers.FindFreePort ();
                        Socket sock = new Socket (AddressFamily.InterNetwork,
                                                  SocketType.Stream,
                                                  ProtocolType.Tcp);
@@ -1789,7 +1786,7 @@ namespace MonoTests.System.Net.Sockets
                        
                        sock.Close ();
                        
-                       sock.BeginConnect (ip, 1244, BCCallback, sock);
+                       sock.BeginConnect (ip, port, BCCallback, sock);
                }
                
                [Test]
@@ -1911,13 +1908,14 @@ namespace MonoTests.System.Net.Sockets
                [Test]
                public void BeginConnectMultipleNull ()
                {
+                       var port = NetworkHelpers.FindFreePort ();
                        Socket sock = new Socket (AddressFamily.InterNetwork,
                                                  SocketType.Stream,
                                                  ProtocolType.Tcp);
                        IPAddress[] ips = null;
                        
                        try {
-                               sock.BeginConnect (ips, 1246, BCCallback,
+                               sock.BeginConnect (ips, port, BCCallback,
                                                   sock);
                                Assert.Fail ("BeginConnectMultipleNull #1");
                        } catch (ArgumentNullException) {
@@ -1961,6 +1959,7 @@ namespace MonoTests.System.Net.Sockets
                [ExpectedException (typeof(ObjectDisposedException))]
                public void BeginConnectMultipleClosed ()
                {
+                       var port = NetworkHelpers.FindFreePort ();
                        Socket sock = new Socket (AddressFamily.InterNetwork,
                                                  SocketType.Stream,
                                                  ProtocolType.Tcp);
@@ -1973,7 +1972,7 @@ namespace MonoTests.System.Net.Sockets
                        
                        sock.Close ();
                        
-                       sock.BeginConnect (ips, 1247, BCCallback, sock);
+                       sock.BeginConnect (ips, port, BCCallback, sock);
                }
                
                [Test]
@@ -2248,13 +2247,14 @@ namespace MonoTests.System.Net.Sockets
                [Test]
                public void ConnectAddressPortNull ()
                {
+                       var port = NetworkHelpers.FindFreePort ();
                        Socket sock = new Socket (AddressFamily.InterNetwork,
                                                  SocketType.Stream,
                                                  ProtocolType.Tcp);
                        IPAddress ip = null;
 
                        try {
-                               sock.Connect (ip, 1249);
+                               sock.Connect (ip, port);
                                Assert.Fail ("ConnectAddressPortNull #1");
                        } catch (ArgumentNullException) {
                        } finally {
@@ -2290,6 +2290,7 @@ namespace MonoTests.System.Net.Sockets
                [ExpectedException (typeof(ObjectDisposedException))]
                public void ConnectAddressPortClosed ()
                {
+                       var port = NetworkHelpers.FindFreePort ();
                        Socket sock = new Socket (AddressFamily.InterNetwork,
                                                  SocketType.Stream,
                                                  ProtocolType.Tcp);
@@ -2297,7 +2298,7 @@ namespace MonoTests.System.Net.Sockets
                        
                        sock.Close ();
                        
-                       sock.Connect (ip, 1250);
+                       sock.Connect (ip, port);
                }
                
                [Test]
@@ -2397,13 +2398,14 @@ namespace MonoTests.System.Net.Sockets
                [Test]
                public void ConnectMultipleNull ()
                {
+                       var port = NetworkHelpers.FindFreePort ();
                        Socket sock = new Socket (AddressFamily.InterNetwork,
                                                  SocketType.Stream,
                                                  ProtocolType.Tcp);
                        IPAddress[] ips = null;
                        
                        try {
-                               sock.Connect (ips, 1251);
+                               sock.Connect (ips, port);
                                Assert.Fail ("ConnectMultipleNull #1");
                        } catch (ArgumentNullException) {
                        } finally {
@@ -2445,6 +2447,7 @@ namespace MonoTests.System.Net.Sockets
                [ExpectedException (typeof(ObjectDisposedException))]
                public void ConnectMultipleClosed ()
                {
+                       var port = NetworkHelpers.FindFreePort ();
                        Socket sock = new Socket (AddressFamily.InterNetwork,
                                                  SocketType.Stream,
                                                  ProtocolType.Tcp);
@@ -2457,7 +2460,7 @@ namespace MonoTests.System.Net.Sockets
                        
                        sock.Close ();
                        
-                       sock.Connect (ips, 1252);
+                       sock.Connect (ips, port);
                }
                
                [Test]
@@ -4301,7 +4304,7 @@ namespace MonoTests.System.Net.Sockets
                                IPv6MulticastOption option = new IPv6MulticastOption (
                                        IPAddress.Parse ("ff02::1"));
 
-                               s.Bind (new IPEndPoint (IPAddress.IPv6Any, 1902));
+                               s.Bind (new IPEndPoint (IPAddress.IPv6Any, 0));
                                s.SetSocketOption (SocketOptionLevel.IPv6, SocketOptionName.AddMembership,
                                        option);
                                s.SetSocketOption (SocketOptionLevel.IPv6, SocketOptionName.DropMembership,
@@ -4551,6 +4554,7 @@ namespace MonoTests.System.Net.Sockets
 #if FEATURE_NO_BSD_SOCKETS
                [ExpectedException (typeof (PlatformNotSupportedException))]
 #endif
+               [Ignore ("https://bugzilla.xamarin.com/show_bug.cgi?id=43172")]
                public void SendAsyncFile ()
                {
                        Socket serverSocket = new Socket (AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
index cefe3bebc599a27a06a3892d3687a73a797be5bc..d827ae4de367cc074666e49c3a182b7ad4148c52 100644 (file)
@@ -155,7 +155,7 @@ namespace MonoTests.System.Net.Sockets
                        TcpClient client = new TcpClient ();
                        IPAddress[] ipAddresses = null;
                        
-                       client.Connect (ipAddresses, 1234);
+                       client.Connect (ipAddresses, NetworkHelpers.FindFreePort ());
                }
                
                [Test]
@@ -170,7 +170,7 @@ namespace MonoTests.System.Net.Sockets
                        ipAddresses[0] = IPAddress.Any;
                        
                        try {
-                               client.Connect (ipAddresses, 1234);
+                               client.Connect (ipAddresses, NetworkHelpers.FindFreePort ());
                                Assert.Fail ("ConnectMultiAny #1");
                        } catch (SocketException ex) {
                                Assert.AreEqual (10049, ex.ErrorCode, "ConnectMultiAny #2");
@@ -191,7 +191,7 @@ namespace MonoTests.System.Net.Sockets
                        ipAddresses[0] = IPAddress.Loopback;
                        
                        try {
-                               client.Connect (ipAddresses, 1234);
+                               client.Connect (ipAddresses, NetworkHelpers.FindFreePort ());
                                Assert.Fail ("ConnectMultiRefused #1");
                        } catch (SocketException ex) {
                                Assert.AreEqual (10061, ex.ErrorCode, "ConnectMultiRefused #2");
index 29ab8ef2ca64a8e4e4ff91f9acbd9959f3804e5a..1d2373b62158a1db5ec1ed67b4a5c9b5c5e87360 100644 (file)
@@ -13,6 +13,8 @@ using System.Threading.Tasks;
 
 using NUnit.Framework;
 
+using MonoTests.Helpers;
+
 namespace MonoTests.System.Net.Sockets {
        [TestFixture]
        public class UdpClientTest {
@@ -212,7 +214,7 @@ namespace MonoTests.System.Net.Sockets {
                        IPEndPoint localEP;
                        IPEndPoint clientEP;
 
-                       clientEP = new IPEndPoint (IPAddress.Loopback, 8001);
+                       clientEP = new IPEndPoint (IPAddress.Loopback, NetworkHelpers.FindFreePort ());
                        using (MyUdpClient client = new MyUdpClient (clientEP))
                        {
                                s = client.Client;
@@ -381,9 +383,7 @@ namespace MonoTests.System.Net.Sockets {
                        Socket s;
                        IPEndPoint localEP;
 
-                       // Bug #5503
-                       // UDP port 0 doesn't seem to be valid.
-                       using (MyUdpClient client = new MyUdpClient ("127.0.0.1", 53))
+                       using (MyUdpClient client = new MyUdpClient ("127.0.0.1", NetworkHelpers.FindFreePort ()))
                        {
                                s = client.Client;
                                Assert.IsNotNull (s, "#A:Client");
@@ -481,7 +481,7 @@ namespace MonoTests.System.Net.Sockets {
                        byte[] bytes = new byte[] {10, 11, 12, 13};
 
                        try {
-                               client.Send (bytes, bytes.Length, new IPEndPoint (IPAddress.Broadcast, 1235));
+                               client.Send (bytes, bytes.Length, new IPEndPoint (IPAddress.Broadcast, NetworkHelpers.FindFreePort ()));
                        } finally {
                                client.Close ();
                        }
@@ -495,7 +495,7 @@ namespace MonoTests.System.Net.Sockets {
                {
                        IPAddress mcast_addr = IPAddress.Parse ("224.0.0.23");
 
-                       using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Any, 1234))) {
+                       using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Any, 0))) {
                                client.JoinMulticastGroup (mcast_addr);
                        }
                }
@@ -511,7 +511,7 @@ namespace MonoTests.System.Net.Sockets {
 
                        IPAddress mcast_addr = IPAddress.Parse ("ff02::1");
 
-                       using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.IPv6Any, 1234))) {
+                       using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.IPv6Any, 0))) {
                                client.JoinMulticastGroup (mcast_addr);
                        }
                }
@@ -522,7 +522,7 @@ namespace MonoTests.System.Net.Sockets {
 #endif
                public void JoinMulticastGroup1_MulticastAddr_Null ()
                {
-                       using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Loopback, 1234))) {
+                       using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Loopback, 0))) {
                                try {
                                        client.JoinMulticastGroup ((IPAddress) null);
                                        Assert.Fail ("#1");
@@ -543,7 +543,7 @@ namespace MonoTests.System.Net.Sockets {
                {
                        IPAddress mcast_addr = null;
 
-                       UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Loopback, 1234));
+                       UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Loopback, 0));
                        client.Close ();
                        try {
                                client.JoinMulticastGroup (mcast_addr);
@@ -578,7 +578,7 @@ namespace MonoTests.System.Net.Sockets {
                {
                        IPAddress mcast_addr = IPAddress.Parse ("224.0.0.23");
 
-                       using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Any, 1234))) {
+                       using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Any, 0))) {
                                try {
                                        client.JoinMulticastGroup (0, mcast_addr);
                                        Assert.Fail ("#1");
@@ -606,7 +606,7 @@ namespace MonoTests.System.Net.Sockets {
 
                        IPAddress mcast_addr = IPAddress.Parse ("ff02::1");
 
-                       using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.IPv6Any, 1234))) {
+                       using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.IPv6Any, 0))) {
                                client.JoinMulticastGroup (0, mcast_addr);
                        }
                }
@@ -617,7 +617,7 @@ namespace MonoTests.System.Net.Sockets {
 #endif
                public void JoinMulticastGroup2_MulticastAddr_Null ()
                {
-                       using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Loopback, 1234))) {
+                       using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Loopback, 0))) {
                                try {
                                        client.JoinMulticastGroup (0, (IPAddress) null);
                                        Assert.Fail ("#1");
@@ -641,7 +641,7 @@ namespace MonoTests.System.Net.Sockets {
 
                        IPAddress mcast_addr = null;
 
-                       UdpClient client = new UdpClient (new IPEndPoint (IPAddress.IPv6Any, 1234));
+                       UdpClient client = new UdpClient (new IPEndPoint (IPAddress.IPv6Any, 0));
                        client.Close ();
                        try {
                                client.JoinMulticastGroup (0, mcast_addr);
@@ -676,11 +676,11 @@ namespace MonoTests.System.Net.Sockets {
                {
                        IPAddress mcast_addr = IPAddress.Parse ("224.0.0.23");
 
-                       using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Any, 1234))) {
+                       using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Any, 0))) {
                                client.JoinMulticastGroup (mcast_addr, 0);
                        }
 
-                       using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Any, 1234))) {
+                       using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Any, 0))) {
                                client.JoinMulticastGroup (mcast_addr, 255);
                        }
                }
@@ -696,11 +696,11 @@ namespace MonoTests.System.Net.Sockets {
 
                        IPAddress mcast_addr = IPAddress.Parse ("ff02::1");
 
-                       using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.IPv6Any, 1234))) {
+                       using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.IPv6Any, 0))) {
                                client.JoinMulticastGroup (mcast_addr, 0);
                        }
 
-                       using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.IPv6Any, 1234))) {
+                       using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.IPv6Any, 0))) {
                                client.JoinMulticastGroup (mcast_addr, 255);
                        }
                }
@@ -711,7 +711,7 @@ namespace MonoTests.System.Net.Sockets {
 #endif
                public void JoinMulticastGroup3_MulticastAddr_Null ()
                {
-                       using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Loopback, 1234))) {
+                       using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Loopback, 0))) {
                                try {
                                        client.JoinMulticastGroup ((IPAddress) null, int.MaxValue);
                                        Assert.Fail ("#1");
@@ -732,7 +732,7 @@ namespace MonoTests.System.Net.Sockets {
                {
                        IPAddress mcast_addr = null;
 
-                       UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Any, 1234));
+                       UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Any, 0));
                        client.Close ();
                        try {
                                client.JoinMulticastGroup (mcast_addr, 0);
@@ -768,7 +768,7 @@ namespace MonoTests.System.Net.Sockets {
                        IPAddress mcast_addr = IPAddress.Parse ("224.0.0.23");
                        IPAddress local_addr = IPAddress.Any;
 
-                       using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Any, 1234))) {
+                       using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Any, 0))) {
                                client.JoinMulticastGroup (mcast_addr, local_addr);
                        }
                }
@@ -785,7 +785,7 @@ namespace MonoTests.System.Net.Sockets {
                        IPAddress mcast_addr = IPAddress.Parse ("ff02::1");
                        IPAddress local_addr = IPAddress.IPv6Any;
 
-                       using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.IPv6Any, 1234))) {
+                       using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.IPv6Any, 0))) {
                                try {
                                        client.JoinMulticastGroup (mcast_addr, local_addr);
                                        Assert.Fail ("#1");
@@ -810,7 +810,7 @@ namespace MonoTests.System.Net.Sockets {
                {
                        IPAddress mcast_addr = IPAddress.Parse ("224.0.0.23");
 
-                       using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Loopback, 1234))) {
+                       using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Loopback, 0))) {
                                try {
                                        client.JoinMulticastGroup (mcast_addr, (IPAddress) null);
                                        Assert.Fail ("#1");
@@ -829,7 +829,7 @@ namespace MonoTests.System.Net.Sockets {
 #endif
                public void JoinMulticastGroup4_MulticastAddr_Null ()
                {
-                       using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Loopback, 1234))) {
+                       using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Loopback, 0))) {
                                try {
                                        client.JoinMulticastGroup ((IPAddress) null, IPAddress.Loopback);
                                        Assert.Fail ("#1");
@@ -851,7 +851,7 @@ namespace MonoTests.System.Net.Sockets {
                        IPAddress mcast_addr = null;
                        IPAddress local_addr = null;
 
-                       UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Any, 1234));
+                       UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Any, 0));
                        client.Close ();
                        try {
                                client.JoinMulticastGroup (mcast_addr, local_addr);
@@ -885,18 +885,7 @@ namespace MonoTests.System.Net.Sockets {
 #endif
                public void CloseInReceive ()
                {
-                       UdpClient client = null;
-                       var rnd = new Random ();
-                       for (int i = 0, max = 5; i < max; i++) {
-                               int port = rnd.Next (1025, 65534);
-                               try {
-                                       client = new UdpClient (port);
-                                       break;
-                               } catch (Exception) {
-                                       if (i == max - 1)
-                                               throw;
-                               }
-                       }
+                       UdpClient client = new UdpClient (NetworkHelpers.FindFreePort ());
 
                        ManualResetEvent ready = new ManualResetEvent (false);
                        bool got_exc = false;
@@ -928,7 +917,7 @@ namespace MonoTests.System.Net.Sockets {
 #endif
                public void JoinMulticastGroupWithLocal ()
                {
-                       UdpClient client = new UdpClient (9001);
+                       UdpClient client = new UdpClient (0);
                        IPAddress mcast_addr = IPAddress.Parse ("224.0.0.24");
                        IPAddress local_addr = IPAddress.Any;
 
@@ -995,7 +984,7 @@ namespace MonoTests.System.Net.Sockets {
                        IPEndPoint ep = null;
                        foreach (IPAddress a in addresses) {
                                if (a.AddressFamily == AddressFamily.InterNetwork) {
-                                       ep = new IPEndPoint (a, 1236);
+                                       ep = new IPEndPoint (a, NetworkHelpers.FindFreePort ());
                                        break;
                                }
                        }
@@ -1035,13 +1024,14 @@ namespace MonoTests.System.Net.Sockets {
 #endif
                public void BeginReceive ()
                {
-                       UdpClient client = new UdpClient (1237);
+                       var port = NetworkHelpers.FindFreePort ();
+                       UdpClient client = new UdpClient (port);
                        
                        BRCalledBack.Reset ();
                        
                        client.BeginReceive (BRCallback, client);
 
-                       IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 1237);
+                       IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, port);
                        byte[] send_bytes = new byte[] {10, 11, 12, 13};
                        client.Send (send_bytes, send_bytes.Length, ep);
 
@@ -1063,8 +1053,9 @@ namespace MonoTests.System.Net.Sockets {
 #endif
                public void Available ()
                {
-                       using (UdpClient client = new UdpClient (1238)) {
-                               IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 1238);
+                       var port = NetworkHelpers.FindFreePort ();
+                       using (UdpClient client = new UdpClient (port)) {
+                               IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, port);
                                byte[] bytes = new byte[] {10, 11, 12, 13};
                                
                                int res = client.Send (bytes, bytes.Length, ep);
@@ -1129,7 +1120,7 @@ namespace MonoTests.System.Net.Sockets {
                [Category ("NotWorking")] // Not supported on Linux
                public void ExclusiveAddressUseBound ()
                {
-                       UdpClient client = new UdpClient (1239);
+                       UdpClient client = new UdpClient (0);
 
                        client.ExclusiveAddressUse = true;
 
@@ -1158,12 +1149,13 @@ namespace MonoTests.System.Net.Sockets {
                        if (!Socket.OSSupportsIPv6)
                                Assert.Ignore ("IPv6 not enabled.");
 
-                       int PORT = 9997;
-                       using(var udpClient = new UdpClient (PORT, AddressFamily.InterNetworkV6))
-                       using(var udpClient2 = new UdpClient (PORT+1, AddressFamily.InterNetworkV6))
+                       int port1 = NetworkHelpers.FindFreePort ();
+                       int port2 = NetworkHelpers.FindFreePort ();
+                       using(var udpClient = new UdpClient (port1, AddressFamily.InterNetworkV6))
+                       using(var udpClient2 = new UdpClient (port2, AddressFamily.InterNetworkV6))
                        {
                                var dataSent = new byte [] {1,2,3};
-                               udpClient2.SendAsync (dataSent, dataSent.Length, "::1", PORT);
+                               udpClient2.SendAsync (dataSent, dataSent.Length, "::1", port1);
 
                                IPEndPoint endPoint = new IPEndPoint (IPAddress.IPv6Any, 0);
                                var data = udpClient.Receive (ref endPoint);
index b09a8180eafd6593fa30a07a9878138a93727de6..20763df580258234f11c7b5f04b0c6262fcf4626 100644 (file)
@@ -31,6 +31,8 @@ using System.Net;
 using NUnit.Framework;
 using HLPC=System.Net.HttpListenerPrefixCollection;
 
+using MonoTests.Helpers;
+
 namespace MonoTests.System.Net {
        [TestFixture]
        public class HttpListenerPrefixCollectionTest {
@@ -68,10 +70,11 @@ namespace MonoTests.System.Net {
 #endif
                public void AddOne ()
                {
+                       var port = NetworkHelpers.FindFreePort ();
                        HttpListener listener = new HttpListener ();
                        HLPC coll = listener.Prefixes;
                        listener.Start ();
-                       coll.Add ("http://127.0.0.1:8181/");
+                       coll.Add ($"http://127.0.0.1:{port}/");
                        Assert.AreEqual (1, coll.Count, "Count");
                        Assert.IsFalse (coll.IsReadOnly, "IsReadOnly");
                        Assert.IsFalse (coll.IsSynchronized, "IsSynchronized");
@@ -84,10 +87,11 @@ namespace MonoTests.System.Net {
 #endif
                public void Duplicate ()
                {
+                       var port = NetworkHelpers.FindFreePort ();
                        HttpListener listener = new HttpListener ();
                        HLPC coll = listener.Prefixes;
-                       coll.Add ("http://127.0.0.1:8181/");
-                       coll.Add ("http://127.0.0.1:8181/");
+                       coll.Add ($"http://127.0.0.1:{port}/");
+                       coll.Add ($"http://127.0.0.1:{port}/");
                        listener.Start ();
                        Assert.AreEqual (1, coll.Count, "Count");
                        Assert.IsFalse (coll.IsReadOnly, "IsReadOnly");
index a38c2ff9c486fded93b9ba91633e543ae750671d..418336ceef9159d17c6c23d4e6f7dc8df18507d9 100644 (file)
@@ -216,6 +216,7 @@ Mono.Btls/MonoBtlsProvider.cs
 Mono.Btls/MonoBtlsSsl.cs
 Mono.Btls/MonoBtlsSslCtx.cs
 Mono.Btls/MonoBtlsSslError.cs
+Mono.Btls/MonoBtlsSslRenegotiateMode.cs
 Mono.Btls/MonoBtlsStream.cs
 Mono.Btls/MonoBtlsUtils.cs
 Mono.Btls/MonoBtlsX509.cs
index 120991b2f79a9de061acadac90235eaa9d4b15fc..48d78605147fd386f643877d855a993c146bb302 100644 (file)
@@ -499,7 +499,7 @@ namespace System
 
                        m = Method;
 
-                       return (m != null ? m.GetHashCode () : GetType ().GetHashCode ()) ^ (m_target != null ? m_target.GetHashCode () : 0);
+                       return (m != null ? m.GetHashCode () : GetType ().GetHashCode ()) ^ RuntimeHelpers.GetHashCode (m_target);
                }
 
                protected virtual MethodInfo GetMethodImpl ()
diff --git a/mcs/class/corlib/Test/System.Runtime.Remoting/RemotingServicesTest.cs b/mcs/class/corlib/Test/System.Runtime.Remoting/RemotingServicesTest.cs
deleted file mode 100644 (file)
index 8582663..0000000
+++ /dev/null
@@ -1,529 +0,0 @@
-//
-// System.Runtime.Remoting.RemotingServices NUnit V2.0 test class
-//
-// Author Jean-Marc ANDRE (jean-marc.andre@polymtl.ca)
-//
-// ToDo: I didn't write test functions for the method not yep
-// implemented by Mono
-
-using System;
-using System.Collections;
-using NUnit.Framework;
-using System.Reflection;
-using System.Runtime.Remoting;
-using System.Threading;
-using System.Runtime.Remoting.Activation;
-using System.Runtime.Remoting.Messaging;
-using System.Runtime.Remoting.Proxies;
-using System.Runtime.Remoting.Channels;
-using System.Runtime.Remoting.Channels.Tcp;
-
-namespace MonoTests.System.Runtime.Remoting.RemotingServicesInternal
-{
-       // We need our own proxy to intercept messages to remote object
-       // and forward them using RemotingServices.ExecuteMessage
-       public class MyProxy: RealProxy
-       {
-               MarshalByRefObject target;
-               IMessageSink _sink;
-               MethodBase _mthBase;
-               bool methodOverloaded = false;
-               
-               public MethodBase MthBase
-               {
-                       get{ return _mthBase;}
-               }
-               
-               public bool IsMethodOverloaded
-               {
-                       get{return methodOverloaded;}
-               }
-               
-               public MyProxy(Type serverType, MarshalByRefObject target): base(serverType)
-               {
-                       this.target = target;
-                       
-                       IChannel[] registeredChannels = ChannelServices.RegisteredChannels;
-                       string ObjectURI;
-                       
-                       // A new IMessageSink chain has to be created
-                       // since the RemotingServices.GetEnvoyChainForProxy() is not yet
-                       // implemented.
-                       foreach(IChannel channel in registeredChannels)
-                       {
-                               IChannelSender channelSender = channel as IChannelSender;
-                               if(channelSender != null)
-                               {
-                                       _sink = (IMessageSink) channelSender.CreateMessageSink(RemotingServices.GetObjectUri(target), null, out ObjectURI);
-                               }
-                       }
-                       
-               }
-               
-               // Messages will be intercepted here and redirected
-               // to another object.
-               public override IMessage Invoke(IMessage msg)
-               {
-                       if(msg is IConstructionCallMessage)
-                       {
-                               IActivator remActivator = (IActivator) RemotingServices.Connect(typeof(IActivator), "tcp://localhost:1234/RemoteActivationService.rem");
-                               IConstructionReturnMessage crm = remActivator.Activate((IConstructionCallMessage)msg);
-                               return crm;
-                       }
-                       else
-                       {
-                               methodOverloaded = RemotingServices.IsMethodOverloaded((IMethodMessage)msg);
-                               
-                               _mthBase = RemotingServices.GetMethodBaseFromMethodMessage((IMethodMessage)msg);
-                               MethodCallMessageWrapper mcm = new MethodCallMessageWrapper((IMethodCallMessage) msg);
-                               mcm.Uri = RemotingServices.GetObjectUri((MarshalByRefObject)target);
-                               MarshalByRefObject objRem = (MarshalByRefObject)Activator.CreateInstance(GetProxiedType());
-                               RemotingServices.ExecuteMessage((MarshalByRefObject)objRem, (IMethodCallMessage)msg);
-                               IMessage rtnMsg = null;
-                               
-                               try
-                               {
-                                       rtnMsg = _sink.SyncProcessMessage(msg);
-                               }
-                               catch(Exception e)
-                               {
-                                       Console.WriteLine(e.Message);
-                               }
-                               
-                               return rtnMsg;
-                       }
-               }
-       } // end MyProxy
-       
-       // This class is used to create "CAO"
-       public class MarshalObjectFactory: MarshalByRefObject
-       {
-               public MarshalObject GetNewMarshalObject()
-               {
-                       return new MarshalObject();
-               }
-       }
-       
-       // A class used by the tests
-       public class MarshalObject: ContextBoundObject
-       {
-               public MarshalObject()
-               {
-                       
-               }
-               
-               public MarshalObject(int id, string uri)
-               {
-                       this.id = id;
-                       this.uri = uri;
-               }
-               public int Id
-               {
-                       get{return id;}
-                       set{id = value;}
-               }
-               public string Uri
-               {
-                       get{return uri;}
-               }
-               
-               public void Method1()
-               {
-                       _called++;
-                       methodOneWay = RemotingServices.IsOneWay(MethodBase.GetCurrentMethod());                        
-               }
-               
-               public void Method2()
-               {
-                       methodOneWay = RemotingServices.IsOneWay(MethodBase.GetCurrentMethod());                        
-               }
-               
-               public void Method2(int i)
-               {
-                       methodOneWay = RemotingServices.IsOneWay(MethodBase.GetCurrentMethod());                        
-                       
-               }
-               
-               [OneWay()]
-               public void Method3()
-               {
-                       methodOneWay = RemotingServices.IsOneWay(MethodBase.GetCurrentMethod());                        
-                       
-               }
-               
-               public static int Called
-               {
-                       get{return _called;}
-               }
-               
-               public static bool IsMethodOneWay
-               {
-                       get{return methodOneWay;}
-               }
-               
-               
-               private static int _called;
-               private int id = 0;
-               private string uri;
-               private static bool methodOneWay = false;
-       }
-       
-       // Another class used by the tests
-       public class DerivedMarshalObject: MarshalObject
-       {
-               public DerivedMarshalObject(){}
-               
-               public DerivedMarshalObject(int id, string uri): base(id, uri) {}
-       }
-} // namespace MonoTests.System.Runtime.Remoting.RemotingServicesInternal
-
-namespace MonoTests.System.Runtime.Remoting
-{
-       using MonoTests.System.Runtime.Remoting.RemotingServicesInternal;
-       
-       // The main test class
-       [TestFixture]
-       public class RemotingServicesTest 
-       {
-               private static int MarshalObjectId = 0;
-                       
-               public RemotingServicesTest()
-               {
-                       MarshalObjectId = 0;
-               }
-               
-               // Helper function that create a new
-               // MarshalObject with an unique ID
-               private static MarshalObject NewMarshalObject()
-               {
-                       string uri = "MonoTests.System.Runtime.Remoting.RemotingServicesTest.MarshalObject" + MarshalObjectId.ToString();
-                       MarshalObject objMarshal = new MarshalObject(MarshalObjectId, uri);
-                       
-                       MarshalObjectId++;
-                       
-                       return objMarshal;
-               }
-               
-               // Another helper function
-               private DerivedMarshalObject NewDerivedMarshalObject()
-               {
-                       string uri = "MonoTests.System.Runtime.Remoting.RemotingServicesTest.DerivedMarshalObject" + MarshalObjectId.ToString();
-                       DerivedMarshalObject objMarshal = new DerivedMarshalObject(MarshalObjectId, uri);
-                       
-                       MarshalObjectId++;
-                       
-                       return objMarshal;
-               }
-               
-               // The two folling method test RemotingServices.Marshal()
-               [Test]
-               public void Marshal1()
-               {
-                       
-                       MarshalObject objMarshal = NewMarshalObject();
-                       ObjRef objRef = RemotingServices.Marshal(objMarshal);
-                       
-                       Assert.IsTrue(objRef.URI != null, "#A01");
-                       
-                       MarshalObject objRem = (MarshalObject) RemotingServices.Unmarshal(objRef);
-                       Assert.AreEqual(objMarshal.Id, objRem.Id, "#A02");
-                       
-                       objRem.Id = 2;
-                       Assert.AreEqual(objMarshal.Id, objRem.Id, "#A03");
-                       
-                       // TODO: uncomment when RemotingServices.Disconnect is implemented
-                       //RemotingServices.Disconnect(objMarshal);
-                       
-                       objMarshal = NewMarshalObject();
-                       
-                       objRef = RemotingServices.Marshal(objMarshal, objMarshal.Uri);
-                       
-                       Assert.IsTrue(objRef.URI.EndsWith(objMarshal.Uri), "#A04");
-                       // TODO: uncomment when RemotingServices.Disconnect is implemented
-                       //RemotingServices.Disconnect(objMarshal);              
-               }
-               
-               [Test]
-               public void Marshal2()
-               {
-                       DerivedMarshalObject derivedObjMarshal = NewDerivedMarshalObject();
-                       
-                       ObjRef objRef = RemotingServices.Marshal(derivedObjMarshal, derivedObjMarshal.Uri, typeof(MarshalObject));
-                       
-                       // Check that the type of the marshaled object is MarshalObject
-                       Assert.IsTrue(objRef.TypeInfo.TypeName.StartsWith((typeof(MarshalObject)).ToString()), "#A05");
-                       
-                       // TODO: uncomment when RemotingServices.Disconnect is implemented
-                       //RemotingServices.Disconnect(derivedObjMarshal);
-               }
-               
-               // Tests RemotingServices.GetObjectUri()
-               [Test]
-               public void GetObjectUri()
-               {
-                       MarshalObject objMarshal = NewMarshalObject();
-                       
-                       Assert.IsTrue(RemotingServices.GetObjectUri(objMarshal) == null, "#A06");
-                       
-                       ObjRef objRef = RemotingServices.Marshal(objMarshal);
-                       
-                       Assert.IsTrue(RemotingServices.GetObjectUri(objMarshal) != null, "#A07");
-                       // TODO: uncomment when RemotingServices.Disconnect is implemented
-                       //RemotingServices.Disconnect(objMarshal);
-               }
-               
-               // Tests RemotingServices.Connect
-               [Test]
-               public void Connect()
-               {
-                       MarshalObject objMarshal = NewMarshalObject();
-                       
-                       IDictionary props = new Hashtable();
-                       props["name"] = objMarshal.Uri;
-                       props["port"] = 1236;
-                       TcpChannel chn = new TcpChannel(props, null, null);
-                       ChannelServices.RegisterChannel(chn);
-                       
-                       RemotingServices.Marshal(objMarshal,objMarshal.Uri);
-                       
-                       MarshalObject objRem = (MarshalObject) RemotingServices.Connect(typeof(MarshalObject), "tcp://localhost:1236/" + objMarshal.Uri);
-                       
-                       Assert.IsTrue(RemotingServices.IsTransparentProxy(objRem), "#A08");
-                       
-                       ChannelServices.UnregisterChannel(chn);
-                       
-                       // TODO: uncomment when RemotingServices.Disconnect is implemented
-                       //RemotingServices.Disconnect(objMarshal);
-               }
-               
-               // Tests RemotingServices.Marshal()
-               [Test]
-               [ExpectedException(typeof(RemotingException))]  
-               public void MarshalThrowException()
-               {
-                       MarshalObject objMarshal = NewMarshalObject();
-                       
-                       IDictionary props = new Hashtable();
-                       props["name"] = objMarshal.Uri;
-                       props["port"] = 1237;
-                       TcpChannel chn = new TcpChannel(props, null, null);
-                       ChannelServices.RegisterChannel(chn);
-                       
-                       RemotingServices.Marshal(objMarshal,objMarshal.Uri);
-                       
-                       MarshalObject objRem = (MarshalObject) RemotingServices.Connect(typeof(MarshalObject), "tcp://localhost:1237/" + objMarshal.Uri);
-                       // This line sould throw a RemotingException
-                       // It is forbidden to export an object which is not
-                       // a real object
-                       try
-                       {
-                               RemotingServices.Marshal(objRem, objMarshal.Uri);
-                       }
-                       catch(Exception e)
-                       {
-                               ChannelServices.UnregisterChannel(chn);
-                       
-                       // TODO: uncomment when RemotingServices.Disconnect is implemented
-                       //RemotingServices.Disconnect(objMarshal);
-                       
-                               throw e;
-                       }               
-               }
-               
-               // Tests RemotingServices.ExecuteMessage()
-               // also tests GetMethodBaseFromMessage()
-               // IsMethodOverloaded()
-               [Test]
-               public void ExecuteMessage()
-               {
-                       TcpChannel chn = null;
-                       try
-                       {
-                               chn = new TcpChannel(1235);
-                               ChannelServices.RegisterChannel(chn);
-                               
-                               MarshalObject objMarshal = NewMarshalObject();
-                               RemotingConfiguration.RegisterWellKnownServiceType(typeof(MarshalObject), objMarshal.Uri, WellKnownObjectMode.SingleCall);
-                               
-                               // use a proxy to catch the Message
-                               MyProxy proxy = new MyProxy(typeof(MarshalObject), (MarshalObject) Activator.GetObject(typeof(MarshalObject), "tcp://localhost:1235/" + objMarshal.Uri));
-                               
-                               MarshalObject objRem = (MarshalObject) proxy.GetTransparentProxy();
-                               
-                               objRem.Method1();
-                               
-                               // Tests RemotingServices.GetMethodBaseFromMethodMessage()
-                               AssertEquals("#A09","Method1",proxy.MthBase.Name);
-                               Assert.IsTrue(!proxy.IsMethodOverloaded, "#A09.1");
-                               
-                               objRem.Method2();
-                               Assert.IsTrue(proxy.IsMethodOverloaded, "#A09.2");
-                       
-                               // Tests RemotingServices.ExecuteMessage();
-                               // If ExecuteMessage does it job well, Method1 should be called 2 times
-                               Assert.AreEqual(2, MarshalObject.Called, "#A10");
-                       }
-                       finally
-                       {
-                               if(chn != null) ChannelServices.UnregisterChannel(chn);
-                       }
-               }
-               
-               // Tests the IsOneWay method
-               [Test]
-               public void IsOneWay()
-               {
-                       TcpChannel chn = null;
-                       try
-                       {
-                               chn = new TcpChannel(1238);
-                               ChannelServices.RegisterChannel(chn);
-                               RemotingConfiguration.RegisterWellKnownServiceType(typeof(MarshalObject), "MarshalObject.rem", WellKnownObjectMode.Singleton);
-                               
-                               MarshalObject objRem = (MarshalObject) Activator.GetObject(typeof(MarshalObject), "tcp://localhost:1238/MarshalObject.rem");
-                               
-                               Assert.IsTrue(RemotingServices.IsTransparentProxy(objRem), "#A10.1");
-                               
-                               objRem.Method1();
-                               Thread.Sleep(20);
-                               Assert.IsTrue(!MarshalObject.IsMethodOneWay, "#A10.2");
-                               objRem.Method3();
-                               Thread.Sleep(20);
-                               Assert.IsTrue(MarshalObject.IsMethodOneWay, "#A10.2");
-                       }
-                       finally
-                       {
-                               if(chn != null) ChannelServices.UnregisterChannel(chn);
-                       }
-               }
-               
-               [Test]
-               public void GetObjRefForProxy()
-               {
-                       TcpChannel chn = null;
-                       try
-                       {
-                               chn = new TcpChannel(1239);
-                               ChannelServices.RegisterChannel(chn);
-                               
-                               // Register le factory as a SAO
-                               RemotingConfiguration.RegisterWellKnownServiceType(typeof(MarshalObjectFactory), "MonoTests.System.Runtime.Remoting.RemotingServicesTest.Factory.soap", WellKnownObjectMode.Singleton);
-                               
-                               MarshalObjectFactory objFactory = (MarshalObjectFactory) Activator.GetObject(typeof(MarshalObjectFactory), "tcp://localhost:1239/MonoTests.System.Runtime.Remoting.RemotingServicesTest.Factory.soap");
-                               
-                               // Get a new "CAO"
-                               MarshalObject objRem = objFactory.GetNewMarshalObject();
-                               
-                               ObjRef objRefRem = RemotingServices.GetObjRefForProxy((MarshalByRefObject)objRem);
-                               
-                               Assert.IsTrue(objRefRem != null, "#A11");
-                       }
-                       finally
-                       {
-                               if(chn != null) ChannelServices.UnregisterChannel(chn);                         
-                       }
-               }
-               
-               // Tests GetRealProxy
-               [Test]
-               public void GetRealProxy()
-               {
-                       TcpChannel chn = null;
-                       try
-                       {
-                               chn = new TcpChannel(1241);
-                               ChannelServices.RegisterChannel(chn);
-                               
-                               RemotingConfiguration.RegisterWellKnownServiceType(typeof(MarshalObject), "MonoTests.System.Runtime.Remoting.RemotingServicesTest.MarshalObject.soap", WellKnownObjectMode.Singleton);
-                               
-                               MyProxy proxy = new  MyProxy(typeof(MarshalObject), (MarshalByRefObject)Activator.GetObject(typeof(MarshalObject), "tcp://localhost:1241/MonoTests.System.Runtime.Remoting.RemotingServicesTest.MarshalObject.soap"));
-                               MarshalObject objRem = (MarshalObject) proxy.GetTransparentProxy();
-                               
-                               RealProxy rp = RemotingServices.GetRealProxy(objRem);
-                               
-                               Assert.IsTrue(rp != null, "#A12");
-                               Assert.AreEqual("MonoTests.System.Runtime.Remoting.RemotingServicesInternal.MyProxy", rp.GetType().ToString(), "#A13");
-                       }
-                       finally
-                       {
-                               if(chn != null) ChannelServices.UnregisterChannel(chn);
-                       }
-               }
-               
-               // Tests SetObjectUriForMarshal()
-               [Test]
-               public void SetObjectUriForMarshal()
-               {
-                       TcpChannel chn = null;
-                       try
-                       {
-                               chn = new TcpChannel(1242);
-                               ChannelServices.RegisterChannel(chn);
-                               
-                               MarshalObject objRem = NewMarshalObject();
-                               RemotingServices.SetObjectUriForMarshal(objRem, objRem.Uri);
-                               RemotingServices.Marshal(objRem);
-                               
-                               objRem = (MarshalObject) Activator.GetObject(typeof(MarshalObject), "tcp://localhost:1242/"+objRem.Uri);
-                               Assert.IsTrue(objRem != null, "#A14");
-                       }
-                       finally
-                       {
-                               if(chn != null) ChannelServices.UnregisterChannel(chn);
-                       }                       
-                       
-               }
-               
-               // Tests GetServeurTypeForUri()
-               [Test]
-               public void GetServeurTypeForUri()
-               {
-                       TcpChannel chn = null;
-                       Type type = typeof(MarshalObject);
-                       try
-                       {
-                               chn = new TcpChannel(1243);
-                               ChannelServices.RegisterChannel(chn);
-                               
-                               MarshalObject objRem = NewMarshalObject();
-                               RemotingServices.SetObjectUriForMarshal(objRem, objRem.Uri);
-                               RemotingServices.Marshal(objRem);
-                               
-                               Type typeRem = RemotingServices.GetServerTypeForUri(RemotingServices.GetObjectUri(objRem));
-                               Assert.AreEqual(type, typeRem, "#A15");
-                       }
-                       finally
-                       {
-                               if(chn != null) ChannelServices.UnregisterChannel(chn);
-                       }                       
-               }
-               
-               // Tests IsObjectOutOfDomain
-               // Tests IsObjectOutOfContext
-               [Test]
-               public void IsObjectOutOf()
-               {
-                       TcpChannel chn = null;
-                       try
-                       {
-                               chn = new TcpChannel(1245);
-                               ChannelServices.RegisterChannel(chn);
-                               
-                               RemotingConfiguration.RegisterWellKnownServiceType(typeof(MarshalObject), "MarshalObject.rem", WellKnownObjectMode.Singleton);
-                               
-                               MarshalObject objRem = (MarshalObject) Activator.GetObject(typeof(MarshalObject), "tcp://localhost:1245/MarshalObject.rem");
-                               
-                               Assert.IsTrue(RemotingServices.IsObjectOutOfAppDomain(objRem), "#A16");
-                               Assert.IsTrue(RemotingServices.IsObjectOutOfContext(objRem), "#A17");
-                               
-                               MarshalObject objMarshal = new MarshalObject();
-                               Assert.IsTrue(!RemotingServices.IsObjectOutOfAppDomain(objMarshal), "#A18");
-                               Assert.IsTrue(!RemotingServices.IsObjectOutOfContext(objMarshal), "#A19");
-                       }
-                       finally
-                       {
-                               ChannelServices.UnregisterChannel(chn);
-                       }
-               }
-       } // end class RemotingServicesTest
-} // end of namespace MonoTests.System.Runtime.Remoting.RemotingServicesTest
index 63b58916eaee510654e48dace49a84ad71c09ea4..8b08b22c32e06a7e696c0b5243627340f0b82464 100644 (file)
@@ -33,7 +33,6 @@ System.Reflection.Emit/TypeBuilderTest.cs
 System.Reflection.Emit/SaveTest.cs
 System.Runtime.Remoting/ContextTest.cs
 System.Runtime.Remoting/RemotingConfigurationTest.cs
-System.Runtime.Remoting/RemotingServicesTest.cs
 System.Runtime.Remoting/SoapServicesTest.cs
 System.Runtime.Remoting/SynchronizationAttributeTest.cs
 System.Runtime.Remoting.Channels/ChannelServicesTest.cs
index 9871a3a8ad785d4ac9c359cf1fa99fc93c3c728f..405235b8d6f68db09990eb0da1ebb5f7fae045fb 100644 (file)
@@ -38,6 +38,7 @@ install-local:
        $(INSTALL_LIB) ../../../external/binary-reference-assemblies/v4.6.1/*.dll $(PROFILE_DIR)/4.6.1-api
        $(INSTALL_LIB) ../../../external/binary-reference-assemblies/v4.6.2/*.dll $(PROFILE_DIR)/4.6.2-api
        $(INSTALL_LIB) ../../../external/binary-reference-assemblies/v4.7/*.dll $(PROFILE_DIR)/4.7-api
+
        $(INSTALL_LIB) ../../../external/binary-reference-assemblies/v4.5/Facades/*.dll $(PROFILE_DIR)/4.5-api/Facades
        $(INSTALL_LIB) ../../../external/binary-reference-assemblies/v4.5.1/Facades/*.dll $(PROFILE_DIR)/4.5.1-api/Facades
        $(INSTALL_LIB) ../../../external/binary-reference-assemblies/v4.5.2/Facades/*.dll $(PROFILE_DIR)/4.5.2-api/Facades
@@ -46,6 +47,16 @@ install-local:
        $(INSTALL_LIB) ../../../external/binary-reference-assemblies/v4.6.2/Facades/*.dll $(PROFILE_DIR)/4.6.2-api/Facades
        $(INSTALL_LIB) ../../../external/binary-reference-assemblies/v4.7/Facades/*.dll $(PROFILE_DIR)/4.7-api/Facades
 
+       $(INSTALL_LIB) ../../../external/binary-reference-assemblies/mono/*.dll $(PROFILE_DIR)/2.0-api
+       $(INSTALL_LIB) ../../../external/binary-reference-assemblies/mono/*.dll $(PROFILE_DIR)/4.0-api
+       $(INSTALL_LIB) ../../../external/binary-reference-assemblies/mono/*.dll $(PROFILE_DIR)/4.5-api
+       $(INSTALL_LIB) ../../../external/binary-reference-assemblies/mono/*.dll $(PROFILE_DIR)/4.5.1-api
+       $(INSTALL_LIB) ../../../external/binary-reference-assemblies/mono/*.dll $(PROFILE_DIR)/4.5.2-api
+       $(INSTALL_LIB) ../../../external/binary-reference-assemblies/mono/*.dll $(PROFILE_DIR)/4.6-api
+       $(INSTALL_LIB) ../../../external/binary-reference-assemblies/mono/*.dll $(PROFILE_DIR)/4.6.1-api
+       $(INSTALL_LIB) ../../../external/binary-reference-assemblies/mono/*.dll $(PROFILE_DIR)/4.6.2-api
+       $(INSTALL_LIB) ../../../external/binary-reference-assemblies/mono/*.dll $(PROFILE_DIR)/4.7-api
+
        # Unfortunately, a few programs (most notably NUnit and FSharp) have hardcoded checks for <prefix>/lib/mono/4.0/mscorlib.dll or Mono.Posix.dll,
        # so we need to place something there or those tools break. We decided to symlink to the reference assembly for now.
        # See https://bugzilla.xamarin.com/show_bug.cgi?id=38331 and https://bugzilla.xamarin.com/show_bug.cgi?id=41052
@@ -71,6 +82,7 @@ DISTFILES =   \
        $(wildcard ../../../external/binary-reference-assemblies/v4.0/*.dll)    \
        $(wildcard ../../../external/binary-reference-assemblies/v3.5/*.dll)    \
        $(wildcard ../../../external/binary-reference-assemblies/v2.0/*.dll)    \
+       $(wildcard ../../../external/binary-reference-assemblies/mono/*.dll)    \
        $(wildcard ../../../external/binary-reference-assemblies/src/v4.7/Facades/*.cs) \
        $(wildcard ../../../external/binary-reference-assemblies/src/v4.6.2/Facades/*.cs)       \
        $(wildcard ../../../external/binary-reference-assemblies/src/v4.6.1/Facades/*.cs)       \
@@ -88,6 +100,7 @@ DISTFILES =  \
        $(wildcard ../../../external/binary-reference-assemblies/src/v4.0/*.cs) \
        $(wildcard ../../../external/binary-reference-assemblies/src/v3.5/*.cs) \
        $(wildcard ../../../external/binary-reference-assemblies/src/v2.0/*.cs) \
+       $(wildcard ../../../external/binary-reference-assemblies/src/mono/*.cs) \
        ../../../external/binary-reference-assemblies/v4.7/Makefile     \
        ../../../external/binary-reference-assemblies/v4.6.2/Makefile   \
        ../../../external/binary-reference-assemblies/v4.6.1/Makefile   \
@@ -98,6 +111,7 @@ DISTFILES =  \
        ../../../external/binary-reference-assemblies/v4.0/Makefile     \
        ../../../external/binary-reference-assemblies/v3.5/Makefile     \
        ../../../external/binary-reference-assemblies/v2.0/Makefile     \
+       ../../../external/binary-reference-assemblies/mono/Makefile     \
        ../../../external/binary-reference-assemblies/Makefile  \
        Makefile
 
index 7ebc1fc9c1512b54e5bf808c6ebde1908f659fac..9d5eb1140816690a5d1ab6c03e97b8a94935da32 100644 (file)
@@ -17,11 +17,12 @@ namespace MonoTests.Helpers {
                {
                        while (true) {
                                var ep = new IPEndPoint (IPAddress.Loopback, rndPort.Next (10000, 60000));
-                               var socket = new Socket (ep.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
 
                                try {
-                                       socket.Bind (ep);
-                                       socket.Close ();
+                                       using (var socket = new Socket (ep.AddressFamily, SocketType.Stream, ProtocolType.Tcp)) {
+                                               socket.Bind (ep);
+                                               socket.Close ();
+                                       }
                                        return ep;
                                } catch (SocketException) { }
                        }
index af7120dce5878fc481227faf290c186e52eb5662..fc2e213bc8730dfb332386dbb5b7447eab669dac 100644 (file)
@@ -53,6 +53,7 @@ namespace Mono.ILASM {
                        private bool keycontainer = false;
                        private string keyname;
                        private StrongName sn;
+                        bool noautoinherit;
 
                         public DriverMain (string[] args)
                         {
@@ -67,7 +68,7 @@ namespace Mono.ILASM {
                                 if (output_file == null)
                                         output_file = CreateOutputFilename ();
                                 try {
-                                        codegen = new CodeGen (output_file, target == Target.Dll, debugging_info);
+                                        codegen = new CodeGen (output_file, target == Target.Dll, debugging_info, noautoinherit);
                                         foreach (string file_path in il_file_list) {
                                                 Report.FilePath = file_path;
                                                 ProcessFile (file_path);
@@ -270,6 +271,9 @@ namespace Mono.ILASM {
                                                else
                                                        keyname = command_arg;
                                                break;
+                                        case "noautoinherit":
+                                                noautoinherit = true;
+                                                break;
                                         case "scan_only":
                                                 scan_only = true;
                                                 break;
@@ -336,16 +340,17 @@ namespace Mono.ILASM {
 
                         private void Usage ()
                         {
-                                Console.WriteLine ("Mono ILasm compiler\n" +
+                                Console.WriteLine ("Mono IL assembler compiler\n" +
                                         "ilasm [options] source-files\n" +
-                                        "   --about            About the Mono ILasm compiler\n" +
-                                        "   --version          Print the version number of the Mono ILasm compiler\n" +
+                                        "   --about            About the Mono IL assembler compiler\n" +
+                                        "   --version          Print the version number of the compiler\n" +
                                         "   /output:file_name  Specifies output file.\n" +
                                         "   /exe               Compile to executable.\n" +
                                         "   /dll               Compile to library.\n" +
                                         "   /debug             Include debug information.\n" +
                                        "   /key:keyfile       Strongname using the specified key file\n" +
                                        "   /key:@container    Strongname using the specified key container\n" +
+                                        "   /noautoinherit     Disable inheriting from System.Object by default\n" +
                                         "Options can be of the form -option or /option\n");
                                 Environment.Exit (1);
                         }
@@ -361,7 +366,7 @@ namespace Mono.ILASM {
                         private void Version ()
                         {
                                 string version = System.Reflection.Assembly.GetExecutingAssembly ().GetName ().Version.ToString ();
-                                Console.WriteLine ("Mono ILasm compiler version {0}", version);
+                                Console.WriteLine ("Mono IL assembler compiler version {0}", version);
                                 Environment.Exit (0);
                         }
 
index 6b9aadfc80ecd363d6e14baea059ba95c60e5d29..1d9ebe4b1ccee3a9220bdbe91356b2f89ee19096 100644 (file)
@@ -63,14 +63,16 @@ namespace Mono.ILASM {
                 private string output_file;\r
                 private bool is_dll;\r
                 private bool entry_point;\r
+                bool noautoinherit;\r
 \r
                 private Module this_module;\r
 \r
-                public CodeGen (string output_file, bool is_dll, bool debugging_info)\r
+                public CodeGen (string output_file, bool is_dll, bool debugging_info, bool noautoinherit)\r
                 {\r
                         this.output_file = output_file;\r
                         this.is_dll = is_dll;\r
-\r
+                        this.noautoinherit = noautoinherit;\r
+                        \r
                        if (debugging_info)\r
                                symwriter = new SymbolWriter (output_file);\r
 \r
@@ -313,7 +315,7 @@ namespace Mono.ILASM {
 \r
                         typedef = new TypeDef (attr, current_namespace,\r
                                         name, parent, impl_list, location, gen_params, outer);\r
-\r
+                        typedef.NoAutoInherit = noautoinherit && parent == null;\r
                         type_manager[cache_name] = typedef;\r
                         current_customattrtarget = current_typedef = typedef;\r
                         current_declsectarget = typedef;\r
index 74200cddf49e06d741e1bfdce3d04f019c0bb672..f35dca0bd4a4216d1a8a9f7cdca45ec62799c43c 100644 (file)
@@ -93,6 +93,8 @@ namespace Mono.ILASM {
                                 this.attr |= PEAPI.TypeAttr.Abstract;
                 }
 
+                               public bool NoAutoInherit { get; set; }
+
                 public string Name {
                         get { return name; }
                 }
@@ -389,7 +391,7 @@ namespace Mono.ILASM {
                                                         name_space, name);
                                         }
                                 }
-                                if (FullName == "System.Object")
+                                if (FullName == "System.Object" || NoAutoInherit)
                                         classdef.SpecialNoSuper ();
                         }
 
index 4c2a6cfd26dc4514426999c3eab5507d3d4ee9e5..a72cd9f0060d791b234405c2fefc8ba8b80e6b9e 100644 (file)
@@ -35,7 +35,7 @@
   <ItemGroup>
     <Reference Include="System" />
     <Reference Include="PEAPI">
-      <HintPath>..\class\lib\net_4_5\PEAPI.dll</HintPath>
+      <HintPath>..\class\lib\net_4_x\PEAPI.dll</HintPath>
     </Reference>
     <Reference Include="Mono.CompilerServices.SymbolWriter" />
     <Reference Include="Mono.Security" />
index c12eeaf978be47f106f6620198cbd223988e3ab2..b564427b568fa5956bc83bf9fee47d3c78750b79 100644 (file)
@@ -288,6 +288,7 @@ namespace Mono.ILASM {
 /* Keywords */\r
 %token K_AT\r
 %token K_AS\r
+%token K_AGGRESSIVEINLINING\r
 %token K_IMPLICITCOM\r
 %token K_IMPLICITRES\r
 %token K_NOAPPDOMAIN\r
@@ -2016,6 +2017,7 @@ impl_attr         : /* EMPTY */                   { $$ = new ImplAttr (); }
                        | impl_attr K_SYNCHRONIZED      { $$ = (ImplAttr) $1 | ImplAttr.Synchronised; }\r
                        | impl_attr K_NOINLINING        { $$ = (ImplAttr) $1 | ImplAttr.NoInLining; }\r
                        | impl_attr K_NOOPTIMIZATION    { $$ = (ImplAttr) $1 | ImplAttr.NoOptimization; }\r
+                       | impl_attr K_AGGRESSIVEINLINING{ $$ = (ImplAttr) $1 | ImplAttr.AggressiveInlining; }\r
                        ;\r
 \r
 sig_args               : /* EMPTY */\r
index fa13dd77c08bb451991546e419feb36d6031e719..9e62ebf638c5ddf57b0df1211211e09a5792a5b1 100644 (file)
@@ -321,6 +321,7 @@ namespace Mono.ILASM {
                                 keywords ["legacy"] = new ILToken (Token.K_LEGACY, "legacy");\r
                                 keywords ["library"] = new ILToken (Token.K_LIBRARY, "library");\r
                                 keywords ["auto"] = new ILToken (Token.K_AUTO, "auto");\r
+                                keywords ["aggressiveinlining"] = new ILToken (Token.K_AGGRESSIVEINLINING, "aggressiveinlining");\r
 \r
                                 return keywords;\r
                         }\r
index f3a7bb79b07a9c0edff9f97614d4b57f4b039f45..98083a7e0ec4b46803e1d2eb34a312883e7d7151 100644 (file)
@@ -346,7 +346,7 @@ namespace Mono.CSharp {
                void About ()
                {
                        output.WriteLine (
-                               "The Mono C# compiler is Copyright 2001-2011, Novell, Inc. 2011-2016 Xamarin Inc, 2016-2017 Microsoft Corp\n\n" +
+                               "The Turbo C# compiler is Copyright 2001-2011, Novell, Inc. 2011-2016 Xamarin Inc, 2016-2017 Microsoft Corp\n\n" +
                                "The compiler source code is released under the terms of the \n" +
                                "MIT X11 or GNU GPL licenses\n\n" +
 
@@ -1603,7 +1603,7 @@ namespace Mono.CSharp {
                void Usage ()
                {
                        output.WriteLine (
-                               "Mono C# compiler, Copyright 2001-2011 Novell, Inc., 2011-2016 Xamarin, Inc, 2016-2017 Microsoft Corp\n" +
+                               "Turbo C# compiler, Copyright 2001-2011 Novell, Inc., 2011-2016 Xamarin, Inc, 2016-2017 Microsoft Corp\n" +
                                "mcs [options] source-files\n" +
                                "   --about              About the Mono C# compiler\n" +
                                "   -addmodule:M1[,Mn]   Adds the module to the generated assembly\n" +
index 559c2f3ee43b32b2a6861129f397ea459fde7a11..bb7faf734df22e1fddf9404fac279a2a91619158 100644 (file)
@@ -234,15 +234,15 @@ namespace Mono.CSharp
                public static bool CheckOverrideName (TypeSpec type, TypeSpec baseType)
                {
                        var btype_ntuple = baseType as NamedTupleSpec;
-                       var mtype_ntupe = type as NamedTupleSpec;
-                       if (btype_ntuple == null && mtype_ntupe == null)
+                       var mtype_ntuple = type as NamedTupleSpec;
+                       if (btype_ntuple == null && mtype_ntuple == null)
                                return true;
 
-                       if (btype_ntuple != null || mtype_ntupe != null)
+                       if (btype_ntuple == null || mtype_ntuple == null)
                                return false;
 
                        var b_elements = btype_ntuple.elements;
-                       var m_elements = mtype_ntupe.elements;
+                       var m_elements = mtype_ntuple.elements;
                        for (int i = 0; i < b_elements.Count; ++i) {
                                if (b_elements [i] != m_elements [i])
                                        return false;
diff --git a/mcs/tests/test-tuple-06.cs b/mcs/tests/test-tuple-06.cs
new file mode 100644 (file)
index 0000000..64bb9b0
--- /dev/null
@@ -0,0 +1,19 @@
+class Base
+{
+       public virtual (int, long rest) Foo ()
+       {
+               return (1, 2);
+       }
+}
+
+class Test : Base
+{
+       public override (int, long rest) Foo ()
+       {
+               return (3, 4);
+       }
+
+       public static void Main ()
+       {       
+       }
+}
\ No newline at end of file
index d3c5c4ff729670f377698b2044e242d2abcefb1c..db5bfbd387c5090a47e7c7e01c8813a6cec6540e 100644 (file)
       </method>
     </type>
   </test>
+  <test name="test-tuple-06.cs">
+    <type name="Base">
+      <method name="System.ValueTuple`2[System.Int32,System.Int64] Foo()" attrs="454">
+        <size>17</size>
+      </method>
+      <method name="Void .ctor()" attrs="6278">
+        <size>7</size>
+      </method>
+    </type>
+    <type name="Test">
+      <method name="System.ValueTuple`2[System.Int32,System.Int64] Foo()" attrs="198">
+        <size>17</size>
+      </method>
+      <method name="Void Main()" attrs="150">
+        <size>2</size>
+      </method>
+      <method name="Void .ctor()" attrs="6278">
+        <size>7</size>
+      </method>
+    </type>
+  </test>
   <test name="test-var-01.cs">
     <type name="Test">
       <method name="Int32 Main()" attrs="150">
index 97cf6c6a240c6521ec1a7d23a6a0f5f70365a443..8680e0bbf8160f8f502a3705956eb7ebc06b88cb 100755 (executable)
@@ -135,7 +135,7 @@ class MakeBundle {
                                        return 1;
                                }
                                if (sdk_path != null || runtime != null)
-                                       Error ("You can not specify one of --runtime, --sdk or --cross");
+                                       Error ("You can only specify one of --runtime, --sdk or --cross");
                                custom_mode = false;
                                autodeps = true;
                                cross_target = args [++i];
@@ -213,7 +213,7 @@ class MakeBundle {
                                autodeps = true;
                                sdk_path = args [++i];
                                if (cross_target != null || runtime != null)
-                                       Error ("You can not specify one of --runtime, --sdk or --cross");
+                                       Error ("You can only specify one of --runtime, --sdk or --cross");
                                break;
                        case "--runtime":
                                if (i+1 == top){
@@ -624,6 +624,8 @@ class MakeBundle {
                        return false;
                }
                maker.Add (code, file);
+               // add a space after code (="systemconfig:" or "machineconfig:")
+               Console.WriteLine (code + " " + file);
                return true;
        }
        
@@ -659,15 +661,17 @@ class MakeBundle {
                        Console.WriteLine ("     Assembly: " + fname);
                        if (File.Exists (fname + ".config")){
                                maker.Add ("config:" + aname, fname + ".config");
-                               Console.WriteLine ("       Config: " + runtime);
+                               Console.WriteLine ("       Config: " + fname + ".config");
                        }
                }
                
                if (!MaybeAddFile (maker, "systemconfig:", config_file) || !MaybeAddFile (maker, "machineconfig:", machine_config_file))
                        return false;
 
-               if (config_dir != null)
+               if (config_dir != null){
                        maker.Add ("config_dir:", config_dir);
+                       Console.WriteLine ("   Config_dir: " + config_dir );
+               }
                if (embedded_options != null)
                        maker.AddString ("options:", embedded_options);
                if (environment.Count > 0){
index edf8c1283791bde051589c5199693cb6ad1014ba..c581a0c277dfa37def4d2823e3f03e023aefa09a 100644 (file)
 ../../../../external/nunit-lite/NUnitLite-1.0.0/src/framework/Internal/Commands/CommandStage.cs
 ../../../../external/nunit-lite/NUnitLite-1.0.0/src/framework/Internal/Commands/DelegatingTestCommand.cs
 ../../../../external/nunit-lite/NUnitLite-1.0.0/src/framework/Internal/Commands/ExpectedExceptionCommand.cs
+../../../../external/nunit-lite/NUnitLite-1.0.0/src/framework/Internal/Commands/FlakyTestRetriesCommand.cs
 ../../../../external/nunit-lite/NUnitLite-1.0.0/src/framework/Internal/Commands/ICommandDecorator.cs
 ../../../../external/nunit-lite/NUnitLite-1.0.0/src/framework/Internal/Commands/MaxTimeCommand.cs
 ../../../../external/nunit-lite/NUnitLite-1.0.0/src/framework/Internal/Commands/OneTimeSetUpCommand.cs
index 880eca2201cef39089aaac9d256265e4cd9a3de9..9c3750e213bc319bb3241a9c7934f59237b520db 100644 (file)
@@ -815,7 +815,7 @@ typedef struct {
 
 #define S390_RRE(c,opc,g1,g2)          s390_emit32(c, (opc << 16 | (g1) << 4 | g2)) 
 
-#define S390_RRF_1(c,opc,g1,g2,g3)     s390_emit32(c, (opc << 16 | (g1) << 12 | (g3) << 4 | g2))
+#define S390_RRF_1(c,opc,g1,g2,g3)     s390_emit32(c, (opc << 16 | (g3) << 12 | (g1) << 4 | g2))
 
 #define S390_RRF_2(c,opc,g1,k3,g2)     s390_emit32(c, (opc << 16 | (k3) << 12 | (g1) << 4 | g2))
 
@@ -881,9 +881,9 @@ typedef struct {
 
 #define S390_RIE_2(c,opc,g1,g2,m3,v) do                                \
 {                                                              \
-       s390_emit16(c, ((opc & 0xff00) | (g1) << 4 | g3));      \
+       s390_emit16(c, ((opc & 0xff00) | (g1) << 4 | g2));      \
        s390_emit16(c, (v));                                    \
-       s390_emit16(c, ((m2) << 12 | (opc & 0xff)));            \
+       s390_emit16(c, ((m3) << 12 | (opc & 0xff)));            \
 } while (0)
 
 #define S390_RIE_3(c,opc,g1,i,m3,d) do                         \
@@ -1131,15 +1131,16 @@ typedef struct {
 #define s390_agf(c, r, x, b, d)                S390_RXY(c, 0xe318, r, x, b, d)
 #define s390_agfi(c, r, v)             S390_RIL_1(c, 0xc28, r, v)
 #define s390_afgr(c, r1, r2)           S390_RRE(c, 0xb918, r1, r2)
+#define s390_agh(c, r, x, b, d)                S390_RXY(c, 0xe338, r, b, d)
 #define s390_aghi(c, r, v)             S390_RI(c, 0xa7b, r, v)
-#define s390_aghik(c, r, v)            S390_RIE_1(c, 0xecd9, r, v)
+#define s390_aghik(c, r1, r3, v)       S390_RIE_1(c, 0xecd9, r1, r3, v)
 #define s390_agr(c, r1, r2)            S390_RRE(c, 0xb908, r1, r2)
 #define s390_agrk(c, r1, r2, r3)       S390_RRF_1(c, 0xb9e8, r1, r2, r3)
 #define s390_agsi(c, r, v)             S390_SIY(c, 0xeb7a, r v)
 #define s390_ahhhr(c, r1, r2, r3)      S390_RRF_1(c, 0xb9c8, r1, r2, r3)
 #define s390_ahhlr(c, r1, r2, r3)      S390_RRF_1(c, 0xb9d8, r1, r2, r3)
 #define s390_ahi(c, r, v)              S390_RI(c, 0xa7a, r, v)
-#define s390_ahik(c, r, v)             S390_RIE_1(c, 0xecd8, r, v)
+#define s390_ahik(c, r1, r3, v)                S390_RIE_1(c, 0xecd8, r1, r3, v)
 #define s390_ahy(c, r, x, b, d)                S390_RXY(c, 0xe37a, r, b, d)
 #define s390_aih(c, r, v)              S390_RIL_1(c, 0xcc8, r, v)
 #define s390_al(c, r, x, b, d)         S390_RX(c, 0x5e, r, x, b, d)
@@ -1152,12 +1153,13 @@ typedef struct {
 #define s390_algf(c, r, x, b, d)       S390_RXY(c, 0xe31a, r, x, b, d)
 #define s390_algfi(c, r, v)            S390_RIL_1(c, 0xc2a, r, v)
 #define s390_algfr(c, r1, r2)          S390_RRE(c, 0xb91a, r1, r2)
-#define s390_alghsik(c, r, v)          S390_RIE_1(c, 0xecd8, r, v)
+#define s390_alghsik(c, r1, r3, v)     S390_RIE_1(c, 0xecdb, r1, r3, v)
 #define s390_algr(c, r1, r2)           S390_RRE(c, 0xb90a, r1, r2)
+#define s390_algrk(c, r1, r2, r3)      S390_RRF_1(c, 0xb9ea, r1, r2, r3)
 #define s390_algsi(c, d1, b1, i2)      S390_SIY_1(c, 0xeb7e, d1, b1, i2)
 #define s390_alhhhr(c, r1, r2, r3)     S390_RRF_1(c, 0xb9ca, r1, r2, r3)
 #define s390_alhhlr(c, r1, r2, r3)     S390_RRF_1(c, 0xb9da, r1, r2, r3)
-#define s390_alhsik(c, r, v)           S390_RIE_1(c, 0xecda, r, v)
+#define s390_alhsik(c, r1, r3, v)      S390_RIE_1(c, 0xecda, r1, r3, v)
 #define s390_alr(c, r1, r2)            S390_RR(c, 0x1e, r1, r2)
 #define s390_alrk(c, r1, r2)           S390_RRF(c, 0xb9fa, r1, r2)
 #define s390_alsi(c, d1, b1, i2)       S390_SIY_1(c, 0xeb6e, d1, b1, i2)
@@ -1172,6 +1174,8 @@ typedef struct {
 #define s390_basr(c, r1, r2)           S390_RR(c, 0x0d, r1, r2)
 #define s390_bctr(c, r1, r2)           S390_RR(c, 0x06, r1, r2)
 #define s390_bctrg(c, r1, r2)          S390_RRE(c, 0xb946, r1, r2)
+#define s390_bi(c, x, b, d)            S390_RXY(c, 0xe347, S390_CC_UN, x, b, d)
+#define s390_bic(c, m, x, b, d)                S390_RXY(c, 0xe347, m, x, b, d)
 #define s390_bnzr(c, r)                        S390_RR(c, 0x07, 0x07, r)
 #define s390_bras(c, r, o)             S390_RI(c, 0xa75, r, o)
 #define s390_brasl(c, r, o)            S390_RIL_1(c, 0xc05, r, o)
@@ -1262,8 +1266,10 @@ typedef struct {
 #define s390_je(c, d)                  s390_brc(c, S390_CC_EQ, d)
 #define s390_jeo(c, d)                 s390_brc(c, S390_CC_ZR|S390_CC_OV, d)
 #define s390_jh(c, d)                  s390_brc(c, S390_CC_GT, d)
+#define s390_jhe(c, d)                 s390_brc(c, S390_CC_GT|S390_CC_EQ, d)
 #define s390_jho(c, d)                 s390_brc(c, S390_CC_GT|S390_CC_OV, d)
 #define s390_jl(c, d)                  s390_brc(c, S390_CC_LT, d)
+#define s390_jle(c, d)                 s390_brc(c, S390_CC_LT|S390_CC_EQ, d)
 #define s390_jlo(c, d)                 s390_brc(c, S390_CC_LT|S390_CC_OV, d)
 #define s390_jm(c, d)                  s390_brc(c, S390_CC_LT, d)
 #define s390_jnc(c, d)                 s390_brc(c, S390_CC_NC, d)
@@ -1296,6 +1302,8 @@ typedef struct {
 #define s390_l(c, r, x, b, d)          S390_RX(c, 0x58, r, x, b, d)
 #define s390_ly(c, r, x, b, d)         S390_RXY(c, 0xe358, r, x, b, d)
 #define s390_la(c, r, x, b, d)         S390_RX(c, 0x41, r, x, b, d)
+#define s390_laa(c, r1, r3, b, d)      S390_RSY_1(c, 0xebf8, r1, r3, b, d)
+#define s390_laag(c, r1, r3, b, d)     S390_RSY_1(c, 0xebe8, r1, r3, b, d)
 #define s390_lay(c, r, x, b, d)                S390_RXY(c, 0xe371, r, x, b, d)
 #define s390_lam(c, r1, r2, b, d)      S390_RS_1(c, 0x9a, r1, r2, b, d)
 #define s390_larl(c, r, o)             S390_RIL_1(c, 0xc00, r, o)
@@ -1323,11 +1331,13 @@ typedef struct {
 #define s390_lgfi(c, r, v)             S390_RIL_1(c, 0xc01, r, v)
 #define s390_lgfrl(c, r1, d)           S390_RIL_1(c, 0xc4c, r1, d)
 #define s390_lgfr(c, r1, r2)           S390_RRE(c, 0xb914, r1, r2)
+#define s390_lgg(c, r, x, b, d)                S390_RXY(c, 0xe34c, r, x, b, d)
 #define s390_lgh(c, r, x, b, d)                S390_RXY(c, 0xe315, r, x, b, d)
 #define s390_lghi(c, r, v)             S390_RI(c, 0xa79, r, v)
 #define s390_lghr(c, r1, r2)           S390_RRE(c, 0xb907, r1, r2)
 #define s390_lgr(c, r1, r2)            S390_RRE(c, 0xb904, r1, r2)
 #define s390_lgrl(c, r1, d)            S390_RIL_1(c, 0xc48, r1, d)
+#define s390_lgsc(c, r, x, b, d)       S390_RXY(c, 0xe34d, r, x, b, d)
 #define s390_lh(c, r, x, b, d)         S390_RX(c, 0x48, r, x, b, d)
 #define s390_lhr(c, r1, r2)            S390_RRE(c, 0xb927, r1, r2)
 #define s390_lhg(c, r, x, b, d)                S390_RXY(c, 0xe315, r, x, b, d)
@@ -1340,6 +1350,7 @@ typedef struct {
 #define s390_llgfr(c, r1, r2)          S390_RRE(c, 0xb916, r1, r2)
 #define s390_llgh(c, r, x, b, d)       S390_RXY(c, 0xe391, r, x, b, d)
 #define s390_llghr(c, r1, r2)          S390_RRE(c, 0xb985, r1, r2)
+#define s390_llgfsg(c, r, x, b, d)     S390_RXY(c, 0xe348, r, x, b, d)
 #define s390_llhr(c, r1, r2)           S390_RRE(c, 0xb995, r1, r2)
 #define s390_llihf(c, r, v)            S390_RIL_1(c, 0xc0e, r, v)
 #define s390_llihh(c, r, v)            S390_RI(c, 0xa5c, r, v)
@@ -1357,6 +1368,8 @@ typedef struct {
 #define s390_lpr(c, r1, r2)            S390_RR(c, 0x10, r1, r2)
 #define s390_lr(c, r1, r2)             S390_RR(c, 0x18, r1, r2)
 #define s390_lrl(c, r1, d)             S390_RIL_1(c, 0xc4d, r1, d)
+#define s390_lt(c, r, x, b, d)         S390_RXY(c, 0xe312, r, x, b, d)
+#define s390_ltg(c, r, x, b, d)                S390_RXY(c, 0xe302, r, x, b, d)
 #define s390_ltgfr(c, r1, r2)          S390_RRE(c, 0xb912, r1, r2)
 #define s390_ltgr(c, r1, r2)           S390_RRE(c, 0xb902, r1, r2)
 #define s390_ltr(c, r1, r2)            S390_RR(c, 0x12, r1, r2)
@@ -1365,15 +1378,19 @@ typedef struct {
 #define s390_m(c, r, x, b, d)          S390_RX(c, 0x5c, r, x, b, d)
 #define s390_mdbr(c, r1, r2)           S390_RRE(c, 0xb31c, r1, r2)
 #define s390_meebr(c, r1, r2)          S390_RRE(c, 0xb317, r1, r2)
+#define s390_mg(c, r, x, b, d)         S390_RXY(c, 0xe384, r, x, b, d)
+#define s390_mgh(c, r, x, b, d)                S390_RXY(c, 0xe33c, r, x, b, d)
+#define s390_mgrk(c, r1, r2, r3)       S390_RRF_1(c, 0xb9ec, r1, r2, r3)
 #define s390_mfy(c, r, x, b, d)                S390_RXY(c, 0xe35c, r, x, b, d)
 #define s390_mlgr(c, r1, r2)           S390_RRE(c, 0xb986, r1, r2)
 #define s390_mlr(c, r1, r2)            S390_RRE(c, 0xb996, r1, r2)
 #define s390_mr(c, r1, r2)             S390_RR(c, 0x1c, r1, r2)
 #define s390_ms(c, r, x, b, d)         S390_RX(c, 0x71, r, x, b, d)
-#define s390_msi(c, r, v)              S390_RIL_1(c, 0xc21, r, v)
+#define s390_msfi(c, r, v)             S390_RIL_1(c, 0xc20, r, v)
+#define s390_msgfi(c, r, v)            S390_RIL_1(c, 0xc21, r, v)
 #define s390_msgfr(c, r1, r2)          S390_RRE(c, 0xb91c, r1, r2)
-#define s390_msgi(c, r, v)             S390_RIL_1(c, 0xc20, r, v)
 #define s390_msgr(c, r1, r2)           S390_RRE(c, 0xb90c, r1, r2)
+#define s390_msgrkc(c, r1, r2, r3)     S390_RRF_1(c, 0xb9ed, r1, r2, r3)
 #define s390_msr(c, r1, r2)            S390_RRE(c, 0xb252, r1, r2)
 #define s390_mvc(c, l, b1, d1, b2, d2) S390_SS_1(c, 0xd2, l, b1, d1, b2, d2)
 #define s390_mvcl(c, r1, r2)           S390_RR(c, 0x0e, r1, r2)
@@ -1407,6 +1424,7 @@ typedef struct {
 #define s390_oiy(c, b, d, v)           S390_SIY(c, 0xeb56 b, d, v) 
 #define s390_og(c, r, x, b, d)         S390_RXY(c, 0xe381, r, x, b, d)
 #define s390_ogr(c, r1, r2)            S390_RRE(c, 0xb981, r1, r2)
+#define s390_ogrk(c, r1, r2, r3)       S390_RRF_1(c, 0xb9e6, r1, r2, r3)
 #define s390_or(c, r1, r2)             S390_RR(c, 0x16, r1, r2)
 #define s390_s(c, r, x, b, d)          S390_RX(c, 0x5b, r, x, b, d)
 #define s390_sdb(c, r, x, b, d)                S390_RXE(c, 0xed1b, r, x, b, d)
@@ -1414,7 +1432,9 @@ typedef struct {
 #define s390_sebr(c, r1, r2)           S390_RRE(c, 0xb30b, r1, r2)
 #define s390_sg(c, r, x, b, d)         S390_RXY(c, 0xe309, r, x, b, d)
 #define s390_sgf(c, r, x, b, d)                S390_RXY(c, 0xe319, r, x, b, d)
+#define s390_sgh(c, r, x, b, d)                S390_RXY(c, 0xe339, r, x, b, d)
 #define s390_sgr(c, r1, r2)            S390_RRE(c, 0xb909, r1, r2)
+#define s390_sgrk(c, r1, r2, r3)       S390_RRF_1(c, 0xb9e9, r1, r2, r3)
 #define s390_sl(c, r, x, b, d)         S390_RX(c, 0x5f, r, x, b, d)
 #define s390_sla(c, r, b, d)           S390_RS_3(c, 0x8b, r, b, d) 
 #define s390_slag(c, r1, r2, b, d)     S390_RSY_1(c, 0xeb0b, r1, r2, b, d) 
@@ -1429,9 +1449,11 @@ typedef struct {
 #define s390_slgfr(c, r1, r2)          S390_RRE(c, 0xb91b, r1, r2)
 #define s390_slgfi(c, r, v)            S390_RIL_1(c, 0xc24, r, v)
 #define s390_slgr(c, r1, r2)           S390_RRE(c, 0xb90b, r1, r2)
+#define s390_slgrk(c, r1, r2, r3)      S390_RRF_1(c, 0xb9eb, r1, r2, r3)
 #define s390_sll(c, r, b, d)           S390_RS_3(c, 0x89, r, b, d) 
 #define s390_sllg(c, r1, r2, b, d)     S390_RSY_1(c, 0xeb0d, r1, r2, b, d) 
 #define s390_slr(c, r1, r2)            S390_RR(c, 0x1f, r1, r2)
+#define s390_slrk(c, r1, r2, r3)       S390_RRF_1(c, 0xb9fb, r1, r2, r3)
 #define s390_sqdbr(c, r1, r2)          S390_RRE(c, 0xb315, r1, r2)
 #define s390_sqebr(c, r1, r2)          S390_RRE(c, 0xb314, r1, r2)
 #define s390_sra(c, r, b, d)           S390_RS_3(c, 0x8a, r, b, d) 
@@ -1439,6 +1461,7 @@ typedef struct {
 #define s390_sr(c, r1, r2)             S390_RR(c, 0x1b, r1, r2)
 #define s390_srda(c, r, b, d)          S390_RS_3(c, 0x8e, r, b, d) 
 #define s390_srdl(c, r, b, d)          S390_RS_3(c, 0x8c, r, b, d) 
+#define s390_srk(c, r1, r2, r3)                S390_RRF_1(c, 0xb9f9, r1, r2, r3)
 #define s390_srl(c, r, b, d)           S390_RS_3(c, 0x88, r, b, d) 
 #define s390_srlg(c, r1, r2, b, d)     S390_RSY_1(c, 0xeb0c, r1, r2, b, d) 
 #define s390_st(c, r, x, b, d)         S390_RX(c, 0x50, r, x, b, d)
@@ -1453,6 +1476,7 @@ typedef struct {
 #define s390_stey(c, r, x, b, d)       S390_RXY(c, 0xed66, r, x, b, d)
 #define s390_stfpc(c, b, d)            S390_S(c, 0xb29c, b, d)
 #define s390_stg(c, r, x, b, d)                S390_RXY(c, 0xe324, r, x, b, d)
+#define s390_stgsc(c, r, x, b, d)      S390_RXY(c, 0xe349, r, x, b, d)
 #define s390_sth(c, r, x, b, d)                S390_RX(c, 0x40, r, x, b, d)
 #define s390_sthy(c, r, x, b, d)       S390_RXY(c, 0xe370, r, x, b, d)
 #define s390_stm(c, r1, r2, b, d)      S390_RS_1(c, 0x90, r1, r2, b, d)
@@ -1470,6 +1494,7 @@ typedef struct {
 #define s390_xilf(c, r, v)             S390_RIL_1(c, 0xc07, r, v)
 #define s390_xg(c, r, x, b, d)         S390_RXY(c, 0xe382, r, x, b, d)
 #define s390_xgr(c, r1, r2)            S390_RRE(c, 0xb982, r1, r2)
+#define s390_xgrk(c, r1, r2, r3)       S390_RRF_1(c, 0xb9e7, r1, r2, r3)
 #define s390_xr(c, r1, r2)             S390_RR(c, 0x17, r1, r2)
 #define s390_xy(c, r, x, b, d)         S390_RXY(c, 0xe357, r, x, b, d)
 #endif
index 17291b5c585e18cd0f11e2c2b4f8bb8c01766776..6a40f63fdf63d05893ee5ec9e90fee8df1bc75fb 100644 (file)
@@ -223,3 +223,16 @@ mono_btls_ssl_get_server_name (MonoBtlsSsl *ptr)
 {
        return SSL_get_servername (ptr->ssl, TLSEXT_NAMETYPE_host_name);
 }
+
+MONO_API void
+mono_btls_ssl_set_renegotiate_mode (MonoBtlsSsl *ptr, MonoBtlsSslRenegotiateMode mode)
+{
+    SSL_set_renegotiate_mode (ptr->ssl, (enum ssl_renegotiate_mode_t)mode);
+}
+
+MONO_API int
+mono_btls_ssl_renegotiate_pending (MonoBtlsSsl *ptr)
+{
+    return SSL_renegotiate_pending (ptr->ssl);
+}
+
index ac93c114995fee4bdf6f24f6c838158ca34aee4c..cb4ddd77dc0fbab029c00b0f4ccff24964bf951e 100644 (file)
@@ -86,6 +86,19 @@ mono_btls_ssl_set_server_name (MonoBtlsSsl *ptr, const char *name);
 const char *
 mono_btls_ssl_get_server_name (MonoBtlsSsl *ptr);
 
+typedef enum {
+    MONO_BTLS_SSL_RENEGOTIATE_NEVER = 0,
+    MONO_BTLS_SSL_RENEGOTIATE_ONCE,
+    MONO_BTLS_SSL_RENEGOTIATE_FREELY,
+    MONO_BTLS_SSL_RENEGOTIATE_IGNORE
+} MonoBtlsSslRenegotiateMode;
+
+void
+mono_btls_ssl_set_renegotiate_mode (MonoBtlsSsl *ptr, MonoBtlsSslRenegotiateMode mode);
+
+int
+mono_btls_ssl_renegotiate_pending (MonoBtlsSsl *ptr);
+
 void
 mono_btls_ssl_destroy (MonoBtlsSsl *ptr);
 
index ab1fbb483bd53d995c6b86f216655563cfc2b757..c213c8823ff1d8ba2858b1b70ad78b6f4baaf79d 100644 (file)
@@ -87,6 +87,6 @@ g_mkdtemp (char *tmp_template)
 
        return mkdtemp (template_copy);
 #else
-       g_error("Function not supported");
+       g_error("Function mkdtemp not supported");
 #endif
 }
index 949ef88d39ffc5baff221917ba6a3c32e14801ce..e8a76e429cccd7ab887be324e7aa855ab3ef0eae 100644 (file)
 
 #include <errno.h>
 
-/*
- *  Linux knows two different versions of strerror_r () that can only be distinguished
- *  by using feature test macros.  Please check the man pages for more details.
- */
-#if defined (_POSIX_C_SOURCE) && defined (_GNU_SOURCE)
-#if (_POSIX_C_SOURCE >= 200112L) && !_GNU_SOURCE
-#define USE_STRERROR_R_XSI
-#endif
-#endif
-
 /* 
  * g_strndup and g_vasprintf need to allocate memory with g_malloc if 
  * ENABLE_OVERRIDABLE_ALLOCATORS is defined so that it can be safely freed with g_free 
@@ -244,7 +234,7 @@ g_strerror (gint errnum)
                size_t buff_len = sizeof (tmp_buff);
                buff [0] = 0;
 
-#ifdef USE_STRERROR_R_XSI
+#ifndef STRERROR_R_CHAR_P
                int r;
                while ((r = strerror_r (errnum, buff, buff_len - 1))) {
                        if (r != ERANGE) {
@@ -262,12 +252,11 @@ g_strerror (gint errnum)
                        error_messages [errnum] = g_strdup (buff);
                if (buff != tmp_buff)
                        g_free (buff);
-#else /* USE_STRERROR_R_XSI */
-               int r;
-               r = strerror_r (errnum, buff, buff_len);
+#else /* STRERROR_R_CHAR_P */
+               buff = strerror_r (errnum, buff, buff_len);
                if (!error_messages [errnum])
                        error_messages [errnum] = g_strdup (buff);
-#endif /* USE_STRERROR_R_XSI */
+#endif /* STRERROR_R_CHAR_P */
 
 #else /* HAVE_STRERROR_R */
                if (!error_messages [errnum])
index a93f04a867d0512a93bd8aafd49c19656eea153c..482a7425d030caa2a41fde1ec756c1aa187c35ee 100644 (file)
@@ -36,6 +36,7 @@
 #include <mono/utils/mono-os-mutex.h>
 #include <mono/utils/mono-counters.h>
 #include <mono/utils/mono-compiler.h>
+#include <mono/utils/unlocked.h>
 
 #if HAVE_BOEHM_GC
 
@@ -277,7 +278,7 @@ void
 mono_gc_collect (int generation)
 {
 #ifndef DISABLE_PERFCOUNTERS
-       mono_perfcounters->gc_induced++;
+       InterlockedIncrement (&mono_perfcounters->gc_induced);
 #endif
        GC_gcollect ();
 }
@@ -456,7 +457,7 @@ on_gc_notification (GC_EventType event)
                MONO_GC_BEGIN (1);
 #ifndef DISABLE_PERFCOUNTERS
                if (mono_perfcounters)
-                       mono_perfcounters->gc_collections0++;
+                       InterlockedIncrement (&mono_perfcounters->gc_collections0);
 #endif
                InterlockedIncrement (&gc_stats.major_gc_count);
                gc_start_time = mono_100ns_ticks ();
@@ -476,13 +477,14 @@ on_gc_notification (GC_EventType event)
                if (mono_perfcounters) {
                        guint64 heap_size = GC_get_heap_size ();
                        guint64 used_size = heap_size - GC_get_free_bytes ();
-                       mono_perfcounters->gc_total_bytes = used_size;
-                       mono_perfcounters->gc_committed_bytes = heap_size;
-                       mono_perfcounters->gc_reserved_bytes = heap_size;
-                       mono_perfcounters->gc_gen0size = heap_size;
+                       /* FIXME: change these to InterlockedWrite64 () */
+                       UnlockedWrite64 (&mono_perfcounters->gc_total_bytes, used_size);
+                       UnlockedWrite64 (&mono_perfcounters->gc_committed_bytes, heap_size);
+                       UnlockedWrite64 (&mono_perfcounters->gc_reserved_bytes, heap_size);
+                       UnlockedWrite64 (&mono_perfcounters->gc_gen0size, heap_size);
                }
 #endif
-               InterlockedAdd64 (&gc_stats.major_gc_time, mono_100ns_ticks () - gc_start_time);
+               UnlockedAdd64 (&gc_stats.major_gc_time, mono_100ns_ticks () - gc_start_time);
                mono_trace_message (MONO_TRACE_GC, "gc took %" G_GINT64_FORMAT " usecs", (mono_100ns_ticks () - gc_start_time) / 10);
                break;
        default:
@@ -521,9 +523,10 @@ on_gc_heap_resize (size_t new_size)
        guint64 heap_size = GC_get_heap_size ();
 #ifndef DISABLE_PERFCOUNTERS
        if (mono_perfcounters) {
-               mono_perfcounters->gc_committed_bytes = heap_size;
-               mono_perfcounters->gc_reserved_bytes = heap_size;
-               mono_perfcounters->gc_gen0size = heap_size;
+               /* FIXME: change these to InterlockedWrite64 () */
+               UnlockedWrite64 (&mono_perfcounters->gc_committed_bytes, heap_size);
+               UnlockedWrite64 (&mono_perfcounters->gc_reserved_bytes, heap_size);
+               UnlockedWrite64 (&mono_perfcounters->gc_gen0size, heap_size);
        }
 #endif
 
@@ -1735,7 +1738,7 @@ alloc_handle (HandleData *handles, MonoObject *obj, gboolean track)
        }
 
 #ifndef DISABLE_PERFCOUNTERS
-       mono_perfcounters->gc_num_handles++;
+       InterlockedIncrement (&mono_perfcounters->gc_num_handles);
 #endif
        unlock_handles (handles);
        res = MONO_GC_HANDLE (slot, handles->type);
@@ -1933,7 +1936,7 @@ mono_gchandle_free (guint32 gchandle)
                /* print a warning? */
        }
 #ifndef DISABLE_PERFCOUNTERS
-       mono_perfcounters->gc_num_handles--;
+       InterlockedDecrement (&mono_perfcounters->gc_num_handles);
 #endif
        /*g_print ("freed entry %d of type %d\n", slot, handles->type);*/
        unlock_handles (handles);
index 67f360e975e3bd44ed0f3f8213170d341c133904..2b3a0b42aa31a9359c2bd01ed41803e6beda8942 100644 (file)
@@ -792,78 +792,78 @@ typedef struct {
  */
 typedef struct {
        /* JIT category */
-       guint32 jit_methods;
-       guint32 jit_bytes;
-       guint32 jit_time;
-       guint32 jit_failures;
+       gint32 jit_methods;
+       gint32 jit_bytes;
+       gint32 jit_time;
+       gint32 jit_failures;
        /* Exceptions category */
-       guint32 exceptions_thrown;
-       guint32 exceptions_filters;
-       guint32 exceptions_finallys;
-       guint32 exceptions_depth;
-       guint32 aspnet_requests_queued;
-       guint32 aspnet_requests;
+       gint32 exceptions_thrown;
+       gint32 exceptions_filters;
+       gint32 exceptions_finallys;
+       gint32 exceptions_depth;
+       gint32 aspnet_requests_queued;
+       gint32 aspnet_requests;
        /* Memory category */
-       guint32 gc_collections0;
-       guint32 gc_collections1;
-       guint32 gc_collections2;
-       guint32 gc_promotions0;
-       guint32 gc_promotions1;
-       guint32 gc_promotion_finalizers;
-       guint32 gc_gen0size;
-       guint32 gc_gen1size;
-       guint32 gc_gen2size;
-       guint32 gc_lossize;
-       guint32 gc_fin_survivors;
-       guint32 gc_num_handles;
-       guint32 gc_allocated;
-       guint32 gc_induced;
-       guint32 gc_time;
-       guint32 gc_total_bytes;
-       guint32 gc_committed_bytes;
-       guint32 gc_reserved_bytes;
-       guint32 gc_num_pinned;
-       guint32 gc_sync_blocks;
+       gint32 gc_collections0;
+       gint32 gc_collections1;
+       gint32 gc_collections2;
+       gint32 gc_promotions0;
+       gint32 gc_promotions1;
+       gint32 gc_promotion_finalizers;
+       gint64 gc_gen0size;
+       gint64 gc_gen1size;
+       gint64 gc_gen2size;
+       gint32 gc_lossize;
+       gint32 gc_fin_survivors;
+       gint32 gc_num_handles;
+       gint32 gc_allocated;
+       gint32 gc_induced;
+       gint32 gc_time;
+       gint64 gc_total_bytes;
+       gint64 gc_committed_bytes;
+       gint64 gc_reserved_bytes;
+       gint32 gc_num_pinned;
+       gint32 gc_sync_blocks;
        /* Remoting category */
-       guint32 remoting_calls;
-       guint32 remoting_channels;
-       guint32 remoting_proxies;
-       guint32 remoting_classes;
-       guint32 remoting_objects;
-       guint32 remoting_contexts;
+       gint32 remoting_calls;
+       gint32 remoting_channels;
+       gint32 remoting_proxies;
+       gint32 remoting_classes;
+       gint32 remoting_objects;
+       gint32 remoting_contexts;
        /* Loader category */
-       guint32 loader_classes;
-       guint32 loader_total_classes;
-       guint32 loader_appdomains;
-       guint32 loader_total_appdomains;
-       guint32 loader_assemblies;
-       guint32 loader_total_assemblies;
-       guint32 loader_failures;
-       guint32 loader_bytes;
-       guint32 loader_appdomains_uloaded;
+       gint32 loader_classes;
+       gint32 loader_total_classes;
+       gint32 loader_appdomains;
+       gint32 loader_total_appdomains;
+       gint32 loader_assemblies;
+       gint32 loader_total_assemblies;
+       gint32 loader_failures;
+       gint32 loader_bytes;
+       gint32 loader_appdomains_uloaded;
        /* Threads and Locks category  */
-       guint32 thread_contentions;
-       guint32 thread_queue_len;
-       guint32 thread_queue_max;
-       guint32 thread_num_logical;
-       guint32 thread_num_physical;
-       guint32 thread_cur_recognized;
-       guint32 thread_num_recognized;
+       gint32 thread_contentions;
+       gint32 thread_queue_len;
+       gint32 thread_queue_max;
+       gint32 thread_num_logical;
+       gint32 thread_num_physical;
+       gint32 thread_cur_recognized;
+       gint32 thread_num_recognized;
        /* Interop category */
-       guint32 interop_num_ccw;
-       guint32 interop_num_stubs;
-       guint32 interop_num_marshals;
+       gint32 interop_num_ccw;
+       gint32 interop_num_stubs;
+       gint32 interop_num_marshals;
        /* Security category */
-       guint32 security_num_checks;
-       guint32 security_num_link_checks;
-       guint32 security_time;
-       guint32 security_depth;
-       guint32 unused;
+       gint32 security_num_checks;
+       gint32 security_num_link_checks;
+       gint32 security_time;
+       gint32 security_depth;
+       gint32 unused;
        /* Threadpool */
-       guint64 threadpool_workitems;
-       guint64 threadpool_ioworkitems;
-       guint threadpool_threads;
-       guint threadpool_iothreads;
+       gint64 threadpool_workitems;
+       gint64 threadpool_ioworkitems;
+       gint32 threadpool_threads;
+       gint32 threadpool_iothreads;
 } MonoPerfCounters;
 
 extern MonoPerfCounters *mono_perfcounters;
index 6492fd6ca214bf232689e806cb2daac25bc5afb4..8df8cb531d4a88faed3a3591ff7afbd5a3a88453 100644 (file)
@@ -56,9 +56,9 @@ gboolean mono_print_vtable = FALSE;
 gboolean mono_align_small_structs = FALSE;
 
 /* Statistics */
-guint32 inflated_classes_size, inflated_methods_size;
-guint32 classes_size, class_ext_size, class_ext_count;
-guint32 class_def_count, class_gtd_count, class_ginst_count, class_gparam_count, class_array_count, class_pointer_count;
+gint32 inflated_classes_size, inflated_methods_size;
+gint32 classes_size;
+gint32 class_def_count, class_gtd_count, class_ginst_count, class_gparam_count, class_array_count, class_pointer_count;
 
 /* Low level lock which protects data structures in this module */
 static mono_mutex_t classes_mutex;
@@ -1092,7 +1092,7 @@ mono_class_inflate_generic_method_full_checked (MonoMethod *method, MonoClass *k
 
        UnlockedIncrement (&mono_stats.inflated_method_count);
 
-       inflated_methods_size += sizeof (MonoMethodInflated);
+       UnlockedAdd (&inflated_methods_size,  sizeof (MonoMethodInflated));
 
        sig = mono_method_signature (method);
        if (!sig) {
@@ -5511,7 +5511,7 @@ mono_class_set_failure_and_error (MonoClass *klass, MonoError *error, const char
  * Create the MonoClass* representing the specified type token.
  * \p type_token must be a TypeDef token.
  *
- * FIXME: don't return NULL on failure, just the the caller figure it out.
+ * FIXME: don't return NULL on failure, just let the caller figure it out.
  */
 static MonoClass *
 mono_class_create_from_typedef (MonoImage *image, guint32 type_token, MonoError *error)
@@ -5550,12 +5550,12 @@ mono_class_create_from_typedef (MonoImage *image, guint32 type_token, MonoError
        if (mono_metadata_has_generic_params (image, type_token)) {
                klass = mono_image_alloc0 (image, sizeof (MonoClassGtd));
                klass->class_kind = MONO_CLASS_GTD;
-               classes_size += sizeof (MonoClassGtd);
+               UnlockedAdd (&classes_size, sizeof (MonoClassGtd));
                ++class_gtd_count;
        } else {
                klass = mono_image_alloc0 (image, sizeof (MonoClassDef));
                klass->class_kind = MONO_CLASS_DEF;
-               classes_size += sizeof (MonoClassDef);
+               UnlockedAdd (&classes_size, sizeof (MonoClassDef));
                ++class_def_count;
        }
 
@@ -5994,8 +5994,8 @@ make_generic_param_class (MonoGenericParam *param, MonoGenericParamInfo *pinfo)
 
        klass = (MonoClass *)mono_image_alloc0 (image, sizeof (MonoClassGenericParam));
        klass->class_kind = MONO_CLASS_GPARAM;
-       classes_size += sizeof (MonoClassGenericParam);
-       ++class_gparam_count;
+       UnlockedAdd (&classes_size, sizeof (MonoClassGenericParam));
+       UnlockedIncrement (&class_gparam_count);
 
        if (pinfo) {
                CHECKED_METADATA_WRITE_PTR_EXEMPT ( klass->name , pinfo->name );
@@ -6274,7 +6274,7 @@ mono_ptr_class_get (MonoType *type)
        
        result = (MonoClass *)mono_image_alloc0 (image, sizeof (MonoClassPointer));
 
-       classes_size += sizeof (MonoClassPointer);
+       UnlockedAdd (&classes_size, sizeof (MonoClassPointer));
        ++class_pointer_count;
 
        result->parent = NULL; /* no parent for PTR types */
@@ -6364,7 +6364,7 @@ mono_fnptr_class_get (MonoMethodSignature *sig)
 
        MONO_PROFILER_RAISE (class_loading, (result));
 
-       classes_size += sizeof (MonoClassPointer);
+       UnlockedAdd (&classes_size, sizeof (MonoClassPointer));
        ++class_pointer_count;
 
        g_hash_table_insert (ptr_hash, sig, result);
@@ -6692,7 +6692,7 @@ mono_bounded_array_class_get (MonoClass *eclass, guint32 rank, gboolean bounded)
 
        MONO_PROFILER_RAISE (class_loading, (klass));
 
-       classes_size += sizeof (MonoClassArray);
+       UnlockedAdd (&classes_size, sizeof (MonoClassArray));
        ++class_array_count;
 
        if (rank == 1 && !bounded) {
@@ -9893,7 +9893,9 @@ mono_class_set_type_load_failure (MonoClass *klass, const char * fmt, ...)
  * mono_classes_init:
  *
  * Initialize the resources used by this module.
+ * Known racy counters: `class_gparam_count`, `classes_size` and `inflated_methods_size`
  */
+MONO_NO_SANITIZE_THREAD
 void
 mono_classes_init (void)
 {
index d57cb52796be252c94d86cffbbc96db8bab7167c..b00ab355d6ecd3c9736d316c0ba167fb3890a521 100644 (file)
@@ -640,14 +640,21 @@ mono_cominterop_cleanup (void)
 }
 
 void
-mono_mb_emit_cominterop_call (MonoMethodBuilder *mb, MonoMethodSignature *sig, MonoMethod* method)
+mono_mb_emit_cominterop_get_function_pointer (MonoMethodBuilder *mb, MonoMethod *method)
 {
 #ifndef DISABLE_JIT
        // get function pointer from 1st arg, the COM interface pointer
        mono_mb_emit_ldarg (mb, 0);
        mono_mb_emit_icon (mb, cominterop_get_com_slot_for_method (method));
        mono_mb_emit_icall (mb, cominterop_get_function_pointer);
+       /* Leaves the function pointer on top of the stack */
+#endif
+}
 
+void
+mono_mb_emit_cominterop_call_function_pointer (MonoMethodBuilder *mb, MonoMethodSignature *sig)
+{
+#ifndef DISABLE_JIT
        mono_mb_emit_byte (mb, MONO_CUSTOM_PREFIX);
        mono_mb_emit_byte (mb, CEE_MONO_SAVE_LMF);
        mono_mb_emit_calli (mb, sig);
@@ -656,6 +663,16 @@ mono_mb_emit_cominterop_call (MonoMethodBuilder *mb, MonoMethodSignature *sig, M
 #endif /* DISABLE_JIT */
 }
 
+void
+mono_mb_emit_cominterop_call (MonoMethodBuilder *mb, MonoMethodSignature *sig, MonoMethod* method)
+{
+#ifndef DISABLE_JIT
+       mono_mb_emit_cominterop_get_function_pointer (mb, method);
+
+       mono_mb_emit_cominterop_call_function_pointer (mb, sig);
+#endif /* DISABLE_JIT */
+}
+
 void
 mono_cominterop_emit_ptr_to_object_conv (MonoMethodBuilder *mb, MonoType *type, MonoMarshalConv conv, MonoMarshalSpec *mspec)
 {
index 04abc6e5fab1015ee3698302894f9f4abd5ac1b1..6f93ec191dfb1dc16b9b4c6d03a815fa5a01ad1c 100644 (file)
@@ -19,6 +19,12 @@ mono_cominterop_init (void);
 void
 mono_cominterop_cleanup (void);
 
+void
+mono_mb_emit_cominterop_get_function_pointer (MonoMethodBuilder *mb, MonoMethod* method);
+
+void
+mono_mb_emit_cominterop_call_function_pointer (MonoMethodBuilder *mb, MonoMethodSignature *sig);
+
 void
 mono_mb_emit_cominterop_call (MonoMethodBuilder *mb, MonoMethodSignature *sig, MonoMethod* method);
 
index de2a6970f73c52d51acec59ab9e4a6416549dab8..b0e7068104da81833aea19ca355510216da3032f 100644 (file)
@@ -430,8 +430,8 @@ mono_domain_create (void)
        mono_appdomains_unlock ();
 
 #ifndef DISABLE_PERFCOUNTERS
-       mono_perfcounters->loader_appdomains++;
-       mono_perfcounters->loader_total_appdomains++;
+       InterlockedIncrement (&mono_perfcounters->loader_appdomains);
+       InterlockedIncrement (&mono_perfcounters->loader_total_appdomains);
 #endif
 
        mono_debug_domain_create (domain);
@@ -1171,7 +1171,8 @@ mono_domain_free (MonoDomain *domain, gboolean force)
                mono_code_manager_invalidate (domain->code_mp);
        } else {
 #ifndef DISABLE_PERFCOUNTERS
-               mono_perfcounters->loader_bytes -= mono_mempool_get_allocated (domain->mp);
+               /* FIXME: use an explicit subtraction method as soon as it's available */
+               InterlockedAdd (&mono_perfcounters->loader_bytes, -1 * mono_mempool_get_allocated (domain->mp));
 #endif
                mono_mempool_destroy (domain->mp);
                domain->mp = NULL;
@@ -1218,7 +1219,7 @@ mono_domain_free (MonoDomain *domain, gboolean force)
        mono_gc_free_fixed (domain);
 
 #ifndef DISABLE_PERFCOUNTERS
-       mono_perfcounters->loader_appdomains--;
+       InterlockedDecrement (&mono_perfcounters->loader_appdomains);
 #endif
 
        if (domain == mono_root_domain)
@@ -1286,7 +1287,7 @@ mono_domain_alloc (MonoDomain *domain, guint size)
 
        mono_domain_lock (domain);
 #ifndef DISABLE_PERFCOUNTERS
-       mono_perfcounters->loader_bytes += size;
+       InterlockedAdd (&mono_perfcounters->loader_bytes, size);
 #endif
        res = mono_mempool_alloc (domain->mp, size);
        mono_domain_unlock (domain);
@@ -1306,7 +1307,7 @@ mono_domain_alloc0 (MonoDomain *domain, guint size)
 
        mono_domain_lock (domain);
 #ifndef DISABLE_PERFCOUNTERS
-       mono_perfcounters->loader_bytes += size;
+       InterlockedAdd (&mono_perfcounters->loader_bytes, size);
 #endif
        res = mono_mempool_alloc0 (domain->mp, size);
        mono_domain_unlock (domain);
index 4b1a56f4c0feeba858aca442d9e0ab057d7b1130..3c78b6153c23f4d56966de04b7c5dba586f11911 100644 (file)
@@ -995,7 +995,7 @@ mono_gc_cleanup (void)
                                        ret = guarded_wait (gc_thread->handle, MONO_INFINITE_WAIT, FALSE);
                                        g_assert (ret == MONO_THREAD_INFO_WAIT_RET_SUCCESS_0);
 
-                                       mono_thread_join (GUINT_TO_POINTER (gc_thread->tid));
+                                       mono_threads_add_joinable_thread (GUINT_TO_POINTER (gc_thread->tid));
                                        break;
                                }
 
@@ -1020,7 +1020,7 @@ mono_gc_cleanup (void)
 
                                        g_assert (ret == MONO_THREAD_INFO_WAIT_RET_SUCCESS_0);
 
-                                       mono_thread_join (GUINT_TO_POINTER (gc_thread->tid));
+                                       mono_threads_add_joinable_thread (GUINT_TO_POINTER (gc_thread->tid));
                                        break;
                                }
 
index ecd050a26e0469e29f4d71f42dce3c75fe5bdc7f..28615d8c1a986bb9eacb71051805387e20e365f0 100644 (file)
@@ -467,15 +467,15 @@ HANDLES(ICALL(SOCK_21, "IOControl_internal(intptr,int,byte[],byte[],int&)", ves_
 HANDLES(ICALL(SOCK_9, "Listen_internal(intptr,int,int&)", ves_icall_System_Net_Sockets_Socket_Listen_internal))
 HANDLES(ICALL(SOCK_10, "LocalEndPoint_internal(intptr,int,int&)", ves_icall_System_Net_Sockets_Socket_LocalEndPoint_internal))
 HANDLES(ICALL(SOCK_11, "Poll_internal", ves_icall_System_Net_Sockets_Socket_Poll_internal))
-HANDLES(ICALL(SOCK_13, "ReceiveFrom_internal(intptr,byte[],int,int,System.Net.Sockets.SocketFlags,System.Net.SocketAddress&,int&,bool)", ves_icall_System_Net_Sockets_Socket_ReceiveFrom_internal))
-HANDLES(ICALL(SOCK_11a, "Receive_internal(intptr,System.Net.Sockets.Socket/WSABUF[],System.Net.Sockets.SocketFlags,int&,bool)", ves_icall_System_Net_Sockets_Socket_Receive_array_internal))
-HANDLES(ICALL(SOCK_12, "Receive_internal(intptr,byte[],int,int,System.Net.Sockets.SocketFlags,int&,bool)", ves_icall_System_Net_Sockets_Socket_Receive_internal))
+HANDLES(ICALL(SOCK_13, "ReceiveFrom_internal(intptr,byte*,int,System.Net.Sockets.SocketFlags,System.Net.SocketAddress&,int&,bool)", ves_icall_System_Net_Sockets_Socket_ReceiveFrom_internal))
+HANDLES(ICALL(SOCK_11a, "Receive_internal(intptr,System.Net.Sockets.Socket/WSABUF*,int,System.Net.Sockets.SocketFlags,int&,bool)", ves_icall_System_Net_Sockets_Socket_Receive_array_internal))
+HANDLES(ICALL(SOCK_12, "Receive_internal(intptr,byte*,int,System.Net.Sockets.SocketFlags,int&,bool)", ves_icall_System_Net_Sockets_Socket_Receive_internal))
 HANDLES(ICALL(SOCK_14, "RemoteEndPoint_internal(intptr,int,int&)", ves_icall_System_Net_Sockets_Socket_RemoteEndPoint_internal))
 HANDLES(ICALL(SOCK_15, "Select_internal(System.Net.Sockets.Socket[]&,int,int&)", ves_icall_System_Net_Sockets_Socket_Select_internal))
 HANDLES(ICALL(SOCK_15a, "SendFile_internal(intptr,string,byte[],byte[],System.Net.Sockets.TransmitFileOptions,int&,bool)", ves_icall_System_Net_Sockets_Socket_SendFile_internal))
-HANDLES(ICALL(SOCK_16, "SendTo_internal(intptr,byte[],int,int,System.Net.Sockets.SocketFlags,System.Net.SocketAddress,int&,bool)", ves_icall_System_Net_Sockets_Socket_SendTo_internal))
-HANDLES(ICALL(SOCK_16a, "Send_internal(intptr,System.Net.Sockets.Socket/WSABUF[],System.Net.Sockets.SocketFlags,int&,bool)", ves_icall_System_Net_Sockets_Socket_Send_array_internal))
-HANDLES(ICALL(SOCK_17, "Send_internal(intptr,byte[],int,int,System.Net.Sockets.SocketFlags,int&,bool)", ves_icall_System_Net_Sockets_Socket_Send_internal))
+HANDLES(ICALL(SOCK_16, "SendTo_internal(intptr,byte*,int,System.Net.Sockets.SocketFlags,System.Net.SocketAddress,int&,bool)", ves_icall_System_Net_Sockets_Socket_SendTo_internal))
+HANDLES(ICALL(SOCK_16a, "Send_internal(intptr,System.Net.Sockets.Socket/WSABUF*,int,System.Net.Sockets.SocketFlags,int&,bool)", ves_icall_System_Net_Sockets_Socket_Send_array_internal))
+HANDLES(ICALL(SOCK_17, "Send_internal(intptr,byte*,int,System.Net.Sockets.SocketFlags,int&,bool)", ves_icall_System_Net_Sockets_Socket_Send_internal))
 HANDLES(ICALL(SOCK_18, "SetSocketOption_internal(intptr,System.Net.Sockets.SocketOptionLevel,System.Net.Sockets.SocketOptionName,object,byte[],int,int&)", ves_icall_System_Net_Sockets_Socket_SetSocketOption_internal))
 HANDLES(ICALL(SOCK_19, "Shutdown_internal(intptr,System.Net.Sockets.SocketShutdown,int&)", ves_icall_System_Net_Sockets_Socket_Shutdown_internal))
 HANDLES(ICALL(SOCK_20, "Socket_internal(System.Net.Sockets.AddressFamily,System.Net.Sockets.SocketType,System.Net.Sockets.ProtocolType,int&)", ves_icall_System_Net_Sockets_Socket_Socket_internal))
index 3f4dd249c6d1b189901384dd07c1e8868ac638e9..6ec372bbe9f2548318b6f68216c2658d8db43176 100644 (file)
@@ -2172,7 +2172,8 @@ mono_image_close_finish (MonoImage *image)
        mono_image_close_all (image->modules, image->module_count);
 
 #ifndef DISABLE_PERFCOUNTERS
-       mono_perfcounters->loader_bytes -= mono_mempool_get_allocated (image->mempool);
+       /* FIXME: use an explicit subtraction method as soon as it's available */
+       InterlockedAdd (&mono_perfcounters->loader_bytes, -1 * mono_mempool_get_allocated (image->mempool));
 #endif
 
        if (!image_is_dynamic (image)) {
@@ -2707,7 +2708,7 @@ mono_image_alloc (MonoImage *image, guint size)
        gpointer res;
 
 #ifndef DISABLE_PERFCOUNTERS
-       mono_perfcounters->loader_bytes += size;
+       InterlockedAdd (&mono_perfcounters->loader_bytes, size);
 #endif
        mono_image_lock (image);
        res = mono_mempool_alloc (image->mempool, size);
@@ -2722,7 +2723,7 @@ mono_image_alloc0 (MonoImage *image, guint size)
        gpointer res;
 
 #ifndef DISABLE_PERFCOUNTERS
-       mono_perfcounters->loader_bytes += size;
+       InterlockedAdd (&mono_perfcounters->loader_bytes, size);
 #endif
        mono_image_lock (image);
        res = mono_mempool_alloc0 (image->mempool, size);
@@ -2737,7 +2738,7 @@ mono_image_strdup (MonoImage *image, const char *s)
        char *res;
 
 #ifndef DISABLE_PERFCOUNTERS
-       mono_perfcounters->loader_bytes += strlen (s);
+       InterlockedAdd (&mono_perfcounters->loader_bytes, strlen (s));
 #endif
        mono_image_lock (image);
        res = mono_mempool_strdup (image->mempool, s);
@@ -2754,7 +2755,7 @@ mono_image_strdup_vprintf (MonoImage *image, const char *format, va_list args)
        buf = mono_mempool_strdup_vprintf (image->mempool, format, args);
        mono_image_unlock (image);
 #ifndef DISABLE_PERFCOUNTERS
-       mono_perfcounters->loader_bytes += strlen (buf);
+       InterlockedAdd (&mono_perfcounters->loader_bytes, strlen (buf));
 #endif
        return buf;
 }
index 0cd4e07b7395ddb3c828a725489412460d6fea31..85b5639384b1e70c1ac590fc5dd5d3108ea336d0 100644 (file)
@@ -62,10 +62,10 @@ static mono_mutex_t global_loader_data_mutex;
 static gboolean loader_lock_inited;
 
 /* Statistics */
-static guint32 inflated_signatures_size;
-static guint32 memberref_sig_cache_size;
-static guint32 methods_size;
-static guint32 signatures_size;
+static gint32 inflated_signatures_size;
+static gint32 memberref_sig_cache_size;
+static gint32 methods_size;
+static gint32 signatures_size;
 
 /*
  * This TLS variable holds how many times the current thread has acquired the loader 
@@ -75,7 +75,6 @@ MonoNativeTlsKey loader_lock_nest_id;
 
 static void dllmap_cleanup (void);
 
-
 static void
 global_loader_data_lock (void)
 {
@@ -164,7 +163,7 @@ cache_memberref_sig (MonoImage *image, guint32 sig_idx, gpointer sig)
        else {
                g_hash_table_insert (image->memberref_signatures, GUINT_TO_POINTER (sig_idx), sig);
                /* An approximation based on glib 2.18 */
-               memberref_sig_cache_size += sizeof (gpointer) * 4;
+               InterlockedAdd (&memberref_sig_cache_size, sizeof (gpointer) * 4);
        }
        mono_image_unlock (image);
 
@@ -725,7 +724,7 @@ mono_method_get_signature_checked (MonoMethod *method, MonoImage *image, guint32
                if (cached != sig)
                        mono_metadata_free_inflated_signature (sig);
                else
-                       inflated_signatures_size += mono_metadata_signature_size (cached);
+                       InterlockedAdd (&inflated_signatures_size, mono_metadata_signature_size (cached));
                sig = cached;
        }
 
@@ -1655,7 +1654,7 @@ mono_get_method_from_token (MonoImage *image, guint32 token, MonoClass *klass,
                result = (MonoMethod *)mono_image_alloc0 (image, sizeof (MonoMethodPInvoke));
        } else {
                result = (MonoMethod *)mono_image_alloc0 (image, sizeof (MonoMethod));
-               methods_size += sizeof (MonoMethod);
+               InterlockedAdd (&methods_size, sizeof (MonoMethod));
        }
 
        InterlockedIncrement (&mono_stats.method_count);
@@ -2394,7 +2393,7 @@ mono_method_signature_checked (MonoMethod *m, MonoError *error)
                if (!mono_error_ok (error))
                        return NULL;
 
-               inflated_signatures_size += mono_metadata_signature_size (signature);
+               InterlockedAdd (&inflated_signatures_size, mono_metadata_signature_size (signature));
 
                mono_image_lock (img);
 
@@ -2451,7 +2450,7 @@ mono_method_signature_checked (MonoMethod *m, MonoError *error)
                        mono_image_unlock (img);
                }
 
-               signatures_size += mono_metadata_signature_size (signature);
+               InterlockedAdd (&signatures_size, mono_metadata_signature_size (signature));
        }
 
        /* Verify metadata consistency */
index 63358bf3baff17983faf525d7d4c0fe1c9d5b5b1..05b23fddf3feae116697913694a6033b94c022df 100644 (file)
@@ -375,8 +375,8 @@ mono_marshal_init (void)
                register_icall (mono_marshal_free_asany, "mono_marshal_free_asany", "void object ptr int32 int32", FALSE);
                register_icall (ves_icall_marshal_alloc, "ves_icall_marshal_alloc", "ptr ptr", FALSE);
                register_icall (mono_marshal_free, "mono_marshal_free", "void ptr", FALSE);
-               register_icall (mono_marshal_set_last_error, "mono_marshal_set_last_error", "void", FALSE);
-               register_icall (mono_marshal_set_last_error_windows, "mono_marshal_set_last_error_windows", "void int32", FALSE);
+               register_icall (mono_marshal_set_last_error, "mono_marshal_set_last_error", "void", TRUE);
+               register_icall (mono_marshal_set_last_error_windows, "mono_marshal_set_last_error_windows", "void int32", TRUE);
                register_icall (mono_string_utf8_to_builder, "mono_string_utf8_to_builder", "void ptr ptr", FALSE);
                register_icall (mono_string_utf8_to_builder2, "mono_string_utf8_to_builder2", "object ptr", FALSE);
                register_icall (mono_string_utf16_to_builder, "mono_string_utf16_to_builder", "void ptr ptr", FALSE);
@@ -7658,6 +7658,9 @@ mono_marshal_emit_native_wrapper (MonoImage *image, MonoMethodBuilder *mb, MonoM
        int i, argnum, *tmp_locals;
        int type, param_shift = 0;
        int coop_gc_stack_dummy, coop_gc_var;
+#ifndef DISABLE_COM
+       int coop_cominterop_fnptr;
+#endif
 
        memset (&m, 0, sizeof (m));
        m.mb = mb;
@@ -7700,6 +7703,11 @@ mono_marshal_emit_native_wrapper (MonoImage *image, MonoMethodBuilder *mb, MonoM
                coop_gc_stack_dummy = mono_mb_add_local (mb, &mono_defaults.int_class->byval_arg);
                /* local 5, the local to be used when calling the suspend funcs */
                coop_gc_var = mono_mb_add_local (mb, &mono_defaults.int_class->byval_arg);
+#ifndef DISABLE_COM
+               if (!func_param && MONO_CLASS_IS_IMPORT (mb->method->klass)) {
+                       coop_cominterop_fnptr = mono_mb_add_local (mb, &mono_defaults.int_class->byval_arg);
+               }
+#endif
        }
 
        /*
@@ -7745,6 +7753,13 @@ mono_marshal_emit_native_wrapper (MonoImage *image, MonoMethodBuilder *mb, MonoM
                        mono_mb_emit_byte (mb, CEE_POP); // Result not needed yet
                }
 
+#ifndef DISABLE_COM
+               if (!func_param && MONO_CLASS_IS_IMPORT (mb->method->klass)) {
+                       mono_mb_emit_cominterop_get_function_pointer (mb, &piinfo->method);
+                       mono_mb_emit_stloc (mb, coop_cominterop_fnptr);
+               }
+#endif
+
                mono_mb_emit_ldloc_addr (mb, coop_gc_stack_dummy);
                mono_mb_emit_icall (mb, mono_threads_enter_gc_safe_region_unbalanced);
                mono_mb_emit_stloc (mb, coop_gc_var);
@@ -7767,7 +7782,12 @@ mono_marshal_emit_native_wrapper (MonoImage *image, MonoMethodBuilder *mb, MonoM
                mono_mb_emit_calli (mb, csig);
        } else if (MONO_CLASS_IS_IMPORT (mb->method->klass)) {
 #ifndef DISABLE_COM
-               mono_mb_emit_cominterop_call (mb, csig, &piinfo->method);
+               if (!mono_threads_is_blocking_transition_enabled ()) {
+                       mono_mb_emit_cominterop_call (mb, csig, &piinfo->method);
+               } else {
+                       mono_mb_emit_ldloc (mb, coop_cominterop_fnptr);
+                       mono_mb_emit_cominterop_call_function_pointer (mb, csig);
+               }
 #else
                g_assert_not_reached ();
 #endif
@@ -10936,6 +10956,9 @@ mono_marshal_string_to_utf16_copy (MonoString *s)
 void
 mono_marshal_set_last_error (void)
 {
+       /* This icall is called just after a P/Invoke call before the P/Invoke
+        * wrapper transitions the runtime back to running mode. */
+       MONO_REQ_GC_SAFE_MODE;
 #ifdef WIN32
        mono_native_tls_set_value (last_error_tls_id, GINT_TO_POINTER (GetLastError ()));
 #else
@@ -10947,6 +10970,9 @@ static void
 mono_marshal_set_last_error_windows (int error)
 {
 #ifdef WIN32
+       /* This icall is called just after a P/Invoke call before the P/Invoke
+        * wrapper transitions the runtime back to running mode. */
+       MONO_REQ_GC_SAFE_MODE;
        mono_native_tls_set_value (last_error_tls_id, GINT_TO_POINTER (error));
 #endif
 }
index 0ba52ce0b7359d578d94ed18991d85ce6a2cbb15..7b31abe9bb9637c1968439945d74662d64d00d04 100644 (file)
 #include <mono/utils/mono-error-internals.h>
 #include <mono/utils/bsearch.h>
 #include <mono/utils/atomic.h>
+#include <mono/utils/unlocked.h>
 #include <mono/utils/mono-counters.h>
 
-static int img_set_cache_hit, img_set_cache_miss, img_set_count;
+static gint32 img_set_cache_hit, img_set_cache_miss, img_set_count;
 
 
 /* Auxiliary structure used for caching inflated signatures */
@@ -2478,10 +2479,10 @@ img_set_cache_get (MonoImage **images, int nimages)
        int index = hash_code % HASH_TABLE_SIZE;
        MonoImageSet *img = img_set_cache [index];
        if (!img || !compare_img_set (img, images, nimages)) {
-               ++img_set_cache_miss;
+               UnlockedIncrement (&img_set_cache_miss);
                return NULL;
        }
-       ++img_set_cache_hit;
+       UnlockedIncrement (&img_set_cache_hit);
        return img;
 }
 
@@ -2566,7 +2567,7 @@ get_image_set (MonoImage **images, int nimages)
                l = l->next;
        }
 
-       // If we iterated all the way through l without breaking, the imageset does not already exist and we shuold create it
+       // If we iterated all the way through l without breaking, the imageset does not already exist and we should create it
        if (!l) {
                set = g_new0 (MonoImageSet, 1);
                set->nimages = nimages;
@@ -2583,7 +2584,7 @@ get_image_set (MonoImage **images, int nimages)
                        set->images [i]->image_sets = g_slist_prepend (set->images [i]->image_sets, set);
 
                g_ptr_array_add (image_sets, set);
-               ++img_set_count;
+               UnlockedIncrement (&img_set_count); /* locked by image_sets_lock () */
        }
 
        /* Cache the set. If there was a cache collision, the previously cached value will be replaced. */
index 702a47c654f285402c0cad5bb601f345e3a78ef1..c371f0f3c476c0e6756c97460e5c37e9cd3e1bc5 100644 (file)
@@ -373,7 +373,7 @@ mon_finalize (MonoThreadsSync *mon)
        mon->data = monitor_freelist;
        monitor_freelist = mon;
 #ifndef DISABLE_PERFCOUNTERS
-       mono_perfcounters->gc_sync_blocks--;
+       InterlockedDecrement (&mono_perfcounters->gc_sync_blocks);
 #endif
 }
 
@@ -445,7 +445,7 @@ mon_new (gsize id)
        new_->data = NULL;
        
 #ifndef DISABLE_PERFCOUNTERS
-       mono_perfcounters->gc_sync_blocks++;
+       InterlockedIncrement (&mono_perfcounters->gc_sync_blocks);
 #endif
        return new_;
 }
@@ -792,7 +792,7 @@ retry:
 
        /* The object must be locked by someone else... */
 #ifndef DISABLE_PERFCOUNTERS
-       mono_perfcounters->thread_contentions++;
+       InterlockedIncrement (&mono_perfcounters->thread_contentions);
 #endif
 
        /* If ms is 0 we don't block, but just fail straight away */
@@ -874,8 +874,8 @@ retry_contended:
        waitms = ms;
        
 #ifndef DISABLE_PERFCOUNTERS
-       mono_perfcounters->thread_queue_len++;
-       mono_perfcounters->thread_queue_max++;
+       InterlockedIncrement (&mono_perfcounters->thread_queue_len);
+       InterlockedIncrement (&mono_perfcounters->thread_queue_max);
 #endif
        thread = mono_thread_internal_current ();
 
@@ -909,7 +909,7 @@ retry_contended:
 
 done_waiting:
 #ifndef DISABLE_PERFCOUNTERS
-       mono_perfcounters->thread_queue_len--;
+       InterlockedDecrement (&mono_perfcounters->thread_queue_len);
 #endif
 
        if (wait_ret == MONO_SEM_TIMEDWAIT_RET_ALERTED && !allow_interruption) {
index c72b708532af58969d727a03353bda785727f477..3a4dbc89110f50d9e12e6100502fa7fa228b25f9 100644 (file)
@@ -59,18 +59,18 @@ PERFCTR_COUNTER(GC_PROM1, "Promoted Memory from Gen 1", "", NumberOfItems32, gc_
 PERFCTR_COUNTER(GC_PROM0SEC, "Gen 0 Promoted Bytes/Sec", "", RateOfCountsPerSecond32, gc_promotions0)
 PERFCTR_COUNTER(GC_PROM1SEC, "Gen 1 Promoted Bytes/Sec", "", RateOfCountsPerSecond32, gc_promotions1)
 PERFCTR_COUNTER(GC_PROMFIN, "Promoted Finalization-Memory from Gen 0", "", NumberOfItems32, gc_promotion_finalizers)
-PERFCTR_COUNTER(GC_GEN0SIZE, "Gen 0 heap size", "", NumberOfItems32, gc_gen0size)
-PERFCTR_COUNTER(GC_GEN1SIZE, "Gen 1 heap size", "", NumberOfItems32, gc_gen1size)
-PERFCTR_COUNTER(GC_GEN2SIZE, "Gen 2 heap size", "", NumberOfItems32, gc_gen2size)
+PERFCTR_COUNTER(GC_GEN0SIZE, "Gen 0 heap size", "", NumberOfItems64, gc_gen0size)
+PERFCTR_COUNTER(GC_GEN1SIZE, "Gen 1 heap size", "", NumberOfItems64, gc_gen1size)
+PERFCTR_COUNTER(GC_GEN2SIZE, "Gen 2 heap size", "", NumberOfItems64, gc_gen2size)
 PERFCTR_COUNTER(GC_LOSIZE, "Large Object Heap size", "", NumberOfItems32, gc_lossize)
 PERFCTR_COUNTER(GC_FINSURV, "Finalization Survivors", "", NumberOfItems32, gc_fin_survivors)
 PERFCTR_COUNTER(GC_NHANDLES, "# GC Handles", "", NumberOfItems32, gc_num_handles)
 PERFCTR_COUNTER(GC_BYTESSEC, "Allocated Bytes/sec", "", RateOfCountsPerSecond32, gc_allocated)
 PERFCTR_COUNTER(GC_INDGC, "# Induced GC", "", NumberOfItems32, gc_induced)
 PERFCTR_COUNTER(GC_PERCTIME, "% Time in GC", "", RawFraction, gc_time)
-PERFCTR_COUNTER(GC_BYTES, "# Bytes in all Heaps", "", NumberOfItems32, gc_total_bytes)
-PERFCTR_COUNTER(GC_COMMBYTES, "# Total committed Bytes", "", NumberOfItems32, gc_committed_bytes)
-PERFCTR_COUNTER(GC_RESBYTES, "# Total reserved Bytes", "", NumberOfItems32, gc_reserved_bytes)
+PERFCTR_COUNTER(GC_BYTES, "# Bytes in all Heaps", "", NumberOfItems64, gc_total_bytes)
+PERFCTR_COUNTER(GC_COMMBYTES, "# Total committed Bytes", "", NumberOfItems64, gc_committed_bytes)
+PERFCTR_COUNTER(GC_RESBYTES, "# Total reserved Bytes", "", NumberOfItems64, gc_reserved_bytes)
 PERFCTR_COUNTER(GC_PINNED, "# of Pinned Objects", "", NumberOfItems32, gc_num_pinned)
 PERFCTR_COUNTER(GC_SYNKB, "# of Sink Blocks in use", "", NumberOfItems32, gc_sync_blocks)
 
index f4ec3e34c2b9a8633eec90b1aa16bf6a02a9b7f6..1a3123a30aad58811bbf8d07c6d0581ac029474e 100644 (file)
@@ -48,6 +48,7 @@
 #include "utils/mono-networkinterfaces.h"
 #include "utils/mono-error-internals.h"
 #include "utils/atomic.h"
+#include "utils/unlocked.h"
 
 /* map of CounterSample.cs */
 struct _MonoCounterSample {
@@ -1073,52 +1074,52 @@ predef_writable_counter (ImplVtable *vtable, MonoBoolean only_value, MonoCounter
        case CATEGORY_EXC:
                switch (id) {
                case COUNTER_EXC_THROWN:
-                       sample->rawValue = mono_perfcounters->exceptions_thrown;
+                       sample->rawValue = InterlockedRead (&mono_perfcounters->exceptions_thrown);
                        return TRUE;
                }
                break;
        case CATEGORY_ASPNET:
                switch (id) {
                case COUNTER_ASPNET_REQ_Q:
-                       sample->rawValue = mono_perfcounters->aspnet_requests_queued;
+                       sample->rawValue = InterlockedRead (&mono_perfcounters->aspnet_requests_queued);
                        return TRUE;
                case COUNTER_ASPNET_REQ_TOTAL:
-                       sample->rawValue = mono_perfcounters->aspnet_requests;
+                       sample->rawValue = InterlockedRead (&mono_perfcounters->aspnet_requests);
                        return TRUE;
                }
                break;
        case CATEGORY_THREADPOOL:
                switch (id) {
                case COUNTER_THREADPOOL_WORKITEMS:
-                       sample->rawValue = mono_perfcounters->threadpool_workitems;
+                       sample->rawValue = InterlockedRead64 (&mono_perfcounters->threadpool_workitems);
                        return TRUE;
                case COUNTER_THREADPOOL_IOWORKITEMS:
-                       sample->rawValue = mono_perfcounters->threadpool_ioworkitems;
+                       sample->rawValue = InterlockedRead64 (&mono_perfcounters->threadpool_ioworkitems);
                        return TRUE;
                case COUNTER_THREADPOOL_THREADS:
-                       sample->rawValue = mono_perfcounters->threadpool_threads;
+                       sample->rawValue = InterlockedRead (&mono_perfcounters->threadpool_threads);
                        return TRUE;
                case COUNTER_THREADPOOL_IOTHREADS:
-                       sample->rawValue = mono_perfcounters->threadpool_iothreads;
+                       sample->rawValue = InterlockedRead (&mono_perfcounters->threadpool_iothreads);
                        return TRUE;
                }
                break;
        case CATEGORY_JIT:
                switch (id) {
                case COUNTER_JIT_BYTES:
-                       sample->rawValue = mono_perfcounters->jit_bytes;
+                       sample->rawValue = InterlockedRead (&mono_perfcounters->jit_bytes);
                        return TRUE;
                case COUNTER_JIT_METHODS:
-                       sample->rawValue = mono_perfcounters->jit_methods;
+                       sample->rawValue = InterlockedRead (&mono_perfcounters->jit_methods);
                        return TRUE;
                case COUNTER_JIT_TIME:
-                       sample->rawValue = mono_perfcounters->jit_time;
+                       sample->rawValue = InterlockedRead (&mono_perfcounters->jit_time);
                        return TRUE;
                case COUNTER_JIT_BYTES_PSEC:
-                       sample->rawValue = mono_perfcounters->jit_bytes;
+                       sample->rawValue = InterlockedRead (&mono_perfcounters->jit_bytes);
                        return TRUE;
                case COUNTER_JIT_FAILURES:
-                       sample->rawValue = mono_perfcounters->jit_failures;
+                       sample->rawValue = InterlockedRead (&mono_perfcounters->jit_failures);
                        return TRUE;
                }
                break;
@@ -1129,7 +1130,7 @@ predef_writable_counter (ImplVtable *vtable, MonoBoolean only_value, MonoCounter
 static gint64
 predef_writable_update (ImplVtable *vtable, MonoBoolean do_incr, gint64 value)
 {
-       guint32 *volatile ptr = NULL;
+       gint32 *volatile ptr = NULL;
        gint64 *volatile ptr64 = NULL;
        int cat_id = GPOINTER_TO_INT (vtable->arg);
        int id = cat_id >> 16;
@@ -1143,8 +1144,8 @@ predef_writable_update (ImplVtable *vtable, MonoBoolean do_incr, gint64 value)
                break;
        case CATEGORY_THREADPOOL:
                switch (id) {
-               case COUNTER_THREADPOOL_WORKITEMS: ptr64 = (gint64 *) &mono_perfcounters->threadpool_workitems; break;
-               case COUNTER_THREADPOOL_IOWORKITEMS: ptr64 = (gint64 *) &mono_perfcounters->threadpool_ioworkitems; break;
+               case COUNTER_THREADPOOL_WORKITEMS: ptr64 = &mono_perfcounters->threadpool_workitems; break;
+               case COUNTER_THREADPOOL_IOWORKITEMS: ptr64 = &mono_perfcounters->threadpool_ioworkitems; break;
                case COUNTER_THREADPOOL_THREADS: ptr = &mono_perfcounters->threadpool_threads; break;
                case COUNTER_THREADPOOL_IOTHREADS: ptr = &mono_perfcounters->threadpool_iothreads; break;
                }
@@ -1153,29 +1154,23 @@ predef_writable_update (ImplVtable *vtable, MonoBoolean do_incr, gint64 value)
        if (ptr) {
                if (do_incr) {
                        if (value == 1)
-                               return InterlockedIncrement ((gint32 *) ptr); /* FIXME: sign */
+                               return InterlockedIncrement (ptr);
                        if (value == -1)
-                               return InterlockedDecrement ((gint32 *) ptr); /* FIXME: sign */
+                               return InterlockedDecrement (ptr);
 
-                       *ptr += value;
-                       return *ptr;
+                       return InterlockedAdd(ptr, value);
                }
                /* this can be non-atomic */
                *ptr = value;
                return value;
        } else if (ptr64) {
                if (do_incr) {
-                       /* FIXME: we need to do this atomically */
-                       /* No InterlockedIncrement64() yet */
-                       /*
                        if (value == 1)
-                               return InterlockedIncrement64 (ptr);
+                               return UnlockedIncrement64 (ptr64); /* FIXME: use InterlockedIncrement64 () */
                        if (value == -1)
-                               return InterlockedDecrement64 (ptr);
-                       */
+                               return UnlockedDecrement64 (ptr64); /* FIXME: use InterlockedDecrement64 () */
 
-                       *ptr64 += value;
-                       return *ptr64;
+                       return UnlockedAdd64 (ptr64, value); /* FIXME: use InterlockedAdd64 () */
                }
                /* this can be non-atomic */
                *ptr64 = value;
index caa0616464d4863525c2d15b81333eec5005b611..8bad1701b2507b3ad65f2b4069118d09b2ebd23c 100644 (file)
@@ -220,7 +220,7 @@ alloc_handle (HandleData *handles, MonoObject *obj, gboolean track)
        }
 
 #ifndef DISABLE_PERFCOUNTERS
-       mono_perfcounters->gc_num_handles++;
+       InterlockedIncrement (&mono_perfcounters->gc_num_handles);
 #endif
        unlock_handles (handles);
        res = MONO_GC_HANDLE (slot, handles->type);
@@ -412,7 +412,7 @@ mono_gchandle_free (guint32 gchandle)
                /* print a warning? */
        }
 #ifndef DISABLE_PERFCOUNTERS
-       mono_perfcounters->gc_num_handles--;
+       InterlockedDecrement (&mono_perfcounters->gc_num_handles);
 #endif
        /*g_print ("freed entry %d of type %d\n", slot, handles->type);*/
        unlock_handles (handles);
index cef662c5b0c41c4d1268be3ff5ccd7c7963e01ef..2ea88c75f8cfde20ecb362453f027e16dbe1225a 100644 (file)
@@ -2565,7 +2565,7 @@ mono_remote_class (MonoDomain *domain, MonoStringHandle class_name, MonoClass *p
        rc->xdomain_vtable = NULL;
        rc->proxy_class_name = name;
 #ifndef DISABLE_PERFCOUNTERS
-       mono_perfcounters->loader_bytes += mono_string_length (MONO_HANDLE_RAW (class_name)) + 1;
+       InterlockedAdd (&mono_perfcounters->loader_bytes, mono_string_length (MONO_HANDLE_RAW (class_name)) + 1);
 #endif
 
        g_hash_table_insert (domain->proxy_vtable_hash, key, rc);
index a5ec02d480e21cb4477a3cf7e5f1eb4416465d0a..b163dcfee81dd909909271e3137a40a015113d9a 100644 (file)
@@ -297,9 +297,9 @@ sgen_client_binary_protocol_collection_begin (int minor_gc_count, int generation
 
 #ifndef DISABLE_PERFCOUNTERS
        if (generation == GENERATION_NURSERY)
-               mono_perfcounters->gc_collections0++;
+               InterlockedIncrement (&mono_perfcounters->gc_collections0);
        else
-               mono_perfcounters->gc_collections1++;
+               InterlockedIncrement (&mono_perfcounters->gc_collections1);
 #endif
 }
 
index 8604d9321a0aa47e35178ebb6013b3e48fb5cd6c..4cd30493fff80524e3b60b368623d7e2d35563c7 100644 (file)
@@ -2665,6 +2665,54 @@ sgen_client_metadata_for_object (GCObject *obj)
        return mono_object_domain (obj);
 }
 
+/**
+ * mono_gchandle_new:
+ * \param obj managed object to get a handle for
+ * \param pinned whether the object should be pinned
+ * This returns a handle that wraps the object, this is used to keep a
+ * reference to a managed object from the unmanaged world and preventing the
+ * object from being disposed.
+ * 
+ * If \p pinned is false the address of the object can not be obtained, if it is
+ * true the address of the object can be obtained.  This will also pin the
+ * object so it will not be possible by a moving garbage collector to move the
+ * object. 
+ * 
+ * \returns a handle that can be used to access the object from unmanaged code.
+ */
+guint32
+mono_gchandle_new (MonoObject *obj, gboolean pinned)
+{
+       return sgen_gchandle_new (obj, pinned);
+}
+
+/**
+ * mono_gchandle_new_weakref:
+ * \param obj managed object to get a handle for
+ * \param track_resurrection Determines how long to track the object, if this is set to TRUE, the object is tracked after finalization, if FALSE, the object is only tracked up until the point of finalization.
+ *
+ * This returns a weak handle that wraps the object, this is used to
+ * keep a reference to a managed object from the unmanaged world.
+ * Unlike the \c mono_gchandle_new the object can be reclaimed by the
+ * garbage collector.  In this case the value of the GCHandle will be
+ * set to zero.
+ * 
+ * If \p track_resurrection is TRUE the object will be tracked through
+ * finalization and if the object is resurrected during the execution
+ * of the finalizer, then the returned weakref will continue to hold
+ * a reference to the object.   If \p track_resurrection is FALSE, then
+ * the weak reference's target will become NULL as soon as the object
+ * is passed on to the finalizer.
+ * 
+ * \returns a handle that can be used to access the object from
+ * unmanaged code.
+ */
+guint32
+mono_gchandle_new_weakref (GCObject *obj, gboolean track_resurrection)
+{
+       return sgen_gchandle_new_weakref (obj, track_resurrection);
+}
+
 /**
  * mono_gchandle_is_in_domain:
  * \param gchandle a GCHandle's handle.
@@ -2678,6 +2726,20 @@ mono_gchandle_is_in_domain (guint32 gchandle, MonoDomain *domain)
        return domain->domain_id == gchandle_domain->domain_id;
 }
 
+/**
+ * mono_gchandle_free:
+ * \param gchandle a GCHandle's handle.
+ *
+ * Frees the \p gchandle handle.  If there are no outstanding
+ * references, the garbage collector can reclaim the memory of the
+ * object wrapped. 
+ */
+void
+mono_gchandle_free (guint32 gchandle)
+{
+       sgen_gchandle_free (gchandle);
+}
+
 /**
  * mono_gchandle_free_domain:
  * \param unloading domain that is unloading
@@ -2690,6 +2752,22 @@ mono_gchandle_free_domain (MonoDomain *unloading)
 {
 }
 
+/**
+ * mono_gchandle_get_target:
+ * \param gchandle a GCHandle's handle.
+ *
+ * The handle was previously created by calling \c mono_gchandle_new or
+ * \c mono_gchandle_new_weakref. 
+ *
+ * \returns a pointer to the \c MonoObject* represented by the handle or
+ * NULL for a collected object if using a weakref handle.
+ */
+MonoObject*
+mono_gchandle_get_target (guint32 gchandle)
+{
+       return sgen_gchandle_get_target (gchandle);
+}
+
 static gpointer
 null_link_if_in_domain (gpointer hidden, GCHandleType handle_type, int max_generation, gpointer user)
 {
@@ -2725,7 +2803,7 @@ void
 sgen_client_gchandle_created (int handle_type, GCObject *obj, guint32 handle)
 {
 #ifndef DISABLE_PERFCOUNTERS
-       mono_perfcounters->gc_num_handles++;
+       InterlockedIncrement (&mono_perfcounters->gc_num_handles);
 #endif
 
        MONO_PROFILER_RAISE (gc_handle_created, (handle, handle_type, obj));
@@ -2735,7 +2813,7 @@ void
 sgen_client_gchandle_destroyed (int handle_type, guint32 handle)
 {
 #ifndef DISABLE_PERFCOUNTERS
-       mono_perfcounters->gc_num_handles--;
+       InterlockedDecrement (&mono_perfcounters->gc_num_handles);
 #endif
 
        MONO_PROFILER_RAISE (gc_handle_deleted, (handle, handle_type));
index 8eb4fe5f24e474e619a68bb2e17a00cb1f52f043..c97f7f3f53cca5e0fc080224d1073b2053d32045 100644 (file)
@@ -45,6 +45,7 @@
 #include <mono/utils/mono-error-internals.h>
 #include <mono/utils/os-event.h>
 #include <mono/utils/mono-threads-debug.h>
+#include <mono/utils/unlocked.h>
 #include <mono/metadata/w32handle.h>
 #include <mono/metadata/w32event.h>
 #include <mono/metadata/w32mutex.h>
@@ -152,7 +153,7 @@ static MonoGHashTable *threads_starting_up = NULL;
 /* Contains tids */
 /* Protected by the threads lock */
 static GHashTable *joinable_threads;
-static int joinable_thread_count;
+static gint32 joinable_thread_count;
 
 #define SET_CURRENT_OBJECT(x) mono_tls_set_thread (x)
 #define GET_CURRENT_OBJECT() (MonoInternalThread*) mono_tls_get_thread ()
@@ -3036,6 +3037,8 @@ mono_thread_callbacks_init (void)
 void
 mono_thread_cleanup (void)
 {
+       mono_threads_join_threads ();
+
 #if !defined(RUN_IN_SUBTHREAD) && !defined(HOST_WIN32)
        /* The main thread must abandon any held mutexes (particularly
         * important for named mutexes as they are shared across
@@ -5000,7 +5003,7 @@ mono_threads_add_joinable_thread (gpointer tid)
        if (!joinable_threads)
                joinable_threads = g_hash_table_new (NULL, NULL);
        g_hash_table_insert (joinable_threads, tid, tid);
-       joinable_thread_count ++;
+       UnlockedIncrement (&joinable_thread_count);
        joinable_threads_unlock ();
 
        mono_gc_finalize_notify ();
@@ -5024,7 +5027,7 @@ mono_threads_join_threads (void)
        gboolean found;
 
        /* Fastpath */
-       if (!joinable_thread_count)
+       if (!UnlockedRead (&joinable_thread_count))
                return;
 
        while (TRUE) {
@@ -5035,7 +5038,7 @@ mono_threads_join_threads (void)
                        g_hash_table_iter_next (&iter, &key, (void**)&tid);
                        thread = (pthread_t)tid;
                        g_hash_table_remove (joinable_threads, key);
-                       joinable_thread_count --;
+                       UnlockedDecrement (&joinable_thread_count);
                        found = TRUE;
                }
                joinable_threads_unlock ();
@@ -5073,7 +5076,7 @@ mono_thread_join (gpointer tid)
                joinable_threads = g_hash_table_new (NULL, NULL);
        if (g_hash_table_lookup (joinable_threads, tid)) {
                g_hash_table_remove (joinable_threads, tid);
-               joinable_thread_count --;
+               UnlockedDecrement (&joinable_thread_count);
                found = TRUE;
        }
        joinable_threads_unlock ();
index 65547135b3b11adacd09a7ed750c426e93d78f43..448cd8c2e5a0dbb4615fe283f8c80a904b8c0b87 100644 (file)
@@ -4256,6 +4256,7 @@ static _wapi_drive_type _wapi_drive_types[] = {
        { DRIVE_REMOTE, "ftp" },
        { DRIVE_FIXED, "hfs" },
        { DRIVE_FIXED, "apfs" },
+       { DRIVE_REMOTE, "kbfuse" },
        { DRIVE_FIXED, "msdos" },
        { DRIVE_REMOTE, "nfs" },
        { DRIVE_FIXED, "ntfs" },
index cf9fb28e466950607f2eee6c681d9ce86c009f40..62e2eb154c9c4e28c62a81e23787d7703c10f134 100644 (file)
 #define TF_DISCONNECT 0x01
 #define TF_REUSE_SOCKET 0x02
 
-typedef struct {
-       guint32 len;
-       gpointer buf;
-} WSABUF, *LPWSABUF;
-
 typedef struct {
        gpointer Head;
        guint32 HeadLength;
index 9c0053455829860be455830da6f617c57ffb73c4..43df41bfdc717181022977d5bbc39853e43bdb87 100644 (file)
@@ -1429,21 +1429,15 @@ ves_icall_System_Net_Sockets_Socket_Duplicate_internal (gpointer handle, gint32
 }
 
 gint32
-ves_icall_System_Net_Sockets_Socket_Receive_internal (gsize sock, MonoArrayHandle buffer, gint32 offset, gint32 count, gint32 flags, gint32 *werror, gboolean blocking, MonoError *error)
+ves_icall_System_Net_Sockets_Socket_Receive_internal (gsize sock, gchar *buffer, gint32 count, gint32 flags, gint32 *werror, gboolean blocking, MonoError *error)
 {
        int ret;
-       gint32 alen;
        int recvflags = 0;
        gboolean interrupted;
-       MonoInternalThread* curthread G_GNUC_UNUSED = mono_thread_internal_current ();
        
        error_init (error);
        *werror = 0;
        
-       alen = mono_array_handle_length (buffer);
-       if (offset > alen - count)
-               return 0;
-       
        recvflags = convert_socketflags (flags);
        if (recvflags == -1) {
                *werror = WSAEOPNOTSUPP;
@@ -1454,12 +1448,7 @@ ves_icall_System_Net_Sockets_Socket_Receive_internal (gsize sock, MonoArrayHandl
        if (interrupted)
                return 0;
 
-       uint32_t gchandle;
-       gchar *buf = MONO_ARRAY_HANDLE_PIN (buffer, gchar, offset, &gchandle);
-
-       ret = mono_w32socket_recv (sock, buf, count, recvflags, blocking);
-
-       mono_gchandle_free (gchandle);
+       ret = mono_w32socket_recv (sock, buffer, count, recvflags, blocking);
        
        if (ret == SOCKET_ERROR)
                *werror = mono_w32socket_get_last_error ();
@@ -1475,9 +1464,9 @@ ves_icall_System_Net_Sockets_Socket_Receive_internal (gsize sock, MonoArrayHandl
 }
 
 gint32
-ves_icall_System_Net_Sockets_Socket_Receive_array_internal (gsize sock, MonoArrayHandle buffers, gint32 flags, gint32 *werror, gboolean blocking, MonoError *error)
+ves_icall_System_Net_Sockets_Socket_Receive_array_internal (gsize sock, WSABUF *buffers, gint32 count, gint32 flags, gint32 *werror, gboolean blocking, MonoError *error)
 {
-       int ret, count;
+       int ret;
        gboolean interrupted;
        guint32 recv;
        guint32 recvflags = 0;
@@ -1485,8 +1474,6 @@ ves_icall_System_Net_Sockets_Socket_Receive_array_internal (gsize sock, MonoArra
        error_init (error);
        *werror = 0;
        
-       count = mono_array_handle_length (buffers);
-       
        recvflags = convert_socketflags (flags);
        if (recvflags == -1) {
                *werror = WSAEOPNOTSUPP;
@@ -1499,12 +1486,7 @@ ves_icall_System_Net_Sockets_Socket_Receive_array_internal (gsize sock, MonoArra
                return 0;
        }
 
-       uint32_t gchandle;
-       WSABUF *wsabufs = MONO_ARRAY_HANDLE_PIN (buffers, WSABUF, 0, &gchandle);
-
-       ret = mono_w32socket_recvbuffers (sock, wsabufs, count, &recv, &recvflags, NULL, NULL, blocking);
-
-       mono_gchandle_free (gchandle);
+       ret = mono_w32socket_recvbuffers (sock, buffers, count, &recv, &recvflags, NULL, NULL, blocking);
 
        if (ret == SOCKET_ERROR)
                *werror = mono_w32socket_get_last_error ();
@@ -1520,11 +1502,9 @@ ves_icall_System_Net_Sockets_Socket_Receive_array_internal (gsize sock, MonoArra
 }
 
 gint32
-ves_icall_System_Net_Sockets_Socket_ReceiveFrom_internal (gsize sock, MonoArrayHandle buffer, gint32 offset, gint32 count, gint32 flags, MonoObjectHandle sockaddr, gint32 *werror, gboolean blocking, MonoError *error)
+ves_icall_System_Net_Sockets_Socket_ReceiveFrom_internal (gsize sock, gchar *buffer, gint32 count, gint32 flags, MonoObjectHandle sockaddr, gint32 *werror, gboolean blocking, MonoError *error)
 {
        int ret;
-       gchar *buf;
-       gint32 alen;
        int recvflags = 0;
        struct sockaddr *sa;
        socklen_t sa_size;
@@ -1532,10 +1512,6 @@ ves_icall_System_Net_Sockets_Socket_ReceiveFrom_internal (gsize sock, MonoArrayH
        
        error_init (error);
        *werror = 0;
-       
-       alen = mono_array_handle_length (buffer);
-       if (offset > alen - count)
-               return 0;
 
        sa = create_sockaddr_from_handle (sockaddr, &sa_size, werror, error);
        if (*werror != 0)
@@ -1556,12 +1532,7 @@ ves_icall_System_Net_Sockets_Socket_ReceiveFrom_internal (gsize sock, MonoArrayH
                return 0;
        }
 
-       uint32_t gchandle;
-       buf = MONO_ARRAY_HANDLE_PIN (buffer, gchar, offset, &gchandle);
-
-       ret = mono_w32socket_recvfrom (sock, buf, count, recvflags, sa, &sa_size, blocking);
-
-       mono_gchandle_free (gchandle);
+       ret = mono_w32socket_recvfrom (sock, buffer, count, recvflags, sa, &sa_size, blocking);
 
        if (ret == SOCKET_ERROR)
                *werror = mono_w32socket_get_last_error ();
@@ -1596,22 +1567,15 @@ ves_icall_System_Net_Sockets_Socket_ReceiveFrom_internal (gsize sock, MonoArrayH
 }
 
 gint32
-ves_icall_System_Net_Sockets_Socket_Send_internal (gsize sock, MonoArrayHandle buffer, gint32 offset, gint32 count, gint32 flags, gint32 *werror, gboolean blocking, MonoError *error)
+ves_icall_System_Net_Sockets_Socket_Send_internal (gsize sock, gchar *buffer, gint32 count, gint32 flags, gint32 *werror, gboolean blocking, MonoError *error)
 {
        int ret;
-       gint32 alen;
        int sendflags = 0;
        gboolean interrupted;
        
        error_init (error);
        *werror = 0;
        
-       alen = mono_array_handle_length (buffer);
-       if (offset > alen - count)
-               return 0;
-
-       LOGDEBUG (g_message("%s: alen: %d", __func__, alen));
-       
        LOGDEBUG (g_message("%s: Sending %d bytes", __func__, count));
 
        sendflags = convert_socketflags (flags);
@@ -1626,12 +1590,7 @@ ves_icall_System_Net_Sockets_Socket_Send_internal (gsize sock, MonoArrayHandle b
                return 0;
        }
 
-       uint32_t gchandle;
-       gchar *buf = MONO_ARRAY_HANDLE_PIN (buffer, gchar, offset, &gchandle);
-
-       ret = mono_w32socket_send (sock, buf, count, sendflags, blocking);
-
-       mono_gchandle_free (gchandle);
+       ret = mono_w32socket_send (sock, buffer, count, sendflags, blocking);
 
        if (ret == SOCKET_ERROR)
                *werror = mono_w32socket_get_last_error ();
@@ -1647,9 +1606,9 @@ ves_icall_System_Net_Sockets_Socket_Send_internal (gsize sock, MonoArrayHandle b
 }
 
 gint32
-ves_icall_System_Net_Sockets_Socket_Send_array_internal (gsize sock, MonoArrayHandle buffers, gint32 flags, gint32 *werror, gboolean blocking, MonoError *error)
+ves_icall_System_Net_Sockets_Socket_Send_array_internal (gsize sock, WSABUF *buffers, gint32 count, gint32 flags, gint32 *werror, gboolean blocking, MonoError *error)
 {
-       int ret, count;
+       int ret;
        guint32 sent;
        guint32 sendflags = 0;
        gboolean interrupted;
@@ -1657,8 +1616,6 @@ ves_icall_System_Net_Sockets_Socket_Send_array_internal (gsize sock, MonoArrayHa
        error_init (error);
        *werror = 0;
        
-       count = mono_array_handle_length (buffers);
-       
        sendflags = convert_socketflags (flags);
        if (sendflags == -1) {
                *werror = WSAEOPNOTSUPP;
@@ -1671,12 +1628,7 @@ ves_icall_System_Net_Sockets_Socket_Send_array_internal (gsize sock, MonoArrayHa
                return 0;
        }
 
-       uint32_t gchandle;
-       WSABUF *wsabufs = MONO_ARRAY_HANDLE_PIN (buffers, WSABUF, 0, &gchandle);
-
-       ret = mono_w32socket_sendbuffers (sock, wsabufs, count, &sent, sendflags, NULL, NULL, blocking);
-
-       mono_gchandle_free (gchandle);
+       ret = mono_w32socket_sendbuffers (sock, buffers, count, &sent, sendflags, NULL, NULL, blocking);
 
        if (ret == SOCKET_ERROR)
                *werror = mono_w32socket_get_last_error ();
@@ -1692,29 +1644,21 @@ ves_icall_System_Net_Sockets_Socket_Send_array_internal (gsize sock, MonoArrayHa
 }
 
 gint32
-ves_icall_System_Net_Sockets_Socket_SendTo_internal (gsize sock, MonoArrayHandle buffer, gint32 offset, gint32 count, gint32 flags, MonoObjectHandle sockaddr, gint32 *werror, gboolean blocking, MonoError *error)
+ves_icall_System_Net_Sockets_Socket_SendTo_internal (gsize sock, gchar *buffer, gint32 count, gint32 flags, MonoObjectHandle sockaddr, gint32 *werror, gboolean blocking, MonoError *error)
 {
        int ret;
-       gint32 alen;
        int sendflags = 0;
        struct sockaddr *sa;
        socklen_t sa_size;
        gboolean interrupted;
        
        *werror = 0;
-       
-       alen = mono_array_handle_length (buffer);
-       if (offset > alen - count) {
-               return 0;
-       }
 
        sa = create_sockaddr_from_handle (sockaddr, &sa_size, werror, error);
        if (*werror != 0)
                return 0;
        return_val_if_nok (error, 0);
        
-       LOGDEBUG (g_message ("%s: alen: %d", __func__, alen));
-       
        LOGDEBUG (g_message("%s: Sending %d bytes", __func__, count));
 
        sendflags = convert_socketflags (flags);
@@ -1731,12 +1675,7 @@ ves_icall_System_Net_Sockets_Socket_SendTo_internal (gsize sock, MonoArrayHandle
                return 0;
        }
 
-       uint32_t gchandle;
-       gchar *buf = MONO_ARRAY_HANDLE_PIN (buffer, gchar, offset, &gchandle);
-
-       ret = mono_w32socket_sendto (sock, buf, count, sendflags, sa, sa_size, blocking);
-
-       mono_gchandle_free (gchandle);
+       ret = mono_w32socket_sendto (sock, buffer, count, sendflags, sa, sa_size, blocking);
 
        if (ret == SOCKET_ERROR)
                *werror = mono_w32socket_get_last_error ();
index 9fcd2341d7825e05b7aeb5065ce87acc0d2f94d0..5d5aa4adc53b472f35e448cf21e01bacc80e1829 100644 (file)
 
 #ifndef HOST_WIN32
 typedef gint SOCKET;
+
+typedef struct {
+       guint32 len;
+       gpointer buf;
+} WSABUF, *LPWSABUF;
 #endif
 
 /* This is a copy of System.Net.Sockets.SocketType */
@@ -204,32 +209,28 @@ void
 ves_icall_System_Net_Sockets_Socket_Connect_internal (gsize sock, MonoObjectHandle sockaddr, gint32 *werror, gboolean blocking, MonoError *error);
 
 gint32
-ves_icall_System_Net_Sockets_Socket_Receive_internal (gsize sock, MonoArrayHandle buffer, gint32 offset, gint32 count,
+ves_icall_System_Net_Sockets_Socket_Receive_internal (gsize sock, gchar *buffer, gint32 count,
                                                      gint32 flags, gint32 *werror, gboolean blocking, MonoError *error);
 
 gint32
-ves_icall_System_Net_Sockets_Socket_Receive_array_internal (gsize sock, MonoArrayHandle buffers, gint32 flags,
+ves_icall_System_Net_Sockets_Socket_Receive_array_internal (gsize sock, WSABUF *buffers, gint32 count, gint32 flags,
                                                            gint32 *werror, gboolean blocking, MonoError *error);
 
-/* gint32 */
-/* ves_icall_System_Net_Sockets_Socket_ReceiveFrom_internal (gsize sock, MonoArray *buffer, gint32 offset, gint32 count, */
-/*                                                       gint32 flags, MonoObject **sockaddr, gint32 *werror, gboolean blocking); */
-
 gint32
-ves_icall_System_Net_Sockets_Socket_ReceiveFrom_internal (gsize sock, MonoArrayHandle buffer, gint32 offset, gint32 count,
+ves_icall_System_Net_Sockets_Socket_ReceiveFrom_internal (gsize sock, gchar *buffer, gint32 count,
                                                          gint32 flags, MonoObjectHandle sockaddr, gint32 *werror, gboolean blocking, MonoError *error);
 
 
 gint32
-ves_icall_System_Net_Sockets_Socket_Send_internal (gsize sock, MonoArrayHandle buffer, gint32 offset, gint32 count,
+ves_icall_System_Net_Sockets_Socket_Send_internal (gsize sock, gchar *buffer, gint32 count,
                                                   gint32 flags, gint32 *werror, gboolean blocking, MonoError *error);
 
 gint32
-ves_icall_System_Net_Sockets_Socket_Send_array_internal (gsize sock, MonoArrayHandle buffers, gint32 flags,
+ves_icall_System_Net_Sockets_Socket_Send_array_internal (gsize sock, WSABUF *buffers, gint32 count, gint32 flags,
                                                         gint32 *werror, gboolean blocking, MonoError *error);
 
 gint32
-ves_icall_System_Net_Sockets_Socket_SendTo_internal (gsize sock, MonoArrayHandle buffer, gint32 offset, gint32 count,
+ves_icall_System_Net_Sockets_Socket_SendTo_internal (gsize sock, gchar *buffer, gint32 count,
                                                     gint32 flags, MonoObjectHandle sockaddr, gint32 *werror,
                                                     gboolean blocking, MonoError *error);
 
index d35a867778fe49e99c74ab07296a3d58d6bc935b..b2354f176286a27a1ebc08ac029f2b253234aaff 100755 (executable)
@@ -99,8 +99,8 @@ long_min_un: dest:i src1:i src2:i len:16 clob:1
 long_max: dest:i src1:i src2:i len:16 clob:1
 long_max_un: dest:i src1:i src2:i len:16 clob:1
 
-throw: src1:i len:18
-rethrow: src1:i len:18
+throw: src1:i len:24
+rethrow: src1:i len:24
 start_handler: len:16
 endfinally: len:9
 endfilter: src1:a len:9
index 8dabb43234f80cb4af5a22bdba870fe28aee4831..e80fcdce42a0b5e0974087d573582f5aa6795866 100644 (file)
@@ -96,6 +96,7 @@ fcall_membase: dest:g src1:b len:14 clob:c
 fcall_reg: dest:g src1:i len:10 clob:c
 fcompare: src1:f src2:f len:14
 float_add: dest:f src1:f src2:f len:6
+
 float_beq: len:10
 float_bge: len:10
 float_bge_un: len:8
@@ -106,11 +107,16 @@ float_blt: len:10
 float_blt_un: len:8
 float_bne_un: len:8
 float_bgt_un: len:8
+
 float_ceq: dest:i src1:f src2:f len:16
 float_cgt: dest:i src1:f src2:f len:16
 float_cgt_un: dest:i src1:f src2:f len:16
 float_clt: dest:i src1:f src2:f len:16
 float_clt_un: dest:i src1:f src2:f len:16
+float_cneq: dest:y src1:f src2:f len:16
+float_cge: dest:y src1:f src2:f len:16
+float_cle: dest:y src1:f src2:f len:16
+
 float_conv_to_i1: dest:i src1:f len:50
 float_conv_to_i2: dest:i src1:f len:50
 float_conv_to_i4: dest:i src1:f len:50
@@ -231,11 +237,19 @@ int_ble_un: len:8
 int_blt: len:8
 int_blt_un: len:8
 int_bne_un: len:8
+
 int_ceq: dest:i len:12
 int_cgt: dest:i len:12
 int_cgt_un: dest:i len:12
 int_clt: dest:i len:12
 int_clt_un: dest:i len:12
+
+int_cneq: dest:i len:12
+int_cge: dest:i len:12
+int_cle: dest:i len:12
+int_cge_un: dest:i len:12
+int_cle_un: dest:i len:12
+
 int_div: dest:a src1:i src2:i len:16
 int_div_imm: dest:a src1:i len:24
 int_div_un: dest:a src1:i src2:i len:16
@@ -340,11 +354,11 @@ jump_table: dest:i len:24
 
 int_conv_to_i1: dest:i src1:i len:12
 int_conv_to_i2: dest:i src1:i len:12
-int_conv_to_i4: dest:i src1:i len:2
-int_conv_to_i: dest:i src1:i len:2
+int_conv_to_i4: dest:i src1:i len:4
+int_conv_to_i: dest:i src1:i len:4
 int_conv_to_u1: dest:i src1:i len:10
 int_conv_to_u2: dest:i src1:i len:16
-int_conv_to_u4: dest:i src1:i
+int_conv_to_u4: dest:i src1:i len:4
 int_conv_to_r_un: dest:f src1:i len:37 
 
 cond_exc_ic: len:8
@@ -393,3 +407,12 @@ gc_param_slot_liveness_def: len:0
 gc_safe_point: clob:c src1:i len:32
 
 generic_class_init: src1:A len:32 clob:c
+
+s390_crj: src1:i src2:i len:24
+s390_crj_un: src1:i src2:i len:24
+s390_cgrj: src1:i src2:i len:24
+s390_cgrj_un: src1:i src2:i len:24
+s390_cij: src1:i len:24
+s390_cij_un: src1:i len:24
+s390_cgij: src1:i len:24
+s390_cgij_un: src1:i len:24
index 016423072bd74048996f6c85363e28b6c52d90d7..cb0600828e9c4116eccd38a44843358bd263666c 100644 (file)
@@ -2670,7 +2670,7 @@ thread_interrupt (DebuggerTlsData *tls, MonoThreadInfo *info, MonoJitInfo *ji)
                                }
 
                                copy_unwind_state_from_frame_data (&tls->async_state, &data, jit_tls);
-                               copy_unwind_state_from_frame_data (&tls->context, &data, jit_tls);
+                               /* Don't set tls->context, it could race with the thread processing a breakpoint etc. */
                        } else {
                                tls->async_state.valid = FALSE;
                        }
@@ -3662,13 +3662,10 @@ process_event (EventKind event, gpointer arg, gint32 il_offset, MonoContext *ctx
                        return;
 
                if (agent_config.defer) {
-                       /* Make sure the thread id is always set when doing deferred debugging */
                        if (is_debugger_thread ()) {
                                /* Don't suspend on events from the debugger thread */
                                suspend_policy = SUSPEND_POLICY_NONE;
-                               thread = mono_thread_get_main ();
                        }
-                       else thread = mono_thread_current ();
                } else {
                        if (is_debugger_thread () && event != EVENT_KIND_VM_DEATH)
                                // FIXME: Send these with a NULL thread, don't suspend the current thread
@@ -3691,7 +3688,7 @@ process_event (EventKind event, gpointer arg, gint32 il_offset, MonoContext *ctx
                        thread = NULL;
                } else {
                        if (!thread)
-                               thread = mono_thread_current ();
+                               thread = is_debugger_thread () ? mono_thread_get_main () : mono_thread_current ();
 
                        if (event == EVENT_KIND_VM_START && arg != NULL)
                                thread = (MonoThread *)arg;
@@ -4749,25 +4746,17 @@ breakpoint_matches_assembly (MonoBreakpoint *bp, MonoAssembly *assembly)
        return bp->method && bp->method->klass->image->assembly == assembly;
 }
 
-static MonoObject*
-get_this (StackFrame *frame)
+static gpointer
+get_this_addr (StackFrame *frame)
 {
        //Logic inspiered by "add_var" method and took out path that happens in async method for getting this
        MonoDebugVarInfo *var = frame->jit->this_var;
        if ((var->index & MONO_DEBUG_VAR_ADDRESS_MODE_FLAGS) != MONO_DEBUG_VAR_ADDRESS_MODE_REGOFFSET)
                return NULL;
 
-       guint8 * addr = (guint8 *)mono_arch_context_get_int_reg (&frame->ctx, var->index & ~MONO_DEBUG_VAR_ADDRESS_MODE_FLAGS);
+       guint8 *addr = (guint8 *)mono_arch_context_get_int_reg (&frame->ctx, var->index & ~MONO_DEBUG_VAR_ADDRESS_MODE_FLAGS);
        addr += (gint32)var->offset;
-       return *(MonoObject**)addr;
-}
-
-//This ID is used to figure out if breakpoint hit on resumeOffset belongs to us or not
-//since thread probably changed...
-static int
-get_this_async_id (StackFrame *frame)
-{
-       return get_objid (get_this (frame));
+       return addr;
 }
 
 static MonoMethod*
@@ -4782,25 +4771,100 @@ get_set_notification_method (MonoClass* async_builder_class)
        return set_notification_method;
 }
 
-static void
-set_set_notification_for_wait_completion_flag (StackFrame *frame)
+static MonoMethod*
+get_object_id_for_debugger_method (MonoClass* async_builder_class)
+{
+       MonoError error;
+       GPtrArray *array = mono_class_get_methods_by_name (async_builder_class, "get_ObjectIdForDebugger", 0x24, FALSE, FALSE, &error);
+       mono_error_assert_ok (&error);
+       g_assert (array->len == 1);
+       MonoMethod *method = (MonoMethod *)g_ptr_array_index (array, 0);
+       g_ptr_array_free (array, TRUE);
+       return method;
+}
+
+/* Return the address of the AsyncMethodBuilder struct belonging to the state machine method pointed to by FRAME */
+static gpointer
+get_async_method_builder (StackFrame *frame)
 {
-       MonoObject* obj = get_this (frame);
-       g_assert (obj);
-       MonoClassField *builder_field = mono_class_get_field_from_name (obj->vtable->klass, "<>t__builder");
+       MonoObject *this_obj;
+       MonoClassField *builder_field;
+       gpointer builder;
+       guint8 *this_addr;
+
+       builder_field = mono_class_get_field_from_name (frame->method->klass, "<>t__builder");
        g_assert (builder_field);
-       MonoObject* builder;
+
+       this_addr = get_this_addr (frame);
+       if (!this_addr)
+               return NULL;
+
+       if (frame->method->klass->valuetype) {
+               guint8 *vtaddr = *(guint8**)this_addr;
+               builder = (char*)vtaddr + builder_field->offset - sizeof (MonoObject);
+       } else {
+               this_obj = *(MonoObject**)this_addr;
+               builder = (char*)this_obj + builder_field->offset;
+       }
+
+       return builder;
+}
+
+//This ID is used to figure out if breakpoint hit on resumeOffset belongs to us or not
+//since thread probably changed...
+static int
+get_this_async_id (StackFrame *frame)
+{
+       MonoClassField *builder_field;
+       gpointer builder;
+       MonoMethod *method;
+       MonoObject *ex;
        MonoError error;
-       builder = mono_field_get_value_object_checked (frame->domain, builder_field, obj, &error);
+       MonoObject *obj;
+       gboolean old_disable_breakpoints = FALSE;
+       DebuggerTlsData *tls;
+
+       /*
+        * FRAME points to a method in a state machine class/struct.
+        * Call the ObjectIdForDebugger method of the associated method builder type.
+        */
+       builder = get_async_method_builder (frame);
+       if (!builder)
+               return 0;
+
+       builder_field = mono_class_get_field_from_name (frame->method->klass, "<>t__builder");
+       g_assert (builder_field);
+
+       tls = (DebuggerTlsData *)mono_native_tls_get_value (debugger_tls_id);
+       if (tls) {
+               old_disable_breakpoints = tls->disable_breakpoints;
+               tls->disable_breakpoints = TRUE;
+       }
+
+       method = get_object_id_for_debugger_method (mono_class_from_mono_type (builder_field->type));
+       obj = mono_runtime_try_invoke (method, builder, NULL, &ex, &error);
        mono_error_assert_ok (&error);
+
+       if (tls)
+               tls->disable_breakpoints = old_disable_breakpoints;
+
+       return get_objid (obj);
+}
+
+static void
+set_set_notification_for_wait_completion_flag (StackFrame *frame)
+{
+       MonoClassField *builder_field = mono_class_get_field_from_name (frame->method->klass, "<>t__builder");
+       g_assert (builder_field);
+       gpointer builder = get_async_method_builder (frame);
        g_assert (builder);
 
        void* args [1];
        gboolean arg = TRUE;
+       MonoError error;
        args [0] = &arg;
-       mono_runtime_invoke_checked (get_set_notification_method (builder->vtable->klass), mono_object_unbox (builder), args, &error);
+       mono_runtime_invoke_checked (get_set_notification_method (mono_class_from_mono_type (builder_field->type)), builder, args, &error);
        mono_error_assert_ok (&error);
-       mono_field_set_value (obj, builder_field, mono_object_unbox (builder));
 }
 
 static MonoMethod* notify_debugger_of_wait_completion_method_cache = NULL;
@@ -6982,7 +7046,7 @@ do_invoke_method (DebuggerTlsData *tls, Buffer *buf, InvokeData *invoke, guint8
        MonoMethodSignature *sig;
        guint8 **arg_buf;
        void **args;
-       MonoObject *this_arg, *res, *exc;
+       MonoObject *this_arg, *res, *exc = NULL;
        MonoDomain *domain;
        guint8 *this_buf;
 #ifdef MONO_ARCH_SOFT_DEBUG_SUPPORTED
@@ -7154,7 +7218,7 @@ do_invoke_method (DebuggerTlsData *tls, Buffer *buf, InvokeData *invoke, guint8
 
        mono_stopwatch_start (&watch);
        res = mono_runtime_try_invoke (m, m->klass->valuetype ? (gpointer) this_buf : (gpointer) this_arg, args, &exc, &error);
-       if (exc == NULL && !mono_error_ok (&error)) {
+       if (!mono_error_ok (&error) && exc == NULL) {
                exc = (MonoObject*) mono_error_convert_to_exception (&error);
        } else {
                mono_error_cleanup (&error); /* FIXME report error */
index e10f65766c97c3db26ecd53d7415bbc893ff44c2..e09d72e9192f97b23ef69eb35c1e97ee6d66b831 100644 (file)
 #include "llvm/ExecutionEngine/Orc/CompileUtils.h"
 #include "llvm/ExecutionEngine/Orc/IRCompileLayer.h"
 #include "llvm/ExecutionEngine/Orc/LambdaResolver.h"
+#if LLVM_API_VERSION >= 500
+#include "llvm/ExecutionEngine/RTDyldMemoryManager.h"
+#include "llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h"
+#include "llvm/ExecutionEngine/JITSymbol.h"
+#else
 #include "llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h"
+#endif
 
 #include <cstdlib>
 
@@ -121,21 +127,46 @@ MonoJitMemoryManager::finalizeMemory(std::string *ErrMsg)
 class MonoLLVMJIT {
 public:
        /* We use our own trampoline infrastructure instead of the Orc one */
+#if LLVM_API_VERSION >= 500
+       typedef RTDyldObjectLinkingLayer ObjLayerT;
+       typedef IRCompileLayer<ObjLayerT, SimpleCompiler> CompileLayerT;
+       typedef CompileLayerT::ModuleHandleT ModuleHandleT;
+#else
        typedef ObjectLinkingLayer<> ObjLayerT;
        typedef IRCompileLayer<ObjLayerT> CompileLayerT;
        typedef CompileLayerT::ModuleSetHandleT ModuleHandleT;
+#endif
 
-       MonoLLVMJIT (TargetMachine *TM)
+       MonoLLVMJIT (TargetMachine *TM, MonoJitMemoryManager *mm)
+#if LLVM_API_VERSION >= 500
+               : TM(TM), ObjectLayer([=] { return std::shared_ptr<RuntimeDyld::MemoryManager> (mm); }),
+#else
                : TM(TM),
-                 CompileLayer (ObjectLayer, SimpleCompiler (*TM)) {
+#endif
+                 CompileLayer (ObjectLayer, SimpleCompiler (*TM)),
+                 modules() {
        }
 
-       ModuleHandleT addModule(Module *M) {
+#if LLVM_API_VERSION >= 500
+       ModuleHandleT addModule(Function *F, std::shared_ptr<Module> M) {
+#else
+       ModuleHandleT addModule(Function *F, Module *M) {
+#endif
                auto Resolver = createLambdaResolver(
                       [&](const std::string &Name) {
                                                  const char *name = Name.c_str ();
-                                                 if (!strcmp (name, "___bzero"))
-                                                         return RuntimeDyld::SymbolInfo((uint64_t)(gssize)(void*)bzero, (JITSymbolFlags)0);
+#if LLVM_API_VERSION >= 500
+                                                 JITSymbolFlags flags = JITSymbolFlags ();
+#else
+                                                 JITSymbolFlags flags = (JITSymbolFlags)0;
+#endif
+                                                 if (!strcmp (name, "___bzero")) {
+#if LLVM_API_VERSION >= 500
+                                                         return JITSymbol((uint64_t)(gssize)(void*)bzero, flags);
+#else
+                                                         return RuntimeDyld::SymbolInfo((uint64_t)(gssize)(void*)bzero, flags);
+#endif
+                                                 }
 
                                                  MonoDl *current;
                                                  char *err;
@@ -150,7 +181,11 @@ public:
                                                  if (!symbol)
                                                          outs () << "R: " << Name << "\n";
                                                  assert (symbol);
-                                                 return RuntimeDyld::SymbolInfo((uint64_t)(gssize)symbol, (JITSymbolFlags)0);
+#if LLVM_API_VERSION >= 500
+                                                 return JITSymbol((uint64_t)(gssize)symbol, flags);
+#else
+                                                 return RuntimeDyld::SymbolInfo((uint64_t)(gssize)symbol, flags);
+#endif
                       },
                       [](const std::string &S) {
                                                  outs () << "R2: " << S << "\n";
@@ -158,9 +193,15 @@ public:
                                                  return nullptr;
                                          } );
 
+#if LLVM_API_VERSION >= 500
+               ModuleHandleT m = CompileLayer.addModule(M,
+                                                                                                std::move(Resolver));
+               return m;
+#else
                return CompileLayer.addModuleSet(singletonSet(M),
                                                                                  make_unique<MonoJitMemoryManager>(),
                                                                                  std::move(Resolver));
+#endif
        }
 
        std::string mangle(const std::string &Name) {
@@ -186,8 +227,14 @@ public:
 
        gpointer compile (Function *F, int nvars, LLVMValueRef *callee_vars, gpointer *callee_addrs, gpointer *eh_frame) {
                F->getParent ()->setDataLayout (TM->createDataLayout ());
-               auto ModuleHandle = addModule (F->getParent ());
-
+#if LLVM_API_VERSION >= 500
+               // Orc uses a shared_ptr to refer to modules so we have to save them ourselves to keep a ref
+               std::shared_ptr<Module> m (F->getParent ());
+               modules.push_back (m);
+               auto ModuleHandle = addModule (F, m);
+#else
+               auto ModuleHandle = addModule (F, F->getParent ());
+#endif
                auto BodySym = CompileLayer.findSymbolIn(ModuleHandle, mangle (F), false);
                auto BodyAddr = BodySym.getAddress();
                assert (BodyAddr);
@@ -213,9 +260,11 @@ private:
        TargetMachine *TM;
        ObjLayerT ObjectLayer;
        CompileLayerT CompileLayer;
+       std::vector<std::shared_ptr<Module>> modules;
 };
 
 static MonoLLVMJIT *jit;
+static MonoJitMemoryManager *mono_mm;
 
 MonoEERef
 mono_llvm_create_ee (LLVMModuleProviderRef MP, AllocCodeMemoryCb *alloc_cb, FunctionEmittedCb *emitted_cb, ExceptionTableCb *exception_cb, DlSymCb *dlsym_cb, LLVMExecutionEngineRef *ee)
@@ -239,7 +288,8 @@ mono_llvm_create_ee (LLVMModuleProviderRef MP, AllocCodeMemoryCb *alloc_cb, Func
        auto TM = EB.selectTarget ();
        assert (TM);
 
-       jit = new MonoLLVMJIT (TM);
+       mono_mm = new MonoJitMemoryManager ();
+       jit = new MonoLLVMJIT (TM, mono_mm);
 
        return NULL;
 }
index 2c30d87a59f34b5949e339e963a638bf63fe324b..442ec3c0a5c9005eab5da957140d8c8851189215 100644 (file)
@@ -8845,6 +8845,9 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
                                        }
                                        for (i = 0; i < n; ++i)
                                                EMIT_NEW_ARGSTORE (cfg, ins, i, sp [i]);
+
+                                       mini_profiler_emit_tail_call (cfg, cmethod);
+
                                        MONO_INST_NEW (cfg, ins, OP_BR);
                                        MONO_ADD_INS (cfg->cbb, ins);
                                        tblock = start_bblock->out_bb [0];
@@ -11779,6 +11782,8 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
                                if (sp != stack_start)
                                        UNVERIFIED;
                                
+                               mini_profiler_emit_leave (cfg, sp [0]);
+
                                MONO_INST_NEW (cfg, ins, OP_BR);
                                ins->inst_target_bb = end_bblock;
                                MONO_ADD_INS (cfg->cbb, ins);
index 02f056f694d4c81251766673338a371789a0c452..949f8946ddd1c73cf2a3d56a303448eff7115656 100644 (file)
@@ -2870,6 +2870,11 @@ emit_call_body (MonoCompile *cfg, guint8 *code, MonoJumpInfoType patch_type, gco
                        amd64_call_code (code, 0);
                }
                else {
+                       if (!no_patch && ((guint32)(code + 2 - cfg->native_code) % 8) != 0) {
+                               guint32 pad_size = 8 - ((guint32)(code + 2 - cfg->native_code) % 8);
+                               amd64_padding (code, pad_size);
+                               g_assert ((guint64)(code + 2 - cfg->native_code) % 8 == 0);
+                       }
                        mono_add_patch_info (cfg, code - cfg->native_code, patch_type, data);
                        amd64_set_reg_template (code, GP_SCRATCH_REG);
                        amd64_call_reg (code, GP_SCRATCH_REG);
@@ -3645,7 +3650,7 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
 
 #define EXTRA_CODE_SPACE (16)
 
-               if (G_UNLIKELY (offset > (cfg->code_size - max_len - EXTRA_CODE_SPACE))) {
+               if (G_UNLIKELY ((offset + max_len + EXTRA_CODE_SPACE) > cfg->code_size)) {
                        cfg->code_size *= 2;
                        cfg->native_code = (unsigned char *)mono_realloc_native_code(cfg);
                        code = cfg->native_code + offset;
@@ -4482,6 +4487,17 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
 
                        g_assert (!cfg->method->save_lmf);
 
+                       /* the size of the tailcall op depends on signature, let's check for enough
+                        * space in the code buffer here again */
+                       max_len += AMD64_NREG * 4 + call->stack_usage * 15 + EXTRA_CODE_SPACE;
+
+                       if (G_UNLIKELY (offset + max_len > cfg->code_size)) {
+                               cfg->code_size *= 2;
+                               cfg->native_code = (unsigned char *) mono_realloc_native_code(cfg);
+                               code = cfg->native_code + offset;
+                               cfg->stat_code_reallocs++;
+                       }
+
                        /* Restore callee saved registers */
                        save_area_offset = cfg->arch.reg_save_area_offset;
                        for (i = 0; i < AMD64_NREG; ++i)
@@ -4512,7 +4528,6 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
 #endif
                        }
 
-                       offset = code - cfg->native_code;
                        mono_add_patch_info (cfg, code - cfg->native_code, MONO_PATCH_INFO_METHOD_JUMP, call->method);
                        if (cfg->compile_aot)
                                amd64_mov_reg_membase (code, AMD64_R11, AMD64_RIP, 0, 8);
index b688502060669d8f06f5cec7f668d70fd6b3284f..f09f285a17bb26b132a9e30ff6710db8b37ad020 100644 (file)
@@ -237,9 +237,10 @@ static AMD64_XMM_Reg_No float_return_regs [] = { AMD64_XMM0 };
 #define PARAM_REGS 6
 #define FLOAT_PARAM_REGS 8
 
-static AMD64_Reg_No param_regs [] = { AMD64_RDI, AMD64_RSI, AMD64_RDX, AMD64_RCX, AMD64_R8, AMD64_R9 };
+static const AMD64_Reg_No param_regs [] = {AMD64_RDI, AMD64_RSI, AMD64_RDX,
+                                          AMD64_RCX, AMD64_R8,  AMD64_R9};
 
-static AMD64_Reg_No return_regs [] = { AMD64_RAX, AMD64_RDX };
+static const AMD64_Reg_No return_regs [] = {AMD64_RAX, AMD64_RDX};
 #endif
 
 typedef struct {
index ae4a87ccae0ef6293e1400c9018455242024bbaf..10cf1b75cb194d9051761962546b5ffba8b9f8f8 100644 (file)
 #define MONO_ARCH_CONTEXT_DEF
 #endif
 
-#ifndef MONO_ARCH_STACK_GROWS_UP
-#define MONO_ARCH_STACK_GROWS_UP 0
-#endif
-
 /*
  * Raw frame information is stored in MonoException.trace_ips as an IntPtr[].
  * This structure represents one entry.
@@ -149,18 +145,6 @@ mono_thread_get_managed_sp (void)
        return addr;
 }
 
-static inline int
-mini_abort_threshold_offset (gpointer threshold, gpointer sp)
-{
-       intptr_t stack_threshold = (intptr_t) threshold;
-       intptr_t stack_pointer = (intptr_t) sp;
-
-       const int direction = MONO_ARCH_STACK_GROWS_UP ? -1 : 1;
-       intptr_t magnitude = stack_pointer - stack_threshold;
-
-       return direction * magnitude;
-}
-
 static inline void
 mini_clear_abort_threshold (void)
 {
@@ -176,7 +160,7 @@ mini_set_abort_threshold (MonoContext *ctx)
        // Only move it up, to avoid thrown/caught
        // exceptions lower in the stack from triggering
        // a rethrow
-       gboolean above_threshold = mini_abort_threshold_offset (jit_tls->abort_exc_stack_threshold, sp) >= 0;
+       gboolean above_threshold = (gsize) sp >= (gsize) jit_tls->abort_exc_stack_threshold;
        if (!jit_tls->abort_exc_stack_threshold || above_threshold) {
                jit_tls->abort_exc_stack_threshold = sp;
        }
@@ -194,7 +178,7 @@ mini_above_abort_threshold (void)
        if (!sp)
                return TRUE;
 
-       gboolean above_threshold = mini_abort_threshold_offset (jit_tls->abort_exc_stack_threshold, sp) >= 0;
+       gboolean above_threshold = (gsize) sp >= (gsize) jit_tls->abort_exc_stack_threshold;
 
        if (above_threshold)
                jit_tls->abort_exc_stack_threshold = sp;
@@ -1685,10 +1669,7 @@ mono_handle_exception_internal_first_pass (MonoContext *ctx, MonoObject *obj, gi
                        dynamic_methods = g_slist_prepend (dynamic_methods, method);
 
                if (stack_overflow) {
-                       if (MONO_ARCH_STACK_GROWS_UP)
-                               free_stack = (guint8*)(MONO_CONTEXT_GET_SP (&initial_ctx)) - (guint8*)(MONO_CONTEXT_GET_SP (ctx));
-                       else
-                               free_stack = (guint8*)(MONO_CONTEXT_GET_SP (ctx)) - (guint8*)(MONO_CONTEXT_GET_SP (&initial_ctx));
+                       free_stack = (guint8*)(MONO_CONTEXT_GET_SP (ctx)) - (guint8*)(MONO_CONTEXT_GET_SP (&initial_ctx));
                } else {
                        free_stack = 0xffffff;
                }
@@ -1719,7 +1700,7 @@ mono_handle_exception_internal_first_pass (MonoContext *ctx, MonoObject *obj, gi
 
                                if (ei->flags == MONO_EXCEPTION_CLAUSE_FILTER) {
 #ifndef DISABLE_PERFCOUNTERS
-                                       mono_perfcounters->exceptions_filters++;
+                                       InterlockedIncrement (&mono_perfcounters->exceptions_filters);
 #endif
 
 #ifndef MONO_CROSS_COMPILE
@@ -2044,10 +2025,7 @@ mono_handle_exception_internal (MonoContext *ctx, MonoObject *obj, gboolean resu
                //printf ("M: %s %d.\n", mono_method_full_name (method, TRUE), frame_count);
 
                if (stack_overflow) {
-                       if (MONO_ARCH_STACK_GROWS_UP)
-                               free_stack = (guint8*)(MONO_CONTEXT_GET_SP (&initial_ctx)) - (guint8*)(MONO_CONTEXT_GET_SP (ctx));
-                       else
-                               free_stack = (guint8*)(MONO_CONTEXT_GET_SP (ctx)) - (guint8*)(MONO_CONTEXT_GET_SP (&initial_ctx));
+                       free_stack = (guint8*)(MONO_CONTEXT_GET_SP (ctx)) - (guint8*)(MONO_CONTEXT_GET_SP (&initial_ctx));
                } else {
                        free_stack = 0xffffff;
                }
@@ -2175,7 +2153,7 @@ mono_handle_exception_internal (MonoContext *ctx, MonoObject *obj, gboolean resu
                                        }
                                        mono_set_lmf (lmf);
 #ifndef DISABLE_PERFCOUNTERS
-                                       mono_perfcounters->exceptions_depth += frame_count;
+                                       InterlockedAdd (&mono_perfcounters->exceptions_depth, frame_count);
 #endif
                                        if (obj == (MonoObject *)domain->stack_overflow_ex)
                                                jit_tls->handling_stack_ovf = FALSE;
@@ -2197,7 +2175,7 @@ mono_handle_exception_internal (MonoContext *ctx, MonoObject *obj, gboolean resu
                                        MONO_PROFILER_RAISE (exception_clause, (method, i, ei->flags, ex_obj));
                                        jit_tls->orig_ex_ctx_set = FALSE;
 #ifndef DISABLE_PERFCOUNTERS
-                                       mono_perfcounters->exceptions_finallys++;
+                                       InterlockedIncrement (&mono_perfcounters->exceptions_finallys);
 #endif
                                }
                                if (ei->flags == MONO_EXCEPTION_CLAUSE_FAULT || ei->flags == MONO_EXCEPTION_CLAUSE_FINALLY) {
@@ -2299,7 +2277,7 @@ mono_handle_exception (MonoContext *ctx, MonoObject *obj)
        MONO_REQ_GC_UNSAFE_MODE;
 
 #ifndef DISABLE_PERFCOUNTERS
-       mono_perfcounters->exceptions_thrown++;
+       InterlockedIncrement (&mono_perfcounters->exceptions_thrown);
 #endif
 
        return mono_handle_exception_internal (ctx, obj, FALSE, NULL);
index 243c83cbe5d9cbbbe8e902d1d27ab72a043269e4..5faf64957697fb047ffe544673c6e28e6244fde1 100644 (file)
@@ -16,6 +16,8 @@
 #include <mono/metadata/method-builder.h>
 #include <mono/metadata/reflection-internals.h>
 #include <mono/utils/mono-counters.h>
+#include <mono/utils/atomic.h>
+#include <mono/utils/unlocked.h>
 
 #include "mini.h"
 
@@ -32,10 +34,19 @@ static void
 mono_class_unregister_image_generic_subclasses (MonoImage *image, gpointer user_data);
 
 /* Counters */
-static int num_templates_allocted;
-static int num_templates_bytes;
-static int num_oti_allocted;
-static int num_oti_bytes;
+static gint32 rgctx_template_num_allocated;
+static gint32 rgctx_template_bytes_allocated;
+static gint32 rgctx_oti_num_allocated;
+static gint32 rgctx_oti_bytes_allocated;
+static gint32 rgctx_oti_num_markers;
+static gint32 rgctx_oti_num_data;
+static gint32 rgctx_max_slot_number;
+static gint32 rgctx_num_allocated;
+static gint32 rgctx_num_arrays_allocated;
+static gint32 rgctx_bytes_allocated;
+static gint32 mrgctx_num_arrays_allocated;
+static gint32 mrgctx_bytes_allocated;
+static gint32 gsharedvt_num_trampolines;
 
 #define gshared_lock() mono_os_mutex_lock (&gshared_mutex)
 #define gshared_unlock() mono_os_mutex_unlock (&gshared_mutex)
@@ -354,10 +365,10 @@ mono_class_unregister_image_generic_subclasses (MonoImage *image, gpointer user_
 static MonoRuntimeGenericContextTemplate*
 alloc_template (MonoClass *klass)
 {
-       int size = sizeof (MonoRuntimeGenericContextTemplate);
+       gint32 size = sizeof (MonoRuntimeGenericContextTemplate);
 
-       num_templates_allocted++;
-       num_templates_bytes += size;
+       InterlockedIncrement (&rgctx_template_num_allocated);
+       InterlockedAdd(&rgctx_template_bytes_allocated, size);
 
        return (MonoRuntimeGenericContextTemplate *)mono_image_alloc0 (klass->image, size);
 }
@@ -366,10 +377,10 @@ alloc_template (MonoClass *klass)
 static MonoRuntimeGenericContextInfoTemplate*
 alloc_oti (MonoImage *image)
 {
-       int size = sizeof (MonoRuntimeGenericContextInfoTemplate);
+       gint32 size = sizeof (MonoRuntimeGenericContextInfoTemplate);
 
-       num_oti_allocted++;
-       num_oti_bytes += size;
+       InterlockedIncrement (&rgctx_oti_num_allocated);
+       InterlockedAdd (&rgctx_oti_bytes_allocated, size);
 
        return (MonoRuntimeGenericContextInfoTemplate *)mono_image_alloc0 (image, size);
 }
@@ -404,20 +415,10 @@ static void
 rgctx_template_set_slot (MonoImage *image, MonoRuntimeGenericContextTemplate *template_, int type_argc,
        int slot, gpointer data, MonoRgctxInfoType info_type)
 {
-       static gboolean inited = FALSE;
-       static int num_markers = 0;
-       static int num_data = 0;
-
        int i;
        MonoRuntimeGenericContextInfoTemplate *list = get_info_templates (template_, type_argc);
        MonoRuntimeGenericContextInfoTemplate **oti = &list;
 
-       if (!inited) {
-               mono_counters_register ("RGCTX oti num markers", MONO_COUNTER_GENERICS | MONO_COUNTER_INT, &num_markers);
-               mono_counters_register ("RGCTX oti num data", MONO_COUNTER_GENERICS | MONO_COUNTER_INT, &num_data);
-               inited = TRUE;
-       }
-
        g_assert (slot >= 0);
        g_assert (data);
 
@@ -436,10 +437,11 @@ rgctx_template_set_slot (MonoImage *image, MonoRuntimeGenericContextTemplate *te
 
        set_info_templates (image, template_, type_argc, list);
 
+       /* interlocked by loader lock (by definition) */
        if (data == MONO_RGCTX_SLOT_USED_MARKER)
-               ++num_markers;
+               UnlockedIncrement (&rgctx_oti_num_markers);
        else
-               ++num_data;
+               UnlockedIncrement (&rgctx_oti_num_data);
 }
 
 /*
@@ -1616,8 +1618,6 @@ mini_get_gsharedvt_out_sig_wrapper_signature (gboolean has_this, gboolean has_re
 gpointer
 mini_get_gsharedvt_wrapper (gboolean gsharedvt_in, gpointer addr, MonoMethodSignature *normal_sig, MonoMethodSignature *gsharedvt_sig, gint32 vcall_offset, gboolean calli)
 {
-       static gboolean inited = FALSE;
-       static int num_trampolines;
        MonoError error;
        gpointer res, info;
        MonoDomain *domain = mono_domain_get ();
@@ -1625,11 +1625,6 @@ mini_get_gsharedvt_wrapper (gboolean gsharedvt_in, gpointer addr, MonoMethodSign
        GSharedVtTrampInfo *tramp_info;
        GSharedVtTrampInfo tinfo;
 
-       if (!inited) {
-               mono_counters_register ("GSHAREDVT arg trampolines", MONO_COUNTER_JIT | MONO_COUNTER_INT, &num_trampolines);
-               inited = TRUE;
-       }
-
        if (mono_llvm_only) {
                MonoMethod *wrapper;
 
@@ -1696,7 +1691,7 @@ mini_get_gsharedvt_wrapper (gboolean gsharedvt_in, gpointer addr, MonoMethodSign
        else
                addr = mono_arch_get_gsharedvt_arg_trampoline (mono_domain_get (), info, addr);
 
-       num_trampolines ++;
+       InterlockedIncrement (&gsharedvt_num_trampolines);
 
        /* Cache it */
        tramp_info = (GSharedVtTrampInfo *)mono_domain_alloc0 (domain, sizeof (GSharedVtTrampInfo));
@@ -2354,9 +2349,6 @@ static int
 lookup_or_register_info (MonoClass *klass, int type_argc, gpointer data, MonoRgctxInfoType info_type,
        MonoGenericContext *generic_context)
 {
-       static gboolean inited = FALSE;
-       static int max_slot = 0;
-
        MonoRuntimeGenericContextTemplate *rgctx_template =
                mono_class_get_runtime_generic_context_template (klass);
        MonoRuntimeGenericContextInfoTemplate *oti_list, *oti;
@@ -2389,14 +2381,11 @@ lookup_or_register_info (MonoClass *klass, int type_argc, gpointer data, MonoRgc
        /* We haven't found the info */
        i = register_info (klass, type_argc, data, info_type);
 
-       mono_loader_unlock ();
+       /* interlocked by loader lock */
+       if (i > UnlockedRead (&rgctx_max_slot_number))
+               UnlockedWrite (&rgctx_max_slot_number, i);
 
-       if (!inited) {
-               mono_counters_register ("RGCTX max slot number", MONO_COUNTER_GENERICS | MONO_COUNTER_INT, &max_slot);
-               inited = TRUE;
-       }
-       if (i > max_slot)
-               max_slot = i;
+       mono_loader_unlock ();
 
        return i;
 }
@@ -2466,29 +2455,16 @@ mono_class_rgctx_get_array_size (int n, gboolean mrgctx)
 static gpointer*
 alloc_rgctx_array (MonoDomain *domain, int n, gboolean is_mrgctx)
 {
-       static gboolean inited = FALSE;
-       static int rgctx_num_alloced = 0;
-       static int rgctx_bytes_alloced = 0;
-       static int mrgctx_num_alloced = 0;
-       static int mrgctx_bytes_alloced = 0;
-
-       int size = mono_class_rgctx_get_array_size (n, is_mrgctx) * sizeof (gpointer);
+       gint32 size = mono_class_rgctx_get_array_size (n, is_mrgctx) * sizeof (gpointer);
        gpointer *array = (gpointer *)mono_domain_alloc0 (domain, size);
 
-       if (!inited) {
-               mono_counters_register ("RGCTX num arrays alloced", MONO_COUNTER_GENERICS | MONO_COUNTER_INT, &rgctx_num_alloced);
-               mono_counters_register ("RGCTX bytes alloced", MONO_COUNTER_GENERICS | MONO_COUNTER_INT, &rgctx_bytes_alloced);
-               mono_counters_register ("MRGCTX num arrays alloced", MONO_COUNTER_GENERICS | MONO_COUNTER_INT, &mrgctx_num_alloced);
-               mono_counters_register ("MRGCTX bytes alloced", MONO_COUNTER_GENERICS | MONO_COUNTER_INT, &mrgctx_bytes_alloced);
-               inited = TRUE;
-       }
-
+       /* interlocked by domain lock (by definition) */
        if (is_mrgctx) {
-               mrgctx_num_alloced++;
-               mrgctx_bytes_alloced += size;
+               UnlockedIncrement (&mrgctx_num_arrays_allocated);
+               UnlockedAdd (&mrgctx_bytes_allocated, size);
        } else {
-               rgctx_num_alloced++;
-               rgctx_bytes_alloced += size;
+               UnlockedIncrement (&rgctx_num_arrays_allocated);
+               UnlockedAdd (&rgctx_bytes_allocated, size);
        }
 
        return array;
@@ -2589,9 +2565,6 @@ fill_runtime_generic_context (MonoVTable *class_vtable, MonoRuntimeGenericContex
 gpointer
 mono_class_fill_runtime_generic_context (MonoVTable *class_vtable, guint32 slot, MonoError *error)
 {
-       static gboolean inited = FALSE;
-       static int num_alloced = 0;
-
        MonoDomain *domain = class_vtable->domain;
        MonoRuntimeGenericContext *rgctx;
        gpointer info;
@@ -2600,16 +2573,11 @@ mono_class_fill_runtime_generic_context (MonoVTable *class_vtable, guint32 slot,
 
        mono_domain_lock (domain);
 
-       if (!inited) {
-               mono_counters_register ("RGCTX num alloced", MONO_COUNTER_GENERICS | MONO_COUNTER_INT, &num_alloced);
-               inited = TRUE;
-       }
-
        rgctx = class_vtable->runtime_generic_context;
        if (!rgctx) {
                rgctx = alloc_rgctx_array (domain, 0, FALSE);
                class_vtable->runtime_generic_context = rgctx;
-               num_alloced++;
+               UnlockedIncrement (&rgctx_num_allocated); /* interlocked by domain lock */
        }
 
        mono_domain_unlock (domain);
@@ -3326,10 +3294,19 @@ mini_type_stack_size_full (MonoType *t, guint32 *align, gboolean pinvoke)
 void
 mono_generic_sharing_init (void)
 {
-       mono_counters_register ("RGCTX template num allocted", MONO_COUNTER_GENERICS | MONO_COUNTER_INT, &num_templates_allocted);
-       mono_counters_register ("RGCTX template bytes allocted", MONO_COUNTER_GENERICS | MONO_COUNTER_INT, &num_templates_bytes);
-       mono_counters_register ("RGCTX oti num allocted", MONO_COUNTER_GENERICS | MONO_COUNTER_INT, &num_oti_allocted);
-       mono_counters_register ("RGCTX oti bytes allocted", MONO_COUNTER_GENERICS | MONO_COUNTER_INT, &num_oti_bytes);
+       mono_counters_register ("RGCTX template num allocated", MONO_COUNTER_GENERICS | MONO_COUNTER_INT, &rgctx_template_num_allocated);
+       mono_counters_register ("RGCTX template bytes allocated", MONO_COUNTER_GENERICS | MONO_COUNTER_INT, &rgctx_template_bytes_allocated);
+       mono_counters_register ("RGCTX oti num allocated", MONO_COUNTER_GENERICS | MONO_COUNTER_INT, &rgctx_oti_num_allocated);
+       mono_counters_register ("RGCTX oti bytes allocated", MONO_COUNTER_GENERICS | MONO_COUNTER_INT, &rgctx_oti_bytes_allocated);
+       mono_counters_register ("RGCTX oti num markers", MONO_COUNTER_GENERICS | MONO_COUNTER_INT, &rgctx_oti_num_markers);
+       mono_counters_register ("RGCTX oti num data", MONO_COUNTER_GENERICS | MONO_COUNTER_INT, &rgctx_oti_num_data);
+       mono_counters_register ("RGCTX max slot number", MONO_COUNTER_GENERICS | MONO_COUNTER_INT, &rgctx_max_slot_number);
+       mono_counters_register ("RGCTX num allocated", MONO_COUNTER_GENERICS | MONO_COUNTER_INT, &rgctx_num_allocated);
+       mono_counters_register ("RGCTX num arrays allocated", MONO_COUNTER_GENERICS | MONO_COUNTER_INT, &rgctx_num_arrays_allocated);
+       mono_counters_register ("RGCTX bytes allocated", MONO_COUNTER_GENERICS | MONO_COUNTER_INT, &rgctx_bytes_allocated);
+       mono_counters_register ("MRGCTX num arrays allocated", MONO_COUNTER_GENERICS | MONO_COUNTER_INT, &mrgctx_num_arrays_allocated);
+       mono_counters_register ("MRGCTX bytes allocated", MONO_COUNTER_GENERICS | MONO_COUNTER_INT, &mrgctx_bytes_allocated);
+       mono_counters_register ("GSHAREDVT num trampolines", MONO_COUNTER_JIT | MONO_COUNTER_INT, &gsharedvt_num_trampolines);
 
        mono_install_image_unload_hook (mono_class_unregister_image_generic_subclasses, NULL);
 
index 8ac2da6b60711132f7873655aa30e318bc9a18d9..253cd42ff81b93f61cfa49d1a40eac51737e1a82 100644 (file)
@@ -30,6 +30,7 @@
 #include <llvm/IR/IRBuilder.h>
 #include <llvm/IR/Module.h>
 #include <llvm/IR/DIBuilder.h>
+#include <llvm/IR/CallSite.h>
 
 #include "mini-llvm-cpp.h"
 
@@ -56,7 +57,11 @@ mono_llvm_build_alloca (LLVMBuilderRef builder, LLVMTypeRef Ty,
                                                LLVMValueRef ArraySize,
                                                int alignment, const char *Name)
 {
+#if LLVM_API_VERSION >= 500
+       return wrap (unwrap (builder)->Insert (new AllocaInst (unwrap (Ty), 0, unwrap (ArraySize), alignment), Name));
+#else
        return wrap (unwrap (builder)->Insert (new AllocaInst (unwrap (Ty), unwrap (ArraySize), alignment), Name));
+#endif
 }
 
 LLVMValueRef 
@@ -244,6 +249,106 @@ mono_llvm_set_call_notail (LLVMValueRef func)
 #endif
 }
 
+#if LLVM_API_VERSION > 500
+static Attribute::AttrKind
+convert_attr (AttrKind kind)
+{
+       switch (kind) {
+       case LLVM_ATTR_NO_UNWIND:
+               return Attribute::NoUnwind;
+       case LLVM_ATTR_NO_INLINE:
+               return Attribute::NoInline;
+       case LLVM_ATTR_OPTIMIZE_FOR_SIZE:
+               return Attribute::OptimizeForSize;
+       case LLVM_ATTR_IN_REG:
+               return Attribute::InReg;
+       case LLVM_ATTR_STRUCT_RET:
+               return Attribute::StructRet;
+       case LLVM_ATTR_NO_ALIAS:
+               return Attribute::NoAlias;
+       case LLVM_ATTR_BY_VAL:
+               return Attribute::ByVal;
+       case LLVM_ATTR_UW_TABLE:
+               return Attribute::UWTable;
+       default:
+               assert (0);
+               return Attribute::NoUnwind;
+       }
+}
+#else
+static LLVMAttribute
+convert_attr (AttrKind kind)
+{
+       switch (kind) {
+       case LLVM_ATTR_NO_UNWIND:
+               return LLVMNoUnwindAttribute;
+       case LLVM_ATTR_NO_INLINE:
+               return LLVMNoInlineAttribute;
+       case LLVM_ATTR_OPTIMIZE_FOR_SIZE:
+               return LLVMOptimizeForSizeAttribute;
+       case LLVM_ATTR_IN_REG:
+               return LLVMInRegAttribute;
+       case LLVM_ATTR_STRUCT_RET:
+               return LLVMStructRetAttribute;
+       case LLVM_ATTR_NO_ALIAS:
+               return LLVMNoAliasAttribute;
+       case LLVM_ATTR_BY_VAL:
+               return LLVMByValAttribute;
+       case LLVM_ATTR_UW_TABLE:
+               return LLVMUWTable;
+       default:
+               assert (0);
+               return LLVMNoUnwindAttribute;
+       }
+}
+#endif
+
+void
+mono_llvm_add_func_attr (LLVMValueRef func, AttrKind kind)
+{
+#if LLVM_API_VERSION > 100
+       unwrap<Function> (func)->addAttribute (AttributeList::FunctionIndex, convert_attr (kind));
+#else
+       Function *Func = unwrap<Function>(func);
+       const AttributeSet PAL = Func->getAttributes();
+       AttrBuilder B(convert_attr (kind));
+       const AttributeSet PALnew =
+               PAL.addAttributes(Func->getContext(), AttributeSet::FunctionIndex,
+                                                 AttributeSet::get(Func->getContext(),
+                                                                                       AttributeSet::FunctionIndex, B));
+       Func->setAttributes(PALnew);
+#endif
+}
+
+void
+mono_llvm_add_param_attr (LLVMValueRef param, AttrKind kind)
+{
+#if LLVM_API_VERSION > 100
+       Function *func = unwrap<Argument> (param)->getParent ();
+       int n = unwrap<Argument> (param)->getArgNo ();
+       func->addParamAttr (n, convert_attr (kind));
+#else
+       Argument *A = unwrap<Argument>(param);
+       AttrBuilder B(convert_attr (kind));
+       A->addAttr(AttributeSet::get(A->getContext(), A->getArgNo() + 1,  B));
+#endif
+}
+
+void
+mono_llvm_add_instr_attr (LLVMValueRef val, int index, AttrKind kind)
+{
+#if LLVM_API_VERSION > 100
+       CallSite (unwrap<Instruction> (val)).addAttribute (index, convert_attr (kind));
+#else
+  CallSite Call = CallSite(unwrap<Instruction>(val));
+  AttrBuilder B(convert_attr (kind));
+  Call.setAttributes(
+    Call.getAttributes().addAttributes(Call->getContext(), index,
+                                       AttributeSet::get(Call->getContext(),
+                                                         index, B)));
+#endif
+}
+
 #if LLVM_API_VERSION > 100
 
 void*
@@ -257,7 +362,14 @@ mono_llvm_di_create_compile_unit (void *di_builder, const char *cu_name, const c
 {
        DIBuilder *builder = (DIBuilder*)di_builder;
 
+#if LLVM_API_VERSION >= 500
+       DIFile *di_file;
+
+       di_file = builder->createFile (cu_name, dir);
+       return builder->createCompileUnit (dwarf::DW_LANG_C99, di_file, producer, true, "", 0);
+#else
        return builder->createCompileUnit (dwarf::DW_LANG_C99, cu_name, dir, producer, true, "", 0);
+#endif
 }
 
 void*
index 67dd9418a7da3f568b288ab010996b5fa1a6cc11..53ecc02de1a0a48e30a11562628e83d96541007c 100644 (file)
@@ -35,6 +35,17 @@ typedef enum {
        LLVM_ATOMICRMW_OP_ADD = 1,
 } AtomicRMWOp;
 
+typedef enum {
+       LLVM_ATTR_NO_UNWIND,
+       LLVM_ATTR_NO_INLINE,
+       LLVM_ATTR_OPTIMIZE_FOR_SIZE,
+       LLVM_ATTR_IN_REG,
+       LLVM_ATTR_STRUCT_RET,
+       LLVM_ATTR_NO_ALIAS,
+       LLVM_ATTR_BY_VAL,
+       LLVM_ATTR_UW_TABLE
+} AttrKind;
+
 void
 mono_llvm_dump_value (LLVMValueRef value);
 
@@ -93,6 +104,15 @@ mono_llvm_set_call_preserveall_cc (LLVMValueRef call);
 void
 mono_llvm_set_call_notail (LLVMValueRef call);
 
+void
+mono_llvm_add_func_attr (LLVMValueRef func, AttrKind kind);
+
+void
+mono_llvm_add_param_attr (LLVMValueRef param, AttrKind kind);
+
+void
+mono_llvm_add_instr_attr (LLVMValueRef val, int index, AttrKind kind);
+
 _Unwind_Reason_Code 
 mono_debug_personality (int a, _Unwind_Action b,
        uint64_t c, struct _Unwind_Exception *d, struct _Unwind_Context *e);
index f072ac56c1eb5f3561fbd7802ffbf85b31643771..8a0b622da281a5d7917e799a7f247b72fc70c0b3 100644 (file)
@@ -2465,7 +2465,7 @@ emit_get_method (MonoLLVMModule *module)
        func = LLVMAddFunction (lmodule, module->get_method_symbol, LLVMFunctionType1 (rtype, LLVMInt32Type (), FALSE));
        LLVMSetLinkage (func, LLVMExternalLinkage);
        LLVMSetVisibility (func, LLVMHiddenVisibility);
-       LLVMAddFunctionAttr (func, LLVMNoUnwindAttribute);
+       mono_llvm_add_func_attr (func, LLVM_ATTR_NO_UNWIND);
        module->get_method = func;
 
        entry_bb = LLVMAppendBasicBlock (func, "ENTRY");
@@ -2545,7 +2545,7 @@ emit_get_unbox_tramp (MonoLLVMModule *module)
        func = LLVMAddFunction (lmodule, module->get_unbox_tramp_symbol, LLVMFunctionType1 (rtype, LLVMInt32Type (), FALSE));
        LLVMSetLinkage (func, LLVMExternalLinkage);
        LLVMSetVisibility (func, LLVMHiddenVisibility);
-       LLVMAddFunctionAttr (func, LLVMNoUnwindAttribute);
+       mono_llvm_add_func_attr (func, LLVM_ATTR_NO_UNWIND);
        module->get_unbox_tramp = func;
 
        entry_bb = LLVMAppendBasicBlock (func, "ENTRY");
@@ -2596,7 +2596,7 @@ emit_llvm_code_start (MonoLLVMModule *module)
 
        func = LLVMAddFunction (lmodule, "llvm_code_start", LLVMFunctionType (LLVMVoidType (), NULL, 0, FALSE));
        LLVMSetLinkage (func, LLVMInternalLinkage);
-       LLVMAddFunctionAttr (func, LLVMNoUnwindAttribute);
+       mono_llvm_add_func_attr (func, LLVM_ATTR_NO_UNWIND);
        module->code_start = func;
        entry_bb = LLVMAppendBasicBlock (func, "ENTRY");
        builder = LLVMCreateBuilder ();
@@ -2635,7 +2635,7 @@ emit_init_icall_wrapper (MonoLLVMModule *module, const char *name, const char *i
                g_assert_not_reached ();
        }
        LLVMSetLinkage (func, LLVMInternalLinkage);
-       LLVMAddFunctionAttr (func, LLVMNoInlineAttribute);
+       mono_llvm_add_func_attr (func, LLVM_ATTR_NO_INLINE);
        mono_llvm_set_preserveall_cc (func);
        entry_bb = LLVMAppendBasicBlock (func, "ENTRY");
        builder = LLVMCreateBuilder ();
@@ -2704,7 +2704,7 @@ emit_llvm_code_end (MonoLLVMModule *module)
 
        func = LLVMAddFunction (lmodule, "llvm_code_end", LLVMFunctionType (LLVMVoidType (), NULL, 0, FALSE));
        LLVMSetLinkage (func, LLVMInternalLinkage);
-       LLVMAddFunctionAttr (func, LLVMNoUnwindAttribute);
+       mono_llvm_add_func_attr (func, LLVM_ATTR_NO_UNWIND);
        module->code_end = func;
        entry_bb = LLVMAppendBasicBlock (func, "ENTRY");
        builder = LLVMCreateBuilder ();
@@ -2857,17 +2857,17 @@ emit_unbox_tramp (EmitContext *ctx, const char *method_name, LLVMTypeRef method_
        tramp_name = g_strdup_printf ("ut_%s", method_name);
        tramp = LLVMAddFunction (ctx->module->lmodule, tramp_name, method_type);
        LLVMSetLinkage (tramp, LLVMInternalLinkage);
-       LLVMAddFunctionAttr (tramp, LLVMOptimizeForSizeAttribute);
-       //LLVMAddFunctionAttr (tramp, LLVMNoUnwindAttribute);
+       mono_llvm_add_func_attr (tramp, LLVM_ATTR_OPTIMIZE_FOR_SIZE);
+       //mono_llvm_add_func_attr (tramp, LLVM_ATTR_NO_UNWIND);
        linfo = ctx->linfo;
        // FIXME: Reduce code duplication with mono_llvm_compile_method () etc.
        if (!ctx->llvm_only && ctx->rgctx_arg_pindex != -1)
-               LLVMAddAttribute (LLVMGetParam (tramp, ctx->rgctx_arg_pindex), LLVMInRegAttribute);
+               mono_llvm_add_param_attr (LLVMGetParam (tramp, ctx->rgctx_arg_pindex), LLVM_ATTR_IN_REG);
        if (ctx->cfg->vret_addr) {
                LLVMSetValueName (LLVMGetParam (tramp, linfo->vret_arg_pindex), "vret");
                if (linfo->ret.storage == LLVMArgVtypeByRef) {
-                       LLVMAddAttribute (LLVMGetParam (tramp, linfo->vret_arg_pindex), LLVMStructRetAttribute);
-                       LLVMAddAttribute (LLVMGetParam (tramp, linfo->vret_arg_pindex), LLVMNoAliasAttribute);
+                       mono_llvm_add_param_attr (LLVMGetParam (tramp, linfo->vret_arg_pindex), LLVM_ATTR_STRUCT_RET);
+                       mono_llvm_add_param_attr (LLVMGetParam (tramp, linfo->vret_arg_pindex), LLVM_ATTR_NO_ALIAS);
                }
        }
 
@@ -2889,9 +2889,9 @@ emit_unbox_tramp (EmitContext *ctx, const char *method_name, LLVMTypeRef method_
        }
        call = LLVMBuildCall (builder, method, args, nargs, "");
        if (!ctx->llvm_only && ctx->rgctx_arg_pindex != -1)
-               LLVMAddInstrAttribute (call, 1 + ctx->rgctx_arg_pindex, LLVMInRegAttribute);
+               mono_llvm_add_instr_attr (call, 1 + ctx->rgctx_arg_pindex, LLVM_ATTR_IN_REG);
        if (linfo->ret.storage == LLVMArgVtypeByRef)
-               LLVMAddInstrAttribute (call, 1 + linfo->vret_arg_pindex, LLVMStructRetAttribute);
+               mono_llvm_add_instr_attr (call, 1 + linfo->vret_arg_pindex, LLVM_ATTR_STRUCT_RET);
 
        // FIXME: This causes assertions in clang
        //mono_llvm_set_must_tail (call);
@@ -3541,18 +3541,18 @@ process_call (EmitContext *ctx, MonoBasicBlock *bb, LLVMBuilderRef *builder_ref,
                mono_llvm_set_call_preserveall_cc (lcall);
 
        if (cinfo->ret.storage == LLVMArgVtypeByRef)
-               LLVMAddInstrAttribute (lcall, 1 + cinfo->vret_arg_pindex, LLVMStructRetAttribute);
+               mono_llvm_add_instr_attr (lcall, 1 + cinfo->vret_arg_pindex, LLVM_ATTR_STRUCT_RET);
        if (!ctx->llvm_only && call->rgctx_arg_reg)
-               LLVMAddInstrAttribute (lcall, 1 + cinfo->rgctx_arg_pindex, LLVMInRegAttribute);
+               mono_llvm_add_instr_attr (lcall, 1 + cinfo->rgctx_arg_pindex, LLVM_ATTR_IN_REG);
        if (call->imt_arg_reg)
-               LLVMAddInstrAttribute (lcall, 1 + cinfo->imt_arg_pindex, LLVMInRegAttribute);
+               mono_llvm_add_instr_attr (lcall, 1 + cinfo->imt_arg_pindex, LLVM_ATTR_IN_REG);
 
        /* Add byval attributes if needed */
        for (i = 0; i < sig->param_count; ++i) {
                LLVMArgInfo *ainfo = &call->cinfo->args [i + sig->hasthis];
 
                if (ainfo && ainfo->storage == LLVMArgVtypeByVal)
-                       LLVMAddInstrAttribute (lcall, 1 + ainfo->pindex, LLVMByValAttribute);
+                       mono_llvm_add_instr_attr (lcall, 1 + ainfo->pindex, LLVM_ATTR_BY_VAL);
        }
 
        /*
@@ -4011,18 +4011,15 @@ emit_handler_start (EmitContext *ctx, MonoBasicBlock *bb, LLVMBuilderRef builder
                g_assert (personality);
        } else {
 #if LLVM_API_VERSION > 100
-               personality = ctx->module->personality;
-               if (!personality) {
-                       LLVMTypeRef personality_type = LLVMFunctionType (LLVMInt32Type (), NULL, 0, TRUE);
-                       personality = LLVMAddFunction (ctx->lmodule, "mono_personality", personality_type);
-                       LLVMAddFunctionAttr (personality, LLVMNoUnwindAttribute);
-                       LLVMBasicBlockRef entry_bb = LLVMAppendBasicBlock (personality, "ENTRY");
-                       LLVMBuilderRef builder2 = LLVMCreateBuilder ();
-                       LLVMPositionBuilderAtEnd (builder2, entry_bb);
-                       LLVMBuildRet (builder2, LLVMConstInt (LLVMInt32Type (), 0, FALSE));
-                       ctx->module->personality = personality;
-                       LLVMDisposeBuilder (builder2);
-               }
+               /* Can't cache this as each method is in its own llvm module */
+               LLVMTypeRef personality_type = LLVMFunctionType (LLVMInt32Type (), NULL, 0, TRUE);
+               personality = LLVMAddFunction (ctx->lmodule, "mono_personality", personality_type);
+               mono_llvm_add_func_attr (personality, LLVM_ATTR_NO_UNWIND);
+               LLVMBasicBlockRef entry_bb = LLVMAppendBasicBlock (personality, "ENTRY");
+               LLVMBuilderRef builder2 = LLVMCreateBuilder ();
+               LLVMPositionBuilderAtEnd (builder2, entry_bb);
+               LLVMBuildRet (builder2, LLVMConstInt (LLVMInt32Type (), 0, FALSE));
+               LLVMDisposeBuilder (builder2);
 #else
                static gint32 mapping_inited;
 
@@ -6466,7 +6463,11 @@ process_bb (EmitContext *ctx, MonoBasicBlock *bb)
                        args [0] = lhs;
                        args [1] = rhs;
                        /* 0xf1 == multiply all 4 elements, add them together, and store the result to the lowest element */
+#if LLVM_API_VERSION >= 500
+                       args [2] = LLVMConstInt (LLVMInt8Type (), 0xf1, FALSE);
+#else
                        args [2] = LLVMConstInt (LLVMInt32Type (), 0xf1, FALSE);
+#endif
 
                        values [ins->dreg] = LLVMBuildCall (builder, get_intrinsic (ctx, simd_op_to_intrins (ins->opcode)), args, 3, dname);
                        break;
@@ -6875,7 +6876,7 @@ mono_llvm_emit_method (MonoCompile *cfg)
        if (cfg->compile_aot)
                ctx->lmodule = ctx->module->lmodule;
        else
-               ctx->lmodule = LLVMModuleCreateWithName ("jit-module");
+               ctx->lmodule = LLVMModuleCreateWithName (g_strdup_printf ("jit-module-%s", cfg->method->name));
 #else
        ctx->lmodule = ctx->module->lmodule;
 #endif
@@ -6976,7 +6977,7 @@ emit_method_inner (EmitContext *ctx)
                LLVMSetFunctionCallConv (method, LLVMMono1CallConv);
        LLVMSetLinkage (method, LLVMPrivateLinkage);
 
-       LLVMAddFunctionAttr (method, LLVMUWTable);
+       mono_llvm_add_func_attr (method, LLVM_ATTR_UW_TABLE);
 
        if (cfg->compile_aot) {
                LLVMSetLinkage (method, LLVMInternalLinkage);
@@ -7016,7 +7017,7 @@ emit_method_inner (EmitContext *ctx)
        }
        if (header->num_clauses || (cfg->method->iflags & METHOD_IMPL_ATTRIBUTE_NOINLINING) || cfg->no_inline)
                /* We can't handle inlined methods with clauses */
-               LLVMAddFunctionAttr (method, LLVMNoInlineAttribute);
+               mono_llvm_add_func_attr (method, LLVM_ATTR_NO_INLINE);
 
        if (linfo->rgctx_arg) {
                ctx->rgctx_arg = LLVMGetParam (method, linfo->rgctx_arg_pindex);
@@ -7027,7 +7028,7 @@ emit_method_inner (EmitContext *ctx)
                 * CC_X86_64_Mono in X86CallingConv.td.
                 */
                if (!ctx->llvm_only)
-                       LLVMAddAttribute (ctx->rgctx_arg, LLVMInRegAttribute);
+                       mono_llvm_add_param_attr (ctx->rgctx_arg, LLVM_ATTR_IN_REG);
                LLVMSetValueName (ctx->rgctx_arg, "rgctx");
        } else {
                ctx->rgctx_arg_pindex = -1;
@@ -7036,8 +7037,8 @@ emit_method_inner (EmitContext *ctx)
                values [cfg->vret_addr->dreg] = LLVMGetParam (method, linfo->vret_arg_pindex);
                LLVMSetValueName (values [cfg->vret_addr->dreg], "vret");
                if (linfo->ret.storage == LLVMArgVtypeByRef) {
-                       LLVMAddAttribute (LLVMGetParam (method, linfo->vret_arg_pindex), LLVMStructRetAttribute);
-                       LLVMAddAttribute (LLVMGetParam (method, linfo->vret_arg_pindex), LLVMNoAliasAttribute);
+                       mono_llvm_add_param_attr (LLVMGetParam (method, linfo->vret_arg_pindex), LLVM_ATTR_STRUCT_RET);
+                       mono_llvm_add_param_attr (LLVMGetParam (method, linfo->vret_arg_pindex), LLVM_ATTR_NO_ALIAS);
                }
        }
 
@@ -7082,7 +7083,7 @@ emit_method_inner (EmitContext *ctx)
                LLVMSetValueName (values [cfg->args [i + sig->hasthis]->dreg], name);
                g_free (name);
                if (ainfo->storage == LLVMArgVtypeByVal)
-                       LLVMAddAttribute (LLVMGetParam (method, pindex), LLVMByValAttribute);
+                       mono_llvm_add_param_attr (LLVMGetParam (method, pindex), LLVM_ATTR_BY_VAL);
 
                if (ainfo->storage == LLVMArgVtypeByRef) {
                        /* For OP_LDADDR */
@@ -8215,7 +8216,11 @@ add_intrinsic (LLVMModuleRef module, int id)
                ret_type = type_to_simd_type (MONO_TYPE_R4);
                arg_types [0] = type_to_simd_type (MONO_TYPE_R4);
                arg_types [1] = type_to_simd_type (MONO_TYPE_R4);
+#if LLVM_API_VERSION >= 500
+               arg_types [2] = LLVMInt8Type ();
+#else
                arg_types [2] = LLVMInt32Type ();
+#endif
                AddFunc (module, name, ret_type, arg_types, 3);
                break;
 #endif
index 29d8cb09fb77e0b2d84586309f48dc85243afc26..32ad106ab571ce0b975e13a92e824ddbec7afc56 100644 (file)
@@ -1219,6 +1219,14 @@ MINI_OP(OP_S390_IADD_OVF,       "s390_int_add_ovf", IREG, IREG, IREG)
 MINI_OP(OP_S390_IADD_OVF_UN,    "s390_int_add_ovf_un", IREG, IREG, IREG)
 MINI_OP(OP_S390_ISUB_OVF,       "s390_int_sub_ovf", IREG, IREG, IREG)
 MINI_OP(OP_S390_ISUB_OVF_UN,    "s390_int_sub_ovf_un", IREG, IREG, IREG)
+MINI_OP(OP_S390_CRJ,            "s390_crj", IREG, IREG, IREG)
+MINI_OP(OP_S390_CLRJ,           "s390_crj_un", IREG, IREG, IREG)
+MINI_OP(OP_S390_CGRJ,           "s390_cgrj", LREG, LREG, IREG)
+MINI_OP(OP_S390_CLGRJ,          "s390_cgrj_un", LREG, LREG, IREG)
+MINI_OP(OP_S390_CIJ,            "s390_cij", IREG, NONE, NONE)
+MINI_OP(OP_S390_CLIJ,           "s390_cij_un", IREG, IREG, NONE)
+MINI_OP(OP_S390_CGIJ,           "s390_cgij", LREG, NONE, NONE)
+MINI_OP(OP_S390_CLGIJ,          "s390_cgij_un", LREG, NONE, NONE)
 #endif
 
 #if defined(__mips__)
index 3b74b398e1bfed72b0773d0216b02bfb7208313a..a3f4883f74d5fc7ffc43c20047a7f5d254dcbc37 100644 (file)
@@ -2622,6 +2622,8 @@ mono_jit_runtime_invoke (MonoMethod *method, void *obj, void **params, MonoObjec
 #endif
 
        error_init (error);
+       if (exc)
+               *exc = NULL;
 
        if (obj == NULL && !(method->flags & METHOD_ATTRIBUTE_STATIC) && !method->string_ctor && (method->wrapper_type == 0)) {
                g_warning ("Ignoring invocation of an instance method on a NULL instance.\n");
index 28aa4dcb2d05fb371e5cae02737f766741bfd469..584813cc4db9caa812d9b5f4c9d75382cb6358f0 100644 (file)
@@ -61,6 +61,69 @@ if (ins->inst_target_bb->native_offset) {                                    \
                s390_jcl (code, cond, 0);                               \
        } while (0); 
 
+#define EMIT_COMP_AND_BRANCH(ins, cab, cmp)                                    \
+{                                                                              \
+if (ins->inst_true_bb->native_offset) {                                        \
+       int displace;                                                           \
+       displace = ((cfg->native_code +                                         \
+                   ins->inst_true_bb->native_offset) - code) / 2;              \
+       if (s390_is_imm16(displace)) {                                          \
+               s390_##cab (code, ins->sreg1, ins->sreg2,                       \
+                           ins->sreg3, displace);                              \
+       } else {                                                                \
+               s390_##cmp (code, ins->sreg1, ins->sreg2);                      \
+               displace = ((cfg->native_code +                                 \
+                           ins->inst_true_bb->native_offset) - code) / 2;      \
+               s390_jcl (code, ins->sreg3, displace);                          \
+       }                                                                       \
+} else {                                                                       \
+       s390_##cmp (code, ins->sreg1, ins->sreg2);                              \
+       mono_add_patch_info (cfg, code - cfg->native_code,                      \
+                            MONO_PATCH_INFO_BB, ins->inst_true_bb);            \
+       s390_jcl (code, ins->sreg3, 0);                                         \
+}                                                                              \
+}
+
+#define EMIT_COMP_AND_BRANCH_IMM(ins, cab, cmp, lat, logical)                  \
+{                                                                              \
+if (ins->inst_true_bb->native_offset) {                                        \
+       int displace;                                                           \
+       if ((ins->backend.data == 0) && (!logical)) {                           \
+               s390_##lat (code, ins->sreg1, ins->sreg1);                      \
+               displace = ((cfg->native_code +                                 \
+                           ins->inst_true_bb->native_offset) - code) / 2;      \
+               if (s390_is_imm16(displace)) {                                  \
+                       s390_brc (code, ins->sreg3, displace);                  \
+               } else {                                                        \
+                       s390_jcl (code, ins->sreg3, displace);                  \
+               }                                                               \
+       } else {                                                                \
+               S390_SET (code, s390_r0, ins->backend.data);                    \
+               displace = ((cfg->native_code +                                 \
+                           ins->inst_true_bb->native_offset) - code) / 2;      \
+               if (s390_is_imm16(displace)) {                                  \
+                       s390_##cab (code, ins->sreg1, s390_r0,                  \
+                                   ins->sreg3, displace);                      \
+               } else {                                                        \
+                       s390_##cmp (code, ins->sreg1, s390_r0);                 \
+                       displace = ((cfg->native_code +                         \
+                           ins->inst_true_bb->native_offset) - code) / 2;      \
+                       s390_jcl (code, ins->sreg3, displace);                  \
+               }                                                               \
+       }                                                                       \
+} else {                                                                       \
+       if ((ins->backend.data == 0) && (!logical)) {                           \
+               s390_##lat (code, ins->sreg1, ins->sreg1);                      \
+       } else {                                                                \
+               S390_SET (code, s390_r0, ins->backend.data);                    \
+               s390_##cmp (code, ins->sreg1, s390_r0);                         \
+       }                                                                       \
+       mono_add_patch_info (cfg, code - cfg->native_code,                      \
+                            MONO_PATCH_INFO_BB, ins->inst_true_bb);            \
+       s390_jcl (code, ins->sreg3, 0);                                         \
+}                                                                              \
+}
+
 #define CHECK_SRCDST_COM                                               \
        if (ins->dreg == ins->sreg2) {                                  \
                src2 = ins->sreg1;                                      \
@@ -379,6 +442,7 @@ static CallInfo * get_call_info (MonoCompile *, MonoMemPool *, MonoMethodSignatu
 static guchar * emit_float_to_int (MonoCompile *, guchar *, int, int, int, gboolean);
 static guint8 * emit_load_volatile_arguments (guint8 *, MonoCompile *);
 static __inline__ void emit_unwind_regs(MonoCompile *, guint8 *, int, int, long);
+static void compare_and_branch(MonoBasicBlock *, MonoInst *, int, gboolean);
 
 /*========================= End of Prototypes ======================*/
 
@@ -389,6 +453,8 @@ static __inline__ void emit_unwind_regs(MonoCompile *, guint8 *, int, int, long)
 int mono_exc_esp_offset = 0;
 
 __thread int indent_level = 0;
+__thread FILE *trFd = NULL;
+int curThreadNo = 0;
 
 /*
  * The code generated for sequence points reads from this location, 
@@ -647,9 +713,9 @@ indent (int diff) {
        if (diff < 0)
                indent_level += diff;
        v = indent_level;
-       printf("%p [%3d] ",(void *)pthread_self(),v);
+       fprintf (trFd, "%p [%3d] ",(void *)pthread_self(),v);
        while (v-- > 0) {
-               printf (". ");
+               fprintf (trFd, ". ");
        }
        if (diff > 0) 
                indent_level += diff;
@@ -750,9 +816,9 @@ cvtMonoType(MonoTypeEnum t)
 
 /*------------------------------------------------------------------*/
 /*                                                                  */
-/* Name                - decodeParm                                        */
+/* Name                - decodeParmString                                  */
 /*                                                                  */
-/* Function    - Decode a parameter for the trace.                 */
+/* Function    - Decode a parameter string for the trace.          */
 /*                                                                 */
 /*------------------------------------------------------------------*/
 
@@ -762,57 +828,68 @@ decodeParmString (MonoString *s)
        MonoError error;
        char *str = mono_string_to_utf8_checked(s, &error);
        if (is_ok (&error))  {
-               printf("[STRING:%p:%s], ", s, str);
+               fprintf (trFd, "[STRING:%p:%s], ", s, str);
                g_free (str);
        } else {
                mono_error_cleanup (&error);
-               printf("[STRING:%p:], ", s);
+               fprintf (trFd, "[STRING:%p:], ", s);
        }
 }
 
+/*========================= End of Function ========================*/
+
+/*------------------------------------------------------------------*/
+/*                                                                  */
+/* Name                - decodeParm                                        */
+/*                                                                  */
+/* Function    - Decode a parameter for the trace.                 */
+/*                                                                 */
+/*------------------------------------------------------------------*/
+
+
 static void 
 decodeParm(MonoType *type, void *curParm, int size)
 {
        guint32 simpleType;
 
        if (type->byref) {
-               printf("[BYREF:%p], ", *((char **) curParm));
+               fprintf (trFd, "[BYREF:%p], ", *((char **) curParm));
        } else {
                simpleType = mini_get_underlying_type(type)->type;
 enum_parmtype:
                switch (simpleType) {
                        case MONO_TYPE_I :
-                               printf ("[INTPTR:%p], ", *((int **) curParm));
+                               fprintf (trFd, "[INTPTR:%p], ", *((int **) curParm));
                                break;
                        case MONO_TYPE_U :
-                               printf ("[UINTPTR:%p], ", *((int **) curParm));
+                               fprintf (trFd, "[UINTPTR:%p], ", *((int **) curParm));
                                break;
                        case MONO_TYPE_BOOLEAN :
-                               printf ("[BOOL:%ld], ", *((gint64 *) curParm));
+                               fprintf (trFd, "[BOOL:%ld], ", *((gint64 *) curParm));
                                break;
                        case MONO_TYPE_CHAR :
-                               printf ("[CHAR:%c], ", *((int  *) curParm));
+                               fprintf (trFd, "[CHAR:%c], ", *((int  *) curParm));
                                break;
                        case MONO_TYPE_I1 :
-                               printf ("[INT1:%ld], ", *((gint64 *) curParm));
+                               fprintf (trFd, "[INT1:%ld], ", *((gint64 *) curParm));
                                break; 
                        case MONO_TYPE_I2 :
-                               printf ("[INT2:%ld], ", *((gint64 *) curParm));
+                               fprintf (trFd, "[INT2:%ld], ", *((gint64 *) curParm));
                                break; 
                        case MONO_TYPE_I4 :
-                               printf ("[INT4:%ld], ", *((gint64 *) curParm));
+                               fprintf (trFd, "[INT4:%ld], ", *((gint64 *) curParm));
                                break; 
                        case MONO_TYPE_U1 :
-                               printf ("[UINT1:%lu], ", *((guint64 *) curParm));
+                               fprintf (trFd, "[UINT1:%lu], ", *((guint64 *) curParm));
                                break; 
                        case MONO_TYPE_U2 :
-                               printf ("[UINT2:%lu], ", *((guint64 *) curParm));
+                               fprintf (trFd, "[UINT2:%lu], ", *((guint64 *) curParm));
                                break; 
                        case MONO_TYPE_U4 :
-                               printf ("[UINT4:%lu], ", *((guint64 *) curParm));
+                               fprintf (trFd, "[UINT4:%lu], ", *((guint64 *) curParm));
                                break; 
                        case MONO_TYPE_U8 :
-                               printf ("[UINT8:%lu], ", *((guint64 *) curParm));
+                               fprintf (trFd, "[UINT8:%lu], ", *((guint64 *) curParm));
                                break; 
                        case MONO_TYPE_STRING : {
                                MonoString *s = *((MonoString **) curParm);
@@ -820,7 +897,7 @@ enum_parmtype:
                                        g_assert (((MonoObject *) s)->vtable->klass == mono_defaults.string_class);
                                        decodeParmString (s);
                                } else {
-                                       printf("[STRING:null], ");
+                                       fprintf (trFd, "[STRING:null], ");
                                }
                                break;
                        }
@@ -829,43 +906,43 @@ enum_parmtype:
                                MonoObject *obj = *((MonoObject **) curParm);
                                MonoClass *klass;
                                if ((obj) && (obj->vtable)) {
-                                       printf("[CLASS/OBJ:");
+                                       fprintf (trFd, "[CLASS/OBJ:");
                                        klass = obj->vtable->klass;
-                                       printf("%p [%p] ",obj,curParm);
+                                       fprintf (trFd, "%p [%p] ",obj,curParm);
                                        if (klass == mono_defaults.string_class) {
                                                decodeParmString ((MonoString *)obj);
                                        } else if (klass == mono_defaults.int32_class) { 
-                                               printf("[INT32:%p:%d]", 
+                                               fprintf (trFd, "[INT32:%p:%d]", 
                                                        obj, *(gint32 *)((char *)obj + sizeof (MonoObject)));
                                        } else
-                                               printf("[%s.%s:%p]", 
+                                               fprintf (trFd, "[%s.%s:%p]", 
                                                       klass->name_space, klass->name, obj);
-                                       printf("], ");
+                                       fprintf (trFd, "], ");
                                } else {
-                                       printf("[OBJECT:null], ");
+                                       fprintf (trFd, "[OBJECT:null], ");
                                }
                                break;
                        }
                        case MONO_TYPE_PTR :
-                               printf("[PTR:%p], ", *((gpointer **) (curParm)));
+                               fprintf (trFd, "[PTR:%p], ", *((gpointer **) (curParm)));
                                break;
                        case MONO_TYPE_FNPTR :
-                               printf("[FNPTR:%p], ", *((gpointer **) (curParm)));
+                               fprintf (trFd, "[FNPTR:%p], ", *((gpointer **) (curParm)));
                                break;
                        case MONO_TYPE_ARRAY :
-                               printf("[ARRAY:%p], ", *((gpointer **) (curParm)));
+                               fprintf (trFd, "[ARRAY:%p], ", *((gpointer **) (curParm)));
                                break;
                        case MONO_TYPE_SZARRAY :
-                               printf("[SZARRAY:%p], ", *((gpointer **) (curParm)));
+                               fprintf (trFd, "[SZARRAY:%p], ", *((gpointer **) (curParm)));
                                break;
                        case MONO_TYPE_I8 :
-                               printf("[INT8:%ld], ", *((gint64 *) (curParm)));
+                               fprintf (trFd, "[INT8:%ld], ", *((gint64 *) (curParm)));
                                break;
                        case MONO_TYPE_R4 :
-                               printf("[FLOAT4:%g], ", *((float *) (curParm)));
+                               fprintf (trFd, "[FLOAT4:%g], ", *((float *) (curParm)));
                                break;
                        case MONO_TYPE_R8 :
-                               printf("[FLOAT8:%g], ", *((double *) (curParm)));
+                               fprintf (trFd, "[FLOAT8:%g], ", *((double *) (curParm)));
                                break;
                        case MONO_TYPE_VALUETYPE : {
                                int i;
@@ -873,7 +950,7 @@ enum_parmtype:
 
                                if (type->data.klass->enumtype) {
                                        simpleType = mono_class_enum_basetype (type->data.klass)->type;
-                                       printf("{VALUETYPE} - ");
+                                       fprintf (trFd, "{VALUETYPE} - ");
                                        goto enum_parmtype;
                                }
 
@@ -882,33 +959,33 @@ enum_parmtype:
                                if ((info->native_size == sizeof(float)) &&
                                    (info->num_fields  == 1) &&
                                    (info->fields[0].field->type->type == MONO_TYPE_R4)) {
-                                               printf("[FLOAT4:%f], ", *((float *) (curParm)));
+                                               fprintf (trFd, "[FLOAT4:%f], ", *((float *) (curParm)));
                                        break;
                                }
 
                                if ((info->native_size == sizeof(double)) &&
                                    (info->num_fields  == 1) &&
                                    (info->fields[0].field->type->type == MONO_TYPE_R8)) {
-                                       printf("[FLOAT8:%g], ", *((double *) (curParm)));
+                                       fprintf (trFd, "[FLOAT8:%g], ", *((double *) (curParm)));
                                        break;
                                }
 
-                               printf("[VALUETYPE:");
+                               fprintf (trFd, "[VALUETYPE:");
                                for (i = 0; i < size; i++)
-                                       printf("%02x,", *((guint8 *)curParm+i));
-                               printf("], ");
+                                       fprintf (trFd, "%02x,", *((guint8 *)curParm+i));
+                               fprintf (trFd, "], ");
                                break;
                        }
                        case MONO_TYPE_TYPEDBYREF: {
                                int i;
-                               printf("[TYPEDBYREF:");
+                               fprintf (trFd, "[TYPEDBYREF:");
                                for (i = 0; i < size; i++)
-                                       printf("%02x,", *((guint8 *)curParm+i));
-                               printf("]");
+                                       fprintf (trFd, "%02x,", *((guint8 *)curParm+i));
+                               fprintf (trFd, "]");
                                break;
                        }
                        default :
-                               printf("[%s], ",cvtMonoType(simpleType));
+                               fprintf (trFd, "[%s], ",cvtMonoType(simpleType));
                }
        }
 }
@@ -937,13 +1014,18 @@ enter_method (MonoMethod *method, RegParm *rParm, char *sp)
        ArgInfo *ainfo;
        void *curParm;
 
+       if (trFd == NULL) {
+               char buf[32];
+               sprintf(buf, "/tmp/mono.%d.trc.%d", getpid(), curThreadNo++);
+               trFd = fopen(buf, "w");
+       }
        fname = mono_method_full_name (method, TRUE);
        indent (1);
-       printf ("ENTER: %s ", fname);
+       fprintf (trFd, "ENTER: %s ", fname);
        g_free (fname);
 
        ip  = (*(guint64 *) (sp+S390_RET_ADDR_OFFSET));
-       printf ("ip: %p sp: %p - ", (gpointer) ip, sp); 
+       fprintf (trFd, "ip: %p sp: %p - ", (gpointer) ip, sp); 
 
        if (rParm == NULL)
                return;
@@ -953,7 +1035,7 @@ enter_method (MonoMethod *method, RegParm *rParm, char *sp)
        cinfo = get_call_info (NULL, NULL, sig);
 
        if (cinfo->struct_ret) {
-               printf ("[STRUCTRET:%p], ", (gpointer) rParm->gr[0]);
+               fprintf (trFd, "[STRUCTRET:%p], ", (gpointer) rParm->gr[0]);
                iParm = 1;
        }
 
@@ -964,28 +1046,28 @@ enter_method (MonoMethod *method, RegParm *rParm, char *sp)
                case MONO_TYPE_VALUETYPE:
                        if (obj) {
                                guint64 *value = (guint64 *) ((uintptr_t)this_arg + sizeof(MonoObject));
-                               printf("this:[value:%p:%016lx], ", this_arg, *value);
+                               fprintf (trFd, "this:[value:%p:%016lx], ", this_arg, *value);
                        } else 
-                               printf ("this:[NULL], ");
+                               fprintf (trFd, "this:[NULL], ");
                        break;
                case MONO_TYPE_STRING:
                        if (obj) {
                                if (obj->vtable) {
                                        klass = obj->vtable->klass;
                                        if (klass == mono_defaults.string_class) {
-                                               printf ("this:");
+                                               fprintf (trFd, "this:");
                                                decodeParmString((MonoString *)obj);
                                        } else {
-                                               printf ("this:%p[%s.%s], ", 
+                                               fprintf (trFd, "this:%p[%s.%s], ", 
                                                        obj, klass->name_space, klass->name);
                                        }
                                } else 
-                                       printf("vtable:[NULL], ");
+                                       fprintf (trFd, "vtable:[NULL], ");
                        } else 
-                               printf ("this:[NULL], ");
+                               fprintf (trFd, "this:[NULL], ");
                        break;
                default :
-                       printf("this[%s]: %p, ",cvtMonoType(method->klass->this_arg.type),this_arg);
+                       fprintf (trFd, "this[%s]: %p, ",cvtMonoType(method->klass->this_arg.type),this_arg);
                }
                oParm++;
        }
@@ -1031,10 +1113,10 @@ enter_method (MonoMethod *method, RegParm *rParm, char *sp)
                                break;
                                
                        default :
-                               printf("???, ");
+                               fprintf (trFd, "???, ");
                }
        }       
-       printf("\n");
+       fprintf (trFd, "\n");
        g_free(cinfo);
 }
 
@@ -1060,7 +1142,7 @@ leave_method (MonoMethod *method, ...)
 
        fname = mono_method_full_name (method, TRUE);
        indent (-1);
-       printf ("LEAVE: %s", fname);
+       fprintf (trFd, "LEAVE: %s", fname);
        g_free (fname);
 
        type = mono_method_signature (method)->ret;
@@ -1072,57 +1154,57 @@ handle_enum:
        case MONO_TYPE_BOOLEAN: {
                int val = va_arg (ap, int);
                if (val)
-                       printf ("[TRUE:%d]", val);
+                       fprintf (trFd, "[TRUE:%d]", val);
                else 
-                       printf ("[FALSE]");
+                       fprintf (trFd, "[FALSE]");
                        
                break;
        }
        case MONO_TYPE_CHAR: {
                int val = va_arg (ap, int);
-               printf ("[CHAR:%d]", val);
+               fprintf (trFd, "[CHAR:%d]", val);
                break;
        }
        case MONO_TYPE_I1: {
                int val = va_arg (ap, int);
-               printf ("[INT1:%d]", val);
+               fprintf (trFd, "[INT1:%d]", val);
                break;
        }
        case MONO_TYPE_U1: {
                int val = va_arg (ap, int);
-               printf ("[UINT1:%d]", val);
+               fprintf (trFd, "[UINT1:%d]", val);
                break;
        }
        case MONO_TYPE_I2: {
                int val = va_arg (ap, int);
-               printf ("[INT2:%d]", val);
+               fprintf (trFd, "[INT2:%d]", val);
                break;
        }
        case MONO_TYPE_U2: {
                int val = va_arg (ap, int);
-               printf ("[UINT2:%d]", val);
+               fprintf (trFd, "[UINT2:%d]", val);
                break;
        }
        case MONO_TYPE_I4: {
                int val = va_arg (ap, int);
-               printf ("[INT4:%d]", val);
+               fprintf (trFd, "[INT4:%d]", val);
                break;
        }
        case MONO_TYPE_U4: {
                int val = va_arg (ap, int);
-               printf ("[UINT4:%d]", val);
+               fprintf (trFd, "[UINT4:%d]", val);
                break;
        }
        case MONO_TYPE_I: {
                gint64 val = va_arg (ap, gint64);
-               printf ("[INT:%ld]", val);
-               printf("]");
+               fprintf (trFd, "[INT:%ld]", val);
+               fprintf (trFd, "]");
                break;
        }
        case MONO_TYPE_U: {
                gint64 val = va_arg (ap, gint64);
-               printf ("[UINT:%lu]", val);
-               printf("]");
+               fprintf (trFd, "[UINT:%lu]", val);
+               fprintf (trFd, "]");
                break;
        }
        case MONO_TYPE_STRING: {
@@ -1132,7 +1214,7 @@ handle_enum:
                        g_assert (((MonoObject *)s)->vtable->klass == mono_defaults.string_class);
                        decodeParmString (s);
                } else 
-                       printf ("[STRING:null], ");
+                       fprintf (trFd, "[STRING:null], ");
                break;
        }
        case MONO_TYPE_CLASS: 
@@ -1141,15 +1223,15 @@ handle_enum:
 
                if ((o) && (o->vtable)) {
                        if (o->vtable->klass == mono_defaults.boolean_class) {
-                               printf ("[BOOLEAN:%p:%d]", o, *((guint8 *)o + sizeof (MonoObject)));            
+                               fprintf (trFd, "[BOOLEAN:%p:%d]", o, *((guint8 *)o + sizeof (MonoObject)));             
                        } else if  (o->vtable->klass == mono_defaults.int32_class) {
-                               printf ("[INT32:%p:%d]", o, *((gint32 *)((char *)o + sizeof (MonoObject))));    
+                               fprintf (trFd, "[INT32:%p:%d]", o, *((gint32 *)((char *)o + sizeof (MonoObject))));     
                        } else if  (o->vtable->klass == mono_defaults.int64_class) {
-                               printf ("[INT64:%p:%ld]", o, *((gint64 *)((char *)o + sizeof (MonoObject))));   
+                               fprintf (trFd, "[INT64:%p:%ld]", o, *((gint64 *)((char *)o + sizeof (MonoObject))));    
                        } else
-                               printf ("[%s.%s:%p]", o->vtable->klass->name_space, o->vtable->klass->name, o);
+                               fprintf (trFd, "[%s.%s:%p]", o->vtable->klass->name_space, o->vtable->klass->name, o);
                } else
-                       printf ("[OBJECT:%p]", o);
+                       fprintf (trFd, "[OBJECT:%p]", o);
               
                break;
        }
@@ -1158,27 +1240,27 @@ handle_enum:
        case MONO_TYPE_ARRAY:
        case MONO_TYPE_SZARRAY: {
                gpointer p = va_arg (ap, gpointer);
-               printf ("[result=%p]", p);
+               fprintf (trFd, "[result=%p]", p);
                break;
        }
        case MONO_TYPE_I8: {
                gint64 l =  va_arg (ap, gint64);
-               printf ("[LONG:%ld]", l);
+               fprintf (trFd, "[LONG:%ld]", l);
                break;
        }
        case MONO_TYPE_U8: {
                guint64 l =  va_arg (ap, guint64);
-               printf ("[ULONG:%lu]", l);
+               fprintf (trFd, "[ULONG:%lu]", l);
                break;
        }
        case MONO_TYPE_R4: {
                double f = va_arg (ap, double);
-               printf ("[FLOAT4:%g]\n", f);
+               fprintf (trFd, "[FLOAT4:%g]\n", f);
                break;
        }
        case MONO_TYPE_R8: {
                double f = va_arg (ap, double);
-               printf ("[FLOAT8:%g]\n", f);
+               fprintf (trFd, "[FLOAT8:%g]\n", f);
                break;
        }
        case MONO_TYPE_VALUETYPE: {
@@ -1195,7 +1277,7 @@ handle_enum:
                            (info->num_fields  == 1) &&
                            (info->fields[0].field->type->type == MONO_TYPE_R4)) {
                                double f = va_arg (ap, double);
-                               printf("[FLOAT4:%g]\n", (double) f);
+                               fprintf (trFd, "[FLOAT4:%g]\n", (double) f);
                                break;
                        }
 
@@ -1203,7 +1285,7 @@ handle_enum:
                            (info->num_fields  == 1) &&
                            (info->fields[0].field->type->type == MONO_TYPE_R8)) {
                                double f = va_arg (ap, double);
-                               printf("[FLOAT8:%g]\n", f);
+                               fprintf (trFd, "[FLOAT8:%g]\n", f);
                                break;
                        }
 
@@ -1211,27 +1293,27 @@ handle_enum:
                        switch (size) {
                                case 1: {
                                        guint32 p = va_arg (ap, guint32);
-                                       printf ("[%02x]\n",p);
+                                       fprintf (trFd, "[%02x]\n",p);
                                        break;
                                }
                                case 2: {
                                        guint32 p = va_arg (ap, guint32);
-                                       printf ("[%04x]\n",p);
+                                       fprintf (trFd, "[%04x]\n",p);
                                        break;
                                }
                                case 4: {
                                        guint32 p = va_arg (ap, guint32);
-                                       printf ("[%08x]\n",p);
+                                       fprintf (trFd, "[%08x]\n",p);
                                        break;
                                }
                                case 8: {
                                        guint64 p = va_arg (ap, guint64);
-                                       printf ("[%016lx]\n",p);
+                                       fprintf (trFd, "[%016lx]\n",p);
                                        break;
                                }
                                default: {
                                        gpointer p = va_arg (ap, gpointer);
-                                       printf ("[VALUETYPE] %p\n",p);
+                                       fprintf (trFd, "[VALUETYPE] %p\n",p);
                                }
                        }
                }
@@ -1246,43 +1328,43 @@ handle_enum:
                case 2:
                case 4:
                case 8:
-                       printf ("[");
+                       fprintf (trFd, "[");
                        for (j = 0; p && j < size; j++)
-                               printf ("%02x,", p [j]);
-                       printf ("]\n");
+                               fprintf (trFd, "%02x,", p [j]);
+                       fprintf (trFd, "]\n");
                        break;
                default:
-                       printf ("[TYPEDBYREF]\n");
+                       fprintf (trFd, "[TYPEDBYREF]\n");
                }
        }
                break;
        case MONO_TYPE_GENERICINST: {
-               printf("[GENERICINST]\n");
+               fprintf (trFd, "[GENERICINST]\n");
        }
                break;
        case MONO_TYPE_MVAR: {
-               printf("[MVAR]\n");
+               fprintf (trFd, "[MVAR]\n");
        }
                break;
        case MONO_TYPE_CMOD_REQD: {
-               printf("[CMOD_REQD]\n");
+               fprintf (trFd, "[CMOD_REQD]\n");
        }
                break;
        case MONO_TYPE_CMOD_OPT: {
-               printf("[CMOD_OPT]\n");
+               fprintf (trFd, "[CMOD_OPT]\n");
        }
                break;
        case MONO_TYPE_INTERNAL: {
-               printf("[INTERNAL]\n");
+               fprintf (trFd, "[INTERNAL]\n");
        }
                break;
        default:
-               printf ("(unknown return type %x)", 
+               fprintf (trFd, "(unknown return type %x)", 
                        mono_method_signature (method)->ret->type);
        }
 
        ip = ((gint64) __builtin_extract_return_addr (__builtin_return_address (0)));
-       printf (" ip: %p\n", (gpointer) ip);
+       fprintf (trFd, " ip: %p\n", (gpointer) ip);
        va_end (ap);
 }
 
@@ -1456,7 +1538,9 @@ mono_arch_get_global_int_regs (MonoCompile *cfg)
        /* FIXME: s390_r12 is reserved for bkchain_reg. Only reserve it if needed */
        top = 12;
        for (i = 8; i < top; ++i) {
-               if (cfg->frame_reg != i)
+               if ((cfg->frame_reg != i) && 
+                   //!((cfg->uses_rgctx_reg) && (i == MONO_ARCH_IMT_REG)))
+                   (i != MONO_ARCH_IMT_REG))
                        regs = g_list_prepend (regs, GUINT_TO_POINTER (i));
        }
 
@@ -1990,10 +2074,7 @@ mono_arch_allocate_vars (MonoCompile *cfg)
        cfg->arch.bkchain_reg = -1;
 
        if (frame_reg != STK_BASE) 
-               cfg->used_int_regs |= (1 << frame_reg);         
-
-       if (cfg->uses_rgctx_reg)
-               cfg->used_int_regs |= (1 << MONO_ARCH_IMT_REG);
+               cfg->used_int_regs |= (1LL << frame_reg);               
 
        sig     = mono_method_signature (cfg->method);
        
@@ -2136,14 +2217,6 @@ mono_arch_allocate_vars (MonoCompile *cfg)
                                }
                                break;
                        }
-#if 0
-                       if ((sig->call_convention == MONO_CALL_VARARG) && 
-                           (cinfo->args[iParm].regtype != RegTypeGeneral) &&
-                           (iParm < sig->sentinelpos)) 
-                               cfg->sig_cookie += size;
-printf("%s %4d cookine %x\n",__FUNCTION__,__LINE__,cfg->sig_cookie);
-#endif
-
                        offset += MAX(size, 8);
                }
                curinst++;
@@ -2474,27 +2547,6 @@ mono_arch_emit_call (MonoCompile *cfg, MonoCallInst *call)
                                ins->inst_destbasereg = STK_BASE;
                                ins->inst_offset = ainfo->offset;
                                ins->sreg1 = in->dreg;
-
-#if 0
-                               /* This is needed by MonoTypedRef->value to point to the correct data */
-                               if ((sig->call_convention == MONO_CALL_VARARG) &&
-                                       (i >= sig->sentinelpos)) {
-                                       switch (ainfo->size) {
-                                       case 1:
-                                               ins->opcode = OP_STOREI1_MEMBASE_REG;
-                                               break;
-                                       case 2:
-                                               ins->opcode = OP_STOREI2_MEMBASE_REG;
-                                               break;
-                                       case 4:
-                                               ins->opcode = OP_STOREI4_MEMBASE_REG;
-                                               break;
-                                       default:
-                                               break;
-                                       }
-                               }
-#endif
-
                                MONO_ADD_INS (cfg->cbb, ins);
                        }
                        break;
@@ -2789,6 +2841,64 @@ handle_enum:
 
 /*========================= End of Function ========================*/
 
+/*------------------------------------------------------------------*/
+/*                                                                  */
+/* Name                - compare_and_branch                                */
+/*                                                                  */
+/* Function    - Form a peephole pass at the code looking for      */
+/*               simple optimizations.                             */
+/*                                                                 */
+/*------------------------------------------------------------------*/
+
+static void
+compare_and_branch(MonoBasicBlock *bb, MonoInst *ins, int cc, gboolean logical)
+{
+       MonoInst *last;
+
+       if (mono_hwcap_s390x_has_gie) {
+               last = mono_inst_prev (ins, FILTER_IL_SEQ_POINT);
+               ins->sreg1 = last->sreg1;
+               ins->sreg2 = last->sreg2;
+               ins->sreg3 = cc;
+               switch(last->opcode) {
+               case OP_ICOMPARE:
+                       if (logical)
+                               ins->opcode = OP_S390_CLRJ;
+                       else
+                               ins->opcode = OP_S390_CRJ;
+                       MONO_DELETE_INS(bb, last);
+                       break;
+               case OP_COMPARE:
+               case OP_LCOMPARE:
+                       if (logical)
+                               ins->opcode = OP_S390_CLGRJ;
+                       else
+                               ins->opcode = OP_S390_CGRJ;
+                       MONO_DELETE_INS(bb, last);
+                       break;
+               case OP_ICOMPARE_IMM:
+                       ins->backend.data = (gpointer) last->inst_imm;
+                       if (logical)
+                               ins->opcode = OP_S390_CLIJ;
+                       else
+                               ins->opcode = OP_S390_CIJ;
+                       MONO_DELETE_INS(bb, last);
+                       break;
+               case OP_COMPARE_IMM:
+               case OP_LCOMPARE_IMM:
+                       ins->backend.data = (gpointer) last->inst_imm;
+                       if (logical)
+                               ins->opcode = OP_S390_CLGIJ;
+                       else
+                               ins->opcode = OP_S390_CGIJ;
+                       MONO_DELETE_INS(bb, last);
+                       break;
+               }
+       }
+}
+
+/*========================= End of Function ========================*/
+
 /*------------------------------------------------------------------*/
 /*                                                                  */
 /* Name                - mono_arch_peephole_pass_1                         */
@@ -2801,6 +2911,55 @@ handle_enum:
 void
 mono_arch_peephole_pass_1 (MonoCompile *cfg, MonoBasicBlock *bb)
 {
+       MonoInst *ins, *n;
+
+       MONO_BB_FOR_EACH_INS_SAFE (bb, n, ins) {
+               switch (ins->opcode) {
+               case OP_IBEQ:
+               case OP_LBEQ:
+                       compare_and_branch(bb, ins, S390_CC_EQ, FALSE);
+                       break;
+               case OP_LBNE_UN:
+               case OP_IBNE_UN:
+                       compare_and_branch(bb, ins, S390_CC_NE, TRUE);
+                       break;
+               case OP_LBLT:
+               case OP_IBLT:
+                       compare_and_branch(bb, ins, S390_CC_LT, FALSE);
+                       break;
+               case OP_LBLT_UN:
+               case OP_IBLT_UN:
+                       compare_and_branch(bb, ins, S390_CC_LT, TRUE);
+                       break;
+               case OP_LBGT:
+               case OP_IBGT:
+                       compare_and_branch(bb, ins, S390_CC_GT, FALSE);
+                       break;
+               case OP_LBGT_UN:
+               case OP_IBGT_UN:
+                       compare_and_branch(bb, ins, S390_CC_GT, TRUE);
+                       break;
+               case OP_LBGE:
+               case OP_IBGE:
+                       compare_and_branch(bb, ins, S390_CC_GE, FALSE);
+                       break;
+               case OP_LBGE_UN:
+               case OP_IBGE_UN:
+                       compare_and_branch(bb, ins, S390_CC_GE, TRUE);
+                       break;
+               case OP_LBLE:
+               case OP_IBLE:
+                       compare_and_branch(bb, ins, S390_CC_LE, FALSE);
+                       break;
+               case OP_LBLE_UN:
+               case OP_IBLE_UN:
+                       compare_and_branch(bb, ins, S390_CC_LE, TRUE);
+                       break;
+
+               // default:
+               //      mono_peephole_ins (bb, ins);
+               }
+       }
 }
 
 /*========================= End of Function ========================*/
@@ -2817,9 +2976,20 @@ mono_arch_peephole_pass_1 (MonoCompile *cfg, MonoBasicBlock *bb)
 void
 mono_arch_peephole_pass_2 (MonoCompile *cfg, MonoBasicBlock *bb)
 {
-       MonoInst *ins, *n;
+       MonoInst *ins, *n, *last_ins = NULL;
 
        MONO_BB_FOR_EACH_INS_SAFE (bb, n, ins) {
+               switch (ins->opcode) {
+               case OP_LOADU4_MEMBASE:
+               case OP_LOADI4_MEMBASE:
+                       if (last_ins && (last_ins->opcode == OP_STOREI4_MEMBASE_REG) &&
+                                       ins->inst_basereg == last_ins->inst_destbasereg &&
+                                       ins->inst_offset == last_ins->inst_offset) {
+                               ins->opcode = (ins->opcode == OP_LOADI4_MEMBASE) ? OP_ICONV_TO_I4 : OP_ICONV_TO_U4;
+                               ins->sreg1 = last_ins->sreg1;
+                       }
+                       break;
+               }
                mono_peephole_ins (bb, ins);
        }
 }
@@ -2930,15 +3100,15 @@ emit_float_to_int (MonoCompile *cfg, guchar *code, int dreg, int sreg, int size,
 
 /*------------------------------------------------------------------*/
 /*                                                                  */
-/* Name                - gboolean_is_unsigned.                             */
+/* Name                - is_unsigned.                                      */
 /*                                                                  */
 /* Function    - Return TRUE if next opcode is checking for un-    */
 /*               signed value.                                     */
 /*                                                                 */
 /*------------------------------------------------------------------*/
 
-static 
-gboolean is_unsigned (MonoInst *next)
+static gboolean 
+is_unsigned (MonoInst *next)
 {
        if ((next) && 
                (((next->opcode >= OP_IBNE_UN) &&
@@ -2950,7 +3120,9 @@ gboolean is_unsigned (MonoInst *next)
                 ((next->opcode >= OP_COND_EXC_INE_UN) &&
                  (next->opcode <= OP_COND_EXC_ILT_UN)) ||
                 ((next->opcode == OP_CLT_UN) ||
-                 (next->opcode == OP_CGT_UN)) ||
+                 (next->opcode == OP_CGT_UN) ||
+                 (next->opcode == OP_ICGE_UN)  ||
+                 (next->opcode == OP_ICLE_UN)) ||
                 ((next->opcode == OP_ICLT_UN) ||
                  (next->opcode == OP_ICGT_UN) ||
                  (next->opcode == OP_LCLT_UN) ||
@@ -3117,6 +3289,14 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
                        s390_llghr (code, ins->dreg, ins->sreg1);
                }
                        break;
+               case OP_ICONV_TO_U4: {
+                       s390_llgfr (code, ins->dreg, ins->sreg1);
+               }
+                       break;
+               case OP_ICONV_TO_I4: {
+                       s390_lgfr (code, ins->dreg, ins->sreg1);
+               }
+                       break;
                case OP_COMPARE: 
                case OP_LCOMPARE: {
                        if (is_unsigned (ins->next))
@@ -3134,19 +3314,29 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
                        break;
                case OP_COMPARE_IMM:
                case OP_LCOMPARE_IMM: {
-                       S390_SET (code, s390_r0, ins->inst_imm);
-                       if (is_unsigned (ins->next))
-                               s390_clgr (code, ins->sreg1, s390_r0);
-                       else
-                               s390_cgr  (code, ins->sreg1, s390_r0);
+                       gboolean branchUn = is_unsigned (ins->next);
+                       if ((ins->inst_imm == 0) && (!branchUn)) {
+                               s390_ltgr (code, ins->sreg1, ins->sreg1);
+                       } else {
+                               S390_SET (code, s390_r0, ins->inst_imm);
+                               if (branchUn)
+                                       s390_clgr (code, ins->sreg1, s390_r0);
+                               else
+                                       s390_cgr  (code, ins->sreg1, s390_r0);
+                       }
                }
                        break;
                case OP_ICOMPARE_IMM: {
-                       S390_SET (code, s390_r0, ins->inst_imm);
-                       if (is_unsigned (ins->next))
-                               s390_clr  (code, ins->sreg1, s390_r0);
-                       else
-                               s390_cr   (code, ins->sreg1, s390_r0);
+                       gboolean branchUn = is_unsigned (ins->next);
+                       if ((ins->inst_imm == 0) && (!branchUn)) {
+                               s390_ltr (code, ins->sreg1, ins->sreg1);
+                       } else {
+                               S390_SET (code, s390_r0, ins->inst_imm);
+                               if (branchUn)
+                                       s390_clr  (code, ins->sreg1, s390_r0);
+                               else
+                                       s390_cr   (code, ins->sreg1, s390_r0);
+                       }
                }
                        break;
                case OP_BREAK: {
@@ -3156,13 +3346,21 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
                }
                        break;
                case OP_ADDCC: {
-                       CHECK_SRCDST_COM;
-                       s390_agr  (code, ins->dreg, src2);
+                       if (mono_hwcap_s390x_has_mlt) {
+                               s390_agrk (code, ins->dreg, ins->sreg1, ins->sreg2);
+                       } else {
+                               CHECK_SRCDST_COM;
+                               s390_agr  (code, ins->dreg, src2);
+                       }
                }
                        break;
                case OP_LADD: {
-                       CHECK_SRCDST_COM;
-                       s390_agr   (code, ins->dreg, src2);
+                       if (mono_hwcap_s390x_has_mlt) {
+                               s390_agrk (code, ins->dreg, ins->sreg1, ins->sreg2);
+                       } else {
+                               CHECK_SRCDST_COM;
+                               s390_agr   (code, ins->dreg, src2);
+                       }
                }
                        break;
                case OP_ADC: {
@@ -3171,16 +3369,25 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
                }
                        break;
                case OP_ADD_IMM: {
-                       if (ins->dreg != ins->sreg1) {
-                               s390_lgr  (code, ins->dreg, ins->sreg1);
-                       }
-                       if (s390_is_imm16 (ins->inst_imm)) {
-                               s390_aghi (code, ins->dreg, ins->inst_imm);
-                       } else if (s390_is_imm32 (ins->inst_imm)) {
-                               s390_agfi (code, ins->dreg, ins->inst_imm);
+                       if (mono_hwcap_s390x_has_mlt) {
+                               if (s390_is_imm16 (ins->inst_imm)) {
+                                       s390_aghik(code, ins->dreg, ins->sreg1, ins->inst_imm);
+                               } else {
+                                       S390_SET  (code, s390_r0, ins->inst_imm);
+                                       s390_agrk (code, ins->dreg, ins->sreg1, s390_r0);
+                               }
                        } else {
-                               S390_SET  (code, s390_r0, ins->inst_imm);
-                               s390_agr  (code, ins->dreg, s390_r0);
+                               if (ins->dreg != ins->sreg1) {
+                                       s390_lgr  (code, ins->dreg, ins->sreg1);
+                               }
+                               if (s390_is_imm16 (ins->inst_imm)) {
+                                       s390_aghi (code, ins->dreg, ins->inst_imm);
+                               } else if (s390_is_imm32 (ins->inst_imm)) {
+                                       s390_agfi (code, ins->dreg, ins->inst_imm);
+                               } else {
+                                       S390_SET  (code, s390_r0, ins->inst_imm);
+                                       s390_agr  (code, ins->dreg, s390_r0);
+                               }
                        }
                }
                        break;
@@ -3188,8 +3395,12 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
                        if (ins->dreg != ins->sreg1) {
                                s390_lgr  (code, ins->dreg, ins->sreg1);
                        }
-                       g_assert (s390_is_imm16 (ins->inst_imm));
-                       s390_aghi (code, ins->dreg, ins->inst_imm);
+                       if (s390_is_imm32 (ins->inst_imm)) {
+                               s390_agfi (code, ins->dreg, ins->inst_imm);
+                       } else {
+                               S390_SET  (code, s390_r0, ins->inst_imm);
+                               s390_agr  (code, ins->dreg, s390_r0);
+                       }
                }
                        break;
                case OP_ADC_IMM: {
@@ -3239,13 +3450,21 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
                }
                        break;
                case OP_SUBCC: {
-                       CHECK_SRCDST_NCOM;
-                       s390_sgr (code, ins->dreg, src2);
+                       if (mono_hwcap_s390x_has_mlt) {
+                           s390_sgrk (code, ins->dreg, ins->sreg1, ins->sreg2);
+                       } else {
+                           CHECK_SRCDST_NCOM;
+                           s390_sgr (code, ins->dreg, src2);
+                       }
                }
                        break;
                case OP_LSUB: {
-                       CHECK_SRCDST_NCOM;
-                       s390_sgr  (code, ins->dreg, src2);
+                       if (mono_hwcap_s390x_has_mlt) {
+                           s390_sgrk (code, ins->dreg, ins->sreg1, ins->sreg2);
+                       } else {
+                           CHECK_SRCDST_NCOM;
+                           s390_sgr  (code, ins->dreg, src2);
+                       }
                }
                        break;
                case OP_SBB: {
@@ -3312,26 +3531,32 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
                }
                        break;
                case OP_LAND: {
-                       if (ins->sreg1 == ins->dreg) {
-                               s390_ngr  (code, ins->dreg, ins->sreg2);
-                       } 
-                       else { 
-                               if (ins->sreg2 == ins->dreg) { 
-                                       s390_ngr (code, ins->dreg, ins->sreg1);
-                               }
-                               else { 
-                                       s390_lgr (code, ins->dreg, ins->sreg1);
-                                       s390_ngr (code, ins->dreg, ins->sreg2);
+                       if (mono_hwcap_s390x_has_mlt) {
+                               s390_ngrk (code, ins->dreg, ins->sreg1, ins->sreg2);
+                       } else {
+                               if (ins->sreg1 == ins->dreg) {
+                                       s390_ngr  (code, ins->dreg, ins->sreg2);
+                               } else { 
+                                       if (ins->sreg2 == ins->dreg) { 
+                                               s390_ngr (code, ins->dreg, ins->sreg1);
+                                       } else { 
+                                               s390_lgr (code, ins->dreg, ins->sreg1);
+                                               s390_ngr (code, ins->dreg, ins->sreg2);
+                                       }
                                }
                        }
                }
                        break;
                case OP_AND_IMM: {
-                       if (ins->dreg != ins->sreg1) {
-                               s390_lgr  (code, ins->dreg, ins->sreg1);
-                       }
                        S390_SET_MASK (code, s390_r0, ins->inst_imm);
-                       s390_ngr (code, ins->dreg, s390_r0);
+                       if (mono_hwcap_s390x_has_mlt) {
+                               s390_ngrk (code, ins->dreg, ins->sreg1, s390_r0);
+                       } else {
+                               if (ins->dreg != ins->sreg1) {
+                                       s390_lgr  (code, ins->dreg, ins->sreg1);
+                               }
+                               s390_ngr (code, ins->dreg, s390_r0);
+                       }
                }
                        break;
                case OP_LDIV: {
@@ -3372,49 +3597,63 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
                }
                        break;
                case OP_LOR: {
-                       if (ins->sreg1 == ins->dreg) {
-                               s390_ogr  (code, ins->dreg, ins->sreg2);
-                       } 
-                       else { 
-                               if (ins->sreg2 == ins->dreg) { 
-                                       s390_ogr (code, ins->dreg, ins->sreg1);
-                               }
-                               else { 
-                                       s390_lgr (code, ins->dreg, ins->sreg1);
-                                       s390_ogr (code, ins->dreg, ins->sreg2);
+                       if (mono_hwcap_s390x_has_mlt) {
+                               s390_ogrk (code, ins->dreg, ins->sreg1, ins->sreg2);
+                       } else {
+                               if (ins->sreg1 == ins->dreg) {
+                                       s390_ogr  (code, ins->dreg, ins->sreg2);
+                               } else { 
+                                       if (ins->sreg2 == ins->dreg) { 
+                                               s390_ogr (code, ins->dreg, ins->sreg1);
+                                       } else { 
+                                               s390_lgr (code, ins->dreg, ins->sreg1);
+                                               s390_ogr (code, ins->dreg, ins->sreg2);
+                                       }
                                }
                        }
                }
                        break;
                case OP_OR_IMM: {
-                       if (ins->dreg != ins->sreg1) {
-                               s390_lgr  (code, ins->dreg, ins->sreg1);
-                       }
                        S390_SET_MASK(code, s390_r0, ins->inst_imm);
-                       s390_ogr (code, ins->dreg, s390_r0);
+                       if (mono_hwcap_s390x_has_mlt) {
+                               s390_ogrk (code, ins->dreg, ins->sreg1, s390_r0);
+                       } else {
+                               if (ins->dreg != ins->sreg1) {
+                                       s390_lgr  (code, ins->dreg, ins->sreg1);
+                               }
+                               s390_ogr (code, ins->dreg, s390_r0);
+                       }
                }
                        break;
                case OP_LXOR: {
-                       if (ins->sreg1 == ins->dreg) {
-                               s390_xgr  (code, ins->dreg, ins->sreg2);
-                       } 
-                       else { 
-                               if (ins->sreg2 == ins->dreg) { 
-                                       s390_xgr (code, ins->dreg, ins->sreg1);
-                               }
+                       if (mono_hwcap_s390x_has_mlt) {
+                               s390_xgrk (code, ins->dreg, ins->sreg1, ins->sreg2);
+                       } else {
+                               if (ins->sreg1 == ins->dreg) {
+                                       s390_xgr  (code, ins->dreg, ins->sreg2);
+                               } 
                                else { 
-                                       s390_lgr (code, ins->dreg, ins->sreg1);
-                                       s390_xgr (code, ins->dreg, ins->sreg2);
+                                       if (ins->sreg2 == ins->dreg) { 
+                                               s390_xgr (code, ins->dreg, ins->sreg1);
+                                       }
+                                       else { 
+                                               s390_lgr (code, ins->dreg, ins->sreg1);
+                                               s390_xgr (code, ins->dreg, ins->sreg2);
+                                       }
                                }
                        }
                }
                        break;
                case OP_XOR_IMM: {
-                       if (ins->dreg != ins->sreg1) {
-                               s390_lgr  (code, ins->dreg, ins->sreg1);
+                       S390_SET_MASK(code, s390_r0, ins->inst_imm);
+                       if (mono_hwcap_s390x_has_mlt) {
+                               s390_xgrk (code, ins->dreg, ins->sreg1, s390_r0);
+                       } else {
+                               if (ins->dreg != ins->sreg1) {
+                                       s390_lgr  (code, ins->dreg, ins->sreg1);
+                               }
+                               s390_xgr (code, ins->dreg, s390_r0);
                        }
-                       S390_SET_MASK (code, s390_r0, ins->inst_imm);
-                       s390_xgr (code, ins->dreg, s390_r0);
                }
                        break;
                case OP_LSHL: {
@@ -3478,33 +3717,43 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
                        if (ins->dreg != ins->sreg1) {
                                s390_lgr  (code, ins->dreg, ins->sreg1);
                        }
-                       if (s390_is_imm16 (ins->inst_imm)) {
-                               s390_lghi (code, s390_r13, ins->inst_imm);
-                       } else if (s390_is_imm32 (ins->inst_imm)) {
-                               s390_lgfi (code, s390_r13, ins->inst_imm);
+                       if ((mono_hwcap_s390x_has_gie) &&
+                           (s390_is_imm32 (ins->inst_imm))) {
+                               s390_msgfi (code, ins->dreg, ins->inst_imm);
                        } else {
-                               S390_SET (code, s390_r13, ins->inst_imm);
+                               if (s390_is_imm16 (ins->inst_imm)) {
+                                       s390_lghi (code, s390_r13, ins->inst_imm);
+                               } else if (s390_is_imm32 (ins->inst_imm)) {
+                                       s390_lgfi (code, s390_r13, ins->inst_imm);
+                               } else {
+                                       S390_SET (code, s390_r13, ins->inst_imm);
+                               }
+                               s390_msgr (code, ins->dreg, s390_r13);
                        }
-                       s390_msgr (code, ins->dreg, s390_r13);
                }
                        break;
                case OP_LMUL_OVF: {
                        short int *o[2];
-                       s390_ltgr (code, s390_r1, ins->sreg1);
-                       s390_jz   (code, 0); CODEPTR(code, o[0]);
-                       s390_ltgr (code, s390_r0, ins->sreg2);
-                       s390_jnz  (code, 6);
-                       s390_lghi (code, s390_r1, 0);
-                       s390_j    (code, 0); CODEPTR(code, o[1]);
-                       s390_xgr  (code, s390_r0, s390_r1);
-                       s390_msgr (code, s390_r1, ins->sreg2);
-                       s390_xgr  (code, s390_r0, s390_r1);
-                       s390_srlg (code, s390_r0, s390_r0, 0, 63);
-                       s390_ltgr (code, s390_r0, s390_r0);
-                       EMIT_COND_SYSTEM_EXCEPTION (S390_CC_NZ, "OverflowException");
-                       PTRSLOT   (code, o[0]); 
-                       PTRSLOT   (code, o[1]);
-                       s390_lgr  (code, ins->dreg, s390_r1);
+                       if (mono_hwcap_s390x_has_mie2) {
+                               s390_msgrkc (code, ins->dreg, ins->sreg1, ins->sreg2);
+                               EMIT_COND_SYSTEM_EXCEPTION (S390_CC_OV, "OverflowException");
+                       } else {
+                               s390_ltgr (code, s390_r1, ins->sreg1);
+                               s390_jz   (code, 0); CODEPTR(code, o[0]);
+                               s390_ltgr (code, s390_r0, ins->sreg2);
+                               s390_jnz  (code, 6);
+                               s390_lghi (code, s390_r1, 0);
+                               s390_j    (code, 0); CODEPTR(code, o[1]);
+                               s390_xgr  (code, s390_r0, s390_r1);
+                               s390_msgr (code, s390_r1, ins->sreg2);
+                               s390_xgr  (code, s390_r0, s390_r1);
+                               s390_srlg (code, s390_r0, s390_r0, 0, 63);
+                               s390_ltgr (code, s390_r0, s390_r0);
+                               EMIT_COND_SYSTEM_EXCEPTION (S390_CC_NZ, "OverflowException");
+                               PTRSLOT   (code, o[0]); 
+                               PTRSLOT   (code, o[1]);
+                               s390_lgr  (code, ins->dreg, s390_r1);
+                       }
                }
                        break;
                case OP_LMUL_OVF_UN: {
@@ -3559,26 +3808,42 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
                        break;
                case OP_LADD_OVF:
                case OP_S390_LADD_OVF: {
-                       CHECK_SRCDST_COM;
-                       s390_agr    (code, ins->dreg, src2);
+                       if (mono_hwcap_s390x_has_mlt) {
+                               s390_agrk (code, ins->dreg, ins->sreg1, ins->sreg2);
+                       } else { 
+                               CHECK_SRCDST_COM;
+                               s390_agr    (code, ins->dreg, src2);
+                       }
                        EMIT_COND_SYSTEM_EXCEPTION (S390_CC_OV, "OverflowException");
                }
                        break;
                case OP_LADD_OVF_UN:
                case OP_S390_LADD_OVF_UN: {
-                       CHECK_SRCDST_COM;
-                       s390_algr  (code, ins->dreg, src2);
+                       if (mono_hwcap_s390x_has_mlt) {
+                               s390_algrk (code, ins->dreg, ins->sreg1, ins->sreg2);
+                       } else { 
+                               CHECK_SRCDST_COM;
+                               s390_algr  (code, ins->dreg, src2);
+                       }
                        EMIT_COND_SYSTEM_EXCEPTION (S390_CC_CY, "OverflowException");
                }
                        break;
                case OP_ISUBCC: {
-                       CHECK_SRCDST_NCOM_I;
-                       s390_slgr (code, ins->dreg, src2);
+                       if (mono_hwcap_s390x_has_mlt) {
+                               s390_slgrk (code, ins->dreg, ins->sreg1, ins->sreg2);
+                       } else {
+                               CHECK_SRCDST_NCOM_I;
+                               s390_slgr (code, ins->dreg, src2);
+                       }
                }
                        break;
                case OP_ISUB: {
-                       CHECK_SRCDST_NCOM_I;
-                       s390_sgr  (code, ins->dreg, src2);
+                       if (mono_hwcap_s390x_has_mlt) {
+                               s390_sgrk (code, ins->dreg, ins->sreg1, ins->sreg2);
+                       } else {
+                               CHECK_SRCDST_NCOM_I;
+                               s390_sgr  (code, ins->dreg, src2);
+                       }
                }
                        break;
                case OP_ISBB: {
@@ -3604,24 +3869,37 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
                        break;
                case OP_ISUB_OVF:
                case OP_S390_ISUB_OVF: {
-                       CHECK_SRCDST_NCOM;
-                       s390_sr   (code, ins->dreg, src2);
-                       EMIT_COND_SYSTEM_EXCEPTION (S390_CC_OV, "OverflowException");
-                       s390_lgfr (code, ins->dreg, ins->dreg);
+                       if (mono_hwcap_s390x_has_mlt) {
+                               s390_srk (code, ins->dreg, ins->sreg1, ins->sreg2);
+                               EMIT_COND_SYSTEM_EXCEPTION (S390_CC_OV, "OverflowException");
+                       } else { 
+                               CHECK_SRCDST_NCOM;
+                               s390_sr   (code, ins->dreg, src2);
+                               EMIT_COND_SYSTEM_EXCEPTION (S390_CC_OV, "OverflowException");
+                               s390_lgfr (code, ins->dreg, ins->dreg);
+                       }
                }
                        break;
                case OP_ISUB_OVF_UN:
                case OP_S390_ISUB_OVF_UN: {
-                       CHECK_SRCDST_NCOM;
-                       s390_slr  (code, ins->dreg, src2);
+                       if (mono_hwcap_s390x_has_mlt) {
+                               s390_slrk  (code, ins->dreg, ins->sreg1, ins->sreg2);
+                       } else {
+                               CHECK_SRCDST_NCOM;
+                               s390_slr  (code, ins->dreg, src2);
+                       }
                        EMIT_COND_SYSTEM_EXCEPTION (S390_CC_NC, "OverflowException");
                        s390_llgfr(code, ins->dreg, ins->dreg);
                }
                        break;
                case OP_LSUB_OVF:
                case OP_S390_LSUB_OVF: {
-                       CHECK_SRCDST_NCOM;
-                       s390_sgr   (code, ins->dreg, src2);
+                       if (mono_hwcap_s390x_has_mlt) {
+                               s390_sgrk  (code, ins->dreg, ins->sreg1, ins->sreg2);
+                       } else {
+                               CHECK_SRCDST_NCOM;
+                               s390_sgr   (code, ins->dreg, src2);
+                       }
                        EMIT_COND_SYSTEM_EXCEPTION (S390_CC_OV, "OverflowException");
                }
                        break;
@@ -3633,16 +3911,24 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
                }
                        break;
                case OP_IAND: {
-                       CHECK_SRCDST_NCOM_I;
-                       s390_ngr (code, ins->dreg, src2);
+                       if (mono_hwcap_s390x_has_mlt) {
+                               s390_ngrk (code, ins->dreg, ins->sreg1, ins->sreg2);
+                       } else {
+                               CHECK_SRCDST_NCOM_I;
+                               s390_ngr (code, ins->dreg, src2);
+                       }
                }
                        break;
                case OP_IAND_IMM: {
-                       if (ins->dreg != ins->sreg1) {
-                               s390_lgfr (code, ins->dreg, ins->sreg1);
-                       }
                        S390_SET_MASK (code, s390_r0, ins->inst_imm);
-                       s390_ngr  (code, ins->dreg, s390_r0);
+                       if (mono_hwcap_s390x_has_mlt) {
+                               s390_ngrk (code, ins->dreg, ins->sreg1, s390_r0);
+                       } else {
+                               if (ins->dreg != ins->sreg1) {
+                                       s390_lgfr (code, ins->dreg, ins->sreg1);
+                               }
+                               s390_ngr  (code, ins->dreg, s390_r0);
+                       }
                }
                        break;
                case OP_IDIV: {
@@ -3697,29 +3983,45 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
                }
                        break;
                case OP_IOR: {
-                       CHECK_SRCDST_COM_I;
-                       s390_ogr (code, ins->dreg, src2);
+                       if (mono_hwcap_s390x_has_mlt) {
+                               s390_ogrk (code, ins->dreg, ins->sreg1, ins->sreg2);
+                       } else {
+                               CHECK_SRCDST_COM_I;
+                               s390_ogr (code, ins->dreg, src2);
+                       }
                }
                        break;
                case OP_IOR_IMM: {
-                       if (ins->dreg != ins->sreg1) {
-                               s390_lgfr (code, ins->dreg, ins->sreg1);
-                       }
                        S390_SET_MASK (code, s390_r0, ins->inst_imm);
-                       s390_ogr  (code, ins->dreg, s390_r0);
+                       if (mono_hwcap_s390x_has_mlt) {
+                               s390_ogrk (code, ins->dreg, ins->sreg1, s390_r0);
+                       } else {
+                               if (ins->dreg != ins->sreg1) {
+                                       s390_lgfr (code, ins->dreg, ins->sreg1);
+                               }
+                               s390_ogr  (code, ins->dreg, s390_r0);
+                       }
                }
                        break;
                case OP_IXOR: {
-                       CHECK_SRCDST_COM_I;
-                       s390_xgr (code, ins->dreg, src2);
+                       if (mono_hwcap_s390x_has_mlt) {
+                               s390_xgrk (code, ins->dreg, ins->sreg1, ins->sreg2);
+                       } else {
+                               CHECK_SRCDST_COM_I;
+                               s390_xgr (code, ins->dreg, src2);
+                       }
                }
                        break;
                case OP_IXOR_IMM: {
-                       if (ins->dreg != ins->sreg1) {
-                               s390_lgfr (code, ins->dreg, ins->sreg1);
-                       }
                        S390_SET_MASK (code, s390_r0, ins->inst_imm);
-                       s390_xgr  (code, ins->dreg, s390_r0);
+                       if (mono_hwcap_s390x_has_mlt) {
+                               s390_xgrk (code, ins->dreg, ins->sreg1, s390_r0);
+                       } else {
+                               if (ins->dreg != ins->sreg1) {
+                                       s390_lgfr (code, ins->dreg, ins->sreg1);
+                               }
+                               s390_xgr  (code, ins->dreg, s390_r0);
+                       }
                }
                        break;
                case OP_ISHL: {
@@ -4247,6 +4549,36 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
                        s390_lghi(code, ins->dreg, 0);
                }
                        break;
+               case OP_ICNEQ: {
+                       s390_lghi(code, ins->dreg, 1);
+                       s390_jne (code, 4);
+                       s390_lghi(code, ins->dreg, 0);
+               }
+                       break;
+               case OP_ICGE: {
+                       s390_lghi(code, ins->dreg, 1);
+                       s390_jhe (code, 4);
+                       s390_lghi(code, ins->dreg, 0);
+               }
+                       break;
+               case OP_ICLE: {
+                       s390_lghi(code, ins->dreg, 1);
+                       s390_jle (code, 4);
+                       s390_lghi(code, ins->dreg, 0);
+               }
+                       break;
+               case OP_ICGE_UN: {
+                       s390_lghi(code, ins->dreg, 1);
+                       s390_jhe (code, 4);
+                       s390_lghi(code, ins->dreg, 0);
+               }
+                       break;
+               case OP_ICLE_UN: {
+                       s390_lghi(code, ins->dreg, 1);
+                       s390_jle (code, 4);
+                       s390_lghi(code, ins->dreg, 0);
+               }
+                       break;
                case OP_COND_EXC_EQ:
                case OP_COND_EXC_IEQ:
                        EMIT_COND_SYSTEM_EXCEPTION (S390_CC_EQ, ins->inst_p1);
@@ -4328,6 +4660,38 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
                        EMIT_COND_BRANCH (ins, S390_CC_LE);
                        break;
 
+               case OP_S390_CRJ:
+                       EMIT_COMP_AND_BRANCH(ins, crj, cr);
+                       break;
+
+               case OP_S390_CLRJ:
+                       EMIT_COMP_AND_BRANCH(ins, clrj, clr);
+                       break;
+
+               case OP_S390_CGRJ:
+                       EMIT_COMP_AND_BRANCH(ins, cgrj, cgr);
+                       break;
+
+               case OP_S390_CLGRJ:
+                       EMIT_COMP_AND_BRANCH(ins, clgrj, clgr);
+                       break;
+
+               case OP_S390_CIJ:
+                       EMIT_COMP_AND_BRANCH_IMM(ins, crj, cr, ltr, FALSE);
+                       break;
+
+               case OP_S390_CLIJ:
+                       EMIT_COMP_AND_BRANCH_IMM(ins, clrj, clr, ltr, TRUE);
+                       break;
+
+               case OP_S390_CGIJ:
+                       EMIT_COMP_AND_BRANCH_IMM(ins, cgrj, cgr, ltgr, FALSE);
+                       break;
+
+               case OP_S390_CLGIJ:
+                       EMIT_COMP_AND_BRANCH_IMM(ins, clgrj, clgr, ltgr, TRUE);
+                       break;
+
                /* floating point opcodes */
                case OP_R8CONST: {
                        if (*((double *) ins->inst_p0) == 0) {
@@ -4563,6 +4927,27 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
                        s390_lghi  (code, ins->dreg, 0);
                }
                        break;
+               case OP_FCNEQ: {
+                       s390_cdbr  (code, ins->sreg1, ins->sreg2);
+                       s390_lghi  (code, ins->dreg, 1);
+                       s390_jne   (code, 4);
+                       s390_lghi  (code, ins->dreg, 0);
+               }
+                       break;
+               case OP_FCGE: {
+                       s390_cdbr  (code, ins->sreg1, ins->sreg2);
+                       s390_lghi  (code, ins->dreg, 1);
+                       s390_jhe   (code, 4);
+                       s390_lghi  (code, ins->dreg, 0);
+               }
+                       break;
+               case OP_FCLE: {
+                       s390_cdbr  (code, ins->sreg1, ins->sreg2);
+                       s390_lghi  (code, ins->dreg, 1);
+                       s390_jle   (code, 4);
+                       s390_lghi  (code, ins->dreg, 0);
+               }
+                       break;
                case OP_FBEQ: {
                        short *o;
                        s390_jo (code, 0); CODEPTR(code, o);
@@ -4668,12 +5053,17 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
                }
                        break;
                case OP_ATOMIC_ADD_I8: {
-                       s390_lgr (code, s390_r1, ins->sreg2);
-                       s390_lg  (code, s390_r0, 0, ins->inst_basereg, ins->inst_offset);
-                       s390_agr (code, s390_r1, s390_r0);
-                       s390_csg (code, s390_r0, s390_r1, ins->inst_basereg, ins->inst_offset);
-                       s390_jnz (code, -10);
-                       s390_lgr (code, ins->dreg, s390_r1);
+                       if (mono_hwcap_s390x_has_ia) {
+                               s390_laag (code, ins->dreg, ins->sreg2, ins->inst_basereg, ins->inst_offset);
+                               s390_agr  (code, ins->dreg, ins->sreg2);
+                       } else {
+                               s390_lgr (code, s390_r1, ins->sreg2);
+                               s390_lg  (code, s390_r0, 0, ins->inst_basereg, ins->inst_offset);
+                               s390_agr (code, s390_r1, s390_r0);
+                               s390_csg (code, s390_r0, s390_r1, ins->inst_basereg, ins->inst_offset);
+                               s390_jnz (code, -10);
+                               s390_lgr (code, ins->dreg, s390_r1);
+                       }
                }
                        break;  
                case OP_ATOMIC_EXCHANGE_I8: {
@@ -4684,12 +5074,17 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
                }
                        break;  
                case OP_ATOMIC_ADD_I4: {
-                       s390_lgfr(code, s390_r1, ins->sreg2);
-                       s390_lgf (code, s390_r0, 0, ins->inst_basereg, ins->inst_offset);
-                       s390_agr (code, s390_r1, s390_r0);
-                       s390_cs  (code, s390_r0, s390_r1, ins->inst_basereg, ins->inst_offset);
-                       s390_jnz (code, -9);
-                       s390_lgfr(code, ins->dreg, s390_r1);
+                       if (mono_hwcap_s390x_has_ia) {
+                               s390_laa (code, ins->dreg, ins->sreg2, ins->inst_basereg, ins->inst_offset);
+                               s390_ar  (code, ins->dreg, ins->sreg2);
+                       } else {
+                               s390_lgfr(code, s390_r1, ins->sreg2);
+                               s390_lgf (code, s390_r0, 0, ins->inst_basereg, ins->inst_offset);
+                               s390_agr (code, s390_r1, s390_r0);
+                               s390_cs  (code, s390_r0, s390_r1, ins->inst_basereg, ins->inst_offset);
+                               s390_jnz (code, -9);
+                               s390_lgfr(code, ins->dreg, s390_r1);
+                       }
                }
                        break;  
                case OP_ATOMIC_EXCHANGE_I4: {
@@ -4715,13 +5110,13 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
                        s390_mem (code);
                        break;
                case OP_GC_SAFE_POINT: {
-                       guint8 *br;
+                       short *br;
 
                        g_assert (mono_threads_is_coop_enabled ());
 
-                       s390_chi (code, ins->sreg1, 1); 
-                       s390_je  (code, 0); CODEPTR(code, br);
-                       mono_add_patch_info (cfg, code- cfg->native_code, MONO_PATCH_INFO_ABS,
+                       s390_ltg (code, s390_r0, 0, ins->sreg1, 0);     
+                       s390_jz  (code, 0); CODEPTR(code, br);
+                       mono_add_patch_info (cfg, code - cfg->native_code, MONO_PATCH_INFO_ABS,
                                             mono_threads_state_poll);
                        S390_CALL_TEMPLATE (code, s390_r14);
                        PTRSLOT (code, br);
@@ -5413,7 +5808,7 @@ mono_arch_patch_code (MonoCompile *cfg, MonoMethod *method, MonoDomain *domain,
                gconstpointer target = NULL;
 
                target = mono_resolve_patch_target (method, domain, code, 
-                                                                                       patch_info, run_cctors, error);
+                                                   patch_info, run_cctors, error);
                return_if_nok (error);
 
                switch (patch_info->type) {
@@ -6132,7 +6527,7 @@ mono_arch_emit_exceptions (MonoCompile *cfg)
 
 /*------------------------------------------------------------------*/
 /*                                                                  */
-/* Name                - mono_arch_finish_init                                 */
+/* Name                - mono_arch_finish_init                             */
 /*                                                                  */
 /* Function    - Setup the JIT's Thread Level Specific Data.       */
 /*                                                                 */
@@ -6390,8 +6785,6 @@ get_delegate_invoke_impl (MonoTrampInfo **info, gboolean has_target, guint32 par
                mono_arch_flush_icache (start, size);
        }
 
-       MONO_PROFILER_RAISE (jit_code_buffer, (start, code - start, MONO_PROFILER_CODE_BUFFER_DELEGATE_INVOKE, NULL));
-
        if (has_target) {
                *info = mono_tramp_info_create ("delegate_invoke_impl_has_target", start, code - start, NULL, NULL);
        } else {
@@ -6676,7 +7069,6 @@ mono_arch_build_imt_trampoline (MonoVTable *vtable, MonoDomain *domain,
        }
 
        mono_arch_flush_icache ((guint8*)start, (code - start));
-       MONO_PROFILER_RAISE (jit_code_buffer, (start, code - start, MONO_PROFILER_CODE_BUFFER_IMT_TRAMPOLINE, NULL));
 
        if (!fail_tramp) 
                UnlockedAdd (&mono_stats.imt_trampolines_size, code - start);
index 01dcfd997a9bf6a9822f412625f7b16b3989aaf0..fd1c2142f3349119f0a4a6cec7b268e3ee9a9ac4 100644 (file)
@@ -64,6 +64,7 @@ typedef struct
 #define MONO_ARCH_HAVE_INVALIDATE_METHOD               1
 #define MONO_ARCH_HAVE_OP_GENERIC_CLASS_INIT           1
 #define MONO_ARCH_HAVE_SETUP_ASYNC_CALLBACK            1
+#define MONO_ARCH_HAVE_INIT_LMF_EXT                    1
 
 #define S390_STACK_ALIGNMENT            8
 #define S390_FIRST_ARG_REG             s390_r2
@@ -78,13 +79,15 @@ typedef struct
 /*------------------------------------------------------*/
 /* use s390_r2-s390_r6 as parm registers                */
 /* s390_r0, s390_r1, s390_r12, s390_r13 used internally */
-/* s390_r8..s390_r11 are used for global regalloc       */
+/* s390_r8..s390_r10 are used for global regalloc       */
+/* -- except for s390_r9 which is used as IMT pointer   */
+/* s390_r11 is sometimes used as the frame pointer      */
 /* s390_r15 is the stack pointer                        */
 /*------------------------------------------------------*/
 
-#define MONO_ARCH_CALLEE_REGS (0xfc)
+#define MONO_ARCH_CALLEE_REGS (0x00fc)
 
-#define MONO_ARCH_CALLEE_SAVED_REGS 0xff80
+#define MONO_ARCH_CALLEE_SAVED_REGS 0xfd00
 
 /*----------------------------------------*/
 /* use s390_f1/s390_f3-s390_f15 as temps  */
index c78abccad633d929d1dcef391ef5ba360dd0ee16..a11911e5c47985a582e0fe4eee35ec362d44fe04 100644 (file)
@@ -567,6 +567,10 @@ common_call_trampoline (mgreg_t *regs, guint8 *code, MonoMethod *m, MonoVTable *
                        vtable_slot = mini_resolve_imt_method (vt, vtable_slot, imt_method, &impl_method, &addr, &need_rgctx_tramp, &variant_iface, error);
                        return_val_if_nok (error, NULL);
 
+                       /* We must handle magic interfaces on rank 1 arrays of ref types as if they were variant */
+                       if (!variant_iface && vt->klass->rank == 1 && !vt->klass->element_class->valuetype && imt_method->klass->is_array_special_interface)
+                               variant_iface = imt_method;
+
                        /* This is the vcall slot which gets called through the IMT trampoline */
                        vtable_slot_to_patch = vtable_slot;
 
@@ -824,19 +828,19 @@ gpointer
 mono_magic_trampoline (mgreg_t *regs, guint8 *code, gpointer arg, guint8* tramp)
 {
        gpointer res;
+       MonoError error;
 
-       MONO_ENTER_GC_UNSAFE_UNBALANCED;
+       MONO_REQ_GC_UNSAFE_MODE;
 
-       MonoError error;
+       g_assert (mono_thread_is_gc_unsafe_mode ());
 
        trampoline_calls ++;
 
        res = common_call_trampoline (regs, code, (MonoMethod *)arg, NULL, NULL, &error);
-       mono_error_set_pending_exception (&error);
-
-       mono_interruption_checkpoint_from_trampoline ();
-
-       MONO_EXIT_GC_UNSAFE_UNBALANCED;
+       if (!is_ok (&error)) {
+               mono_error_set_pending_exception (&error);
+               return NULL;
+       }
 
        return res;
 }
index 608b4a32a0007b85e635e9cd11db6355d8778abf..4cfe898b0a085c284912893fd16961e504021ee3 100644 (file)
@@ -1380,9 +1380,8 @@ mono_allocate_stack_slots2 (MonoCompile *cfg, gboolean backward, guint32 *stack_
                                printf ("LAST: %s\n", mono_method_full_name (cfg->method, TRUE));
                        if (count > atoi (g_getenv ("COUNT3")))
                                slot = 0xffffff;
-                       else {
+                       else
                                mono_print_ins (inst);
-                               }
                }
 #endif
 
@@ -1614,20 +1613,19 @@ mono_allocate_stack_slots (MonoCompile *cfg, gboolean backward, guint32 *stack_s
                        }
                }
 
+#if 0
                {
                        static int count = 0;
                        count ++;
 
-                       /*
                        if (count == atoi (g_getenv ("COUNT")))
                                printf ("LAST: %s\n", mono_method_full_name (cfg->method, TRUE));
                        if (count > atoi (g_getenv ("COUNT")))
                                slot = 0xffffff;
-                       else {
+                       else
                                mono_print_ins (inst);
-                               }
-                       */
                }
+#endif
 
                if (inst->flags & MONO_INST_LMF) {
                        /*
@@ -3877,8 +3875,8 @@ mini_method_compile (MonoMethod *method, guint32 opts, MonoDomain *domain, JitFl
 
        /* collect statistics */
 #ifndef DISABLE_PERFCOUNTERS
-       mono_perfcounters->jit_methods++;
-       mono_perfcounters->jit_bytes += header->code_size;
+       InterlockedIncrement (&mono_perfcounters->jit_methods);
+       InterlockedAdd (&mono_perfcounters->jit_bytes, header->code_size);
 #endif
        mono_jit_stats.allocated_code_size += cfg->code_len;
        code_size_ratio = cfg->code_len;
index ea912ba6ce94a94a9c7e0735b15c05a0c24fa550..365b0ae81630cb6ef7d753bb016931ba1d2bcaf6 100644 (file)
@@ -144,6 +144,7 @@ mono_arch_patch_callsite (guint8 *method_start, guint8 *orig_code, guint8 *addr)
        if (((code [-13] == 0x49) && (code [-12] == 0xbb)) || (code [-5] == 0xe8)) {
                if (code [-5] != 0xe8) {
                        if (can_write) {
+                               g_assert ((guint64)(orig_code - 11) % 8 == 0);
                                InterlockedExchangePointer ((gpointer*)(orig_code - 11), addr);
                                VALGRIND_DISCARD_TRANSLATIONS (orig_code - 11, sizeof (gpointer));
                        }
index 91aed0b96e22801406dbc4482762d9e10cc4d63b..e3262fbe9de16e3e7e0af9cddd9e05517d01ab89 100644 (file)
@@ -526,7 +526,9 @@ mono_arch_create_rgctx_lazy_fetch_trampoline (guint32 slot, MonoTrampInfo **info
        g_free (rgctx_null_jumps);
 
        /* move the rgctx pointer to the VTABLE register */
+#if MONO_ARCH_VTABLE_REG != s390_r2
        s390_lgr (code, MONO_ARCH_VTABLE_REG, s390_r2);
+#endif
 
        tramp = mono_arch_create_specific_trampoline (GUINT_TO_POINTER (slot),
                MONO_TRAMPOLINE_RGCTX_LAZY_FETCH, mono_get_root_domain (), NULL);
@@ -559,8 +561,7 @@ mono_arch_create_rgctx_lazy_fetch_trampoline (guint32 slot, MonoTrampInfo **info
 /*------------------------------------------------------------------*/
 
 gpointer
-mono_arch_get_static_rgctx_trampoline (gpointer arg,
-                                                                          gpointer addr)
+mono_arch_get_static_rgctx_trampoline (gpointer arg, gpointer addr)
 {
        guint8 *code, *start;
        gint32 displace;
@@ -586,3 +587,20 @@ mono_arch_get_static_rgctx_trampoline (gpointer arg,
 }      
 
 /*========================= End of Function ========================*/
+
+/*------------------------------------------------------------------*/
+/*                                                                  */
+/* Name            - mono_arch_get_enter_icall_trampoline.                 */
+/*                                                                  */
+/* Function -                                                      */
+/*                                                                  */
+/*------------------------------------------------------------------*/
+
+gpointer
+mono_arch_get_enter_icall_trampoline (MonoTrampInfo **info)
+{
+       g_assert_not_reached ();
+       return NULL;
+}
+
+/*========================= End of Function ========================*/
index 4ff899fc9dec21bd325414b3866e8a0f1ff66b0f..070a81633143aea8a914fa7ba5e21d7b4f2e8e8c 100644 (file)
@@ -70,33 +70,58 @@ class Tests {
                return 0;
        }
 
+
        public static unsafe int test_0_ldobj ()
        {
                byte *ptr = stackalloc byte [20];
                for (int i = 0; i < 20; ++i)
                        ptr [i] = (byte)i;
 
+               if (BitConverter.IsLittleEndian) {
 
-               if (Intrinsics.UnalignedLdobj<short> (ptr + 0) != 0x0100)
-                       return 1;
+                       if (Intrinsics.UnalignedLdobj<short> (ptr + 0) != 0x0100)
+                               return 1;
 
-               if (Intrinsics.UnalignedLdobj<short> (ptr + 1) != 0x0201)
-                       return 2;
+                       if (Intrinsics.UnalignedLdobj<short> (ptr + 1) != 0x0201)
+                               return 2;
 
-               if (Intrinsics.UnalignedLdobj<short> (ptr + 2) != 0x0302)
-                       return 3;
+                       if (Intrinsics.UnalignedLdobj<short> (ptr + 2) != 0x0302)
+                               return 3;
 
-               if (Intrinsics.UnalignedLdobj<int> (ptr + 1) != 0x04030201)
-                       return 4;
+                       if (Intrinsics.UnalignedLdobj<int> (ptr + 1) != 0x04030201)
+                               return 4;
 
-               if (Intrinsics.UnalignedLdobj<int> (ptr + 2) != 0x05040302)
-                       return 5;
+                       if (Intrinsics.UnalignedLdobj<int> (ptr + 2) != 0x05040302)
+                               return 5;
+
+                       if (Intrinsics.UnalignedLdobj<long> (ptr + 1) != 0x0807060504030201)
+                               return 6;
+
+                       if (Intrinsics.UnalignedLdobj<long> (ptr + 6) != 0xD0C0B0A09080706)
+                               return 7;
+               } else {
+
+                       if (Intrinsics.UnalignedLdobj<short> (ptr + 0) != 0x0001)
+                               return 1;
 
-               if (Intrinsics.UnalignedLdobj<long> (ptr + 1) != 0x0807060504030201)
-                       return 6;
+                       if (Intrinsics.UnalignedLdobj<short> (ptr + 1) != 0x0102)
+                               return 2;
 
-               if (Intrinsics.UnalignedLdobj<long> (ptr + 6) != 0xD0C0B0A09080706)
-                       return 7;
+                       if (Intrinsics.UnalignedLdobj<short> (ptr + 2) != 0x0203)
+                               return 3;
+
+                       if (Intrinsics.UnalignedLdobj<int> (ptr + 1) != 0x01020304)
+                               return 4;
+
+                       if (Intrinsics.UnalignedLdobj<int> (ptr + 2) != 0x02030405)
+                               return 5;
+
+                       if (Intrinsics.UnalignedLdobj<long> (ptr + 1) != 0x0102030405060708)
+                               return 6;
+
+                       if (Intrinsics.UnalignedLdobj<long> (ptr + 6) != 0x60708090A0B0C0D)
+                               return 7;
+               }
 
                return 0;
        }
@@ -108,26 +133,51 @@ class Tests {
                        ptr [i] = (byte)i;
 
 
-               if (Intrinsics.UnalignedLdInd2 (ptr + 0) != 0x0100)
-                       return 1;
+               if (BitConverter.IsLittleEndian) {
 
-               if (Intrinsics.UnalignedLdInd2 (ptr + 1) != 0x0201)
-                       return 2;
+                       if (Intrinsics.UnalignedLdInd2 (ptr + 0) != 0x0100)
+                               return 1;
 
-               if (Intrinsics.UnalignedLdInd2 (ptr + 2) != 0x0302)
-                       return 3;
+                       if (Intrinsics.UnalignedLdInd2 (ptr + 1) != 0x0201)
+                               return 2;
 
-               if (Intrinsics.UnalignedLdInd4 (ptr + 1) != 0x04030201)
-                       return 4;
+                       if (Intrinsics.UnalignedLdInd2 (ptr + 2) != 0x0302)
+                               return 3;
 
-               if (Intrinsics.UnalignedLdInd4 (ptr + 2) != 0x05040302)
-                       return 5;
+                       if (Intrinsics.UnalignedLdInd4 (ptr + 1) != 0x04030201)
+                               return 4;
+
+                       if (Intrinsics.UnalignedLdInd4 (ptr + 2) != 0x05040302)
+                               return 5;
 
-               if (Intrinsics.UnalignedLdInd8 (ptr + 1) != 0x0807060504030201)
-                       return 6;
+                       if (Intrinsics.UnalignedLdInd8 (ptr + 1) != 0x0807060504030201)
+                               return 6;
+
+                       if (Intrinsics.UnalignedLdInd8 (ptr + 6) != 0xD0C0B0A09080706)
+                               return 7;
+               } else {
 
-               if (Intrinsics.UnalignedLdInd8 (ptr + 6) != 0xD0C0B0A09080706)
-                       return 7;
+                       if (Intrinsics.UnalignedLdInd2 (ptr + 0) != 0x0001)
+                               return 1;
+
+                       if (Intrinsics.UnalignedLdInd2 (ptr + 1) != 0x0102)
+                               return 2;
+
+                       if (Intrinsics.UnalignedLdInd2 (ptr + 2) != 0x0203)
+                               return 3;
+
+                       if (Intrinsics.UnalignedLdInd4 (ptr + 1) != 0x01020304)
+                               return 4;
+
+                       if (Intrinsics.UnalignedLdInd4 (ptr + 2) != 0x02030405)
+                               return 5;
+
+                       if (Intrinsics.UnalignedLdInd8 (ptr + 1) != 0x0102030405060708)
+                               return 6;
+
+                       if (Intrinsics.UnalignedLdInd8 (ptr + 6) != 0x60708090A0B0C0D)
+                               return 7;
+               }
 
                return 0;
        }
@@ -185,21 +235,41 @@ class Tests {
        {
                byte *ptr = stackalloc byte [20];
 
-               Intrinsics.UnalignedStobj <short> (ptr + 0, 0x6688);
-               if (ptr [0] != 0x88 || ptr [1] != 0x66)
-                       return 1;
+               if (BitConverter.IsLittleEndian) {
+                       Intrinsics.UnalignedStobj <short> (ptr + 0, 0x6688);
+                       if (ptr [0] != 0x88 || ptr [1] != 0x66)
+                               return 1;
 
-               Intrinsics.UnalignedStobj <short> (ptr + 1, 0x6589);
-               if (ptr [1] != 0x89 || ptr [2] != 0x65)
-                       return 2;
+                       Intrinsics.UnalignedStobj <short> (ptr + 1, 0x6589);
+                       if (ptr [1] != 0x89 || ptr [2] != 0x65)
+                               return 2;
 
-               Intrinsics.UnalignedStobj <int> (ptr + 1, 0x60708090);
-               if (ptr [1] != 0x90 || ptr [2] != 0x80 || ptr [3] != 0x70 || ptr [4] != 0x60)
-                       return 3;
+                       Intrinsics.UnalignedStobj <int> (ptr + 1, 0x60708090);
+                       if (ptr [1] != 0x90 || ptr [2] != 0x80 || ptr [3] != 0x70 || ptr [4] != 0x60)
+                               return 3;
 
-               Intrinsics.UnalignedStobj <long> (ptr + 1, 0x405060708090);
-               if (ptr [1] != 0x90 || ptr [2] != 0x80 || ptr [3] != 0x70 || ptr [4] != 0x60 || ptr [5] != 0x50 || ptr [6] != 0x40)
-                       return 4;
+                       Intrinsics.UnalignedStobj <long> (ptr + 1, 0x405060708090);
+                       if (ptr [1] != 0x90 || ptr [2] != 0x80 || ptr [3] != 0x70 || 
+                           ptr [4] != 0x60 || ptr [5] != 0x50 || ptr [6] != 0x40)
+                               return 4;
+               } else {
+                       Intrinsics.UnalignedStobj <short> (ptr + 0, 0x6688);
+                       if (ptr [0] != 0x66 || ptr [1] != 0x88)
+                               return 1;
+
+                       Intrinsics.UnalignedStobj <short> (ptr + 1, 0x6589);
+                       if (ptr [1] != 0x65 || ptr [2] != 0x89)
+                               return 2;
+
+                       Intrinsics.UnalignedStobj <int> (ptr + 1, 0x60708090);
+                       if (ptr [1] != 0x60 || ptr [2] != 0x70 || ptr [3] != 0x80 || ptr [4] != 0x90)
+                               return 3;
+
+                       Intrinsics.UnalignedStobj <long> (ptr + 1, 0x2030405060708090);
+                       if (ptr [1] != 0x20 || ptr [2] != 0x30 || ptr [3] != 0x40 || 
+                           ptr [4] != 0x50 || ptr [5] != 0x60 || ptr [6] != 0x70)
+                               return 4;
+               }
 
                return 0;
        }
index 8f56a644ac7bb9678f3405b6ebd154fea8f85ed3..1b9c83586944fd6d007bec4655810afa0edf91bf 100644 (file)
@@ -262,7 +262,7 @@ usage (void)
                mono_profiler_printf ("\t                         %s", event_list [i].event_name);
 
        mono_profiler_printf ("\t[no]alloc            enable/disable recording allocation info");
-       mono_profiler_printf ("\t[no]legacy           enable/disable pre mono 5.4 default profiler events");
+       mono_profiler_printf ("\t[no]legacy           enable/disable pre Mono 5.6 default profiler events");
        mono_profiler_printf ("\tsample[-real][=FREQ] enable/disable statistical sampling of threads");
        mono_profiler_printf ("\t                     FREQ in Hz, 100 by default");
        mono_profiler_printf ("\t                     the -real variant uses wall clock time instead of process time");
index 1c54fc261f9ecd5133b5edc84f467de7169917ec..d5416f0df3630ee6a6bc5b4781bc0e9c5442873c 100644 (file)
 
 #include <mono/utils/memcheck.h>
 #include <mono/utils/mono-mmap-internals.h>
+#include <mono/utils/unlocked.h>
 
 #undef pthread_create
 #undef pthread_join
@@ -1855,7 +1856,7 @@ collect_nursery (const char *reason, gboolean is_overflow, SgenGrayQueue *unpin_
        major_collector.finish_nursery_collection ();
 
        TV_GETTIME (last_minor_collection_end_tv);
-       InterlockedAdd64 (&gc_stats.minor_gc_time, TV_ELAPSED (last_minor_collection_start_tv, last_minor_collection_end_tv));
+       UnlockedAdd64 (&gc_stats.minor_gc_time, TV_ELAPSED (last_minor_collection_start_tv, last_minor_collection_end_tv));
 
        sgen_debug_dump_heap ("minor", InterlockedRead (&gc_stats.minor_gc_count) - 1, NULL);
 
@@ -2349,7 +2350,7 @@ major_do_collection (const char *reason, gboolean is_overflow, gboolean forced)
        sgen_gray_object_queue_dispose (&gc_thread_gray_queue);
 
        TV_GETTIME (time_end);
-       InterlockedAdd64 (&gc_stats.major_gc_time, TV_ELAPSED (time_start, time_end));
+       UnlockedAdd64 (&gc_stats.major_gc_time, TV_ELAPSED (time_start, time_end));
 
        /* FIXME: also report this to the user, preferably in gc-end. */
        if (major_collector.get_and_reset_num_major_objects_marked)
@@ -2385,7 +2386,7 @@ major_start_concurrent_collection (const char *reason)
        num_objects_marked = major_collector.get_and_reset_num_major_objects_marked ();
 
        TV_GETTIME (time_end);
-       InterlockedAdd64 (&gc_stats.major_gc_time, TV_ELAPSED (time_start, time_end));
+       UnlockedAdd64 (&gc_stats.major_gc_time, TV_ELAPSED (time_start, time_end));
 
        current_collection_generation = -1;
 }
@@ -2413,7 +2414,7 @@ major_update_concurrent_collection (void)
        sgen_los_update_cardtable_mod_union ();
 
        TV_GETTIME (total_end);
-       InterlockedAdd64 (&gc_stats.major_gc_time, TV_ELAPSED (total_start, total_end));
+       UnlockedAdd64 (&gc_stats.major_gc_time, TV_ELAPSED (total_start, total_end));
 }
 
 static void
@@ -2435,7 +2436,7 @@ major_finish_concurrent_collection (gboolean forced)
        sgen_workers_stop_all_workers (GENERATION_OLD);
 
        SGEN_TV_GETTIME (time_major_conc_collection_end);
-       InterlockedAdd64 (&gc_stats.major_gc_time_concurrent, SGEN_TV_ELAPSED (time_major_conc_collection_start, time_major_conc_collection_end));
+       UnlockedAdd64 (&gc_stats.major_gc_time_concurrent, SGEN_TV_ELAPSED (time_major_conc_collection_start, time_major_conc_collection_end));
 
        major_collector.update_cardtable_mod_union ();
        sgen_los_update_cardtable_mod_union ();
@@ -2450,7 +2451,7 @@ major_finish_concurrent_collection (gboolean forced)
        sgen_gray_object_queue_dispose (&gc_thread_gray_queue);
 
        TV_GETTIME (total_end);
-       InterlockedAdd64 (&gc_stats.major_gc_time, TV_ELAPSED (total_start, total_end));
+       UnlockedAdd64 (&gc_stats.major_gc_time, TV_ELAPSED (total_start, total_end));
 
        current_collection_generation = -1;
 }
index 3e2620b219fdfca712a8afec98468c49b63945b7..4ed1ec495f98cd7ba2d87e689458aab47ecbd979 100644 (file)
@@ -968,10 +968,14 @@ void sgen_null_links_if (SgenObjectPredicateFunc predicate, void *data, int gene
 
 typedef gpointer (*SgenGCHandleIterateCallback) (gpointer hidden, GCHandleType handle_type, int max_generation, gpointer user);
 
+guint32 sgen_gchandle_new (GCObject *obj, gboolean pinned);
+guint32 sgen_gchandle_new_weakref (GCObject *obj, gboolean track_resurrection);
 void sgen_gchandle_iterate (GCHandleType handle_type, int max_generation, SgenGCHandleIterateCallback callback, gpointer user);
 void sgen_gchandle_set_target (guint32 gchandle, GCObject *obj);
 void sgen_mark_normal_gc_handles (void *addr, SgenUserMarkFunc mark_func, void *gc_data);
 gpointer sgen_gchandle_get_metadata (guint32 gchandle);
+GCObject *sgen_gchandle_get_target (guint32 gchandle);
+void sgen_gchandle_free (guint32 gchandle);
 
 /* Other globals */
 
index 555d5bf483f68db8dc8f02f59fec6d389f129f5b..ba7259f50f9bd9a77e3317ff4d3090ec6f21011b 100644 (file)
@@ -202,50 +202,14 @@ sgen_gchandle_iterate (GCHandleType handle_type, int max_generation, SgenGCHandl
        } SGEN_ARRAY_LIST_END_FOREACH_SLOT;
 }
 
-/**
- * mono_gchandle_new:
- * \param obj managed object to get a handle for
- * \param pinned whether the object should be pinned
- * This returns a handle that wraps the object, this is used to keep a
- * reference to a managed object from the unmanaged world and preventing the
- * object from being disposed.
- * 
- * If \p pinned is false the address of the object can not be obtained, if it is
- * true the address of the object can be obtained.  This will also pin the
- * object so it will not be possible by a moving garbage collector to move the
- * object. 
- * 
- * \returns a handle that can be used to access the object from unmanaged code.
- */
 guint32
-mono_gchandle_new (GCObject *obj, gboolean pinned)
+sgen_gchandle_new (GCObject *obj, gboolean pinned)
 {
        return alloc_handle (gc_handles_for_type (pinned ? HANDLE_PINNED : HANDLE_NORMAL), obj, FALSE);
 }
 
-/**
- * mono_gchandle_new_weakref:
- * \param obj managed object to get a handle for
- * \param track_resurrection Determines how long to track the object, if this is set to TRUE, the object is tracked after finalization, if FALSE, the object is only tracked up until the point of finalization.
- *
- * This returns a weak handle that wraps the object, this is used to
- * keep a reference to a managed object from the unmanaged world.
- * Unlike the \c mono_gchandle_new the object can be reclaimed by the
- * garbage collector.  In this case the value of the GCHandle will be
- * set to zero.
- * 
- * If \p track_resurrection is TRUE the object will be tracked through
- * finalization and if the object is resurrected during the execution
- * of the finalizer, then the returned weakref will continue to hold
- * a reference to the object.   If \p track_resurrection is FALSE, then
- * the weak reference's target will become NULL as soon as the object
- * is passed on to the finalizer.
- * 
- * \returns a handle that can be used to access the object from
- * unmanaged code.
- */
 guint32
-mono_gchandle_new_weakref (GCObject *obj, gboolean track_resurrection)
+sgen_gchandle_new_weakref (GCObject *obj, gboolean track_resurrection)
 {
        return alloc_handle (gc_handles_for_type (track_resurrection ? HANDLE_WEAK_TRACK : HANDLE_WEAK), obj, track_resurrection);
 }
@@ -292,18 +256,8 @@ retry:
        return obj;
 }
 
-/**
- * mono_gchandle_get_target:
- * \param gchandle a GCHandle's handle.
- *
- * The handle was previously created by calling \c mono_gchandle_new or
- * \c mono_gchandle_new_weakref. 
- *
- * \returns a pointer to the \c MonoObject* represented by the handle or
- * NULL for a collected object if using a weakref handle.
- */
 GCObject*
-mono_gchandle_get_target (guint32 gchandle)
+sgen_gchandle_get_target (guint32 gchandle)
 {
        guint index = MONO_GC_HANDLE_SLOT (gchandle);
        GCHandleType type = MONO_GC_HANDLE_TYPE (gchandle);
@@ -382,16 +336,8 @@ sgen_gchandle_get_metadata (guint32 gchandle)
        return mono_gchandle_slot_metadata (slot, MONO_GC_HANDLE_TYPE_IS_WEAK (type));
 }
 
-/**
- * mono_gchandle_free:
- * \param gchandle a GCHandle's handle.
- *
- * Frees the \p gchandle handle.  If there are no outstanding
- * references, the garbage collector can reclaim the memory of the
- * object wrapped. 
- */
 void
-mono_gchandle_free (guint32 gchandle)
+sgen_gchandle_free (guint32 gchandle)
 {
        guint32 index = MONO_GC_HANDLE_SLOT (gchandle);
        GCHandleType type = MONO_GC_HANDLE_TYPE (gchandle);
index 211bc8b7277975471954dec78c7775c9a8e8c9f6..c9aaaa2667b5cb9b45cf5b7427f43e8a8bd96060 100644 (file)
@@ -305,6 +305,10 @@ sgen_thread_pool_shutdown (void)
        mono_os_mutex_destroy (&lock);
        mono_os_cond_destroy (&work_cond);
        mono_os_cond_destroy (&done_cond);
+
+       for (int i = 0; i < threads_num; i++) {
+               mono_threads_add_joinable_thread ((gpointer)threads [i]);
+       }
 }
 
 SgenThreadPoolJob*
index d7b3119374d47584deb42bf0b5b4e826ceecc9d2..4e4de8f0db8ea40e7395e7fbf32f6551863f0b1c 100755 (executable)
@@ -304,6 +304,7 @@ TESTS_CS_SRC=               \
        delegate-async-exit.cs  \
        delegate-delegate-exit.cs       \
        delegate-exit.cs        \
+       delegate-disposed-hashcode.cs   \
        finalizer-abort.cs      \
        finalizer-exception.cs  \
        finalizer-exit.cs       \
diff --git a/mono/tests/delegate-disposed-hashcode.cs b/mono/tests/delegate-disposed-hashcode.cs
new file mode 100644 (file)
index 0000000..f90118a
--- /dev/null
@@ -0,0 +1,38 @@
+using System;
+
+// Regression test for bug #59235
+
+public static class Program {
+       delegate void MyDel (int i, int j);
+
+       public static void Main (string[] args) {
+               var o = new MyTarget ();
+               Console.WriteLine ("Hashcode1: " + o.GetHashCode ());
+
+               MyDel d = o.DoStuff;
+               Console.WriteLine ("Hashcode2: " + d.GetHashCode ());
+               Console.WriteLine ("Hashcode3: " + o.GetHashCode ());
+
+               o.Dispose ();
+               Console.WriteLine ("Hashcode4: " + d.GetHashCode ());
+       }
+
+       class MyTarget : IDisposable {
+               public int counter = 0;
+               bool avail = true;
+
+               public void DoStuff (int i, int j) {
+                       counter += i + j;
+               }
+
+               public void Dispose () {
+                       avail = false;
+               }
+
+               public override int GetHashCode () {
+                       if (!avail)
+                               throw new ObjectDisposedException ("MyTarget is dead");
+                       return counter.GetHashCode ();
+               }
+       }
+}
index 39e5c3766a8fc0a7dc25bbcbaa546eb3fe0c01ea..185c987665e8ab25ee4bd915680c7167904e5b35 100644 (file)
@@ -7488,7 +7488,7 @@ mono_test_marshal_pointer_array (int *arr[])
 
 #ifndef WIN32
 
-typedef void (*NativeToManagedExceptionRethrowFunc) ();
+typedef void (*NativeToManagedExceptionRethrowFunc) (void);
 
 void *mono_test_native_to_managed_exception_rethrow_thread (void *arg)
 {
index a7108623b82a0d4699c3dfcfbd369e7d11bf974c..8aed46593919d72db2d801668c48073302e466ea 100644 (file)
@@ -150,7 +150,7 @@ register_internal (const char *name, int type, void *addr, int size)
 
        for (counter = counters; counter; counter = counter->next) {
                if (counter->addr == addr) {
-                       g_warning ("you are registering twice the same counter address");
+                       g_warning ("you are registering the same counter address twice: %s at %p", name, addr);
                        mono_os_mutex_unlock (&counters_mutex);
                        return;
                }
index 12df49b91ba84fbad94d2c64b25c9d71afdb9d3e..f6a6dfa9a5aebce012f9554ca65a196210810611 100644 (file)
@@ -63,7 +63,7 @@ typedef struct {
        uint8_t ee:1;           // 035 - Execute extensions
        uint8_t em:1;           // 036 - Enhanced monitor
        uint8_t fpe:1;          // 037 - Floating point extension
-       uint8_t x001:1;         // 038 - Undefined
+       uint8_t opcf:1;         // 038 - Order-preserving-compression facility
        uint8_t ibm03:1;        // 039 - Assigned to IBM
        uint8_t spp:1;          // 040 - Set program parameters
        uint8_t fpse:1;         // 041 - FP support enhancement
@@ -79,11 +79,11 @@ typedef struct {
        uint8_t ltlb:1;         // 051 - Local TLB clearing
        uint8_t ia:1;           // 052 - Interlocked access
        uint8_t lsoc2:1;        // 053 - Load/store on CC 2
-       uint8_t x002:1;         // 054 - Undefined
+       uint8_t eecf:1;         // 054 - Entropy-encoding compression facility
        uint8_t ibm05:1;        // 055 - Assigned to IBM
        uint8_t x003:1;         // 056 - Undefined
        uint8_t msa5:1;         // 057 - Message security assist 5
-       uint8_t x004:1;         // 058 - Undefined
+       uint8_t mie2:1;         // 058 - Miscellaneous execution facility 2
        uint8_t x005:1;         // 059 - Undefined
        uint8_t x006:1;         // 060 - Undefined
        uint8_t x007:1;         // 061 - Undefined
@@ -110,11 +110,27 @@ typedef struct {
        uint8_t x012[5];        // 088-127 - Undefined
        uint8_t ibm12:1;        // 128 - Assigned to IBM
        uint8_t vec:1;          // 129 - Vector facility
-       uint8_t x013:6;         // 130-135 - Undefined
-       uint8_t x014:6;         // 136-141 - Undefined
+       uint8_t iep:1;          // 130 - Instruction Execution Protection Facility
+       uint8_t sea:1;          // 131 - Side-effect-access Faility
+       uint8_t x013:1;         // 132 - Undefined
+       uint8_t gs:1;           // 133 - Guarded Storage Facility
+       uint8_t vpd:1;          // 134 - Vector Packed Decimal Facility
+       uint8_t ve1:1;          // 135 - Vector Enhancements Facilityty
+       uint8_t x014:2;         // 136-137 - Undefined
+       uint8_t cazm:1;         // 138 - Configuration-z/Architecture-arcitectural -mode Faciliy
+       uint8_t mef:1;          // 139 - Multiple-epoch Facility ture-arcitectural -mode Faciliy
+       uint8_t ibm13:2;        // 140-141 - Assigned to IBM
        uint8_t sccm:1;         // 142 - Store CPU counter multiple
-       uint8_t ibm13:1;        // 143 - Assigned to IBM
-       uint8_t x015[14];       // 144-256 Undefined
+       uint8_t x015:1;         // 143 - Assigned to IBM
+       uint8_t tpei:1;         // 144 - Test Pending External Interrption Facility
+       uint8_t irbm:1;         // 145 - Insert Reference Bits Multiple Facility
+       uint8_t mse8:1;         // 146 - Message Security Assist Extension 8
+       uint8_t ibm14:1;        // 147 - Reserved for IBM use
+       uint8_t x016:4;         // 148-151 - Undefined
+       uint8_t x017[2];        // 152-167 - Undefined
+       uint8_t esac:1;         // 168 - ESA/390 Compatibility Mode Facility
+       uint8_t x018:7;         // 169-175 - Undefined
+       uint8_t x019[10];       // 176-256 Undefined
 } __attribute__ ((__packed__)) __attribute__ ((__aligned__(8))) facilityList_t;
 
 void
@@ -131,6 +147,11 @@ mono_hwcap_arch_init (void)
                : "0", "cc"
        );
 
-       mono_hwcap_s390x_has_fpe = facs.fpe;
-       mono_hwcap_s390x_has_vec = facs.vec;
+       mono_hwcap_s390x_has_fpe  = facs.fpe;
+       mono_hwcap_s390x_has_vec  = facs.vec;
+       mono_hwcap_s390x_has_mlt  = facs.multi;
+       mono_hwcap_s390x_has_ia   = facs.ia;
+       mono_hwcap_s390x_has_gie  = facs.gie;
+       mono_hwcap_s390x_has_mie2 = facs.mie2;
+       mono_hwcap_s390x_has_gs   = facs.gs;
 }
index 419066ad04dbba33ad7cda003ab81f3080337d7f..05f89a34ef93ed73ebab52f971a7b8c8fda88c30 100644 (file)
@@ -35,6 +35,11 @@ MONO_HWCAP_VAR(ppc_has_multiple_ls_units)
 
 MONO_HWCAP_VAR(s390x_has_fpe)
 MONO_HWCAP_VAR(s390x_has_vec)
+MONO_HWCAP_VAR(s390x_has_mlt)
+MONO_HWCAP_VAR(s390x_has_ia)
+MONO_HWCAP_VAR(s390x_has_gie)
+MONO_HWCAP_VAR(s390x_has_mie2)
+MONO_HWCAP_VAR(s390x_has_gs)
 
 #elif defined (TARGET_SPARC) || defined (TARGET_SPARC64)
 
index 38e869cd040e9ffb3504349cbd9bb7c25aa0babb..1518438babbb9a99d2f1844bf65b3a35888d8bd0 100644 (file)
@@ -633,3 +633,21 @@ mono_thread_state_name (int state)
 {
        return state_name (state);
 }
+
+gboolean
+mono_thread_is_gc_unsafe_mode (void)
+{
+       MonoThreadInfo *cur = mono_thread_info_current ();
+
+       if (!cur)
+               return FALSE;
+
+       switch (mono_thread_info_current_state (cur)) {
+       case STATE_RUNNING:
+       case STATE_ASYNC_SUSPEND_REQUESTED:
+       case STATE_SELF_SUSPEND_REQUESTED:
+               return TRUE;
+       default:
+               return FALSE;
+       }
+}
index ffa9de63a66e5468d8cd5fe58989202cb73755b1..b95784fa6fd9ebeb5d69a5f94eba78e658ad4809 100644 (file)
@@ -612,6 +612,7 @@ gboolean mono_thread_info_is_live (THREAD_INFO_TYPE *info);
 int mono_thread_info_suspend_count (THREAD_INFO_TYPE *info);
 int mono_thread_info_current_state (THREAD_INFO_TYPE *info);
 const char* mono_thread_state_name (int state);
+gboolean mono_thread_is_gc_unsafe_mode (void);
 
 gboolean mono_thread_info_in_critical_location (THREAD_INFO_TYPE *info);
 gboolean mono_thread_info_begin_suspend (THREAD_INFO_TYPE *info);
index 2ece0733d122a42d8ac969a7027081faf6af501a..81b0ade26bc94114cf06cfc43f78da7296cd9953 100644 (file)
@@ -90,8 +90,10 @@ mono_unicode_from_external (const gchar *in, gsize *bytes)
        g_strfreev (encodings);
        
        if(g_utf8_validate (in, -1, NULL)) {
-               gunichar2 *unires=g_utf8_to_utf16 (in, -1, NULL, (glong *)bytes, NULL);
-               *bytes *= 2;
+               glong items_written;
+               gunichar2 *unires=g_utf8_to_utf16 (in, -1, NULL, &items_written, NULL);
+               items_written *= 2;
+               *bytes = items_written;
                return(unires);
        }
 
index 19114ac61051812767258e9aee684f6fc99efe57..6c4abcf468286674a1738b8276e37e9b9bd3e0ba 100644 (file)
@@ -31,6 +31,27 @@ UnlockedIncrement (gint32 *val)
        return ++*val;
 }
 
+MONO_UNLOCKED_ATTRS
+gint64
+UnlockedIncrement64 (gint64 *val)
+{
+       return ++*val;
+}
+
+MONO_UNLOCKED_ATTRS
+gint64
+UnlockedDecrement64 (gint64 *val)
+{
+       return --*val;
+}
+
+MONO_UNLOCKED_ATTRS
+gint32
+UnlockedDecrement (gint32 *val)
+{
+       return --*val;
+}
+
 MONO_UNLOCKED_ATTRS
 gint32
 UnlockedAdd (gint32 *dest, gint32 add)
@@ -59,6 +80,13 @@ UnlockedWrite (gint32 *dest, gint32 val)
        *dest = val;
 }
 
+MONO_UNLOCKED_ATTRS
+void
+UnlockedWrite64 (gint64 *dest, gint64 val)
+{
+       *dest = val;
+}
+
 MONO_UNLOCKED_ATTRS
 gint32
 UnlockedRead (gint32 *src)
index eeab6c36a927c82329a4337ce14a54705e29b6e4..f2e7a9bcdb6fc2e4362f257c8ae9ae5ed4470ad6 100644 (file)
@@ -8,7 +8,7 @@ class FsharpPackage(GitHubTarballPackage):
             override_properties={ 'make': 'make' })
 
         self.extra_stage_files = ['lib/mono/xbuild/Microsoft/VisualStudio/v/FSharp/Microsoft.FSharp.Targets']
-        self.sources.extend(['patches/fsharp-fix-mdb-support.patch'])
+        self.sources.extend(['patches/fsharp-portable-pdb.patch', 'patches/fsharp-metadata-table-size-fix.patch'])
 
     def prep(self):
         Package.prep(self)
index ab426a7c952cf4560a1b3df82404a29da88b16d2..686347a87f9e94e8703dbcd582b607ab63460c79 100755 (executable)
@@ -38,7 +38,9 @@ rm -rf share/emacs
 rm -rf share/strings
 rm -rf share/pixmaps
 rm -rf share/intltool
+rm -rf share/llvm
 rm -rf var/cache/fontconfig
+rm -rf include/llvm
 
 # delete most of the *.a files
 rm -rf lib/cairo/libcairo-trace.a
@@ -46,38 +48,8 @@ rm -rf lib/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-svg.a
 rm -rf lib/gtk-2.0/2.10.0/engines/libsvg.a
 rm -rf lib/libCompilerDriver.a
 rm -rf lib/libEnhancedDisassembly.a
-rm -rf lib/libLLVMAnalysis.a
-rm -rf lib/libLLVMArchive.a
-rm -rf lib/libLLVMAsmParser.a
-rm -rf lib/libLLVMAsmPrinter.a
-rm -rf lib/libLLVMBitReader.a
-rm -rf lib/libLLVMBitWriter.a
-rm -rf lib/libLLVMCodeGen.a
-rm -rf lib/libLLVMCore.a
-rm -rf lib/libLLVMExecutionEngine.a
-rm -rf lib/libLLVMInstCombine.a
-rm -rf lib/libLLVMInstrumentation.a
-rm -rf lib/libLLVMInterpreter.a
-rm -rf lib/libLLVMJIT.a
-rm -rf lib/libLLVMLinker.a
-rm -rf lib/libLLVMMC.a
-rm -rf lib/libLLVMMCDisassembler.a
-rm -rf lib/libLLVMMCJIT.a
-rm -rf lib/libLLVMMCParser.a
-rm -rf lib/libLLVMObject.a
-rm -rf lib/libLLVMScalarOpts.a
-rm -rf lib/libLLVMSelectionDAG.a
-rm -rf lib/libLLVMSupport.a
-rm -rf lib/libLLVMTarget.a
-rm -rf lib/libLLVMTransformUtils.a
-rm -rf lib/libLLVMX86AsmParser.a
-rm -rf lib/libLLVMX86AsmPrinter.a
-rm -rf lib/libLLVMX86CodeGen.a
-rm -rf lib/libLLVMX86Disassembler.a
-rm -rf lib/libLLVMX86Info.a
-rm -rf lib/libLLVMipa.a
-rm -rf lib/libLLVMipo.a
-rm -rf lib/libLTO.a
+rm -rf lib/libLLVM*.a
+rm -rf lib/libLTO.*
 # rm -rf lib/libMonoPosixHelper.a
 # rm -rf lib/libMonoSupportW.a
 rm -rf lib/libUnitTestMain.a
@@ -121,10 +93,12 @@ rm -rf lib/libxml2.a
 
 # we don't need any of the llvm executables except llc and opt
 rm -rf bin/bugpoint
-rm -rf bin/lli
+rm -rf bin/lli*
 rm -rf bin/llvm-*
 rm -rf bin/macho-dump
 rm -rf bin/ccache
+rm -rf bin/llc32
+rm -rf bin/opt32
 
 #
 # 14:39 <baulig> the install script needs to be modified not to
diff --git a/packaging/MacSDK/patches/fsharp-fix-mdb-support.patch b/packaging/MacSDK/patches/fsharp-fix-mdb-support.patch
deleted file mode 100644 (file)
index 164ad3d..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-commit 26e3e557e25b0ba5103dfb683050d2435f7708bb
-Author: Ankit Jain <ankit.jain@xamarin.com>
-Date:   Wed Feb 8 18:44:41 2017 -0500
-
-    [msbuild] Add support for .mdb files to be copied, with mono's msbuild
-
-    msbuild defaults to .pdb files as the default debug file extension.
-    Mono's msbuild has `$(_DebugFileExt)` property to override this. We need
-    to set that to `.mdb`, else the generated `.mdb` files won't get
-    copied/deployed.
-
-    But this feature is not upstream yet, so it is not present in upstream
-    F# yet.
-
-diff --git a/src/fsharp/FSharp.Build/Microsoft.FSharp.targets b/src/fsharp/FSharp.Build/Microsoft.FSharp.targets
-index e185bdf..2788988 100644
---- a/src/fsharp/FSharp.Build/Microsoft.FSharp.targets
-+++ b/src/fsharp/FSharp.Build/Microsoft.FSharp.targets
-@@ -38,6 +38,10 @@ this file.
-         <RootNamespace Condition="'$(RootNamespace)'==''">RootNamespace</RootNamespace>
-         <Actual32Bit Condition="'$(TargetFrameworkVersion)'=='v2.0' or '$(TargetFrameworkVersion)'=='v3.0' or '$(TargetFrameworkVersion)'=='v3.5' or '$(TargetFrameworkVersion)'=='v4.0'">false</Actual32Bit>
-         <Actual32Bit Condition="!('$(TargetFrameworkVersion)'=='v2.0' or '$(TargetFrameworkVersion)'=='v3.0' or '$(TargetFrameworkVersion)'=='v3.5' or '$(TargetFrameworkVersion)'=='v4.0')">$(Prefer32Bit)</Actual32Bit>
-+
-+        <!-- _DebugFileExt is not an upstream msbuild feature yet -->
-+        <_DebugFileExt Condition="'$(FscDebugFileExt)' != ''">$(FscDebugFileExt)</_DebugFileExt>
-+        <_DebugFileExt Condition="'$(_DebugFileExt)' == ''">.mdb</_DebugFileExt>
-     </PropertyGroup>
-     <!--
diff --git a/packaging/MacSDK/patches/fsharp-metadata-table-size-fix.patch b/packaging/MacSDK/patches/fsharp-metadata-table-size-fix.patch
new file mode 100644 (file)
index 0000000..cdc0111
--- /dev/null
@@ -0,0 +1,451 @@
+From a7ac2facce91c15940e466f67a4ba9a31f687a1a Mon Sep 17 00:00:00 2001
+From: Kevin Ransom <kevinr@microsoft.com>
+Date: Sun, 3 Sep 2017 17:00:18 -0700
+Subject: [PATCH 1/3] Fix MethodDebugTable for portablePDBs
+
+---
+ src/absil/ilwritepdb.fs | 27 ++++++++++++++-------------
+ 1 file changed, 14 insertions(+), 13 deletions(-)
+
+diff --git a/src/absil/ilwritepdb.fs b/src/absil/ilwritepdb.fs
+index 009d39f653..3d68edee38 100644
+--- a/src/absil/ilwritepdb.fs
++++ b/src/absil/ilwritepdb.fs
+@@ -330,17 +330,22 @@ let generatePortablePdb (embedAllSource:bool) (embedSourceList:string list) (sou
+                     | None -> Array.empty<PdbSequencePoint>
+                     | Some (_,_) -> minfo.SequencePoints
+-            let getDocumentHandle d =
+-                if docs.Length = 0 || d < 0 || d > docs.Length then
+-                    Unchecked.defaultof<DocumentHandle>
+-                else 
+-                    match documentIndex.TryGetValue(docs.[d].File) with
+-                    | false, _ -> Unchecked.defaultof<DocumentHandle>
+-                    | true, h -> h
+-
+-            if sps.Length = 0 then
++            let builder = new BlobBuilder()
++            builder.WriteCompressedInteger(minfo.LocalSignatureToken)
++
++            if sps = Array.empty then
++                builder.WriteCompressedInteger( 0 )
++                builder.WriteCompressedInteger( 0 )
+                 Unchecked.defaultof<DocumentHandle>, Unchecked.defaultof<BlobHandle>
+             else
++                let getDocumentHandle d =
++                    if docs.Length = 0 || d < 0 || d > docs.Length then
++                        Unchecked.defaultof<DocumentHandle>
++                    else 
++                        match documentIndex.TryGetValue(docs.[d].File) with
++                        | false, _ -> Unchecked.defaultof<DocumentHandle>
++                        | true, h -> h
++
+                 // Return a document that the entire method body is declared within.
+                 // If part of the method body is in another document returns nil handle.
+                 let tryGetSingleDocumentIndex =
+@@ -350,12 +355,8 @@ let generatePortablePdb (embedAllSource:bool) (embedSourceList:string list) (sou
+                             singleDocumentIndex <- -1
+                     singleDocumentIndex
+-                let builder = new BlobBuilder()
+-                builder.WriteCompressedInteger(minfo.LocalSignatureToken)
+-
+                 // Initial document:  When sp's spread over more than one document we put the initial document here.
+                 let singleDocumentIndex = tryGetSingleDocumentIndex
+-
+                 if singleDocumentIndex = -1 then
+                     builder.WriteCompressedInteger( MetadataTokens.GetRowNumber(DocumentHandle.op_Implicit(getDocumentHandle (sps.[0].Document))) )
+
+From 01d3e175e7e5c8c554c92bf121adba44e1287f9a Mon Sep 17 00:00:00 2001
+From: Kevin Ransom <kevinr@microsoft.com>
+Date: Tue, 5 Sep 2017 02:59:55 -0700
+Subject: [PATCH 2/3] ensure that pdb gets a record for abstract methods
+
+---
+ src/absil/ilread.fs      |   1 -
+ src/absil/ilsupp.fs      |   3 --
+ src/absil/ilsupp.fsi     |   1 -
+ src/absil/ilwrite.fs     |  17 +++++--
+ src/absil/ilwritepdb.fs  | 113 ++++++++++++++++++++++++++---------------------
+ src/absil/ilwritepdb.fsi |   2 +-
+ 6 files changed, 77 insertions(+), 60 deletions(-)
+
+diff --git a/src/absil/ilread.fs b/src/absil/ilread.fs
+index c7a435291c..2d42a6abd8 100644
+--- a/src/absil/ilread.fs
++++ b/src/absil/ilread.fs
+@@ -2903,7 +2903,6 @@ and seekReadMethodRVA ctxt (idx,nm,_internalcall,noinline,aggressiveinline,numty
+                try 
+                  let pdbm = pdbReaderGetMethod pdbr (uncodedToken TableNames.Method idx)
+-                 //let rootScope = pdbMethodGetRootScope pdbm 
+                  let sps = pdbMethodGetSequencePoints pdbm
+                  (*dprintf "#sps for 0x%x = %d\n" (uncodedToken TableNames.Method idx) (Array.length sps)  *)
+                  (* let roota,rootb = pdbScopeGetOffsets rootScope in  *)
+diff --git a/src/absil/ilsupp.fs b/src/absil/ilsupp.fs
+index c95480bc06..66a1a6aa16 100644
+--- a/src/absil/ilsupp.fs
++++ b/src/absil/ilsupp.fs
+@@ -1230,9 +1230,6 @@ let pdbMethodGetToken (meth:PdbMethod) : int32 =
+     let token = meth.symMethod.Token
+     token.GetToken()
+   
+-let pdbMethodGetRootScope (meth:PdbMethod) : PdbMethodScope = 
+-    { symScope = meth.symMethod.RootScope }
+-
+ let pdbMethodGetSequencePoints (meth:PdbMethod) : PdbSequencePoint array =
+     let  pSize = meth.symMethod.SequencePointCount
+     let offsets = Array.zeroCreate pSize
+diff --git a/src/absil/ilsupp.fsi b/src/absil/ilsupp.fsi
+index 15da0aa215..3a3748c6d2 100644
+--- a/src/absil/ilsupp.fsi
++++ b/src/absil/ilsupp.fsi
+@@ -73,7 +73,6 @@ val pdbDocumentGetLanguageVendor: PdbDocument -> byte[] (* guid *)
+ val pdbDocumentFindClosestLine: PdbDocument -> int -> int
+ val pdbMethodGetToken: PdbMethod -> int32
+-val pdbMethodGetRootScope: PdbMethod ->  PdbMethodScope
+ val pdbMethodGetSequencePoints: PdbMethod -> PdbSequencePoint array
+ val pdbScopeGetChildren: PdbMethodScope -> PdbMethodScope array
+diff --git a/src/absil/ilwrite.fs b/src/absil/ilwrite.fs
+index 838b78783b..3b10ff4340 100644
+--- a/src/absil/ilwrite.fs
++++ b/src/absil/ilwrite.fs
+@@ -2577,7 +2577,7 @@ let GenMethodDefAsRow cenv env midx (md: ILMethodDef) =
+                 MethName=md.Name
+                 LocalSignatureToken=localToken
+                 Params= [| |] (* REVIEW *)
+-                RootScope = rootScope
++                RootScope = Some rootScope
+                 Range=  
+                   match ilmbody.SourceMarker with 
+                   | Some m  when cenv.generatePdb -> 
+@@ -2592,9 +2592,20 @@ let GenMethodDefAsRow cenv env midx (md: ILMethodDef) =
+                               Column=m.EndColumn })
+                   | _ -> None
+                 SequencePoints=seqpoints }
+-         
+           cenv.AddCode code
+-          addr 
++          addr
++      | MethodBody.Abstract ->
++          // Now record the PDB record for this method - we write this out later. 
++          if cenv.generatePdb then 
++            cenv.pdbinfo.Add  
++              { MethToken = getUncodedToken TableNames.Method midx
++                MethName = md.Name
++                LocalSignatureToken = 0x0                   // No locals it's abstract
++                Params = [| |]
++                RootScope = None
++                Range = None
++                SequencePoints = [| |] }
++          0x0000
+       | MethodBody.Native -> 
+           failwith "cannot write body of native method - Abstract IL cannot roundtrip mixed native/managed binaries"
+       | _  -> 0x0000)
+diff --git a/src/absil/ilwritepdb.fs b/src/absil/ilwritepdb.fs
+index 3d68edee38..996110e9b7 100644
+--- a/src/absil/ilwritepdb.fs
++++ b/src/absil/ilwritepdb.fs
+@@ -81,7 +81,7 @@ type PdbMethodData =
+       MethName:string
+       LocalSignatureToken: int32
+       Params: PdbLocalVar array
+-      RootScope: PdbMethodScope
++      RootScope: PdbMethodScope option
+       Range: (PdbSourceLoc * PdbSourceLoc) option
+       SequencePoints: PdbSequencePoint array }
+@@ -224,7 +224,7 @@ let generatePortablePdb (embedAllSource:bool) (embedSourceList:string list) (sou
+     let externalRowCounts = getRowCounts info.TableRowCounts
+     let docs = 
+         match info.Documents with
+-        | null -> Array.empty<PdbDocumentData>
++        | null -> Array.empty
+         | _ -> info.Documents
+     let metadata = MetadataBuilder()
+@@ -324,16 +324,16 @@ let generatePortablePdb (embedAllSource:bool) (embedSourceList:string list) (sou
+         let docHandle, sequencePointBlob =
+             let sps =
+                 match minfo.SequencePoints with
+-                | null -> Array.empty<PdbSequencePoint>
++                | null -> Array.empty
+                 | _ ->
+                     match minfo.Range with
+-                    | None -> Array.empty<PdbSequencePoint>
++                    | None -> Array.empty
+                     | Some (_,_) -> minfo.SequencePoints
+             let builder = new BlobBuilder()
+             builder.WriteCompressedInteger(minfo.LocalSignatureToken)
+-            if sps = Array.empty then
++            if sps.Length = 0 then
+                 builder.WriteCompressedInteger( 0 )
+                 builder.WriteCompressedInteger( 0 )
+                 Unchecked.defaultof<DocumentHandle>, Unchecked.defaultof<BlobHandle>
+@@ -407,38 +407,41 @@ let generatePortablePdb (embedAllSource:bool) (embedSourceList:string list) (sou
+         // Write the scopes
+         let nextHandle handle = MetadataTokens.LocalVariableHandle(MetadataTokens.GetRowNumber(LocalVariableHandle.op_Implicit(handle)) + 1)
+         let writeMethodScope scope =
+-            let scopeSorter (scope1:PdbMethodScope) (scope2:PdbMethodScope) =
+-                if scope1.StartOffset > scope2.StartOffset then 1
+-                elif scope1.StartOffset < scope2.StartOffset then -1
+-                elif (scope1.EndOffset - scope1.StartOffset) > (scope2.EndOffset - scope2.StartOffset) then -1
+-                elif (scope1.EndOffset - scope1.StartOffset) < (scope2.EndOffset - scope2.StartOffset) then 1
+-                else 0
+-
+-            let collectScopes scope =
+-                let list = new List<PdbMethodScope>()
+-                let rec toList scope =
+-                    list.Add scope
+-                    scope.Children |> Seq.iter(fun s -> toList s)
+-                toList scope
+-                list.ToArray() |> Array.sortWith<PdbMethodScope> scopeSorter
+-
+-            collectScopes scope |> Seq.iter(fun s ->
+-                                    if s.Children.Length = 0 then
+-                                        metadata.AddLocalScope(MetadataTokens.MethodDefinitionHandle(minfo.MethToken),
+-                                                               Unchecked.defaultof<ImportScopeHandle>,
+-                                                               nextHandle lastLocalVariableHandle,
+-                                                               Unchecked.defaultof<LocalConstantHandle>,
+-                                                               0, s.EndOffset - s.StartOffset ) |>ignore
+-                                    else
+-                                        metadata.AddLocalScope(MetadataTokens.MethodDefinitionHandle(minfo.MethToken),
+-                                                               Unchecked.defaultof<ImportScopeHandle>,
+-                                                               nextHandle lastLocalVariableHandle,
+-                                                               Unchecked.defaultof<LocalConstantHandle>,
+-                                                               s.StartOffset, s.EndOffset - s.StartOffset) |>ignore
+-
+-                                    for localVariable in s.Locals do
+-                                        lastLocalVariableHandle <- metadata.AddLocalVariable(LocalVariableAttributes.None, localVariable.Index, metadata.GetOrAddString(localVariable.Name))
+-                                    )
++            match scope with
++            | Some scope ->
++                let scopeSorter (scope1:PdbMethodScope) (scope2:PdbMethodScope) =
++                    if scope1.StartOffset > scope2.StartOffset then 1
++                    elif scope1.StartOffset < scope2.StartOffset then -1
++                    elif (scope1.EndOffset - scope1.StartOffset) > (scope2.EndOffset - scope2.StartOffset) then -1
++                    elif (scope1.EndOffset - scope1.StartOffset) < (scope2.EndOffset - scope2.StartOffset) then 1
++                    else 0
++
++                let collectScopes scope =
++                    let list = new List<PdbMethodScope>()
++                    let rec toList scope =
++                        list.Add scope
++                        scope.Children |> Seq.iter(fun s -> toList s)
++                    toList scope
++                    list.ToArray() |> Array.sortWith<PdbMethodScope> scopeSorter
++
++                collectScopes scope |> Seq.iter(fun s ->
++                                        if s.Children.Length = 0 then
++                                            metadata.AddLocalScope(MetadataTokens.MethodDefinitionHandle(minfo.MethToken),
++                                                                   Unchecked.defaultof<ImportScopeHandle>,
++                                                                   nextHandle lastLocalVariableHandle,
++                                                                   Unchecked.defaultof<LocalConstantHandle>,
++                                                                   0, s.EndOffset - s.StartOffset ) |>ignore
++                                        else
++                                            metadata.AddLocalScope(MetadataTokens.MethodDefinitionHandle(minfo.MethToken),
++                                                                   Unchecked.defaultof<ImportScopeHandle>,
++                                                                   nextHandle lastLocalVariableHandle,
++                                                                   Unchecked.defaultof<LocalConstantHandle>,
++                                                                   s.StartOffset, s.EndOffset - s.StartOffset) |>ignore
++
++                                        for localVariable in s.Locals do
++                                            lastLocalVariableHandle <- metadata.AddLocalVariable(LocalVariableAttributes.None, localVariable.Index, metadata.GetOrAddString(localVariable.Name))
++                                        )
++            | None -> ()
+         writeMethodScope minfo.RootScope )
+     let entryPoint =
+@@ -554,18 +557,20 @@ let writePdbInfo showTimes f fpdb info cvChunk =
+               // Write the scopes 
+               let rec writePdbScope parent sco = 
+-                  if parent = None || sco.Locals.Length <> 0 || sco.Children.Length <> 0 then
+-                      // Only nest scopes if the child scope is a different size from 
+-                      let nested =
+-                          match parent with
+-                          | Some p -> sco.StartOffset <> p.StartOffset || sco.EndOffset <> p.EndOffset
+-                          | None -> true
+-                      if nested then pdbOpenScope !pdbw sco.StartOffset
+-                      sco.Locals |> Array.iter (fun v -> pdbDefineLocalVariable !pdbw v.Name v.Signature v.Index)
+-                      sco.Children |> Array.iter (writePdbScope (if nested then Some sco else parent))
+-                      if nested then pdbCloseScope !pdbw sco.EndOffset
+-
+-              writePdbScope None minfo.RootScope 
++                    if parent = None || sco.Locals.Length <> 0 || sco.Children.Length <> 0 then
++                        // Only nest scopes if the child scope is a different size from 
++                        let nested =
++                            match parent with
++                            | Some p -> sco.StartOffset <> p.StartOffset || sco.EndOffset <> p.EndOffset
++                            | None -> true
++                        if nested then pdbOpenScope !pdbw sco.StartOffset
++                        sco.Locals |> Array.iter (fun v -> pdbDefineLocalVariable !pdbw v.Name v.Signature v.Index)
++                        sco.Children |> Array.iter (writePdbScope (if nested then Some sco else parent))
++                        if nested then pdbCloseScope !pdbw sco.EndOffset
++
++              match minfo.RootScope with
++              | None -> ()
++              | Some rootscope -> writePdbScope None rootscope 
+               pdbCloseMethod !pdbw
+           end)
+     reportTime showTimes "PDB: Wrote methods"
+@@ -675,7 +680,10 @@ let writeMdbInfo fmdb f info =
+                 for child in scope.Children do 
+                     writeScope(child)
+                 wr?CloseScope(scope.EndOffset)          
+-            writeScope(meth.RootScope)
++            match meth.RootScope with
++            | None -> ()
++            | Some rootscope -> writeScope(rootscope)
++
+             // Finished generating debug information for the curretn method
+             wr?CloseMethod()
+@@ -722,5 +730,8 @@ let logDebugInfo (outfile:string) (info:PdbData) =
+         if scope.Locals.Length > 0 then
+           fprintfn sw "      %s  Locals: %A" offs [ for p in scope.Locals -> sprintf "%d: %s" p.Index p.Name ]
+         for child in scope.Children do writeScope (offs + "  ") child
+-      writeScope "" meth.RootScope
++
++      match meth.RootScope with
++      | None -> ()
++      | Some rootscope -> writeScope "" rootscope
+       fprintfn sw ""
+diff --git a/src/absil/ilwritepdb.fsi b/src/absil/ilwritepdb.fsi
+index e5d1c8d03a..af9f16be9e 100644
+--- a/src/absil/ilwritepdb.fsi
++++ b/src/absil/ilwritepdb.fsi
+@@ -44,7 +44,7 @@ type PdbMethodData =
+       MethName:string
+       LocalSignatureToken: int32
+       Params: PdbLocalVar array
+-      RootScope: PdbMethodScope
++      RootScope: PdbMethodScope option
+       Range: (PdbSourceLoc * PdbSourceLoc) option
+       SequencePoints: PdbSequencePoint array }
+
+From 64ecadb27b24c1486610deb32c3044ad0b3449ae Mon Sep 17 00:00:00 2001
+From: Kevin Ransom <kevinr@microsoft.com>
+Date: Tue, 5 Sep 2017 03:13:04 -0700
+Subject: [PATCH 3/3] minimise diff
+
+---
+ src/absil/ilwritepdb.fs | 92 ++++++++++++++++++++++++-------------------------
+ 1 file changed, 46 insertions(+), 46 deletions(-)
+
+diff --git a/src/absil/ilwritepdb.fs b/src/absil/ilwritepdb.fs
+index 996110e9b7..f8baa3aea4 100644
+--- a/src/absil/ilwritepdb.fs
++++ b/src/absil/ilwritepdb.fs
+@@ -407,42 +407,42 @@ let generatePortablePdb (embedAllSource:bool) (embedSourceList:string list) (sou
+         // Write the scopes
+         let nextHandle handle = MetadataTokens.LocalVariableHandle(MetadataTokens.GetRowNumber(LocalVariableHandle.op_Implicit(handle)) + 1)
+         let writeMethodScope scope =
+-            match scope with
+-            | Some scope ->
+-                let scopeSorter (scope1:PdbMethodScope) (scope2:PdbMethodScope) =
+-                    if scope1.StartOffset > scope2.StartOffset then 1
+-                    elif scope1.StartOffset < scope2.StartOffset then -1
+-                    elif (scope1.EndOffset - scope1.StartOffset) > (scope2.EndOffset - scope2.StartOffset) then -1
+-                    elif (scope1.EndOffset - scope1.StartOffset) < (scope2.EndOffset - scope2.StartOffset) then 1
+-                    else 0
+-
+-                let collectScopes scope =
+-                    let list = new List<PdbMethodScope>()
+-                    let rec toList scope =
+-                        list.Add scope
+-                        scope.Children |> Seq.iter(fun s -> toList s)
+-                    toList scope
+-                    list.ToArray() |> Array.sortWith<PdbMethodScope> scopeSorter
+-
+-                collectScopes scope |> Seq.iter(fun s ->
+-                                        if s.Children.Length = 0 then
+-                                            metadata.AddLocalScope(MetadataTokens.MethodDefinitionHandle(minfo.MethToken),
+-                                                                   Unchecked.defaultof<ImportScopeHandle>,
+-                                                                   nextHandle lastLocalVariableHandle,
+-                                                                   Unchecked.defaultof<LocalConstantHandle>,
+-                                                                   0, s.EndOffset - s.StartOffset ) |>ignore
+-                                        else
+-                                            metadata.AddLocalScope(MetadataTokens.MethodDefinitionHandle(minfo.MethToken),
+-                                                                   Unchecked.defaultof<ImportScopeHandle>,
+-                                                                   nextHandle lastLocalVariableHandle,
+-                                                                   Unchecked.defaultof<LocalConstantHandle>,
+-                                                                   s.StartOffset, s.EndOffset - s.StartOffset) |>ignore
+-
+-                                        for localVariable in s.Locals do
+-                                            lastLocalVariableHandle <- metadata.AddLocalVariable(LocalVariableAttributes.None, localVariable.Index, metadata.GetOrAddString(localVariable.Name))
+-                                        )
+-            | None -> ()
+-        writeMethodScope minfo.RootScope )
++            let scopeSorter (scope1:PdbMethodScope) (scope2:PdbMethodScope) =
++                if scope1.StartOffset > scope2.StartOffset then 1
++                elif scope1.StartOffset < scope2.StartOffset then -1
++                elif (scope1.EndOffset - scope1.StartOffset) > (scope2.EndOffset - scope2.StartOffset) then -1
++                elif (scope1.EndOffset - scope1.StartOffset) < (scope2.EndOffset - scope2.StartOffset) then 1
++                else 0
++
++            let collectScopes scope =
++                let list = new List<PdbMethodScope>()
++                let rec toList scope =
++                    list.Add scope
++                    scope.Children |> Seq.iter(fun s -> toList s)
++                toList scope
++                list.ToArray() |> Array.sortWith<PdbMethodScope> scopeSorter
++
++            collectScopes scope |> Seq.iter(fun s ->
++                                    if s.Children.Length = 0 then
++                                        metadata.AddLocalScope(MetadataTokens.MethodDefinitionHandle(minfo.MethToken),
++                                                               Unchecked.defaultof<ImportScopeHandle>,
++                                                               nextHandle lastLocalVariableHandle,
++                                                               Unchecked.defaultof<LocalConstantHandle>,
++                                                               0, s.EndOffset - s.StartOffset ) |>ignore
++                                    else
++                                        metadata.AddLocalScope(MetadataTokens.MethodDefinitionHandle(minfo.MethToken),
++                                                               Unchecked.defaultof<ImportScopeHandle>,
++                                                               nextHandle lastLocalVariableHandle,
++                                                               Unchecked.defaultof<LocalConstantHandle>,
++                                                               s.StartOffset, s.EndOffset - s.StartOffset) |>ignore
++
++                                    for localVariable in s.Locals do
++                                        lastLocalVariableHandle <- metadata.AddLocalVariable(LocalVariableAttributes.None, localVariable.Index, metadata.GetOrAddString(localVariable.Name))
++                                    )
++
++        match minfo.RootScope with
++        | None -> ()
++        | Some scope -> writeMethodScope scope )
+     let entryPoint =
+         match info.EntryPoint with
+@@ -557,16 +557,16 @@ let writePdbInfo showTimes f fpdb info cvChunk =
+               // Write the scopes 
+               let rec writePdbScope parent sco = 
+-                    if parent = None || sco.Locals.Length <> 0 || sco.Children.Length <> 0 then
+-                        // Only nest scopes if the child scope is a different size from 
+-                        let nested =
+-                            match parent with
+-                            | Some p -> sco.StartOffset <> p.StartOffset || sco.EndOffset <> p.EndOffset
+-                            | None -> true
+-                        if nested then pdbOpenScope !pdbw sco.StartOffset
+-                        sco.Locals |> Array.iter (fun v -> pdbDefineLocalVariable !pdbw v.Name v.Signature v.Index)
+-                        sco.Children |> Array.iter (writePdbScope (if nested then Some sco else parent))
+-                        if nested then pdbCloseScope !pdbw sco.EndOffset
++                  if parent = None || sco.Locals.Length <> 0 || sco.Children.Length <> 0 then
++                      // Only nest scopes if the child scope is a different size from 
++                      let nested =
++                          match parent with
++                          | Some p -> sco.StartOffset <> p.StartOffset || sco.EndOffset <> p.EndOffset
++                          | None -> true
++                      if nested then pdbOpenScope !pdbw sco.StartOffset
++                      sco.Locals |> Array.iter (fun v -> pdbDefineLocalVariable !pdbw v.Name v.Signature v.Index)
++                      sco.Children |> Array.iter (writePdbScope (if nested then Some sco else parent))
++                      if nested then pdbCloseScope !pdbw sco.EndOffset
+               match minfo.RootScope with
+               | None -> ()
diff --git a/packaging/MacSDK/patches/fsharp-portable-pdb.patch b/packaging/MacSDK/patches/fsharp-portable-pdb.patch
new file mode 100644 (file)
index 0000000..3ced495
--- /dev/null
@@ -0,0 +1,21 @@
+diff --git a/src/fsharp/FSharp.Build/Microsoft.FSharp.Targets b/src/fsharp/FSharp.Build/Microsoft.FSharp.Targets
+index 34d716485..ec99e87ed 100644
+--- a/src/fsharp/FSharp.Build/Microsoft.FSharp.Targets
++++ b/src/fsharp/FSharp.Build/Microsoft.FSharp.Targets
+@@ -41,6 +41,16 @@ this file.
+         <RootNamespace Condition="'$(RootNamespace)'==''">RootNamespace</RootNamespace>
+         <Actual32Bit Condition="'$(TargetFrameworkVersion)'=='v2.0' or '$(TargetFrameworkVersion)'=='v3.0' or '$(TargetFrameworkVersion)'=='v3.5' or '$(TargetFrameworkVersion)'=='v4.0'">false</Actual32Bit>
+         <Actual32Bit Condition="!('$(TargetFrameworkVersion)'=='v2.0' or '$(TargetFrameworkVersion)'=='v3.0' or '$(TargetFrameworkVersion)'=='v3.5' or '$(TargetFrameworkVersion)'=='v4.0')">$(Prefer32Bit)</Actual32Bit>
++        <!--
++             `/debug+` is produced based on `$(DebugSymols)`, which gets a default value of 'true' in
++             Microsoft.Common.CurrentVersion.targets, with a condition:
++               Condition=" '$(ConfigurationName)' == 'Debug' and '$(DebugSymbols)' == '' and '$(DebugType)'=='' "
++             But that file is imported later, so we cannot depend on the default value of `$(DebugSymbols)` or `$(ConfigurationName)`.
++        -->
++        <_ConfigurationNameTmp>$(ConfigurationName)</_ConfigurationNameTmp>
++        <_ConfigurationNameTmp Condition="'$(ConfigurationName)' == ''">$(Configuration)</_ConfigurationNameTmp>
++
++        <DebugType Condition="'$(OS)' != 'Windows_NT' And ('$(DebugSymbols)'=='True' or ('$(DebugSymbols)'=='' And '$(_ConfigurationNameTmp)'=='Debug'))">portable</DebugType>
+     </PropertyGroup>
+     <!--
index ef12456508a57232cf204090d76755ad5e88dfc6..5188f37291151780129e4e1fb41e9f4d9393f9ad 100644 (file)
@@ -1,50 +1,80 @@
-# ------------------------------------------------------------ #
-#   mono/eglib
-# ------------------------------------------------------------ #
+# --------------------------------------------------------------------------- #
+#   mono/eglib                                                                #
+# --------------------------------------------------------------------------- #
+
+# ghashtable.c #
 
 fun:monoeg_g_hash_table_iter_next
+fun:monoeg_g_hash_table_lookup_extended
+
+# sort.frag.h #
+
+fun:init_sort_info
+fun:insert_list
+fun:merge_lists
+
+# --------------------------------------------------------------------------- #
+#   mono/metadata                                                             #
+# --------------------------------------------------------------------------- #
+
+# class-accessors.c #
+
+fun:mono_class_get_first_method_idx
+fun:mono_class_get_flags
+fun:mono_class_get_generic_class
+fun:mono_class_get_method_count
+fun:mono_class_get_field_count
+fun:mono_class_set_first_method_idx
+fun:mono_class_set_method_count
+
+# class-inlines.h #
+
+fun:mono_class_is_ginst
+fun:mono_class_is_gtd
 
-# ------------------------------------------------------------ #
-#   mono/metadata
-# ------------------------------------------------------------ #
+# class-internals.h #
+
+fun:mono_class_has_parent
+fun:mono_class_has_parent_fast
 
 # class.c #
 
+fun:can_access_type
+fun:inflate_generic_context
 fun:inflate_generic_type
 fun:init_sizes_with_info
 fun:make_generic_param_class
+fun:mono_bounded_array_class_get
 fun:mono_class_create_from_typedef
 fun:mono_class_from_generic_parameter_internal
-fun:mono_class_get_field_count
+fun:mono_class_from_mono_type
+fun:mono_class_get_cctor
+fun:mono_class_get_inflated_method
 fun:mono_class_get_method_from_name_flags
 fun:mono_class_get_methods
+fun:mono_class_get_vtable_entry
 fun:mono_class_has_failure
 fun:mono_class_has_finalizer
 fun:mono_class_inflate_generic_method_full_checked
-fun:mono_class_inflate_generic_type_no_copy
-fun:mono_class_inflate_generic_type_with_mempool
 fun:mono_class_init
+fun:mono_class_instance_size
+fun:mono_class_is_assignable_from
 fun:mono_class_layout_fields
 fun:mono_class_setup_basic_field_info
 fun:mono_class_setup_fields
+fun:mono_class_setup_interfaces
 fun:mono_class_setup_methods
+fun:mono_class_setup_supertypes
 fun:mono_class_setup_vtable_full
 fun:mono_class_setup_vtable_general
+fun:mono_field_resolve_type
 fun:mono_generic_class_get_class
 fun:mono_method_get_context_general
+fun:mono_method_get_method_definition
+fun:mono_ptr_class_get
 fun:mono_type_get_basic_type_from_generic
 fun:mono_type_get_underlying_type
-
-# class-accessors.c #
-
-fun:mono_class_get_flags
-fun:mono_class_get_method_count
-fun:mono_class_set_method_count
-
-# class-inlines.h #
-
-fun:mono_class_is_ginst
-fun:mono_class_is_gtd
+fun:mono_type_has_exceptions
 
 # domain.c #
 
@@ -56,21 +86,26 @@ fun:finalize_domain_objects
 fun:finalizer_thread
 fun:mono_domain_finalize
 fun:mono_gc_cleanup
-
-# handle.h #
-
-fun:mono_stack_mark_pop
+fun:object_register_finalizer
 
 # handle.c #
 
 fun:mono_handle_new
 fun:mono_handle_stack_scan
 
+# handle.h #
+
+fun:mono_stack_mark_init
+fun:mono_stack_mark_pop
+
 # icall.c #
 
+fun:vell_icall_get_method_attributes
+fun:ves_icall_InternalInvoke
+fun:ves_icall_RuntimeTypeHandle_IsArray
+fun:ves_icall_RuntimeType_GetConstructors_native
 fun:ves_icall_System_Array_FastCopy
 fun:ves_icall_System_Reflection_MonoMethodInfo_get_parameter_info
-fun:ves_icall_RuntimeType_GetConstructors_native
 
 # image.c #
 
@@ -82,79 +117,101 @@ fun:mono_image_strdup
 
 fun:jit_info_table_add
 fun:jit_info_table_chunk_index
+fun:jit_info_table_copy_and_split_chunk
 fun:jit_info_table_find
 fun:jit_info_table_index
-fun:mono_jit_compile_method_with_opt
+fun:jit_info_table_split_chunk
 fun:mono_jit_info_init
-fun:mono_jit_info_table_find_internal
 
 # loader.c #
 
 fun:cache_memberref_sig
-fun:mon_new
+fun:inflate_generic_signature_checked
 fun:mono_get_method_from_token
 fun:mono_method_get_signature_checked
 fun:mono_method_signature_checked
 
 # marshal.c #
 
+fun:mono_icall_start
 fun:mono_marshal_get_native_wrapper
 fun:mono_marshal_isinst_with_cache
 
 # metadata.c #
 
-fun:img_set_cache_get
 fun:_mono_metadata_generic_class_equal
+fun:collect_method_images
+fun:do_mono_metadata_parse_type
+fun:img_set_cache_get
+fun:mono_metadata_decode_row
+fun:mono_metadata_get_canonical_generic_inst
 fun:mono_metadata_lookup_generic_class
+fun:mono_metadata_parse_type_internal
+fun:mono_type_get_class
 fun:mono_type_get_type
 fun:mono_type_is_struct
 
 # monitor.c #
 
+fun:mon_new
 fun:mono_monitor_ensure_owned
+fun:mono_monitor_enter_v4_fast
 fun:mono_monitor_exit_inflated
+fun:mono_monitor_inflate
 fun:mono_monitor_try_enter_inflated
 fun:mono_monitor_try_enter_internal
 fun:mono_object_hash
 fun:ves_icall_System_Threading_Monitor_Monitor_pulse_all
 fun:ves_icall_System_Threading_Monitor_Monitor_test_synchronised
+fun:ves_icall_System_Threading_Monitor_Monitor_try_enter_with_atomic_var
 fun:ves_icall_System_Threading_Monitor_Monitor_wait
 
 # mono-conc-hash.c #
 
+fun:expand_table
 fun:mono_conc_g_hash_table_lookup_extended
 fun:set_key
 
 # mono-hash.c #
 
 fun:mono_g_hash_table_find_slot
-fun:mono_g_hash_table_max_chain_length
 
 # object.c #
 
 fun:mono_class_compute_gc_descriptor
 fun:mono_class_create_runtime_vtable
 fun:mono_class_vtable_full
-fun:mono_delegate_ctor_with_method
+fun:mono_object_handle_get_virtual_method
 fun:mono_object_handle_isinst
+fun:mono_object_isinst_checked
+fun:mono_object_new_alloc_specific_checked
+fun:mono_object_new_specific_checked
 fun:mono_runtime_class_init_full
+fun:mono_runtime_invoke_array_checked
+fun:mono_runtime_try_invoke_array
+fun:mono_string_new_size_checked
+
+# reflection-cache.h #
+
+fun:cache_object_handle
 
 # reflection.c #
 
 fun:method_object_construct
 fun:reflected_equal
 
-# reflection-cache.h #
-
-fun:cache_object_handle
-
 # runtime.c #
 
 fun:mono_runtime_is_shutting_down
 fun:mono_runtime_try_shutdown
 
+# sgen-client-mono.h #
+
+fun:SGEN_LOAD_VTABLE_UNCHECKED
+
 # sgen-mono.c #
 
+fun:mono_gchandle_free
 fun:mono_gc_alloc_string
 fun:mono_gc_alloc_vector
 fun:mono_gc_thread_in_critical_region
@@ -162,18 +219,22 @@ fun:mono_gc_wbarrier_set_arrayref
 fun:sgen_client_gchandle_created
 fun:sgen_client_gchandle_destroyed
 
-# threadpool.c #
-
-fun:worker_callback
-
 # threadpool-worker-default.c #
 
 fun:heuristic_adjust
 fun:heuristic_notify_work_completed
 fun:heuristic_should_adjust
+fun:hill_climbing_change_thread_count
+fun:hill_climbing_force_change
 fun:hill_climbing_update
 fun:monitor_should_keep_running
 fun:monitor_thread
+fun:monitor_sufficient_delay_since_last_dequeue
+
+# threadpool.c #
+
+fun:try_invoke_perform_wait_callback
+fun:worker_callback
 
 # threads.c #
 
@@ -181,40 +242,69 @@ fun:build_wait_tids
 fun:create_thread
 fun:mono_thread_clr_state
 fun:mono_thread_detach_internal
+fun:mono_thread_set_name_internal
 fun:mono_threads_add_joinable_thread
 fun:mono_threads_join_threads
 fun:remove_and_abort_threads
+fun:request_thread_abort
 
 # w32handle.c #
 
-fun:mono_w32handle_init_handle
+fun:mono_w32handle_lookup
 fun:mono_w32handle_lookup_data
+fun:mono_w32handle_new_internal
+fun:mono_w32handle_ref_core
 fun:mono_w32handle_unref_core
 
-# ------------------------------------------------------------ #
-#   mono/mini
-# ------------------------------------------------------------ #
+# --------------------------------------------------------------------------- #
+#   mono/mini                                                                 #
+# --------------------------------------------------------------------------- #
 
 # alias-analysis.c #
 
 fun:recompute_aliased_variables
 
-# method-to-ir.c #
+# aot-runtime.c #
 
-fun:mono_method_to_ir
+fun:mono_aot_get_cached_class_info
+fun:mono_aot_get_method_from_vt_slot
 
-# mini.c #
+# decompose.c #
 
-fun:mini_method_compile
-fun:mono_allocate_stack_slots
-fun:mono_jit_compile_method_inner
-fun:mono_save_seq_point_info
-fun:mono_time_track_end
-fun:mono_type_to_load_membase
+fun:mono_decompose_vtype_opts
+
+# linear-scan.c #
+
+fun:mono_linear_scan
+
+# liveness.c #
+
+fun:mono_analyze_liveness
+fun:mono_liveness_handle_exception_clauses
+
+# method-to-ir.c #
+
+fun:check_call_signature
+fun:emit_init_rvar
+fun:inline_method
+fun:mono_method_check_inlining
+fun:mono_method_to_ir
+fun:mono_spill_global_vars
 
 # mini-amd64.c #
 
+fun:get_call_info
+fun:mono_arch_allocate_vars
+fun:mono_arch_emit_epilog
+fun:mono_arch_emit_prolog
 fun:mono_arch_get_delegate_invoke_impl
+fun:mono_arch_lowering_pass
+fun:mono_arch_peephole_pass_2
+
+# mini-codegen.c #
+
+fun:mono_local_regalloc
+fun:mono_peephole_ins
 
 # mini-exceptions.c #
 
@@ -222,12 +312,23 @@ fun:mono_thread_state_init_from_sigctx
 
 # mini-generic-sharing.c #
 
+fun:alloc_template
+fun:class_get_rgctx_template_oti
+fun:get_info_templates
+fun:inflate_info
+fun:inst_check_context_used
 fun:mini_get_basic_type_from_generic
 fun:mini_is_gsharedvt_type
 fun:mini_type_get_underlying_type
 fun:mono_class_fill_runtime_generic_context
 fun:mono_generic_context_check_used
 fun:mono_method_check_context_used
+fun:mono_method_fill_runtime_generic_context
+fun:mono_method_get_declaring_generic_method
+fun:mono_method_is_generic_impl
+fun:mono_method_needs_static_rgctx_invoke
+fun:rgctx_template_set_slot
+fun:set_info_templates
 
 # mini-native-types.c #
 
@@ -235,21 +336,52 @@ fun:mini_native_type_replace_type
 
 # mini-runtime.c #
 
+fun:create_runtime_invoke_info
+fun:mini_imt_entry_inited
+fun:mono_jit_compile_method_with_opt
 fun:mono_jit_find_compiled_method_with_jit_info
+fun:mono_jit_runtime_invoke
 
 # mini-trampolines.c #
 
 fun:common_call_trampoline
+fun:mini_add_method_trampoline
 fun:mini_resolve_imt_method
+fun:mono_create_delegate_trampoline_info
 fun:mono_create_jit_trampoline
+fun:mono_create_jump_trampoline
 fun:mono_delegate_trampoline
 fun:mono_magic_trampoline
 fun:mono_rgctx_lazy_fetch_trampoline
 fun:mono_vcall_trampoline
 
-# ------------------------------------------------------------ #
-#   mono/sgen
-# ------------------------------------------------------------ #
+# mini.c #
+
+fun:mini_method_compile
+fun:mono_allocate_stack_slots
+fun:mono_codegen
+fun:mono_compile_create_vars
+fun:mono_insert_branches_between_bblocks
+fun:mono_jit_compile_method_inner
+fun:mono_time_track_end
+fun:mono_type_to_load_membase
+fun:mono_type_to_store_membase
+
+# seq-points.c #
+
+fun:mono_save_seq_point_info
+
+# tramp-amd64.c #
+
+fun:mono_arch_patch_callsite
+
+# unwind.c #
+
+fun:mono_unwind_ops_encode_full
+
+# --------------------------------------------------------------------------- #
+#   mono/sgen                                                                 #
+# --------------------------------------------------------------------------- #
 
 # sgen-alloc.c #
 
@@ -257,14 +389,18 @@ fun:sgen_alloc_obj
 fun:sgen_clear_tlabs
 fun:sgen_try_alloc_obj_nolock
 
+# sgen-array-list.c #
+
+fun:sgen_array_list_add
+fun:sgen_array_list_find_unset
+
 # sgen-array-list.h #
 
 fun:sgen_array_list_bucketize
 
-# sgen-array-list.c #
+# sgen-cardtable.c #
 
-fun:sgen_array_list_add
-fun:sgen_array_list_find_unset
+fun:sgen_card_table_wbarrier_range_copy
 
 # sgen-cardtable.h #
 
@@ -274,25 +410,24 @@ fun:sgen_card_table_mark_address
 
 fun:add_stage_entry
 
-# sgen-gc.h #
-
-fun:sgen_set_nursery_scan_start
-
 # sgen-gc.c #
 
 fun:mono_gc_wbarrier_generic_store
-fun:sgen_conservatively_pin_objects_from
+
+# sgen-gc.h #
+
+fun:sgen_set_nursery_scan_start
 
 # sgen-gchandles.c #
 
 fun:is_slot_set
 fun:link_get
-fun:mono_gchandle_free
 fun:sgen_gchandle_iterate
 
 # sgen-marksweep.c #
 
 fun:ensure_block_is_checked_for_sweeping
+fun:ensure_can_access_block_free_list
 fun:major_finish_sweep_checking
 fun:set_block_state
 fun:sweep_block
@@ -306,14 +441,20 @@ fun:sgen_fragment_allocator_alloc
 fun:sgen_fragment_allocator_par_range_alloc
 fun:sgen_fragment_allocator_release
 
-# ------------------------------------------------------------ #
-#   mono/utils
-# ------------------------------------------------------------ #
+# --------------------------------------------------------------------------- #
+#   mono/utils                                                                #
+# --------------------------------------------------------------------------- #
 
 # hazard-pointer.c #
 
 fun:is_pointer_hazardous
 fun:mono_get_hazardous_pointer
+fun:mono_thread_small_id_alloc
+
+# lock-free-array-queue.c #
+
+fun:mono_lock_free_array_queue_pop
+fun:mono_lock_free_array_queue_push
 
 # memfuncs.c #
 
@@ -322,16 +463,27 @@ fun:mono_gc_memmove_aligned
 
 # mono-conc-hashtable.c #
 
+fun:expand_table
+fun:mono_conc_hashtable_insert
 fun:mono_conc_hashtable_lookup
 
 # mono-context.c #
 
 fun:mono_sigctx_to_monoctx
 
+# mono-error.c #
+
+fun:mono_error_cleanup
+
 # mono-lazy-init.h #
 
 fun:mono_lazy_initialize
 
+# mono-linked-list-set.c #
+
+fun:mono_lls_find
+fun:mono_lls_get_hazardous_pointer_with_mask
+
 # mono-threads-posix-signals.c #
 
 fun:restart_signal_handler
@@ -342,6 +494,10 @@ fun:suspend_signal_handler
 fun:check_thread_state
 fun:mono_threads_transition_finish_async_suspend
 
+# mono-threads.c #
+
+fun:mono_thread_info_uninstall_interrupt
+
 # os-event-unix.c #
 
 fun:mono_os_event_set
diff --git a/scripts/ci/collect-coverage.sh b/scripts/ci/collect-coverage.sh
new file mode 100755 (executable)
index 0000000..f600c3a
--- /dev/null
@@ -0,0 +1,20 @@
+#!/bin/bash -x
+
+# This script is meant to be executed on all "slave" machines that run coverage collection.
+
+COV_DIR=coverage
+COV_INFO="$COV_DIR/$JOB_NAME.info"
+
+# Build Mono and collect coverage on the test suite.
+CI_TAGS=collect-coverage,monolite scripts/ci/run-jenkins.sh
+
+# Place the coverage info file into the coverage directory.
+# Multiple such files can be assembled to create a unified coverage report that spans multiple architectures and operating systems.
+mkdir "$COV_DIR"
+scripts/ci/run-step.sh --label=coverage-lcov --timeout=20m lcov --no-external -c -d mono -d support -d tools -o "$COV_INFO"
+
+# Generate HTML coverage report in the lcov directory at the root of the project.
+scripts/ci/run-step.sh --label=coverage-genhtml --timeout=20m genhtml "$COV_INFO" -o lcov
+
+# Make the paths relative so that they could be assembled from different Jenkins workspaces.
+sed -Eie "s#^SF:$WORKSPACE/?#SF:#" "$COV_INFO"
index fcc26b7eff6e02dcbe4470a76569be0cae8c8109..bdecfae3efb974b15ed2b08a787f2b04716aa4ab 100755 (executable)
@@ -29,6 +29,10 @@ else
     export CFLAGS="-ggdb3 -O2"
 fi
 
+if [[ $CI_TAGS == *'retry-flaky-tests'* ]]; then
+    export MONO_FLAKY_TEST_RETRIES=5
+fi
+
 if [[ ${label} == 'osx-i386' ]]; then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --with-libgdiplus=/Library/Frameworks/Mono.framework/Versions/Current/lib/libgdiplus.dylib --build=i386-apple-darwin11.2.0"; fi
 if [[ ${label} == 'osx-amd64' ]]; then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --with-libgdiplus=/Library/Frameworks/Mono.framework/Versions/Current/lib/libgdiplus.dylib "; fi
 if [[ ${label} == 'w32' ]]; then PLATFORM=Win32; EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --host=i686-w64-mingw32"; export MONO_EXECUTABLE="${MONO_REPO_ROOT}/msvc/build/sgen/Win32/bin/Release/mono-sgen.exe"; fi
index daad48d3cc538f196077065665e323834e0c5d65..3511574fb97a9aac6408d9e37b8ef860ffff9ff4 100755 (executable)
@@ -10,7 +10,7 @@ ${TESTCMD} --label=compile-runtime-tests --timeout=40m make -w -C mono/tests -j4
 ${TESTCMD} --label=runtime --timeout=160m make -w -C mono/tests -k test-wrench V=1 CI=1 CI_PR=${ghprbPullId}
 ${TESTCMD} --label=runtime-unit-tests --timeout=5m make -w -C mono/unit-tests -k check
 ${TESTCMD} --label=corlib --timeout=30m make -w -C mcs/class/corlib run-test
-if [[ ${label} == w* ]]; then ${TESTCMD} --label=corlib-xunit --skip; else ${TESTCMD} --label=corlib-xunit --timeout=5m make -w -C mcs/class/corlib run-xunit-test; fi
+${TESTCMD} --label=corlib-xunit --timeout=5m make -w -C mcs/class/corlib run-xunit-test
 ${TESTCMD} --label=verify --timeout=15m make -w -C runtime mcs-compileall
 ${TESTCMD} --label=profiler --timeout=30m make -w -C mono/profiler -k check
 ${TESTCMD} --label=compiler --timeout=30m make -w -C mcs/tests run-test
@@ -75,7 +75,7 @@ ${TESTCMD} --label=System.Web.DynamicData --timeout=5m make -w -C mcs/class/Syst
 ${TESTCMD} --label=Mono.CSharp --timeout=5m make -w -C mcs/class/Mono.CSharp run-test
 ${TESTCMD} --label=WindowsBase --timeout=5m make -w -C mcs/class/WindowsBase run-test
 ${TESTCMD} --label=System.Numerics --timeout=5m make -w -C mcs/class/System.Numerics run-test
-if [[ ${label} == w* ]]; then ${TESTCMD} --label=System.Numerics-xunit --skip; else ${TESTCMD} --label=System.Numerics-xunit --timeout=5m make -w -C mcs/class/System.Numerics run-xunit-test; fi
+${TESTCMD} --label=System.Numerics-xunit --timeout=5m make -w -C mcs/class/System.Numerics run-xunit-test
 ${TESTCMD} --label=System.Runtime.DurableInstancing --timeout=5m make -w -C mcs/class/System.Runtime.DurableInstancing run-test
 ${TESTCMD} --label=System.ServiceModel.Discovery --timeout=5m make -w -C mcs/class/System.ServiceModel.Discovery run-test
 ${TESTCMD} --label=System.Xaml --timeout=5m make -w -C mcs/class/System.Xaml run-test
index 247f310c23b95a26c7fd1ae7460fe672766ab1a6..b5fdae354c22ba3e820da8c13b5b2ae9e7db394d 100644 (file)
@@ -52,7 +52,7 @@ get_function (const char *name)
                        compare_names);
 
        if (ptr == NULL) {
-               g_warning ("Function '%s' not not found.", name);
+               g_warning ("Function '%s' not found.", name);
                return NULL;
        }