📄 heapmanager.h
字号:
/* Note that the allocated flag is stored in the LSB bit of iRegionSize.
The Unused pointer is added to expand the size up to 16 bytes so we can use a
shift operation instead of division. */
typedef struct blockStruct *BlockStructPtr;
typedef struct LargeObject {
BlockStructPtr pLeftChild;
BlockStructPtr pRightChild;
BlockStructPtr pLLHeadOrNext; /* Either ptr to ll head, or next node */
} LargeObject;
typedef struct SmallObject {
BlockStructPtr pPrevBlock;
BlockStructPtr pNextBlock;
char *Unused;
} SmallObject;
typedef struct blockStruct {
int iRegionSize;
union {
SmallObject udSmallObj;
LargeObject udLargeObj;
} u;
} blockStruct;
/* ibm.5833 TMR - 6/98
* -------------------Sticky Bits macros --------------------------------
* The Dirty Bit is the last (LSB) in the third pointer in the block header.
* In large object the third pointer is in use only when the block is not
* allocated.
* In small object this pointer is not in use at all*/
#define markDirtyBit(mem) (MEMORY_TO_HEADER(mem))->u.udLargeObj.pLLHeadOrNext = (BlockStructPtr)1;
#define markDirtyBit_ee(mem,ee) \
{ \
((char*)ee->compensatedBlockHeaders)[(((unsigned int)mem>>12)<<4)+12]=1; \
}
#define clearDirtyBit(ud) (ud)->u.udLargeObj.pLLHeadOrNext = 0;
#define isBitDirty(ud) (ud)->u.udLargeObj.pLLHeadOrNext
/* ITL - (2/98) */
/* ----------------- Common gc routines & variables ---------------------- */
#ifdef ALLOC_BARRIERS
void DoASChangeCallback(int as_old, int as_new);
extern volatile int allocstate;
extern long _barriersize_red;
extern long _barriersize_yellow;
#define ALLOCSTATE_GREEN 1
#define ALLOCSTATE_YELLOW 2
#define ALLOCSTATE_RED 3
#endif /* ALLOC_BARRIERS */
/* ----------------------- Heap Manager global variables ---------------- */
extern BlockStructPtr pTreeStart; /* Start of binary tree */
//extern void *pWildernessStart; /* Start of wilderness area */
extern int iFreeBytes; /* Number of free bytes left in our Java heap */
extern int iLastAsync; /* Cycle number of sweep when last GC occurred */
extern int iNumSweeps; /* Number of sweeps executed */
extern void *vpHeaderBlkStart; /* start of header area in allocated heap */
//extern void *vpColorMapStart; /* Start of color map */
extern void *heapbase; /* Start of Java heap */
/* ------------------------ Binary tree routines ------------------------ */
BlockStructPtr HMremoveMin(BlockStructPtr pStartSearch);
BlockStructPtr HMfindAndRemove(int iRequestedNumBlocks, BlockStructPtr p);
int HMremoveNode(BlockStructPtr pRemoveMe, BlockStructPtr *p);
int HMinsert(BlockStructPtr udNewElement);
/*ibm.6565*/
extern void * HMallocate(int iSize,
int index,
struct methodtable *mptr,
int obj_type,
ExecEnv *ee);
/*ibm.6565*/
/* --------------------- Common Routines --------------------------------*/
extern void * HMallocateBlocks(int iNumBlocks);
extern BlockStructPtr HMremoveFromWilderness(int iNumBlocks);
extern void HMfreeBlocks(BlockStructPtr p);
extern BlockStructPtr HMremoveSize(int iSize);
extern BlockStructPtr HMremoveAddress(BlockStructPtr pHdrBlk);
/* ITL (2/98) */
#ifdef ALLOC_BARRIERS
extern long HMlargestContiguousChunk();
extern long HMlargestElementInTree();
extern int HMcurrentAllocationState();
extern int HMtestIfAllocationStateChanged();
#endif /* ALLOC_BARRIERS */
#ifdef PURPLE_ASYNC_TRIGGER
extern int iBlocksInPartially[sizeof(binsizes)/sizeof(int)];
extern int iLargestBin;
extern int iBlocksInLargest;
#define MIN_BLOCK_IN_BIN (int)(iBlocksInLargest*0.2)
#define MIN_BLOCK_AFTER_SWEEP 50
#define SMALLEST_BIN_CHECKED GetActualIndex(128)
#endif
void HMstartSweep(); /*ibm.5404*/
/*ibm.6565*/
#define INDEX 0
#define ACTUALSIZE 1
#define GetActualIndex(requestedSize) aGeneralBinVector[requestedSize][INDEX]
#define AllocateSize(size) aGeneralBinVector[size][ACTUALSIZE]
#define SizeToAllocationSize(n0) (n0 + HANDLE_SIZE + (OBJECTGRAIN - 1)) & ~(OBJECTGRAIN - 1)
extern int aGeneralBinVector[MAX_SMALL_OBJECT+1][2];
#define InitializeChunk(__vpChunk,__mptr,__obj_type,__ee) \
{ \
__vpChunk->methods = __mptr; \
__vpChunk->locknflags = obj_makelocknflags(__obj_type, \
__obj_type ? OBJ_IsArray : 0); \
__ee->cantCooperate=TRUE; \
SET_COLOR(__vpChunk,allocationColor); \
__ee->cantCooperate=FALSE; \
sysAssert(ValidHandle(__vpChunk)); \
}
#define TOTAL_BIN_SIZES 32
extern int binsizes[TOTAL_BIN_SIZES];
#ifdef IBM_MVS
/* ibm.7978 Kathy -- dynamic bin vectors number, start */
extern void * volatile *paActualBinVectorArray;
#define EESetBin(__ee,__n) \
{ \
__ee->AllocVecNum = __n ; \
__ee->pBin = (JHandle (* volatile (*) ) ) \
&paActualBinVectorArray[(__ee->AllocVecNum)*TOTAL_BIN_SIZES]; \
}
/* ibm.7978 Kathy -- dynamic bin vectors number, end */
#endif /* IBM_MVS */
/*
* Use __ for all identifiers to avoid aliasing.
*/
#define allocate(__mptr, \
__iSize, \
__index, \
__obj_type, \
__ee, \
__vpChunk) \
{ \
if( __index >= 0 ) \
{ \
JHandle *__vpNextChunk; \
JHandle *volatile *__pBin=&__ee->pBin[__index]; \
\
__vpChunk = *__pBin; \
if(!__vpChunk) \
goto call; \
sysAssert(MaybeValidHandle(__vpChunk)); \
\
__vpNextChunk = (JHandle *)NextChunk(__vpChunk); \
sysAssert((!__vpChunk)||MaybeValidHandle(__vpChunk)); \
\
if (!CMP_AND_SWP(__pBin, __vpChunk, __vpNextChunk)) \
goto call; \
\
sysAssert(*__pBin!=__vpChunk); \
\
InitializeChunk(__vpChunk,__mptr,__obj_type,__ee); \
goto exit; \
\
} \
call: \
__vpChunk=(JHandle*)(HMallocate(__iSize,__index,__mptr,__obj_type,__ee)); \
exit: \
; \
}
/*ibm.6565*/
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -