Remove the zone pointer from objects. Now we always query the zones to find the relevant pointer. Zones are still supported, but we now optimise for the case where they are not used.

To disable zone support completely, NSAllocateObject() should ignore the zone and NSDeallocateObject() should skip the zone lookup.



git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@33610 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
David Chisnall 2011-07-23 12:19:19 +00:00
parent 018fab87bd
commit 40456f7787

View file

@ -409,7 +409,6 @@ static inline NSLock *GSAllocationLockForObject(id p)
* (before the start) in each object.
*/
typedef struct obj_layout_unpadded {
NSZone *zone;
NSUInteger retained;
} unp;
#define UNP sizeof(unp)
@ -420,7 +419,6 @@ typedef struct obj_layout_unpadded {
* structure correct.
*/
struct obj_layout {
NSZone *zone;
NSUInteger retained;
char padding[ALIGN - ((UNP % ALIGN) ? (UNP % ALIGN) : ALIGN)];
};
@ -770,7 +768,7 @@ GSObjCZone(NSObject *object)
GSOnceFLog(@"GSObjCZone() is deprecated ... use -zone instead");
if (object_getClass(object) == NSConstantStringClass)
return NSDefaultMallocZone();
return ((obj)object)[-1].zone;
return NSZoneFromPointer(object);
}
#endif
@ -818,7 +816,6 @@ NSAllocateObject (Class aClass, NSUInteger extraBytes, NSZone *zone)
if (new != nil)
{
memset (new, 0, size);
((obj)new)->zone = zone;
new = (id)&((obj)new)[1];
object_setClass(new, aClass);
AADD(aClass, new);
@ -861,7 +858,7 @@ NSDeallocateObject(id anObject)
if ((anObject != nil) && !class_isMetaClass(aClass))
{
obj o = &((obj)anObject)[-1];
NSZone *z = o->zone;
NSZone *z = NSZoneFromPointer(o);
/* Call the default finalizer to handle C++ destructors.
*/
@ -2160,7 +2157,7 @@ static id gs_weak_load(id obj)
*/
return NSDefaultMallocZone();
#else
return (((obj)self)[-1]).zone;
return NSZoneFromPointer(self);
#endif
}