use scanned memory for arrays

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@27849 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2009-02-11 18:14:46 +00:00
parent 7201a1f33f
commit 50811ad964
3 changed files with 49 additions and 8 deletions

View file

@ -6,6 +6,8 @@
* Source/NSData.m: * Source/NSData.m:
* Source/GSHTTPAuthentication.m: * Source/GSHTTPAuthentication.m:
* Source/NSSerializer.m: * Source/NSSerializer.m:
* Source/unix/GSRunLoopCtxt.m:
* Source/win32/GSRunLoopCtxt.m:
Various changes to use unscanned collectable memory with GC. Various changes to use unscanned collectable memory with GC.
2009-02-11 Richard Frith-Macdonald <rfm@gnu.org> 2009-02-11 Richard Frith-Macdonald <rfm@gnu.org>

View file

@ -179,12 +179,21 @@ static const NSMapTableValueCallBacks WatcherMapValueCallBacks =
mode = [theMode copy]; mode = [theMode copy];
extra = e; extra = e;
#if GS_WITH_GC
performers = NSAllocateCollectable(sizeof(GSIArray_t), NSScannedOption);
timers = NSAllocateCollectable(sizeof(GSIArray_t), NSScannedOption);
watchers = NSAllocateCollectable(sizeof(GSIArray_t), NSScannedOption);
_trigger = NSAllocateCollectable(sizeof(GSIArray_t), NSScannedOption);
#else
performers = NSZoneMalloc(z, sizeof(GSIArray_t)); performers = NSZoneMalloc(z, sizeof(GSIArray_t));
GSIArrayInitWithZoneAndCapacity(performers, z, 8);
timers = NSZoneMalloc(z, sizeof(GSIArray_t)); timers = NSZoneMalloc(z, sizeof(GSIArray_t));
GSIArrayInitWithZoneAndCapacity(timers, z, 8);
watchers = NSZoneMalloc(z, sizeof(GSIArray_t)); watchers = NSZoneMalloc(z, sizeof(GSIArray_t));
_trigger = NSZoneMalloc(z, sizeof(GSIArray_t));
#endif
GSIArrayInitWithZoneAndCapacity(performers, z, 8);
GSIArrayInitWithZoneAndCapacity(timers, z, 8);
GSIArrayInitWithZoneAndCapacity(watchers, z, 8); GSIArrayInitWithZoneAndCapacity(watchers, z, 8);
GSIArrayInitWithZoneAndCapacity(_trigger, z, 8);
_efdMap = NSCreateMapTable (NSIntMapKeyCallBacks, _efdMap = NSCreateMapTable (NSIntMapKeyCallBacks,
WatcherMapValueCallBacks, 0); WatcherMapValueCallBacks, 0);
@ -192,8 +201,6 @@ static const NSMapTableValueCallBacks WatcherMapValueCallBacks =
WatcherMapValueCallBacks, 0); WatcherMapValueCallBacks, 0);
_wfdMap = NSCreateMapTable (NSIntMapKeyCallBacks, _wfdMap = NSCreateMapTable (NSIntMapKeyCallBacks,
WatcherMapValueCallBacks, 0); WatcherMapValueCallBacks, 0);
_trigger = NSZoneMalloc(z, sizeof(GSIArray_t));
GSIArrayInitWithZoneAndCapacity(_trigger, z, 8);
} }
return self; return self;
} }
@ -213,11 +220,21 @@ static void setPollfd(int fd, int event, GSRunLoopCtxt *ctxt)
pe->limit = fd + 1; pe->limit = fd + 1;
if (pe->index == 0) if (pe->index == 0)
{ {
#if GS_WITH_GC
pe->index
= NSAllocateCollectable(pe->limit * sizeof(*(pe->index)), 0);
#else
pe->index = objc_malloc(pe->limit * sizeof(*(pe->index))); pe->index = objc_malloc(pe->limit * sizeof(*(pe->index)));
#endif
} }
else else
{ {
#if GS_WITH_GC
pe->index = NSReallocateCollectable(pe->index,
pe->limit * sizeof(*(pe->index)), 0);
#else
pe->index = objc_realloc(pe->index, pe->limit * sizeof(*(pe->index))); pe->index = objc_realloc(pe->index, pe->limit * sizeof(*(pe->index)));
#endif
} }
do do
{ {
@ -231,8 +248,13 @@ static void setPollfd(int fd, int event, GSRunLoopCtxt *ctxt)
if (ctxt->pollfds_count >= ctxt->pollfds_capacity) if (ctxt->pollfds_count >= ctxt->pollfds_capacity)
{ {
ctxt->pollfds_capacity += 8; ctxt->pollfds_capacity += 8;
#if GS_WITH_GC
pollfds = NSReallocateCollectable(pollfds,
ctxt->pollfds_capacity * sizeof (*pollfds), 0);
#else
pollfds = pollfds =
objc_realloc(pollfds, ctxt->pollfds_capacity * sizeof (*pollfds)); objc_realloc(pollfds, ctxt->pollfds_capacity * sizeof (*pollfds));
#endif
ctxt->pollfds = pollfds; ctxt->pollfds = pollfds;
} }
index = ctxt->pollfds_count++; index = ctxt->pollfds_count++;
@ -281,11 +303,21 @@ static void setPollfd(int fd, int event, GSRunLoopCtxt *ctxt)
pollfds_capacity = i + 2; pollfds_capacity = i + 2;
if (pollfds == 0) if (pollfds == 0)
{ {
#if GS_WITH_GC
pollfds
= NSAllocateCollectable(pollfds_capacity * sizeof(*pollfds), 0);
#else
pollfds = objc_malloc(pollfds_capacity * sizeof(*pollfds)); pollfds = objc_malloc(pollfds_capacity * sizeof(*pollfds));
#endif
} }
else else
{ {
#if GS_WITH_GC
pollfds = NSReallocateCollectable(pollfds,
pollfds_capacity * sizeof(*pollfds), 0);
#else
pollfds = objc_realloc(pollfds, pollfds_capacity * sizeof(*pollfds)); pollfds = objc_realloc(pollfds, pollfds_capacity * sizeof(*pollfds));
#endif
} }
} }
pollfds_count = 0; pollfds_count = 0;

