Search in sources :

Example 46 with UDATA

use of com.ibm.j9ddr.vm29.types.UDATA in project openj9 by eclipse.

the class J9ObjectFieldOffsetIterator_V1 method fieldOffsetsFindNext.

// Based on fieldOffsetsFindNext from resolvefield.c
private void fieldOffsetsFindNext() throws CorruptDataException {
    while (romFieldsShapeIterator.hasNext()) {
        J9ROMFieldShapePointer localField = (J9ROMFieldShapePointer) romFieldsShapeIterator.next();
        U32 modifiers = localField.modifiers();
        /* count the index for jvmti */
        index = index.add(1);
        if (modifiers.anyBitsIn(J9AccStatic)) {
            if (walkFlags.anyBitsIn(J9VM_FIELD_OFFSET_WALK_INCLUDE_STATIC)) {
                /* found a static, the walk wants statics */
                if (modifiers.anyBitsIn(J9FieldFlagObject)) {
                    offset = new UDATA(objectStaticsSeen.mult(UDATA.SIZEOF));
                    objectStaticsSeen = objectStaticsSeen.add(1);
                    field = localField;
                    break;
                } else if (!(walkFlags.anyBitsIn(J9VM_FIELD_OFFSET_WALK_ONLY_OBJECT_SLOTS))) {
                    if (modifiers.anyBitsIn(J9FieldSizeDouble)) {
                        /* Add single scalar and object counts together, round up to 2 and divide by 2 to get number of doubles used by singles */
                        UDATA doubleSlots;
                        if (J9BuildFlags.env_data64) {
                            doubleSlots = new UDATA(romClass.objectStaticCount().add(romClass.singleScalarStaticCount()));
                        } else {
                            doubleSlots = new UDATA(romClass.objectStaticCount().add(romClass.singleScalarStaticCount()).add(1)).rightShift(1);
                        }
                        offset = doubleSlots.mult(U64.SIZEOF).add(doubleStaticsSeen.mult(U64.SIZEOF));
                        doubleStaticsSeen = doubleStaticsSeen.add(1);
                    } else {
                        offset = new UDATA(romClass.objectStaticCount().mult(UDATA.SIZEOF).add(singleStaticsSeen.mult(UDATA.SIZEOF)));
                        singleStaticsSeen = singleStaticsSeen.add(1);
                    }
                    field = localField;
                    break;
                }
            }
        } else {
            if (walkFlags.anyBitsIn(J9VM_FIELD_OFFSET_WALK_INCLUDE_INSTANCE)) {
                if (modifiers.anyBitsIn(J9FieldFlagObject)) {
                    if (walkFlags.anyBitsIn(J9VM_FIELD_OFFSET_WALK_BACKFILL_OBJECT_FIELD)) {
                        // Assert_VM_true(state->backfillOffsetToUse >= 0);
                        offset = new UDATA(backfillOffsetToUse);
                        walkFlags = walkFlags.bitAnd(new U32(new UDATA(J9VM_FIELD_OFFSET_WALK_BACKFILL_OBJECT_FIELD).bitNot()));
                    } else {
                        offset = firstObjectOffset.add(objectsSeen.mult(fj9object_t_SizeOf));
                        objectsSeen = objectsSeen.add(1);
                    }
                    field = localField;
                    break;
                } else if (!walkFlags.anyBitsIn(J9VM_FIELD_OFFSET_WALK_ONLY_OBJECT_SLOTS)) {
                    if (modifiers.anyBitsIn(J9FieldSizeDouble)) {
                        offset = firstDoubleOffset.add(doubleSeen.mult(U64.SIZEOF));
                        doubleSeen = doubleSeen.add(1);
                    } else {
                        if (walkFlags.anyBitsIn(J9VM_FIELD_OFFSET_WALK_BACKFILL_SINGLE_FIELD)) {
                            // Assert_VM_true(state->backfillOffsetToUse >= 0);
                            offset = new UDATA(backfillOffsetToUse);
                            walkFlags = walkFlags.bitAnd(new U32(new UDATA(J9VM_FIELD_OFFSET_WALK_BACKFILL_SINGLE_FIELD).bitNot()));
                        } else {
                            offset = firstSingleOffset.add(singlesSeen.mult(U32.SIZEOF));
                            singlesSeen = singlesSeen.add(1);
                        }
                    }
                    field = localField;
                    break;
                }
            }
        }
    }
    // At this point all the info we need is stashed away in private state variables
    return;
}
Also used : UDATA(com.ibm.j9ddr.vm29.types.UDATA) U32(com.ibm.j9ddr.vm29.types.U32) J9ROMFieldShapePointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMFieldShapePointer)

