Merge pull request #5504 from ntherning/wait-for-native-thread-to-die-in-Thread-Join
authorNiklas Therning <niklas@therning.org>
Mon, 11 Sep 2017 09:07:53 +0000 (11:07 +0200)
committerGitHub <noreply@github.com>
Mon, 11 Sep 2017 09:07:53 +0000 (11:07 +0200)
Wait for the native thread to die in Thread.Join() on Windows

88 files changed:
CODEOWNERS
CONTRIBUTING.md
configure.ac
external/api-snapshot
external/binary-reference-assemblies
external/roslyn-binaries
man/mcs.1
mcs/class/Mono.Data.Tds/Test/bug-4786.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/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/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.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/corlib/System/Delegate.cs
mcs/class/reference-assemblies/Makefile
mcs/mcs/settings.cs
mono/arch/s390x/s390x-codegen.h
mono/eglib/eglib-config.h.in
mono/eglib/gpath.c
mono/metadata/boehm-gc.c
mono/metadata/class-internals.h
mono/metadata/domain.c
mono/metadata/gc.c
mono/metadata/image.c
mono/metadata/loader.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/mini/Makefile.am.in
mono/mini/aot-runtime-wasm.c [new file with mode: 0644]
mono/mini/aot-runtime.c
mono/mini/cpu-wasm.md [new file with mode: 0644]
mono/mini/debugger-agent.c
mono/mini/driver.c
mono/mini/exceptions-wasm.c [new file with mode: 0644]
mono/mini/genmdesc.pl [changed mode: 0644->0755]
mono/mini/interp/interp.c
mono/mini/interp/interp.h
mono/mini/jit.h
mono/mini/mini-amd64.c
mono/mini/mini-arch.h
mono/mini/mini-exceptions.c
mono/mini/mini-generic-sharing.c
mono/mini/mini-s390x.c
mono/mini/mini-wasm.c [new file with mode: 0644]
mono/mini/mini-wasm.h [new file with mode: 0644]
mono/mini/mini.c
mono/mini/mini.h
mono/mini/trace.c
mono/mini/tramp-wasm.c [new file with mode: 0644]
mono/sgen/sgen-conf.h
mono/sgen/sgen-gc.c
mono/sgen/sgen-marksweep.c
mono/sgen/sgen-thread-pool.c
mono/tests/Makefile.am
mono/tests/delegate-disposed-hashcode.cs [new file with mode: 0644]
mono/utils/mono-counters.c
mono/utils/mono-dl-posix.c
mono/utils/mono-hwcap-s390x.c
mono/utils/mono-hwcap-vars.h
mono/utils/mono-threads-coop.c
mono/utils/mono-threads-wasm.c
mono/utils/networking-missing.c
mono/utils/unlocked.h
packaging/MacSDK/fsharp.py
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]

index 8c203a4b093b3bd515e4d3ece603e9e003741072..d72a176cb795514a1423bb2f986c4757abccc6f1 100644 (file)
@@ -1,22 +1,18 @@
 # 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
 
-/ @luhenry @marek-safar
+
+# 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
index b767c969fb6c0c6bee4a89a3c422073624a62095..96ba2a40f3837fa4a18007178c1cc315ae689b20 100644 (file)
@@ -34,6 +34,11 @@ CLA
 
 Contributions are now taken under the [.NET Foundation CLA](https://cla2.dotnetfoundation.org/).
 
+Code Review
+=======
+We are requiring code reviews before merging a pull request.
+GitHub won't let you merge a PR until someone from the Mono team approves it.
+
 Testing
 =======
 
index 2c5e83eb768c35d4926a5bd84e6461187b1dee40..bad8ecc8e3c8d08b5978acdf663d81535eb076be 100644 (file)
@@ -117,8 +117,8 @@ host_darwin=no
 
 
 if test "x$enable_wasm" = "xyes"; then
-CFLAGS="$CFLAGS -D_REENTRANT -D_GNU_SOURCE -DNO_UNALIGNED_ACCESS -s WASM=1 -DWASM -Os"
-CPPFLAGS="$CPPFLAGS -D_REENTRANT -DUSE_MMAP -D_GNU_SOURCE -DNO_UNALIGNED_ACCESS -s WASM=1 -DWASM -Os"
+CFLAGS="$CFLAGS -D_REENTRANT -D_GNU_SOURCE -DNO_UNALIGNED_ACCESS -s WASM=1"
+CPPFLAGS="$CPPFLAGS -D_REENTRANT -DUSE_MMAP -D_GNU_SOURCE -DNO_UNALIGNED_ACCESS -s WASM=1"
 libdl="-ldl"
 libgc_threads=pthreads
 
@@ -555,7 +555,18 @@ AC_CHECK_FUNCS(_finite, , AC_MSG_CHECKING(for _finite in math.h)
 AC_CHECK_HEADERS(linux/magic.h)
 
 # not 64 bit clean in cross-compile
-AC_CHECK_SIZEOF(void *, 4)
+if test "x$enable_wasm" = "xyes"; then
+AC_DEFINE(SIZEOF_VOID_P,4)
+AC_DEFINE(SIZEOF_LONG,4)
+ac_cv_sizeof_void_p="4"
+ac_cv_sizeof_long="4"
+else
+AC_CHECK_SIZEOF(void *)
+AC_CHECK_SIZEOF(long)
+fi
+
+AC_CHECK_SIZEOF(int)
+AC_CHECK_SIZEOF(long long)
 
 AC_CACHE_CHECK([for clang],
        mono_cv_clang,[
@@ -3067,6 +3078,7 @@ TARGET=WASM
 HOST=WASM
 arch_target=wasm
 AC_DEFINE(TARGET_WASM, 1, [Target wasm])
+AC_DEFINE(HOST_WASM, 1, [Host wasm])
 BTLS_SUPPORTED=no
 with_tls=pthread
 target_mach=no
@@ -3752,10 +3764,6 @@ AC_SUBST(PIDTYPE)
 AC_DEFINE(HAVE_CLASSIC_WINAPI_SUPPORT, 1, [Use classic Windows API support])
 AC_DEFINE(HAVE_UWP_WINAPI_SUPPORT, 0, [Don't use UWP Windows API support])
 
-AC_CHECK_SIZEOF(int)
-AC_CHECK_SIZEOF(void *)
-AC_CHECK_SIZEOF(long)
-AC_CHECK_SIZEOF(long long)
 AC_CHECK_FUNCS(strlcpy stpcpy strtok_r rewinddir vasprintf strerror_r)
 AC_CHECK_FUNCS(getrlimit)
 AC_CHECK_FUNCS(fork execv execve)
@@ -4342,6 +4350,7 @@ AM_CONDITIONAL(POWERPC64, test x$TARGET = xPOWERPC64)
 AM_CONDITIONAL(ARM, test x$TARGET = xARM)
 AM_CONDITIONAL(ARM64, test x$TARGET = xARM64)
 AM_CONDITIONAL(S390X, test x$TARGET = xS390X)
+AM_CONDITIONAL(WASM, test x$TARGET = xWASM)
 AM_CONDITIONAL(HOST_X86, test x$HOST = xX86)
 AM_CONDITIONAL(HOST_AMD64, test x$HOST = xAMD64)
 AM_CONDITIONAL(HOST_ARM, test x$HOST = xARM)
@@ -4373,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 4dfe97ec246b7ebd2f7b4af378817abf436cf102..08ec62bbd349c042a40f959f242db7a54412e916 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 4dfe97ec246b7ebd2f7b4af378817abf436cf102
+Subproject commit 08ec62bbd349c042a40f959f242db7a54412e916
index 142cbeb62ffabf1dd9c1414d8dd76f93bcbed0c2..9c5cc7f051a0bba2e41341a5baebfc4d2c2133ef 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 142cbeb62ffabf1dd9c1414d8dd76f93bcbed0c2
+Subproject commit 9c5cc7f051a0bba2e41341a5baebfc4d2c2133ef
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 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 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 ();
-       }
-}
-
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
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
-
-
-
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 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 ()
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 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 695e318267dfcdb054690188fab29f3f710eac11..9c3750e213bc319bb3241a9c7934f59237b520db 100644 (file)
@@ -1131,6 +1131,7 @@ 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, r1, r3, v)       S390_RIE_1(c, 0xecd9, r1, r3, v)
 #define s390_agr(c, r1, r2)            S390_RRE(c, 0xb908, r1, r2)
@@ -1154,6 +1155,7 @@ typedef struct {
 #define s390_algfr(c, r1, r2)          S390_RRE(c, 0xb91a, r1, r2)
 #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)
@@ -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)
@@ -1327,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)
@@ -1344,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)
@@ -1371,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)
@@ -1421,6 +1432,7 @@ 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)
@@ -1437,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) 
@@ -1447,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)
@@ -1461,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)
index 71797575e685c1107665e4eb14481f1fcb3a796f..26e48fd3490604163234891c3852203c5449f507 100644 (file)
@@ -37,6 +37,11 @@ typedef signed   @GSIZE@ gssize;
 #define G_BREAKPOINT()
 #endif
 
+#if defined (HOST_WASM)
+#undef G_BREAKPOINT
+#define G_BREAKPOINT() do { printf ("MONO: BREAKPOINT\n"); abort (); } while (0)
+#endif
+
 typedef @PIDTYPE@ GPid;
 
 #endif
index 59f5923125bffef92db3ff085e4d4ac12773cbd6..21e7770460345029bb2dea2ddd6a56eca8c7f57f 100644 (file)
@@ -160,7 +160,8 @@ g_path_get_basename (const char *filename)
        return g_strdup (&r[1]);
 }
 
-#ifndef HAVE_STRTOK_R
+//wasm does have strtok_r even though autoconf fails to find
+#if !defined (HAVE_STRTOK_R) && !defined (HOST_WASM)
 // This is from BSD's strtok_r
 
 char *
index 33ccf0294164002e9d62603d38005b5244c1b29e..482a7425d030caa2a41fde1ec756c1aa187c35ee 100644 (file)
@@ -278,7 +278,7 @@ void
 mono_gc_collect (int generation)
 {
 #ifndef DISABLE_PERFCOUNTERS
-       mono_perfcounters->gc_induced++;
+       InterlockedIncrement (&mono_perfcounters->gc_induced);
 #endif
        GC_gcollect ();
 }
@@ -457,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 ();
@@ -477,10 +477,11 @@ 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
                UnlockedAdd64 (&gc_stats.major_gc_time, mono_100ns_ticks () - gc_start_time);
@@ -522,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
 
@@ -1736,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);
@@ -1934,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 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 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 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 4ebc52bca25fdeb0a644e042c1b45fa89af53009..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);
@@ -5257,8 +5257,9 @@ mono_object_new_checked (MonoDomain *domain, MonoClass *klass, MonoError *error)
 
        MonoVTable *vtable;
 
-       vtable = mono_class_vtable (domain, klass);
-       g_assert (vtable); /* FIXME don't swallow the error */
+       vtable = mono_class_vtable_full (domain, klass, error);
+       if (!is_ok (error))
+               return NULL;
 
        MonoObject *o = mono_object_new_specific_checked (vtable, error);
        return o;
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 7f2a233401d7da565051c04dbd08f7faf851c95d..4cd30493fff80524e3b60b368623d7e2d35563c7 100644 (file)
@@ -2803,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));
@@ -2813,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 4e29232b78557608570ce0052c1464e348ddda2f..3eb6b3b623c8994cf3b2442b79a4270c2eebcc0b 100644 (file)
@@ -3049,6 +3049,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
index e33441b6d35a4218910e493ff5375292217e37b7..28fb9ee5b8d2fdbc6a19ed9ea8541ad4814c313b 100755 (executable)
@@ -312,6 +312,12 @@ genmdesc_LDADD = \
        $(GLIB_LIBS)                                    \
        $(LIBICONV)
 
+wasm_sources = \
+       mini-wasm.c             \
+       mini-wasm.h             \
+       exceptions-wasm.c       \
+       tramp-wasm.c
+
 x86_sources = \
        mini-x86.c              \
        mini-x86.h              \
@@ -456,6 +462,7 @@ common_sources = \
        aot-compiler.h          \
        aot-compiler.c          \
        aot-runtime.c           \
+       aot-runtime-wasm.c      \
        graph.c                 \
        mini-codegen.c          \
        mini-exceptions.c       \
@@ -541,6 +548,12 @@ endif
 
 regtests = $(filter-out $(regtests_DISABLED),$(regtests_UNIVERSAL))
 
+if WASM
+arch_sources = $(wasm_sources)
+arch_built=cpu-wasm.h
+arch_define=__wasm__
+endif
+
 if X86
 arch_sources = $(x86_sources)
 arch_built=cpu-x86.h
@@ -687,12 +700,20 @@ GENMDESC_OPTS=
 # build dependency for the poor windows users
 # $(arch_define) is the preprocessor symbol that enables all the opcodes
 # for the specific platform in mini-ops.h
+
 if CROSS_COMPILING
 GENMDESC_PRG=perl $(srcdir)/genmdesc.pl $(arch_define) $(srcdir) $(GENMDESC_OPTS)
-else !CROSS_COMPILING
+else
+if WASM
+GENMDESC_PRG=perl $(srcdir)/genmdesc.pl $(arch_define) $(srcdir) $(GENMDESC_OPTS)
+else
 GENMDESC_PRG=./genmdesc $(GENMDESC_OPTS)
+endif
 endif !CROSS_COMPILING
 
+cpu-wasm.h: cpu-wasm.md genmdesc$(EXEEXT)
+       $(GENMDESC_PRG) cpu-wasm.h wasm_desc $(srcdir)/cpu-wasm.md
+
 cpu-x86.h: cpu-x86.md genmdesc$(EXEEXT)
        $(GENMDESC_PRG) cpu-x86.h x86_desc $(srcdir)/cpu-x86.md
 
@@ -882,6 +903,7 @@ EXTRA_DIST = TestDriver.cs \
        TestHelpers.cs \
        genmdesc.pl                             \
        $(test_sources)                         \
+       $(wasm_sources) cpu-wasm.md             \
        $(x86_sources) cpu-x86.md               \
        $(amd64_sources) cpu-amd64.md           \
        $(ppc_sources) cpu-ppc.md cpu-ppc64.md  \
