int32_t GCConfigTest::removeObjectFromParentSlot(const char *name, omrobjectptr_t parentPtr) { OMRPORT_ACCESS_FROM_OMRVM(exampleVM->_omrVM); int32_t rt = 1; GC_ObjectIterator objectIterator(exampleVM->_omrVM, parentPtr); GC_SlotObject *slotObject = NULL; ObjectEntry *objEntry; rt = objectTable.find(&objEntry, name); if (0 != rt) { omrtty_printf("%s:%d Could not find object %s in hash table.\n", __FILE__, __LINE__, name); goto done; } while (NULL != (slotObject = objectIterator.nextSlot())) { if (objEntry->objPtr == slotObject->readReferenceFromSlot()) { slotObject->writeReferenceToSlot(NULL); rt = 0; break; } } if (0 != rt) { omrtty_printf("%s:%d Failed to find object %s from its parent's slot.\n", __FILE__, __LINE__, name); goto done; } #if defined(OMRGCTEST_DEBUG) omrtty_printf("Remove object %s from its parent's slot.\n", name); #endif done: return rt; }
omr_error_t OMRAgent_OnUnload(OMR_TI const *ti, OMR_VM *vm) { OMRPORT_ACCESS_FROM_OMRVM(vm); omr_error_t rc = testData.rc; OMR_VMThread *vmThread = NULL; if (OMR_ERROR_NONE == rc) { rc = OMRTEST_PRINT_ERROR(ti->BindCurrentThread(vm, NULL, &vmThread)); } if (OMR_ERROR_NONE == rc) { omr_error_t apiRc = OMRTEST_PRINT_ERROR(ti->DeregisterRecordSubscriber(vmThread, testData.subscriptionID)); if (OMR_ERROR_NONE != apiRc) { rc = OMR_ERROR_INTERNAL; } } if (OMR_ERROR_NONE == rc) { rc = OMRTEST_PRINT_ERROR(ti->UnbindCurrentThread(vmThread)); } testData.rc = rc; return rc; }
omr_error_t OMR_MethodDictionary::dupEntryStrings(OMR_MethodDictionaryEntry *dest, const OMR_MethodDictionaryEntry *src) { omr_error_t rc = OMR_ERROR_NONE; OMRPORT_ACCESS_FROM_OMRVM(_vm); for (size_t i = 0; i < _numProperties; i++) { if (NULL != src->propertyValues[i]) { size_t len = strlen(src->propertyValues[i]) + 1; void *copy = omrmem_allocate_memory(len, OMRMEM_CATEGORY_OMRTI); if (NULL != copy) { memcpy(copy, src->propertyValues[i], len); dest->propertyValues[i] = (const char *)copy; } else { rc = OMR_ERROR_OUT_OF_NATIVE_MEMORY; dest->propertyValues[i] = NULL; /* Release previously allocated strings */ for (size_t j = 0; j < i; j++) { omrmem_free_memory((void *)dest->propertyValues[j]); dest->propertyValues[j] = NULL; } break; } } } return rc; }
void OMR_MethodDictionary::formatEntryProperties(const OMR_MethodDictionaryEntry *entry, char **str) const { if (_numProperties == 0) { *str = NULL; } else { OMRPORT_ACCESS_FROM_OMRVM(_vm); size_t buflen = _numProperties; /* space between each property + nul-terminator, might include some extra if we have nulls */ for (size_t i = 0; i < _numProperties; ++i) { if (NULL != entry->propertyValues[i]) { buflen += strlen(entry->propertyValues[i]); } } char *buf = (char *)omrmem_allocate_memory(buflen, OMRMEM_CATEGORY_OMRTI); uintptr_t bufUsed = 0; if (NULL != buf) { bufUsed += omrstr_printf(buf, (uintptr_t)buflen, "%s", entry->propertyValues[0]); for (size_t i = 1; i < _numProperties; ++i) { if (NULL != entry->propertyValues[i]) { bufUsed += omrstr_printf(buf + bufUsed, (uintptr_t)buflen - bufUsed, " %s", entry->propertyValues[i]); } } } *str = buf; } }
OMR_Agent::OMR_Agent(OMR_VM *vm, char const *arg) : _handle(0), _vm(vm), _onload(NULL), _onunload(NULL), _dllpath(NULL), _options(NULL), _state(UNINITIALIZED) { OMRPORT_ACCESS_FROM_OMRVM(_vm); _agentCallbacks.version = 0; _agentCallbacks.onPreFork = onPreForkDefault; _agentCallbacks.onPostForkParent = onPostForkParentDefault; _agentCallbacks.onPostForkChild = onPostForkChildDefault; size_t len = strlen(arg) + 1; _dllpath = (char const *)omrmem_allocate_memory(len, OMRMEM_CATEGORY_VM); if (NULL != _dllpath) { memcpy((void *)_dllpath, arg, len); char *equals = strchr((char *)_dllpath, '='); if (NULL != equals) { *equals = '\0'; /* split the options from the dllpath */ if ('\0' != equals[1]) { _options = &equals[1]; } } _state = INITIALIZED; } }
/** * Commit the address range into physical memory. * @return true if successful, false otherwise. */ bool MM_VirtualMemory::commitMemory(void* address, uintptr_t size) { OMRPORT_ACCESS_FROM_OMRVM(_extensions->getOmrVM()); Assert_MM_true(0 != _pageSize); bool success = true; /* port library takes page aligned addresses and sizes only */ void* commitBase = (void*)MM_Math::roundToFloor(_pageSize, (uintptr_t)address); void* commitTop = (void*)MM_Math::roundToCeiling(_pageSize, (uintptr_t)address + size + _tailPadding); uintptr_t commitSize; if (commitBase <= commitTop) { commitSize = (uintptr_t)commitTop - (uintptr_t)commitBase; } else { /* wrapped around - this is end of the memory */ commitSize = UDATA_MAX - (uintptr_t)commitBase + 1; } if (0 < commitSize) { success = omrvmem_commit_memory(commitBase, commitSize, &_identifier) != 0; } if (success) { Trc_MM_VirtualMemory_commitMemory_success(address, size); } else { Trc_MM_VirtualMemory_commitMemory_failure(address, size); } return success; }
int32_t GCConfigTest::removeObjectFromRootTable(const char *name) { OMRPORT_ACCESS_FROM_OMRVM(exampleVM->_omrVM); int32_t rt = 0; RootEntry searchEntry; RootEntry *rEntryPtr = NULL; searchEntry.name = name; rEntryPtr = (RootEntry *)hashTableFind(exampleVM->rootTable, &searchEntry); if (NULL == rEntryPtr) { rt = 1; omrtty_printf("%s:%d Failed to find root object %s in root table.\n", __FILE__, __LINE__, name); goto done; } if (0 != hashTableRemove(exampleVM->rootTable, rEntryPtr)) { rt = 1; omrtty_printf("%s:%d Failed to remove root object %s from root table!\n", __FILE__, __LINE__, name); goto done; } #if defined(OMRGCTEST_DEBUG) omrtty_printf("Remove object(%s) from root table.\n", name); #endif done: return rt; }
bool MM_VirtualMemory::setNumaAffinity(uintptr_t numaNode, void* address, uintptr_t byteAmount) { Assert_MM_true(0 != _pageSize); /* start address must be above heap start address */ Assert_MM_true(address >= _heapBase); /* start address must be below heap top address */ Assert_MM_true(address <= _heapTop); /* start address must be aligned to physical page size */ Assert_MM_true(0 == ((uintptr_t)address % _pageSize)); void* topAddress = (void*)((uintptr_t)address + byteAmount); /* top address must be above heap start address */ Assert_MM_true(topAddress >= _heapBase); /* top address must be below heap top address */ Assert_MM_true(topAddress <= _heapTop); bool didSetAffinity = true; if (_extensions->_numaManager.isPhysicalNUMASupported()) { OMRPORT_ACCESS_FROM_OMRVM(_extensions->getOmrVM()); uintptr_t byteAmountPageAligned = MM_Math::roundToCeiling(_pageSize, byteAmount); /* aligned high address might be higher then heapTop but * must be in the heap reserved memory range */ Assert_MM_true(((uintptr_t)address + byteAmountPageAligned) <= ((uintptr_t)_heapBase + _reserveSize)); didSetAffinity = (0 == omrvmem_numa_set_affinity(numaNode, address, byteAmountPageAligned, &_identifier)); } return didSetAffinity; }
int32_t GCConfigTest::attachChildEntry(ObjectEntry *parentEntry, ObjectEntry *childEntry) { int32_t rc = 0; MM_GCExtensionsBase *extensions = (MM_GCExtensionsBase *)exampleVM->_omrVM->_gcOmrVMExtensions; uintptr_t size = extensions->objectModel.getConsumedSizeInBytesWithHeader(parentEntry->objPtr); fomrobject_t *firstSlot = (fomrobject_t *)parentEntry->objPtr + 1; fomrobject_t *endSlot = (fomrobject_t *)((uint8_t *)parentEntry->objPtr + size); uintptr_t slotCount = endSlot - firstSlot; OMRPORT_ACCESS_FROM_OMRVM(exampleVM->_omrVM); if ((uint32_t)parentEntry->numOfRef < slotCount) { fomrobject_t *childSlot = firstSlot + parentEntry->numOfRef; #if defined(OMR_GC_MODRON_SCAVENGER) cli->generationalWriteBarrierStore(exampleVM->_omrVMThread, parentEntry->objPtr, childSlot, childEntry->objPtr); #endif /* OMR_GC_MODRON_SCAVENGER */ #if defined(OMRGCTEST_DEBUG) omrtty_printf("\tadd child %s(%p[0x%llx]) to parent %s(%p[0x%llx]) slot %p[%llx].\n", childEntry->name, childEntry->objPtr, *(childEntry->objPtr), parentEntry->name, parentEntry->objPtr, *(parentEntry->objPtr), childSlot, (uintptr_t)*childSlot); #endif parentEntry->numOfRef += 1; } else { omrtty_printf("%s:%d Invalid XML input: numOfFields %d defined for %s(%p[0x%llx]) is not enough to hold child reference for %s(%p[0x%llx]).\n", __FILE__, __LINE__, parentEntry->numOfRef, parentEntry->name, parentEntry->objPtr, *(parentEntry->objPtr), childEntry->name, childEntry->objPtr, *(childEntry->objPtr)); rc = 1; } return rc; }
bool MM_VerboseHandlerOutput::getThreadName(char *buf, uintptr_t bufLen, OMR_VMThread *vmThread) { OMRPORT_ACCESS_FROM_OMRVM(_omrVM); omrstr_printf(buf, bufLen, "OMR_VMThread [%p]",vmThread); return true; }
void OMR_MethodDictionary::print() { OMRPORT_ACCESS_FROM_OMRVM(_vm); omrtty_printf("OMR Method Dictionary\n"); omrtty_printf("=====================\n"); omrtty_printf("%016s %032s %032s %032s %10s\n", "key", "methodName", "className", "fileName", "lineNumber"); hashTableForEachDo(_hashTable, OMR_MethodDictionary::printEntry, this); }
void omr_ras_cleanupMethodDictionary(OMR_VM *vm) { if (NULL != vm->_methodDictionary) { OMRPORT_ACCESS_FROM_OMRVM(vm); ((OMR_MethodDictionary *)vm->_methodDictionary)->cleanup(); omrmem_free_memory(vm->_methodDictionary); vm->_methodDictionary = NULL; } }
bool MM_VirtualMemory::freeMemory() { OMRPORT_ACCESS_FROM_OMRVM(_extensions->getOmrVM()); bool success = (0 == omrvmem_free_memory(_baseAddress, _reserveSize, &_identifier)); if (success) { _baseAddress = NULL; _reserveSize = 0; } return success; }
uintptr_t OMR_MethodDictionary::cleanupEntryStrings(void *entry, void *userData) { OMR_MethodDictionary *md = (OMR_MethodDictionary *)userData; OMR_MethodDictionaryEntry *mdEntry = (OMR_MethodDictionaryEntry *)entry; OMRPORT_ACCESS_FROM_OMRVM(md->_vm); for (size_t i = 0; i < md->_numProperties; ++i) { omrmem_free_memory((void *)mdEntry->propertyValues[i]); mdEntry->propertyValues[i] = NULL; } return FALSE; /* don't remove the entry */ }
void OMR_Agent::destroyAgent(OMR_Agent *agent) { if (NULL != agent) { OMRPORT_ACCESS_FROM_OMRVM(agent->_vm); if ((0 != agent->_handle) && (ONUNLOAD_SUCCESS == agent->_state)) { omrsl_close_shared_library(agent->_handle); } omrmem_free_memory((void *)agent->_dllpath); omrmem_free_memory((void *)agent); } }
uintptr_t MM_VerboseHandlerOutput::getTagTemplate(char *buf, uintptr_t bufsize, uintptr_t id, const char *type, uintptr_t contextId, uint64_t timeus, uint64_t wallTimeMs) { OMRPORT_ACCESS_FROM_OMRVM(_omrVM); uintptr_t bufPos = 0; bufPos += omrstr_printf(buf, bufsize, "id=\"%zu\" type=\"%s\" timems=\"%llu.%03.3llu\" contextid=\"%zu\" timestamp=\"", id, type, timeus / 1000, timeus % 1000, contextId); bufPos += omrstr_ftime(buf + bufPos, bufsize - bufPos, VERBOSEGC_DATE_FORMAT_PRE_MS, wallTimeMs); bufPos += omrstr_printf(buf + bufPos, bufsize - bufPos, "%03llu", wallTimeMs % 1000); bufPos += omrstr_ftime(buf + bufPos, bufsize - bufPos, VERBOSEGC_DATE_FORMAT_POST_MS, wallTimeMs); bufPos += omrstr_printf(buf + bufPos, bufsize - bufPos, "\""); return bufPos; }
uintptr_t MM_VerboseHandlerOutput::getTagTemplate(char *buf, uintptr_t bufsize, uint64_t wallTimeMs) { OMRPORT_ACCESS_FROM_OMRVM(_omrVM); uintptr_t bufPos = 0; bufPos += omrstr_printf(buf, bufsize, "timestamp=\""); bufPos += omrstr_ftime(buf + bufPos, bufsize - bufPos, VERBOSEGC_DATE_FORMAT_PRE_MS, wallTimeMs); bufPos += omrstr_printf(buf + bufPos, bufsize - bufPos, "%03llu", wallTimeMs % 1000); bufPos += omrstr_ftime(buf + bufPos, bufsize - bufPos, VERBOSEGC_DATE_FORMAT_POST_MS, wallTimeMs); bufPos += omrstr_printf(buf + bufPos, bufsize - bufPos, "\""); return bufPos; }
int J9THREAD_PROC MM_MasterGCThread::master_thread_proc(void *info) { MM_MasterGCThread *masterGCThread = (MM_MasterGCThread*)info; MM_GCExtensionsBase *extensions = masterGCThread->_extensions; OMR_VM *omrVM = extensions->getOmrVM(); OMRPORT_ACCESS_FROM_OMRVM(omrVM); uintptr_t rc = 0; omrsig_protect(master_thread_proc2, info, ((MM_ParallelDispatcher *)extensions->dispatcher)->getSignalHandler(), omrVM, OMRPORT_SIG_FLAG_SIGALLSYNC | OMRPORT_SIG_FLAG_MAY_CONTINUE_EXECUTION, &rc); return 0; }
void OMR_MethodDictionary::traceInsertEntryReplace(const OMR_MethodDictionaryEntry *newEntry) const { if (TrcEnabled_Trc_OMRPROF_insertMethodDictionary_replaceExistingEntry) { OMRPORT_ACCESS_FROM_OMRVM(_vm); char *propertyStr = NULL; formatEntryProperties(newEntry, &propertyStr); if (NULL == propertyStr) { Trc_OMRPROF_insertMethodDictionary_replaceExistingEntry(newEntry->key, ""); } else { Trc_OMRPROF_insertMethodDictionary_replaceExistingEntry(newEntry->key, propertyStr); omrmem_free_memory(propertyStr); } } }
void OMR_MethodDictionary::traceInsertEntryFailed(omr_error_t rc, const OMR_MethodDictionaryEntry *newEntry) const { if (TrcEnabled_Trc_OMRPROF_insertMethodDictionary_failed) { OMRPORT_ACCESS_FROM_OMRVM(_vm); char *propertyStr = NULL; formatEntryProperties(newEntry, &propertyStr); if (NULL == propertyStr) { Trc_OMRPROF_insertMethodDictionary_failed(rc, newEntry->key, ""); } else { Trc_OMRPROF_insertMethodDictionary_failed(rc, newEntry->key, propertyStr); omrmem_free_memory(propertyStr); } } }
uintptr_t OMR_MethodDictionary::printEntry(void *entry, void *userData) { OMR_MethodDictionary *md = (OMR_MethodDictionary *)userData; OMR_MethodDictionaryEntry *mdEntry = (OMR_MethodDictionaryEntry *)entry; OMRPORT_ACCESS_FROM_OMRVM(md->_vm); omrtty_printf("%016p", mdEntry->key); for (size_t i = 0; i < md->_numProperties; ++i) { if (mdEntry->propertyValues[i]) { omrtty_printf(" %s", mdEntry->propertyValues[i]); } } omrtty_printf("\n"); return FALSE; /* don't remove the entry */ }
void MM_MarkingDelegate::masterCleanupAfterGC(MM_EnvironmentBase *env) { OMRPORT_ACCESS_FROM_OMRVM(env->getOmrVM()); J9HashTableState state; ObjectEntry *objEntry = NULL; OMR_VM_Example *omrVM = (OMR_VM_Example *)env->getOmrVM()->_language_vm; objEntry = (ObjectEntry *)hashTableStartDo(omrVM->objectTable, &state); while (objEntry != NULL) { if (!_markingScheme->isMarked(objEntry->objPtr)) { omrmem_free_memory((void *)objEntry->name); objEntry->name = NULL; hashTableDoRemove(&state); } objEntry = (ObjectEntry *)hashTableNextDo(&state); } }
OMR_Agent * OMR_Agent::createAgent(OMR_VM *vm, char const *arg) { OMR_Agent *newAgent = NULL; if (NULL != arg) { OMRPORT_ACCESS_FROM_OMRVM(vm); newAgent = (OMR_Agent *)omrmem_allocate_memory(sizeof(*newAgent), OMRMEM_CATEGORY_VM); if (NULL != newAgent) { new(newAgent) OMR_Agent(vm, arg); if (INITIALIZED != newAgent->_state) { destroyAgent(newAgent); newAgent = NULL; } } } return newAgent; }
/* * Test scenario for CorruptedAgent: * - create an empty agent file * - call omr_agent_create() and OMR_Agent::createAgent by providing the empty agent file * - expect openLibrary() to fail */ TEST_F(RASAgentNegativeTest, CorruptedAgent) { intptr_t fileDescriptor; char fileName[256]; char agentName[256]; char hostname[128]; OMRPORT_ACCESS_FROM_OMRVM(&testVM.omrVM); ASSERT_EQ(0, gethostname(hostname, sizeof(hostname))); /* generate machine specific file name to prevent conflict between multiple tests running on shared drive */ omrstr_printf(agentName, sizeof(agentName), "corruptedAgent_%s", hostname); /* create fileName with platform-dependent shared library prefix & suffix. * for Windows, fileName = corruptedAgent_<hostname>.dll * for Unix, fileName = libcorruptedAgent_<hostname>.so * for OSX, fileName = libcorruptedAgent_<hostname>.dylib */ #if defined(WIN32) || defined(WIN64) omrstr_printf(fileName, sizeof(fileName), "%s.dll", agentName); #elif defined(OSX) omrstr_printf(fileName, sizeof(fileName), "lib%s.dylib", agentName); #else /* defined(OSX) */ omrstr_printf(fileName, sizeof(fileName), "lib%s.so", agentName); #endif /* defined(WIN32) || defined(WIN64) */ /* create the empty agent file with permission 751*/ fileDescriptor = omrfile_open(fileName, EsOpenCreate | EsOpenWrite, 0751); ASSERT_NE(-1, fileDescriptor) << "omrfile_open \"" << fileName << "\" failed"; omrfile_close(fileDescriptor); /* call omr_agent_create() by providing the empty agent file */ struct OMR_Agent *agentC = omr_agent_create(&testVM.omrVM, agentName); ASSERT_FALSE(NULL == agentC) << "testAgent: createAgent() " << agentName << " failed"; OMRTEST_ASSERT_ERROR(OMR_ERROR_ILLEGAL_ARGUMENT, omr_agent_openLibrary(agentC)); /* call OMR_Agent::createAgent() by providing the empty agent file */ OMR_Agent *agentCPP = OMR_Agent::createAgent(&testVM.omrVM, agentName); ASSERT_FALSE(NULL == agentCPP) << "testAgent: createAgent() failed"; OMRTEST_ASSERT_ERROR(OMR_ERROR_ILLEGAL_ARGUMENT, agentCPP->openLibrary()); omrfile_unlink(fileName); }
bool MM_VerboseManagerImpl::configureVerboseGC(OMR_VM *omrVM, char *filename, uintptr_t fileCount, uintptr_t iterations) { OMRPORT_ACCESS_FROM_OMRVM(omrVM); if (!MM_VerboseManager::configureVerboseGC(omrVM, filename, fileCount, iterations)) { return false; } this->fileCount = fileCount; this->iterations = iterations; size_t len = strlen(filename); this->filename = (char *)omrmem_allocate_memory(len+1, OMRMEM_CATEGORY_MM); if (NULL == this->filename) { return false; } strcpy(this->filename, filename); return true; }
omr_error_t omr_ras_initMethodDictionary(OMR_VM *vm, size_t numProperties, const char * const *propertyNames) { omr_error_t rc = OMR_ERROR_NONE; if (NULL == vm->_methodDictionary) { OMRPORT_ACCESS_FROM_OMRVM(vm); OMR_MethodDictionary *methodDictionary = (OMR_MethodDictionary *)omrmem_allocate_memory(sizeof(*methodDictionary), OMRMEM_CATEGORY_OMRTI); if (NULL != methodDictionary) { rc = methodDictionary->init(vm, numProperties, propertyNames); if (OMR_ERROR_NONE == rc) { vm->_methodDictionary = methodDictionary; } else { omrmem_free_memory(methodDictionary); } } else { rc = OMR_ERROR_OUT_OF_NATIVE_MEMORY; } } return rc; }
bool MM_VerboseManagerImpl::reconfigureVerboseGC(OMR_VM *omrVM) { OMRPORT_ACCESS_FROM_OMRVM(omrVM); /* If the pid is specified in the filename, then the pid of the * new process will be used during verbose reinitialization, * otherwise we append the pid of the child before the extension. */ WriterType type = parseWriterType(NULL, filename, 0, 0); /* All parameters other than filename aren't used */ if ( ((type == VERBOSE_WRITER_FILE_LOGGING_SYNCHRONOUS) || (type == VERBOSE_WRITER_FILE_LOGGING_BUFFERED)) && (NULL == strstr(filename, "%p")) && (NULL == strstr(filename, "%pid")) ) { #define MAX_PID_LENGTH 16 char pidStr[MAX_PID_LENGTH]; uintptr_t pid = omrsysinfo_get_pid(); int pidLen = snprintf(pidStr,MAX_PID_LENGTH, "_%lu",(long unsigned int)pid); /* Allocate new buffer */ char *newLog = (char *)omrmem_allocate_memory(pidLen+strlen(filename)+1, OMRMEM_CATEGORY_MM); /* Locate extension, if any */ char *extension = strchr(filename, '.'); if (NULL != extension) { size_t nameLen = extension - filename; size_t extLen = strlen(filename) - nameLen; strncpy(newLog, filename, nameLen); strncpy(newLog + nameLen, pidStr, pidLen); strncpy(newLog + nameLen + pidLen, extension, extLen); newLog[nameLen + pidLen + extLen] = '\0'; /* strncpy does NOT NULL terminate */ } else { size_t len = strlen(filename); strncpy(newLog,filename,len); newLog[len] = '\0'; /* strncpy does NOT NULL terminate */ strncat(newLog,pidStr,pidLen); /* strncat does NULL terminate */ } omrmem_free_memory(this->filename); filename = newLog; } return MM_VerboseManager::configureVerboseGC(omrVM, filename, 1, 0); }
int32_t GCConfigTest::removeObjectFromObjectTable(const char *name) { OMRPORT_ACCESS_FROM_OMRVM(exampleVM->_omrVM); int32_t rt = 1; ObjectEntry *foundEntry = find(name); if (NULL == foundEntry) { omrtty_printf("%s:%d Failed to find object %s in object table.\n", __FILE__, __LINE__, name); goto done; } if (0 != hashTableRemove(exampleVM->objectTable, foundEntry)) { omrtty_printf("%s:%d Failed to remove object %s from object table!\n", __FILE__, __LINE__, name); goto done; } #if defined(OMRGCTEST_DEBUG) omrtty_printf("Remove object %s(%p[0x%llx]) from object table.\n", name, foundEntry->objPtr, *(foundEntry->objPtr)); #endif rt = 0; done: return rt; }
int32_t GCConfigTest::insertGarbage() { OMRPORT_ACCESS_FROM_OMRVM(exampleVM->_omrVM); int32_t rt = 0; char fullNamePrefix[MAX_NAME_LENGTH]; omrstr_printf(fullNamePrefix, sizeof(fullNamePrefix), "%s_%d", gp.namePrefix, gp.garbageSeq++); int32_t breadth = 2; uintptr_t totalSize = (uintptr_t)(gp.accumulatedSize * gp.percentage) / 100; uintptr_t objSize = 0; if (0 == strcmp(gp.structure, "node")) { objSize = totalSize; } else if (0 == strcmp(gp.structure, "tree")) { objSize = 64; } #if defined(OMRGCTEST_DEBUG) omrtty_printf("Inserting garbage %s of %dB (%f%% of previous object/tree size %dB) ...\n", fullNamePrefix, totalSize, gp.percentage, gp.accumulatedSize); #endif omrobjectptr_t rootObj = NULL; rt = createFixedSizeTree(&rootObj, fullNamePrefix, GARBAGE_ROOT, totalSize, objSize, breadth); OMRGCTEST_CHECK_RT(rt); /* remove garbage root object from the root set */ if (NULL != rootObj) { char rootObjName[MAX_NAME_LENGTH]; omrstr_printf(rootObjName, MAX_NAME_LENGTH, "%s_%d_%d", fullNamePrefix, 0, 0); rt = removeObjectFromRootTable(rootObjName); OMRGCTEST_CHECK_RT(rt); } /* reset accumulatedSize */ gp.accumulatedSize = 0; done: return rt; }
omr_error_t OMR_Agent::openLibrary(void) { omr_error_t rc = OMR_ERROR_NONE; if (INITIALIZED != _state) { rc = OMR_ERROR_ILLEGAL_ARGUMENT; } else { uintptr_t portRc = 0; OMRPORT_ACCESS_FROM_OMRVM(_vm); portRc = omrsl_open_shared_library((char *)_dllpath, &_handle, OMRPORT_SLOPEN_DECORATE | OMRPORT_SLOPEN_LAZY); if (0 != portRc) { _state = OPEN_LIBRARY_ERROR; rc = OMR_ERROR_ILLEGAL_ARGUMENT; } if (OMR_ERROR_NONE == rc) { portRc = omrsl_lookup_name(_handle, (char *)"OMRAgent_OnLoad", (uintptr_t *)&_onload, (char *)"IPPPP"); if (0 != portRc) { _state = LOOKUP_ONLOAD_ERROR; rc = OMR_ERROR_ILLEGAL_ARGUMENT; } } if (OMR_ERROR_NONE == rc) { portRc = omrsl_lookup_name(_handle, (char *)"OMRAgent_OnUnload", (uintptr_t *)&_onunload, (char *)"IPP"); if (0 != portRc) { _state = LOOKUP_ONUNLOAD_ERROR; rc = OMR_ERROR_ILLEGAL_ARGUMENT; } } if (OMR_ERROR_NONE == rc) { _state = LIBRARY_OPENED; } } return rc; }