Merge pull request #1780 from alexrp/master
[mono.git] / mono / metadata / object.c
index e097726278b23afc58c06ada6b135dcc86592426..b56dd2c82654d5527158b61fb5d1d8fb33086b82 100644 (file)
@@ -1416,7 +1416,7 @@ build_imt_slots (MonoClass *klass, MonoVTable *vt, MonoDomain *domain, gpointer*
                                 * The IMT thunk might be called with an instance of one of the 
                                 * generic virtual methods, so has to fallback to the IMT trampoline.
                                 */
-                               imt [i] = initialize_imt_slot (vt, domain, imt_builder [i], callbacks.get_imt_trampoline ? callbacks.get_imt_trampoline (i) : NULL);
+                               imt [i] = initialize_imt_slot (vt, domain, imt_builder [i], callbacks.get_imt_trampoline (i));
                        } else {
                                imt [i] = initialize_imt_slot (vt, domain, imt_builder [i], NULL);
                        }
@@ -2121,13 +2121,8 @@ mono_class_create_runtime_vtable (MonoDomain *domain, MonoClass *class, gboolean
 
        if (imt_table_bytes) {
                /* Now that the vtable is full, we can actually fill up the IMT */
-               if (callbacks.get_imt_trampoline) {
-                       /* lazy construction of the IMT entries enabled */
                        for (i = 0; i < MONO_IMT_SIZE; ++i)
                                interface_offsets [i] = callbacks.get_imt_trampoline (i);
-               } else {
-                       build_imt (class, vt, domain, interface_offsets, NULL);
-               }
        }
 
        /*
@@ -2202,10 +2197,6 @@ mono_class_create_runtime_vtable (MonoDomain *domain, MonoClass *class, gboolean
        mono_domain_unlock (domain);
        mono_loader_unlock ();
 
-       /* Initialization is now complete, we can throw if the InheritanceDemand aren't satisfied */
-       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 */
        /*FIXME shouldn't this fail the current type?*/
        if (class->parent)
@@ -4628,13 +4619,9 @@ mono_object_clone (MonoObject *obj)
 
        o = mono_object_allocate (size, obj->vtable);
 
-       if (obj->vtable->klass->has_references) {
-               mono_gc_wbarrier_object_copy (o, obj);
-       } else {
-               int size = obj->vtable->klass->instance_size;
-               /* do not copy the sync state */
-               mono_gc_memmove_atomic ((char*)o + sizeof (MonoObject), (char*)obj + sizeof (MonoObject), size - sizeof (MonoObject));
-       }
+       /* If the object doesn't contain references this will do a simple memmove. */
+       mono_gc_wbarrier_object_copy (o, obj);
+
        if (G_UNLIKELY (profile_allocs))
                mono_profiler_allocation (o, obj->vtable->klass);
 
@@ -6066,6 +6053,16 @@ mono_async_result_invoke (MonoAsyncResult *ares, MonoObject **exc)
        return res;
 }
 
+MonoObject *
+ves_icall_System_Runtime_Remoting_Messaging_AsyncResult_Invoke (MonoAsyncResult *this)
+{
+       MonoObject *exc = NULL;
+       MonoObject *res = mono_async_result_invoke (this, &exc);
+       if (exc)
+               mono_raise_exception ((MonoException*) exc);
+       return res;
+}
+
 void
 mono_message_init (MonoDomain *domain,
                   MonoMethodMessage *this, 
@@ -6278,6 +6275,9 @@ mono_print_unhandled_exception (MonoObject *exc)
        if (exc == (MonoObject*)mono_object_domain (exc)->out_of_memory_ex) {
                message = g_strdup ("OutOfMemoryException");
                free_message = TRUE;
+       } else if (exc == (MonoObject*)mono_object_domain (exc)->stack_overflow_ex) {
+               message = g_strdup ("StackOverflowException"); //if we OVF, we can't expect to have stack space to JIT Exception::ToString.
+               free_message = TRUE;
        } else {
                
                if (((MonoException*)exc)->native_trace_ips) {
@@ -6338,6 +6338,8 @@ mono_delegate_ctor_with_method (MonoObject *this, MonoObject *target, gpointer a
        g_assert (this);
        g_assert (addr);
 
+       g_assert (mono_class_has_parent (mono_object_class (this), mono_defaults.multicastdelegate_class));
+
        if (method)
                delegate->method = method;