public void iterateFields(OopVisitor visitor, boolean doVMFields) {
   super.iterateFields(visitor, doVMFields);
   if (doVMFields) {
     visitor.doOop(constants, true);
     for (int i = 0; i < getLength(); i++) {
       ConstantPoolCacheEntry entry = getEntryAt(i);
       entry.iterateFields(visitor);
     }
   }
 }
Exemple #2
0
 public long getObjectSize() {
   ArrayKlass klass = (ArrayKlass) getKlass();
   // We have to fetch the length of the array, shift (multiply) it
   // appropriately, up to wordSize, add the header, and align to
   // object size.
   long s = getLength() << klass.getLog2ElementSize();
   s += klass.getArrayHeaderInBytes();
   s = Oop.alignObjectSize(s);
   return s;
 }
 public void iterateFields(OopVisitor visitor, boolean doVMFields) {
   super.iterateFields(visitor, doVMFields);
   if (doVMFields) {
     visitor.doOop(constMethod, true);
     visitor.doOop(constants, true);
     visitor.doCInt(methodSize, true);
     visitor.doCInt(maxStack, true);
     visitor.doCInt(maxLocals, true);
     visitor.doCInt(sizeOfParameters, true);
     visitor.doCInt(accessFlags, true);
   }
 }
Exemple #4
0
 private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
   Type type = db.lookupType("arrayKlass");
   dimension = new CIntField(type.getCIntegerField("_dimension"), Oop.getHeaderSize());
   higherDimension = new OopField(type.getOopField("_higher_dimension"), Oop.getHeaderSize());
   lowerDimension = new OopField(type.getOopField("_lower_dimension"), Oop.getHeaderSize());
   vtableLen = new CIntField(type.getCIntegerField("_vtable_len"), Oop.getHeaderSize());
   allocSize = new CIntField(type.getCIntegerField("_alloc_size"), Oop.getHeaderSize());
   componentMirror = new OopField(type.getOopField("_component_mirror"), Oop.getHeaderSize());
   javaLangCloneableName = null;
   javaLangObjectName = null;
   javaIoSerializableName = null;
 }
Exemple #5
0
 public void iterateFields(OopVisitor visitor, boolean doVMFields) {
   super.iterateFields(visitor, doVMFields);
 }
