[interp] respect generic context for cee_sizeof
authorBernhard Urban <bernhard.urban@xamarin.com>
Tue, 7 Mar 2017 09:46:59 +0000 (10:46 +0100)
committerBernhard Urban <bernhard.urban@xamarin.com>
Wed, 8 Mar 2017 22:02:51 +0000 (23:02 +0100)
mono/mini/iltests.il
mono/mini/interp/transform.c

index 9e32f6358d41b4ba9236e09108dd749a7e54ace2..aa594838a3bb5361531f0e2bb45f91318da8c79e 100644 (file)
@@ -2630,7 +2630,6 @@ END:
        }
 
        .method public static default int32 test_1_sizeof_gshared () cil managed {
-               .custom instance void [TestDriver]CategoryAttribute::.ctor(string) = ( 01 00 0C 21 49 4E 54 45 52 50 52 45 54 45 52 00 00 )   // ...!INTERPRETER.
            call   int32 Tests::SizeOfT<int8>()
                ldc.i4.1
                ceq
index 00c5acdaa0442b24f73ec559ce97b93fc67ec77f..a1481a39226001f729bbb606369fb6e3e109d687 100644 (file)
@@ -3110,19 +3110,19 @@ generate (MonoMethod *method, RuntimeMethod *rtm, unsigned char *is_bb_start, Mo
                                gint32 size;
                                token = read32 (td.ip + 1);
                                td.ip += 5;
-                               if (mono_metadata_token_table (token) == MONO_TABLE_TYPESPEC) {
+                               if (mono_metadata_token_table (token) == MONO_TABLE_TYPESPEC && !image_is_dynamic (method->klass->image) && !generic_context) {
                                        int align;
                                        MonoType *type = mono_type_create_from_typespec (image, token);
                                        size = mono_type_size (type, &align);
                                } else {
-                                       guint32 align;
+                                       int align;
                                        MonoClass *szclass = mono_class_get_full (image, token, generic_context);
                                        mono_class_init (szclass);
 #if 0
                                        if (!szclass->valuetype)
                                                THROW_EX (mono_exception_from_name (mono_defaults.corlib, "System", "InvalidProgramException"), ip - 5);
 #endif
-                                       size = mono_class_value_size (szclass, &align);
+                                       size = mono_type_size (&szclass->byval_arg, &align);
                                } 
                                ADD_CODE(&td, MINT_LDC_I4);
                                WRITE32(&td, &size);