Call management instructions



      call      call_ctor      call_interface      call_native
      call_native_raw      call_native_void      call_native_void_raw      call_virtual
      cctor_once      ldftn      ldinterfftn      ldvirtftn
      pack_varargs      push_thread      push_thread_raw      pushdown
      return      return_1      return_2      return_n
      set_num_args      tail_call      tail_calli      tail_callintf
      tail_callvirt      waddr_native_<n>      waddr_native_n 


 call 
  ·  OperationCall a method
  ·  Format
call
mptr
  ·  Direct Format
{call}
mptr
  ·  Forms call = 206 (0xCE)
   · Description The call instruction effects a method call to mptr. The call proceeds as follows:
  • The method is converted into CVM bytecode. If this is not possible, then System.Security.VerificationException will be thrown.
  • A new call frame is allocated.
  • The current method, program counter, frame pointer, and exception frame height are saved into the call frame.
  • The program counter is set to the first instruction in the method mptr.
  • The current method is set to mptr.
   · Notes The mptr value is a 32-bit or 64-bit method pointer reference.

The call instruction does not set up a new frame pointer. The set_num_args instruction is used to set up local variable frames at the start of the new method's code. The return* instructions are responsible for popping the method arguments from the stack at method exit.

   · Exceptions System.Security.VerificationException -- Raised if the method could not be translated into CVM bytecode.


 call_ctor 
  ·  OperationCall a constructor
  ·  Format
call_ctor
mptr
  ·  Direct Format
{call_ctor}
mptr
  ·  Forms call_ctor = 207 (0xCF)
   · Description The call_ctor instruction effects a method call to the constructor identified by mptr.
   · Notes Constructors in the CVM system have two entry points: one which creates a block of memory and then initializes it; and the other which initializes a pre-allocated block. The particular entry point is chosen based on the constructor's usage in the original CIL bytecode:
  • If the CIL bytecode invoked the constructor method using newobj, then call_ctor should be used.
  • If the CIL bytecode invoked a parent class's constructor method directly using the IL call instruction, then call should be used.
See the description of the call instruction for a full account of frame handling, argument handling, etc.


 call_interface 
  ·  OperationCall an interface method
  ·  Format
call_interface
N[1]
M[1]
cptr
wide
call_interface
N[4]
M[4]
cptr
  ·  Direct Format
{call_interface}
N
M
cptr
  ·  Forms call_interface = 213 (0xD5)
   · Description The call_interface instruction effects an interface method call. The value N indicates the position of the this pointer on the stack: 1 indicates the top of stack, 2 indicates the stack word just below the top-most stack word, etc. The value M is the offset into the interface's vtable for the method. The value cptr indicates the interface class pointer.
   · Notes See the description of the call instruction for a full account of frame handling, argument handling, etc.

The cptr value is a native pointer that may be either 32 or 64 bits in size, depending upon the platform.

   · Exceptions System.NullReferenceException -- Raised if the this pointer is null.
System.Security.VerificationException -- Raised if the method could not be translated into CVM bytecode.


 call_native 
  ·  OperationCall a native function that has a return value
  ·  Format
call_native
function
cif
  ·  Direct Format
{call_native}
function
cif
  ·  Forms call_native = 208 (0xD0)
  ·  Stack..., address => ...
   · Description The call_native instruction effects a native function call to function, using cif to define the format of the function arguments and return value. The return value is stored at address. The arguments are assumed to have already been stored into the "native argument buffer" using the waddr_native* instructions.
   · Notes Both function and cif are native pointers, which may be either 32 or 64 bits in size, depending upon the platform.

Native function calls occur in CIL "InternalCall" and "PInvoke" methods. For each such method, the CVM translation process creates a CVM stub method that transfers the arguments on the CVM stack to the native argument buffer, makes the native call, and then puts the function's return value back onto the CVM stack prior to exiting.



 call_native_raw 
  ·  OperationCall a native function that has a return value, using a raw call
  ·  Format
