Skip to content

Latest commit

 

History

History
25 lines (14 loc) · 1.48 KB

iii.4.19-mkrefany.md

File metadata and controls

25 lines (14 loc) · 1.48 KB

III.4.19 mkrefany – push a typed reference on the stack

Format Assembly Format Description
C6 <T> mkrefany class Push a typed reference to ptr of type class onto the stack.

Stack Transition:

…, ptr → …, typedRef

Description:

The mkrefany instruction supports the passing of dynamically typed references. ptr shall be a pointer (type &, or native int) that holds the address of a piece of data. class is the class token (a typeref, typedef or typespec; see Partition II) describing the type of ptr. mkrefany pushes a typed reference on the stack, that is an opaque descriptor of ptr and class. This instruction enables the passing of dynamically typed references as arguments. The callee can use the refanytype and refanyval instructions to retrieve the type (class) and address (ptr) respectively of the parameter.

Exceptions:

System.TypeLoadException is thrown if class cannot be found. This is typically detected when CIL is converted to native code rather than at runtime.

Correctness:

Correct CIL ensures that class is a valid typeref or typedef or typespec token describing some type and that ptr is a pointer to exactly that type.

Verifiability:

Verification additionally requires that ptr be a managed pointer. Verification will fail if it cannot deduce that ptr is a pointer to an instance of class.