comparison agent/src/share/classes/sun/jvm/hotspot/oops/Oop.java @ 6725:da91efe96a93

6964458: Reimplement class meta-data storage to use native memory Summary: Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland Contributed-by: jmasa <jon.masamitsu@oracle.com>, stefank <stefan.karlsson@oracle.com>, mgerdin <mikael.gerdin@oracle.com>, never <tom.rodriguez@oracle.com>
author coleenp
date Sat, 01 Sep 2012 13:25:18 -0400
parents 63997f575155
children 8e47bac5643a
comparison
equal deleted inserted replaced
6724:36d1d483d5d6 6725:da91efe96a93
1 /* 1 /*
2 * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
28 import java.util.*; 28 import java.util.*;
29 import sun.jvm.hotspot.utilities.*; 29 import sun.jvm.hotspot.utilities.*;
30 import sun.jvm.hotspot.debugger.*; 30 import sun.jvm.hotspot.debugger.*;
31 import sun.jvm.hotspot.runtime.*; 31 import sun.jvm.hotspot.runtime.*;
32 import sun.jvm.hotspot.types.*; 32 import sun.jvm.hotspot.types.*;
33 import sun.jvm.hotspot.memory.CompactingPermGenGen;
34 33
35 // Oop represents the superclass for all types of 34 // Oop represents the superclass for all types of
36 // objects in the HotSpot object heap. 35 // objects in the HotSpot object heap.
37 36
38 public class Oop { 37 public class Oop {
45 } 44 }
46 45
47 private static synchronized void initialize(TypeDataBase db) throws WrongTypeException { 46 private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
48 Type type = db.lookupType("oopDesc"); 47 Type type = db.lookupType("oopDesc");
49 mark = new CIntField(type.getCIntegerField("_mark"), 0); 48 mark = new CIntField(type.getCIntegerField("_mark"), 0);
50 klass = new OopField(type.getOopField("_metadata._klass"), 0); 49 klass = new MetadataField(type.getAddressField("_metadata._klass"), 0);
51 compressedKlass = new NarrowOopField(type.getOopField("_metadata._compressed_klass"), 0); 50 if (VM.getVM().isCompressedHeadersEnabled()) {
51 // compressedKlass = new CIntField(type.getCIntegerField("_metadata._compressed_klass"), 0);
52 throw new InternalError("unimplemented");
53 }
52 headerSize = type.getSize(); 54 headerSize = type.getSize();
53 } 55 }
54 56
55 private OopHandle handle; 57 private OopHandle handle;
56 private ObjectHeap heap; 58 private ObjectHeap heap;
69 71
70 private static long headerSize; 72 private static long headerSize;
71 public static long getHeaderSize() { return headerSize; } // Header size in bytes. 73 public static long getHeaderSize() { return headerSize; } // Header size in bytes.
72 74
73 private static CIntField mark; 75 private static CIntField mark;
74 private static OopField klass; 76 private static MetadataField klass;
75 private static NarrowOopField compressedKlass; 77 private static CIntField compressedKlass;
76
77 public boolean isShared() {
78 return CompactingPermGenGen.isShared(handle);
79 }
80
81 public boolean isSharedReadOnly() {
82 return CompactingPermGenGen.isSharedReadOnly(handle);
83 }
84
85 public boolean isSharedReadWrite() {
86 return CompactingPermGenGen.isSharedReadWrite(handle);
87 }
88 78
89 // Accessors for declared fields 79 // Accessors for declared fields
90 public Mark getMark() { return new Mark(getHandle()); } 80 public Mark getMark() { return new Mark(getHandle()); }
91 public Klass getKlass() { 81 public Klass getKlass() {
92 if (VM.getVM().isCompressedOopsEnabled()) { 82 if (VM.getVM().isCompressedHeadersEnabled()) {
93 return (Klass) compressedKlass.getValue(this); 83 throw new InternalError("unimplemented");
94 } else { 84 } else {
95 return (Klass) klass.getValue(this); 85 return (Klass)klass.getValue(getHandle());
96 } 86 }
97 } 87 }
98 88
99 public boolean isA(Klass k) { 89 public boolean isA(Klass k) {
100 return getKlass().isSubtypeOf(k); 90 return getKlass().isSubtypeOf(k);
111 public boolean isInstance() { return false; } 101 public boolean isInstance() { return false; }
112 public boolean isInstanceRef() { return false; } 102 public boolean isInstanceRef() { return false; }
113 public boolean isArray() { return false; } 103 public boolean isArray() { return false; }
114 public boolean isObjArray() { return false; } 104 public boolean isObjArray() { return false; }
115 public boolean isTypeArray() { return false; } 105 public boolean isTypeArray() { return false; }
116 public boolean isSymbol() { return false; }
117 public boolean isKlass() { return false; }
118 public boolean isThread() { return false; } 106 public boolean isThread() { return false; }
119 public boolean isMethod() { return false; }
120 public boolean isMethodData() { return false; }
121 public boolean isConstantPool() { return false; }
122 public boolean isConstantPoolCache() { return false; }
123 public boolean isCompiledICHolder() { return false; }
124 107
125 // Align the object size. 108 // Align the object size.
126 public static long alignObjectSize(long size) { 109 public static long alignObjectSize(long size) {
127 return VM.getVM().alignUp(size, VM.getVM().getMinObjAlignmentInBytes()); 110 return VM.getVM().alignUp(size, VM.getVM().getMinObjAlignmentInBytes());
128 } 111 }
165 } 148 }
166 149
167 void iterateFields(OopVisitor visitor, boolean doVMFields) { 150 void iterateFields(OopVisitor visitor, boolean doVMFields) {
168 if (doVMFields) { 151 if (doVMFields) {
169 visitor.doCInt(mark, true); 152 visitor.doCInt(mark, true);
170 if (VM.getVM().isCompressedOopsEnabled()) { 153 if (VM.getVM().isCompressedHeadersEnabled()) {
171 visitor.doOop(compressedKlass, true); 154 throw new InternalError("unimplemented");
172 } else { 155 } else {
173 visitor.doOop(klass, true); 156 visitor.doMetadata(klass, true);
174 } 157 }
175 } 158 }
176 } 159 }
177 160
178 public void print() { printOn(System.out); } 161 public void print() { printOn(System.out); }
221 } 204 }
222 205
223 public boolean verify() { return true;} 206 public boolean verify() { return true;}
224 207
225 // Package-private routine to speed up ObjectHeap.newOop 208 // Package-private routine to speed up ObjectHeap.newOop
226 static OopHandle getKlassForOopHandle(OopHandle handle) { 209 static Klass getKlassForOopHandle(OopHandle handle) {
227 if (handle == null) { 210 if (handle == null) {
228 return null; 211 return null;
229 } 212 }
230 if (VM.getVM().isCompressedOopsEnabled()) { 213 if (VM.getVM().isCompressedHeadersEnabled()) {
231 return handle.getCompOopHandleAt(compressedKlass.getOffset()); 214 throw new InternalError("Unimplemented");
232 } else { 215 } else {
233 return handle.getOopHandleAt(klass.getOffset()); 216 return (Klass)Metadata.instantiateWrapperFor(handle.getAddressAt(klass.getOffset()));
234 } 217 }
235 } 218 }
236 }; 219 };