#include "metadata/runtime.h"
#include "metadata/sgen-bridge-internals.h"
#include "metadata/gc-internals.h"
+#include "metadata/handle.h"
#include "utils/mono-memory-model.h"
#include "utils/mono-logger-internals.h"
{
MonoObject *obj = sgen_alloc_obj (vtable, size);
- if (G_UNLIKELY (alloc_events))
- mono_profiler_allocation (obj);
+ if (G_UNLIKELY (alloc_events)) {
+ if (obj)
+ mono_profiler_allocation (obj);
+ }
return obj;
}
{
MonoObject *obj = sgen_alloc_obj_pinned (vtable, size);
- if (G_UNLIKELY (alloc_events))
- mono_profiler_allocation (obj);
+ if (G_UNLIKELY (alloc_events)) {
+ if (obj)
+ mono_profiler_allocation (obj);
+ }
return obj;
}
void*
-mono_gc_alloc_mature (MonoVTable *vtable)
+mono_gc_alloc_mature (MonoVTable *vtable, size_t size)
{
- MonoObject *obj = sgen_alloc_obj_mature (vtable, vtable->klass->instance_size);
-
- if (obj && G_UNLIKELY (obj->vtable->klass->has_finalize))
- mono_object_register_finalizer (obj);
+ MonoObject *obj = sgen_alloc_obj_mature (vtable, size);
- if (G_UNLIKELY (alloc_events))
- mono_profiler_allocation (obj);
+ if (G_UNLIKELY (alloc_events)) {
+ if (obj)
+ mono_profiler_allocation (obj);
+ }
return obj;
}
case ATYPE_NORMAL:
case ATYPE_SMALL:
mono_mb_emit_ldarg (mb, 0);
- mono_mb_emit_icall (mb, mono_object_new_specific);
+ mono_mb_emit_icall (mb, ves_icall_object_new_specific);
break;
case ATYPE_VECTOR:
mono_mb_emit_ldarg (mb, 0);
int
mono_gc_get_aligned_size_for_allocator (int size)
{
- int aligned_size = size;
- aligned_size += SGEN_ALLOC_ALIGN - 1;
- aligned_size &= ~(SGEN_ALLOC_ALIGN - 1);
- return aligned_size;
+ return SGEN_ALIGN_UP (size);
}
/*
arr = (MonoArray*)sgen_alloc_obj_nolock (vtable, size);
if (G_UNLIKELY (!arr)) {
UNLOCK_GC;
- return mono_gc_out_of_memory (size);
+ return NULL;
}
arr->max_length = (mono_array_size_t)max_length;
arr = (MonoArray*)sgen_alloc_obj_nolock (vtable, size);
if (G_UNLIKELY (!arr)) {
UNLOCK_GC;
- return mono_gc_out_of_memory (size);
+ return NULL;
}
arr->max_length = (mono_array_size_t)max_length;
str = (MonoString*)sgen_alloc_obj_nolock (vtable, size);
if (G_UNLIKELY (!str)) {
UNLOCK_GC;
- return mono_gc_out_of_memory (size);
+ return NULL;
}
str->length = len;
static void
sgen_thread_attach (SgenThreadInfo *info)
{
+ mono_handle_arena_init ((MonoHandleArena**) &info->client_info.info.handle_arena);
+
if (mono_gc_get_gc_callbacks ()->thread_attach_func && !info->client_info.runtime_data)
info->client_info.runtime_data = mono_gc_get_gc_callbacks ()->thread_attach_func ();
}
*/
if (mono_domain_get ())
mono_thread_detach_internal (mono_thread_internal_current ());
+
+ mono_handle_arena_cleanup ((MonoHandleArena**) &p->client_info.info.handle_arena);
}
gboolean
// FIXME:
}
-void
-sgen_client_out_of_memory (size_t size)
-{
- mono_gc_out_of_memory (size);
-}
-
guint8*
mono_gc_get_card_table (int *shift_bits, gpointer *mask)
{
if (nursery_canaries_enabled ())
sgen_set_use_managed_allocator (FALSE);
+
+#if defined(HAVE_KW_THREAD)
+ /* This can happen with using libmonosgen.so */
+ if (mono_tls_key_get_offset (TLS_KEY_SGEN_TLAB_NEXT_ADDR) == -1)
+ sgen_set_use_managed_allocator (FALSE);
+#endif
}
void