2 * object.c: Object creation for the Mono runtime
5 * Miguel de Icaza (miguel@ximian.com)
7 * (C) 2001 Ximian, Inc.
14 #include <mono/metadata/mono-endian.h>
15 #include <mono/metadata/tabledefs.h>
16 #include <mono/metadata/tokentype.h>
17 #include <mono/metadata/loader.h>
18 #include <mono/metadata/object.h>
19 #include <mono/metadata/appdomain.h>
26 /* next object id for object hashcode */
27 static guint32 uoid = 0;
30 mono_runtime_object_init (MonoObject *this)
33 MonoMethod *method = NULL;
34 MonoClass *klass = this->vtable->klass;
36 for (i = 0; i < klass->method.count; ++i) {
37 if (!strcmp (".ctor", klass->methods [i]->name) &&
38 klass->methods [i]->signature->param_count == 0) {
39 method = klass->methods [i];
46 mono_runtime_invoke (method, this, NULL);
51 * @klass: klass that needs to be initialized
53 * This routine calls the class constructor for @class.
56 mono_runtime_class_init (MonoClass *klass)
60 for (i = 0; i < klass->method.count; ++i) {
61 MonoMethod *method = klass->methods [i];
62 if ((method->flags & METHOD_ATTRIBUTE_SPECIAL_NAME) &&
63 (strcmp (".cctor", method->name) == 0)) {
64 mono_runtime_invoke (method, NULL, NULL);
68 /* No class constructor found */
72 default_trampoline (MonoMethod *method)
78 default_remoting_trampoline (MonoMethod *method)
80 g_error ("remoting not installed");
84 static MonoTrampoline arch_create_jit_trampoline = default_trampoline;
85 static MonoTrampoline arch_create_remoting_trampoline = default_remoting_trampoline;
88 mono_install_trampoline (MonoTrampoline func)
90 arch_create_jit_trampoline = func? func: default_trampoline;
94 mono_install_remoting_trampoline (MonoTrampoline func)
96 arch_create_remoting_trampoline = func? func: default_remoting_trampoline;
99 #if 0 && HAVE_BOEHM_GC
101 vtable_finalizer (void *obj, void *data) {
102 g_print ("%s finalized (%p)\n", (char*)data, obj);
108 * @domain: the application domain
109 * @class: the class to initialize
111 * VTables are domain specific because we create domain specific code, and
112 * they contain the domain specific static class data.
115 mono_class_vtable (MonoDomain *domain, MonoClass *class)
119 MonoClassField *field;
121 guint32 cols [MONO_CONSTANT_SIZE];
128 /* can interfaces have static fields? */
129 if (class->flags & TYPE_ATTRIBUTE_INTERFACE)
130 g_assert_not_reached ();
132 mono_domain_lock (domain);
133 if ((vt = mono_g_hash_table_lookup (domain->class_vtable_hash, class))) {
134 mono_domain_unlock (domain);
139 mono_class_init (class);
141 // mono_stats.used_class_count++;
142 // mono_stats.class_vtable_size += sizeof (MonoVTable) + class->vtable_size * sizeof (gpointer);
144 vt = mono_mempool_alloc0 (domain->mp, sizeof (MonoVTable) +
145 class->vtable_size * sizeof (gpointer));
149 if (class->class_size) {
151 vt->data = GC_malloc (class->class_size + 8);
152 /*vt->data = GC_debug_malloc (class->class_size + 8, class->name, 2);*/
153 /*GC_register_finalizer (vt->data, vtable_finalizer, class->name, NULL, NULL);*/
154 mono_g_hash_table_insert (domain->static_data_hash, class, vt->data);
156 vt->data = mono_mempool_alloc0 (domain->mp, class->class_size + 8);
159 // mono_stats.class_static_data_size += class->class_size + 8;
162 for (i = class->field.first; i < class->field.last; ++i) {
163 field = &class->fields [i - class->field.first];
164 if (!(field->type->attrs & FIELD_ATTRIBUTE_STATIC))
166 if (!(field->type->attrs & FIELD_ATTRIBUTE_HAS_DEFAULT))
168 cindex = mono_metadata_get_constant_index (class->image, MONO_TOKEN_FIELD_DEF | (i + 1));
170 g_warning ("constant for field %s not found", field->name);
173 mono_metadata_decode_row (&class->image->tables [MONO_TABLE_CONSTANT], cindex - 1, cols, MONO_CONSTANT_SIZE);
174 p = mono_metadata_blob_heap (class->image, cols [MONO_CONSTANT_VALUE]);
175 len = mono_metadata_decode_blob_size (p, &p);
176 t = (char*)vt->data + field->offset;
177 /* should we check that the type matches? */
178 switch (cols [MONO_CONSTANT_TYPE]) {
179 case MONO_TYPE_BOOLEAN:
187 guint16 *val = (guint16*)t;
193 guint32 *val = (guint32*)t;
199 guint64 *val = (guint64*)t;
204 float *val = (float*)t;
209 double *val = (double*)t;
213 case MONO_TYPE_STRING: {
214 //gpointer *val = (gpointer*)t;
215 //*val = mono_string_new_utf16 (domain, (const guint16*)p, len/2);
218 case MONO_TYPE_CLASS:
219 /* nothing to do, we malloc0 the data and the value can be 0 only */
222 g_warning ("type 0x%02x should not be in constant table", cols [MONO_CONSTANT_TYPE]);
226 vt->max_interface_id = class->max_interface_id;
228 vt->interface_offsets = mono_mempool_alloc0 (domain->mp,
229 sizeof (gpointer) * (class->max_interface_id + 1));
231 /* initialize interface offsets */
232 for (k = class; k ; k = k->parent) {
233 for (i = 0; i < k->interface_count; i++) {
235 MonoClass *ic = k->interfaces [i];
236 slot = class->interface_offsets [ic->interface_id];
237 vt->interface_offsets [ic->interface_id] = &vt->vtable [slot];
241 /* initialize vtable */
242 for (i = 0; i < class->vtable_size; ++i) {
245 if ((cm = class->vtable [i]))
246 vt->vtable [i] = arch_create_jit_trampoline (cm);
249 mono_g_hash_table_insert (domain->class_vtable_hash, class, vt);
250 mono_domain_unlock (domain);
252 mono_runtime_class_init (class);
258 * mono_class_proxy_vtable:
259 * @domain: the application domain
260 * @class: the class to proxy
262 * Creates a vtable for transparent proxies. It is basically
263 * a copy of the real vtable of @class, but all function pointers invoke
264 * the remoting functions, and vtable->klass points to the
265 * transparent proxy class, and not to @class.
268 mono_class_proxy_vtable (MonoDomain *domain, MonoClass *class)
270 MonoVTable *vt, *pvt;
273 if ((pvt = mono_g_hash_table_lookup (domain->proxy_vtable_hash, class)))
276 vt = mono_class_vtable (domain, class);
277 vtsize = sizeof (MonoVTable) + class->vtable_size * sizeof (gpointer);
279 // mono_stats.class_vtable_size += vtsize;
281 pvt = mono_mempool_alloc (domain->mp, vtsize);
282 memcpy (pvt, vt, vtsize);
284 pvt->klass = mono_defaults.transparent_proxy_class;
286 /* initialize vtable */
287 for (i = 0; i < class->vtable_size; ++i) {
290 if ((cm = class->vtable [i]))
291 pvt->vtable [i] = arch_create_remoting_trampoline (cm);
294 mono_g_hash_table_insert (domain->proxy_vtable_hash, class, pvt);
299 static MonoInvokeFunc default_mono_runtime_invoke = NULL;
302 mono_runtime_invoke (MonoMethod *method, void *obj, void **params)
304 if (!default_mono_runtime_invoke) {
305 g_error ("runtime invoke called on uninitialized runtime");
308 return default_mono_runtime_invoke (method, obj, params);
312 mono_runtime_exec_main (MonoMethod *method, MonoArray *args)
318 if (method->signature->ret->type == MONO_TYPE_I4) {
320 res = mono_runtime_invoke (method, NULL, pa);
321 return *(guint32 *)((char *)res + sizeof (MonoObject));
323 mono_runtime_invoke (method, NULL, pa);
329 mono_install_runtime_invoke (MonoInvokeFunc func)
331 default_mono_runtime_invoke = func;
335 mono_runtime_invoke_array (MonoMethod *method, void *obj, MonoArray *params)
337 MonoMethodSignature *sig = method->signature;
341 pa = alloca (sizeof (gpointer) * mono_array_length (params));
343 for (i = 0; i < mono_array_length (params); i++) {
344 if (sig->params [i]->byref) {
348 switch (sig->params [i]->type) {
351 case MONO_TYPE_BOOLEAN:
361 case MONO_TYPE_VALUETYPE:
362 pa [i] = (char *)(((gpointer *)params->vector)[i]) + sizeof (MonoObject);
364 case MONO_TYPE_STRING:
365 case MONO_TYPE_OBJECT:
366 case MONO_TYPE_CLASS:
367 pa [i] = (char *)(((gpointer *)params->vector)[i]);
370 g_error ("type 0x%x not handled in ves_icall_InternalInvoke", sig->params [i]->type);
374 if (!strcmp (method->name, ".ctor")) {
375 obj = mono_object_new (mono_domain_get (), method->klass);
376 mono_runtime_invoke (method, obj, pa);
379 return mono_runtime_invoke (method, obj, pa);
383 * mono_object_allocate:
384 * @size: number of bytes to allocate
386 * This is a very simplistic routine until we have our GC-aware
389 * Returns: an allocated object of size @size, or NULL on failure.
392 mono_object_allocate (size_t size)
395 void *o = GC_debug_malloc (size, "object", 1);
397 void *o = calloc (1, size);
406 * Frees the memory used by the object. Debugging purposes
407 * only, as we will have our GC system.
410 mono_object_free (MonoObject *o)
413 g_error ("mono_object_free called with boehm gc.");
415 MonoClass *c = o->vtable->klass;
417 memset (o, 0, c->instance_size);
424 * @klass: the class of the object that we want to create
426 * Returns: A newly created object whose definition is
427 * looked up using @klass
430 mono_object_new (MonoDomain *domain, MonoClass *klass)
432 return mono_object_new_specific (mono_class_vtable (domain, klass));
436 * mono_object_new_specific:
437 * @vtable: the vtable of the object that we want to create
439 * Returns: A newly created object with class and domain specified
443 mono_object_new_specific (MonoVTable *vtable)
447 mono_stats.new_object_count++; /* thread safe? */
449 if (vtable->klass->ghcimpl)
450 o = mono_object_allocate (vtable->klass->instance_size);
453 t = mono_object_allocate (vtable->klass->instance_size + 4);
455 o = (MonoObject *)(++t);
463 * mono_object_new_from_token:
464 * @image: Context where the type_token is hosted
465 * @token: a token of the type that we want to create
467 * Returns: A newly created object whose definition is
468 * looked up using @token in the @image image
471 mono_object_new_from_token (MonoDomain *domain, MonoImage *image, guint32 token)
475 class = mono_class_get (image, token);
477 return mono_object_new (domain, class);
483 * @obj: the object to clone
485 * Returns: A newly created object who is a shallow copy of @obj
488 mono_object_clone (MonoObject *obj)
493 size = obj->vtable->klass->instance_size;
494 o = mono_object_allocate (size);
496 memcpy (o, obj, size);
503 * @array: the array to clone
505 * Returns: A newly created array who is a shallow copy of @array
508 mono_array_clone (MonoArray *array)
513 MonoClass *klass = array->obj.vtable->klass;
515 if (array->bounds == NULL) {
516 size = mono_array_length (array);
517 o = mono_array_new_full (((MonoObject *)array)->vtable->domain,
520 size *= mono_array_element_size (klass);
521 memcpy (o, array, sizeof (MonoArray) + size);
526 sizes = alloca (klass->rank * sizeof(guint32) * 2);
527 size = mono_array_element_size (klass);
528 for (i = 0; i < klass->rank; ++i) {
529 sizes [i] = array->bounds [i].length;
530 size *= array->bounds [i].length;
531 sizes [i + klass->rank] = array->bounds [i].lower_bound;
533 o = mono_array_new_full (((MonoObject *)array)->vtable->domain,
534 klass, sizes, sizes + klass->rank);
535 memcpy (o, array, sizeof(MonoArray) + size);
541 * mono_array_new_full:
542 * @domain: domain where the object is created
543 * @array_class: array class
544 * @lengths: lengths for each dimension in the array
545 * @lower_bounds: lower bounds for each dimension in the array (may be NULL)
547 * This routine creates a new array objects with the given dimensions,
548 * lower bounds and type.
551 mono_array_new_full (MonoDomain *domain, MonoClass *array_class,
552 guint32 *lengths, guint32 *lower_bounds)
554 guint32 byte_len, len;
557 MonoArrayBounds *bounds;
560 if (!array_class->inited)
561 mono_class_init (array_class);
563 byte_len = mono_array_element_size (array_class);
566 if (array_class->rank == 1 &&
567 (lower_bounds == NULL || lower_bounds [0] == 0)) {
572 bounds = GC_debug_malloc (sizeof (MonoArrayBounds) * array_class->rank, "bounds", 0);
574 bounds = g_malloc0 (sizeof (MonoArrayBounds) * array_class->rank);
576 for (i = 0; i < array_class->rank; ++i) {
577 bounds [i].length = lengths [i];
582 for (i = 0; i < array_class->rank; ++i)
583 bounds [i].lower_bound = lower_bounds [i];
588 * Following three lines almost taken from mono_object_new ():
589 * they need to be kept in sync.
591 o = mono_object_allocate (sizeof (MonoArray) + byte_len);
594 o->vtable = mono_class_vtable (domain, array_class);
596 array = (MonoArray*)o;
598 array->bounds = bounds;
599 array->max_length = len;
606 * @domain: domain where the object is created
607 * @eclass: element class
608 * @n: number of array elements
610 * This routine creates a new szarray with @n elements of type @eclass.
613 mono_array_new (MonoDomain *domain, MonoClass *eclass, guint32 n)
617 ac = mono_array_class_get (&eclass->byval_arg, 1);
618 g_assert (ac != NULL);
620 return mono_array_new_specific (mono_class_vtable (domain, ac), n);
624 * mono_array_new_specific:
625 * @vtable: a vtable in the appropriate domain for an initialized class
626 * @n: number of array elements
628 * This routine is a fast alternative to mono_array_new() for code which
629 * can be sure about the domain it operates in.
632 mono_array_new_specific (MonoVTable *vtable, guint32 n)
638 byte_len = n * mono_array_element_size (vtable->klass);
639 o = mono_object_allocate (sizeof (MonoArray) + byte_len);
652 * mono_string_new_utf16:
653 * @text: a pointer to an utf16 string
654 * @len: the length of the string
656 * Returns: A newly created string object which contains @text.
659 mono_string_new_utf16 (MonoDomain *domain, const guint16 *text, gint32 len)
663 s = mono_string_new_size (domain, len);
664 g_assert (s != NULL);
666 memcpy (mono_string_chars (s), text, len * 2);
672 * mono_string_new_size:
673 * @text: a pointer to an utf16 string
674 * @len: the length of the string
676 * Returns: A newly created string object of @len
679 mono_string_new_size (MonoDomain *domain, gint32 len)
683 s = (MonoString*)mono_object_allocate (sizeof (MonoString) + (len * 2));
687 s->object.vtable = mono_class_vtable (domain, mono_defaults.string_class);
694 * mono_string_new_len:
695 * @text: a pointer to an utf8 string
696 * @length: number of bytes in @text to consider
698 * Returns: A newly created string object which contains @text.
701 mono_string_new_len (MonoDomain *domain, const char *text, guint length)
703 GError *error = NULL;
704 MonoString *o = NULL;
709 ut = g_utf8_to_utf16 (text, length, NULL, &items_written, &error);
712 o = mono_string_new_utf16 (domain, ut, items_written);
714 g_error_free (error);
723 * @text: a pointer to an utf8 string
725 * Returns: A newly created string object which contains @text.
728 mono_string_new (MonoDomain *domain, const char *text)
730 GError *error = NULL;
731 MonoString *o = NULL;
738 ut = g_utf8_to_utf16 (text, l, NULL, &items_written, &error);
741 o = mono_string_new_utf16 (domain, ut, items_written);
743 g_error_free (error);
751 * mono_string_new_wrapper:
752 * @text: pointer to utf8 characters.
754 * Helper function to create a string object from @text in the current domain.
757 mono_string_new_wrapper (const char *text)
759 MonoDomain *domain = mono_domain_get ();
761 return mono_string_new (domain, text);
766 * @class: the class of the value
767 * @value: a pointer to the unboxed data
769 * Returns: A newly created object which contains @value.
772 mono_value_box (MonoDomain *domain, MonoClass *class, gpointer value)
777 g_assert (class->valuetype);
779 size = mono_class_instance_size (class);
780 res = mono_object_allocate (size);
781 res->vtable = mono_class_vtable (domain, class);
783 size = size - sizeof (MonoObject);
785 memcpy ((char *)res + sizeof (MonoObject), value, size);
791 * mono_object_isinst:
793 * @klass: a pointer to a class
795 * Returns: @obj if @obj is derived from @klass
798 mono_object_isinst (MonoObject *obj, MonoClass *klass)
810 mono_class_init (klass);
812 if (klass->flags & TYPE_ATTRIBUTE_INTERFACE) {
813 if ((klass->interface_id <= oklass->max_interface_id) &&
814 vt->interface_offsets [klass->interface_id])
817 if (oklass == mono_defaults.transparent_proxy_class) {
818 /* fixme: add check for IRemotingTypeInfo */
819 oklass = ((MonoTransparentProxy *)obj)->klass;
822 if (oklass->rank == klass->rank &&
823 (oklass->element_class->baseval - klass->element_class->baseval) <=
824 klass->element_class->diffval)
827 } else if ((oklass->baseval - klass->baseval) <= klass->diffval)
835 mono_string_is_interned_lookup (MonoString *str, int insert)
837 MonoGHashTable *ldstr_table;
840 char *ins = g_malloc (4 + str->length * 2);
844 /* Encode the length */
846 mono_metadata_encode_value (2 * str->length, p, &p);
849 mono_metadata_encode_value (bloblen + 2 * str->length, p, &p);
850 bloblen = (p - ins) + 2 * str->length;
852 * ins is stored in the hash table as a key and needs to have the same
853 * representation as in the metadata: we swap the character bytes on big
856 #if G_BYTE_ORDER != G_LITTLE_ENDIAN
859 char *p2 = mono_string_chars (str);
860 for (i = 0; i < str->length; ++i) {
867 memcpy (p, mono_string_chars (str), str->length * 2);
869 domain = ((MonoObject *)str)->vtable->domain;
870 ldstr_table = domain->ldstr_table;
871 mono_domain_lock (domain);
872 if ((res = mono_g_hash_table_lookup (ldstr_table, ins))) {
873 mono_domain_unlock (domain);
878 mono_g_hash_table_insert (ldstr_table, ins, str);
879 mono_domain_unlock (domain);
882 mono_domain_unlock (domain);
888 mono_string_is_interned (MonoString *o)
890 return mono_string_is_interned_lookup (o, FALSE);
894 mono_string_intern (MonoString *str)
896 return mono_string_is_interned_lookup (str, TRUE);
901 * @domain: the domain where the string will be used.
902 * @image: a metadata context
903 * @idx: index into the user string table.
905 * Implementation for the ldstr opcode.
908 mono_ldstr (MonoDomain *domain, MonoImage *image, guint32 idx)
910 const char *str, *sig;
914 sig = str = mono_metadata_user_string (image, idx);
916 mono_domain_lock (domain);
917 if ((o = mono_g_hash_table_lookup (domain->ldstr_table, sig))) {
918 mono_domain_unlock (domain);
922 len2 = mono_metadata_decode_blob_size (str, &str);
925 o = mono_string_new_utf16 (domain, (guint16*)str, len2);
926 #if G_BYTE_ORDER != G_LITTLE_ENDIAN
929 guint16 *p2 = (guint16*)mono_array_addr (o->c_str, guint16, 0);
930 for (i = 0; i < len2; ++i) {
931 *p2 = GUINT16_FROM_LE (*p2);
936 mono_g_hash_table_insert (domain->ldstr_table, (gpointer)sig, o);
937 mono_domain_unlock (domain);
943 * mono_string_to_utf8:
944 * @s: a System.String
946 * Return the UTF8 representation for @s.
947 * the resulting buffer nedds to be freed with g_free().
950 mono_string_to_utf8 (MonoString *s)
953 GError *error = NULL;
955 g_assert (s != NULL);
958 return g_strdup ("");
960 as = g_utf16_to_utf8 (mono_string_chars (s), s->length, NULL, NULL, &error);
962 g_warning (error->message);
968 * mono_string_to_utf16:
971 * Return an null-terminated array of the utf-16 chars
972 * contained in @s. The result must be freed with g_free().
973 * This is a temporary helper until our string implementation
974 * is reworked to always include the null terminating char.
977 mono_string_to_utf16 (MonoString *s)
981 g_assert (s != NULL);
983 as = g_malloc ((s->length * 2) + 2);
984 as [(s->length * 2)] = '\0';
985 as [(s->length * 2) + 1] = '\0';
988 return (gunichar2 *)(as);
991 memcpy (as, mono_string_chars(s), s->length * 2);
993 return (gunichar2 *)(as);
997 default_ex_handler (MonoException *ex)
999 MonoObject *o = (MonoObject*)ex;
1000 g_error ("Exception %s.%s raised in C code", o->vtable->klass->name_space, o->vtable->klass->name);
1003 static MonoExceptionFunc ex_handler = default_ex_handler;
1006 mono_install_handler (MonoExceptionFunc func)
1008 ex_handler = func? func: default_ex_handler;
1012 * mono_raise_exception:
1013 * @ex: exception object
1015 * Signal the runtime that the exception @ex has been raised in unmanaged code.
1018 mono_raise_exception (MonoException *ex)
1024 mono_wait_handle_new (MonoDomain *domain, HANDLE handle)
1026 MonoWaitHandle *res;
1028 res = (MonoWaitHandle *)mono_object_new (domain, mono_defaults.waithandle_class);
1030 res->handle = handle;
1036 mono_async_result_new (MonoDomain *domain, HANDLE handle, MonoObject *state, gpointer data)
1038 MonoAsyncResult *res;
1040 res = (MonoAsyncResult *)mono_object_new (domain, mono_defaults.asyncresult_class);
1043 res->async_state = state;
1044 res->handle = (MonoObject *)mono_wait_handle_new (domain, handle);
1045 res->sync_completed = FALSE;
1046 res->completed = FALSE;
1052 mono_message_init (MonoDomain *domain,
1053 MonoMethodMessage *this,
1054 MonoReflectionMethod *method,
1055 MonoArray *out_args)
1057 MonoMethodSignature *sig = method->method->signature;
1063 this->method = method;
1065 this->args = mono_array_new (domain, mono_defaults.object_class, sig->param_count);
1066 this->arg_types = mono_array_new (domain, mono_defaults.byte_class, sig->param_count);
1068 names = g_new (char *, sig->param_count);
1069 mono_method_get_param_names (method->method, (const char **) names);
1070 this->names = mono_array_new (domain, mono_defaults.string_class, sig->param_count);
1072 for (i = 0; i < sig->param_count; i++) {
1073 name = mono_string_new (domain, names [i]);
1074 mono_array_set (this->names, gpointer, i, name);
1079 for (i = 0, j = 0; i < sig->param_count; i++) {
1081 if (sig->params [i]->byref) {
1083 gpointer arg = mono_array_get (out_args, gpointer, j);
1084 mono_array_set (this->args, gpointer, i, arg);
1088 if (sig->params [i]->attrs & PARAM_ATTRIBUTE_IN)
1094 mono_array_set (this->arg_types, guint8, i, arg_type);
1099 * mono_remoting_invoke:
1100 * @real_proxy: pointer to a RealProxy object
1101 * @msg: The MonoMethodMessage to execute
1102 * @exc: used to store exceptions
1103 * @out_args: used to store output arguments
1105 * This is used to call RealProxy::Invoke(). RealProxy::Invoke() returns an
1106 * IMessage interface and it is not trivial to extract results from there. So
1107 * we call an helper method PrivateInvoke instead of calling
1108 * RealProxy::Invoke() directly.
1110 * Returns: the result object.
1113 mono_remoting_invoke (MonoObject *real_proxy, MonoMethodMessage *msg,
1114 MonoObject **exc, MonoArray **out_args)
1116 static MonoMethod *im = NULL;
1119 //static MonoObject *(*invoke) (gpointer, gpointer, MonoObject **, MonoArray **) = NULL;
1121 /* fixme: make this domain dependent */
1126 klass = mono_defaults.real_proxy_class;
1128 for (i = 0; i < klass->method.count; ++i) {
1129 if (!strcmp ("PrivateInvoke", klass->methods [i]->name) &&
1130 klass->methods [i]->signature->param_count == 4) {
1131 im = klass->methods [i];
1139 pa [0] = real_proxy;
1144 return mono_runtime_invoke (im, NULL, pa);
1148 mono_message_invoke (MonoObject *target, MonoMethodMessage *msg,
1149 MonoObject **exc, MonoArray **out_args)
1151 if (target && target->vtable->klass == mono_defaults.transparent_proxy_class) {
1153 return mono_remoting_invoke ((MonoObject *)((MonoTransparentProxy *)target)->rp,
1154 msg, exc, out_args);
1157 MonoDomain *domain = mono_domain_get ();
1158 MonoMethod *method = msg->method->method;
1159 MonoMethodSignature *sig = method->signature;
1160 int i, j, outarg_count = 0;
1162 for (i = 0; i < sig->param_count; i++) {
1163 if (sig->params [i]->byref)
1167 *out_args = mono_array_new (domain, mono_defaults.object_class, outarg_count);
1170 for (i = 0, j = 0; i < sig->param_count; i++) {
1171 if (sig->params [i]->byref) {
1173 arg = mono_array_get (msg->args, gpointer, i);
1174 mono_array_set (*out_args, gpointer, j, arg);
1179 return mono_runtime_invoke_array (method, target, msg->args);