Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement portable tailcall helpers #341

Merged
merged 42 commits into from
Apr 28, 2020

Commits on Nov 27, 2019

  1. Implement portable tailcall helpers

    This implements tailcall-via-help support for all platforms supported by
    the runtime. In this new mechanism the JIT asks the runtime for help
    whenever it realizes it will need a helper to perform a tailcall, i.e.
    when it sees an explicit tail. prefixed call that it cannot make into a
    fast jump-based tailcall.
    
    The runtime created two important IL stubs to help the JIT in performing
    the necessary tailcalls. One IL stub is used to store the args for the
    tailcall, while the other is used to dispatch the actual tailcall
    itself. The JIT will then transform the call from
    
    return tail. F(a1, ..., an);
    
    to
    
    IL_STUB_StoreTailCallArgs(a1, ..., an);
    T result;
    IL_STUB_DispatchTailCalls(..., &result);
    return result;
    
    The dispatcher is written in such a way that it is able to dispatch
    multiple tailcalls in a row when tailcalled functions also perform
    tailcalls. To do this, the JIT helps the dispatcher detect if the
    caller's caller is also a dispatcher. When this is the case the
    dispatcher returns to let the previous dispatcher perform the tailcall
    with the currently stored args. This allows the frame to unwind and
    ensures that sequences of tailcalls do not grow the stack more than by a
    constant factor.
    
    Due to this unwinding the args cannot be stored on the stack and are
    instead stored in TLS. The GC is made specially of this buffer as the
    args can be anything, including interior pointers.
    
    The control-flow when performing the new tailcalls is nonstandard, so
    this also changes the debugger to support proper stepping into/over/out
    of tailcalled functions when they go through the new dispatcher.
    
    x86's tailcalling mechanism does not change.
    jakobbotsch committed Nov 27, 2019
    Configuration menu
    Copy the full SHA
    cc45a0e View commit details
    Browse the repository at this point in the history
  2. Fix build

    jakobbotsch committed Nov 27, 2019
    Configuration menu
    Copy the full SHA
    62a0134 View commit details
    Browse the repository at this point in the history

Commits on Feb 5, 2020

  1. Configuration menu
    Copy the full SHA
    b6af537 View commit details
    Browse the repository at this point in the history

Commits on Mar 3, 2020

  1. Address some feedback

    jakobbotsch committed Mar 3, 2020
    Configuration menu
    Copy the full SHA
    de7608a View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    c121e9e View commit details
    Browse the repository at this point in the history
  3. Fix some bad merges

    jakobbotsch committed Mar 3, 2020
    Configuration menu
    Copy the full SHA
    442f186 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    f21b9c6 View commit details
    Browse the repository at this point in the history
  5. Undo unnecessary change

    jakobbotsch committed Mar 3, 2020
    Configuration menu
    Copy the full SHA
    2671b74 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    0406cbb View commit details
    Browse the repository at this point in the history

Commits on Mar 5, 2020

  1. Address feedback

    jakobbotsch committed Mar 5, 2020
    Configuration menu
    Copy the full SHA
    08a44e4 View commit details
    Browse the repository at this point in the history

Commits on Mar 6, 2020

  1. Fix uses of TARGET macros.

    erozenfeld authored and jakobbotsch committed Mar 6, 2020
    Configuration menu
    Copy the full SHA
    0b7e464 View commit details
    Browse the repository at this point in the history

Commits on Mar 7, 2020

  1. Configuration menu
    Copy the full SHA
    46a869b View commit details
    Browse the repository at this point in the history

Commits on Mar 8, 2020

  1. Configuration menu
    Copy the full SHA
    f43b6a2 View commit details
    Browse the repository at this point in the history

Commits on Mar 10, 2020

  1. Configuration menu
    Copy the full SHA
    710f7a2 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    6af504a View commit details
    Browse the repository at this point in the history

Commits on Mar 11, 2020

  1. Configuration menu
    Copy the full SHA
    ad93d07 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    565833f View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    13c9e22 View commit details
    Browse the repository at this point in the history

Commits on Mar 13, 2020

  1. Configuration menu
    Copy the full SHA
    2209664 View commit details
    Browse the repository at this point in the history

Commits on Mar 14, 2020

  1. Configuration menu
    Copy the full SHA
    6081e53 View commit details
    Browse the repository at this point in the history
  2. Fix formatting.

    erozenfeld committed Mar 14, 2020
    Configuration menu
    Copy the full SHA
    a508947 View commit details
    Browse the repository at this point in the history

Commits on Mar 16, 2020

  1. Configuration menu
    Copy the full SHA
    4801b25 View commit details
    Browse the repository at this point in the history

