You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When encoding method body header the encoder needs to decide whether to emit tiny or fat header. A small method that has no locals but contains localloc instruction and has InitLocals set to true should not be encoded with tiny header since tiny header implies InitLocals is false. The presence of localloc instruction needs to be indicated by the caller of the method body encoder similarly to max stack and other info. Hence we need to add an overload that takes an extra bool parameter.
namespaceSystem.Reflection.Metadata.Ecma335{publicreadonlystructMethodBodyStreamEncoder{// existing overloadspublicMethodBodyAddMethodBody(intcodeSize,intmaxStack,intexceptionRegionCount,boolhasSmallExceptionRegions,StandaloneSignatureHandlelocalVariablesSignature,MethodBodyAttributesattributes);publicintAddMethodBody(InstructionEncoderinstructionEncoder,intmaxStack,StandaloneSignatureHandlelocalVariablesSignature,MethodBodyAttributesattributes)// new overloads/// <summary>/// Encodes a method body and adds it to the method body stream./// </summary>/// <param name="codeSize">Number of bytes to be reserved for instructions.</param>/// <param name="maxStack">Max stack.</param>/// <param name="exceptionRegionCount">Number of exception regions.</param>/// <param name="hasSmallExceptionRegions">True if the exception regions should be encoded in 'small' format.</param>/// <param name="localVariablesSignature">Local variables signature handle.</param>/// <param name="attributes">Attributes.</param>/// <param name="hasDynamicStackAllocation">True if the method allocates from dynamic local memory pool (<c>localloc</c> instruction).</param>/// <returns>The offset of the encoded body within the method body stream.</returns>/// <exception cref="ArgumentOutOfRangeException">/// <paramref name="codeSize"/>, <paramref name="exceptionRegionCount"/>, or <paramref name="maxStack"/> is out of allowed range./// </exception>publicMethodBodyAddMethodBody(intcodeSize,intmaxStack=8,intexceptionRegionCount=0,boolhasSmallExceptionRegions=true,StandaloneSignatureHandlelocalVariablesSignature=default,MethodBodyAttributesattributes=MethodBodyAttributes.InitLocals,boolhasDynamicStackAllocation=false);/// <summary>/// Encodes a method body and adds it to the method body stream./// </summary>/// <param name="instructionEncoder">Instruction encoder.</param>/// <param name="maxStack">Max stack.</param>/// <param name="localVariablesSignature">Local variables signature handle.</param>/// <param name="attributes">Attributes.</param>/// <param name="hasDynamicStackAllocation">True if the method allocates from dynamic local memory pool (the IL contains <c>localloc</c> instruction)./// </param>/// <returns>The offset of the encoded body within the method body stream.</returns>/// <exception cref="ArgumentNullException"><paramref name="instructionEncoder"/> has default value.</exception>/// <exception cref="ArgumentOutOfRangeException"><paramref name="maxStack"/> is out of range [0, <see cref="ushort.MaxValue"/>].</exception>/// <exception cref="InvalidOperationException">/// A label targeted by a branch in the instruction stream has not been marked,/// or the distance between a branch instruction and the target label is doesn't fit the size of the instruction operand./// </exception>publicintAddMethodBody(InstructionEncoderinstructionEncoder,intmaxStack=8,StandaloneSignatureHandlelocalVariablesSignature=default,MethodBodyAttributesattributes=MethodBodyAttributes.InitLocals,boolhasDynamicStackAllocation=false)}}
The text was updated successfully, but these errors were encountered:
When encoding method body header the encoder needs to decide whether to emit tiny or fat header. A small method that has no locals but contains localloc instruction and has InitLocals set to true should not be encoded with tiny header since tiny header implies InitLocals is false. The presence of localloc instruction needs to be indicated by the caller of the method body encoder similarly to max stack and other info. Hence we need to add an overload that takes an extra bool parameter.
Addresses https://github.com/dotnet/corefx/issues/26910
Proposed API
The text was updated successfully, but these errors were encountered: