Skip to content

Latest commit

 

History

History
27 lines (15 loc) · 1.69 KB

iii.4.4-cpobj.md

File metadata and controls

27 lines (15 loc) · 1.69 KB

III.4.4 cpobj – copy a value from one address to another

Format Assembly Format Description
70 <T> cpobj typeTok Copy a value type from src to dest.

Stack Transition:

…, dest, src → …,

Description:

The cpobj instruction copies the value at the address specified by src (an unmanaged pointer, native int, or a managed pointer, &) to the address specified by dest (also a pointer). typeTok can be a typedef, typeref, or typespec. The behavior is unspecified if the type of the location referenced by src is not assignable-toI.8.7.3) the type of the location referenced by dest. If typeTok is a reference type, the cpobj instruction has the same effect as ldind.ref followed by stind.ref.

Exceptions:

System.NullReferenceException can be thrown if an invalid address is detected.

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

Correctness:

typeTok shall be a valid typedef, typeref, or typespec metadata token.

Verifiability:

The tracked types of the destination (dest) and source (src) values shall both be managed pointers (&) to values whose types we denote destType and srcType, respectively. Finally, srcType shall be assignable-toI.8.7.3) typeTok, and typeTok shall be assignable-toI.8.7.3) destType. In the case of an Enum, its type is that of the underlying, or base, type of the Enum.