return NULL;
}
+#ifndef DISABLE_REMOTING
+
static gpointer
default_remoting_trampoline (MonoDomain *domain, MonoMethod *method, MonoRemotingTarget target)
{
return NULL;
}
+static MonoRemotingTrampoline arch_create_remoting_trampoline = default_remoting_trampoline;
+#endif
+
static gpointer
default_delegate_trampoline (MonoDomain *domain, MonoClass *klass)
{
static MonoTrampoline arch_create_jit_trampoline = default_trampoline;
static MonoJumpTrampoline arch_create_jump_trampoline = default_jump_trampoline;
-static MonoRemotingTrampoline arch_create_remoting_trampoline = default_remoting_trampoline;
static MonoDelegateTrampoline arch_create_delegate_trampoline = default_delegate_trampoline;
static MonoImtThunkBuilder imt_thunk_builder = NULL;
#define ARCH_USE_IMT (imt_thunk_builder != NULL)
arch_create_jump_trampoline = func? func: default_jump_trampoline;
}
+#ifndef DISABLE_REMOTING
void
mono_install_remoting_trampoline (MonoRemotingTrampoline func)
{
arch_create_remoting_trampoline = func? func: default_remoting_trampoline;
}
+#endif
void
mono_install_delegate_trampoline (MonoDelegateTrampoline func)
if (mono_class_has_variant_generic_params (iface))
has_variant_iface = TRUE;
+ mono_class_setup_methods (iface);
vt_slot = interface_offset;
for (method_slot_in_interface = 0; method_slot_in_interface < iface->method.count; method_slot_in_interface++) {
MonoMethod *method;
bitmap = default_bitmap;
} else if (mono_type_is_struct (field->type)) {
fclass = mono_class_from_mono_type (field->type);
- bitmap = compute_class_bitmap (fclass, default_bitmap, sizeof (default_bitmap) * 8, 0, &max_set, FALSE);
+ bitmap = compute_class_bitmap (fclass, default_bitmap, sizeof (default_bitmap) * 8, - (int)(sizeof (MonoObject) / sizeof (gpointer)), &max_set, FALSE);
numbits = max_set + 1;
} else {
default_bitmap [0] = 0;
MONO_GC_REGISTER_ROOT_IF_MOVING(vt->type);
}
- if (class->contextbound)
- vt->remote = 1;
- else
- vt->remote = 0;
+ mono_vtable_set_is_remote (vt, mono_class_is_contextbound (class));
/* class_vtable_array keeps an array of created vtables
*/
mono_loader_unlock ();
/* Initialization is now complete, we can throw if the InheritanceDemand aren't satisfied */
- if (mono_is_security_manager_active () && (class->exception_type == MONO_EXCEPTION_SECURITY_INHERITANCEDEMAND) && raise_on_error)
+ if (mono_security_enabled () && (class->exception_type == MONO_EXCEPTION_SECURITY_INHERITANCEDEMAND) && raise_on_error)
mono_raise_exception (mono_class_get_exception_for_failure (class));
/* make sure the parent is initialized */
return vt;
}
+#ifndef DISABLE_REMOTING
/**
* mono_class_proxy_vtable:
* @domain: the application domain
return pvt;
}
+#endif /* DISABLE_REMOTING */
+
/**
* mono_class_field_is_special_static:
*
return FALSE;
}
+#ifndef DISABLE_REMOTING
/**
* create_remote_class_key:
* Creates an array of pointers that can be used as a hash key for a remote class.
type = ((MonoReflectionType *)rp->class_to_proxy)->type;
klass = mono_class_from_mono_type (type);
#ifndef DISABLE_COM
- if ((klass->is_com_object || (mono_defaults.com_object_class && klass == mono_defaults.com_object_class)) && !mono_class_vtable (mono_domain_get (), klass)->remote)
+ if ((mono_class_is_com_object (klass) || (mono_class_get_com_object_class () && klass == mono_class_get_com_object_class ())) && !mono_vtable_is_remote (mono_class_vtable (mono_domain_get (), klass)))
remote_class->default_vtable = mono_class_proxy_vtable (domain, remote_class, MONO_REMOTING_TARGET_COMINTEROP);
else
#endif
mono_domain_unlock (domain);
mono_loader_unlock ();
}
+#endif /* DISABLE_REMOTING */
/**
{
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;
}
}
+#ifndef DISABLE_REMOTING
if (is_proxy) {
/* It may be an interface, abstract class method or generic method */
if (!res || mono_method_signature (res)->generic_param_count)
res = mono_marshal_get_remoting_invoke_with_check (res);
else {
#ifndef DISABLE_COM
- if (klass == mono_defaults.com_object_class || klass->is_com_object)
+ if (klass == mono_class_get_com_object_class () || mono_class_is_com_object (klass))
res = mono_cominterop_get_invoke (res);
else
#endif
res = mono_marshal_get_remoting_invoke (res);
}
- } else {
+ } else
+#endif
+ {
if (method->is_inflated) {
/* Have to inflate the result */
res = mono_class_inflate_generic_method (res, &((MonoMethodInflated*)method)->context);
is_static = TRUE;
if (!is_literal) {
- vtable = mono_class_vtable (domain, field->parent);
- if (!vtable) {
- char *name = mono_type_get_full_name (field->parent);
- /*FIXME extend this to use the MonoError api*/
- g_warning ("Could not retrieve the vtable for type %s in mono_field_get_value_object", name);
- g_free (name);
- return NULL;
- }
+ vtable = mono_class_vtable_full (domain, field->parent, TRUE);
if (!vtable->initialized)
mono_runtime_class_init (vtable);
}
return im;
}
+/**
+ * mono_get_delegate_begin_invoke:
+ * @klass: The delegate class
+ *
+ * Returns: the MonoMethod for the "BeginInvoke" method in the delegate klass or NULL if @klass is a broken delegate type
+ */
+MonoMethod *
+mono_get_delegate_begin_invoke (MonoClass *klass)
+{
+ MonoMethod *im;
+
+ /* This is called at runtime, so avoid the slower search in metadata */
+ mono_class_setup_methods (klass);
+ if (klass->exception_type)
+ return NULL;
+ im = mono_class_get_method_from_name (klass, "BeginInvoke", -1);
+ return im;
+}
+
+/**
+ * mono_get_delegate_end_invoke:
+ * @klass: The delegate class
+ *
+ * Returns: the MonoMethod for the "EndInvoke" method in the delegate klass or NULL if @klass is a broken delegate type
+ */
+MonoMethod *
+mono_get_delegate_end_invoke (MonoClass *klass)
+{
+ MonoMethod *im;
+
+ /* This is called at runtime, so avoid the slower search in metadata */
+ mono_class_setup_methods (klass);
+ if (klass->exception_type)
+ return NULL;
+ im = mono_class_get_method_from_name (klass, "EndInvoke", -1);
+ return im;
+}
+
/**
* mono_runtime_delegate_invoke:
* @delegate: pointer to a delegate object.
return NULL;
}
- g_assert (!mono_object_class (obj)->marshalbyref);
+ g_assert (!mono_class_is_marshalbyref (mono_object_class (obj)));
params [0] = obj;
*exc = NULL;
return result;
}
+#ifndef DISABLE_REMOTING
static MonoObject*
make_transparent_proxy (MonoObject *obj, gboolean *failure, MonoObject **exc)
{
if (!get_proxy_method)
get_proxy_method = mono_class_get_method_from_name (mono_defaults.real_proxy_class, "GetTransparentProxy", 0);
- g_assert (obj->vtable->klass->marshalbyref);
+ g_assert (mono_class_is_marshalbyref (obj->vtable->klass));
real_proxy = (MonoRealProxy*) mono_object_new (domain, mono_defaults.real_proxy_class);
reflection_type = mono_type_get_object (domain, &obj->vtable->klass->byval_arg);
return (MonoObject*) transparent_proxy;
}
+#endif /* DISABLE_REMOTING */
/**
* mono_object_xdomain_representation
*exc = NULL;
- if (mono_object_class (obj)->marshalbyref) {
+#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;
}
mono_thread_init_apartment_state ();
- mono_debugger_event (MONO_DEBUGGER_EVENT_REACHED_MAIN, 0, 0);
-
/* FIXME: check signature of method */
if (mono_method_signature (method)->ret->type == MONO_TYPE_I4) {
MonoObject *res;
}
}
- mono_debugger_event (MONO_DEBUGGER_EVENT_MAIN_EXITED, (guint64) (gsize) rval, 0);
-
return rval;
}
if (!obj) {
obj = mono_object_new (mono_domain_get (), method->klass);
g_assert (obj); /*maybe we should raise a TLE instead?*/
+#ifndef DISABLE_REMOTING
if (mono_object_class(obj) == mono_defaults.transparent_proxy_class) {
method = mono_marshal_get_remoting_invoke (method->slot == -1 ? method : method->klass->vtable [method->slot]);
}
+#endif
if (method->klass->valuetype)
o = mono_object_unbox (obj);
else
MONO_ARCH_SAVE_REGS;
/* check for is_com_object for COM Interop */
- if (vtable->remote || vtable->klass->is_com_object)
+ if (mono_vtable_is_remote (vtable) || mono_class_is_com_object (vtable->klass))
{
gpointer pa [1];
MonoMethod *im = vtable->domain->create_proxy_for_type_method;
if (!(mono_profiler_get_events () & MONO_PROFILE_ALLOCATIONS))
profile_allocs = FALSE;
- if (mono_class_has_finalizer (vtable->klass) || vtable->klass->marshalbyref || (mono_profiler_get_events () & MONO_PROFILE_ALLOCATIONS))
+ if (mono_class_has_finalizer (vtable->klass) || mono_class_is_marshalbyref (vtable->klass) || (mono_profiler_get_events () & MONO_PROFILE_ALLOCATIONS))
return mono_object_new_specific;
if (!vtable->klass->has_references) {
#ifdef HAVE_SGEN_GC
if (klass->element_class->valuetype) {
if (klass->element_class->has_references)
- mono_value_copy_array (dest, 0, mono_array_addr_with_size (src, 0, 0), mono_array_length (src));
+ mono_value_copy_array (dest, 0, mono_array_addr_with_size_fast (src, 0, 0), mono_array_length (src));
else
mono_gc_memmove (&dest->vector, &src->vector, size);
} else {
#ifdef HAVE_SGEN_GC
if (klass->element_class->valuetype) {
if (klass->element_class->has_references)
- mono_value_copy_array (o, 0, mono_array_addr_with_size (array, 0, 0), mono_array_length (array));
+ mono_value_copy_array (o, 0, mono_array_addr_with_size_fast (array, 0, 0), mono_array_length (array));
else
mono_gc_memmove (&o->vector, &array->vector, size);
} else {
#ifdef HAVE_SGEN_GC
if (klass->element_class->valuetype) {
if (klass->element_class->has_references)
- mono_value_copy_array (o, 0, mono_array_addr_with_size (array, 0, 0), mono_array_length (array));
+ mono_value_copy_array (o, 0, mono_array_addr_with_size_fast (array, 0, 0), mono_array_length (array));
else
mono_gc_memmove (&o->vector, &array->vector, size);
} else {
{
MonoString *s;
MonoVTable *vtable;
- size_t size = (sizeof (MonoString) + ((len + 1) * 2));
+ size_t size;
- /* overflow ? can't fit it, can't allocate it! */
- if (len > size)
+ /* check for overflow */
+ if (len < 0 || len > ((SIZE_MAX - sizeof (MonoString) - 2) / 2))
mono_gc_out_of_memory (-1);
+ size = (sizeof (MonoString) + ((len + 1) * 2));
+ g_assert (size > 0);
+
vtable = mono_class_vtable (domain, mono_defaults.string_class);
g_assert (vtable);
mono_value_copy_array (MonoArray *dest, int dest_idx, gpointer src, int count)
{
int size = mono_array_element_size (dest->obj.vtable->klass);
- char *d = mono_array_addr_with_size (dest, size, dest_idx);
+ char *d = mono_array_addr_with_size_fast (dest, size, dest_idx);
g_assert (size == mono_class_value_size (mono_object_class (dest)->element_class, NULL));
mono_gc_wbarrier_value_copy (d, src, count, mono_object_class (dest)->element_class);
}
if (!klass->inited)
mono_class_init (klass);
- if (klass->marshalbyref || (klass->flags & TYPE_ATTRIBUTE_INTERFACE))
+ if (mono_class_is_marshalbyref (klass) || (klass->flags & TYPE_ATTRIBUTE_INTERFACE))
return mono_object_isinst_mbyref (obj, klass);
if (!obj)
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);
if ((oklass->idepth >= klass->idepth) && (oklass->supertypes [klass->idepth - 1] == klass))
return obj;
}
-
+#ifndef DISABLE_REMOTING
if (vt->klass == mono_defaults.transparent_proxy_class && ((MonoTransparentProxy *)obj)->custom_type_info)
{
MonoDomain *domain = mono_domain_get ();
return obj;
}
}
-
+#endif /* DISABLE_REMOTING */
return NULL;
}
}
}
+#ifndef DISABLE_REMOTING
/**
* mono_remoting_invoke:
* @real_proxy: pointer to a RealProxy object
return mono_runtime_invoke (im, NULL, pa, exc);
}
+#endif
MonoObject *
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 (tp->remote_class->proxy_class->contextbound && tp->rp->context == (MonoObject *) mono_context_get ()) {
+ 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;
{
static MonoMethod *to_string = NULL;
MonoMethod *method;
+ void *target = obj;
g_assert (obj);
method = mono_object_get_virtual_method (obj, to_string);
- return (MonoString *) mono_runtime_invoke (method, obj, NULL, exc);
+ // Unbox value type if needed
+ if (mono_class_is_valuetype (mono_method_get_class (method))) {
+ target = mono_object_unbox (obj);
+ }
+
+ return (MonoString *) mono_runtime_invoke (method, target, NULL, exc);
}
/**
message = mono_exception_get_native_backtrace ((MonoException*)exc);
free_message = TRUE;
} else {
- str = mono_object_to_string (exc, NULL);
- if (str) {
+ MonoObject *other_exc = NULL;
+ str = mono_object_to_string (exc, &other_exc);
+ if (other_exc) {
+ char *original_backtrace = mono_exception_get_managed_backtrace ((MonoException*)exc);
+ char *nested_backtrace = mono_exception_get_managed_backtrace ((MonoException*)other_exc);
+
+ message = g_strdup_printf ("Nested exception detected.\nOriginal Exception: %s\nNested exception:%s\n",
+ original_backtrace, nested_backtrace);
+
+ g_free (original_backtrace);
+ g_free (nested_backtrace);
+ free_message = TRUE;
+ } else if (str) {
message = mono_string_to_utf8_checked (str, &error);
if (!mono_error_ok (&error)) {
mono_error_cleanup (&error);
class = this->vtable->klass;
mono_stats.delegate_creations++;
+#ifndef DISABLE_REMOTING
if (target && target->vtable->klass == mono_defaults.transparent_proxy_class) {
g_assert (method);
method = mono_marshal_get_remoting_invoke (method);
delegate->method_ptr = mono_compile_method (method);
MONO_OBJECT_SETREF (delegate, target, target);
- } else if (method && mono_method_signature (method)->hasthis && method->klass->valuetype) {
- method = mono_marshal_get_unbox_wrapper (method);
- delegate->method_ptr = mono_compile_method (method);
- MONO_OBJECT_SETREF (delegate, target, target);
- } else {
+ } else
+#endif
+ {
delegate->method_ptr = addr;
MONO_OBJECT_SETREF (delegate, target, target);
}
if (!ji && domain != mono_get_root_domain ())
ji = mono_jit_info_table_find (mono_get_root_domain (), mono_get_addr_from_ftnptr (addr));
if (ji) {
- method = ji->method;
+ method = mono_jit_info_get_method (ji);
g_assert (!method->klass->generic_container);
}
}
}
+#ifndef DISABLE_REMOTING
+
/**
* mono_load_remote_field:
* @this: pointer to an object
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 (tp->remote_class->proxy_class->contextbound && tp->rp->context == (MonoObject *) mono_context_get ()) {
+ if (mono_class_is_contextbound (tp->remote_class->proxy_class) && tp->rp->context == (MonoObject *) mono_context_get ()) {
mono_field_get_value (tp->rp->unwrapped_server, field, res);
return res;
}
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);
- if (tp->remote_class->proxy_class->contextbound && tp->rp->context == (MonoObject *) mono_context_get ()) {
+ if (mono_class_is_contextbound (tp->remote_class->proxy_class) && tp->rp->context == (MonoObject *) mono_context_get ()) {
gpointer val;
if (field_class->valuetype) {
res = mono_object_new (domain, field_class);
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);
- if (tp->remote_class->proxy_class->contextbound && tp->rp->context == (MonoObject *) mono_context_get ()) {
+ 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;
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);
- if (tp->remote_class->proxy_class->contextbound && tp->rp->context == (MonoObject *) mono_context_get ()) {
+ 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;
if (exc) mono_raise_exception ((MonoException *)exc);
}
+#endif
/*
* mono_create_ftnptr: