Specifically, a call to objc_msgSend would have this fast path: cbz self,cache_miss ; nil check ldp type/targetcache ; compiler generates a slot ldr self->isa cmp typecache,isa bne cache_miss br targetcache
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.
-
-
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
-
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.
- 3 more replies
New conversation -
-
-
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.
-
And ICs are about *dynamically* avoiding dispatch overhead, which can’t lead to specialization and inlining unless you have a JIT.
- 5 more replies
New conversation -
-
-
Should also mention that memory usage / code size are generally prioritized over throughput in ObjC. Probably wouldn’t take a 1% system wide dirty memory regression to make objc_msgSend 50% faster, for example.
Thanks. 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.