Exemple #6
0
  public void iterateFields(OopVisitor visitor, boolean doVMFields) {
    super.iterateFields(visitor, doVMFields);
    if (doVMFields) {
      visitor.doOop(tags, true);
      visitor.doOop(cache, true);
      visitor.doOop(poolHolder, true);

      final int length = (int) getLength();
      // zero'th pool entry is always invalid. ignore it.
      for (int index = 1; index < length; index++) {
        int ctag = (int) getTags().getByteAt((int) index);
        switch (ctag) {
          case JVM_CONSTANT_ClassIndex:
          case JVM_CONSTANT_StringIndex:
          case JVM_CONSTANT_Integer:
            visitor.doInt(
                new IntField(new NamedFieldIdentifier(nameForTag(ctag)), indexOffset(index), true),
                true);
            break;

          case JVM_CONSTANT_Float:
            visitor.doFloat(
                new FloatField(
                    new NamedFieldIdentifier(nameForTag(ctag)), indexOffset(index), true),
                true);
            break;

          case JVM_CONSTANT_Long:
            visitor.doLong(
                new LongField(new NamedFieldIdentifier(nameForTag(ctag)), indexOffset(index), true),
                true);
            // long entries occupy two slots
            index++;
            break;

          case JVM_CONSTANT_Double:
            visitor.doDouble(
                new DoubleField(
                    new NamedFieldIdentifier(nameForTag(ctag)), indexOffset(index), true),
                true);
            // double entries occupy two slots
            index++;
            break;

          case JVM_CONSTANT_UnresolvedClass:
          case JVM_CONSTANT_Class:
          case JVM_CONSTANT_UnresolvedString:
          case JVM_CONSTANT_Utf8:
            visitor.doOop(
                new OopField(new NamedFieldIdentifier(nameForTag(ctag)), indexOffset(index), true),
                true);
            break;

          case JVM_CONSTANT_Fieldref:
          case JVM_CONSTANT_Methodref:
          case JVM_CONSTANT_InterfaceMethodref:
          case JVM_CONSTANT_NameAndType:
            visitor.doInt(
                new IntField(new NamedFieldIdentifier(nameForTag(ctag)), indexOffset(index), true),
                true);
            break;
        }
      }
    }
    /*
    int length = getLength();
    for (int index = 0; index < length; index++) {
      long offset = baseOffset + (index + typeDataBase.getOopSize());
      visitor.doOop(new IndexableField(index, offset, false), getObjAt(index));
    }
    */
  }
  private void markAndTraverse(final Oop obj) {

    // End of path
    if (obj == null) {
      return;
    }

    // Visited object
    if (!markBits.mark(obj)) {
      return;
    }

    // Root of work list for objects to be visited.  A simple
    // stack for saving new objects to be analyzed.

    final Stack workList = new Stack();

    // Next object to be visited.
    Oop next = obj;

    try {
      // Node in the list currently being visited.

      while (true) {
        final Oop currObj = next;

        // For the progress meter
        if (progressThunk != null) {
          visitedSize += currObj.getObjectSize();
          double curFrac = (double) visitedSize / (double) usedSize;
          if (curFrac > lastNotificationFraction + MINIMUM_NOTIFICATION_FRACTION) {
            progressThunk.heapIterationFractionUpdate(curFrac);
            lastNotificationFraction = curFrac;
          }
        }

        if (DEBUG) {
          ++depth;
          printHeader();
          System.err.println("ReversePtrs.markAndTraverse(" + currObj.getHandle() + ")");
        }

        // Iterate over the references in the object.  Do the
        // reverse pointer analysis for each reference.
        // Add the reference to the work-list so that its
        // references will be visited.
        currObj.iterate(
            new DefaultOopVisitor() {
              public void doOop(OopField field, boolean isVMField) {
                // "field" refers to a reference in currObj
                Oop next = field.getValue(currObj);
                rp.put(new LivenessPathElement(currObj, field.getID()), next);
                if ((next != null) && markBits.mark(next)) {
                  workList.push(next);
                }
              }
            },
            false);

        if (DEBUG) {
          --depth;
        }

        // Get the next object to visit.
        next = (Oop) workList.pop();
      }
    } catch (EmptyStackException e) {
      // Done
    } catch (NullPointerException e) {
      System.err.println("ReversePtrs: WARNING: " + e + " during traversal");
    } catch (Exception e) {
      System.err.println("ReversePtrs: WARNING: " + e + " during traversal");
    }
  }
 /** Breakpoint support (see methods on methodOop for details) */
 public BreakpointInfo getBreakpoints() {
   Address addr = getHandle().getAddressAt(Oop.getHeaderSize() + breakpoints.getOffset());
   return (BreakpointInfo) VMObjectFactory.newObject(BreakpointInfo.class, addr);
 }
  private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
    Type type = db.lookupType("instanceKlass");
    arrayKlasses = new OopField(type.getOopField("_array_klasses"), Oop.getHeaderSize());
    methods = new OopField(type.getOopField("_methods"), Oop.getHeaderSize());
    methodOrdering = new OopField(type.getOopField("_method_ordering"), Oop.getHeaderSize());
    localInterfaces = new OopField(type.getOopField("_local_interfaces"), Oop.getHeaderSize());
    transitiveInterfaces =
        new OopField(type.getOopField("_transitive_interfaces"), Oop.getHeaderSize());
    nofImplementors =
        new CIntField(type.getCIntegerField("_nof_implementors"), Oop.getHeaderSize());
    IMPLEMENTORS_LIMIT = db.lookupIntConstant("instanceKlass::implementors_limit").intValue();
    implementors = new OopField[IMPLEMENTORS_LIMIT];
    for (int i = 0; i < IMPLEMENTORS_LIMIT; i++) {
      long arrayOffset = Oop.getHeaderSize() + (i * db.getAddressSize());
      implementors[i] = new OopField(type.getOopField("_implementors[0]"), arrayOffset);
    }
    fields = new OopField(type.getOopField("_fields"), Oop.getHeaderSize());
    constants = new OopField(type.getOopField("_constants"), Oop.getHeaderSize());
    classLoader = new OopField(type.getOopField("_class_loader"), Oop.getHeaderSize());
    protectionDomain = new OopField(type.getOopField("_protection_domain"), Oop.getHeaderSize());
    signers = new OopField(type.getOopField("_signers"), Oop.getHeaderSize());
    sourceFileName = new OopField(type.getOopField("_source_file_name"), Oop.getHeaderSize());
    sourceDebugExtension =
        new OopField(type.getOopField("_source_debug_extension"), Oop.getHeaderSize());
    innerClasses = new OopField(type.getOopField("_inner_classes"), Oop.getHeaderSize());
    nonstaticFieldSize =
        new CIntField(type.getCIntegerField("_nonstatic_field_size"), Oop.getHeaderSize());
    staticFieldSize =
        new CIntField(type.getCIntegerField("_static_field_size"), Oop.getHeaderSize());
    staticOopFieldSize =
        new CIntField(type.getCIntegerField("_static_oop_field_size"), Oop.getHeaderSize());
    nonstaticOopMapSize =
        new CIntField(type.getCIntegerField("_nonstatic_oop_map_size"), Oop.getHeaderSize());
    isMarkedDependent =
        new CIntField(type.getCIntegerField("_is_marked_dependent"), Oop.getHeaderSize());
    initState = new CIntField(type.getCIntegerField("_init_state"), Oop.getHeaderSize());
    vtableLen = new CIntField(type.getCIntegerField("_vtable_len"), Oop.getHeaderSize());
    itableLen = new CIntField(type.getCIntegerField("_itable_len"), Oop.getHeaderSize());
    breakpoints = type.getAddressField("_breakpoints");
    genericSignature = new OopField(type.getOopField("_generic_signature"), Oop.getHeaderSize());
    majorVersion = new CIntField(type.getCIntegerField("_major_version"), Oop.getHeaderSize());
    minorVersion = new CIntField(type.getCIntegerField("_minor_version"), Oop.getHeaderSize());
    headerSize = alignObjectOffset(Oop.getHeaderSize() + type.getSize());

    // read field offset constants
    ACCESS_FLAGS_OFFSET = db.lookupIntConstant("instanceKlass::access_flags_offset").intValue();
    NAME_INDEX_OFFSET = db.lookupIntConstant("instanceKlass::name_index_offset").intValue();
    SIGNATURE_INDEX_OFFSET =
        db.lookupIntConstant("instanceKlass::signature_index_offset").intValue();
    INITVAL_INDEX_OFFSET = db.lookupIntConstant("instanceKlass::initval_index_offset").intValue();
    LOW_OFFSET = db.lookupIntConstant("instanceKlass::low_offset").intValue();
    HIGH_OFFSET = db.lookupIntConstant("instanceKlass::high_offset").intValue();
    GENERIC_SIGNATURE_INDEX_OFFSET =
        db.lookupIntConstant("instanceKlass::generic_signature_offset").intValue();
    NEXT_OFFSET = db.lookupIntConstant("instanceKlass::next_offset").intValue();
    // read ClassState constants
    CLASS_STATE_UNPARSABLE_BY_GC =
        db.lookupIntConstant("instanceKlass::unparsable_by_gc").intValue();
    CLASS_STATE_ALLOCATED = db.lookupIntConstant("instanceKlass::allocated").intValue();
    CLASS_STATE_LOADED = db.lookupIntConstant("instanceKlass::loaded").intValue();
    CLASS_STATE_LINKED = db.lookupIntConstant("instanceKlass::linked").intValue();
    CLASS_STATE_BEING_INITIALIZED =
        db.lookupIntConstant("instanceKlass::being_initialized").intValue();
    CLASS_STATE_FULLY_INITIALIZED =
        db.lookupIntConstant("instanceKlass::fully_initialized").intValue();
    CLASS_STATE_INITIALIZATION_ERROR =
        db.lookupIntConstant("instanceKlass::initialization_error").intValue();
  }
 private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
   Type t = db.lookupType("typeArrayKlass");
   maxLength = new CIntField(t.getCIntegerField("_max_length"), Oop.getHeaderSize());
 }
Exemple #11
0
 public double getValue(Oop obj) {
   return obj.getHandle().getJDoubleAt(getOffset());
 }
 private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
   Type type = db.lookupType("objArrayKlass");
   elementKlass = new OopField(type.getOopField("_element_klass"), Oop.getHeaderSize());
   bottomKlass = new OopField(type.getOopField("_bottom_klass"), Oop.getHeaderSize());
 }