Permalink
Browse files

The runtime no longer need the remoting types under DISABLE_REMOTING.

  • Loading branch information...
1 parent b36302a commit 4a59194ee09f78ccfbce5cdd2d90cd7934b55da1 @kumpera kumpera committed Feb 28, 2013
@@ -1070,8 +1070,12 @@ typedef struct {
MonoClass *threadabortexception_class;
MonoClass *thread_class;
MonoClass *internal_thread_class;
+#ifndef DISABLE_REMOTING
MonoClass *transparent_proxy_class;
MonoClass *real_proxy_class;
+ MonoClass *marshalbyrefobject_class;
+ MonoClass *iremotingtypeinfo_class;
+#endif
MonoClass *mono_method_message_class;
MonoClass *appdomain_class;
MonoClass *field_info_class;
@@ -1081,12 +1085,9 @@ typedef struct {
MonoClass *stack_frame_class;
MonoClass *stack_trace_class;
MonoClass *marshal_class;
-
MonoClass *typed_reference_class;
MonoClass *argumenthandle_class;
- MonoClass *marshalbyrefobject_class;
MonoClass *monitor_class;
- MonoClass *iremotingtypeinfo_class;
MonoClass *runtimesecurityframe_class;
MonoClass *executioncontext_class;
MonoClass *internals_visible_class;
@@ -1107,6 +1108,17 @@ typedef struct {
MonoClass *generic_ireadonlylist_class;
} MonoDefaults;
+#ifdef DISABLE_REMOTING
+#define mono_class_is_transparent_proxy(klass) (FALSE)
+#define mono_class_is_real_proxy(klass) (FALSE)
+#define mono_object_is_transparent_proxy(object) (FALSE)
+
+#else
+#define mono_class_is_transparent_proxy(klass) ((klass) == mono_defaults.transparent_proxy_class)
+#define mono_class_is_real_proxy(klass) ((klass) == mono_defaults.real_proxy_class)
+#define mono_object_is_transparent_proxy(object) (((MOnoObject*)object)->vtable->klass == mono_defaults.transparent_proxy_class)
+#endif
+
extern MonoDefaults mono_defaults MONO_INTERNAL;
void
@@ -254,7 +254,7 @@ cominterop_object_is_rcw (MonoObject *obj)
if (!obj)
return FALSE;
klass = mono_object_class (obj);
- if (klass != mono_defaults.transparent_proxy_class)
+ if (mono_class_is_transparent_proxy (klass))
return FALSE;
real_proxy = ((MonoTransparentProxy*)obj)->rp;
@@ -608,8 +608,10 @@ mono_cominterop_emit_ptr_to_object_conv (MonoMethodBuilder *mb, MonoType *type,
com_interop_proxy_class = mono_class_from_name (mono_defaults.corlib, "Mono.Interop", "ComInteropProxy");
if (!com_interop_proxy_get_proxy)
com_interop_proxy_get_proxy = mono_class_get_method_from_name_flags (com_interop_proxy_class, "GetProxy", 2, METHOD_ATTRIBUTE_PRIVATE);
+#ifndef DISABLE_REMOTING
if (!get_transparent_proxy)
get_transparent_proxy = mono_class_get_method_from_name (mono_defaults.real_proxy_class, "GetTransparentProxy", 0);
+#endif
real_proxy = mono_mb_add_local (mb, &com_interop_proxy_class->byval_arg);
@@ -1456,7 +1458,7 @@ ves_icall_System_Runtime_InteropServices_Marshal_GetIUnknownForObjectInternal (M
if (!object)
return NULL;
klass = mono_object_class (object);
- if (klass != mono_defaults.transparent_proxy_class) {
+ if (mono_class_is_transparent_proxy (klass)) {
g_assert_not_reached ();
return NULL;
}
View
@@ -1513,6 +1513,7 @@ mono_init_internal (const char *filename, const char *exe_filename, const char *
mono_defaults.corlib, "System", "AppDomain");
g_assert (mono_defaults.appdomain_class != 0);
+#ifndef DISABLE_REMOTING
mono_defaults.transparent_proxy_class = mono_class_from_name (
mono_defaults.corlib, "System.Runtime.Remoting.Proxies", "TransparentProxy");
g_assert (mono_defaults.transparent_proxy_class != 0);
@@ -1521,6 +1522,15 @@ mono_init_internal (const char *filename, const char *exe_filename, const char *
mono_defaults.corlib, "System.Runtime.Remoting.Proxies", "RealProxy");
g_assert (mono_defaults.real_proxy_class != 0);
+ mono_defaults.marshalbyrefobject_class = mono_class_from_name (
+ mono_defaults.corlib, "System", "MarshalByRefObject");
+ g_assert (mono_defaults.marshalbyrefobject_class != 0);
+
+ mono_defaults.iremotingtypeinfo_class = mono_class_from_name (
+ mono_defaults.corlib, "System.Runtime.Remoting", "IRemotingTypeInfo");
+ g_assert (mono_defaults.iremotingtypeinfo_class != 0);
+#endif
+
mono_defaults.mono_method_message_class = mono_class_from_name (
mono_defaults.corlib, "System.Runtime.Remoting.Messaging", "MonoMethodMessage");
g_assert (mono_defaults.mono_method_message_class != 0);
@@ -1561,18 +1571,10 @@ mono_init_internal (const char *filename, const char *exe_filename, const char *
mono_defaults.corlib, "System", "RuntimeArgumentHandle");
g_assert (mono_defaults.argumenthandle_class != 0);
- mono_defaults.marshalbyrefobject_class = mono_class_from_name (
- mono_defaults.corlib, "System", "MarshalByRefObject");
- g_assert (mono_defaults.marshalbyrefobject_class != 0);
-
mono_defaults.monitor_class = mono_class_from_name (
mono_defaults.corlib, "System.Threading", "Monitor");
g_assert (mono_defaults.monitor_class != 0);
- mono_defaults.iremotingtypeinfo_class = mono_class_from_name (
- mono_defaults.corlib, "System.Runtime.Remoting", "IRemotingTypeInfo");
- g_assert (mono_defaults.iremotingtypeinfo_class != 0);
-
mono_defaults.runtimesecurityframe_class = mono_class_from_name (
mono_defaults.corlib, "System.Security", "RuntimeSecurityFrame");
View
@@ -1169,10 +1169,12 @@ ves_icall_System_Object_GetType (MonoObject *obj)
{
MONO_ARCH_SAVE_REGS;
+#ifndef DISABLE_REMOTING
if (obj->vtable->klass != mono_defaults.transparent_proxy_class)
- return mono_type_get_object (mono_object_domain (obj), &obj->vtable->klass->byval_arg);
- else
return mono_type_get_object (mono_object_domain (obj), &((MonoTransparentProxy*)obj)->remote_class->proxy_class->byval_arg);
+ else
+#endif
+ return mono_type_get_object (mono_object_domain (obj), &obj->vtable->klass->byval_arg);
}
ICALL_EXPORT void
View
@@ -2119,6 +2119,7 @@ mono_delegate_begin_invoke (MonoDelegate *delegate, gpointer *params)
if (mcast_delegate->prev != NULL)
mono_raise_exception (mono_get_exception_argument (NULL, "The delegate must have only one target"));
+#ifndef DISABLE_REMOTING
if (delegate->target && mono_object_class (delegate->target) == mono_defaults.transparent_proxy_class) {
MonoTransparentProxy* tp = (MonoTransparentProxy *)delegate->target;
@@ -2146,6 +2147,7 @@ mono_delegate_begin_invoke (MonoDelegate *delegate, gpointer *params)
return ares;
}
}
+#endif
klass = delegate->object.vtable->klass;
@@ -2742,14 +2744,17 @@ mono_delegate_end_invoke (MonoDelegate *delegate, gpointer *params)
return NULL;
}
- if (delegate->target && mono_object_class (delegate->target) == mono_defaults.transparent_proxy_class) {
+#ifndef DISABLE_REMOTING
+ if (delegate->target && mono_object_is_transparent_proxy (delegate->target)) {
MonoTransparentProxy* tp = (MonoTransparentProxy *)delegate->target;
msg = (MonoMethodMessage *)mono_object_new (domain, mono_defaults.mono_method_message_class);
mono_message_init (domain, msg, delegate->method_info, NULL);
msg->call_type = CallType_EndInvoke;
MONO_OBJECT_SETREF (msg, async_result, ares);
res = mono_remoting_invoke ((MonoObject *)tp->rp, msg, &exc, &out_args);
- } else {
+ } else
+#endif
+ {
res = mono_thread_pool_finish (ares, &out_args, &exc);
}
@@ -1454,7 +1454,7 @@ mono_array_full_copy (MonoArray *src, MonoArray *dest) MONO_INTERNAL;
gboolean
mono_array_calc_byte_len (MonoClass *class, uintptr_t len, uintptr_t *res) MONO_INTERNAL;
-#ifdef DISABLE_REMOTING
+#ifndef DISABLE_REMOTING
MonoObject *
mono_remoting_invoke (MonoObject *real_proxy, MonoMethodMessage *msg,
MonoObject **exc, MonoArray **out_args) MONO_INTERNAL;
View
@@ -2700,16 +2700,16 @@ mono_object_get_virtual_method (MonoObject *obj, MonoMethod *method)
{
MonoClass *klass;
MonoMethod **vtable;
- gboolean is_proxy;
+ gboolean is_proxy = FALSE;
MonoMethod *res = NULL;
klass = mono_object_class (obj);
+#ifndef DISABLE_REMOTING
if (klass == mono_defaults.transparent_proxy_class) {
klass = ((MonoTransparentProxy *)obj)->remote_class->proxy_class;
is_proxy = TRUE;
- } else {
- is_proxy = FALSE;
}
+#endif
if (!is_proxy && ((method->flags & METHOD_ATTRIBUTE_FINAL) || !(method->flags & METHOD_ATTRIBUTE_VIRTUAL)))
return method;
@@ -3705,6 +3705,7 @@ deserialize_object (MonoObject *obj, gboolean *failure, MonoObject **exc)
return result;
}
+#ifndef DISABLE_REMOTING
static MonoObject*
make_transparent_proxy (MonoObject *obj, gboolean *failure, MonoObject **exc)
{
@@ -3733,6 +3734,7 @@ make_transparent_proxy (MonoObject *obj, gboolean *failure, MonoObject **exc)
return (MonoObject*) transparent_proxy;
}
+#endif /* DISABLE_REMOTING */
/**
* mono_object_xdomain_representation
@@ -3756,9 +3758,13 @@ mono_object_xdomain_representation (MonoObject *obj, MonoDomain *target_domain,
*exc = NULL;
+#ifndef DISABLE_REMOTING
if (mono_class_is_marshalbyref (mono_object_class (obj))) {
deserialized = make_transparent_proxy (obj, &failure, exc);
- } else {
+ }
+ else
+#endif
+ {
MonoDomain *domain = mono_domain_get ();
MonoObject *serialized;
@@ -5245,7 +5251,7 @@ mono_object_isinst_mbyref (MonoObject *obj, MonoClass *klass)
return obj;
} else {
MonoClass *oklass = vt->klass;
- if (oklass == mono_defaults.transparent_proxy_class)
+ if (mono_class_is_transparent_proxy (oklass))
oklass = ((MonoTransparentProxy *)obj)->remote_class->proxy_class;
mono_class_setup_supertypes (klass);
@@ -5906,6 +5912,7 @@ mono_message_init (MonoDomain *domain,
}
}
+#ifndef DISABLE_REMOTING
/**
* mono_remoting_invoke:
* @real_proxy: pointer to a RealProxy object
@@ -5942,6 +5949,7 @@ mono_remoting_invoke (MonoObject *real_proxy, MonoMethodMessage *msg,
return mono_runtime_invoke (im, NULL, pa, exc);
}
+#endif
MonoObject *
mono_message_invoke (MonoObject *target, MonoMethodMessage *msg,
@@ -5954,15 +5962,16 @@ mono_message_invoke (MonoObject *target, MonoMethodMessage *msg,
MonoObject *ret;
int i, j, outarg_count = 0;
- if (target && target->vtable->klass == mono_defaults.transparent_proxy_class) {
-
+#ifndef DISABLE_REMOTING
+ if (target && mono_object_is_transparent_proxy (target)) {
MonoTransparentProxy* tp = (MonoTransparentProxy *)target;
if (mono_class_is_contextbound (tp->remote_class->proxy_class) && tp->rp->context == (MonoObject *) mono_context_get ()) {
target = tp->rp->unwrapped_server;
} else {
return mono_remoting_invoke ((MonoObject *)tp->rp, msg, exc, out_args);
}
}
+#endif
domain = mono_domain_get ();
method = msg->method->method;
@@ -6255,6 +6264,8 @@ mono_method_return_message_restore (MonoMethod *method, gpointer *params, MonoAr
}
}
+#ifndef DISABLE_REMOTING
+
/**
* mono_load_remote_field:
* @this: pointer to an object
@@ -6281,7 +6292,7 @@ mono_load_remote_field (MonoObject *this, MonoClass *klass, MonoClassField *fiel
MonoObject *exc;
char* full_name;
- g_assert (this->vtable->klass == mono_defaults.transparent_proxy_class);
+ g_assert (mono_object_is_transparent_proxy (this));
g_assert (res != NULL);
if (mono_class_is_contextbound (tp->remote_class->proxy_class) && tp->rp->context == (MonoObject *) mono_context_get ()) {
@@ -6320,7 +6331,6 @@ mono_load_remote_field (MonoObject *this, MonoClass *klass, MonoClassField *fiel
return res;
}
-#ifdef DISABLE_REMOTING
/**
* mono_load_remote_field_new:
* @this:
@@ -6341,7 +6351,7 @@ mono_load_remote_field_new (MonoObject *this, MonoClass *klass, MonoClassField *
MonoObject *exc, *res;
char* full_name;
- g_assert (this->vtable->klass == mono_defaults.transparent_proxy_class);
+ g_assert (mono_object_is_transparent_proxy (this));
field_class = mono_class_from_mono_type (field->type);
@@ -6408,7 +6418,7 @@ mono_store_remote_field (MonoObject *this, MonoClass *klass, MonoClassField *fie
MonoObject *arg;
char* full_name;
- g_assert (this->vtable->klass == mono_defaults.transparent_proxy_class);
+ g_assert (mono_object_is_transparent_proxy (this));
field_class = mono_class_from_mono_type (field->type);
@@ -6464,7 +6474,7 @@ mono_store_remote_field_new (MonoObject *this, MonoClass *klass, MonoClassField
MonoObject *exc;
char* full_name;
- g_assert (this->vtable->klass == mono_defaults.transparent_proxy_class);
+ g_assert (mono_object_is_transparent_proxy (this));
field_class = mono_class_from_mono_type (field->type);
View
@@ -240,7 +240,7 @@ mono_runtime_exec_main (MonoMethod *method, MonoArray *args,
MonoObject **exc);
/* The following functions won't be available with mono was configured with remoting disabled. */
-/*#ifdef DISABLE_REMOTING */
+/*#ifndef DISABLE_REMOTING */
void*
mono_load_remote_field (MonoObject *this_obj, MonoClass *klass, MonoClassField *field, void **res);
View
@@ -615,9 +615,12 @@ is_xdomain_ref_allowed (gpointer *ptr, char *obj, MonoDomain *domain)
return TRUE;
if (o->vtable->klass == mono_defaults.internal_thread_class && offset == G_STRUCT_OFFSET (MonoInternalThread, current_appcontext))
return TRUE;
+
+#ifndef DISABLE_REMOTING
if (mono_class_has_parent_fast (o->vtable->klass, mono_defaults.real_proxy_class) &&
offset == G_STRUCT_OFFSET (MonoRealProxy, unwrapped_server))
return TRUE;
+#endif
/* Thread.cached_culture_info */
if (!strcmp (ref->vtable->klass->name_space, "System.Globalization") &&
!strcmp (ref->vtable->klass->name, "CultureInfo") &&
@@ -888,6 +891,7 @@ process_object_for_domain_clearing (char *start, MonoDomain *domain)
g_assert (mono_object_domain (start) == mono_get_root_domain ());
/* The object could be a proxy for an object in the domain
we're deleting. */
+#ifndef DISABLE_REMOTING
if (mono_class_has_parent_fast (vt->klass, mono_defaults.real_proxy_class)) {
MonoObject *server = ((MonoRealProxy*)start)->unwrapped_server;
@@ -898,6 +902,7 @@ process_object_for_domain_clearing (char *start, MonoDomain *domain)
((MonoRealProxy*)start)->unwrapped_server = NULL;
}
}
+#endif
}
static MonoDomain *check_domain = NULL;
@@ -5522,7 +5522,7 @@ obj_is_of_type (MonoObject *obj, MonoType *t)
{
MonoClass *klass = obj->vtable->klass;
if (!mono_class_is_assignable_from (mono_class_from_mono_type (t), klass)) {
- if (klass == mono_defaults.transparent_proxy_class) {
+ if (mono_class_is_transparent_proxy (klass)) {
klass = ((MonoTransparentProxy *)obj)->remote_class->proxy_class;
if (mono_class_is_assignable_from (mono_class_from_mono_type (t), klass)) {
return TRUE;
@@ -404,7 +404,7 @@ common_call_trampoline (mgreg_t *regs, guint8 *code, MonoMethod *m, guint8* tram
this_arg = mono_arch_get_this_arg_from_call (regs, code);
- if (this_arg->vtable->klass == mono_defaults.transparent_proxy_class) {
+ if (mono_object_is_transparent_proxy (this_arg)) {
/* Use the slow path for now */
m = mono_object_get_virtual_method (this_arg, m);
vtable_slot_to_patch = NULL;
View
@@ -6914,8 +6914,10 @@ mini_init (const char *filename, const char *runtime_version)
register_icall (mono_thread_get_undeniable_exception, "mono_thread_get_undeniable_exception", "object", FALSE);
register_icall (mono_thread_interruption_checkpoint, "mono_thread_interruption_checkpoint", "void", FALSE);
register_icall (mono_thread_force_interruption_checkpoint, "mono_thread_force_interruption_checkpoint", "void", FALSE);
+#ifndef DISABLE_REMOTING
register_icall (mono_load_remote_field_new, "mono_load_remote_field_new", "object object ptr ptr", FALSE);
register_icall (mono_store_remote_field_new, "mono_store_remote_field_new", "void object ptr ptr object", FALSE);
+#endif
#if defined(__native_client__) || defined(__native_client_codegen__)
register_icall (mono_nacl_gc, "mono_nacl_gc", "void", TRUE);

0 comments on commit 4a59194

Please sign in to comment.