#include <mono/metadata/tokentype.h>
#include <mono/metadata/loader.h>
#include <mono/metadata/object.h>
+#include <mono/metadata/gc.h>
#include <mono/metadata/appdomain.h>
#if HAVE_BOEHM_GC
#include <gc/gc.h>
int i;
if (NULL != params) {
- pa = alloca (sizeof (gpointer) * mono_array_length (params);
+ pa = alloca (sizeof (gpointer) * mono_array_length (params));
for (i = 0; i < mono_array_length (params); i++) {
if (sig->params [i]->byref) {
/* nothing to do */
mono_object_allocate (size_t size)
{
#if HAVE_BOEHM_GC
- void *o = GC_debug_malloc (size, "object", 1);
+ /* if this is changed to GC_debug_malloc(), we need to change also metadata/gc.c */
+ void *o = GC_malloc (size);
#else
void *o = calloc (1, size);
#endif
mono_stats.new_object_count++; /* thread safe? */
+ /* if the returned pointer is not the same as the address returned by GC_malloc(),
+ * we need to change also metadata/gc.c to take into account the new offset.
+ */
if (vtable->klass->ghcimpl)
o = mono_object_allocate (vtable->klass->instance_size);
else {
o = (MonoObject *)(++t);
}
o->vtable = vtable;
+ if (vtable->klass->has_finalize)
+ mono_object_register_finalizer (o);
return o;
}
memcpy (o, obj, size);
+ if (obj->vtable->klass->has_finalize)
+ mono_object_register_finalizer (o);
return o;
}
len = lengths [0];
} else {
#if HAVE_BOEHM_GC
- bounds = GC_debug_malloc (sizeof (MonoArrayBounds) * array_class->rank, "bounds", 0);
+ bounds = GC_malloc (sizeof (MonoArrayBounds) * array_class->rank);
#else
bounds = g_malloc0 (sizeof (MonoArrayBounds) * array_class->rank);
#endif
{
MonoString *s;
- s = (MonoString*)mono_object_allocate (sizeof (MonoString) + (len * 2));
+ /*
+ * enable to get a good speedup: we still need to figure out
+ * how the sync structure is freed.
+ */
+#ifdef 0 && HAVE_BOEHM_GC
+ s = GC_malloc_atomic (sizeof (MonoString) + ((len + 1) * 2));
+ s->object.synchronisation = 0;
+ mono_string_chars (s) [len] = 0;
+#else
+ s = (MonoString*)mono_object_allocate (sizeof (MonoString) + ((len + 1) * 2));
+#endif
if (!s)
G_BREAKPOINT ();
memcpy ((char *)res + sizeof (MonoObject), value, size);
+ if (class->has_finalize)
+ mono_object_register_finalizer (res);
return res;
}