* mini.h, *.c: prepare for MonoMethodHeader to become a transient entity.
svn path=/trunk/mono/; revision=153270
+Mon Mar 8 17:58:26 CET 2010 Paolo Molaro <lupus@ximian.com>
+
+ * mini.h, *.c: prepare for MonoMethodHeader to become a transient entity.
+
Mon Mar 8 17:35:26 CET 2010 Paolo Molaro <lupus@ximian.com>
* driver.c: report also other misc build options.
MonoInst *
mono_branch_optimize_exception_target (MonoCompile *cfg, MonoBasicBlock *bb, const char * exname)
{
- MonoMethod *method = cfg->method;
- MonoMethodHeader *header = mono_method_get_header (method);
+ MonoMethodHeader *header = cfg->header;
MonoExceptionClause *clause;
MonoClass *exclass;
int i;
mono_class_init (cfg->method->klass);
- header = mono_method_get_header (cfg->method);
+ header = cfg->header;
g_assert (header);
info->jit = jit = g_new0 (MonoDebugMethodJitInfo, 1);
g_free (addresses);
g_free (lines);
+ mono_metadata_free_mh (header);
#endif /* VALGRIND_ADD_LINE_INFO */
}
}
method = cfg->method;
- header = mono_method_get_header (method);
+ header = cfg->header;
sig = mono_method_signature (method);
jit = info->jit;
if (!info || !info->jit || !ins->cil_code)
return;
- header = mono_method_get_header (cfg->method);
+ header = cfg->header;
g_assert (header);
if ((ins->cil_code < header->code) ||
if (!info || !info->jit || !bb->cil_code)
return;
- header = mono_method_get_header (cfg->method);
+ header = cfg->header;
g_assert (header);
if ((bb->cil_code < header->code) ||
prev_native_offset = native_offset;
}
+ mono_metadata_free_mh (header);
return jit;
}
buffer_add_int (buf, header->code_size);
buffer_add_string (buf, "");
buffer_add_int (buf, 0);
+ mono_metadata_free_mh (header);
break;
}
g_free (source_file);
g_free (il_offsets);
g_free (line_numbers);
+ mono_metadata_free_mh (header);
break;
}
case CMD_METHOD_GET_PARAM_INFO: {
buffer_add_int (buf, 0);
buffer_add_int (buf, header->code_size);
}
+ mono_metadata_free_mh (header);
break;
}
for (i = 0; i < header->code_size; ++i)
buffer_add_byte (buf, header->code [i]);
}
+ mono_metadata_free_mh (header);
break;
}
case CMD_METHOD_RESOLVE_TOKEN: {
add_var (buf, header->locals [pos], &jit->locals [pos], &frame->ctx, frame->domain, FALSE);
}
}
+ mono_metadata_free_mh (header);
break;
}
case CMD_STACK_FRAME_GET_THIS: {
set_var (t, var, &frame->ctx, frame->domain, val_buf);
}
+ mono_metadata_free_mh (header);
break;
}
default:
#ifdef DEBUG_DOMINATORS
printf ("DTREE %s %d\n", mono_method_full_name (cfg->method, TRUE),
- mono_method_get_header (cfg->method)->num_clauses);
+ cfg->header->num_clauses);
for (i = 0; i < cfg->num_bblocks; ++i) {
MonoBasicBlock *bb = cfg->bblocks [i];
printf ("BB%d(dfn=%d) (IDOM=BB%d): ", bb->block_num, bb->dfn, bb->idom ? bb->idom->block_num : -1);
token_handler_ip = NULL;
*endip = ip;
+ mono_metadata_free_mh (header);
return dis;
}
GArray *ln_array;
int *native_to_il_offset = NULL;
- if (!w->emit_line)
+ if (!w->emit_line) {
+ mono_metadata_free_mh (header);
return;
+ }
minfo = mono_debug_lookup_method (method);
g_assert (code_size);
#ifdef _EGLIB_MAJOR
+ mono_metadata_free_mh (header);
/* g_array is not implemented in eglib */
return;
#else
fflush (w->il_file);
g_free (il_to_line);
}
+ mono_metadata_free_mh (header);
}
static MonoMethodVar*
emit_line_number_info (w, method, start_symbol, end_symbol, code, code_size, debug_info);
emit_line (w);
+ mono_metadata_free_mh (header);
}
void
static int
mono_find_block_region (MonoCompile *cfg, int offset)
{
- MonoMethod *method = cfg->method;
- MonoMethodHeader *header = mono_method_get_header (method);
+ MonoMethodHeader *header = cfg->header;
MonoExceptionClause *clause;
int i;
static GList*
mono_find_final_block (MonoCompile *cfg, unsigned char *ip, unsigned char *target, int type)
{
- MonoMethod *method = cfg->method;
- MonoMethodHeader *header = mono_method_get_header (method);
+ MonoMethodHeader *header = cfg->header;
MonoExceptionClause *clause;
MonoBasicBlock *handler;
int i;
int pos, vnum;
/* inlining can result in deeper stacks */
- if (slot >= mono_method_get_header (cfg->method)->max_stack)
+ if (slot >= cfg->header->max_stack)
return mono_compile_create_var (cfg, type_from_stack_type (ins), OP_LOCAL);
pos = ins->type - 1 + slot * STACK_MAX;
cheader = mono_method_get_header (cmethod);
if (cheader == NULL || mono_loader_get_last_error ()) {
+ if (cheader)
+ mono_metadata_free_mh (cheader);
mono_loader_clear_error ();
return 0;
}
EMIT_NEW_TEMPLOAD (cfg, ins, rvar->inst_c0);
*sp++ = ins;
}
+ mono_metadata_free_mh (cheader);
return costs + 1;
} else {
if (cfg->verbose_level > 2)
/* This gets rid of the newly added bblocks */
cfg->cbb = prev_cbb;
}
+ mono_metadata_free_mh (cheader);
return 0;
}
{
char *method_fname = mono_method_full_name (method, TRUE);
char *method_code;
+ MonoMethodHeader *header = mono_method_get_header (method);
- if (mono_method_get_header (method)->code_size == 0)
+ if (header->code_size == 0)
method_code = g_strdup ("method body is empty.");
else
method_code = mono_disasm_code_one (NULL, method, ip, NULL);
cfg->exception_message = g_strdup_printf ("Invalid IL code in %s: %s\n", method_fname, method_code);
g_free (method_fname);
g_free (method_code);
+ mono_metadata_free_mh (header);
}
static void
cfg->exception_type = MONO_EXCEPTION_INVALID_PROGRAM;
cfg->exception_message = g_strdup_printf ("Method %s is too complex.", mname);
g_free (mname);
+ mono_metadata_free_mh (header);
return -1;
}
if ((cfg->verbose_level > 2) && (cfg->method == method))
mono_print_code (cfg, "AFTER METHOD-TO-IR");
+ mono_metadata_free_mh (header);
return inline_costs;
exception_exit:
g_assert (cfg->exception_type != MONO_EXCEPTION_NONE);
- g_slist_free (class_inits);
- mono_basic_block_free (bb);
- dont_inline = g_list_remove (dont_inline, method);
- return -1;
+ goto cleanup;
inline_failure:
- g_slist_free (class_inits);
- mono_basic_block_free (bb);
- dont_inline = g_list_remove (dont_inline, method);
- return -1;
+ goto cleanup;
load_error:
- g_slist_free (class_inits);
- mono_basic_block_free (bb);
- dont_inline = g_list_remove (dont_inline, method);
cfg->exception_type = MONO_EXCEPTION_TYPE_LOAD;
- return -1;
+ goto cleanup;
unverified:
+ set_exception_type_from_invalid_il (cfg, method, ip);
+ goto cleanup;
+
+ cleanup:
g_slist_free (class_inits);
mono_basic_block_free (bb);
dont_inline = g_list_remove (dont_inline, method);
- set_exception_type_from_invalid_il (cfg, method, ip);
+ mono_metadata_free_mh (header);
return -1;
}
CFG_DEBUG(2) ALPHA_DEBUG("mono_arch_get_allocatable_int_vars");
- header = mono_method_get_header (cfg->method);
+ header = cfg->header;
sig = mono_method_signature (cfg->method);
CFG_DEBUG(2) ALPHA_DEBUG("mono_arch_allocate_vars");
- header = mono_method_get_header (cfg->method);
+ header = cfg->header;
sig = mono_method_signature (cfg->method);
if (cfg->arch.omit_fp_computed)
return;
- header = mono_method_get_header (cfg->method);
+ header = cfg->header;
sig = mono_method_signature (cfg->method);
int i;
CallInfo *cinfo;
- header = mono_method_get_header (cfg->method);
+ header = cfg->header;
sig = mono_method_signature (cfg->method);
gint32 *offsets;
CallInfo *cinfo;
- header = mono_method_get_header (cfg->method);
+ header = cfg->header;
sig = mono_method_signature (cfg->method);
if (mono_jit_trace_calls != NULL && mono_trace_eval (cfg->method))
cfg->param_area = MAX (cfg->param_area, sizeof (gpointer)*8);
- header = mono_method_get_header (cfg->method);
+ header = cfg->header;
/*
* We use the frame register also for any method that has
DEBUG_FUNC_ENTER();
m->flags |= MONO_CFG_HAS_SPILLUP;
- header = mono_method_get_header (m->method);
+ header = m->header;
sig = mono_method_signature (m->method);
DEBUG (printf ("Allocating locals - incoming params:\n"));
MonoMethodHeader *header;
CallInfo *cinfo;
- header = mono_method_get_header (cfg->method);
+ header = cfg->header;
sig = mono_method_signature (cfg->method);
cinfo = get_call_info (cfg, cfg->mempool, mono_method_signature (cfg->method), FALSE);
- header = mono_method_get_header (cfg->method);
+ header = cfg->header;
/* Some registers are reserved for use by the prolog/epilog */
reserved_regs = header->num_clauses ? 4 : 3;
gint32 *offsets;
CallInfo *cinfo;
- header = mono_method_get_header (cfg->method);
+ header = cfg->header;
sig = mono_method_signature (cfg->method);
// FIXME: Nested clauses
if (bb->region != -1 && MONO_BBLOCK_IS_IN_REGION (bb, MONO_REGION_TRY)) {
- MonoMethodHeader *header = mono_method_get_header (cfg->method);
+ MonoMethodHeader *header = cfg->header;
// FIXME: Add a macro for this
int clause_index = (bb->region >> 8) - 1;
MonoExceptionClause *ec = &header->clauses [clause_index];
if (sig->pinvoke)
LLVM_FAILURE (ctx, "pinvoke signature");
- header = mono_method_get_header (cfg->method);
+ header = cfg->header;
for (i = 0; i < header->num_clauses; ++i) {
clause = &header->clauses [i];
if (clause->flags != MONO_EXCEPTION_CLAUSE_FINALLY && clause->flags != MONO_EXCEPTION_CLAUSE_NONE)
/* Fill the rest of the information from the type info */
for (i = 0; i < ei_len; ++i) {
gint32 clause_index = *(gint32*)type_info [i];
- MonoExceptionClause *clause = &mono_method_get_header (cfg->method)->clauses [clause_index];
+ MonoExceptionClause *clause = &cfg->header->clauses [clause_index];
cfg->llvm_ex_info [i].flags = clause->flags;
cfg->llvm_ex_info [i].data.catch_class = clause->data.catch_class;
/* a0-a3 always present */
cfg->param_area = MAX (cfg->param_area, MIPS_STACK_PARAM_OFFSET);
- header = mono_method_get_header (cfg->method);
+ header = cfg->header;
sig = mono_method_signature (cfg->method);
if (m->method->wrapper_type == MONO_WRAPPER_MANAGED_TO_NATIVE)
m->param_area = MAX (m->param_area, sizeof (gpointer)*8);
- header = mono_method_get_header (m->method);
+ header = m->header;
/*
* We use the frame register also for any method that has
MonoMethodHeader *header;
int i, top = 13;
- header = mono_method_get_header (cfg->method);
+ header = cfg->header;
if ((cfg->flags & MONO_CFG_HAS_ALLOCA) || header->num_clauses)
cfg->frame_reg = s390_r11;
int frame_reg = STK_BASE;
int sArg, eArg;
- header = mono_method_get_header (cfg->method);
+ header = cfg->header;
cfg->flags |= MONO_CFG_HAS_SPILLUP;
MonoMethodHeader *header;
int i, top = 13;
- header = mono_method_get_header (cfg->method);
+ header = cfg->header;
if ((cfg->flags & MONO_CFG_HAS_ALLOCA) || header->num_clauses)
cfg->frame_reg = s390_r11;
int frame_reg = STK_BASE;
int sArg, eArg;
- header = mono_method_get_header (cfg->method);
+ header = cfg->header;
cfg->flags |= MONO_CFG_HAS_SPILLUP;
int i, offset, size, align, curinst;
CallInfo *cinfo;
- header = mono_method_get_header (cfg->method);
+ header = cfg->header;
sig = mono_method_signature (cfg->method);
* Only do this if the method is small since BPr only has a 16bit
* displacement.
*/
- if (v64 && (mono_method_get_header (cfg->method)->code_size < 10000) && last_ins &&
+ if (v64 && (cfg->header->code_size < 10000) && last_ins &&
(last_ins->opcode == OP_COMPARE_IMM) &&
(last_ins->inst_imm == 0)) {
switch (ins->opcode) {
if (cfg->arch.need_stack_frame_inited)
return cfg->arch.need_stack_frame;
- header = mono_method_get_header (cfg->method);
+ header = cfg->header;
sig = mono_method_signature (cfg->method);
if (cfg->disable_omit_fp)
gint32 *offsets;
CallInfo *cinfo;
- header = mono_method_get_header (cfg->method);
+ header = cfg->header;
sig = mono_method_signature (cfg->method);
cinfo = get_call_info (cfg->generic_sharing_context, cfg->mempool, sig, FALSE);
guint8 *code;
gboolean need_stack_frame;
- cfg->code_size = MAX (mono_method_get_header (method)->code_size * 4, 10240);
+ cfg->code_size = MAX (cfg->header->code_size * 4, 10240);
if (cfg->prof_options & MONO_PROFILE_ENTER_LEAVE)
cfg->code_size += 512;
static int
mono_find_block_region_notry (MonoCompile *cfg, int offset)
{
- MonoMethod *method = cfg->method;
- MonoMethodHeader *header = mono_method_get_header (method);
+ MonoMethodHeader *header = cfg->header;
MonoExceptionClause *clause;
int i;
mono_get_block_region_notry (MonoCompile *cfg, int region)
{
if ((region & (0xf << 4)) == MONO_REGION_TRY) {
- MonoMethodHeader *header = mono_method_get_header (cfg->method);
+ MonoMethodHeader *header = cfg->header;
/*
* This can happen if a try clause is nested inside a finally clause.
void
mono_destroy_compile (MonoCompile *cfg)
{
+ if (cfg->header)
+ mono_metadata_free_mh (cfg->header);
//mono_mempool_stats (cfg->mempool);
mono_free_loop_info (cfg);
if (cfg->rs)
MonoMethodHeader *header;
int i;
- header = mono_method_get_header (cfg->method);
+ header = cfg->header;
sig = mono_method_signature (cfg->method);
int num_clauses;
int generic_info_size;
- header = mono_method_get_header (method_to_compile);
+ g_assert (method_to_compile == cfg->method);
+ header = cfg->header;
if (cfg->generic_sharing_context)
generic_info_size = sizeof (MonoGenericJitInfo);
cfg = g_new0 (MonoCompile, 1);
cfg->method = method_to_compile;
+ cfg->header = mono_method_get_header (cfg->method);
cfg->mempool = mono_mempool_new ();
cfg->opt = opts;
cfg->prof_options = mono_profiler_get_events ();
}
}
- header = mono_method_get_header (method_to_compile);
+ header = cfg->header;
if (!header) {
MonoLoaderError *error;
g_free (mono_jit_stats.biggest_method);
mono_jit_stats.biggest_method = g_strdup_printf ("%s::%s)", method->klass->name, method->name);
}
- code_size_ratio = (code_size_ratio * 100) / mono_method_get_header (method)->code_size;
+ code_size_ratio = (code_size_ratio * 100) / header->code_size;
if (code_size_ratio > mono_jit_stats.max_code_size_ratio && mono_jit_stats.enabled) {
mono_jit_stats.max_code_size_ratio = code_size_ratio;
g_free (mono_jit_stats.max_ratio_method);
*/
typedef struct {
MonoMethod *method;
+ MonoMethodHeader *header;
MonoMemPool *mempool;
MonoInst **varinfo;
MonoMethodVar *vars;
LSCAN_DEBUG (printf ("\nLINEAR SCAN 2 for %s:\n", mono_method_full_name (cfg->method, TRUE)));
- header = mono_method_get_header (cfg->method);
+ header = cfg->header;
sig = mono_method_signature (cfg->method);