OpCodes.Localloc OpCodes.Localloc OpCodes.Localloc OpCodes.Localloc Field


从本地动态内存池分配特定数目的字节并将第一个分配的字节的地址(瞬态指针, 类型)推送到计算堆栈上。Allocates a certain number of bytes from the local dynamic memory pool and pushes the address (a transient pointer, type ) of the first allocated byte onto the evaluation stack.

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



下表列出了指令的十六进制和 Microsoft 中间语言(MSIL)程序集格式以及简短的参考摘要: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
FE 0FFE 0F localloclocalloc 从本地堆中分配空间。Allocate space from the local heap.

堆栈转换行为顺序如下:The stack transitional behavior, in sequential order, is:

  1. 要分配的字节数将被推送到堆栈上。The number of bytes to be allocated is pushed onto the stack.

  2. 从堆栈中弹出字节数;与该大小相对应的内存量从本地堆中分配。The number of bytes is popped from the stack; an amount of memory corresponding to the size is allocated from the local heap.

  3. 指向分配的内存的第一个字节的指针被推送到堆栈上。A pointer to the first byte of the allocated memory is pushed onto the stack.

@No__t-0 指令从本地动态内存池分配 @no__t (类型 natural unsigned int)字节,并返回第一个分配的字节的地址(瞬态指针,类型 *)。The localloc instruction allocates size (type natural unsigned int) bytes from the local dynamic memory pool and returns the address (a transient pointer, type *) of the first allocated byte. 仅当方法的 initialize 标志 @no__t 为0时,返回的内存块才初始化为0。The block of memory returned is initialized to 0 only if the initialize flag on the method is true. 当前方法执行 Ret 时,本地内存池可供重复使用。When the current method executes a Ret, the local memory pool is made available for reuse.

生成的地址是对齐的,以便可以使用 @no__t 0 指令(如 @no__t)将任何基元数据类型存储在此处,并使用 ldind 指令(如 Ldind_I4)进行加载。The resulting address is aligned so that any primitive data type can be stored there using the stind instructions (such as Stind_I4) and loaded using the ldind instructions (such as Ldind_I4).

@No__t-0 指令不能出现在 filtercatchfinally 或 @no__t 的块内。The localloc instruction cannot occur within a filter, catch, finally, or fault block.

如果内存不足,无法为请求提供服务,则会引发 StackOverflowExceptionStackOverflowException is thrown if there is insufficient memory to service the request.

以下 @no__t 0 方法重载可以使用 @no__t 操作码:The following Emit method overload can use the localloc opcode:

  • ILGenerator.Emit(OpCode)ILGenerator.Emit(OpCode)