OpCodes.Calli Field

Definition

Calls the method indicated on the evaluation stack (as a pointer to an entry point) with arguments described by a calling convention.

public: static initonly System::Reflection::Emit::OpCode Calli;
public static readonly System.Reflection.Emit.OpCode Calli;
 staticval mutable Calli : System.Reflection.Emit.OpCode
Public Shared ReadOnly Calli As OpCode 

Field Value

Remarks

The following table lists the instruction's hexadecimal and Microsoft Intermediate Language (MSIL) assembly format, along with a brief reference summary:

Format Assembly Format Description
29 < T > calli callSiteDescr Calls the method pointed to with arguments described by the calling convention.

The stack transitional behavior, in sequential order, is:

  1. Method arguments arg1 through argN are pushed onto the stack.

  2. The method entry pointer is pushed onto the stack.

  3. Method arguments arg1 through argN and the method entry pointer are popped from the stack; the call to the method is performed. When complete, a return value is generated by the callee method and sent to the caller.

  4. The return value is pushed onto the stack.

The calli instruction calls the method entry pointer with the arguments arg1 through argN. The types of these arguments are described by the specific calling convention (callSiteDesc). The calli instruction may be immediately preceded by a tail prefix (Tailcall) to specify that the current method state should be released before transferring control. If the call would transfer control to a method of higher trust than the origin method the stack frame will not be released; instead, the execution will continue silently as if the tail had not been supplied.

The method entry pointer is assumed to be a specific pointer to native code (of the target machine) that can be legitimately called with the arguments described by the calling convention (a metadata token for a stand-alone signature). Such a pointer can be created using the Ldftn or Ldvirtftn instructions, or passed in from native code.

The calling convention is not checked dynamically, so code that uses a calli instruction does not work correctly if the destination does not actually use the specified calling convention.

The arguments are placed on the stack in left-to-right order. That is, the first argument is computed and placed on the stack, then the second argument, then the third, until all necessary arguments are atop the stack in descending order. The argument-building code sequence for an instance or virtual method must push that instance reference (which must not be a null reference) before any of the user-visible arguments.

SecurityException may be thrown if the system security does not grant the caller access to the called method. The security check can occur when the Microsoft Intermediate Language (MSIL) instructions are converted to native code rather than at runtime.

The following EmitCalli methods can be used to perform a calli instruction on the stack. Note that calli should be called through the below methods rather than using the Emit class to place the instruction directly on the stack.

Applies to