bool
MM_HeapRegionManagerTarok::enableRegionsInTable(MM_EnvironmentBase *env, MM_MemoryHandle *handle)
{
	bool result = true;
	MM_GCExtensionsBase *extensions = env->getExtensions();
	MM_MemoryManager *memoryManager = extensions->memoryManager;
	void *lowHeapEdge = memoryManager->getHeapBase(handle);
	void *highHeapEdge = memoryManager->getHeapTop(handle);
	
	/* maintained for RTJ */
	setNodeAndLinkRegions(env, lowHeapEdge, highHeapEdge, 0);

	return result;
}
Beispiel #2
0
bool
MM_HeapVirtualMemory::initializeHeapRegionManager(MM_EnvironmentBase* env, MM_HeapRegionManager* manager)
{
	bool result = false;

	/* since this kind of heap is backed by contiguous memory, tell the heap region manager (which was just
	 * initialized by super) that we want to enable this range of regions for later use.
	 */
	MM_MemoryManager* memoryManager = MM_GCExtensionsBase::getExtensions(_omrVM)->memoryManager;
	void* heapBase = memoryManager->getHeapBase(&_vmemHandle);
	void* heapTop = memoryManager->getHeapTop(&_vmemHandle);

	if (manager->setContiguousHeapRange(env, heapBase, heapTop)) {
		result = manager->enableRegionsInTable(env, &_vmemHandle);
	}

	return result;
}
Beispiel #3
0
bool
MM_HeapVirtualMemory::initialize(MM_EnvironmentBase* env, uintptr_t size)
{
	/* call the superclass to inialize before we do any work */
	if (!MM_Heap::initialize(env)) {
		return false;
	}

	MM_GCExtensionsBase* extensions = env->getExtensions();
	uintptr_t padding = extensions->heapTailPadding;

	uintptr_t effectiveHeapAlignment = _heapAlignment;
	/* we need to ensure that we allocate the heap with region alignment since the region table requires that */
	MM_HeapRegionManager* manager = getHeapRegionManager();
	effectiveHeapAlignment = MM_Math::roundToCeiling(manager->getRegionSize(), effectiveHeapAlignment);

	MM_MemoryManager* memoryManager = extensions->memoryManager;
	bool created = false;
	bool forcedOverflowProtection = false;

	/* Under -Xaggressive ensure a full page of padding -- see JAZZ103 45254 */
	if (extensions->padToPageSize) {
#if (defined(AIXPPC) && !defined(PPC64))
		/*
		 * An attempt to allocate heap with top at 0xffffffff
		 * In this case extra padding is not required because of overflow protection padding can be used instead
		 */
		uintptr_t effectiveSize = MM_Math::roundToCeiling(manager->getRegionSize(), size);
		void *preferredHeapBase = (void *)((uintptr_t)0 - effectiveSize);

		created = memoryManager->createVirtualMemoryForHeap(env, &_vmemHandle, effectiveHeapAlignment, size, padding, preferredHeapBase, (void *)(extensions->heapCeiling));
		if (created) {
			/* overflow protection must be there to play role of padding even top is not so close to the end of the memory */
			forcedOverflowProtection = true;
		} else
#endif /* (defined(AIXPPC) && !defined(PPC64)) */
		{
			/* Ignore extra full page padding if page size is too large (hard coded here for 1G or larger) */
#define ONE_GB ((uintptr_t)1 * 1024 * 1024 * 1024)
			if (extensions->requestedPageSize < ONE_GB)
			{
				if (padding < extensions->requestedPageSize) {
					padding = extensions->requestedPageSize;
				}
			}
		}
	}

	if (!created && !memoryManager->createVirtualMemoryForHeap(env, &_vmemHandle, effectiveHeapAlignment, size, padding, (void*)(extensions->preferredHeapBase), (void*)(extensions->heapCeiling))) {
		return false;
	}

	/* Check we haven't overflowed the address range */
	if (forcedOverflowProtection || (HIGH_ADDRESS - ((uintptr_t)memoryManager->getHeapTop(&_vmemHandle)) < (OVERFLOW_ROUNDING)) || extensions->fvtest_alwaysApplyOverflowRounding) {
		/* Address range overflow */
		memoryManager->roundDownTop(&_vmemHandle, OVERFLOW_ROUNDING);
	}
	extensions->overflowSafeAllocSize = ((HIGH_ADDRESS - (uintptr_t)(memoryManager->getHeapTop(&_vmemHandle))) + 1);

	/* The memory returned might be less than we asked for -- get the actual size */
	_maximumMemorySize = memoryManager->getMaximumSize(&_vmemHandle);

	return true;
}
Beispiel #4
0
/**
 * Answer the highest possible address for the heap that will ever be possible.
 * @return Highest address possible for the heap.
 */
void*
MM_HeapVirtualMemory::getHeapTop()
{
	MM_MemoryManager* memoryManager = MM_GCExtensionsBase::getExtensions(_omrVM)->memoryManager;
	return memoryManager->getHeapTop(&_vmemHandle);
}