Skip to content

JIT ARM64: Funclets with "frame type 5" not handled correctly #66089

Description

@jakobbotsch

Description

Funclets with large frame sizes in functions using stackalloc use an unusual kind of frame. The JIT does not generate correct prolog code for these funclets.

Reproduction Steps

using System;
using System.Runtime.CompilerServices;

public class Program
{
    public static unsafe void Main()
    {
        int* foo = stackalloc int[30];
        try
        {
            Console.WriteLine("try");
            throw new Exception();
        }
        catch (Exception)
        {
            Console.WriteLine("catch");
            foo[0] = 10;
            ManyArgs(new Guid(foo[0], 0, 0, 0, 0, 0, 0, 0, 0, 0, 0));
        }
        Console.WriteLine("after");
    }

    [MethodImpl(MethodImplOptions.NoInlining)]
    private static void ManyArgs(
        Guid g0 = default,
        Guid g1 = default,
        Guid g2 = default,
        Guid g3 = default,
        Guid g4 = default,
        Guid g5 = default,
        Guid g6 = default,
        Guid g7 = default,
        Guid g8 = default,
        Guid g9 = default,
        Guid g10 = default,
        Guid g11 = default,
        Guid g12 = default,
        Guid g13 = default,
        Guid g14 = default,
        Guid g15 = default,
        Guid g16 = default,
        Guid g17 = default,
        Guid g18 = default,
        Guid g19 = default,
        Guid g20 = default,
        Guid g21 = default,
        Guid g22 = default,
        Guid g23 = default,
        Guid g24 = default,
        Guid g25 = default,
        Guid g26 = default,
        Guid g27 = default,
        Guid g28 = default,
        Guid g29 = default,
        Guid g30 = default,
        Guid g31 = default,
        Guid g32 = default,
        Guid g33 = default,
        Guid g34 = default,
        Guid g35 = default,
        Guid g36 = default,
        Guid g37 = default,
        Guid g38 = default,
        Guid g39 = default,
        Guid g40 = default,
        Guid g41 = default)
    {
    }
}

Expected behavior

Prints "try", "catch" and "after".

Actual behavior

"after" is not printed.

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

The JIT generates the following prolog for the funclet:

G_M27646_IG06:              ;; offset=00C0H
        F90007F3          str     x19, [sp,#8]
        A9017BFD          stp     fp, lr, [sp,#16]
        D10983FF          sub     sp, sp, #608
        910043A3          add     x3, fp, #16
        F90133E3          str     x3, [sp,#608]

This overrides caller stack with callee saves.

cc @dotnet/jit-contrib

Activity

  1. added
    area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
    on Mar 2, 2022
  2. added this to the 7.0.0 milestone on Mar 2, 2022
  3. ghost added
    untriagedNew issue has not been triaged by the area owner
    on Mar 2, 2022
  4. AndyAyersMS commented on Mar 2, 2022

    @AndyAyersMS
    Member

    Also worth noting that very large funclet frames won't do stack probing. OSR hits this in GitHub_21999 because it has to pad the funclet frame with the Tier0 frame size.

  5. removed
    untriagedNew issue has not been triaged by the area owner
    on Mar 3, 2022
  6. JulieLeeMSFT commented on May 20, 2022

    @JulieLeeMSFT
    Member

    Assigining Arm64 issues to @kunalspathak. Please redistrubte to members.

  7. BruceForstall commented on Jun 18, 2022

    @BruceForstall
    Contributor

    @kunalspathak Can I take this?

  8. kunalspathak commented on Jun 18, 2022

    @kunalspathak
    Contributor

    Sure

  9. ghost locked as resolved and limited conversation to collaborators on Jul 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

arch-arm64area-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