void MM_TLHAllocationSupport::setupTLH(MM_EnvironmentBase *env, void *addrBase, void *addrTop, MM_MemorySubSpace *memorySubSpace, MM_MemoryPool *memoryPool) { MM_GCExtensionsBase *extensions = env->getExtensions(); if (extensions->doFrequentObjectAllocationSampling){ updateFrequentObjectsStats(env); } /* Set the new TLH values */ setBase(addrBase); setAlloc(addrBase); setTop(addrTop); if (NULL != memorySubSpace) { setObjectFlags(memorySubSpace->getObjectFlags()); } setMemoryPool(memoryPool); setMemorySubSpace(memorySubSpace); #if defined(OMR_GC_TLH_PREFETCH_FTA) *_pointerToTlhPrefetchFTA = 0; #endif /* OMR_GC_TLH_PREFETCH_FTA */ }
/** * Replenishes the cache for the given size class. The cache for the given size class must be empty. * @param sizeInBytes The size in bytes of a single cell (ie: not the total of bytes in the cache) * @param cacheMemory The head of the new cell linked free list to use as a cache * @param cacheSize The total size of allocatable memory contained in cacheMemory */ void MM_SegregatedAllocationInterface::replenishCache(MM_EnvironmentBase* env, uintptr_t sizeInBytes, void* cacheMemory, uintptr_t cacheSize) { MM_GCExtensionsBase* extensions = env->getExtensions(); uintptr_t* cellLink = (uintptr_t*)cacheMemory; uintptr_t sizeClass = _sizeClasses->getSizeClass(sizeInBytes); /* The allocation cache for the size class being replenished must be empty, otherwise we'd have * to append the cellLink to the end, which would require traversing the list. There should be no * reason to replenish a non-empty cache. */ Assert_MM_true(_allocationCache[sizeClass].current == _allocationCache[sizeClass].top); if (extensions->doFrequentObjectAllocationSampling) { updateFrequentObjectsStats(env, sizeClass); } _allocationCache[sizeClass].current = cellLink; _allocationCacheBases[sizeClass] = cellLink; _allocationCache[sizeClass].top = (uintptr_t *)((uintptr_t)cellLink + cacheSize); if (_cachedAllocationsEnabled) { /* Update the allocation stats. */ _allocationCacheStats.bytesPreAllocatedTotal[sizeClass] += cacheSize; _allocationCacheStats.replenishesTotal[sizeClass] += 1; _allocationCacheStats.bytesPreAllocatedSinceRestart[sizeClass] += cacheSize; _allocationCacheStats.replenishesSinceRestart[sizeClass] += 1; /* Based on the new allocation stats, determine if we should bump up the desired amount of pre-allocated cells. */ if ((_allocationCacheStats.bytesPreAllocatedSinceRestart[sizeClass] >= _replenishSizes[sizeClass]) && (_replenishSizes[sizeClass] < extensions->allocationCacheMaximumSize) ) { _replenishSizes[sizeClass] += extensions->allocationCacheIncrementSize; } } }