# 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
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
=======
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
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,[
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
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)
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)
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
-Subproject commit 4dfe97ec246b7ebd2f7b4af378817abf436cf102
+Subproject commit 08ec62bbd349c042a40f959f242db7a54412e916
-Subproject commit 142cbeb62ffabf1dd9c1414d8dd76f93bcbed0c2
+Subproject commit 9c5cc7f051a0bba2e41341a5baebfc4d2c2133ef
-Subproject commit 9d196fb777776880b2f3c31602aa167394ae2f6b
+Subproject commit 1904c7d0682a878e2d25b4d49f3475d12fbb9cc6
..
.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
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.
.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
//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
}
pool.ReleaseConnection(tds);
+ Listener.Stop ();
//exit
}
}
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;
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 (),
};
}
- 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 {
};
}
- 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++) {
};
}
- 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) {
});
}
- 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 ()
<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
+++ /dev/null
-//
-// 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;
- }
- }
-}
-
+++ /dev/null
-//
-// 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;
- }
- }
-}
-
+++ /dev/null
-//
-// 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 ();
- }
-}
-
+++ /dev/null
-//
-// 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);
- }
- }
-}
-
+++ /dev/null
-//
-// 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;
- }
- }
- }
-}
-
+++ /dev/null
-//
-// 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];
- }
-}
-
+++ /dev/null
-//
-// 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 ();
- }
- }
-}
-
./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
+++ /dev/null
-#!/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
+++ /dev/null
-#!/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
-
-
-
+++ /dev/null
-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.
-
-
-
+++ /dev/null
-#!/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
+++ /dev/null
-#!/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
-
-
-
+++ /dev/null
-#!/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
-
-
-
+++ /dev/null
-#!/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
+++ /dev/null
-#!/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
-
-
-
+++ /dev/null
-#!/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
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 ()
$(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
$(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
$(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) \
$(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 \
../../../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
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" +
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" +
#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)
#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)
#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)
#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)
#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)
#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)
#define s390_sebr(c, r1, r2) S390_RRE(c, 0xb30b, r1, r2)
#define s390_sg(c, r, x, b, d) S390_RXY(c, 0xe309, r, x, b, d)
#define s390_sgf(c, r, x, b, d) S390_RXY(c, 0xe319, r, x, b, d)
+#define s390_sgh(c, r, x, b, d) S390_RXY(c, 0xe339, r, x, b, d)
#define s390_sgr(c, r1, r2) S390_RRE(c, 0xb909, r1, r2)
#define s390_sgrk(c, r1, r2, r3) S390_RRF_1(c, 0xb9e9, r1, r2, r3)
#define s390_sl(c, r, x, b, d) S390_RX(c, 0x5f, r, x, b, d)
#define s390_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)
#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)
#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)
#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
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 *
mono_gc_collect (int generation)
{
#ifndef DISABLE_PERFCOUNTERS
- mono_perfcounters->gc_induced++;
+ InterlockedIncrement (&mono_perfcounters->gc_induced);
#endif
GC_gcollect ();
}
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 ();
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);
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
}
#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);
/* 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);
*/
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;
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);
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;
mono_gc_free_fixed (domain);
#ifndef DISABLE_PERFCOUNTERS
- mono_perfcounters->loader_appdomains--;
+ InterlockedDecrement (&mono_perfcounters->loader_appdomains);
#endif
if (domain == mono_root_domain)
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);
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);
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;
}
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;
}
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)) {
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);
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);
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);
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;
}
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
static void dllmap_cleanup (void);
-
static void
global_loader_data_lock (void)
{
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);
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;
}
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);
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);
mono_image_unlock (img);
}
- signatures_size += mono_metadata_signature_size (signature);
+ InterlockedAdd (&signatures_size, mono_metadata_signature_size (signature));
}
/* Verify metadata consistency */
#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 */
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;
}
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;
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. */
mon->data = monitor_freelist;
monitor_freelist = mon;
#ifndef DISABLE_PERFCOUNTERS
- mono_perfcounters->gc_sync_blocks--;
+ InterlockedDecrement (&mono_perfcounters->gc_sync_blocks);
#endif
}
new_->data = NULL;
#ifndef DISABLE_PERFCOUNTERS
- mono_perfcounters->gc_sync_blocks++;
+ InterlockedIncrement (&mono_perfcounters->gc_sync_blocks);
#endif
return new_;
}
/* 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 */
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 ();
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) {
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)
#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 {
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;
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;
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;
}
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;
}
#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);
/* 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);
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);
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;
#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
}
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));
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));
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
$(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 \
aot-compiler.h \
aot-compiler.c \
aot-runtime.c \
+ aot-runtime-wasm.c \
graph.c \
mini-codegen.c \
mini-exceptions.c \
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
# 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
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 \
--- /dev/null
+/**
+ * \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
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.
return mono_create_ftnptr_malloc ((guint8 *)load_function_full (amodule, name, out_tinfo));
}
+#endif
+
gpointer
mono_aot_get_trampoline (const char *name)
}
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;
}
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
--- /dev/null
+#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
# 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 = ();
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|";
int i8_align = mono_arm_i8_align ();
#endif
+#ifdef TARGET_WASM
+ margs->sig = sig;
+#endif
+
if (sig->hasthis)
margs->ilen++;
#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;
double *fargs;
gpointer *retval;
size_t is_float_ret;
+#ifdef TARGET_WASM
+ MonoMethodSignature *sig;
+#endif
};
typedef struct _InterpMethodArguments InterpMethodArguments;
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
#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;
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)
#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);
#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
if (ei->flags == MONO_EXCEPTION_CLAUSE_FILTER) {
#ifndef DISABLE_PERFCOUNTERS
- mono_perfcounters->exceptions_filters++;
+ InterlockedIncrement (&mono_perfcounters->exceptions_filters);
#endif
#ifndef MONO_CROSS_COMPILE
}
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;
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) {
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);
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);
#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"
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)
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);
}
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);
}
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);
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);
}
/*
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 ();
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;
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));
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;
/* 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;
}
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;
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;
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);
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);
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: {
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: {
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;
--- /dev/null
+#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;
+
+}
--- /dev/null
+#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__ */
/* 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;
*/
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__ */
# 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;
--- /dev/null
+#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
#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
#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,
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;
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*
delegate-async-exit.cs \
delegate-delegate-exit.cs \
delegate-exit.cs \
+ delegate-disposed-hashcode.cs \
finalizer-abort.cs \
finalizer-exception.cs \
finalizer-exit.cs \
--- /dev/null
+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 ();
+ }
+ }
+}
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;
}
#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"
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
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
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
: "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;
}
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)
#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
#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)
{
{
}
+//----
+
+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
#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)
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)
*dest = val;
}
+MONO_UNLOCKED_ATTRS
+void
+UnlockedWrite64 (gint64 *dest, gint64 val)
+{
+ *dest = val;
+}
+
MONO_UNLOCKED_ATTRS
gint32
UnlockedRead (gint32 *src)
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)
+++ /dev/null
-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>
-
- <!--
--- /dev/null
+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 -> ()
--- /dev/null
+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>
+
+ <!--