Yeah, you can chain them to make polymorphic ICs (all JS engines do this). Can you use PGO to determine which call sites are hot?
-
-
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…
2 replies 0 retweets 1 like -
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 -
Type specialization would be a far less profitable optimization in ObjC than it is in JS because methods already take fundamental types as concrete, unboxed values.
1 reply 0 retweets 0 likes -
Replying to @pathofshrines @pcwalton and
And ICs are about *dynamically* avoiding dispatch overhead, which can’t lead to specialization and inlining unless you have a JIT.
2 replies 0 retweets 0 likes
-
-
That optimization is called speculative devirtualization, not inline caching.
1 reply 0 retweets 0 likes -
Inline caching is a form of speculative devirtualization. The devirtualized method is a single “call IMP” instruction :)
1 reply 0 retweets 0 likes - 2 more replies
New conversation -
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.