Author: zoltan
Date: 2005-06-18 17:09:22 -0400 (Sat, 18 Jun 2005)
New Revision: 46195
Modified:
trunk/mono/mono/mini/ChangeLog
trunk/mono/mono/mini/exceptions-ia64.c
trunk/mono/mono/mini/mini-ia64.c
trunk/mono/mono/mini/mini-ia64.h
trunk/mono/mono/mini/mini.h
trunk/mono/mono/mini/tramp-ia64.c
Log:
2005-06-18 Zoltan Varga <[EMAIL PROTECTED]>
* *-ia64.*: Ongoing IA64 work.
Modified: trunk/mono/mono/mini/ChangeLog
===================================================================
--- trunk/mono/mono/mini/ChangeLog 2005-06-18 21:07:05 UTC (rev 46194)
+++ trunk/mono/mono/mini/ChangeLog 2005-06-18 21:09:22 UTC (rev 46195)
@@ -1,5 +1,7 @@
2005-06-18 Zoltan Varga <[EMAIL PROTECTED]>
+ * *-ia64.*: Ongoing IA64 work.
+
* aot.c: Lower memory usage while loading AOT methods.
* tramp-x86.c: Avoid allocating+freeing MonoJitInfo structures.
Modified: trunk/mono/mono/mini/exceptions-ia64.c
===================================================================
--- trunk/mono/mono/mini/exceptions-ia64.c 2005-06-18 21:07:05 UTC (rev
46194)
+++ trunk/mono/mono/mini/exceptions-ia64.c 2005-06-18 21:09:22 UTC (rev
46195)
@@ -81,15 +81,15 @@
static guint8 *start;
static gboolean inited = FALSE;
Ia64CodegenState code;
- int in0, local0, out0, nout;
+ int i, in0, local0, out0, nout;
+ unw_dyn_info_t *di;
+ unw_dyn_region_info_t *r_pro;
if (inited)
return start;
start = mono_global_codeman_reserve (1024);
- /* FIXME: add unwind info */
-
/* int call_filter (guint64 fp, guint64 ip) */
/*
@@ -116,6 +116,18 @@
ia64_alloc (code, local0 + 0, local0 - in0, out0 - local0, nout, 0);
ia64_mov_from_br (code, local0 + 1, IA64_B0);
+ /* FIXME: This depends on the current instruction emitter */
+
+ r_pro = g_malloc0 (_U_dyn_region_info_size (2));
+ r_pro->op_count = 2;
+ r_pro->insn_count = 6;
+ i = 0;
+ _U_dyn_op_save_reg (&r_pro->op[i++], _U_QP_TRUE, /* when=*/ 2,
+ /* reg=*/ UNW_IA64_AR_PFS, /*
dst=*/ UNW_IA64_GR + local0 + 0);
+ _U_dyn_op_save_reg (&r_pro->op[i++], _U_QP_TRUE, /* when=*/ 5,
+ /* reg=*/ UNW_IA64_RP, /*
dst=*/ UNW_IA64_GR + local0 + 1);
+ g_assert ((unsigned) i <= r_pro->op_count);
+
/* Frame pointer */
ia64_mov (code, IA64_R15, in0 + 0);
/* Target ip */
@@ -138,6 +150,16 @@
mono_arch_flush_icache (start, code.buf - start);
+ di = g_malloc0 (sizeof (unw_dyn_info_t));
+ di->start_ip = (unw_word_t) start;
+ di->end_ip = (unw_word_t) code.buf;
+ di->gp = 0;
+ di->format = UNW_INFO_FORMAT_DYNAMIC;
+ di->u.pi.name_ptr = (unw_word_t)"throw_trampoline";
+ di->u.pi.regions = r_pro;
+
+ _U_dyn_register (di);
+
return mono_create_ftnptr (start);
}
@@ -202,6 +224,14 @@
break;
res = unw_step (&ctx.cursor);
+
+ if (res == 0) {
+ /*
+ * This means an unhandled exception during the
compilation of a
+ * topmost method like Main
+ */
+ break;
+ }
g_assert (res >= 0);
}
@@ -255,7 +285,7 @@
ia64_br_call_reg (code, IA64_B0, IA64_B6);
/* Not reached */
- ia64_break_i (code, 0);
+ ia64_break_i (code, 1000);
ia64_codegen_close (code);
g_assert ((code.buf - start) <= 256);
@@ -325,7 +355,7 @@
/* Not used on ia64 */
ia64_codegen_init (code, start);
- ia64_break_i (code, 0);
+ ia64_break_i (code, 1001);
ia64_codegen_close (code);
g_assert ((code.buf - start) <= 256);
@@ -410,7 +440,7 @@
ia64_ld8 (code, IA64_GP, GP_SCRATCH_REG);
ia64_br_call_reg (code, IA64_B0, IA64_B6);
- ia64_break_i (code, 0);
+ ia64_break_i (code, 1002);
ia64_codegen_close (code);
g_assert ((code.buf - start) <= 1024);
@@ -511,7 +541,7 @@
return ji;
}
else
- return NULL;
+ return (gpointer)(gssize)-1;
}
/**
Modified: trunk/mono/mono/mini/mini-ia64.c
===================================================================
--- trunk/mono/mono/mini/mini-ia64.c 2005-06-18 21:07:05 UTC (rev 46194)
+++ trunk/mono/mono/mini/mini-ia64.c 2005-06-18 21:09:22 UTC (rev 46195)
@@ -604,8 +604,7 @@
/* Allocate locals */
offsets = mono_allocate_stack_slots (m, &locals_stack_size,
&locals_stack_align);
if (locals_stack_align) {
- offset += (locals_stack_align - 1);
- offset &= ~(locals_stack_align - 1);
+ offset = ALIGN_TO (offset, locals_stack_align);
}
for (i = m->locals_start; i < m->num_varinfo; i++) {
if (offsets [i] != -1) {
@@ -674,6 +673,7 @@
}
else
offset += sizeof (gpointer);
+ offset = ALIGN_TO (offset, sizeof (gpointer));
inst->inst_offset = - offset;
}
}
@@ -2443,11 +2443,19 @@
ia64_mov (code, cfg->arch.reg_out0, ins->sreg1);
code = emit_call (cfg, code,
MONO_PATCH_INFO_INTERNAL_METHOD,
(gpointer)"mono_arch_throw_exception");
+
+ /*
+ * This might be the last instruction in the method, so
add a dummy
+ * instruction so the unwinder will work.
+ */
+ ia64_break_i (code, 0);
break;
case OP_RETHROW:
ia64_mov (code, cfg->arch.reg_out0, ins->sreg1);
code = emit_call (cfg, code,
MONO_PATCH_INFO_INTERNAL_METHOD,
(gpointer)"mono_arch_rethrow_exception");
+
+ ia64_break_i (code, 0);
break;
default:
@@ -2735,10 +2743,9 @@
mono_arch_emit_prolog (MonoCompile *cfg)
{
MonoMethod *method = cfg->method;
- MonoBasicBlock *bb;
MonoMethodSignature *sig;
MonoInst *inst;
- int alloc_size, pos, max_offset, i;
+ int alloc_size, pos, i;
Ia64CodegenState code;
CallInfo *cinfo;
unw_dyn_region_info_t *r_pro;
@@ -2890,6 +2897,10 @@
if (inst->dreg != cfg->arch.reg_in0 +
ainfo->reg)
ia64_mov (code, inst->dreg,
cfg->arch.reg_in0 + ainfo->reg);
break;
+ case ArgOnStack:
+ ia64_adds_imm (code, GP_SCRATCH_REG,
ainfo->offset, cfg->frame_reg);
+ ia64_ld8 (code, inst->dreg, GP_SCRATCH_REG);
+ break;
default:
NOT_IMPLEMENTED;
}
@@ -2911,6 +2922,8 @@
g_assert (cfg->code_len < cfg->code_size);
+ cfg->arch.prolog_end_offset = cfg->code_len;
+
return code.buf;
}
@@ -2924,6 +2937,8 @@
guint8 *buf;
CallInfo *cinfo;
+ cfg->arch.epilog_begin_offset = cfg->code_len;
+
while (cfg->code_len + max_epilog_size > (cfg->code_size - 16)) {
cfg->code_size *= 2;
cfg->native_code = g_realloc (cfg->native_code, cfg->code_size);
@@ -2985,6 +3000,7 @@
MonoJumpInfo *patch_info;
int nthrows;
Ia64CodegenState code;
+ gboolean empty = TRUE;
/*
MonoClass *exc_classes [16];
guint8 *exc_throw_start [16], *exc_throw_end [16];
@@ -3044,6 +3060,8 @@
ia64_movl (code, cfg->arch.reg_out0 + 1, buf -
throw_ip);
ia64_br_call_reg (code, IA64_B0, IA64_B6);
+
+ empty = FALSE;
break;
}
default:
@@ -3051,6 +3069,10 @@
}
}
+ if (!empty)
+ /* The unwinder needs this to work */
+ ia64_break_i (code, 0);
+
ia64_codegen_close (code);
cfg->code_len = code.buf - cfg->native_code;
Modified: trunk/mono/mono/mini/mini-ia64.h
===================================================================
--- trunk/mono/mono/mini/mini-ia64.h 2005-06-18 21:07:05 UTC (rev 46194)
+++ trunk/mono/mono/mini/mini-ia64.h 2005-06-18 21:09:22 UTC (rev 46195)
@@ -68,6 +68,7 @@
gint32 reg_saved_ar_pfs;
gint32 reg_saved_b0;
gint32 reg_saved_sp;
+ guint32 prolog_end_offset, epilog_begin_offset, epilog_end_offset;
unw_dyn_region_info_t *r_pro;
} MonoCompileArch;
@@ -125,9 +126,9 @@
return fp;
}
-#define MONO_CONTEXT_SET_IP(ctx,eip) do { int err = unw_set_reg
(&(ctx)->cursor, UNW_IA64_IP, (eip)); g_assert (err == 0); } while (0)
+#define MONO_CONTEXT_SET_IP(ctx,eip) do { int err = unw_set_reg
(&(ctx)->cursor, UNW_IA64_IP, (unw_word_t)(eip)); g_assert (err == 0); } while
(0)
#define MONO_CONTEXT_SET_BP(ctx,ebp) do { } while (0)
-#define MONO_CONTEXT_SET_SP(ctx,esp) do { int err = unw_set_reg
(&(ctx)->cursor, UNW_IA64_SP, (esp)); g_assert (err == 0); } while (0)
+#define MONO_CONTEXT_SET_SP(ctx,esp) do { int err = unw_set_reg
(&(ctx)->cursor, UNW_IA64_SP, (unw_word_t)(esp)); g_assert (err == 0); } while
(0)
#define MONO_CONTEXT_GET_IP(ctx) ((gpointer)(mono_ia64_context_get_ip ((ctx))))
#define MONO_CONTEXT_GET_BP(ctx) ((gpointer)(mono_ia64_context_get_fp ((ctx))))
@@ -139,6 +140,16 @@
MONO_CONTEXT_SET_BP ((ctx), __builtin_frame_address (0));
\
} while (0)
+#define MONO_INIT_CONTEXT_FROM_CURRENT(ctx) do { \
+ int res; \
+ res = unw_getcontext (&unw_ctx); \
+ g_assert (res == 0); \
+ res = unw_init_local (&(ctx)->cursor, &unw_ctx); \
+ g_assert (res == 0); \
+} while (0)
+
+#define MONO_ARCH_CONTEXT_DEF unw_context_t unw_ctx;
+
#define MONO_ARCH_USE_SIGACTION 1
#ifdef HAVE_WORKING_SIGALTSTACK
Modified: trunk/mono/mono/mini/mini.h
===================================================================
--- trunk/mono/mono/mini/mini.h 2005-06-18 21:07:05 UTC (rev 46194)
+++ trunk/mono/mono/mini/mini.h 2005-06-18 21:09:22 UTC (rev 46195)
@@ -809,7 +809,6 @@
gboolean mono_method_blittable (MonoMethod *method);
gboolean mono_method_same_domain (MonoJitInfo *caller, MonoJitInfo
*callee);
void mono_register_opcode_emulation (int opcode, const char* name,
MonoMethodSignature *sig, gpointer func, gboolean no_throw);
-void mono_arch_register_lowlevel_calls (void);
void mono_draw_graph (MonoCompile *cfg,
MonoGraphOptions draw_options);
void mono_add_varcopy_to_end (MonoCompile *cfg, MonoBasicBlock
*bb, int src, int dest);
void mono_add_ins_to_end (MonoBasicBlock *bb, MonoInst
*inst);
@@ -901,6 +900,7 @@
gpointer*mono_arch_get_delegate_method_ptr_addr (guint8* code, gpointer *regs);
void mono_arch_create_vars (MonoCompile *cfg);
void mono_arch_save_unwind_info (MonoCompile *cfg);
+void mono_arch_register_lowlevel_calls (void);
/* Exception handling */
gboolean mono_handle_exception (MonoContext *ctx, gpointer
obj,
Modified: trunk/mono/mono/mini/tramp-ia64.c
===================================================================
--- trunk/mono/mono/mini/tramp-ia64.c 2005-06-18 21:07:05 UTC (rev 46194)
+++ trunk/mono/mono/mini/tramp-ia64.c 2005-06-18 21:09:22 UTC (rev 46195)
@@ -274,9 +274,11 @@
/* FIXME: Handle NATs in fp regs / scratch regs */
- /* Load method address from function descriptor */
- ia64_ld8 (code, l0, IA64_R8);
- ia64_mov_to_br (code, IA64_B6, l0);
+ if (tramp_type != MONO_TRAMPOLINE_CLASS_INIT) {
+ /* Load method address from function descriptor */
+ ia64_ld8 (code, l0, IA64_R8);
+ ia64_mov_to_br (code, IA64_B6, l0);
+ }
/* Clean up register/memory stack frame */
ia64_adds_imm (code, IA64_SP, framesize, IA64_SP);
@@ -314,10 +316,9 @@
#define TRAMPOLINE_SIZE 128
-static MonoJitInfo*
-create_specific_trampoline (gpointer arg1, MonoTrampolineType tramp_type,
MonoDomain *domain)
+static gpointer
+create_specific_trampoline (gpointer arg1, MonoTrampolineType tramp_type,
MonoDomain *domain, guint32 *code_len)
{
- MonoJitInfo *ji;
guint8 *buf, *tramp;
gint64 disp;
Ia64CodegenState code;
@@ -351,41 +352,39 @@
mono_arch_flush_icache (buf, code.buf - buf);
- ji = g_new0 (MonoJitInfo, 1);
- ji->code_start = buf;
- ji->code_size = code.buf - buf;
+ if (code_len)
+ *code_len = code.buf - buf;
- return ji;
+ return buf;
}
MonoJitInfo*
mono_arch_create_jump_trampoline (MonoMethod *method)
{
- MonoJitInfo *ji = create_specific_trampoline (method,
MONO_TRAMPOLINE_JUMP, mono_domain_get ());
+ MonoJitInfo *ji;
+ gpointer code;
+ guint32 code_size;
+ code = create_specific_trampoline (method, MONO_TRAMPOLINE_JUMP,
mono_domain_get (), &code_size);
+
+ ji = g_new0 (MonoJitInfo, 1);
+ ji->code_start = code;
+ ji->code_size = code_size;
ji->method = method;
+
return ji;
}
gpointer
mono_arch_create_jit_trampoline (MonoMethod *method)
{
- MonoJitInfo *ji;
- gpointer code_start;
-
- ji = create_specific_trampoline (method, MONO_TRAMPOLINE_GENERIC,
mono_domain_get ());
- code_start = ji->code_start;
- g_free (ji);
-
- return code_start;
+ return create_specific_trampoline (method, MONO_TRAMPOLINE_GENERIC,
mono_domain_get (), NULL);
}
gpointer
mono_arch_create_jit_trampoline_from_token (MonoImage *image, guint32 token)
{
MonoDomain *domain = mono_domain_get ();
- MonoJitInfo *ji;
- gpointer code_start;
guint8 *buf, *start;
mono_domain_lock (domain);
@@ -396,11 +395,7 @@
buf += sizeof (gpointer);
*(guint32*)(gpointer)buf = token;
- ji = create_specific_trampoline (start, MONO_TRAMPOLINE_AOT, domain);
- code_start = ji->code_start;
- g_free (ji);
-
- return code_start;
+ return create_specific_trampoline (start, MONO_TRAMPOLINE_AOT, domain,
NULL);
}
/**
@@ -417,14 +412,7 @@
gpointer
mono_arch_create_class_init_trampoline (MonoVTable *vtable)
{
- MonoJitInfo *ji;
- gpointer code;
-
- ji = create_specific_trampoline (vtable, MONO_TRAMPOLINE_CLASS_INIT,
vtable->domain);
- code = ji->code_start;
- g_free (ji);
-
- return code;
+ return create_specific_trampoline (vtable, MONO_TRAMPOLINE_CLASS_INIT,
vtable->domain, NULL);
}
void
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches