mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-17 11:21:39 -10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9435de91f2 | ||
|
|
1281853553 | ||
|
|
6922ed8629 | ||
|
|
cd3c79413a | ||
|
|
bc36fbe193 | ||
|
|
53d8062782 | ||
|
|
44983be8f2 | ||
|
|
015444e23d | ||
|
|
f4433694ac | ||
|
|
a02076baf6 | ||
|
|
0a3a379ee0 | ||
|
|
fbbe941b69 | ||
|
|
61963ca6b1 | ||
|
|
50cc972397 | ||
|
|
340361ff91 | ||
|
|
de6a0113fb | ||
|
|
636f9ec0b9 | ||
|
|
e5e8c141c5 | ||
|
|
764f9cbd32 | ||
|
|
a96b9dd614 | ||
|
|
b4c110c021 |
No files matched your search
+1
-1
@@ -6,7 +6,7 @@ AC_CANONICAL_SYSTEM
|
||||
m4_ifdef([_A][M_PROG_TAR],[_A][M_SET_OPTION([tar-ustar])])
|
||||
|
||||
AM_CONFIG_HEADER(config.h)
|
||||
AM_INIT_AUTOMAKE(mono,2.10.7)
|
||||
AM_INIT_AUTOMAKE(mono,2.10.9)
|
||||
AM_MAINTAINER_MODE
|
||||
|
||||
API_VER=2.0
|
||||
|
||||
@@ -409,6 +409,7 @@ namespace System.Web.Services.Protocols
|
||||
InvokeAsyncInfo info = (InvokeAsyncInfo) ar.AsyncState;
|
||||
SoapWebClientAsyncResult sar = (SoapWebClientAsyncResult) ar;
|
||||
InvokeCompletedEventArgs args = new InvokeCompletedEventArgs (sar.Exception, false, info.UserState, (object[]) sar.Result);
|
||||
UnregisterMapping (ar.AsyncState);
|
||||
if (info.Context != null)
|
||||
info.Context.Send (info.Callback, args);
|
||||
else
|
||||
|
||||
@@ -469,7 +469,7 @@ namespace System.Net.NetworkInformation {
|
||||
MacOsStructs.sockaddr_dl sockaddrdl = (MacOsStructs.sockaddr_dl) Marshal.PtrToStructure (addr.ifa_addr, typeof (MacOsStructs.sockaddr_dl));
|
||||
|
||||
macAddress = new byte [(int) sockaddrdl.sdl_alen];
|
||||
Array.Copy (sockaddrdl.sdl_data, sockaddrdl.sdl_alen, macAddress, 0, Math.Min (macAddress.Length, sockaddrdl.sdl_data.Length - sockaddrdl.sdl_alen));
|
||||
Array.Copy (sockaddrdl.sdl_data, sockaddrdl.sdl_nlen, macAddress, 0, Math.Min (macAddress.Length, sockaddrdl.sdl_data.Length - macAddress.Length));
|
||||
index = sockaddrdl.sdl_index;
|
||||
|
||||
int hwtype = (int) sockaddrdl.sdl_type;
|
||||
|
||||
@@ -467,6 +467,8 @@ namespace System.Collections.Generic {
|
||||
|
||||
public int LastIndexOf (T item)
|
||||
{
|
||||
if (_size == 0)
|
||||
return -1;
|
||||
return Array.LastIndexOf<T> (_items, item, _size - 1, _size);
|
||||
}
|
||||
|
||||
|
||||
@@ -1307,6 +1307,12 @@ namespace MonoTests.System.Collections.Generic {
|
||||
Assert.IsTrue (e is ArgumentException, "#10");
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void LastIndexOfEmpty_2558 () {
|
||||
var l = new List<int> ();
|
||||
Assert.AreEqual (-1, l.IndexOf (-1));
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
// CS0121: The call is ambiguous between the following methods or properties: `C.C(double[], int, object)' and `C.C(double[], int, string[])'
|
||||
// Line: 16
|
||||
|
||||
class C
|
||||
{
|
||||
C (double[] o, int i = -1, object ii = null)
|
||||
{
|
||||
}
|
||||
|
||||
C (double[] o, int i = -1, string[] s = null)
|
||||
{
|
||||
}
|
||||
|
||||
public static void Main ()
|
||||
{
|
||||
new C (null, 1);
|
||||
}
|
||||
}
|
||||
+4
-1
@@ -4100,7 +4100,10 @@ namespace Mono.CSharp {
|
||||
|
||||
var ac_p = p as ArrayContainer;
|
||||
if (ac_p != null) {
|
||||
var ac_q = ((ArrayContainer) q);
|
||||
var ac_q = q as ArrayContainer;
|
||||
if (ac_q == null)
|
||||
return null;
|
||||
|
||||
TypeSpec specific = MoreSpecific (ac_p.Element, ac_q.Element);
|
||||
if (specific == ac_p.Element)
|
||||
return p;
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include <mono/utils/mono-logger-internal.h>
|
||||
#include <mono/utils/mono-membar.h>
|
||||
#include <mono/utils/mono-counters.h>
|
||||
#include <mono/utils/mono-tls.h>
|
||||
#include <mono/metadata/object.h>
|
||||
#include <mono/metadata/object-internals.h>
|
||||
#include <mono/metadata/domain-internals.h>
|
||||
@@ -44,7 +45,7 @@
|
||||
* or the other (we used to do it because tls slots were GC-tracked,
|
||||
* but we can't depend on this).
|
||||
*/
|
||||
static guint32 appdomain_thread_id = -1;
|
||||
static MonoNativeTlsKey appdomain_thread_id;
|
||||
|
||||
/*
|
||||
* Avoid calling TlsSetValue () if possible, since in the io-layer, it acquires
|
||||
@@ -67,14 +68,14 @@ static __thread MonoDomain * tls_appdomain MONO_TLS_FAST;
|
||||
#else
|
||||
#define SET_APPDOMAIN(x) do { \
|
||||
tls_appdomain = x; \
|
||||
TlsSetValue (appdomain_thread_id, x); \
|
||||
mono_native_tls_set_value (appdomain_thread_id, x); \
|
||||
} while (FALSE)
|
||||
#endif
|
||||
|
||||
#else /* !HAVE_KW_THREAD */
|
||||
|
||||
#define GET_APPDOMAIN() ((MonoDomain *)TlsGetValue (appdomain_thread_id))
|
||||
#define SET_APPDOMAIN(x) TlsSetValue (appdomain_thread_id, x);
|
||||
#define GET_APPDOMAIN() ((MonoDomain *)mono_native_tls_get_value (appdomain_thread_id))
|
||||
#define SET_APPDOMAIN(x) mono_native_tls_set_value (appdomain_thread_id, x);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -157,8 +158,8 @@ get_runtime_by_version (const char *version);
|
||||
static MonoImage*
|
||||
mono_jit_info_find_aot_module (guint8* addr);
|
||||
|
||||
guint32
|
||||
mono_domain_get_tls_key (void)
|
||||
MonoNativeTlsKey
|
||||
mono_domain_get_native_tls_key (void)
|
||||
{
|
||||
return appdomain_thread_id;
|
||||
}
|
||||
@@ -1301,7 +1302,7 @@ mono_init_internal (const char *filename, const char *exe_filename, const char *
|
||||
|
||||
mono_gc_base_init ();
|
||||
|
||||
appdomain_thread_id = TlsAlloc ();
|
||||
mono_native_tls_alloc (&appdomain_thread_id, NULL);
|
||||
|
||||
InitializeCriticalSection (&appdomains_mutex);
|
||||
|
||||
@@ -1766,7 +1767,7 @@ mono_cleanup (void)
|
||||
mono_debug_cleanup ();
|
||||
mono_metadata_cleanup ();
|
||||
|
||||
TlsFree (appdomain_thread_id);
|
||||
mono_native_tls_free (appdomain_thread_id);
|
||||
DeleteCriticalSection (&appdomains_mutex);
|
||||
|
||||
/*
|
||||
|
||||
@@ -6057,8 +6057,19 @@ ves_icall_System_CurrentSystemTimeZone_GetTimeZoneData (guint32 year, MonoArray
|
||||
mono_array_set ((*data), gint64, 1, ((gint64)t1 + EPOCH_ADJUST) * 10000000L);
|
||||
return 1;
|
||||
} else {
|
||||
struct tm end;
|
||||
time_t te;
|
||||
|
||||
memset (&end, 0, sizeof (end));
|
||||
end.tm_year = year-1900 + 1;
|
||||
end.tm_mday = 1;
|
||||
|
||||
te = mktime (&end);
|
||||
|
||||
mono_array_setref ((*names), 1, mono_string_new (domain, tzone));
|
||||
mono_array_set ((*data), gint64, 0, ((gint64)t1 + EPOCH_ADJUST) * 10000000L);
|
||||
mono_array_setref ((*names), 0, mono_string_new (domain, tzone));
|
||||
mono_array_set ((*data), gint64, 1, ((gint64)te + EPOCH_ADJUST) * 10000000L);
|
||||
is_daylight = 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <mono/io-layer/io-layer.h>
|
||||
#include "mono/utils/mono-compiler.h"
|
||||
#include "mono/utils/mono-error.h"
|
||||
#include "mono/utils/mono-tls.h"
|
||||
|
||||
/*
|
||||
* We should find a better place for this stuff. We can't put it in mono-compiler.h,
|
||||
@@ -652,14 +653,14 @@ mono_type_initialization_cleanup (void) MONO_INTERNAL;
|
||||
int
|
||||
mono_thread_kill (MonoInternalThread *thread, int signal) MONO_INTERNAL;
|
||||
|
||||
guint32
|
||||
mono_thread_get_tls_key (void) MONO_INTERNAL;
|
||||
MonoNativeTlsKey
|
||||
mono_thread_get_native_tls_key (void) MONO_INTERNAL;
|
||||
|
||||
gint32
|
||||
mono_thread_get_tls_offset (void) MONO_INTERNAL;
|
||||
|
||||
guint32
|
||||
mono_domain_get_tls_key (void) MONO_INTERNAL;
|
||||
MonoNativeTlsKey
|
||||
mono_domain_get_native_tls_key (void) MONO_INTERNAL;
|
||||
|
||||
gint32
|
||||
mono_domain_get_tls_offset (void) MONO_INTERNAL;
|
||||
|
||||
+44
-31
@@ -56,6 +56,8 @@ typedef struct {
|
||||
#define DYN_ARRAY_REF(da,i) ((void*)((da)->data + (i) * (da)->elem_size))
|
||||
#define DYN_ARRAY_PTR_REF(da,i) (((void**)(da)->data) [(i)])
|
||||
#define DYN_ARRAY_INT_REF(da,i) (((int*)(da)->data) [(i)])
|
||||
#define DYN_ARRAY_PTR_STATIC_INITIALIZER { 0, sizeof (void*), 0, NULL }
|
||||
#define DYN_ARRAY_INT_STATIC_INITIALIZER { 0, sizeof (int), 0, NULL }
|
||||
|
||||
static void
|
||||
dyn_array_init (DynArray *da, int elem_size)
|
||||
@@ -168,16 +170,6 @@ dyn_array_int_contains (DynArray *da, int x)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
dyn_array_append (DynArray *dst, DynArray *src)
|
||||
{
|
||||
g_assert (dst->elem_size == src->elem_size);
|
||||
|
||||
dyn_array_ensure_capacity (dst, dst->size + src->size);
|
||||
memcpy (DYN_ARRAY_REF (dst, dst->size), DYN_ARRAY_REF (src, 0), src->size * src->elem_size);
|
||||
dst->size += src->size;
|
||||
}
|
||||
|
||||
static DynArray merge_array;
|
||||
|
||||
static void
|
||||
@@ -352,13 +344,18 @@ lookup_hash_entry (MonoObject *obj)
|
||||
}
|
||||
|
||||
static HashEntry*
|
||||
get_hash_entry (MonoObject *obj)
|
||||
get_hash_entry (MonoObject *obj, gboolean *existing)
|
||||
{
|
||||
HashEntry *entry = lookup_hash_entry (obj);
|
||||
int hash;
|
||||
|
||||
if (entry)
|
||||
if (entry) {
|
||||
if (existing)
|
||||
*existing = TRUE;
|
||||
return entry;
|
||||
}
|
||||
if (existing)
|
||||
*existing = FALSE;
|
||||
|
||||
entry = mono_sgen_alloc_internal_dynamic (sizeof (HashEntry), INTERNAL_MEM_BRIDGE_DATA);
|
||||
memset (entry, 0, sizeof (HashEntry));
|
||||
@@ -419,12 +416,13 @@ free_data (void)
|
||||
//g_print ("total srcs %d - max %d\n", total_srcs, max_srcs);
|
||||
}
|
||||
|
||||
static void
|
||||
static gboolean
|
||||
register_bridge_object (MonoObject *obj)
|
||||
{
|
||||
HashEntry *entry = get_hash_entry (obj);
|
||||
g_assert (!entry->is_bridge);
|
||||
gboolean existing;
|
||||
HashEntry *entry = get_hash_entry (obj, &existing);
|
||||
entry->is_bridge = TRUE;
|
||||
return !existing;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -448,6 +446,7 @@ object_is_live (MonoObject **objp)
|
||||
return lookup_hash_entry (obj) == NULL;
|
||||
}
|
||||
|
||||
static DynArray registered_bridges = DYN_ARRAY_PTR_STATIC_INITIALIZER;
|
||||
static DynArray dfs_stack;
|
||||
|
||||
static int dsf1_passes, dsf2_passes;
|
||||
@@ -458,7 +457,7 @@ static int dsf1_passes, dsf2_passes;
|
||||
MonoObject *dst = (MonoObject*)*(ptr); \
|
||||
if (dst && !object_is_live (&dst)) { \
|
||||
dyn_array_ptr_push (&dfs_stack, obj_entry); \
|
||||
dyn_array_ptr_push (&dfs_stack, get_hash_entry (dst)); \
|
||||
dyn_array_ptr_push (&dfs_stack, get_hash_entry (dst, NULL)); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
@@ -583,7 +582,7 @@ static int fist_pass_links, second_pass_links, sccs_links;
|
||||
static int max_sccs_links = 0;
|
||||
|
||||
void
|
||||
mono_sgen_bridge_processing_start (int num_objs, MonoObject **objs)
|
||||
mono_sgen_bridge_processing_register_objects (int num_objs, MonoObject **objs)
|
||||
{
|
||||
int j = 0;
|
||||
int i;
|
||||
@@ -598,22 +597,28 @@ mono_sgen_bridge_processing_start (int num_objs, MonoObject **objs)
|
||||
|
||||
//g_print ("%d finalized objects\n", num_objs);
|
||||
|
||||
/* remove objects that are not bridge objects */
|
||||
|
||||
/* The collector step checks for bridge objects already, so we don't need to do it again. */
|
||||
for (i = 0; i < num_objs; ++i) {
|
||||
MonoObject *obj = objs [i];
|
||||
//g_assert (!mono_sgen_object_is_live (obj));
|
||||
if (bridge_callbacks.is_bridge_object (obj)) {
|
||||
register_bridge_object (obj);
|
||||
objs [j++] = obj;
|
||||
}
|
||||
if (register_bridge_object (obj))
|
||||
dyn_array_ptr_push (®istered_bridges, obj);
|
||||
}
|
||||
num_objs = j;
|
||||
|
||||
SGEN_TV_GETTIME (btv);
|
||||
step_1 = SGEN_TV_ELAPSED (atv, btv);
|
||||
step_1 += SGEN_TV_ELAPSED (atv, btv);
|
||||
}
|
||||
|
||||
//g_print ("%d bridge objects\n", num_objs);
|
||||
void
|
||||
mono_sgen_bridge_processing_stw_step (void)
|
||||
{
|
||||
int i;
|
||||
SGEN_TV_DECLARE (atv);
|
||||
SGEN_TV_DECLARE (btv);
|
||||
|
||||
if (!registered_bridges.size)
|
||||
return;
|
||||
|
||||
SGEN_TV_GETTIME (btv);
|
||||
|
||||
/* first DFS pass */
|
||||
|
||||
@@ -621,15 +626,15 @@ mono_sgen_bridge_processing_start (int num_objs, MonoObject **objs)
|
||||
dyn_array_int_init (&merge_array);
|
||||
|
||||
current_time = 0;
|
||||
for (i = 0; i < num_objs; ++i)
|
||||
dfs1 (get_hash_entry (objs [i]), NULL);
|
||||
for (i = 0; i < registered_bridges.size; ++i)
|
||||
dfs1 (get_hash_entry (DYN_ARRAY_PTR_REF (®istered_bridges, i), NULL), NULL);
|
||||
|
||||
SGEN_TV_GETTIME (atv);
|
||||
step_2 = SGEN_TV_ELAPSED (btv, atv);
|
||||
}
|
||||
|
||||
void
|
||||
mono_sgen_bridge_processing_finish (int num_objs, MonoObject **objs)
|
||||
mono_sgen_bridge_processing_finish (void)
|
||||
{
|
||||
int i, j;
|
||||
int num_sccs, num_xrefs;
|
||||
@@ -637,12 +642,16 @@ mono_sgen_bridge_processing_finish (int num_objs, MonoObject **objs)
|
||||
int hash_table_size, sccs_size;
|
||||
MonoObject *obj;
|
||||
HashEntry *entry;
|
||||
int num_registered_bridges;
|
||||
HashEntry **all_entries;
|
||||
MonoGCBridgeSCC **api_sccs;
|
||||
MonoGCBridgeXRef *api_xrefs;
|
||||
SGEN_TV_DECLARE (atv);
|
||||
SGEN_TV_DECLARE (btv);
|
||||
|
||||
if (!registered_bridges.size)
|
||||
return;
|
||||
|
||||
SGEN_TV_GETTIME (atv);
|
||||
|
||||
/* alloc and fill array of all entries */
|
||||
@@ -785,6 +794,9 @@ mono_sgen_bridge_processing_finish (int num_objs, MonoObject **objs)
|
||||
mono_sgen_free_internal_dynamic (all_entries, sizeof (HashEntry*) * num_hash_entries, INTERNAL_MEM_BRIDGE_DATA);
|
||||
|
||||
free_data ();
|
||||
/* Empty the registered bridges array */
|
||||
num_registered_bridges = registered_bridges.size;
|
||||
registered_bridges.size = 0;
|
||||
|
||||
SGEN_TV_GETTIME (atv);
|
||||
step_6 = SGEN_TV_ELAPSED (btv, atv);
|
||||
@@ -821,7 +833,7 @@ mono_sgen_bridge_processing_finish (int num_objs, MonoObject **objs)
|
||||
step_8 = SGEN_TV_ELAPSED (btv, atv);
|
||||
|
||||
mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_GC, "GC_BRIDGE num-objects %d num_hash_entries %d sccs size %d init %.2fms df1 %.2fms sort %.2fms dfs2 %.2fms setup-cb %.2fms free-data %.2fms user-cb %.2fms clenanup %.2fms links %d/%d/%d/%d dfs passes %d/%d",
|
||||
num_objs, hash_table_size, sccs.size,
|
||||
num_registered_bridges, hash_table_size, sccs.size,
|
||||
step_1 / 1000.0f,
|
||||
step_2 / 1000.0f,
|
||||
step_3 / 1000.0f,
|
||||
@@ -833,6 +845,7 @@ mono_sgen_bridge_processing_finish (int num_objs, MonoObject **objs)
|
||||
fist_pass_links, second_pass_links, sccs_links, max_sccs_links,
|
||||
dsf1_passes, dsf2_passes);
|
||||
|
||||
step_1 = 0; /* We must cleanup since this value is used as an accumulator. */
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
||||
+12
-9
@@ -2500,16 +2500,16 @@ bridge_register_finalized_object (MonoObject *object)
|
||||
finalized_array [finalized_array_entries++] = object;
|
||||
}
|
||||
|
||||
static void
|
||||
stw_bridge_process (void)
|
||||
{
|
||||
mono_sgen_bridge_processing_stw_step ();
|
||||
}
|
||||
|
||||
static void
|
||||
bridge_process (void)
|
||||
{
|
||||
if (finalized_array_entries <= 0)
|
||||
return;
|
||||
|
||||
g_assert (mono_sgen_need_bridge_processing ());
|
||||
mono_sgen_bridge_processing_finish (finalized_array_entries, finalized_array);
|
||||
|
||||
finalized_array_entries = 0;
|
||||
mono_sgen_bridge_processing_finish ();
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -2566,8 +2566,10 @@ finish_gray_stack (char *start_addr, char *end_addr, int generation, GrayQueue *
|
||||
if (generation == GENERATION_OLD)
|
||||
collect_bridge_objects (copy_func, nursery_start, nursery_real_end, GENERATION_NURSERY, queue);
|
||||
|
||||
if (finalized_array_entries > 0)
|
||||
mono_sgen_bridge_processing_start (finalized_array_entries, finalized_array);
|
||||
if (finalized_array_entries > 0) {
|
||||
mono_sgen_bridge_processing_register_objects (finalized_array_entries, finalized_array);
|
||||
finalized_array_entries = 0;
|
||||
}
|
||||
drain_gray_stack (queue);
|
||||
}
|
||||
|
||||
@@ -5409,6 +5411,7 @@ restart_world (int generation)
|
||||
}
|
||||
}
|
||||
|
||||
stw_bridge_process ();
|
||||
release_gc_locks ();
|
||||
|
||||
count = mono_sgen_thread_handshake (restart_signal_num);
|
||||
|
||||
@@ -803,8 +803,10 @@ const char* mono_sgen_safe_name (void* obj) MONO_INTERNAL;
|
||||
gboolean mono_sgen_object_is_live (void *obj) MONO_INTERNAL;
|
||||
|
||||
gboolean mono_sgen_need_bridge_processing (void) MONO_INTERNAL;
|
||||
void mono_sgen_bridge_processing_start (int num_objs, MonoObject **objs) MONO_INTERNAL;
|
||||
void mono_sgen_bridge_processing_finish (int num_objs, MonoObject **objs) MONO_INTERNAL;
|
||||
void mono_sgen_bridge_processing_register_objects (int num_objs, MonoObject **objs) MONO_INTERNAL;
|
||||
void mono_sgen_bridge_processing_stw_step (void) MONO_INTERNAL;
|
||||
void mono_sgen_bridge_processing_finish (void) MONO_INTERNAL;
|
||||
void mono_sgen_register_test_bridge_callbacks (void) MONO_INTERNAL;
|
||||
gboolean mono_sgen_is_bridge_object (MonoObject *obj) MONO_INTERNAL;
|
||||
void mono_sgen_mark_bridge_object (MonoObject *obj) MONO_INTERNAL;
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ mono_sgen_suspend_thread (SgenThreadInfo *info)
|
||||
mono_mach_arch_thread_state_to_mcontext (state, mctx);
|
||||
ctx.uc_mcontext = mctx;
|
||||
|
||||
info->stopped_domain = mono_mach_arch_get_tls_value_from_thread ((pthread_t)info->id, mono_pthread_key_for_tls (mono_domain_get_tls_key ()));
|
||||
info->stopped_domain = mono_mach_arch_get_tls_value_from_thread ((pthread_t)info->id, mono_domain_get_native_tls_key ());
|
||||
info->stopped_ip = (gpointer) mono_mach_arch_get_ip (state);
|
||||
stack_start = (char*) mono_mach_arch_get_sp (state) - REDZONE_SIZE;
|
||||
/* If stack_start is not within the limits, then don't set it in info and we will be restarted. */
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
#include <mono/utils/mono-mmap.h>
|
||||
#include <mono/utils/mono-membar.h>
|
||||
#include <mono/utils/mono-time.h>
|
||||
#include <mono/utils/mono-tls.h>
|
||||
|
||||
#include <mono/metadata/gc-internal.h>
|
||||
|
||||
@@ -151,7 +152,7 @@ static MonoGHashTable *threads_starting_up = NULL;
|
||||
static MonoGHashTable *thread_start_args = NULL;
|
||||
|
||||
/* The TLS key that holds the MonoObject assigned to each thread */
|
||||
static guint32 current_object_key = -1;
|
||||
static MonoNativeTlsKey current_object_key;
|
||||
|
||||
#ifdef HAVE_KW_THREAD
|
||||
/* we need to use both the Tls* functions and __thread because
|
||||
@@ -160,12 +161,12 @@ static guint32 current_object_key = -1;
|
||||
static __thread MonoInternalThread * tls_current_object MONO_TLS_FAST;
|
||||
#define SET_CURRENT_OBJECT(x) do { \
|
||||
tls_current_object = x; \
|
||||
TlsSetValue (current_object_key, x); \
|
||||
mono_native_tls_set_value (current_object_key, x); \
|
||||
} while (FALSE)
|
||||
#define GET_CURRENT_OBJECT() tls_current_object
|
||||
#else
|
||||
#define SET_CURRENT_OBJECT(x) TlsSetValue (current_object_key, x)
|
||||
#define GET_CURRENT_OBJECT() (MonoThread*) TlsGetValue (current_object_key)
|
||||
#define SET_CURRENT_OBJECT(x) mono_native_tls_set_value (current_object_key, x)
|
||||
#define GET_CURRENT_OBJECT() (MonoThread*) mono_native_tls_get_value (current_object_key)
|
||||
#endif
|
||||
|
||||
/* function called at thread start */
|
||||
@@ -237,8 +238,8 @@ get_next_managed_thread_id (void)
|
||||
return InterlockedIncrement (&managed_thread_id_counter);
|
||||
}
|
||||
|
||||
guint32
|
||||
mono_thread_get_tls_key (void)
|
||||
MonoNativeTlsKey
|
||||
mono_thread_get_native_tls_key (void)
|
||||
{
|
||||
return current_object_key;
|
||||
}
|
||||
@@ -2649,7 +2650,7 @@ void mono_thread_init (MonoThreadStartCB start_cb,
|
||||
mono_init_static_data_info (&thread_static_info);
|
||||
mono_init_static_data_info (&context_static_info);
|
||||
|
||||
current_object_key=TlsAlloc();
|
||||
mono_native_tls_alloc (¤t_object_key, NULL);
|
||||
THREAD_DEBUG (g_message ("%s: Allocated current_object_key %d", __func__, current_object_key));
|
||||
|
||||
mono_thread_start_cb = start_cb;
|
||||
@@ -2699,7 +2700,7 @@ void mono_thread_cleanup (void)
|
||||
g_array_free (delayed_free_table, TRUE);
|
||||
delayed_free_table = NULL;
|
||||
|
||||
TlsFree (current_object_key);
|
||||
mono_native_tls_free (current_object_key);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -7921,7 +7921,7 @@ mono_arch_setup_jit_tls_data (MonoJitTlsData *tls)
|
||||
* We need to init this multiple times, since when we are first called, the key might not
|
||||
* be initialized yet.
|
||||
*/
|
||||
appdomain_tls_offset = mono_domain_get_tls_key ();
|
||||
appdomain_tls_offset = mono_domain_get_native_tls_key ();
|
||||
lmf_tls_offset = mono_get_jit_tls_key ();
|
||||
lmf_addr_tls_offset = mono_get_jit_tls_key ();
|
||||
|
||||
|
||||
@@ -226,7 +226,7 @@ mono_runtime_syscall_fork ()
|
||||
return (pid_t) fork ();
|
||||
}
|
||||
|
||||
gboolean
|
||||
void
|
||||
mono_gdb_render_native_backtraces (pid_t crashed_pid)
|
||||
{
|
||||
const char *argv [5];
|
||||
@@ -234,7 +234,7 @@ mono_gdb_render_native_backtraces (pid_t crashed_pid)
|
||||
|
||||
argv [0] = g_find_program_in_path ("gdb");
|
||||
if (argv [0] == NULL) {
|
||||
return FALSE;
|
||||
return;
|
||||
}
|
||||
|
||||
if (mkstemp (gdb_template) != -1) {
|
||||
@@ -256,6 +256,4 @@ mono_gdb_render_native_backtraces (pid_t crashed_pid)
|
||||
|
||||
unlink (gdb_template);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -2170,16 +2170,10 @@ mono_handle_native_sigsegv (int signal, void *ctx)
|
||||
#if !defined(HOST_WIN32) && defined(HAVE_SYS_SYSCALL_H) && defined(SYS_fork)
|
||||
if (!mini_get_debug_options ()->no_gdb_backtrace && !mono_debug_using_mono_debugger ()) {
|
||||
/* From g_spawn_command_line_sync () in eglib */
|
||||
int res;
|
||||
int stdout_pipe [2] = { -1, -1 };
|
||||
pid_t pid;
|
||||
int status;
|
||||
char buffer [1024];
|
||||
pid_t crashed_pid = getpid ();
|
||||
|
||||
res = pipe (stdout_pipe);
|
||||
g_assert (res != -1);
|
||||
|
||||
//pid = fork ();
|
||||
/*
|
||||
* glibc fork acquires some locks, so if the crash happened inside malloc/free,
|
||||
@@ -2188,31 +2182,14 @@ mono_handle_native_sigsegv (int signal, void *ctx)
|
||||
pid = mono_runtime_syscall_fork ();
|
||||
|
||||
if (pid == 0) {
|
||||
close (stdout_pipe [0]);
|
||||
dup2 (stdout_pipe [1], STDOUT_FILENO);
|
||||
|
||||
for (i = getdtablesize () - 1; i >= 3; i--)
|
||||
close (i);
|
||||
|
||||
if (!mono_gdb_render_native_backtraces (crashed_pid))
|
||||
close (STDOUT_FILENO);
|
||||
dup2 (STDERR_FILENO, STDOUT_FILENO);
|
||||
|
||||
mono_gdb_render_native_backtraces (crashed_pid);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
close (stdout_pipe [1]);
|
||||
|
||||
fprintf (stderr, "\nDebug info from gdb:\n\n");
|
||||
|
||||
while (1) {
|
||||
int nread = read (stdout_pipe [0], buffer, 1024);
|
||||
|
||||
if (nread <= 0)
|
||||
break;
|
||||
write (STDERR_FILENO, buffer, nread);
|
||||
}
|
||||
|
||||
waitpid (pid, &status, WNOHANG);
|
||||
waitpid (pid, &status, 0);
|
||||
}
|
||||
#endif
|
||||
/*
|
||||
|
||||
+5
-13
@@ -5448,12 +5448,9 @@ setup_tls_access (void)
|
||||
#endif
|
||||
}
|
||||
if (monodomain_key == -1) {
|
||||
ptk = mono_domain_get_tls_key ();
|
||||
ptk = mono_domain_get_native_tls_key ();
|
||||
if (ptk < 1024) {
|
||||
ptk = mono_pthread_key_for_tls (ptk);
|
||||
if (ptk < 1024) {
|
||||
monodomain_key = ptk;
|
||||
}
|
||||
monodomain_key = ptk;
|
||||
}
|
||||
}
|
||||
if (lmf_pthread_key == -1) {
|
||||
@@ -5468,15 +5465,10 @@ setup_tls_access (void)
|
||||
}
|
||||
}
|
||||
if (monothread_key == -1) {
|
||||
ptk = mono_thread_get_tls_key ();
|
||||
ptk = mono_thread_get_native_tls_key ();
|
||||
if (ptk < 1024) {
|
||||
ptk = mono_pthread_key_for_tls (ptk);
|
||||
if (ptk < 1024) {
|
||||
monothread_key = ptk;
|
||||
/*g_print ("thread inited: %d\n", ptk);*/
|
||||
}
|
||||
} else {
|
||||
/*g_print ("thread not inited yet %d\n", ptk);*/
|
||||
monothread_key = ptk;
|
||||
/*g_print ("thread inited: %d\n", ptk);*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -635,7 +635,7 @@ mono_runtime_syscall_fork ()
|
||||
#endif
|
||||
}
|
||||
|
||||
gboolean
|
||||
void
|
||||
mono_gdb_render_native_backtraces (pid_t crashed_pid)
|
||||
{
|
||||
const char *argv [9];
|
||||
@@ -643,7 +643,7 @@ mono_gdb_render_native_backtraces (pid_t crashed_pid)
|
||||
|
||||
argv [0] = g_find_program_in_path ("gdb");
|
||||
if (argv [0] == NULL) {
|
||||
return FALSE;
|
||||
return;
|
||||
}
|
||||
|
||||
argv [1] = "-ex";
|
||||
@@ -657,8 +657,6 @@ mono_gdb_render_native_backtraces (pid_t crashed_pid)
|
||||
argv [8] = 0;
|
||||
|
||||
execv (argv [0], (char**)argv);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
#endif /* __native_client__ */
|
||||
|
||||
@@ -5717,12 +5717,9 @@ setup_tls_access (void)
|
||||
/* if not TLS_MODE_NPTL or local dynamic (as indicated by
|
||||
mono_domain_get_tls_offset returning -1) then use keyed access. */
|
||||
if (monodomain_key == -1) {
|
||||
ptk = mono_domain_get_tls_key ();
|
||||
ptk = mono_domain_get_native_tls_key ();
|
||||
if (ptk < 1024) {
|
||||
ptk = mono_pthread_key_for_tls (ptk);
|
||||
if (ptk < 1024) {
|
||||
monodomain_key = ptk;
|
||||
}
|
||||
monodomain_key = ptk;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5512,7 +5512,7 @@ mono_arch_setup_jit_tls_data (MonoJitTlsData *tls)
|
||||
* We need to init this multiple times, since when we are first called, the key might not
|
||||
* be initialized yet.
|
||||
*/
|
||||
appdomain_tls_offset = mono_domain_get_tls_key ();
|
||||
appdomain_tls_offset = mono_domain_get_native_tls_key ();
|
||||
lmf_tls_offset = mono_get_jit_tls_key ();
|
||||
|
||||
/* Only 64 tls entries can be accessed using inline code */
|
||||
|
||||
+1
-1
@@ -2400,7 +2400,7 @@ void mono_runtime_setup_stat_profiler (void) MONO_INTERNAL;
|
||||
void mono_runtime_shutdown_stat_profiler (void) MONO_INTERNAL;
|
||||
void mono_runtime_posix_install_handlers (void) MONO_INTERNAL;
|
||||
pid_t mono_runtime_syscall_fork (void) MONO_INTERNAL;
|
||||
gboolean mono_gdb_render_native_backtraces (pid_t crashed_pid) MONO_INTERNAL;
|
||||
void mono_gdb_render_native_backtraces (pid_t crashed_pid) MONO_INTERNAL;
|
||||
|
||||
/*
|
||||
* Signal handling
|
||||
|
||||
@@ -72,6 +72,7 @@ monoutils_sources = \
|
||||
mono-membar.h \
|
||||
mono-path.h \
|
||||
mono-poll.h \
|
||||
mono-tls.h \
|
||||
mono-uri.h \
|
||||
mono-stdlib.h \
|
||||
valgrind.h \
|
||||
|
||||
+11
-3
@@ -25,12 +25,20 @@ gint64
|
||||
mono_100ns_ticks (void)
|
||||
{
|
||||
static LARGE_INTEGER freq;
|
||||
static UINT64 start_time;
|
||||
UINT64 cur_time;
|
||||
LARGE_INTEGER value;
|
||||
|
||||
if (!freq.QuadPart && !QueryPerformanceFrequency (&freq))
|
||||
return mono_100ns_datetime ();
|
||||
if (!freq.QuadPart) {
|
||||
if (!QueryPerformanceFrequency (&freq))
|
||||
return mono_100ns_datetime ();
|
||||
QueryPerformanceCounter (&value);
|
||||
start_time = value.QuadPart;
|
||||
}
|
||||
QueryPerformanceCounter (&value);
|
||||
return value.QuadPart * MTICKS_PER_SEC / freq.QuadPart;
|
||||
cur_time = value.QuadPart;
|
||||
/* we use unsigned numbers and return the difference to avoid overflows */
|
||||
return (cur_time - start_time) * (double)MTICKS_PER_SEC / freq.QuadPart;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* mono-tls.h: Low-level TLS support
|
||||
*
|
||||
* Author:
|
||||
* Rodrigo Kumpera (kumpera@gmail.com)
|
||||
*
|
||||
* Copyright 2011 Novell, Inc (http://www.novell.com)
|
||||
* Copyright 2011 Xamarin, Inc (http://www.xamarin.com)
|
||||
*/
|
||||
|
||||
#ifndef __MONO_TLS_H__
|
||||
#define __MONO_TLS_H__
|
||||
|
||||
|
||||
#ifdef HOST_WIN32
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#define MonoNativeTlsKey DWORD
|
||||
#define mono_native_tls_alloc(key,destructor) ((*(key) = TlsAlloc ()) != TLS_OUT_OF_INDEXES && destructor == NULL)
|
||||
#define mono_native_tls_free TlsFree
|
||||
#define mono_native_tls_set_value TlsSetValue
|
||||
#define mono_native_tls_get_value TlsGetValue
|
||||
|
||||
#else
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
#define MonoNativeTlsKey pthread_key_t
|
||||
#define mono_native_tls_get_value pthread_getspecific
|
||||
|
||||
static inline int
|
||||
mono_native_tls_alloc (MonoNativeTlsKey *key, void *destructor)
|
||||
{
|
||||
return pthread_key_create (key, destructor) == 0;
|
||||
}
|
||||
|
||||
static inline void
|
||||
mono_native_tls_free (MonoNativeTlsKey key)
|
||||
{
|
||||
pthread_key_delete (key);
|
||||
}
|
||||
|
||||
static inline int
|
||||
mono_native_tls_set_value (MonoNativeTlsKey key, gpointer value)
|
||||
{
|
||||
return !pthread_setspecific (key, value);
|
||||
}
|
||||
|
||||
#endif /* HOST_WIN32 */
|
||||
|
||||
|
||||
#endif /* __MONO_TLS_H__ */
|
||||
Reference in new issue
Block a user