Skip to content

Commit

Permalink
[jit] Compute has_references correctly for gshared types whose constr…
Browse files Browse the repository at this point in the history
…aint is a generic valuetype.
  • Loading branch information
vargaz committed Jan 25, 2020
1 parent 03833e1 commit e797669
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/mono/mono/metadata/class-init.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions src/mono/mono/mini/memory-access.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit e797669

Please sign in to comment.