本文整理汇总了C++中MM_MemorySubSpace::allocateTLH方法的典型用法代码示例。如果您正苦于以下问题:C++ MM_MemorySubSpace::allocateTLH方法的具体用法?C++ MM_MemorySubSpace::allocateTLH怎么用?C++ MM_MemorySubSpace::allocateTLH使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MM_MemorySubSpace
的用法示例。
在下文中一共展示了MM_MemorySubSpace::allocateTLH方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getRefreshSize
/**
* Refresh the TLH.
*/
bool
MM_TLHAllocationSupport::refresh(MM_EnvironmentBase *env, MM_AllocateDescription *allocDescription, bool shouldCollectOnFailure)
{
MM_GCExtensionsBase* extensions = env->getExtensions();
/* Refresh the TLH only if the allocation request will fit in half the refresh size
* or in the TLH minimum size.
*/
uintptr_t sizeInBytesRequired = allocDescription->getContiguousBytes();
uintptr_t tlhMinimumSize = extensions->tlhMinimumSize;
uintptr_t tlhMaximumSize = extensions->tlhMaximumSize;
uintptr_t halfRefreshSize = getRefreshSize() >> 1;
uintptr_t abandonSize = (tlhMinimumSize > halfRefreshSize ? tlhMinimumSize : halfRefreshSize);
if (sizeInBytesRequired > abandonSize) {
/* increase thread hungriness if we did not refresh */
if (getRefreshSize() < tlhMaximumSize && sizeInBytesRequired < tlhMaximumSize) {
setRefreshSize(getRefreshSize() + extensions->tlhIncrementSize);
}
return false;
}
MM_AllocationStats *stats = _objectAllocationInterface->getAllocationStats();
stats->_tlhDiscardedBytes += getSize();
/* Try to cache the current TLH */
if (NULL != getRealAlloc() && getSize() >= tlhMinimumSize) {
/* Cache the current TLH because it is bigger than the minimum size */
MM_HeapLinkedFreeHeaderTLH* newCache = (MM_HeapLinkedFreeHeaderTLH*)getRealAlloc();
newCache->setSize(getSize());
newCache->_memoryPool = getMemoryPool();
newCache->_memorySubSpace = getMemorySubSpace();
newCache->setNext(_abandonedList);
_abandonedList = newCache;
++_abandonedListSize;
if (_abandonedListSize > stats->_tlhMaxAbandonedListSize) {
stats->_tlhMaxAbandonedListSize = _abandonedListSize;
}
wipeTLH(env);
} else {
clear(env);
}
bool didRefresh = false;
/* Try allocating a TLH */
if ((NULL != _abandonedList) && (sizeInBytesRequired <= tlhMinimumSize)) {
/* Try to get a cached TLH */
setupTLH(env, (void *)_abandonedList, (void *)_abandonedList->afterEnd(),
_abandonedList->_memorySubSpace, _abandonedList->_memoryPool);
_abandonedList = (MM_HeapLinkedFreeHeaderTLH *)_abandonedList->getNext();
--_abandonedListSize;
#if defined(OMR_GC_BATCH_CLEAR_TLH)
if (_zeroTLH) {
if (0 != extensions->batchClearTLH) {
memset(getBase(), 0, sizeof(MM_HeapLinkedFreeHeaderTLH));
}
}
#endif /* OMR_GC_BATCH_CLEAR_TLH */
allocDescription->setTLHAllocation(true);
allocDescription->setNurseryAllocation(getMemorySubSpace()->getTypeFlags() == MEMORY_TYPE_NEW);
allocDescription->setMemoryPool(getMemoryPool());
stats->_tlhRefreshCountReused += 1;
stats->_tlhAllocatedReused += getSize();
stats->_tlhDiscardedBytes -= getSize();
didRefresh = true;
} else {
/* Try allocating a fresh TLH */
MM_AllocationContext *ac = env->getAllocationContext();
MM_MemorySpace *memorySpace = _objectAllocationInterface->getOwningEnv()->getMemorySpace();
if (NULL != ac) {
/* ensure that we are allowed to use the AI in this configuration in the Tarok case */
/* allocation contexts currently aren't supported with generational schemes */
Assert_MM_true(memorySpace->getTenureMemorySubSpace() == memorySpace->getDefaultMemorySubSpace());
didRefresh = (NULL != ac->allocateTLH(env, allocDescription, _objectAllocationInterface, shouldCollectOnFailure));
} else {
MM_MemorySubSpace *subspace = memorySpace->getDefaultMemorySubSpace();
didRefresh = (NULL != subspace->allocateTLH(env, allocDescription, _objectAllocationInterface, NULL, NULL, shouldCollectOnFailure));
}
if (didRefresh) {
#if defined(OMR_GC_BATCH_CLEAR_TLH)
if (_zeroTLH) {
if (0 != extensions->batchClearTLH) {
void *base = getBase();
void *top = getTop();
OMRZeroMemory(base, (uintptr_t)top - (uintptr_t)base);
}
}
#endif /* defined(OMR_GC_BATCH_CLEAR_TLH) */
/*
//.........这里部分代码省略.........