mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-16 11:21:08 -10:00
Compare commits
61
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1887074366 | ||
|
|
a901ec0ba3 | ||
|
|
aca7cfd994 | ||
|
|
7bf7bc69a5 | ||
|
|
b2269514e9 | ||
|
|
88950e72bb | ||
|
|
049023723d | ||
|
|
3245d4bab4 | ||
|
|
2121f55593 | ||
|
|
924483c9d6 | ||
|
|
5b9ec05150 | ||
|
|
aa81a7132b | ||
|
|
1f46d47c3a | ||
|
|
8f828ff4ac | ||
|
|
6544cc7f15 | ||
|
|
67ef18be7d | ||
|
|
92be1aebdb | ||
|
|
7138ab117f | ||
|
|
09d18d4f47 | ||
|
|
75b30d0fd9 | ||
|
|
b813e56737 | ||
|
|
117302400a | ||
|
|
399facb8ca | ||
|
|
2311da7b9a | ||
|
|
5b3813b1d2 | ||
|
|
2e5167402b | ||
|
|
bf54221823 | ||
|
|
f9afcf06b9 | ||
|
|
d955217874 | ||
|
|
d457bae593 | ||
|
|
6e152a16a1 | ||
|
|
a824dad5f6 | ||
|
|
55fcfb81be | ||
|
|
f8691c441b | ||
|
|
2f569721a7 | ||
|
|
f07e7d0850 | ||
|
|
a9a6e86072 | ||
|
|
219bd64946 | ||
|
|
255a8971e5 | ||
|
|
91a4a3d504 | ||
|
|
6d5c45d559 | ||
|
|
5e1afc4533 | ||
|
|
e7da99bb17 | ||
|
|
e9e611d501 | ||
|
|
cefe30a5cc | ||
|
|
928436efc6 | ||
|
|
838ec2fb6f | ||
|
|
45d8971caa | ||
|
|
cf53f2aab3 | ||
|
|
f2c520372f | ||
|
|
3bc58c925b | ||
|
|
3790413f38 | ||
|
|
ef4965a6dd | ||
|
|
7cb75c8355 | ||
|
|
90a83b65df | ||
|
|
96a5c1247e | ||
|
|
b5a5402beb | ||
|
|
9d2eec1131 | ||
|
|
a825298e9d | ||
|
|
e11a0b175d | ||
|
|
2f5ddd0210 |
No files matched your search
+1
-1
@@ -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
@@ -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)
|
||||
|
||||
|
||||
@@ -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
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 ");
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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__ */
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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__ */
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
@@ -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]]));
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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[] = {
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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
@@ -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));
|
||||
|
||||
|
||||
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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;
|
||||
|
||||
@@ -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
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -214,6 +214,7 @@ BASE_TEST_CS_SRC= \
|
||||
array3.cs \
|
||||
classinit.cs \
|
||||
classinit2.cs \
|
||||
classinit3.cs \
|
||||
synchronized.cs \
|
||||
async_read.cs \
|
||||
threadpool.cs \
|
||||
|
||||
@@ -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 ();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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 \
|
||||
} \
|
||||
} \
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
@@ -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__ */
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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) */
|
||||
|
||||
|
||||
Reference in new issue
Block a user