Example 47 with UDATA

use of com.ibm.j9ddr.vm29.types.UDATA in project openj9 by eclipse.

the class J9VMThreadPointerUtil method getJ9State.

// Taken from thrinfo.c getVMThreadStateHelper
// Note that DDR has access to a wrapper for getting information about object monitors
// this should be used as the single point of access for obtaining this information rather
// than local copies of the functionality e.g. monitorPeekTable.
public static ThreadInfo getJ9State(J9VMThreadPointer targetThread) throws CorruptDataException {
    final ThreadInfo thrinfo = new ThreadInfo();
    if (targetThread.isNull()) {
        thrinfo.state = new UDATA(J9VMTHREAD_STATE_UNKNOWN).longValue();
        return thrinfo;
    }
    thrinfo.thread = targetThread;
    long vmstate = J9VMTHREAD_STATE_RUNNING;
    UDATA publicFlags = targetThread.publicFlags();
    J9ThreadPointer j9self = targetThread.osThread();
    /* j9self may be NULL if this function is used by RAS on a corrupt VM */
    ThreadState j9state = new ThreadState(j9self);
    if (publicFlags.anyBitsIn(J9_PUBLIC_FLAGS_THREAD_BLOCKED | J9_PUBLIC_FLAGS_THREAD_WAITING)) {
        /* Assert_VMUtil_true(targetThread->blockingEnterObject != NULL); */
        thrinfo.lockObject = targetThread.blockingEnterObject();
        // use the DDR object monitor wrapper
        ObjectMonitor monitor = ObjectMonitor.fromJ9Object(thrinfo.lockObject);
        // isInflated
        if (monitor.isInflated()) {
            if (publicFlags.anyBitsIn(J9_PUBLIC_FLAGS_THREAD_BLOCKED)) {
                if (monitor.getOwner().notNull() && !monitor.getOwner().equals(j9self)) {
                    /* 
						 * The omrthread may be accessing other raw monitors, but
						 * the vmthread is blocked while the object monitor is
						 * owned by a competing thread.
						 */
                    vmstate = J9VMTHREAD_STATE_BLOCKED;
                    thrinfo.rawLock = J9ThreadMonitorPointer.cast(monitor.getInflatedMonitor());
                }
            } else {
                if (j9self.isNull()) {
                    if (publicFlags.anyBitsIn(J9_PUBLIC_FLAGS_THREAD_TIMED)) {
                        vmstate = J9VMTHREAD_STATE_WAITING_TIMED;
                    } else {
                        vmstate = J9VMTHREAD_STATE_WAITING;
                    }
                    thrinfo.rawLock = J9ThreadMonitorPointer.cast(monitor.getInflatedMonitor());
                } else if (monitor.getInflatedMonitor().equals(j9state.blocker)) {
                    vmstate = getInflatedMonitorState(j9self, j9state, thrinfo);
                }
            /* 
					 * If the omrthread is using a different monitor, it must be for vm access.
					 * So the vmthread is either not waiting yet or already awakened.
					 */
            }
        } else {
            if (monitor.getOwner().notNull() && (!monitor.getOwner().equals(targetThread))) {
                /* count = J9_FLATLOCK_COUNT(lockWord); */
                /* rawLock = (omrthread_monitor_t)monitorTablePeekMonitor(targetThread->javaVM, lockObject); */
                vmstate = J9VMTHREAD_STATE_BLOCKED;
            }
        }
    /* 
			 * targetThread may be blocked attempting to reacquire VM access, after 
			 * succeeding to acquire the object monitor. In this case, the returned 
			 * vmstate depends on includeRawMonitors.
			 * includeRawMonitors == FALSE: the vmstate is RUNNING.
			 * includeRawMonitors == TRUE: the vmstate depends on the state of
			 * the omrthread. e.g. The omrthread may be blocked on publicFlagsMutex.
			 */
    } else if (publicFlags.anyBitsIn(J9_PUBLIC_FLAGS_THREAD_PARKED)) {
        /* if the osthread is not parked, then the thread is runnable */
        if (j9self.isNull() || (j9state.flags.anyBitsIn(J9THREAD_FLAG_PARKED))) {
            thrinfo.lockObject = targetThread.blockingEnterObject();
            if (publicFlags.anyBitsIn(J9_PUBLIC_FLAGS_THREAD_TIMED)) {
                vmstate = J9VMTHREAD_STATE_PARKED_TIMED;
            } else {
                vmstate = J9VMTHREAD_STATE_PARKED;
            }
        }
    } else if (publicFlags.anyBitsIn(J9_PUBLIC_FLAGS_THREAD_SLEEPING)) {
        /* if the osthread is not sleeping, then the thread is runnable */
        if (j9self.isNull() || (j9state.flags.anyBitsIn(J9THREAD_FLAG_SLEEPING))) {
            vmstate = J9VMTHREAD_STATE_SLEEPING;
        }
    } else {
        /* no vmthread flags apply, so go through the omrthread flags */
        if (j9self.isNull()) {
            vmstate = J9VMTHREAD_STATE_UNKNOWN;
        } else if (j9state.flags.anyBitsIn(J9THREAD_FLAG_PARKED)) {
            if (j9state.flags.anyBitsIn(J9THREAD_FLAG_TIMER_SET)) {
                vmstate = J9VMTHREAD_STATE_PARKED_TIMED;
            } else {
                vmstate = J9VMTHREAD_STATE_PARKED;
            }
        } else if (j9state.flags.anyBitsIn(J9THREAD_FLAG_SLEEPING)) {
            vmstate = J9VMTHREAD_STATE_SLEEPING;
        } else if (j9state.flags.anyBitsIn(J9THREAD_FLAG_DEAD)) {
            vmstate = J9VMTHREAD_STATE_DEAD;
        }
    }
    if (J9VMTHREAD_STATE_RUNNING == vmstate) {
        /* check if the omrthread is blocked/waiting on a raw monitor */
        thrinfo.lockObject = null;
        vmstate = getInflatedMonitorState(j9self, j9state, thrinfo);
    }
    if (thrinfo.rawLock != null) {
        if (thrinfo.rawLock.flags().allBitsIn(J9THREAD_MONITOR_OBJECT)) {
            thrinfo.lockObject = J9ObjectPointer.cast(thrinfo.rawLock.userData());
        }
    }
    /* j9state was zeroed if j9self is NULL */
    if (j9state.flags.anyBitsIn(J9THREAD_FLAG_INTERRUPTED)) {
        vmstate |= J9VMTHREAD_STATE_INTERRUPTED;
    }
    if (j9state.flags.anyBitsIn(J9THREAD_FLAG_SUSPENDED)) {
        vmstate |= J9VMTHREAD_STATE_SUSPENDED;
    }
    if (publicFlags.anyBitsIn(J9_PUBLIC_FLAGS_HALT_THREAD_JAVA_SUSPEND)) {
        vmstate |= J9VMTHREAD_STATE_SUSPENDED;
    }
    thrinfo.state = new UDATA(vmstate).longValue();
    return thrinfo;
}
Also used : J9ThreadPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ThreadPointer) UDATA(com.ibm.j9ddr.vm29.types.UDATA)

