69 #include "SystemInterpreter.hpp"
72 #include "SysFileSystem.hpp"
80 #define RESTORE_CLASS(name, className) The##name##Class = (className *)RexxBehaviour::getPrimitiveBehaviour(T_##name)->restoreClass();
88 #define LiveStackSize 16370
90 #define SaveStackSize 10
91 #define SaveStackAllocSize 500
98 #define MaxImageSize 3000000
116 va_start(args, message);
117 vprintf(message, args);
118 if (outfile != NULL) {
119 vfprintf(outfile, message, args);
262 outFile = fopen(
"memory.prf",
"wb");
281 ObjEnd = (
void **)((
char *)objectRef + objectRef->
getObjectSize());
282 for (dmpPtr = (
void **)objectRef; dmpPtr <= ObjEnd ; dmpPtr++)
284 logMemoryCheck(outfile,
" >Parent Dump -->%p %p %p %p \n", *dmpPtr, *(dmpPtr+1), *(dmpPtr+2), *(dmpPtr+3));
390 markObject->
live(liveMark);
506 verboseMessage(
"Calling runUninits from RexxMemory::collectAndUninit\n");
546 verboseMessage(
"Leaving runUninits immediatly because recursive call\n");
578 activity->
run(dispatcher);
601 verboseMessage(
"Leaving runUninits (was called when pendingUninits=%d)\n", pendingUninits_onEntry);
754 printf(
"Allocating a new segment of %d bytes\n", requestedBytes);
760 printf(
"Allocating boundary a new segment of %d bytes\n", requestedBytes);
797 printf(
"Allocating large boundary new segment of %d bytes for request of %d\n", allocationBytes, requestedBytes);
831 char *objectPointer, *endPointer;
834 size_t primitiveTypeNum;
848 while (objectPointer < endPointer)
875 primitiveTypeNum = ((
RexxObject *)objectPointer)->behaviour->getClassType();
902 objectPointer += ((
RexxObject *)objectPointer)->getObjectSize();
1201 totalSize = objSize * count;
1259 prototype = largeObject;
1267 for (i=1 ;i < count ; i++ )
1273 arrayOfObjects->
put(largeObject, i);
1275 largeObject = (
RexxObject *)((
char *)largeObject + objSize);
1279 arrayOfObjects->
put(largeObject, i);
1284 return arrayOfObjects;
1308 size_t deadObjectSize = shrinkObj->
getObjectSize() - newSize;
1311 newDeadObj =
new ((
void *)((
char *)shrinkObj + newSize))
DeadObject (deadObjectSize);
1319 if (deadObjectSize != 0)
1334 size_t allocationLength)
1369 if (largeObject != NULL)
1544 memcpy((
void *)bufferReference, (
void *)markObject, size);
1546 bufferReference->clearObjectMark();
1561 const char *owningClassIdCstr = owningClassId ? owningClassId->
getStringData() :
"NULL";
1567 bufferReference->setPrimitive();
1591 const char *outFileName;
1595 const char *objectClassName;
1603 outfile = fopen(outFileName,
"wb");
1604 logMemoryCheck(outfile,
"Found non Object at %p, being marked from %p\n",markObject, pMarkObject);
1630 className = markObject->
id();
1632 objectClassName =
"";
1637 printf(
"-->Parent node was marking offset '%ld'x \n",
long((
char *)pMarkObject - (
char *)markObject));
1640 logMemoryCheck(outfile,
"Parent node is at %p, of type %s(%d) \n",
1641 markObject, objectClassName, markObject->behaviour->getClassType());
1652 printf(
"All data has been captured in file %s \n", outFileName);
1720 _imageStats.
clear();
1818 image = fopen(imageTarget == NULL ?
BASEIMAGE : imageTarget,
"wb");
1827 printf(
"Object stats for this image save are \n");
1829 printf(
"\n\n Total bytes for this image %lu bytes \n", (
unsigned long)
image_offset);
1851 printf(
"Dumping object memory to orexdump.dmp\n");
1853 dumpfile = fopen(
"orexdump.dmp",
"wb");
1856 printf(
"Creating dump key file in orexdump.key\n");
1858 keyfile = fopen(
"orexdump.key",
"w");
1859 fprintf(keyfile,
"/* Object REXX dump key file */\n");
1860 fprintf(keyfile,
"memoryaddr = %p\n",
this);
1861 fprintf(keyfile,
"marker = %d\n", (
int)
markWord);
1872 fprintf(keyfile,
"Pool addr.%d = %p\n", i,
currentPool);
1914 bool restoreimagesave;
1922 printf(
"Comparing old2new with the current system.\n");
1947 printf(
"object: %p, type: %lu, is extra in old2new.\n\n",
1956 if (count != testcount)
1958 printf(
"object: %p, type: %lu, has an incorrect refcount.\n",
1960 printf(
"Refcount for object is %ld, should be %ld.\n\n", (
long)count, (
long)testcount);
1963 tempold2new->
remove(index);
1970 for (j = tempold2new->
first();
1972 j = tempold2new->
next(j))
1974 printf(
"object: %p, type: %lu, is missing from old2new.\n\n",
1981 printf(
"Dumping object memory.\n");
2093 printf(
"******** error in memory_setoref, unable to decrement refcount\n");
2094 printf(
"Naughty object reference is from: %p\n", oldValueLoc);
2095 printf(
"Naughty object reference is at: %p\n", index);
2096 printf(
"Naughty object reference type is: %lu\n", (
unsigned long)(index)->
behaviour->
getClassType());
2124 return *oldValueLoc = value;
2132 const char *fileName,
2142 const char *outFileName;
2151 outfile = fopen(outFileName,
"wb");
2152 logMemoryCheck(outfile,
"The Setter object at %p is invalid...\n");
2160 outfile = fopen(outFileName,
"wb");
2161 logMemoryCheck(outfile,
"The Setter object at %p attempted to put a non object %p, at offset %p\n",setter, value, (
char *)index - (
char *)setter);
2162 logMemoryCheck(outfile,
" A dump of the Setting object follows: \n");
2170 outfile = fopen(outFileName,
"wb");
2171 logMemoryCheck(outfile,
"The Setter object at %p has tried to store at offset, which is outside his object range\n",setter, (
char *)index - (
char *)setter);
2172 logMemoryCheck(outfile,
" A dump of the Setting object follows: \n");
2181 logMemoryCheck(outfile,
" The error occurred in line %u of file %s\n", lineNum, fileName);
2182 printf(
"The dump data has been written to file %s \n",outFileName);
2187 return(setter->
isOldSpace() ? (this->setOref(index, value)) : (*index = value));
2227 _imageStats.
clear();
2258 while (pool != NULL)
2363 args[0] = OREF_BYTE;
void reportException(wholenumber_t error)
RexxArray * new_array(size_t s)
RexxIdentityTable * new_identity_table()
RexxInteger * new_integer(wholenumber_t v)
#define MemorySegmentOverhead
size_t roundSegmentBoundary(size_t n)
#define LargeBlockThreshold
#define TheMemoryBehaviour
#define TheBehaviourBehaviour
#define TheStackBehaviour
#define TheObjectBehaviour
#define TheCommonRetrievers
#define TheFunctionsDirectory
#define Error_Logical_value_method
#define Error_System_resources
bool SysAccessPool(MemorySegmentPool **pool)
#define SaveStackAllocSize
static void logMemoryCheck(FILE *outfile, const char *message,...)
#define RESTORE_CLASS(name, className)
#define memory_mark(oref)
size_t roundObjectBoundary(size_t n)
#define ObjectNeedsMarking(oref)
size_t roundLargeObjectAllocation(size_t n)
#define MinimumObjectSize
#define memory_mark_general(oref)
size_t roundObjectResize(size_t n)
RexxString * new_string(const char *s, stringsize_t l)
RexxString * new_proxy(const char *name)
RexxText * new_text(RexxString *s)
static void liveGeneral(int reason)
static RexxActivity *volatile currentActivity
GlobalProtectedObject * next
RexxObject * protectedObject
static void logicError(const char *desc, const char *info1=NULL, size_t info2=0)
static void liveGeneral(int reason)
RexxObject * allocateObject(size_t allocationLength)
virtual void dumpMemoryProfile(FILE *outfile)
RexxObject * handleAllocationFailure(size_t allocationLength)
MemorySegment * newLargeSegment(size_t minSize)
MemorySegment * newSegment(size_t minSize)
static MemorySegmentPool * createPool()
MemorySegmentPool * nextPool()
void dumpSegments(FILE *keyfile, FILE *dumpfile)
bool isInSegmentSet(RexxObject *object)
void addSegment(MemorySegment *segment, bool createDeadObject=1)
void gatherStats(MemoryStats *memStats, SegmentStats *stats)
virtual DeadObject * donateObject(size_t allocationLength)
virtual MemorySegment * donateSegment(size_t allocationLength)
virtual void addDeadObject(DeadObject *object)
void printSavedImageStats()
virtual void dumpMemoryProfile(FILE *outfile)
RexxObject * handleAllocationFailure(size_t allocationLength)
RexxObject * allocateObject(size_t allocationLength)
RexxObject * allocateObject(size_t allocationLength)
void markOldSpaceObjects()
static void liveGeneral(int reason)
static void live(size_t liveMark)
static RexxArray * getImageData()
static void initializeThreadContext()
void put(RexxObject *eref, size_t pos)
RexxObject * get(size_t pos)
static RexxBehaviour * restoreSavedPrimitiveBehaviour(RexxBehaviour *b)
void restore(RexxBehaviour *)
RexxClass * getOwningClass()
RexxBehaviour * getSavedPrimitiveBehaviour()
static RexxBehaviour * getPrimitiveBehaviour(size_t index)
static RexxBehaviour primitiveBehaviours[]
static void createInstance()
RexxObject * at(RexxString *)
RexxObject * put(RexxObject *, RexxString *)
RexxObject * value(HashLink pos)
HashLink next(HashLink pos)
RexxObject * index(HashLink pos)
virtual RexxObject * put(RexxObject *, RexxObject *)
virtual RexxObject * get(RexxObject *key)
virtual RexxObject * remove(RexxObject *key)
static void createInstance()
wholenumber_t incrementValue()
RexxObject * getValue(RexxActivation *)
wholenumber_t decrementValue()
void setBehaviour(RexxBehaviour *b)
void setObjectSize(size_t s)
void setObjectLive(size_t markword)
bool isObjectLive(size_t mark)
virtual RexxString * stringValue()
bool isObjectDead(size_t mark)
RexxBehaviour * behaviour
RexxBehaviour * getObjectType()
static RexxDirectory * functionsDir
void setEnvelope(RexxEnvelope *)
void markObjectsMain(RexxObject *)
void addWeakReference(WeakReference *ref)
RexxIdentityTable * old2new
static RexxDirectory * environment
void saveImageMark(RexxObject *markObject, RexxObject **pMarkObject)
void discardHoldObject(RexxInternalObject *obj)
RexxSaveStack * saveStack
MemorySegmentPool * firstPool
void removeUninitObject(RexxObject *obj)
void orphanCheckMark(RexxObject *markObject, RexxObject **pMarkObject)
bool objectReferenceOK(RexxObject *o)
@ saveArray_COMMON_RETRIEVERS
void initialize(bool restoringImage, const char *imageTarget)
void memoryPoolAdded(MemorySegmentPool *)
RexxObject * setParms(RexxObject *, RexxObject *)
void saveImage(const char *imageTarget)
RexxIdentityTable * uninitTable
void restoreObjectMark(RexxObject *markObject, RexxObject **pMarkObject)
WeakReference * weakReferenceList
static RexxDirectory * globalStrings
RexxObject * saveObject(RexxInternalObject *saveObj)
static void createImage(const char *imageTarget)
RexxObject * newObject(size_t size)
static SysMutex unflattenMutex
NormalSegmentSet newSpaceNormalSegments
MemorySegment * newSegment(size_t requestLength, size_t minLength)
static void * virtualFunctionTable[]
void killOrphans(RexxObject *)
bool inSharedObjectStorage(RexxObject *obj)
RexxObject * setDump(RexxObject *)
static PackageClass * rexxPackage
RexxObject * makeProxy(RexxEnvelope *)
static RexxArray * saveStrings()
MemorySegment * newLargeSegment(size_t requestLength, size_t minLength)
bool isPendingUninit(RexxObject *obj)
RexxArray * newObjects(size_t size, size_t count, size_t objectType)
RexxVariable * variableCache
RexxStack * getFlattenStack()
void addUninitObject(RexxObject *obj)
RexxObject * popLiveStack()
static void createLocks()
static RexxDirectory * system
void restoreMark(RexxObject *markObject, RexxObject **pMarkObject)
OldSpaceSegmentSet oldSpaceSegments
static void restoreStrings(RexxArray *stringArray)
void setUpMemoryTables(RexxIdentityTable *old2newTable)
void collectAndUninit(bool clearStack)
RexxObject * holdObject(RexxInternalObject *obj)
void pushLiveStack(RexxObject *obj)
RexxObject * dumpImageStats()
GlobalProtectedObject * protectedObjects
static SysMutex envelopeMutex
static void buildVirtualFunctionTable()
void liveGeneral(int reason)
bool inObjectStorage(RexxObject *obj)
LargeSegmentSet newSpaceLargeSegments
void logObjectStats(RexxObject *obj)
static RexxString * getGlobalName(const char *value)
void returnFlattenStack()
RexxObject * checkSetOref(RexxObject *, RexxObject **, RexxObject *, const char *, int)
char * allocateImageBuffer(size_t size)
void unflattenMark(RexxObject *markObject, RexxObject **pMarkObject)
static RexxDirectory * commonRetrievers
RexxIdentityTable * saveTable
void setObjectOffset(size_t offset)
RexxObject * oldObject(size_t size)
void verboseMessage(const char *message)
void dumpObject(RexxObject *objectRef, FILE *outfile)
void checkWeakReferences()
static RexxDirectory * kernel
static SysMutex flattenMutex
RexxObject * setOref(void *index, RexxObject *value)
RexxObject * temporaryObject(size_t size)
RexxStack * originalLiveStack
void reSize(RexxObject *, size_t)
MemorySegmentPool * currentPool
void pushSaveStack(RexxObject *obj)
void flatten(RexxEnvelope *)
void scavengeSegmentSets(MemorySegmentSet *requester, size_t allocationLength)
void logVerboseOutput(const char *message, void *sub1, void *sub2)
void initializeNewObject(size_t size, size_t mark, void *vft, RexxBehaviour *b)
void liveGeneral(int reason)
bool messageSend(RexxString *, RexxObject **, size_t, size_t, ProtectedObject &, bool processUnknown=true, bool dynamicTarget=true)
RexxClass * classObject()
void copyEntries(RexxStack *other)
RexxObject * push(RexxObject *obj)
RexxObject * getEncoding()
const char * getStringData()
RexxObject * replace(RexxObject *newValue, HashLink pos)
static const char * getTempFileName()
void release(const char *ds, int di)
bool requestImmediate(const char *ds, int di)
void request(const char *ds, int di)
static void liveGeneral(int reason)
static void loadImage(char **imageBuffer, size_t *imageSize)
RexxObject * referentObject
WeakReference * nextReferenceList