[interpreter] fix castclass and isinst instruction
authorBernhard Urban <bernhard.urban@xamarin.com>
Tue, 17 Jan 2017 16:26:32 +0000 (17:26 +0100)
committerBernhard Urban <bernhard.urban@xamarin.com>
Tue, 17 Jan 2017 16:26:32 +0000 (17:26 +0100)
`mono_object_isinst_mbyref_checked` was removed recently. however, this
code unnecessary checks cases that are covered by
`mono_object_isinst_checked` anyway.

mono/mini/interpreter/interp.c

index 32d69499808df815071d90988eb5ae4eb9d3332b..84271d1d6671e5d5fdb4b98d71541af4608fff31 100644 (file)
@@ -2830,56 +2830,20 @@ array_constructed:
                MINT_IN_CASE(MINT_CASTCLASS)
                        c = rtm->data_items [*(guint16 *)(ip + 1)];
                        if ((o = sp [-1].data.p)) {
-                               if (c->marshalbyref) {
-                                       MonoObject *isinst_obj = mono_object_isinst_mbyref_checked (o, c, &error);
-                                       mono_error_cleanup (&error); /* FIXME: don't swallow the error */
-                                       if (!isinst_obj)
-                                               THROW_EX (mono_get_exception_invalid_cast (), ip);
-                               } else {
-                                       MonoVTable *vt = o->vtable;
-                                       MonoClass *oklass = vt->klass;
-                                       if (mono_class_is_interface (c)) {
-                                               g_error ("FIXME: interface method lookup");
-                                               if (c->interface_id > vt->max_interface_id /* || vt->interface_offsets [c->interface_id] == 0 */) {
-                                                       THROW_EX (mono_get_exception_invalid_cast (), ip);
-                                               }
-                                       } else if (c->rank) {
-                                               MonoObject *isinst_obj = mono_object_isinst_checked (o, c, &error);
-                                               mono_error_cleanup (&error); /* FIXME: don't swallow the error */
-                                               if (!isinst_obj)
-                                                       THROW_EX (mono_get_exception_invalid_cast (), ip);
-                                       } else if (!mono_class_has_parent (oklass, c)) {
-                                               THROW_EX (mono_get_exception_invalid_cast (), ip);
-                                       }
-                               }
+                               MonoObject *isinst_obj = mono_object_isinst_checked (o, c, &error);
+                               mono_error_cleanup (&error); /* FIXME: don't swallow the error */
+                               if (!isinst_obj)
+                                       THROW_EX (mono_get_exception_invalid_cast (), ip);
                        }
                        ip += 2;
                        MINT_IN_BREAK;
                MINT_IN_CASE(MINT_ISINST)
                        c = rtm->data_items [*(guint16 *)(ip + 1)];
                        if ((o = sp [-1].data.p)) {
-                               if (c->marshalbyref) {
-                                       MonoObject *isinst_obj = mono_object_isinst_mbyref_checked (o, c, &error);
-                                       mono_error_cleanup (&error); /* FIXME: don't swallow the error */
-                                       if (!isinst_obj)
-                                               sp [-1].data.p = NULL;
-                               } else {
-                                       MonoVTable *vt = o->vtable;
-                                       MonoClass *oklass = vt->klass;
-                                       if (mono_class_is_interface (c)) {
-                                               g_error ("FIXME: interface method lookup");
-                                               if (c->interface_id > vt->max_interface_id /* || vt->interface_offsets [c->interface_id] == 0 */) {
-                                                       sp [-1].data.p = NULL;
-                                               }
-                                       } else if (c->rank) {
-                                               MonoObject *isinst_obj = mono_object_isinst_checked (o, c, &error);
-                                               mono_error_cleanup (&error); /* FIXME: don't swallow the error */
-                                               if (!isinst_obj)
-                                                       sp [-1].data.p = NULL;
-                                       } else if (!mono_class_has_parent (oklass, c)) {
-                                               sp [-1].data.p = NULL;
-                                       }
-                               }
+                               MonoObject *isinst_obj = mono_object_isinst_checked (o, c, &error);
+                               mono_error_cleanup (&error); /* FIXME: don't swallow the error */
+                               if (!isinst_obj)
+                                       sp [-1].data.p = NULL;
                        }
                        ip += 2;
                        MINT_IN_BREAK;