[io-layer] Remove GetCurrentThreadId
[mono.git] / mono / metadata / remoting.c
index c35a3406b899dd2b63143cec3009cb841a295a20..dcc60ecc5504a93656884ca5c78eb8ad47709457 100644 (file)
@@ -69,8 +69,10 @@ static mono_mutex_t remoting_mutex;
 static gboolean remoting_mutex_inited;
 
 static MonoClass *byte_array_class;
+#ifndef DISABLE_JIT
 static MonoMethod *method_rs_serialize, *method_rs_deserialize, *method_exc_fixexc, *method_rs_appdomain_target;
 static MonoMethod *method_set_call_context, *method_needs_context_sink, *method_rs_serialize_exc;
+#endif
 
 static void
 register_icall (gpointer func, const char *name, const char *sigstr, gboolean save)
@@ -147,24 +149,33 @@ mono_remoting_marshal_init (void)
        if (module_initialized)
                return;
 
+       byte_array_class = mono_array_class_get (mono_defaults.byte_class, 1);
+
+#ifndef DISABLE_JIT
        klass = mono_class_from_name (mono_defaults.corlib, "System.Runtime.Remoting", "RemotingServices");
        method_rs_serialize = mono_class_get_method_from_name (klass, "SerializeCallData", -1);
+       g_assert (method_rs_serialize);
        method_rs_deserialize = mono_class_get_method_from_name (klass, "DeserializeCallData", -1);
+       g_assert (method_rs_deserialize);
        method_rs_serialize_exc = mono_class_get_method_from_name (klass, "SerializeExceptionData", -1);
+       g_assert (method_rs_serialize_exc);
        
        klass = mono_defaults.real_proxy_class;
        method_rs_appdomain_target = mono_class_get_method_from_name (klass, "GetAppDomainTarget", -1);
+       g_assert (method_rs_appdomain_target);
        
        klass = mono_defaults.exception_class;
        method_exc_fixexc = mono_class_get_method_from_name (klass, "FixRemotingException", -1);
-       
-       byte_array_class = mono_array_class_get (mono_defaults.byte_class, 1);
-       
+       g_assert (method_exc_fixexc);
+
        klass = mono_class_from_name (mono_defaults.corlib, "System.Runtime.Remoting.Messaging", "CallContext");
        method_set_call_context = mono_class_get_method_from_name (klass, "SetCurrentCallContext", -1);
-       
+       g_assert (method_set_call_context);
+
        klass = mono_class_from_name (mono_defaults.corlib, "System.Runtime.Remoting.Contexts", "Context");
        method_needs_context_sink = mono_class_get_method_from_name (klass, "get_NeedsContextSink", -1);
+       g_assert (method_needs_context_sink);
+#endif 
 
        mono_loader_lock ();
 
@@ -251,13 +262,11 @@ static inline MonoMethod*
 mono_marshal_remoting_find_in_cache (MonoMethod *method, int wrapper_type)
 {
        MonoMethod *res = NULL;
-       MonoRemotingMethods *wrps;
+       MonoRemotingMethods *wrps = NULL;
 
        mono_marshal_lock_internal ();
-       if (method->klass->image->remoting_invoke_cache)
-               wrps = g_hash_table_lookup (method->klass->image->remoting_invoke_cache, method);
-       else
-               wrps = NULL;
+       if (mono_method_get_wrapper_cache (method)->remoting_invoke_cache)
+               wrps = g_hash_table_lookup (mono_method_get_wrapper_cache (method)->remoting_invoke_cache, method);
 
        if (wrps) {
                switch (wrapper_type) {
@@ -283,7 +292,9 @@ mono_remoting_mb_create_and_cache (MonoMethod *key, MonoMethodBuilder *mb,
 {
        MonoMethod **res = NULL;
        MonoRemotingMethods *wrps;
-       GHashTable *cache = get_cache_full (&key->klass->image->remoting_invoke_cache, mono_aligned_addr_hash, NULL, NULL, g_free);
+       GHashTable *cache;
+
+       cache = get_cache_full (&mono_method_get_wrapper_cache (key)->remoting_invoke_cache, mono_aligned_addr_hash, NULL, NULL, g_free);
 
        mono_marshal_lock_internal ();
        wrps = g_hash_table_lookup (cache, key);
@@ -323,19 +334,19 @@ static MonoObject *
 mono_remoting_wrapper (MonoMethod *method, gpointer *params)
 {
        MonoMethodMessage *msg;
-       MonoTransparentProxy *this;
+       MonoTransparentProxy *this_obj;
        MonoObject *res, *exc;
        MonoArray *out_args;
 
-       this = *((MonoTransparentProxy **)params [0]);
+       this_obj = *((MonoTransparentProxy **)params [0]);
 
-       g_assert (this);
-       g_assert (((MonoObject *)this)->vtable->klass == mono_defaults.transparent_proxy_class);
+       g_assert (this_obj);
+       g_assert (((MonoObject *)this_obj)->vtable->klass == mono_defaults.transparent_proxy_class);
        
        /* skip the this pointer */
        params++;
 
-       if (mono_class_is_contextbound (this->remote_class->proxy_class) && this->rp->context == (MonoObject *) mono_context_get ())
+       if (mono_class_is_contextbound (this_obj->remote_class->proxy_class) && this_obj->rp->context == (MonoObject *) mono_context_get ())
        {
                int i;
                MonoMethodSignature *sig = mono_method_signature (method);
@@ -359,12 +370,12 @@ mono_remoting_wrapper (MonoMethod *method, gpointer *params)
                        }
                }
 
-               return mono_runtime_invoke (method, method->klass->valuetype? mono_object_unbox ((MonoObject*)this): this, mparams, NULL);
+               return mono_runtime_invoke (method, method->klass->valuetype? mono_object_unbox ((MonoObject*)this_obj): this_obj, mparams, NULL);
        }
 
        msg = mono_method_call_message_new (method, params, NULL, NULL, NULL);
 
-       res = mono_remoting_invoke ((MonoObject *)this->rp, msg, &exc, &out_args);
+       res = mono_remoting_invoke ((MonoObject *)this_obj->rp, msg, &exc, &out_args);
 
        if (exc)
                mono_raise_exception ((MonoException *)exc);