use of com.ibm.j9ddr.vm29.pointer.VoidPointer in project openj9 by eclipse.
the class HashTable_V1 method find.
// find by pointer value
@Override
public StructType find(StructType entry) throws CorruptDataException {
UDATA hash = _hashFn.hash(entry).mod(_table.tableSize());
PointerPointer head = _table.nodes().add(hash);
VoidPointer findNode = VoidPointer.NULL;
if (_table.listNodePool().isNull()) {
PointerPointer node = hashTableFindNodeSpaceOpt(_table, entry, head);
if (node.at(0).notNull()) {
findNode = VoidPointer.cast(node);
} else {
findNode = VoidPointer.NULL;
}
} else if (head.at(0).isNull()) {
findNode = VoidPointer.NULL;
} else if (isAVLTreeTagged(head.at(0))) {
findNode = hashTableFindNodeInTree(_table, entry, head);
} else {
findNode = hashTableFindNodeInList(_table, entry, head);
}
if (!_isInline && findNode.notNull()) {
findNode = PointerPointer.cast(findNode).at(0);
}
StructType node = (StructType) DataType.getStructure(_structType, findNode.getAddress());
return node;
}
use of com.ibm.j9ddr.vm29.pointer.VoidPointer in project openj9 by eclipse.
the class StringTable method iterator.
public SlotIterator<J9ObjectPointer> iterator() {
return new SlotIterator<J9ObjectPointer>() {
private SlotIterator<PointerPointer> hashTableIterator = null;
private long currentIndex = 0;
public boolean hasNext() {
while (true) {
// Is the current iterator good?
if (hashTableIterator != null) {
// Are there still entries?
if (hashTableIterator.hasNext()) {
return true;
}
// Move to the next hash table
currentIndex++;
}
// Are there more hash tables?
if (currentIndex >= _tableCount) {
hashTableIterator = null;
return false;
}
// Get the next hash table iterator
try {
J9HashTablePointer hashTable = J9HashTablePointer.cast(_stringTable._table().at(currentIndex));
HashTable<PointerPointer> currentHashTable = HashTable.fromJ9HashTable(hashTable, false, PointerPointer.class, _hashFn, new StringComparatorFunction<PointerPointer>());
hashTableIterator = currentHashTable.iterator();
} catch (CorruptDataException e) {
raiseCorruptDataEvent("Error getting next item", e, false);
// Keep trying
}
}
}
public J9ObjectPointer next() {
if (hasNext()) {
PointerPointer next = hashTableIterator.next();
return J9ObjectPointer.cast(next);
} else {
throw new NoSuchElementException("There are no more items available through this iterator");
}
}
public VoidPointer nextAddress() {
if (hasNext()) {
return VoidPointer.cast(hashTableIterator.nextAddress());
} else {
throw new NoSuchElementException("There are no more items available through this iterator");
}
}
public void remove() {
throw new UnsupportedOperationException("The image is read only and cannot be modified.");
}
};
}
use of com.ibm.j9ddr.vm29.pointer.VoidPointer in project openj9 by eclipse.
the class Pool_29_V0 method pool_startDo.
private VoidPointer pool_startDo() throws CorruptDataException {
slot = 0;
J9PoolPuddleListPointer puddleList = J9PoolPuddleListPointer.cast(pool.puddleList());
return poolPuddle_startDo(puddleList.nextPuddle(), true);
}
use of com.ibm.j9ddr.vm29.pointer.VoidPointer in project openj9 by eclipse.
the class Pool_29_V0 method poolPuddle_startDo.
private VoidPointer poolPuddle_startDo(J9PoolPuddlePointer currentPuddle, boolean followNextPointers) throws CorruptDataException {
UDATAPointer currAddr = null;
if (pool.isNull() || currentPuddle.isNull()) {
return null;
}
if (currentPuddle.usedElements().longValue() == 0) {
if ((currentPuddle.nextPuddle().notNull()) && followNextPointers) {
return poolPuddle_startDo(currentPuddle.nextPuddle(), followNextPointers);
} else {
return null;
}
}
while (isPuddleSlotFree(currentPuddle)) {
slot++;
}
currAddr = UDATAPointer.cast(currentPuddle.firstElementAddress().getAddress() + (elementSize * slot));
state.currentPuddle = currentPuddle;
state.lastSlot = slot;
state.leftToDo = currentPuddle.usedElements().intValue() - 1;
state.flags = 0;
if (followNextPointers) {
// TODO find out where this is set
state.flags |= POOLSTATE_FOLLOW_NEXT_POINTERS;
}
if (state.leftToDo == 0) {
if (followNextPointers) {
state.currentPuddle = state.currentPuddle.nextPuddle();
state.lastSlot = -1;
} else {
state.currentPuddle = null;
}
}
logger.fine(String.format("Next pool item 0x%016x", currAddr.getAddress()));
if (logger.isLoggable(Level.FINER)) {
logger.finer(state.toString());
}
return VoidPointer.cast(currAddr);
}
use of com.ibm.j9ddr.vm29.pointer.VoidPointer in project openj9 by eclipse.
the class GCConstantPoolSlotIterator method initializeSlots_V1.
protected void initializeSlots_V1(J9ClassPointer clazz, boolean returnClassSlots, boolean returnObjectSlots) throws CorruptDataException {
U32Pointer cpDescriptionSlots = clazz.romClass().cpShapeDescription();
PointerPointer cpEntry = PointerPointer.cast(clazz.ramConstantPool());
long cpDescription = 0;
long cpEntryCount = clazz.romClass().ramConstantPoolCount().longValue();
long cpDescriptionIndex = 0;
ArrayList<AbstractPointer> slots = new ArrayList<AbstractPointer>();
ArrayList<VoidPointer> addresses = new ArrayList<VoidPointer>();
while (cpEntryCount > 0) {
if (0 == cpDescriptionIndex) {
// Load a new description word
cpDescription = cpDescriptionSlots.at(0).longValue();
cpDescriptionSlots = cpDescriptionSlots.add(1);
cpDescriptionIndex = J9_CP_DESCRIPTIONS_PER_U32;
}
long slotType = cpDescription & J9_CP_DESCRIPTION_MASK;
if ((slotType == J9CPTYPE_STRING) || (slotType == J9CPTYPE_ANNOTATION_UTF8)) {
if (returnObjectSlots) {
J9RAMStringRefPointer ref = J9RAMStringRefPointer.cast(cpEntry);
J9ObjectPointer slot = ref.stringObject();
if (slot.notNull()) {
slots.add(slot);
addresses.add(VoidPointer.cast(ref.stringObjectEA()));
}
}
} else if (slotType == J9CPTYPE_METHOD_TYPE) {
if (returnObjectSlots) {
J9RAMMethodTypeRefPointer ref = J9RAMMethodTypeRefPointer.cast(cpEntry);
J9ObjectPointer slot = ref.type();
if (slot.notNull()) {
slots.add(slot);
addresses.add(VoidPointer.cast(ref.typeEA()));
}
}
} else if (slotType == J9CPTYPE_METHODHANDLE) {
if (returnObjectSlots) {
J9RAMMethodHandleRefPointer ref = J9RAMMethodHandleRefPointer.cast(cpEntry);
J9ObjectPointer slot = ref.methodHandle();
if (slot.notNull()) {
slots.add(slot);
addresses.add(VoidPointer.cast(ref.methodHandleEA()));
}
}
} else if (slotType == J9CPTYPE_CLASS) {
if (returnClassSlots) {
J9RAMClassRefPointer ref = J9RAMClassRefPointer.cast(cpEntry);
J9ClassPointer slot = ref.value();
if (slot.notNull()) {
slots.add(slot);
addresses.add(VoidPointer.cast(ref.valueEA()));
}
}
}
cpEntry = cpEntry.addOffset(J9RAMConstantPoolItem.SIZEOF);
cpEntryCount -= 1;
cpDescription >>= J9_CP_BITS_PER_DESCRIPTION;
cpDescriptionIndex -= 1;
}
slotIterator = slots.iterator();
addressIterator = addresses.iterator();
}
Aggregations