Пример #1
0
 @Uninterruptible
 public static void dumpRef(ObjectReference ref) {
   VM.sysWrite("REF=");
   if (ref.isNull()) {
     VM.sysWrite("NULL\n");
     return;
   }
   VM.sysWrite(ref);
   if (!mappedVMRef(ref)) {
     VM.sysWrite(" (REF OUTSIDE OF HEAP OR NOT MAPPED)\n");
     return;
   }
   ObjectModel.dumpHeader(ref);
   ObjectReference tib = ObjectReference.fromObject(ObjectModel.getTIB(ref));
   if (!MemoryManager.mightBeTIB(tib)) {
     VM.sysWrite(" (INVALID TIB: CLASS NOT ACCESSIBLE)\n");
     return;
   }
   RVMType type = Magic.getObjectType(ref.toObject());
   ObjectReference itype = ObjectReference.fromObject(type);
   VM.sysWrite(" TYPE=");
   VM.sysWrite(itype);
   if (!validType(itype)) {
     VM.sysWrite(" (INVALID TYPE: CLASS NOT ACCESSIBLE)\n");
     return;
   }
   VM.sysWrite(" CLASS=");
   VM.sysWrite(type.getDescriptor());
   VM.sysWrite("\n");
 }
Пример #2
0
 @Interruptible
 static void boot(BootRecord theBootRecord) {
   // get addresses of TIBs for RVMArray & RVMClass used for testing Type ptrs
   RVMType t = RVMArray.IntArray;
   tibForArrayType = ObjectModel.getTIB(t);
   tibForPrimitiveType = ObjectModel.getTIB(RVMType.IntType);
   t = Magic.getObjectType(BootRecord.the_boot_record);
   tibForClassType = ObjectModel.getTIB(t);
 }
 /** Fallback */
 public static void fallback(Object object, TransitiveClosure trace) {
   ObjectReference objectRef = ObjectReference.fromObject(object);
   RVMType type = ObjectModel.getObjectType(objectRef.toObject());
   if (type.isClassType()) {
     RVMClass klass = type.asClass();
     int[] offsets = klass.getReferenceOffsets();
     for (int i = 0; i < offsets.length; i++) {
       trace.processEdge(objectRef, objectRef.toAddress().plus(offsets[i]));
     }
   } else if (type.isArrayType() && type.asArray().getElementType().isReferenceType()) {
     for (int i = 0; i < ObjectModel.getArrayLength(objectRef.toObject()); i++) {
       trace.processEdge(objectRef, objectRef.toAddress().plus(i << LOG_BYTES_IN_ADDRESS));
     }
   }
 }
Пример #4
0
  /** Reports the state of a heavy-weight lock, via {@link VM#sysWrite}. */
  private void dump() {
    if (!active) {
      return;
    }
    VM.sysWrite("Lock ");
    VM.sysWriteInt(index);
    VM.sysWrite(":\n");
    VM.sysWrite(" lockedObject: ");
    VM.sysWriteHex(Magic.objectAsAddress(lockedObject));
    VM.sysWrite("   thin lock = ");
    VM.sysWriteHex(
        Magic.objectAsAddress(lockedObject).loadAddress(ObjectModel.defaultThinLockOffset()));
    VM.sysWrite(" object type = ");
    VM.sysWrite(Magic.getObjectType(lockedObject).getDescriptor());
    VM.sysWriteln();

    VM.sysWrite(" ownerId: ");
    VM.sysWriteInt(ownerId);
    VM.sysWrite(" (");
    VM.sysWriteInt(ownerId >>> ThinLockConstants.TL_THREAD_ID_SHIFT);
    VM.sysWrite(") recursionCount: ");
    VM.sysWriteInt(recursionCount);
    VM.sysWriteln();
    dumpBlockedThreads();
    dumpWaitingThreads();

    VM.sysWrite(" mutexLatestContender: ");
    if (mutex.latestContender == null) {
      VM.sysWrite("<null>");
    } else {
      VM.sysWriteInt(mutex.latestContender.getThreadSlot());
    }
    VM.sysWrite("\n");
  }
 /** Reference Arrays */
 public static void referenceArray(Object object, TransitiveClosure trace) {
   Address base = Magic.objectAsAddress(object);
   int length = ObjectModel.getArrayLength(object);
   for (int i = 0; i < length; i++) {
     trace.processEdge(ObjectReference.fromObject(object), base.plus(i << LOG_BYTES_IN_ADDRESS));
   }
 }
 /** All Scalars */
 public static void scalar(Object object, TransitiveClosure trace) {
   Address base = Magic.objectAsAddress(object);
   int[] offsets = ObjectModel.getObjectType(object).asClass().getReferenceOffsets();
   for (int i = 0; i < offsets.length; i++) {
     trace.processEdge(ObjectReference.fromObject(object), base.plus(offsets[i]));
   }
 }
