#define MONO_LLVM_IN_MINI 1
#include <config.h>
-#include <signal.h>
#ifdef HAVE_ALLOCA_H
#include <alloca.h>
#endif
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
+#ifdef HAVE_SIGNAL_H
+#include <signal.h>
+#endif
#include <mono/utils/memcheck.h>
/* Whenever to check for pending exceptions in managed-to-native wrappers */
gboolean check_for_pending_exc = TRUE;
-/* Whenever to disable passing/returning small valuetypes in registers for managed methods */
-gboolean disable_vtypes_in_regs = FALSE;
-
static GSList *tramp_infos;
static void register_icalls (void);
dest->klass = dest->inst_i0->klass;
}
+MonoInst*
+mini_get_int_to_float_spill_area (MonoCompile *cfg)
+{
+#ifdef TARGET_X86
+ if (!cfg->iconv_raw_var) {
+ cfg->iconv_raw_var = mono_compile_create_var (cfg, &mono_defaults.int32_class->byval_arg, OP_LOCAL);
+ cfg->iconv_raw_var->flags |= MONO_INST_VOLATILE; /*FIXME, use the don't regalloc flag*/
+ }
+ return cfg->iconv_raw_var;
+#else
+ return NULL;
+#endif
+}
+
#endif
void
/* Only two instructions */
opcode = bb->code->opcode;
- if ((opcode == OP_COMPARE) || (opcode == OP_COMPARE_IMM) || (opcode == OP_ICOMPARE) || (opcode == OP_ICOMPARE_IMM) || (opcode == OP_FCOMPARE) || (opcode == OP_LCOMPARE) || (opcode == OP_LCOMPARE_IMM)) {
+ if ((opcode == OP_COMPARE) || (opcode == OP_COMPARE_IMM) || (opcode == OP_ICOMPARE) || (opcode == OP_ICOMPARE_IMM) || (opcode == OP_FCOMPARE) || (opcode == OP_LCOMPARE) || (opcode == OP_LCOMPARE_IMM) || (opcode == OP_RCOMPARE)) {
/* NEW IR */
mono_bblock_insert_before_ins (bb, bb->code, inst);
} else {
} else {
opcode = bb->last_ins->prev->opcode;
- if ((opcode == OP_COMPARE) || (opcode == OP_COMPARE_IMM) || (opcode == OP_ICOMPARE) || (opcode == OP_ICOMPARE_IMM) || (opcode == OP_FCOMPARE) || (opcode == OP_LCOMPARE) || (opcode == OP_LCOMPARE_IMM)) {
+ if ((opcode == OP_COMPARE) || (opcode == OP_COMPARE_IMM) || (opcode == OP_ICOMPARE) || (opcode == OP_ICOMPARE_IMM) || (opcode == OP_FCOMPARE) || (opcode == OP_LCOMPARE) || (opcode == OP_LCOMPARE_IMM) || (opcode == OP_RCOMPARE)) {
/* NEW IR */
mono_bblock_insert_before_ins (bb, bb->last_ins->prev, inst);
} else {
MonoMethod *wrapper;
gconstpointer trampoline;
MonoDomain *domain = mono_get_root_domain ();
+ gboolean check_exc = check_for_pending_exc;
if (callinfo->wrapper) {
return callinfo->wrapper;
return callinfo->trampoline;
}
+ if (!strcmp (callinfo->name, "mono_thread_interruption_checkpoint"))
+ /* This icall is used to check for exceptions, so don't check in the wrapper */
+ check_exc = FALSE;
+
name = g_strdup_printf ("__icall_wrapper_%s", callinfo->name);
- wrapper = mono_marshal_get_icall_wrapper (callinfo->sig, name, callinfo->func, check_for_pending_exc);
+ wrapper = mono_marshal_get_icall_wrapper (callinfo->sig, name, callinfo->func, check_exc);
g_free (name);
if (do_compile)
g_assert (!sig->hasthis);
g_assert (sig->param_count < 3);
- info = mono_register_jit_icall_full (func, name, sig, no_throw, symbol);
+ /* Opcode emulation functions are assumed to don't call mono_raise_exception () */
+ info = mono_register_jit_icall_full (func, name, sig, no_throw, TRUE, symbol);
if (emul_opcode_num >= emul_opcode_alloced) {
int incr = emul_opcode_alloced? emul_opcode_alloced/2: 16;
else
sig = NULL;
- mono_register_jit_icall_full (func, name, sig, save, save ? name : NULL);
+ mono_register_jit_icall_full (func, name, sig, save, FALSE, save ? name : NULL);
+}
+
+/* Register a jit icall which doesn't throw exceptions through mono_raise_exception () */
+static void
+register_icall_noraise (gpointer func, const char *name, const char *sigstr)
+{
+ MonoMethodSignature *sig;
+
+ if (sigstr)
+ sig = mono_create_icall_signature (sigstr);
+ else
+ sig = NULL;
+
+ mono_register_jit_icall_full (func, name, sig, TRUE, TRUE, name);
}
static void
case MONO_PATCH_INFO_GC_CARD_TABLE_ADDR:
case MONO_PATCH_INFO_JIT_TLS_ID:
case MONO_PATCH_INFO_MONITOR_ENTER:
+ case MONO_PATCH_INFO_MONITOR_ENTER_V4:
case MONO_PATCH_INFO_MONITOR_EXIT:
case MONO_PATCH_INFO_GOT_OFFSET:
return (ji->type << 8);
case MONO_PATCH_INFO_TYPE_FROM_HANDLE: {
gpointer handle;
MonoClass *handle_class;
+ MonoError error;
- handle = mono_ldtoken (patch_info->data.token->image,
- patch_info->data.token->token, &handle_class, patch_info->data.token->has_context ? &patch_info->data.token->context : NULL);
+ handle = mono_ldtoken_checked (patch_info->data.token->image,
+ patch_info->data.token->token, &handle_class, patch_info->data.token->has_context ? &patch_info->data.token->context : NULL, &error);
+ if (!mono_error_ok (&error))
+ g_error ("Could not patch ldtoken due to %s", mono_error_get_message (&error));
mono_class_init (handle_class);
mono_class_init (mono_class_from_mono_type (handle));
case MONO_PATCH_INFO_LDTOKEN: {
gpointer handle;
MonoClass *handle_class;
+ MonoError error;
- handle = mono_ldtoken (patch_info->data.token->image,
- patch_info->data.token->token, &handle_class, patch_info->data.token->has_context ? &patch_info->data.token->context : NULL);
+ handle = mono_ldtoken_checked (patch_info->data.token->image,
+ patch_info->data.token->token, &handle_class, patch_info->data.token->has_context ? &patch_info->data.token->context : NULL, &error);
+ if (!mono_error_ok (&error))
+ g_error ("Could not patch ldtoken due to %s", mono_error_get_message (&error));
mono_class_init (handle_class);
target = handle;
case MONO_PATCH_INFO_MONITOR_ENTER:
target = mono_create_monitor_enter_trampoline ();
break;
+ case MONO_PATCH_INFO_MONITOR_ENTER_V4:
+ target = mono_create_monitor_enter_v4_trampoline ();
+ break;
case MONO_PATCH_INFO_MONITOR_EXIT:
target = mono_create_monitor_exit_trampoline ();
break;
if (cfg->opt & MONO_OPT_PEEPHOLE)
mono_arch_peephole_pass_2 (cfg, bb);
+
+ if (cfg->gen_seq_points && !cfg->gen_seq_points_debug_data)
+ bb_deduplicate_op_il_seq_points (cfg, bb);
}
if (cfg->prof_options & MONO_PROFILE_COVERAGE)
MonoMethod*
mini_get_shared_method_full (MonoMethod *method, gboolean all_vt, gboolean is_gsharedvt)
{
+ MonoError error;
MonoGenericContext shared_context;
MonoMethod *declaring_method, *res;
gboolean partial = FALSE;
partial = TRUE;
}
- res = mono_class_inflate_generic_method (declaring_method, &shared_context);
+ res = mono_class_inflate_generic_method_checked (declaring_method, &shared_context, &error);
+ g_assert (mono_error_ok (&error)); /* FIXME don't swallow the error */
+
if (!partial) {
/* The result should be an inflated method whose parent is not inflated */
g_assert (!res->klass->is_inflated);
cfg->compile_llvm = try_llvm;
cfg->token_info_hash = g_hash_table_new (NULL, NULL);
+ if (!mono_debug_count ())
+ cfg->opt &= ~MONO_OPT_FLOAT32;
+ cfg->r4fp = (cfg->opt & MONO_OPT_FLOAT32) ? 1 : 0;
+ cfg->r4_stack_type = cfg->r4fp ? STACK_R4 : STACK_R8;
+
if (cfg->gen_seq_points)
cfg->seq_points = g_ptr_array_new ();
mono_error_init (&cfg->error);
if (method->is_inflated)
ctx = mono_method_get_context (method);
method = info->d.synchronized_inner.method;
- if (ctx)
- method = mono_class_inflate_generic_method (method, ctx);
+ if (ctx) {
+ MonoError error;
+ method = mono_class_inflate_generic_method_checked (method, ctx, &error);
+ g_assert (mono_error_ok (&error)); /* FIXME don't swallow the error */
+ }
}
}
gpointer *args;
static RuntimeInvokeDynamicFunction dyn_runtime_invoke;
int i, pindex;
- guint8 buf [128];
- guint8 retval [128];
+ guint8 buf [256];
+ guint8 retval [256];
if (!dyn_runtime_invoke) {
invoke = mono_marshal_get_runtime_invoke_dynamic ();
gpointer fault_addr = NULL;
#ifdef HAVE_SIG_INFO
MONO_SIG_HANDLER_INFO_TYPE *info = MONO_SIG_HANDLER_GET_INFO ();
+#else
+ void *info = NULL;
#endif
MONO_SIG_HANDLER_GET_CONTEXT;
}
#endif
-#if !defined(HOST_WIN32) && defined(HAVE_SIG_INFO)
+#if defined(HAVE_SIG_INFO)
+#if !defined(HOST_WIN32)
fault_addr = info->si_addr;
if (mono_aot_is_pagefault (info->si_addr)) {
mono_aot_handle_pagefault (info->si_addr);
return;
}
}
+#endif
ji = mono_jit_info_table_find (mono_domain_get (), mono_arch_ip_from_context (ctx));
register_dyn_icall (mono_get_rethrow_exception (), "mono_arch_rethrow_exception", "void object", TRUE);
register_dyn_icall (mono_get_throw_corlib_exception (), "mono_arch_throw_corlib_exception", "void ptr", TRUE);
register_icall (mono_thread_get_undeniable_exception, "mono_thread_get_undeniable_exception", "object", FALSE);
- register_icall (mono_thread_interruption_checkpoint, "mono_thread_interruption_checkpoint", "void", FALSE);
+ register_icall (mono_thread_interruption_checkpoint, "mono_thread_interruption_checkpoint", "object", FALSE);
+ register_icall (mono_thread_force_interruption_checkpoint_noraise, "mono_thread_force_interruption_checkpoint_noraise", "object", FALSE);
register_icall (mono_thread_force_interruption_checkpoint, "mono_thread_force_interruption_checkpoint", "void", FALSE);
#ifndef DISABLE_REMOTING
register_icall (mono_load_remote_field_new, "mono_load_remote_field_new", "object object ptr ptr", FALSE);
register_opcode_emulation (OP_FCONV_TO_U4, "__emul_fconv_to_u4", "uint32 double", mono_fconv_u4, "mono_fconv_u4", FALSE);
register_opcode_emulation (OP_FCONV_TO_OVF_I8, "__emul_fconv_to_ovf_i8", "long double", mono_fconv_ovf_i8, "mono_fconv_ovf_i8", FALSE);
register_opcode_emulation (OP_FCONV_TO_OVF_U8, "__emul_fconv_to_ovf_u8", "ulong double", mono_fconv_ovf_u8, "mono_fconv_ovf_u8", FALSE);
+ register_opcode_emulation (OP_RCONV_TO_OVF_I8, "__emul_rconv_to_ovf_i8", "long float", mono_rconv_ovf_i8, "mono_rconv_ovf_i8", FALSE);
+ register_opcode_emulation (OP_RCONV_TO_OVF_U8, "__emul_rconv_to_ovf_u8", "ulong float", mono_rconv_ovf_u8, "mono_rconv_ovf_u8", FALSE);
#ifdef MONO_ARCH_EMULATE_FCONV_TO_I8
register_opcode_emulation (OP_FCONV_TO_I8, "__emul_fconv_to_i8", "long double", mono_fconv_i8, "mono_fconv_i8", FALSE);
+ register_opcode_emulation (OP_RCONV_TO_I8, "__emul_rconv_to_i8", "long float", mono_rconv_i8, "mono_rconv_i8", FALSE);
#endif
#ifdef MONO_ARCH_EMULATE_CONV_R8_UN
register_opcode_emulation (OP_ICONV_TO_R_UN, "__emul_iconv_to_r_un", "double int32", mono_conv_to_r8_un, "mono_conv_to_r8_un", FALSE);