From: Bernhard Urban Date: Tue, 17 Jan 2017 16:26:32 +0000 (+0100) Subject: [interpreter] fix castclass and isinst instruction X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=commitdiff_plain;h=03c4efe204275ccaf19248c9a3624d1b0b6add3c;p=mono.git [interpreter] fix castclass and isinst instruction `mono_object_isinst_mbyref_checked` was removed recently. however, this code unnecessary checks cases that are covered by `mono_object_isinst_checked` anyway. --- diff --git a/mono/mini/interpreter/interp.c b/mono/mini/interpreter/interp.c index 32d69499808..84271d1d667 100644 --- a/mono/mini/interpreter/interp.c +++ b/mono/mini/interpreter/interp.c @@ -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;