Example 48 with UDATA

use of com.ibm.j9ddr.vm29.types.UDATA in project openj9 by eclipse.

the class JITLook method hash_jit_artifact_search.

public static J9JITExceptionTablePointer hash_jit_artifact_search(J9JITHashTablePointer table, UDATA searchValue) throws CorruptDataException {
    PointerPointer bucket;
    J9JITExceptionTablePointer entry;
    if (searchValue.gte(table.start()) && searchValue.lt(table.end())) {
        /* The search value is in this hash table */
        bucket = DETERMINE_BUCKET(searchValue, table.start(), table.buckets());
        if (bucket.at(0).notNull()) {
            /* The bucket for this search value is not empty */
            if (bucket.at(0).allBitsIn(1)) {
                // LOW_BIT_SET
                /* The bucket consists of a single low-tagged J9JITExceptionTable pointer */
                entry = J9JITExceptionTablePointer.cast(bucket.at(0));
            } else {
                /* The bucket consists of an array of J9JITExceptionTable pointers,
					 * the last of which is low-tagged */
                /* Search all but the last entry in the array */
                bucket = PointerPointer.cast(bucket.at(0));
                for (; ; bucket = bucket.add(1)) {
                    entry = J9JITExceptionTablePointer.cast(bucket.at(0));
                    if (entry.allBitsIn(1)) {
                        break;
                    }
                    if (searchValue.gte(entry.startPC()) && searchValue.lt(entry.endWarmPC()))
                        return entry;
                    if ((entry.startColdPC().longValue() != 0) && searchValue.gte(entry.startColdPC()) && searchValue.lt(entry.endPC()))
                        return entry;
                }
            }
            /* Search the last (or only) entry in the bucket, which is low-tagged */
            entry = J9JITExceptionTablePointer.cast(UDATA.cast(entry).bitAnd(new UDATA(1).bitNot()));
            if (searchValue.gte(entry.startPC()) && searchValue.lt(entry.endWarmPC()))
                return entry;
            if ((entry.startColdPC().longValue() != 0) && searchValue.gte(entry.startColdPC()) && searchValue.lt(entry.endPC()))
                return entry;
        }
    }
    return J9JITExceptionTablePointer.NULL;
}
Also used : UDATA(com.ibm.j9ddr.vm29.types.UDATA) PointerPointer(com.ibm.j9ddr.vm29.pointer.PointerPointer) J9JITExceptionTablePointer(com.ibm.j9ddr.vm29.pointer.generated.J9JITExceptionTablePointer)

