+/*------------------------------------------------------------------*/
+/* */
+/* 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 ========================*/
+