• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Future of Cocoa
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Future of Cocoa


  • Subject: Re: Future of Cocoa
  • From: Saagar Jha via Cocoa-dev <email@hidden>
  • Date: Wed, 20 Nov 2019 17:21:26 -0800

Oh, I guess I didn’t explain what I was talking about well. I’m saying that the
compiler would do a full method inline but put it behind a check to see if it’s
legal to continue executing. For example, code like this:

@interface Foo
- (void)bar;
@end

// Another method in some random class
- (void)baz {
        Foo *foo = // whatever
        [foo bar];
}

would end up being compiled to something like this:

- (void)baz {
        Foo *foo = // whatever
        if (bar_is_unswizzled()) {
                // Inlined version of -[Foo bar]
        } else {
                // Fall back to going through objc_msgSend
        }
}

where bar_is_unswizzled() is some sort of runtime check that makes sure that
the actual target is what we had thought it’d be at compile time. I’d hope that
a branch predictor would be able to do a pretty good job on this considering
that the guessing “true” would work 99% of the time.

Saagar Jha

> On Nov 20, 2019, at 17:01, Jens Alfke <email@hidden> wrote:
>
>
>
>> On Nov 20, 2019, at 2:46 PM, Saagar Jha <email@hidden
>> <mailto:email@hidden>> wrote:
>>
>> I am curious why this optimization went in instead of guarded speculative
>> inlining, which would let you keep dynamism.
>
> If I understand it correctly, that only 'inlines' (really caches) the
> resolved method address for the call site. That's not much of a win in Obj-C
> where method lookup is already quite fast.
>
> The real win comes with literally inlining the method at compile time.
> Link-Time Optimization allows _any_ method anywhere in the program to be
> inlined, provided the call is monomorphic. And this new feature allows
> monomorphic method calls in Obj-C. This is a big win for small method like
> getters/setters, and for methods with only one call site (i.e. where you
> factor out a method for readability even though it's only used in one place.)
>
> —Jens

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Future of Cocoa
      • From: Jens Alfke via Cocoa-dev <email@hidden>
References: 
 >Future of Cocoa (From: Turtle Creek Software via Cocoa-dev <email@hidden>)
 >Re: Future of Cocoa (From: Richard Charles via Cocoa-dev <email@hidden>)
 >Re: Future of Cocoa (From: Gerald Henriksen via Cocoa-dev <email@hidden>)
 >Re: Future of Cocoa (From: Jean-Daniel via Cocoa-dev <email@hidden>)
 >Re: Future of Cocoa (From: Jens Alfke via Cocoa-dev <email@hidden>)
 >Re: Future of Cocoa (From: Saagar Jha via Cocoa-dev <email@hidden>)
 >Re: Future of Cocoa (From: Jens Alfke via Cocoa-dev <email@hidden>)

  • Prev by Date: Re: Future of Cocoa
  • Next by Date: Re: Future of Cocoa
  • Previous by thread: Re: Future of Cocoa
  • Next by thread: Re: Future of Cocoa
  • Index(es):
    • Date
    • Thread