Skip to content

NoTailCall option #3732

Closed
Closed

Description

@daurnimator

Originally from #2598

I just recalled something from https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66826

Now dlsym (and other dl-functions) secretly take shadow parameter - return address on stack

We need a way to ensure that a given call is not a tail call.

LLVM does have a notail option

Activity

  1. daurnimator commented on Nov 20, 2019

    @daurnimator
    ContributorAuthor

    To avoid proliferation of @inlineCall/@noInlineCall/@newStackCall/@noTailCall, etc.
    I propose a @call builtin that takes a structure of options:

    const Maybe = enum {
        Default,
        Always,
        Never,
    };
    @call(comptime options: struct {
        tailCall: Maybe = .Default,
        inlineCall: Maybe = .Default,
        newStack: ?[]align(target_stack_align) u8 = null,
    }, function: var, args: ...);
  2. added
    proposal
    on Nov 20, 2019
  3. added this to the 0.6.0 milestone on Nov 20, 2019
  4. emekoi commented on Nov 20, 2019

    @emekoi
    Contributor

    perhaps asyncCall could be merged with this?

  5. fengb commented on Nov 20, 2019

    @fengb
    Contributor

    How about just 1 argument?

     @call(.{
        .tailCall = false,
        .func = myFunc,
        .args = .{ false, 1, "three" })
    });
  6. daurnimator commented on Nov 20, 2019

    @daurnimator
    ContributorAuthor

    How about just 1 argument?

    I think this looks harder to use. Also the call type needs to be comptime known, while the function and arguments can be runtime known.

  7. daurnimator commented on Nov 22, 2019

    @daurnimator
    ContributorAuthor

    Your code example is missing the handle to the function itself,

    Fixed.

    and if we are getting rid of var args (#208) then the args argument should be a var which is filled using anonymous literal syntax. That would end up looking like this:

    const result = @call(myFunc, .{ .tailCall = false }, .{ false, 1, "three" });

    Builtins don't need to follow the rest of the language like this: they aren't normal functions. see e.g. @field

  8. added
    accepted
    on Dec 4, 2019
  9. added a commit that references this issue on Dec 6, 2019
    1f602fe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    acceptedproposal

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions