ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

内联函数

2022-06-09 14:31:25  阅读:136  来源: 互联网

标签:ConsoleApp1 函数 void Program IL 内联 method size


namespace ConsoleApp1
{
    internal class Program
    {
        static void Main(string[] args)
        {
            int a = M();

            int M()
            {
                return 1;
            }
        }
    }
}
.class private auto ansi beforefieldinit ConsoleApp1.Program
    extends [mscorlib]System.Object
{
    // Methods
    .method private hidebysig static 
        void Main (
            string[] args
        ) cil managed 
    {
        // Method begins at RVA 0x2050
        // Header size: 12
        // Code size: 9 (0x9)
        .maxstack 1
        .entrypoint
        .locals init (
            [0] int32 a
        )

        IL_0000: nop
        IL_0001: call int32 ConsoleApp1.Program::'<Main>g__M|0_0'()
        IL_0006: stloc.0
        IL_0007: nop
        IL_0008: ret
    } // end of method Program::Main

    .method public hidebysig specialname rtspecialname 
        instance void .ctor () cil managed 
    {
        // Method begins at RVA 0x2065
        // Header size: 1
        // Code size: 8 (0x8)
        .maxstack 8

        IL_0000: ldarg.0
        IL_0001: call instance void [mscorlib]System.Object::.ctor()
        IL_0006: nop
        IL_0007: ret
    } // end of method Program::.ctor

    .method assembly hidebysig static 
        int32 '<Main>g__M|0_0' () cil managed 
    {
        .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = (
            01 00 00 00
        )
        // Method begins at RVA 0x2070
        // Header size: 12
        // Code size: 7 (0x7)
        .maxstack 1
        .locals init (
            [0] int32
        )

        IL_0000: nop
        IL_0001: ldc.i4.1
        IL_0002: stloc.0
        IL_0003: br.s IL_0005

        IL_0005: ldloc.0
        IL_0006: ret
    } // end of method Program::'<Main>g__M|0_0'

} // end of class ConsoleApp1.Program
IL中间语言

以下不是内联函数

namespace ConsoleApp1
{
    internal class Program
    {
        static void Main(string[] args)
        {
            int a = M();
        }

        static int M()
        {
            return 1;
        }
    }
}
不是内联函数
.namespace ConsoleApp1
{
    .class private auto ansi beforefieldinit ConsoleApp1.Program
        extends [mscorlib]System.Object
    {
        // Methods
        .method private hidebysig static 
            void Main (
                string[] args
            ) cil managed 
        {
            // Method begins at RVA 0x2050
            // Header size: 12
            // Code size: 8 (0x8)
            .maxstack 1
            .entrypoint
            .locals init (
                [0] int32 a
            )

            IL_0000: nop
            IL_0001: call int32 ConsoleApp1.Program::M()
            IL_0006: stloc.0
            IL_0007: ret
        } // end of method Program::Main

        .method private hidebysig static 
            int32 M () cil managed 
        {
            // Method begins at RVA 0x2064
            // Header size: 12
            // Code size: 7 (0x7)
            .maxstack 1
            .locals init (
                [0] int32
            )

            IL_0000: nop
            IL_0001: ldc.i4.1
            IL_0002: stloc.0
            IL_0003: br.s IL_0005

            IL_0005: ldloc.0
            IL_0006: ret
        } // end of method Program::M

        .method public hidebysig specialname rtspecialname 
            instance void .ctor () cil managed 
        {
            // Method begins at RVA 0x2077
            // Header size: 1
            // Code size: 8 (0x8)
            .maxstack 8

            IL_0000: ldarg.0
            IL_0001: call instance void [mscorlib]System.Object::.ctor()
            IL_0006: nop
            IL_0007: ret
        } // end of method Program::.ctor

    } // end of class ConsoleApp1.Program

}
IL中间语言

 

标签:ConsoleApp1,函数,void,Program,IL,内联,method,size
来源: https://www.cnblogs.com/yangmengke2018/p/16359211.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有