diff --git a/mono/mini/aot-runtime-wasm.c b/mono/mini/aot-runtime-wasm.c
new file mode 100644 (file)
index 0000000..4fb8906
--- /dev/null
@@ -0,0 +1,408 @@
+/**
+ * \file
+ * WASM AOT runtime
+ */
+
+#include "config.h"
+
+#include <sys/types.h>
+
+#include "mini.h"
+#include "interp/interp.h"
+
+#ifdef TARGET_WASM
+
+static void
+wasm_restore_context (void)
+{
+       g_error ("wasm_restore_context");
+}
+
+static void
+wasm_call_filter (void)
+{
+       g_error ("wasm_call_filter");
+}
+
+static void
+wasm_throw_exception (void)
+{
+       g_error ("wasm_throw_exception");
+}
+
+static void
+wasm_rethrow_exception (void)
+{
+       g_error ("wasm_rethrow_exception");
+}
+
+static void
+wasm_throw_corlib_exception (void)
+{
+       g_error ("wasm_throw_corlib_exception");
+}
+
+static char
+type_to_c (MonoType *t)
+{
+       if (t->byref)
+               return 'I';
+
+handle_enum:
+       switch (t->type) {
+       case MONO_TYPE_BOOLEAN:
+       case MONO_TYPE_CHAR:
+       case MONO_TYPE_I1:
+       case MONO_TYPE_U1:
+       case MONO_TYPE_I2:
+       case MONO_TYPE_U2:
+       case MONO_TYPE_I4:
+       case MONO_TYPE_U4:
+       case MONO_TYPE_I:
+       case MONO_TYPE_U:
+       case MONO_TYPE_PTR:
+       case MONO_TYPE_SZARRAY:
+       case MONO_TYPE_CLASS:
+       case MONO_TYPE_OBJECT:
+       case MONO_TYPE_STRING:
+               return 'I';
+       case MONO_TYPE_R4:
+               return 'F';
+       case MONO_TYPE_R8:
+               return 'D';
+               break;
+       case MONO_TYPE_I8:
+       case MONO_TYPE_U8:
+               return 'L';
+       case MONO_TYPE_VOID:
+               return 'V';
+       case MONO_TYPE_VALUETYPE:
+               if (t->data.klass->enumtype) {
+                       t = mono_class_enum_basetype (t->data.klass);
+                       goto handle_enum;
+               }
+
+               return 'I';
+       case MONO_TYPE_GENERICINST:
+               if (t->data.klass->valuetype)
+                       return 'S';
+               return 'I';
+       default:
+               g_warning ("CANT TRANSLATE %s", mono_type_full_name (t));
+               return 'X';
+       }
+}
+
+#if SIZEOF_VOID_P == 4
+#define FIDX(x) ((x) * 2)
+#else
+#define FIDX(x) (x)
+#endif
+
+static void
+wasm_invoke_v (void *target_func, InterpMethodArguments *margs)
+{
+       void (*func)(void) = target_func;
+       func ();
+}
+
+static void
+wasm_invoke_vi (void *target_func, InterpMethodArguments *margs)
+{
+       void (*func)(gpointer a) = target_func;
+       func (margs->iargs [0]);
+}
+
+static void
+wasm_invoke_vii (void *target_func, InterpMethodArguments *margs)
+{
+       void (*func)(gpointer a, gpointer b) = target_func;
+       func (margs->iargs [0], margs->iargs [1]);
+}
+
+static void
+wasm_invoke_viii (void *target_func, InterpMethodArguments *margs)
+{
+       void (*func)(gpointer a, gpointer b, gpointer c) = target_func;
+       func (margs->iargs [0], margs->iargs [1], margs->iargs [2]);
+}
+
+static void
+wasm_invoke_viiii (void *target_func, InterpMethodArguments *margs)
+{
+       void (*func)(gpointer a, gpointer b, gpointer c, gpointer d) = target_func;
+       func (margs->iargs [0], margs->iargs [1], margs->iargs [2], margs->iargs [3]);
+}
+
+static void
+wasm_invoke_viiiii (void *target_func, InterpMethodArguments *margs)
+{
+       void (*func)(gpointer a, gpointer b, gpointer c, gpointer d, gpointer e) = target_func;
+       func (margs->iargs [0], margs->iargs [1], margs->iargs [2], margs->iargs [3], margs->iargs [4]);
+}
+
+static void
+wasm_invoke_viiiiii (void *target_func, InterpMethodArguments *margs)
+{
+       void (*func)(gpointer a, gpointer b, gpointer c, gpointer d, gpointer e, gpointer f) = target_func;
+       func (margs->iargs [0], margs->iargs [1], margs->iargs [2], margs->iargs [3], margs->iargs [4], margs->iargs [5]);
+}
+
+static void
+wasm_invoke_i (void *target_func, InterpMethodArguments *margs)
+{
+       int (*func)(void) = target_func;
+       int res = func ();
+       *(int*)margs->retval = res;
+}
+
+static void
+wasm_invoke_ii (void *target_func, InterpMethodArguments *margs)
+{
+       int (*func)(gpointer a) = target_func;
+       int res = func (margs->iargs [0]);
+       *(int*)margs->retval = res;
+}
+
+static void
+wasm_invoke_iii (void *target_func, InterpMethodArguments *margs)
+{
+       int (*func)(gpointer a, gpointer b) = target_func;
+       int res = func (margs->iargs [0], margs->iargs [1]);
+       *(int*)margs->retval = res;
+}
+
+static void
+wasm_invoke_iiii (void *target_func, InterpMethodArguments *margs)
+{
+       int (*func)(gpointer a, gpointer b, gpointer c) = target_func;
+       int res = func (margs->iargs [0], margs->iargs [1], margs->iargs [2]);
+       *(int*)margs->retval = res;
+}
+
+static void
+wasm_invoke_iiiii (void *target_func, InterpMethodArguments *margs)
+{
+       int (*func)(gpointer a, gpointer b, gpointer c, gpointer d) = target_func;
+       int res = func (margs->iargs [0], margs->iargs [1], margs->iargs [2], margs->iargs [3]);
+       *(int*)margs->retval = res;
+}
+
+static void
+wasm_invoke_iiiiii (void *target_func, InterpMethodArguments *margs)
+{
+       int (*func)(gpointer a, gpointer b, gpointer c, gpointer d, gpointer e) = target_func;
+       int res = func (margs->iargs [0], margs->iargs [1], margs->iargs [2], margs->iargs [3], margs->iargs [4]);
+       *(int*)margs->retval = res;
+}
+
+typedef union {
+       gint64 l;
+       struct {
+               gint32 lo;
+               gint32 hi;
+       } pair;
+} interp_pair;
+
+static void
+wasm_invoke_ll (void *target_func, InterpMethodArguments *margs)
+{
+       gint64 (*func)(gint64 a) = target_func;
+
+       interp_pair p;
+       p.pair.lo = (gint32)margs->iargs [0];
+       p.pair.hi = (gint32)margs->iargs [1];
+
+       gint64 res = func (p.l);
+       *(gint64*)margs->retval = res;
+}
+
+static void
+wasm_invoke_li (void *target_func, InterpMethodArguments *margs)
+{
+       gint64 (*func)(gpointer a) = target_func;
+       gint64 res = func (margs->iargs [0]);
+       *(gint64*)margs->retval = res;
+}
+
+static void
+wasm_invoke_lil (void *target_func, InterpMethodArguments *margs)
+{
+       gint64 (*func)(gpointer a, gint64 b) = target_func;
+
+       interp_pair p;
+       p.pair.lo = (gint32)margs->iargs [1];
+       p.pair.hi = (gint32)margs->iargs [2];
+
+       gint64 res = func (margs->iargs [0], p.l);
+       *(gint64*)margs->retval = res;
+}
+
+static void
+wasm_invoke_dd (void *target_func, InterpMethodArguments *margs)
+{
+       double (*func)(double a) = target_func;
+
+       double res = func (margs->fargs [FIDX (0)]);
+       *(double*)margs->retval = res;
+}
+
+static void
+wasm_invoke_ddd (void *target_func, InterpMethodArguments *margs)
+{
+       double (*func)(double a, double b) = target_func;
+
+       double res = func (margs->fargs [FIDX (0)], margs->fargs [FIDX (1)]);
+       *(double*)margs->retval = res;
+}
+
+
+       
+static void
+wasm_invoke_vif (void *target_func, InterpMethodArguments *margs)
+{
+       void (*func)(gpointer a, float b) = target_func;
+
+       func (margs->iargs [0], 
+               *(float*)&margs->fargs [FIDX (0)]);
+}
+
+static void
+wasm_invoke_viff (void *target_func, InterpMethodArguments *margs)
+{
+       void (*func)(gpointer a, float b, float c) = target_func;
+
+       func (margs->iargs [0],
+               *(float*)&margs->fargs [FIDX (0)],
+               *(float*)&margs->fargs [FIDX (1)]);
+}
+
+static void
+wasm_invoke_viffff (void *target_func, InterpMethodArguments *margs)
+{
+       void (*func)(gpointer a, float b, float c, float d, float e) = target_func;
+
+       func (margs->iargs [0],
+               *(float*)&margs->fargs [FIDX (0)],
+               *(float*)&margs->fargs [FIDX (1)],
+               *(float*)&margs->fargs [FIDX (2)],
+               *(float*)&margs->fargs [FIDX (3)]);
+}
+
+static void
+wasm_invoke_vifffffi (void *target_func, InterpMethodArguments *margs)
+{
+       void (*func)(gpointer a, float b, float c, float d, float e, float f, int g) = target_func;
+
+       func (margs->iargs [0],
+               *(float*)&margs->fargs [FIDX (0)],
+               *(float*)&margs->fargs [FIDX (1)],
+               *(float*)&margs->fargs [FIDX (2)],
+               *(float*)&margs->fargs [FIDX (3)],
+               *(float*)&margs->fargs [FIDX (4)],
+               *(float*)&margs->iargs [1]);
+}
+
+static void
+wasm_enter_icall_trampoline (void *target_func, InterpMethodArguments *margs)
+{
+       static char cookie [8];
+       static int c_count;
+
+       MonoMethodSignature *sig = margs->sig;
+
+       c_count = sig->param_count + sig->hasthis + 1;
+       cookie [0] = type_to_c (sig->ret);
+       if (sig->hasthis)
+               cookie [1] = 'I';
+       for (int i = 0; i < sig->param_count; ++i)
+               cookie [1 + sig->hasthis + i ] = type_to_c (sig->params [i]);
+       cookie [c_count] = 0;
+
+       if (!strcmp ("V", cookie))
+               wasm_invoke_v (target_func, margs);
+       else if (!strcmp ("VI", cookie))
+               wasm_invoke_vi (target_func, margs);
+       else if (!strcmp ("VII", cookie))
+               wasm_invoke_vii (target_func, margs);
+       else if (!strcmp ("VIII", cookie))
+               wasm_invoke_viii (target_func, margs);
+       else if (!strcmp ("VIIII", cookie))
+               wasm_invoke_viiii (target_func, margs);
+       else if (!strcmp ("VIIIII", cookie))
+               wasm_invoke_viiiii (target_func, margs);
+       else if (!strcmp ("VIIIIII", cookie))
+               wasm_invoke_viiiiii (target_func, margs);
+       else if (!strcmp ("I", cookie))
+               wasm_invoke_i (target_func, margs);
+       else if (!strcmp ("II", cookie))
+               wasm_invoke_ii (target_func, margs);
+       else if (!strcmp ("III", cookie))
+               wasm_invoke_iii (target_func, margs);
+       else if (!strcmp ("IIII", cookie))
+               wasm_invoke_iiii (target_func, margs);
+       else if (!strcmp ("IIIII", cookie))
+               wasm_invoke_iiiii (target_func, margs);
+       else if (!strcmp ("IIIIII", cookie))
+               wasm_invoke_iiiiii (target_func, margs);
+       else if (!strcmp ("LL", cookie))
+               wasm_invoke_ll (target_func, margs);
+       else if (!strcmp ("LI", cookie))
+               wasm_invoke_li (target_func, margs);
+       else if (!strcmp ("LIL", cookie))
+               wasm_invoke_lil (target_func, margs);
+       else if (!strcmp ("DD", cookie))
+               wasm_invoke_dd (target_func, margs);
+       else if (!strcmp ("DDD", cookie))
+               wasm_invoke_ddd (target_func, margs);
+       else if (!strcmp ("VIF", cookie))
+               wasm_invoke_vif (target_func, margs);
+       else if (!strcmp ("VIFF", cookie))
+               wasm_invoke_viff (target_func, margs);
+       else if (!strcmp ("VIFFFF", cookie))
+               wasm_invoke_viffff (target_func, margs);
+       else if (!strcmp ("VIFFFFFI", cookie))
+               wasm_invoke_vifffffi (target_func, margs);
+       else {
+               printf ("CANNOT HANDLE COOKIE %s\n", cookie);
+               g_assert (0);
+       }
+}
+
+gpointer
+mono_aot_get_trampoline_full (const char *name, MonoTrampInfo **out_tinfo)
+{
+       gpointer code = NULL;
+
+       if (!strcmp (name, "restore_context"))
+               code = wasm_restore_context;
+       else if (!strcmp (name, "call_filter"))
+               code = wasm_call_filter;
+       else if (!strcmp (name, "throw_exception"))
+               code = wasm_throw_exception;
+       else if (!strcmp (name, "rethrow_exception"))
+               code = wasm_rethrow_exception;
+       else if (!strcmp (name, "throw_corlib_exception"))
+               code = wasm_throw_corlib_exception;
+       else if (!strcmp (name, "enter_icall_trampoline"))
+               code = wasm_enter_icall_trampoline;
+
+       g_assert (code);
+
+       if (out_tinfo) {
+               MonoTrampInfo *tinfo = g_new0 (MonoTrampInfo, 1);
+               tinfo->code = code;
+               tinfo->code_size = 1;
+               tinfo->name = g_strdup (name);
+               tinfo->ji = NULL;
+               tinfo->unwind_ops = NULL;
+               tinfo->uw_info = NULL;
+               tinfo->uw_info_len = 0;
+               tinfo->owns_uw_info = FALSE;
+
+               *out_tinfo = tinfo;
+       }
+
+       return code;
+}
+#endif
index d6c2486414f3278b960ec7480d50137ea27e7cee..4e86a5a3f32dc0f21460bfb23046f2a12f34f55b 100644 (file)
@@ -5143,6 +5143,8 @@ no_trampolines (void)
        g_assert_not_reached ();
 }
 
+
+#ifndef TARGET_WASM
 /*
  * Return the trampoline identified by NAME from the mscorlib AOT file.
  * On ppc64, this returns a function descriptor.
@@ -5159,6 +5161,8 @@ mono_aot_get_trampoline_full (const char *name, MonoTrampInfo **out_tinfo)
 
        return mono_create_ftnptr_malloc ((guint8 *)load_function_full (amodule, name, out_tinfo));
 }
+#endif
+
 
 gpointer
 mono_aot_get_trampoline (const char *name)
diff --git a/mono/mini/cpu-wasm.md b/mono/mini/cpu-wasm.md
new file mode 100644 (file)
index 0000000..e69de29
index 4a2637c1943e4339c4aaca8a2762a8a538012405..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;
                        }
index 297179bf86cabaa76b112108bb7a977d9c65db1f..f293f7c6803ff1e3dc488d9d694711479610b208 100644 (file)
@@ -2376,6 +2376,11 @@ mono_jit_set_aot_mode (MonoAotMode mode)
                mono_aot_only = TRUE;
                mono_use_interpreter = TRUE;
        }
+       if (mono_aot_mode == MONO_AOT_MODE_INTERP_LLVMONLY) {
+               mono_aot_only = TRUE;
+               mono_use_interpreter = TRUE;
+               mono_llvm_only = TRUE;
+       }
 }
 
 mono_bool
diff --git a/mono/mini/exceptions-wasm.c b/mono/mini/exceptions-wasm.c
new file mode 100644 (file)
index 0000000..63e72b0
--- /dev/null
@@ -0,0 +1,34 @@
+#include "mini.h"
+
+
+gpointer
+mono_arch_get_call_filter (MonoTrampInfo **info, gboolean aot)
+{
+       g_error ("mono_arch_get_call_filter");
+       return NULL;
+}
+
+gpointer
+mono_arch_get_restore_context (MonoTrampInfo **info, gboolean aot)
+{
+       g_error ("mono_arch_get_restore_context");
+       return NULL;
+}
+
+gboolean
+mono_arch_unwind_frame (MonoDomain *domain, MonoJitTlsData *jit_tls, 
+                                                        MonoJitInfo *ji, MonoContext *ctx, 
+                                                        MonoContext *new_ctx, MonoLMF **lmf,
+                                                        mgreg_t **save_locations,
+                                                        StackFrameInfo *frame)
+{
+       g_error ("mono_arch_unwind_frame");
+       return FALSE;
+}
+
+gpointer 
+mono_arch_get_throw_corlib_exception (MonoTrampInfo **info, gboolean aot)
+{
+       g_error ("mono_arch_get_throw_corlib_exception");
+       return NULL;
+}
\ No newline at end of file
old mode 100644 (file)
new mode 100755 (executable)
index 8c8e7ea..ae49ecb
@@ -20,7 +20,7 @@ sub INST_MAX   () {return 6;}
 
 # this must include all the #defines used in mini-ops.h
 my @defines = qw (__i386__ __x86_64__ __ppc__ __powerpc__ __ppc64__ __arm__ 
-       __sparc__ sparc __s390__ s390 __alpha__ __mips__ __aarch64__);
+       __sparc__ sparc __s390__ s390 __alpha__ __mips__ __aarch64__ __wasm__);
 my %table =();
 my %template_table =();
 my @opcodes = ();
@@ -88,7 +88,9 @@ sub load_opcodes
        if ($arch =~ "__aarch64__") {
                $arch_define = "TARGET_ARM64";
        }
-
+       if ($arch =~ "__wasm__") {
+               $arch_define = "TARGET_WASM";
+       }
        parse_file ($arch_define, "$srcdir/mini-ops.h");
        return;
        $cpp .= " -D$arch_define $srcdir/mini-ops.h|";
index fccce6b3411211e47139f783249bb0032de10225..42b91954fcf2c223e6c66a23fd404544ff3cb88b 100644 (file)
@@ -795,6 +795,10 @@ static InterpMethodArguments* build_args_from_sig (MonoMethodSignature *sig, Int
        int i8_align = mono_arm_i8_align ();
 #endif
 
+#ifdef TARGET_WASM
+       margs->sig = sig;
+#endif
+
        if (sig->hasthis)
                margs->ilen++;
 
index 6abf93a6f0a38c900820258f6b73859f2b35d048..42198d92193fa81bec29b67d47c4d6325364fd62 100644 (file)
@@ -6,8 +6,13 @@
 #define __MONO_MINI_INTERPRETER_H__
 #include <mono/mini/mini.h>
 
+#ifdef TARGET_WASM
+#define INTERP_ICALL_TRAMP_IARGS 12
+#define INTERP_ICALL_TRAMP_FARGS 12
+#else
 #define INTERP_ICALL_TRAMP_IARGS 12
 #define INTERP_ICALL_TRAMP_FARGS 4
+#endif
 
 struct _InterpMethodArguments {
        size_t ilen;
@@ -16,6 +21,9 @@ struct _InterpMethodArguments {
        double *fargs;
        gpointer *retval;
        size_t is_float_ret;
+#ifdef TARGET_WASM
+       MonoMethodSignature *sig;
+#endif
 };
 
 typedef struct _InterpMethodArguments InterpMethodArguments;
index 408fead304ef2f95073bbe518c329125f519ea24..3a91c13f0d56369aeee04453a39dfd3e1e577514 100644 (file)
@@ -57,7 +57,9 @@ typedef enum {
        MONO_AOT_MODE_LLVMONLY,
        /* Uses Interpreter, JIT is disabled and not allowed,
         * equivalent to "--full-aot --interpreter" */
