Пример #1
0
static J9Pool *
createNewPool(OMRPortLibrary *portLib, PoolInputData *input)
{
	uint32_t expectedNumElems = (input->numberElements == 0) ? 1 : input->numberElements;
	uint32_t expectedAlignment = (input->elementAlignment == 0) ? MIN_GRANULARITY : input->elementAlignment;

	J9Pool *pool = pool_new(
					input->structSize,
					input->numberElements,
					input->elementAlignment,
					input->poolFlags,
					OMR_GET_CALLSITE(),
					OMRMEM_CATEGORY_VM,
					POOL_FOR_PORT(portLib));

	/* Check that creation succeeded */
	if (NULL == pool) {
		return NULL;
	}

	if (pool->puddleAllocSize < ((expectedNumElems * ROUND_TO(expectedAlignment, input->structSize)) + ROUND_TO(expectedAlignment, sizeof(J9PoolPuddle)))) {
		pool_kill(pool);
		return NULL;
	}
	else if ((input->poolFlags & POOL_ROUND_TO_PAGE_SIZE) && (pool->puddleAllocSize < OS_PAGE_SIZE)) {
		pool_kill(pool);
		return NULL;
	}
	return pool;
}
Пример #2
0
J9Pool *
MM_ConfigurationSegregated::createEnvironmentPool(MM_EnvironmentBase *env)
{
	OMRPORT_ACCESS_FROM_OMRPORT(env->getPortLibrary());

	uintptr_t numberOfElements = getConfigurationDelegate()->getInitialNumberOfPooledEnvironments(env);
	/* number of elements, pool flags = 0, 0 selects default pool configuration (at least 1 element, puddle size rounded to OS page size) */
	return pool_new(sizeof(MM_EnvironmentBase), numberOfElements, sizeof(uint64_t), 0, OMR_GET_CALLSITE(), OMRMEM_CATEGORY_MM, POOL_FOR_PORT(OMRPORTLIB));
}
Пример #3
0
/*
 * Prepares the specified hook interface for first use.
 *
 * This function may be called directly.
 *
 * Returns 0 on success, non-zero on failure
 */
intptr_t
J9HookInitializeInterface(struct J9HookInterface **hookInterface, OMRPortLibrary *portLib, size_t interfaceSize)
{
	J9CommonHookInterface *commonInterface = (J9CommonHookInterface *)hookInterface;

	memset(commonInterface, 0, interfaceSize);

	commonInterface->hookInterface = (J9HookInterface *)GLOBAL_TABLE(hookFunctionTable);

	commonInterface->size = interfaceSize;

	if (omrthread_monitor_init_with_name(&commonInterface->lock, 0, "Hook Interface")) {
		J9HookShutdownInterface(hookInterface);
		return J9HOOK_ERR_NOMEM;
	}

	commonInterface->pool = pool_new(sizeof(J9HookRecord), 0, 0, 0, OMR_GET_CALLSITE(), OMRMEM_CATEGORY_VM, POOL_FOR_PORT((OMRPortLibrary *)portLib));
	if (commonInterface->pool == NULL) {
		J9HookShutdownInterface(hookInterface);
		return J9HOOK_ERR_NOMEM;
	}

	commonInterface->nextAgentID = J9HOOK_AGENTID_DEFAULT + 1;
	commonInterface->portLib = portLib;
	commonInterface->threshold4Trace = OMRHOOK_DEFAULT_THRESHOLD_IN_MILLISECONDS_WARNING_CALLBACK_ELAPSED_TIME;

	commonInterface->eventSize = (interfaceSize - sizeof(J9CommonHookInterface)) / (sizeof(U_8) + sizeof(OMREventInfo4Dump) + sizeof(J9HookRecord*));
	return 0;
}
Пример #4
0
/**
 * Request to create sweepPoolState class for pool
 * @param  memoryPool memory pool to attach sweep state to
 * @return pointer to created class
 */
void *
MM_ParallelSweepScheme::createSweepPoolState(MM_EnvironmentBase *env, MM_MemoryPool *memoryPool)
{
	OMRPORT_ACCESS_FROM_OMRPORT(env->getPortLibrary());

	omrthread_monitor_enter(_mutexSweepPoolState);
	if (NULL == _poolSweepPoolState) {
		_poolSweepPoolState = pool_new(sizeof(MM_SweepPoolState), 0, 2 * sizeof(uintptr_t), 0, OMR_GET_CALLSITE(), OMRMEM_CATEGORY_MM, POOL_FOR_PORT(OMRPORTLIB));
		if (NULL == _poolSweepPoolState) {
			omrthread_monitor_exit(_mutexSweepPoolState);
			return NULL;
		}
	}
	omrthread_monitor_exit(_mutexSweepPoolState);
	
	return MM_SweepPoolState::newInstance(env, _poolSweepPoolState, _mutexSweepPoolState, memoryPool);
}
Пример #5
0
J9Pool*
MM_ConfigurationStandard::createEnvironmentPool(MM_EnvironmentBase* env)
{
	OMRPORT_ACCESS_FROM_OMRPORT(env->getPortLibrary());

	uintptr_t numberElements = _configurationLanguageInterface->getEnvPoolNumElements();
	uintptr_t poolFlags = _configurationLanguageInterface->getEnvPoolFlags();

	return pool_new(sizeof(MM_EnvironmentStandard), numberElements, sizeof(uint64_t), poolFlags, OMR_GET_CALLSITE(), OMRMEM_CATEGORY_MM, POOL_FOR_PORT(OMRPORTLIB));
}
Пример #6
0
/*
 * Prepares the specified hook interface for first use.
 *
 * This function may be called directly.
 *
 * Returns 0 on success, non-zero on failure
 */
intptr_t
J9HookInitializeInterface(struct J9HookInterface **hookInterface, OMRPortLibrary *portLib, size_t interfaceSize)
{
	J9CommonHookInterface *commonInterface = (J9CommonHookInterface *)hookInterface;

	memset(commonInterface, 0, interfaceSize);

	commonInterface->hookInterface = (J9HookInterface *)GLOBAL_TABLE(hookFunctionTable);

	commonInterface->size = interfaceSize;

	if (omrthread_monitor_init_with_name(&commonInterface->lock, 0, "Hook Interface")) {
		J9HookShutdownInterface(hookInterface);
		return J9HOOK_ERR_NOMEM;
	}

	commonInterface->pool = pool_new(sizeof(J9HookRecord), 0, 0, 0, OMR_GET_CALLSITE(), OMRMEM_CATEGORY_VM, POOL_FOR_PORT((OMRPortLibrary *)portLib));
	if (commonInterface->pool == NULL) {
		J9HookShutdownInterface(hookInterface);
		return J9HOOK_ERR_NOMEM;
	}

	commonInterface->nextAgentID = J9HOOK_AGENTID_DEFAULT + 1;

	return 0;
}