# Mono Code Owners File
#
-# GitHub uses this file to determine who to ping for reviews on pull requests.
-# If you're the primary maintainer of an area of Mono and you don't mind
-# reviewing pull requests, please add yourself to this file. You may want to
-# avoid adding entries for commonly changed or automatically generated files
-# (e.g. stuff in external/, or various generated *.csproj files) so as not to
-# get spammed with emails.
+# GitHub uses this file to determine who to assign for reviews
+# on pull requests. Please keep this file alphabetically sorted.
#
-# Note that if two patterns match a file, the later pattern takes precedence.
-#
-# Please keep this file alphabetically sorted.
-#
-# Reference:
+# References:
#
# https://github.com/blog/2392-introducing-code-owners
# https://help.github.com/articles/about-codeowners
+
+# These owners will be the default owners for everything in the repo.
+* @luhenry @marek-safar
+
+# Order is important. The last matching pattern has the most precedence.
+
/acceptance-tests @akoeplinger
/acceptance-tests/profiler-stress* @alexrp
+/data @marek-safar @akoeplinger
+/data/gdb @vargaz
+/data/lldb @lewurm @vargaz
+
/docs @luhenry @marek-safar
/docs/sources/mono-api-profiler.html @alexrp
+/external @marek-safar @luhenry
+/external/binary-reference-assemblies @marek-safar @akoeplinger
+/external/bockbuild @akoeplinger @alexischr
+/external/boringssl @baulig
+/external/nuget-buildtasks @radical @akoeplinger
+
+/libgc @BrzVlad @vargaz
+
+/llvm @vargaz
+
/man @marek-safar @miguel
/man/mprof-report.1 @alexrp
+/mcs @marek-safar
+
/mcs/build @marek-safar @akoeplinger
/mcs/class @marek-safar @akoeplinger
/mcs/class/System/Mono.Btls @baulig
/mcs/class/System/Mono.Net.Security @baulig
/mcs/class/System/Mono.Security.Interface @baulig
-/mcs/class/System.Data @egorbo
+/mcs/class/System.Data* @egorbo
/mcs/errors @marek-safar
+/mcs/ilasm @marek-safar
+/mcs/jay @marek-safar
/mcs/mcs @marek-safar
/mcs/tests @marek-safar
+/mcs/tools @marek-safar @akoeplinger
+/mono @luhenry
+
+/mono/btls @baulig
+/mono/dis @lambdageek @vargaz
/mono/eglib @kumpera @vargaz @luhenry
/mono/metadata @vargaz @kumpera
/mono/mini/*type-check* @lewurm
/mono/mini/interp/* @lewurm
/mono/mini/*profiler* @alexrp
+/mono/mini/debugger-agent.c @DavidKarlas
/mono/profiler @alexrp @kumpera
/mono/utils/mono-mem* @alexrp
/mono/utils/mono-threads* @luhenry @kumpera
+/msvc @ntherning
/msvc/*profiler* @alexrp
/msvc/scripts @akoeplinger
/packaging/ @alexischr @akoeplinger
/packaging/MacSDK/msbuild.py @radical @akoeplinger
+/runtime @akoeplinger @marek-safar
+
+/samples @luhenry
/samples/profiler @alexrp
/samples/size @alexrp
/scripts/ci @akoeplinger
/scripts/ci/run-test-profiler-stress-tests.sh @alexrp
+/support @luhenry @vargaz
+
/tools @kumpera
/tools/checker @tritao
/tools/crash-bisector @kumpera
endif
-win32getdeps:
- wget http://www.go-mono.com/archive/pkgconfig-0.11-20020310.zip
- wget http://www.go-mono.com/archive/glib-2.0.4-20020703.zip
- wget http://www.go-mono.com/archive/glib-dev-2.0.4-20020703.zip
- wget http://www.go-mono.com/archive/libiconv-1.7.zip
- wget http://www.go-mono.com/archive/libiconv-dev-1.7.zip
- wget http://www.go-mono.com/archive/libintl-0.10.40-20020101.zip
- unzip -n -d / pkgconfig-0.11-20020310.zip
- unzip -n -d / glib-2.0.4-20020703.zip
- unzip -n -d / glib-dev-2.0.4-20020703.zip
- unzip -n -d / libiconv-1.7.zip
- unzip -n -d / libiconv-dev-1.7.zip
- unzip -n -d / libintl-0.10.40-20020101.zip
-
-win32setup:
- makensis /DMILESTONE=$(VERSION) /DSOURCE_INSTALL_DIR=$(SOURCE_INSTALL_DIR) /DBUILDNUM=$(BUILDNUM) monowiz.win32.nsi
-
update-csproj:
-rm msvc/scripts/order
-rm msvc/scripts/order.xml
# This can be reset to 0 when Mono's version number is bumped
# since it's part of the corlib version (the prefix '1' in the full
# version number is to ensure the number isn't treated as octal in C)
-MONO_CORLIB_COUNTER=0
-MONO_CORLIB_VERSION=`printf "1%02d%02d%02d%03d" $MONO_VERSION_MAJOR $MONO_VERSION_MINOR $MONO_VERSION_BUILD $MONO_CORLIB_COUNTER`
+MONO_CORLIB_COUNTER=1
+MONO_CORLIB_VERSION=`printf "1%02d%02d%02d%03d" $MONO_VERSION_MAJOR $MONO_VERSION_MINOR 0 $MONO_CORLIB_COUNTER`
AC_DEFINE_UNQUOTED(MONO_CORLIB_VERSION,$MONO_CORLIB_VERSION,[Version of the corlib-runtime interface])
AC_SUBST(MONO_CORLIB_VERSION)
AC_CHECK_FUNCS(getpwuid_r)
fi
+ AC_FUNC_STRERROR_R()
+
dnl ****************************************************************
dnl *** Check for sched_setaffinity from glibc versions before ***
dnl *** 2.3.4. The older versions of the function only take 2 ***
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 bf03a7c5cf6b692fa662f1568ad66de35166b8ea
+Subproject commit 08ec62bbd349c042a40f959f242db7a54412e916
-Subproject commit 142cbeb62ffabf1dd9c1414d8dd76f93bcbed0c2
+Subproject commit 9c5cc7f051a0bba2e41341a5baebfc4d2c2133ef
-Subproject commit 14e17dfbebf5651b5ce70c7fb317e388f8a3a271
+Subproject commit bc11f472954694ebd92ae4956f110c1036a7c2e0
-Subproject commit 305e0f60533d164676099c918fa4dd09c718017b
+Subproject commit 99354bf5c13b8055209cb082cddc50c8047ab088
-Subproject commit 690603bea98aae69fca9a65130d88591bc6cabee
+Subproject commit 764656cdafdb3acd25df8cb52a4e0ea14760fccd
-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
Embeds the dynamic library file pointed to by `PATH' and optionally
give it the name `LIB' into the bundled executable. This is used to
ship native library dependencies that are unpacked at startup and
-loaded from the runtime.
+loaded from the runtime. Multiple libraries should be specified in
+dependency order, where later ones on the command line depend on
+earlier ones.
.TP
.I "--lists-targets"
Lists all of the available local cross compilation targets available
For a sample of how to write your own custom profiler look in the
Mono source tree for in the samples/profiler.c.
.SH CODE COVERAGE
-Mono ships with a code coverage module. This module is activated by
-using the Mono --profile=cov option. The format is:
-\fB--profile=cov[:assembly-name[/namespace]] test-suite.exe\fR
-.PP
-By default code coverage will default to all the assemblies loaded,
-you can limit this by specifying the assembly name, for example to
-perform code coverage in the routines of your program use, for example
-the following command line limits the code coverage to routines in the
-"demo" assembly:
-.nf
-
- mono --profile=cov:demo demo.exe
-
-.fi
-.PP
-Notice that the
-.I assembly-name
-does not include the extension.
-.PP
-You can further restrict the code coverage output by specifying a
-namespace:
-.nf
-
- mono --profile=cov:demo/My.Utilities demo.exe
-
-.fi
-.PP
-Which will only perform code coverage in the given assembly and
-namespace.
-.PP
-Typical output looks like this:
-.nf
-
- Not covered: Class:.ctor ()
- Not covered: Class:A ()
- Not covered: Driver:.ctor ()
- Not covered: Driver:method ()
- Partial coverage: Driver:Main ()
- offset 0x000a
-
-.fi
-.PP
-The offsets displayed are IL offsets.
-.PP
-A more powerful coverage tool is available in the module `monocov'.
-See the monocov(1) man page for details.
+Mono ships with a code coverage module in the \f[I]log\f[] profiler.
+Check the `coverage' option on the mprof-report(1) page for more details.
.SH AOT PROFILING
You can improve startup performance by using the AOT profiler.
.PP
http://www.mono-project.com
.SH SEE ALSO
.PP
-certmgr(1), cert-sync(1), csharp(1), gacutil(1), mcs(1), mdb(1), monocov(1), monodis(1),
+certmgr(1), cert-sync(1), csharp(1), gacutil(1), mcs(1), mdb(1), monodis(1),
mono-config(5), mprof-report(1), pdb2mdb(1), xsp(1), mod_mono(8).
.PP
For more information on AOT:
xunit-test-local: $(xunit_test_lib)
run-xunit-test-local: run-xunit-test-lib
-# ln -s is a HACK for xunit runner to require xunit.execution.desktop.dll file in local folder on .net only
+# cp -rf is a HACK for xunit runner to require xunit.execution.desktop.dll file in local folder on .net only
run-xunit-test-lib: xunit-test-local
- @ln -fs $(XTEST_HARNESS_PATH)/xunit.execution.desktop.dll xunit.execution.desktop.dll
+ @cp -rf $(XTEST_HARNESS_PATH)/xunit.execution.desktop.dll xunit.execution.desktop.dll
ok=:; \
PATH="$(TEST_RUNTIME_WRAPPERS_PATH):$(PATH)" $(TEST_RUNTIME) $(RUNTIME_FLAGS) $(AOT_RUN_FLAGS) $(XTEST_HARNESS) $(xunit_test_lib) $(XTEST_HARNESS_FLAGS) $(XTEST_TRAIT) || ok=false; \
$$ok
p.Precision = (p.Precision !=0 ? p.Precision : (byte) Precision);
parms.Append (p.Prepare ());
- if (p.Direction == TdsParameterDirection.Output)
+ if (p.Direction == TdsParameterDirection.Output || p.Direction == TdsParameterDirection.InputOutput)
parms.Append (" output");
}
return parms.ToString ();
//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
}
}
leave end
} filter {
+ castclass [mscorlib]System.Exception
call int32 class ExceptionFilterTest::Filter([mscorlib]System.Exception)
endfilter
} {
+ castclass [mscorlib]System.Exception
call void class ExceptionFilterTest::Handler([mscorlib]System.Exception)
leave end
}
Assert.AreEqual (0, frames [0].Location.ILOffset);
Assert.AreEqual (test_method.Name, frames [1].Location.Method.Name);
- Assert.AreEqual (37, frames [1].Location.LineNumber);
- Assert.AreEqual (0x0b, frames [1].Location.ILOffset);
+ Assert.AreEqual (38, frames [1].Location.LineNumber);
+ Assert.AreEqual (0x10, frames [1].Location.ILOffset);
Assert.AreEqual (test_method.Name, frames [2].Location.Method.Name);
Assert.AreEqual (33, frames [2].Location.LineNumber);
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 ();
- }
-}
-
X509CertificateCollection certificates, bool wantsChain, ref X509Chain chain,
ref MonoSslPolicyErrors errors, ref int status11);
#endregion
+
+#region Misc
+
+ internal abstract bool SupportsCleanShutdown {
+ get;
+ }
+
+#endregion
+
}
}
get; set;
}
+ /*
+ * This is only supported if MonoTlsProvider.SupportsCleanShutdown is true.
+ */
+ internal bool SendCloseNotify {
+ get; set;
+ }
+
/*
* If you set this here, then it will override 'ServicePointManager.SecurityProtocol'.
*/
EnabledProtocols = other.EnabledProtocols;
EnabledCiphers = other.EnabledCiphers;
CertificateValidationTime = other.CertificateValidationTime;
+ SendCloseNotify = other.SendCloseNotify;
if (other.TrustAnchors != null)
TrustAnchors = new X509CertificateCollection (other.TrustAnchors);
if (other.CertificateSearchPaths != null) {
+++ /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
/// </summary>
public enum ImplAttr { IL, Native, Runtime = 0x03, Unmanaged = 0x04,
ForwardRef = 0x10, PreserveSig = 0x0080, InternalCall = 0x1000,
- Synchronised = 0x0020, Synchronized = 0x0020, NoInLining = 0x0008, NoOptimization = 0x0040, Optil = 0x0002}
+ Synchronised = 0x0020, Synchronized = 0x0020, NoInLining = 0x0008, NoOptimization = 0x0040, Optil = 0x0002,
+ AggressiveInlining = 0x0100
+ }
/// <summary>
/// Storage location for initial field data
public class ClassDef : Class {
Class superType;
+ bool setSuperType;
ArrayList fields = new ArrayList();
ArrayList methods = new ArrayList();
ArrayList events;
MetaData md) : base(nsName, name, md)
{
metaData = md;
- if (! ((nsName == "" && name == "<Module>") || (nsName == "System" && name == "Object")) ) {
- superType = metaData.mscorlib.GetSpecialSystemClass(PrimitiveType.Object);
- }
flags = (uint)attrSet;
tabIx = MDTable.TypeDef;
}
internal void SetSuper(Class sClass)
{
superType = sClass;
+ setSuperType = true;
if (! (sClass is GenericTypeInst))
typeIndexChecked = false;
}
else
superType = metaData.mscorlib.ValueType();
+ setSuperType = true;
typeIndex = PrimitiveType.ValueType.GetTypeIndex ();
}
public void SpecialNoSuper()
{
- superType = null;
+ setSuperType = true;
}
/// <summary>
internal sealed override void BuildTables(MetaData md)
{
- if (done) return;
- if ((flags & (uint)TypeAttr.Interface) != 0) { superType = null; }
+ if (done)
+ return;
+
+ if ((flags & (uint)TypeAttr.Interface) != 0) {
+ superType = null;
+ setSuperType = true;
+ }
// Console.WriteLine("Building tables for " + name);
if (layout != null) md.AddToTable(MDTable.ClassLayout,layout);
// Console.WriteLine("adding methods " + methods.Count);
((Property)properties[0]).Row,MDTable.Property));
}
// Console.WriteLine("End of building tables");
+
+ if (!setSuperType)
+ superType = metaData.mscorlib.GetSpecialSystemClass(PrimitiveType.Object);
+
done = true;
}
private byte heapSizes = 0;
MetaDataElement entryPoint;
BinaryWriter output;
- public MSCorLib mscorlib;
+ MSCorLib _mscorlib;
private TypeSpec[] systemTypeSpecs = new TypeSpec[PrimitiveType.NumSystemTypes];
long mdStart;
private ArrayList cattr_list;
for (int i=0; i < lgeCIx.Length; i++) {
lgeCIx[i] = false;
}
- mscorlib = new MSCorLib(this);
}
+ public MSCorLib mscorlib {
+ get {
+ return _mscorlib ?? (_mscorlib = new MSCorLib (this));
+ }
+ }
+
+
internal TypeSpec GetPrimitiveTypeSpec(int ix)
{
return systemTypeSpecs[ix];
+++ /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
-
-
-
+../../test-helpers/NetworkHelpers.cs
System.Net.Http/DelegatingHandlerTest.cs
System.Net.Http/ByteArrayContentTest.cs
System.Net.Http/FormUrlEncodedContentTest.cs
using System.Linq;
using System.IO;
+using MonoTests.Helpers;
+
namespace MonoTests.System.Net.Http
{
[TestFixture]
const int WaitTimeout = 5000;
- string TestHost, LocalServer;
- int port;
-
- [SetUp]
- public void SetupFixture ()
- {
- if (Environment.OSVersion.Platform == PlatformID.Win32NT) {
- port = 810;
- } else {
- port = 8810;
- }
-
- TestHost = "localhost:" + port;
- LocalServer = string.Format ("http://{0}/", TestHost);
- }
-
[Test]
public void Ctor_Default ()
{
public void Send_Complete_Default ()
{
bool? failed = null;
+ var port = NetworkHelpers.FindFreePort ();
var listener = CreateListener (l => {
try {
var request = l.Request;
Assert.IsNull (request.ContentType, "#3");
Assert.AreEqual (0, request.Cookies.Count, "#4");
Assert.IsFalse (request.HasEntityBody, "#5");
- Assert.AreEqual (TestHost, request.Headers["Host"], "#6b");
+ Assert.AreEqual ($"localhost:{port}", request.Headers["Host"], "#6b");
Assert.AreEqual ("GET", request.HttpMethod, "#7");
Assert.IsFalse (request.IsAuthenticated, "#8");
Assert.IsTrue (request.IsLocal, "#9");
} catch {
failed = true;
}
- });
+ }, port);
try {
var client = new HttpClient ();
- var request = new HttpRequestMessage (HttpMethod.Get, LocalServer);
+ var request = new HttpRequestMessage (HttpMethod.Get, $"http://localhost:{port}/");
var response = client.SendAsync (request, HttpCompletionOption.ResponseHeadersRead).Result;
Assert.AreEqual ("", response.Content.ReadAsStringAsync ().Result, "#100");
{
bool? failed = null;
+ var port = NetworkHelpers.FindFreePort ();
var listener = CreateListener (l => {
try {
var request = l.Request;
Assert.AreEqual (0, request.Cookies.Count, "#4");
Assert.IsFalse (request.HasEntityBody, "#5");
Assert.AreEqual (1, request.Headers.Count, "#6");
- Assert.AreEqual (TestHost, request.Headers["Host"], "#6a");
+ Assert.AreEqual ($"localhost:{port}", request.Headers["Host"], "#6a");
Assert.AreEqual ("GET", request.HttpMethod, "#7");
Assert.IsFalse (request.IsAuthenticated, "#8");
Assert.IsTrue (request.IsLocal, "#9");
} catch {
failed = true;
}
- });
+ }, port);
try {
var client = new HttpClient ();
- var request = new HttpRequestMessage (HttpMethod.Get, LocalServer);
+ var request = new HttpRequestMessage (HttpMethod.Get, $"http://localhost:{port}/");
request.Version = HttpVersion.Version10;
var response = client.SendAsync (request, HttpCompletionOption.ResponseHeadersRead).Result;
{
bool? failed = null;
+ var port = NetworkHelpers.FindFreePort ();
var listener = CreateListener (l => {
var request = l.Request;
Assert.AreEqual (new Cookie ("mycookie", "vv"), request.Cookies[0], "#4a");
Assert.IsFalse (request.HasEntityBody, "#5");
Assert.AreEqual (4, request.Headers.Count, "#6");
- Assert.AreEqual (TestHost, request.Headers["Host"], "#6a");
+ Assert.AreEqual ($"localhost:{port}", request.Headers["Host"], "#6a");
Assert.AreEqual ("gzip", request.Headers["Accept-Encoding"], "#6b");
Assert.AreEqual ("mycookie=vv", request.Headers["Cookie"], "#6c");
Assert.AreEqual ("GET", request.HttpMethod, "#7");
} catch {
failed = true;
}
- });
+ }, port);
try {
var chandler = new HttpClientHandler ();
chandler.MaxAutomaticRedirections = 33;
chandler.MaxRequestContentBufferSize = 5555;
chandler.PreAuthenticate = true;
- chandler.CookieContainer.Add (new Uri (LocalServer), new Cookie ( "mycookie", "vv"));
+ chandler.CookieContainer.Add (new Uri ($"http://localhost:{port}/"), new Cookie ( "mycookie", "vv"));
chandler.UseCookies = true;
chandler.UseDefaultCredentials = true;
chandler.Proxy = new WebProxy ("ee");
chandler.UseProxy = true;
var client = new HttpClient (chandler);
- var request = new HttpRequestMessage (HttpMethod.Get, LocalServer);
+ var request = new HttpRequestMessage (HttpMethod.Get, $"http://localhost:{port}/");
request.Version = HttpVersion.Version10;
request.Headers.Add ("Keep-Alive", "false");
var response = client.SendAsync (request, HttpCompletionOption.ResponseHeadersRead).Result;
{
bool? failed = null;
+ var port = NetworkHelpers.FindFreePort ();
var listener = CreateListener (l => {
var request = l.Request;
try {
} catch {
failed = true;
}
- });
+ }, port);
try {
var client = new HttpClient ();
- var request = new HttpRequestMessage (HttpMethod.Get, LocalServer);
+ var request = new HttpRequestMessage (HttpMethod.Get, $"http://localhost:{port}/");
Assert.IsTrue (request.Headers.TryAddWithoutValidation ("aa", "vv"), "#0");
var response = client.SendAsync (request, HttpCompletionOption.ResponseHeadersRead).Result;
{
bool? failed = null;
+ var port = NetworkHelpers.FindFreePort ();
var listener = CreateListener (l => {
var request = l.Request;
} catch {
failed = true;
}
- });
+ }, port);
try {
var client = new HttpClient ();
client.DefaultRequestHeaders.Add("User-Agent", "MLK Android Phone 1.1.9");
- var request = new HttpRequestMessage (HttpMethod.Get, LocalServer);
+ var request = new HttpRequestMessage (HttpMethod.Get, $"http://localhost:{port}/");
var response = client.SendAsync (request, HttpCompletionOption.ResponseHeadersRead).Result;
public void Send_Complete_CustomHeaders_Host ()
{
bool? failed = null;
+ var port = NetworkHelpers.FindFreePort ();
var listener = CreateListener (l => {
var request = l.Request;
} catch {
failed = true;
}
- });
+ }, port);
try {
var client = new HttpClient ();
client.DefaultRequestHeaders.Add("Host", "customhost");
- var request = new HttpRequestMessage (HttpMethod.Get, LocalServer);
+ var request = new HttpRequestMessage (HttpMethod.Get, $"http://localhost:{port}/");
var response = client.SendAsync (request, HttpCompletionOption.ResponseHeadersRead).Result;
{
bool? failed = null;
+ var port = NetworkHelpers.FindFreePort ();
var listener = CreateListener (l => {
var request = l.Request;
try {
- Assert.AreEqual (1, request.Headers.Count, "#1");
+ Assert.AreEqual (2, request.Headers.Count, "#1");
+ Assert.AreEqual ("keep-alive", request.Headers ["Connection"], "#2");
failed = false;
- } catch {
+ } catch (Exception ex){
+ Console.WriteLine (ex);
+ Console.WriteLine (String.Join ("#", l.Request.Headers.AllKeys));
failed = true;
}
- });
+ }, port);
try {
var client = new HttpClient ();
client.DefaultRequestHeaders.TransferEncodingChunked = true;
- client.GetAsync (LocalServer).Wait ();
+ client.GetAsync ($"http://localhost:{port}/").Wait ();
Assert.AreEqual (false, failed, "#102");
} finally {
{
bool? failed = null;
+ var port = NetworkHelpers.FindFreePort ();
var listener = CreateListener (l => {
failed = true;
- });
+ }, port);
try {
var client = new HttpClient ();
client.DefaultRequestHeaders.TransferEncoding.Add (new TransferCodingHeaderValue ("chunked2"));
- var request = new HttpRequestMessage (HttpMethod.Get, LocalServer);
+ var request = new HttpRequestMessage (HttpMethod.Get, $"http://localhost:{port}/");
try {
client.SendAsync (request, HttpCompletionOption.ResponseHeadersRead).Wait ();
#endif
public void Send_Complete_Content ()
{
+ var port = NetworkHelpers.FindFreePort ();
var listener = CreateListener (l => {
var request = l.Request;
l.Response.OutputStream.WriteByte (55);
l.Response.OutputStream.WriteByte (75);
- });
+ }, port);
try {
var client = new HttpClient ();
- var request = new HttpRequestMessage (HttpMethod.Get, LocalServer);
+ var request = new HttpRequestMessage (HttpMethod.Get, $"http://localhost:{port}/");
Assert.IsTrue (request.Headers.TryAddWithoutValidation ("aa", "vv"), "#0");
var response = client.SendAsync (request, HttpCompletionOption.ResponseHeadersRead).Result;
#endif
public void Send_Complete_Content_MaxResponseContentBufferSize ()
{
+ var port = NetworkHelpers.FindFreePort ();
var listener = CreateListener (l => {
var request = l.Request;
var b = new byte[4000];
l.Response.OutputStream.Write (b, 0, b.Length);
- });
+ }, port);
try {
var client = new HttpClient ();
client.MaxResponseContentBufferSize = 1000;
- var request = new HttpRequestMessage (HttpMethod.Get, LocalServer);
+ var request = new HttpRequestMessage (HttpMethod.Get, $"http://localhost:{port}/");
var response = client.SendAsync (request, HttpCompletionOption.ResponseHeadersRead).Result;
Assert.AreEqual (4000, response.Content.ReadAsStringAsync ().Result.Length, "#100");
#endif
public void Send_Complete_Content_MaxResponseContentBufferSize_Error ()
{
+ var port = NetworkHelpers.FindFreePort ();
var listener = CreateListener (l => {
var request = l.Request;
var b = new byte[4000];
l.Response.OutputStream.Write (b, 0, b.Length);
- });
+ }, port);
try {
var client = new HttpClient ();
client.MaxResponseContentBufferSize = 1000;
- var request = new HttpRequestMessage (HttpMethod.Get, LocalServer);
+ var request = new HttpRequestMessage (HttpMethod.Get, $"http://localhost:{port}/");
try {
client.SendAsync (request, HttpCompletionOption.ResponseContentRead).Wait (WaitTimeout);
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
- public void Send_Complete_NoContent ()
+ public void Send_Complete_NoContent_Post ()
+ {
+ Send_Complete_NoContent (HttpMethod.Post);
+ }
+
+ [Test]
+#if FEATURE_NO_BSD_SOCKETS
+ [ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
+ public void Send_Complete_NoContent_Put ()
{
- foreach (var method in new HttpMethod[] { HttpMethod.Post, HttpMethod.Put, HttpMethod.Delete }) {
- bool? failed = null;
- var listener = CreateListener (l => {
- try {
- var request = l.Request;
-
- Assert.AreEqual (2, request.Headers.Count, "#1");
- Assert.AreEqual ("0", request.Headers ["Content-Length"], "#1b");
- Assert.AreEqual (method.Method, request.HttpMethod, "#2");
- failed = false;
- } catch {
- failed = true;
- }
- });
+ Send_Complete_NoContent (HttpMethod.Put);
+ }
+
+ [Test]
+#if FEATURE_NO_BSD_SOCKETS
+ [ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
+ public void Send_Complete_NoContent_Delete ()
+ {
+ Send_Complete_NoContent (HttpMethod.Delete);
+ }
+ void Send_Complete_NoContent (HttpMethod method)
+ {
+ bool? failed = null;
+ var port = NetworkHelpers.FindFreePort ();
+ var listener = CreateListener (l => {
try {
- var client = new HttpClient ();
- var request = new HttpRequestMessage (method, LocalServer);
- var response = client.SendAsync (request, HttpCompletionOption.ResponseHeadersRead).Result;
+ var request = l.Request;
- Assert.AreEqual ("", response.Content.ReadAsStringAsync ().Result, "#100");
- Assert.AreEqual (HttpStatusCode.OK, response.StatusCode, "#101");
- Assert.AreEqual (false, failed, "#102");
- } finally {
- listener.Close ();
+ Assert.AreEqual (3, request.Headers.Count, "#1");
+ Assert.AreEqual ("0", request.Headers ["Content-Length"], "#1b");
+ Assert.AreEqual ("keep-alive", request.Headers ["Connection"], "#1c");
+ Assert.AreEqual (method.Method, request.HttpMethod, "#2");
+ failed = false;
+ } catch (Exception ex){
+ Console.WriteLine (ex);
+ Console.WriteLine (String.Join ("#", l.Request.Headers.AllKeys));
+
+ failed = true;
}
+ }, port);
+
+ try {
+ var client = new HttpClient ();
+ var request = new HttpRequestMessage (method, $"http://localhost:{port}/");
+ var response = client.SendAsync (request, HttpCompletionOption.ResponseHeadersRead).Result;
+
+ Assert.AreEqual ("", response.Content.ReadAsStringAsync ().Result, "#100");
+ Assert.AreEqual (HttpStatusCode.OK, response.StatusCode, "#101");
+ Assert.AreEqual (false, failed, "#102");
+ } finally {
+ listener.Close ();
}
}
#endif
public void Send_Complete_Error ()
{
+ var port = NetworkHelpers.FindFreePort ();
var listener = CreateListener (l => {
var response = l.Response;
response.StatusCode = 500;
- });
+ }, port);
try {
var client = new HttpClient ();
- var request = new HttpRequestMessage (HttpMethod.Get, LocalServer);
+ var request = new HttpRequestMessage (HttpMethod.Get, $"http://localhost:{port}/");
var response = client.SendAsync (request, HttpCompletionOption.ResponseHeadersRead).Result;
Assert.AreEqual ("", response.Content.ReadAsStringAsync ().Result, "#100");
#endif
public void Send_Content_Get ()
{
+ var port = NetworkHelpers.FindFreePort ();
var listener = CreateListener (l => {
var request = l.Request;
l.Response.OutputStream.WriteByte (72);
- });
+ }, port);
try {
var client = new HttpClient ();
- var r = new HttpRequestMessage (HttpMethod.Get, LocalServer);
+ var r = new HttpRequestMessage (HttpMethod.Get, $"http://localhost:{port}/");
var response = client.SendAsync (r).Result;
Assert.AreEqual ("H", response.Content.ReadAsStringAsync ().Result);
#endif
public void Send_Content_BomEncoding ()
{
+ var port = NetworkHelpers.FindFreePort ();
var listener = CreateListener (l => {
var request = l.Request;
str.WriteByte (0xBB);
str.WriteByte (0xBF);
str.WriteByte (71);
- });
+ }, port);
try {
var client = new HttpClient ();
- var r = new HttpRequestMessage (HttpMethod.Get, LocalServer);
+ var r = new HttpRequestMessage (HttpMethod.Get, $"http://localhost:{port}/");
var response = client.SendAsync (r).Result;
Assert.AreEqual ("G", response.Content.ReadAsStringAsync ().Result);
public void Send_Content_Put ()
{
bool passed = false;
+ var port = NetworkHelpers.FindFreePort ();
var listener = CreateListener (l => {
var request = l.Request;
passed = 7 == request.ContentLength64;
passed &= request.ContentType == "text/plain; charset=utf-8";
passed &= request.InputStream.ReadByte () == 'm';
- });
+ }, port);
try {
var client = new HttpClient ();
- var r = new HttpRequestMessage (HttpMethod.Put, LocalServer);
+ var r = new HttpRequestMessage (HttpMethod.Put, $"http://localhost:{port}/");
r.Content = new StringContent ("my text");
var response = client.SendAsync (r).Result;
public void Send_Content_Put_CustomStream ()
{
bool passed = false;
+ var port = NetworkHelpers.FindFreePort ();
var listener = CreateListener (l => {
var request = l.Request;
passed = 44 == request.ContentLength64;
passed &= request.ContentType == null;
- });
+ }, port);
try {
var client = new HttpClient ();
- var r = new HttpRequestMessage (HttpMethod.Put, LocalServer);
+ var r = new HttpRequestMessage (HttpMethod.Put, $"http://localhost:{port}/");
r.Content = new StreamContent (new CustomStream ());
var response = client.SendAsync (r).Result;
public void Post_TransferEncodingChunked ()
{
bool? failed = null;
+ var port = NetworkHelpers.FindFreePort ();
var listener = CreateListener (l => {
try {
var request = l.Request;
Assert.IsNull (request.ContentType, "#3");
Assert.AreEqual (0, request.Cookies.Count, "#4");
Assert.IsTrue (request.HasEntityBody, "#5");
- Assert.AreEqual (TestHost, request.Headers ["Host"], "#6b");
+ Assert.AreEqual ($"localhost:{port}", request.Headers ["Host"], "#6b");
Assert.AreEqual ("POST", request.HttpMethod, "#7");
Assert.IsFalse (request.IsAuthenticated, "#8");
Assert.IsTrue (request.IsLocal, "#9");
failed = true;
Console.WriteLine (e);
}
- });
+ }, port);
try {
var client = new HttpClient ();
var imageContent = new StreamContent (new MemoryStream ());
- var response = client.PostAsync (LocalServer, imageContent).Result;
+ var response = client.PostAsync ($"http://localhost:{port}/", imageContent).Result;
Assert.AreEqual(HttpStatusCode.OK, response.StatusCode, "#101");
Assert.AreEqual(false, failed, "#102");
public void Post_StreamCaching ()
{
bool? failed = null;
+ var port = NetworkHelpers.FindFreePort ();
var listener = CreateListener (l => {
try {
var request = l.Request;
Assert.IsNull (request.ContentType, "#3");
Assert.AreEqual (0, request.Cookies.Count, "#4");
Assert.IsFalse (request.HasEntityBody, "#5");
- Assert.AreEqual (TestHost, request.Headers ["Host"], "#6b");
+ Assert.AreEqual ($"localhost:{port}", request.Headers ["Host"], "#6b");
Assert.AreEqual ("POST", request.HttpMethod, "#7");
Assert.IsFalse (request.IsAuthenticated, "#8");
Assert.IsTrue (request.IsLocal, "#9");
failed = true;
Console.WriteLine (e);
}
- });
+ }, port);
try {
var client = new HttpClient ();
var imageContent = new StreamContent (new MemoryStream ());
- var response = client.PostAsync (LocalServer, imageContent).Result;
+ var response = client.PostAsync ($"http://localhost:{port}/", imageContent).Result;
Assert.AreEqual(HttpStatusCode.OK, response.StatusCode, "#101");
Assert.AreEqual(false, failed, "#102");
response.OutputStream.WriteByte (0x6f);
};
- var listener = CreateListener (context); // creates a default request handler
+ var port = NetworkHelpers.FindFreePort ();
+ var listener = CreateListener (context, port); // creates a default request handler
AddListenerContext (listener, context); // add another request handler for the second request
try {
var client = new HttpClient ();
- var t1 = client.GetStringAsync (LocalServer);
- var t2 = client.GetStringAsync (LocalServer);
+ var t1 = client.GetStringAsync ($"http://localhost:{port}/");
+ var t2 = client.GetStringAsync ($"http://localhost:{port}/");
Assert.IsTrue (Task.WaitAll (new [] { t1, t2 }, WaitTimeout));
Assert.AreEqual ("hello", t1.Result, "#1");
Assert.AreEqual ("hello", t2.Result, "#2");
#endif
public void GetByteArray_ServerError ()
{
+ var port = NetworkHelpers.FindFreePort ();
var listener = CreateListener (l => {
var response = l.Response;
response.StatusCode = 500;
l.Response.OutputStream.WriteByte (72);
- });
+ }, port);
try {
var client = new HttpClient ();
try {
- client.GetByteArrayAsync (LocalServer).Wait (WaitTimeout);
+ client.GetByteArrayAsync ($"http://localhost:{port}/").Wait (WaitTimeout);
Assert.Fail ("#1");
} catch (AggregateException e) {
Assert.IsTrue (e.InnerException is HttpRequestException , "#2");
#endif
public void DisallowAutoRedirect ()
{
+ var port = NetworkHelpers.FindFreePort ();
var listener = CreateListener (l => {
var request = l.Request;
var response = l.Response;
response.StatusCode = (int)HttpStatusCode.Moved;
response.RedirectLocation = "http://xamarin.com/";
- });
+ }, port);
try {
var chandler = new HttpClientHandler ();
var client = new HttpClient (chandler);
try {
- client.GetStringAsync (LocalServer).Wait (WaitTimeout);
+ client.GetStringAsync ($"http://localhost:{port}/").Wait (WaitTimeout);
Assert.Fail ("#1");
} catch (AggregateException e) {
Assert.IsTrue (e.InnerException is HttpRequestException, "#2");
#endif
public void RequestUriAfterRedirect ()
{
+ var port = NetworkHelpers.FindFreePort ();
+ var redirectPort = NetworkHelpers.FindFreePort ();
+
var listener = CreateListener (l => {
var request = l.Request;
var response = l.Response;
response.StatusCode = (int)HttpStatusCode.Moved;
- response.RedirectLocation = "http://localhost:8811/";
- });
+ response.RedirectLocation = $"http://localhost:{redirectPort}/";
+ }, port);
var listener2 = CreateListener (l => {
var response = l.Response;
response.OutputStream.WriteByte (0x6c);
response.OutputStream.WriteByte (0x6c);
response.OutputStream.WriteByte (0x6f);
- }, 8811);
+ }, redirectPort);
try {
var chandler = new HttpClientHandler ();
chandler.AllowAutoRedirect = true;
var client = new HttpClient (chandler);
- var r = client.GetAsync (LocalServer);
+ var r = client.GetAsync ($"http://localhost:{port}/");
Assert.IsTrue (r.Wait (WaitTimeout), "#1");
var resp = r.Result;
- Assert.AreEqual ("http://localhost:8811/", resp.RequestMessage.RequestUri.AbsoluteUri, "#2");
+ Assert.AreEqual ($"http://localhost:{redirectPort}/", resp.RequestMessage.RequestUri.AbsoluteUri, "#2");
Assert.AreEqual ("hello", resp.Content.ReadAsStringAsync ().Result, "#3");
} finally {
listener.Abort ();
chandler.AllowAutoRedirect = true;
var client = new HttpClient (chandler, true);
+ var port = NetworkHelpers.FindFreePort ();
var listener = CreateListener (l => {
var response = l.Response;
response.StatusCode = 200;
response.OutputStream.WriteByte (55);
- });
+ }, port);
try {
- client.GetStringAsync (LocalServer).Wait (WaitTimeout);
+ client.GetStringAsync ($"http://localhost:{port}/").Wait (WaitTimeout);
try {
chandler.AllowAutoRedirect = false;
Assert.Fail ("#1");
ch.AllowAutoRedirect = false;
}
- HttpListener CreateListener (Action<HttpListenerContext> contextAssert)
- {
- return CreateListener (contextAssert, port);
- }
-
HttpListener CreateListener (Action<HttpListenerContext> contextAssert, int port)
{
var l = new HttpListener ();
../../test-helpers/NunitHelpers.cs
+../../test-helpers/NetworkHelpers.cs
System.Runtime.Remoting.Channels.Tcp/TcpChannelTest.cs
ServerObject.cs
ContextsTest.cs
using System.Runtime.Remoting.Channels.Http;
using NUnit.Framework;
+using MonoTests.Helpers;
+
namespace MonoTests.Remoting
{
[TestFixture]
AppDomain domain = BaseCallTest.CreateDomain ("testdomain_activation");
server = (ActivationServer) domain.CreateInstanceAndUnwrap(GetType().Assembly.FullName,"MonoTests.Remoting.ActivationServer");
- RemotingConfiguration.RegisterActivatedClientType (typeof(CaObject1), "tcp://localhost:9433");
- RemotingConfiguration.RegisterActivatedClientType (typeof(CaObject2), "http://localhost:9434");
- RemotingConfiguration.RegisterWellKnownClientType (typeof(WkObjectSinglecall1), "tcp://localhost:9433/wkoSingleCall1");
- RemotingConfiguration.RegisterWellKnownClientType (typeof(WkObjectSingleton1), "tcp://localhost:9433/wkoSingleton1");
- RemotingConfiguration.RegisterWellKnownClientType (typeof(WkObjectSinglecall2), "http://localhost:9434/wkoSingleCall2");
- RemotingConfiguration.RegisterWellKnownClientType (typeof(WkObjectSingleton2), "http://localhost:9434/wkoSingleton2");
+ var tcpUrlPrefix = $"tcp://localhost:{server.TcpPort}";
+ var httpUrlPrefix = $"http://localhost:{server.HttpPort}";
+ RemotingConfiguration.RegisterActivatedClientType (typeof(CaObject1), tcpUrlPrefix);
+ RemotingConfiguration.RegisterActivatedClientType (typeof(CaObject2), httpUrlPrefix);
+ RemotingConfiguration.RegisterWellKnownClientType (typeof(WkObjectSinglecall1), tcpUrlPrefix + "/wkoSingleCall1");
+ RemotingConfiguration.RegisterWellKnownClientType (typeof(WkObjectSingleton1), tcpUrlPrefix + "/wkoSingleton1");
+ RemotingConfiguration.RegisterWellKnownClientType (typeof(WkObjectSinglecall2), httpUrlPrefix + "/wkoSingleCall2");
+ RemotingConfiguration.RegisterWellKnownClientType (typeof(WkObjectSingleton2), httpUrlPrefix + "/wkoSingleton2");
}
catch (Exception ex)
{
public ActivationServer ()
{
- tcp = new TcpChannel (9433);
- http = new HttpChannel (9434);
+ TcpPort = NetworkHelpers.FindFreePort ();
+ HttpPort = NetworkHelpers.FindFreePort ();
+ tcp = new TcpChannel (TcpPort);
+ http = new HttpChannel (HttpPort);
ChannelServices.RegisterChannel (tcp);
ChannelServices.RegisterChannel (http);
ChannelServices.UnregisterChannel (tcp);
ChannelServices.UnregisterChannel (http);
}
+
+ public int TcpPort { get; private set; }
+ public int HttpPort { get; private set; }
}
public class BaseObject: MarshalByRefObject
using System.Threading;
using NUnit.Framework;
+using MonoTests.Helpers;
+
namespace MonoTests.Remoting
{
public interface INested
[Test]
public void TestTcpChannel ()
{
+ var port = NetworkHelpers.FindFreePort ();
IDictionary props = new Hashtable ();
props ["name"] = Guid.NewGuid ().ToString("N");
- props ["port"] = 18191;
+ props ["port"] = port;
TcpChannel chan = new TcpChannel (props, null, null);
ChannelServices.RegisterChannel (chan);
try {
Register <Server<object>> ("gentcptest.rem");
- RunTests (Connect <Server<object>> ("tcp://localhost:18191/gentcptest.rem"));
+ RunTests (Connect <Server<object>> ($"tcp://localhost:{port}/gentcptest.rem"));
} finally {
ChannelServices.UnregisterChannel (chan);
}
using System.Runtime.Remoting.Channels.Http;
using NUnit.Framework;
+using MonoTests.Helpers;
+
namespace MonoTests.Remoting.Http
{
//Test for Bug 324362 - SoapFormatter cannot deserialize the same MBR twice
[Test]
public void Main ()
{
- channel = new HttpChannel (3344);
+ var port = NetworkHelpers.FindFreePort ();
+ channel = new HttpChannel (port);
ChannelServices.RegisterChannel (channel);
RemotingConfiguration.RegisterWellKnownServiceType
(typeof (Bug321420),"Server.soap", WellKnownObjectMode.Singleton);
Bug321420 s = (Bug321420) Activator.GetObject (typeof
- (Bug321420), "http://localhost:3344/Server.soap");
+ (Bug321420), $"http://localhost:{port}/Server.soap");
// this works: s.Method ("a", "b");
s.Method ("a", "a");
public void Main ()
{
Foo foo = (Foo) Activator.GetObject (typeof (Foo),
- "http://localhost:4321/Test");
+ $"http://localhost:{server.HttpPort}/Test");
Bar bar = foo.Login ();
if (bar != null)
public void Start ()
{
- c = new HttpChannel (4321);
+ HttpPort = NetworkHelpers.FindFreePort ();
+ c = new HttpChannel (HttpPort);
ChannelServices.RegisterChannel (c);
Type t = typeof(Foo);
c.StopListening (null);
ChannelServices.UnregisterChannel (c);
}
+
+ public int HttpPort { get; private set; }
}
}
ChannelServices.RegisterChannel (channel);
MarshalByRefObject obj = (MarshalByRefObject) RemotingServices.Connect (
typeof (IFactorial),
- "http://localhost:60000/MyEndPoint");
+ $"http://localhost:{server.HttpPort}/MyEndPoint");
IFactorial cal = (IFactorial) obj;
Assert.AreEqual (cal.CalculateFactorial (4), 24);
}
public void Start ()
{
- c = new HttpChannel (60000);
+ HttpPort = NetworkHelpers.FindFreePort ();
+ c = new HttpChannel (HttpPort);
ChannelServices.RegisterChannel (c);
Type t = typeof(Calculator);
c.StopListening (null);
ChannelServices.UnregisterChannel (c);
}
+
+ public int HttpPort { get; private set; }
}
public class Calculator : MarshalByRefObject, IFactorial
using System.Runtime.Remoting.Channels;\r
using System.Runtime.Remoting.Channels.Tcp;\r
\r
+using MonoTests.Helpers;\r
+\r
namespace MonoTests.System.Runtime.Remoting.RemotingServicesInternal\r
{\r
// We need our own proxy to intercept messages to remote object\r
[Test]\r
public void Connect ()\r
{\r
+ var port = NetworkHelpers.FindFreePort ();\r
MarshalObject objMarshal = NewMarshalObject ();\r
\r
IDictionary props = new Hashtable ();\r
props ["name"] = objMarshal.Uri;\r
- props ["port"] = 1236;\r
+ props ["port"] = port;\r
TcpChannel chn = new TcpChannel (props, null, null);\r
ChannelServices.RegisterChannel (chn);\r
\r
try {\r
RemotingServices.Marshal (objMarshal, objMarshal.Uri);\r
- MarshalObject objRem = (MarshalObject) RemotingServices.Connect (typeof (MarshalObject), "tcp://localhost:1236/" + objMarshal.Uri);\r
+ MarshalObject objRem = (MarshalObject) RemotingServices.Connect (typeof (MarshalObject), $"tcp://localhost:{port}/" + objMarshal.Uri);\r
Assert.IsTrue (RemotingServices.IsTransparentProxy (objRem), "#A08");\r
} finally {\r
ChannelServices.UnregisterChannel (chn);\r
[Test]\r
public void MarshalThrowException ()\r
{\r
+ var port = NetworkHelpers.FindFreePort ();\r
MarshalObject objMarshal = NewMarshalObject ();\r
\r
IDictionary props = new Hashtable ();\r
props ["name"] = objMarshal.Uri;\r
- props ["port"] = 1237;\r
+ props ["port"] = port;\r
TcpChannel chn = new TcpChannel (props, null, null);\r
ChannelServices.RegisterChannel (chn);\r
\r
try {\r
RemotingServices.Marshal (objMarshal, objMarshal.Uri);\r
- MarshalObject objRem = (MarshalObject) RemotingServices.Connect (typeof (MarshalObject), "tcp://localhost:1237/" + objMarshal.Uri);\r
+ MarshalObject objRem = (MarshalObject) RemotingServices.Connect (typeof (MarshalObject), $"tcp://localhost:{port}/" + objMarshal.Uri);\r
// This line should throw a RemotingException\r
// It is forbidden to export an object which is not\r
// a real object\r
[Test]\r
public void ExecuteMessage ()\r
{\r
- TcpChannel chn = new TcpChannel (1235);\r
+ var port = NetworkHelpers.FindFreePort ();\r
+ TcpChannel chn = new TcpChannel (port);\r
ChannelServices.RegisterChannel (chn);\r
try {\r
MarshalObject objMarshal = NewMarshalObject ();\r
RemotingConfiguration.RegisterWellKnownServiceType (typeof (MarshalObject), objMarshal.Uri, WellKnownObjectMode.SingleCall);\r
\r
// use a proxy to catch the Message\r
- MyProxy proxy = new MyProxy (typeof (MarshalObject), (MarshalObject) Activator.GetObject (typeof (MarshalObject), "tcp://localhost:1235/" + objMarshal.Uri));\r
+ MyProxy proxy = new MyProxy (typeof (MarshalObject), (MarshalObject) Activator.GetObject (typeof (MarshalObject), $"tcp://localhost:{port}/" + objMarshal.Uri));\r
\r
MarshalObject objRem = (MarshalObject) proxy.GetTransparentProxy ();\r
\r
[Test]\r
public void IsOneWay ()\r
{\r
- TcpChannel chn = new TcpChannel (1238);\r
+ var port = NetworkHelpers.FindFreePort ();\r
+ TcpChannel chn = new TcpChannel (port);\r
ChannelServices.RegisterChannel (chn);\r
try {\r
RemotingConfiguration.RegisterWellKnownServiceType (typeof (MarshalObject), "MarshalObject.rem", WellKnownObjectMode.Singleton);\r
\r
- MarshalObject objRem = (MarshalObject) Activator.GetObject (typeof (MarshalObject), "tcp://localhost:1238/MarshalObject.rem");\r
+ MarshalObject objRem = (MarshalObject) Activator.GetObject (typeof (MarshalObject), $"tcp://localhost:{port}/MarshalObject.rem");\r
\r
Assert.IsTrue (RemotingServices.IsTransparentProxy (objRem), "#A10.1");\r
\r
[Test]\r
public void GetObjRefForProxy ()\r
{\r
- TcpChannel chn = new TcpChannel (1239);\r
+ var port = NetworkHelpers.FindFreePort ();\r
+ TcpChannel chn = new TcpChannel (port);\r
ChannelServices.RegisterChannel (chn);\r
try {\r
// Register le factory as a SAO\r
RemotingConfiguration.RegisterWellKnownServiceType (typeof (MarshalObjectFactory), "MonoTests.System.Runtime.Remoting.RemotingServicesTest.Factory.soap", WellKnownObjectMode.Singleton);\r
\r
- MarshalObjectFactory objFactory = (MarshalObjectFactory) Activator.GetObject (typeof (MarshalObjectFactory), "tcp://localhost:1239/MonoTests.System.Runtime.Remoting.RemotingServicesTest.Factory.soap");\r
+ MarshalObjectFactory objFactory = (MarshalObjectFactory) Activator.GetObject (typeof (MarshalObjectFactory), $"tcp://localhost:{port}/MonoTests.System.Runtime.Remoting.RemotingServicesTest.Factory.soap");\r
\r
// Get a new "CAO"\r
MarshalObject objRem = objFactory.GetNewMarshalObject ();\r
[Test]\r
public void GetRealProxy ()\r
{\r
- TcpChannel chn = new TcpChannel (1241);\r
+ var port = NetworkHelpers.FindFreePort ();\r
+ TcpChannel chn = new TcpChannel (port);\r
ChannelServices.RegisterChannel (chn);\r
try {\r
RemotingConfiguration.RegisterWellKnownServiceType (typeof (MarshalObject), "MonoTests.System.Runtime.Remoting.RemotingServicesTest.MarshalObject.soap", WellKnownObjectMode.Singleton);\r
\r
- MyProxy proxy = new MyProxy (typeof (MarshalObject), (MarshalByRefObject) Activator.GetObject (typeof (MarshalObject), "tcp://localhost:1241/MonoTests.System.Runtime.Remoting.RemotingServicesTest.MarshalObject.soap"));\r
+ MyProxy proxy = new MyProxy (typeof (MarshalObject), (MarshalByRefObject) Activator.GetObject (typeof (MarshalObject), $"tcp://localhost:{port}/MonoTests.System.Runtime.Remoting.RemotingServicesTest.MarshalObject.soap"));\r
MarshalObject objRem = (MarshalObject) proxy.GetTransparentProxy ();\r
\r
RealProxy rp = RemotingServices.GetRealProxy (objRem);\r
[Test]\r
public void SetObjectUriForMarshal ()\r
{\r
- TcpChannel chn = new TcpChannel (1242);\r
+ var port = NetworkHelpers.FindFreePort ();\r
+ TcpChannel chn = new TcpChannel (port);\r
ChannelServices.RegisterChannel (chn);\r
try {\r
MarshalObject objRem = NewMarshalObject ();\r
RemotingServices.SetObjectUriForMarshal (objRem, objRem.Uri);\r
RemotingServices.Marshal (objRem);\r
\r
- objRem = (MarshalObject) Activator.GetObject (typeof (MarshalObject), "tcp://localhost:1242/" + objRem.Uri);\r
+ objRem = (MarshalObject) Activator.GetObject (typeof (MarshalObject), $"tcp://localhost:{port}/" + objRem.Uri);\r
Assert.IsNotNull (objRem, "#A14");\r
} finally {\r
ChannelServices.UnregisterChannel (chn);\r
[Test]\r
public void GetServeurTypeForUri ()\r
{\r
- TcpChannel chn = new TcpChannel (1243);\r
+ var port = NetworkHelpers.FindFreePort ();\r
+ TcpChannel chn = new TcpChannel (port);\r
Type type = typeof (MarshalObject);\r
ChannelServices.RegisterChannel (chn);\r
try {\r
[Category ("NotWorking")]\r
public void IsObjectOutOf ()\r
{\r
- TcpChannel chn = new TcpChannel (1245);\r
+ var port = NetworkHelpers.FindFreePort ();\r
+ TcpChannel chn = new TcpChannel (port);\r
ChannelServices.RegisterChannel (chn);\r
try {\r
RemotingConfiguration.RegisterWellKnownServiceType (typeof (MarshalObject), "MarshalObject2.rem", WellKnownObjectMode.Singleton);\r
\r
- MarshalObject objRem = (MarshalObject) Activator.GetObject (typeof (MarshalObject), "tcp://localhost:1245/MarshalObject2.rem");\r
+ MarshalObject objRem = (MarshalObject) Activator.GetObject (typeof (MarshalObject), $"tcp://localhost:{port}/MarshalObject2.rem");\r
\r
Assert.IsTrue (RemotingServices.IsObjectOutOfAppDomain (objRem), "#A16");\r
Assert.IsTrue (RemotingServices.IsObjectOutOfContext (objRem), "#A17");\r
[Test]\r
public void ApplicationNameTest ()\r
{\r
+ var port = NetworkHelpers.FindFreePort ();\r
RemotingConfiguration.ApplicationName = "app";\r
- TcpChannel chn = new TcpChannel (1246);\r
+ TcpChannel chn = new TcpChannel (port);\r
ChannelServices.RegisterChannel (chn);\r
try {\r
RemotingConfiguration.RegisterWellKnownServiceType (typeof (MarshalObject), "obj3.rem", WellKnownObjectMode.Singleton);\r
\r
- MarshalObject objRem = (MarshalObject) Activator.GetObject (typeof (MarshalObject), "tcp://localhost:1246/app/obj3.rem");\r
- MarshalObject objRem2 = (MarshalObject) Activator.GetObject (typeof (MarshalObject), "tcp://localhost:1246/obj3.rem");\r
+ MarshalObject objRem = (MarshalObject) Activator.GetObject (typeof (MarshalObject), $"tcp://localhost:{port}/app/obj3.rem");\r
+ MarshalObject objRem2 = (MarshalObject) Activator.GetObject (typeof (MarshalObject), $"tcp://localhost:{port}/obj3.rem");\r
\r
Assert.IsTrue (RemotingServices.IsTransparentProxy (objRem), "#AN1");\r
Assert.IsTrue (RemotingServices.IsTransparentProxy (objRem2), "#AN2");\r
[Test]\r
public void GetObjectWithChannelDataTest ()\r
{\r
- TcpChannel chn = new TcpChannel (1247);\r
+ var port = NetworkHelpers.FindFreePort ();\r
+ TcpChannel chn = new TcpChannel (port);\r
ChannelServices.RegisterChannel (chn);\r
try {\r
RemotingConfiguration.RegisterWellKnownServiceType (typeof (MarshalObject), "getobjectwithchanneldata.rem", WellKnownObjectMode.Singleton);\r
\r
string channelData = "test";\r
- Assert.IsNotNull (Activator.GetObject (typeof (MarshalObject), "tcp://localhost:1247/getobjectwithchanneldata.rem", channelData), "#01");\r
+ Assert.IsNotNull (Activator.GetObject (typeof (MarshalObject), $"tcp://localhost:{port}/getobjectwithchanneldata.rem", channelData), "#01");\r
} finally {\r
ChannelServices.UnregisterChannel (chn);\r
}\r
[Ignore ("We cannot test RemotingConfiguration.Configure() because it keeps channels registered. If we really need to test it, do it as a standalone case")]\r
public void ConnectProxyCast ()\r
{\r
+ var port = NetworkHelpers.FindFreePort ();\r
object o;\r
RemotingConfiguration.Configure (null);\r
\r
- o = RemotingServices.Connect (typeof (MarshalByRefObject), "tcp://localhost:3434/ff1.rem");\r
+ o = RemotingServices.Connect (typeof (MarshalByRefObject), $"tcp://localhost:{port}/ff1.rem");\r
Assert.IsInstanceOfType (typeof (DD), o, "#m1");\r
Assert.IsInstanceOfType (typeof (A), o, "#m2");\r
Assert.IsInstanceOfType (typeof (B), o, "#m3");\r
AssertHelper.IsNotInstanceOfType (typeof (CC), !(o is CC), "#m4");\r
\r
- o = RemotingServices.Connect (typeof (A), "tcp://localhost:3434/ff3.rem");\r
+ o = RemotingServices.Connect (typeof (A), $"tcp://localhost:{port}/ff3.rem");\r
Assert.IsInstanceOfType (typeof (DD), o, "#a1");\r
Assert.IsInstanceOfType (typeof (A), o, "#a2");\r
Assert.IsInstanceOfType (typeof (B), o, "#a3");\r
AssertHelper.IsNotInstanceOfType (typeof (CC), o, "#a4");\r
\r
- o = RemotingServices.Connect (typeof (DD), "tcp://localhost:3434/ff4.rem");\r
+ o = RemotingServices.Connect (typeof (DD), $"tcp://localhost:{port}/ff4.rem");\r
Assert.IsInstanceOfType (typeof (DD), o, "#d1");\r
Assert.IsInstanceOfType (typeof (A), o, "#d2");\r
Assert.IsInstanceOfType (typeof (B), o, "#d3");\r
AssertHelper.IsNotInstanceOfType (typeof (CC), o, "#d4");\r
\r
- o = RemotingServices.Connect (typeof (CC), "tcp://localhost:3434/ff5.rem");\r
+ o = RemotingServices.Connect (typeof (CC), $"tcp://localhost:{port}/ff5.rem");\r
AssertHelper.IsNotInstanceOfType (typeof (DD), o, "#c1");\r
Assert.IsInstanceOfType (typeof (A), o, "#c2");\r
Assert.IsInstanceOfType (typeof (B), o, "#c3");\r
using NUnit.Framework;
+using MonoTests.Helpers;
+
namespace MonoTests.Remoting
{
[TestFixture]
MarshalObject marshal = new MarshalObject ();
+ var port = NetworkHelpers.FindFreePort ();
IDictionary props = new Hashtable ();
props ["name"] = "marshal channel";
- props ["port"] = 1236;
+ props ["port"] = port;
props ["bindTo"] = IPAddress.Loopback.ToString ();
chn = new TcpChannel (props, null, null);
urls = chn.GetUrlsForUri (SERVICE_URI);
Assert.IsNotNull (urls, "#A2");
Assert.AreEqual (1, urls.Length, "#A3");
- Assert.AreEqual ("tcp://" + IPAddress.Loopback.ToString () + ":1236/" + SERVICE_URI, urls [0], "#A6");
+ Assert.AreEqual ($"tcp://{IPAddress.Loopback.ToString ()}:{port}/{SERVICE_URI}", urls [0], "#A6");
ds = chn.ChannelData as ChannelDataStore;
Assert.IsNotNull (ds, "#A4");
Assert.AreEqual (1, ds.ChannelUris.Length, "#A5");
- Assert.AreEqual ("tcp://" + IPAddress.Loopback.ToString () + ":1236", ds.ChannelUris [0], "#A6");
+ Assert.AreEqual ($"tcp://{IPAddress.Loopback.ToString ()}:{port}", ds.ChannelUris [0], "#A6");
ChannelServices.UnregisterChannel (chn);
using System.ServiceModel.Web;
using NUnit.Framework;
+using MonoTests.Helpers;
+
namespace MonoTests.System.ServiceModel.Activation
{
class MyHostFactory : WebScriptServiceHostFactory
[Test]
public void CreateServiceHost ()
{
+ var port = NetworkHelpers.FindFreePort ();
var f = new MyHostFactory ();
- var host = f.DoCreateServiceHost (typeof (TestService), new Uri [] {new Uri ("http://localhost:37564")});
+ var host = f.DoCreateServiceHost (typeof (TestService), new Uri [] {new Uri ($"http://localhost:{port}")});
Assert.IsFalse (host is WebServiceHost, "#1");
host.Open ();
host.Close ();
[ExpectedException (typeof (NotSupportedException))]
public void ResponseWrappedIsInvalid ()
{
+ var port = NetworkHelpers.FindFreePort ();
var f = new MyHostFactory ();
- var host = f.DoCreateServiceHost (typeof (TestService2), new Uri [] {new Uri ("http://localhost:37564")});
+ var host = f.DoCreateServiceHost (typeof (TestService2), new Uri [] {new Uri ($"http://localhost:{port}")});
host.Open (); // should raise an error here.
}
[ExpectedException (typeof (InvalidOperationException))]
public void MultipleContract ()
{
+ var port = NetworkHelpers.FindFreePort ();
var f = new MyHostFactory ();
- var host = f.DoCreateServiceHost (typeof (TestServiceMultiple), new Uri [] {new Uri ("http://localhost:37564")});
+ var host = f.DoCreateServiceHost (typeof (TestServiceMultiple), new Uri [] {new Uri ($"http://localhost:{port}")});
host.Open ();
}
public class CustomPeerResolverService : IPeerResolverContract
{
static ServiceHost localhost;
+ static int port;
static void SetupCustomPeerResolverServiceHost ()
{
+ string customPort = Environment.GetEnvironmentVariable ("MONO_CUSTOMPEERRESOLVERSERVICE_PORT");
+ if (customPort == null || !int.TryParse (customPort, out port))
+ port = 8931;
+
// launch peer resolver service locally only when it does not seem to be running ...
- var t = new TcpListener (8931);
+ var t = new TcpListener (port);
try {
t.Start ();
t.Stop ();
Console.WriteLine ("WARNING: it is running peer resolver service locally. This means, the node registration is valid only within this application domain...");
var host = new ServiceHost (new LocalPeerResolverService (TextWriter.Null));
host.Description.Behaviors.Find<ServiceBehaviorAttribute> ().InstanceContextMode = InstanceContextMode.Single;
- host.AddServiceEndpoint (typeof (ICustomPeerResolverContract), new BasicHttpBinding (), "http://localhost:8931");
+ host.AddServiceEndpoint (typeof (ICustomPeerResolverContract), new BasicHttpBinding (), $"http://localhost:{port}");
localhost = host;
host.Open ();
}
public CustomPeerResolverService ()
{
- client = ChannelFactory<ICustomPeerResolverClient>.CreateChannel (new BasicHttpBinding (), new EndpointAddress ("http://localhost:8931"));
+ client = ChannelFactory<ICustomPeerResolverClient>.CreateChannel (new BasicHttpBinding (), new EndpointAddress ($"http://localhost:{port}"));
refresh_interval = new TimeSpan (0, 10, 0);
cleanup_interval = new TimeSpan (0, 1, 0);
using System.ServiceModel.Dispatcher;
using System.Collections.ObjectModel;
+using MonoTests.Helpers;
+
namespace MonoTests.Features
{
public class Configuration
{
static Configuration() {
+ var port = NetworkHelpers.FindFreePort ();
onlyServers = Boolean.Parse (ConfigurationManager.AppSettings ["onlyServers"] ?? "false");
onlyClients = Boolean.Parse (ConfigurationManager.AppSettings ["onlyClients"] ?? "false");
- endpointBase = ConfigurationManager.AppSettings ["endpointBase"] ?? "http://localhost:9999/";
+ endpointBase = ConfigurationManager.AppSettings ["endpointBase"] ?? $"http://localhost:{port}/";
if (!endpointBase.EndsWith ("/"))
endpointBase = endpointBase + '/';
logMessages = Boolean.Parse (ConfigurationManager.AppSettings ["logMessages"] ?? "false");
using NUnit.Framework;
+using MonoTests.Helpers;
+
namespace MonoTests.System.ServiceModel.PeerResolvers
{
[TestFixture]
[SetUp]
protected void SetUp ()
{
+ var port = NetworkHelpers.FindFreePort ();
+ Environment.SetEnvironmentVariable ("MONO_CUSTOMPEERRESOLVERSERVICE_PORT", port.ToString ());
cprs = new CustomPeerResolverService ();
}
+++ /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
get { return !disposed && context != IntPtr.Zero; }
}
- [System.Diagnostics.Conditional ("APPLE_TLS_DEBUG")]
- protected new void Debug (string message, params object[] args)
- {
- Console.Error.WriteLine ("MobileTlsStream({0}): {1}", Parent.ID, string.Format (message, args));
- }
-
void CheckStatusAndThrow (SslStatus status, params SslStatus[] acceptable)
{
var last = Interlocked.Exchange (ref lastException, null);
else
MaxProtocol = SslProtocol.Tls_1_0;
-#if APPLE_TLS_DEBUG
- foreach (var c in GetSupportedCiphers ())
- Debug (" {0} SslCipherSuite.{1} {2:x} {3}", IsServer ? "Server" : "Client", c, (int)c, (CipherSuiteCode)c);
-#endif
-
if (Settings != null && Settings.EnabledCiphers != null) {
SslCipherSuite [] ciphers = new SslCipherSuite [Settings.EnabledCiphers.Length];
for (int i = 0 ; i < Settings.EnabledCiphers.Length; ++i)
[DllImport (SecurityLibrary)]
extern unsafe static /* OSStatus */ SslStatus SSLRead (/* SSLContextRef */ IntPtr context, /* const void* */ byte* data, /* size_t */ IntPtr dataLength, /* size_t* */ out IntPtr processed);
- public override unsafe int Read (byte[] buffer, int offset, int count, out bool wantMore)
+ public override unsafe (int ret, bool wantMore) Read (byte[] buffer, int offset, int count)
{
if (Interlocked.Exchange (ref pendingIO, 1) == 1)
throw new InvalidOperationException ();
* when the first inner Read() returns 0. MobileAuthenticatedStream.InnerRead() attempts
* to distinguish between a graceful close and abnormal termination of connection.
*/
- wantMore = false;
- return 0;
+ return (0, false);
}
CheckStatusAndThrow (status, SslStatus.WouldBlock, SslStatus.ClosedGraceful);
- wantMore = status == SslStatus.WouldBlock;
- return (int)processed;
+ var wantMore = status == SslStatus.WouldBlock;
+ return ((int)processed, wantMore);
} catch (Exception ex) {
Debug ("Read error: {0}", ex);
throw;
[DllImport (SecurityLibrary)]
extern unsafe static /* OSStatus */ SslStatus SSLWrite (/* SSLContextRef */ IntPtr context, /* const void* */ byte* data, /* size_t */ IntPtr dataLength, /* size_t* */ out IntPtr processed);
- public override unsafe int Write (byte[] buffer, int offset, int count, out bool wantMore)
+ public override unsafe (int ret, bool wantMore) Write (byte[] buffer, int offset, int count)
{
if (Interlocked.Exchange (ref pendingIO, 1) == 1)
throw new InvalidOperationException ();
CheckStatusAndThrow (status, SslStatus.WouldBlock);
- wantMore = status == SslStatus.WouldBlock;
- return (int)processed;
+ var wantMore = status == SslStatus.WouldBlock;
+ return ((int)processed, wantMore);
} finally {
pendingIO = 0;
}
public override void Shutdown ()
{
- if (Interlocked.Exchange (ref pendingIO, 1) == 1)
- throw new InvalidOperationException ();
-
- Debug ("Shutdown");
-
- lastException = null;
-
- try {
- if (closed || disposed)
- return;
-
- var status = SSLClose (Handle);
- Debug ("Shutdown done: {0}", status);
- CheckStatusAndThrow (status);
- } finally {
- closed = true;
- pendingIO = 0;
- }
+ closed = true;
}
#endregion
get { return true; }
}
+ internal override bool SupportsCleanShutdown {
+ get { return false; }
+ }
+
public override SslProtocols SupportedProtocols {
get { return SslProtocols.Tls12 | SslProtocols.Tls11 | SslProtocols.Tls; }
}
throw new NotImplementedException ();
}
- public override int Read (byte[] buffer, int offset, int size, out bool wantMore)
+ public override (int ret, bool wantMore) Read (byte[] buffer, int offset, int size)
{
Debug ("Read: {0} {1} {2}", buffer.Length, offset, size);
var status = ssl.Read (data, ref size);
Debug ("Read done: {0} {1}", status, size);
- if (status == MonoBtlsSslError.WantRead) {
- wantMore = true;
- return 0;
- } else if (status == MonoBtlsSslError.ZeroReturn) {
- wantMore = false;
- return size;
- } else if (status != MonoBtlsSslError.None) {
+ if (status == MonoBtlsSslError.WantRead)
+ return (0, true);
+ if (status == MonoBtlsSslError.ZeroReturn)
+ return (size, false);
+ if (status != MonoBtlsSslError.None)
throw GetException (status);
- }
if (size > 0)
Marshal.Copy (data, buffer, offset, size);
- wantMore = false;
- return size;
+ return (size, false);
} finally {
Marshal.FreeHGlobal (data);
}
}
- public override int Write (byte[] buffer, int offset, int size, out bool wantMore)
+ public override (int ret, bool wantMore) Write (byte[] buffer, int offset, int size)
{
Debug ("Write: {0} {1} {2}", buffer.Length, offset, size);
var status = ssl.Write (data, ref size);
Debug ("Write done: {0} {1}", status, size);
- if (status == MonoBtlsSslError.WantWrite) {
- wantMore = true;
- return 0;
- } else if (status != MonoBtlsSslError.None) {
+ if (status == MonoBtlsSslError.WantWrite)
+ return (0, true);
+ if (status != MonoBtlsSslError.None)
throw GetException (status);
- }
- wantMore = false;
- return size;
+ return (size, false);
} finally {
Marshal.FreeHGlobal (data);
}
public override void Shutdown ()
{
Debug ("Shutdown!");
-// ssl.SetQuietShutdown ();
+ if (Settings == null || !Settings.SendCloseNotify)
+ ssl.SetQuietShutdown ();
ssl.Shutdown ();
}
get { return true; }
}
+ internal override bool SupportsCleanShutdown {
+ get { return true; }
+ }
+
public override SslProtocols SupportedProtocols {
get { return SslProtocols.Tls12 | SslProtocols.Tls11 | SslProtocols.Tls; }
}
[DllImport (BTLS_DYLIB)]
extern static IntPtr mono_btls_ssl_get_server_name (IntPtr handle);
+ [DllImport (BTLS_DYLIB)]
+ extern static void mono_btls_ssl_set_renegotiate_mode (IntPtr handle, int mode);
+
+ [DllImport (BTLS_DYLIB)]
+ extern static int mono_btls_ssl_renegotiate_pending (IntPtr handle);
+
static BoringSslHandle Create_internal (MonoBtlsSslCtx ctx)
{
var handle = mono_btls_ssl_new (ctx.Handle.DangerousGetHandle ());
if (!Handle.IsInvalid)
mono_btls_ssl_close (Handle.DangerousGetHandle ());
}
+
+ public void SetRenegotiateMode (MonoBtlsSslRenegotiateMode mode)
+ {
+ CheckThrow ();
+ mono_btls_ssl_set_renegotiate_mode (Handle.DangerousGetHandle (), (int)mode);
+ }
+
+ public bool RenegotiatePending ()
+ {
+ return mono_btls_ssl_renegotiate_pending (Handle.DangerousGetHandle ()) != 0;
+ }
}
}
#endif
--- /dev/null
+//
+// MonoBtlsSslRenegotiateMode.cs
+//
+// Author:
+// Martin Baulig <mabaul@microsoft.com>
+//
+// Copyright (c) 2017 Xamarin Inc. (http://www.xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+#if SECURITY_DEP && MONO_FEATURE_BTLS
+using System;
+namespace Mono.Btls
+{
+ [Flags]
+ enum MonoBtlsSslRenegotiateMode
+ {
+ NEVER = 0,
+ ONCE,
+ FREELY,
+ IGNORE
+ }
+}
+#endif
RunSynchronously = sync;
}
- [SD.Conditional ("MARTIN_DEBUG")]
+ [SD.Conditional ("MONO_TLS_DEBUG")]
protected void Debug (string message, params object[] args)
{
Parent.Debug ("{0}({1}:{2}): {3}", Name, Parent.ID, ID, string.Format (message, args));
if (Interlocked.Exchange (ref WriteRequested, 0) != 0) {
// Flush the write queue.
+ Debug ("ProcessOperation - flushing write queue");
await Parent.InnerWrite (RunSynchronously, cancellationToken);
}
get { return false; }
}
+ internal override bool SupportsCleanShutdown {
+ get { return false; }
+ }
+
public override SslProtocols SupportedProtocols {
get { return SslProtocols.Tls; }
}
static int nextId;
internal readonly int ID = ++nextId;
- [SD.Conditional ("MARTIN_DEBUG")]
+ [SD.Conditional ("MONO_TLS_DEBUG")]
protected internal void Debug (string message, params object[] args)
{
- Console.Error.WriteLine ("MobileAuthenticatedStream({0}): {1}", ID, string.Format (message, args));
+ MonoTlsProviderFactory.Debug ("MobileAuthenticatedStream({0}): {1}", ID, string.Format (message, args));
}
#region Called back from native code via SslConnection
* SSLHandshake() will return repeatedly with 'SslStatus.WouldBlock', we then need
* to take care of I/O and call it again.
*/
+ var newStatus = AsyncOperationStatus.Continue;
if (xobileTlsContext.ProcessHandshake ()) {
xobileTlsContext.FinishHandshake ();
- return AsyncOperationStatus.Complete;
+ newStatus = AsyncOperationStatus.Complete;
}
- return AsyncOperationStatus.Continue;
+
+ if (lastException != null)
+ lastException.Throw ();
+
+ return newStatus;
}
}
{
lock (ioLock) {
// This operates on the internal buffer and will never block.
- var ret = xobileTlsContext.Read (userBuffer.Buffer, userBuffer.Offset, userBuffer.Size, out bool wantMore);
- return (ret, wantMore);
+ var ret = xobileTlsContext.Read (userBuffer.Buffer, userBuffer.Offset, userBuffer.Size);
+ if (lastException != null)
+ lastException.Throw ();
+ return ret;
}
}
{
lock (ioLock) {
// This operates on the internal buffer and will never block.
- var ret = xobileTlsContext.Write (userBuffer.Buffer, userBuffer.Offset, userBuffer.Size, out bool wantMore);
- return (ret, wantMore);
+ var ret = xobileTlsContext.Write (userBuffer.Buffer, userBuffer.Offset, userBuffer.Size);
+ if (lastException != null)
+ lastException.Throw ();
+ return ret;
}
}
get { return parent.Provider; }
}
- [SD.Conditional ("MARTIN_DEBUG")]
+ [SD.Conditional ("MONO_TLS_DEBUG")]
protected void Debug (string message, params object[] args)
{
- Console.Error.WriteLine ("{0}: {1}", GetType ().Name, string.Format (message, args));
+ parent.Debug ("{0}: {1}", GetType ().Name, string.Format (message, args));
}
public abstract bool HasContext {
public abstract void Flush ();
- public abstract int Read (byte[] buffer, int offset, int count, out bool wantMore);
+ public abstract (int ret, bool wantMore) Read (byte[] buffer, int offset, int count);
- public abstract int Write (byte[] buffer, int offset, int count, out bool wantMore);
+ public abstract (int ret, bool wantMore) Write (byte[] buffer, int offset, int count);
public abstract void Shutdown ();
using System;
using System.Net;
+using System.Diagnostics;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
}
}
+ static bool enableDebug;
+
+ [Conditional ("MONO_TLS_DEBUG")]
+ static void InitializeDebug ()
+ {
+ if (Environment.GetEnvironmentVariable ("MONO_TLS_DEBUG") != null)
+ enableDebug = true;
+ }
+
+ [Conditional ("MONO_TLS_DEBUG")]
+ internal static void Debug (string message, params object[] args)
+ {
+ if (enableDebug)
+ Console.Error.WriteLine (message, args);
+ }
+
#endregion
internal static readonly Guid AppleTlsId = new Guid ("981af8af-a3a3-419a-9f01-a518e3a17c1c");
lock (locker) {
if (providerRegistration != null)
return;
+
+ InitializeDebug ();
+
providerRegistration = new Dictionary<string,Tuple<Guid,string>> ();
providerCache = new Dictionary<Guid,MSI.MonoTlsProvider> ();
<Compile Include="Mono.Btls\MonoBtlsSsl.cs" />\r
<Compile Include="Mono.Btls\MonoBtlsSslCtx.cs" />\r
<Compile Include="Mono.Btls\MonoBtlsSslError.cs" />\r
+ <Compile Include="Mono.Btls\MonoBtlsSslRenegotiateMode.cs" />\r
<Compile Include="Mono.Btls\MonoBtlsStream.cs" />\r
<Compile Include="Mono.Btls\MonoBtlsUtils.cs" />\r
<Compile Include="Mono.Btls\MonoBtlsX509.cs" />\r
<Compile Include="Mono.Btls\MonoBtlsSsl.cs" />\r
<Compile Include="Mono.Btls\MonoBtlsSslCtx.cs" />\r
<Compile Include="Mono.Btls\MonoBtlsSslError.cs" />\r
+ <Compile Include="Mono.Btls\MonoBtlsSslRenegotiateMode.cs" />\r
<Compile Include="Mono.Btls\MonoBtlsStream.cs" />\r
<Compile Include="Mono.Btls\MonoBtlsUtils.cs" />\r
<Compile Include="Mono.Btls\MonoBtlsX509.cs" />\r
<Compile Include="Mono.Btls\MonoBtlsSsl.cs" />\r
<Compile Include="Mono.Btls\MonoBtlsSslCtx.cs" />\r
<Compile Include="Mono.Btls\MonoBtlsSslError.cs" />\r
+ <Compile Include="Mono.Btls\MonoBtlsSslRenegotiateMode.cs" />\r
<Compile Include="Mono.Btls\MonoBtlsStream.cs" />\r
<Compile Include="Mono.Btls\MonoBtlsUtils.cs" />\r
<Compile Include="Mono.Btls\MonoBtlsX509.cs" />\r
ThrowIfBufferOutOfRange (buffer, offset, size);
int nativeError;
- int ret = Receive_internal (m_Handle, buffer, offset, size, socketFlags, out nativeError, is_blocking);
+ int ret;
+ unsafe {
+ fixed (byte* pbuffer = buffer) {
+ ret = Receive_internal (m_Handle, &pbuffer[offset], size, socketFlags, out nativeError, is_blocking);
+ }
+ }
errorCode = (SocketError) nativeError;
if (errorCode != SocketError.Success && errorCode != SocketError.WouldBlock && errorCode != SocketError.InProgress) {
int nativeError;
int ret;
- /* Only example I can find of sending a byte array reference directly into an internal
- * call is in System.Runtime.Remoting/System.Runtime.Remoting.Channels.Ipc.Win32/NamedPipeSocket.cs,
- * so taking a lead from that... */
- WSABUF[] bufarray = new WSABUF[numsegments];
GCHandle[] gch = new GCHandle[numsegments];
+ try {
+ unsafe {
+ fixed (WSABUF* bufarray = new WSABUF[numsegments]) {
+ for (int i = 0; i < numsegments; i++) {
+ ArraySegment<byte> segment = buffers[i];
- for (int i = 0; i < numsegments; i++) {
- ArraySegment<byte> segment = buffers[i];
+ if (segment.Offset < 0 || segment.Count < 0 || segment.Count > segment.Array.Length - segment.Offset)
+ throw new ArgumentOutOfRangeException ("segment");
- if (segment.Offset < 0 || segment.Count < 0 || segment.Count > segment.Array.Length - segment.Offset)
- throw new ArgumentOutOfRangeException ("segment");
+ try {} finally {
+ gch[i] = GCHandle.Alloc (segment.Array, GCHandleType.Pinned);
+ }
- gch[i] = GCHandle.Alloc (segment.Array, GCHandleType.Pinned);
- bufarray[i].len = segment.Count;
- bufarray[i].buf = Marshal.UnsafeAddrOfPinnedArrayElement (segment.Array, segment.Offset);
- }
+ bufarray[i].len = segment.Count;
+ bufarray[i].buf = Marshal.UnsafeAddrOfPinnedArrayElement (segment.Array, segment.Offset);
+ }
- try {
- ret = Receive_internal (m_Handle, bufarray, socketFlags, out nativeError, is_blocking);
+ ret = Receive_internal (m_Handle, bufarray, numsegments, socketFlags, out nativeError, is_blocking);
+ }
+ }
} finally {
for (int i = 0; i < numsegments; i++) {
if (gch[i].IsAllocated)
int total = 0;
try {
- total = Receive_internal (sockares.socket.m_Handle, sockares.Buffer, sockares.Offset, sockares.Size, sockares.SockFlags, out sockares.error, sockares.socket.is_blocking);
+ unsafe {
+ fixed (byte* pbuffer = sockares.Buffer) {
+ total = Receive_internal (sockares.socket.m_Handle, &pbuffer[sockares.Offset], sockares.Size, sockares.SockFlags, out sockares.error, sockares.socket.is_blocking);
+ }
+ }
} catch (Exception e) {
sockares.Complete (e);
return;
return sockares.Total;
}
- static int Receive_internal (SafeSocketHandle safeHandle, WSABUF[] bufarray, SocketFlags flags, out int error, bool blocking)
+ static unsafe int Receive_internal (SafeSocketHandle safeHandle, WSABUF* bufarray, int count, SocketFlags flags, out int error, bool blocking)
{
try {
safeHandle.RegisterForBlockingSyscall ();
- return Receive_internal (safeHandle.DangerousGetHandle (), bufarray, flags, out error, blocking);
+ return Receive_internal (safeHandle.DangerousGetHandle (), bufarray, count, flags, out error, blocking);
} finally {
safeHandle.UnRegisterForBlockingSyscall ();
}
}
[MethodImplAttribute (MethodImplOptions.InternalCall)]
- extern static int Receive_internal (IntPtr sock, WSABUF[] bufarray, SocketFlags flags, out int error, bool blocking);
+ extern static unsafe int Receive_internal (IntPtr sock, WSABUF* bufarray, int count, SocketFlags flags, out int error, bool blocking);
- static int Receive_internal (SafeSocketHandle safeHandle, byte[] buffer, int offset, int count, SocketFlags flags, out int error, bool blocking)
+ static unsafe int Receive_internal (SafeSocketHandle safeHandle, byte* buffer, int count, SocketFlags flags, out int error, bool blocking)
{
try {
safeHandle.RegisterForBlockingSyscall ();
- return Receive_internal (safeHandle.DangerousGetHandle (), buffer, offset, count, flags, out error, blocking);
+ return Receive_internal (safeHandle.DangerousGetHandle (), buffer, count, flags, out error, blocking);
} finally {
safeHandle.UnRegisterForBlockingSyscall ();
}
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- extern static int Receive_internal(IntPtr sock, byte[] buffer, int offset, int count, SocketFlags flags, out int error, bool blocking);
+ extern static unsafe int Receive_internal(IntPtr sock, byte* buffer, int count, SocketFlags flags, out int error, bool blocking);
#endregion
SocketAddress sockaddr = remoteEP.Serialize();
int nativeError;
- int cnt = ReceiveFrom_internal (m_Handle, buffer, offset, size, socketFlags, ref sockaddr, out nativeError, is_blocking);
+ int cnt;
+ unsafe {
+ fixed (byte* pbuffer = buffer) {
+ cnt = ReceiveFrom_internal (m_Handle, &pbuffer[offset], size, socketFlags, ref sockaddr, out nativeError, is_blocking);
+ }
+ }
errorCode = (SocketError) nativeError;
if (errorCode != SocketError.Success) {
- static int ReceiveFrom_internal (SafeSocketHandle safeHandle, byte[] buffer, int offset, int count, SocketFlags flags, ref SocketAddress sockaddr, out int error, bool blocking)
+ static unsafe int ReceiveFrom_internal (SafeSocketHandle safeHandle, byte* buffer, int count, SocketFlags flags, ref SocketAddress sockaddr, out int error, bool blocking)
{
try {
safeHandle.RegisterForBlockingSyscall ();
- return ReceiveFrom_internal (safeHandle.DangerousGetHandle (), buffer, offset, count, flags, ref sockaddr, out error, blocking);
+ return ReceiveFrom_internal (safeHandle.DangerousGetHandle (), buffer, count, flags, ref sockaddr, out error, blocking);
} finally {
safeHandle.UnRegisterForBlockingSyscall ();
}
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- extern static int ReceiveFrom_internal(IntPtr sock, byte[] buffer, int offset, int count, SocketFlags flags, ref SocketAddress sockaddr, out int error, bool blocking);
+ extern static unsafe int ReceiveFrom_internal(IntPtr sock, byte* buffer, int count, SocketFlags flags, ref SocketAddress sockaddr, out int error, bool blocking);
#endregion
int nativeError;
int sent = 0;
do {
- sent += Send_internal (
-m_Handle, buffer, offset + sent, size - sent, socketFlags, out nativeError, is_blocking);
+ unsafe {
+ fixed (byte *pbuffer = buffer) {
+ sent += Send_internal (m_Handle, &pbuffer[offset + sent], size - sent, socketFlags, out nativeError, is_blocking);
+ }
+ }
+
errorCode = (SocketError)nativeError;
if (errorCode != SocketError.Success && errorCode != SocketError.WouldBlock && errorCode != SocketError.InProgress) {
is_connected = false;
int nativeError;
int ret;
- WSABUF[] bufarray = new WSABUF[numsegments];
GCHandle[] gch = new GCHandle[numsegments];
+ try {
+ unsafe {
+ fixed (WSABUF* bufarray = new WSABUF[numsegments]) {
+ for(int i = 0; i < numsegments; i++) {
+ ArraySegment<byte> segment = buffers[i];
- for(int i = 0; i < numsegments; i++) {
- ArraySegment<byte> segment = buffers[i];
+ if (segment.Offset < 0 || segment.Count < 0 || segment.Count > segment.Array.Length - segment.Offset)
+ throw new ArgumentOutOfRangeException ("segment");
- if (segment.Offset < 0 || segment.Count < 0 || segment.Count > segment.Array.Length - segment.Offset)
- throw new ArgumentOutOfRangeException ("segment");
+ try {} finally {
+ gch[i] = GCHandle.Alloc (segment.Array, GCHandleType.Pinned);
+ }
- gch[i] = GCHandle.Alloc (segment.Array, GCHandleType.Pinned);
- bufarray[i].len = segment.Count;
- bufarray[i].buf = Marshal.UnsafeAddrOfPinnedArrayElement (segment.Array, segment.Offset);
- }
+ bufarray[i].len = segment.Count;
+ bufarray[i].buf = Marshal.UnsafeAddrOfPinnedArrayElement (segment.Array, segment.Offset);
+ }
- try {
- ret = Send_internal (m_Handle, bufarray, socketFlags, out nativeError, is_blocking);
- } finally {
- for(int i = 0; i < numsegments; i++) {
- if (gch[i].IsAllocated) {
- gch[i].Free ();
+ ret = Send_internal (m_Handle, bufarray, numsegments, socketFlags, out nativeError, is_blocking);
}
}
+ } finally {
+ for (int i = 0; i < numsegments; i++) {
+ if (gch[i].IsAllocated)
+ gch[i].Free();
+ }
}
errorCode = (SocketError)nativeError;
int total = 0;
try {
- total = Socket.Send_internal (sockares.socket.m_Handle, sockares.Buffer, sockares.Offset, sockares.Size, sockares.SockFlags, out sockares.error, false);
+ unsafe {
+ fixed (byte *pbuffer = sockares.Buffer) {
+ total = Socket.Send_internal (sockares.socket.m_Handle, &pbuffer[sockares.Offset], sockares.Size, sockares.SockFlags, out sockares.error, false);
+ }
+ }
} catch (Exception e) {
sockares.Complete (e);
return;
return sockares.Total;
}
- static int Send_internal (SafeSocketHandle safeHandle, WSABUF[] bufarray, SocketFlags flags, out int error, bool blocking)
+ static unsafe int Send_internal (SafeSocketHandle safeHandle, WSABUF* bufarray, int count, SocketFlags flags, out int error, bool blocking)
{
try {
safeHandle.RegisterForBlockingSyscall ();
- return Send_internal (safeHandle.DangerousGetHandle (), bufarray, flags, out error, blocking);
+ return Send_internal (safeHandle.DangerousGetHandle (), bufarray, count, flags, out error, blocking);
} finally {
safeHandle.UnRegisterForBlockingSyscall ();
}
}
[MethodImplAttribute (MethodImplOptions.InternalCall)]
- extern static int Send_internal (IntPtr sock, WSABUF[] bufarray, SocketFlags flags, out int error, bool blocking);
+ extern static unsafe int Send_internal (IntPtr sock, WSABUF* bufarray, int count, SocketFlags flags, out int error, bool blocking);
- static int Send_internal (SafeSocketHandle safeHandle, byte[] buf, int offset, int count, SocketFlags flags, out int error, bool blocking)
+ static unsafe int Send_internal (SafeSocketHandle safeHandle, byte* buffer, int count, SocketFlags flags, out int error, bool blocking)
{
try {
safeHandle.RegisterForBlockingSyscall ();
- return Send_internal (safeHandle.DangerousGetHandle (), buf, offset, count, flags, out error, blocking);
+ return Send_internal (safeHandle.DangerousGetHandle (), buffer, count, flags, out error, blocking);
} finally {
safeHandle.UnRegisterForBlockingSyscall ();
}
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- extern static int Send_internal(IntPtr sock, byte[] buf, int offset, int count, SocketFlags flags, out int error, bool blocking);
+ extern static unsafe int Send_internal(IntPtr sock, byte* buffer, int count, SocketFlags flags, out int error, bool blocking);
#endregion
throw new ArgumentNullException("remoteEP");
int error;
- int ret = SendTo_internal (m_Handle, buffer, offset, size, socketFlags, remoteEP.Serialize (), out error, is_blocking);
+ int ret;
+ unsafe {
+ fixed (byte *pbuffer = buffer) {
+ ret = SendTo_internal (m_Handle, &pbuffer[offset], size, socketFlags, remoteEP.Serialize (), out error, is_blocking);
+ }
+ }
SocketError err = (SocketError) error;
if (err != 0) {
return sockares.Total;
}
- static int SendTo_internal (SafeSocketHandle safeHandle, byte[] buffer, int offset, int count, SocketFlags flags, SocketAddress sa, out int error, bool blocking)
+ static unsafe int SendTo_internal (SafeSocketHandle safeHandle, byte* buffer, int count, SocketFlags flags, SocketAddress sa, out int error, bool blocking)
{
try {
safeHandle.RegisterForBlockingSyscall ();
- return SendTo_internal (safeHandle.DangerousGetHandle (), buffer, offset, count, flags, sa, out error, blocking);
+ return SendTo_internal (safeHandle.DangerousGetHandle (), buffer, count, flags, sa, out error, blocking);
} finally {
safeHandle.UnRegisterForBlockingSyscall ();
}
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- extern static int SendTo_internal (IntPtr sock, byte[] buffer, int offset, int count, SocketFlags flags, SocketAddress sa, out int error, bool blocking);
+ extern static unsafe int SendTo_internal (IntPtr sock, byte* buffer, int count, SocketFlags flags, SocketAddress sa, out int error, bool blocking);
#endregion
[TestFixture]
public class SocketTest
{
- // note: also used in SocketCas tests
public const string BogusAddress = "192.168.244.244";
- public const int BogusPort = 23483;
[Test]
#if FEATURE_NO_BSD_SOCKETS
public void BogusEndConnect ()
{
IPAddress ipOne = IPAddress.Parse (BogusAddress);
- IPEndPoint ipEP = new IPEndPoint (ipOne, BogusPort);
+ IPEndPoint ipEP = new IPEndPoint (ipOne, NetworkHelpers.FindFreePort ());
Socket sock = new Socket (ipEP.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
IAsyncResult ar = sock.BeginConnect (ipEP, null, null);
Socket sock = new Socket (AddressFamily.InterNetwork,
SocketType.Stream,
ProtocolType.Tcp);
- IPEndPoint ep = new IPEndPoint (IPAddress.Loopback,
- BogusPort);
+ IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
SocketError_event.Reset ();
Socket sock = new Socket (AddressFamily.InterNetwork,
SocketType.Stream,
ProtocolType.Tcp);
- IPEndPoint ep = new IPEndPoint (IPAddress.Loopback,
- BogusPort);
+ IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
Assert.AreEqual (false, sock.IsBound, "IsBoundTcp #1");
Socket sock = new Socket (AddressFamily.InterNetwork,
SocketType.Dgram,
ProtocolType.Udp);
- IPEndPoint ep = new IPEndPoint (IPAddress.Loopback,
- BogusPort);
+ IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
Assert.AreEqual (false, sock.IsBound, "IsBoundUdp #1");
[Test]
public void BeginConnectAddressPortNull ()
{
+ var port = NetworkHelpers.FindFreePort ();
Socket sock = new Socket (AddressFamily.InterNetwork,
SocketType.Stream,
ProtocolType.Tcp);
IPAddress ip = null;
try {
- sock.BeginConnect (ip, 1244, BCCallback,
+ sock.BeginConnect (ip, port, BCCallback,
sock);
Assert.Fail ("BeginConnectAddressPortNull #1");
} catch (ArgumentNullException) {
[ExpectedException (typeof(ObjectDisposedException))]
public void BeginConnectAddressPortClosed ()
{
+ var port = NetworkHelpers.FindFreePort ();
Socket sock = new Socket (AddressFamily.InterNetwork,
SocketType.Stream,
ProtocolType.Tcp);
sock.Close ();
- sock.BeginConnect (ip, 1244, BCCallback, sock);
+ sock.BeginConnect (ip, port, BCCallback, sock);
}
[Test]
[Test]
public void BeginConnectMultipleNull ()
{
+ var port = NetworkHelpers.FindFreePort ();
Socket sock = new Socket (AddressFamily.InterNetwork,
SocketType.Stream,
ProtocolType.Tcp);
IPAddress[] ips = null;
try {
- sock.BeginConnect (ips, 1246, BCCallback,
+ sock.BeginConnect (ips, port, BCCallback,
sock);
Assert.Fail ("BeginConnectMultipleNull #1");
} catch (ArgumentNullException) {
[ExpectedException (typeof(ObjectDisposedException))]
public void BeginConnectMultipleClosed ()
{
+ var port = NetworkHelpers.FindFreePort ();
Socket sock = new Socket (AddressFamily.InterNetwork,
SocketType.Stream,
ProtocolType.Tcp);
sock.Close ();
- sock.BeginConnect (ips, 1247, BCCallback, sock);
+ sock.BeginConnect (ips, port, BCCallback, sock);
}
[Test]
[Test]
public void ConnectAddressPortNull ()
{
+ var port = NetworkHelpers.FindFreePort ();
Socket sock = new Socket (AddressFamily.InterNetwork,
SocketType.Stream,
ProtocolType.Tcp);
IPAddress ip = null;
try {
- sock.Connect (ip, 1249);
+ sock.Connect (ip, port);
Assert.Fail ("ConnectAddressPortNull #1");
} catch (ArgumentNullException) {
} finally {
[ExpectedException (typeof(ObjectDisposedException))]
public void ConnectAddressPortClosed ()
{
+ var port = NetworkHelpers.FindFreePort ();
Socket sock = new Socket (AddressFamily.InterNetwork,
SocketType.Stream,
ProtocolType.Tcp);
sock.Close ();
- sock.Connect (ip, 1250);
+ sock.Connect (ip, port);
}
[Test]
[Test]
public void ConnectMultipleNull ()
{
+ var port = NetworkHelpers.FindFreePort ();
Socket sock = new Socket (AddressFamily.InterNetwork,
SocketType.Stream,
ProtocolType.Tcp);
IPAddress[] ips = null;
try {
- sock.Connect (ips, 1251);
+ sock.Connect (ips, port);
Assert.Fail ("ConnectMultipleNull #1");
} catch (ArgumentNullException) {
} finally {
[ExpectedException (typeof(ObjectDisposedException))]
public void ConnectMultipleClosed ()
{
+ var port = NetworkHelpers.FindFreePort ();
Socket sock = new Socket (AddressFamily.InterNetwork,
SocketType.Stream,
ProtocolType.Tcp);
sock.Close ();
- sock.Connect (ips, 1252);
+ sock.Connect (ips, port);
}
[Test]
IPv6MulticastOption option = new IPv6MulticastOption (
IPAddress.Parse ("ff02::1"));
- s.Bind (new IPEndPoint (IPAddress.IPv6Any, 1902));
+ s.Bind (new IPEndPoint (IPAddress.IPv6Any, 0));
s.SetSocketOption (SocketOptionLevel.IPv6, SocketOptionName.AddMembership,
option);
s.SetSocketOption (SocketOptionLevel.IPv6, SocketOptionName.DropMembership,
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
+ [Ignore ("https://bugzilla.xamarin.com/show_bug.cgi?id=43172")]
public void SendAsyncFile ()
{
Socket serverSocket = new Socket (AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
TcpClient client = new TcpClient ();
IPAddress[] ipAddresses = null;
- client.Connect (ipAddresses, 1234);
+ client.Connect (ipAddresses, NetworkHelpers.FindFreePort ());
}
[Test]
ipAddresses[0] = IPAddress.Any;
try {
- client.Connect (ipAddresses, 1234);
+ client.Connect (ipAddresses, NetworkHelpers.FindFreePort ());
Assert.Fail ("ConnectMultiAny #1");
} catch (SocketException ex) {
Assert.AreEqual (10049, ex.ErrorCode, "ConnectMultiAny #2");
ipAddresses[0] = IPAddress.Loopback;
try {
- client.Connect (ipAddresses, 1234);
+ client.Connect (ipAddresses, NetworkHelpers.FindFreePort ());
Assert.Fail ("ConnectMultiRefused #1");
} catch (SocketException ex) {
Assert.AreEqual (10061, ex.ErrorCode, "ConnectMultiRefused #2");
using NUnit.Framework;
+using MonoTests.Helpers;
+
namespace MonoTests.System.Net.Sockets {
[TestFixture]
public class UdpClientTest {
IPEndPoint localEP;
IPEndPoint clientEP;
- clientEP = new IPEndPoint (IPAddress.Loopback, 8001);
+ clientEP = new IPEndPoint (IPAddress.Loopback, NetworkHelpers.FindFreePort ());
using (MyUdpClient client = new MyUdpClient (clientEP))
{
s = client.Client;
Socket s;
IPEndPoint localEP;
- // Bug #5503
- // UDP port 0 doesn't seem to be valid.
- using (MyUdpClient client = new MyUdpClient ("127.0.0.1", 53))
+ using (MyUdpClient client = new MyUdpClient ("127.0.0.1", NetworkHelpers.FindFreePort ()))
{
s = client.Client;
Assert.IsNotNull (s, "#A:Client");
byte[] bytes = new byte[] {10, 11, 12, 13};
try {
- client.Send (bytes, bytes.Length, new IPEndPoint (IPAddress.Broadcast, 1235));
+ client.Send (bytes, bytes.Length, new IPEndPoint (IPAddress.Broadcast, NetworkHelpers.FindFreePort ()));
} finally {
client.Close ();
}
{
IPAddress mcast_addr = IPAddress.Parse ("224.0.0.23");
- using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Any, 1234))) {
+ using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Any, 0))) {
client.JoinMulticastGroup (mcast_addr);
}
}
IPAddress mcast_addr = IPAddress.Parse ("ff02::1");
- using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.IPv6Any, 1234))) {
+ using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.IPv6Any, 0))) {
client.JoinMulticastGroup (mcast_addr);
}
}
#endif
public void JoinMulticastGroup1_MulticastAddr_Null ()
{
- using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Loopback, 1234))) {
+ using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Loopback, 0))) {
try {
client.JoinMulticastGroup ((IPAddress) null);
Assert.Fail ("#1");
{
IPAddress mcast_addr = null;
- UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Loopback, 1234));
+ UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Loopback, 0));
client.Close ();
try {
client.JoinMulticastGroup (mcast_addr);
{
IPAddress mcast_addr = IPAddress.Parse ("224.0.0.23");
- using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Any, 1234))) {
+ using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Any, 0))) {
try {
client.JoinMulticastGroup (0, mcast_addr);
Assert.Fail ("#1");
IPAddress mcast_addr = IPAddress.Parse ("ff02::1");
- using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.IPv6Any, 1234))) {
+ using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.IPv6Any, 0))) {
client.JoinMulticastGroup (0, mcast_addr);
}
}
#endif
public void JoinMulticastGroup2_MulticastAddr_Null ()
{
- using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Loopback, 1234))) {
+ using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Loopback, 0))) {
try {
client.JoinMulticastGroup (0, (IPAddress) null);
Assert.Fail ("#1");
IPAddress mcast_addr = null;
- UdpClient client = new UdpClient (new IPEndPoint (IPAddress.IPv6Any, 1234));
+ UdpClient client = new UdpClient (new IPEndPoint (IPAddress.IPv6Any, 0));
client.Close ();
try {
client.JoinMulticastGroup (0, mcast_addr);
{
IPAddress mcast_addr = IPAddress.Parse ("224.0.0.23");
- using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Any, 1234))) {
+ using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Any, 0))) {
client.JoinMulticastGroup (mcast_addr, 0);
}
- using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Any, 1234))) {
+ using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Any, 0))) {
client.JoinMulticastGroup (mcast_addr, 255);
}
}
IPAddress mcast_addr = IPAddress.Parse ("ff02::1");
- using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.IPv6Any, 1234))) {
+ using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.IPv6Any, 0))) {
client.JoinMulticastGroup (mcast_addr, 0);
}
- using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.IPv6Any, 1234))) {
+ using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.IPv6Any, 0))) {
client.JoinMulticastGroup (mcast_addr, 255);
}
}
#endif
public void JoinMulticastGroup3_MulticastAddr_Null ()
{
- using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Loopback, 1234))) {
+ using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Loopback, 0))) {
try {
client.JoinMulticastGroup ((IPAddress) null, int.MaxValue);
Assert.Fail ("#1");
{
IPAddress mcast_addr = null;
- UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Any, 1234));
+ UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Any, 0));
client.Close ();
try {
client.JoinMulticastGroup (mcast_addr, 0);
IPAddress mcast_addr = IPAddress.Parse ("224.0.0.23");
IPAddress local_addr = IPAddress.Any;
- using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Any, 1234))) {
+ using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Any, 0))) {
client.JoinMulticastGroup (mcast_addr, local_addr);
}
}
IPAddress mcast_addr = IPAddress.Parse ("ff02::1");
IPAddress local_addr = IPAddress.IPv6Any;
- using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.IPv6Any, 1234))) {
+ using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.IPv6Any, 0))) {
try {
client.JoinMulticastGroup (mcast_addr, local_addr);
Assert.Fail ("#1");
{
IPAddress mcast_addr = IPAddress.Parse ("224.0.0.23");
- using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Loopback, 1234))) {
+ using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Loopback, 0))) {
try {
client.JoinMulticastGroup (mcast_addr, (IPAddress) null);
Assert.Fail ("#1");
#endif
public void JoinMulticastGroup4_MulticastAddr_Null ()
{
- using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Loopback, 1234))) {
+ using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Loopback, 0))) {
try {
client.JoinMulticastGroup ((IPAddress) null, IPAddress.Loopback);
Assert.Fail ("#1");
IPAddress mcast_addr = null;
IPAddress local_addr = null;
- UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Any, 1234));
+ UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Any, 0));
client.Close ();
try {
client.JoinMulticastGroup (mcast_addr, local_addr);
#endif
public void CloseInReceive ()
{
- UdpClient client = null;
- var rnd = new Random ();
- for (int i = 0, max = 5; i < max; i++) {
- int port = rnd.Next (1025, 65534);
- try {
- client = new UdpClient (port);
- break;
- } catch (Exception) {
- if (i == max - 1)
- throw;
- }
- }
+ UdpClient client = new UdpClient (NetworkHelpers.FindFreePort ());
ManualResetEvent ready = new ManualResetEvent (false);
bool got_exc = false;
#endif
public void JoinMulticastGroupWithLocal ()
{
- UdpClient client = new UdpClient (9001);
+ UdpClient client = new UdpClient (0);
IPAddress mcast_addr = IPAddress.Parse ("224.0.0.24");
IPAddress local_addr = IPAddress.Any;
IPEndPoint ep = null;
foreach (IPAddress a in addresses) {
if (a.AddressFamily == AddressFamily.InterNetwork) {
- ep = new IPEndPoint (a, 1236);
+ ep = new IPEndPoint (a, NetworkHelpers.FindFreePort ());
break;
}
}
#endif
public void BeginReceive ()
{
- UdpClient client = new UdpClient (1237);
+ var port = NetworkHelpers.FindFreePort ();
+ UdpClient client = new UdpClient (port);
BRCalledBack.Reset ();
client.BeginReceive (BRCallback, client);
- IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 1237);
+ IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, port);
byte[] send_bytes = new byte[] {10, 11, 12, 13};
client.Send (send_bytes, send_bytes.Length, ep);
#endif
public void Available ()
{
- using (UdpClient client = new UdpClient (1238)) {
- IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 1238);
+ var port = NetworkHelpers.FindFreePort ();
+ using (UdpClient client = new UdpClient (port)) {
+ IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, port);
byte[] bytes = new byte[] {10, 11, 12, 13};
int res = client.Send (bytes, bytes.Length, ep);
[Category ("NotWorking")] // Not supported on Linux
public void ExclusiveAddressUseBound ()
{
- UdpClient client = new UdpClient (1239);
+ UdpClient client = new UdpClient (0);
client.ExclusiveAddressUse = true;
if (!Socket.OSSupportsIPv6)
Assert.Ignore ("IPv6 not enabled.");
- int PORT = 9997;
- using(var udpClient = new UdpClient (PORT, AddressFamily.InterNetworkV6))
- using(var udpClient2 = new UdpClient (PORT+1, AddressFamily.InterNetworkV6))
+ int port1 = NetworkHelpers.FindFreePort ();
+ int port2 = NetworkHelpers.FindFreePort ();
+ using(var udpClient = new UdpClient (port1, AddressFamily.InterNetworkV6))
+ using(var udpClient2 = new UdpClient (port2, AddressFamily.InterNetworkV6))
{
var dataSent = new byte [] {1,2,3};
- udpClient2.SendAsync (dataSent, dataSent.Length, "::1", PORT);
+ udpClient2.SendAsync (dataSent, dataSent.Length, "::1", port1);
IPEndPoint endPoint = new IPEndPoint (IPAddress.IPv6Any, 0);
var data = udpClient.Receive (ref endPoint);
using NUnit.Framework;
using HLPC=System.Net.HttpListenerPrefixCollection;
+using MonoTests.Helpers;
+
namespace MonoTests.System.Net {
[TestFixture]
public class HttpListenerPrefixCollectionTest {
#endif
public void AddOne ()
{
+ var port = NetworkHelpers.FindFreePort ();
HttpListener listener = new HttpListener ();
HLPC coll = listener.Prefixes;
listener.Start ();
- coll.Add ("http://127.0.0.1:8181/");
+ coll.Add ($"http://127.0.0.1:{port}/");
Assert.AreEqual (1, coll.Count, "Count");
Assert.IsFalse (coll.IsReadOnly, "IsReadOnly");
Assert.IsFalse (coll.IsSynchronized, "IsSynchronized");
#endif
public void Duplicate ()
{
+ var port = NetworkHelpers.FindFreePort ();
HttpListener listener = new HttpListener ();
HLPC coll = listener.Prefixes;
- coll.Add ("http://127.0.0.1:8181/");
- coll.Add ("http://127.0.0.1:8181/");
+ coll.Add ($"http://127.0.0.1:{port}/");
+ coll.Add ($"http://127.0.0.1:{port}/");
listener.Start ();
Assert.AreEqual (1, coll.Count, "Count");
Assert.IsFalse (coll.IsReadOnly, "IsReadOnly");
Mono.Btls/MonoBtlsSsl.cs
Mono.Btls/MonoBtlsSslCtx.cs
Mono.Btls/MonoBtlsSslError.cs
+Mono.Btls/MonoBtlsSslRenegotiateMode.cs
Mono.Btls/MonoBtlsStream.cs
Mono.Btls/MonoBtlsUtils.cs
Mono.Btls/MonoBtlsX509.cs
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 ()
+++ /dev/null
-//
-// System.Runtime.Remoting.RemotingServices NUnit V2.0 test class
-//
-// Author Jean-Marc ANDRE (jean-marc.andre@polymtl.ca)
-//
-// ToDo: I didn't write test functions for the method not yep
-// implemented by Mono
-
-using System;
-using System.Collections;
-using NUnit.Framework;
-using System.Reflection;
-using System.Runtime.Remoting;
-using System.Threading;
-using System.Runtime.Remoting.Activation;
-using System.Runtime.Remoting.Messaging;
-using System.Runtime.Remoting.Proxies;
-using System.Runtime.Remoting.Channels;
-using System.Runtime.Remoting.Channels.Tcp;
-
-namespace MonoTests.System.Runtime.Remoting.RemotingServicesInternal
-{
- // We need our own proxy to intercept messages to remote object
- // and forward them using RemotingServices.ExecuteMessage
- public class MyProxy: RealProxy
- {
- MarshalByRefObject target;
- IMessageSink _sink;
- MethodBase _mthBase;
- bool methodOverloaded = false;
-
- public MethodBase MthBase
- {
- get{ return _mthBase;}
- }
-
- public bool IsMethodOverloaded
- {
- get{return methodOverloaded;}
- }
-
- public MyProxy(Type serverType, MarshalByRefObject target): base(serverType)
- {
- this.target = target;
-
- IChannel[] registeredChannels = ChannelServices.RegisteredChannels;
- string ObjectURI;
-
- // A new IMessageSink chain has to be created
- // since the RemotingServices.GetEnvoyChainForProxy() is not yet
- // implemented.
- foreach(IChannel channel in registeredChannels)
- {
- IChannelSender channelSender = channel as IChannelSender;
- if(channelSender != null)
- {
- _sink = (IMessageSink) channelSender.CreateMessageSink(RemotingServices.GetObjectUri(target), null, out ObjectURI);
- }
- }
-
- }
-
- // Messages will be intercepted here and redirected
- // to another object.
- public override IMessage Invoke(IMessage msg)
- {
- if(msg is IConstructionCallMessage)
- {
- IActivator remActivator = (IActivator) RemotingServices.Connect(typeof(IActivator), "tcp://localhost:1234/RemoteActivationService.rem");
- IConstructionReturnMessage crm = remActivator.Activate((IConstructionCallMessage)msg);
- return crm;
- }
- else
- {
- methodOverloaded = RemotingServices.IsMethodOverloaded((IMethodMessage)msg);
-
- _mthBase = RemotingServices.GetMethodBaseFromMethodMessage((IMethodMessage)msg);
- MethodCallMessageWrapper mcm = new MethodCallMessageWrapper((IMethodCallMessage) msg);
- mcm.Uri = RemotingServices.GetObjectUri((MarshalByRefObject)target);
- MarshalByRefObject objRem = (MarshalByRefObject)Activator.CreateInstance(GetProxiedType());
- RemotingServices.ExecuteMessage((MarshalByRefObject)objRem, (IMethodCallMessage)msg);
- IMessage rtnMsg = null;
-
- try
- {
- rtnMsg = _sink.SyncProcessMessage(msg);
- }
- catch(Exception e)
- {
- Console.WriteLine(e.Message);
- }
-
- return rtnMsg;
- }
- }
- } // end MyProxy
-
- // This class is used to create "CAO"
- public class MarshalObjectFactory: MarshalByRefObject
- {
- public MarshalObject GetNewMarshalObject()
- {
- return new MarshalObject();
- }
- }
-
- // A class used by the tests
- public class MarshalObject: ContextBoundObject
- {
- public MarshalObject()
- {
-
- }
-
- public MarshalObject(int id, string uri)
- {
- this.id = id;
- this.uri = uri;
- }
- public int Id
- {
- get{return id;}
- set{id = value;}
- }
- public string Uri
- {
- get{return uri;}
- }
-
- public void Method1()
- {
- _called++;
- methodOneWay = RemotingServices.IsOneWay(MethodBase.GetCurrentMethod());
- }
-
- public void Method2()
- {
- methodOneWay = RemotingServices.IsOneWay(MethodBase.GetCurrentMethod());
- }
-
- public void Method2(int i)
- {
- methodOneWay = RemotingServices.IsOneWay(MethodBase.GetCurrentMethod());
-
- }
-
- [OneWay()]
- public void Method3()
- {
- methodOneWay = RemotingServices.IsOneWay(MethodBase.GetCurrentMethod());
-
- }
-
- public static int Called
- {
- get{return _called;}
- }
-
- public static bool IsMethodOneWay
- {
- get{return methodOneWay;}
- }
-
-
- private static int _called;
- private int id = 0;
- private string uri;
- private static bool methodOneWay = false;
- }
-
- // Another class used by the tests
- public class DerivedMarshalObject: MarshalObject
- {
- public DerivedMarshalObject(){}
-
- public DerivedMarshalObject(int id, string uri): base(id, uri) {}
- }
-} // namespace MonoTests.System.Runtime.Remoting.RemotingServicesInternal
-
-namespace MonoTests.System.Runtime.Remoting
-{
- using MonoTests.System.Runtime.Remoting.RemotingServicesInternal;
-
- // The main test class
- [TestFixture]
- public class RemotingServicesTest
- {
- private static int MarshalObjectId = 0;
-
- public RemotingServicesTest()
- {
- MarshalObjectId = 0;
- }
-
- // Helper function that create a new
- // MarshalObject with an unique ID
- private static MarshalObject NewMarshalObject()
- {
- string uri = "MonoTests.System.Runtime.Remoting.RemotingServicesTest.MarshalObject" + MarshalObjectId.ToString();
- MarshalObject objMarshal = new MarshalObject(MarshalObjectId, uri);
-
- MarshalObjectId++;
-
- return objMarshal;
- }
-
- // Another helper function
- private DerivedMarshalObject NewDerivedMarshalObject()
- {
- string uri = "MonoTests.System.Runtime.Remoting.RemotingServicesTest.DerivedMarshalObject" + MarshalObjectId.ToString();
- DerivedMarshalObject objMarshal = new DerivedMarshalObject(MarshalObjectId, uri);
-
- MarshalObjectId++;
-
- return objMarshal;
- }
-
- // The two folling method test RemotingServices.Marshal()
- [Test]
- public void Marshal1()
- {
-
- MarshalObject objMarshal = NewMarshalObject();
- ObjRef objRef = RemotingServices.Marshal(objMarshal);
-
- Assert.IsTrue(objRef.URI != null, "#A01");
-
- MarshalObject objRem = (MarshalObject) RemotingServices.Unmarshal(objRef);
- Assert.AreEqual(objMarshal.Id, objRem.Id, "#A02");
-
- objRem.Id = 2;
- Assert.AreEqual(objMarshal.Id, objRem.Id, "#A03");
-
- // TODO: uncomment when RemotingServices.Disconnect is implemented
- //RemotingServices.Disconnect(objMarshal);
-
- objMarshal = NewMarshalObject();
-
- objRef = RemotingServices.Marshal(objMarshal, objMarshal.Uri);
-
- Assert.IsTrue(objRef.URI.EndsWith(objMarshal.Uri), "#A04");
- // TODO: uncomment when RemotingServices.Disconnect is implemented
- //RemotingServices.Disconnect(objMarshal);
- }
-
- [Test]
- public void Marshal2()
- {
- DerivedMarshalObject derivedObjMarshal = NewDerivedMarshalObject();
-
- ObjRef objRef = RemotingServices.Marshal(derivedObjMarshal, derivedObjMarshal.Uri, typeof(MarshalObject));
-
- // Check that the type of the marshaled object is MarshalObject
- Assert.IsTrue(objRef.TypeInfo.TypeName.StartsWith((typeof(MarshalObject)).ToString()), "#A05");
-
- // TODO: uncomment when RemotingServices.Disconnect is implemented
- //RemotingServices.Disconnect(derivedObjMarshal);
- }
-
- // Tests RemotingServices.GetObjectUri()
- [Test]
- public void GetObjectUri()
- {
- MarshalObject objMarshal = NewMarshalObject();
-
- Assert.IsTrue(RemotingServices.GetObjectUri(objMarshal) == null, "#A06");
-
- ObjRef objRef = RemotingServices.Marshal(objMarshal);
-
- Assert.IsTrue(RemotingServices.GetObjectUri(objMarshal) != null, "#A07");
- // TODO: uncomment when RemotingServices.Disconnect is implemented
- //RemotingServices.Disconnect(objMarshal);
- }
-
- // Tests RemotingServices.Connect
- [Test]
- public void Connect()
- {
- MarshalObject objMarshal = NewMarshalObject();
-
- IDictionary props = new Hashtable();
- props["name"] = objMarshal.Uri;
- props["port"] = 1236;
- TcpChannel chn = new TcpChannel(props, null, null);
- ChannelServices.RegisterChannel(chn);
-
- RemotingServices.Marshal(objMarshal,objMarshal.Uri);
-
- MarshalObject objRem = (MarshalObject) RemotingServices.Connect(typeof(MarshalObject), "tcp://localhost:1236/" + objMarshal.Uri);
-
- Assert.IsTrue(RemotingServices.IsTransparentProxy(objRem), "#A08");
-
- ChannelServices.UnregisterChannel(chn);
-
- // TODO: uncomment when RemotingServices.Disconnect is implemented
- //RemotingServices.Disconnect(objMarshal);
- }
-
- // Tests RemotingServices.Marshal()
- [Test]
- [ExpectedException(typeof(RemotingException))]
- public void MarshalThrowException()
- {
- MarshalObject objMarshal = NewMarshalObject();
-
- IDictionary props = new Hashtable();
- props["name"] = objMarshal.Uri;
- props["port"] = 1237;
- TcpChannel chn = new TcpChannel(props, null, null);
- ChannelServices.RegisterChannel(chn);
-
- RemotingServices.Marshal(objMarshal,objMarshal.Uri);
-
- MarshalObject objRem = (MarshalObject) RemotingServices.Connect(typeof(MarshalObject), "tcp://localhost:1237/" + objMarshal.Uri);
- // This line sould throw a RemotingException
- // It is forbidden to export an object which is not
- // a real object
- try
- {
- RemotingServices.Marshal(objRem, objMarshal.Uri);
- }
- catch(Exception e)
- {
- ChannelServices.UnregisterChannel(chn);
-
- // TODO: uncomment when RemotingServices.Disconnect is implemented
- //RemotingServices.Disconnect(objMarshal);
-
- throw e;
- }
- }
-
- // Tests RemotingServices.ExecuteMessage()
- // also tests GetMethodBaseFromMessage()
- // IsMethodOverloaded()
- [Test]
- public void ExecuteMessage()
- {
- TcpChannel chn = null;
- try
- {
- chn = new TcpChannel(1235);
- ChannelServices.RegisterChannel(chn);
-
- MarshalObject objMarshal = NewMarshalObject();
- RemotingConfiguration.RegisterWellKnownServiceType(typeof(MarshalObject), objMarshal.Uri, WellKnownObjectMode.SingleCall);
-
- // use a proxy to catch the Message
- MyProxy proxy = new MyProxy(typeof(MarshalObject), (MarshalObject) Activator.GetObject(typeof(MarshalObject), "tcp://localhost:1235/" + objMarshal.Uri));
-
- MarshalObject objRem = (MarshalObject) proxy.GetTransparentProxy();
-
- objRem.Method1();
-
- // Tests RemotingServices.GetMethodBaseFromMethodMessage()
- AssertEquals("#A09","Method1",proxy.MthBase.Name);
- Assert.IsTrue(!proxy.IsMethodOverloaded, "#A09.1");
-
- objRem.Method2();
- Assert.IsTrue(proxy.IsMethodOverloaded, "#A09.2");
-
- // Tests RemotingServices.ExecuteMessage();
- // If ExecuteMessage does it job well, Method1 should be called 2 times
- Assert.AreEqual(2, MarshalObject.Called, "#A10");
- }
- finally
- {
- if(chn != null) ChannelServices.UnregisterChannel(chn);
- }
- }
-
- // Tests the IsOneWay method
- [Test]
- public void IsOneWay()
- {
- TcpChannel chn = null;
- try
- {
- chn = new TcpChannel(1238);
- ChannelServices.RegisterChannel(chn);
- RemotingConfiguration.RegisterWellKnownServiceType(typeof(MarshalObject), "MarshalObject.rem", WellKnownObjectMode.Singleton);
-
- MarshalObject objRem = (MarshalObject) Activator.GetObject(typeof(MarshalObject), "tcp://localhost:1238/MarshalObject.rem");
-
- Assert.IsTrue(RemotingServices.IsTransparentProxy(objRem), "#A10.1");
-
- objRem.Method1();
- Thread.Sleep(20);
- Assert.IsTrue(!MarshalObject.IsMethodOneWay, "#A10.2");
- objRem.Method3();
- Thread.Sleep(20);
- Assert.IsTrue(MarshalObject.IsMethodOneWay, "#A10.2");
- }
- finally
- {
- if(chn != null) ChannelServices.UnregisterChannel(chn);
- }
- }
-
- [Test]
- public void GetObjRefForProxy()
- {
- TcpChannel chn = null;
- try
- {
- chn = new TcpChannel(1239);
- ChannelServices.RegisterChannel(chn);
-
- // Register le factory as a SAO
- RemotingConfiguration.RegisterWellKnownServiceType(typeof(MarshalObjectFactory), "MonoTests.System.Runtime.Remoting.RemotingServicesTest.Factory.soap", WellKnownObjectMode.Singleton);
-
- MarshalObjectFactory objFactory = (MarshalObjectFactory) Activator.GetObject(typeof(MarshalObjectFactory), "tcp://localhost:1239/MonoTests.System.Runtime.Remoting.RemotingServicesTest.Factory.soap");
-
- // Get a new "CAO"
- MarshalObject objRem = objFactory.GetNewMarshalObject();
-
- ObjRef objRefRem = RemotingServices.GetObjRefForProxy((MarshalByRefObject)objRem);
-
- Assert.IsTrue(objRefRem != null, "#A11");
- }
- finally
- {
- if(chn != null) ChannelServices.UnregisterChannel(chn);
- }
- }
-
- // Tests GetRealProxy
- [Test]
- public void GetRealProxy()
- {
- TcpChannel chn = null;
- try
- {
- chn = new TcpChannel(1241);
- ChannelServices.RegisterChannel(chn);
-
- RemotingConfiguration.RegisterWellKnownServiceType(typeof(MarshalObject), "MonoTests.System.Runtime.Remoting.RemotingServicesTest.MarshalObject.soap", WellKnownObjectMode.Singleton);
-
- MyProxy proxy = new MyProxy(typeof(MarshalObject), (MarshalByRefObject)Activator.GetObject(typeof(MarshalObject), "tcp://localhost:1241/MonoTests.System.Runtime.Remoting.RemotingServicesTest.MarshalObject.soap"));
- MarshalObject objRem = (MarshalObject) proxy.GetTransparentProxy();
-
- RealProxy rp = RemotingServices.GetRealProxy(objRem);
-
- Assert.IsTrue(rp != null, "#A12");
- Assert.AreEqual("MonoTests.System.Runtime.Remoting.RemotingServicesInternal.MyProxy", rp.GetType().ToString(), "#A13");
- }
- finally
- {
- if(chn != null) ChannelServices.UnregisterChannel(chn);
- }
- }
-
- // Tests SetObjectUriForMarshal()
- [Test]
- public void SetObjectUriForMarshal()
- {
- TcpChannel chn = null;
- try
- {
- chn = new TcpChannel(1242);
- ChannelServices.RegisterChannel(chn);
-
- MarshalObject objRem = NewMarshalObject();
- RemotingServices.SetObjectUriForMarshal(objRem, objRem.Uri);
- RemotingServices.Marshal(objRem);
-
- objRem = (MarshalObject) Activator.GetObject(typeof(MarshalObject), "tcp://localhost:1242/"+objRem.Uri);
- Assert.IsTrue(objRem != null, "#A14");
- }
- finally
- {
- if(chn != null) ChannelServices.UnregisterChannel(chn);
- }
-
- }
-
- // Tests GetServeurTypeForUri()
- [Test]
- public void GetServeurTypeForUri()
- {
- TcpChannel chn = null;
- Type type = typeof(MarshalObject);
- try
- {
- chn = new TcpChannel(1243);
- ChannelServices.RegisterChannel(chn);
-
- MarshalObject objRem = NewMarshalObject();
- RemotingServices.SetObjectUriForMarshal(objRem, objRem.Uri);
- RemotingServices.Marshal(objRem);
-
- Type typeRem = RemotingServices.GetServerTypeForUri(RemotingServices.GetObjectUri(objRem));
- Assert.AreEqual(type, typeRem, "#A15");
- }
- finally
- {
- if(chn != null) ChannelServices.UnregisterChannel(chn);
- }
- }
-
- // Tests IsObjectOutOfDomain
- // Tests IsObjectOutOfContext
- [Test]
- public void IsObjectOutOf()
- {
- TcpChannel chn = null;
- try
- {
- chn = new TcpChannel(1245);
- ChannelServices.RegisterChannel(chn);
-
- RemotingConfiguration.RegisterWellKnownServiceType(typeof(MarshalObject), "MarshalObject.rem", WellKnownObjectMode.Singleton);
-
- MarshalObject objRem = (MarshalObject) Activator.GetObject(typeof(MarshalObject), "tcp://localhost:1245/MarshalObject.rem");
-
- Assert.IsTrue(RemotingServices.IsObjectOutOfAppDomain(objRem), "#A16");
- Assert.IsTrue(RemotingServices.IsObjectOutOfContext(objRem), "#A17");
-
- MarshalObject objMarshal = new MarshalObject();
- Assert.IsTrue(!RemotingServices.IsObjectOutOfAppDomain(objMarshal), "#A18");
- Assert.IsTrue(!RemotingServices.IsObjectOutOfContext(objMarshal), "#A19");
- }
- finally
- {
- ChannelServices.UnregisterChannel(chn);
- }
- }
- } // end class RemotingServicesTest
-} // end of namespace MonoTests.System.Runtime.Remoting.RemotingServicesTest
System.Reflection.Emit/SaveTest.cs
System.Runtime.Remoting/ContextTest.cs
System.Runtime.Remoting/RemotingConfigurationTest.cs
-System.Runtime.Remoting/RemotingServicesTest.cs
System.Runtime.Remoting/SoapServicesTest.cs
System.Runtime.Remoting/SynchronizationAttributeTest.cs
System.Runtime.Remoting.Channels/ChannelServicesTest.cs
$(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
{
while (true) {
var ep = new IPEndPoint (IPAddress.Loopback, rndPort.Next (10000, 60000));
- var socket = new Socket (ep.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
try {
- socket.Bind (ep);
- socket.Close ();
+ using (var socket = new Socket (ep.AddressFamily, SocketType.Stream, ProtocolType.Tcp)) {
+ socket.Bind (ep);
+ socket.Close ();
+ }
return ep;
} catch (SocketException) { }
}
private bool keycontainer = false;
private string keyname;
private StrongName sn;
+ bool noautoinherit;
public DriverMain (string[] args)
{
if (output_file == null)
output_file = CreateOutputFilename ();
try {
- codegen = new CodeGen (output_file, target == Target.Dll, debugging_info);
+ codegen = new CodeGen (output_file, target == Target.Dll, debugging_info, noautoinherit);
foreach (string file_path in il_file_list) {
Report.FilePath = file_path;
ProcessFile (file_path);
else
keyname = command_arg;
break;
+ case "noautoinherit":
+ noautoinherit = true;
+ break;
case "scan_only":
scan_only = true;
break;
private void Usage ()
{
- Console.WriteLine ("Mono ILasm compiler\n" +
+ Console.WriteLine ("Mono IL assembler compiler\n" +
"ilasm [options] source-files\n" +
- " --about About the Mono ILasm compiler\n" +
- " --version Print the version number of the Mono ILasm compiler\n" +
+ " --about About the Mono IL assembler compiler\n" +
+ " --version Print the version number of the compiler\n" +
" /output:file_name Specifies output file.\n" +
" /exe Compile to executable.\n" +
" /dll Compile to library.\n" +
" /debug Include debug information.\n" +
" /key:keyfile Strongname using the specified key file\n" +
" /key:@container Strongname using the specified key container\n" +
+ " /noautoinherit Disable inheriting from System.Object by default\n" +
"Options can be of the form -option or /option\n");
Environment.Exit (1);
}
private void Version ()
{
string version = System.Reflection.Assembly.GetExecutingAssembly ().GetName ().Version.ToString ();
- Console.WriteLine ("Mono ILasm compiler version {0}", version);
+ Console.WriteLine ("Mono IL assembler compiler version {0}", version);
Environment.Exit (0);
}
private string output_file;\r
private bool is_dll;\r
private bool entry_point;\r
+ bool noautoinherit;\r
\r
private Module this_module;\r
\r
- public CodeGen (string output_file, bool is_dll, bool debugging_info)\r
+ public CodeGen (string output_file, bool is_dll, bool debugging_info, bool noautoinherit)\r
{\r
this.output_file = output_file;\r
this.is_dll = is_dll;\r
-\r
+ this.noautoinherit = noautoinherit;\r
+ \r
if (debugging_info)\r
symwriter = new SymbolWriter (output_file);\r
\r
\r
typedef = new TypeDef (attr, current_namespace,\r
name, parent, impl_list, location, gen_params, outer);\r
-\r
+ typedef.NoAutoInherit = noautoinherit && parent == null;\r
type_manager[cache_name] = typedef;\r
current_customattrtarget = current_typedef = typedef;\r
current_declsectarget = typedef;\r
this.attr |= PEAPI.TypeAttr.Abstract;
}
+ public bool NoAutoInherit { get; set; }
+
public string Name {
get { return name; }
}
name_space, name);
}
}
- if (FullName == "System.Object")
+ if (FullName == "System.Object" || NoAutoInherit)
classdef.SpecialNoSuper ();
}
<ItemGroup>
<Reference Include="System" />
<Reference Include="PEAPI">
- <HintPath>..\class\lib\net_4_5\PEAPI.dll</HintPath>
+ <HintPath>..\class\lib\net_4_x\PEAPI.dll</HintPath>
</Reference>
<Reference Include="Mono.CompilerServices.SymbolWriter" />
<Reference Include="Mono.Security" />
/* Keywords */\r
%token K_AT\r
%token K_AS\r
+%token K_AGGRESSIVEINLINING\r
%token K_IMPLICITCOM\r
%token K_IMPLICITRES\r
%token K_NOAPPDOMAIN\r
| impl_attr K_SYNCHRONIZED { $$ = (ImplAttr) $1 | ImplAttr.Synchronised; }\r
| impl_attr K_NOINLINING { $$ = (ImplAttr) $1 | ImplAttr.NoInLining; }\r
| impl_attr K_NOOPTIMIZATION { $$ = (ImplAttr) $1 | ImplAttr.NoOptimization; }\r
+ | impl_attr K_AGGRESSIVEINLINING{ $$ = (ImplAttr) $1 | ImplAttr.AggressiveInlining; }\r
;\r
\r
sig_args : /* EMPTY */\r
keywords ["legacy"] = new ILToken (Token.K_LEGACY, "legacy");\r
keywords ["library"] = new ILToken (Token.K_LIBRARY, "library");\r
keywords ["auto"] = new ILToken (Token.K_AUTO, "auto");\r
+ keywords ["aggressiveinlining"] = new ILToken (Token.K_AGGRESSIVEINLINING, "aggressiveinlining");\r
\r
return keywords;\r
}\r
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" +
public static bool CheckOverrideName (TypeSpec type, TypeSpec baseType)
{
var btype_ntuple = baseType as NamedTupleSpec;
- var mtype_ntupe = type as NamedTupleSpec;
- if (btype_ntuple == null && mtype_ntupe == null)
+ var mtype_ntuple = type as NamedTupleSpec;
+ if (btype_ntuple == null && mtype_ntuple == null)
return true;
- if (btype_ntuple != null || mtype_ntupe != null)
+ if (btype_ntuple == null || mtype_ntuple == null)
return false;
var b_elements = btype_ntuple.elements;
- var m_elements = mtype_ntupe.elements;
+ var m_elements = mtype_ntuple.elements;
for (int i = 0; i < b_elements.Count; ++i) {
if (b_elements [i] != m_elements [i])
return false;
--- /dev/null
+class Base
+{
+ public virtual (int, long rest) Foo ()
+ {
+ return (1, 2);
+ }
+}
+
+class Test : Base
+{
+ public override (int, long rest) Foo ()
+ {
+ return (3, 4);
+ }
+
+ public static void Main ()
+ {
+ }
+}
\ No newline at end of file
</method>
</type>
</test>
+ <test name="test-tuple-06.cs">
+ <type name="Base">
+ <method name="System.ValueTuple`2[System.Int32,System.Int64] Foo()" attrs="454">
+ <size>17</size>
+ </method>
+ <method name="Void .ctor()" attrs="6278">
+ <size>7</size>
+ </method>
+ </type>
+ <type name="Test">
+ <method name="System.ValueTuple`2[System.Int32,System.Int64] Foo()" attrs="198">
+ <size>17</size>
+ </method>
+ <method name="Void Main()" attrs="150">
+ <size>2</size>
+ </method>
+ <method name="Void .ctor()" attrs="6278">
+ <size>7</size>
+ </method>
+ </type>
+ </test>
<test name="test-var-01.cs">
<type name="Test">
<method name="Int32 Main()" attrs="150">
return 1;
}
if (sdk_path != null || runtime != null)
- Error ("You can not specify one of --runtime, --sdk or --cross");
+ Error ("You can only specify one of --runtime, --sdk or --cross");
custom_mode = false;
autodeps = true;
cross_target = args [++i];
autodeps = true;
sdk_path = args [++i];
if (cross_target != null || runtime != null)
- Error ("You can not specify one of --runtime, --sdk or --cross");
+ Error ("You can only specify one of --runtime, --sdk or --cross");
break;
case "--runtime":
if (i+1 == top){
return false;
}
maker.Add (code, file);
+ // add a space after code (="systemconfig:" or "machineconfig:")
+ Console.WriteLine (code + " " + file);
return true;
}
Console.WriteLine (" Assembly: " + fname);
if (File.Exists (fname + ".config")){
maker.Add ("config:" + aname, fname + ".config");
- Console.WriteLine (" Config: " + runtime);
+ Console.WriteLine (" Config: " + fname + ".config");
}
}
if (!MaybeAddFile (maker, "systemconfig:", config_file) || !MaybeAddFile (maker, "machineconfig:", machine_config_file))
return false;
- if (config_dir != null)
+ if (config_dir != null){
maker.Add ("config_dir:", config_dir);
+ Console.WriteLine (" Config_dir: " + config_dir );
+ }
if (embedded_options != null)
maker.AddString ("options:", embedded_options);
if (environment.Count > 0){
../../../../external/nunit-lite/NUnitLite-1.0.0/src/framework/Internal/Commands/CommandStage.cs
../../../../external/nunit-lite/NUnitLite-1.0.0/src/framework/Internal/Commands/DelegatingTestCommand.cs
../../../../external/nunit-lite/NUnitLite-1.0.0/src/framework/Internal/Commands/ExpectedExceptionCommand.cs
+../../../../external/nunit-lite/NUnitLite-1.0.0/src/framework/Internal/Commands/FlakyTestRetriesCommand.cs
../../../../external/nunit-lite/NUnitLite-1.0.0/src/framework/Internal/Commands/ICommandDecorator.cs
../../../../external/nunit-lite/NUnitLite-1.0.0/src/framework/Internal/Commands/MaxTimeCommand.cs
../../../../external/nunit-lite/NUnitLite-1.0.0/src/framework/Internal/Commands/OneTimeSetUpCommand.cs
#define S390_RRE(c,opc,g1,g2) s390_emit32(c, (opc << 16 | (g1) << 4 | g2))
-#define S390_RRF_1(c,opc,g1,g2,g3) s390_emit32(c, (opc << 16 | (g1) << 12 | (g3) << 4 | g2))
+#define S390_RRF_1(c,opc,g1,g2,g3) s390_emit32(c, (opc << 16 | (g3) << 12 | (g1) << 4 | g2))
#define S390_RRF_2(c,opc,g1,k3,g2) s390_emit32(c, (opc << 16 | (k3) << 12 | (g1) << 4 | g2))
#define S390_RIE_2(c,opc,g1,g2,m3,v) do \
{ \
- s390_emit16(c, ((opc & 0xff00) | (g1) << 4 | g3)); \
+ s390_emit16(c, ((opc & 0xff00) | (g1) << 4 | g2)); \
s390_emit16(c, (v)); \
- s390_emit16(c, ((m2) << 12 | (opc & 0xff))); \
+ s390_emit16(c, ((m3) << 12 | (opc & 0xff))); \
} while (0)
#define S390_RIE_3(c,opc,g1,i,m3,d) do \
#define s390_agf(c, r, x, b, d) S390_RXY(c, 0xe318, r, x, b, d)
#define s390_agfi(c, r, v) S390_RIL_1(c, 0xc28, r, v)
#define s390_afgr(c, r1, r2) S390_RRE(c, 0xb918, r1, r2)
+#define s390_agh(c, r, x, b, d) S390_RXY(c, 0xe338, r, b, d)
#define s390_aghi(c, r, v) S390_RI(c, 0xa7b, r, v)
-#define s390_aghik(c, r, v) S390_RIE_1(c, 0xecd9, r, v)
+#define s390_aghik(c, r1, r3, v) S390_RIE_1(c, 0xecd9, r1, r3, v)
#define s390_agr(c, r1, r2) S390_RRE(c, 0xb908, r1, r2)
#define s390_agrk(c, r1, r2, r3) S390_RRF_1(c, 0xb9e8, r1, r2, r3)
#define s390_agsi(c, r, v) S390_SIY(c, 0xeb7a, r v)
#define s390_ahhhr(c, r1, r2, r3) S390_RRF_1(c, 0xb9c8, r1, r2, r3)
#define s390_ahhlr(c, r1, r2, r3) S390_RRF_1(c, 0xb9d8, r1, r2, r3)
#define s390_ahi(c, r, v) S390_RI(c, 0xa7a, r, v)
-#define s390_ahik(c, r, v) S390_RIE_1(c, 0xecd8, r, v)
+#define s390_ahik(c, r1, r3, v) S390_RIE_1(c, 0xecd8, r1, r3, v)
#define s390_ahy(c, r, x, b, d) S390_RXY(c, 0xe37a, r, b, d)
#define s390_aih(c, r, v) S390_RIL_1(c, 0xcc8, r, v)
#define s390_al(c, r, x, b, d) S390_RX(c, 0x5e, r, x, b, d)
#define s390_algf(c, r, x, b, d) S390_RXY(c, 0xe31a, r, x, b, d)
#define s390_algfi(c, r, v) S390_RIL_1(c, 0xc2a, r, v)
#define s390_algfr(c, r1, r2) S390_RRE(c, 0xb91a, r1, r2)
-#define s390_alghsik(c, r, v) S390_RIE_1(c, 0xecd8, r, v)
+#define s390_alghsik(c, r1, r3, v) S390_RIE_1(c, 0xecdb, r1, r3, v)
#define s390_algr(c, r1, r2) S390_RRE(c, 0xb90a, r1, r2)
+#define s390_algrk(c, r1, r2, r3) S390_RRF_1(c, 0xb9ea, r1, r2, r3)
#define s390_algsi(c, d1, b1, i2) S390_SIY_1(c, 0xeb7e, d1, b1, i2)
#define s390_alhhhr(c, r1, r2, r3) S390_RRF_1(c, 0xb9ca, r1, r2, r3)
#define s390_alhhlr(c, r1, r2, r3) S390_RRF_1(c, 0xb9da, r1, r2, r3)
-#define s390_alhsik(c, r, v) S390_RIE_1(c, 0xecda, r, v)
+#define s390_alhsik(c, r1, r3, v) S390_RIE_1(c, 0xecda, r1, r3, v)
#define s390_alr(c, r1, r2) S390_RR(c, 0x1e, r1, r2)
#define s390_alrk(c, r1, r2) S390_RRF(c, 0xb9fa, r1, r2)
#define s390_alsi(c, d1, b1, i2) S390_SIY_1(c, 0xeb6e, d1, b1, i2)
#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_je(c, d) s390_brc(c, S390_CC_EQ, d)
#define s390_jeo(c, d) s390_brc(c, S390_CC_ZR|S390_CC_OV, d)
#define s390_jh(c, d) s390_brc(c, S390_CC_GT, d)
+#define s390_jhe(c, d) s390_brc(c, S390_CC_GT|S390_CC_EQ, d)
#define s390_jho(c, d) s390_brc(c, S390_CC_GT|S390_CC_OV, d)
#define s390_jl(c, d) s390_brc(c, S390_CC_LT, d)
+#define s390_jle(c, d) s390_brc(c, S390_CC_LT|S390_CC_EQ, d)
#define s390_jlo(c, d) s390_brc(c, S390_CC_LT|S390_CC_OV, d)
#define s390_jm(c, d) s390_brc(c, S390_CC_LT, d)
#define s390_jnc(c, d) s390_brc(c, S390_CC_NC, d)
#define s390_l(c, r, x, b, d) S390_RX(c, 0x58, r, x, b, d)
#define s390_ly(c, r, x, b, d) S390_RXY(c, 0xe358, r, x, b, d)
#define s390_la(c, r, x, b, d) S390_RX(c, 0x41, r, x, b, d)
+#define s390_laa(c, r1, r3, b, d) S390_RSY_1(c, 0xebf8, r1, r3, b, d)
+#define s390_laag(c, r1, r3, b, d) S390_RSY_1(c, 0xebe8, r1, r3, b, d)
#define s390_lay(c, r, x, b, d) S390_RXY(c, 0xe371, r, x, b, d)
#define s390_lam(c, r1, r2, b, d) S390_RS_1(c, 0x9a, r1, r2, b, d)
#define s390_larl(c, r, o) S390_RIL_1(c, 0xc00, r, o)
#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_lpr(c, r1, r2) S390_RR(c, 0x10, r1, r2)
#define s390_lr(c, r1, r2) S390_RR(c, 0x18, r1, r2)
#define s390_lrl(c, r1, d) S390_RIL_1(c, 0xc4d, r1, d)
+#define s390_lt(c, r, x, b, d) S390_RXY(c, 0xe312, r, x, b, d)
+#define s390_ltg(c, r, x, b, d) S390_RXY(c, 0xe302, r, x, b, d)
#define s390_ltgfr(c, r1, r2) S390_RRE(c, 0xb912, r1, r2)
#define s390_ltgr(c, r1, r2) S390_RRE(c, 0xb902, r1, r2)
#define s390_ltr(c, r1, r2) S390_RR(c, 0x12, r1, r2)
#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_oiy(c, b, d, v) S390_SIY(c, 0xeb56 b, d, v)
#define s390_og(c, r, x, b, d) S390_RXY(c, 0xe381, r, x, b, d)
#define s390_ogr(c, r1, r2) S390_RRE(c, 0xb981, r1, r2)
+#define s390_ogrk(c, r1, r2, r3) S390_RRF_1(c, 0xb9e6, r1, r2, r3)
#define s390_or(c, r1, r2) S390_RR(c, 0x16, r1, r2)
#define s390_s(c, r, x, b, d) S390_RX(c, 0x5b, r, x, b, d)
#define s390_sdb(c, r, x, b, d) S390_RXE(c, 0xed1b, r, x, b, d)
#define s390_sebr(c, r1, r2) S390_RRE(c, 0xb30b, r1, r2)
#define s390_sg(c, r, x, b, d) S390_RXY(c, 0xe309, r, x, b, d)
#define s390_sgf(c, r, x, b, d) S390_RXY(c, 0xe319, r, x, b, d)
+#define s390_sgh(c, r, x, b, d) S390_RXY(c, 0xe339, r, x, b, d)
#define s390_sgr(c, r1, r2) S390_RRE(c, 0xb909, r1, r2)
+#define s390_sgrk(c, r1, r2, r3) S390_RRF_1(c, 0xb9e9, r1, r2, r3)
#define s390_sl(c, r, x, b, d) S390_RX(c, 0x5f, r, x, b, d)
#define s390_sla(c, r, b, d) S390_RS_3(c, 0x8b, r, b, d)
#define s390_slag(c, r1, r2, b, d) S390_RSY_1(c, 0xeb0b, r1, r2, b, d)
#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 s390_xilf(c, r, v) S390_RIL_1(c, 0xc07, r, v)
#define s390_xg(c, r, x, b, d) S390_RXY(c, 0xe382, r, x, b, d)
#define s390_xgr(c, r1, r2) S390_RRE(c, 0xb982, r1, r2)
+#define s390_xgrk(c, r1, r2, r3) S390_RRF_1(c, 0xb9e7, r1, r2, r3)
#define s390_xr(c, r1, r2) S390_RR(c, 0x17, r1, r2)
#define s390_xy(c, r, x, b, d) S390_RXY(c, 0xe357, r, x, b, d)
#endif
{
return SSL_get_servername (ptr->ssl, TLSEXT_NAMETYPE_host_name);
}
+
+MONO_API void
+mono_btls_ssl_set_renegotiate_mode (MonoBtlsSsl *ptr, MonoBtlsSslRenegotiateMode mode)
+{
+ SSL_set_renegotiate_mode (ptr->ssl, (enum ssl_renegotiate_mode_t)mode);
+}
+
+MONO_API int
+mono_btls_ssl_renegotiate_pending (MonoBtlsSsl *ptr)
+{
+ return SSL_renegotiate_pending (ptr->ssl);
+}
+
const char *
mono_btls_ssl_get_server_name (MonoBtlsSsl *ptr);
+typedef enum {
+ MONO_BTLS_SSL_RENEGOTIATE_NEVER = 0,
+ MONO_BTLS_SSL_RENEGOTIATE_ONCE,
+ MONO_BTLS_SSL_RENEGOTIATE_FREELY,
+ MONO_BTLS_SSL_RENEGOTIATE_IGNORE
+} MonoBtlsSslRenegotiateMode;
+
+void
+mono_btls_ssl_set_renegotiate_mode (MonoBtlsSsl *ptr, MonoBtlsSslRenegotiateMode mode);
+
+int
+mono_btls_ssl_renegotiate_pending (MonoBtlsSsl *ptr);
+
void
mono_btls_ssl_destroy (MonoBtlsSsl *ptr);
return mkdtemp (template_copy);
#else
- g_error("Function not supported");
+ g_error("Function mkdtemp not supported");
#endif
}
#include <errno.h>
-/*
- * Linux knows two different versions of strerror_r () that can only be distinguished
- * by using feature test macros. Please check the man pages for more details.
- */
-#if defined (_POSIX_C_SOURCE) && defined (_GNU_SOURCE)
-#if (_POSIX_C_SOURCE >= 200112L) && !_GNU_SOURCE
-#define USE_STRERROR_R_XSI
-#endif
-#endif
-
/*
* g_strndup and g_vasprintf need to allocate memory with g_malloc if
* ENABLE_OVERRIDABLE_ALLOCATORS is defined so that it can be safely freed with g_free
size_t buff_len = sizeof (tmp_buff);
buff [0] = 0;
-#ifdef USE_STRERROR_R_XSI
+#ifndef STRERROR_R_CHAR_P
int r;
while ((r = strerror_r (errnum, buff, buff_len - 1))) {
if (r != ERANGE) {
error_messages [errnum] = g_strdup (buff);
if (buff != tmp_buff)
g_free (buff);
-#else /* USE_STRERROR_R_XSI */
- int r;
- r = strerror_r (errnum, buff, buff_len);
+#else /* STRERROR_R_CHAR_P */
+ buff = strerror_r (errnum, buff, buff_len);
if (!error_messages [errnum])
error_messages [errnum] = g_strdup (buff);
-#endif /* USE_STRERROR_R_XSI */
+#endif /* STRERROR_R_CHAR_P */
#else /* HAVE_STRERROR_R */
if (!error_messages [errnum])
#include <mono/utils/mono-os-mutex.h>
#include <mono/utils/mono-counters.h>
#include <mono/utils/mono-compiler.h>
+#include <mono/utils/unlocked.h>
#if HAVE_BOEHM_GC
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
- InterlockedAdd64 (&gc_stats.major_gc_time, mono_100ns_ticks () - gc_start_time);
+ UnlockedAdd64 (&gc_stats.major_gc_time, mono_100ns_ticks () - gc_start_time);
mono_trace_message (MONO_TRACE_GC, "gc took %" G_GINT64_FORMAT " usecs", (mono_100ns_ticks () - gc_start_time) / 10);
break;
default:
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;
gboolean mono_align_small_structs = FALSE;
/* Statistics */
-guint32 inflated_classes_size, inflated_methods_size;
-guint32 classes_size, class_ext_size, class_ext_count;
-guint32 class_def_count, class_gtd_count, class_ginst_count, class_gparam_count, class_array_count, class_pointer_count;
+gint32 inflated_classes_size, inflated_methods_size;
+gint32 classes_size;
+gint32 class_def_count, class_gtd_count, class_ginst_count, class_gparam_count, class_array_count, class_pointer_count;
/* Low level lock which protects data structures in this module */
static mono_mutex_t classes_mutex;
UnlockedIncrement (&mono_stats.inflated_method_count);
- inflated_methods_size += sizeof (MonoMethodInflated);
+ UnlockedAdd (&inflated_methods_size, sizeof (MonoMethodInflated));
sig = mono_method_signature (method);
if (!sig) {
* Create the MonoClass* representing the specified type token.
* \p type_token must be a TypeDef token.
*
- * FIXME: don't return NULL on failure, just the the caller figure it out.
+ * FIXME: don't return NULL on failure, just let the caller figure it out.
*/
static MonoClass *
mono_class_create_from_typedef (MonoImage *image, guint32 type_token, MonoError *error)
if (mono_metadata_has_generic_params (image, type_token)) {
klass = mono_image_alloc0 (image, sizeof (MonoClassGtd));
klass->class_kind = MONO_CLASS_GTD;
- classes_size += sizeof (MonoClassGtd);
+ UnlockedAdd (&classes_size, sizeof (MonoClassGtd));
++class_gtd_count;
} else {
klass = mono_image_alloc0 (image, sizeof (MonoClassDef));
klass->class_kind = MONO_CLASS_DEF;
- classes_size += sizeof (MonoClassDef);
+ UnlockedAdd (&classes_size, sizeof (MonoClassDef));
++class_def_count;
}
klass = (MonoClass *)mono_image_alloc0 (image, sizeof (MonoClassGenericParam));
klass->class_kind = MONO_CLASS_GPARAM;
- classes_size += sizeof (MonoClassGenericParam);
- ++class_gparam_count;
+ UnlockedAdd (&classes_size, sizeof (MonoClassGenericParam));
+ UnlockedIncrement (&class_gparam_count);
if (pinfo) {
CHECKED_METADATA_WRITE_PTR_EXEMPT ( klass->name , pinfo->name );
result = (MonoClass *)mono_image_alloc0 (image, sizeof (MonoClassPointer));
- classes_size += sizeof (MonoClassPointer);
+ UnlockedAdd (&classes_size, sizeof (MonoClassPointer));
++class_pointer_count;
result->parent = NULL; /* no parent for PTR types */
MONO_PROFILER_RAISE (class_loading, (result));
- classes_size += sizeof (MonoClassPointer);
+ UnlockedAdd (&classes_size, sizeof (MonoClassPointer));
++class_pointer_count;
g_hash_table_insert (ptr_hash, sig, result);
MONO_PROFILER_RAISE (class_loading, (klass));
- classes_size += sizeof (MonoClassArray);
+ UnlockedAdd (&classes_size, sizeof (MonoClassArray));
++class_array_count;
if (rank == 1 && !bounded) {
* mono_classes_init:
*
* Initialize the resources used by this module.
+ * Known racy counters: `class_gparam_count`, `classes_size` and `inflated_methods_size`
*/
+MONO_NO_SANITIZE_THREAD
void
mono_classes_init (void)
{
}
void
-mono_mb_emit_cominterop_call (MonoMethodBuilder *mb, MonoMethodSignature *sig, MonoMethod* method)
+mono_mb_emit_cominterop_get_function_pointer (MonoMethodBuilder *mb, MonoMethod *method)
{
#ifndef DISABLE_JIT
// get function pointer from 1st arg, the COM interface pointer
mono_mb_emit_ldarg (mb, 0);
mono_mb_emit_icon (mb, cominterop_get_com_slot_for_method (method));
mono_mb_emit_icall (mb, cominterop_get_function_pointer);
+ /* Leaves the function pointer on top of the stack */
+#endif
+}
+void
+mono_mb_emit_cominterop_call_function_pointer (MonoMethodBuilder *mb, MonoMethodSignature *sig)
+{
+#ifndef DISABLE_JIT
mono_mb_emit_byte (mb, MONO_CUSTOM_PREFIX);
mono_mb_emit_byte (mb, CEE_MONO_SAVE_LMF);
mono_mb_emit_calli (mb, sig);
#endif /* DISABLE_JIT */
}
+void
+mono_mb_emit_cominterop_call (MonoMethodBuilder *mb, MonoMethodSignature *sig, MonoMethod* method)
+{
+#ifndef DISABLE_JIT
+ mono_mb_emit_cominterop_get_function_pointer (mb, method);
+
+ mono_mb_emit_cominterop_call_function_pointer (mb, sig);
+#endif /* DISABLE_JIT */
+}
+
void
mono_cominterop_emit_ptr_to_object_conv (MonoMethodBuilder *mb, MonoType *type, MonoMarshalConv conv, MonoMarshalSpec *mspec)
{
void
mono_cominterop_cleanup (void);
+void
+mono_mb_emit_cominterop_get_function_pointer (MonoMethodBuilder *mb, MonoMethod* method);
+
+void
+mono_mb_emit_cominterop_call_function_pointer (MonoMethodBuilder *mb, MonoMethodSignature *sig);
+
void
mono_mb_emit_cominterop_call (MonoMethodBuilder *mb, MonoMethodSignature *sig, MonoMethod* method);
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;
}
HANDLES(ICALL(SOCK_9, "Listen_internal(intptr,int,int&)", ves_icall_System_Net_Sockets_Socket_Listen_internal))
HANDLES(ICALL(SOCK_10, "LocalEndPoint_internal(intptr,int,int&)", ves_icall_System_Net_Sockets_Socket_LocalEndPoint_internal))
HANDLES(ICALL(SOCK_11, "Poll_internal", ves_icall_System_Net_Sockets_Socket_Poll_internal))
-HANDLES(ICALL(SOCK_13, "ReceiveFrom_internal(intptr,byte[],int,int,System.Net.Sockets.SocketFlags,System.Net.SocketAddress&,int&,bool)", ves_icall_System_Net_Sockets_Socket_ReceiveFrom_internal))
-HANDLES(ICALL(SOCK_11a, "Receive_internal(intptr,System.Net.Sockets.Socket/WSABUF[],System.Net.Sockets.SocketFlags,int&,bool)", ves_icall_System_Net_Sockets_Socket_Receive_array_internal))
-HANDLES(ICALL(SOCK_12, "Receive_internal(intptr,byte[],int,int,System.Net.Sockets.SocketFlags,int&,bool)", ves_icall_System_Net_Sockets_Socket_Receive_internal))
+HANDLES(ICALL(SOCK_13, "ReceiveFrom_internal(intptr,byte*,int,System.Net.Sockets.SocketFlags,System.Net.SocketAddress&,int&,bool)", ves_icall_System_Net_Sockets_Socket_ReceiveFrom_internal))
+HANDLES(ICALL(SOCK_11a, "Receive_internal(intptr,System.Net.Sockets.Socket/WSABUF*,int,System.Net.Sockets.SocketFlags,int&,bool)", ves_icall_System_Net_Sockets_Socket_Receive_array_internal))
+HANDLES(ICALL(SOCK_12, "Receive_internal(intptr,byte*,int,System.Net.Sockets.SocketFlags,int&,bool)", ves_icall_System_Net_Sockets_Socket_Receive_internal))
HANDLES(ICALL(SOCK_14, "RemoteEndPoint_internal(intptr,int,int&)", ves_icall_System_Net_Sockets_Socket_RemoteEndPoint_internal))
HANDLES(ICALL(SOCK_15, "Select_internal(System.Net.Sockets.Socket[]&,int,int&)", ves_icall_System_Net_Sockets_Socket_Select_internal))
HANDLES(ICALL(SOCK_15a, "SendFile_internal(intptr,string,byte[],byte[],System.Net.Sockets.TransmitFileOptions,int&,bool)", ves_icall_System_Net_Sockets_Socket_SendFile_internal))
-HANDLES(ICALL(SOCK_16, "SendTo_internal(intptr,byte[],int,int,System.Net.Sockets.SocketFlags,System.Net.SocketAddress,int&,bool)", ves_icall_System_Net_Sockets_Socket_SendTo_internal))
-HANDLES(ICALL(SOCK_16a, "Send_internal(intptr,System.Net.Sockets.Socket/WSABUF[],System.Net.Sockets.SocketFlags,int&,bool)", ves_icall_System_Net_Sockets_Socket_Send_array_internal))
-HANDLES(ICALL(SOCK_17, "Send_internal(intptr,byte[],int,int,System.Net.Sockets.SocketFlags,int&,bool)", ves_icall_System_Net_Sockets_Socket_Send_internal))
+HANDLES(ICALL(SOCK_16, "SendTo_internal(intptr,byte*,int,System.Net.Sockets.SocketFlags,System.Net.SocketAddress,int&,bool)", ves_icall_System_Net_Sockets_Socket_SendTo_internal))
+HANDLES(ICALL(SOCK_16a, "Send_internal(intptr,System.Net.Sockets.Socket/WSABUF*,int,System.Net.Sockets.SocketFlags,int&,bool)", ves_icall_System_Net_Sockets_Socket_Send_array_internal))
+HANDLES(ICALL(SOCK_17, "Send_internal(intptr,byte*,int,System.Net.Sockets.SocketFlags,int&,bool)", ves_icall_System_Net_Sockets_Socket_Send_internal))
HANDLES(ICALL(SOCK_18, "SetSocketOption_internal(intptr,System.Net.Sockets.SocketOptionLevel,System.Net.Sockets.SocketOptionName,object,byte[],int,int&)", ves_icall_System_Net_Sockets_Socket_SetSocketOption_internal))
HANDLES(ICALL(SOCK_19, "Shutdown_internal(intptr,System.Net.Sockets.SocketShutdown,int&)", ves_icall_System_Net_Sockets_Socket_Shutdown_internal))
HANDLES(ICALL(SOCK_20, "Socket_internal(System.Net.Sockets.AddressFamily,System.Net.Sockets.SocketType,System.Net.Sockets.ProtocolType,int&)", ves_icall_System_Net_Sockets_Socket_Socket_internal))
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 */
register_icall (mono_marshal_free_asany, "mono_marshal_free_asany", "void object ptr int32 int32", FALSE);
register_icall (ves_icall_marshal_alloc, "ves_icall_marshal_alloc", "ptr ptr", FALSE);
register_icall (mono_marshal_free, "mono_marshal_free", "void ptr", FALSE);
- register_icall (mono_marshal_set_last_error, "mono_marshal_set_last_error", "void", FALSE);
- register_icall (mono_marshal_set_last_error_windows, "mono_marshal_set_last_error_windows", "void int32", FALSE);
+ register_icall (mono_marshal_set_last_error, "mono_marshal_set_last_error", "void", TRUE);
+ register_icall (mono_marshal_set_last_error_windows, "mono_marshal_set_last_error_windows", "void int32", TRUE);
register_icall (mono_string_utf8_to_builder, "mono_string_utf8_to_builder", "void ptr ptr", FALSE);
register_icall (mono_string_utf8_to_builder2, "mono_string_utf8_to_builder2", "object ptr", FALSE);
register_icall (mono_string_utf16_to_builder, "mono_string_utf16_to_builder", "void ptr ptr", FALSE);
int i, argnum, *tmp_locals;
int type, param_shift = 0;
int coop_gc_stack_dummy, coop_gc_var;
+#ifndef DISABLE_COM
+ int coop_cominterop_fnptr;
+#endif
memset (&m, 0, sizeof (m));
m.mb = mb;
coop_gc_stack_dummy = mono_mb_add_local (mb, &mono_defaults.int_class->byval_arg);
/* local 5, the local to be used when calling the suspend funcs */
coop_gc_var = mono_mb_add_local (mb, &mono_defaults.int_class->byval_arg);
+#ifndef DISABLE_COM
+ if (!func_param && MONO_CLASS_IS_IMPORT (mb->method->klass)) {
+ coop_cominterop_fnptr = mono_mb_add_local (mb, &mono_defaults.int_class->byval_arg);
+ }
+#endif
}
/*
mono_mb_emit_byte (mb, CEE_POP); // Result not needed yet
}
+#ifndef DISABLE_COM
+ if (!func_param && MONO_CLASS_IS_IMPORT (mb->method->klass)) {
+ mono_mb_emit_cominterop_get_function_pointer (mb, &piinfo->method);
+ mono_mb_emit_stloc (mb, coop_cominterop_fnptr);
+ }
+#endif
+
mono_mb_emit_ldloc_addr (mb, coop_gc_stack_dummy);
mono_mb_emit_icall (mb, mono_threads_enter_gc_safe_region_unbalanced);
mono_mb_emit_stloc (mb, coop_gc_var);
mono_mb_emit_calli (mb, csig);
} else if (MONO_CLASS_IS_IMPORT (mb->method->klass)) {
#ifndef DISABLE_COM
- mono_mb_emit_cominterop_call (mb, csig, &piinfo->method);
+ if (!mono_threads_is_blocking_transition_enabled ()) {
+ mono_mb_emit_cominterop_call (mb, csig, &piinfo->method);
+ } else {
+ mono_mb_emit_ldloc (mb, coop_cominterop_fnptr);
+ mono_mb_emit_cominterop_call_function_pointer (mb, csig);
+ }
#else
g_assert_not_reached ();
#endif
void
mono_marshal_set_last_error (void)
{
+ /* This icall is called just after a P/Invoke call before the P/Invoke
+ * wrapper transitions the runtime back to running mode. */
+ MONO_REQ_GC_SAFE_MODE;
#ifdef WIN32
mono_native_tls_set_value (last_error_tls_id, GINT_TO_POINTER (GetLastError ()));
#else
mono_marshal_set_last_error_windows (int error)
{
#ifdef WIN32
+ /* This icall is called just after a P/Invoke call before the P/Invoke
+ * wrapper transitions the runtime back to running mode. */
+ MONO_REQ_GC_SAFE_MODE;
mono_native_tls_set_value (last_error_tls_id, GINT_TO_POINTER (error));
#endif
}
#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);
#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
}
return mono_object_domain (obj);
}
+/**
+ * mono_gchandle_new:
+ * \param obj managed object to get a handle for
+ * \param pinned whether the object should be pinned
+ * This returns a handle that wraps the object, this is used to keep a
+ * reference to a managed object from the unmanaged world and preventing the
+ * object from being disposed.
+ *
+ * If \p pinned is false the address of the object can not be obtained, if it is
+ * true the address of the object can be obtained. This will also pin the
+ * object so it will not be possible by a moving garbage collector to move the
+ * object.
+ *
+ * \returns a handle that can be used to access the object from unmanaged code.
+ */
+guint32
+mono_gchandle_new (MonoObject *obj, gboolean pinned)
+{
+ return sgen_gchandle_new (obj, pinned);
+}
+
+/**
+ * mono_gchandle_new_weakref:
+ * \param obj managed object to get a handle for
+ * \param track_resurrection Determines how long to track the object, if this is set to TRUE, the object is tracked after finalization, if FALSE, the object is only tracked up until the point of finalization.
+ *
+ * This returns a weak handle that wraps the object, this is used to
+ * keep a reference to a managed object from the unmanaged world.
+ * Unlike the \c mono_gchandle_new the object can be reclaimed by the
+ * garbage collector. In this case the value of the GCHandle will be
+ * set to zero.
+ *
+ * If \p track_resurrection is TRUE the object will be tracked through
+ * finalization and if the object is resurrected during the execution
+ * of the finalizer, then the returned weakref will continue to hold
+ * a reference to the object. If \p track_resurrection is FALSE, then
+ * the weak reference's target will become NULL as soon as the object
+ * is passed on to the finalizer.
+ *
+ * \returns a handle that can be used to access the object from
+ * unmanaged code.
+ */
+guint32
+mono_gchandle_new_weakref (GCObject *obj, gboolean track_resurrection)
+{
+ return sgen_gchandle_new_weakref (obj, track_resurrection);
+}
+
/**
* mono_gchandle_is_in_domain:
* \param gchandle a GCHandle's handle.
return domain->domain_id == gchandle_domain->domain_id;
}
+/**
+ * mono_gchandle_free:
+ * \param gchandle a GCHandle's handle.
+ *
+ * Frees the \p gchandle handle. If there are no outstanding
+ * references, the garbage collector can reclaim the memory of the
+ * object wrapped.
+ */
+void
+mono_gchandle_free (guint32 gchandle)
+{
+ sgen_gchandle_free (gchandle);
+}
+
/**
* mono_gchandle_free_domain:
* \param unloading domain that is unloading
{
}
+/**
+ * mono_gchandle_get_target:
+ * \param gchandle a GCHandle's handle.
+ *
+ * The handle was previously created by calling \c mono_gchandle_new or
+ * \c mono_gchandle_new_weakref.
+ *
+ * \returns a pointer to the \c MonoObject* represented by the handle or
+ * NULL for a collected object if using a weakref handle.
+ */
+MonoObject*
+mono_gchandle_get_target (guint32 gchandle)
+{
+ return sgen_gchandle_get_target (gchandle);
+}
+
static gpointer
null_link_if_in_domain (gpointer hidden, GCHandleType handle_type, int max_generation, gpointer user)
{
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));
#include <mono/utils/mono-error-internals.h>
#include <mono/utils/os-event.h>
#include <mono/utils/mono-threads-debug.h>
+#include <mono/utils/unlocked.h>
#include <mono/metadata/w32handle.h>
#include <mono/metadata/w32event.h>
#include <mono/metadata/w32mutex.h>
/* Contains tids */
/* Protected by the threads lock */
static GHashTable *joinable_threads;
-static int joinable_thread_count;
+static gint32 joinable_thread_count;
#define SET_CURRENT_OBJECT(x) mono_tls_set_thread (x)
#define GET_CURRENT_OBJECT() (MonoInternalThread*) mono_tls_get_thread ()
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
if (!joinable_threads)
joinable_threads = g_hash_table_new (NULL, NULL);
g_hash_table_insert (joinable_threads, tid, tid);
- joinable_thread_count ++;
+ UnlockedIncrement (&joinable_thread_count);
joinable_threads_unlock ();
mono_gc_finalize_notify ();
gboolean found;
/* Fastpath */
- if (!joinable_thread_count)
+ if (!UnlockedRead (&joinable_thread_count))
return;
while (TRUE) {
g_hash_table_iter_next (&iter, &key, (void**)&tid);
thread = (pthread_t)tid;
g_hash_table_remove (joinable_threads, key);
- joinable_thread_count --;
+ UnlockedDecrement (&joinable_thread_count);
found = TRUE;
}
joinable_threads_unlock ();
joinable_threads = g_hash_table_new (NULL, NULL);
if (g_hash_table_lookup (joinable_threads, tid)) {
g_hash_table_remove (joinable_threads, tid);
- joinable_thread_count --;
+ UnlockedDecrement (&joinable_thread_count);
found = TRUE;
}
joinable_threads_unlock ();
{ DRIVE_REMOTE, "ftp" },
{ DRIVE_FIXED, "hfs" },
{ DRIVE_FIXED, "apfs" },
+ { DRIVE_REMOTE, "kbfuse" },
{ DRIVE_FIXED, "msdos" },
{ DRIVE_REMOTE, "nfs" },
{ DRIVE_FIXED, "ntfs" },
#define TF_DISCONNECT 0x01
#define TF_REUSE_SOCKET 0x02
-typedef struct {
- guint32 len;
- gpointer buf;
-} WSABUF, *LPWSABUF;
-
typedef struct {
gpointer Head;
guint32 HeadLength;
}
gint32
-ves_icall_System_Net_Sockets_Socket_Receive_internal (gsize sock, MonoArrayHandle buffer, gint32 offset, gint32 count, gint32 flags, gint32 *werror, gboolean blocking, MonoError *error)
+ves_icall_System_Net_Sockets_Socket_Receive_internal (gsize sock, gchar *buffer, gint32 count, gint32 flags, gint32 *werror, gboolean blocking, MonoError *error)
{
int ret;
- gint32 alen;
int recvflags = 0;
gboolean interrupted;
- MonoInternalThread* curthread G_GNUC_UNUSED = mono_thread_internal_current ();
error_init (error);
*werror = 0;
- alen = mono_array_handle_length (buffer);
- if (offset > alen - count)
- return 0;
-
recvflags = convert_socketflags (flags);
if (recvflags == -1) {
*werror = WSAEOPNOTSUPP;
if (interrupted)
return 0;
- uint32_t gchandle;
- gchar *buf = MONO_ARRAY_HANDLE_PIN (buffer, gchar, offset, &gchandle);
-
- ret = mono_w32socket_recv (sock, buf, count, recvflags, blocking);
-
- mono_gchandle_free (gchandle);
+ ret = mono_w32socket_recv (sock, buffer, count, recvflags, blocking);
if (ret == SOCKET_ERROR)
*werror = mono_w32socket_get_last_error ();
}
gint32
-ves_icall_System_Net_Sockets_Socket_Receive_array_internal (gsize sock, MonoArrayHandle buffers, gint32 flags, gint32 *werror, gboolean blocking, MonoError *error)
+ves_icall_System_Net_Sockets_Socket_Receive_array_internal (gsize sock, WSABUF *buffers, gint32 count, gint32 flags, gint32 *werror, gboolean blocking, MonoError *error)
{
- int ret, count;
+ int ret;
gboolean interrupted;
guint32 recv;
guint32 recvflags = 0;
error_init (error);
*werror = 0;
- count = mono_array_handle_length (buffers);
-
recvflags = convert_socketflags (flags);
if (recvflags == -1) {
*werror = WSAEOPNOTSUPP;
return 0;
}
- uint32_t gchandle;
- WSABUF *wsabufs = MONO_ARRAY_HANDLE_PIN (buffers, WSABUF, 0, &gchandle);
-
- ret = mono_w32socket_recvbuffers (sock, wsabufs, count, &recv, &recvflags, NULL, NULL, blocking);
-
- mono_gchandle_free (gchandle);
+ ret = mono_w32socket_recvbuffers (sock, buffers, count, &recv, &recvflags, NULL, NULL, blocking);
if (ret == SOCKET_ERROR)
*werror = mono_w32socket_get_last_error ();
}
gint32
-ves_icall_System_Net_Sockets_Socket_ReceiveFrom_internal (gsize sock, MonoArrayHandle buffer, gint32 offset, gint32 count, gint32 flags, MonoObjectHandle sockaddr, gint32 *werror, gboolean blocking, MonoError *error)
+ves_icall_System_Net_Sockets_Socket_ReceiveFrom_internal (gsize sock, gchar *buffer, gint32 count, gint32 flags, MonoObjectHandle sockaddr, gint32 *werror, gboolean blocking, MonoError *error)
{
int ret;
- gchar *buf;
- gint32 alen;
int recvflags = 0;
struct sockaddr *sa;
socklen_t sa_size;
error_init (error);
*werror = 0;
-
- alen = mono_array_handle_length (buffer);
- if (offset > alen - count)
- return 0;
sa = create_sockaddr_from_handle (sockaddr, &sa_size, werror, error);
if (*werror != 0)
return 0;
}
- uint32_t gchandle;
- buf = MONO_ARRAY_HANDLE_PIN (buffer, gchar, offset, &gchandle);
-
- ret = mono_w32socket_recvfrom (sock, buf, count, recvflags, sa, &sa_size, blocking);
-
- mono_gchandle_free (gchandle);
+ ret = mono_w32socket_recvfrom (sock, buffer, count, recvflags, sa, &sa_size, blocking);
if (ret == SOCKET_ERROR)
*werror = mono_w32socket_get_last_error ();
}
gint32
-ves_icall_System_Net_Sockets_Socket_Send_internal (gsize sock, MonoArrayHandle buffer, gint32 offset, gint32 count, gint32 flags, gint32 *werror, gboolean blocking, MonoError *error)
+ves_icall_System_Net_Sockets_Socket_Send_internal (gsize sock, gchar *buffer, gint32 count, gint32 flags, gint32 *werror, gboolean blocking, MonoError *error)
{
int ret;
- gint32 alen;
int sendflags = 0;
gboolean interrupted;
error_init (error);
*werror = 0;
- alen = mono_array_handle_length (buffer);
- if (offset > alen - count)
- return 0;
-
- LOGDEBUG (g_message("%s: alen: %d", __func__, alen));
-
LOGDEBUG (g_message("%s: Sending %d bytes", __func__, count));
sendflags = convert_socketflags (flags);
return 0;
}
- uint32_t gchandle;
- gchar *buf = MONO_ARRAY_HANDLE_PIN (buffer, gchar, offset, &gchandle);
-
- ret = mono_w32socket_send (sock, buf, count, sendflags, blocking);
-
- mono_gchandle_free (gchandle);
+ ret = mono_w32socket_send (sock, buffer, count, sendflags, blocking);
if (ret == SOCKET_ERROR)
*werror = mono_w32socket_get_last_error ();
}
gint32
-ves_icall_System_Net_Sockets_Socket_Send_array_internal (gsize sock, MonoArrayHandle buffers, gint32 flags, gint32 *werror, gboolean blocking, MonoError *error)
+ves_icall_System_Net_Sockets_Socket_Send_array_internal (gsize sock, WSABUF *buffers, gint32 count, gint32 flags, gint32 *werror, gboolean blocking, MonoError *error)
{
- int ret, count;
+ int ret;
guint32 sent;
guint32 sendflags = 0;
gboolean interrupted;
error_init (error);
*werror = 0;
- count = mono_array_handle_length (buffers);
-
sendflags = convert_socketflags (flags);
if (sendflags == -1) {
*werror = WSAEOPNOTSUPP;
return 0;
}
- uint32_t gchandle;
- WSABUF *wsabufs = MONO_ARRAY_HANDLE_PIN (buffers, WSABUF, 0, &gchandle);
-
- ret = mono_w32socket_sendbuffers (sock, wsabufs, count, &sent, sendflags, NULL, NULL, blocking);
-
- mono_gchandle_free (gchandle);
+ ret = mono_w32socket_sendbuffers (sock, buffers, count, &sent, sendflags, NULL, NULL, blocking);
if (ret == SOCKET_ERROR)
*werror = mono_w32socket_get_last_error ();
}
gint32
-ves_icall_System_Net_Sockets_Socket_SendTo_internal (gsize sock, MonoArrayHandle buffer, gint32 offset, gint32 count, gint32 flags, MonoObjectHandle sockaddr, gint32 *werror, gboolean blocking, MonoError *error)
+ves_icall_System_Net_Sockets_Socket_SendTo_internal (gsize sock, gchar *buffer, gint32 count, gint32 flags, MonoObjectHandle sockaddr, gint32 *werror, gboolean blocking, MonoError *error)
{
int ret;
- gint32 alen;
int sendflags = 0;
struct sockaddr *sa;
socklen_t sa_size;
gboolean interrupted;
*werror = 0;
-
- alen = mono_array_handle_length (buffer);
- if (offset > alen - count) {
- return 0;
- }
sa = create_sockaddr_from_handle (sockaddr, &sa_size, werror, error);
if (*werror != 0)
return 0;
return_val_if_nok (error, 0);
- LOGDEBUG (g_message ("%s: alen: %d", __func__, alen));
-
LOGDEBUG (g_message("%s: Sending %d bytes", __func__, count));
sendflags = convert_socketflags (flags);
return 0;
}
- uint32_t gchandle;
- gchar *buf = MONO_ARRAY_HANDLE_PIN (buffer, gchar, offset, &gchandle);
-
- ret = mono_w32socket_sendto (sock, buf, count, sendflags, sa, sa_size, blocking);
-
- mono_gchandle_free (gchandle);
+ ret = mono_w32socket_sendto (sock, buffer, count, sendflags, sa, sa_size, blocking);
if (ret == SOCKET_ERROR)
*werror = mono_w32socket_get_last_error ();
#ifndef HOST_WIN32
typedef gint SOCKET;
+
+typedef struct {
+ guint32 len;
+ gpointer buf;
+} WSABUF, *LPWSABUF;
#endif
/* This is a copy of System.Net.Sockets.SocketType */
ves_icall_System_Net_Sockets_Socket_Connect_internal (gsize sock, MonoObjectHandle sockaddr, gint32 *werror, gboolean blocking, MonoError *error);
gint32
-ves_icall_System_Net_Sockets_Socket_Receive_internal (gsize sock, MonoArrayHandle buffer, gint32 offset, gint32 count,
+ves_icall_System_Net_Sockets_Socket_Receive_internal (gsize sock, gchar *buffer, gint32 count,
gint32 flags, gint32 *werror, gboolean blocking, MonoError *error);
gint32
-ves_icall_System_Net_Sockets_Socket_Receive_array_internal (gsize sock, MonoArrayHandle buffers, gint32 flags,
+ves_icall_System_Net_Sockets_Socket_Receive_array_internal (gsize sock, WSABUF *buffers, gint32 count, gint32 flags,
gint32 *werror, gboolean blocking, MonoError *error);
-/* gint32 */
-/* ves_icall_System_Net_Sockets_Socket_ReceiveFrom_internal (gsize sock, MonoArray *buffer, gint32 offset, gint32 count, */
-/* gint32 flags, MonoObject **sockaddr, gint32 *werror, gboolean blocking); */
-
gint32
-ves_icall_System_Net_Sockets_Socket_ReceiveFrom_internal (gsize sock, MonoArrayHandle buffer, gint32 offset, gint32 count,
+ves_icall_System_Net_Sockets_Socket_ReceiveFrom_internal (gsize sock, gchar *buffer, gint32 count,
gint32 flags, MonoObjectHandle sockaddr, gint32 *werror, gboolean blocking, MonoError *error);
gint32
-ves_icall_System_Net_Sockets_Socket_Send_internal (gsize sock, MonoArrayHandle buffer, gint32 offset, gint32 count,
+ves_icall_System_Net_Sockets_Socket_Send_internal (gsize sock, gchar *buffer, gint32 count,
gint32 flags, gint32 *werror, gboolean blocking, MonoError *error);
gint32
-ves_icall_System_Net_Sockets_Socket_Send_array_internal (gsize sock, MonoArrayHandle buffers, gint32 flags,
+ves_icall_System_Net_Sockets_Socket_Send_array_internal (gsize sock, WSABUF *buffers, gint32 count, gint32 flags,
gint32 *werror, gboolean blocking, MonoError *error);
gint32
-ves_icall_System_Net_Sockets_Socket_SendTo_internal (gsize sock, MonoArrayHandle buffer, gint32 offset, gint32 count,
+ves_icall_System_Net_Sockets_Socket_SendTo_internal (gsize sock, gchar *buffer, gint32 count,
gint32 flags, MonoObjectHandle sockaddr, gint32 *werror,
gboolean blocking, MonoError *error);
long_max: dest:i src1:i src2:i len:16 clob:1
long_max_un: dest:i src1:i src2:i len:16 clob:1
-throw: src1:i len:18
-rethrow: src1:i len:18
+throw: src1:i len:24
+rethrow: src1:i len:24
start_handler: len:16
endfinally: len:9
endfilter: src1:a len:9
fcall_reg: dest:g src1:i len:10 clob:c
fcompare: src1:f src2:f len:14
float_add: dest:f src1:f src2:f len:6
+
float_beq: len:10
float_bge: len:10
float_bge_un: len:8
float_blt_un: len:8
float_bne_un: len:8
float_bgt_un: len:8
+
float_ceq: dest:i src1:f src2:f len:16
float_cgt: dest:i src1:f src2:f len:16
float_cgt_un: dest:i src1:f src2:f len:16
float_clt: dest:i src1:f src2:f len:16
float_clt_un: dest:i src1:f src2:f len:16
+float_cneq: dest:y src1:f src2:f len:16
+float_cge: dest:y src1:f src2:f len:16
+float_cle: dest:y src1:f src2:f len:16
+
float_conv_to_i1: dest:i src1:f len:50
float_conv_to_i2: dest:i src1:f len:50
float_conv_to_i4: dest:i src1:f len:50
int_blt: len:8
int_blt_un: len:8
int_bne_un: len:8
+
int_ceq: dest:i len:12
int_cgt: dest:i len:12
int_cgt_un: dest:i len:12
int_clt: dest:i len:12
int_clt_un: dest:i len:12
+
+int_cneq: dest:i len:12
+int_cge: dest:i len:12
+int_cle: dest:i len:12
+int_cge_un: dest:i len:12
+int_cle_un: dest:i len:12
+
int_div: dest:a src1:i src2:i len:16
int_div_imm: dest:a src1:i len:24
int_div_un: dest:a src1:i src2:i len:16
int_conv_to_i1: dest:i src1:i len:12
int_conv_to_i2: dest:i src1:i len:12
-int_conv_to_i4: dest:i src1:i len:2
-int_conv_to_i: dest:i src1:i len:2
+int_conv_to_i4: dest:i src1:i len:4
+int_conv_to_i: dest:i src1:i len:4
int_conv_to_u1: dest:i src1:i len:10
int_conv_to_u2: dest:i src1:i len:16
-int_conv_to_u4: dest:i src1:i
+int_conv_to_u4: dest:i src1:i len:4
int_conv_to_r_un: dest:f src1:i len:37
cond_exc_ic: len:8
gc_safe_point: clob:c src1:i len:32
generic_class_init: src1:A len:32 clob:c
+
+s390_crj: src1:i src2:i len:24
+s390_crj_un: src1:i src2:i len:24
+s390_cgrj: src1:i src2:i len:24
+s390_cgrj_un: src1:i src2:i len:24
+s390_cij: src1:i len:24
+s390_cij_un: src1:i len:24
+s390_cgij: src1:i len:24
+s390_cgij_un: src1:i len:24
}
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;
}
return;
if (agent_config.defer) {
- /* Make sure the thread id is always set when doing deferred debugging */
if (is_debugger_thread ()) {
/* Don't suspend on events from the debugger thread */
suspend_policy = SUSPEND_POLICY_NONE;
- thread = mono_thread_get_main ();
}
- else thread = mono_thread_current ();
} else {
if (is_debugger_thread () && event != EVENT_KIND_VM_DEATH)
// FIXME: Send these with a NULL thread, don't suspend the current thread
thread = NULL;
} else {
if (!thread)
- thread = mono_thread_current ();
+ thread = is_debugger_thread () ? mono_thread_get_main () : mono_thread_current ();
if (event == EVENT_KIND_VM_START && arg != NULL)
thread = (MonoThread *)arg;
return bp->method && bp->method->klass->image->assembly == assembly;
}
-static MonoObject*
-get_this (StackFrame *frame)
+static gpointer
+get_this_addr (StackFrame *frame)
{
//Logic inspiered by "add_var" method and took out path that happens in async method for getting this
MonoDebugVarInfo *var = frame->jit->this_var;
if ((var->index & MONO_DEBUG_VAR_ADDRESS_MODE_FLAGS) != MONO_DEBUG_VAR_ADDRESS_MODE_REGOFFSET)
return NULL;
- guint8 * addr = (guint8 *)mono_arch_context_get_int_reg (&frame->ctx, var->index & ~MONO_DEBUG_VAR_ADDRESS_MODE_FLAGS);
+ guint8 *addr = (guint8 *)mono_arch_context_get_int_reg (&frame->ctx, var->index & ~MONO_DEBUG_VAR_ADDRESS_MODE_FLAGS);
addr += (gint32)var->offset;
- return *(MonoObject**)addr;
-}
-
-//This ID is used to figure out if breakpoint hit on resumeOffset belongs to us or not
-//since thread probably changed...
-static int
-get_this_async_id (StackFrame *frame)
-{
- return get_objid (get_this (frame));
+ return addr;
}
static MonoMethod*
return set_notification_method;
}
-static void
-set_set_notification_for_wait_completion_flag (StackFrame *frame)
+static MonoMethod*
+get_object_id_for_debugger_method (MonoClass* async_builder_class)
+{
+ MonoError error;
+ GPtrArray *array = mono_class_get_methods_by_name (async_builder_class, "get_ObjectIdForDebugger", 0x24, FALSE, FALSE, &error);
+ mono_error_assert_ok (&error);
+ g_assert (array->len == 1);
+ MonoMethod *method = (MonoMethod *)g_ptr_array_index (array, 0);
+ g_ptr_array_free (array, TRUE);
+ return method;
+}
+
+/* Return the address of the AsyncMethodBuilder struct belonging to the state machine method pointed to by FRAME */
+static gpointer
+get_async_method_builder (StackFrame *frame)
{
- MonoObject* obj = get_this (frame);
- g_assert (obj);
- MonoClassField *builder_field = mono_class_get_field_from_name (obj->vtable->klass, "<>t__builder");
+ MonoObject *this_obj;
+ MonoClassField *builder_field;
+ gpointer builder;
+ guint8 *this_addr;
+
+ builder_field = mono_class_get_field_from_name (frame->method->klass, "<>t__builder");
g_assert (builder_field);
- MonoObject* builder;
+
+ this_addr = get_this_addr (frame);
+ if (!this_addr)
+ return NULL;
+
+ if (frame->method->klass->valuetype) {
+ guint8 *vtaddr = *(guint8**)this_addr;
+ builder = (char*)vtaddr + builder_field->offset - sizeof (MonoObject);
+ } else {
+ this_obj = *(MonoObject**)this_addr;
+ builder = (char*)this_obj + builder_field->offset;
+ }
+
+ return builder;
+}
+
+//This ID is used to figure out if breakpoint hit on resumeOffset belongs to us or not
+//since thread probably changed...
+static int
+get_this_async_id (StackFrame *frame)
+{
+ MonoClassField *builder_field;
+ gpointer builder;
+ MonoMethod *method;
+ MonoObject *ex;
MonoError error;
- builder = mono_field_get_value_object_checked (frame->domain, builder_field, obj, &error);
+ MonoObject *obj;
+ gboolean old_disable_breakpoints = FALSE;
+ DebuggerTlsData *tls;
+
+ /*
+ * FRAME points to a method in a state machine class/struct.
+ * Call the ObjectIdForDebugger method of the associated method builder type.
+ */
+ builder = get_async_method_builder (frame);
+ if (!builder)
+ return 0;
+
+ builder_field = mono_class_get_field_from_name (frame->method->klass, "<>t__builder");
+ g_assert (builder_field);
+
+ tls = (DebuggerTlsData *)mono_native_tls_get_value (debugger_tls_id);
+ if (tls) {
+ old_disable_breakpoints = tls->disable_breakpoints;
+ tls->disable_breakpoints = TRUE;
+ }
+
+ method = get_object_id_for_debugger_method (mono_class_from_mono_type (builder_field->type));
+ obj = mono_runtime_try_invoke (method, builder, NULL, &ex, &error);
mono_error_assert_ok (&error);
+
+ if (tls)
+ tls->disable_breakpoints = old_disable_breakpoints;
+
+ return get_objid (obj);
+}
+
+static void
+set_set_notification_for_wait_completion_flag (StackFrame *frame)
+{
+ MonoClassField *builder_field = mono_class_get_field_from_name (frame->method->klass, "<>t__builder");
+ g_assert (builder_field);
+ gpointer builder = get_async_method_builder (frame);
g_assert (builder);
void* args [1];
gboolean arg = TRUE;
+ MonoError error;
args [0] = &arg;
- mono_runtime_invoke_checked (get_set_notification_method (builder->vtable->klass), mono_object_unbox (builder), args, &error);
+ mono_runtime_invoke_checked (get_set_notification_method (mono_class_from_mono_type (builder_field->type)), builder, args, &error);
mono_error_assert_ok (&error);
- mono_field_set_value (obj, builder_field, mono_object_unbox (builder));
}
static MonoMethod* notify_debugger_of_wait_completion_method_cache = NULL;
MonoMethodSignature *sig;
guint8 **arg_buf;
void **args;
- MonoObject *this_arg, *res, *exc;
+ MonoObject *this_arg, *res, *exc = NULL;
MonoDomain *domain;
guint8 *this_buf;
#ifdef MONO_ARCH_SOFT_DEBUG_SUPPORTED
mono_stopwatch_start (&watch);
res = mono_runtime_try_invoke (m, m->klass->valuetype ? (gpointer) this_buf : (gpointer) this_arg, args, &exc, &error);
- if (exc == NULL && !mono_error_ok (&error)) {
+ if (!mono_error_ok (&error) && exc == NULL) {
exc = (MonoObject*) mono_error_convert_to_exception (&error);
} else {
mono_error_cleanup (&error); /* FIXME report error */
#include "llvm/ExecutionEngine/Orc/CompileUtils.h"
#include "llvm/ExecutionEngine/Orc/IRCompileLayer.h"
#include "llvm/ExecutionEngine/Orc/LambdaResolver.h"
+#if LLVM_API_VERSION >= 500
+#include "llvm/ExecutionEngine/RTDyldMemoryManager.h"
+#include "llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h"
+#include "llvm/ExecutionEngine/JITSymbol.h"
+#else
#include "llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h"
+#endif
#include <cstdlib>
class MonoLLVMJIT {
public:
/* We use our own trampoline infrastructure instead of the Orc one */
+#if LLVM_API_VERSION >= 500
+ typedef RTDyldObjectLinkingLayer ObjLayerT;
+ typedef IRCompileLayer<ObjLayerT, SimpleCompiler> CompileLayerT;
+ typedef CompileLayerT::ModuleHandleT ModuleHandleT;
+#else
typedef ObjectLinkingLayer<> ObjLayerT;
typedef IRCompileLayer<ObjLayerT> CompileLayerT;
typedef CompileLayerT::ModuleSetHandleT ModuleHandleT;
+#endif
- MonoLLVMJIT (TargetMachine *TM)
+ MonoLLVMJIT (TargetMachine *TM, MonoJitMemoryManager *mm)
+#if LLVM_API_VERSION >= 500
+ : TM(TM), ObjectLayer([=] { return std::shared_ptr<RuntimeDyld::MemoryManager> (mm); }),
+#else
: TM(TM),
- CompileLayer (ObjectLayer, SimpleCompiler (*TM)) {
+#endif
+ CompileLayer (ObjectLayer, SimpleCompiler (*TM)),
+ modules() {
}
- ModuleHandleT addModule(Module *M) {
+#if LLVM_API_VERSION >= 500
+ ModuleHandleT addModule(Function *F, std::shared_ptr<Module> M) {
+#else
+ ModuleHandleT addModule(Function *F, Module *M) {
+#endif
auto Resolver = createLambdaResolver(
[&](const std::string &Name) {
const char *name = Name.c_str ();
- if (!strcmp (name, "___bzero"))
- return RuntimeDyld::SymbolInfo((uint64_t)(gssize)(void*)bzero, (JITSymbolFlags)0);
+#if LLVM_API_VERSION >= 500
+ JITSymbolFlags flags = JITSymbolFlags ();
+#else
+ JITSymbolFlags flags = (JITSymbolFlags)0;
+#endif
+ if (!strcmp (name, "___bzero")) {
+#if LLVM_API_VERSION >= 500
+ return JITSymbol((uint64_t)(gssize)(void*)bzero, flags);
+#else
+ return RuntimeDyld::SymbolInfo((uint64_t)(gssize)(void*)bzero, flags);
+#endif
+ }
MonoDl *current;
char *err;
if (!symbol)
outs () << "R: " << Name << "\n";
assert (symbol);
- return RuntimeDyld::SymbolInfo((uint64_t)(gssize)symbol, (JITSymbolFlags)0);
+#if LLVM_API_VERSION >= 500
+ return JITSymbol((uint64_t)(gssize)symbol, flags);
+#else
+ return RuntimeDyld::SymbolInfo((uint64_t)(gssize)symbol, flags);
+#endif
},
[](const std::string &S) {
outs () << "R2: " << S << "\n";
return nullptr;
} );
+#if LLVM_API_VERSION >= 500
+ ModuleHandleT m = CompileLayer.addModule(M,
+ std::move(Resolver));
+ return m;
+#else
return CompileLayer.addModuleSet(singletonSet(M),
make_unique<MonoJitMemoryManager>(),
std::move(Resolver));
+#endif
}
std::string mangle(const std::string &Name) {
gpointer compile (Function *F, int nvars, LLVMValueRef *callee_vars, gpointer *callee_addrs, gpointer *eh_frame) {
F->getParent ()->setDataLayout (TM->createDataLayout ());
- auto ModuleHandle = addModule (F->getParent ());
-
+#if LLVM_API_VERSION >= 500
+ // Orc uses a shared_ptr to refer to modules so we have to save them ourselves to keep a ref
+ std::shared_ptr<Module> m (F->getParent ());
+ modules.push_back (m);
+ auto ModuleHandle = addModule (F, m);
+#else
+ auto ModuleHandle = addModule (F, F->getParent ());
+#endif
auto BodySym = CompileLayer.findSymbolIn(ModuleHandle, mangle (F), false);
auto BodyAddr = BodySym.getAddress();
assert (BodyAddr);
TargetMachine *TM;
ObjLayerT ObjectLayer;
CompileLayerT CompileLayer;
+ std::vector<std::shared_ptr<Module>> modules;
};
static MonoLLVMJIT *jit;
+static MonoJitMemoryManager *mono_mm;
MonoEERef
mono_llvm_create_ee (LLVMModuleProviderRef MP, AllocCodeMemoryCb *alloc_cb, FunctionEmittedCb *emitted_cb, ExceptionTableCb *exception_cb, DlSymCb *dlsym_cb, LLVMExecutionEngineRef *ee)
auto TM = EB.selectTarget ();
assert (TM);
- jit = new MonoLLVMJIT (TM);
+ mono_mm = new MonoJitMemoryManager ();
+ jit = new MonoLLVMJIT (TM, mono_mm);
return NULL;
}
}
for (i = 0; i < n; ++i)
EMIT_NEW_ARGSTORE (cfg, ins, i, sp [i]);
+
+ mini_profiler_emit_tail_call (cfg, cmethod);
+
MONO_INST_NEW (cfg, ins, OP_BR);
MONO_ADD_INS (cfg->cbb, ins);
tblock = start_bblock->out_bb [0];
if (sp != stack_start)
UNVERIFIED;
+ mini_profiler_emit_leave (cfg, sp [0]);
+
MONO_INST_NEW (cfg, ins, OP_BR);
ins->inst_target_bb = end_bblock;
MONO_ADD_INS (cfg->cbb, ins);
amd64_call_code (code, 0);
}
else {
+ if (!no_patch && ((guint32)(code + 2 - cfg->native_code) % 8) != 0) {
+ guint32 pad_size = 8 - ((guint32)(code + 2 - cfg->native_code) % 8);
+ amd64_padding (code, pad_size);
+ g_assert ((guint64)(code + 2 - cfg->native_code) % 8 == 0);
+ }
mono_add_patch_info (cfg, code - cfg->native_code, patch_type, data);
amd64_set_reg_template (code, GP_SCRATCH_REG);
amd64_call_reg (code, GP_SCRATCH_REG);
#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);
#define PARAM_REGS 6
#define FLOAT_PARAM_REGS 8
-static AMD64_Reg_No param_regs [] = { AMD64_RDI, AMD64_RSI, AMD64_RDX, AMD64_RCX, AMD64_R8, AMD64_R9 };
+static const AMD64_Reg_No param_regs [] = {AMD64_RDI, AMD64_RSI, AMD64_RDX,
+ AMD64_RCX, AMD64_R8, AMD64_R9};
-static AMD64_Reg_No return_regs [] = { AMD64_RAX, AMD64_RDX };
+static const AMD64_Reg_No return_regs [] = {AMD64_RAX, AMD64_RDX};
#endif
typedef struct {
#define MONO_ARCH_CONTEXT_DEF
#endif
-#ifndef MONO_ARCH_STACK_GROWS_UP
-#define MONO_ARCH_STACK_GROWS_UP 0
-#endif
-
/*
* Raw frame information is stored in MonoException.trace_ips as an IntPtr[].
* This structure represents one entry.
return addr;
}
-static inline int
-mini_abort_threshold_offset (gpointer threshold, gpointer sp)
-{
- intptr_t stack_threshold = (intptr_t) threshold;
- intptr_t stack_pointer = (intptr_t) sp;
-
- const int direction = MONO_ARCH_STACK_GROWS_UP ? -1 : 1;
- intptr_t magnitude = stack_pointer - stack_threshold;
-
- return direction * magnitude;
-}
-
static inline void
mini_clear_abort_threshold (void)
{
// Only move it up, to avoid thrown/caught
// exceptions lower in the stack from triggering
// a rethrow
- gboolean above_threshold = mini_abort_threshold_offset (jit_tls->abort_exc_stack_threshold, sp) >= 0;
+ gboolean above_threshold = (gsize) sp >= (gsize) jit_tls->abort_exc_stack_threshold;
if (!jit_tls->abort_exc_stack_threshold || above_threshold) {
jit_tls->abort_exc_stack_threshold = sp;
}
if (!sp)
return TRUE;
- gboolean above_threshold = mini_abort_threshold_offset (jit_tls->abort_exc_stack_threshold, sp) >= 0;
+ gboolean above_threshold = (gsize) sp >= (gsize) jit_tls->abort_exc_stack_threshold;
if (above_threshold)
jit_tls->abort_exc_stack_threshold = sp;
dynamic_methods = g_slist_prepend (dynamic_methods, method);
if (stack_overflow) {
- if (MONO_ARCH_STACK_GROWS_UP)
- free_stack = (guint8*)(MONO_CONTEXT_GET_SP (&initial_ctx)) - (guint8*)(MONO_CONTEXT_GET_SP (ctx));
- else
- free_stack = (guint8*)(MONO_CONTEXT_GET_SP (ctx)) - (guint8*)(MONO_CONTEXT_GET_SP (&initial_ctx));
+ free_stack = (guint8*)(MONO_CONTEXT_GET_SP (ctx)) - (guint8*)(MONO_CONTEXT_GET_SP (&initial_ctx));
} else {
free_stack = 0xffffff;
}
if (ei->flags == MONO_EXCEPTION_CLAUSE_FILTER) {
#ifndef DISABLE_PERFCOUNTERS
- mono_perfcounters->exceptions_filters++;
+ InterlockedIncrement (&mono_perfcounters->exceptions_filters);
#endif
#ifndef MONO_CROSS_COMPILE
//printf ("M: %s %d.\n", mono_method_full_name (method, TRUE), frame_count);
if (stack_overflow) {
- if (MONO_ARCH_STACK_GROWS_UP)
- free_stack = (guint8*)(MONO_CONTEXT_GET_SP (&initial_ctx)) - (guint8*)(MONO_CONTEXT_GET_SP (ctx));
- else
- free_stack = (guint8*)(MONO_CONTEXT_GET_SP (ctx)) - (guint8*)(MONO_CONTEXT_GET_SP (&initial_ctx));
+ free_stack = (guint8*)(MONO_CONTEXT_GET_SP (ctx)) - (guint8*)(MONO_CONTEXT_GET_SP (&initial_ctx));
} else {
free_stack = 0xffffff;
}
}
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);
#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);
#include <llvm/IR/IRBuilder.h>
#include <llvm/IR/Module.h>
#include <llvm/IR/DIBuilder.h>
+#include <llvm/IR/CallSite.h>
#include "mini-llvm-cpp.h"
LLVMValueRef ArraySize,
int alignment, const char *Name)
{
+#if LLVM_API_VERSION >= 500
+ return wrap (unwrap (builder)->Insert (new AllocaInst (unwrap (Ty), 0, unwrap (ArraySize), alignment), Name));
+#else
return wrap (unwrap (builder)->Insert (new AllocaInst (unwrap (Ty), unwrap (ArraySize), alignment), Name));
+#endif
}
LLVMValueRef
#endif
}
+#if LLVM_API_VERSION > 500
+static Attribute::AttrKind
+convert_attr (AttrKind kind)
+{
+ switch (kind) {
+ case LLVM_ATTR_NO_UNWIND:
+ return Attribute::NoUnwind;
+ case LLVM_ATTR_NO_INLINE:
+ return Attribute::NoInline;
+ case LLVM_ATTR_OPTIMIZE_FOR_SIZE:
+ return Attribute::OptimizeForSize;
+ case LLVM_ATTR_IN_REG:
+ return Attribute::InReg;
+ case LLVM_ATTR_STRUCT_RET:
+ return Attribute::StructRet;
+ case LLVM_ATTR_NO_ALIAS:
+ return Attribute::NoAlias;
+ case LLVM_ATTR_BY_VAL:
+ return Attribute::ByVal;
+ case LLVM_ATTR_UW_TABLE:
+ return Attribute::UWTable;
+ default:
+ assert (0);
+ return Attribute::NoUnwind;
+ }
+}
+#else
+static LLVMAttribute
+convert_attr (AttrKind kind)
+{
+ switch (kind) {
+ case LLVM_ATTR_NO_UNWIND:
+ return LLVMNoUnwindAttribute;
+ case LLVM_ATTR_NO_INLINE:
+ return LLVMNoInlineAttribute;
+ case LLVM_ATTR_OPTIMIZE_FOR_SIZE:
+ return LLVMOptimizeForSizeAttribute;
+ case LLVM_ATTR_IN_REG:
+ return LLVMInRegAttribute;
+ case LLVM_ATTR_STRUCT_RET:
+ return LLVMStructRetAttribute;
+ case LLVM_ATTR_NO_ALIAS:
+ return LLVMNoAliasAttribute;
+ case LLVM_ATTR_BY_VAL:
+ return LLVMByValAttribute;
+ case LLVM_ATTR_UW_TABLE:
+ return LLVMUWTable;
+ default:
+ assert (0);
+ return LLVMNoUnwindAttribute;
+ }
+}
+#endif
+
+void
+mono_llvm_add_func_attr (LLVMValueRef func, AttrKind kind)
+{
+#if LLVM_API_VERSION > 100
+ unwrap<Function> (func)->addAttribute (AttributeList::FunctionIndex, convert_attr (kind));
+#else
+ Function *Func = unwrap<Function>(func);
+ const AttributeSet PAL = Func->getAttributes();
+ AttrBuilder B(convert_attr (kind));
+ const AttributeSet PALnew =
+ PAL.addAttributes(Func->getContext(), AttributeSet::FunctionIndex,
+ AttributeSet::get(Func->getContext(),
+ AttributeSet::FunctionIndex, B));
+ Func->setAttributes(PALnew);
+#endif
+}
+
+void
+mono_llvm_add_param_attr (LLVMValueRef param, AttrKind kind)
+{
+#if LLVM_API_VERSION > 100
+ Function *func = unwrap<Argument> (param)->getParent ();
+ int n = unwrap<Argument> (param)->getArgNo ();
+ func->addParamAttr (n, convert_attr (kind));
+#else
+ Argument *A = unwrap<Argument>(param);
+ AttrBuilder B(convert_attr (kind));
+ A->addAttr(AttributeSet::get(A->getContext(), A->getArgNo() + 1, B));
+#endif
+}
+
+void
+mono_llvm_add_instr_attr (LLVMValueRef val, int index, AttrKind kind)
+{
+#if LLVM_API_VERSION > 100
+ CallSite (unwrap<Instruction> (val)).addAttribute (index, convert_attr (kind));
+#else
+ CallSite Call = CallSite(unwrap<Instruction>(val));
+ AttrBuilder B(convert_attr (kind));
+ Call.setAttributes(
+ Call.getAttributes().addAttributes(Call->getContext(), index,
+ AttributeSet::get(Call->getContext(),
+ index, B)));
+#endif
+}
+
#if LLVM_API_VERSION > 100
void*
{
DIBuilder *builder = (DIBuilder*)di_builder;
+#if LLVM_API_VERSION >= 500
+ DIFile *di_file;
+
+ di_file = builder->createFile (cu_name, dir);
+ return builder->createCompileUnit (dwarf::DW_LANG_C99, di_file, producer, true, "", 0);
+#else
return builder->createCompileUnit (dwarf::DW_LANG_C99, cu_name, dir, producer, true, "", 0);
+#endif
}
void*
LLVM_ATOMICRMW_OP_ADD = 1,
} AtomicRMWOp;
+typedef enum {
+ LLVM_ATTR_NO_UNWIND,
+ LLVM_ATTR_NO_INLINE,
+ LLVM_ATTR_OPTIMIZE_FOR_SIZE,
+ LLVM_ATTR_IN_REG,
+ LLVM_ATTR_STRUCT_RET,
+ LLVM_ATTR_NO_ALIAS,
+ LLVM_ATTR_BY_VAL,
+ LLVM_ATTR_UW_TABLE
+} AttrKind;
+
void
mono_llvm_dump_value (LLVMValueRef value);
void
mono_llvm_set_call_notail (LLVMValueRef call);
+void
+mono_llvm_add_func_attr (LLVMValueRef func, AttrKind kind);
+
+void
+mono_llvm_add_param_attr (LLVMValueRef param, AttrKind kind);
+
+void
+mono_llvm_add_instr_attr (LLVMValueRef val, int index, AttrKind kind);
+
_Unwind_Reason_Code
mono_debug_personality (int a, _Unwind_Action b,
uint64_t c, struct _Unwind_Exception *d, struct _Unwind_Context *e);
func = LLVMAddFunction (lmodule, module->get_method_symbol, LLVMFunctionType1 (rtype, LLVMInt32Type (), FALSE));
LLVMSetLinkage (func, LLVMExternalLinkage);
LLVMSetVisibility (func, LLVMHiddenVisibility);
- LLVMAddFunctionAttr (func, LLVMNoUnwindAttribute);
+ mono_llvm_add_func_attr (func, LLVM_ATTR_NO_UNWIND);
module->get_method = func;
entry_bb = LLVMAppendBasicBlock (func, "ENTRY");
func = LLVMAddFunction (lmodule, module->get_unbox_tramp_symbol, LLVMFunctionType1 (rtype, LLVMInt32Type (), FALSE));
LLVMSetLinkage (func, LLVMExternalLinkage);
LLVMSetVisibility (func, LLVMHiddenVisibility);
- LLVMAddFunctionAttr (func, LLVMNoUnwindAttribute);
+ mono_llvm_add_func_attr (func, LLVM_ATTR_NO_UNWIND);
module->get_unbox_tramp = func;
entry_bb = LLVMAppendBasicBlock (func, "ENTRY");
func = LLVMAddFunction (lmodule, "llvm_code_start", LLVMFunctionType (LLVMVoidType (), NULL, 0, FALSE));
LLVMSetLinkage (func, LLVMInternalLinkage);
- LLVMAddFunctionAttr (func, LLVMNoUnwindAttribute);
+ mono_llvm_add_func_attr (func, LLVM_ATTR_NO_UNWIND);
module->code_start = func;
entry_bb = LLVMAppendBasicBlock (func, "ENTRY");
builder = LLVMCreateBuilder ();
g_assert_not_reached ();
}
LLVMSetLinkage (func, LLVMInternalLinkage);
- LLVMAddFunctionAttr (func, LLVMNoInlineAttribute);
+ mono_llvm_add_func_attr (func, LLVM_ATTR_NO_INLINE);
mono_llvm_set_preserveall_cc (func);
entry_bb = LLVMAppendBasicBlock (func, "ENTRY");
builder = LLVMCreateBuilder ();
func = LLVMAddFunction (lmodule, "llvm_code_end", LLVMFunctionType (LLVMVoidType (), NULL, 0, FALSE));
LLVMSetLinkage (func, LLVMInternalLinkage);
- LLVMAddFunctionAttr (func, LLVMNoUnwindAttribute);
+ mono_llvm_add_func_attr (func, LLVM_ATTR_NO_UNWIND);
module->code_end = func;
entry_bb = LLVMAppendBasicBlock (func, "ENTRY");
builder = LLVMCreateBuilder ();
tramp_name = g_strdup_printf ("ut_%s", method_name);
tramp = LLVMAddFunction (ctx->module->lmodule, tramp_name, method_type);
LLVMSetLinkage (tramp, LLVMInternalLinkage);
- LLVMAddFunctionAttr (tramp, LLVMOptimizeForSizeAttribute);
- //LLVMAddFunctionAttr (tramp, LLVMNoUnwindAttribute);
+ mono_llvm_add_func_attr (tramp, LLVM_ATTR_OPTIMIZE_FOR_SIZE);
+ //mono_llvm_add_func_attr (tramp, LLVM_ATTR_NO_UNWIND);
linfo = ctx->linfo;
// FIXME: Reduce code duplication with mono_llvm_compile_method () etc.
if (!ctx->llvm_only && ctx->rgctx_arg_pindex != -1)
- LLVMAddAttribute (LLVMGetParam (tramp, ctx->rgctx_arg_pindex), LLVMInRegAttribute);
+ mono_llvm_add_param_attr (LLVMGetParam (tramp, ctx->rgctx_arg_pindex), LLVM_ATTR_IN_REG);
if (ctx->cfg->vret_addr) {
LLVMSetValueName (LLVMGetParam (tramp, linfo->vret_arg_pindex), "vret");
if (linfo->ret.storage == LLVMArgVtypeByRef) {
- LLVMAddAttribute (LLVMGetParam (tramp, linfo->vret_arg_pindex), LLVMStructRetAttribute);
- LLVMAddAttribute (LLVMGetParam (tramp, linfo->vret_arg_pindex), LLVMNoAliasAttribute);
+ mono_llvm_add_param_attr (LLVMGetParam (tramp, linfo->vret_arg_pindex), LLVM_ATTR_STRUCT_RET);
+ mono_llvm_add_param_attr (LLVMGetParam (tramp, linfo->vret_arg_pindex), LLVM_ATTR_NO_ALIAS);
}
}
}
call = LLVMBuildCall (builder, method, args, nargs, "");
if (!ctx->llvm_only && ctx->rgctx_arg_pindex != -1)
- LLVMAddInstrAttribute (call, 1 + ctx->rgctx_arg_pindex, LLVMInRegAttribute);
+ mono_llvm_add_instr_attr (call, 1 + ctx->rgctx_arg_pindex, LLVM_ATTR_IN_REG);
if (linfo->ret.storage == LLVMArgVtypeByRef)
- LLVMAddInstrAttribute (call, 1 + linfo->vret_arg_pindex, LLVMStructRetAttribute);
+ mono_llvm_add_instr_attr (call, 1 + linfo->vret_arg_pindex, LLVM_ATTR_STRUCT_RET);
// FIXME: This causes assertions in clang
//mono_llvm_set_must_tail (call);
mono_llvm_set_call_preserveall_cc (lcall);
if (cinfo->ret.storage == LLVMArgVtypeByRef)
- LLVMAddInstrAttribute (lcall, 1 + cinfo->vret_arg_pindex, LLVMStructRetAttribute);
+ mono_llvm_add_instr_attr (lcall, 1 + cinfo->vret_arg_pindex, LLVM_ATTR_STRUCT_RET);
if (!ctx->llvm_only && call->rgctx_arg_reg)
- LLVMAddInstrAttribute (lcall, 1 + cinfo->rgctx_arg_pindex, LLVMInRegAttribute);
+ mono_llvm_add_instr_attr (lcall, 1 + cinfo->rgctx_arg_pindex, LLVM_ATTR_IN_REG);
if (call->imt_arg_reg)
- LLVMAddInstrAttribute (lcall, 1 + cinfo->imt_arg_pindex, LLVMInRegAttribute);
+ mono_llvm_add_instr_attr (lcall, 1 + cinfo->imt_arg_pindex, LLVM_ATTR_IN_REG);
/* Add byval attributes if needed */
for (i = 0; i < sig->param_count; ++i) {
LLVMArgInfo *ainfo = &call->cinfo->args [i + sig->hasthis];
if (ainfo && ainfo->storage == LLVMArgVtypeByVal)
- LLVMAddInstrAttribute (lcall, 1 + ainfo->pindex, LLVMByValAttribute);
+ mono_llvm_add_instr_attr (lcall, 1 + ainfo->pindex, LLVM_ATTR_BY_VAL);
}
/*
g_assert (personality);
} else {
#if LLVM_API_VERSION > 100
- personality = ctx->module->personality;
- if (!personality) {
- LLVMTypeRef personality_type = LLVMFunctionType (LLVMInt32Type (), NULL, 0, TRUE);
- personality = LLVMAddFunction (ctx->lmodule, "mono_personality", personality_type);
- LLVMAddFunctionAttr (personality, LLVMNoUnwindAttribute);
- LLVMBasicBlockRef entry_bb = LLVMAppendBasicBlock (personality, "ENTRY");
- LLVMBuilderRef builder2 = LLVMCreateBuilder ();
- LLVMPositionBuilderAtEnd (builder2, entry_bb);
- LLVMBuildRet (builder2, LLVMConstInt (LLVMInt32Type (), 0, FALSE));
- ctx->module->personality = personality;
- LLVMDisposeBuilder (builder2);
- }
+ /* Can't cache this as each method is in its own llvm module */
+ LLVMTypeRef personality_type = LLVMFunctionType (LLVMInt32Type (), NULL, 0, TRUE);
+ personality = LLVMAddFunction (ctx->lmodule, "mono_personality", personality_type);
+ mono_llvm_add_func_attr (personality, LLVM_ATTR_NO_UNWIND);
+ LLVMBasicBlockRef entry_bb = LLVMAppendBasicBlock (personality, "ENTRY");
+ LLVMBuilderRef builder2 = LLVMCreateBuilder ();
+ LLVMPositionBuilderAtEnd (builder2, entry_bb);
+ LLVMBuildRet (builder2, LLVMConstInt (LLVMInt32Type (), 0, FALSE));
+ LLVMDisposeBuilder (builder2);
#else
static gint32 mapping_inited;
args [0] = lhs;
args [1] = rhs;
/* 0xf1 == multiply all 4 elements, add them together, and store the result to the lowest element */
+#if LLVM_API_VERSION >= 500
+ args [2] = LLVMConstInt (LLVMInt8Type (), 0xf1, FALSE);
+#else
args [2] = LLVMConstInt (LLVMInt32Type (), 0xf1, FALSE);
+#endif
values [ins->dreg] = LLVMBuildCall (builder, get_intrinsic (ctx, simd_op_to_intrins (ins->opcode)), args, 3, dname);
break;
if (cfg->compile_aot)
ctx->lmodule = ctx->module->lmodule;
else
- ctx->lmodule = LLVMModuleCreateWithName ("jit-module");
+ ctx->lmodule = LLVMModuleCreateWithName (g_strdup_printf ("jit-module-%s", cfg->method->name));
#else
ctx->lmodule = ctx->module->lmodule;
#endif
LLVMSetFunctionCallConv (method, LLVMMono1CallConv);
LLVMSetLinkage (method, LLVMPrivateLinkage);
- LLVMAddFunctionAttr (method, LLVMUWTable);
+ mono_llvm_add_func_attr (method, LLVM_ATTR_UW_TABLE);
if (cfg->compile_aot) {
LLVMSetLinkage (method, LLVMInternalLinkage);
}
if (header->num_clauses || (cfg->method->iflags & METHOD_IMPL_ATTRIBUTE_NOINLINING) || cfg->no_inline)
/* We can't handle inlined methods with clauses */
- LLVMAddFunctionAttr (method, LLVMNoInlineAttribute);
+ mono_llvm_add_func_attr (method, LLVM_ATTR_NO_INLINE);
if (linfo->rgctx_arg) {
ctx->rgctx_arg = LLVMGetParam (method, linfo->rgctx_arg_pindex);
* CC_X86_64_Mono in X86CallingConv.td.
*/
if (!ctx->llvm_only)
- LLVMAddAttribute (ctx->rgctx_arg, LLVMInRegAttribute);
+ mono_llvm_add_param_attr (ctx->rgctx_arg, LLVM_ATTR_IN_REG);
LLVMSetValueName (ctx->rgctx_arg, "rgctx");
} else {
ctx->rgctx_arg_pindex = -1;
values [cfg->vret_addr->dreg] = LLVMGetParam (method, linfo->vret_arg_pindex);
LLVMSetValueName (values [cfg->vret_addr->dreg], "vret");
if (linfo->ret.storage == LLVMArgVtypeByRef) {
- LLVMAddAttribute (LLVMGetParam (method, linfo->vret_arg_pindex), LLVMStructRetAttribute);
- LLVMAddAttribute (LLVMGetParam (method, linfo->vret_arg_pindex), LLVMNoAliasAttribute);
+ mono_llvm_add_param_attr (LLVMGetParam (method, linfo->vret_arg_pindex), LLVM_ATTR_STRUCT_RET);
+ mono_llvm_add_param_attr (LLVMGetParam (method, linfo->vret_arg_pindex), LLVM_ATTR_NO_ALIAS);
}
}
LLVMSetValueName (values [cfg->args [i + sig->hasthis]->dreg], name);
g_free (name);
if (ainfo->storage == LLVMArgVtypeByVal)
- LLVMAddAttribute (LLVMGetParam (method, pindex), LLVMByValAttribute);
+ mono_llvm_add_param_attr (LLVMGetParam (method, pindex), LLVM_ATTR_BY_VAL);
if (ainfo->storage == LLVMArgVtypeByRef) {
/* For OP_LDADDR */
ret_type = type_to_simd_type (MONO_TYPE_R4);
arg_types [0] = type_to_simd_type (MONO_TYPE_R4);
arg_types [1] = type_to_simd_type (MONO_TYPE_R4);
+#if LLVM_API_VERSION >= 500
+ arg_types [2] = LLVMInt8Type ();
+#else
arg_types [2] = LLVMInt32Type ();
+#endif
AddFunc (module, name, ret_type, arg_types, 3);
break;
#endif
MINI_OP(OP_S390_IADD_OVF_UN, "s390_int_add_ovf_un", IREG, IREG, IREG)
MINI_OP(OP_S390_ISUB_OVF, "s390_int_sub_ovf", IREG, IREG, IREG)
MINI_OP(OP_S390_ISUB_OVF_UN, "s390_int_sub_ovf_un", IREG, IREG, IREG)
+MINI_OP(OP_S390_CRJ, "s390_crj", IREG, IREG, IREG)
+MINI_OP(OP_S390_CLRJ, "s390_crj_un", IREG, IREG, IREG)
+MINI_OP(OP_S390_CGRJ, "s390_cgrj", LREG, LREG, IREG)
+MINI_OP(OP_S390_CLGRJ, "s390_cgrj_un", LREG, LREG, IREG)
+MINI_OP(OP_S390_CIJ, "s390_cij", IREG, NONE, NONE)
+MINI_OP(OP_S390_CLIJ, "s390_cij_un", IREG, IREG, NONE)
+MINI_OP(OP_S390_CGIJ, "s390_cgij", LREG, NONE, NONE)
+MINI_OP(OP_S390_CLGIJ, "s390_cgij_un", LREG, NONE, NONE)
#endif
#if defined(__mips__)
#endif
error_init (error);
+ if (exc)
+ *exc = NULL;
if (obj == NULL && !(method->flags & METHOD_ATTRIBUTE_STATIC) && !method->string_ctor && (method->wrapper_type == 0)) {
g_warning ("Ignoring invocation of an instance method on a NULL instance.\n");
s390_jcl (code, cond, 0); \
} while (0);
+#define EMIT_COMP_AND_BRANCH(ins, cab, cmp) \
+{ \
+if (ins->inst_true_bb->native_offset) { \
+ int displace; \
+ displace = ((cfg->native_code + \
+ ins->inst_true_bb->native_offset) - code) / 2; \
+ if (s390_is_imm16(displace)) { \
+ s390_##cab (code, ins->sreg1, ins->sreg2, \
+ ins->sreg3, displace); \
+ } else { \
+ s390_##cmp (code, ins->sreg1, ins->sreg2); \
+ displace = ((cfg->native_code + \
+ ins->inst_true_bb->native_offset) - code) / 2; \
+ s390_jcl (code, ins->sreg3, displace); \
+ } \
+} else { \
+ s390_##cmp (code, ins->sreg1, ins->sreg2); \
+ mono_add_patch_info (cfg, code - cfg->native_code, \
+ MONO_PATCH_INFO_BB, ins->inst_true_bb); \
+ s390_jcl (code, ins->sreg3, 0); \
+} \
+}
+
+#define EMIT_COMP_AND_BRANCH_IMM(ins, cab, cmp, lat, logical) \
+{ \
+if (ins->inst_true_bb->native_offset) { \
+ int displace; \
+ if ((ins->backend.data == 0) && (!logical)) { \
+ s390_##lat (code, ins->sreg1, ins->sreg1); \
+ displace = ((cfg->native_code + \
+ ins->inst_true_bb->native_offset) - code) / 2; \
+ if (s390_is_imm16(displace)) { \
+ s390_brc (code, ins->sreg3, displace); \
+ } else { \
+ s390_jcl (code, ins->sreg3, displace); \
+ } \
+ } else { \
+ S390_SET (code, s390_r0, ins->backend.data); \
+ displace = ((cfg->native_code + \
+ ins->inst_true_bb->native_offset) - code) / 2; \
+ if (s390_is_imm16(displace)) { \
+ s390_##cab (code, ins->sreg1, s390_r0, \
+ ins->sreg3, displace); \
+ } else { \
+ s390_##cmp (code, ins->sreg1, s390_r0); \
+ displace = ((cfg->native_code + \
+ ins->inst_true_bb->native_offset) - code) / 2; \
+ s390_jcl (code, ins->sreg3, displace); \
+ } \
+ } \
+} else { \
+ if ((ins->backend.data == 0) && (!logical)) { \
+ s390_##lat (code, ins->sreg1, ins->sreg1); \
+ } else { \
+ S390_SET (code, s390_r0, ins->backend.data); \
+ s390_##cmp (code, ins->sreg1, s390_r0); \
+ } \
+ mono_add_patch_info (cfg, code - cfg->native_code, \
+ MONO_PATCH_INFO_BB, ins->inst_true_bb); \
+ s390_jcl (code, ins->sreg3, 0); \
+} \
+}
+
#define CHECK_SRCDST_COM \
if (ins->dreg == ins->sreg2) { \
src2 = ins->sreg1; \
static guchar * emit_float_to_int (MonoCompile *, guchar *, int, int, int, gboolean);
static guint8 * emit_load_volatile_arguments (guint8 *, MonoCompile *);
static __inline__ void emit_unwind_regs(MonoCompile *, guint8 *, int, int, long);
+static void compare_and_branch(MonoBasicBlock *, MonoInst *, int, gboolean);
/*========================= End of Prototypes ======================*/
int mono_exc_esp_offset = 0;
__thread int indent_level = 0;
+__thread FILE *trFd = NULL;
+int curThreadNo = 0;
/*
* The code generated for sequence points reads from this location,
if (diff < 0)
indent_level += diff;
v = indent_level;
- printf("%p [%3d] ",(void *)pthread_self(),v);
+ fprintf (trFd, "%p [%3d] ",(void *)pthread_self(),v);
while (v-- > 0) {
- printf (". ");
+ fprintf (trFd, ". ");
}
if (diff > 0)
indent_level += diff;
/*------------------------------------------------------------------*/
/* */
-/* Name - decodeParm */
+/* Name - decodeParmString */
/* */
-/* Function - Decode a parameter for the trace. */
+/* Function - Decode a parameter string for the trace. */
/* */
/*------------------------------------------------------------------*/
MonoError error;
char *str = mono_string_to_utf8_checked(s, &error);
if (is_ok (&error)) {
- printf("[STRING:%p:%s], ", s, str);
+ fprintf (trFd, "[STRING:%p:%s], ", s, str);
g_free (str);
} else {
mono_error_cleanup (&error);
- printf("[STRING:%p:], ", s);
+ fprintf (trFd, "[STRING:%p:], ", s);
}
}
+/*========================= End of Function ========================*/
+
+/*------------------------------------------------------------------*/
+/* */
+/* Name - decodeParm */
+/* */
+/* Function - Decode a parameter for the trace. */
+/* */
+/*------------------------------------------------------------------*/
+
+
static void
decodeParm(MonoType *type, void *curParm, int size)
{
guint32 simpleType;
if (type->byref) {
- printf("[BYREF:%p], ", *((char **) curParm));
+ fprintf (trFd, "[BYREF:%p], ", *((char **) curParm));
} else {
simpleType = mini_get_underlying_type(type)->type;
enum_parmtype:
switch (simpleType) {
case MONO_TYPE_I :
- printf ("[INTPTR:%p], ", *((int **) curParm));
+ fprintf (trFd, "[INTPTR:%p], ", *((int **) curParm));
break;
case MONO_TYPE_U :
- printf ("[UINTPTR:%p], ", *((int **) curParm));
+ fprintf (trFd, "[UINTPTR:%p], ", *((int **) curParm));
break;
case MONO_TYPE_BOOLEAN :
- printf ("[BOOL:%ld], ", *((gint64 *) curParm));
+ fprintf (trFd, "[BOOL:%ld], ", *((gint64 *) curParm));
break;
case MONO_TYPE_CHAR :
- printf ("[CHAR:%c], ", *((int *) curParm));
+ fprintf (trFd, "[CHAR:%c], ", *((int *) curParm));
break;
case MONO_TYPE_I1 :
- printf ("[INT1:%ld], ", *((gint64 *) curParm));
+ fprintf (trFd, "[INT1:%ld], ", *((gint64 *) curParm));
break;
case MONO_TYPE_I2 :
- printf ("[INT2:%ld], ", *((gint64 *) curParm));
+ fprintf (trFd, "[INT2:%ld], ", *((gint64 *) curParm));
break;
case MONO_TYPE_I4 :
- printf ("[INT4:%ld], ", *((gint64 *) curParm));
+ fprintf (trFd, "[INT4:%ld], ", *((gint64 *) curParm));
break;
case MONO_TYPE_U1 :
- printf ("[UINT1:%lu], ", *((guint64 *) curParm));
+ fprintf (trFd, "[UINT1:%lu], ", *((guint64 *) curParm));
break;
case MONO_TYPE_U2 :
- printf ("[UINT2:%lu], ", *((guint64 *) curParm));
+ fprintf (trFd, "[UINT2:%lu], ", *((guint64 *) curParm));
break;
case MONO_TYPE_U4 :
- printf ("[UINT4:%lu], ", *((guint64 *) curParm));
+ fprintf (trFd, "[UINT4:%lu], ", *((guint64 *) curParm));
break;
case MONO_TYPE_U8 :
- printf ("[UINT8:%lu], ", *((guint64 *) curParm));
+ fprintf (trFd, "[UINT8:%lu], ", *((guint64 *) curParm));
break;
case MONO_TYPE_STRING : {
MonoString *s = *((MonoString **) curParm);
g_assert (((MonoObject *) s)->vtable->klass == mono_defaults.string_class);
decodeParmString (s);
} else {
- printf("[STRING:null], ");
+ fprintf (trFd, "[STRING:null], ");
}
break;
}
MonoObject *obj = *((MonoObject **) curParm);
MonoClass *klass;
if ((obj) && (obj->vtable)) {
- printf("[CLASS/OBJ:");
+ fprintf (trFd, "[CLASS/OBJ:");
klass = obj->vtable->klass;
- printf("%p [%p] ",obj,curParm);
+ fprintf (trFd, "%p [%p] ",obj,curParm);
if (klass == mono_defaults.string_class) {
decodeParmString ((MonoString *)obj);
} else if (klass == mono_defaults.int32_class) {
- printf("[INT32:%p:%d]",
+ fprintf (trFd, "[INT32:%p:%d]",
obj, *(gint32 *)((char *)obj + sizeof (MonoObject)));
} else
- printf("[%s.%s:%p]",
+ fprintf (trFd, "[%s.%s:%p]",
klass->name_space, klass->name, obj);
- printf("], ");
+ fprintf (trFd, "], ");
} else {
- printf("[OBJECT:null], ");
+ fprintf (trFd, "[OBJECT:null], ");
}
break;
}
case MONO_TYPE_PTR :
- printf("[PTR:%p], ", *((gpointer **) (curParm)));
+ fprintf (trFd, "[PTR:%p], ", *((gpointer **) (curParm)));
break;
case MONO_TYPE_FNPTR :
- printf("[FNPTR:%p], ", *((gpointer **) (curParm)));
+ fprintf (trFd, "[FNPTR:%p], ", *((gpointer **) (curParm)));
break;
case MONO_TYPE_ARRAY :
- printf("[ARRAY:%p], ", *((gpointer **) (curParm)));
+ fprintf (trFd, "[ARRAY:%p], ", *((gpointer **) (curParm)));
break;
case MONO_TYPE_SZARRAY :
- printf("[SZARRAY:%p], ", *((gpointer **) (curParm)));
+ fprintf (trFd, "[SZARRAY:%p], ", *((gpointer **) (curParm)));
break;
case MONO_TYPE_I8 :
- printf("[INT8:%ld], ", *((gint64 *) (curParm)));
+ fprintf (trFd, "[INT8:%ld], ", *((gint64 *) (curParm)));
break;
case MONO_TYPE_R4 :
- printf("[FLOAT4:%g], ", *((float *) (curParm)));
+ fprintf (trFd, "[FLOAT4:%g], ", *((float *) (curParm)));
break;
case MONO_TYPE_R8 :
- printf("[FLOAT8:%g], ", *((double *) (curParm)));
+ fprintf (trFd, "[FLOAT8:%g], ", *((double *) (curParm)));
break;
case MONO_TYPE_VALUETYPE : {
int i;
if (type->data.klass->enumtype) {
simpleType = mono_class_enum_basetype (type->data.klass)->type;
- printf("{VALUETYPE} - ");
+ fprintf (trFd, "{VALUETYPE} - ");
goto enum_parmtype;
}
if ((info->native_size == sizeof(float)) &&
(info->num_fields == 1) &&
(info->fields[0].field->type->type == MONO_TYPE_R4)) {
- printf("[FLOAT4:%f], ", *((float *) (curParm)));
+ fprintf (trFd, "[FLOAT4:%f], ", *((float *) (curParm)));
break;
}
if ((info->native_size == sizeof(double)) &&
(info->num_fields == 1) &&
(info->fields[0].field->type->type == MONO_TYPE_R8)) {
- printf("[FLOAT8:%g], ", *((double *) (curParm)));
+ fprintf (trFd, "[FLOAT8:%g], ", *((double *) (curParm)));
break;
}
- printf("[VALUETYPE:");
+ fprintf (trFd, "[VALUETYPE:");
for (i = 0; i < size; i++)
- printf("%02x,", *((guint8 *)curParm+i));
- printf("], ");
+ fprintf (trFd, "%02x,", *((guint8 *)curParm+i));
+ fprintf (trFd, "], ");
break;
}
case MONO_TYPE_TYPEDBYREF: {
int i;
- printf("[TYPEDBYREF:");
+ fprintf (trFd, "[TYPEDBYREF:");
for (i = 0; i < size; i++)
- printf("%02x,", *((guint8 *)curParm+i));
- printf("]");
+ fprintf (trFd, "%02x,", *((guint8 *)curParm+i));
+ fprintf (trFd, "]");
break;
}
default :
- printf("[%s], ",cvtMonoType(simpleType));
+ fprintf (trFd, "[%s], ",cvtMonoType(simpleType));
}
}
}
ArgInfo *ainfo;
void *curParm;
+ if (trFd == NULL) {
+ char buf[32];
+ sprintf(buf, "/tmp/mono.%d.trc.%d", getpid(), curThreadNo++);
+ trFd = fopen(buf, "w");
+ }
fname = mono_method_full_name (method, TRUE);
indent (1);
- printf ("ENTER: %s ", fname);
+ fprintf (trFd, "ENTER: %s ", fname);
g_free (fname);
ip = (*(guint64 *) (sp+S390_RET_ADDR_OFFSET));
- printf ("ip: %p sp: %p - ", (gpointer) ip, sp);
+ fprintf (trFd, "ip: %p sp: %p - ", (gpointer) ip, sp);
if (rParm == NULL)
return;
cinfo = get_call_info (NULL, NULL, sig);
if (cinfo->struct_ret) {
- printf ("[STRUCTRET:%p], ", (gpointer) rParm->gr[0]);
+ fprintf (trFd, "[STRUCTRET:%p], ", (gpointer) rParm->gr[0]);
iParm = 1;
}
case MONO_TYPE_VALUETYPE:
if (obj) {
guint64 *value = (guint64 *) ((uintptr_t)this_arg + sizeof(MonoObject));
- printf("this:[value:%p:%016lx], ", this_arg, *value);
+ fprintf (trFd, "this:[value:%p:%016lx], ", this_arg, *value);
} else
- printf ("this:[NULL], ");
+ fprintf (trFd, "this:[NULL], ");
break;
case MONO_TYPE_STRING:
if (obj) {
if (obj->vtable) {
klass = obj->vtable->klass;
if (klass == mono_defaults.string_class) {
- printf ("this:");
+ fprintf (trFd, "this:");
decodeParmString((MonoString *)obj);
} else {
- printf ("this:%p[%s.%s], ",
+ fprintf (trFd, "this:%p[%s.%s], ",
obj, klass->name_space, klass->name);
}
} else
- printf("vtable:[NULL], ");
+ fprintf (trFd, "vtable:[NULL], ");
} else
- printf ("this:[NULL], ");
+ fprintf (trFd, "this:[NULL], ");
break;
default :
- printf("this[%s]: %p, ",cvtMonoType(method->klass->this_arg.type),this_arg);
+ fprintf (trFd, "this[%s]: %p, ",cvtMonoType(method->klass->this_arg.type),this_arg);
}
oParm++;
}
break;
default :
- printf("???, ");
+ fprintf (trFd, "???, ");
}
}
- printf("\n");
+ fprintf (trFd, "\n");
g_free(cinfo);
}
fname = mono_method_full_name (method, TRUE);
indent (-1);
- printf ("LEAVE: %s", fname);
+ fprintf (trFd, "LEAVE: %s", fname);
g_free (fname);
type = mono_method_signature (method)->ret;
case MONO_TYPE_BOOLEAN: {
int val = va_arg (ap, int);
if (val)
- printf ("[TRUE:%d]", val);
+ fprintf (trFd, "[TRUE:%d]", val);
else
- printf ("[FALSE]");
+ fprintf (trFd, "[FALSE]");
break;
}
case MONO_TYPE_CHAR: {
int val = va_arg (ap, int);
- printf ("[CHAR:%d]", val);
+ fprintf (trFd, "[CHAR:%d]", val);
break;
}
case MONO_TYPE_I1: {
int val = va_arg (ap, int);
- printf ("[INT1:%d]", val);
+ fprintf (trFd, "[INT1:%d]", val);
break;
}
case MONO_TYPE_U1: {
int val = va_arg (ap, int);
- printf ("[UINT1:%d]", val);
+ fprintf (trFd, "[UINT1:%d]", val);
break;
}
case MONO_TYPE_I2: {
int val = va_arg (ap, int);
- printf ("[INT2:%d]", val);
+ fprintf (trFd, "[INT2:%d]", val);
break;
}
case MONO_TYPE_U2: {
int val = va_arg (ap, int);
- printf ("[UINT2:%d]", val);
+ fprintf (trFd, "[UINT2:%d]", val);
break;
}
case MONO_TYPE_I4: {
int val = va_arg (ap, int);
- printf ("[INT4:%d]", val);
+ fprintf (trFd, "[INT4:%d]", val);
break;
}
case MONO_TYPE_U4: {
int val = va_arg (ap, int);
- printf ("[UINT4:%d]", val);
+ fprintf (trFd, "[UINT4:%d]", val);
break;
}
case MONO_TYPE_I: {
gint64 val = va_arg (ap, gint64);
- printf ("[INT:%ld]", val);
- printf("]");
+ fprintf (trFd, "[INT:%ld]", val);
+ fprintf (trFd, "]");
break;
}
case MONO_TYPE_U: {
gint64 val = va_arg (ap, gint64);
- printf ("[UINT:%lu]", val);
- printf("]");
+ fprintf (trFd, "[UINT:%lu]", val);
+ fprintf (trFd, "]");
break;
}
case MONO_TYPE_STRING: {
g_assert (((MonoObject *)s)->vtable->klass == mono_defaults.string_class);
decodeParmString (s);
} else
- printf ("[STRING:null], ");
+ fprintf (trFd, "[STRING:null], ");
break;
}
case MONO_TYPE_CLASS:
if ((o) && (o->vtable)) {
if (o->vtable->klass == mono_defaults.boolean_class) {
- printf ("[BOOLEAN:%p:%d]", o, *((guint8 *)o + sizeof (MonoObject)));
+ fprintf (trFd, "[BOOLEAN:%p:%d]", o, *((guint8 *)o + sizeof (MonoObject)));
} else if (o->vtable->klass == mono_defaults.int32_class) {
- printf ("[INT32:%p:%d]", o, *((gint32 *)((char *)o + sizeof (MonoObject))));
+ fprintf (trFd, "[INT32:%p:%d]", o, *((gint32 *)((char *)o + sizeof (MonoObject))));
} else if (o->vtable->klass == mono_defaults.int64_class) {
- printf ("[INT64:%p:%ld]", o, *((gint64 *)((char *)o + sizeof (MonoObject))));
+ fprintf (trFd, "[INT64:%p:%ld]", o, *((gint64 *)((char *)o + sizeof (MonoObject))));
} else
- printf ("[%s.%s:%p]", o->vtable->klass->name_space, o->vtable->klass->name, o);
+ fprintf (trFd, "[%s.%s:%p]", o->vtable->klass->name_space, o->vtable->klass->name, o);
} else
- printf ("[OBJECT:%p]", o);
+ fprintf (trFd, "[OBJECT:%p]", o);
break;
}
case MONO_TYPE_ARRAY:
case MONO_TYPE_SZARRAY: {
gpointer p = va_arg (ap, gpointer);
- printf ("[result=%p]", p);
+ fprintf (trFd, "[result=%p]", p);
break;
}
case MONO_TYPE_I8: {
gint64 l = va_arg (ap, gint64);
- printf ("[LONG:%ld]", l);
+ fprintf (trFd, "[LONG:%ld]", l);
break;
}
case MONO_TYPE_U8: {
guint64 l = va_arg (ap, guint64);
- printf ("[ULONG:%lu]", l);
+ fprintf (trFd, "[ULONG:%lu]", l);
break;
}
case MONO_TYPE_R4: {
double f = va_arg (ap, double);
- printf ("[FLOAT4:%g]\n", f);
+ fprintf (trFd, "[FLOAT4:%g]\n", f);
break;
}
case MONO_TYPE_R8: {
double f = va_arg (ap, double);
- printf ("[FLOAT8:%g]\n", f);
+ fprintf (trFd, "[FLOAT8:%g]\n", f);
break;
}
case MONO_TYPE_VALUETYPE: {
(info->num_fields == 1) &&
(info->fields[0].field->type->type == MONO_TYPE_R4)) {
double f = va_arg (ap, double);
- printf("[FLOAT4:%g]\n", (double) f);
+ fprintf (trFd, "[FLOAT4:%g]\n", (double) f);
break;
}
(info->num_fields == 1) &&
(info->fields[0].field->type->type == MONO_TYPE_R8)) {
double f = va_arg (ap, double);
- printf("[FLOAT8:%g]\n", f);
+ fprintf (trFd, "[FLOAT8:%g]\n", f);
break;
}
switch (size) {
case 1: {
guint32 p = va_arg (ap, guint32);
- printf ("[%02x]\n",p);
+ fprintf (trFd, "[%02x]\n",p);
break;
}
case 2: {
guint32 p = va_arg (ap, guint32);
- printf ("[%04x]\n",p);
+ fprintf (trFd, "[%04x]\n",p);
break;
}
case 4: {
guint32 p = va_arg (ap, guint32);
- printf ("[%08x]\n",p);
+ fprintf (trFd, "[%08x]\n",p);
break;
}
case 8: {
guint64 p = va_arg (ap, guint64);
- printf ("[%016lx]\n",p);
+ fprintf (trFd, "[%016lx]\n",p);
break;
}
default: {
gpointer p = va_arg (ap, gpointer);
- printf ("[VALUETYPE] %p\n",p);
+ fprintf (trFd, "[VALUETYPE] %p\n",p);
}
}
}
case 2:
case 4:
case 8:
- printf ("[");
+ fprintf (trFd, "[");
for (j = 0; p && j < size; j++)
- printf ("%02x,", p [j]);
- printf ("]\n");
+ fprintf (trFd, "%02x,", p [j]);
+ fprintf (trFd, "]\n");
break;
default:
- printf ("[TYPEDBYREF]\n");
+ fprintf (trFd, "[TYPEDBYREF]\n");
}
}
break;
case MONO_TYPE_GENERICINST: {
- printf("[GENERICINST]\n");
+ fprintf (trFd, "[GENERICINST]\n");
}
break;
case MONO_TYPE_MVAR: {
- printf("[MVAR]\n");
+ fprintf (trFd, "[MVAR]\n");
}
break;
case MONO_TYPE_CMOD_REQD: {
- printf("[CMOD_REQD]\n");
+ fprintf (trFd, "[CMOD_REQD]\n");
}
break;
case MONO_TYPE_CMOD_OPT: {
- printf("[CMOD_OPT]\n");
+ fprintf (trFd, "[CMOD_OPT]\n");
}
break;
case MONO_TYPE_INTERNAL: {
- printf("[INTERNAL]\n");
+ fprintf (trFd, "[INTERNAL]\n");
}
break;
default:
- printf ("(unknown return type %x)",
+ fprintf (trFd, "(unknown return type %x)",
mono_method_signature (method)->ret->type);
}
ip = ((gint64) __builtin_extract_return_addr (__builtin_return_address (0)));
- printf (" ip: %p\n", (gpointer) ip);
+ fprintf (trFd, " ip: %p\n", (gpointer) ip);
va_end (ap);
}
/* FIXME: s390_r12 is reserved for bkchain_reg. Only reserve it if needed */
top = 12;
for (i = 8; i < top; ++i) {
- if (cfg->frame_reg != i)
+ if ((cfg->frame_reg != i) &&
+ //!((cfg->uses_rgctx_reg) && (i == MONO_ARCH_IMT_REG)))
+ (i != MONO_ARCH_IMT_REG))
regs = g_list_prepend (regs, GUINT_TO_POINTER (i));
}
cfg->arch.bkchain_reg = -1;
if (frame_reg != STK_BASE)
- cfg->used_int_regs |= (1 << frame_reg);
-
- if (cfg->uses_rgctx_reg)
- cfg->used_int_regs |= (1 << MONO_ARCH_IMT_REG);
+ cfg->used_int_regs |= (1LL << frame_reg);
sig = mono_method_signature (cfg->method);
}
break;
}
-#if 0
- if ((sig->call_convention == MONO_CALL_VARARG) &&
- (cinfo->args[iParm].regtype != RegTypeGeneral) &&
- (iParm < sig->sentinelpos))
- cfg->sig_cookie += size;
-printf("%s %4d cookine %x\n",__FUNCTION__,__LINE__,cfg->sig_cookie);
-#endif
-
offset += MAX(size, 8);
}
curinst++;
ins->inst_destbasereg = STK_BASE;
ins->inst_offset = ainfo->offset;
ins->sreg1 = in->dreg;
-
-#if 0
- /* This is needed by MonoTypedRef->value to point to the correct data */
- if ((sig->call_convention == MONO_CALL_VARARG) &&
- (i >= sig->sentinelpos)) {
- switch (ainfo->size) {
- case 1:
- ins->opcode = OP_STOREI1_MEMBASE_REG;
- break;
- case 2:
- ins->opcode = OP_STOREI2_MEMBASE_REG;
- break;
- case 4:
- ins->opcode = OP_STOREI4_MEMBASE_REG;
- break;
- default:
- break;
- }
- }
-#endif
-
MONO_ADD_INS (cfg->cbb, ins);
}
break;
/*========================= End of Function ========================*/
+/*------------------------------------------------------------------*/
+/* */
+/* Name - compare_and_branch */
+/* */
+/* Function - Form a peephole pass at the code looking for */
+/* simple optimizations. */
+/* */
+/*------------------------------------------------------------------*/
+
+static void
+compare_and_branch(MonoBasicBlock *bb, MonoInst *ins, int cc, gboolean logical)
+{
+ MonoInst *last;
+
+ if (mono_hwcap_s390x_has_gie) {
+ last = mono_inst_prev (ins, FILTER_IL_SEQ_POINT);
+ ins->sreg1 = last->sreg1;
+ ins->sreg2 = last->sreg2;
+ ins->sreg3 = cc;
+ switch(last->opcode) {
+ case OP_ICOMPARE:
+ if (logical)
+ ins->opcode = OP_S390_CLRJ;
+ else
+ ins->opcode = OP_S390_CRJ;
+ MONO_DELETE_INS(bb, last);
+ break;
+ case OP_COMPARE:
+ case OP_LCOMPARE:
+ if (logical)
+ ins->opcode = OP_S390_CLGRJ;
+ else
+ ins->opcode = OP_S390_CGRJ;
+ MONO_DELETE_INS(bb, last);
+ break;
+ case OP_ICOMPARE_IMM:
+ ins->backend.data = (gpointer) last->inst_imm;
+ if (logical)
+ ins->opcode = OP_S390_CLIJ;
+ else
+ ins->opcode = OP_S390_CIJ;
+ MONO_DELETE_INS(bb, last);
+ break;
+ case OP_COMPARE_IMM:
+ case OP_LCOMPARE_IMM:
+ ins->backend.data = (gpointer) last->inst_imm;
+ if (logical)
+ ins->opcode = OP_S390_CLGIJ;
+ else
+ ins->opcode = OP_S390_CGIJ;
+ MONO_DELETE_INS(bb, last);
+ break;
+ }
+ }
+}
+
+/*========================= End of Function ========================*/
+
/*------------------------------------------------------------------*/
/* */
/* Name - mono_arch_peephole_pass_1 */
void
mono_arch_peephole_pass_1 (MonoCompile *cfg, MonoBasicBlock *bb)
{
+ MonoInst *ins, *n;
+
+ MONO_BB_FOR_EACH_INS_SAFE (bb, n, ins) {
+ switch (ins->opcode) {
+ case OP_IBEQ:
+ case OP_LBEQ:
+ compare_and_branch(bb, ins, S390_CC_EQ, FALSE);
+ break;
+ case OP_LBNE_UN:
+ case OP_IBNE_UN:
+ compare_and_branch(bb, ins, S390_CC_NE, TRUE);
+ break;
+ case OP_LBLT:
+ case OP_IBLT:
+ compare_and_branch(bb, ins, S390_CC_LT, FALSE);
+ break;
+ case OP_LBLT_UN:
+ case OP_IBLT_UN:
+ compare_and_branch(bb, ins, S390_CC_LT, TRUE);
+ break;
+ case OP_LBGT:
+ case OP_IBGT:
+ compare_and_branch(bb, ins, S390_CC_GT, FALSE);
+ break;
+ case OP_LBGT_UN:
+ case OP_IBGT_UN:
+ compare_and_branch(bb, ins, S390_CC_GT, TRUE);
+ break;
+ case OP_LBGE:
+ case OP_IBGE:
+ compare_and_branch(bb, ins, S390_CC_GE, FALSE);
+ break;
+ case OP_LBGE_UN:
+ case OP_IBGE_UN:
+ compare_and_branch(bb, ins, S390_CC_GE, TRUE);
+ break;
+ case OP_LBLE:
+ case OP_IBLE:
+ compare_and_branch(bb, ins, S390_CC_LE, FALSE);
+ break;
+ case OP_LBLE_UN:
+ case OP_IBLE_UN:
+ compare_and_branch(bb, ins, S390_CC_LE, TRUE);
+ break;
+
+ // default:
+ // mono_peephole_ins (bb, ins);
+ }
+ }
}
/*========================= End of Function ========================*/
void
mono_arch_peephole_pass_2 (MonoCompile *cfg, MonoBasicBlock *bb)
{
- MonoInst *ins, *n;
+ MonoInst *ins, *n, *last_ins = NULL;
MONO_BB_FOR_EACH_INS_SAFE (bb, n, ins) {
+ switch (ins->opcode) {
+ case OP_LOADU4_MEMBASE:
+ case OP_LOADI4_MEMBASE:
+ if (last_ins && (last_ins->opcode == OP_STOREI4_MEMBASE_REG) &&
+ ins->inst_basereg == last_ins->inst_destbasereg &&
+ ins->inst_offset == last_ins->inst_offset) {
+ ins->opcode = (ins->opcode == OP_LOADI4_MEMBASE) ? OP_ICONV_TO_I4 : OP_ICONV_TO_U4;
+ ins->sreg1 = last_ins->sreg1;
+ }
+ break;
+ }
mono_peephole_ins (bb, ins);
}
}
/*------------------------------------------------------------------*/
/* */
-/* Name - gboolean_is_unsigned. */
+/* Name - is_unsigned. */
/* */
/* Function - Return TRUE if next opcode is checking for un- */
/* signed value. */
/* */
/*------------------------------------------------------------------*/
-static
-gboolean is_unsigned (MonoInst *next)
+static gboolean
+is_unsigned (MonoInst *next)
{
if ((next) &&
(((next->opcode >= OP_IBNE_UN) &&
((next->opcode >= OP_COND_EXC_INE_UN) &&
(next->opcode <= OP_COND_EXC_ILT_UN)) ||
((next->opcode == OP_CLT_UN) ||
- (next->opcode == OP_CGT_UN)) ||
+ (next->opcode == OP_CGT_UN) ||
+ (next->opcode == OP_ICGE_UN) ||
+ (next->opcode == OP_ICLE_UN)) ||
((next->opcode == OP_ICLT_UN) ||
(next->opcode == OP_ICGT_UN) ||
(next->opcode == OP_LCLT_UN) ||
s390_llghr (code, ins->dreg, ins->sreg1);
}
break;
+ case OP_ICONV_TO_U4: {
+ s390_llgfr (code, ins->dreg, ins->sreg1);
+ }
+ break;
+ case OP_ICONV_TO_I4: {
+ s390_lgfr (code, ins->dreg, ins->sreg1);
+ }
+ break;
case OP_COMPARE:
case OP_LCOMPARE: {
if (is_unsigned (ins->next))
break;
case OP_COMPARE_IMM:
case OP_LCOMPARE_IMM: {
- S390_SET (code, s390_r0, ins->inst_imm);
- if (is_unsigned (ins->next))
- s390_clgr (code, ins->sreg1, s390_r0);
- else
- s390_cgr (code, ins->sreg1, s390_r0);
+ gboolean branchUn = is_unsigned (ins->next);
+ if ((ins->inst_imm == 0) && (!branchUn)) {
+ s390_ltgr (code, ins->sreg1, ins->sreg1);
+ } else {
+ S390_SET (code, s390_r0, ins->inst_imm);
+ if (branchUn)
+ s390_clgr (code, ins->sreg1, s390_r0);
+ else
+ s390_cgr (code, ins->sreg1, s390_r0);
+ }
}
break;
case OP_ICOMPARE_IMM: {
- S390_SET (code, s390_r0, ins->inst_imm);
- if (is_unsigned (ins->next))
- s390_clr (code, ins->sreg1, s390_r0);
- else
- s390_cr (code, ins->sreg1, s390_r0);
+ gboolean branchUn = is_unsigned (ins->next);
+ if ((ins->inst_imm == 0) && (!branchUn)) {
+ s390_ltr (code, ins->sreg1, ins->sreg1);
+ } else {
+ S390_SET (code, s390_r0, ins->inst_imm);
+ if (branchUn)
+ s390_clr (code, ins->sreg1, s390_r0);
+ else
+ s390_cr (code, ins->sreg1, s390_r0);
+ }
}
break;
case OP_BREAK: {
}
break;
case OP_ADDCC: {
- CHECK_SRCDST_COM;
- s390_agr (code, ins->dreg, src2);
+ if (mono_hwcap_s390x_has_mlt) {
+ s390_agrk (code, ins->dreg, ins->sreg1, ins->sreg2);
+ } else {
+ CHECK_SRCDST_COM;
+ s390_agr (code, ins->dreg, src2);
+ }
}
break;
case OP_LADD: {
- CHECK_SRCDST_COM;
- s390_agr (code, ins->dreg, src2);
+ if (mono_hwcap_s390x_has_mlt) {
+ s390_agrk (code, ins->dreg, ins->sreg1, ins->sreg2);
+ } else {
+ CHECK_SRCDST_COM;
+ s390_agr (code, ins->dreg, src2);
+ }
}
break;
case OP_ADC: {
}
break;
case OP_ADD_IMM: {
- if (ins->dreg != ins->sreg1) {
- s390_lgr (code, ins->dreg, ins->sreg1);
- }
- if (s390_is_imm16 (ins->inst_imm)) {
- s390_aghi (code, ins->dreg, ins->inst_imm);
- } else if (s390_is_imm32 (ins->inst_imm)) {
- s390_agfi (code, ins->dreg, ins->inst_imm);
+ if (mono_hwcap_s390x_has_mlt) {
+ if (s390_is_imm16 (ins->inst_imm)) {
+ s390_aghik(code, ins->dreg, ins->sreg1, ins->inst_imm);
+ } else {
+ S390_SET (code, s390_r0, ins->inst_imm);
+ s390_agrk (code, ins->dreg, ins->sreg1, s390_r0);
+ }
} else {
- S390_SET (code, s390_r0, ins->inst_imm);
- s390_agr (code, ins->dreg, s390_r0);
+ if (ins->dreg != ins->sreg1) {
+ s390_lgr (code, ins->dreg, ins->sreg1);
+ }
+ if (s390_is_imm16 (ins->inst_imm)) {
+ s390_aghi (code, ins->dreg, ins->inst_imm);
+ } else if (s390_is_imm32 (ins->inst_imm)) {
+ s390_agfi (code, ins->dreg, ins->inst_imm);
+ } else {
+ S390_SET (code, s390_r0, ins->inst_imm);
+ s390_agr (code, ins->dreg, s390_r0);
+ }
}
}
break;
if (ins->dreg != ins->sreg1) {
s390_lgr (code, ins->dreg, ins->sreg1);
}
- g_assert (s390_is_imm16 (ins->inst_imm));
- s390_aghi (code, ins->dreg, ins->inst_imm);
+ if (s390_is_imm32 (ins->inst_imm)) {
+ s390_agfi (code, ins->dreg, ins->inst_imm);
+ } else {
+ S390_SET (code, s390_r0, ins->inst_imm);
+ s390_agr (code, ins->dreg, s390_r0);
+ }
}
break;
case OP_ADC_IMM: {
}
break;
case OP_SUBCC: {
- CHECK_SRCDST_NCOM;
- s390_sgr (code, ins->dreg, src2);
+ if (mono_hwcap_s390x_has_mlt) {
+ s390_sgrk (code, ins->dreg, ins->sreg1, ins->sreg2);
+ } else {
+ CHECK_SRCDST_NCOM;
+ s390_sgr (code, ins->dreg, src2);
+ }
}
break;
case OP_LSUB: {
- CHECK_SRCDST_NCOM;
- s390_sgr (code, ins->dreg, src2);
+ if (mono_hwcap_s390x_has_mlt) {
+ s390_sgrk (code, ins->dreg, ins->sreg1, ins->sreg2);
+ } else {
+ CHECK_SRCDST_NCOM;
+ s390_sgr (code, ins->dreg, src2);
+ }
}
break;
case OP_SBB: {
}
break;
case OP_LAND: {
- if (ins->sreg1 == ins->dreg) {
- s390_ngr (code, ins->dreg, ins->sreg2);
- }
- else {
- if (ins->sreg2 == ins->dreg) {
- s390_ngr (code, ins->dreg, ins->sreg1);
- }
- else {
- s390_lgr (code, ins->dreg, ins->sreg1);
- s390_ngr (code, ins->dreg, ins->sreg2);
+ if (mono_hwcap_s390x_has_mlt) {
+ s390_ngrk (code, ins->dreg, ins->sreg1, ins->sreg2);
+ } else {
+ if (ins->sreg1 == ins->dreg) {
+ s390_ngr (code, ins->dreg, ins->sreg2);
+ } else {
+ if (ins->sreg2 == ins->dreg) {
+ s390_ngr (code, ins->dreg, ins->sreg1);
+ } else {
+ s390_lgr (code, ins->dreg, ins->sreg1);
+ s390_ngr (code, ins->dreg, ins->sreg2);
+ }
}
}
}
break;
case OP_AND_IMM: {
- if (ins->dreg != ins->sreg1) {
- s390_lgr (code, ins->dreg, ins->sreg1);
- }
S390_SET_MASK (code, s390_r0, ins->inst_imm);
- s390_ngr (code, ins->dreg, s390_r0);
+ if (mono_hwcap_s390x_has_mlt) {
+ s390_ngrk (code, ins->dreg, ins->sreg1, s390_r0);
+ } else {
+ if (ins->dreg != ins->sreg1) {
+ s390_lgr (code, ins->dreg, ins->sreg1);
+ }
+ s390_ngr (code, ins->dreg, s390_r0);
+ }
}
break;
case OP_LDIV: {
}
break;
case OP_LOR: {
- if (ins->sreg1 == ins->dreg) {
- s390_ogr (code, ins->dreg, ins->sreg2);
- }
- else {
- if (ins->sreg2 == ins->dreg) {
- s390_ogr (code, ins->dreg, ins->sreg1);
- }
- else {
- s390_lgr (code, ins->dreg, ins->sreg1);
- s390_ogr (code, ins->dreg, ins->sreg2);
+ if (mono_hwcap_s390x_has_mlt) {
+ s390_ogrk (code, ins->dreg, ins->sreg1, ins->sreg2);
+ } else {
+ if (ins->sreg1 == ins->dreg) {
+ s390_ogr (code, ins->dreg, ins->sreg2);
+ } else {
+ if (ins->sreg2 == ins->dreg) {
+ s390_ogr (code, ins->dreg, ins->sreg1);
+ } else {
+ s390_lgr (code, ins->dreg, ins->sreg1);
+ s390_ogr (code, ins->dreg, ins->sreg2);
+ }
}
}
}
break;
case OP_OR_IMM: {
- if (ins->dreg != ins->sreg1) {
- s390_lgr (code, ins->dreg, ins->sreg1);
- }
S390_SET_MASK(code, s390_r0, ins->inst_imm);
- s390_ogr (code, ins->dreg, s390_r0);
+ if (mono_hwcap_s390x_has_mlt) {
+ s390_ogrk (code, ins->dreg, ins->sreg1, s390_r0);
+ } else {
+ if (ins->dreg != ins->sreg1) {
+ s390_lgr (code, ins->dreg, ins->sreg1);
+ }
+ s390_ogr (code, ins->dreg, s390_r0);
+ }
}
break;
case OP_LXOR: {
- if (ins->sreg1 == ins->dreg) {
- s390_xgr (code, ins->dreg, ins->sreg2);
- }
- else {
- if (ins->sreg2 == ins->dreg) {
- s390_xgr (code, ins->dreg, ins->sreg1);
- }
+ if (mono_hwcap_s390x_has_mlt) {
+ s390_xgrk (code, ins->dreg, ins->sreg1, ins->sreg2);
+ } else {
+ if (ins->sreg1 == ins->dreg) {
+ s390_xgr (code, ins->dreg, ins->sreg2);
+ }
else {
- s390_lgr (code, ins->dreg, ins->sreg1);
- s390_xgr (code, ins->dreg, ins->sreg2);
+ if (ins->sreg2 == ins->dreg) {
+ s390_xgr (code, ins->dreg, ins->sreg1);
+ }
+ else {
+ s390_lgr (code, ins->dreg, ins->sreg1);
+ s390_xgr (code, ins->dreg, ins->sreg2);
+ }
}
}
}
break;
case OP_XOR_IMM: {
- if (ins->dreg != ins->sreg1) {
- s390_lgr (code, ins->dreg, ins->sreg1);
+ S390_SET_MASK(code, s390_r0, ins->inst_imm);
+ if (mono_hwcap_s390x_has_mlt) {
+ s390_xgrk (code, ins->dreg, ins->sreg1, s390_r0);
+ } else {
+ if (ins->dreg != ins->sreg1) {
+ s390_lgr (code, ins->dreg, ins->sreg1);
+ }
+ s390_xgr (code, ins->dreg, s390_r0);
}
- S390_SET_MASK (code, s390_r0, ins->inst_imm);
- s390_xgr (code, ins->dreg, s390_r0);
}
break;
case OP_LSHL: {
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;
}
break;
case OP_IAND: {
- CHECK_SRCDST_NCOM_I;
- s390_ngr (code, ins->dreg, src2);
+ if (mono_hwcap_s390x_has_mlt) {
+ s390_ngrk (code, ins->dreg, ins->sreg1, ins->sreg2);
+ } else {
+ CHECK_SRCDST_NCOM_I;
+ s390_ngr (code, ins->dreg, src2);
+ }
}
break;
case OP_IAND_IMM: {
- if (ins->dreg != ins->sreg1) {
- s390_lgfr (code, ins->dreg, ins->sreg1);
- }
S390_SET_MASK (code, s390_r0, ins->inst_imm);
- s390_ngr (code, ins->dreg, s390_r0);
+ if (mono_hwcap_s390x_has_mlt) {
+ s390_ngrk (code, ins->dreg, ins->sreg1, s390_r0);
+ } else {
+ if (ins->dreg != ins->sreg1) {
+ s390_lgfr (code, ins->dreg, ins->sreg1);
+ }
+ s390_ngr (code, ins->dreg, s390_r0);
+ }
}
break;
case OP_IDIV: {
}
break;
case OP_IOR: {
- CHECK_SRCDST_COM_I;
- s390_ogr (code, ins->dreg, src2);
+ if (mono_hwcap_s390x_has_mlt) {
+ s390_ogrk (code, ins->dreg, ins->sreg1, ins->sreg2);
+ } else {
+ CHECK_SRCDST_COM_I;
+ s390_ogr (code, ins->dreg, src2);
+ }
}
break;
case OP_IOR_IMM: {
- if (ins->dreg != ins->sreg1) {
- s390_lgfr (code, ins->dreg, ins->sreg1);
- }
S390_SET_MASK (code, s390_r0, ins->inst_imm);
- s390_ogr (code, ins->dreg, s390_r0);
+ if (mono_hwcap_s390x_has_mlt) {
+ s390_ogrk (code, ins->dreg, ins->sreg1, s390_r0);
+ } else {
+ if (ins->dreg != ins->sreg1) {
+ s390_lgfr (code, ins->dreg, ins->sreg1);
+ }
+ s390_ogr (code, ins->dreg, s390_r0);
+ }
}
break;
case OP_IXOR: {
- CHECK_SRCDST_COM_I;
- s390_xgr (code, ins->dreg, src2);
+ if (mono_hwcap_s390x_has_mlt) {
+ s390_xgrk (code, ins->dreg, ins->sreg1, ins->sreg2);
+ } else {
+ CHECK_SRCDST_COM_I;
+ s390_xgr (code, ins->dreg, src2);
+ }
}
break;
case OP_IXOR_IMM: {
- if (ins->dreg != ins->sreg1) {
- s390_lgfr (code, ins->dreg, ins->sreg1);
- }
S390_SET_MASK (code, s390_r0, ins->inst_imm);
- s390_xgr (code, ins->dreg, s390_r0);
+ if (mono_hwcap_s390x_has_mlt) {
+ s390_xgrk (code, ins->dreg, ins->sreg1, s390_r0);
+ } else {
+ if (ins->dreg != ins->sreg1) {
+ s390_lgfr (code, ins->dreg, ins->sreg1);
+ }
+ s390_xgr (code, ins->dreg, s390_r0);
+ }
}
break;
case OP_ISHL: {
s390_lghi(code, ins->dreg, 0);
}
break;
+ case OP_ICNEQ: {
+ s390_lghi(code, ins->dreg, 1);
+ s390_jne (code, 4);
+ s390_lghi(code, ins->dreg, 0);
+ }
+ break;
+ case OP_ICGE: {
+ s390_lghi(code, ins->dreg, 1);
+ s390_jhe (code, 4);
+ s390_lghi(code, ins->dreg, 0);
+ }
+ break;
+ case OP_ICLE: {
+ s390_lghi(code, ins->dreg, 1);
+ s390_jle (code, 4);
+ s390_lghi(code, ins->dreg, 0);
+ }
+ break;
+ case OP_ICGE_UN: {
+ s390_lghi(code, ins->dreg, 1);
+ s390_jhe (code, 4);
+ s390_lghi(code, ins->dreg, 0);
+ }
+ break;
+ case OP_ICLE_UN: {
+ s390_lghi(code, ins->dreg, 1);
+ s390_jle (code, 4);
+ s390_lghi(code, ins->dreg, 0);
+ }
+ break;
case OP_COND_EXC_EQ:
case OP_COND_EXC_IEQ:
EMIT_COND_SYSTEM_EXCEPTION (S390_CC_EQ, ins->inst_p1);
EMIT_COND_BRANCH (ins, S390_CC_LE);
break;
+ case OP_S390_CRJ:
+ EMIT_COMP_AND_BRANCH(ins, crj, cr);
+ break;
+
+ case OP_S390_CLRJ:
+ EMIT_COMP_AND_BRANCH(ins, clrj, clr);
+ break;
+
+ case OP_S390_CGRJ:
+ EMIT_COMP_AND_BRANCH(ins, cgrj, cgr);
+ break;
+
+ case OP_S390_CLGRJ:
+ EMIT_COMP_AND_BRANCH(ins, clgrj, clgr);
+ break;
+
+ case OP_S390_CIJ:
+ EMIT_COMP_AND_BRANCH_IMM(ins, crj, cr, ltr, FALSE);
+ break;
+
+ case OP_S390_CLIJ:
+ EMIT_COMP_AND_BRANCH_IMM(ins, clrj, clr, ltr, TRUE);
+ break;
+
+ case OP_S390_CGIJ:
+ EMIT_COMP_AND_BRANCH_IMM(ins, cgrj, cgr, ltgr, FALSE);
+ break;
+
+ case OP_S390_CLGIJ:
+ EMIT_COMP_AND_BRANCH_IMM(ins, clgrj, clgr, ltgr, TRUE);
+ break;
+
/* floating point opcodes */
case OP_R8CONST: {
if (*((double *) ins->inst_p0) == 0) {
s390_lghi (code, ins->dreg, 0);
}
break;
+ case OP_FCNEQ: {
+ s390_cdbr (code, ins->sreg1, ins->sreg2);
+ s390_lghi (code, ins->dreg, 1);
+ s390_jne (code, 4);
+ s390_lghi (code, ins->dreg, 0);
+ }
+ break;
+ case OP_FCGE: {
+ s390_cdbr (code, ins->sreg1, ins->sreg2);
+ s390_lghi (code, ins->dreg, 1);
+ s390_jhe (code, 4);
+ s390_lghi (code, ins->dreg, 0);
+ }
+ break;
+ case OP_FCLE: {
+ s390_cdbr (code, ins->sreg1, ins->sreg2);
+ s390_lghi (code, ins->dreg, 1);
+ s390_jle (code, 4);
+ s390_lghi (code, ins->dreg, 0);
+ }
+ break;
case OP_FBEQ: {
short *o;
s390_jo (code, 0); CODEPTR(code, o);
}
break;
case OP_ATOMIC_ADD_I8: {
- s390_lgr (code, s390_r1, ins->sreg2);
- s390_lg (code, s390_r0, 0, ins->inst_basereg, ins->inst_offset);
- s390_agr (code, s390_r1, s390_r0);
- s390_csg (code, s390_r0, s390_r1, ins->inst_basereg, ins->inst_offset);
- s390_jnz (code, -10);
- s390_lgr (code, ins->dreg, s390_r1);
+ if (mono_hwcap_s390x_has_ia) {
+ s390_laag (code, ins->dreg, ins->sreg2, ins->inst_basereg, ins->inst_offset);
+ s390_agr (code, ins->dreg, ins->sreg2);
+ } else {
+ s390_lgr (code, s390_r1, ins->sreg2);
+ s390_lg (code, s390_r0, 0, ins->inst_basereg, ins->inst_offset);
+ s390_agr (code, s390_r1, s390_r0);
+ s390_csg (code, s390_r0, s390_r1, ins->inst_basereg, ins->inst_offset);
+ s390_jnz (code, -10);
+ s390_lgr (code, ins->dreg, s390_r1);
+ }
}
break;
case OP_ATOMIC_EXCHANGE_I8: {
}
break;
case OP_ATOMIC_ADD_I4: {
- s390_lgfr(code, s390_r1, ins->sreg2);
- s390_lgf (code, s390_r0, 0, ins->inst_basereg, ins->inst_offset);
- s390_agr (code, s390_r1, s390_r0);
- s390_cs (code, s390_r0, s390_r1, ins->inst_basereg, ins->inst_offset);
- s390_jnz (code, -9);
- s390_lgfr(code, ins->dreg, s390_r1);
+ if (mono_hwcap_s390x_has_ia) {
+ s390_laa (code, ins->dreg, ins->sreg2, ins->inst_basereg, ins->inst_offset);
+ s390_ar (code, ins->dreg, ins->sreg2);
+ } else {
+ s390_lgfr(code, s390_r1, ins->sreg2);
+ s390_lgf (code, s390_r0, 0, ins->inst_basereg, ins->inst_offset);
+ s390_agr (code, s390_r1, s390_r0);
+ s390_cs (code, s390_r0, s390_r1, ins->inst_basereg, ins->inst_offset);
+ s390_jnz (code, -9);
+ s390_lgfr(code, ins->dreg, s390_r1);
+ }
}
break;
case OP_ATOMIC_EXCHANGE_I4: {
s390_mem (code);
break;
case OP_GC_SAFE_POINT: {
- guint8 *br;
+ short *br;
g_assert (mono_threads_is_coop_enabled ());
- s390_chi (code, ins->sreg1, 1);
- s390_je (code, 0); CODEPTR(code, br);
- mono_add_patch_info (cfg, code- cfg->native_code, MONO_PATCH_INFO_ABS,
+ s390_ltg (code, s390_r0, 0, ins->sreg1, 0);
+ s390_jz (code, 0); CODEPTR(code, br);
+ mono_add_patch_info (cfg, code - cfg->native_code, MONO_PATCH_INFO_ABS,
mono_threads_state_poll);
S390_CALL_TEMPLATE (code, s390_r14);
PTRSLOT (code, br);
gconstpointer target = NULL;
target = mono_resolve_patch_target (method, domain, code,
- patch_info, run_cctors, error);
+ patch_info, run_cctors, error);
return_if_nok (error);
switch (patch_info->type) {
/*------------------------------------------------------------------*/
/* */
-/* Name - mono_arch_finish_init */
+/* Name - mono_arch_finish_init */
/* */
/* Function - Setup the JIT's Thread Level Specific Data. */
/* */
mono_arch_flush_icache (start, size);
}
- MONO_PROFILER_RAISE (jit_code_buffer, (start, code - start, MONO_PROFILER_CODE_BUFFER_DELEGATE_INVOKE, NULL));
-
if (has_target) {
*info = mono_tramp_info_create ("delegate_invoke_impl_has_target", start, code - start, NULL, NULL);
} else {
}
mono_arch_flush_icache ((guint8*)start, (code - start));
- MONO_PROFILER_RAISE (jit_code_buffer, (start, code - start, MONO_PROFILER_CODE_BUFFER_IMT_TRAMPOLINE, NULL));
if (!fail_tramp)
UnlockedAdd (&mono_stats.imt_trampolines_size, code - start);
#define MONO_ARCH_HAVE_INVALIDATE_METHOD 1
#define MONO_ARCH_HAVE_OP_GENERIC_CLASS_INIT 1
#define MONO_ARCH_HAVE_SETUP_ASYNC_CALLBACK 1
+#define MONO_ARCH_HAVE_INIT_LMF_EXT 1
#define S390_STACK_ALIGNMENT 8
#define S390_FIRST_ARG_REG s390_r2
/*------------------------------------------------------*/
/* use s390_r2-s390_r6 as parm registers */
/* s390_r0, s390_r1, s390_r12, s390_r13 used internally */
-/* s390_r8..s390_r11 are used for global regalloc */
+/* s390_r8..s390_r10 are used for global regalloc */
+/* -- except for s390_r9 which is used as IMT pointer */
+/* s390_r11 is sometimes used as the frame pointer */
/* s390_r15 is the stack pointer */
/*------------------------------------------------------*/
-#define MONO_ARCH_CALLEE_REGS (0xfc)
+#define MONO_ARCH_CALLEE_REGS (0x00fc)
-#define MONO_ARCH_CALLEE_SAVED_REGS 0xff80
+#define MONO_ARCH_CALLEE_SAVED_REGS 0xfd00
/*----------------------------------------*/
/* use s390_f1/s390_f3-s390_f15 as temps */
vtable_slot = mini_resolve_imt_method (vt, vtable_slot, imt_method, &impl_method, &addr, &need_rgctx_tramp, &variant_iface, error);
return_val_if_nok (error, NULL);
+ /* We must handle magic interfaces on rank 1 arrays of ref types as if they were variant */
+ if (!variant_iface && vt->klass->rank == 1 && !vt->klass->element_class->valuetype && imt_method->klass->is_array_special_interface)
+ variant_iface = imt_method;
+
/* This is the vcall slot which gets called through the IMT trampoline */
vtable_slot_to_patch = vtable_slot;
mono_magic_trampoline (mgreg_t *regs, guint8 *code, gpointer arg, guint8* tramp)
{
gpointer res;
+ MonoError error;
- MONO_ENTER_GC_UNSAFE_UNBALANCED;
+ MONO_REQ_GC_UNSAFE_MODE;
- MonoError error;
+ g_assert (mono_thread_is_gc_unsafe_mode ());
trampoline_calls ++;
res = common_call_trampoline (regs, code, (MonoMethod *)arg, NULL, NULL, &error);
- mono_error_set_pending_exception (&error);
-
- mono_interruption_checkpoint_from_trampoline ();
-
- MONO_EXIT_GC_UNSAFE_UNBALANCED;
+ if (!is_ok (&error)) {
+ mono_error_set_pending_exception (&error);
+ return NULL;
+ }
return res;
}
printf ("LAST: %s\n", mono_method_full_name (cfg->method, TRUE));
if (count > atoi (g_getenv ("COUNT3")))
slot = 0xffffff;
- else {
+ else
mono_print_ins (inst);
- }
}
#endif
}
}
+#if 0
{
static int count = 0;
count ++;
- /*
if (count == atoi (g_getenv ("COUNT")))
printf ("LAST: %s\n", mono_method_full_name (cfg->method, TRUE));
if (count > atoi (g_getenv ("COUNT")))
slot = 0xffffff;
- else {
+ else
mono_print_ins (inst);
- }
- */
}
+#endif
if (inst->flags & MONO_INST_LMF) {
/*
/* 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;
if (((code [-13] == 0x49) && (code [-12] == 0xbb)) || (code [-5] == 0xe8)) {
if (code [-5] != 0xe8) {
if (can_write) {
+ g_assert ((guint64)(orig_code - 11) % 8 == 0);
InterlockedExchangePointer ((gpointer*)(orig_code - 11), addr);
VALGRIND_DISCARD_TRANSLATIONS (orig_code - 11, sizeof (gpointer));
}
g_free (rgctx_null_jumps);
/* move the rgctx pointer to the VTABLE register */
+#if MONO_ARCH_VTABLE_REG != s390_r2
s390_lgr (code, MONO_ARCH_VTABLE_REG, s390_r2);
+#endif
tramp = mono_arch_create_specific_trampoline (GUINT_TO_POINTER (slot),
MONO_TRAMPOLINE_RGCTX_LAZY_FETCH, mono_get_root_domain (), NULL);
/*------------------------------------------------------------------*/
gpointer
-mono_arch_get_static_rgctx_trampoline (gpointer arg,
- gpointer addr)
+mono_arch_get_static_rgctx_trampoline (gpointer arg, gpointer addr)
{
guint8 *code, *start;
gint32 displace;
}
/*========================= End of Function ========================*/
+
+/*------------------------------------------------------------------*/
+/* */
+/* Name - mono_arch_get_enter_icall_trampoline. */
+/* */
+/* Function - */
+/* */
+/*------------------------------------------------------------------*/
+
+gpointer
+mono_arch_get_enter_icall_trampoline (MonoTrampInfo **info)
+{
+ g_assert_not_reached ();
+ return NULL;
+}
+
+/*========================= End of Function ========================*/
return 0;
}
+
public static unsafe int test_0_ldobj ()
{
byte *ptr = stackalloc byte [20];
for (int i = 0; i < 20; ++i)
ptr [i] = (byte)i;
+ if (BitConverter.IsLittleEndian) {
- if (Intrinsics.UnalignedLdobj<short> (ptr + 0) != 0x0100)
- return 1;
+ if (Intrinsics.UnalignedLdobj<short> (ptr + 0) != 0x0100)
+ return 1;
- if (Intrinsics.UnalignedLdobj<short> (ptr + 1) != 0x0201)
- return 2;
+ if (Intrinsics.UnalignedLdobj<short> (ptr + 1) != 0x0201)
+ return 2;
- if (Intrinsics.UnalignedLdobj<short> (ptr + 2) != 0x0302)
- return 3;
+ if (Intrinsics.UnalignedLdobj<short> (ptr + 2) != 0x0302)
+ return 3;
- if (Intrinsics.UnalignedLdobj<int> (ptr + 1) != 0x04030201)
- return 4;
+ if (Intrinsics.UnalignedLdobj<int> (ptr + 1) != 0x04030201)
+ return 4;
- if (Intrinsics.UnalignedLdobj<int> (ptr + 2) != 0x05040302)
- return 5;
+ if (Intrinsics.UnalignedLdobj<int> (ptr + 2) != 0x05040302)
+ return 5;
+
+ if (Intrinsics.UnalignedLdobj<long> (ptr + 1) != 0x0807060504030201)
+ return 6;
+
+ if (Intrinsics.UnalignedLdobj<long> (ptr + 6) != 0xD0C0B0A09080706)
+ return 7;
+ } else {
+
+ if (Intrinsics.UnalignedLdobj<short> (ptr + 0) != 0x0001)
+ return 1;
- if (Intrinsics.UnalignedLdobj<long> (ptr + 1) != 0x0807060504030201)
- return 6;
+ if (Intrinsics.UnalignedLdobj<short> (ptr + 1) != 0x0102)
+ return 2;
- if (Intrinsics.UnalignedLdobj<long> (ptr + 6) != 0xD0C0B0A09080706)
- return 7;
+ if (Intrinsics.UnalignedLdobj<short> (ptr + 2) != 0x0203)
+ return 3;
+
+ if (Intrinsics.UnalignedLdobj<int> (ptr + 1) != 0x01020304)
+ return 4;
+
+ if (Intrinsics.UnalignedLdobj<int> (ptr + 2) != 0x02030405)
+ return 5;
+
+ if (Intrinsics.UnalignedLdobj<long> (ptr + 1) != 0x0102030405060708)
+ return 6;
+
+ if (Intrinsics.UnalignedLdobj<long> (ptr + 6) != 0x60708090A0B0C0D)
+ return 7;
+ }
return 0;
}
ptr [i] = (byte)i;
- if (Intrinsics.UnalignedLdInd2 (ptr + 0) != 0x0100)
- return 1;
+ if (BitConverter.IsLittleEndian) {
- if (Intrinsics.UnalignedLdInd2 (ptr + 1) != 0x0201)
- return 2;
+ if (Intrinsics.UnalignedLdInd2 (ptr + 0) != 0x0100)
+ return 1;
- if (Intrinsics.UnalignedLdInd2 (ptr + 2) != 0x0302)
- return 3;
+ if (Intrinsics.UnalignedLdInd2 (ptr + 1) != 0x0201)
+ return 2;
- if (Intrinsics.UnalignedLdInd4 (ptr + 1) != 0x04030201)
- return 4;
+ if (Intrinsics.UnalignedLdInd2 (ptr + 2) != 0x0302)
+ return 3;
- if (Intrinsics.UnalignedLdInd4 (ptr + 2) != 0x05040302)
- return 5;
+ if (Intrinsics.UnalignedLdInd4 (ptr + 1) != 0x04030201)
+ return 4;
+
+ if (Intrinsics.UnalignedLdInd4 (ptr + 2) != 0x05040302)
+ return 5;
- if (Intrinsics.UnalignedLdInd8 (ptr + 1) != 0x0807060504030201)
- return 6;
+ if (Intrinsics.UnalignedLdInd8 (ptr + 1) != 0x0807060504030201)
+ return 6;
+
+ if (Intrinsics.UnalignedLdInd8 (ptr + 6) != 0xD0C0B0A09080706)
+ return 7;
+ } else {
- if (Intrinsics.UnalignedLdInd8 (ptr + 6) != 0xD0C0B0A09080706)
- return 7;
+ if (Intrinsics.UnalignedLdInd2 (ptr + 0) != 0x0001)
+ return 1;
+
+ if (Intrinsics.UnalignedLdInd2 (ptr + 1) != 0x0102)
+ return 2;
+
+ if (Intrinsics.UnalignedLdInd2 (ptr + 2) != 0x0203)
+ return 3;
+
+ if (Intrinsics.UnalignedLdInd4 (ptr + 1) != 0x01020304)
+ return 4;
+
+ if (Intrinsics.UnalignedLdInd4 (ptr + 2) != 0x02030405)
+ return 5;
+
+ if (Intrinsics.UnalignedLdInd8 (ptr + 1) != 0x0102030405060708)
+ return 6;
+
+ if (Intrinsics.UnalignedLdInd8 (ptr + 6) != 0x60708090A0B0C0D)
+ return 7;
+ }
return 0;
}
{
byte *ptr = stackalloc byte [20];
- Intrinsics.UnalignedStobj <short> (ptr + 0, 0x6688);
- if (ptr [0] != 0x88 || ptr [1] != 0x66)
- return 1;
+ if (BitConverter.IsLittleEndian) {
+ Intrinsics.UnalignedStobj <short> (ptr + 0, 0x6688);
+ if (ptr [0] != 0x88 || ptr [1] != 0x66)
+ return 1;
- Intrinsics.UnalignedStobj <short> (ptr + 1, 0x6589);
- if (ptr [1] != 0x89 || ptr [2] != 0x65)
- return 2;
+ Intrinsics.UnalignedStobj <short> (ptr + 1, 0x6589);
+ if (ptr [1] != 0x89 || ptr [2] != 0x65)
+ return 2;
- Intrinsics.UnalignedStobj <int> (ptr + 1, 0x60708090);
- if (ptr [1] != 0x90 || ptr [2] != 0x80 || ptr [3] != 0x70 || ptr [4] != 0x60)
- return 3;
+ Intrinsics.UnalignedStobj <int> (ptr + 1, 0x60708090);
+ if (ptr [1] != 0x90 || ptr [2] != 0x80 || ptr [3] != 0x70 || ptr [4] != 0x60)
+ return 3;
- Intrinsics.UnalignedStobj <long> (ptr + 1, 0x405060708090);
- if (ptr [1] != 0x90 || ptr [2] != 0x80 || ptr [3] != 0x70 || ptr [4] != 0x60 || ptr [5] != 0x50 || ptr [6] != 0x40)
- return 4;
+ Intrinsics.UnalignedStobj <long> (ptr + 1, 0x405060708090);
+ if (ptr [1] != 0x90 || ptr [2] != 0x80 || ptr [3] != 0x70 ||
+ ptr [4] != 0x60 || ptr [5] != 0x50 || ptr [6] != 0x40)
+ return 4;
+ } else {
+ Intrinsics.UnalignedStobj <short> (ptr + 0, 0x6688);
+ if (ptr [0] != 0x66 || ptr [1] != 0x88)
+ return 1;
+
+ Intrinsics.UnalignedStobj <short> (ptr + 1, 0x6589);
+ if (ptr [1] != 0x65 || ptr [2] != 0x89)
+ return 2;
+
+ Intrinsics.UnalignedStobj <int> (ptr + 1, 0x60708090);
+ if (ptr [1] != 0x60 || ptr [2] != 0x70 || ptr [3] != 0x80 || ptr [4] != 0x90)
+ return 3;
+
+ Intrinsics.UnalignedStobj <long> (ptr + 1, 0x2030405060708090);
+ if (ptr [1] != 0x20 || ptr [2] != 0x30 || ptr [3] != 0x40 ||
+ ptr [4] != 0x50 || ptr [5] != 0x60 || ptr [6] != 0x70)
+ return 4;
+ }
return 0;
}
mono_profiler_printf ("\t %s", event_list [i].event_name);
mono_profiler_printf ("\t[no]alloc enable/disable recording allocation info");
- mono_profiler_printf ("\t[no]legacy enable/disable pre mono 5.4 default profiler events");
+ mono_profiler_printf ("\t[no]legacy enable/disable pre Mono 5.6 default profiler events");
mono_profiler_printf ("\tsample[-real][=FREQ] enable/disable statistical sampling of threads");
mono_profiler_printf ("\t FREQ in Hz, 100 by default");
mono_profiler_printf ("\t the -real variant uses wall clock time instead of process time");
#include <mono/utils/memcheck.h>
#include <mono/utils/mono-mmap-internals.h>
+#include <mono/utils/unlocked.h>
#undef pthread_create
#undef pthread_join
major_collector.finish_nursery_collection ();
TV_GETTIME (last_minor_collection_end_tv);
- InterlockedAdd64 (&gc_stats.minor_gc_time, TV_ELAPSED (last_minor_collection_start_tv, last_minor_collection_end_tv));
+ UnlockedAdd64 (&gc_stats.minor_gc_time, TV_ELAPSED (last_minor_collection_start_tv, last_minor_collection_end_tv));
sgen_debug_dump_heap ("minor", InterlockedRead (&gc_stats.minor_gc_count) - 1, NULL);
sgen_gray_object_queue_dispose (&gc_thread_gray_queue);
TV_GETTIME (time_end);
- InterlockedAdd64 (&gc_stats.major_gc_time, TV_ELAPSED (time_start, time_end));
+ UnlockedAdd64 (&gc_stats.major_gc_time, TV_ELAPSED (time_start, time_end));
/* FIXME: also report this to the user, preferably in gc-end. */
if (major_collector.get_and_reset_num_major_objects_marked)
num_objects_marked = major_collector.get_and_reset_num_major_objects_marked ();
TV_GETTIME (time_end);
- InterlockedAdd64 (&gc_stats.major_gc_time, TV_ELAPSED (time_start, time_end));
+ UnlockedAdd64 (&gc_stats.major_gc_time, TV_ELAPSED (time_start, time_end));
current_collection_generation = -1;
}
sgen_los_update_cardtable_mod_union ();
TV_GETTIME (total_end);
- InterlockedAdd64 (&gc_stats.major_gc_time, TV_ELAPSED (total_start, total_end));
+ UnlockedAdd64 (&gc_stats.major_gc_time, TV_ELAPSED (total_start, total_end));
}
static void
sgen_workers_stop_all_workers (GENERATION_OLD);
SGEN_TV_GETTIME (time_major_conc_collection_end);
- InterlockedAdd64 (&gc_stats.major_gc_time_concurrent, SGEN_TV_ELAPSED (time_major_conc_collection_start, time_major_conc_collection_end));
+ UnlockedAdd64 (&gc_stats.major_gc_time_concurrent, SGEN_TV_ELAPSED (time_major_conc_collection_start, time_major_conc_collection_end));
major_collector.update_cardtable_mod_union ();
sgen_los_update_cardtable_mod_union ();
sgen_gray_object_queue_dispose (&gc_thread_gray_queue);
TV_GETTIME (total_end);
- InterlockedAdd64 (&gc_stats.major_gc_time, TV_ELAPSED (total_start, total_end));
+ UnlockedAdd64 (&gc_stats.major_gc_time, TV_ELAPSED (total_start, total_end));
current_collection_generation = -1;
}
typedef gpointer (*SgenGCHandleIterateCallback) (gpointer hidden, GCHandleType handle_type, int max_generation, gpointer user);
+guint32 sgen_gchandle_new (GCObject *obj, gboolean pinned);
+guint32 sgen_gchandle_new_weakref (GCObject *obj, gboolean track_resurrection);
void sgen_gchandle_iterate (GCHandleType handle_type, int max_generation, SgenGCHandleIterateCallback callback, gpointer user);
void sgen_gchandle_set_target (guint32 gchandle, GCObject *obj);
void sgen_mark_normal_gc_handles (void *addr, SgenUserMarkFunc mark_func, void *gc_data);
gpointer sgen_gchandle_get_metadata (guint32 gchandle);
+GCObject *sgen_gchandle_get_target (guint32 gchandle);
+void sgen_gchandle_free (guint32 gchandle);
/* Other globals */
} SGEN_ARRAY_LIST_END_FOREACH_SLOT;
}
-/**
- * mono_gchandle_new:
- * \param obj managed object to get a handle for
- * \param pinned whether the object should be pinned
- * This returns a handle that wraps the object, this is used to keep a
- * reference to a managed object from the unmanaged world and preventing the
- * object from being disposed.
- *
- * If \p pinned is false the address of the object can not be obtained, if it is
- * true the address of the object can be obtained. This will also pin the
- * object so it will not be possible by a moving garbage collector to move the
- * object.
- *
- * \returns a handle that can be used to access the object from unmanaged code.
- */
guint32
-mono_gchandle_new (GCObject *obj, gboolean pinned)
+sgen_gchandle_new (GCObject *obj, gboolean pinned)
{
return alloc_handle (gc_handles_for_type (pinned ? HANDLE_PINNED : HANDLE_NORMAL), obj, FALSE);
}
-/**
- * mono_gchandle_new_weakref:
- * \param obj managed object to get a handle for
- * \param track_resurrection Determines how long to track the object, if this is set to TRUE, the object is tracked after finalization, if FALSE, the object is only tracked up until the point of finalization.
- *
- * This returns a weak handle that wraps the object, this is used to
- * keep a reference to a managed object from the unmanaged world.
- * Unlike the \c mono_gchandle_new the object can be reclaimed by the
- * garbage collector. In this case the value of the GCHandle will be
- * set to zero.
- *
- * If \p track_resurrection is TRUE the object will be tracked through
- * finalization and if the object is resurrected during the execution
- * of the finalizer, then the returned weakref will continue to hold
- * a reference to the object. If \p track_resurrection is FALSE, then
- * the weak reference's target will become NULL as soon as the object
- * is passed on to the finalizer.
- *
- * \returns a handle that can be used to access the object from
- * unmanaged code.
- */
guint32
-mono_gchandle_new_weakref (GCObject *obj, gboolean track_resurrection)
+sgen_gchandle_new_weakref (GCObject *obj, gboolean track_resurrection)
{
return alloc_handle (gc_handles_for_type (track_resurrection ? HANDLE_WEAK_TRACK : HANDLE_WEAK), obj, track_resurrection);
}
return obj;
}
-/**
- * mono_gchandle_get_target:
- * \param gchandle a GCHandle's handle.
- *
- * The handle was previously created by calling \c mono_gchandle_new or
- * \c mono_gchandle_new_weakref.
- *
- * \returns a pointer to the \c MonoObject* represented by the handle or
- * NULL for a collected object if using a weakref handle.
- */
GCObject*
-mono_gchandle_get_target (guint32 gchandle)
+sgen_gchandle_get_target (guint32 gchandle)
{
guint index = MONO_GC_HANDLE_SLOT (gchandle);
GCHandleType type = MONO_GC_HANDLE_TYPE (gchandle);
return mono_gchandle_slot_metadata (slot, MONO_GC_HANDLE_TYPE_IS_WEAK (type));
}
-/**
- * mono_gchandle_free:
- * \param gchandle a GCHandle's handle.
- *
- * Frees the \p gchandle handle. If there are no outstanding
- * references, the garbage collector can reclaim the memory of the
- * object wrapped.
- */
void
-mono_gchandle_free (guint32 gchandle)
+sgen_gchandle_free (guint32 gchandle)
{
guint32 index = MONO_GC_HANDLE_SLOT (gchandle);
GCHandleType type = MONO_GC_HANDLE_TYPE (gchandle);
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 ();
+ }
+ }
+}
#ifndef WIN32
-typedef void (*NativeToManagedExceptionRethrowFunc) ();
+typedef void (*NativeToManagedExceptionRethrowFunc) (void);
void *mono_test_native_to_managed_exception_rethrow_thread (void *arg)
{
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;
}
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_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_fpe)
MONO_HWCAP_VAR(s390x_has_vec)
+MONO_HWCAP_VAR(s390x_has_mlt)
+MONO_HWCAP_VAR(s390x_has_ia)
+MONO_HWCAP_VAR(s390x_has_gie)
+MONO_HWCAP_VAR(s390x_has_mie2)
+MONO_HWCAP_VAR(s390x_has_gs)
#elif defined (TARGET_SPARC) || defined (TARGET_SPARC64)
{
return state_name (state);
}
+
+gboolean
+mono_thread_is_gc_unsafe_mode (void)
+{
+ MonoThreadInfo *cur = mono_thread_info_current ();
+
+ if (!cur)
+ return FALSE;
+
+ switch (mono_thread_info_current_state (cur)) {
+ case STATE_RUNNING:
+ case STATE_ASYNC_SUSPEND_REQUESTED:
+ case STATE_SELF_SUSPEND_REQUESTED:
+ return TRUE;
+ default:
+ return FALSE;
+ }
+}
int mono_thread_info_suspend_count (THREAD_INFO_TYPE *info);
int mono_thread_info_current_state (THREAD_INFO_TYPE *info);
const char* mono_thread_state_name (int state);
+gboolean mono_thread_is_gc_unsafe_mode (void);
gboolean mono_thread_info_in_critical_location (THREAD_INFO_TYPE *info);
gboolean mono_thread_info_begin_suspend (THREAD_INFO_TYPE *info);
g_strfreev (encodings);
if(g_utf8_validate (in, -1, NULL)) {
- gunichar2 *unires=g_utf8_to_utf16 (in, -1, NULL, (glong *)bytes, NULL);
- *bytes *= 2;
+ glong items_written;
+ gunichar2 *unires=g_utf8_to_utf16 (in, -1, NULL, &items_written, NULL);
+ items_written *= 2;
+ *bytes = items_written;
return(unires);
}
return ++*val;
}
+MONO_UNLOCKED_ATTRS
+gint64
+UnlockedIncrement64 (gint64 *val)
+{
+ return ++*val;
+}
+
+MONO_UNLOCKED_ATTRS
+gint64
+UnlockedDecrement64 (gint64 *val)
+{
+ return --*val;
+}
+
+MONO_UNLOCKED_ATTRS
+gint32
+UnlockedDecrement (gint32 *val)
+{
+ return --*val;
+}
+
MONO_UNLOCKED_ATTRS
gint32
UnlockedAdd (gint32 *dest, gint32 add)
*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)
rm -rf share/strings
rm -rf share/pixmaps
rm -rf share/intltool
+rm -rf share/llvm
rm -rf var/cache/fontconfig
+rm -rf include/llvm
# delete most of the *.a files
rm -rf lib/cairo/libcairo-trace.a
rm -rf lib/gtk-2.0/2.10.0/engines/libsvg.a
rm -rf lib/libCompilerDriver.a
rm -rf lib/libEnhancedDisassembly.a
-rm -rf lib/libLLVMAnalysis.a
-rm -rf lib/libLLVMArchive.a
-rm -rf lib/libLLVMAsmParser.a
-rm -rf lib/libLLVMAsmPrinter.a
-rm -rf lib/libLLVMBitReader.a
-rm -rf lib/libLLVMBitWriter.a
-rm -rf lib/libLLVMCodeGen.a
-rm -rf lib/libLLVMCore.a
-rm -rf lib/libLLVMExecutionEngine.a
-rm -rf lib/libLLVMInstCombine.a
-rm -rf lib/libLLVMInstrumentation.a
-rm -rf lib/libLLVMInterpreter.a
-rm -rf lib/libLLVMJIT.a
-rm -rf lib/libLLVMLinker.a
-rm -rf lib/libLLVMMC.a
-rm -rf lib/libLLVMMCDisassembler.a
-rm -rf lib/libLLVMMCJIT.a
-rm -rf lib/libLLVMMCParser.a
-rm -rf lib/libLLVMObject.a
-rm -rf lib/libLLVMScalarOpts.a
-rm -rf lib/libLLVMSelectionDAG.a
-rm -rf lib/libLLVMSupport.a
-rm -rf lib/libLLVMTarget.a
-rm -rf lib/libLLVMTransformUtils.a
-rm -rf lib/libLLVMX86AsmParser.a
-rm -rf lib/libLLVMX86AsmPrinter.a
-rm -rf lib/libLLVMX86CodeGen.a
-rm -rf lib/libLLVMX86Disassembler.a
-rm -rf lib/libLLVMX86Info.a
-rm -rf lib/libLLVMipa.a
-rm -rf lib/libLLVMipo.a
-rm -rf lib/libLTO.a
+rm -rf lib/libLLVM*.a
+rm -rf lib/libLTO.*
# rm -rf lib/libMonoPosixHelper.a
# rm -rf lib/libMonoSupportW.a
rm -rf lib/libUnitTestMain.a
# we don't need any of the llvm executables except llc and opt
rm -rf bin/bugpoint
-rm -rf bin/lli
+rm -rf bin/lli*
rm -rf bin/llvm-*
rm -rf bin/macho-dump
rm -rf bin/ccache
+rm -rf bin/llc32
+rm -rf bin/opt32
#
# 14:39 <baulig> the install script needs to be modified not to
+++ /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,16 @@ this file.
+ <RootNamespace Condition="'$(RootNamespace)'==''">RootNamespace</RootNamespace>
+ <Actual32Bit Condition="'$(TargetFrameworkVersion)'=='v2.0' or '$(TargetFrameworkVersion)'=='v3.0' or '$(TargetFrameworkVersion)'=='v3.5' or '$(TargetFrameworkVersion)'=='v4.0'">false</Actual32Bit>
+ <Actual32Bit Condition="!('$(TargetFrameworkVersion)'=='v2.0' or '$(TargetFrameworkVersion)'=='v3.0' or '$(TargetFrameworkVersion)'=='v3.5' or '$(TargetFrameworkVersion)'=='v4.0')">$(Prefer32Bit)</Actual32Bit>
++ <!--
++ `/debug+` is produced based on `$(DebugSymols)`, which gets a default value of 'true' in
++ Microsoft.Common.CurrentVersion.targets, with a condition:
++ Condition=" '$(ConfigurationName)' == 'Debug' and '$(DebugSymbols)' == '' and '$(DebugType)'=='' "
++ But that file is imported later, so we cannot depend on the default value of `$(DebugSymbols)` or `$(ConfigurationName)`.
++ -->
++ <_ConfigurationNameTmp>$(ConfigurationName)</_ConfigurationNameTmp>
++ <_ConfigurationNameTmp Condition="'$(ConfigurationName)' == ''">$(Configuration)</_ConfigurationNameTmp>
++
++ <DebugType Condition="'$(OS)' != 'Windows_NT' And ('$(DebugSymbols)'=='True' or ('$(DebugSymbols)'=='' And '$(_ConfigurationNameTmp)'=='Debug'))">portable</DebugType>
+ </PropertyGroup>
+
+ <!--
-# ------------------------------------------------------------ #
-# mono/eglib
-# ------------------------------------------------------------ #
+# --------------------------------------------------------------------------- #
+# mono/eglib #
+# --------------------------------------------------------------------------- #
+
+# ghashtable.c #
fun:monoeg_g_hash_table_iter_next
+fun:monoeg_g_hash_table_lookup_extended
+
+# sort.frag.h #
+
+fun:init_sort_info
+fun:insert_list
+fun:merge_lists
+
+# --------------------------------------------------------------------------- #
+# mono/metadata #
+# --------------------------------------------------------------------------- #
+
+# class-accessors.c #
+
+fun:mono_class_get_first_method_idx
+fun:mono_class_get_flags
+fun:mono_class_get_generic_class
+fun:mono_class_get_method_count
+fun:mono_class_get_field_count
+fun:mono_class_set_first_method_idx
+fun:mono_class_set_method_count
+
+# class-inlines.h #
+
+fun:mono_class_is_ginst
+fun:mono_class_is_gtd
-# ------------------------------------------------------------ #
-# mono/metadata
-# ------------------------------------------------------------ #
+# class-internals.h #
+
+fun:mono_class_has_parent
+fun:mono_class_has_parent_fast
# class.c #
+fun:can_access_type
+fun:inflate_generic_context
fun:inflate_generic_type
fun:init_sizes_with_info
fun:make_generic_param_class
+fun:mono_bounded_array_class_get
fun:mono_class_create_from_typedef
fun:mono_class_from_generic_parameter_internal
-fun:mono_class_get_field_count
+fun:mono_class_from_mono_type
+fun:mono_class_get_cctor
+fun:mono_class_get_inflated_method
fun:mono_class_get_method_from_name_flags
fun:mono_class_get_methods
+fun:mono_class_get_vtable_entry
fun:mono_class_has_failure
fun:mono_class_has_finalizer
fun:mono_class_inflate_generic_method_full_checked
-fun:mono_class_inflate_generic_type_no_copy
-fun:mono_class_inflate_generic_type_with_mempool
fun:mono_class_init
+fun:mono_class_instance_size
+fun:mono_class_is_assignable_from
fun:mono_class_layout_fields
fun:mono_class_setup_basic_field_info
fun:mono_class_setup_fields
+fun:mono_class_setup_interfaces
fun:mono_class_setup_methods
+fun:mono_class_setup_supertypes
fun:mono_class_setup_vtable_full
fun:mono_class_setup_vtable_general
+fun:mono_field_resolve_type
fun:mono_generic_class_get_class
fun:mono_method_get_context_general
+fun:mono_method_get_method_definition
+fun:mono_ptr_class_get
fun:mono_type_get_basic_type_from_generic
fun:mono_type_get_underlying_type
-
-# class-accessors.c #
-
-fun:mono_class_get_flags
-fun:mono_class_get_method_count
-fun:mono_class_set_method_count
-
-# class-inlines.h #
-
-fun:mono_class_is_ginst
-fun:mono_class_is_gtd
+fun:mono_type_has_exceptions
# domain.c #
fun:finalizer_thread
fun:mono_domain_finalize
fun:mono_gc_cleanup
-
-# handle.h #
-
-fun:mono_stack_mark_pop
+fun:object_register_finalizer
# handle.c #
fun:mono_handle_new
fun:mono_handle_stack_scan
+# handle.h #
+
+fun:mono_stack_mark_init
+fun:mono_stack_mark_pop
+
# icall.c #
+fun:vell_icall_get_method_attributes
+fun:ves_icall_InternalInvoke
+fun:ves_icall_RuntimeTypeHandle_IsArray
+fun:ves_icall_RuntimeType_GetConstructors_native
fun:ves_icall_System_Array_FastCopy
fun:ves_icall_System_Reflection_MonoMethodInfo_get_parameter_info
-fun:ves_icall_RuntimeType_GetConstructors_native
# image.c #
fun:jit_info_table_add
fun:jit_info_table_chunk_index
+fun:jit_info_table_copy_and_split_chunk
fun:jit_info_table_find
fun:jit_info_table_index
-fun:mono_jit_compile_method_with_opt
+fun:jit_info_table_split_chunk
fun:mono_jit_info_init
-fun:mono_jit_info_table_find_internal
# loader.c #
fun:cache_memberref_sig
-fun:mon_new
+fun:inflate_generic_signature_checked
fun:mono_get_method_from_token
fun:mono_method_get_signature_checked
fun:mono_method_signature_checked
# marshal.c #
+fun:mono_icall_start
fun:mono_marshal_get_native_wrapper
fun:mono_marshal_isinst_with_cache
# metadata.c #
-fun:img_set_cache_get
fun:_mono_metadata_generic_class_equal
+fun:collect_method_images
+fun:do_mono_metadata_parse_type
+fun:img_set_cache_get
+fun:mono_metadata_decode_row
+fun:mono_metadata_get_canonical_generic_inst
fun:mono_metadata_lookup_generic_class
+fun:mono_metadata_parse_type_internal
+fun:mono_type_get_class
fun:mono_type_get_type
fun:mono_type_is_struct
# monitor.c #
+fun:mon_new
fun:mono_monitor_ensure_owned
+fun:mono_monitor_enter_v4_fast
fun:mono_monitor_exit_inflated
+fun:mono_monitor_inflate
fun:mono_monitor_try_enter_inflated
fun:mono_monitor_try_enter_internal
fun:mono_object_hash
fun:ves_icall_System_Threading_Monitor_Monitor_pulse_all
fun:ves_icall_System_Threading_Monitor_Monitor_test_synchronised
+fun:ves_icall_System_Threading_Monitor_Monitor_try_enter_with_atomic_var
fun:ves_icall_System_Threading_Monitor_Monitor_wait
# mono-conc-hash.c #
+fun:expand_table
fun:mono_conc_g_hash_table_lookup_extended
fun:set_key
# mono-hash.c #
fun:mono_g_hash_table_find_slot
-fun:mono_g_hash_table_max_chain_length
# object.c #
fun:mono_class_compute_gc_descriptor
fun:mono_class_create_runtime_vtable
fun:mono_class_vtable_full
-fun:mono_delegate_ctor_with_method
+fun:mono_object_handle_get_virtual_method
fun:mono_object_handle_isinst
+fun:mono_object_isinst_checked
+fun:mono_object_new_alloc_specific_checked
+fun:mono_object_new_specific_checked
fun:mono_runtime_class_init_full
+fun:mono_runtime_invoke_array_checked
+fun:mono_runtime_try_invoke_array
+fun:mono_string_new_size_checked
+
+# reflection-cache.h #
+
+fun:cache_object_handle
# reflection.c #
fun:method_object_construct
fun:reflected_equal
-# reflection-cache.h #
-
-fun:cache_object_handle
-
# runtime.c #
fun:mono_runtime_is_shutting_down
fun:mono_runtime_try_shutdown
+# sgen-client-mono.h #
+
+fun:SGEN_LOAD_VTABLE_UNCHECKED
+
# sgen-mono.c #
+fun:mono_gchandle_free
fun:mono_gc_alloc_string
fun:mono_gc_alloc_vector
fun:mono_gc_thread_in_critical_region
fun:sgen_client_gchandle_created
fun:sgen_client_gchandle_destroyed
-# threadpool.c #
-
-fun:worker_callback
-
# threadpool-worker-default.c #
fun:heuristic_adjust
fun:heuristic_notify_work_completed
fun:heuristic_should_adjust
+fun:hill_climbing_change_thread_count
+fun:hill_climbing_force_change
fun:hill_climbing_update
fun:monitor_should_keep_running
fun:monitor_thread
+fun:monitor_sufficient_delay_since_last_dequeue
+
+# threadpool.c #
+
+fun:try_invoke_perform_wait_callback
+fun:worker_callback
# threads.c #
fun:create_thread
fun:mono_thread_clr_state
fun:mono_thread_detach_internal
+fun:mono_thread_set_name_internal
fun:mono_threads_add_joinable_thread
fun:mono_threads_join_threads
fun:remove_and_abort_threads
+fun:request_thread_abort
# w32handle.c #
-fun:mono_w32handle_init_handle
+fun:mono_w32handle_lookup
fun:mono_w32handle_lookup_data
+fun:mono_w32handle_new_internal
+fun:mono_w32handle_ref_core
fun:mono_w32handle_unref_core
-# ------------------------------------------------------------ #
-# mono/mini
-# ------------------------------------------------------------ #
+# --------------------------------------------------------------------------- #
+# mono/mini #
+# --------------------------------------------------------------------------- #
# alias-analysis.c #
fun:recompute_aliased_variables
-# method-to-ir.c #
+# aot-runtime.c #
-fun:mono_method_to_ir
+fun:mono_aot_get_cached_class_info
+fun:mono_aot_get_method_from_vt_slot
-# mini.c #
+# decompose.c #
-fun:mini_method_compile
-fun:mono_allocate_stack_slots
-fun:mono_jit_compile_method_inner
-fun:mono_save_seq_point_info
-fun:mono_time_track_end
-fun:mono_type_to_load_membase
+fun:mono_decompose_vtype_opts
+
+# linear-scan.c #
+
+fun:mono_linear_scan
+
+# liveness.c #
+
+fun:mono_analyze_liveness
+fun:mono_liveness_handle_exception_clauses
+
+# method-to-ir.c #
+
+fun:check_call_signature
+fun:emit_init_rvar
+fun:inline_method
+fun:mono_method_check_inlining
+fun:mono_method_to_ir
+fun:mono_spill_global_vars
# mini-amd64.c #
+fun:get_call_info
+fun:mono_arch_allocate_vars
+fun:mono_arch_emit_epilog
+fun:mono_arch_emit_prolog
fun:mono_arch_get_delegate_invoke_impl
+fun:mono_arch_lowering_pass
+fun:mono_arch_peephole_pass_2
+
+# mini-codegen.c #
+
+fun:mono_local_regalloc
+fun:mono_peephole_ins
# mini-exceptions.c #
# mini-generic-sharing.c #
+fun:alloc_template
+fun:class_get_rgctx_template_oti
+fun:get_info_templates
+fun:inflate_info
+fun:inst_check_context_used
fun:mini_get_basic_type_from_generic
fun:mini_is_gsharedvt_type
fun:mini_type_get_underlying_type
fun:mono_class_fill_runtime_generic_context
fun:mono_generic_context_check_used
fun:mono_method_check_context_used
+fun:mono_method_fill_runtime_generic_context
+fun:mono_method_get_declaring_generic_method
+fun:mono_method_is_generic_impl
+fun:mono_method_needs_static_rgctx_invoke
+fun:rgctx_template_set_slot
+fun:set_info_templates
# mini-native-types.c #
# mini-runtime.c #
+fun:create_runtime_invoke_info
+fun:mini_imt_entry_inited
+fun:mono_jit_compile_method_with_opt
fun:mono_jit_find_compiled_method_with_jit_info
+fun:mono_jit_runtime_invoke
# mini-trampolines.c #
fun:common_call_trampoline
+fun:mini_add_method_trampoline
fun:mini_resolve_imt_method
+fun:mono_create_delegate_trampoline_info
fun:mono_create_jit_trampoline
+fun:mono_create_jump_trampoline
fun:mono_delegate_trampoline
fun:mono_magic_trampoline
fun:mono_rgctx_lazy_fetch_trampoline
fun:mono_vcall_trampoline
-# ------------------------------------------------------------ #
-# mono/sgen
-# ------------------------------------------------------------ #
+# mini.c #
+
+fun:mini_method_compile
+fun:mono_allocate_stack_slots
+fun:mono_codegen
+fun:mono_compile_create_vars
+fun:mono_insert_branches_between_bblocks
+fun:mono_jit_compile_method_inner
+fun:mono_time_track_end
+fun:mono_type_to_load_membase
+fun:mono_type_to_store_membase
+
+# seq-points.c #
+
+fun:mono_save_seq_point_info
+
+# tramp-amd64.c #
+
+fun:mono_arch_patch_callsite
+
+# unwind.c #
+
+fun:mono_unwind_ops_encode_full
+
+# --------------------------------------------------------------------------- #
+# mono/sgen #
+# --------------------------------------------------------------------------- #
# sgen-alloc.c #
fun:sgen_clear_tlabs
fun:sgen_try_alloc_obj_nolock
+# sgen-array-list.c #
+
+fun:sgen_array_list_add
+fun:sgen_array_list_find_unset
+
# sgen-array-list.h #
fun:sgen_array_list_bucketize
-# sgen-array-list.c #
+# sgen-cardtable.c #
-fun:sgen_array_list_add
-fun:sgen_array_list_find_unset
+fun:sgen_card_table_wbarrier_range_copy
# sgen-cardtable.h #
fun:add_stage_entry
-# sgen-gc.h #
-
-fun:sgen_set_nursery_scan_start
-
# sgen-gc.c #
fun:mono_gc_wbarrier_generic_store
-fun:sgen_conservatively_pin_objects_from
+
+# sgen-gc.h #
+
+fun:sgen_set_nursery_scan_start
# sgen-gchandles.c #
fun:is_slot_set
fun:link_get
-fun:mono_gchandle_free
fun:sgen_gchandle_iterate
# sgen-marksweep.c #
fun:ensure_block_is_checked_for_sweeping
+fun:ensure_can_access_block_free_list
fun:major_finish_sweep_checking
fun:set_block_state
fun:sweep_block
fun:sgen_fragment_allocator_par_range_alloc
fun:sgen_fragment_allocator_release
-# ------------------------------------------------------------ #
-# mono/utils
-# ------------------------------------------------------------ #
+# --------------------------------------------------------------------------- #
+# mono/utils #
+# --------------------------------------------------------------------------- #
# hazard-pointer.c #
fun:is_pointer_hazardous
fun:mono_get_hazardous_pointer
+fun:mono_thread_small_id_alloc
+
+# lock-free-array-queue.c #
+
+fun:mono_lock_free_array_queue_pop
+fun:mono_lock_free_array_queue_push
# memfuncs.c #
# mono-conc-hashtable.c #
+fun:expand_table
+fun:mono_conc_hashtable_insert
fun:mono_conc_hashtable_lookup
# mono-context.c #
fun:mono_sigctx_to_monoctx
+# mono-error.c #
+
+fun:mono_error_cleanup
+
# mono-lazy-init.h #
fun:mono_lazy_initialize
+# mono-linked-list-set.c #
+
+fun:mono_lls_find
+fun:mono_lls_get_hazardous_pointer_with_mask
+
# mono-threads-posix-signals.c #
fun:restart_signal_handler
fun:check_thread_state
fun:mono_threads_transition_finish_async_suspend
+# mono-threads.c #
+
+fun:mono_thread_info_uninstall_interrupt
+
# os-event-unix.c #
fun:mono_os_event_set
--- /dev/null
+#!/bin/bash -x
+
+# This script is meant to be executed on all "slave" machines that run coverage collection.
+
+COV_DIR=coverage
+COV_INFO="$COV_DIR/$JOB_NAME.info"
+
+# Build Mono and collect coverage on the test suite.
+CI_TAGS=collect-coverage,monolite scripts/ci/run-jenkins.sh
+
+# Place the coverage info file into the coverage directory.
+# Multiple such files can be assembled to create a unified coverage report that spans multiple architectures and operating systems.
+mkdir "$COV_DIR"
+scripts/ci/run-step.sh --label=coverage-lcov --timeout=20m lcov --no-external -c -d mono -d support -d tools -o "$COV_INFO"
+
+# Generate HTML coverage report in the lcov directory at the root of the project.
+scripts/ci/run-step.sh --label=coverage-genhtml --timeout=20m genhtml "$COV_INFO" -o lcov
+
+# Make the paths relative so that they could be assembled from different Jenkins workspaces.
+sed -Eie "s#^SF:$WORKSPACE/?#SF:#" "$COV_INFO"
export CFLAGS="-ggdb3 -O2"
fi
+if [[ $CI_TAGS == *'retry-flaky-tests'* ]]; then
+ export MONO_FLAKY_TEST_RETRIES=5
+fi
+
if [[ ${label} == 'osx-i386' ]]; then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --with-libgdiplus=/Library/Frameworks/Mono.framework/Versions/Current/lib/libgdiplus.dylib --build=i386-apple-darwin11.2.0"; fi
if [[ ${label} == 'osx-amd64' ]]; then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --with-libgdiplus=/Library/Frameworks/Mono.framework/Versions/Current/lib/libgdiplus.dylib "; fi
if [[ ${label} == 'w32' ]]; then PLATFORM=Win32; EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --host=i686-w64-mingw32"; export MONO_EXECUTABLE="${MONO_REPO_ROOT}/msvc/build/sgen/Win32/bin/Release/mono-sgen.exe"; fi
${TESTCMD} --label=runtime --timeout=160m make -w -C mono/tests -k test-wrench V=1 CI=1 CI_PR=${ghprbPullId}
${TESTCMD} --label=runtime-unit-tests --timeout=5m make -w -C mono/unit-tests -k check
${TESTCMD} --label=corlib --timeout=30m make -w -C mcs/class/corlib run-test
-if [[ ${label} == w* ]]; then ${TESTCMD} --label=corlib-xunit --skip; else ${TESTCMD} --label=corlib-xunit --timeout=5m make -w -C mcs/class/corlib run-xunit-test; fi
+${TESTCMD} --label=corlib-xunit --timeout=5m make -w -C mcs/class/corlib run-xunit-test
${TESTCMD} --label=verify --timeout=15m make -w -C runtime mcs-compileall
${TESTCMD} --label=profiler --timeout=30m make -w -C mono/profiler -k check
${TESTCMD} --label=compiler --timeout=30m make -w -C mcs/tests run-test
${TESTCMD} --label=Mono.CSharp --timeout=5m make -w -C mcs/class/Mono.CSharp run-test
${TESTCMD} --label=WindowsBase --timeout=5m make -w -C mcs/class/WindowsBase run-test
${TESTCMD} --label=System.Numerics --timeout=5m make -w -C mcs/class/System.Numerics run-test
-if [[ ${label} == w* ]]; then ${TESTCMD} --label=System.Numerics-xunit --skip; else ${TESTCMD} --label=System.Numerics-xunit --timeout=5m make -w -C mcs/class/System.Numerics run-xunit-test; fi
+${TESTCMD} --label=System.Numerics-xunit --timeout=5m make -w -C mcs/class/System.Numerics run-xunit-test
${TESTCMD} --label=System.Runtime.DurableInstancing --timeout=5m make -w -C mcs/class/System.Runtime.DurableInstancing run-test
${TESTCMD} --label=System.ServiceModel.Discovery --timeout=5m make -w -C mcs/class/System.ServiceModel.Discovery run-test
${TESTCMD} --label=System.Xaml --timeout=5m make -w -C mcs/class/System.Xaml run-test
compare_names);
if (ptr == NULL) {
- g_warning ("Function '%s' not not found.", name);
+ g_warning ("Function '%s' not found.", name);
return NULL;
}