Compare commits

...
Author SHA1 Message Date
Miguel de Icaza 1887074366 [SslClientStream] Add extra logging information, prevent crashes
Based on a number of exceptions being raised, we want to track down the reason
for some of the exception.   This patch both fixes the build (fixes the last
commit) and provides more information for the reason that the Alert is being
sent to the remote end.

The alert is currently being sent to the remote end when something fails in
the negotiation.   We likely need to *not send* alerts when the reason the
negotiation failed was that the connection was shutdown in some form (that is
why we have ObjectDisposed, or NotConnected exceptions).

This patch is a step towards verifying the theory.  This will help us
establish which step failed.   And the next step is determine why it failed.
2015-02-24 11:12:34 -05:00
Martin Baulig a901ec0ba3 Add new ServicePointManager.Mono_Suppress_TLS_Alerts property to make it conditionally. 2015-02-23 13:58:43 +01:00
Martin Baulig aca7cfd994 Revert "Step II: rethrow the exception"
This reverts commit 88950e72bb.
2015-02-23 13:55:18 +01:00
Martin Baulig 7bf7bc69a5 Revert "Step III: do not catch the exception in the first place."
This reverts commit b2269514e9.
2015-02-23 13:54:49 +01:00
Martin Baulig b2269514e9 Step III: do not catch the exception in the first place. 2015-02-20 11:07:48 +01:00
Martin Baulig 88950e72bb Step II: rethrow the exception 2015-02-20 11:07:06 +01:00
Martin Baulig 049023723d Step I: do not send any TLS alerts. 2015-02-20 11:06:59 +01:00
Zoltan Varga 3245d4bab4 [jit] Fix a regression introduced by 00a28a7dfd which disabled liveness2 for most methods. 2015-02-14 16:01:56 -05:00
Alexander Köplinger 2121f55593 Fix CookieContainerTest to use expiration date in the future
It is 2015 now, so the cookie is already expired and the test fails otherwise.
2015-02-12 09:53:15 -05:00
Rolf Bjarne Kvinge 924483c9d6 [mono-api-html] Take arity into account when comparing methods.
Fixes a crash when there are two methods overloaded by arity:

