mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 16:30:41 +00:00
Initial pass at implementing fully Apple-compatible GC. This requires the code to be built with -fobjc-gc or -fobjc-gc-only, and requires a runtime that implements all of the support functions (GNUstep runtime trunk or 1.5 when it's release).
Currently, there are a few places where we should be calling NSAllocateCollectable() without NSScannedOption, but are actually calling NSZoneMalloc() unless we're in GC mode. We should not need separate code paths for this anywhere outside NSZone, since NSAllocateCollectable() will work in non-GC mode as well. A few of the changes should be tweaked slightly so that they do run-time tests. For example, when compiling with -fobjc-gc, we may be linked against non-GC code, which will use -retain and -release but won't use the memory barriers. Supporting this nicely is a lot of effort, and I'm not fully convinced it's a good idea. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@33104 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
d9f4c65624
commit
9c75389ee7
7 changed files with 241 additions and 14 deletions
|
@ -125,7 +125,7 @@ BOOL NSDeallocateZombies = NO;
|
|||
static Class zombieClass = Nil;
|
||||
static NSMapTable *zombieMap = 0;
|
||||
|
||||
#if !GS_WITH_GC
|
||||
#if !GS_WITH_GC && !__OBJC_GC__
|
||||
static void GSMakeZombie(NSObject *o)
|
||||
{
|
||||
Class c;
|
||||
|
@ -414,7 +414,7 @@ typedef struct obj_layout *obj;
|
|||
BOOL
|
||||
NSDecrementExtraRefCountWasZero(id anObject)
|
||||
{
|
||||
#if !GS_WITH_GC
|
||||
#if !GS_WITH_GC && !__OBJC_GC__
|
||||
if (double_release_check_enabled)
|
||||
{
|
||||
NSUInteger release_count;
|
||||
|
@ -504,7 +504,7 @@ NSExtraRefCount(id anObject)
|
|||
inline void
|
||||
NSIncrementExtraRefCount(id anObject)
|
||||
{
|
||||
#if GS_WITH_GC
|
||||
#if GS_WITH_GC || __OBJC_GC__
|
||||
return;
|
||||
#else /* GS_WITH_GC */
|
||||
if (allocationLock != 0)
|
||||
|
@ -594,7 +594,32 @@ callCXXConstructors(Class aClass, id anObject)
|
|||
* depending on what information (if any) we are storing before
|
||||
* the start of each object.
|
||||
*/
|
||||
#if GS_WITH_GC
|
||||
#if __OBJC_GC__
|
||||
|
||||
inline NSZone *
|
||||
GSObjCZone(NSObject *object)
|
||||
{
|
||||
return NSDefaultMallocZone();
|
||||
}
|
||||
|
||||
inline id
|
||||
NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone)
|
||||
{
|
||||
id new = class_createInstance(aClass, extraBytes);
|
||||
if (0 == cxx_construct)
|
||||
{
|
||||
cxx_construct = sel_registerName(".cxx_construct");
|
||||
cxx_destruct = sel_registerName(".cxx_destruct");
|
||||
}
|
||||
callCXXConstructors(aClass, new);
|
||||
return new;
|
||||
}
|
||||
|
||||
inline void
|
||||
NSDeallocateObject(id anObject)
|
||||
{
|
||||
}
|
||||
#elif GS_WITH_GC
|
||||
|
||||
inline NSZone *
|
||||
GSObjCZone(NSObject *object)
|
||||
|
@ -777,7 +802,7 @@ NSDeallocateObject(id anObject)
|
|||
BOOL
|
||||
NSShouldRetainWithZone (NSObject *anObject, NSZone *requestedZone)
|
||||
{
|
||||
#if GS_WITH_GC
|
||||
#if GS_WITH_GC || __OBJC_GC__
|
||||
return YES;
|
||||
#else
|
||||
return (!requestedZone || requestedZone == NSDefaultMallocZone()
|
||||
|
@ -1904,7 +1929,7 @@ objc_create_block_classes_as_subclasses_of(Class super);
|
|||
*/
|
||||
- (oneway void) release
|
||||
{
|
||||
#if GS_WITH_GC == 0
|
||||
#if GS_WITH_GC == 0 && !__OBJC_GC__
|
||||
if (NSDecrementExtraRefCountWasZero(self))
|
||||
{
|
||||
[self dealloc];
|
||||
|
@ -1954,7 +1979,7 @@ objc_create_block_classes_as_subclasses_of(Class super);
|
|||
*/
|
||||
- (id) retain
|
||||
{
|
||||
#if GS_WITH_GC == 0
|
||||
#if GS_WITH_GC == 0 && !__OBJC_GC__
|
||||
NSIncrementExtraRefCount(self);
|
||||
#endif
|
||||
return self;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue