/*This doesn't require fencing since EXIT_CRITICAL_REGION already does it for us*/
arr->max_length = (mono_array_size_t)max_length;
EXIT_CRITICAL_REGION;
- return arr;
+ goto done;
}
EXIT_CRITICAL_REGION;
#endif
arr->max_length = (mono_array_size_t)max_length;
+
UNLOCK_GC;
+ done:
+ SGEN_ASSERT (6, SGEN_ALIGN_UP (size) == SGEN_ALIGN_UP (sgen_par_object_get_size (vtable, (MonoObject*)arr)), "Vector has incorrect size.");
return arr;
}
bounds = (MonoArrayBounds*)((char*)arr + size - bounds_size);
arr->bounds = bounds;
EXIT_CRITICAL_REGION;
- return arr;
+ goto done;
}
EXIT_CRITICAL_REGION;
#endif
UNLOCK_GC;
+ done:
+ SGEN_ASSERT (6, SGEN_ALIGN_UP (size) == SGEN_ALIGN_UP (sgen_par_object_get_size (vtable, (MonoObject*)arr)), "Array has incorrect size.");
return arr;
}
MonoArray *array = (MonoArray*)o;
size_t size = sizeof (MonoArray) + element_size * mono_array_length_fast (array);
- if (descr & VECTOR_KIND_ARRAY) {
+ /*
+ * Non-vector arrays with a single dimension whose lower bound is zero are
+ * allocated without bounds.
+ */
+ if ((descr & VECTOR_KIND_ARRAY) && array->bounds) {
size += sizeof (mono_array_size_t) - 1;
size &= ~(sizeof (mono_array_size_t) - 1);
size += sizeof (MonoArrayBounds) * vtable->klass->rank;