System.InvalidOperationException: Sequence contains more than one matching element
  at System.Linq.Enumerable.Single[XElement] (IEnumerable`1 source, System.Func`2 predicate, Fallback fallback) [0x00038] in /private/tmp/source-mono-mac-3.10.0-branch/bockbuild-mono-3.10.0-branch/profiles/mono-mac-xamarin/build-root/mono-3.10.0/mcs/class/System.Core/System.Linq/Enumerable.cs:2371
  at System.Linq.Enumerable.SingleOrDefault[XElement] (IEnumerable`1 source, System.Func`2 predicate) [0x00007] in /private/tmp/source-mono-mac-3.10.0-branch/bockbuild-mono-3.10.0-branch/profiles/mono-mac-xamarin/build-root/mono-3.10.0/mcs/class/System.Core/System.Linq/Enumerable.cs:2445
  at Xamarin.ApiDiff.MemberComparer.Find (IEnumerable`1 target) [0x00019] in /Users/builder/data/lanes/macios-mac-master/177810cb/source/mono/mcs/tools/corcompare/mono-api-html/MemberComparer.cs:72
  at Xamarin.ApiDiff.MemberComparer.Compare (IEnumerable`1 source, IEnumerable`1 target) [0x0003c] in /Users/builder/data/lanes/macios-mac-master/177810cb/source/mono/mcs/tools/corcompare/mono-api-html/MemberComparer.cs:83
  at Xamarin.ApiDiff.MemberComparer.Compare (System.Xml.Linq.XElement source, System.Xml.Linq.XElement target) [0x000a2] in /Users/builder/data/lanes/macios-mac-master/177810cb/source/mono/mcs/tools/corcompare/mono-api-html/MemberComparer.cs:55
  at Xamarin.ApiDiff.ClassComparer.Modified (System.Xml.Linq.XElement source, System.Xml.Linq.XElement target) [0x0005b] in /Users/builder/data/lanes/macios-mac-master/177810cb/source/mono/mcs/tools/corcompare/mono-api-html/ClassComparer.cs:210
  at Xamarin.ApiDiff.Comparer.Compare (IEnumerable`1 source, IEnumerable`1 target) [0x00093] in /Users/builder/data/lanes/macios-mac-master/177810cb/source/mono/mcs/tools/corcompare/mono-api-html/Comparer.cs:80
  at Xamarin.ApiDiff.ClassComparer.Compare (System.Xml.Linq.XElement source, System.Xml.Linq.XElement target) [0x00055] in /Users/builder/data/lanes/macios-mac-master/177810cb/source/mono/mcs/tools/corcompare/mono-api-html/ClassComparer.cs:67
  at Xamarin.ApiDiff.NamespaceComparer.Modified (System.Xml.Linq.XElement source, System.Xml.Linq.XElement target) [0x0001a] in /Users/builder/data/lanes/macios-mac-master/177810cb/source/mono/mcs/tools/corcompare/mono-api-html/NamespaceComparer.cs:75
  at Xamarin.ApiDiff.Comparer.Compare (IEnumerable`1 source, IEnumerable`1 target) [0x00093] in /Users/builder/data/lanes/macios-mac-master/177810cb/source/mono/mcs/tools/corcompare/mono-api-html/Comparer.cs:80
  at Xamarin.ApiDiff.NamespaceComparer.Compare (System.Xml.Linq.XElement source, System.Xml.Linq.XElement target) [0x00055] in /Users/builder/data/lanes/macios-mac-master/177810cb/source/mono/mcs/tools/corcompare/mono-api-html/NamespaceComparer.cs:49
  at Xamarin.ApiDiff.AssemblyComparer.Modified (System.Xml.Linq.XElement source, System.Xml.Linq.XElement target) [0x0002b] in /Users/builder/data/lanes/macios-mac-master/177810cb/source/mono/mcs/tools/corcompare/mono-api-html/AssemblyComparer.cs:70
  at Xamarin.ApiDiff.Comparer.Compare (IEnumerable`1 source, IEnumerable`1 target) [0x00093] in /Users/builder/data/lanes/macios-mac-master/177810cb/source/mono/mcs/tools/corcompare/mono-api-html/Comparer.cs:80
  at Xamarin.ApiDiff.AssemblyComparer.Compare () [0x0004a] in /Users/builder/data/lanes/macios-mac-master/177810cb/source/mono/mcs/tools/corcompare/mono-api-html/AssemblyComparer.cs:50
  at Xamarin.ApiDiff.Program.Main (System.String[] args) [0x00328] in /Users/builder/data/lanes/macios-mac-master/177810cb/source/mono/mcs/tools/corcompare/mono-api-html/ApiDiff.cs:164
2015-02-12 09:52:53 -05:00
Zoltan Varga 5b9ec05150 [amd64] Fix r8->int conversions. Fixes #26219. 2015-02-11 17:25:35 -05:00
Zoltan Varga aa81a7132b [jit] Avoid live range indexes overflowing for large basic blocks in the liveness pass. Fixes #26732. 2015-02-11 16:34:25 -05:00
Zoltan Varga 1f46d47c3a [arm64] Increase the size of the dyn_call instruction, and the buffers used during dyn calls. 2015-01-20 17:44:21 -05:00
Zoltan Varga 8f828ff4ac [jit] Add a MONO_PATCH_INFO_LDSTR_LIT patch type to handle strings which do not come from metadata, i.e. they are used in wrappers. Fixes #25891. 2015-01-14 16:47:19 -05:00
Zoltan Varga 6544cc7f15 [arm] Fix OP_ICLE_UN. Fixes #25798. 2015-01-08 13:00:46 -05:00
Zoltan Varga 67ef18be7d [arm64] Mark the 'tailcall' opcode as a call. Fixes #25646. 2015-01-06 13:48:20 -05:00
Zoltan Varga 92be1aebdb Revert "[android] Add a workaround for ndk r10c defining RTLD_DEFAULT as 0 on 64 bit platforms."
This reverts commit 5ee92ecb76.

Revert this. There was already some android specific code in LL_SO_OPEN ().
2014-11-23 02:32:26 -05:00
Zoltan Varga 7138ab117f [runtime] Add a wrapper around atexit () since it is missing on some android versions. 2014-11-22 00:08:18 -05:00
Zoltan Varga 09d18d4f47 [android] Avoid referencing SYS_fork which is not defined in some ndk versions. 2014-11-21 23:17:13 -05:00
Zoltan Varga 75b30d0fd9 [android] Add a workaround for ndk r10c defining RTLD_DEFAULT as 0 on 64 bit platforms. 2014-11-21 23:17:08 -05:00
Zoltan Varga b813e56737 [android] Disable the usage of tkill () on android/arm64, the tkill () function is no longer there. 2014-11-21 23:17:03 -05:00
Zoltan Varga 117302400a [runtime] Remove another getdtablesize () reference. 2014-11-21 20:40:16 -05:00
Zoltan Varga 399facb8ca [jit] Fix the AOT part of #24577, the epilog beginning was calculated using the code size, which can be different in AOT mode due to alignment padding between methods. 2014-11-21 20:32:27 -05:00
Zoltan Varga 2311da7b9a [runtime] Remove a getdtablesize () reference from eglib too. 2014-11-21 20:32:07 -05:00
Marek Safar 5b3813b1d2 [system.data] Fixes DbEnumerator current property to clone read data. Fixes #24452 2014-11-21 10:28:04 +01:00
Rodrigo Kumpera 2e5167402b [profiler] Use the new hidden API to attach the helper thread as a tools thread. This makes JI lookup work more reliably. 2014-11-20 18:35:21 -05:00
Rodrigo Kumpera bf54221823 [jit] Don't sample threads that are not fully attached. 2014-11-20 18:35:21 -05:00
Rodrigo Kumpera f9afcf06b9 [runtime] Introduce the notion of a tools thread.
A tools thread is one that can access core runtime structures but not touch anything managed (code or heap).

It's intended to enable the profiler to resolve missing backtraces from its helper thread.

THIS IS A HACK.

The right solution would be to not perform this on the profiler at all and simply log IPs and let the decoder
resolve them. But then there's reality and we can't simply break the current format without consequences.

We're taking this hack for now until we can fix the profiler to do something sensible.
2014-11-20 18:35:20 -05:00
Rodrigo Kumpera d955217874 [utils] Add foreach variant that supports filtering the list as you go. 2014-11-20 18:35:20 -05:00
Zoltan Varga d457bae593 Merge pull request #1411 from jbevain/sdb-frame-domain
[sdb] Expose the domain of the stack frames
2014-11-20 04:49:30 -05:00
Zoltan Varga 6e152a16a1 Fix #24577 correctly, cfg->code_len is the size of the code, while cfg->code_size is the size of the memory area allocated for code. 2014-11-20 04:46:24 -05:00
Rolf Bjarne Kvinge a824dad5f6 Fix typo, there is no profile called 'xammaci'. 2014-11-19 10:50:07 +01:00
Zoltan Varga 55fcfb81be [sdb] Avoid asserts on shutdown when the appdomain unload callbacks are called on the debugger thread during shutdown. Fixes #24342. 2014-11-18 20:55:20 -05:00
Zoltan Varga f8691c441b [jit] Remove an assert from mono_arch_find_jit_info () on x86 which can be hit when a profiler stack walk is done while in a jump trampoline. 2014-11-18 16:55:25 -05:00
Zoltan Varga 2f569721a7 [jit] Fix the calculation of the epilog size for EH info. Fixes #24577. 2014-11-18 16:54:48 -05:00
Zoltan Varga f07e7d0850 [jit] Fix a class initialization race which happens if a class initializer initializes a got slot before it finishes running. Fixes #23242. 2014-11-17 21:45:28 -05:00
Rolf Bjarne Kvinge a9a6e86072 [System] Ignore two tests which are failing due to external factors changing.
See https://bugzilla.xamarin.com/show_bug.cgi?id=24340
2014-11-14 00:30:50 +01:00
Jonathan Pryor 219bd64946 [mono-api-html] Allow ignoring addition of property setters.
As mentioned in commit 789517f8, I'm trying to compare inter-API level
differences in Mono.Android.dll, and want to reduce as much
"meaningless noise" as possible -- changes which don't meaningfully
break API or ABI.

Among those "meaningless" changes are the addition of property setters
to properties. Adding a setter doesn't break API or ABI.

Add a `mono-api-html --ignore-changes-property-setters` option.

  --ignore-changes-property-setters:
      Ignore the addition of property setters.

      If a source property contains a getter and the target property
      contains both a getter and a setter, do not flag this as a
      change.
2014-11-13 14:15:52 -05:00
Jonathan Pryor 255a8971e5 [mono-api-html] Make --ignore-changes-virtual less lenient.
As mentioned in commit 789517f8, the intentino of
`mono-api-html --ignore-changes-virtual` is so that when a method is
changed from non-virtual to virtual or override, or from virtual to
override, a "Removed member" message isn't triggered.

However, the previous implementation was too lenient. While *adding*
virtual to the method is fine, *removing* is NOT fine, as that would
be an API breaking change (e.g. all classes which attempt to override
a previously virtual method could no longer do so).

Make the virtual check stricter so that virtual/override to
non-virtual changes are not ignored.
2014-11-13 14:15:52 -05:00
Zoltan Varga 91a4a3d504 Fix the build. 2014-11-13 03:58:22 -05:00
Zoltan Varga 6d5c45d559 [jit] Fix gshared and aot support for --debug=casts. 2014-11-12 20:15:30 -05:00
Zoltan Varga 5e1afc4533 [jit] Fix --debug=casts support for casts in gshared methods. 2014-11-12 20:15:23 -05:00
Jonathan Pryor e7da99bb17 [mono-api-html] Allow ignoring parameter names, virtual.
I've been trying to review API diffs in Xamarin.Android between API
levels, but the diffs are "noisy" because Google will change parameter
names at-will, or will change a non-virtual method into a virtual
method, or a virtual method into an override, all of which are
acceptable changes but individually generate a Removed line in
mono-api-html output, and manually removing the *hundreds* of changes
is error-prone.

Add two new option flags to mono-api-html:

  --ignore-changes-parameter-names:
      Ignore changes in constructor and method parameter names.

      If parameter names change between <reference.xml> and
      <assembly.xml>, don't report a change for the constructor or
      method.

  --ignore-changes-virtual:
      Ignore changes in "virtual-ness".

      If a method or property changes from non-virtual to virtual,
      non-virtual to override, or virtual to override, don't report a
      change for the member.
2014-11-12 17:45:37 -05:00
Rodrigo Kumpera e9e611d501 [runtime] Remove the second signal used by profiling and now multiplex distribution and sampling with the same signal. 2014-11-10 18:40:00 -05:00
Rodrigo Kumpera cefe30a5cc [runtime] Introduce new MonoThread API for signal multiplexing. It's a provisional API until we figure out more of how it's suposed to work. 2014-11-10 18:39:59 -05:00
Rodrigo Kumpera 928436efc6 [profiler] Guard against null sbuff when serializing statistical data. 2014-11-10 18:39:58 -05:00
Rodrigo Kumpera 838ec2fb6f [profiler] Fix statistical backtraces to work and collect as many frames as possible.
This is a jumbo commit that addresses multiple issues with statistical backtrace collection:

1) It's not possible to reliably collect MonoMethod* so we check that they exist before
serializing to the .mlpd file and retrieve in sync context.

2) It was reporting the generic instance MonoMethod* under gsharing. Those methods are
not reported to the profiler since they are never compiled. They would turn out as unknowns.

3) Collecting IL offsets from async context is currently impossible to be done safely, so it's
now disabled. The way we'll do it in the future is by serializing the sequence point table when
JIT'ing.

4) The way we used to collect frames in statistical ignored all frames until the first LMF, which
discards a lot of them under statistical mode. We now properly pass sigcontext and have it been consumed.
In the future we should simply use the callchain mode.
2014-11-10 18:39:58 -05:00
Rodrigo Kumpera 45d8971caa [runtime] Changes mono_stack_walk_async_safe API to be truly async safe.
This is a very very tricky API, so we restrict the returned data to be what's really
possible under sig context.
2014-11-10 18:39:51 -05:00
Rodrigo Kumpera cf53f2aab3 [runtime] Harden the profiler signal handlers against not fully attached threads and HP reentrancy. 2014-11-10 16:46:03 -05:00
Zoltan Varga f2c520372f [jit] Use xmm5 as an fp scratch register on winx64. 2014-11-10 15:31:30 -05:00
Zoltan Varga 3bc58c925b Fix a problem introduced by e19f539121. 2014-11-10 15:31:23 -05:00
Zoltan Varga 3790413f38 [amd64] Make xmm6:xmm15 callee saved on winx64 as required by the ABI. 2014-11-10 15:31:17 -05:00
Rodrigo Kumpera ef4965a6dd [profiler] Expose new profiling modes and allow sampling rate to be set when using signal-based sampling. 2014-11-05 14:01:56 -05:00
Rodrigo Kumpera 7cb75c8355 [profiler] Add new profiler API mono_profiler_set_statistical_mode that gives control to statistical mode and sampling rate. 2014-11-05 14:01:53 -05:00
Rodrigo Kumpera 90a83b65df [profiler] Fix signal based profiling to sample all registered threads.
The current signal profiling code depended on invalid linux behavior of setitimer
allowing multiple threads to register for the same timer. Linux kernel 2.6.12 fixed
this and only the main thread gets the signal. Always.

The correct POSIX behavior happens on OSX/iOS.

On Linux we could use timer_create and SIGEV_THREAD_ID but that would not work on iOS/OSX
since it's specific to it. Given that little detail, I'll leave implementing it as an
exercise to the reader.

The solution, which aims to be as portable as possible, is to use a pair of signals and
have the first one fire the second one against all other threads.

We use a pair of signals since it's not well defined which thread will receive the signal
so detecting this from the signal is non-trivial.
2014-11-05 14:01:49 -05:00
Rodrigo Kumpera 96a5c1247e Make mono_threads_pthread_kill available to mach targets. 2014-11-05 14:01:44 -05:00
Zoltan Varga b5a5402beb [arm] Fix OP_LOCALLOC on arm so it correctly adjusts sp with the param area size even if the size is large. Fixes #24221. 2014-11-04 22:56:38 -05:00
Zoltan Varga 9d2eec1131 [runtime] Fix the android build with ndk r10c. 2014-10-30 18:44:19 -04:00
Zoltan Varga a825298e9d [Mono.Data.Tds] Allow sending of text data longer than 4000 characters by using a different column type. Fixes #21172. 2014-10-30 14:40:26 -04:00
Alexis Christoforides e11a0b175d Revert "[runtime] Fix allocation size calculation for strings in 64-bit builds."
The change has been implicated in https://bugzilla.xamarin.com/show_bug.cgi?id=12842.

This reverts commit b0cff959e4.
2014-10-29 14:58:30 -04:00
Alexis Christoforides 2f5ddd0210 Bump Mono version -> 3.12.0 2014-10-29 13:14:44 -04:00
60 changed files with 820 additions and 168 deletions

No files matched your search

+1 -1
View File
@@ -1,7 +1,7 @@
# Process this file with autoconf to produce a configure script.
#AC_PREREQ([2.62])
AC_INIT(mono, [3.10.1],
AC_INIT(mono, [3.12.0],
[http://bugzilla.xamarin.com/enter_bug.cgi?classification=Mono])
AC_CONFIG_SRCDIR([README.md])
+2 -1
View File
@@ -135,6 +135,7 @@ AC_CHECK_SIZEOF(void *)
AC_CHECK_SIZEOF(long)
AC_CHECK_SIZEOF(long long)
AC_CHECK_FUNCS(strlcpy stpcpy strtok_r rewinddir vasprintf)
AC_CHECK_FUNCS(getrlimit)
#
# Mono currently supports 10.6, but strndup is not available prior to 10.7; avoiding
@@ -179,7 +180,7 @@ if test "x$have_iso_varargs" = "xyes"; then
fi
AC_SUBST(G_HAVE_ISO_VARARGS)
AC_CHECK_HEADERS(getopt.h sys/select.h sys/time.h sys/wait.h pwd.h langinfo.h iconv.h localcharset.h sys/types.h)
AC_CHECK_HEADERS(getopt.h sys/select.h sys/time.h sys/wait.h pwd.h langinfo.h iconv.h localcharset.h sys/types.h sys/resource.h)
AC_CHECK_HEADER(alloca.h, [HAVE_ALLOCA_H=1], [HAVE_ALLOCA_H=0])
AC_SUBST(HAVE_ALLOCA_H)
-1
View File
@@ -176,7 +176,6 @@ typedef struct _GMemChunk GMemChunk;
/*
* Misc.
*/
#define g_atexit(func) ((void) atexit (func))
const gchar * g_getenv(const gchar *variable);
gboolean g_setenv(const gchar *variable, const gchar *value, gboolean overwrite);
+23 -2
View File
@@ -53,6 +53,10 @@
#include <sys/wait.h>
#endif
#ifdef HAVE_SYS_RESOURCE_H
# include <sys/resource.h>
#endif
#ifdef G_OS_WIN32
#include <io.h>
#include <winsock2.h>
@@ -213,6 +217,23 @@ write_all (int fd, const void *vbuf, size_t n)
return nwritten;
}
#ifndef G_OS_WIN32
static int
g_getdtablesize (void)
{
#ifdef HAVE_GETRLIMIT
struct rlimit limit;
int res;
res = getrlimit (RLIMIT_NOFILE, &limit);
g_assert (res == 0);
return limit.rlim_cur;
#else
return getdtablesize ();
#endif
}
#endif
gboolean
g_spawn_command_line_sync (const gchar *command_line,
gchar **standard_output,
@@ -256,7 +277,7 @@ g_spawn_command_line_sync (const gchar *command_line,
close (stderr_pipe [0]);
dup2 (stderr_pipe [1], STDERR_FILENO);
}
for (i = getdtablesize () - 1; i >= 3; i--)
for (i = g_getdtablesize () - 1; i >= 3; i--)
close (i);
/* G_SPAWN_SEARCH_PATH is always enabled for g_spawn_command_line_sync */
@@ -417,7 +438,7 @@ g_spawn_async_with_pipes (const gchar *working_directory,
}
if ((flags & G_SPAWN_LEAVE_DESCRIPTORS_OPEN) != 0) {
for (i = getdtablesize () - 1; i >= 3; i--)
for (i = g_getdtablesize () - 1; i >= 3; i--)
close (i);
}
@@ -489,6 +489,19 @@ namespace Mono.Data.Tds.Protocol
Comm.Append ((byte) 0x00); // no param meta data name
Comm.Append ((byte) 0x00); // no status flags
// Convert BigNVarChar values larger than 4000 chars to nvarchar(max)
// Need to do this here so WritePreparedParameterInfo emit the
// correct data type
foreach (TdsMetaParameter param2 in parameters) {
var colType = param2.GetMetaType ();
if (colType == TdsColumnType.BigNVarChar) {
int size = param2.GetActualSize ();
if ((size >> 1) > 4000)
param2.Size = -1;
}
}
// Write sql as a parameter value - UCS2
TdsMetaParameter param = new TdsMetaParameter ("sql",
@@ -417,7 +417,7 @@ namespace Mono.Debugger.Soft
* with newer runtimes, and vice versa.
*/
internal const int MAJOR_VERSION = 2;
internal const int MINOR_VERSION = 37;
internal const int MINOR_VERSION = 38;
enum WPSuspendPolicy {
NONE = 0,
@@ -585,7 +585,8 @@ namespace Mono.Debugger.Soft
enum CmdStackFrame {
GET_VALUES = 1,
GET_THIS = 2,
SET_VALUES = 3
SET_VALUES = 3,
GET_DOMAIN = 4,
}
enum CmdArrayRef {
@@ -2378,6 +2379,10 @@ namespace Mono.Debugger.Soft
SendReceive (CommandSet.STACK_FRAME, (int)CmdStackFrame.SET_VALUES, new PacketWriter ().WriteId (thread_id).WriteId (id).WriteInt (len).WriteInts (pos).WriteValues (values));
}
internal long StackFrame_GetDomain (long thread_id, long id) {
return SendReceive (CommandSet.STACK_FRAME, (int)CmdStackFrame.GET_DOMAIN, new PacketWriter ().WriteId (thread_id).WriteId (id)).ReadId ();
}
/*
* ARRAYS
*/
@@ -7,6 +7,7 @@ namespace Mono.Debugger.Soft
public class StackFrame : Mirror
{
ThreadMirror thread;
AppDomainMirror domain;
MethodMirror method;
int il_offset;
Location location;
@@ -32,6 +33,16 @@ namespace Mono.Debugger.Soft
}
}
public AppDomainMirror Domain {
get {
vm.CheckProtocolVersion (2, 38);
if (domain == null)
domain = vm.GetDomain (vm.conn.StackFrame_GetDomain (thread.Id, Id));
return domain;
}
}
public MethodMirror Method {
get {
return method;
@@ -2869,8 +2869,10 @@ public class DebuggerTests
var frames = e.Thread.GetFrames ();
Assert.AreEqual ("invoke_in_domain", frames [0].Method.Name);
Assert.AreEqual (domain, frames [0].Domain);
Assert.AreEqual ("invoke", frames [1].Method.Name);
Assert.AreEqual ("domains", frames [2].Method.Name);
Assert.AreEqual (vm.RootDomain, frames [2].Domain);
// Test breakpoints on already JITted methods in other domains
m = entry_point.DeclaringType.GetMethod ("invoke_in_domain_2");
@@ -26,7 +26,7 @@ using System;
using System.Collections;
using System.IO;
using System.Threading;
using System.Net;
using Mono.Security.Protocol.Tls.Handshake;
namespace Mono.Security.Protocol.Tls
@@ -683,6 +683,9 @@ namespace Mono.Security.Protocol.Tls
public void SendAlert(Alert alert)
{
if (ServicePointManager.Mono_Suppress_TLS_Alerts)
return;
AlertLevel level;
AlertDescription description;
bool close;
@@ -428,7 +428,8 @@ namespace Mono.Security.Protocol.Tls
private void NegotiateAsyncWorker (IAsyncResult result)
{
NegotiateAsyncResult negotiate = result.AsyncState as NegotiateAsyncResult;
var state = negotiate.State;
try
{
switch (negotiate.State)
@@ -589,12 +590,23 @@ namespace Mono.Security.Protocol.Tls
catch (TlsException ex)
{
// FIXME: should the send alert also be done asynchronously here and below?
this.protocol.SendAlert(ex.Alert);
Console.WriteLine ("TlsException when handling state {1}: {0}", ex, state);
try {
this.protocol.SendAlert(ex.Alert);
} catch (Exception ex2) {
Console.WriteLine ("TLS: Send Alert raised an exception: {0}", ex2);
}
negotiate.SetComplete (new IOException("The authentication or decryption has failed.", ex));
}
catch (Exception ex)
{
this.protocol.SendAlert(AlertDescription.InternalError);
Console.WriteLine ("General Exception: {0} when handling state {1}", ex, state);
try {
this.protocol.SendAlert(AlertDescription.InternalError);
} catch (Exception ex2) {
Console.WriteLine ("TLS: Send Alert raised an exception: {0}", ex2);
}
negotiate.SetComplete (new IOException("The authentication or decryption has failed.", ex));
}
}
@@ -43,7 +43,6 @@ namespace System.Data.Common {
readonly IDataReader reader;
readonly bool closeReader;
readonly SchemaInfo [] schema;
readonly object [] values;
#endregion // Fields
@@ -58,7 +57,6 @@ namespace System.Data.Common {
{
this.reader = reader;
this.closeReader = closeReader;
this.values = new object [reader.FieldCount];
this.schema = LoadSchema (reader);
}
@@ -67,8 +65,13 @@ namespace System.Data.Common {
#region Properties
public object Current {
get {
get {
// DbDataRecordImpl does not do copy of the array
// and MoveNext would overwrite any previously filled data
var values = new object [reader.FieldCount];
reader.GetValues (values);
// TODO: Should not allocate on every property call
return new DbDataRecordImpl (schema, values);
}
}
+1 -1
View File
@@ -24,7 +24,7 @@ TEST_MCS_FLAGS = -r:System.Drawing.dll -r:Mono.Security.dll -r:System.Data -r:Sy
LIB_MCS_FLAGS = -nowarn:618 -d:CONFIGURATION_2_0 -unsafe $(RESOURCE_FILES:%=-resource:%)
TEST_MCS_FLAGS += -r:System.Configuration
PROFILE_ANY_MOBILE := $(filter monotouch monotouch_runtime monodroid xammaci mobile mobile_static, $(PROFILE))
PROFILE_ANY_MOBILE := $(filter monotouch monotouch_runtime monodroid xammac mobile mobile_static, $(PROFILE))
ifeq (2.1, $(FRAMEWORK_VERSION))
LIB_MCS_FLAGS += -d:INSIDE_SYSTEM
@@ -186,6 +186,14 @@ namespace System.Net
}
// Properties
/*
* Hack for bug #19334.
*
*/
public static bool Mono_Suppress_TLS_Alerts {
get; set;
}
[Obsolete ("Use ServerCertificateValidationCallback instead", false)]
public static ICertificatePolicy CertificatePolicy {
@@ -101,6 +101,7 @@ namespace MonoTests.System.Net.WebSockets
}
[Test]
[Ignore ("See bug #24340")]
public void EchoTest ()
{
const string Payload = "This is a websocket test";
@@ -125,6 +126,7 @@ namespace MonoTests.System.Net.WebSockets
}
[Test]
[Ignore ("See bug #24340")]
public void CloseOutputAsyncTest ()
{
Assert.IsTrue (socket.ConnectAsync (new Uri (EchoServerUrl), CancellationToken.None).Wait (5000));
@@ -1529,7 +1529,7 @@ namespace MonoTests.System.Net {
Cookie cookie = new Cookie ("name", "value")
{
Domain = ".example.com",
Expires = new DateTime (2015, 1, 1, 0, 0, 0, DateTimeKind.Utc),
Expires = new DateTime (2100, 1, 1, 0, 0, 0, DateTimeKind.Utc),
HttpOnly = true,
Secure = true,
};
@@ -1562,14 +1562,14 @@ namespace MonoTests.System.Net {
Cookie cookie = new Cookie ("name", "value")
{
Domain = ".example.com",
Expires = new DateTime (2015, 1, 1, 0, 0, 0, DateTimeKind.Utc),
Expires = new DateTime (2100, 1, 1, 0, 0, 0, DateTimeKind.Utc),
HttpOnly = true,
Secure = true,
};
Uri uri = new Uri ("https://www.example.com/path/file");
CookieContainer container = new CookieContainer ();
container.SetCookies (uri, "name=value; domain=.example.com; expires=Thu, 01-Jan-2015 00:00:00 GMT; HttpOnly; secure");
container.SetCookies (uri, "name=value; domain=.example.com; expires=Fri, 01-Jan-2100 00:00:00 GMT; HttpOnly; secure");
CookieCollection collection = container.GetCookies (uri);
Assert.AreEqual (collection.Count, 1, "#A1");
Cookie cloned = collection [0];
@@ -74,6 +74,10 @@ namespace Xamarin.ApiDiff {
get { return ignoreRemoved; }
}
public static bool IgnoreParameterNameChanges { get; set; }
public static bool IgnoreVirtualChanges { get; set; }
public static bool IgnoreAddedPropertySetters { get; set; }
public static bool Lax;
}
@@ -105,6 +109,15 @@ namespace Xamarin.ApiDiff {
{ "n|ignore-new=", "Ignore new namespaces and types whose description matches a given C# regular expression (see below).",
v => State.IgnoreNew.Add (new Regex (v))
},
{ "ignore-changes-parameter-names", "Ignore changes to parameter names for identically prototyped methods.",
v => State.IgnoreParameterNameChanges = v != null
},
{ "ignore-changes-property-setters", "Ignore adding setters to properties.",
v => State.IgnoreAddedPropertySetters = v != null
},
{ "ignore-changes-virtual", "Ignore changing non-`virtual` to `virtual` or adding `override`.",
v => State.IgnoreVirtualChanges = v != null
},
{ "x|lax", "Ignore duplicate XML entries", v => State.Lax = true }
};
@@ -99,7 +99,10 @@ namespace Xamarin.ApiDiff {
if (parameters != null) {
var list = new List<string> ();
foreach (var p in parameters.Elements ("parameter")) {
list.Add (p.GetTypeName ("type") + " " + p.GetAttribute ("name"));
var pTypeName = p.GetTypeName ("type");
list.Add (State.IgnoreParameterNameChanges
? pTypeName
: pTypeName + " " + p.GetAttribute ("name"));
}
sb.Append (String.Join (", ", list));
}
@@ -177,7 +177,25 @@ namespace Xamarin.ApiDiff {
if (base.Equals (source, target))
return true;
return GetDescription (source) == GetDescription (target);
string sourceDescription = GetDescription (source);
string targetDescription = GetDescription (target);
return CheckVirtualChanges (sourceDescription, targetDescription) ||
(State.IgnoreAddedPropertySetters &&
CheckVirtualChanges (sourceDescription, targetDescription.Replace (" set; ", " ")));
}
static bool CheckVirtualChanges (string sourceDescription, string targetDescription)
{
return (sourceDescription == targetDescription) ||
// *adding* virtual or override to target is acceptable; *removing* them is NOT
(State.IgnoreVirtualChanges &&
// non-virtual to virtual is fine
(sourceDescription == targetDescription.Replace ("virtual ", "")) ||
// non-virtual to override is fine
(sourceDescription == targetDescription.Replace ("override ", "")) ||
// virtual to override is fine
(sourceDescription.Replace (" virtual ", " override ") == targetDescription));
}
bool IsNowObsoleted (XElement source, XElement target)
@@ -25,6 +25,7 @@
//
using System;
using System.Linq;
using System.Xml.Linq;
namespace Xamarin.ApiDiff {
@@ -42,8 +43,24 @@ namespace Xamarin.ApiDiff {
// operators have identical names but vary by return types
public override bool Find (XElement e)
{
return (e.GetAttribute ("name") == Source.GetAttribute ("name")) &&
(e.GetAttribute ("returntype") == Source.GetAttribute ("returntype"));
if (e.GetAttribute ("name") != Source.GetAttribute ("name"))
return false;
if (e.GetAttribute ("returntype") != Source.GetAttribute ("returntype"))
return false;
var eGP = e.Element ("generic-parameters");
var sGP = Source.Element ("generic-parameters");
if (eGP == null && sGP == null)
return true;
else if (eGP == null ^ sGP == null)
return false;
else {
var eGPs = eGP.Elements ("generic-parameter");
var sGPs = sGP.Elements ("generic-parameter");
return eGPs.Count () == sGPs.Count ();
}
}
}
}
@@ -77,7 +77,7 @@ namespace Xamarin.ApiDiff {
var sb = new StringBuilder ();
sb.Append (family ? "protected " : "public ");
if (virt)
if (virt && !State.IgnoreVirtualChanges)
sb.Append (over ? "override " : "virtual ");
else if (stat)
sb.Append ("static ");
+3 -2
View File
@@ -42,6 +42,7 @@
#include <mono/io-layer/process-private.h>
#include <mono/utils/mono-mutex.h>
#include <mono/utils/mono-proclib.h>
#undef DEBUG_REFS
#if 0
@@ -286,12 +287,12 @@ wapi_init (void)
wapi_processes_init ();
/* Using g_atexit here instead of an explicit function call in
/* Using atexit here instead of an explicit function call in
* a cleanup routine lets us cope when a third-party library
* calls exit (eg if an X client loses the connection to its
* server.)
*/
g_atexit (handle_cleanup);
mono_atexit (handle_cleanup);
}
void
+1 -1
View File
@@ -753,7 +753,7 @@ create_allocator (int atype, int tls_key)
bytes_var = mono_mb_add_local (mb, &mono_defaults.int32_class->byval_arg);
if (atype == ATYPE_STRING) {
/* a string alloator method takes the args: (vtable, len) */
/* bytes = (offsetof (MonoString, chars) + ((len + 1) * 2)); */
/* bytes = (sizeof (MonoString) + ((len + 1) * 2)); */
mono_mb_emit_ldarg (mb, 1);
mono_mb_emit_icon (mb, 1);
mono_mb_emit_byte (mb, MONO_CEE_ADD);
+2 -1
View File
@@ -35,6 +35,7 @@
#include <mono/metadata/metadata.h>
#include <mono/metadata/threadpool.h>
#include <mono/utils/mono-signal-handler.h>
#include <mono/utils/mono-proclib.h>
/* On solaris, curses.h must come before both termios.h and term.h */
#ifdef HAVE_CURSES_H
@@ -502,7 +503,7 @@ ves_icall_System_ConsoleDriver_TtySetup (MonoString *keypad, MonoString *teardow
if (teardown != NULL)
teardown_str = mono_string_to_utf8 (teardown);
atexit (tty_teardown);
mono_atexit (tty_teardown);
}
return TRUE;
+36 -3
View File
@@ -2278,16 +2278,49 @@ mono_stack_walk_no_il (MonoStackWalk func, gpointer user_data)
mono_get_eh_callbacks ()->mono_walk_stack_with_ctx (stack_walk_adapter, NULL, MONO_UNWIND_DEFAULT, &ud);
}
typedef struct {
MonoStackWalkAsyncSafe func;
gpointer user_data;
} AsyncStackWalkUserData;
static gboolean
async_stack_walk_adapter (MonoStackFrameInfo *frame, MonoContext *ctx, gpointer data)
{
AsyncStackWalkUserData *d = data;
switch (frame->type) {
case FRAME_TYPE_DEBUGGER_INVOKE:
case FRAME_TYPE_MANAGED_TO_NATIVE:
return FALSE;
case FRAME_TYPE_MANAGED:
if (!frame->ji)
return FALSE;
if (frame->ji->async)
return d->func (NULL, frame->domain, frame->ji->code_start, frame->native_offset, d->user_data);
else
return d->func (mono_jit_info_get_method (frame->ji), frame->domain, frame->ji->code_start, frame->native_offset, d->user_data);
break;
default:
g_assert_not_reached ();
return FALSE;
}
}
/*
* mono_stack_walk_async_safe:
*
* Async safe version callable from signal handlers.
*/
void
mono_stack_walk_async_safe (MonoStackWalk func, gpointer user_data)
mono_stack_walk_async_safe (MonoStackWalkAsyncSafe func, void *initial_sig_context, void *user_data)
{
StackWalkUserData ud = { func, user_data };
mono_get_eh_callbacks ()->mono_walk_stack_with_ctx (stack_walk_adapter, NULL, MONO_UNWIND_NONE, &ud);
MonoContext ctx;
AsyncStackWalkUserData ud = { func, user_data };
mono_sigctx_to_monoctx (initial_sig_context, &ctx);
mono_get_eh_callbacks ()->mono_walk_stack_with_ctx (async_stack_walk_adapter, NULL, MONO_UNWIND_SIGNAL_SAFE, &ud);
}
static gboolean
+2 -1
View File
@@ -90,8 +90,9 @@ mono_stack_walk (MonoStackWalk func, void* user_data);
MONO_API void
mono_stack_walk_no_il (MonoStackWalk func, void* user_data);
typedef mono_bool (*MonoStackWalkAsyncSafe) (MonoMethod *method, MonoDomain *domain, void *base_address, int offset, void* data);
MONO_API void
mono_stack_walk_async_safe (MonoStackWalk func, void* user_data);
mono_stack_walk_async_safe (MonoStackWalkAsyncSafe func, void *initial_sig_context, void* user_data);
MONO_END_DECLS
+2 -2
View File
@@ -5041,10 +5041,10 @@ mono_string_new_size (MonoDomain *domain, gint32 len)
size_t size;
/* check for overflow */
if (len < 0 || len > ((SIZE_MAX - offsetof (MonoString, chars) - 2) / 2))
if (len < 0 || len > ((SIZE_MAX - sizeof (MonoString) - 2) / 2))
mono_gc_out_of_memory (-1);
size = (offsetof (MonoString, chars) + ((len + 1) * 2));
size = (sizeof (MonoString) + ((len + 1) * 2));
g_assert (size > 0);
vtable = mono_class_vtable (domain, mono_defaults.string_class);
+3
View File
@@ -77,5 +77,8 @@ void mono_profiler_code_buffer_new (gpointer buffer, int size, MonoProfilerCodeB
void mono_profiler_runtime_initialized (void) MONO_INTERNAL;
int64_t mono_profiler_get_sampling_rate (void) MONO_INTERNAL;
MonoProfileSamplingMode mono_profiler_get_sampling_mode (void) MONO_INTERNAL;
#endif /* __MONO_PROFILER_PRIVATE_H__ */
+34
View File
@@ -273,6 +273,28 @@ mono_profiler_install_monitor (MonoProfileMonitorFunc callback)
prof_list->monitor_event_cb = callback;
}
static MonoProfileSamplingMode sampling_mode = MONO_PROFILER_STAT_MODE_PROCESS;
static int64_t sampling_frequency = 1000; //1ms
/**
* mono_profiler_set_statistical_mode:
* @mode the sampling mode used.
* @sample_frequency_is_us the sampling frequency in microseconds.
*
* Set the sampling parameters for the profiler. Sampling mode affects the effective sampling rate as in samples/s you'll witness.
* The default sampling mode is process mode, which only reports samples when there's activity in the process.
*
* Sampling frequency should be interpreted as a suggestion that can't always be honored due to how most kernels expose alarms.
*
* Said that, when using statistical sampling, always assume variable rate sampling as all sort of external factors can interfere.
*/
void
mono_profiler_set_statistical_mode (MonoProfileSamplingMode mode, int64_t sampling_frequency_is_us)
{
sampling_mode = mode;
sampling_frequency = sampling_frequency_is_us;
}
void
mono_profiler_install_statistical (MonoProfileStatFunc callback)
{
@@ -281,6 +303,18 @@ mono_profiler_install_statistical (MonoProfileStatFunc callback)
prof_list->statistical_cb = callback;
}
int64_t
mono_profiler_get_sampling_rate (void)
{
return sampling_frequency;
}
MonoProfileSamplingMode
mono_profiler_get_sampling_mode (void)
{
return sampling_mode;
}
void
mono_profiler_install_statistical_call_chain (MonoProfileStatCallChainFunc callback, int call_chain_depth, MonoProfilerCallChainStrategy call_chain_strategy) {
if (!prof_list)
+9
View File
@@ -193,6 +193,15 @@ MONO_API void mono_profiler_install_iomap (MonoProfileIomapFunc callback);
MONO_API void mono_profiler_load (const char *desc);
typedef enum {
/* Elapsed time is tracked by user+kernel time of the process - this is the default*/
MONO_PROFILER_STAT_MODE_PROCESS = 0,
/* Elapsed time is tracked by wallclock time */
MONO_PROFILER_STAT_MODE_REAL = 1,
} MonoProfileSamplingMode;
MONO_API void mono_profiler_set_statistical_mode (MonoProfileSamplingMode mode, int64_t sampling_frequency_is_us);
MONO_END_DECLS
#endif /* __MONO_PROFILER_H__ */
+5 -5
View File
@@ -896,7 +896,7 @@ create_allocator (int atype)
/*
* a string allocator method takes the args: (vtable, len)
*
* bytes = offsetof (MonoString, chars) + ((len + 1) * 2)
* bytes = sizeof (MonoString) + ((len + 1) * 2)
*
* condition:
*
@@ -904,11 +904,11 @@ create_allocator (int atype)
*
* therefore:
*
* offsetof (MonoString, chars) + ((len + 1) * 2) <= INT32_MAX - (SGEN_ALLOC_ALIGN - 1)
* len <= (INT32_MAX - (SGEN_ALLOC_ALIGN - 1) - offsetof (MonoString, chars)) / 2 - 1
* sizeof (MonoString) + ((len + 1) * 2) <= INT32_MAX - (SGEN_ALLOC_ALIGN - 1)
* len <= (INT32_MAX - (SGEN_ALLOC_ALIGN - 1) - sizeof (MonoString)) / 2 - 1
*/
mono_mb_emit_ldarg (mb, 1);
mono_mb_emit_icon (mb, (INT32_MAX - (SGEN_ALLOC_ALIGN - 1) - MONO_STRUCT_OFFSET (MonoString, chars)) / 2 - 1);
mono_mb_emit_icon (mb, (INT32_MAX - (SGEN_ALLOC_ALIGN - 1) - sizeof (MonoString)) / 2 - 1);
pos = mono_mb_emit_short_branch (mb, MONO_CEE_BLE_UN_S);
mono_mb_emit_byte (mb, MONO_CUSTOM_PREFIX);
@@ -920,7 +920,7 @@ create_allocator (int atype)
mono_mb_emit_icon (mb, 1);
mono_mb_emit_byte (mb, MONO_CEE_SHL);
//WE manually fold the above + 2 here
mono_mb_emit_icon (mb, MONO_STRUCT_OFFSET (MonoString, chars) + 2);
mono_mb_emit_icon (mb, sizeof (MonoString) + 2);
mono_mb_emit_byte (mb, CEE_ADD);
mono_mb_emit_stloc (mb, size_var);
} else {
+2 -2
View File
@@ -731,7 +731,7 @@ slow_object_get_size (MonoVTable *vtable, MonoObject* o)
* mono_array_length_fast not using the object's vtable.
*/
if (klass == mono_defaults.string_class) {
return offsetof (MonoString, chars) + 2 * mono_string_length_fast ((MonoString*) o) + 2;
return sizeof (MonoString) + 2 * mono_string_length_fast ((MonoString*) o) + 2;
} else if (klass->rank) {
MonoArray *array = (MonoArray*)o;
size_t size = sizeof (MonoArray) + klass->sizes.element_size * mono_array_length_fast (array);
@@ -782,7 +782,7 @@ sgen_par_object_get_size (MonoVTable *vtable, MonoObject* o)
if (type == DESC_TYPE_RUN_LENGTH || type == DESC_TYPE_SMALL_BITMAP) {
mword size = descr & 0xfff8;
if (size == 0) /* This is used to encode a string */
return offsetof (MonoString, chars) + 2 * mono_string_length_fast ((MonoString*) o) + 2;
return sizeof (MonoString) + 2 * mono_string_length_fast ((MonoString*) o) + 2;
return size;
} else if (type == DESC_TYPE_VECTOR) {
int element_size = ((descr) >> VECTOR_ELSIZE_SHIFT) & MAX_ELEMENT_SIZE;
+1 -1
View File
@@ -65,7 +65,7 @@ ves_icall_System_String_GetLOSLimit (void)
{
int limit = mono_gc_get_los_limit ();
return (limit - 2 - offsetof (MonoString, chars)) / 2;
return (limit - 2 - sizeof (MonoString)) / 2;
}
void
+7 -1
View File
@@ -44,11 +44,17 @@
#include <mono/metadata/gc-internal.h>
#if defined(PLATFORM_ANDROID) && !defined(TARGET_ARM64)
#define USE_TKILL_ON_ANDROID 1
#endif
#ifdef PLATFORM_ANDROID
#include <errno.h>
#ifdef USE_TKILL_ON_ANDROID
extern int tkill (pid_t tid, int signal);
#endif
#endif
/*#define THREAD_DEBUG(a) do { a; } while (0)*/
#define THREAD_DEBUG(a)
@@ -4476,7 +4482,7 @@ mono_thread_kill (MonoInternalThread *thread, int signal)
# ifdef PTHREAD_POINTER_ID
return pthread_kill ((gpointer)(gsize)(thread->tid), mono_thread_get_abort_signal ());
# else
# ifdef PLATFORM_ANDROID
# ifdef USE_TKILL_ON_ANDROID
if (thread->android_tid != 0) {
int ret;
int old_errno = errno;
+16
View File
@@ -5176,6 +5176,13 @@ encode_patch (MonoAotCompile *acfg, MonoJumpInfo *patch_info, guint8 *buf, guint
}
break;
}
case MONO_PATCH_INFO_LDSTR_LIT: {
const char *s = patch_info->data.target;
encode_value (strlen (s), p, &p);
memcpy (p, s, strlen (s) + 1);
break;
}
default:
g_warning ("unable to handle jump info %d", patch_info->type);
g_assert_not_reached ();
@@ -5392,6 +5399,15 @@ emit_exception_debug_info (MonoAotCompile *acfg, MonoCompile *cfg)
encode_value (table->num_holes, p, &p);
}
if (jinfo->has_arch_eh_info) {
/*
* In AOT mode, the code length is calculated from the address of the previous method,
* which could include alignment padding, so calculating the start of the epilog as
* code_len - epilog_size is correct any more. Save the real code len as a workaround.
*/
encode_value (jinfo->code_size, p, &p);
}
/* Exception table */
if (cfg->compile_llvm) {
/*
+38 -15
View File
@@ -2585,17 +2585,21 @@ decode_exception_debug_info (MonoAotModule *amodule, MonoDomain *domain,
} else {
num_holes = try_holes_info_size = 0;
}
if (has_arch_eh_jit_info) {
flags |= JIT_INFO_HAS_ARCH_EH_INFO;
arch_eh_jit_info_size = sizeof (MonoArchEHJitInfo);
/* Overwrite the original code_len which includes alignment padding */
code_len = decode_value (p, &p);
} else {
arch_eh_jit_info_size = 0;
}
/* Exception table */
if (has_clauses)
num_clauses = decode_value (p, &p);
else
num_clauses = 0;
if (has_arch_eh_jit_info) {
flags |= JIT_INFO_HAS_ARCH_EH_INFO;
arch_eh_jit_info_size = sizeof (MonoArchEHJitInfo);
} else {
arch_eh_jit_info_size = 0;
}
if (from_llvm) {
MonoJitExceptionInfo *clauses;
@@ -3363,6 +3367,17 @@ decode_patch (MonoAotModule *aot_module, MonoMemPool *mp, MonoJumpInfo *ji, guin
ji->data.target = info;
break;
}
case MONO_PATCH_INFO_LDSTR_LIT: {
int len = decode_value (p, &p);
char *s;
s = mono_mempool_alloc0 (mp, len + 1);
memcpy (s, p, len + 1);
p += len + 1;
ji->data.target = s;
break;
}
default:
g_warning ("unhandled type %d", ji->type);
g_assert_not_reached ();
@@ -3399,14 +3414,14 @@ load_patch_info (MonoAotModule *aot_module, MonoMemPool *mp, int n_patches,
got_offset = decode_value (p, &p);
if (aot_module->got [got_offset]) {
shared_p = aot_module->blob + mono_aot_get_offset (aot_module->got_info_offsets, got_offset);
ji->type = decode_value (shared_p, &shared_p);
/* See load_method () for SFLDA */
if (aot_module->got [got_offset] && ji->type != MONO_PATCH_INFO_SFLDA) {
/* Already loaded */
//printf ("HIT!\n");
} else {
shared_p = aot_module->blob + mono_aot_get_offset (aot_module->got_info_offsets, got_offset);
ji->type = decode_value (shared_p, &shared_p);
res = decode_patch (aot_module, mp, ji, shared_p, &shared_p);
if (!res)
goto cleanup;
@@ -3574,11 +3589,19 @@ load_method (MonoDomain *domain, MonoAotModule *amodule, MonoImage *image, MonoM
for (pindex = 0; pindex < n_patches; ++pindex) {
MonoJumpInfo *ji = &patches [pindex];
gpointer addr;
if (!amodule->got [got_slots [pindex]]) {
amodule->got [got_slots [pindex]] = mono_resolve_patch_target (method, domain, code, ji, TRUE);
/*
* For SFLDA, we need to call resolve_patch_target () since the GOT slot could have
* been initialized by load_method () for a static cctor before the cctor has
* finished executing (#23242).
*/
if (!amodule->got [got_slots [pindex]] || ji->type == MONO_PATCH_INFO_SFLDA) {
addr = mono_resolve_patch_target (method, domain, code, ji, TRUE);
if (ji->type == MONO_PATCH_INFO_METHOD_JUMP)
amodule->got [got_slots [pindex]] = mono_create_ftnptr (domain, amodule->got [got_slots [pindex]]);
addr = mono_create_ftnptr (domain, addr);
mono_memory_barrier ();
amodule->got [got_slots [pindex]] = addr;
if (ji->type == MONO_PATCH_INFO_METHOD_JUMP)
register_jump_target_got_slot (domain, ji->data.method, &(amodule->got [got_slots [pindex]]));
}
+4
View File
@@ -93,6 +93,10 @@ class Tests
ui = (uint)d;
if (ui != 0)
return 9;
d = Double.MaxValue;
i = (int)d;
if (i != -2147483648)
return 10;
return 0;
}
+2 -2
View File
@@ -94,7 +94,7 @@ lcall_membase: dest:l src1:b len:32 clob:c
vcall: len:32 clob:c
vcall_reg: src1:i len:32 clob:c
vcall_membase: src1:b len:32 clob:c
tailcall: len:64
tailcall: len:64 clob:c
iconst: dest:i len:16
r4const: dest:f len:24
r8const: dest:f len:20
@@ -324,7 +324,7 @@ long_conv_to_ovf_i4_2: dest:i src1:i src2:i len:36
vcall2: len:40 clob:c
vcall2_reg: src1:i len:40 clob:c
vcall2_membase: src1:b len:40 clob:c
dyn_call: src1:i src2:i len:120 clob:c
dyn_call: src1:i src2:i len:192 clob:c
# This is different from the original JIT opcodes
float_beq: len:32
+23 -3
View File
@@ -289,7 +289,7 @@ typedef struct {
#define HEADER_LENGTH 11
#define MAJOR_VERSION 2
#define MINOR_VERSION 37
#define MINOR_VERSION 38
typedef enum {
CMD_SET_VM = 1,
@@ -514,7 +514,8 @@ typedef enum {
typedef enum {
CMD_STACK_FRAME_GET_VALUES = 1,
CMD_STACK_FRAME_GET_THIS = 2,
CMD_STACK_FRAME_SET_VALUES = 3
CMD_STACK_FRAME_SET_VALUES = 3,
CMD_STACK_FRAME_GET_DOMAIN = 4,
} CmdStackFrame;
typedef enum {
@@ -815,6 +816,12 @@ static void
register_socket_transport (void);
#endif
static inline gboolean
is_debugger_thread (void)
{
return GetCurrentThreadId () == debugger_thread_id;
}
static int
parse_address (char *address, char **host, int *port)
{
@@ -4070,6 +4077,10 @@ appdomain_start_unload (MonoProfiler *prof, MonoDomain *domain)
{
DebuggerTlsData *tls;
/* This might be called during shutdown on the debugger thread from the CMD_VM_EXIT code */
if (is_debugger_thread ())
return;
/*
* Remember the currently unloading appdomain as it is needed to generate
* proper ids for unloading assemblies.
@@ -4084,6 +4095,9 @@ appdomain_unload (MonoProfiler *prof, MonoDomain *domain)
{
DebuggerTlsData *tls;
if (is_debugger_thread ())
return;
tls = mono_native_tls_get_value (debugger_tls_id);
g_assert (tls);
tls->domain_unloading = NULL;
@@ -9037,6 +9051,11 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf)
mono_metadata_free_mh (header);
break;
}
case CMD_STACK_FRAME_GET_DOMAIN: {
if (CHECK_PROTOCOL_VERSION (2, 38))
buffer_add_domainid (buf, frame->domain);
break;
}
default:
return ERR_NOT_IMPLEMENTED;
}
@@ -9405,7 +9424,8 @@ static const char* type_cmds_str[] = {
static const char* stack_frame_cmds_str[] = {
"GET_VALUES",
"GET_THIS",
"SET_VALUES"
"SET_VALUES",
"GET_DOMAIN",
};
static const char* array_cmds_str[] = {
+3 -6
View File
@@ -828,14 +828,12 @@ mono_arch_find_jit_info (MonoDomain *domain, MonoJitTlsData *jit_tls,
return TRUE;
}
if ((ji = mini_jit_info_table_find (domain, (gpointer)(*lmf)->eip, NULL))) {
frame->ji = ji;
} else {
if (!((guint32)((*lmf)->previous_lmf) & 1))
/* Top LMF entry */
if (!(*lmf)->method)
return FALSE;
g_assert_not_reached ();
/* Trampoline lmf frame */
frame->method = (*lmf)->method;
}
@@ -848,7 +846,6 @@ mono_arch_find_jit_info (MonoDomain *domain, MonoJitTlsData *jit_tls,
/* Adjust IP */
new_ctx->eip --;
frame->ji = ji;
frame->type = FRAME_TYPE_MANAGED_TO_NATIVE;
/* Check if we are in a trampoline LMF frame */
+4
View File
@@ -259,6 +259,8 @@ alloc_dreg (MonoCompile *cfg, MonoStackType stack_type)
#define NEW_LDSTRCONST(cfg,dest,image,token) NEW_AOTCONST_TOKEN ((cfg), (dest), MONO_PATCH_INFO_LDSTR, (image), (token), NULL, STACK_OBJ, mono_defaults.string_class)
#define NEW_LDSTRLITCONST(cfg,dest,val) NEW_AOTCONST ((cfg), (dest), MONO_PATCH_INFO_LDSTR_LIT, (val))
#define NEW_TYPE_FROM_HANDLE_CONST(cfg,dest,image,token,generic_context) NEW_AOTCONST_TOKEN ((cfg), (dest), MONO_PATCH_INFO_TYPE_FROM_HANDLE, (image), (token), (generic_context), STACK_OBJ, mono_defaults.monotype_class)
#define NEW_LDTOKENCONST(cfg,dest,image,token,generic_context) NEW_AOTCONST_TOKEN ((cfg), (dest), MONO_PATCH_INFO_LDTOKEN, (image), (token), (generic_context), STACK_PTR, NULL)
@@ -445,6 +447,8 @@ handle_gsharedvt_ldaddr (MonoCompile *cfg)
#define EMIT_NEW_LDSTRCONST(cfg,dest,image,token) do { NEW_AOTCONST_TOKEN ((cfg), (dest), MONO_PATCH_INFO_LDSTR, (image), (token), NULL, STACK_OBJ, mono_defaults.string_class); MONO_ADD_INS ((cfg)->cbb, (dest)); } while (0)
#define EMIT_NEW_LDSTRLITCONST(cfg,dest,val) do { NEW_AOTCONST ((cfg), (dest), MONO_PATCH_INFO_LDSTR_LIT, (val)); MONO_ADD_INS ((cfg)->cbb, (dest)); } while (0)
#define EMIT_NEW_TYPE_FROM_HANDLE_CONST(cfg,dest,image,token,generic_context) do { NEW_AOTCONST_TOKEN ((cfg), (dest), MONO_PATCH_INFO_TYPE_FROM_HANDLE, (image), (token), (generic_context), STACK_OBJ, mono_defaults.monotype_class); MONO_ADD_INS ((cfg)->cbb, (dest)); } while (0)
#define EMIT_NEW_LDTOKENCONST(cfg,dest,image,token,generic_context) do { NEW_AOTCONST_TOKEN ((cfg), (dest), MONO_PATCH_INFO_LDTOKEN, (image), (token), (generic_context), STACK_PTR, NULL); MONO_ADD_INS ((cfg)->cbb, (dest)); } while (0)
+25 -6
View File
@@ -20,6 +20,8 @@
#define BITS_PER_CHUNK MONO_BITSET_BITS_PER_CHUNK
#define BB_ID_SHIFT 18
/*
* The liveness2 pass can't handle long vars on 32 bit platforms because the component
* vars have the same 'idx'.
@@ -217,7 +219,7 @@ analyze_liveness_bb (MonoCompile *cfg, MonoBasicBlock *bb)
MonoInst *ins;
int sreg, inst_num;
MonoMethodVar *vars = cfg->vars;
guint32 abs_pos = (bb->dfn << 16);
guint32 abs_pos = (bb->dfn << BB_ID_SHIFT);
/* Start inst_num from > 0, so last_use.abs_pos is only 0 for dead variables */
for (inst_num = 2, ins = bb->code; ins; ins = ins->next, inst_num += 2) {
@@ -492,7 +494,7 @@ mono_analyze_liveness (MonoCompile *cfg)
for (i = 0; i < cfg->num_bblocks; ++i) {
MonoBasicBlock *bb = cfg->bblocks [i];
guint32 max;
guint32 abs_pos = (bb->dfn << 16);
guint32 abs_pos = (bb->dfn << BB_ID_SHIFT);
MonoMethodVar *vars = cfg->vars;
if (!bb->live_out_set)
@@ -512,7 +514,7 @@ mono_analyze_liveness (MonoCompile *cfg)
if (bits_in & 1)
update_live_range (&vars [k], abs_pos + 0);
if (bits_out & 1)
update_live_range (&vars [k], abs_pos + 0xffff);
update_live_range (&vars [k], abs_pos + ((1 << BB_ID_SHIFT) - 1));
bits_in >>= 1;
bits_out >>= 1;
k ++;
@@ -852,6 +854,23 @@ mono_analyze_liveness2 (MonoCompile *cfg)
if (disabled)
return;
if (cfg->num_bblocks >= (1 << (32 - BB_ID_SHIFT)))
/* Ranges would overflow */
return;
for (bnum = cfg->num_bblocks - 1; bnum >= 0; --bnum) {
MonoBasicBlock *bb = cfg->bblocks [bnum];
MonoInst *ins;
nins = 0;
for (nins = 0, ins = bb->code; ins; ins = ins->next, ++nins)
nins ++;
if (nins >= ((1 << BB_ID_SHIFT) - 1))
/* Ranges would overflow */
return;
}
LIVENESS_DEBUG (printf ("LIVENESS 2 %s\n", mono_method_full_name (cfg->method, TRUE)));
/*
@@ -879,12 +898,12 @@ mono_analyze_liveness2 (MonoCompile *cfg)
MonoBasicBlock *bb = cfg->bblocks [bnum];
MonoInst *ins;
block_from = (bb->dfn << 16) + 1; /* so pos > 0 */
block_from = (bb->dfn << BB_ID_SHIFT) + 1; /* so pos > 0 */
if (bnum < cfg->num_bblocks - 1)
/* Beginning of the next bblock */
block_to = (cfg->bblocks [bnum + 1]->dfn << 16) + 1;
block_to = (cfg->bblocks [bnum + 1]->dfn << BB_ID_SHIFT) + 1;
else
block_to = (bb->dfn << 16) + 0xffff;
block_to = (bb->dfn << BB_ID_SHIFT) + ((1 << BB_ID_SHIFT) - 1);
LIVENESS_DEBUG (printf ("LIVENESS BLOCK BB%d:\n", bb->block_num));
+26 -7
View File
@@ -3579,11 +3579,11 @@ static void
save_cast_details (MonoCompile *cfg, MonoClass *klass, int obj_reg, gboolean null_check, MonoBasicBlock **out_bblock)
{
if (mini_get_debug_options ()->better_cast_details) {
int to_klass_reg = alloc_preg (cfg);
int vtable_reg = alloc_preg (cfg);
int klass_reg = alloc_preg (cfg);
MonoBasicBlock *is_null_bb = NULL;
MonoInst *tls_get;
int to_klass_reg, context_used;
if (null_check) {
NEW_BBLOCK (cfg, is_null_bb);
@@ -3603,7 +3603,17 @@ save_cast_details (MonoCompile *cfg, MonoClass *klass, int obj_reg, gboolean nul
MONO_EMIT_NEW_LOAD_MEMBASE (cfg, klass_reg, vtable_reg, MONO_STRUCT_OFFSET (MonoVTable, klass));
MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STORE_MEMBASE_REG, tls_get->dreg, MONO_STRUCT_OFFSET (MonoJitTlsData, class_cast_from), klass_reg);
MONO_EMIT_NEW_PCONST (cfg, to_klass_reg, klass);
context_used = mini_class_check_context_used (cfg, klass);
if (context_used) {
MonoInst *class_ins;
class_ins = emit_get_rgctx_klass (cfg, context_used, klass, MONO_RGCTX_INFO_KLASS);
to_klass_reg = class_ins->dreg;
} else {
to_klass_reg = alloc_preg (cfg);
MONO_EMIT_NEW_CLASSCONST (cfg, to_klass_reg, klass);
}
MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STORE_MEMBASE_REG, tls_get->dreg, MONO_STRUCT_OFFSET (MonoJitTlsData, class_cast_to), to_klass_reg);
if (null_check) {
@@ -4095,6 +4105,7 @@ emit_castclass_with_cache (MonoCompile *cfg, MonoClass *klass, MonoInst **args,
save_cast_details (cfg, klass, args [0]->dreg, TRUE, out_bblock);
res = mono_emit_method_call (cfg, mono_castclass, args, NULL);
reset_cast_details (cfg);
*out_bblock = cfg->cbb;
return res;
}
@@ -4130,13 +4141,15 @@ emit_castclass_with_cache_nonshared (MonoCompile *cfg, MonoInst *obj, MonoClass
* Returns NULL and set the cfg exception on error.
*/
static MonoInst*
handle_castclass (MonoCompile *cfg, MonoClass *klass, MonoInst *src, int context_used)
handle_castclass (MonoCompile *cfg, MonoClass *klass, MonoInst *src, int context_used, MonoBasicBlock **out_bb)
{
MonoBasicBlock *is_null_bb;
int obj_reg = src->dreg;
int vtable_reg = alloc_preg (cfg);
MonoInst *klass_inst = NULL;
*out_bb = cfg->cbb;
if (context_used) {
MonoInst *args [3];
@@ -4154,7 +4167,7 @@ handle_castclass (MonoCompile *cfg, MonoClass *klass, MonoInst *src, int context
/* cache */
args [2] = cache_ins;
return emit_castclass_with_cache (cfg, klass, args, NULL);
return emit_castclass_with_cache (cfg, klass, args, out_bb);
}
klass_inst = emit_get_rgctx_klass (cfg, context_used, klass, MONO_RGCTX_INFO_KLASS);
@@ -4200,6 +4213,8 @@ handle_castclass (MonoCompile *cfg, MonoClass *klass, MonoInst *src, int context
reset_cast_details (cfg);
*out_bb = cfg->cbb;
return src;
}
@@ -9590,8 +9605,12 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
}
else if (method->wrapper_type != MONO_WRAPPER_NONE) {
MonoInst *iargs [1];
char *str = mono_method_get_wrapper_data (method, n);
EMIT_NEW_PCONST (cfg, iargs [0], mono_method_get_wrapper_data (method, n));
if (cfg->compile_aot)
EMIT_NEW_LDSTRLITCONST (cfg, iargs [0], str);
else
EMIT_NEW_PCONST (cfg, iargs [0], str);
*sp = mono_emit_jit_icall (cfg, mono_string_new_wrapper, iargs);
} else {
if (cfg->opt & MONO_OPT_SHARED) {
@@ -9863,7 +9882,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
inline_costs += costs;
}
else {
ins = handle_castclass (cfg, klass, *sp, context_used);
ins = handle_castclass (cfg, klass, *sp, context_used, &bblock);
CHECK_CFG_EXCEPTION;
bblock = cfg->cbb;
*sp ++ = ins;
@@ -9977,7 +9996,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
*sp++ = iargs [0];
inline_costs += costs;
} else {
ins = handle_castclass (cfg, klass, *sp, context_used);
ins = handle_castclass (cfg, klass, *sp, context_used, &bblock);
CHECK_CFG_EXCEPTION;
bblock = cfg->cbb;
*sp ++ = ins;
+11 -8
View File
@@ -3279,7 +3279,10 @@ cc_signed_table [] = {
static unsigned char*
emit_float_to_int (MonoCompile *cfg, guchar *code, int dreg, int sreg, int size, gboolean is_signed)
{
amd64_sse_cvttsd2si_reg_reg (code, dreg, sreg);
if (size == 8)
amd64_sse_cvttsd2si_reg_reg (code, dreg, sreg);
else
amd64_sse_cvttsd2si_reg_reg_size (code, dreg, sreg, 4);
if (size == 1)
amd64_widen_reg (code, dreg, dreg, is_signed, FALSE);
@@ -5022,8 +5025,8 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
break;
case OP_STORER4_MEMBASE_REG:
/* This requires a double->single conversion */
amd64_sse_cvtsd2ss_reg_reg (code, AMD64_XMM15, ins->sreg1);
amd64_sse_movss_membase_reg (code, ins->inst_destbasereg, ins->inst_offset, AMD64_XMM15);
amd64_sse_cvtsd2ss_reg_reg (code, MONO_ARCH_FP_SCRATCH_REG, ins->sreg1);
amd64_sse_movss_membase_reg (code, ins->inst_destbasereg, ins->inst_offset, MONO_ARCH_FP_SCRATCH_REG);
break;
case OP_LOADR4_MEMBASE:
amd64_sse_movss_reg_membase (code, ins->dreg, ins->inst_basereg, ins->inst_offset);
@@ -6070,8 +6073,8 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
break;
case OP_EXTRACT_I8:
if (ins->inst_c0) {
amd64_movhlps_reg_reg (code, AMD64_XMM15, ins->sreg1);
amd64_movd_reg_xreg_size (code, ins->dreg, AMD64_XMM15, 8);
amd64_movhlps_reg_reg (code, MONO_ARCH_FP_SCRATCH_REG, ins->sreg1);
amd64_movd_reg_xreg_size (code, ins->dreg, MONO_ARCH_FP_SCRATCH_REG, 8);
} else {
amd64_movd_reg_xreg_size (code, ins->dreg, ins->sreg1, 8);
}
@@ -6123,11 +6126,11 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
amd64_sse_pinsrw_reg_reg_imm (code, ins->dreg, ins->sreg2, ins->inst_c0 * 2 + 1);
break;
case OP_INSERTX_I8_SLOW:
amd64_movd_xreg_reg_size(code, AMD64_XMM15, ins->sreg2, 8);
amd64_movd_xreg_reg_size(code, MONO_ARCH_FP_SCRATCH_REG, ins->sreg2, 8);
if (ins->inst_c0)
amd64_movlhps_reg_reg (code, ins->dreg, AMD64_XMM15);
amd64_movlhps_reg_reg (code, ins->dreg, MONO_ARCH_FP_SCRATCH_REG);
else
amd64_sse_movsd_reg_reg (code, ins->dreg, AMD64_XMM15);
amd64_sse_movsd_reg_reg (code, ins->dreg, MONO_ARCH_FP_SCRATCH_REG);
break;
case OP_INSERTX_R4_SLOW:
+12 -3
View File
@@ -122,14 +122,23 @@ struct sigcontext {
#define MONO_ARCH_FP_RETURN_REG AMD64_XMM0
/* xmm15 is reserved for use by some opcodes */
#ifdef TARGET_WIN32
/* xmm5 is used as a scratch register */
#define MONO_ARCH_CALLEE_FREGS 0x1f
/* xmm6:xmm15 */
#define MONO_ARCH_CALLEE_SAVED_FREGS (0xffff - 0x3f)
#define MONO_ARCH_FP_SCRATCH_REG AMD64_XMM5
#else
/* xmm15 is used as a scratch register */
#define MONO_ARCH_CALLEE_FREGS 0x7fff
#define MONO_ARCH_CALLEE_SAVED_FREGS 0
#define MONO_ARCH_FP_SCRATCH_REG AMD64_XMM15
#endif
#define MONO_MAX_XREGS MONO_MAX_FREGS
#define MONO_ARCH_CALLEE_XREGS 0x7fff
#define MONO_ARCH_CALLEE_SAVED_XREGS 0
#define MONO_ARCH_CALLEE_XREGS MONO_ARCH_CALLEE_FREGS
#define MONO_ARCH_CALLEE_SAVED_XREGS MONO_ARCH_CALLEE_SAVED_FREGS
#define MONO_ARCH_CALLEE_REGS AMD64_CALLEE_REGS
+33 -11
View File
@@ -247,9 +247,32 @@ emit_big_add (guint8 *code, int dreg, int sreg, int imm)
ARM_ADD_REG_IMM (code, dreg, sreg, imm8, rot_amount);
return code;
}
g_assert (dreg != sreg);
code = mono_arm_emit_load_imm (code, dreg, imm);
ARM_ADD_REG_REG (code, dreg, dreg, sreg);
if (dreg == sreg) {
code = mono_arm_emit_load_imm (code, ARMREG_IP, imm);
ARM_ADD_REG_REG (code, dreg, sreg, ARMREG_IP);
} else {
code = mono_arm_emit_load_imm (code, dreg, imm);
ARM_ADD_REG_REG (code, dreg, dreg, sreg);
}
return code;
}
/* If dreg == sreg, this clobbers IP */
static guint8*
emit_sub_imm (guint8 *code, int dreg, int sreg, int imm)
{
int imm8, rot_amount;
if ((imm8 = mono_arm_is_rotated_imm8 (imm, &rot_amount)) >= 0) {
ARM_SUB_REG_IMM (code, dreg, sreg, imm8, rot_amount);
return code;
}
if (dreg == sreg) {
code = mono_arm_emit_load_imm (code, ARMREG_IP, imm);
ARM_SUB_REG_REG (code, dreg, sreg, ARMREG_IP);
} else {
code = mono_arm_emit_load_imm (code, dreg, imm);
ARM_SUB_REG_REG (code, dreg, dreg, sreg);
}
return code;
}
@@ -4945,15 +4968,9 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
break;
}
case OP_LOCALLOC: {
/* keep alignment */
int alloca_waste = cfg->param_area;
alloca_waste += 7;
alloca_waste &= ~7;
/* round the size to 8 bytes */
ARM_ADD_REG_IMM8 (code, ins->dreg, ins->sreg1, 7);
ARM_BIC_REG_IMM8 (code, ins->dreg, ins->dreg, 7);
if (alloca_waste)
ARM_ADD_REG_IMM8 (code, ins->dreg, ins->dreg, alloca_waste);
ARM_SUB_REG_REG (code, ARMREG_SP, ARMREG_SP, ins->dreg);
/* memzero the area: dreg holds the size, sp is the pointer */
if (ins->flags & MONO_INST_INIT) {
@@ -4969,7 +4986,9 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
ARM_B_COND (code, ARMCOND_GE, 0);
arm_patch (code - 4, start_loop);
}
ARM_ADD_REG_IMM8 (code, ins->dreg, ARMREG_SP, alloca_waste);
ARM_MOV_REG_REG (code, ins->dreg, ARMREG_SP);
if (cfg->param_area)
code = emit_sub_imm (code, ARMREG_SP, ARMREG_SP, ALIGN_TO (cfg->param_area, MONO_ARCH_FRAME_ALIGNMENT));
break;
}
case OP_DYN_CALL: {
@@ -5186,10 +5205,13 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
ARM_MOV_REG_IMM8_COND (code, ins->dreg, 0, ARMCOND_GT);
break;
case OP_ICGE_UN:
case OP_ICLE_UN:
ARM_MOV_REG_IMM8 (code, ins->dreg, 1);
ARM_MOV_REG_IMM8_COND (code, ins->dreg, 0, ARMCOND_LO);
break;
case OP_ICLE_UN:
ARM_MOV_REG_IMM8 (code, ins->dreg, 1);
ARM_MOV_REG_IMM8_COND (code, ins->dreg, 0, ARMCOND_HI);
break;
case OP_COND_EXC_EQ:
case OP_COND_EXC_NE_UN:
case OP_COND_EXC_LT:
+77 -8
View File
@@ -25,6 +25,8 @@
#ifdef HAVE_SYS_SYSCALL_H
#include <sys/syscall.h>
#endif
#include <errno.h>
#include <mono/metadata/assembly.h>
#include <mono/metadata/loader.h>
@@ -55,6 +57,7 @@
#include <mono/utils/mono-mmap.h>
#include <mono/utils/dtrace.h>
#include <mono/utils/mono-signal-handler.h>
#include <mono/utils/mono-threads.h>
#include "mini.h"
#include <string.h>
@@ -306,12 +309,14 @@ MONO_SIG_HANDLER_FUNC (static, sigprof_signal_handler)
#else
MONO_SIG_HANDLER_FUNC (static, sigprof_signal_handler)
static int profiling_signal_in_use;
static void
per_thread_profiler_hit (void *ctx)
{
int call_chain_depth = mono_profiler_stat_get_call_chain_depth ();
MonoProfilerCallChainStrategy call_chain_strategy = mono_profiler_stat_get_call_chain_strategy ();
MONO_SIG_HANDLER_GET_CONTEXT;
if (call_chain_depth == 0) {
mono_profiler_stat_hit (mono_arch_ip_from_context (ctx), ctx);
} else {
@@ -378,6 +383,40 @@ MONO_SIG_HANDLER_FUNC (static, sigprof_signal_handler)
mono_profiler_stat_call_chain (current_frame_index, & ips [0], ctx);
}
}
MONO_SIG_HANDLER_FUNC (static, sigprof_signal_handler)
{
MonoThreadInfo *info;
int old_errno = errno;
int hp_save_index;
MONO_SIG_HANDLER_GET_CONTEXT;
if (mono_thread_info_get_small_id () == -1)
return; //an non-attached thread got the signal
if (!mono_domain_get () || !mono_native_tls_get_value (mono_jit_tls_id))
return; //thread in the process of dettaching
hp_save_index = mono_hazard_pointer_save_for_signal_handler ();
/* If we can't consume a profiling request it means we're the initiator. */
if (!(mono_threads_consume_async_jobs () & MONO_SERVICE_REQUEST_SAMPLE)) {
FOREACH_THREAD_SAFE (info) {
if (mono_thread_info_get_tid (info) == mono_native_thread_id_get ())
continue;
mono_threads_add_async_job (info, MONO_SERVICE_REQUEST_SAMPLE);
mono_threads_pthread_kill (info, profiling_signal_in_use);
} END_FOREACH_THREAD_SAFE;
}
mono_thread_info_set_is_async_context (TRUE);
per_thread_profiler_hit (ctx);
mono_thread_info_set_is_async_context (FALSE);
mono_hazard_pointer_restore_for_signal_handler (hp_save_index);
errno = old_errno;
mono_chain_signal (MONO_SIG_HANDLER_PARAMS);
}
@@ -600,6 +639,30 @@ mono_runtime_shutdown_stat_profiler (void)
#endif
}
#ifdef ITIMER_PROF
static int
get_itimer_mode (void)
{
switch (mono_profiler_get_sampling_mode ()) {
case MONO_PROFILER_STAT_MODE_PROCESS: return ITIMER_PROF;
case MONO_PROFILER_STAT_MODE_REAL: return ITIMER_REAL;
}
g_assert_not_reached ();
return 0;
}
static int
get_itimer_signal (void)
{
switch (mono_profiler_get_sampling_mode ()) {
case MONO_PROFILER_STAT_MODE_PROCESS: return SIGPROF;
case MONO_PROFILER_STAT_MODE_REAL: return SIGALRM;
}
g_assert_not_reached ();
return 0;
}
#endif
void
mono_runtime_setup_stat_profiler (void)
{
@@ -620,7 +683,8 @@ mono_runtime_setup_stat_profiler (void)
perror ("open /dev/rtc");
return;
}
add_signal_handler (SIGPROF, sigprof_signal_handler);
profiling_signal_in_use = SIGPROF;
add_signal_handler (profiling_signal_in_use, sigprof_signal_handler);
if (ioctl (rtc_fd, RTC_IRQP_SET, freq) == -1) {
perror ("set rtc freq");
return;
@@ -644,14 +708,15 @@ mono_runtime_setup_stat_profiler (void)
return;
#endif
itval.it_interval.tv_usec = 999;
itval.it_interval.tv_usec = (1000000 / mono_profiler_get_sampling_rate ()) - 1;
itval.it_interval.tv_sec = 0;
itval.it_value = itval.it_interval;
setitimer (ITIMER_PROF, &itval, NULL);
if (inited)
return;
inited = 1;
add_signal_handler (SIGPROF, sigprof_signal_handler);
profiling_signal_in_use = get_itimer_signal ();
add_signal_handler (profiling_signal_in_use, sigprof_signal_handler);
setitimer (get_itimer_mode (), &itval, NULL);
#endif
}
@@ -659,7 +724,11 @@ mono_runtime_setup_stat_profiler (void)
pid_t
mono_runtime_syscall_fork ()
{
#if defined(SYS_fork)
#if defined(PLATFORM_ANDROID)
/* SYS_fork is defined to be __NR_fork which is not defined in some ndk versions */
g_assert_not_reached ();
return 0;
#elif defined(SYS_fork)
return (pid_t) syscall (SYS_fork);
#else
g_assert_not_reached ();
+10 -3
View File
@@ -3257,6 +3257,8 @@ mono_patch_info_hash (gconstpointer data)
return g_str_hash (ji->data.target);
case MONO_PATCH_INFO_DELEGATE_TRAMPOLINE:
return (ji->type << 8) | (gsize)ji->data.del_tramp->klass | (gsize)ji->data.del_tramp->method | (gsize)ji->data.del_tramp->virtual;
case MONO_PATCH_INFO_LDSTR_LIT:
return g_str_hash (ji->data.target);
default:
printf ("info type: %d\n", ji->type);
mono_print_ji (ji); printf ("\n");
@@ -3708,6 +3710,10 @@ mono_resolve_patch_target (MonoMethod *method, MonoDomain *domain, guint8 *code,
target = NULL;
break;
}
case MONO_PATCH_INFO_LDSTR_LIT: {
target = mono_string_new (domain, patch_info->data.target);
break;
}
default:
g_assert_not_reached ();
}
@@ -4137,6 +4143,7 @@ mono_codegen (MonoCompile *cfg)
if (bb == cfg->bb_exit) {
cfg->epilog_begin = cfg->code_len;
mono_arch_emit_epilog (cfg);
cfg->epilog_end = cfg->code_len;
}
}
@@ -4645,7 +4652,7 @@ create_jit_info (MonoCompile *cfg, MonoMethod *method_to_compile)
info = mono_jit_info_get_arch_eh_info (jinfo);
g_assert (info);
info->epilog_size = cfg->code_size - cfg->epilog_begin;
info->epilog_size = cfg->code_len - cfg->epilog_begin;
}
jinfo->unwind_info = unwind_desc;
g_free (unwind_info);
@@ -6691,8 +6698,8 @@ mono_jit_runtime_invoke (MonoMethod *method, void *obj, void **params, MonoObjec
gpointer *args;
static RuntimeInvokeDynamicFunction dyn_runtime_invoke;
int i, pindex;
guint8 buf [128];
guint8 retval [128];
guint8 buf [256];
guint8 retval [256];
if (!dyn_runtime_invoke) {
invoke = mono_marshal_get_runtime_invoke_dynamic ();
+2 -1
View File
@@ -111,7 +111,7 @@
#endif
/* Version number of the AOT file format */
#define MONO_AOT_FILE_VERSION 103
#define MONO_AOT_FILE_VERSION 104
//TODO: This is x86/amd64 specific.
#define mono_simd_shuffle_mask(a,b,c,d) ((a) | ((b) << 2) | ((c) << 4) | ((d) << 6))
@@ -1454,6 +1454,7 @@ typedef struct {
guint code_len;
guint prolog_end;
guint epilog_begin;
guint epilog_end;
regmask_t used_int_regs;
guint32 opt;
guint32 prof_options;
+1
View File
@@ -51,4 +51,5 @@ PATCH_INFO(JIT_TLS_ID, "jit_tls_id")
PATCH_INFO(TLS_OFFSET, "tls_offset")
PATCH_INFO(OBJC_SELECTOR_REF, "objc_selector_ref")
PATCH_INFO(METHOD_CODE_SLOT, "method_code_slot")
PATCH_INFO(LDSTR_LIT, "ldstr_lit")
PATCH_INFO(NONE, "none")
+87 -22
View File
@@ -90,6 +90,7 @@ static int do_mono_sample = 0;
static int in_shutdown = 0;
static int do_debug = 0;
static int do_counters = 0;
static MonoProfileSamplingMode sampling_mode = MONO_PROFILER_STAT_MODE_PROCESS;
/* For linux compile with:
* gcc -fPIC -shared -o libmono-profiler-log.so proflog.c utils.c -Wall -g -lz `pkg-config --cflags --libs mono-2`
@@ -831,13 +832,10 @@ walk_stack (MonoMethod *method, int32_t native_offset, int32_t il_offset, mono_b
* event, hence the collect_bt/emit_bt split.
*/
static void
collect_bt (FrameData *data, gboolean async_safe)
collect_bt (FrameData *data)
{
data->count = 0;
if (async_safe)
mono_stack_walk_async_safe (walk_stack, data);
else
mono_stack_walk_no_il (walk_stack, data);
mono_stack_walk_no_il (walk_stack, data);
}
static void
@@ -870,7 +868,7 @@ gc_alloc (MonoProfiler *prof, MonoObject *obj, MonoClass *klass)
len += 7;
len &= ~7;
if (do_bt)
collect_bt (&data, FALSE);
collect_bt (&data);
logbuffer = ensure_logbuf (32 + MAX_FRAMES * 8);
now = current_time ();
ENTER_LOG (logbuffer, "gcalloc");
@@ -1135,7 +1133,7 @@ throw_exc (MonoProfiler *prof, MonoObject *object)
FrameData data;
LogBuffer *logbuffer;
if (do_bt)
collect_bt (&data, FALSE);
collect_bt (&data);
logbuffer = ensure_logbuf (16 + MAX_FRAMES * 8);
now = current_time ();
ENTER_LOG (logbuffer, "throw");
@@ -1171,7 +1169,7 @@ monitor_event (MonoProfiler *profiler, MonoObject *object, MonoProfilerMonitorEv
FrameData data;
LogBuffer *logbuffer;
if (do_bt)
collect_bt (&data, FALSE);
collect_bt (&data);
logbuffer = ensure_logbuf (16 + MAX_FRAMES * 8);
now = current_time ();
ENTER_LOG (logbuffer, "monitor");
@@ -1220,11 +1218,44 @@ thread_name (MonoProfiler *prof, uintptr_t tid, const char *name)
EXIT_LOG (logbuffer);
}
typedef struct {
MonoMethod *method;
MonoDomain *domain;
void *base_address;
int offset;
} AsyncFrameInfo;
typedef struct {
int count;
AsyncFrameInfo *data;
} AsyncFrameData;
static mono_bool
async_walk_stack (MonoMethod *method, MonoDomain *domain, void *base_address, int offset, void *data)
{
AsyncFrameData *frame = data;
if (frame->count < num_frames) {
frame->data [frame->count].method = method;
frame->data [frame->count].domain = domain;
frame->data [frame->count].base_address = base_address;
frame->data [frame->count].offset = offset;
// printf ("In %d at %p (dom %p) (native: %p)\n", frame->count, method, domain, base_address);
frame->count++;
}
return frame->count == num_frames;
}
/*
(type | frame count), tid, time, ip, [method, domain, base address, offset] * frames
*/
#define SAMPLE_EVENT_SIZE_IN_SLOTS(FRAMES) (4 + (FRAMES) * 4)
static void
mono_sample_hit (MonoProfiler *profiler, unsigned char *ip, void *context)
{
StatBuffer *sbuf;
FrameData bt_data;
AsyncFrameInfo frames [num_frames];
AsyncFrameData bt_data = { 0, &frames [0]};
uint64_t now;
uintptr_t *data, *new_data, *old_data;
uintptr_t elapsed;
@@ -1233,7 +1264,9 @@ mono_sample_hit (MonoProfiler *profiler, unsigned char *ip, void *context)
if (in_shutdown)
return;
now = current_time ();
collect_bt (&bt_data, TRUE);
mono_stack_walk_async_safe (&async_walk_stack, context, &bt_data);
elapsed = (now - profiler->startup_time) / 10000;
if (do_debug) {
int len;
@@ -1272,7 +1305,7 @@ mono_sample_hit (MonoProfiler *profiler, unsigned char *ip, void *context)
}
do {
old_data = sbuf->data;
new_data = old_data + 4 + bt_data.count * 3;
new_data = old_data + SAMPLE_EVENT_SIZE_IN_SLOTS (bt_data.count);
data = InterlockedCompareExchangePointer ((void * volatile*)&sbuf->data, new_data, old_data);
} while (data != old_data);
if (old_data >= sbuf->data_end)
@@ -1282,9 +1315,10 @@ mono_sample_hit (MonoProfiler *profiler, unsigned char *ip, void *context)
old_data [2] = elapsed;
old_data [3] = (uintptr_t)ip;
for (i = 0; i < bt_data.count; ++i) {
old_data [4+3*i] = (uintptr_t)bt_data.methods [i];
old_data [4+3*i+1] = (uintptr_t)bt_data.il_offsets [i];
old_data [4+3*i+2] = (uintptr_t)bt_data.native_offsets [i];
old_data [4 + 4 * i + 0] = (uintptr_t)frames [i].method;
old_data [4 + 4 * i + 1] = (uintptr_t)frames [i].domain;
old_data [4 + 4 * i + 2] = (uintptr_t)frames [i].base_address;
old_data [4 + 4 * i + 3] = (uintptr_t)frames [i].offset;
}
}
@@ -1624,8 +1658,22 @@ dump_sample_hits (MonoProfiler *prof, StatBuffer *sbuf, int recurse)
int count = sample [0] & 0xff;
int mbt_count = (sample [0] & 0xff00) >> 8;
int type = sample [0] >> 16;
if (sample + count + 3 + mbt_count * 3 > sbuf->data)
uintptr_t *managed_sample_base = sample + count + 3;
if (sample + SAMPLE_EVENT_SIZE_IN_SLOTS (mbt_count) > sbuf->data)
break;
for (i = 0; i < mbt_count; ++i) {
MonoMethod *method = (MonoMethod*)managed_sample_base [i * 4 + 0];
MonoDomain *domain = (MonoDomain*)managed_sample_base [i * 4 + 1];
void *address = (void*)managed_sample_base [i * 4 + 2];
if (!method) {
MonoJitInfo *ji = mono_jit_info_table_find (domain, address);
if (ji)
managed_sample_base [i * 4 + 0] = (uintptr_t)mono_jit_info_get_method (ji);
}
}
logbuffer = ensure_logbuf (20 + count * 8);
emit_byte (logbuffer, TYPE_SAMPLE | TYPE_SAMPLE_HIT);
emit_value (logbuffer, type);
@@ -1635,15 +1683,16 @@ dump_sample_hits (MonoProfiler *prof, StatBuffer *sbuf, int recurse)
emit_ptr (logbuffer, (void*)sample [i + 3]);
add_code_pointer (sample [i + 3]);
}
sample += count + 3;
/* new in data version 6 */
emit_uvalue (logbuffer, mbt_count);
for (i = 0; i < mbt_count; ++i) {
emit_method (logbuffer, (void*)sample [i * 3]); /* method */
emit_svalue (logbuffer, sample [i * 3 + 1]); /* il offset */
emit_svalue (logbuffer, sample [i * 3 + 2]); /* native offset */
emit_method (logbuffer, (void*)sample [i * 4]); /* method */
emit_svalue (logbuffer, 0); /* il offset will always be 0 from now on */
emit_svalue (logbuffer, sample [i * 4 + 3]); /* native offset */
}
sample += 3 * mbt_count;
sample += 4 * mbt_count;
}
dump_unmanaged_coderefs (prof);
}
@@ -2188,6 +2237,10 @@ new_filename (const char* filename)
}
#ifndef DISABLE_HELPER_THREAD
//this is exposed by the JIT, but it's not meant to be a supported API for now.
extern void mono_threads_attach_tools_thread (void);
static void*
helper_thread (void* arg)
{
@@ -2198,6 +2251,7 @@ helper_thread (void* arg)
MonoThread *thread = NULL;
uint64_t start, now;
mono_threads_attach_tools_thread ();
//fprintf (stderr, "Server listening\n");
start = current_time ();
command_socket = -1;
@@ -2255,9 +2309,11 @@ helper_thread (void* arg)
sbufbase->next->next = NULL;
if (do_debug)
fprintf (stderr, "stat buffer dump\n");
dump_sample_hits (prof, sbuf, 1);
free_buffer (sbuf, sbuf->size);
safe_dump (prof, ensure_logbuf (0));
if (sbuf) {
dump_sample_hits (prof, sbuf, 1);
free_buffer (sbuf, sbuf->size);
safe_dump (prof, ensure_logbuf (0));
}
continue;
}
/* time to shut down */
@@ -2692,6 +2748,14 @@ mono_profiler_startup (const char *desc)
do_debug = 1;
continue;
}
if ((opt = match_option (p, "sampling-real", NULL)) != p) {
sampling_mode = MONO_PROFILER_STAT_MODE_REAL;
continue;
}
if ((opt = match_option (p, "sampling-process", NULL)) != p) {
sampling_mode = MONO_PROFILER_STAT_MODE_PROCESS;
continue;
}
if ((opt = match_option (p, "heapshot", &val)) != p) {
events &= ~MONO_PROFILE_ALLOCATIONS;
events &= ~MONO_PROFILE_ENTER_LEAVE;
@@ -2781,6 +2845,7 @@ mono_profiler_startup (const char *desc)
if (do_mono_sample && sample_type == SAMPLE_CYCLES) {
events |= MONO_PROFILE_STATISTICAL;
mono_profiler_set_statistical_mode (sampling_mode, 1000000 / sample_freq);
mono_profiler_install_statistical (mono_sample_hit);
}
+1
View File
@@ -214,6 +214,7 @@ BASE_TEST_CS_SRC= \
array3.cs \
classinit.cs \
classinit2.cs \
classinit3.cs \
synchronized.cs \
async_read.cs \
threadpool.cs \
+35
View File
@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Threading;
namespace integer_test
{
class MainClass
{
// #23242
public static void Main (string[] args)
{
var _trigger = new ManualResetEvent (false);
var testThreads = new Thread[100];
for (Int16 i = 0; i < testThreads.Length; ++i)
{
testThreads [i] = new Thread ( () =>
{
_trigger.WaitOne();
for (Int16 index = 0; index < 1000; ++index)
{
var val = index.ToString();
GC.KeepAlive(val);
}
});
testThreads [i].Start ();
}
Console.WriteLine ("setting event");
_trigger.Set ();
foreach (var thread in testThreads)
{
thread.Join ();
}
}
}
}
+21 -1
View File
@@ -66,7 +66,15 @@ Requires the world to be stoped
MonoLinkedListSetNode *__cur; \
for (__cur = (list)->head; __cur; __cur = mono_lls_pointer_unmask (__cur->next)) \
if (!mono_lls_pointer_get_mark (__cur->next)) { \
(element) = (type)__cur; \
(element) = (type)__cur;
#define MONO_LLS_FOREACH_FILTERED(list, element, filter_func, type) {\
MonoLinkedListSetNode *__cur; \
for (__cur = (list)->head; __cur; __cur = mono_lls_pointer_unmask (__cur->next)) \
if (!mono_lls_pointer_get_mark (__cur->next)) { \
(element) = (type)__cur; \
if (!filter_func (element)) continue;
#define MONO_LLS_END_FOREACH }}
@@ -91,6 +99,18 @@ Provides snapshot iteration
if (!mono_lls_pointer_get_mark (__next)) { \
(element) = (type)__cur;
#define MONO_LLS_FOREACH_FILTERED_SAFE(list, element, filter_func, type) {\
MonoThreadHazardPointers *__hp = mono_hazard_pointer_get (); \
MonoLinkedListSetNode *__cur, *__next; \
for (__cur = mono_lls_pointer_unmask (get_hazardous_pointer ((gpointer volatile*)&(list)->head, __hp, 1)); \
__cur; \
__cur = mono_lls_info_step (__next, __hp)) { \
__next = get_hazardous_pointer_with_mask ((gpointer volatile*)&__cur->next, __hp, 0); \
if (!mono_lls_pointer_get_mark (__next)) { \
(element) = (type)__cur; \
if (!filter_func (element)) continue;
#define MONO_LLS_END_FOREACH_SAFE \
} \
} \
+1 -1
View File
@@ -645,7 +645,7 @@ mono_shared_area (void)
header->stats_start = sizeof (SAreaHeader);
header->stats_end = sizeof (SAreaHeader);
atexit (mono_shared_area_remove);
mono_atexit (mono_shared_area_remove);
return res;
}
+10
View File
@@ -664,3 +664,13 @@ mono_cpu_get_data (int cpu_id, MonoCpuData data, MonoProcessError *error)
return value;
}
int
mono_atexit (void (*func)(void))
{
#ifdef PLATFORM_ANDROID
/* Some versions of android libc doesn't define atexit () */
return 0;
#else
return atexit (func);
#endif
}
+2
View File
@@ -52,5 +52,7 @@ int mono_process_current_pid (void) MONO_INTERNAL;
int mono_cpu_count (void) MONO_INTERNAL;
gint64 mono_cpu_get_data (int cpu_id, MonoCpuData data, MonoProcessError *error) MONO_INTERNAL;
int mono_atexit (void (*func)(void)) MONO_INTERNAL;
#endif /* __MONO_PROC_LIB_H__ */
+1 -4
View File
@@ -19,9 +19,6 @@
#if defined(TARGET_X86)
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__APPLE__) || defined(__DragonFly__)
#include <ucontext.h>
#endif
#if defined(__APPLE__)
#include <AvailabilityMacros.h>
#endif
@@ -90,7 +87,7 @@
#define UCONTEXT_REG_EIP(ctx) (((ucontext_t*)(ctx))->uc_mcontext.gregs [EIP])
#else
#if defined(PLATFORM_ANDROID)
#if defined(PLATFORM_ANDROID) && !defined(HAVE_UCONTEXT_H)
/* No ucontext.h as of NDK v6b */
typedef int greg_t;
#define NGREG 19
+25 -21
View File
@@ -19,7 +19,11 @@
#include <errno.h>
#if defined(PLATFORM_ANDROID)
#if defined(PLATFORM_ANDROID) && !defined(TARGET_ARM64)
#define USE_TKILL_ON_ANDROID 1
#endif
#ifdef USE_TKILL_ON_ANDROID
extern int tkill (pid_t tid, int signal);
#endif
@@ -260,6 +264,26 @@ mono_threads_core_clear_interruption (void)
wapi_clear_interruption ();
}
int
mono_threads_pthread_kill (MonoThreadInfo *info, int signum)
{
#ifdef USE_TKILL_ON_ANDROID
int result, old_errno = errno;
result = tkill (info->native_handle, signum);
if (result < 0) {
result = errno;
errno = old_errno;
}
return result;
#elif defined(__native_client__)
/* Workaround pthread_kill abort() in NaCl glibc. */
return 0;
#else
return pthread_kill (mono_thread_info_get_tid (info), signum);
#endif
}
#if !defined (__MACH__)
#if !defined(__native_client__)
@@ -341,26 +365,6 @@ mono_threads_core_interrupt (MonoThreadInfo *info)
{
}
int
mono_threads_pthread_kill (MonoThreadInfo *info, int signum)
{
#if defined (PLATFORM_ANDROID)
int result, old_errno = errno;
result = tkill (info->native_handle, signum);
if (result < 0) {
result = errno;
errno = old_errno;
}
return result;
#elif defined(__native_client__)
/* Workaround pthread_kill abort() in NaCl glibc. */
return 0;
#else
return pthread_kill (mono_thread_info_get_tid (info), signum);
#endif
}
void
mono_threads_core_abort_syscall (MonoThreadInfo *info)
{
+50
View File
@@ -15,6 +15,7 @@
#include <mono/utils/hazard-pointer.h>
#include <mono/utils/mono-memory-model.h>
#include <mono/utils/mono-mmap.h>
#include <mono/utils/atomic.h>
#include <errno.h>
@@ -286,6 +287,31 @@ mono_thread_info_list_head (void)
return &thread_list;
}
/**
* mono_threads_attach_tools_thread
*
* Attach the current thread as a tool thread. DON'T USE THIS FUNCTION WITHOUT READING ALL DISCLAIMERS.
*
* A tools thread is a very special kind of thread that needs access to core runtime facilities but should
* not be counted as a regular thread for high order facilities such as executing managed code or accessing
* the managed heap.
*
* This is intended only to tools such as a profiler than needs to be able to use our lock-free support when
* doing things like resolving backtraces in their background processing thread.
*/
void
mono_threads_attach_tools_thread (void)
{
int dummy = 0;
MonoThreadInfo *info;
/* Must only be called once */
g_assert (!mono_native_tls_get_value (thread_info_key));
info = mono_thread_info_attach (&dummy);
info->tools_thread = TRUE;
}
MonoThreadInfo*
mono_thread_info_attach (void *baseptr)
{
@@ -909,3 +935,27 @@ mono_thread_info_clear_interruption (void)
{
mono_threads_core_clear_interruption ();
}
/* info must be self or be held in a hazard pointer. */
gboolean
mono_threads_add_async_job (MonoThreadInfo *info, MonoAsyncJob job)
{
MonoAsyncJob old_job;
do {
old_job = info->service_requests;
if (old_job & job)
return FALSE;
} while (InterlockedCompareExchange (&info->service_requests, old_job | job, old_job) != old_job);
return TRUE;
}
MonoAsyncJob
mono_threads_consume_async_jobs (void)
{
MonoThreadInfo *info = (MonoThreadInfo*)mono_native_tls_get_value (thread_info_key);
if (!info)
return 0;
return InterlockedExchange (&info->service_requests, 0);
}
+39 -4
View File
@@ -94,6 +94,13 @@ enum {
SUSPEND_STATE_MASK = 0xF0,
};
/*
* This enum tells which async thread service corresponds to which bit.
*/
typedef enum {
MONO_SERVICE_REQUEST_SAMPLE = 1,
} MonoAsyncJob;
#define mono_thread_info_run_state(info) (((MonoThreadInfo*)info)->thread_state & RUN_STATE_MASK)
#define mono_thread_info_suspend_state(info) (((MonoThreadInfo*)info)->thread_state & SUSPEND_STATE_MASK)
@@ -106,6 +113,9 @@ typedef struct {
/*Tells if this thread was created by the runtime or not.*/
gboolean runtime_thread;
/* Tells if this thread should be ignored or not by runtime services such as GC and profiling */
gboolean tools_thread;
/* suspend machinery, fields protected by suspend_semaphore */
MonoSemType suspend_semaphore;
int suspend_count;
@@ -155,6 +165,12 @@ typedef struct {
/* IO layer handle for this thread */
/* Set when the thread is started, or in _wapi_thread_duplicate () */
HANDLE handle;
/* Asynchronous service request. This flag is meant to be consumed by the multiplexing signal handlers to discover what sort of work they need to do.
* Use the mono_threads_add_async_job and mono_threads_consume_async_jobs APIs to modify this flag.
* In the future the signaling should be part of the API, but for now, it's only for massaging the bits.
*/
volatile gint32 service_requests;
} MonoThreadInfo;
typedef struct {
@@ -187,16 +203,22 @@ typedef struct {
gboolean (*thread_state_init_from_handle) (MonoThreadUnwindState *tctx, MonoThreadInfo *info);
} MonoThreadInfoRuntimeCallbacks;
static inline gboolean
mono_threads_filter_tools_threads (THREAD_INFO_TYPE *info)
{
return !((MonoThreadInfo*)info)->tools_thread;
}
/*
Requires the world to be stoped
*/
#define FOREACH_THREAD(thread) MONO_LLS_FOREACH (mono_thread_info_list_head (), thread, THREAD_INFO_TYPE*)
#define FOREACH_THREAD(thread) MONO_LLS_FOREACH_FILTERED (mono_thread_info_list_head (), thread, mono_threads_filter_tools_threads, THREAD_INFO_TYPE*)
#define END_FOREACH_THREAD MONO_LLS_END_FOREACH
/*
Snapshot iteration.
*/
#define FOREACH_THREAD_SAFE(thread) MONO_LLS_FOREACH_SAFE (mono_thread_info_list_head (), thread, THREAD_INFO_TYPE*)
#define FOREACH_THREAD_SAFE(thread) MONO_LLS_FOREACH_FILTERED_SAFE (mono_thread_info_list_head (), thread, mono_threads_filter_tools_threads, THREAD_INFO_TYPE*)
#define END_FOREACH_THREAD_SAFE MONO_LLS_END_FOREACH_SAFE
#define mono_thread_info_get_tid(info) ((MonoNativeThreadId)((MonoThreadInfo*)info)->node.key)
@@ -326,13 +348,26 @@ mono_threads_get_max_stack_size (void) MONO_INTERNAL;
HANDLE
mono_threads_open_thread_handle (HANDLE handle, MonoNativeThreadId tid) MONO_INTERNAL;
/*
This is the async job submission/consumption API.
XXX: This is a PROVISIONAL API only meant to be used by the statistical profiler.
If you want to use/extend it anywhere else, understand that you'll have to do some API design work to better fit this puppy.
*/
gboolean
mono_threads_add_async_job (THREAD_INFO_TYPE *info, MonoAsyncJob job) MONO_INTERNAL;
MonoAsyncJob
mono_threads_consume_async_jobs (void) MONO_INTERNAL;
void
mono_threads_attach_tools_thread (void);
#if !defined(HOST_WIN32)
#if !defined(__MACH__)
/*Use this instead of pthread_kill */
int
mono_threads_pthread_kill (THREAD_INFO_TYPE *info, int signum) MONO_INTERNAL;
#endif
#endif /* !defined(HOST_WIN32) */