On Jun 8, 2008, at 10:03 PM, John Engelhart wrote:

The result from [data self] is invariant, it does not matter if it is executed immediately after the object is instantiated or just before [data release], the result is always the same.

There is no way in the Objective-C language as it currently stands that the compiler can make that assumption.

Since -(id)self causes no side effects, and the result of which is presumably unused in our hypothetical example, the statement accomplishes no real work and can be eliminated.

The compiler has no intimate knowledge of what the -self message actually represents, and *cannot* make that optimization, without substantial extension to the semantics of Objective-C.

The compiler -- as it currently is -- MUST emit a call to one of the objc_msgSend* functions for EVERY message expression it sees, without re-ordering them, due to the semantics of the language.

If Objective-C *is* ever extended to support a construct like __attribute__((const)) on methods, it must do so in a way that is both binary- and source-compatible with existing code. Hence you're taking a purely-hypothetical language construct and extrapolating a problem that wouldn't be allowed due to

Use of interior pointers in a garbage collected system is hard to get right, especially when the garbage collection is concurrent/threaded. That doesn't mean, however, that Objective-C garbage collection in Leopard is inherently flawed or that it should be avoided: It works quite well both theoretically and in practice, and it supports the development of large and well-performing applications.

  -- Chris

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to