Пример #7
0
  /**
   * Check if an address appears to point to an instance of RVMType
   *
   * @param typeAddress the address to check
   * @return {@code true} if and only if the address appears to be an an instance of RVMType
   */
  @Uninterruptible
  public static boolean validType(ObjectReference typeAddress) {
    if (!Space.isMappedObject(typeAddress)) {
      return false; // type address is outside of heap
    }

    // check if types tib is one of three possible values
    TIB typeTib = ObjectModel.getTIB(typeAddress);
    return ((typeTib == tibForClassType)
        || (typeTib == tibForArrayType)
        || (typeTib == tibForPrimitiveType));
  }
Пример #8
0
  @Uninterruptible
  public static boolean validRef(ObjectReference ref) {

    if (ref.isNull()) return true;
    if (!Space.isMappedObject(ref)) {
      VM.sysWrite("validRef: REF outside heap, ref = ");
      VM.sysWrite(ref);
      VM.sysWrite("\n");
      Space.printVMMap();
      return false;
    }
    if (MOVES_OBJECTS) {
      /*
      TODO: Work out how to check if forwarded
      if (Plan.isForwardedOrBeingForwarded(ref)) {
        // TODO: actually follow forwarding pointer
        // (need to bound recursion when things are broken!!)
        return true;
      }
      */
    }

    TIB tib = ObjectModel.getTIB(ref);
    Address tibAddr = Magic.objectAsAddress(tib);
    if (!Space.isMappedObject(ObjectReference.fromObject(tib))) {
      VM.sysWrite("validRef: TIB outside heap, ref = ");
      VM.sysWrite(ref);
      VM.sysWrite(" tib = ");
      VM.sysWrite(tibAddr);
      VM.sysWrite("\n");
      ObjectModel.dumpHeader(ref);
      return false;
    }
    if (tibAddr.isZero()) {
      VM.sysWrite("validRef: TIB is Zero! ");
      VM.sysWrite(ref);
      VM.sysWrite("\n");
      ObjectModel.dumpHeader(ref);
      return false;
    }
    if (tib.length() == 0) {
      VM.sysWrite("validRef: TIB length zero, ref = ");
      VM.sysWrite(ref);
      VM.sysWrite(" tib = ");
      VM.sysWrite(tibAddr);
      VM.sysWrite("\n");
      ObjectModel.dumpHeader(ref);
      return false;
    }

    ObjectReference type = ObjectReference.fromObject(tib.getType());
    if (!validType(type)) {
      VM.sysWrite("validRef: invalid TYPE, ref = ");
      VM.sysWrite(ref);
      VM.sysWrite(" tib = ");
      VM.sysWrite(Magic.objectAsAddress(tib));
      VM.sysWrite(" type = ");
      VM.sysWrite(type);
      VM.sysWrite("\n");
      ObjectModel.dumpHeader(ref);
      return false;
    }
    return true;
  } // validRef