#include <mono/utils/mono-counters.h>
#include <mono/utils/mono-error-internals.h>
#include <mono/utils/mono-membar.h>
+#include <mono/utils/mono-compiler.h>
#include "mini.h"
static GHashTable *rgctx_lazy_fetch_trampoline_hash_addr;
static guint32 trampoline_calls, jit_trampolines, unbox_trampolines, static_rgctx_trampolines;
-#define mono_trampolines_lock() EnterCriticalSection (&trampolines_mutex)
-#define mono_trampolines_unlock() LeaveCriticalSection (&trampolines_mutex)
-static CRITICAL_SECTION trampolines_mutex;
+#define mono_trampolines_lock() mono_mutex_lock (&trampolines_mutex)
+#define mono_trampolines_unlock() mono_mutex_unlock (&trampolines_mutex)
+static mono_mutex_t trampolines_mutex;
#ifdef MONO_ARCH_GSHARED_SUPPORTED
/*
* Either IMPL_METHOD or AOT_ADDR will be set on return.
- */
-static gpointer*
-#ifdef __GNUC__
-/*
+ *
+ * MONO_NEVER_INLINE :
* This works against problems when compiling with gcc 4.6 on arm. The 'then' part of
* this line gets executed, even when the condition is false:
* if (impl && mono_method_needs_static_rgctx_invoke (impl, FALSE))
* *need_rgctx_tramp = TRUE;
*/
-__attribute__ ((noinline))
-#endif
- mono_convert_imt_slot_to_vtable_slot (gpointer* slot, mgreg_t *regs, guint8 *code, MonoMethod *method, gboolean lookup_aot, MonoMethod **impl_method, gboolean *need_rgctx_tramp, gboolean *variance_used, gpointer *aot_addr)
+static MONO_NEVER_INLINE gpointer*
+mono_convert_imt_slot_to_vtable_slot (gpointer* slot, mgreg_t *regs, guint8 *code, MonoMethod *method, gboolean lookup_aot, MonoMethod **impl_method, gboolean *need_rgctx_tramp, gboolean *variance_used, gpointer *aot_addr)
{
MonoObject *this_argument = mono_arch_get_this_arg_from_call (regs, code);
MonoVTable *vt = this_argument->vtable;
* We use one vtable trampoline per vtable slot index, so we need only the vtable,
* the other two can be computed from the vtable + the slot index.
*/
-#ifndef MONO_ARCH_THIS_AS_FIRST_ARG
- /* All architectures should support this */
- g_assert_not_reached ();
-#endif
/*
* Obtain the vtable from the 'this' arg.
invoke = mono_get_delegate_invoke (klass);
g_assert (invoke);
- tramp_data = mono_domain_alloc (domain, sizeof (MonoDelegateTrampInfo));
+ tramp_data = mono_domain_alloc0 (domain, sizeof (MonoDelegateTrampInfo));
tramp_data->invoke = invoke;
tramp_data->invoke_sig = mono_method_signature (invoke);
tramp_data->impl_this = mono_arch_get_delegate_invoke_impl (mono_method_signature (invoke), TRUE);
void
mono_trampolines_init (void)
{
- InitializeCriticalSection (&trampolines_mutex);
+ mono_mutex_init_recursive (&trampolines_mutex);
if (mono_aot_only)
return;
if (rgctx_lazy_fetch_trampoline_hash_addr)
g_hash_table_destroy (rgctx_lazy_fetch_trampoline_hash_addr);
- DeleteCriticalSection (&trampolines_mutex);
+ mono_mutex_destroy (&trampolines_mutex);
}
guint8 *
#endif
}
+gpointer
+mono_create_delegate_virtual_trampoline (MonoDomain *domain, MonoClass *klass, MonoMethod *method)
+{
+#ifdef MONO_ARCH_HAVE_CREATE_DELEGATE_TRAMPOLINE
+ MonoMethod *invoke = mono_get_delegate_invoke (klass);
+ g_assert (invoke);
+
+ return mono_get_delegate_virtual_invoke_impl (mono_method_signature (invoke), method);
+#else
+ return NULL;
+#endif
+}
+
gpointer
mono_create_rgctx_lazy_fetch_trampoline (guint32 offset)
{