void MM_OverflowStandard::handleOverflow(MM_EnvironmentBase *env) { if (env->_currentTask->synchronizeGCThreadsAndReleaseMaster(env, UNIQUE_ID)) { _overflow = false; MM_Heap *heap = _extensions->heap; MM_HeapRegionManager *regionManager = heap->getHeapRegionManager(); GC_HeapRegionIterator regionIterator(regionManager); MM_HeapRegionDescriptor *region = NULL; // MM_ParallelGlobalGC *globalCollector = (MM_ParallelGlobalGC *)_extensions->getGlobalCollector(); MM_MarkMap *markMap = env->getMarkingEnvironment()->markingExtensions()->markMap(); while((region = regionIterator.nextRegion()) != NULL) { GC_ObjectHeapIteratorAddressOrderedList objectIterator(_extensions, region, false); omrobjectptr_t object; while((object = objectIterator.nextObject()) != NULL) { /* search for double marked (overflowed) objects */ if ((markMap->isBitSet(object)) && (markMap->isBitSet((omrobjectptr_t)((uintptr_t)object + markMap->getObjectGrain())))) { /* clean overflow mark */ markMap->clearBit((omrobjectptr_t)((uintptr_t)object + markMap->getObjectGrain())); /* scan overflowed object */ OMR::App::ObjectScanner().scanObject(env, env->getMarkingEnvironment(), object, SCAN_REASON_OVERFLOWED_OBJECT); } } } env->_currentTask->releaseSynchronizedGCThreads(env); } }
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; }
/** * walk through slots of mixed object and apply the user function. */ static void heapWalkerObjectSlotDo(OMR_VM *omrVM, omrobjectptr_t object, MM_HeapWalkerSlotFunc oSlotIterator, void *localUserData) { GC_ObjectIterator objectIterator(omrVM, object); GC_SlotObject *slotObject; while ((slotObject = objectIterator.nextSlot()) != NULL) { heapWalkerObjectFieldSlotDo(omrVM, object, slotObject, oSlotIterator, localUserData); } }
void TargetsDialog::createTargetFromSelection() { if (StelApp::getInstance().getStelObjectMgr().getWasSelected()) { QList<StelObjectP> selectedObjects = StelApp::getInstance().getStelObjectMgr().getSelectedObject(); QListIterator<StelObjectP> objectIterator(selectedObjects); StelCore* core = StelApp::getInstance().getCore(); while (objectIterator.hasNext()) { StelObjectP stelObject = objectIterator.next(); QString type = stelObject->getType(); QString englishName = stelObject->getEnglishName(); if (englishName == "") { englishName = "No Name"; } float magnatude = stelObject->getVMagnitude(core); double angularSize = stelObject->getAngularSize(core); Vec3d pos; double ra, dec; // ra/dec in J2000 pos = stelObject->getJ2000EquatorialPos(core); StelUtils::rectToSphe(&ra, &dec, pos); QSqlField field1("name", QVariant::String); QSqlField field2("right_ascension", QVariant::Double); QSqlField field3("declination", QVariant::Double); QSqlField field4("target_type_id", QVariant::Int); QSqlField field5("magnitude", QVariant::Double); QSqlField field6("size", QVariant::Double); field1.setValue(QVariant(englishName)); field2.setValue(QVariant(ra)); field3.setValue(QVariant(dec)); field4.setValue(QVariant(1)); field5.setValue(QVariant(magnatude)); field6.setValue(QVariant(angularSize)); QSqlRecord newRecord = QSqlRecord(); newRecord.append(field1); newRecord.append(field2); newRecord.append(field3); newRecord.append(field4); newRecord.append(field5); newRecord.append(field6); if (tableModel->insertRecord(-1, newRecord)) { ui->targetsListView->setCurrentIndex(tableModel->index(tableModel->rowCount() - 1, 1)); } else { qWarning() << "LogBook: could not insert new target. The error is: " << tableModel->lastError(); } } } else { qDebug() << "====> Nothing selected."; } }
uintptr_t MM_CollectorLanguageInterfaceImpl::markingScheme_scanObject(MM_EnvironmentBase *env, omrobjectptr_t objectPtr, MarkingSchemeScanReason reason) { GC_ObjectIterator objectIterator(_omrVM, objectPtr); GC_SlotObject *slotObject = NULL; while (NULL != (slotObject = objectIterator.nextSlot())) { omrobjectptr_t slot = slotObject->readReferenceFromSlot(); if (_markingScheme->isHeapObject(slot)) { _markingScheme->markObject(env, slot); } } return env->getExtensions()->objectModel.getSizeInBytesWithHeader(objectPtr); }
/* ********************************************************************* */ void LogBook::enableLogBook(bool b) { sessionsDialog->setVisible(b); // Toggle the plugin on & off. To toggle on, we want to ensure there is a selected object. if (!StelApp::getInstance().getStelObjectMgr().getWasSelected()) { qDebug() << "====> Nothing selected."; } else { QList<StelObjectP> selectedObjects = StelApp::getInstance().getStelObjectMgr().getSelectedObject(); QListIterator<StelObjectP> objectIterator(selectedObjects); while (objectIterator.hasNext()) { StelObjectP stelObject = objectIterator.next(); qDebug() << "====> Name: "<< stelObject->getNameI18n(); } } }
int32_t GCConfigTest::processObjNode(pugi::xml_node node, const char *namePrefixStr, OMRGCObjectType objType, AttributeElem *numOfFieldsElem, AttributeElem *breadthElem, int32_t depth) { OMRPORT_ACCESS_FROM_OMRPORT(gcTestEnv->portLib); int32_t rt = 0; OMR_VM *omrVMPtr = exampleVM->_omrVM; int32_t numOfParents = 0; /* Create objects and store them in the root table or the slot object based on objType. */ if ((ROOT == objType) || (GARBAGE_ROOT == objType)) { for (int32_t i = 0; i < breadthElem->value; i++) { omrobjectptr_t obj; char *objName = NULL; uintptr_t sizeCalculated = numOfFieldsElem->value * sizeof(fomrobject_t) + sizeof(uintptr_t); rt = createObject(&obj, &objName, namePrefixStr, objType, 0, i, sizeCalculated); OMRGCTEST_CHECK_RT(rt); numOfFieldsElem = numOfFieldsElem->linkNext; /* Add object to root hash table. If it's the root of the garbage tree, temporarily keep it as root for allocating * the rest of the tree. Remove it from the root set after the entire garbage tree is allocated.*/ RootEntry rEntry; rEntry.name = objName; rEntry.rootPtr = obj; if (NULL == hashTableAdd(exampleVM->rootTable, &rEntry)) { rt = 1; omrtty_printf("%s:%d Failed to add new root entry to root table!\n", __FILE__, __LINE__); goto done; } /* insert garbage per node */ if ((ROOT == objType) && (0 == strcmp(gp.frequency, "perObject"))) { rt = insertGarbage(); OMRGCTEST_CHECK_RT(rt); } } } else if ((NORMAL == objType) || (GARBAGE_TOP == objType) || (GARBAGE_CHILD == objType)) { char parentName[MAX_NAME_LENGTH]; omrstr_printf(parentName, MAX_NAME_LENGTH, "%s_%d_%d", node.parent().attribute("namePrefix").value(), 0, 0); ObjectEntry *parentEntry; rt = objectTable.find(&parentEntry, parentName); if (0 != rt) { omrtty_printf("%s:%d Could not find object %s in hash table.\n", __FILE__, __LINE__, parentName); goto done; } omrobjectptr_t parent = parentEntry->objPtr; GC_ObjectIterator objectIterator(omrVMPtr, parent); objectIterator.restore(parentEntry->numOfRef); for (int32_t i = 0; i < breadthElem->value; i++) { omrobjectptr_t obj; char *objName = NULL; uintptr_t sizeCalculated = numOfFieldsElem->value * sizeof(fomrobject_t) + sizeof(uintptr_t); rt = createObject(&obj, &objName, namePrefixStr, objType, 0, i, sizeCalculated); OMRGCTEST_CHECK_RT(rt); numOfFieldsElem = numOfFieldsElem->linkNext; GC_SlotObject *slotObject = NULL; if (NULL != (slotObject = objectIterator.nextSlot())) { #if defined(OMRGCTEST_DEBUG) omrtty_printf("\tadd to slot of parent(%llu) %d\n", parent, parentEntry->numOfRef + i); #endif /* Add object to parent's slot. If it's the top of the garbage tree, temporarily keep it in the slot until * the rest of the tree is allocated. */ slotObject->writeReferenceToSlot(obj); } else { rt = 1; omrtty_printf("%s:%d Invalid XML input: numOfFields defined for %s is not enough to hold all children references.\n", __FILE__, __LINE__, parentName); goto done; } /* insert garbage per node */ if ((NORMAL == objType) && (0 == strcmp(gp.frequency, "perObject"))) { rt = insertGarbage(); OMRGCTEST_CHECK_RT(rt); } } parentEntry->numOfRef += breadthElem->value; } else { rt = 1; goto done; } /* Create the rest of the tree, if any, defined with depth. First, we set the child object with correct objType. */ if (ROOT == objType) { objType = NORMAL; } else if ((GARBAGE_TOP == objType) || (GARBAGE_ROOT == objType)) { objType = GARBAGE_CHILD; } numOfParents = breadthElem->value; breadthElem = breadthElem->linkNext; for (int32_t i = 1; i < depth; i++) { int32_t nthInRow = 0; for (int32_t j = 0; j < numOfParents; j++) { char parentName[MAX_NAME_LENGTH]; omrstr_printf(parentName, sizeof(parentName), "%s_%d_%d", namePrefixStr, (i - 1), j); ObjectEntry *parentEntry; rt = objectTable.find(&parentEntry, parentName); if (0 != rt) { omrtty_printf("%s:%d Could not find object %s in hash table.\n", __FILE__, __LINE__, parentName); goto done; } omrobjectptr_t parent = parentEntry->objPtr; GC_ObjectIterator objectIterator(omrVMPtr, parent); objectIterator.restore(parentEntry->numOfRef); for (int32_t k = 0; k < breadthElem->value; k++) { omrobjectptr_t obj; char *objName = NULL; uintptr_t sizeCalculated = numOfFieldsElem->value * sizeof(fomrobject_t) + sizeof(uintptr_t); rt = createObject(&obj, &objName, namePrefixStr, objType, i, nthInRow, sizeCalculated); OMRGCTEST_CHECK_RT(rt); numOfFieldsElem = numOfFieldsElem->linkNext; nthInRow += 1; GC_SlotObject *slotObject = NULL; if (NULL != (slotObject = objectIterator.nextSlot())) { #if defined(OMRGCTEST_DEBUG) omrtty_printf("\tadd to parent(%llu) slot %d.\n", parent, parentEntry->numOfRef + k); #endif slotObject->writeReferenceToSlot(obj); } else { rt = 1; omrtty_printf("%s:%d Invalid XML input: numOfFields defined for %s is not enough to hold all children references.\n", __FILE__, __LINE__, parentName); goto done; } /* insert garbage per node */ if ((NORMAL == objType) && (0 == strcmp(gp.frequency, "perObject"))) { rt = insertGarbage(); OMRGCTEST_CHECK_RT(rt); } } parentEntry->numOfRef += breadthElem->value; } numOfParents = nthInRow; breadthElem = breadthElem->linkNext; } done: return rt; }
int32_t GCConfigTest::createFixedSizeTree(omrobjectptr_t *rootObj, const char *namePrefixStr, OMRGCObjectType objType, uintptr_t totalSize, uintptr_t objSize, int32_t breadth) { OMRPORT_ACCESS_FROM_OMRPORT(gcTestEnv->portLib); int32_t rt = 0; OMR_VM *omrVMPtr = exampleVM->_omrVM; int32_t depth = 1; int32_t numOfParents = 1; uintptr_t bytesLeft = totalSize; if (bytesLeft < objSize) { objSize = bytesLeft; if (objSize <= 0) { return rt; } } /* allocate the root object */ char *rootObjName = NULL; rt = createObject(rootObj, &rootObjName, namePrefixStr, objType, 0, 0, objSize); OMRGCTEST_CHECK_RT(rt); bytesLeft -= objSize; /* Add object to root hash table. If it's the root of the garbage tree, temporarily keep it as root for allocating * the rest of the tree. Remove it from the root set after the entire garbage tree is allocated.*/ RootEntry rEntry; rEntry.name = rootObjName; rEntry.rootPtr = *rootObj; if (NULL == hashTableAdd(exampleVM->rootTable, &rEntry)) { rt = 1; omrtty_printf("%s:%d Failed to add new root entry to root table!\n", __FILE__, __LINE__); goto done; } /* create the rest of the tree */ if (ROOT == objType) { objType = NORMAL; } else if ((GARBAGE_TOP == objType) || (GARBAGE_ROOT == objType)) { objType = GARBAGE_CHILD; } while (bytesLeft > 0) { int32_t nthInRow = 0; for (int32_t j = 0; j < numOfParents; j++) { char parentName[MAX_NAME_LENGTH]; omrstr_printf(parentName, sizeof(parentName), "%s_%d_%d", namePrefixStr, (depth - 1), j); ObjectEntry *parentEntry; rt = objectTable.find(&parentEntry, parentName); if (0 != rt) { omrtty_printf("%s:%d Could not find object %s in hash table.\n", __FILE__, __LINE__, parentName); goto done; } omrobjectptr_t parent = parentEntry->objPtr; GC_ObjectIterator objectIterator(omrVMPtr, parent); objectIterator.restore(parentEntry->numOfRef); for (int32_t k = 0; k < breadth; k++) { if (bytesLeft < objSize) { objSize = bytesLeft; if (objSize <= 0) { goto done; } } omrobjectptr_t obj; char *objName = NULL; rt = createObject(&obj, &objName, namePrefixStr, objType, depth, nthInRow, objSize); OMRGCTEST_CHECK_RT(rt); bytesLeft -= objSize; nthInRow += 1; GC_SlotObject *slotObject = NULL; if (NULL != (slotObject = objectIterator.nextSlot())) { #if defined(OMRGCTEST_DEBUG) omrtty_printf("\tadd to parent(%llu) slot %d.\n", parent, parentEntry->numOfRef + k); #endif slotObject->writeReferenceToSlot(obj); } else { rt = 1; omrtty_printf("%s:%d Invalid XML input: numOfFields defined for %s is not enough to hold all children references.\n", __FILE__, __LINE__, parentName); goto done; } } parentEntry->numOfRef += breadth; } numOfParents = nthInRow; depth += 1; } done: return rt; }