Skip to content

Bypass Tier0 in recursive calls #119862

@EgorBo

Description

@EgorBo

The following program works with TC=0 and fails with StackOverflowException in default (Tiered) mode:

FibRecursive(0, 1, 10000000);

long FibRecursive(long acc1, long acc2, int count) =>
    count switch
    {
        0 => acc1,
        1 => acc2,
        _ => FibRecursive(acc2, acc1 + acc2, count - 1)
    };

Since Roslyn never emits .tail prefix, I think JIT should at least catch obvious recursive calls by bypassing Tier0 and compile such methods with optimizations immediately (or emit tails even in Tier0 ?)

@dotnet/jit-contrib for opinions

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions