56 fprintf(keyfile,
"%s addr.%zu = %p\n", owner, counter, &
segmentStart);
57 fprintf(keyfile,
"%s size.%zu = %zu\n", owner, counter,
segmentSize);
69 char *objectPtr, *endPtr;
70 char *lastObjectPtr = NULL;
74 for (objectPtr =
start(), endPtr =
end();
76 objectPtr += ((
RexxObject *)objectPtr)->getObjectSize())
78 lastObjectPtr = objectPtr;
128 for (segment =
first(); segment != NULL; segment =
next(segment))
130 segment->
dump(
name, ++counter, keyfile, dumpfile);
147 fprintf(outfile,
"Memory profile for large object allocations\n\n");
160 fprintf(outfile,
"Memory profile for normal object allocations\n\n");
190 deadCache(
"Large Block Allocation Pool"), requests(0), smallestObject(0), largestObject(0) { }
198 deadCache(
"Old Space Allocation Pool")
209 largeDead(
"Large Normal Allocation Pool")
219 snprintf(buffer,
sizeof buffer,
"Normal allocation subpool %d for blocks of size %d", i,
DeadPoolToLength(i));
278 if (segment == NULL) {
281 if (segment == NULL) {
299 if (segment->
size() > requestLength)
304 segment = segment->
next;
385 size_t length =
object->getObjectSize();
481 while (insertPosition->
isReal())
485 if (segment < insertPosition)
489 insertPosition = insertPosition->
next;
499 size_t deadLength = segment->
realSize();
501 memory->
verboseMessage(
"Combining newly allocated segment of %d bytes to create new segment of %d bytes\n", deadLength, previous->
size());
509 if (createDeadObject)
592 NO_SEGMENT, SPLIT_FRONT, SPLIT_REAR, SPLIT_MIDDLE
595 SplitType split = NO_SEGMENT;
597 char *splitBlock = NULL;
609 while (segment != NULL)
615 for (objectPtr = segment->
start(), endPtr = segment->
end(), deadLength = ((
RexxObject *)objectPtr)->getObjectSize();
635 if (split == SPLIT_REAR)
638 if (splitLength < deadLength)
646 candidateSegment = segment;
647 splitBlock = objectPtr;
648 splitLength = deadLength;
658 if (split == SPLIT_REAR)
663 if (split == SPLIT_FRONT && splitLength < deadLength)
668 candidateSegment = segment;
669 splitBlock = objectPtr;
670 splitLength = deadLength;
683 if ((split == SPLIT_MIDDLE && splitLength < deadLength))
688 if (split != NO_SEGMENT)
692 split = SPLIT_MIDDLE;
693 candidateSegment = segment;
694 splitBlock = objectPtr;
695 splitLength = deadLength;
704 segment =
next(segment);
725 candidateSegment->
shrink(splitLength);
737 size_t tailLength = candidateSegment->
realSize() - splitLength;
760 size_t frontLength = splitBlock - candidateSegment->
start();
762 size_t tailLength = candidateSegment->
size() - (frontLength + splitLength);
775 candidateSegment =
new (candidateSegment)
MemorySegment(frontLength);
797 memory->
verboseMessage(
"Normal segment set free memory percentage is %d\n", (
int)(freePercent * 100.0));
810 return expansionSize;
894 if (suggestedExpansion > 0)
926 for (;segment != NULL; segment =
next(segment))
929 if (segment->
isEmpty() && segment->
size() <= releaseSize)
991 segmentSize = newSeg->
size();
993 if (segmentSize >= requiredSpace)
998 requiredSpace -= segmentSize;
1114 char *objectPtr, *endPtr, *nextObjectPtr;
1124 sweepSegment =
first();
1125 while (sweepSegment != NULL)
1130 for (objectPtr = sweepSegment->
start(), endPtr = sweepSegment->
end(); objectPtr < endPtr; )
1136 bytes = ((
RexxObject *)objectPtr)->getObjectSize();
1150 deadLength = ((
RexxObject *)objectPtr)->getObjectSize();
1154 for (nextObjectPtr = objectPtr + deadLength;
1156 nextObjectPtr += bytes)
1159 bytes = ((
RexxObject *)nextObjectPtr)->getObjectSize();
1163 deadLength += bytes;
1170 objectPtr += deadLength;
1174 sweepSegment =
next(sweepSegment);
1192 size_t allocationLength,
1193 size_t splitMinimum)
1200 size_t deadLength =
object->
getObjectSize() - allocationLength;
1207 if (deadLength < splitMinimum)
1210 allocationLength += deadLength;
1225 ((
RexxObject *)
object)->setObjectSize(allocationLength);
1231 size_t allocationLength)
1242 if (largeObject != NULL)
1392 if (largeObject != NULL)
1420 newSegment(allocationLength, allocationLength);
1439 if (segment->
size() > largest->
size())
1461 if (segment->
size() > largest->
size())
1474 size_t allocationLength)
1488 if (largestEmpty->
size() > allocationLength)
1502 if (largestActive->
size() < allocationLength)
1555 if (largestEmpty->
size() > allocationLength)
1584 if (largestEmpty->
size() > allocationLength)
1601 if (lastBlock != NULL)
1620 emptySegment = nextSeg;
1621 nextSeg = nextSeg->
next;
1629 if (firstBlock != NULL)
1632 tailSegment = nextSeg;
1639 if (emptySegment != NULL)
1645 segment->
combine(emptySegment);
1648 if (tailSegment != NULL)
1654 segment->
combine(tailSegment);
1701 size_t allocationLength)
1727 newSegment(allocationLength, allocationLength);
1764 for (seg =
first(); seg != NULL; seg =
next(seg))
1779 for (op =
start(), ep =
end(); op < ep; )
1803 for (segment =
first(); segment != NULL; segment =
next(segment))
void reportException(wholenumber_t error)
bool objectIsNotLive(char *obj, size_t mark)
bool objectIsLive(char *obj, size_t mark)
#define InitialNormalSegmentSpace
#define LengthToDeadPool(l)
#define RecoverSegmentSize
#define NormalMemoryExpansionThreshold
#define MemorySegmentOverhead
#define MemoryThrashingThreshold
size_t roundSegmentBoundary(size_t n)
#define NormalMemoryContractionThreshold
#define LargeSegmentDeadSpace
#define DeadPoolToLength(d)
#define MinimumSegmentSize
#define Error_System_resources
#define LargeAllocationUnit
size_t roundLargeObjectAllocation(size_t n)
#define MinimumObjectSize
#define MaximumObjectSize
#define memory_mark_general(oref)
void setObjectSize(size_t newSize)
void setID(const char *poolID)
DeadObject * findSmallestFit(size_t minSize)
void dumpMemoryProfile(FILE *outfile)
void addSortedBySize(DeadObject *obj)
void checkObjectOverlap(DeadObject *obj)
void add(DeadObject *obj)
void addSingle(DeadObject *obj)
DeadObject * findFit(size_t length)
static void logicError(const char *desc, const char *info1=NULL, size_t info2=0)
RexxObject * findObject(size_t allocationLength)
virtual void prepareForSweep()
RexxObject * allocateObject(size_t allocationLength)
virtual void dumpMemoryProfile(FILE *outfile)
virtual DeadObject * donateObject(size_t allocationLength)
RexxObject * handleAllocationFailure(size_t allocationLength)
virtual MemorySegment * allocateSegment(size_t requestLength, size_t minimumLength)
void expandOrCollect(size_t allocationLength)
void expandSegmentSet(size_t allocationLength)
void completeSweepOperation()
virtual void addDeadObject(DeadObject *object)
void gatherObjectStats(MemoryStats *memStats, SegmentStats *stats)
bool isFirstBlock(char *addr)
bool isLastBlock(char *addr, size_t length)
void shrink(size_t delta)
void combine(MemorySegment *nextSegment)
DeadObject * lastDeadObject()
DeadObject * firstDeadObject()
void dump(const char *owner, size_t counter, FILE *keyfile, FILE *dumpfile)
DeadObject * createDeadObject()
bool isAdjacentTo(MemorySegment *seg)
DeadObject * firstObject()
void insertBefore(MemorySegment *newSegment)
void dumpSegments(FILE *keyfile, FILE *dumpfile)
void activateEmptySegments()
MemorySegment * findEmptySegment(size_t allocationLength)
void addSegment(MemorySegment *segment, bool createDeadObject=1)
void removeSegmentAndStorage(MemorySegment *segment)
virtual size_t suggestMemoryContraction()
size_t calculateSegmentAllocation(size_t n)
void releaseEmptySegments(size_t releaseSize)
MemorySegment emptySegments
RexxObject * splitDeadObject(DeadObject *object, size_t allocationLength, size_t splitMinimum)
void mergeSegments(size_t allocationLength)
MemorySegment * largestEmptySegment()
void combineEmptySegments(MemorySegment *front, MemorySegment *back)
void addSegments(size_t requiredSpace)
virtual MemorySegment * allocateSegment(size_t requestLength, size_t minimumLength)
virtual void completeSweepOperation()
virtual size_t suggestMemoryExpansion()
void releaseSegment(MemorySegment *segment)
virtual void prepareForSweep()
virtual void collectEmptySegments()
MemorySegment * getSegment(size_t requestLength, size_t minimumLength)
float freeMemoryPercentage()
void gatherStats(MemoryStats *memStats, SegmentStats *stats)
MemorySegment * splitSegment(size_t allocationLength)
void removeSegment(MemorySegment *segment)
virtual DeadObject * donateObject(size_t allocationLength)
virtual void dumpMemoryProfile(FILE *outfile)
MemorySegment * next(MemorySegment *segment)
bool newSegment(size_t requestLength, size_t minimumLength)
void validateObject(size_t bytes)
MemorySegment * largestActiveSegment()
virtual MemorySegment * donateSegment(size_t allocationLength)
virtual void addDeadObject(DeadObject *object)
size_t recommendedMaximumMemorySize()
virtual void addDeadObject(DeadObject *object)
virtual size_t suggestMemoryContraction()
RexxObject * findObject(size_t allocationLength)
MemorySegment * recoverSegment
virtual DeadObject * donateObject(size_t allocationLength)
virtual void dumpMemoryProfile(FILE *outfile)
DeadObjectPool subpools[DeadPools]
virtual void prepareForSweep()
RexxObject * handleAllocationFailure(size_t allocationLength)
RexxObject * findLargeDeadObject(size_t allocationLength)
void completeSweepOperation()
void checkObjectOverlap(DeadObject *obj)
size_t lastUsedSubpool[DeadPools+1]
size_t recommendedMemorySize()
virtual size_t suggestMemoryExpansion()
RexxObject * allocateObject(size_t allocationLength)
static wholenumber_t maxVal(wholenumber_t n1, wholenumber_t n2)
RexxObject * allocateObject(size_t allocationLength)
virtual void addDeadObject(DeadObject *object)
RexxObject * findObject(size_t allocationLength)
void markOldSpaceObjects()
MemorySegment * newSegment(size_t requestLength, size_t minLength)
MemorySegment * newLargeSegment(size_t requestLength, size_t minLength)
void verboseMessage(const char *message)
void scavengeSegmentSets(MemorySegmentSet *requester, size_t allocationLength)
void recordObject(MemoryStats *memStats, char *obj)