diff options
author | Zoltan Varga <vargaz@gmail.com> | 2020-01-25 17:20:31 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-25 17:20:31 +0300 |
commit | 9fc4cae8759da737baa66093b6cbf8cb3da1e124 (patch) | |
tree | b380ca18a93b0561cc26ad18c248dd6c87aa31be | |
parent | 9e377af674215421cc7712fd5671343fd9538a4b (diff) |
[jit] Compute has_references correctly for gshared types whose constraint is a generic valuetype. (#18552)
Also emit write barriers correctly for these types.
-rw-r--r-- | mono/metadata/class-init.c | 5 | ||||
-rw-r--r-- | mono/mini/memory-access.c | 2 |
2 files changed, 7 insertions, 0 deletions
diff --git a/mono/metadata/class-init.c b/mono/metadata/class-init.c index ce317780d68..3529a2824f3 100644 --- a/mono/metadata/class-init.c +++ b/mono/metadata/class-init.c @@ -1260,6 +1260,11 @@ make_generic_param_class (MonoGenericParam *param) /* We don't use type_token for VAR since only classes can use it (not arrays, pointer, VARs, etc) */ klass->sizes.generic_param_token = !is_anonymous ? pinfo->token : 0; + if (param->gshared_constraint) { + MonoClass *constraint_class = mono_class_from_mono_type_internal (param->gshared_constraint); + mono_class_init_sizes (constraint_class); + klass->has_references = m_class_has_references (constraint_class); + } /* * This makes sure the the value size of this class is equal to the size of the types the gparam is * constrained to, the JIT depends on this. diff --git a/mono/mini/memory-access.c b/mono/mini/memory-access.c index da695ada36b..c5d5cd5f5ab 100644 --- a/mono/mini/memory-access.c +++ b/mono/mini/memory-access.c @@ -260,6 +260,8 @@ create_write_barrier_bitmap (MonoCompile *cfg, MonoClass *klass, unsigned *wb_bi *wb_bitmap |= 1 << ((offset + foffset) / TARGET_SIZEOF_VOID_P); } else { MonoClass *field_class = mono_class_from_mono_type_internal (field->type); + if (cfg->gshared) + field_class = mono_class_from_mono_type_internal (mini_get_underlying_type (m_class_get_byval_arg (field_class))); if (m_class_has_references (field_class)) create_write_barrier_bitmap (cfg, field_class, wb_bitmap, offset + foffset); } |