Re: Garbage collector vs variable lifetime
Re: Garbage collector vs variable lifetime
- Subject: Re: Garbage collector vs variable lifetime
- From: Quincey Morris <email@hidden>
- Date: Sat, 7 Jun 2008 23:24:03 -0700
On Jun 7, 2008, at 17:23, Bill Bumgarner wrote:
As well, if foo / bar fall in a register, then those registers would
have to be preserved for all of the while loop, too, either by not
being available to the bulk of the program (which raises some
serious codegen issues) or being moved out/in the registers every
time one of the funcs in the while loop is called or returns.
The realities of register allocation are a strong enough reason to let
the compiler go on optimizing variable lifetimes the way it does now.
Fine. Moving on from there, the consequence is that -[NSData bytes]
and -[NSMutableData mutableBytes] start looking very dangerous, and at
the same time high profile from a coding point of view.
As Michael Ash has also been suggesting, the danger would be
eliminated if the pointers returned by bytes/mutableBytes were also GC-
references -- meaning that they were recognized by the GC as keeping
something or other alive so that their pointer values remain valid.
This might be done by having them point to collectable blocks, or by
enhancing the GC to recognize them in some other way, the exact
methodology being an implementation detail.
I know you are reluctant to engage in useless speculation, but I
wonder if you know a reason why bytes/mutableBytes pointers should not
or could not be GC-references in this possibly expanded sense. Such a
change would simply solve the entire problem out of hand.
_______________________________________________
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