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/gc.h>
20 #include <mono/metadata/appdomain.h>
27 /* next object id for object hashcode */
28 static guint32 uoid = 0;
31 mono_runtime_object_init (MonoObject *this)
34 MonoMethod *method = NULL;
35 MonoClass *klass = this->vtable->klass;
37 for (i = 0; i < klass->method.count; ++i) {
38 if (!strcmp (".ctor", klass->methods [i]->name) &&
39 klass->methods [i]->signature->param_count == 0) {
40 method = klass->methods [i];
47 mono_runtime_invoke (method, this, NULL);
52 * @klass: klass that needs to be initialized
54 * This routine calls the class constructor for @class.
57 mono_runtime_class_init (MonoClass *klass)
61 for (i = 0; i < klass->method.count; ++i) {
62 MonoMethod *method = klass->methods [i];
63 if ((method->flags & METHOD_ATTRIBUTE_SPECIAL_NAME) &&
64 (strcmp (".cctor", method->name) == 0)) {
65 mono_runtime_invoke (method, NULL, NULL);
69 /* No class constructor found */
73 default_trampoline (MonoMethod *method)
79 default_remoting_trampoline (MonoMethod *method)
81 g_error ("remoting not installed");
85 static MonoTrampoline arch_create_jit_trampoline = default_trampoline;
86 static MonoTrampoline arch_create_remoting_trampoline = default_remoting_trampoline;
89 mono_install_trampoline (MonoTrampoline func)
91 arch_create_jit_trampoline = func? func: default_trampoline;
95 mono_install_remoting_trampoline (MonoTrampoline func)
97 arch_create_remoting_trampoline = func? func: default_remoting_trampoline;
100 #if 0 && HAVE_BOEHM_GC
102 vtable_finalizer (void *obj, void *data) {
103 g_print ("%s finalized (%p)\n", (char*)data, obj);
109 * @domain: the application domain
110 * @class: the class to initialize
112 * VTables are domain specific because we create domain specific code, and
113 * they contain the domain specific static class data.
116 mono_class_vtable (MonoDomain *domain, MonoClass *class)
120 MonoClassField *field;
122 guint32 cols [MONO_CONSTANT_SIZE];
129 /* can interfaces have static fields? */
130 if (class->flags & TYPE_ATTRIBUTE_INTERFACE)
131 g_assert_not_reached ();
133 mono_domain_lock (domain);
134 if ((vt = mono_g_hash_table_lookup (domain->class_vtable_hash, class))) {
135 mono_domain_unlock (domain);
140 mono_class_init (class);
142 // mono_stats.used_class_count++;
143 // mono_stats.class_vtable_size += sizeof (MonoVTable) + class->vtable_size * sizeof (gpointer);
145 vt = mono_mempool_alloc0 (domain->mp, sizeof (MonoVTable) +
146 class->vtable_size * sizeof (gpointer));
150 if (class->class_size) {
152 vt->data = GC_malloc (class->class_size + 8);
153 /*vt->data = GC_debug_malloc (class->class_size + 8, class->name, 2);*/
154 /*GC_register_finalizer (vt->data, vtable_finalizer, class->name, NULL, NULL);*/
155 mono_g_hash_table_insert (domain->static_data_hash, class, vt->data);
157 vt->data = mono_mempool_alloc0 (domain->mp, class->class_size + 8);
160 // mono_stats.class_static_data_size += class->class_size + 8;
163 for (i = class->field.first; i < class->field.last; ++i) {
164 field = &class->fields [i - class->field.first];
165 if (!(field->type->attrs & FIELD_ATTRIBUTE_STATIC))
167 if (!(field->type->attrs & FIELD_ATTRIBUTE_HAS_DEFAULT))
169 cindex = mono_metadata_get_constant_index (class->image, MONO_TOKEN_FIELD_DEF | (i + 1));
171 g_warning ("constant for field %s not found", field->name);
174 mono_metadata_decode_row (&class->image->tables [MONO_TABLE_CONSTANT], cindex - 1, cols, MONO_CONSTANT_SIZE);
175 p = mono_metadata_blob_heap (class->image, cols [MONO_CONSTANT_VALUE]);
176 len = mono_metadata_decode_blob_size (p, &p);
177 t = (char*)vt->data + field->offset;
178 /* should we check that the type matches? */
179 switch (cols [MONO_CONSTANT_TYPE]) {
180 case MONO_TYPE_BOOLEAN:
188 guint16 *val = (guint16*)t;
194 guint32 *val = (guint32*)t;
200 guint64 *val = (guint64*)t;
205 float *val = (float*)t;
210 double *val = (double*)t;
214 case MONO_TYPE_STRING: {
215 //gpointer *val = (gpointer*)t;
216 //*val = mono_string_new_utf16 (domain, (const guint16*)p, len/2);
219 case MONO_TYPE_CLASS:
220 /* nothing to do, we malloc0 the data and the value can be 0 only */
223 g_warning ("type 0x%02x should not be in constant table", cols [MONO_CONSTANT_TYPE]);
227 vt->max_interface_id = class->max_interface_id;
229 vt->interface_offsets = mono_mempool_alloc0 (domain->mp,
230 sizeof (gpointer) * (class->max_interface_id + 1));
232 /* initialize interface offsets */
233 for (k = class; k ; k = k->parent) {
234 for (i = 0; i < k->interface_count; i++) {
236 MonoClass *ic = k->interfaces [i];
237 slot = class->interface_offsets [ic->interface_id];
238 vt->interface_offsets [ic->interface_id] = &vt->vtable [slot];
242 /* initialize vtable */
243 for (i = 0; i < class->vtable_size; ++i) {
246 if ((cm = class->vtable [i]))
247 vt->vtable [i] = arch_create_jit_trampoline (cm);
250 mono_g_hash_table_insert (domain->class_vtable_hash, class, vt);
251 mono_domain_unlock (domain);
253 mono_runtime_class_init (class);
259 * mono_class_proxy_vtable:
260 * @domain: the application domain
261 * @class: the class to proxy
263 * Creates a vtable for transparent proxies. It is basically
264 * a copy of the real vtable of @class, but all function pointers invoke
265 * the remoting functions, and vtable->klass points to the
266 * transparent proxy class, and not to @class.
269 mono_class_proxy_vtable (MonoDomain *domain, MonoClass *class)
271 MonoVTable *vt, *pvt;
274 if ((pvt = mono_g_hash_table_lookup (domain->proxy_vtable_hash, class)))
277 vt = mono_class_vtable (domain, class);
278 vtsize = sizeof (MonoVTable) + class->vtable_size * sizeof (gpointer);
280 // mono_stats.class_vtable_size += vtsize;
282 pvt = mono_mempool_alloc (domain->mp, vtsize);
283 memcpy (pvt, vt, vtsize);
285 pvt->klass = mono_defaults.transparent_proxy_class;
287 /* initialize vtable */
288 for (i = 0; i < class->vtable_size; ++i) {
291 if ((cm = class->vtable [i]))
292 pvt->vtable [i] = arch_create_remoting_trampoline (cm);
295 mono_g_hash_table_insert (domain->proxy_vtable_hash, class, pvt);
300 static MonoInvokeFunc default_mono_runtime_invoke = NULL;
303 mono_runtime_invoke (MonoMethod *method, void *obj, void **params)
305 if (!default_mono_runtime_invoke) {
306 g_error ("runtime invoke called on uninitialized runtime");
309 return default_mono_runtime_invoke (method, obj, params);
313 mono_runtime_exec_main (MonoMethod *method, MonoArray *args)
319 if (method->signature->ret->type == MONO_TYPE_I4) {
321 res = mono_runtime_invoke (method, NULL, pa);
322 return *(guint32 *)((char *)res + sizeof (MonoObject));
324 mono_runtime_invoke (method, NULL, pa);
330 mono_install_runtime_invoke (MonoInvokeFunc func)
332 default_mono_runtime_invoke = func;
336 mono_runtime_invoke_array (MonoMethod *method, void *obj, MonoArray *params)
338 MonoMethodSignature *sig = method->signature;
342 if (NULL != params) {
343 pa = alloca (sizeof (gpointer) * mono_array_length (params));
344 for (i = 0; i < mono_array_length (params); i++) {
345 if (sig->params [i]->byref) {
349 switch (sig->params [i]->type) {
352 case MONO_TYPE_BOOLEAN:
362 case MONO_TYPE_VALUETYPE:
363 pa [i] = (char *)(((gpointer *)params->vector)[i]) + sizeof (MonoObject);
365 case MONO_TYPE_STRING:
366 case MONO_TYPE_OBJECT:
367 case MONO_TYPE_CLASS:
368 pa [i] = (char *)(((gpointer *)params->vector)[i]);
371 g_error ("type 0x%x not handled in ves_icall_InternalInvoke", sig->params [i]->type);
376 if (!strcmp (method->name, ".ctor")) {
377 obj = mono_object_new (mono_domain_get (), method->klass);
378 mono_runtime_invoke (method, obj, pa);
381 return mono_runtime_invoke (method, obj, pa);
385 * mono_object_allocate:
386 * @size: number of bytes to allocate
388 * This is a very simplistic routine until we have our GC-aware
391 * Returns: an allocated object of size @size, or NULL on failure.
394 mono_object_allocate (size_t size)
397 void *o = GC_debug_malloc (size, "object", 1);
399 void *o = calloc (1, size);
408 * Frees the memory used by the object. Debugging purposes
409 * only, as we will have our GC system.
412 mono_object_free (MonoObject *o)
415 g_error ("mono_object_free called with boehm gc.");
417 MonoClass *c = o->vtable->klass;
419 memset (o, 0, c->instance_size);
426 * @klass: the class of the object that we want to create
428 * Returns: A newly created object whose definition is
429 * looked up using @klass
432 mono_object_new (MonoDomain *domain, MonoClass *klass)
434 return mono_object_new_specific (mono_class_vtable (domain, klass));
438 * mono_object_new_specific:
439 * @vtable: the vtable of the object that we want to create
441 * Returns: A newly created object with class and domain specified
445 mono_object_new_specific (MonoVTable *vtable)
449 mono_stats.new_object_count++; /* thread safe? */
451 if (vtable->klass->ghcimpl)
452 o = mono_object_allocate (vtable->klass->instance_size);
455 t = mono_object_allocate (vtable->klass->instance_size + 4);
457 o = (MonoObject *)(++t);
460 if (vtable->klass->has_finalize)
461 mono_object_register_finalizer (o);
467 * mono_object_new_from_token:
468 * @image: Context where the type_token is hosted
469 * @token: a token of the type that we want to create
471 * Returns: A newly created object whose definition is
472 * looked up using @token in the @image image
475 mono_object_new_from_token (MonoDomain *domain, MonoImage *image, guint32 token)
479 class = mono_class_get (image, token);
481 return mono_object_new (domain, class);
487 * @obj: the object to clone
489 * Returns: A newly created object who is a shallow copy of @obj
492 mono_object_clone (MonoObject *obj)
497 size = obj->vtable->klass->instance_size;
498 o = mono_object_allocate (size);
500 memcpy (o, obj, size);
502 if (obj->vtable->klass->has_finalize)
503 mono_object_register_finalizer (o);
509 * @array: the array to clone
511 * Returns: A newly created array who is a shallow copy of @array
514 mono_array_clone (MonoArray *array)
519 MonoClass *klass = array->obj.vtable->klass;
521 if (array->bounds == NULL) {
522 size = mono_array_length (array);
523 o = mono_array_new_full (((MonoObject *)array)->vtable->domain,
526 size *= mono_array_element_size (klass);
527 memcpy (o, array, sizeof (MonoArray) + size);
532 sizes = alloca (klass->rank * sizeof(guint32) * 2);
533 size = mono_array_element_size (klass);
534 for (i = 0; i < klass->rank; ++i) {
535 sizes [i] = array->bounds [i].length;
536 size *= array->bounds [i].length;
537 sizes [i + klass->rank] = array->bounds [i].lower_bound;
539 o = mono_array_new_full (((MonoObject *)array)->vtable->domain,
540 klass, sizes, sizes + klass->rank);
541 memcpy (o, array, sizeof(MonoArray) + size);
547 * mono_array_new_full:
548 * @domain: domain where the object is created
549 * @array_class: array class
550 * @lengths: lengths for each dimension in the array
551 * @lower_bounds: lower bounds for each dimension in the array (may be NULL)
553 * This routine creates a new array objects with the given dimensions,
554 * lower bounds and type.
557 mono_array_new_full (MonoDomain *domain, MonoClass *array_class,
558 guint32 *lengths, guint32 *lower_bounds)
560 guint32 byte_len, len;
563 MonoArrayBounds *bounds;
566 if (!array_class->inited)
567 mono_class_init (array_class);
569 byte_len = mono_array_element_size (array_class);
572 if (array_class->rank == 1 &&
573 (lower_bounds == NULL || lower_bounds [0] == 0)) {
578 bounds = GC_debug_malloc (sizeof (MonoArrayBounds) * array_class->rank, "bounds", 0);
580 bounds = g_malloc0 (sizeof (MonoArrayBounds) * array_class->rank);
582 for (i = 0; i < array_class->rank; ++i) {
583 bounds [i].length = lengths [i];
588 for (i = 0; i < array_class->rank; ++i)
589 bounds [i].lower_bound = lower_bounds [i];
594 * Following three lines almost taken from mono_object_new ():
595 * they need to be kept in sync.
597 o = mono_object_allocate (sizeof (MonoArray) + byte_len);
600 o->vtable = mono_class_vtable (domain, array_class);
602 array = (MonoArray*)o;
604 array->bounds = bounds;
605 array->max_length = len;
612 * @domain: domain where the object is created
613 * @eclass: element class
614 * @n: number of array elements
616 * This routine creates a new szarray with @n elements of type @eclass.
619 mono_array_new (MonoDomain *domain, MonoClass *eclass, guint32 n)
623 ac = mono_array_class_get (&eclass->byval_arg, 1);
624 g_assert (ac != NULL);
626 return mono_array_new_specific (mono_class_vtable (domain, ac), n);
630 * mono_array_new_specific:
631 * @vtable: a vtable in the appropriate domain for an initialized class
632 * @n: number of array elements
634 * This routine is a fast alternative to mono_array_new() for code which
635 * can be sure about the domain it operates in.
638 mono_array_new_specific (MonoVTable *vtable, guint32 n)
644 byte_len = n * mono_array_element_size (vtable->klass);
645 o = mono_object_allocate (sizeof (MonoArray) + byte_len);
658 * mono_string_new_utf16:
659 * @text: a pointer to an utf16 string
660 * @len: the length of the string
662 * Returns: A newly created string object which contains @text.
665 mono_string_new_utf16 (MonoDomain *domain, const guint16 *text, gint32 len)
669 s = mono_string_new_size (domain, len);
670 g_assert (s != NULL);
672 memcpy (mono_string_chars (s), text, len * 2);
678 * mono_string_new_size:
679 * @text: a pointer to an utf16 string
680 * @len: the length of the string
682 * Returns: A newly created string object of @len
685 mono_string_new_size (MonoDomain *domain, gint32 len)
689 s = (MonoString*)mono_object_allocate (sizeof (MonoString) + ((len + 1) * 2));
693 s->object.vtable = mono_class_vtable (domain, mono_defaults.string_class);
700 * mono_string_new_len:
701 * @text: a pointer to an utf8 string
702 * @length: number of bytes in @text to consider
704 * Returns: A newly created string object which contains @text.
707 mono_string_new_len (MonoDomain *domain, const char *text, guint length)
709 GError *error = NULL;
710 MonoString *o = NULL;
715 ut = g_utf8_to_utf16 (text, length, NULL, &items_written, &error);
718 o = mono_string_new_utf16 (domain, ut, items_written);
720 g_error_free (error);
729 * @text: a pointer to an utf8 string
731 * Returns: A newly created string object which contains @text.
734 mono_string_new (MonoDomain *domain, const char *text)
736 GError *error = NULL;
737 MonoString *o = NULL;
744 ut = g_utf8_to_utf16 (text, l, NULL, &items_written, &error);
747 o = mono_string_new_utf16 (domain, ut, items_written);
749 g_error_free (error);
757 * mono_string_new_wrapper:
758 * @text: pointer to utf8 characters.
760 * Helper function to create a string object from @text in the current domain.
763 mono_string_new_wrapper (const char *text)
765 MonoDomain *domain = mono_domain_get ();
767 return mono_string_new (domain, text);
772 * @class: the class of the value
773 * @value: a pointer to the unboxed data
775 * Returns: A newly created object which contains @value.
778 mono_value_box (MonoDomain *domain, MonoClass *class, gpointer value)
783 g_assert (class->valuetype);
785 size = mono_class_instance_size (class);
786 res = mono_object_allocate (size);
787 res->vtable = mono_class_vtable (domain, class);
789 size = size - sizeof (MonoObject);
791 memcpy ((char *)res + sizeof (MonoObject), value, size);
793 if (class->has_finalize)
794 mono_object_register_finalizer (res);
799 * mono_object_isinst:
801 * @klass: a pointer to a class
803 * Returns: @obj if @obj is derived from @klass
806 mono_object_isinst (MonoObject *obj, MonoClass *klass)
818 mono_class_init (klass);
820 if (klass->flags & TYPE_ATTRIBUTE_INTERFACE) {
821 if ((klass->interface_id <= oklass->max_interface_id) &&
822 vt->interface_offsets [klass->interface_id])
825 if (oklass == mono_defaults.transparent_proxy_class) {
826 /* fixme: add check for IRemotingTypeInfo */
827 oklass = ((MonoTransparentProxy *)obj)->klass;
830 if (oklass->rank == klass->rank &&
831 (oklass->element_class->baseval - klass->element_class->baseval) <=
832 klass->element_class->diffval)
835 } else if ((oklass->baseval - klass->baseval) <= klass->diffval)
843 mono_string_is_interned_lookup (MonoString *str, int insert)
845 MonoGHashTable *ldstr_table;
848 char *ins = g_malloc (4 + str->length * 2);
852 /* Encode the length */
854 mono_metadata_encode_value (2 * str->length, p, &p);
857 mono_metadata_encode_value (bloblen + 2 * str->length, p, &p);
858 bloblen = (p - ins) + 2 * str->length;
860 * ins is stored in the hash table as a key and needs to have the same
861 * representation as in the metadata: we swap the character bytes on big
864 #if G_BYTE_ORDER != G_LITTLE_ENDIAN
867 char *p2 = mono_string_chars (str);
868 for (i = 0; i < str->length; ++i) {
875 memcpy (p, mono_string_chars (str), str->length * 2);
877 domain = ((MonoObject *)str)->vtable->domain;
878 ldstr_table = domain->ldstr_table;
879 mono_domain_lock (domain);
880 if ((res = mono_g_hash_table_lookup (ldstr_table, ins))) {
881 mono_domain_unlock (domain);
886 mono_g_hash_table_insert (ldstr_table, ins, str);
887 mono_domain_unlock (domain);
890 mono_domain_unlock (domain);
896 mono_string_is_interned (MonoString *o)
898 return mono_string_is_interned_lookup (o, FALSE);
902 mono_string_intern (MonoString *str)
904 return mono_string_is_interned_lookup (str, TRUE);
909 * @domain: the domain where the string will be used.
910 * @image: a metadata context
911 * @idx: index into the user string table.
913 * Implementation for the ldstr opcode.
916 mono_ldstr (MonoDomain *domain, MonoImage *image, guint32 idx)
918 const char *str, *sig;
922 sig = str = mono_metadata_user_string (image, idx);
924 mono_domain_lock (domain);
925 if ((o = mono_g_hash_table_lookup (domain->ldstr_table, sig))) {
926 mono_domain_unlock (domain);
930 len2 = mono_metadata_decode_blob_size (str, &str);
933 o = mono_string_new_utf16 (domain, (guint16*)str, len2);
934 #if G_BYTE_ORDER != G_LITTLE_ENDIAN
937 guint16 *p2 = (guint16*)mono_array_addr (o->c_str, guint16, 0);
938 for (i = 0; i < len2; ++i) {
939 *p2 = GUINT16_FROM_LE (*p2);
944 mono_g_hash_table_insert (domain->ldstr_table, (gpointer)sig, o);
945 mono_domain_unlock (domain);
951 * mono_string_to_utf8:
952 * @s: a System.String
954 * Return the UTF8 representation for @s.
955 * the resulting buffer nedds to be freed with g_free().
958 mono_string_to_utf8 (MonoString *s)
961 GError *error = NULL;
963 g_assert (s != NULL);
966 return g_strdup ("");
968 as = g_utf16_to_utf8 (mono_string_chars (s), s->length, NULL, NULL, &error);
970 g_warning (error->message);
976 * mono_string_to_utf16:
979 * Return an null-terminated array of the utf-16 chars
980 * contained in @s. The result must be freed with g_free().
981 * This is a temporary helper until our string implementation
982 * is reworked to always include the null terminating char.
985 mono_string_to_utf16 (MonoString *s)
989 g_assert (s != NULL);
991 as = g_malloc ((s->length * 2) + 2);
992 as [(s->length * 2)] = '\0';
993 as [(s->length * 2) + 1] = '\0';
996 return (gunichar2 *)(as);
999 memcpy (as, mono_string_chars(s), s->length * 2);
1001 return (gunichar2 *)(as);
1005 default_ex_handler (MonoException *ex)
1007 MonoObject *o = (MonoObject*)ex;
1008 g_error ("Exception %s.%s raised in C code", o->vtable->klass->name_space, o->vtable->klass->name);
1011 static MonoExceptionFunc ex_handler = default_ex_handler;
1014 mono_install_handler (MonoExceptionFunc func)
1016 ex_handler = func? func: default_ex_handler;
1020 * mono_raise_exception:
1021 * @ex: exception object
1023 * Signal the runtime that the exception @ex has been raised in unmanaged code.
1026 mono_raise_exception (MonoException *ex)
1032 mono_wait_handle_new (MonoDomain *domain, HANDLE handle)
1034 MonoWaitHandle *res;
1036 res = (MonoWaitHandle *)mono_object_new (domain, mono_defaults.waithandle_class);
1038 res->handle = handle;
1044 mono_async_result_new (MonoDomain *domain, HANDLE handle, MonoObject *state, gpointer data)
1046 MonoAsyncResult *res;
1048 res = (MonoAsyncResult *)mono_object_new (domain, mono_defaults.asyncresult_class);
1051 res->async_state = state;
1052 res->handle = (MonoObject *)mono_wait_handle_new (domain, handle);
1053 res->sync_completed = FALSE;
1054 res->completed = FALSE;
1060 mono_message_init (MonoDomain *domain,
1061 MonoMethodMessage *this,
1062 MonoReflectionMethod *method,
1063 MonoArray *out_args)
1065 MonoMethodSignature *sig = method->method->signature;
1071 this->method = method;
1073 this->args = mono_array_new (domain, mono_defaults.object_class, sig->param_count);
1074 this->arg_types = mono_array_new (domain, mono_defaults.byte_class, sig->param_count);
1076 names = g_new (char *, sig->param_count);
1077 mono_method_get_param_names (method->method, (const char **) names);
1078 this->names = mono_array_new (domain, mono_defaults.string_class, sig->param_count);
1080 for (i = 0; i < sig->param_count; i++) {
1081 name = mono_string_new (domain, names [i]);
1082 mono_array_set (this->names, gpointer, i, name);
1087 for (i = 0, j = 0; i < sig->param_count; i++) {
1089 if (sig->params [i]->byref) {
1091 gpointer arg = mono_array_get (out_args, gpointer, j);
1092 mono_array_set (this->args, gpointer, i, arg);
1096 if (sig->params [i]->attrs & PARAM_ATTRIBUTE_IN)
1102 mono_array_set (this->arg_types, guint8, i, arg_type);
1107 * mono_remoting_invoke:
1108 * @real_proxy: pointer to a RealProxy object
1109 * @msg: The MonoMethodMessage to execute
1110 * @exc: used to store exceptions
1111 * @out_args: used to store output arguments
1113 * This is used to call RealProxy::Invoke(). RealProxy::Invoke() returns an
1114 * IMessage interface and it is not trivial to extract results from there. So
1115 * we call an helper method PrivateInvoke instead of calling
1116 * RealProxy::Invoke() directly.
1118 * Returns: the result object.
1121 mono_remoting_invoke (MonoObject *real_proxy, MonoMethodMessage *msg,
1122 MonoObject **exc, MonoArray **out_args)
1124 static MonoMethod *im = NULL;
1127 //static MonoObject *(*invoke) (gpointer, gpointer, MonoObject **, MonoArray **) = NULL;
1129 /* fixme: make this domain dependent */
1134 klass = mono_defaults.real_proxy_class;
1136 for (i = 0; i < klass->method.count; ++i) {
1137 if (!strcmp ("PrivateInvoke", klass->methods [i]->name) &&
1138 klass->methods [i]->signature->param_count == 4) {
1139 im = klass->methods [i];
1147 pa [0] = real_proxy;
1152 return mono_runtime_invoke (im, NULL, pa);
1156 mono_message_invoke (MonoObject *target, MonoMethodMessage *msg,
1157 MonoObject **exc, MonoArray **out_args)
1159 if (target && target->vtable->klass == mono_defaults.transparent_proxy_class) {
1161 return mono_remoting_invoke ((MonoObject *)((MonoTransparentProxy *)target)->rp,
1162 msg, exc, out_args);
1165 MonoDomain *domain = mono_domain_get ();
1166 MonoMethod *method = msg->method->method;
1167 MonoMethodSignature *sig = method->signature;
1168 int i, j, outarg_count = 0;
1170 for (i = 0; i < sig->param_count; i++) {
1171 if (sig->params [i]->byref)
1175 *out_args = mono_array_new (domain, mono_defaults.object_class, outarg_count);
1178 for (i = 0, j = 0; i < sig->param_count; i++) {
1179 if (sig->params [i]->byref) {
1181 arg = mono_array_get (msg->args, gpointer, i);
1182 mono_array_set (*out_args, gpointer, j, arg);
1187 return mono_runtime_invoke_array (method, target, msg->args);