[jit] Allow Unsafe.As<TFrom, TTo> on gsharedvt types. (mono/mono#17692)
authorZoltan Varga <vargaz@gmail.com>
Mon, 4 Nov 2019 17:14:59 +0000 (12:14 -0500)
committerAlexander Köplinger <alex.koeplinger@outlook.com>
Mon, 4 Nov 2019 17:14:59 +0000 (18:14 +0100)
Commit migrated from https://github.com/mono/mono/commit/929a8a7fd836cc4d6d746c30d4ef1c5b73aed248

src/mono/mono/mini/intrinsics.c

index 297711d..52728c0 100644 (file)
@@ -392,8 +392,6 @@ emit_unsafe_intrinsics (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignatu
                g_assert (ctx->method_inst);
 
                t = ctx->method_inst->type_argv [0];
-               if (mini_is_gsharedvt_variable_type (t))
-                       return NULL;
                if (ctx->method_inst->type_argc == 2) {
                        dreg = alloc_preg (cfg);
                        EMIT_NEW_UNALU (cfg, ins, OP_MOVE, dreg, args [0]->dreg);
@@ -401,6 +399,8 @@ emit_unsafe_intrinsics (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignatu
                        ins->klass = mono_get_object_class ();
                        return ins;
                } else if (ctx->method_inst->type_argc == 1) {
+                       if (mini_is_gsharedvt_variable_type (t))
+                               return NULL;
                        // Casts the given object to the specified type, performs no dynamic type checking.
                        g_assert (fsig->param_count == 1);
                        g_assert (fsig->params [0]->type == MONO_TYPE_OBJECT);