}
static void
-create_write_barrier_bitmap (MonoClass *klass, unsigned *wb_bitmap, int offset)
+create_write_barrier_bitmap (MonoCompile *cfg, MonoClass *klass, unsigned *wb_bitmap, int offset)
{
MonoClassField *field;
gpointer iter = NULL;
if (field->type->attrs & FIELD_ATTRIBUTE_STATIC)
continue;
foffset = klass->valuetype ? field->offset - sizeof (MonoObject): field->offset;
- if (mono_type_is_reference (field->type)) {
+ if (mini_type_is_reference (cfg, mono_field_get_type (field))) {
g_assert ((foffset % SIZEOF_VOID_P) == 0);
*wb_bitmap |= 1 << ((offset + foffset) / SIZEOF_VOID_P);
} else {
- /*FIXME support nested value types so this works for: struct X { Y y; int z;} struct Y { object a,b; }*/
MonoClass *field_class = mono_class_from_mono_type (field->type);
if (field_class->has_references)
- create_write_barrier_bitmap (field_class, wb_bitmap, offset + foffset);
+ create_write_barrier_bitmap (cfg, field_class, wb_bitmap, offset + foffset);
}
}
}
if (size > 32 * SIZEOF_VOID_P)
return FALSE;
- create_write_barrier_bitmap (klass, &need_wb, 0);
+ create_write_barrier_bitmap (cfg, klass, &need_wb, 0);
/* We don't unroll more than 5 stores to avoid code bloat. */
if (size > 5 * SIZEOF_VOID_P) {
static gboolean
-mini_class_has_reference_variant_generic_argument (MonoClass *klass, int context_used)
+mini_class_has_reference_variant_generic_argument (MonoCompile *cfg, MonoClass *klass, int context_used)
{
int i;
MonoGenericContainer *container;
if (!(mono_generic_container_get_param_info (container, i)->flags & (MONO_GEN_PARAM_VARIANT|MONO_GEN_PARAM_COVARIANT)))
continue;
type = ginst->type_argv [i];
- if (MONO_TYPE_IS_REFERENCE (type))
- return TRUE;
-
- if (context_used && (type->type == MONO_TYPE_VAR || type->type == MONO_TYPE_MVAR))
+ if (mini_type_is_reference (cfg, type))
return TRUE;
}
return FALSE;
if (context_used) {
MonoInst *args [3];
- if(mini_class_has_reference_variant_generic_argument (klass, context_used)) {
+ if(mini_class_has_reference_variant_generic_argument (cfg, klass, context_used)) {
MonoMethod *mono_castclass = mono_marshal_get_castclass_with_cache ();
MonoInst *cache_ins;
if (context_used) {
MonoInst *args [3];
- if(mini_class_has_reference_variant_generic_argument (klass, context_used)) {
+ if(mini_class_has_reference_variant_generic_argument (cfg, klass, context_used)) {
MonoMethod *mono_isinst = mono_marshal_get_isinst_with_cache ();
MonoInst *cache_ins;
#ifdef MONO_ARCH_HAVE_ATOMIC_CAS
if ((strcmp (cmethod->name, "CompareExchange") == 0)) {
int size = 0;
- gboolean is_ref = MONO_TYPE_IS_REFERENCE (fsig->params [1]);
+ gboolean is_ref = mini_type_is_reference (cfg, fsig->params [1]);
if (fsig->params [1]->type == MONO_TYPE_I4)
size = 4;
else if (is_ref || fsig->params [1]->type == MONO_TYPE_I)
static gboolean
generic_class_is_reference_type (MonoCompile *cfg, MonoClass *klass)
{
- MonoType *type;
-
- if (cfg->generic_sharing_context)
- type = mini_get_basic_type_from_generic (cfg->generic_sharing_context, &klass->byval_arg);
- else
- type = &klass->byval_arg;
- return MONO_TYPE_IS_REFERENCE (type);
+ return mini_type_is_reference (cfg, &klass->byval_arg);
}
static void
token = read32 (ip + 2);
klass = mini_get_class (cfg->current_method, token, cfg->generic_context);
CHECK_TYPELOAD (klass);
- if (generic_class_is_reference_type (cfg, klass)) {
- MONO_EMIT_NEW_PCONST (cfg, cfg->locals [local]->dreg, NULL);
- } else if (MONO_TYPE_IS_REFERENCE (&klass->byval_arg)) {
+ if (mini_type_is_reference (cfg, &klass->byval_arg)) {
MONO_EMIT_NEW_PCONST (cfg, cfg->locals [local]->dreg, NULL);
} else if (MONO_TYPE_ISSTRUCT (&klass->byval_arg)) {
MONO_EMIT_NEW_VZERO (cfg, cfg->locals [local]->dreg, klass);
if (cfg->generic_sharing_context)
context_used = mono_class_check_context_used (klass);
- if (!context_used && mini_class_has_reference_variant_generic_argument (klass, context_used)) {
+ if (!context_used && mini_class_has_reference_variant_generic_argument (cfg, klass, context_used)) {
MonoMethod *mono_castclass = mono_marshal_get_castclass_with_cache ();
MonoInst *args [3];
if (cfg->generic_sharing_context)
context_used = mono_class_check_context_used (klass);
- if (!context_used && mini_class_has_reference_variant_generic_argument (klass, context_used)) {
+ if (!context_used && mini_class_has_reference_variant_generic_argument (cfg, klass, context_used)) {
MonoMethod *mono_isinst = mono_marshal_get_isinst_with_cache ();
MonoInst *args [3];
if (generic_class_is_reference_type (cfg, klass)) {
/* CASTCLASS FIXME kill this huge slice of duplicated code*/
- if (!context_used && mini_class_has_reference_variant_generic_argument (klass, context_used)) {
+ if (!context_used && mini_class_has_reference_variant_generic_argument (cfg, klass, context_used)) {
MonoMethod *mono_castclass = mono_marshal_get_castclass_with_cache ();
MonoInst *args [3];
if (byref)
slot_type = SLOT_PIN;
else
- slot_type = MONO_TYPE_IS_REFERENCE (t) ? SLOT_REF : SLOT_NOREF;
+ slot_type = mini_type_is_reference (cfg, t) ? SLOT_REF : SLOT_NOREF;
if (slot_type == SLOT_PIN) {
/* These have no live interval, be conservative */
t = mini_type_get_underlying_type (NULL, t);
- if (!MONO_TYPE_IS_REFERENCE (t)) {
+ if (!mini_type_is_reference (cfg, t)) {
set_slot_everywhere (gcfg, pos, SLOT_NOREF);
if (cfg->verbose_level > 1)
printf ("\tnoref at %s0x%x(fp) (R%d, slot = %d): %s\n", ins->inst_offset < 0 ? "-" : "", (ins->inst_offset < 0) ? -(int)ins->inst_offset : (int)ins->inst_offset, vmv->vreg, pos, mono_type_full_name (ins->inst_vtype));
}
static GCSlotType
-type_to_gc_slot_type (MonoType *t)
+type_to_gc_slot_type (MonoCompile *cfg, MonoType *t)
{
if (t->byref)
return SLOT_PIN;
t = mini_type_get_underlying_type (NULL, t);
- if (MONO_TYPE_IS_REFERENCE (t))
+ if (mini_type_is_reference (cfg, t))
return SLOT_REF;
else {
if (MONO_TYPE_ISSTRUCT (t)) {
int sp_offset = def->inst_offset;
int fp_offset = sp_offset_to_fp_offset (cfg, sp_offset);
int slot = fp_offset_to_slot (cfg, fp_offset);
- GCSlotType type = type_to_gc_slot_type (t);
+ GCSlotType type = type_to_gc_slot_type (cfg, t);
/* The slot is live between the def instruction and the call */
set_slot_in_range (gcfg, slot, def->backend.pc_offset, callsite->pc_offset + 1, type);