< prev index next >

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

Print this page

 85       lengthOffsetInBytes = Oop.getHeaderSize();
 86     } else {
 87       lengthOffsetInBytes = typeSize - VM.getVM().getIntSize();
 88     }
 89     return lengthOffsetInBytes;
 90   }
 91 
 92   // Accessors for declared fields
 93   public long getLength() {
 94     boolean isUnsigned = true;
 95     return this.getHandle().getCIntegerAt(lengthOffsetInBytes(), VM.getVM().getIntSize(), isUnsigned);
 96   }
 97 
 98   public long getObjectSize() {
 99     ArrayKlass klass = (ArrayKlass) getKlass();
100     // We have to fetch the length of the array, shift (multiply) it
101     // appropriately, up to wordSize, add the header, and align to
102     // object size.
103     long s = getLength() << klass.getLog2ElementSize();
104     s += klass.getArrayHeaderInBytes();







105     s = Oop.alignObjectSize(s);
106     return s;
107   }
108 
109   public static long baseOffsetInBytes(BasicType type) {
110     long typeSizeInBytes = headerSizeInBytes();
111     if (elementTypeShouldBeAligned(type)) {
112       VM vm = VM.getVM();
113       return vm.alignUp(typeSizeInBytes, vm.getVM().getHeapWordSize());
114     } else {
115       return typeSizeInBytes;
116     }
117   }
118 
119   public boolean isArray()             { return true; }
120 
121   public void iterateFields(OopVisitor visitor, boolean doVMFields) {
122     super.iterateFields(visitor, doVMFields);
123   }
124 }

 85       lengthOffsetInBytes = Oop.getHeaderSize();
 86     } else {
 87       lengthOffsetInBytes = typeSize - VM.getVM().getIntSize();
 88     }
 89     return lengthOffsetInBytes;
 90   }
 91 
 92   // Accessors for declared fields
 93   public long getLength() {
 94     boolean isUnsigned = true;
 95     return this.getHandle().getCIntegerAt(lengthOffsetInBytes(), VM.getVM().getIntSize(), isUnsigned);
 96   }
 97 
 98   public long getObjectSize() {
 99     ArrayKlass klass = (ArrayKlass) getKlass();
100     // We have to fetch the length of the array, shift (multiply) it
101     // appropriately, up to wordSize, add the header, and align to
102     // object size.
103     long s = getLength() << klass.getLog2ElementSize();
104     s += klass.getArrayHeaderInBytes();
105     if (VM.getVM().isCompactObjectHeadersEnabled()) {
106       Mark mark = getMark();
107       if (mark.isExpanded()) {
108         // Needs extra 4 bytes for identity hash-code.
109         s += 4;
110       }
111     }
112     s = Oop.alignObjectSize(s);
113     return s;
114   }
115 
116   public static long baseOffsetInBytes(BasicType type) {
117     long typeSizeInBytes = headerSizeInBytes();
118     if (elementTypeShouldBeAligned(type)) {
119       VM vm = VM.getVM();
120       return vm.alignUp(typeSizeInBytes, vm.getVM().getHeapWordSize());
121     } else {
122       return typeSizeInBytes;
123     }
124   }
125 
126   public boolean isArray()             { return true; }
127 
128   public void iterateFields(OopVisitor visitor, boolean doVMFields) {
129     super.iterateFields(visitor, doVMFields);
130   }
131 }
< prev index next >