Commits on Mar 21, 2020

  1. Merge branch 'master' of https://github.com/dotnet/runtime

    # Conflicts:
    #	src/coreclr/src/inc/corinfo.h
    #	src/coreclr/src/jit/morph.cpp
    #	src/coreclr/src/tools/Common/JitInterface/CorInfoBase.cs
    #	src/coreclr/src/tools/crossgen2/jitinterface/jitwrapper.cpp
    erozenfeld committed Mar 21, 2020
    Configuration menu
    Copy the full SHA
    29f2832 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    03256b6 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    bd4fe1b View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    cc36784 View commit details
    Browse the repository at this point in the history

Commits on Mar 22, 2020

  1. Configuration menu
    Copy the full SHA
    84bd83e View commit details
    Browse the repository at this point in the history

Commits on Mar 31, 2020

  1. Merge branch 'master' of https://github.com/dotnet/runtime

    # Conflicts:
    #	src/coreclr/src/inc/corinfo.h
    #	src/coreclr/src/tools/Common/JitInterface/CorInfoBase.cs
    #	src/coreclr/src/tools/crossgen2/jitinterface/jitwrapper.cpp
    erozenfeld committed Mar 31, 2020
    Configuration menu
    Copy the full SHA
    bcd44da View commit details
    Browse the repository at this point in the history
  2. Expand only required intrinsics in methods that call NextCallReturnAd…

    …dress.
    
    This mitigates cases where the tail call caller is not optimized
    (e.g., when it's a static constructor) and a tail-prefixed intrinsic
    is not expanded and then IL_STUB_CallTailCallTarget is optimized
    and the intrinsic is expanded. In that case codegen for
    NextCallReturnAddress is confused since there is no call.
    erozenfeld committed Mar 31, 2020
    Configuration menu
    Copy the full SHA
    b1d2b41 View commit details
    Browse the repository at this point in the history

Commits on Apr 13, 2020

  1. Merge branch 'master' of https://github.com/dotnet/runtime

    # Conflicts:
    #	src/coreclr/tests/issues.targets
    erozenfeld committed Apr 13, 2020
    Configuration menu
    Copy the full SHA
    bd8415b View commit details
    Browse the repository at this point in the history
  2. Change lowering of GT_LABEL on arm.

    Generate movw/movt instead of adr on arm. adr on arm allows offsets
    up to 4k, which may not be enough. In particular,
    IL_STUB_CallTailCallTarget uses GT_LABEL before argument setup code
    and it can be more than 4k.
    erozenfeld committed Apr 13, 2020
    Configuration menu
    Copy the full SHA
    4219e96 View commit details
    Browse the repository at this point in the history
  3. Add COMPlus_FastTailCalls environment variable.

    COMPlus_FastTailCalls controls whether fast tail calls are allowed.
    If COMPlus_FastTailCalls is 0, fast tail calls are not allowed even for
    tail-prefixed calls. Only helper-based calls are allowed. This is useful
    for testing helper-based calls.
    erozenfeld committed Apr 13, 2020
    Configuration menu
    Copy the full SHA
    564b089 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    f3d9f09 View commit details
    Browse the repository at this point in the history

Commits on Apr 21, 2020

  1. Merge branch 'master' of https://github.com/dotnet/runtime

    # Conflicts:
    #	src/coreclr/src/jit/lower.cpp
    erozenfeld committed Apr 21, 2020
    Configuration menu
    Copy the full SHA
    28878a8 View commit details
    Browse the repository at this point in the history
  2. Fix the type of IL_STUB_StoreTailCallArgs this parameter.

    When we have an indirect tail call, we may not be able
    to figure out the target MethodDesc so we need to
    use the type of the caller's 'this` argument to get the
    correct type of the callee's this parameter.
    
    Without this fix we were passing a `byref` as 'this' argument to
    `IL_STUB_StoreTailCallArgs`, whose `this` parameter was typed as
    `ref`. This lead to validation failures during GC. With the fix we
    correctly set the type of the stub's `this` parameter as `byref`.
    erozenfeld committed Apr 21, 2020
    Configuration menu
    Copy the full SHA
    8b641b1 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    47030d2 View commit details
    Browse the repository at this point in the history

Commits on Apr 22, 2020

  1. Configuration menu
    Copy the full SHA
    8fc501c View commit details
    Browse the repository at this point in the history
  2. Merge branch 'master' of https://github.com/dotnet/runtime

    # Conflicts:
    #	src/coreclr/tests/issues.targets
    erozenfeld committed Apr 22, 2020
    Configuration menu
    Copy the full SHA
    fb3d883 View commit details
    Browse the repository at this point in the history

Commits on Apr 24, 2020

  1. Configuration menu
    Copy the full SHA
    3ac5187 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    20138ab View commit details
    Browse the repository at this point in the history

Commits on Apr 25, 2020

  1. Address feedback

    jakobbotsch committed Apr 25, 2020
    Configuration menu
    Copy the full SHA
    be718ba View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    f1e5638 View commit details
    Browse the repository at this point in the history