#include <mono/metadata/opcodes.h>
#include <mono/metadata/domain-internals.h>
#include <mono/metadata/metadata-internals.h>
-#include <mono/utils/mono-logger.h>
+#include <mono/metadata/marshal.h>
+#include <mono/utils/mono-logger-internal.h>
#include <mono/utils/mono-time.h>
#include <mono/utils/dtrace.h>
}
#endif
+#if !defined(PLATFORM_ANDROID)
+ /* If GC_no_dls is set to true, GC_find_limit is not called. This causes a seg fault on Android. */
GC_no_dls = TRUE;
+#endif
GC_init ();
GC_oom_fn = mono_gc_out_of_memory;
GC_set_warn_proc (mono_gc_warning);
#else
if (mono_gc_is_gc_thread())
return TRUE;
-#if defined(USE_INCLUDED_LIBGC) && !defined(PLATFORM_WIN32)
+#if defined(USE_INCLUDED_LIBGC) && !defined(HOST_WIN32)
return GC_thread_register_foreign (baseptr);
#else
return FALSE;
void
mono_gc_deregister_root (char* addr)
{
-#ifndef PLATFORM_WIN32
+#ifndef HOST_WIN32
/* FIXME: libgc doesn't define this work win32 for some reason */
/* FIXME: No size info */
GC_remove_roots (addr, addr + sizeof (gpointer) + 1);
*link_addr = NULL;
}
+static gpointer
+reveal_link (gpointer link_addr)
+{
+ void **link_a = link_addr;
+ return REVEAL_POINTER (*link_a);
+}
+
MonoObject*
mono_gc_weak_link_get (void **link_addr)
{
- MonoObject *obj = REVEAL_POINTER (*link_addr);
+ MonoObject *obj = GC_call_with_alloc_lock (reveal_link, link_addr);
if (obj == (MonoObject *) -1)
return NULL;
return obj;
int
mono_gc_get_suspend_signal (void)
{
+#ifdef USE_INCLUDED_GC
return GC_get_suspend_signal ();
+#else
+ return -1;
+#endif
}
#if defined(USE_INCLUDED_LIBGC) && defined(USE_COMPILER_TLS) && defined(__linux__) && (defined(__i386__) || defined(__x86_64__))
MonoMethodBuilder *mb;
MonoMethod *res;
MonoMethodSignature *csig;
+ AllocatorWrapperInfo *info;
if (atype == ATYPE_STRING) {
csig = mono_metadata_signature_alloc (mono_defaults.corlib, 2);
res = mono_mb_create_method (mb, csig, 8);
mono_mb_free (mb);
mono_method_get_header (res)->init_locals = FALSE;
+
+ info = mono_image_alloc0 (mono_defaults.corlib, sizeof (AllocatorWrapperInfo));
+ info->alloc_type = atype;
+ mono_marshal_set_wrapper_info (res, info);
+
return res;
}
return NULL;
}
-/**
- * mono_gc_get_managed_allocator_id:
- *
- * Return a type for the managed allocator method MANAGED_ALLOC which can later be passed
- * to mono_gc_get_managed_allocator_by_type () to get back this allocator method. This can be
- * used by the AOT code to encode references to managed allocator methods.
- */
-int
-mono_gc_get_managed_allocator_type (MonoMethod *managed_alloc)
-{
- int i;
-
- mono_loader_lock ();
- for (i = 0; i < ATYPE_NUM; ++i) {
- if (alloc_method_cache [i] == managed_alloc) {
- mono_loader_unlock ();
- return i;
- }
- }
- mono_loader_unlock ();
-
- return -1;
-}
-
/**
* mono_gc_get_managed_allocator_by_type:
*
return ATYPE_NUM;
}
+MonoMethod*
+mono_gc_get_write_barrier (void)
+{
+ g_assert_not_reached ();
+ return NULL;
+}
+
#else
MonoMethod*
return NULL;
}
-int
-mono_gc_get_managed_allocator_type (MonoMethod *managed_alloc)
-{
- return -1;
-}
-
MonoMethod*
mono_gc_get_managed_allocator_by_type (int atype)
{
return 0;
}
+MonoMethod*
+mono_gc_get_write_barrier (void)
+{
+ g_assert_not_reached ();
+ return NULL;
+}
+
#endif
+void*
+mono_gc_invoke_with_gc_lock (MonoGCLockedCallbackFunc func, void *data)
+{
+ return GC_call_with_alloc_lock (func, data);
+}
+
#endif /* no Boehm GC */