内联函数
作者:互联网
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.ProgramIL中间语言
以下不是内联函数
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