45 #ifndef Included_RexxMemory
46 #define Included_RexxMemory
48 #include "SysSemaphore.hpp"
57 #define ObjectGrain 16
59 #define LargeAllocationUnit 2048
61 #define VeryLargeAllocationUnit 8192
65 #define VeryLargeObjectGrain 512
70 #define MinimumObjectSize ((size_t)48)
71 #define MaximumObjectSize ((size_t)0xfffffffffffffff0ull)
76 #define LargeAllocationUnit 1024
78 #define VeryLargeAllocationUnit 4096
80 #define VeryLargeObjectGrain 256
85 #define MinimumObjectSize ((size_t)24)
86 #define MaximumObjectSize ((size_t)0xfffffff0)
92 #define IsObjectGrained(o) ((((size_t)o)%ObjectGrain) == 0)
93 #define IsValidSize(s) ((s) >= MinimumObjectSize && ((s) % ObjectGrain) == 0)
147 void *
operator new(
size_t size,
size_t minSize);
148 void *
operator new(
size_t size,
void *pool) {
return pool;}
149 inline void operator delete(
void *) { }
150 inline void operator delete(
void *, size_t) { }
151 inline void operator delete(
void *,
void *) { }
363 *pMarkObject = markObject;
441 #define setUpFlatten(type) \
443 size_t newSelf = envelope->currentOffset; \
444 type * volatile newThis = (type *)this;
446 #define cleanUpFlatten \
449 #define ObjectNeedsMarking(oref) ((oref) != OREF_NULL && !((oref)->isObjectMarked(liveMark)) )
450 #define memory_mark(oref) if (ObjectNeedsMarking(oref)) memoryObject.mark((RexxObject *)(oref))
451 #define memory_mark_general(oref) (memoryObject.markGeneral((void *)&(oref)))
454 #define memory_mark_array(count, array) \
455 for (size_t i = 0; i < count; i++) \
457 memory_mark(array[i]); \
460 #define memory_mark_general_array(count, array) \
461 for (size_t i = 0; i < count; i++) \
463 memory_mark_general(array[i]); \
478 #define setUpFlatten(type) \
480 size_t newSelf = envelope->currentOffset; \
481 type * volatile newThis = (type *)this;
484 #define cleanUpFlatten \
488 #define flattenRef(oref) if ((newThis->oref) != OREF_NULL) envelope->flattenReference((void *)&newThis, newSelf, (void *)&(newThis->oref))
491 #define flattenArrayRefs(count, array) \
492 for (size_t i = 0; i < count; i++) \
494 flattenRef(array[i]); \
498 #define flatten_reference(oref,envel) if (oref) envel->flattenReference((void *)&newThis, newSelf, (void *)&(oref))
503 #define CLASS_CREATE(name, id, className) The##name##Class = (className *)new (sizeof(className), id, The##name##ClassBehaviour, The##name##Behaviour) RexxClass;
RexxObject *(RexxObject::* PCPPM)()
RexxArray * new_arrayOfObject(size_t s, size_t c, size_t t)
void saveObject(RexxInternalObject *o)
RexxObject * new_object(size_t s)
size_t roundObjectBoundary(size_t n)
#define LargeAllocationUnit
size_t roundLargeObjectAllocation(size_t n)
void SetObjectLive(void *o, size_t mark)
void holdObject(RexxInternalObject *o)
void discardObject(RexxInternalObject *o)
void discardHoldObject(RexxInternalObject *o)
size_t roundObjectResize(size_t n)
MemorySegment * newLargeSegment(size_t minSize)
MemorySegment * newSegment(size_t minSize)
friend bool SysAccessPool(MemorySegmentPool **)
static MemorySegmentPool * createPool()
MemorySegmentPool * nextPool()
void setNext(MemorySegmentPool *nextPool)
void logObject(RexxObject *obj)
virtual RexxObject * remove(RexxObject *key)
virtual RexxObject * add(RexxObject *, RexxObject *)
void setObjectLive(size_t markword)
RexxBehaviour * behaviour
static RexxDirectory * functionsDir
void setEnvelope(RexxEnvelope *)
void markObjectsMain(RexxObject *)
void addWeakReference(WeakReference *ref)
RexxIdentityTable * old2new
static RexxDirectory * environment
static void definePrivateKernelMethod(const char *name, RexxBehaviour *behaviour, PCPPM entryPoint, size_t arguments, bool named_arguments=false)
void saveImageMark(RexxObject *markObject, RexxObject **pMarkObject)
void discardHoldObject(RexxInternalObject *obj)
RexxSaveStack * saveStack
MemorySegmentPool * firstPool
RexxMemory(RESTORETYPE restoreType)
void removeUninitObject(RexxObject *obj)
void orphanCheckMark(RexxObject *markObject, RexxObject **pMarkObject)
static void createRexxPackage()
bool objectReferenceOK(RexxObject *o)
@ saveArray_GLOBAL_STRINGS
@ saveArray_COMMON_RETRIEVERS
void verboseMessage(const char *message, size_t sub1)
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
static void createStrings()
RexxObject * saveObject(RexxInternalObject *saveObj)
static void createImage(const char *imageTarget)
RexxObject * newObject(size_t size)
static SysMutex unflattenMutex
void setMarkTable(RexxTable *marktable)
NormalSegmentSet newSpaceNormalSegments
static void completeSystemClass(const char *name, RexxClass *classObj)
MemorySegment * newSegment(size_t requestLength, size_t minLength)
static void * virtualFunctionTable[]
void killOrphans(RexxObject *)
static void defineKernelMethod(const char *name, RexxBehaviour *behaviour, PCPPM entryPoint, size_t arguments, bool named_arguments=false)
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)
static void addToSystem(const char *name, RexxInternalObject *classObj)
OldSpaceSegmentSet oldSpaceSegments
static void restoreStrings(RexxArray *stringArray)
void setUpMemoryTables(RexxIdentityTable *old2newTable)
static void defineProtectedKernelMethod(const char *name, RexxBehaviour *behaviour, PCPPM entryPoint, size_t arguments, bool named_arguments=false)
void removeSavedObject(RexxObject *obj)
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)
void verboseMessage(const char *message, const char *sub1, size_t sub2)
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)
void discardObject(RexxInternalObject *obj)
RexxObject * oldObject(size_t size)
void verboseMessage(const char *message)
void dumpObject(RexxObject *objectRef, FILE *outfile)
void checkWeakReferences()
static RexxDirectory * kernel
static SysMutex flattenMutex
RexxDirectory * getGlobalStrings()
RexxObject * setOref(void *index, RexxObject *value)
RexxObject * temporaryObject(size_t size)
RexxObject * operator=(DeadObject *d)
void verboseMessage(const char *message, size_t sub1, size_t sub2)
void setOrphanCheck(bool orphancheck)
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 removeHold(RexxInternalObject *obj)
static PCPPM exportedMethods[]
void remove(RexxObject *, bool search=false)
void fastPush(RexxObject *element)
RexxObject * push(RexxObject *obj)
virtual RexxObject * unflatten(RexxEnvelope *)