-       MONO_AOT_MODE_INTERP
+       MONO_AOT_MODE_INTERP,
+       /* Same as INTERP, but use only llvm compiled code */
+       MONO_AOT_MODE_INTERP_LLVMONLY,
 } MonoAotMode;
 
 MONO_API void
index 949e5a362a6f7a4a413fcc0d3d19757f3fd72d1b..949f8946ddd1c73cf2a3d56a303448eff7115656 100644 (file)
@@ -3650,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;
@@ -4487,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)
@@ -4517,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 eb50de0f5e4aebe8a94ce6bea359635255c92c11..c49ed5a41d569c71627c295a89ac0de4365ac1aa 100644 (file)
@@ -25,6 +25,8 @@
 #include "mini-arm64.h"
 #elif defined(__mips__)
 #include "mini-mips.h"
+#elif TARGET_WASM
+#include "mini-wasm.h"
 #else
 #error add arch specific include file in mini-arch.h
 #endif
index f15af494bb150609956f9baf5570fc1ed08ed9a3..10cf1b75cb194d9051761962546b5ffba8b9f8f8 100644 (file)
@@ -1700,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
@@ -2153,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;
@@ -2175,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) {
@@ -2277,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);
@@ -3263,7 +3263,7 @@ mono_llvm_load_exception (void)
 
        if (mono_ex->trace_ips) {
                GList *trace_ips = NULL;
-               gpointer ip = __builtin_return_address (0);
+               gpointer ip = RETURN_ADDRESS ();
 
                size_t upper = mono_array_length (mono_ex->trace_ips);
 
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 8e82dfa0ccabaccba02d16c6d25542d0895fb87d..584813cc4db9caa812d9b5f4c9d75382cb6358f0 100644 (file)
@@ -3717,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: {
@@ -3798,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: {
@@ -3843,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;
diff --git a/mono/mini/mini-wasm.c b/mono/mini/mini-wasm.c
new file mode 100644 (file)
index 0000000..0104909
--- /dev/null
@@ -0,0 +1,253 @@
+#include "mini.h"
+
+
+gpointer
+mono_arch_get_this_arg_from_call (mgreg_t *regs, guint8 *code)
+{
+       g_error ("mono_arch_get_this_arg_from_call");
+}
+
+gpointer
+mono_arch_get_delegate_virtual_invoke_impl (MonoMethodSignature *sig, MonoMethod *method, int offset, gboolean load_imt_reg)
+{
+       g_error ("mono_arch_get_delegate_virtual_invoke_impl");
+}
+
+
+void
+mono_arch_cpu_init (void)
+{
+       // printf ("mono_arch_cpu_init\n");
+}
+
+void
+mono_arch_finish_init (void)
+{
+       // printf ("mono_arch_finish_init\n");
+}
+
+void
+mono_arch_init (void)
+{
+       // printf ("mono_arch_init\n");
+}
+
+void
+mono_arch_cleanup (void)
+{
+}
+
+void
+mono_arch_register_lowlevel_calls (void)
+{
+}
+
+void
+mono_arch_flush_register_windows (void)
+{
+}
+
+void
+mono_arch_free_jit_tls_data (MonoJitTlsData *tls)
+{
+}
+
+
+MonoMethod*
+mono_arch_find_imt_method (mgreg_t *regs, guint8 *code)
+{
+       g_error ("mono_arch_find_static_call_vtable");
+       return (MonoMethod*) regs [MONO_ARCH_IMT_REG];
+}
+
+MonoVTable*
+mono_arch_find_static_call_vtable (mgreg_t *regs, guint8 *code)
+{
+       g_error ("mono_arch_find_static_call_vtable");
+       return (MonoVTable*) regs [MONO_ARCH_RGCTX_REG];
+}
+
+gpointer
+mono_arch_build_imt_trampoline (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckItem **imt_entries, int count, gpointer fail_tramp)
+{
+       g_error ("mono_arch_build_imt_trampoline");
+}
+
+guint32
+mono_arch_cpu_enumerate_simd_versions (void)
+{
+       return 0;
+}
+
+guint32
+mono_arch_cpu_optimizations (guint32 *exclude_mask)
+{
+       return 0;
+}
+
+GSList*
+mono_arch_get_delegate_invoke_impls (void)
+{
+       g_error ("mono_arch_get_delegate_invoke_impls");
+       return NULL;
+}
+
+gpointer
+mono_arch_get_delegate_invoke_impl (MonoMethodSignature *sig, gboolean has_target)
+{
+       g_error ("mono_arch_get_delegate_invoke_impl");
+       return NULL;
+}
+
+mgreg_t
+mono_arch_context_get_int_reg (MonoContext *ctx, int reg)
+{
+       g_error ("mono_arch_context_get_int_reg");
+       return 0;
+}
+
+int
+mono_arch_get_argument_info (MonoMethodSignature *csig, int param_count, MonoJitArgumentInfo *arg_info)
+{
+       g_error ("mono_arch_get_argument_info");
+       return 0;
+
+}
+
+void
+mono_arch_init_lmf_ext (MonoLMFExt *ext, gpointer prev_lmf)
+{
+       ext->lmf.previous_lmf = (gsize)prev_lmf;
+       /* Mark that this is a MonoLMFExt */
+       ext->lmf.previous_lmf = (gsize)(gpointer)(((gssize)ext->lmf.previous_lmf) | 2);
+}
+
+
+
+void
+mono_runtime_setup_stat_profiler (void)
+{
+       g_error ("mono_runtime_setup_stat_profiler");
+}
+
+
+void
+mono_runtime_shutdown_stat_profiler (void)
+{
+       g_error ("mono_runtime_shutdown_stat_profiler");
+}
+
+
+gboolean
+MONO_SIG_HANDLER_SIGNATURE (mono_chain_signal)
+{
+       g_error ("mono_chain_signal");
+       
+       return FALSE;
+}
+
+void
+mono_runtime_install_handlers (void)
+{
+}
+
+void
+mono_runtime_cleanup_handlers (void)
+{
+}
+
+gboolean
+mono_thread_state_init_from_handle (MonoThreadUnwindState *tctx, MonoThreadInfo *info)
+{
+       g_error ("WASM systems don't support mono_thread_state_init_from_handle");
+       return FALSE;
+}
+
+
+/*
+The following functions don't belong here, but are due to laziness.
+*/
+
+//w32file-wasm.c
+gboolean
+mono_w32file_get_volume_information (const gunichar2 *path, gunichar2 *volumename, gint volumesize, gint *outserial, gint *maxcomp, gint *fsflags, gunichar2 *fsbuffer, gint fsbuffersize)
+{
+       g_error ("mono_w32file_get_volume_information");
+}
+
+
+//llvm builtin's that we should not have used in the first place
+
+
+//libc / libpthread missing bits from musl or shit we didn't detect :facepalm:
+int pthread_getschedparam (pthread_t thread, int *policy, struct sched_param *param)
+{
+       g_error ("pthread_getschedparam");
+       return 0;
+}
+
+int
+pthread_attr_getstacksize (const pthread_attr_t *restrict attr, size_t *restrict stacksize)
+{
+       return 65536; //wasm page size
+}
+
+int
+pthread_sigmask (int how, const sigset_t * restrict set, sigset_t * restrict oset)
+{
+       return 0;
+}
+
+
+int
+sigsuspend(const sigset_t *sigmask)
+{
+       g_error ("sigsuspend");
+       return 0;
+}
+
+int
+getdtablesize (void)
+{
+       return 256; //random constant that is the fd limit
+}
+
+void *
+getgrnam (const char *name)
+{
+       return NULL;
+}
+
+void *
+getgrgid (gid_t gid)
+{
+       return NULL;
+}
+
+int
+inotify_init (void)
+{
+       g_error ("inotify_init");
+}
+
+int
+inotify_rm_watch (int fd, int wd)
+{
+       g_error ("inotify_rm_watch");
+       return 0;
+}
+
+int
+inotify_add_watch (int fd, const char *pathname, uint32_t mask)
+{
+       g_error ("inotify_add_watch");
+       return 0;
+}
+
+int
+sem_timedwait (sem_t *sem, const struct timespec *abs_timeout)
+{
+       g_error ("sem_timedwait");
+       return 0;
+       
+}
diff --git a/mono/mini/mini-wasm.h b/mono/mini/mini-wasm.h
new file mode 100644 (file)
index 0000000..8205dc1
--- /dev/null
@@ -0,0 +1,50 @@
+#ifndef __MONO_MINI_WASM_H__
+#define __MONO_MINI_WASM_H__
+
+#include <mono/utils/mono-sigcontext.h>
+#include <mono/utils/mono-context.h>
+
+#define MONO_ARCH_CPU_SPEC mono_wasm_desc
+
+#define MONO_ARCH_HAVE_INIT_LMF_EXT 1
+
+#define MONO_MAX_IREGS 1
+#define MONO_MAX_FREGS 1
+
+#define WASM_REG_0 0
+
+
+struct MonoLMF {
+       /* 
+        * If the second lowest bit is set to 1, then this is a MonoLMFExt structure, and
+        * the other fields are not valid.
+        */
+       gpointer previous_lmf;
+       gpointer lmf_addr;
+
+       /* This is only set in trampoline LMF frames */
+       MonoMethod *method;
+
+       gboolean top_entry;
+};
+
+typedef struct {
+       int dummy;
+} MonoCompileArch;
+
+#define MONO_ARCH_INIT_TOP_LMF_ENTRY(lmf) do { (lmf)->top_entry = TRUE; } while (0)
+
+#define MONO_CONTEXT_SET_LLVM_EXC_REG(ctx, exc) do { (ctx)->llvm_exc_reg = (gsize)exc; } while (0)
+
+#define MONO_INIT_CONTEXT_FROM_FUNC(ctx,start_func) do {       \
+               MONO_CONTEXT_SET_IP ((ctx), (start_func));      \
+               MONO_CONTEXT_SET_BP ((ctx), (0));       \
+               MONO_CONTEXT_SET_SP ((ctx), (0));       \
+       } while (0)
+
+
+#define MONO_ARCH_VTABLE_REG WASM_REG_0
+#define MONO_ARCH_IMT_REG WASM_REG_0
+#define MONO_ARCH_RGCTX_REG WASM_REG_0
+
+#endif /* __MONO_MINI_WASM_H__ */  
index ee6ec6659bf1455c4c23f5703106ad311e2eafe1..4cfe898b0a085c284912893fd16961e504021ee3 100644 (file)
@@ -3875,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 9645a0de7b99d1b9ac7e8caedbb37a3bf0cabded..0edfea186b4e5adfaacc6013a6d1e6f82e83613e 100644 (file)
@@ -3266,4 +3266,31 @@ gboolean MONO_SIG_HANDLER_SIGNATURE (mono_chain_signal);
  */
 void mono_interruption_checkpoint_from_trampoline (void);
 
+
+#if defined (HOST_WASM)
+
+#define RETURN_ADDRESS_N(N) NULL
+#define RETURN_ADDRESS() RETURN_ADDRESS_N(0)
+
+
+#elif defined (__GNUC__)
+
+#define RETURN_ADDRESS_N(N) (__builtin_extract_return_addr (__builtin_return_address (N)))
+#define RETURN_ADDRESS() RETURN_ADDRESS_N(0)
+
+#elif defined(_MSC_VER)
+
+#include <intrin.h>
+#pragma intrinsic(_ReturnAddress)
+
+#define RETURN_ADDRESS() _ReturnAddress()
+#define RETURN_ADDRESS_N(N) NULL
+
+#else
+
+#error "Missing return address intrinsics implementation"
+
+#endif
+
+
 #endif /* __MONO_MINI_H__ */
index 0e50ae550707597de0aee029b8dc9cdda3829405..b81fe604ed3aef345b7eef2ca52c01e4630172d7 100644 (file)
 #  define fprintf(__ignore, ...) g_log ("mono-gc", G_LOG_LEVEL_MESSAGE, __VA_ARGS__)
 #endif
 
-#ifdef __GNUC__
-
-#define RETURN_ADDRESS_N(N) (__builtin_extract_return_addr (__builtin_return_address (N)))
-#define RETURN_ADDRESS() RETURN_ADDRESS_N(0)
-
-#elif defined(_MSC_VER)
-
-#include <intrin.h>
-#pragma intrinsic(_ReturnAddress)
-
-#define RETURN_ADDRESS() _ReturnAddress()
-#define RETURN_ADDRESS_N(N) NULL
-
-#else
-
-#error "Missing return address intrinsics implementation"
-
-#endif
-
 static MonoTraceSpec trace_spec;
 
 static volatile gint32 output_lock = 0;
diff --git a/mono/mini/tramp-wasm.c b/mono/mini/tramp-wasm.c
new file mode 100644 (file)
index 0000000..50447fb
--- /dev/null
@@ -0,0 +1,54 @@
+#include "mini.h"
+
+
+gpointer
+mono_arch_create_specific_trampoline (gpointer arg1, MonoTrampolineType tramp_type, MonoDomain *domain, guint32 *code_len)
+{
+       g_error ("mono_arch_create_specific_trampoline");
+}
+
+guchar*
+mono_arch_create_generic_trampoline (MonoTrampolineType tramp_type, MonoTrampInfo **info, gboolean aot)
+{
+       g_error ("mono_arch_create_generic_trampoline");
+}
+
+gpointer
+mono_arch_create_rgctx_lazy_fetch_trampoline (guint32 slot, MonoTrampInfo **info, gboolean aot)
+{
+       g_error ("mono_arch_create_rgctx_lazy_fetch_trampoline");
+}
+
+void
+mono_arch_patch_plt_entry (guint8 *code, gpointer *got, mgreg_t *regs, guint8 *addr)
+{
+       g_error ("mono_arch_patch_plt_entry");
+}
+
+gpointer
+mono_arch_get_enter_icall_trampoline (MonoTrampInfo **info)
+{
+       printf ("mono_arch_get_enter_icall_trampoline");
+       g_assert (0);
+       return NULL;
+}
+
+void
+mono_arch_patch_callsite (guint8 *method_start, guint8 *orig_code, guint8 *addr)
+{
+       g_error ("mono_arch_patch_callsite");
+}
+
+gpointer
+mono_arch_get_unbox_trampoline (MonoMethod *m, gpointer addr)
+{
+       g_error ("mono_arch_get_unbox_trampoline");
+       return NULL;
+}
+
+gpointer
+mono_arch_get_static_rgctx_trampoline (gpointer arg, gpointer addr)
+{
+       g_error ("mono_arch_get_static_rgctx_trampoline");
+       return NULL;
+}
\ No newline at end of file
index 53e962c2b702e7ea8a893dc940ea8d42d227b967..5e8866ffff869d2123ece47d39040009b0a95118 100644 (file)
@@ -104,6 +104,20 @@ typedef mword SgenDescriptor;
 #endif
 #endif
 
+#if defined (TARGET_WASM)
+#define DEFAULT_MAJOR SGEN_MAJOR_SERIAL
+#define DEFAULT_SWEEP_MODE SGEN_SWEEP_SERIAL
+#elif defined(HAVE_CONC_GC_AS_DEFAULT)
+/* Use concurrent major on deskstop platforms */
+#define DEFAULT_MAJOR SGEN_MAJOR_CONCURRENT
+#define DEFAULT_SWEEP_MODE SGEN_SWEEP_CONCURRENT
+#else
+#define DEFAULT_MAJOR SGEN_MAJOR_SERIAL
+#define DEFAULT_SWEEP_MODE SGEN_SWEEP_CONCURRENT
+#endif
+
+
+
 /*
  * Maximum level of debug to enable on this build.
  * Making this a constant enables us to put logging in a lot of places and
index beb5ce1b2580c265935db3200a138fd91f31c9a4..d5416f0df3630ee6a6bc5b4781bc0e9c5442873c 100644 (file)
@@ -337,13 +337,6 @@ nursery_canaries_enabled (void)
 
 #define safe_object_get_size   sgen_safe_object_get_size
 
-#if defined(HAVE_CONC_GC_AS_DEFAULT)
-/* Use concurrent major on deskstop platforms */
-#define DEFAULT_MAJOR SGEN_MAJOR_CONCURRENT
-#else
-#define DEFAULT_MAJOR SGEN_MAJOR_SERIAL
-#endif
-
 typedef enum {
        SGEN_MAJOR_DEFAULT,
        SGEN_MAJOR_SERIAL,
index 5f4185d4df70ec4f48a692aae3edfc46cfd3396b..e06ac6d3f83f22177fa54f48f5dc96fa23870e98 100644 (file)
@@ -189,10 +189,15 @@ enum {
        SWEEP_STATE_COMPACTING
 };
 
+typedef enum {
+       SGEN_SWEEP_SERIAL = FALSE,
+       SGEN_SWEEP_CONCURRENT = TRUE,
+} SgenSweepMode;
+
 static volatile int sweep_state = SWEEP_STATE_SWEPT;
 
 static gboolean concurrent_mark;
-static gboolean concurrent_sweep = TRUE;
+static gboolean concurrent_sweep = DEFAULT_SWEEP_MODE;
 
 int sweep_pool_context = -1;
 
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 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 c2b2b96d9d7419c0eea9d9400a84da27323b6d7a..ea1b595c4a5b6b66bb0016c10ef2cc4ed2706c98 100644 (file)
@@ -15,7 +15,7 @@
 #include <unistd.h>
 #endif
 
-#if defined(_POSIX_VERSION)
+#if defined(_POSIX_VERSION) && !defined (HOST_WASM)
 
 #include "mono/utils/mono-dl.h"
 #include "mono/utils/mono-embed.h"
index 40318232c2134f68563a10d855b52987092c52e5..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,9 +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_mlt = facs.multi;
-       mono_hwcap_s390x_has_ia  = facs.ia;
-       mono_hwcap_s390x_has_gie = facs.gie;
+       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 47ae051428a9050b7596f0b53c37b489a8c4b84e..05f89a34ef93ed73ebab52f971a7b8c8fda88c30 100644 (file)
@@ -38,6 +38,8 @@ 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 440eff85125121729d9c330de899bf5d74e43d0f..1b9849fe5aff24f0672b6d232e28c526827f8525 100644 (file)
@@ -37,6 +37,9 @@
 #ifdef _MSC_VER
 // TODO: Find MSVC replacement for __builtin_unwind_init
 #define SAVE_REGS_ON_STACK g_assert_not_reached ();
+#elif defined (HOST_WASM)
+//TODO: figure out wasm stack scanning
+#define SAVE_REGS_ON_STACK do {} while (0)
 #else 
 #define SAVE_REGS_ON_STACK __builtin_unwind_init ();
 #endif
index 6ef8a9c5e843d7b84415ffdb13d71121930dc3ba..60816ed8d578d1cfbf9fc4d37c8688521f297833 100644 (file)
@@ -7,13 +7,13 @@
 
 #define round_down(addr, val) ((void*)((addr) & ~((val) - 1)))
 
-void
-mono_threads_platform_get_stack_bounds (guint8 **staddr, size_t *stsize)
+int
+mono_threads_get_max_stack_size (void)
 {
-       *staddr = round_down ((size_t)&staddr, 65536); //WASM pagesize is 64k
-       *stsize = 65536 * 4; //we say it's 4 pages, there isn't much that uses this beyond the GC
+       return 65536 * 8; //totally arbitrary, this value is actually useless until WASM supports multiple threads.
 }
 
+
 void
 mono_threads_suspend_init_signals (void)
 {
@@ -57,4 +57,79 @@ mono_threads_suspend_abort_syscall (MonoThreadInfo *info)
 {
 }
 
+//----
+
+gboolean
+mono_native_thread_id_equals (MonoNativeThreadId id1, MonoNativeThreadId id2)
+{
+       return id1 == id2;
+}
+
+
+MonoNativeThreadId
+mono_native_thread_id_get (void)
+{
+       return (MonoNativeThreadId)1;
+}
+
+MONO_API gboolean
+mono_native_thread_create (MonoNativeThreadId *tid, gpointer func, gpointer arg)
+{
+       g_error ("WASM doesn't support threading");
+}
+
+static const char *thread_name;
+
+void
+mono_native_thread_set_name (MonoNativeThreadId tid, const char *name)
+{
+       thread_name = g_strdup (name);
+}
+
+gboolean
+mono_native_thread_join (MonoNativeThreadId tid)
+{
+       g_error ("WASM doesn't support threading");
+       return FALSE;
+}
+
+//----
+
+gboolean
+mono_threads_platform_yield (void)
+{
+       return TRUE;
+}
+
+void
+mono_threads_platform_get_stack_bounds (guint8 **staddr, size_t *stsize)
+{
+       *staddr = round_down ((size_t)&staddr, 65536); //WASM pagesize is 64k
+       *stsize = 65536 * 4; //we say it's 4 pages, there isn't much that uses this beyond the GC
+}
+
+
+gboolean
+mono_thread_platform_create_thread (MonoThreadStart thread_fn, gpointer thread_data, gsize* const stack_size, MonoNativeThreadId *tid)
+{
+       g_error ("WASM doesn't support threading");
+       return FALSE;
+}
+
+void mono_threads_platform_init (void)
+{
+}
+
+void
+mono_threads_platform_exit (gsize exit_code)
+{
+       g_error ("WASM doesn't support threading");
+}
+
+gboolean
+mono_threads_platform_in_critical_region (MonoNativeThreadId tid)
+{
+       return FALSE;
+}
+
 #endif
index 32aeb9633886e6fed3fd9f09e10ab79386cbd4f0..45ccf518a7db1658ea9cae743458f0ce6be97961 100644 (file)
@@ -16,7 +16,8 @@
 #include <netdb.h>
 #endif
 
-#ifndef HAVE_INET_PTON
+//wasm does have inet_pton even though autoconf fails to find
+#if !defined (HAVE_INET_PTON) && !defined (HOST_WASM)
 
 int
 inet_pton (int family, const char *address, void *inaddrp)
index a989dafdbc7f0b7fdb143bbf4974658ba5608ffd..6c4abcf468286674a1738b8276e37e9b9bd3e0ba 100644 (file)
@@ -31,6 +31,20 @@ 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)
@@ -66,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)
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..2d633c4
--- /dev/null
@@ -0,0 +1,26 @@
+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,21 @@ 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>
++
++        <!-- _DebugFileExt is not an upstream msbuild feature yet -->
++        <_DebugFileExt>.pdb</_DebugFileExt>
++        <_DebugFileExt Condition="'$(FscDebugFileExt)' != ''">$(FscDebugFileExt)</_DebugFileExt>
++
++        <DebugType Condition="'$(OS)' != 'Windows_NT' And ('$(DebugSymbols)'=='True' or ('$(DebugSymbols)'=='' And '$(_ConfigurationNameTmp)'=='Debug'))">portable</DebugType>
++        <DebugType Condition="'$(FscDebugType)' != ''">$(FscDebugType)</DebugType>
+     </PropertyGroup>
+     <!--