View file

@ -151,19 +151,26 @@ static const NSMapTableValueCallBacks WatcherMapValueCallBacks =
mode = [theMode copy]; mode = [theMode copy];
extra = e; extra = e;
#if GS_WITH_GC
performers = NSAllocateCollectable(sizeof(GSIArray_t), NSScannedOption);
timers = NSAllocateCollectable(sizeof(GSIArray_t), NSScannedOption);
watchers = NSAllocateCollectable(sizeof(GSIArray_t), NSScannedOption);
_trigger = NSAllocateCollectable(sizeof(GSIArray_t), NSScannedOption);
#else
performers = NSZoneMalloc(z, sizeof(GSIArray_t)); performers = NSZoneMalloc(z, sizeof(GSIArray_t));
GSIArrayInitWithZoneAndCapacity(performers, z, 8);
timers = NSZoneMalloc(z, sizeof(GSIArray_t)); timers = NSZoneMalloc(z, sizeof(GSIArray_t));
GSIArrayInitWithZoneAndCapacity(timers, z, 8);
watchers = NSZoneMalloc(z, sizeof(GSIArray_t)); watchers = NSZoneMalloc(z, sizeof(GSIArray_t));
_trigger = NSZoneMalloc(z, sizeof(GSIArray_t));
#endif
GSIArrayInitWithZoneAndCapacity(performers, z, 8);
GSIArrayInitWithZoneAndCapacity(timers, z, 8);
GSIArrayInitWithZoneAndCapacity(watchers, z, 8); GSIArrayInitWithZoneAndCapacity(watchers, z, 8);
GSIArrayInitWithZoneAndCapacity(_trigger, z, 8);
handleMap = NSCreateMapTable(NSIntMapKeyCallBacks, handleMap = NSCreateMapTable(NSIntMapKeyCallBacks,
WatcherMapValueCallBacks, 0); WatcherMapValueCallBacks, 0);
winMsgMap = NSCreateMapTable(NSIntMapKeyCallBacks, winMsgMap = NSCreateMapTable(NSIntMapKeyCallBacks,
WatcherMapValueCallBacks, 0); WatcherMapValueCallBacks, 0);
_trigger = NSZoneMalloc(z, sizeof(GSIArray_t));
GSIArrayInitWithZoneAndCapacity(_trigger, z, 8);
} }
return self; return self;
} }