[remoting] Use coop handles for S.R.Remoting.Contexts.Context.{Register,Release}Context
authorAleksey Kliger <aleksey@xamarin.com>
Wed, 22 Mar 2017 15:54:26 +0000 (11:54 -0400)
committerAleksey Kliger <aleksey@xamarin.com>
Fri, 14 Apr 2017 14:59:25 +0000 (10:59 -0400)
* ves_icall_System_Runtime_Remoting_Contexts_Context_RegisterContext
* ves_icall_System_Runtime_Remoting_Contexts_Context_ReleaseContext

Added new mono_threads_{register,release}_app_context to be used internally in
the runtime.

mono/metadata/appdomain.c
mono/metadata/icall-def.h
mono/metadata/threads-types.h
mono/metadata/threads.c

index 984631949122e169016b662804c94c63f3221f5f..c8cc8222782d14af67155969a972ff001aa8e678 100644 (file)
@@ -397,7 +397,8 @@ mono_context_init_checked (MonoDomain *domain, MonoError *error)
 
        context->domain_id = domain->domain_id;
        context->context_id = 0;
-       ves_icall_System_Runtime_Remoting_Contexts_Context_RegisterContext (context);
+       mono_threads_register_app_context (context, error);
+       mono_error_assert_ok (error);
        domain->default_context = context;
 }
 
index 12617c755f5ffd5fe986652c71f0e0a9b34828f0..27bf284219e9b873f61b8d070f57cf542a49c902 100644 (file)
@@ -741,8 +741,8 @@ ICALL(ACTS_1, "AllocateUninitializedClassInstance", ves_icall_System_Runtime_Act
 ICALL(ACTS_2, "EnableProxyActivation", ves_icall_System_Runtime_Activation_ActivationServices_EnableProxyActivation)
 
 ICALL_TYPE(CONTEXT, "System.Runtime.Remoting.Contexts.Context", CONTEXT_1)
-ICALL(CONTEXT_1, "RegisterContext", ves_icall_System_Runtime_Remoting_Contexts_Context_RegisterContext)
-ICALL(CONTEXT_2, "ReleaseContext", ves_icall_System_Runtime_Remoting_Contexts_Context_ReleaseContext)
+HANDLES(ICALL(CONTEXT_1, "RegisterContext", ves_icall_System_Runtime_Remoting_Contexts_Context_RegisterContext))
+HANDLES(ICALL(CONTEXT_2, "ReleaseContext", ves_icall_System_Runtime_Remoting_Contexts_Context_ReleaseContext))
 
 ICALL_TYPE(ARES, "System.Runtime.Remoting.Messaging.AsyncResult", ARES_1)
 ICALL(ARES_1, "Invoke", ves_icall_System_Runtime_Remoting_Messaging_AsyncResult_Invoke)
index 9bf9cb639b046ab04165d36265e386eb3e830872..59d4856629bbd526b4a902e9e290c6422cbb99c1 100644 (file)
@@ -16,6 +16,7 @@
 #include <glib.h>
 
 #include <mono/metadata/object.h>
+#include "mono/metadata/handle.h"
 #include "mono/utils/mono-compiler.h"
 #include "mono/utils/mono-membar.h"
 #include "mono/utils/mono-threads.h"
@@ -177,8 +178,13 @@ void ves_icall_System_Threading_Thread_MemoryBarrier (void);
 void ves_icall_System_Threading_Thread_Interrupt_internal (MonoThread *this_obj);
 void ves_icall_System_Threading_Thread_SpinWait_nop (void);
 
-void ves_icall_System_Runtime_Remoting_Contexts_Context_RegisterContext (MonoAppContext *ctx);
-void ves_icall_System_Runtime_Remoting_Contexts_Context_ReleaseContext (MonoAppContext *ctx);
+void
+mono_threads_register_app_context (MonoAppContext* ctx, MonoError *error);
+void
+mono_threads_release_app_context (MonoAppContext* ctx, MonoError *error);
+
+void ves_icall_System_Runtime_Remoting_Contexts_Context_RegisterContext (MonoAppContextHandle ctx, MonoError *error);
+void ves_icall_System_Runtime_Remoting_Contexts_Context_ReleaseContext (MonoAppContextHandle ctx, MonoError *error);
 
 MonoInternalThread *mono_thread_internal_current (void);
 
index 4a3c91fe2c704780e95aba5384c6b1f443114a99..f669790739f01e73ffa05876f24017ea6f16151c 100644 (file)
@@ -135,7 +135,7 @@ static StaticDataInfo context_static_info;
 static MonoGHashTable *threads=NULL;
 
 /* List of app context GC handles.
- * Added to from ves_icall_System_Runtime_Remoting_Contexts_Context_RegisterContext ().
+ * Added to from mono_threads_register_app_context ().
  */
 static GHashTable *contexts = NULL;
 
@@ -2964,8 +2964,9 @@ free_context (void *user_data)
 }
 
 void
-ves_icall_System_Runtime_Remoting_Contexts_Context_RegisterContext (MonoAppContext *ctx)
+mono_threads_register_app_context (MonoAppContext *ctx, MonoError *error)
 {
+       error_init (error);
        mono_threads_lock ();
 
        //g_print ("Registering context %d in domain %d\n", ctx->context_id, ctx->domain_id);
@@ -2997,7 +2998,14 @@ ves_icall_System_Runtime_Remoting_Contexts_Context_RegisterContext (MonoAppConte
 }
 
 void
-ves_icall_System_Runtime_Remoting_Contexts_Context_ReleaseContext (MonoAppContext *ctx)
+ves_icall_System_Runtime_Remoting_Contexts_Context_RegisterContext (MonoAppContextHandle ctx, MonoError *error)
+{
+       error_init (error);
+       mono_threads_register_app_context (MONO_HANDLE_RAW (ctx), error); /* FIXME use handles in mono_threads_register_app_context */
+}
+
+void
+mono_threads_release_app_context (MonoAppContext* ctx, MonoError *error)
 {
        /*
         * NOTE: Since finalizers are unreliable for the purposes of ensuring
@@ -3010,6 +3018,13 @@ ves_icall_System_Runtime_Remoting_Contexts_Context_ReleaseContext (MonoAppContex
        mono_profiler_context_unloaded (ctx);
 }
 
+void
+ves_icall_System_Runtime_Remoting_Contexts_Context_ReleaseContext (MonoAppContextHandle ctx, MonoError *error)
+{
+       error_init (error);
+       mono_threads_release_app_context (MONO_HANDLE_RAW (ctx), error); /* FIXME use handles in mono_threads_release_app_context */
+}
+
 void mono_thread_init (MonoThreadStartCB start_cb,
                       MonoThreadAttachCB attach_cb)
 {