Author: neale
Date: 2006-08-29 10:24:40 -0400 (Tue, 29 Aug 2006)
New Revision: 64511
Modified:
trunk/mono/mono/mini/ChangeLog
trunk/mono/mono/mini/exceptions-s390x.c
trunk/mono/mono/mini/mini-s390.c
trunk/mono/mono/mini/mini-s390x.c
Log:
* mini-s390.c, mini-s390x.c: Fix VARARG case processing with 0
arguments. Add mono_arch_get_patch_offset as a dummy entry point to allow
successful link.
Modified: trunk/mono/mono/mini/ChangeLog
===================================================================
--- trunk/mono/mono/mini/ChangeLog 2006-08-29 13:36:15 UTC (rev 64510)
+++ trunk/mono/mono/mini/ChangeLog 2006-08-29 14:24:40 UTC (rev 64511)
@@ -1,4 +1,10 @@
+2006-08-29 Neale Ferguson <[EMAIL PROTECTED]>
+ * mini-s390.c, mini-s390x.c: Fix VARARG case processing with 0
arguments. Add
+ mono_arch_get_patch_offset as a dummy entry point to allow successful
link.
+
+ * exceptions-s390x.c: Cosmetic change.
+
Wed Aug 23 19:24:00 CEST 2006 Paolo Molaro <[EMAIL PROTECTED]>
* aot-compiler.c: added binary writer with ELF backend
Modified: trunk/mono/mono/mini/exceptions-s390x.c
===================================================================
--- trunk/mono/mono/mini/exceptions-s390x.c 2006-08-29 13:36:15 UTC (rev
64510)
+++ trunk/mono/mono/mini/exceptions-s390x.c 2006-08-29 14:24:40 UTC (rev
64511)
@@ -426,7 +426,7 @@
/* */
/* Name - mono_arch_find_jit_info */
/* */
-/* Function - This function is used to gather informatoin from */
+/* Function - This function is used to gather information from */
/* @ctx. It returns the MonoJitInfo of the corres- */
/* ponding function, unwinds one stack frame and */
/* stores the resulting context into @new_ctx. It */
@@ -434,7 +434,7 @@
/* into @trace (if not NULL), and modifies the @lmf */
/* if necessary. @native_offset returns the IP off- */
/* set from the start of the function or -1 if that */
-/* informatoin is not available. */
+/* information is not available. */
/* */
/*------------------------------------------------------------------*/
@@ -458,8 +458,8 @@
if (trace)
*trace = NULL;
- if (native_offset)
- *native_offset = -1;
+// if (native_offset)
+// *native_offset = -1;
if (managed)
*managed = FALSE;
@@ -489,6 +489,7 @@
MONO_CONTEXT_SET_IP (new_ctx, sframe->return_address);
memcpy (&new_ctx->uc_mcontext.gregs[6], sframe->regs,
(8*sizeof(gint64)));
return ji;
+
} else if (*lmf) {
*new_ctx = *ctx;
Modified: trunk/mono/mono/mini/mini-s390.c
===================================================================
--- trunk/mono/mono/mini/mini-s390.c 2006-08-29 13:36:15 UTC (rev 64510)
+++ trunk/mono/mono/mini/mini-s390.c 2006-08-29 14:24:40 UTC (rev 64511)
@@ -221,6 +221,7 @@
typedef struct {
int nargs;
+ int lastgr;
guint32 stack_usage;
guint32 struct_ret;
ArgInfo ret;
@@ -254,6 +255,7 @@
static void mono_arch_break(void);
gpointer mono_arch_get_lmf_addr (void);
static guint8 * emit_load_volatile_registers(guint8 *, MonoCompile *);
+static void emit_sig_cookie (MonoCompile *, MonoCallInst *, CallInfo *, int);
/*========================= End of Prototypes ======================*/
@@ -1565,6 +1567,16 @@
}
}
+ /*----------------------------------------------------------*/
+ /* Handle the case where there are no implicit arguments */
+ /*----------------------------------------------------------*/
+ if ((sig->call_convention == MONO_CALL_VARARG) &&
+ (sig->param_count == sig->sentinelpos)) {
+ gr = S390_LAST_ARG_REG + 1;
+ add_general (&gr, sz, &cinfo->sigCookie, TRUE);
+ }
+
+ cinfo->lastgr = gr;
sz->stack_size = sz->stack_size + sz->local_size + sz->parm_size +
sz->offset;
sz->stack_size = S390_ALIGN(sz->stack_size, sizeof(long));
@@ -1828,20 +1840,7 @@
if ((sig->call_convention == MONO_CALL_VARARG) &&
(i == sig->sentinelpos)) {
- MonoInst *sigArg;
-
- cfg->disable_aot = TRUE;
- MONO_INST_NEW (cfg, sigArg, OP_ICONST);
- sigArg->inst_p0 = call->signature;
-
- MONO_INST_NEW_CALL_ARG (cfg, arg, OP_OUTARG_MEMBASE);
- arg->ins.inst_left = sigArg;
- arg->ins.inst_right = (MonoInst *) call;
- arg->size = ainfo->size;
- arg->offset = cinfo->sigCookie.offset;
- call->used_iregs |= 1 << ainfo->reg;
- arg->ins.next = call->out_args;
- call->out_args = (MonoInst *) arg;
+ emit_sig_cookie (cfg, call, cinfo, ainfo->size);
}
if (is_virtual && i == 0) {
@@ -1910,7 +1909,16 @@
}
}
}
+
/*
+ * Handle the case where there are no implicit arguments
+ */
+ if ((sig->call_convention == MONO_CALL_VARARG) &&
+ (i == sig->sentinelpos)) {
+ emit_sig_cookie (cfg, call, cinfo, ainfo->size);
+ }
+
+ /*
* Reverse the call->out_args list.
*/
{
@@ -1932,6 +1940,53 @@
/*------------------------------------------------------------------*/
/* */
+/* Name - emit_sig_cookie. */
+/* */
+/* Function - For variable length parameter lists construct a */
+/* signature cookie and emit it. */
+/* */
+/*------------------------------------------------------------------*/
+
+static void
+emit_sig_cookie (MonoCompile *cfg, MonoCallInst *call,
+ CallInfo *cinfo, int argSize)
+{
+ MonoCallArgParm *arg;
+ MonoMethodSignature *tmpSig;
+ MonoInst *sigArg;
+
+ cfg->disable_aot = TRUE;
+
+ /*----------------------------------------------------------*/
+ /* mono_ArgIterator_Setup assumes the signature cookie is */
+ /* passed first and all the arguments which were before it */
+ /* passed on the stack after the signature. So compensate */
+ /* by passing a different signature. */
+ /*----------------------------------------------------------*/
+ tmpSig = mono_metadata_signature_dup (call->signature);
+ tmpSig->param_count -= call->signature->sentinelpos;
+ tmpSig->sentinelpos = 0;
+ if (tmpSig->param_count > 0)
+ memcpy (tmpSig->params,
+ call->signature->params + call->signature->sentinelpos,
+ tmpSig->param_count * sizeof(MonoType *));
+
+ MONO_INST_NEW (cfg, sigArg, OP_ICONST);
+ sigArg->inst_p0 = tmpSig;
+
+ MONO_INST_NEW_CALL_ARG (cfg, arg, OP_OUTARG_MEMBASE);
+ arg->ins.inst_left = sigArg;
+ arg->ins.inst_right = (MonoInst *) call;
+ arg->size = argSize;
+ arg->offset = cinfo->sigCookie.offset;
+ arg->ins.next = call->out_args;
+ call->out_args = (MonoInst *) arg;
+}
+
+/*========================= End of Function ========================*/
+
+/*------------------------------------------------------------------*/
+/* */
/* Name - mono_arch_instrument_mem_needs */
/* */
/* Function - Allow tracing to work with this interface (with */
@@ -4974,3 +5029,21 @@
/*========================= End of Function ========================*/
+
+/*------------------------------------------------------------------*/
+/* */
+/* Name - mono_arch_get_patch_offset */
+/* */
+/* Function - Dummy entry point until s390x supports aot. */
+/* */
+/* Returns - Offset for patch. */
+/* */
+/*------------------------------------------------------------------*/
+
+guint32
+mono_arch_get_patch_offset (guint8 *code)
+{
+ return 0;
+}
+
+/*========================= End of Function ========================*/
Modified: trunk/mono/mono/mini/mini-s390x.c
===================================================================
--- trunk/mono/mono/mini/mini-s390x.c 2006-08-29 13:36:15 UTC (rev 64510)
+++ trunk/mono/mono/mini/mini-s390x.c 2006-08-29 14:24:40 UTC (rev 64511)
@@ -262,6 +262,7 @@
typedef struct {
int nargs;
+ int lastgr;
guint32 stack_usage;
guint32 struct_ret;
ArgInfo ret;
@@ -297,6 +298,7 @@
static guint8 * emit_load_volatile_registers (guint8 *, MonoCompile *);
static CompRelation opcode_to_cond (int);
static void catch_SIGILL(int, siginfo_t *, void *);
+static void emit_sig_cookie (MonoCompile *, MonoCallInst *, CallInfo *, int);
/*========================= End of Prototypes ======================*/
@@ -556,7 +558,7 @@
printf ("[BOOL:%ld], ", *((gint64 *) curParm));
break;
case MONO_TYPE_CHAR :
- printf ("[CHAR:%c], ", *((gint64 *) curParm));
+ printf ("[CHAR:%c], ", *((int *) curParm));
break;
case MONO_TYPE_I1 :
printf ("[INT1:%ld], ", *((gint64 *) curParm));
@@ -599,7 +601,7 @@
printf("%p [%p] ",obj,curParm);
if (class ==
mono_defaults.string_class) {
printf("[STRING:%p:%s]",
- obj, mono_string_to_utf8
(obj));
+ obj, mono_string_to_utf8
((MonoString *) obj));
} else if (class ==
mono_defaults.int32_class) {
printf("[INT32:%p:%d]",
obj, *(gint32 *)((char
*)obj + sizeof (MonoObject)));
@@ -1599,6 +1601,15 @@
}
/*----------------------------------------------------------*/
+ /* Handle the case where there are no implicit arguments */
+ /*----------------------------------------------------------*/
+ if ((sig->call_convention == MONO_CALL_VARARG) &&
+ (sig->param_count == sig->sentinelpos)) {
+ gr = S390_LAST_ARG_REG + 1;
+ add_general (&gr, sz, &cinfo->sigCookie);
+ }
+
+ /*----------------------------------------------------------*/
/* If we are passing a structure back then if it won't be */
/* in a register(s) then we make room at the end of the */
/* parameters that may have been placed on the stack */
@@ -1617,6 +1628,7 @@
}
}
+ cinfo->lastgr = gr;
sz->stack_size = sz->stack_size + sz->local_size + sz->parm_size +
sz->offset;
sz->stack_size = S390_ALIGN(sz->stack_size, sizeof(long));
@@ -1876,22 +1888,10 @@
for (i = 0; i < n; ++i) {
ainfo = cinfo->args + i;
- if ((sig->call_convention == MONO_CALL_VARARG) &&
+ if (!(sig->pinvoke) &&
+ (sig->call_convention == MONO_CALL_VARARG) &&
(i == sig->sentinelpos)) {
- MonoInst *sigArg;
-
- cfg->disable_aot = TRUE;
- MONO_INST_NEW (cfg, sigArg, OP_ICONST);
- sigArg->inst_p0 = call->signature;
-
- MONO_INST_NEW_CALL_ARG (cfg, arg, OP_OUTARG_MEMBASE);
- arg->ins.inst_left = sigArg;
- arg->ins.inst_right = (MonoInst *) call;
- arg->size = ainfo->size;
- arg->offset = cinfo->sigCookie.offset;
- call->used_iregs |= 1 << ainfo->reg;
- arg->ins.next = call->out_args;
- call->out_args = (MonoInst *) arg;
+ emit_sig_cookie (cfg, call, cinfo, ainfo->size);
}
if (is_virtual && i == 0) {
@@ -1904,6 +1904,7 @@
arg->ins.cil_code = in->cil_code;
arg->ins.inst_left = in;
arg->ins.type = in->type;
+
/* prepend, we'll need to reverse them later */
arg->ins.next = call->out_args;
call->out_args = (MonoInst *) arg;
@@ -1944,7 +1945,17 @@
}
}
}
+
/*
+ * Handle the case where there are no implicit arguments
+ */
+ if (!(sig->pinvoke) &&
+ (sig->call_convention == MONO_CALL_VARARG) &&
+ (n == sig->sentinelpos)) {
+ emit_sig_cookie (cfg, call, cinfo, sizeof(MonoType *));
+ }
+
+ /*
* Reverse the call->out_args list.
*/
{
@@ -1966,6 +1977,55 @@
/*------------------------------------------------------------------*/
/* */
+/* Name - emit_sig_cookie. */
+/* */
+/* Function - For variable length parameter lists construct a */
+/* signature cookie and emit it. */
+/* */
+/*------------------------------------------------------------------*/
+
+static void
+emit_sig_cookie (MonoCompile *cfg, MonoCallInst *call,
+ CallInfo *cinfo, int argSize)
+{
+ MonoCallArgParm *arg;
+ MonoMethodSignature *tmpSig;
+ MonoInst *sigArg;
+
+ cfg->disable_aot = TRUE;
+
+ /*----------------------------------------------------------*/
+ /* mono_ArgIterator_Setup assumes the signature cookie is */
+ /* passed first and all the arguments which were before it */
+ /* passed on the stack after the signature. So compensate */
+ /* by passing a different signature. */
+ /*----------------------------------------------------------*/
+ tmpSig = mono_metadata_signature_dup (call->signature);
+ tmpSig->param_count -= call->signature->sentinelpos;
+ tmpSig->sentinelpos = 0;
+ if (tmpSig->param_count > 0)
+ memcpy (tmpSig->params,
+ call->signature->params + call->signature->sentinelpos,
+ tmpSig->param_count * sizeof(MonoType *));
+
+ MONO_INST_NEW (cfg, sigArg, OP_ICONST);
+ sigArg->inst_p0 = tmpSig;
+
+ MONO_INST_NEW_CALL_ARG (cfg, arg, OP_OUTARG_MEMBASE);
+ arg->ins.inst_left = sigArg;
+ arg->ins.inst_right = (MonoInst *) call;
+ arg->size = argSize;
+ arg->offset = cinfo->sigCookie.offset;
+
+ /* prepend, we'll need to reverse them later */
+ arg->ins.next = call->out_args;
+ call->out_args = (MonoInst *) arg;
+}
+
+/*========================= End of Function ========================*/
+
+/*------------------------------------------------------------------*/
+/* */
/* Name - mono_arch_instrument_mem_needs */
/* */
/* Function - Allow tracing to work with this interface (with */
@@ -5332,3 +5392,21 @@
}
/*========================= End of Function ========================*/
+
+/*------------------------------------------------------------------*/
+/* */
+/* Name - mono_arch_get_patch_offset */
+/* */
+/* Function - Dummy entry point until s390x supports aot. */
+/* */
+/* Returns - Offset for patch. */
+/* */
+/*------------------------------------------------------------------*/
+
+guint32
+mono_arch_get_patch_offset (guint8 *code)
+{
+ return 0;
+}
+
+/*========================= End of Function ========================*/
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches