Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does LLVM convert Objective-C methods to inline functions?

  1. Does LLVM automatically convert Objective-C methods to inline functions when possible?

    (I.e., is it just as performant to create an Objective-C method for a block of code that you could otherwise paste inline?)

  2. If LLVM doesn't perform this optimization, why not? If it does, (a) are there certain build settings I must set for this to happen? (b) How can I tell if an Objective-C method will be inlined?

like image 826
ma11hew28 Avatar asked Nov 19 '11 13:11

ma11hew28


1 Answers

No, because its impossible to know in the context of the Obj-C runtime if those kind of optimizations can be performed. The thing to remember is that Obj-C methods are invoked by a message send, these messages can come from more than just the [myObject doSomething] syntax.

Consider [obj performSelector:NSSelectorFromString(@"hello")] the fact that this can happen means that it would be impossible to ever inline any method.

There is also a chain of events that happens when a message is received by a class, these events can reroute, or even change the message that is being sent. This happens transparently underneath the message send.

like image 120
Joshua Weinberg Avatar answered Sep 28 '22 19:09

Joshua Weinberg