Example 49 with UDATA

use of com.ibm.j9ddr.vm29.types.UDATA in project openj9 by eclipse.

the class JITLook method jit_artifact_search.

public static J9JITExceptionTablePointer jit_artifact_search(J9AVLTreePointer tree, UDATA searchValue) throws CorruptDataException {
    /* find the right hash table to look in */
    AVLTree localTree = AVLTree.fromJ9AVLTreePointer(tree, new JITArtifactSearchCompare());
    J9JITHashTablePointer table = J9JITHashTablePointer.cast(localTree.search(searchValue));
    if (table.notNull()) {
        /* return the result of looking in the correct hash table */
        return hash_jit_artifact_search(table, searchValue);
    }
    return J9JITExceptionTablePointer.NULL;
}
Also used : J9JITHashTablePointer(com.ibm.j9ddr.vm29.pointer.generated.J9JITHashTablePointer)

Example 50 with UDATA

use of com.ibm.j9ddr.vm29.types.UDATA in project openj9 by eclipse.

the class SendSlot method getSendSlotsFromSignature.

public static UDATA getSendSlotsFromSignature(J9UTF8Pointer signature) throws CorruptDataException {
    UDATA sendArgs = new UDATA(0);
    int i = 1;
    for (; ; i++) {
        switch(J9UTF8Helper.stringValue(signature).charAt(i)) {
            case ')':
                return sendArgs;
            case '[':
                /* skip all '['s */
                for (i++; J9UTF8Helper.stringValue(signature).charAt(i) == '['; i++) ;
                if (J9UTF8Helper.stringValue(signature).charAt(i) == 'L') {
                /* FALL THRU */
                } else {
                    sendArgs = sendArgs.add(1);
                    break;
                }
            case 'L':
                for (i++; J9UTF8Helper.stringValue(signature).charAt(i) != ';'; i++) ;
                sendArgs = sendArgs.add(1);
                break;
            case 'D':
            case 'J':
                sendArgs = sendArgs.add(2);
                break;
            default:
                /* any other primitive type */
                sendArgs = sendArgs.add(1);
                break;
        }
    }
}
Also used : UDATA(com.ibm.j9ddr.vm29.types.UDATA)

Aggregations

UDATA (com.ibm.j9ddr.vm29.types.UDATA)86 CorruptDataException (com.ibm.j9ddr.CorruptDataException)22 U32 (com.ibm.j9ddr.vm29.types.U32)16 J9ObjectPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer)14 U8Pointer (com.ibm.j9ddr.vm29.pointer.U8Pointer)10 J9JavaVMPointer (com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer)10 UDATAPointer (com.ibm.j9ddr.vm29.pointer.UDATAPointer)9 DDRInteractiveCommandException (com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException)8 J9ClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer)8 VoidPointer (com.ibm.j9ddr.vm29.pointer.VoidPointer)7 J9VMThreadPointer (com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer)6 PointerPointer (com.ibm.j9ddr.vm29.pointer.PointerPointer)5 J9ROMMethodPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMMethodPointer)4 U16 (com.ibm.j9ddr.vm29.types.U16)4 J9ObjectFieldOffset (com.ibm.j9ddr.vm29.j9.J9ObjectFieldOffset)3 GCHeapRegionDescriptor (com.ibm.j9ddr.vm29.j9.gc.GCHeapRegionDescriptor)3 J9ArrayClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ArrayClassPointer)3 J9JITExceptionTablePointer (com.ibm.j9ddr.vm29.pointer.generated.J9JITExceptionTablePointer)3 J9MethodPointer (com.ibm.j9ddr.vm29.pointer.generated.J9MethodPointer)3 IDATA (com.ibm.j9ddr.vm29.types.IDATA)3