-
+/*
+ * (C) 2003 Ximian, Inc.
+ * (C) 2003-2011 Novell, Inc.
+ * Copyright 2011 Xamarin, Inc (http://www.xamarin.com)
+ */
#include <config.h>
#include <glib.h>
}
}
-#ifdef MONO_ARCH_HAVE_STATIC_RGCTX_TRAMPOLINE
+#ifdef MONO_ARCH_GSHARED_SUPPORTED
typedef struct {
MonoMethod *m;
gpointer
mono_create_static_rgctx_trampoline (MonoMethod *m, gpointer addr)
{
- /*
- * This shouldn't happen as all arches which support generic sharing support
- * static rgctx trampolines as well.
- */
- g_assert_not_reached ();
+ /*
+ * This shouldn't happen as all arches which support generic sharing support
+ * static rgctx trampolines as well.
+ */
+ g_assert_not_reached ();
}
#endif
* Either IMPL_METHOD or AOT_ADDR will be set on return.
*/
static gpointer*
+#ifdef __GNUC__
+/*
+ * 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, 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);
g_assert (this_argument->vtable->klass->inited);
//mono_class_init (this_argument->vtable->klass);
- if (!vtable_slot)
+ if (!vtable_slot) {
+ mono_class_setup_supertypes (this_argument->vtable->klass);
klass = this_argument->vtable->klass->supertypes [m->klass->idepth - 1];
+ }
#else
NOT_IMPLEMENTED;
#endif
}
if (m->iflags & METHOD_IMPL_ATTRIBUTE_SYNCHRONIZED) {
- MonoJitInfo *ji;
-
- if (code)
- ji = mini_jit_info_table_find (mono_domain_get (), (char*)code, NULL);
- else
- ji = NULL;
-
- /* Avoid recursion */
- if (!(ji && ji->method->wrapper_type == MONO_WRAPPER_SYNCHRONIZED)) {
- m = mono_marshal_get_synchronized_wrapper (m);
- need_rgctx_tramp = FALSE;
- }
+ m = mono_marshal_get_synchronized_wrapper (m);
+ need_rgctx_tramp = FALSE;
}
/* Calls made through delegates on platforms without delegate trampolines */
{
MonoContext ctx;
MonoException *exc;
- MonoJitTlsData *jit_tls = TlsGetValue (mono_jit_tls_id);
+ MonoJitTlsData *jit_tls = mono_native_tls_get_value (mono_jit_tls_id);
gpointer resume_ip = jit_tls->handler_block_return_address;
memcpy (&ctx, &jit_tls->handler_block_context, sizeof (MonoContext));
if (!restore_context)
restore_context = mono_get_restore_context ();
- mono_handle_exception (&ctx, exc, NULL, FALSE);
+ mono_handle_exception (&ctx, exc);
restore_context (&ctx);
}
* We cannot recover the correct type of a shared generic
* method from its native code address, so we use the
* trampoline instead.
+ * For synchronized methods, the trampoline adds the wrapper.
*/
- if (code && !ji->has_generic_jit_info)
+ if (code && !ji->has_generic_jit_info && !(method->iflags & METHOD_IMPL_ATTRIBUTE_SYNCHRONIZED))
return code;
mono_domain_lock (domain);
MonoDomain *domain = mono_domain_get ();
guint8 *buf, *start;
- buf = start = mono_domain_code_reserve (domain, 2 * sizeof (gpointer));
+ buf = start = mono_domain_alloc0 (domain, 2 * sizeof (gpointer));
*(gpointer*)(gpointer)buf = image;
buf += sizeof (gpointer);
}
gpointer
-mono_create_delegate_trampoline (MonoClass *klass)
+mono_create_delegate_trampoline (MonoDomain *domain, MonoClass *klass)
{
#ifdef MONO_ARCH_HAVE_CREATE_DELEGATE_TRAMPOLINE
- MonoDomain *domain = mono_domain_get ();
gpointer ptr;
guint32 code_size = 0;
gpointer *tramp_data;
tramp_data [1] = mono_arch_get_delegate_invoke_impl (mono_method_signature (invoke), TRUE);
tramp_data [2] = mono_arch_get_delegate_invoke_impl (mono_method_signature (invoke), FALSE);
- ptr = mono_create_specific_trampoline (tramp_data, MONO_TRAMPOLINE_DELEGATE, mono_domain_get (), &code_size);
+ ptr = mono_create_specific_trampoline (tramp_data, MONO_TRAMPOLINE_DELEGATE, domain, &code_size);
g_assert (code_size);
/* store trampoline address */
mono_create_monitor_enter_trampoline (void)
{
static gpointer code;
- MonoTrampInfo *info;
if (mono_aot_only) {
if (!code)
mono_trampolines_lock ();
if (!code) {
+ MonoTrampInfo *info;
+
code = mono_arch_create_monitor_enter_trampoline (&info, FALSE);
if (info) {
mono_save_trampoline_xdebug_info (info);
mono_create_monitor_exit_trampoline (void)
{
static gpointer code;
- MonoTrampInfo *info;
if (mono_aot_only) {
if (!code)
mono_trampolines_lock ();
if (!code) {
+ MonoTrampInfo *info;
+
code = mono_arch_create_monitor_exit_trampoline (&info, FALSE);
if (info) {
mono_save_trampoline_xdebug_info (info);