return field.GetValue(o);
}
- object[] inArgs = new object[] { Type.GetTypeFromHandle(typeHandle).FullName,
- field.Name };
+ string typeName = Type.GetTypeFromHandle(typeHandle).FullName;
+ string fieldName = field.Name;
+ object[] inArgs = new object[] { typeName,
+ fieldName };
object[] outArgsMsg = new object[1];
MethodInfo minfo = typeof(object).GetMethod("FieldGetter", BindingFlags.NonPublic | BindingFlags.Instance);
if (minfo == null)
throw exc;
return outArgs[0];
}
+
+ internal void StoreRemoteField (IntPtr classPtr, IntPtr fieldPtr, object arg) {
+ Mono.RuntimeClassHandle classHandle = new Mono.RuntimeClassHandle (classPtr);
+ RuntimeFieldHandle fieldHandle = new RuntimeFieldHandle (fieldPtr);
+ RuntimeTypeHandle typeHandle = classHandle.GetTypeHandle ();
+ FieldInfo field = FieldInfo.GetFieldFromHandle (fieldHandle);
+
+ if (InCurrentContext ()) {
+ object o = _rp._server;
+ field.SetValue (o, arg);
+ return;
+ }
+
+ string typeName = Type.GetTypeFromHandle (typeHandle).FullName;
+ string fieldName = field.Name;
+ object [] inArgs = new object[] { typeName,
+ fieldName,
+ arg };
+ MethodInfo minfo = typeof(object).GetMethod ("FieldSetter", BindingFlags.NonPublic | BindingFlags.Instance);
+ if (minfo == null)
+ throw new MissingMethodException ("System.Object", "FieldSetter");
+
+ MonoMethodMessage msg = new MonoMethodMessage (minfo, inArgs, null);
+ object [] outArgs;
+ Exception exc;
+ RealProxy.PrivateInvoke (_rp, msg, out exc, out outArgs);
+ if (exc != null)
+ throw exc;
+ }
+
}
#pragma warning restore 169, 649
</type>
<type fullname="System.Runtime.Remoting.Proxies.TransparentProxy" preserve="fields">
<method name="LoadRemoteFieldNew" />
+ <method name="StoreRemoteField" />
</type>
<type fullname="System.Runtime.Remoting.RemotingServices">
<method name="SerializeCallData" />
gboolean
mono_store_remote_field_checked (MonoObject *this_obj, MonoClass *klass, MonoClassField *field, void* val, MonoError *error);
-void
-mono_store_remote_field_new_icall (MonoObject *this_obj, MonoClass *klass, MonoClassField *field, MonoObject *arg);
-
gboolean
mono_store_remote_field_new_checked (MonoObject *this_obj, MonoClass *klass, MonoClassField *field, MonoObject *arg, MonoError *error);
MONO_REQ_GC_UNSAFE_MODE;
- static MonoMethod *setter = NULL;
+ mono_error_init (error);
MonoDomain *domain = mono_domain_get ();
- MonoTransparentProxy *tp = (MonoTransparentProxy *) this_obj;
MonoClass *field_class;
- MonoMethodMessage *msg;
- MonoArray *out_args;
- MonoObject *exc;
MonoObject *arg;
- char* full_name;
-
- mono_error_init (error);
g_assert (mono_object_is_transparent_proxy (this_obj));
field_class = mono_class_from_mono_type (field->type);
- if (mono_class_is_contextbound (tp->remote_class->proxy_class) && tp->rp->context == (MonoObject *) mono_context_get ()) {
- if (field_class->valuetype) mono_field_set_value (tp->rp->unwrapped_server, field, val);
- else mono_field_set_value (tp->rp->unwrapped_server, field, *((MonoObject **)val));
- return TRUE;
- }
-
- if (!setter) {
- setter = mono_class_get_method_from_name (mono_defaults.object_class, "FieldSetter", -1);
- if (!setter) {
- mono_error_set_not_supported (error, "Linked away.");
- return FALSE;
- }
- }
-
if (field_class->valuetype) {
arg = mono_value_box_checked (domain, field_class, val, error);
return_val_if_nok (error, FALSE);
- } else
- arg = *((MonoObject **)val);
-
-
- msg = (MonoMethodMessage *)mono_object_new_checked (domain, mono_defaults.mono_method_message_class, error);
- return_val_if_nok (error, FALSE);
- MonoReflectionMethod *rm = mono_method_get_object_checked (domain, setter, NULL, error);
- return_val_if_nok (error, FALSE);
- mono_message_init (domain, msg, rm, NULL, error);
- return_val_if_nok (error, FALSE);
-
- full_name = mono_type_get_full_name (klass);
- mono_array_setref (msg->args, 0, mono_string_new (domain, full_name));
- mono_array_setref (msg->args, 1, mono_string_new (domain, mono_field_get_name (field)));
- mono_array_setref (msg->args, 2, arg);
- g_free (full_name);
-
- mono_remoting_invoke ((MonoObject *)(tp->rp), msg, &exc, &out_args, error);
- return_val_if_nok (error, FALSE);
-
- if (exc) {
- mono_error_set_exception_instance (error, (MonoException *)exc);
- return FALSE;
+ } else {
+ arg = *((MonoObject**)val);
}
- return TRUE;
+
+ return mono_store_remote_field_new_checked (this_obj, klass, field, arg, error);
}
/**
mono_error_cleanup (&error);
}
-/**
- * mono_store_remote_field_new_icall:
- * @this_obj:
- * @klass:
- * @field:
- * @arg:
- *
- * Missing documentation
- */
-void
-mono_store_remote_field_new_icall (MonoObject *this_obj, MonoClass *klass, MonoClassField *field, MonoObject *arg)
-{
- MonoError error;
- (void) mono_store_remote_field_new_checked (this_obj, klass, field, arg, &error);
- mono_error_set_pending_exception (&error);
-}
-
/**
* mono_store_remote_field_new_checked:
* @this_obj:
{
MONO_REQ_GC_UNSAFE_MODE;
- static MonoMethod *setter = NULL;
- MonoDomain *domain = mono_domain_get ();
- MonoTransparentProxy *tp = (MonoTransparentProxy *) this_obj;
- MonoClass *field_class;
- MonoMethodMessage *msg;
- MonoArray *out_args;
- MonoObject *exc;
- char* full_name;
+ static MonoMethod *tp_store = NULL;
mono_error_init (error);
g_assert (mono_object_is_transparent_proxy (this_obj));
- field_class = mono_class_from_mono_type (field->type);
-
- if (mono_class_is_contextbound (tp->remote_class->proxy_class) && tp->rp->context == (MonoObject *) mono_context_get ()) {
- if (field_class->valuetype) mono_field_set_value (tp->rp->unwrapped_server, field, ((gchar *) arg) + sizeof (MonoObject));
- else mono_field_set_value (tp->rp->unwrapped_server, field, arg);
- return TRUE;
- }
-
- if (!setter) {
- setter = mono_class_get_method_from_name (mono_defaults.object_class, "FieldSetter", -1);
- if (!setter) {
+ if (!tp_store) {
+ tp_store = mono_class_get_method_from_name (mono_defaults.transparent_proxy_class, "StoreRemoteField", -1);
+ if (!tp_store) {
mono_error_set_not_supported (error, "Linked away.");
return FALSE;
}
}
- msg = (MonoMethodMessage *)mono_object_new_checked (domain, mono_defaults.mono_method_message_class, error);
- return_val_if_nok (error, FALSE);
- MonoReflectionMethod *rm = mono_method_get_object_checked (domain, setter, NULL, error);
- return_val_if_nok (error, FALSE);
- mono_message_init (domain, msg, rm, NULL, error);
- return_val_if_nok (error, FALSE);
-
- full_name = mono_type_get_full_name (klass);
- mono_array_setref (msg->args, 0, mono_string_new (domain, full_name));
- mono_array_setref (msg->args, 1, mono_string_new (domain, mono_field_get_name (field)));
- mono_array_setref (msg->args, 2, arg);
- g_free (full_name);
-
- mono_remoting_invoke ((MonoObject *)(tp->rp), msg, &exc, &out_args, error);
- return_val_if_nok (error, FALSE);
+ gpointer args[3];
+ args [0] = &klass;
+ args [1] = &field;
+ args [2] = arg;
- if (exc) {
- mono_error_set_exception_instance (error, (MonoException *)exc);
- return FALSE;
- }
- return TRUE;
+ mono_runtime_invoke_checked (tp_store, this_obj, args, error);
+ return is_ok (error);
}
#endif
register_icall (mono_remoting_wrapper, "mono_remoting_wrapper", "object ptr ptr", FALSE);
register_icall (mono_upgrade_remote_class_wrapper, "mono_upgrade_remote_class_wrapper", "void object object", FALSE);
register_icall (mono_compile_method_icall, "mono_compile_method_icall", "ptr ptr", FALSE);
- /* mono_store_remote_field_new_icall registered by mini-runtime.c */
}
return res;
}
-/*
- * mono_marshal_get_stfld_remote_wrapper:
- * klass: The type of the field
- *
- * This function generates a wrapper for calling mono_store_remote_field_new
- * with the appropriate signature.
- * Similarly to mono_marshal_get_ldfld_remote_wrapper () this doesn't depend on the
- * klass argument anymore.
- */
-MonoMethod *
-mono_marshal_get_stfld_remote_wrapper (MonoClass *klass)
-{
- MonoMethodSignature *sig;
- MonoMethodBuilder *mb;
- MonoMethod *res;
- static MonoMethod *cached = NULL;
-
- mono_marshal_lock_internal ();
- if (cached) {
- mono_marshal_unlock_internal ();
- return cached;
- }
- mono_marshal_unlock_internal ();
-
- mb = mono_mb_new_no_dup_name (mono_defaults.object_class, "__mono_store_remote_field_new_wrapper", MONO_WRAPPER_STFLD_REMOTE);
-
- mb->method->save_lmf = 1;
-
- sig = mono_metadata_signature_alloc (mono_defaults.corlib, 4);
- sig->params [0] = &mono_defaults.object_class->byval_arg;
- sig->params [1] = &mono_defaults.int_class->byval_arg;
- sig->params [2] = &mono_defaults.int_class->byval_arg;
- sig->params [3] = &mono_defaults.object_class->byval_arg;
- sig->ret = &mono_defaults.void_class->byval_arg;
-
-#ifndef DISABLE_JIT
- mono_mb_emit_ldarg (mb, 0);
- mono_mb_emit_ldarg (mb, 1);
- mono_mb_emit_ldarg (mb, 2);
- mono_mb_emit_ldarg (mb, 3);
-
- mono_mb_emit_icall (mb, mono_store_remote_field_new_icall);
-
- mono_mb_emit_byte (mb, CEE_RET);
-#endif
-
- mono_marshal_lock_internal ();
- res = cached;
- mono_marshal_unlock_internal ();
- if (!res) {
- MonoMethod *newm;
- newm = mono_mb_create (mb, sig, 6, NULL);
- mono_marshal_lock_internal ();
- res = cached;
- if (!res) {
- res = newm;
- cached = res;
- mono_marshal_unlock_internal ();
- } else {
- mono_marshal_unlock_internal ();
- mono_free_method (newm);
- }
- }
- mono_mb_free (mb);
-
- return res;
-}
/*
* mono_marshal_get_stfld_wrapper:
WrapperInfo *info;
char *name;
int t, pos;
+ static MonoMethod *tp_store = NULL;
type = mono_type_get_underlying_type (type);
t = type->type;
if ((res = mono_marshal_find_in_cache (cache, klass)))
return res;
+#ifndef DISABLE_REMOTING
+ if (!tp_store) {
+ tp_store = mono_class_get_method_from_name (mono_defaults.transparent_proxy_class, "StoreRemoteField", -1);
+ g_assert (tp_store != NULL);
+ }
+#endif
+
/* we add the %p pointer value of klass because class names are not unique */
name = g_strdup_printf ("__stfld_wrapper_%p_%s.%s", klass, klass->name_space, klass->name);
mb = mono_mb_new (mono_defaults.object_class, name, MONO_WRAPPER_STFLD);
mono_mb_emit_ldarg (mb, 0);
pos = mono_mb_emit_proxy_check (mb, CEE_BNE_UN);
+#ifndef DISABLE_REMOTING
mono_mb_emit_ldarg (mb, 0);
mono_mb_emit_ldarg (mb, 1);
mono_mb_emit_ldarg (mb, 2);
if (klass->valuetype)
mono_mb_emit_op (mb, CEE_BOX, klass);
- mono_mb_emit_managed_call (mb, mono_marshal_get_stfld_remote_wrapper (klass), NULL);
+ mono_mb_emit_managed_call (mb, tp_store, NULL);
mono_mb_emit_byte (mb, CEE_RET);
+#endif
mono_mb_patch_branch (mb, pos);
MonoMethod *
mono_marshal_get_ldflda_wrapper (MonoType *type);
-MonoMethod *
-mono_marshal_get_ldfld_remote_wrapper (MonoClass *klass);
-
-MonoMethod *
-mono_marshal_get_stfld_remote_wrapper (MonoClass *klass);
-
MonoMethod *
mono_marshal_get_proxy_cancast (MonoClass *klass);
WRAPPER(XDOMAIN_DISPATCH, "xdomain-dispatch")
WRAPPER(LDFLD, "ldfld")
WRAPPER(STFLD, "stfld")
-WRAPPER(STFLD_REMOTE, "stfld-remote")
WRAPPER(SYNCHRONIZED, "synchronized")
WRAPPER(DYNAMIC_METHOD, "dynamic-method")
WRAPPER(ISINST, "isinst")
encode_klass_ref (acfg, info->d.proxy.klass, p, &p);
break;
}
- case MONO_WRAPPER_STFLD_REMOTE:
- break;
case MONO_WRAPPER_ALLOC: {
/* The GC name is saved once in MonoAotFileInfo */
g_assert (info->d.alloc.alloc_type != -1);
case MONO_WRAPPER_STFLD:
case MONO_WRAPPER_LDFLD:
case MONO_WRAPPER_LDFLDA:
- case MONO_WRAPPER_STFLD_REMOTE:
case MONO_WRAPPER_STELEMREF:
case MONO_WRAPPER_ISINST:
case MONO_WRAPPER_PROXY_ISINST:
}
break;
}
- case MONO_WRAPPER_STFLD_REMOTE:
- ref->method = mono_marshal_get_stfld_remote_wrapper (NULL);
- break;
#endif
case MONO_WRAPPER_ALLOC: {
int atype = decode_value (p, &p);
register_icall (mono_thread_get_undeniable_exception, "mono_thread_get_undeniable_exception", "object", FALSE);
register_icall (mono_thread_interruption_checkpoint, "mono_thread_interruption_checkpoint", "object", FALSE);
register_icall (mono_thread_force_interruption_checkpoint_noraise, "mono_thread_force_interruption_checkpoint_noraise", "object", FALSE);
-#ifndef DISABLE_REMOTING
- register_icall (mono_store_remote_field_new_icall, "mono_store_remote_field_new_icall", "void object ptr ptr object", FALSE);
-#endif
#if defined(__native_client__) || defined(__native_client_codegen__)
register_icall (mono_nacl_gc, "mono_nacl_gc", "void", FALSE);
if (code)
return code;
if (mono_llvm_only) {
- if (method->wrapper_type == MONO_WRAPPER_PROXY_ISINST ||
- method->wrapper_type == MONO_WRAPPER_STFLD_REMOTE)
+ if (method->wrapper_type == MONO_WRAPPER_PROXY_ISINST)
/* These wrappers are not generated */
return method_not_found;
/* Methods are lazily initialized on first call, so this can't lead recursion */