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:
theraven 2011-07-23 12:19:19 +00:00
parent 9dbeddeeae
commit 863fff32b7

View file

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