call_native_raw
function
cif
  ·  Direct Format
{call_native_raw}
function
cif
  ·  Forms call_native_raw = 210 (0xD2)
  ·  Stack..., avalue, rvalue => ...
   · Description The call_native_raw instruction effects a native function call to function, using cif to define the format of the function arguments and return value. The arguments are stored on the stack beginning at avalue. The return value is stored at rvalue.
   · Notes This instruction differs from call_native in the manner in which the call is performed. This instruction uses a "raw" call, which is only applicable on some platforms. The arguments are passed on the stack, instead of in a separate native argument buffer.


 call_native_void 
  ·  OperationCall a native function with no return value
  ·  Format
call_native_void
function
cif
  ·  Direct Format
{call_native_void}
function
cif
  ·  Forms call_native_void = 209 (0xD1)
   · Description The call_native_void instruction is identical to call_native, except that the native function is assumed not to have a return value.


 call_native_void_raw 
  ·  OperationCall a native function with no return value using a raw call
  ·  Format
call_native_void_raw
function
cif
  ·  Direct Format
{call_native_void_raw}
function
cif
  ·  Forms call_native_void_raw = 211 (0xD3)
  ·  Stack..., avalue => ...
   · Description The call_native_void_raw instruction is identical to call_native_raw, except that the native function is assumed not to have a return value.


 call_virtual 
  ·  OperationCall a virtual method
  ·  Format
call_virtual
N[1]
M[1]
wide
call_virtual
N[4]
M[4]
  ·  Direct Format
{call_virtual}
N
M
  ·  Forms call_virtual = 212 (0xD4)
   · Description The call_virtual instruction effects a virtual method call. The value N indicates the position of the this pointer on the stack: 1 indicates the top of stack, 2 indicates the stack word just below the top-most stack word, etc. The value M is the offset into the object's vtable for the method.
   · Notes See the description of the call instruction for a full account of frame handling, argument handling, etc.
   · Exceptions System.NullReferenceException -- Raised if the this pointer is null.
System.Security.VerificationException -- Raised if the method could not be translated into CVM bytecode.


 cctor_once 
  ·  OperationBlock the current method from being executed more than once
  ·  Format
cctor_once
  ·  Direct Format
{cctor_once}
  ·  Forms cctor_once = 223 (0xDF)
   · Description The cctor_once instruction is typically the first instruction in a static constructor. If this is the first time that the static constructor has been called, then the method will continue. Otherwise, the effect will be the same as for return.
   · Notes This instruction permits CVM bytecode to call static constructors from anywhere in the system, without having to worry about whether it has already been called. This instruction will also prevent recursive static constructor calls from looping indefinitely.


 ldftn 
  ·  OperationLoad the address of a function method onto the stack
  ·  Format
prefix
ldftn
method
  ·  Direct Format
{ltftn}
method
  ·  Forms ldftn = 255, 26 (0xFF, 0x1A)
  ·  Stack... => ..., method
   · Description Push method onto the stack as a ptr value.
   · Notes The method value may be either 32 or 64 bits in size, depending upon the platform.


 ldinterfftn 
  ·  OperationLoad the address of an interface function method onto the stack
  ·  Format
prefix
ldinterfftn
index[4]
class
  ·  Direct Format
{ltinterfftn}
index
class
  ·  Forms ldinterfftn = 255, 28 (0xFF, 0x1C)
  ·  Stack..., object => ..., address
   · Description Pop object from the stack as type ptr and locate the virtual method at index within the object's interface vtable for the interface class. The address of this method is pushed onto the stack as type ptr.
   · Notes The class value may be either 32 or 64 bits in size, depending upon the platform.


 ldvirtftn 
  ·  OperationLoad the address of a virtual function method onto the stack
  ·  Format
prefix
ldvirtftn
index[4]
  ·  Direct Format
{ltvirtftn}
index
  ·  Forms ldvirtftn = 255, 27 (0xFF, 0x1B)
  ·  Stack..., object => ..., address
   · Description Pop object from the stack as type ptr and locate the virtual method at index within the object's vtable. The address of this method is pushed onto the stack as type ptr.


 pack_varargs 
  ·  OperationPack a set of arguments for a vararg method call
  ·  Format
