#include "jit-icalls.c"
+#define MONO_IS_COND_BRANCH(op) ((op >= CEE_BEQ && op <= CEE_BLT_UN) || (op >= OP_LBEQ && op <= OP_LBLT_UN) || (op >= OP_FBEQ && op <= OP_FBLT_UN))
+
#define MONO_CHECK_THIS(ins) (cfg->method->signature->hasthis && (ins)->ssa_op == MONO_SSA_LOAD && (ins)->inst_left->inst_c0 == 0)
gboolean mono_arch_handle_exception (struct sigcontext *ctx, gpointer obj, gboolean test_only);
gboolean mono_jit_trace_calls = FALSE;
gboolean mono_break_on_exc = FALSE;
gboolean mono_compile_aot = FALSE;
-gboolean mono_trace_coverage = FALSE;
-gboolean mono_jit_profile = FALSE;
-MonoDebugFormat mono_debug_format = MONO_DEBUG_FORMAT_NONE;
-
-CRITICAL_SECTION *metadata_section = NULL;
static int mini_verbose = 0;
#endif
/* debug function */
-static void
+G_GNUC_UNUSED static void
print_method_from_ip (void *ip)
{
MonoJitInfo *ji;
char *method;
+ char *source;
+ MonoDomain *domain = mono_domain_get ();
- ji = mono_jit_info_table_find (mono_domain_get (), ip);
+ ji = mono_jit_info_table_find (domain, ip);
if (!ji) {
g_print ("No method at %p\n", ip);
return;
}
method = mono_method_full_name (ji->method, TRUE);
- g_print ("IP at offset 0x%x of method %s (%p %p)\n", (char*)ip - (char*)ji->code_start, method, ji->code_start, (char*)ji->code_start + ji->code_size);
+ source = mono_debug_source_location_from_address (ji->method, (int) ip, NULL, domain);
+
+ g_print ("IP %p at offset 0x%x of method %s (%p %p)\n", ip, (char*)ip - (char*)ji->code_start, method, ji->code_start, (char*)ji->code_start + ji->code_size);
+
+ if (source)
+ g_print ("%s\n", source);
+
+ g_free (source);
g_free (method);
}
(dest)->inst_right = (el2); \
} while (0)
-static GHashTable *coverage_hash = NULL;
-
-MonoCoverageInfo *
-mono_allocate_coverage_info (MonoMethod *method, int size)
-{
- MonoCoverageInfo *res;
-
- if (!coverage_hash)
- coverage_hash = g_hash_table_new (NULL, NULL);
-
- res = g_malloc0 (sizeof (MonoCoverageInfo) + sizeof (int) * size * 2);
-
- res->entries = size;
-
- g_hash_table_insert (coverage_hash, method, res);
-
- return res;
-}
-
-MonoCoverageInfo *
-mono_get_coverage_info (MonoMethod *method)
-{
- if (!coverage_hash)
- return NULL;
-
- return g_hash_table_lookup (coverage_hash, method);
-}
-
#if 0
static gint
compare_bblock (gconstpointer a, gconstpointer b)
clause = &header->clauses [i];
if ((clause->flags & MONO_EXCEPTION_CLAUSE_FILTER) && (offset >= clause->token_or_filter) &&
(offset < (clause->token_or_filter + filter_lengths [i])))
- return (i << 8) | 128 | clause->flags;
+ return ((i + 1) << 8) | MONO_REGION_FILTER | clause->flags;
if (MONO_OFFSET_IN_HANDLER (clause, offset)) {
- return (i << 8) | 64 | clause->flags;
+ if (clause->flags & MONO_EXCEPTION_CLAUSE_FINALLY)
+ return ((i + 1) << 8) | MONO_REGION_FINALLY | clause->flags;
+ else
+ return ((i + 1) << 8) | MONO_REGION_CATCH | clause->flags;
}
}
for (i = 0; i < header->num_clauses; ++i) {
clause = &header->clauses [i];
if (MONO_OFFSET_IN_CLAUSE (clause, offset))
- return (i << 8) | clause->flags;
+ return ((i + 1) << 8) | clause->flags;
}
return -1;
goto handle_enum;
}
return CEE_LDOBJ;
+ case MONO_TYPE_TYPEDBYREF:
+ return CEE_LDOBJ;
+ case MONO_TYPE_GENERICINST:
+ if (type->data.generic_inst->generic_type->type == MONO_TYPE_VALUETYPE)
+ return CEE_LDOBJ;
+ return CEE_LDIND_REF;
default:
g_error ("unknown type 0x%02x in type_to_ldind", type->type);
}
goto handle_enum;
}
return CEE_STOBJ;
- /* fail right now */
+ case MONO_TYPE_TYPEDBYREF:
+ return CEE_STOBJ;
+ case MONO_TYPE_GENERICINST:
+ if (type->data.generic_inst->generic_type->type == MONO_TYPE_VALUETYPE)
+ return CEE_STOBJ;
+ return CEE_STIND_REF;
default:
- g_error ("unknown type %02x in type_to_stind", type->type);
+ g_error ("unknown type 0x%02x in type_to_stind", type->type);
}
return -1;
}
inst->type = STACK_VTYPE;
return;
}
+ case MONO_TYPE_TYPEDBYREF:
+ inst->klass = mono_defaults.typed_reference_class;
+ inst->type = STACK_VTYPE;
+ return;
+ case MONO_TYPE_GENERICINST:
+ if (type->data.generic_inst->generic_type->type == MONO_TYPE_VALUETYPE) {
+ inst->klass = mono_class_from_mono_type (type);
+ inst->type = STACK_VTYPE;
+ } else {
+ inst->type = STACK_OBJ;
+ }
+ return;
default:
g_error ("unknown type 0x%02x in eval stack type", type->type);
}
cfg->vars = (MonoMethodVar **)g_realloc (cfg->vars, sizeof (MonoMethodVar*) * cfg->varinfo_count);
}
+ /*g_print ("created temp %d of type 0x%x\n", num, type->type);*/
mono_jit_stats.allocate_var++;
MONO_INST_NEW (cfg, inst, opcode);
goto handle_enum;
} else
return calli? OP_VCALL_REG: virt? OP_VCALLVIRT: OP_VCALL;
+ case MONO_TYPE_TYPEDBYREF:
+ return calli? OP_VCALL_REG: virt? OP_VCALLVIRT: OP_VCALL;
default:
- g_error ("unknown type %02x in ret_type_to_call_opcode", type->type);
+ g_error ("unknown type 0x%02x in ret_type_to_call_opcode", type->type);
}
return -1;
}
}
}
+/*
+ * Prepare arguments for passing to a function call.
+ * Return a non-zero value if the arguments can't be passed to the given
+ * signature.
+ * The type checks are not yet complete and some conversions may need
+ * casts on 32 or 64 bit architectures.
+ */
+static int
+check_call_signature (MonoCompile *cfg, MonoMethodSignature *sig, MonoInst **args)
+{
+ int i, simple_type;
+
+ if (sig->hasthis) {
+ if (args [0]->type != STACK_OBJ && args [0]->type != STACK_MP && args [0]->type != STACK_PTR)
+ return 1;
+ args++;
+ }
+ for (i = 0; i < sig->param_count; ++i) {
+ if (sig->params [i]->byref) {
+ /*
+ * check the result of ldelema is only passed as an argument if the byref
+ * type matches exactly the array element type.
+ * FIXME: if the argument as been saved on the stack as part of the
+ * interface variable code (the value was on the stack at a basic block boundary)
+ * we need to add the check in that case, too.
+ */
+ if (args [i]->opcode == CEE_LDELEMA) {
+ MonoInst *check;
+ MonoClass *exact_class = mono_class_from_mono_type (sig->params [i]);
+ if (!exact_class->valuetype) {
+ MONO_INST_NEW (cfg, check, OP_CHECK_ARRAY_TYPE);
+ check->cil_code = args [i]->cil_code;
+ check->klass = exact_class;
+ check->inst_left = args [i]->inst_left;
+ check->type = STACK_OBJ;
+ args [i]->inst_left = check;
+ }
+ }
+ if (args [i]->type != STACK_MP && args [i]->type != STACK_PTR)
+ return 1;
+ continue;
+ }
+ simple_type = sig->params [i]->type;
+handle_enum:
+ switch (simple_type) {
+ case MONO_TYPE_VOID:
+ return 1;
+ continue;
+ case MONO_TYPE_I1:
+ case MONO_TYPE_U1:
+ case MONO_TYPE_BOOLEAN:
+ case MONO_TYPE_I2:
+ case MONO_TYPE_U2:
+ case MONO_TYPE_CHAR:
+ case MONO_TYPE_I4:
+ case MONO_TYPE_U4:
+ if (args [i]->type != STACK_I4 && args [i]->type != STACK_PTR)
+ return 1;
+ continue;
+ case MONO_TYPE_I:
+ case MONO_TYPE_U:
+ case MONO_TYPE_PTR:
+ if (args [i]->type != STACK_I4 && args [i]->type != STACK_PTR && args [i]->type != STACK_MP && args [i]->type != STACK_OBJ)
+ return 1;
+ continue;
+ case MONO_TYPE_CLASS:
+ case MONO_TYPE_STRING:
+ case MONO_TYPE_OBJECT:
+ case MONO_TYPE_SZARRAY:
+ case MONO_TYPE_ARRAY:
+ if (args [i]->type != STACK_OBJ)
+ return 1;
+ continue;
+ case MONO_TYPE_I8:
+ case MONO_TYPE_U8:
+ if (args [i]->type != STACK_I8)
+ return 1;
+ continue;
+ case MONO_TYPE_R4:
+ case MONO_TYPE_R8:
+ if (args [i]->type != STACK_R8)
+ return 1;
+ continue;
+ case MONO_TYPE_VALUETYPE:
+ if (sig->params [i]->data.klass->enumtype) {
+ simple_type = sig->params [i]->data.klass->enum_basetype->type;
+ goto handle_enum;
+ }
+ if (args [i]->type != STACK_VTYPE)
+ return 1;
+ continue;
+ case MONO_TYPE_TYPEDBYREF:
+ if (args [i]->type != STACK_VTYPE)
+ return 1;
+ continue;
+ default:
+ g_error ("unknown type 0x%02x in check_call_signature", simple_type);
+ }
+ }
+ return 0;
+}
+
inline static int
mono_spill_call (MonoCompile *cfg, MonoBasicBlock *bblock, MonoCallInst *call, MonoMethodSignature *sig, gboolean ret_object,
const guint8 *ip, gboolean to_end)
MonoInst **args, int calli, int virtual, const guint8 *ip, gboolean to_end)
{
MonoCallInst *call;
+ MonoInst *arg;
int i;
MONO_INST_NEW_CALL (cfg, call, ret_type_to_call_opcode (sig->ret, calli, virtual));
call->signature = sig;
call = mono_arch_call_opcode (cfg, bblock, call, virtual);
- for (i = 0; i < (sig->param_count + sig->hasthis); ++i) {
- if (call->args [i]) {
- if (!call->args [i]->cil_code)
- call->args [i]->cil_code = ip;
- if (to_end)
- mono_add_ins_to_end (bblock, call->args [i]);
- else
- MONO_ADD_INS (bblock, call->args [i]);
- }
+ for (arg = call->out_args; arg;) {
+ MonoInst *narg = arg->next;
+ arg->next = NULL;
+ if (!arg->cil_code)
+ arg->cil_code = ip;
+ if (to_end)
+ mono_add_ins_to_end (bblock, arg);
+ else
+ MONO_ADD_INS (bblock, arg);
+ arg = narg;
}
return call;
}
inline static int
mono_emit_method_call_spilled (MonoCompile *cfg, MonoBasicBlock *bblock, MonoMethod *method,
- MonoInst **args, const guint8 *ip, MonoInst *this)
+ MonoMethodSignature *signature, MonoInst **args, const guint8 *ip, MonoInst *this)
{
- MonoCallInst *call = mono_emit_method_call (cfg, bblock, method, method->signature, args, ip, this);
+ MonoCallInst *call = mono_emit_method_call (cfg, bblock, method, signature, args, ip, this);
- return mono_spill_call (cfg, bblock, call, method->signature, method->string_ctor, ip, FALSE);
+ return mono_spill_call (cfg, bblock, call, signature, method->string_ctor, ip, FALSE);
}
inline static int
mono_emulate_opcode (MonoCompile *cfg, MonoInst *tree, MonoInst **iargs, MonoJitICallInfo *info)
{
MonoInst *ins, *temp = NULL, *store, *load;
+ MonoInst *last_arg = NULL;
int i, nargs;
MonoCallInst *call;
nargs = info->sig->param_count + info->sig->hasthis;
- for (i = 1; i < nargs; i++) {
- call->args [i - 1]->next = call->args [i];
- }
+ for (last_arg = call->out_args; last_arg && last_arg->next; last_arg = last_arg->next) ;
if (nargs)
- call->args [nargs - 1]->next = store;
+ last_arg->next = store;
if (cfg->prev_ins) {
store->next = cfg->prev_ins->next;
if (nargs)
- cfg->prev_ins->next = call->args [0];
+ cfg->prev_ins->next = call->out_args;
else
cfg->prev_ins->next = store;
} else {
store->next = cfg->cbb->code;
if (nargs)
- cfg->cbb->code = call->args [0];
+ cfg->cbb->code = call->out_args;
else
cfg->cbb->code = store;
}
MONO_ADD_INS (bblock, ins);
break;
default:
+ if (n <= sizeof (gpointer) * 5) {
+ ins->opcode = OP_MEMSET;
+ ins->inst_imm = 0;
+ ins->unused = n;
+ MONO_ADD_INS (bblock, ins);
+ break;
+ }
handle_loaded_temps (cfg, bblock, stack_start, sp);
NEW_ICONST (cfg, ins, n);
iargs [0] = dest;
op = OP_SQRT;
else if (strcmp (cmethod->name, "Abs") == 0 && fsig->params [0]->type == MONO_TYPE_R8)
op = OP_ABS;
+#if 0
+ /* OP_FREM is not IEEE compatible */
+ else if (strcmp (cmethod->name, "IEEERemainder") == 0)
+ op = OP_FREM;
+#endif
+ else
+ return NULL;
+ } else if (cmethod->klass == mono_defaults.array_class) {
+ if (strcmp (cmethod->name, "get_Rank") == 0)
+ op = OP_ARRAY_RANK;
+ else if (strcmp (cmethod->name, "get_Length") == 0)
+ op = CEE_LDLEN;
else
return NULL;
} else {
#define CHECK_STACK(num) if ((sp - stack_start) < (num)) goto unverified
#define CHECK_STACK_OVF(num) if (((sp - stack_start) + (num)) > header->max_stack) goto unverified
+#define TYPE_PARAM_TO_TYPE(num) (method->klass->generic_inst->data.generic_inst->type_argv [(num)])
+#define TYPE_PARAM_TO_CLASS(num) (mono_class_from_mono_type (TYPE_PARAM_TO_TYPE ((num))))
+
/* offset from br.s -> br like opcodes */
#define BIG_BRANCH_OFFSET 13
while (ip < end) {
cli_addr = ip - start;
- i = mono_opcode_value (&ip);
+ i = mono_opcode_value ((const guint8 **)&ip);
opcode = &mono_opcodes [i];
switch (opcode->argument) {
case MonoInlineNone:
return 1;
}
+static MonoClassField *
+get_generic_field_inst (MonoClassField *field, MonoClass *klass, MonoClass **retclass)
+{
+ int i;
+ for (i = 0; i < field->parent->field.count; ++i) {
+ if (field == &field->parent->fields [i]) {
+ *retclass = klass;
+ return &klass->fields [i];
+ }
+ }
+ return NULL;
+}
+
/*
* mono_method_to_ir: translates IL into basic blocks containing trees
*/
bbhash = g_hash_table_new (g_direct_hash, NULL);
}
+ if (cfg->verbose_level > 2)
+ g_print ("method to IR %s\n", mono_method_full_name (method, TRUE));
+
+ if (cfg->prof_options & MONO_PROFILE_INS_COVERAGE)
+ cfg->coverage_info = mono_profiler_coverage_alloc (cfg->method, header->code_size);
+
dont_inline = g_list_prepend (dont_inline, method);
if (cfg->method == method) {
}
}
+ if (cfg->coverage_info) {
+ MonoInst *store, *one;
+ guint32 cil_offset = ip - header->code;
+ cfg->coverage_info->data [cil_offset].cil_code = ip;
+
+ /* TODO: Use an increment here */
+ NEW_ICONST (cfg, one, 1);
+ one->cil_code = ip;
+
+ NEW_PCONST (cfg, ins, &(cfg->coverage_info->data [cil_offset].count));
+ ins->cil_code = ip;
+
+ MONO_INST_NEW (cfg, store, CEE_STIND_I);
+ store->cil_code = ip;
+ store->inst_left = ins;
+ store->inst_right = one;
+
+ MONO_ADD_INS (bblock, store);
+ }
+
if (cfg->verbose_level > 3)
g_print ("converting (in B%d: stack: %d) %s", bblock->block_num, sp-stack_start, mono_disasm_code_one (NULL, method, ip, NULL));
n = fsig->param_count + fsig->hasthis;
} else {
- cmethod = mono_get_method (image, token, NULL);
+ if (method->wrapper_type != MONO_WRAPPER_NONE) {
+ cmethod = (MonoMethod *)mono_method_get_wrapper_data (method, token);
+ } else {
+ cmethod = mono_get_method (image, token, NULL);
+ }
if (!cmethod->klass->inited)
mono_class_init (cmethod->klass);
}
#endif
} else {
- fsig = cmethod->signature;
+ fsig = mono_method_get_signature (cmethod, image, token);
}
n = fsig->param_count + fsig->hasthis;
sp -= n;
+ if (*ip != CEE_CALLI && check_call_signature (cfg, fsig, sp))
+ goto unverified;
+
if ((ins_flag & MONO_INST_TAILCALL) && cmethod && (*ip == CEE_CALL)) {
int i;
for (i = 0; i < n; ++i) {
ins = (MonoInst*)mono_emit_method_call (cfg, bblock, cmethod, fsig, sp, ip, virtual ? sp [0] : NULL);
*sp++ = ins;
} else {
- if ((temp = mono_emit_method_call_spilled (cfg, bblock, cmethod, sp, ip, virtual ? sp [0] : NULL)) != -1) {
+ if ((temp = mono_emit_method_call_spilled (cfg, bblock, cmethod, fsig, sp, ip, virtual ? sp [0] : NULL)) != -1) {
NEW_TEMPLOAD (cfg, *sp, temp);
sp++;
}
case CEE_CONV_I1:
case CEE_CONV_I2:
case CEE_CONV_I4:
- case CEE_CONV_I8:
case CEE_CONV_R4:
case CEE_CONV_R8:
case CEE_CONV_U4:
+ case CEE_CONV_I8:
case CEE_CONV_U8:
case CEE_CONV_OVF_I8:
case CEE_CONV_OVF_U8:
case CEE_CONV_R_UN:
CHECK_STACK (1);
ADD_UNOP (*ip);
- ip++;
+ ip++;
break;
case CEE_CONV_OVF_I4:
case CEE_CONV_OVF_I1:
ip++;
break;
case CEE_CPOBJ:
- g_error ("opcode 0x%02x not handled", *ip);
+ CHECK_STACK (2);
+ token = read32 (ip + 1);
+ if (method->wrapper_type != MONO_WRAPPER_NONE)
+ klass = mono_method_get_wrapper_data (method, token);
+ else
+ klass = mono_class_get (image, token);
+
+ mono_class_init (klass);
+ if (klass->byval_arg.type == MONO_TYPE_VAR)
+ klass = TYPE_PARAM_TO_CLASS (klass->byval_arg.data.type_param);
+ sp -= 2;
+ if (MONO_TYPE_IS_REFERENCE (&klass->byval_arg)) {
+ MonoInst *store, *load;
+ MONO_INST_NEW (cfg, load, CEE_LDIND_REF);
+ load->cil_code = ip;
+ load->inst_i0 = sp [1];
+ load->type = ldind_type [CEE_LDIND_REF];
+ load->flags |= ins_flag;
+ MONO_INST_NEW (cfg, store, CEE_STIND_REF);
+ store->cil_code = ip;
+ handle_loaded_temps (cfg, bblock, stack_start, sp);
+ MONO_ADD_INS (bblock, store);
+ store->inst_i0 = sp [0];
+ store->inst_i1 = load;
+ store->flags |= ins_flag;
+ } else {
+ n = mono_class_value_size (klass, NULL);
+ if ((cfg->opt & MONO_OPT_INTRINS) && n <= sizeof (gpointer) * 5) {
+ MonoInst *copy;
+ MONO_INST_NEW (cfg, copy, OP_MEMCPY);
+ copy->inst_left = sp [0];
+ copy->inst_right = sp [1];
+ copy->cil_code = ip;
+ copy->unused = n;
+ MONO_ADD_INS (bblock, copy);
+ } else {
+ MonoInst *iargs [3];
+ iargs [0] = sp [0];
+ iargs [1] = sp [1];
+ NEW_ICONST (cfg, iargs [2], n);
+ iargs [2]->cil_code = ip;
+
+ mono_emit_jit_icall (cfg, bblock, helper_memcpy, iargs, ip);
+ }
+ }
+ ins_flag = 0;
+ ip += 5;
break;
case CEE_LDOBJ: {
MonoInst *iargs [3];
klass = mono_class_get (image, token);
mono_class_init (klass);
+ if (klass->byval_arg.type == MONO_TYPE_VAR)
+ klass = TYPE_PARAM_TO_CLASS (klass->byval_arg.data.type_param);
+ if (MONO_TYPE_IS_REFERENCE (&klass->byval_arg)) {
+ MONO_INST_NEW (cfg, ins, CEE_LDIND_REF);
+ ins->cil_code = ip;
+ ins->inst_i0 = sp [0];
+ ins->type = ldind_type [CEE_LDIND_REF];
+ ins->flags |= ins_flag;
+ ins_flag = 0;
+ *sp++ = ins;
+ ip += 5;
+ break;
+ }
n = mono_class_value_size (klass, NULL);
ins = mono_compile_create_var (cfg, &klass->byval_arg, OP_LOCAL);
NEW_TEMPLOADA (cfg, iargs [0], ins->inst_c0);
NEW_TEMPLOAD (cfg, *sp, ins->inst_c0);
++sp;
ip += 5;
+ ins_flag = 0;
inline_costs += 1;
break;
}
CHECK_STACK_OVF (1);
n = read32 (ip + 1);
- if (mono_compile_aot) {
- cfg->ldstr_list = g_list_prepend (cfg->ldstr_list, (gpointer)n);
- }
-
- if ((cfg->opt & MONO_OPT_SHARED) || mono_compile_aot) {
+ if (method->wrapper_type != MONO_WRAPPER_NONE) {
int temp;
- MonoInst *iargs [3];
- NEW_TEMPLOAD (cfg, iargs [0], mono_get_domainvar (cfg)->inst_c0);
- NEW_IMAGECONST (cfg, iargs [1], image);
- NEW_ICONST (cfg, iargs [2], mono_metadata_token_index (n));
- temp = mono_emit_jit_icall (cfg, bblock, mono_ldstr, iargs, ip);
+ MonoInst *iargs [1];
+
+ NEW_PCONST (cfg, iargs [0], mono_method_get_wrapper_data (method, n));
+ temp = mono_emit_jit_icall (cfg, bblock, mono_string_new_wrapper, iargs, ip);
NEW_TEMPLOAD (cfg, *sp, temp);
- mono_ldstr (cfg->domain, image, mono_metadata_token_index (n));
+
} else {
- NEW_PCONST (cfg, ins, NULL);
- ins->cil_code = ip;
- ins->type = STACK_OBJ;
- ins->inst_p0 = mono_ldstr (cfg->domain, image, mono_metadata_token_index (n));
- *sp = ins;
+
+ if (mono_compile_aot) {
+ cfg->ldstr_list = g_list_prepend (cfg->ldstr_list, (gpointer)n);
+ }
+
+ if ((cfg->opt & MONO_OPT_SHARED) || mono_compile_aot) {
+ int temp;
+ MonoInst *iargs [3];
+ NEW_TEMPLOAD (cfg, iargs [0], mono_get_domainvar (cfg)->inst_c0);
+ NEW_IMAGECONST (cfg, iargs [1], image);
+ NEW_ICONST (cfg, iargs [2], mono_metadata_token_index (n));
+ temp = mono_emit_jit_icall (cfg, bblock, mono_ldstr, iargs, ip);
+ NEW_TEMPLOAD (cfg, *sp, temp);
+ mono_ldstr (cfg->domain, image, mono_metadata_token_index (n));
+ } else {
+ NEW_PCONST (cfg, ins, NULL);
+ ins->cil_code = ip;
+ ins->type = STACK_OBJ;
+ ins->inst_p0 = mono_ldstr (cfg->domain, image, mono_metadata_token_index (n));
+ *sp = ins;
+ }
}
+
sp++;
ip += 5;
break;
case CEE_NEWOBJ: {
MonoInst *iargs [2];
+ MonoMethodSignature *fsig;
int temp;
token = read32 (ip + 1);
cmethod = mono_method_get_wrapper_data (method, token);
} else
cmethod = mono_get_method (image, token, NULL);
+ fsig = mono_method_get_signature (cmethod, image, token);
mono_class_init (cmethod->klass);
- n = cmethod->signature->param_count;
+ n = fsig->param_count;
CHECK_STACK (n);
/* move the args to allow room for 'this' in the first position */
if (cmethod->klass->parent == mono_defaults.array_class) {
NEW_METHODCONST (cfg, *sp, cmethod);
- temp = mono_emit_native_call (cfg, bblock, mono_array_new_va, cmethod->signature, sp, ip, FALSE);
+ temp = mono_emit_native_call (cfg, bblock, mono_array_new_va, fsig, sp, ip, FALSE);
} else if (cmethod->string_ctor) {
/* we simply pass a null pointer */
NEW_PCONST (cfg, *sp, NULL);
/* now call the string ctor */
- temp = mono_emit_method_call_spilled (cfg, bblock, cmethod, sp, ip, NULL);
+ temp = mono_emit_method_call_spilled (cfg, bblock, cmethod, fsig, sp, ip, NULL);
} else {
if (cmethod->klass->valuetype) {
iargs [0] = mono_compile_create_var (cfg, &cmethod->klass->byval_arg, OP_LOCAL);
} else {
MonoVTable *vtable = mono_class_vtable (cfg->domain, cmethod->klass);
NEW_PCONST (cfg, iargs [0], vtable);
- temp = mono_emit_jit_icall (cfg, bblock, mono_object_new_specific, iargs, ip);
+ if (cmethod->klass->has_finalize || cmethod->klass->marshalbyref || (cfg->prof_options & MONO_PROFILE_ALLOCATIONS))
+ temp = mono_emit_jit_icall (cfg, bblock, mono_object_new_specific, iargs, ip);
+ else
+ temp = mono_emit_jit_icall (cfg, bblock, mono_object_new_fast, iargs, ip);
}
NEW_TEMPLOAD (cfg, *sp, temp);
}
!g_list_find (dont_inline, cmethod)) {
int costs;
MonoBasicBlock *ebblock;
- if ((costs = inline_method (cfg, cmethod, cmethod->signature, bblock, sp, ip, real_offset, dont_inline, &ebblock))) {
+ if ((costs = inline_method (cfg, cmethod, fsig, bblock, sp, ip, real_offset, dont_inline, &ebblock))) {
ip += 5;
real_offset += 5;
break;
} else {
- mono_emit_method_call_spilled (cfg, bblock, cmethod, sp, ip, sp[0]);
+ mono_emit_method_call_spilled (cfg, bblock, cmethod, fsig, sp, ip, sp[0]);
}
} else {
/* now call the actual ctor */
- mono_emit_method_call_spilled (cfg, bblock, cmethod, sp, ip, sp[0]);
+ mono_emit_method_call_spilled (cfg, bblock, cmethod, fsig, sp, ip, sp[0]);
}
}
ip += 5;
*sp++ = ins;
break;
+ case CEE_UNBOX_ANY: {
+ MonoInst *add, *vtoffset;
+ MonoInst *iargs [3];
+
+ CHECK_STACK (1);
+ --sp;
+ token = read32 (ip + 1);
+ if (method->wrapper_type != MONO_WRAPPER_NONE)
+ klass = (MonoClass *)mono_method_get_wrapper_data (method, token);
+ else
+ klass = mono_class_get (image, token);
+ mono_class_init (klass);
+
+ if (klass->byval_arg.type == MONO_TYPE_VAR)
+ klass = TYPE_PARAM_TO_CLASS (klass->byval_arg.data.type_param);
+
+ if (MONO_TYPE_IS_REFERENCE (&klass->byval_arg)) {
+ /* CASTCLASS */
+ MONO_INST_NEW (cfg, ins, CEE_CASTCLASS);
+ ins->type = STACK_OBJ;
+ ins->inst_left = *sp;
+ ins->klass = klass;
+ ins->inst_newa_class = klass;
+ ins->cil_code = ip;
+ *sp++ = ins;
+ ip += 5;
+ break;
+ }
+
+ MONO_INST_NEW (cfg, ins, OP_UNBOXCAST);
+ ins->type = STACK_OBJ;
+ ins->inst_left = *sp;
+ ins->klass = klass;
+ ins->inst_newa_class = klass;
+ ins->cil_code = ip;
+
+ MONO_INST_NEW (cfg, add, CEE_ADD);
+ NEW_ICONST (cfg, vtoffset, sizeof (MonoObject));
+ add->inst_left = ins;
+ add->inst_right = vtoffset;
+ add->type = STACK_MP;
+ *sp = add;
+ ip += 5;
+ /* LDOBJ impl */
+ n = mono_class_value_size (klass, NULL);
+ ins = mono_compile_create_var (cfg, &klass->byval_arg, OP_LOCAL);
+ NEW_TEMPLOADA (cfg, iargs [0], ins->inst_c0);
+ if ((cfg->opt & MONO_OPT_INTRINS) && n <= sizeof (gpointer) * 5) {
+ MonoInst *copy;
+ MONO_INST_NEW (cfg, copy, OP_MEMCPY);
+ copy->inst_left = iargs [0];
+ copy->inst_right = *sp;
+ copy->cil_code = ip;
+ copy->unused = n;
+ MONO_ADD_INS (bblock, copy);
+ } else {
+ iargs [1] = *sp;
+ NEW_ICONST (cfg, iargs [2], n);
+ iargs [2]->cil_code = ip;
+
+ mono_emit_jit_icall (cfg, bblock, helper_memcpy, iargs, ip);
+ }
+ NEW_TEMPLOAD (cfg, *sp, ins->inst_c0);
+ ++sp;
+ inline_costs += 2;
+ break;
+ }
case CEE_UNBOX: {
MonoInst *add, *vtoffset;
klass = mono_class_get (image, token);
mono_class_init (klass);
+ if (klass->byval_arg.type == MONO_TYPE_VAR)
+ klass = TYPE_PARAM_TO_CLASS (klass->byval_arg.data.type_param);
MONO_INST_NEW (cfg, ins, OP_UNBOXCAST);
ins->type = STACK_OBJ;
--sp;
klass = mono_class_get (image, read32 (ip + 1));
mono_class_init (klass);
+ if (klass->byval_arg.type == MONO_TYPE_VAR)
+ klass = TYPE_PARAM_TO_CLASS (klass->byval_arg.data.type_param);
ins->type = STACK_OBJ;
ins->inst_left = *sp;
ins->klass = klass;
// goto unverified;
token = read32 (ip + 1);
field = mono_field_from_token (image, token, &klass);
+ if (field->parent->gen_params)
+ field = get_generic_field_inst (field, method->klass, &klass);
mono_class_init (klass);
foffset = klass->valuetype? field->offset - sizeof (MonoObject): field->offset;
inline_costs += costs;
break;
} else {
- mono_emit_method_call_spilled (cfg, bblock, stfld_wrapper, iargs, ip, NULL);
+ mono_emit_method_call_spilled (cfg, bblock, stfld_wrapper, stfld_wrapper->signature, iargs, ip, NULL);
}
} else {
MonoInst *store;
inline_costs += costs;
break;
} else {
- temp = mono_emit_method_call_spilled (cfg, bblock, ldfld_wrapper, iargs, ip, NULL);
+ temp = mono_emit_method_call_spilled (cfg, bblock, ldfld_wrapper, ldfld_wrapper->signature, iargs, ip, NULL);
if (*ip == CEE_LDFLDA) {
/* not sure howto handle this */
NEW_TEMPLOADA (cfg, *sp, temp);
NEW_TEMPLOAD (cfg, ins, temp);
} else {
gpointer addr;
+ MonoVTable *vtable;
+ vtable = mono_class_vtable (cfg->domain, klass);
if (!cfg->domain->thread_static_fields || !(addr = g_hash_table_lookup (cfg->domain->thread_static_fields, field))) {
- MonoVTable *vtable;
- vtable = mono_class_vtable (cfg->domain, klass);
if (!vtable->initialized && !(klass->flags & TYPE_ATTRIBUTE_BEFORE_FIELD_INIT) && needs_cctor_run (klass, method)) {
MonoInst *iargs [1];
NEW_PCONST (cfg, iargs [0], vtable);
} else
MONO_ADD_INS (bblock, store);
} else {
- MonoInst *load;
- CHECK_STACK_OVF (1);
- MONO_INST_NEW (cfg, load, mono_type_to_ldind (field->type));
- type_to_eval_stack_type (field->type, load);
- load->cil_code = ip;
- load->inst_left = ins;
- *sp++ = load;
- load->flags |= ins_flag;
- ins_flag = 0;
- /* fixme: dont see the problem why this does not work */
- //cfg->disable_aot = TRUE;
+ gboolean is_const = FALSE;
+ MonoVTable *vtable = mono_class_vtable (cfg->domain, klass);
+ if (!((cfg->opt & MONO_OPT_SHARED) || mono_compile_aot) &&
+ vtable->initialized && (field->type->attrs & FIELD_ATTRIBUTE_INIT_ONLY)) {
+ gpointer addr = (char*)vtable->data + field->offset;
+ /* g_print ("RO-FIELD %s.%s:%s\n", klass->name_space, klass->name, field->name);*/
+ is_const = TRUE;
+ switch (field->type->type) {
+ case MONO_TYPE_BOOLEAN:
+ case MONO_TYPE_U1:
+ NEW_ICONST (cfg, *sp, *((guint8 *)addr));
+ sp++;
+ break;
+ case MONO_TYPE_I1:
+ NEW_ICONST (cfg, *sp, *((gint8 *)addr));
+ sp++;
+ break;
+ case MONO_TYPE_CHAR:
+ case MONO_TYPE_U2:
+ NEW_ICONST (cfg, *sp, *((guint16 *)addr));
+ sp++;
+ break;
+ case MONO_TYPE_I2:
+ NEW_ICONST (cfg, *sp, *((gint16 *)addr));
+ sp++;
+ break;
+ break;
+ case MONO_TYPE_I4:
+ NEW_ICONST (cfg, *sp, *((gint32 *)addr));
+ sp++;
+ break;
+ case MONO_TYPE_U4:
+ NEW_ICONST (cfg, *sp, *((guint32 *)addr));
+ sp++;
+ break;
+ case MONO_TYPE_I:
+ case MONO_TYPE_U:
+ case MONO_TYPE_STRING:
+ case MONO_TYPE_OBJECT:
+ case MONO_TYPE_CLASS:
+ case MONO_TYPE_SZARRAY:
+ case MONO_TYPE_PTR:
+ case MONO_TYPE_FNPTR:
+ case MONO_TYPE_ARRAY:
+ NEW_PCONST (cfg, *sp, *((gpointer *)addr));
+ type_to_eval_stack_type (field->type, *sp);
+ sp++;
+ break;
+ case MONO_TYPE_I8:
+ case MONO_TYPE_U8:
+ MONO_INST_NEW (cfg, *sp, OP_I8CONST);
+ sp [0]->type = STACK_I8;
+ sp [0]->inst_l = *((gint64 *)addr);
+ sp++;
+ break;
+ case MONO_TYPE_R4:
+ case MONO_TYPE_R8:
+ case MONO_TYPE_VALUETYPE:
+ default:
+ is_const = FALSE;
+ break;
+ }
+ }
+
+ if (!is_const) {
+ MonoInst *load;
+ CHECK_STACK_OVF (1);
+ MONO_INST_NEW (cfg, load, mono_type_to_ldind (field->type));
+ type_to_eval_stack_type (field->type, load);
+ load->cil_code = ip;
+ load->inst_left = ins;
+ *sp++ = load;
+ load->flags |= ins_flag;
+ ins_flag = 0;
+ /* fixme: dont see the problem why this does not work */
+ //cfg->disable_aot = TRUE;
+ }
}
ip += 5;
break;
else
klass = mono_class_get (image, token);
mono_class_init (klass);
- handle_stobj (cfg, bblock, sp [0], sp [1], ip, klass, FALSE, FALSE);
+ if (klass->byval_arg.type == MONO_TYPE_VAR)
+ klass = TYPE_PARAM_TO_CLASS (klass->byval_arg.data.type_param);
+ n = mono_type_to_stind (&klass->byval_arg);
+ if (n == CEE_STOBJ) {
+ handle_stobj (cfg, bblock, sp [0], sp [1], ip, klass, FALSE, FALSE);
+ } else {
+ /* FIXME: should check item at sp [1] is compatible with the type of the store. */
+ MonoInst *store;
+ MONO_INST_NEW (cfg, store, n);
+ store->cil_code = ip;
+ store->inst_left = sp [0];
+ store->inst_right = sp [1];
+ store->flags |= ins_flag;
+ MONO_ADD_INS (bblock, store);
+ }
+ ins_flag = 0;
ip += 5;
inline_costs += 1;
break;
else
klass = mono_class_get (image, token);
mono_class_init (klass);
+ if (klass->byval_arg.type == MONO_TYPE_VAR)
+ klass = TYPE_PARAM_TO_CLASS (klass->byval_arg.data.type_param);
+ if (MONO_TYPE_IS_REFERENCE (&klass->byval_arg)) {
+ *sp = val;
+ ip += 5;
+ break;
+ }
/* much like NEWOBJ */
- NEW_DOMAINCONST (cfg, iargs [0]);
- NEW_CLASSCONST (cfg, iargs [1], klass);
-
- temp = mono_emit_jit_icall (cfg, bblock, mono_object_new, iargs, ip);
+ if ((cfg->opt & MONO_OPT_SHARED) || mono_compile_aot) {
+ NEW_DOMAINCONST (cfg, iargs [0]);
+ NEW_CLASSCONST (cfg, iargs [1], klass);
+
+ temp = mono_emit_jit_icall (cfg, bblock, mono_object_new, iargs, ip);
+ } else {
+ MonoVTable *vtable = mono_class_vtable (cfg->domain, klass);
+ NEW_PCONST (cfg, iargs [0], vtable);
+ if (1 || klass->has_finalize || (cfg->prof_options & MONO_PROFILE_ALLOCATIONS))
+ temp = mono_emit_jit_icall (cfg, bblock, mono_object_new_specific, iargs, ip);
+ else
+ temp = mono_emit_jit_icall (cfg, bblock, mono_object_new_fast, iargs, ip);
+ }
NEW_TEMPLOAD (cfg, load, temp);
NEW_ICONST (cfg, vtoffset, sizeof (MonoObject));
MONO_INST_NEW (cfg, add, CEE_ADD);
klass = mono_class_get (image, token);
mono_class_init (klass);
+ if (klass->byval_arg.type == MONO_TYPE_VAR)
+ klass = TYPE_PARAM_TO_CLASS (klass->byval_arg.data.type_param);
ins->inst_newa_class = klass;
ins->inst_newa_len = *sp;
ins->type = STACK_OBJ;
sp -= 2;
klass = mono_class_get (image, read32 (ip + 1));
mono_class_init (klass);
+ if (klass->byval_arg.type == MONO_TYPE_VAR)
+ klass = TYPE_PARAM_TO_CLASS (klass->byval_arg.data.type_param);
NEW_LDELEMA (cfg, ins, sp, klass);
ins->cil_code = ip;
*sp++ = ins;
ip += 5;
break;
+ case CEE_LDELEM: {
+ MonoInst *load;
+ CHECK_STACK (2);
+ sp -= 2;
+ token = read32 (ip + 1);
+ klass = mono_class_get (image, token);
+ mono_class_init (klass);
+ if (klass->byval_arg.type == MONO_TYPE_VAR)
+ klass = TYPE_PARAM_TO_CLASS (klass->byval_arg.data.type_param);
+ NEW_LDELEMA (cfg, load, sp, klass);
+ load->cil_code = ip;
+ MONO_INST_NEW (cfg, ins, mono_type_to_ldind (&klass->byval_arg));
+ ins->cil_code = ip;
+ ins->inst_left = load;
+ *sp++ = ins;
+ type_to_eval_stack_type (&klass->byval_arg, ins);
+ ip += 5;
+ break;
+ }
case CEE_LDELEM_I1:
case CEE_LDELEM_U1:
case CEE_LDELEM_I2:
++ip;
handle_loaded_temps (cfg, bblock, stack_start, sp);
MONO_ADD_INS (bblock, ins);
- /* FIXME: add the implicit STELEM_REF castclass */
+ inline_costs += 1;
+ cfg->disable_ssa = TRUE;
+ break;
+ }
+ case CEE_STELEM: {
+ MonoInst *load;
+ /*
+ * translate to:
+ * stind.x (ldelema (array, index), val)
+ * ldelema does the bounds check
+ */
+ CHECK_STACK (3);
+ sp -= 3;
+ token = read32 (ip + 1);
+ klass = mono_class_get (image, token);
+ mono_class_init (klass);
+ if (klass->byval_arg.type == MONO_TYPE_VAR)
+ klass = TYPE_PARAM_TO_CLASS (klass->byval_arg.data.type_param);
+ if (MONO_TYPE_IS_REFERENCE (&klass->byval_arg)) {
+ MonoInst *iargs [3];
+ handle_loaded_temps (cfg, bblock, stack_start, sp);
+
+ iargs [2] = sp [2];
+ iargs [1] = sp [1];
+ iargs [0] = sp [0];
+
+ mono_emit_jit_icall (cfg, bblock, helper_stelem_ref, iargs, ip);
+ } else {
+ NEW_LDELEMA (cfg, load, sp, klass);
+ load->cil_code = ip;
+ MONO_INST_NEW (cfg, ins, mono_type_to_stind (&klass->byval_arg));
+ ins->cil_code = ip;
+ ins->inst_left = load;
+ ins->inst_right = sp [2];
+ handle_loaded_temps (cfg, bblock, stack_start, sp);
+ MONO_ADD_INS (bblock, ins);
+ }
+ ip += 5;
inline_costs += 1;
cfg->disable_ssa = TRUE;
break;
}
case CEE_PREFIX1: {
switch (ip [1]) {
- case CEE_ARGLIST:
- g_error ("opcode 0xfe 0x%02x not handled", ip [1]);
+ case CEE_ARGLIST: {
+ /* somewhat similar to LDTOKEN */
+ MonoInst *addr, *vtvar;
+ CHECK_STACK_OVF (1);
+ vtvar = mono_compile_create_var (cfg, &mono_defaults.argumenthandle_class->byval_arg, OP_LOCAL);
+
+ NEW_TEMPLOADA (cfg, addr, vtvar->inst_c0);
+ addr->cil_code = ip;
+ MONO_INST_NEW (cfg, ins, OP_ARGLIST);
+ ins->cil_code = ip;
+ ins->inst_left = addr;
+ MONO_ADD_INS (bblock, ins);
+ NEW_TEMPLOAD (cfg, ins, vtvar->inst_c0);
+ ins->cil_code = ip;
+ *sp++ = ins;
+ ip += 2;
break;
+ }
case CEE_CEQ:
case CEE_CGT:
case CEE_CGT_UN:
klass = mono_method_get_wrapper_data (method, token);
else
klass = mono_class_get (image, token);
- handle_initobj (cfg, bblock, *sp, NULL, klass, stack_start, sp);
+ if (klass->byval_arg.type == MONO_TYPE_VAR)
+ klass = TYPE_PARAM_TO_CLASS (klass->byval_arg.data.type_param);
+ if (MONO_TYPE_IS_REFERENCE (&klass->byval_arg)) {
+ MonoInst *store, *load;
+ NEW_PCONST (cfg, load, NULL);
+ load->cil_code = ip;
+ load->type = STACK_OBJ;
+ MONO_INST_NEW (cfg, store, CEE_STIND_REF);
+ store->cil_code = ip;
+ handle_loaded_temps (cfg, bblock, stack_start, sp);
+ MONO_ADD_INS (bblock, store);
+ store->inst_i0 = sp [0];
+ store->inst_i1 = load;
+ break;
+ } else {
+ handle_initobj (cfg, bblock, *sp, NULL, klass, stack_start, sp);
+ }
ip += 6;
inline_costs += 1;
break;
+ case CEE_CONSTRAINED_:
+ /* FIXME: implement */
+ token = read32 (ip + 2);
+ ip += 6;
+ break;
case CEE_CPBLK:
case CEE_INITBLK: {
MonoInst *iargs [3];
inline_costs += 1;
break;
}
+ case CEE_NO_:
+ if (ip [2] & 0x1)
+ ins_flag |= MONO_INST_NOTYPECHECK;
+ if (ip [2] & 0x2)
+ ins_flag |= MONO_INST_NORANGECHECK;
+ /* we ignore the no-nullcheck for now since we
+ * really do it explicitly only when doing callvirt->call
+ */
+ ip += 3;
+ break;
case CEE_RETHROW: {
MonoInst *load;
/* FIXME: check we are in a catch handler */
case CEE_SIZEOF:
CHECK_STACK_OVF (1);
token = read32 (ip + 2);
+ /* FIXXME: handle generics. */
if (mono_metadata_token_table (token) == MONO_TABLE_TYPESPEC) {
MonoType *type = mono_type_create_from_typespec (image, token);
token = mono_type_size (type, &align);
case CEE_REFANYTYPE:
g_error ("opcode 0xfe 0x%02x not handled", ip [1]);
break;
+ case CEE_READONLY_:
+ ip += 2;
+ break;
default:
g_error ("opcode 0xfe 0x%02x not handled", ip [1]);
}
}
void
-mono_register_opcode_emulation (int opcode, const char *name, MonoMethodSignature *sig, gpointer func)
+mono_register_opcode_emulation (int opcode, const char *name, MonoMethodSignature *sig, gpointer func, gboolean no_throw)
{
MonoJitICallInfo *info;
g_assert (!sig->hasthis);
g_assert (sig->param_count < 3);
- info = mono_register_jit_icall (func, name, sig, FALSE);
+ info = mono_register_jit_icall (func, name, sig, no_throw);
g_hash_table_insert (emul_opcode_hash, (gpointer)opcode, info);
}
info = newarr_info;
}
else {
- MonoVTable *vtable = mono_class_vtable (cfg->domain,
- mono_array_class_get (&tree->inst_newa_class->byval_arg, 1));
+ MonoVTable *vtable = mono_class_vtable (cfg->domain, mono_array_class_get (tree->inst_newa_class, 1));
NEW_PCONST (cfg, iargs [0], vtable);
iargs [1] = tree->inst_newa_len;
{
MonoJitTlsData *jit_tls = TlsGetValue (mono_jit_tls_id);
- g_free (jit_tls);
+ /* handle_remove should be eventually called for this thread, too
+ g_free (jit_tls);*/
ExitThread (-1);
}
static void
-mono_thread_start_cb (guint32 tid, gpointer stack_start, gpointer func)
+setup_jit_tls_data (gpointer stack_start, gpointer abort_func)
{
MonoJitTlsData *jit_tls;
MonoLMF *lmf;
+ MonoThread *thread;
jit_tls = g_new0 (MonoJitTlsData, 1);
TlsSetValue (mono_jit_tls_id, jit_tls);
- jit_tls->abort_func = mono_thread_abort;
+ jit_tls->abort_func = abort_func;
jit_tls->end_of_stack = stack_start;
lmf = g_new0 (MonoLMF, 1);
lmf->ebp = -1;
- jit_tls->lmf = lmf;
+ jit_tls->lmf = jit_tls->first_lmf = lmf;
+
+ thread = mono_thread_current ();
+ if (thread)
+ thread->jit_data = jit_tls;
+}
+
+static void
+mono_thread_start_cb (guint32 tid, gpointer stack_start, gpointer func)
+{
+ setup_jit_tls_data (stack_start, mono_thread_abort);
}
void (*mono_thread_attach_aborted_cb ) (MonoObject *obj) = NULL;
static void
mono_thread_attach_cb (guint32 tid, gpointer stack_start)
{
- MonoJitTlsData *jit_tls;
- MonoLMF *lmf;
-
- jit_tls = g_new0 (MonoJitTlsData, 1);
-
- TlsSetValue (mono_jit_tls_id, jit_tls);
-
- jit_tls->abort_func = mono_thread_abort_dummy;
- jit_tls->end_of_stack = stack_start;
+ setup_jit_tls_data (stack_start, mono_thread_abort_dummy);
+}
- lmf = g_new0 (MonoLMF, 1);
- lmf->ebp = -1;
+static void
+mini_thread_cleanup (MonoThread *thread)
+{
+ MonoJitTlsData *jit_tls = thread->jit_data;
- jit_tls->lmf = lmf;
+ if (jit_tls) {
+ g_free (jit_tls->first_lmf);
+ g_free (jit_tls);
+ thread->jit_data = NULL;
+ }
}
void
}
break;
- case 2:
- if ((info = mono_find_jit_opcode_emulation (tree->opcode))) {
+ case 2:
+ if (tree->opcode == OP_LMUL
+ && (cfg->opt & MONO_OPT_INTRINS)
+ && (tree->inst_left->opcode == CEE_CONV_I8
+ || tree->inst_left->opcode == CEE_CONV_U8)
+ && tree->inst_left->inst_left->type == STACK_I4
+ && (tree->inst_right->opcode == CEE_CONV_I8
+ || tree->inst_right->opcode == CEE_CONV_U8)
+ && tree->inst_right->inst_left->type == STACK_I4) {
+ tree->opcode = (tree->inst_left->opcode == CEE_CONV_I8 ? OP_BIGMUL: OP_BIGMUL_UN);
+ tree->inst_left = tree->inst_left->inst_left;
+ tree->inst_right = tree->inst_right->inst_left;
+ dec_foreach (tree, cfg);
+ } else if ((info = mono_find_jit_opcode_emulation (tree->opcode))) {
MonoInst *iargs [2];
iargs [0] = tree->inst_i0;
bb->out_bb = NULL;
bb->next_bb = NULL;
bb->code = bb->last_ins = NULL;
+ bb->cil_code = NULL;
+}
+
+static void
+replace_out_block (MonoBasicBlock *bb, MonoBasicBlock *orig, MonoBasicBlock *repl)
+{
+ int i;
+
+ for (i = 0; i < bb->out_count; i++) {
+ MonoBasicBlock *ob = bb->out_bb [i];
+ if (ob == orig) {
+ if (!repl) {
+ if (bb->out_count > 1) {
+ bb->out_bb [i] = bb->out_bb [bb->out_count - 1];
+ }
+ bb->out_count--;
+ } else {
+ bb->out_bb [i] = repl;
+ }
+ }
+ }
+}
+
+static void
+replace_in_block (MonoBasicBlock *bb, MonoBasicBlock *orig, MonoBasicBlock *repl)
+{
+ int i;
+
+ for (i = 0; i < bb->in_count; i++) {
+ MonoBasicBlock *ib = bb->in_bb [i];
+ if (ib == orig) {
+ if (!repl) {
+ if (bb->in_count > 1) {
+ bb->in_bb [i] = bb->in_bb [bb->in_count - 1];
+ }
+ bb->in_count--;
+ } else {
+ bb->in_bb [i] = repl;
+ }
+ }
+ }
}
static void
for (i = 0; i < bb->out_count; i++) {
MonoBasicBlock *ob = bb->out_bb [i];
for (j = 0; j < ob->in_count; j++) {
- if (ob->in_bb [j] == orig)
+ if (ob->in_bb [j] == orig) {
ob->in_bb [j] = repl;
+ }
}
}
}
+
static void
merge_basic_blocks (MonoBasicBlock *bb, MonoBasicBlock *bbn)
{
static void
optimize_branches (MonoCompile *cfg) {
- int changed = FALSE;
+ int i, changed = FALSE;
MonoBasicBlock *bb, *bbn;
do {
if (bb->region != -1)
continue;
+ if ((bbn = bb->next_bb) && bbn->in_count == 0 && bb->region == bbn->region) {
+ if (cfg->verbose_level > 2)
+ g_print ("nullify block triggered %d\n", bbn->block_num);
+
+ bb->next_bb = bbn->next_bb;
+
+ for (i = 0; i < bbn->out_count; i++)
+ replace_in_block (bbn->out_bb [i], bbn, NULL);
+
+ nullify_basic_block (bbn);
+ changed = TRUE;
+ }
+
if (bb->out_count == 1) {
bbn = bb->out_bb [0];
+ /* conditional branches where true and false targets are the same can be also replaced with CEE_BR */
+ if (bb->last_ins && MONO_IS_COND_BRANCH (bb->last_ins->opcode)) {
+ bb->last_ins->opcode = CEE_BR;
+ bb->last_ins->inst_target_bb = bb->last_ins->inst_true_bb;
+ changed = TRUE;
+ if (cfg->verbose_level > 2)
+ g_print ("cond branch removal triggered in %d %d\n", bb->block_num, bb->out_count);
+ }
+
if (bb->region == bbn->region && bb->next_bb == bbn) {
- /* the block are in sequence anyway ... */
+ /* the block are in sequence anyway ... */
- /*
- * miguel: I do not understand what the test below does, could we
- * use a macro, or a comment here? opcode > CEE_BEQ && <= BLT_UN
- *
- * It could also test for bb->last_in only once, and the value
- * could be cached (last_ins->opcode)
- */
- if (bb->last_ins && (bb->last_ins->opcode == CEE_BR || (
- (bb->last_ins && bb->last_ins->opcode >= CEE_BEQ && bb->last_ins->opcode <= CEE_BLT_UN)))) {
+ /* branches to the following block can be removed */
+ if (bb->last_ins && bb->last_ins->opcode == CEE_BR) {
bb->last_ins->opcode = CEE_NOP;
changed = TRUE;
if (cfg->verbose_level > 2)
g_print ("br removal triggered %d -> %d\n", bb->block_num, bbn->block_num);
}
+
if (bbn->in_count == 1) {
if (bbn != cfg->bb_exit) {
//mono_print_bb_code (bb);
}
- } else {
- if (bb->last_ins && bb->last_ins->opcode == CEE_BR) {
- bbn = bb->last_ins->inst_target_bb;
- if (bb->region == bbn->region && bbn->code && bbn->code->opcode == CEE_BR &&
- bbn->code->inst_target_bb->region == bb->region) {
-
- if (cfg->verbose_level > 2)
- g_print ("in %s branch to branch triggered %d -> %d\n", cfg->method->name,
- bb->block_num, bbn->block_num);
+ }
+ }
+ }
+ } while (changed);
- replace_basic_block (bb, bb->out_bb [0], bbn->code->inst_target_bb);
- bb->last_ins->inst_target_bb = bbn->code->inst_target_bb;
- changed = TRUE;
- }
- }
+ do {
+ changed = FALSE;
+
+ /* we skip the entry block (exit is handled specially instead ) */
+ for (bb = cfg->bb_entry->next_bb; bb; bb = bb->next_bb) {
+
+ /* dont touch code inside exception clauses */
+ if (bb->region != -1)
+ continue;
+
+ if ((bbn = bb->next_bb) && bbn->in_count == 0 && bb->region == bbn->region) {
+ if (cfg->verbose_level > 2) {
+ g_print ("nullify block triggered %d\n", bbn->block_num);
}
+ bb->next_bb = bbn->next_bb;
- } else if (bb->out_count == 2) {
- /* fixme: this does not correctly - no idea whats wrong */
- if (0 && bb->last_ins && bb->last_ins->opcode >= CEE_BEQ && bb->last_ins->opcode <= CEE_BLT_UN) {
- bbn = bb->last_ins->inst_true_bb;
+ for (i = 0; i < bbn->out_count; i++)
+ replace_in_block (bbn->out_bb [i], bbn, NULL);
+
+ nullify_basic_block (bbn);
+ changed = TRUE;
+ break;
+ }
+
+
+ if (bb->out_count == 1) {
+ bbn = bb->out_bb [0];
+
+ if (bb->last_ins && bb->last_ins->opcode == CEE_BR) {
+ bbn = bb->last_ins->inst_target_bb;
if (bb->region == bbn->region && bbn->code && bbn->code->opcode == CEE_BR &&
bbn->code->inst_target_bb->region == bb->region) {
+
if (cfg->verbose_level > 2)
- g_print ("cbranch to branch triggered %d -> %d (0x%02x)\n", bb->block_num,
- bbn->block_num, bbn->code->opcode);
-
+ g_print ("in %s branch to branch triggered %d -> %d\n", cfg->method->name,
+ bb->block_num, bbn->block_num);
+
replace_basic_block (bb, bb->out_bb [0], bbn->code->inst_target_bb);
+ bb->last_ins->inst_target_bb = bbn->code->inst_target_bb;
+ changed = TRUE;
+ break;
+ }
+ }
+ } else if (bb->out_count == 2) {
+ if (bb->last_ins && MONO_IS_COND_BRANCH (bb->last_ins->opcode)) {
+ bbn = bb->last_ins->inst_true_bb;
+ if (bb->region == bbn->region && bbn->code && bbn->code->opcode == CEE_BR &&
+ bbn->code->inst_target_bb->region == bb->region) {
+ if (cfg->verbose_level > 2)
+ g_print ("cbranch1 to branch triggered %d -> (%d) %d (0x%02x)\n",
+ bb->block_num, bbn->block_num, bbn->code->inst_target_bb->block_num,
+ bbn->code->opcode);
+
bb->last_ins->inst_true_bb = bbn->code->inst_target_bb;
+
+ replace_in_block (bbn, bb, NULL);
+ if (!bbn->in_count)
+ replace_in_block (bbn->code->inst_target_bb, bbn, bb);
+ replace_out_block (bb, bbn, bbn->code->inst_target_bb);
+
+ link_bblock (cfg, bb, bbn->code->inst_target_bb);
+
changed = TRUE;
+ break;
}
bbn = bb->last_ins->inst_false_bb;
if (bb->region == bbn->region && bbn->code && bbn->code->opcode == CEE_BR &&
bbn->code->inst_target_bb->region == bb->region) {
if (cfg->verbose_level > 2)
- g_print ("cbranch to branch triggered %d -> %d (0x%02x)\n", bb->block_num,
- bbn->block_num, bbn->code->opcode);
-
- replace_basic_block (bb, bb->out_bb [0], bbn->code->inst_target_bb);
+ g_print ("cbranch2 to branch triggered %d -> (%d) %d (0x%02x)\n",
+ bb->block_num, bbn->block_num, bbn->code->inst_target_bb->block_num,
+ bbn->code->opcode);
+
bb->last_ins->inst_false_bb = bbn->code->inst_target_bb;
+
+ replace_in_block (bbn, bb, NULL);
+ if (!bbn->in_count)
+ replace_in_block (bbn->code->inst_target_bb, bbn, bb);
+ replace_out_block (bb, bbn, bbn->code->inst_target_bb);
+
+ link_bblock (cfg, bb, bbn->code->inst_target_bb);
+
changed = TRUE;
+ break;
}
}
}
}
} while (changed);
+
}
static void
cfg->ret->inst_vtype = sig->ret;
cfg->ret->klass = mono_class_from_mono_type (sig->ret);
}
+ if (cfg->verbose_level > 2)
+ g_print ("creating vars\n");
if (sig->hasthis)
mono_compile_create_var (cfg, &cfg->method->klass->this_arg, OP_ARG);
cfg->locals_start = cfg->num_varinfo;
+ if (cfg->verbose_level > 2)
+ g_print ("creating locals\n");
for (i = 0; i < header->num_locals; ++i)
mono_compile_create_var (cfg, header->locals [i], OP_LOCAL);
+ if (cfg->verbose_level > 2)
+ g_print ("locals done\n");
}
#if 0
static void
mini_select_instructions (MonoCompile *cfg)
{
+ static int reverse_map [] = {
+ CEE_BNE_UN, CEE_BLT, CEE_BLE, CEE_BGT, CEE_BGE,
+ CEE_BEQ, CEE_BLT_UN, CEE_BLE_UN, CEE_BGT_UN, CEE_BGE_UN
+ };
+ static int reverse_fmap [] = {
+ OP_FBNE_UN, OP_FBLT, OP_FBLE, OP_FBGT, OP_FBGE,
+ OP_FBEQ, OP_FBLT_UN, OP_FBLE_UN, OP_FBGT_UN, OP_FBGE_UN
+ };
+ static int reverse_lmap [] = {
+ OP_LBNE_UN, OP_LBLT, OP_LBLE, OP_LBGT, OP_LBGE,
+ OP_LBEQ, OP_LBLT_UN, OP_LBLE_UN, OP_LBGT_UN, OP_LBGE_UN
+ };
+
MonoBasicBlock *bb;
cfg->state_pool = mono_mempool_new ();
cfg->rs = mono_regstate_new ();
+ for (bb = cfg->bb_entry; bb; bb = bb->next_bb) {
+ if (bb->last_ins && MONO_IS_COND_BRANCH (bb->last_ins->opcode) &&
+ bb->next_bb != bb->last_ins->inst_false_bb) {
+
+ if (bb->next_bb == bb->last_ins->inst_true_bb) {
+ MonoBasicBlock *tmp = bb->last_ins->inst_true_bb;
+ bb->last_ins->inst_true_bb = bb->last_ins->inst_false_bb;
+ bb->last_ins->inst_false_bb = tmp;
+
+ if (bb->last_ins->opcode >= CEE_BEQ && bb->last_ins->opcode <= CEE_BLT_UN) {
+ bb->last_ins->opcode = reverse_map [bb->last_ins->opcode - CEE_BEQ];
+ } else if (bb->last_ins->opcode >= OP_FBEQ && bb->last_ins->opcode <= OP_FBLT_UN) {
+ bb->last_ins->opcode = reverse_fmap [bb->last_ins->opcode - OP_FBEQ];
+ } else if (bb->last_ins->opcode >= OP_LBEQ && bb->last_ins->opcode <= OP_LBLT_UN) {
+ bb->last_ins->opcode = reverse_lmap [bb->last_ins->opcode - OP_LBEQ];
+ }
+ } else {
+ MonoInst *inst = mono_mempool_alloc0 (cfg->mempool, sizeof (MonoInst));
+ inst->opcode = CEE_BR;
+ inst->inst_target_bb = bb->last_ins->inst_false_bb;
+ mono_bblock_add_inst (bb, inst);
+ }
+ }
+ }
+
#ifdef DEBUG_SELECTION
if (cfg->verbose_level >= 4) {
for (bb = cfg->bb_entry; bb; bb = bb->next_bb) {
mono_arch_local_regalloc (cfg, bb);
}
- if (mono_trace_coverage)
- mono_allocate_coverage_info (cfg->method, cfg->num_bblocks);
+ if (cfg->prof_options & MONO_PROFILE_COVERAGE)
+ cfg->coverage_info = mono_profiler_coverage_alloc (cfg->method, cfg->num_bblocks);
code = mono_arch_emit_prolog (cfg);
- if (mono_jit_profile)
+ if (cfg->prof_options & MONO_PROFILE_ENTER_LEAVE)
code = mono_arch_instrument_prolog (cfg, mono_profiler_method_enter, code, FALSE);
cfg->code_len = code - cfg->native_code;
cfg->epilog_begin = cfg->code_len;
- if (mono_jit_profile)
+ if (cfg->prof_options & MONO_PROFILE_ENTER_LEAVE)
code = mono_arch_instrument_epilog (cfg, mono_profiler_method_leave, code, FALSE);
cfg->code_len = code - cfg->native_code;
int dfn = 0, i, code_size_ratio;
mono_jit_stats.methods_compiled++;
- if (mono_jit_profile)
+ if (mono_profiler_get_events () & MONO_PROFILE_JIT_COMPILATION)
mono_profiler_method_jit (method);
cfg = g_new0 (MonoCompile, 1);
cfg->method = method;
cfg->mempool = mono_mempool_new ();
cfg->opt = opts;
+ cfg->prof_options = mono_profiler_get_events ();
cfg->bb_hash = g_hash_table_new (g_direct_hash, NULL);
cfg->domain = domain;
cfg->verbose_level = mini_verbose;
cfg->intvars = mono_mempool_alloc0 (cfg->mempool, sizeof (guint16) * STACK_MAX *
((MonoMethodNormal *)method)->header->max_stack);
+ if (cfg->verbose_level > 2)
+ g_print ("converting method %s\n", mono_method_full_name (method, TRUE));
+
/*
* create MonoInst* which represents arguments and local variables
*/
mono_compile_create_vars (cfg);
- if (cfg->verbose_level > 2)
- g_print ("converting method %s\n", mono_method_full_name (method, TRUE));
-
if ((i = mono_method_to_ir (cfg, method, NULL, NULL, cfg->locals_start, NULL, NULL, NULL, 0, FALSE)) < 0) {
- mono_destroy_compile (cfg);
- if (mono_jit_profile)
+ if (cfg->prof_options & MONO_PROFILE_JIT_COMPILATION)
mono_profiler_method_end_jit (method, MONO_PROFILE_FAILED);
+ mono_destroy_compile (cfg);
return NULL;
}
mono_jit_stats.basic_blocks += cfg->num_bblocks;
mono_jit_stats.max_basic_blocks = MAX (cfg->num_bblocks, mono_jit_stats.max_basic_blocks);
+ if (cfg->num_varinfo > 2000) {
+ /*
+ * we disable some optimizations if there are too many variables
+ * because JIT time may become too expensive. The actual number needs
+ * to be tweaked and eventually the non-linear algorithms should be fixed.
+ */
+ cfg->opt &= ~ (MONO_OPT_LINEARS | MONO_OPT_COPYPROP | MONO_OPT_CONSPROP);
+ cfg->disable_ssa = TRUE;
+ }
/*g_print ("numblocks = %d\n", cfg->num_bblocks);*/
/* Depth-first ordering on basic blocks */
df_visit (cfg->bb_entry, &dfn, cfg->bblocks);
if (cfg->num_bblocks != dfn + 1) {
- if (cfg->verbose_level > 1)
- g_print ("unreachable code?\n");
+ MonoBasicBlock *bb;
+
cfg->num_bblocks = dfn + 1;
+
+ if (!header->clauses) {
+ /* remove unreachable code, because the code in them may be
+ * inconsistent (access to dead variables for example) */
+ for (bb = cfg->bb_entry; bb;) {
+ MonoBasicBlock *bbn = bb->next_bb;
+
+ if (bbn && bbn->region == -1 && !bbn->dfn) {
+ if (cfg->verbose_level > 1)
+ g_print ("found unreachabel code in BB%d\n", bbn->block_num);
+ bb->next_bb = bbn->next_bb;
+ nullify_basic_block (bbn);
+ } else {
+ bb = bb->next_bb;
+ }
+ }
+ }
}
if (cfg->opt & MONO_OPT_LOOP) {
}
//mono_print_code (cfg);
-
- //print_dfn (cfg);
+ //print_dfn (cfg);
+
/* variables are allocated after decompose, since decompose could create temps */
mono_arch_allocate_vars (cfg);
}
mono_jit_stats.native_code_size += cfg->code_len;
- if (mono_jit_profile)
+ if (cfg->prof_options & MONO_PROFILE_JIT_COMPILATION)
mono_profiler_method_end_jit (method, MONO_PROFILE_OK);
return cfg;
mono_arch_handle_exception (ctx, thread->abort_exc, FALSE);
}
+static void
+sigquit_signal_handler (int _dummy)
+{
+ MonoException *exc;
+ GET_CONTEXT
+
+ exc = mono_get_exception_execution_engine ("Interrupted (SIGQUIT).");
+
+ mono_arch_handle_exception (ctx, exc, FALSE);
+}
+
+
static void
mono_runtime_install_handlers (void)
{
//g_assert (syscall (SYS_sigaction, SIGFPE, &sa, NULL) != -1);
g_assert (sigaction (SIGFPE, &sa, NULL) != -1);
+ /* catch SIGQUIT */
+ sa.sa_handler = sigquit_signal_handler;
+ sigemptyset (&sa.sa_mask);
+ sa.sa_flags = 0;
+ g_assert (sigaction (SIGQUIT, &sa, NULL) != -1);
+
/* catch SIGILL */
sa.sa_handler = sigill_signal_handler;
sigemptyset (&sa.sa_mask);
mini_init (const char *filename)
{
MonoDomain *domain;
-
+
+ mono_arch_cpu_init ();
+
metadata_section = &ms;
InitializeCriticalSection (metadata_section);
mono_burg_init ();
mono_runtime_install_handlers ();
+ mono_threads_install_cleanup (mini_thread_cleanup);
mono_install_compile_method (mono_jit_compile_method);
mono_install_trampoline (mono_arch_create_jit_trampoline);
* when adding emulation for some opcodes, remember to also add a dummy
* rule to the burg files, because we need the arity information to be correct.
*/
- mono_register_opcode_emulation (OP_LMUL, "__emul_lmul", helper_sig_long_long_long, mono_llmult);
- mono_register_opcode_emulation (OP_LMUL_OVF_UN, "__emul_lmul_ovf_un", helper_sig_long_long_long, mono_llmult_ovf_un);
- mono_register_opcode_emulation (OP_LMUL_OVF, "__emul_lmul_ovf", helper_sig_long_long_long, mono_llmult_ovf);
- mono_register_opcode_emulation (OP_LDIV, "__emul_ldiv", helper_sig_long_long_long, mono_lldiv);
- mono_register_opcode_emulation (OP_LDIV_UN, "__emul_ldiv_un", helper_sig_long_long_long, mono_lldiv_un);
- mono_register_opcode_emulation (OP_LREM, "__emul_lrem", helper_sig_long_long_long, mono_llrem);
- mono_register_opcode_emulation (OP_LREM_UN, "__emul_lrem_un", helper_sig_long_long_long, mono_llrem_un);
-
- mono_register_opcode_emulation (OP_LSHL, "__emul_lshl", helper_sig_long_long_int, mono_lshl);
- mono_register_opcode_emulation (OP_LSHR, "__emul_lshr", helper_sig_long_long_int, mono_lshr);
- mono_register_opcode_emulation (OP_LSHR_UN, "__emul_lshr_un", helper_sig_long_long_int, mono_lshr_un);
-
- mono_register_opcode_emulation (OP_FCONV_TO_U8, "__emul_fconv_to_u8", helper_sig_ulong_double, mono_fconv_u8);
- mono_register_opcode_emulation (OP_FCONV_TO_U4, "__emul_fconv_to_u4", helper_sig_uint_double, mono_fconv_u4);
- mono_register_opcode_emulation (OP_FCONV_TO_OVF_I8, "__emul_fconv_to_ovf_i8", helper_sig_long_double, mono_fconv_ovf_i8);
- mono_register_opcode_emulation (OP_FCONV_TO_OVF_U8, "__emul_fconv_to_ovf_u8", helper_sig_ulong_double, mono_fconv_ovf_u8);
+ mono_register_opcode_emulation (OP_LMUL, "__emul_lmul", helper_sig_long_long_long, mono_llmult, TRUE);
+ mono_register_opcode_emulation (OP_LMUL_OVF_UN, "__emul_lmul_ovf_un", helper_sig_long_long_long, mono_llmult_ovf_un, FALSE);
+ mono_register_opcode_emulation (OP_LMUL_OVF, "__emul_lmul_ovf", helper_sig_long_long_long, mono_llmult_ovf, FALSE);
+ mono_register_opcode_emulation (OP_LDIV, "__emul_ldiv", helper_sig_long_long_long, mono_lldiv, FALSE);
+ mono_register_opcode_emulation (OP_LDIV_UN, "__emul_ldiv_un", helper_sig_long_long_long, mono_lldiv_un, FALSE);
+ mono_register_opcode_emulation (OP_LREM, "__emul_lrem", helper_sig_long_long_long, mono_llrem, FALSE);
+ mono_register_opcode_emulation (OP_LREM_UN, "__emul_lrem_un", helper_sig_long_long_long, mono_llrem_un, FALSE);
+
+ mono_register_opcode_emulation (OP_LSHL, "__emul_lshl", helper_sig_long_long_int, mono_lshl, TRUE);
+ mono_register_opcode_emulation (OP_LSHR, "__emul_lshr", helper_sig_long_long_int, mono_lshr, TRUE);
+ mono_register_opcode_emulation (OP_LSHR_UN, "__emul_lshr_un", helper_sig_long_long_int, mono_lshr_un, TRUE);
+
+ mono_register_opcode_emulation (OP_FCONV_TO_U8, "__emul_fconv_to_u8", helper_sig_ulong_double, mono_fconv_u8, FALSE);
+ mono_register_opcode_emulation (OP_FCONV_TO_U4, "__emul_fconv_to_u4", helper_sig_uint_double, mono_fconv_u4, FALSE);
+ mono_register_opcode_emulation (OP_FCONV_TO_OVF_I8, "__emul_fconv_to_ovf_i8", helper_sig_long_double, mono_fconv_ovf_i8, TRUE);
+ mono_register_opcode_emulation (OP_FCONV_TO_OVF_U8, "__emul_fconv_to_ovf_u8", helper_sig_ulong_double, mono_fconv_ovf_u8, TRUE);
#if SIZEOF_VOID_P == 4
- mono_register_opcode_emulation (OP_FCONV_TO_U, "__emul_fconv_to_u", helper_sig_uint_double, mono_fconv_u4);
+ mono_register_opcode_emulation (OP_FCONV_TO_U, "__emul_fconv_to_u", helper_sig_uint_double, mono_fconv_u4, TRUE);
#else
#warning "fixme: add opcode emulation"
#endif
mono_register_jit_icall (helper_stelem_ref, "helper_stelem_ref", helper_sig_stelem_ref, FALSE);
mono_register_jit_icall (mono_object_new, "mono_object_new", helper_sig_object_new, FALSE);
mono_register_jit_icall (mono_object_new_specific, "mono_object_new_specific", helper_sig_object_new_specific, FALSE);
+ mono_register_jit_icall (mono_object_new_fast, "mono_object_new_fast", helper_sig_object_new_specific, FALSE);
mono_register_jit_icall (mono_array_new, "mono_array_new", helper_sig_newarr, FALSE);
mono_register_jit_icall (mono_array_new_specific, "mono_array_new_specific", helper_sig_newarr_specific, FALSE);
mono_register_jit_icall (mono_string_to_utf16, "mono_string_to_utf16", helper_sig_ptr_obj, FALSE);
mono_register_jit_icall (mono_ldftn, "mono_ldftn", helper_sig_compile, FALSE);
mono_register_jit_icall (mono_ldvirtfn, "mono_ldvirtfn", helper_sig_compile_virt, FALSE);
- mono_runtime_init (domain, mono_thread_start_cb,
- mono_thread_attach_cb);
+ mono_runtime_install_cleanup ((MonoDomainFunc)mini_cleanup);
+ mono_runtime_init (domain, mono_thread_start_cb, mono_thread_attach_cb);
//mono_thread_attach (domain);
return domain;
mono_profiler_shutdown ();
mono_debug_cleanup ();
+
#ifdef PLATFORM_WIN32
win32_seh_cleanup();
#endif