[Top][All Lists]

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

Re: [GDL2] NSAutoreleasePool/EOFault

From: David Ayers
Subject: Re: [GDL2] NSAutoreleasePool/EOFault
Date: Mon, 14 Mar 2005 20:07:14 +0100
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041217

Manuel Guesdon wrote:

Another idea is to return NULL in (instance)methodForSelector: to tell the caller should not use imp or cache the method.
It should be clean and safe isn't it ?
The drawback is that callers should verify returned IMP and handle the case...

I'm not sure which is worse here. I think most developers may check with respondsToSelector: before caching the IMP but I doubt that they would then again check (instance)methodForSelector:. And even if they did and tested all this against non-faulted object, the object can be faulted again by virtue of some indirect invalidation notification. EO(Fault)s and implementation casting simply don't work well together.

I've been trying to find some time to think about this. But I don't think we can automagically deal with both optimizations. Both have their merit but the just don't work well together. We need to support EOFaults by design in GDL2. And we should take care that we design any IMP caching optimization as EOFault tolerant as we can. But I don't think that we should skip optimizations if we can insure them to be safe.

In the case of the NSAutoreleasePool, I think we are clear as each object is tested via GSObjCClass before the release is sent. The fault will be cleared as soon as it is dealloced. This may trigger other faults to fire, but then GSObjCClass will return the real class if those faults also still happen to be in the autorelease pool.

I've only done some preliminary testing but it seems that EOF's EOFault does not implement the class method's and that sending methodForSelector: fires a fault. So EOF will also break with this scheme.

I agree with Richard, that this is all a bit worry some. But by design those two optimization simply don't work to well together. I think we could implement the EOFault class method instanceMethodForSelector: to accommodate the NSAutoreleasePool optimization, at least temporarily to unbreak GDL2. Maybe add an NSWarnLog saying. @"Returning an EOFault instance implementation pointer for selector:".

I'm still a bit unsure on how to deal with the methodForSelector: class method. But that's just because it looks like the issue seems unsolvable.


reply via email to

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