gnustep-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [GDL2] NSAutoreleasePool/EOFault


From: Richard Frith-Macdonald
Subject: Re: [GDL2] NSAutoreleasePool/EOFault
Date: Sun, 13 Mar 2005 06:16:29 +0000

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 2005-03-12 20:43:15 +0000 David Ayers <address@hidden> wrote:


But back to NSAutoreleasePool, it currently uses GSObjCClass which will give it the EOFault class. If it would have used -class, it would have obtained the object's class. In this case EOFault is indeed preferable as it intends get the faults implementation of release and invoke it. If this release happens to dealloc the object, the fault will be cleared and dealloc is then called with the original isa. So I guess we're safe.

I think I'll add some comments in NSAutoreleasePool explaining that GSObjCClass is actually not merely a performance issue but that sending -class would break GDL2.

I'm not too worried about losing the implemenation caching in
NSAutoreleasePool if it helps ... it's not a big optimisation, and using
- -class rather than GSObjCClass() would make the caching pointless (so nobody
is going to change it to use -class regasrdless of comments in the code).

However, the issue is a bit of a worry ... implementation caching is a
common optimisation technique, and I was actually a little concerned about
using  GSObjCClass() rather than -class, since doing so gives the object no
chance to return another class, and hence provide the 'correct'
implementation of -release for the particular instance.
That being said, accessing the 'isa' ivar of the class directly (pretty much
what GSObjCClass() does) is also a common optimisation technique, and as in
the NSAutoreleasePool case there is often no point caching a method
implementation if you are then going to have the method dispatch overhead of
calling -class, so I think the two teqhniques are commonly used together and
class implementations should expect that.

Given the lack of clarity about this ... would it be a good idea to produce
guidelines to say that, where caching method implementations, we should use
GSObjCClass() in conjunction with -instanceMethodForSelector:, and that
classes should be written expecting this sort of thing to be done?

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)
Comment: Using the GPG bundle for GNUMail

iD8DBQFCM9q9E6AJp3nmKIkRAtB6AKCgaTPCms/NISokZSbNrTNp/phMjgCguMAl
LrDm2ynhGMSFvw1N9d3lkqY=
=XPZM
-----END PGP SIGNATURE-----





reply via email to

[Prev in Thread] Current Thread [Next in Thread]