prefix
pack_varargs
first[4]
num[4]
signature
  ·  Direct Format
{pack_varargs}
first
num
signature
  ·  Forms pack_varargs = 255, 29 (0xFF, 0x1D)
  ·  Stack..., arg1, ..., argN => ..., array
   · Description Pop N words from the stack and pack them into an array of type System.Object. The first value is the index of the first parameter in signature that corresponds to a word on the stack. The num value is the number of logical arguments to be packed. The final array is pushed onto the stack as type ptr.
   · Notes The signature value may be either 32 or 64 bits in size, depending upon the platform, and will usually include a sentinel marker at position first - 1. The signature may not have a sentinel marker if num is zero.

This instruction is used to pack the arguments for a call to a vararg method. The method itself will receive a single argument containing a pointer to the array.



 push_thread 
  ·  OperationPush the thread identifier onto the native argument stack
  ·  Format
push_thread
  ·  Direct Format
{push_thread}
  ·  Forms push_thread = 220 (0xDC)
   · Description Pushes an identifier for the current thread onto the native argument stack. This is only used for "InternalCall" methods. "PInvoke" methods should use waddr_native_m1 instead.


 push_thread_raw 
  ·  OperationPush the thread identifier onto the native argument stack as a raw value
  ·  Format
push_thread_raw
  ·  Direct Format
{push_thread_raw}
  ·  Forms push_thread_raw = 221 (0xDD)
   · Description Pushes an identifier for the current thread onto the native argument stack. This is only used for "InternalCall" methods. This instruction differs from push_thread in that it is intended for use with call_native_raw instead of call_native.


 pushdown 
  ·  OperationPush the ptr value at the top of stack down and duplicate it twice
  ·  Format
pushdown
N[4]
  ·  Direct Format
{pushdown}
N
  ·  Forms pushdown = 222 (0xDE)
  ·  Stack..., val1, ..., valN, value => ..., value, value, val1, ..., valN
   · Description The value at the top of the stack is popped, pushed down N stack words, and duplicated twice.
   · Notes This instruction is used in combination with new to construct a block of memory for a new object. The block is allocated, and then pushed down. The lowest duplicated value becomes the return value for the constructor method. The other duplicated value becomes the this argument for the constructor method.


 return 
  ·  OperationReturn from the current method with no return value
  ·  Format
return
  ·  Direct Format
{return}
  ·  Forms return = 214 (0xD6)
   · Description Return control to the method that called the current method, as follows:
  • Set the top of stack pointer to the frame pointer.
  • Pop the top-most call frame from the call frame stack.
  • Retrieve the method pointer, progrm counter, exception frame height, and the frame pointer from the call frame.
   · Notes The set_num_args instruction has previously set the frame pointer to the address of the first argument. When return is executed, the first step above will pop all of the arguments.


 return_1 
  ·  OperationReturn from the current method with a single stack word as a return value
  ·  Format
return_1
  ·  Direct Format
{return_1}
  ·  Forms return_1 = 215 (0xD7)
   · Description Return control to the method that called the current method, as follows:
  • Copy the top-most word on the stack to the position indicated by the frame pointer, and then set the top of stack pointer to point just after the copy.
  • Pop the top-most call frame from the call frame stack.
  • Retrieve the method pointer, progrm counter, exception frame height, and the frame pointer from the call frame.
   · Notes The set_num_args instruction has previously set the frame pointer to the address of the first argument. When return_1 is executed, the first step above will pop all of the arguments, with the single-word return value left in their place.


 return_2 
  ·  OperationReturn from the current method with two stack words as the return value
  ·  Format
return_2
  ·  Direct Format
{return_2}
  ·  Forms return_2 = 216 (0xD8)
   · Description Return control to the method that called the current method, as follows:
  • Copy the two top-most words on the stack to the position indicated by the frame pointer, and then set the top of stack pointer to point just after the two copied words.
  • Pop the top-most call frame from the call frame stack.
  • Retrieve the method pointer, progrm counter, exception frame height, and the frame pointer from the call frame.
   · Notes The set_num_args instruction has previously set the frame pointer to the address of the first argument. When return_2 is executed, the first step above will pop all of the arguments, with the double-word return value left in their place.


 return_n 
  ·  OperationReturn from the current method with n stack words as the return value
  ·  Format
