* mini-s390.c, mini-s390x.c: Fix VARARG case processing with 0
authorNeale Ferguson <neale@mono-cvs.ximian.com>
Tue, 29 Aug 2006 14:24:40 +0000 (14:24 -0000)
committerNeale Ferguson <neale@mono-cvs.ximian.com>
Tue, 29 Aug 2006 14:24:40 +0000 (14:24 -0000)
arguments. Add mono_arch_get_patch_offset as a dummy entry point to allow
successful link.

svn path=/trunk/mono/; revision=64511

mono/mini/ChangeLog
mono/mini/exceptions-s390x.c
mono/mini/mini-s390.c
mono/mini/mini-s390x.c

index fe8a1796283c527f7547a6e86e7d453c58969521..ee09a91144a87f03ec2083d08b39ea575adb8fad 100644 (file)
@@ -1,3 +1,9 @@
+2006-08-29 Neale Ferguson <neale@sinenomine.net>
+
+       * 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 <lupus@ximian.com>
 
index 65dddc08a4f3a87fb901dcd74ab640478d3d9dc4..b40b50ce84fefb7eb659015440c986f23595b560 100644 (file)
@@ -426,7 +426,7 @@ mono_arch_get_throw_exception_by_name (void)
 /*                                                                  */
 /* 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 @@ mono_arch_get_throw_exception_by_name (void)
 /*                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 @@ mono_arch_find_jit_info (MonoDomain *domain, MonoJitTlsData *jit_tls,
        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_arch_find_jit_info (MonoDomain *domain, MonoJitTlsData *jit_tls,
                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;
index 173870b9646961e81d4999a5799f403bde1da82d..d889f71193d30d849dd5ed75950e6081de3feb32 100644 (file)
@@ -221,6 +221,7 @@ typedef struct {
 
 typedef struct {
        int nargs;
+       int lastgr;
        guint32 stack_usage;
        guint32 struct_ret;
        ArgInfo ret;
@@ -254,6 +255,7 @@ static guchar * emit_float_to_int (MonoCompile *, guchar *, int, int, int, gbool
 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 @@ enum_retvalue:
                }
        }
 
+       /*----------------------------------------------------------*/
+       /* 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 @@ mono_arch_call_opcode (MonoCompile *cfg, MonoBasicBlock* bb,
 
                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,6 +1909,15 @@ mono_arch_call_opcode (MonoCompile *cfg, MonoBasicBlock* bb,
                        }
                }
        }
+
+       /*
+        * 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.
         */
@@ -1930,6 +1938,53 @@ mono_arch_call_opcode (MonoCompile *cfg, MonoBasicBlock* bb,
 
 /*========================= End of Function ========================*/
 
+/*------------------------------------------------------------------*/
+/*                                                                  */
+/* 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                    */
@@ -4973,4 +5028,22 @@ mono_arch_get_lmf_addr (void)
 }
 
 
+/*========================= 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 ========================*/
index ea8084d421008a085b4d09b305047945c963559d..7244e9aef0a8478cc26062a34036b539c64c98bc 100644 (file)
@@ -262,6 +262,7 @@ typedef struct {
 
 typedef struct {
        int nargs;
+       int lastgr;
        guint32 stack_usage;
        guint32 struct_ret;
        ArgInfo ret;
@@ -297,6 +298,7 @@ gpointer mono_arch_get_lmf_addr (void);
 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 @@ enum_parmtype:
                                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 @@ enum_parmtype:
                                        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)));
@@ -1598,6 +1600,15 @@ enum_retvalue:
                }
        }
 
+       /*----------------------------------------------------------*/
+       /* 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     */
@@ -1617,6 +1628,7 @@ enum_retvalue:
                }
        }
 
+       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 @@ mono_arch_call_opcode (MonoCompile *cfg, MonoBasicBlock* bb,
        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 @@ mono_arch_call_opcode (MonoCompile *cfg, MonoBasicBlock* bb,
                        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,6 +1945,16 @@ mono_arch_call_opcode (MonoCompile *cfg, MonoBasicBlock* bb,
                        }
                }
        }
+
+       /*
+        * 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.
         */
@@ -1964,6 +1975,55 @@ mono_arch_call_opcode (MonoCompile *cfg, MonoBasicBlock* bb,
 
 /*========================= End of Function ========================*/
 
+/*------------------------------------------------------------------*/
+/*                                                                  */
+/* 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                    */
@@ -5332,3 +5392,21 @@ opcode_to_cond (int opcode)
 }
 
 /*========================= 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 ========================*/