• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Garbage collector vs variable lifetime
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Garbage collector vs variable lifetime


  • Subject: Re: Garbage collector vs variable lifetime
  • From: Chris Hanson <email@hidden>
  • Date: Mon, 09 Jun 2008 03:33:06 -0700

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 (email@hidden)

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:
This email sent to email@hidden


References: 
 >Garbage collector vs variable lifetime (From: Quincey Morris <email@hidden>)
 >Re: Garbage collector vs variable lifetime (From: Ken Thomases <email@hidden>)
 >Re: Garbage collector vs variable lifetime (From: Bill Bumgarner <email@hidden>)
 >Re: Garbage collector vs variable lifetime (From: Ken Thomases <email@hidden>)
 >Re: Garbage collector vs variable lifetime (From: "Michael Ash" <email@hidden>)
 >Re: Garbage collector vs variable lifetime (From: "Hamish Allan" <email@hidden>)
 >Re: Garbage collector vs variable lifetime (From: "Michael Ash" <email@hidden>)
 >Re: Garbage collector vs variable lifetime (From: "Hamish Allan" <email@hidden>)
 >Re: Garbage collector vs variable lifetime (From: "Michael Ash" <email@hidden>)
 >Re: Garbage collector vs variable lifetime (From: "Hamish Allan" <email@hidden>)
 >Re: Garbage collector vs variable lifetime (From: "Michael Ash" <email@hidden>)
 >Re: Garbage collector vs variable lifetime (From: John Engelhart <email@hidden>)

  • Prev by Date: Re: crash in outlineView:isGroupItem:
  • Next by Date: Filling screen under menu bar and above dock
  • Previous by thread: Re: Garbage collector vs variable lifetime
  • Next by thread: Re: Garbage collector vs variable lifetime
  • Index(es):
    • Date
    • Thread