It’s hard to believe that devirtualization is never worth it. objc_msgSend is pretty much always a BTB miss and that’s gotta hurt…
-
-
That’s not really true on newer architectures. Branch prediction with history in practice predicts msgSend fairly well
2 replies 0 retweets 2 likes -
Well enough that tricks that increase local code size or memory usage aren’t worth the systemwide costs, at least
1 reply 0 retweets 0 likes -
That would imply that JS inline caches aren't worth it. I'm skeptical, given that it's completely impossible to write a competitive JS engine without them.
3 replies 0 retweets 1 like -
In addition to all of Greg’s points, remember that a call cache in JS gets to skip more work; ObjC assumes you’re calling a method with the right signature.
1 reply 0 retweets 1 like -
Replying to @pathofshrines @pcwalton and
And the caching can do more than just devirtualization, e.g. you can devirtualize to a variant which propagates argument type information.
2 replies 0 retweets 0 likes -
You can do that in Objective-C too! Devirtualization can result in inlining, and this unlocks a whole bunch of optimizations. I think you all are really too easily dismissing a large source of optimizations.
3 replies 0 retweets 0 likes -
These things have been tried and found to be too expensive at the system level. PGO might change the game there if the workflow issues can be smoothed over, but I think ObjC code already tends to put msgSends along cold paths like API boundaries
1 reply 0 retweets 1 like -
I suspect it’d help quite a bit for the long tail of apps that aren’t carefully profiled. I see IMP caching brought up a lot, but I rarely see it actually done. objc_msgSend is a “peanut butter cost” that’s smeared over all the code. Exactly the kind of thing optzns are good at.
1 reply 0 retweets 0 likes -
Well Swift is trying to address that by letting you use the same abstractions for cheaper when you don’t have to cross an ABI boundary. These sorts of AOT optimizations are easier to justify when they can be definitive rather than speculative thanks to stricter language semantics
1 reply 0 retweets 0 likes
Agreed, Swift is a much more sensible design for AOT. Obj-C was always…weird :)
-
-
Yeah. For example, type-based devirt is a lot less powerful in ObjC than it would be in almost any other statically-typed language because of dynamic method replacement.
0 replies 0 retweets 0 likesThanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.