Skip to content

JIT doesn't inline methods contain EH code #62038

@hez2010

Description

@hez2010

Description

JIT doesn't inline methods contain EH code.

Let's say this code:

void Test()
{
	Console.WriteLine(Foo(3));
}

int Foo(int x)
{
	try
	{
		return Get(x);
	}
	catch
	{
		return 0;
	}
}

int Get(int x) => x is 1 ? throw new Exception() : x + 1;

Expected codegen for Test:

mov	ecx, 4
jmp	System.Console.WriteLine(Int32)

Actual codegen for Test:

sub	rsp, 0x28
mov	ecx, 3
call	Program.Foo(Int32)
mov	ecx, eax
add	rsp, 0x28
jmp	System.Console.WriteLine(Int32)

Note that even I added [MethodImpl(MethodImplOptions.AggressiveInlining)] on top of the method Foo, it won't be inlined either.

Configuration

.NET 6

category:cq
theme:inlining
skill-level:expert
cost:medium
impact:medium

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMItenet-performancePerformance related issue

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions