[coop] store MonoHandleArena pointer in MonoThreadInfo
authorAleksey Kliger <aleksey@xamarin.com>
Mon, 28 Dec 2015 22:49:15 +0000 (17:49 -0500)
committerAleksey Kliger <aleksey@xamarin.com>
Thu, 14 Jan 2016 16:38:15 +0000 (11:38 -0500)
mono/metadata/handle.c
mono/metadata/sgen-mono.c
mono/utils/mono-threads.h

index bf0abc24e4f518b2e1b4b882d9f4d22b7347f669..964fefe93478f8b14bf7f6db1c3bc4491575694c 100644 (file)
@@ -15,6 +15,7 @@
 #include <mono/metadata/gc-internals.h>
 #include <mono/utils/atomic.h>
 #include <mono/utils/mono-lazy-init.h>
+#include <mono/utils/mono-threads.h>
 
 #define HANDLES_PER_CHUNK (16 - 2)
 
@@ -196,11 +197,11 @@ mono_handle_arena_deinitialize (MonoHandleArena **arena_stack)
 MonoHandleArena*
 mono_handle_arena_current (void)
 {
-       g_assert_not_reached ();
+       return (MonoHandleArena*) mono_thread_info_current ()->handle_arena;
 }
 
 MonoHandleArena**
 mono_handle_arena_current_addr (void)
 {
-       g_assert_not_reached ();
+       return (MonoHandleArena**) &mono_thread_info_current ()->handle_arena;
 }
index 8d3b7c137eb4fa444980841bcfbb68b1e6cb4773..1613e9304fe6e5e11da483775574fc79fe4a0fa1 100644 (file)
@@ -34,6 +34,7 @@
 #include "metadata/runtime.h"
 #include "metadata/sgen-bridge-internals.h"
 #include "metadata/gc-internals.h"
+#include "metadata/handle.h"
 #include "utils/mono-memory-model.h"
 #include "utils/mono-logger-internals.h"
 
@@ -2276,6 +2277,8 @@ thread_in_critical_region (SgenThreadInfo *info)
 static void
 sgen_thread_attach (SgenThreadInfo *info)
 {
+       mono_handle_arena_initialize ((MonoHandleArena**) &info->client_info.info.handle_arena);
+
        if (mono_gc_get_gc_callbacks ()->thread_attach_func && !info->client_info.runtime_data)
                info->client_info.runtime_data = mono_gc_get_gc_callbacks ()->thread_attach_func ();
 }
@@ -2291,6 +2294,8 @@ sgen_thread_detach (SgenThreadInfo *p)
         */
        if (mono_domain_get ())
                mono_thread_detach_internal (mono_thread_internal_current ());
+
+       mono_handle_arena_deinitialize ((MonoHandleArena**) &p->client_info.info.handle_arena);
 }
 
 gboolean
index 5fe411dbe1ae05f60bfcd355b1b436204d57ae5a..111146811de55977a4b16717d77eeca992b5b478 100644 (file)
@@ -250,6 +250,9 @@ typedef struct {
        void *jit_data;
 
        MonoThreadInfoInterruptToken *interrupt_token;
+
+       /* MonoHandleArena for coop handles */
+       gpointer handle_arena;
 } MonoThreadInfo;
 
 typedef struct {