return_n
N[4]
  ·  Direct Format
{return_n}
N
  ·  Forms return_n = 217 (0xD9)
   · Description Return control to the method that called the current method, as follows:
  • Copy the n top-most words on the stack to the position indicated by the frame pointer, and then set the top of stack pointer to point just after the n copied words.
  • Pop the top-most call frame from the call frame stack.
  • Retrieve the method pointer, progrm counter, exception frame height, and the frame pointer from the call frame.
   · Notes The set_num_args instruction has previously set the frame pointer to the address of the first argument. When return_n is executed, the first step above will pop all of the arguments, with the n-word return value left in their place.


 set_num_args 
  ·  OperationSet the number of arguments for the current method
  ·  Format
set_num_args
N[1]
wide
set_num_args
N[4]
  ·  Direct Format
{set_num_args}
N
  ·  Forms set_num_args = 66 (0x42)
   · Description Set the frame pointer for the current method to the address of the N'th word down the stack.
   · Notes This is typically the first instruction in a method, which sets up the local variable frame.


 tail_call 
  ·  OperationCall a method using tail call semantics
  ·  Format
prefix
tail_call
mptr
  ·  Direct Format
{tail_call}
mptr
  ·  Forms tail_call = 255, 22 (0xFF, 0x16)
   · Description This instruction is identical to call, except that it performs a tail-optimized call to the method identified by mptr.


 tail_calli 
  ·  OperationCall a method using indirect tail call semantics
  ·  Format
prefix
tail_calli
  ·  Direct Format
{tail_calli}
  ·  Forms tail_calli = 255, 23 (0xFF, 0x17)
   · Description This instruction is identical to calli, except that it performs a tail-optimized call.


 tail_callintf 
  ·  OperationCall an interface method using tail call semantics
  ·  Format
prefix
tail_callintf
N[1]
M[1]
cptr
  ·  Direct Format
{tail_callintf}
N
M
cptr
  ·  Forms tail_callintf = 255, 25 (0xFF, 0x19)
   · Description The tail_callintf instruction is identical to call_interface, except that it uses tail call semantics.


 tail_callvirt 
  ·  OperationCall a virtual method using tail call semantics
  ·  Format
prefix
tail_callvirt
N[1]
M[1]
  ·  Direct Format
{tail_callvirt}
N
M
  ·  Forms tail_callvirt = 255, 24 (0xFF, 0x18)
   · Description The tail_callvirt instruction is identical to call_virtual, except that it uses tail call semantics.


 waddr_native_<n> 
  ·  OperationSet position n of the native argument buffer to the address of a local variable
  ·  Format
waddr_native_<n>
V[1]
wide
waddr_native_<n>
V[4]
  ·  Direct Format
{waddr_native_<n>}
V
  ·  Forms waddr_native_m1 = 241 (0xF1)
waddr_native_0 = 242 (0xF2)
waddr_native_1 = 243 (0xF3)
waddr_native_2 = 244 (0xF4)
waddr_native_3 = 245 (0xF5)
waddr_native_4 = 246 (0xF6)
waddr_native_5 = 247 (0xF7)
waddr_native_6 = 248 (0xF8)
waddr_native_7 = 249 (0xF9)
   · Description Set position n of the native argument buffer to the address of local variable V. For an "InternalCall" method, 0 is the first argument. For a "PInvoke" method, -1 (m1) is the first argument.


 waddr_native_n 
  ·  OperationSet position n of the native argument buffer to the address of a local variable
  ·  Format
prefix
waddr_native_n
N[4]
V[4]
  ·  Direct Format
{waddr_native_n}
N
V
  ·  Forms waddr_native_n = 255, 95 (0xFF, 0x5F)
   · Description Set position N of the native argument buffer to the address of local variable V. For an "InternalCall" method, 0 is the first argument. For a "PInvoke" method, -1 (m1) is the first argument.


Copyright © Southern Storm Software Pty Ltd 2002
Licensed under GNU FDL