< prev index next >

src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/Oop.java

Print this page
*** 44,13 ***
    }
  
    private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
      Type type  = db.lookupType("oopDesc");
      mark       = new CIntField(type.getCIntegerField("_mark"), 0);
!     klass      = new MetadataField(type.getAddressField("_metadata._klass"), 0);
!     compressedKlass  = new NarrowKlassField(type.getAddressField("_metadata._compressed_klass"), 0);
!     headerSize = type.getSize();
    }
  
    private OopHandle  handle;
    private ObjectHeap heap;
  
--- 44,18 ---
    }
  
    private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
      Type type  = db.lookupType("oopDesc");
      mark       = new CIntField(type.getCIntegerField("_mark"), 0);
!     if (VM.getVM().isCompactObjectHeadersEnabled()) {
!       Type markType = db.lookupType("markWord");
!       headerSize = markType.getSize();
+     } else {
+       headerSize = type.getSize();
+       klass      = new MetadataField(type.getAddressField("_metadata._klass"), 0);
+       compressedKlass  = new NarrowKlassField(type.getAddressField("_metadata._compressed_klass"), 0);
+     }
    }
  
    private OopHandle  handle;
    private ObjectHeap heap;
  

*** 73,12 ***
    private static MetadataField  klass;
    private static NarrowKlassField compressedKlass;
  
    // Accessors for declared fields
    public Mark  getMark()   { return new Mark(getHandle()); }
    public Klass getKlass() {
!     if (VM.getVM().isCompressedKlassPointersEnabled()) {
        return (Klass)compressedKlass.getValue(getHandle());
      } else {
        return (Klass)klass.getValue(getHandle());
      }
    }
--- 78,21 ---
    private static MetadataField  klass;
    private static NarrowKlassField compressedKlass;
  
    // Accessors for declared fields
    public Mark  getMark()   { return new Mark(getHandle()); }
+ 
+   private static Klass getKlass(Mark mark) {
+     assert(VM.getVM().isCompactObjectHeadersEnabled());
+     return mark.getKlass();
+   }
+ 
    public Klass getKlass() {
!     if (VM.getVM().isCompactObjectHeadersEnabled()) {
+       assert(VM.getVM().isCompressedKlassPointersEnabled());
+       return getKlass(getMark());
+     } else if (VM.getVM().isCompressedKlassPointersEnabled()) {
        return (Klass)compressedKlass.getValue(getHandle());
      } else {
        return (Klass)klass.getValue(getHandle());
      }
    }

*** 145,14 ***
    }
  
    void iterateFields(OopVisitor visitor, boolean doVMFields) {
      if (doVMFields) {
        visitor.doCInt(mark, true);
!       if (VM.getVM().isCompressedKlassPointersEnabled()) {
!         visitor.doMetadata(compressedKlass, true);
!       } else {
!         visitor.doMetadata(klass, true);
        }
      }
    }
  
    public void print()      { printOn(System.out); }
--- 159,16 ---
    }
  
    void iterateFields(OopVisitor visitor, boolean doVMFields) {
      if (doVMFields) {
        visitor.doCInt(mark, true);
!       if (!VM.getVM().isCompactObjectHeadersEnabled()) {
!         if (VM.getVM().isCompressedKlassPointersEnabled()) {
!           visitor.doMetadata(compressedKlass, true);
!         } else {
+           visitor.doMetadata(klass, true);
+         }
        }
      }
    }
  
    public void print()      { printOn(System.out); }

*** 204,11 ***
  
    public static Klass getKlassForOopHandle(OopHandle handle) {
      if (handle == null) {
        return null;
      }
!     if (VM.getVM().isCompressedKlassPointersEnabled()) {
        return (Klass)Metadata.instantiateWrapperFor(handle.getCompKlassAddressAt(compressedKlass.getOffset()));
      } else {
        return (Klass)Metadata.instantiateWrapperFor(handle.getAddressAt(klass.getOffset()));
      }
    }
--- 220,14 ---
  
    public static Klass getKlassForOopHandle(OopHandle handle) {
      if (handle == null) {
        return null;
      }
!     if (VM.getVM().isCompactObjectHeadersEnabled()) {
+       Mark mark = new Mark(handle);
+       return getKlass(mark);
+     } else if (VM.getVM().isCompressedKlassPointersEnabled()) {
        return (Klass)Metadata.instantiateWrapperFor(handle.getCompKlassAddressAt(compressedKlass.getOffset()));
      } else {
        return (Klass)Metadata.instantiateWrapperFor(handle.getAddressAt(klass.getOffset()));
      }
    }
< prev index next >