comparison agent/src/share/classes/sun/jvm/hotspot/oops/Klass.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 1d1603768966
children d8ce2825b193
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.debugger.*; 29 import sun.jvm.hotspot.debugger.*;
30 import sun.jvm.hotspot.runtime.*; 30 import sun.jvm.hotspot.runtime.*;
31 import sun.jvm.hotspot.types.*; 31 import sun.jvm.hotspot.types.*;
32 32
33 public class Klass extends Oop implements ClassConstants { 33 public class Klass extends Metadata implements ClassConstants {
34 static { 34 static {
35 VM.registerVMInitializedObserver(new Observer() { 35 VM.registerVMInitializedObserver(new Observer() {
36 public void update(Observable o, Object data) { 36 public void update(Observable o, Object data) {
37 initialize(VM.getVM().getTypeDataBase()); 37 initialize(VM.getVM().getTypeDataBase());
38 } 38 }
48 public static int LH_ARRAY_TAG_TYPE_VALUE; 48 public static int LH_ARRAY_TAG_TYPE_VALUE;
49 public static int LH_ARRAY_TAG_OBJ_VALUE; 49 public static int LH_ARRAY_TAG_OBJ_VALUE;
50 50
51 private static synchronized void initialize(TypeDataBase db) throws WrongTypeException { 51 private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
52 Type type = db.lookupType("Klass"); 52 Type type = db.lookupType("Klass");
53 javaMirror = new OopField(type.getOopField("_java_mirror"), Oop.getHeaderSize()); 53 javaMirror = new OopField(type.getOopField("_java_mirror"), 0);
54 superField = new OopField(type.getOopField("_super"), Oop.getHeaderSize()); 54 superField = new MetadataField(type.getAddressField("_super"), 0);
55 layoutHelper = new IntField(type.getJIntField("_layout_helper"), Oop.getHeaderSize()); 55 layoutHelper = new IntField(type.getJIntField("_layout_helper"), 0);
56 name = type.getAddressField("_name"); 56 name = type.getAddressField("_name");
57 accessFlags = new CIntField(type.getCIntegerField("_access_flags"), Oop.getHeaderSize()); 57 accessFlags = new CIntField(type.getCIntegerField("_access_flags"), 0);
58 subklass = new OopField(type.getOopField("_subklass"), Oop.getHeaderSize()); 58 subklass = new MetadataField(type.getAddressField("_subklass"), 0);
59 nextSibling = new OopField(type.getOopField("_next_sibling"), Oop.getHeaderSize()); 59 nextSibling = new MetadataField(type.getAddressField("_next_sibling"), 0);
60 allocCount = new CIntField(type.getCIntegerField("_alloc_count"), Oop.getHeaderSize()); 60 allocCount = new CIntField(type.getCIntegerField("_alloc_count"), 0);
61 61
62 LH_INSTANCE_SLOW_PATH_BIT = db.lookupIntConstant("Klass::_lh_instance_slow_path_bit").intValue(); 62 LH_INSTANCE_SLOW_PATH_BIT = db.lookupIntConstant("Klass::_lh_instance_slow_path_bit").intValue();
63 LH_LOG2_ELEMENT_SIZE_SHIFT = db.lookupIntConstant("Klass::_lh_log2_element_size_shift").intValue(); 63 LH_LOG2_ELEMENT_SIZE_SHIFT = db.lookupIntConstant("Klass::_lh_log2_element_size_shift").intValue();
64 LH_ELEMENT_TYPE_SHIFT = db.lookupIntConstant("Klass::_lh_element_type_shift").intValue(); 64 LH_ELEMENT_TYPE_SHIFT = db.lookupIntConstant("Klass::_lh_element_type_shift").intValue();
65 LH_HEADER_SIZE_SHIFT = db.lookupIntConstant("Klass::_lh_header_size_shift").intValue(); 65 LH_HEADER_SIZE_SHIFT = db.lookupIntConstant("Klass::_lh_header_size_shift").intValue();
66 LH_ARRAY_TAG_SHIFT = db.lookupIntConstant("Klass::_lh_array_tag_shift").intValue(); 66 LH_ARRAY_TAG_SHIFT = db.lookupIntConstant("Klass::_lh_array_tag_shift").intValue();
67 LH_ARRAY_TAG_TYPE_VALUE = db.lookupIntConstant("Klass::_lh_array_tag_type_value").intValue(); 67 LH_ARRAY_TAG_TYPE_VALUE = db.lookupIntConstant("Klass::_lh_array_tag_type_value").intValue();
68 LH_ARRAY_TAG_OBJ_VALUE = db.lookupIntConstant("Klass::_lh_array_tag_obj_value").intValue(); 68 LH_ARRAY_TAG_OBJ_VALUE = db.lookupIntConstant("Klass::_lh_array_tag_obj_value").intValue();
69 } 69 }
70 70
71 Klass(OopHandle handle, ObjectHeap heap) { 71 public Klass(Address addr) {
72 super(handle, heap); 72 super(addr);
73 } 73 }
74 74
75 // jvmdi support - see also class_status in VM code 75 // jvmdi support - see also class_status in VM code
76 public int getClassStatus() { 76 public int getClassStatus() {
77 return 0; // overridden in derived classes 77 return 0; // overridden in derived classes
79 79
80 public boolean isKlass() { return true; } 80 public boolean isKlass() { return true; }
81 81
82 // Fields 82 // Fields
83 private static OopField javaMirror; 83 private static OopField javaMirror;
84 private static OopField superField; 84 private static MetadataField superField;
85 private static IntField layoutHelper; 85 private static IntField layoutHelper;
86 private static AddressField name; 86 private static AddressField name;
87 private static CIntField accessFlags; 87 private static CIntField accessFlags;
88 private static OopField subklass; 88 private static MetadataField subklass;
89 private static OopField nextSibling; 89 private static MetadataField nextSibling;
90 private static CIntField allocCount; 90 private static CIntField allocCount;
91 91
92 private Address getValue(AddressField field) { 92 private Address getValue(AddressField field) {
93 return getHandle().getAddressAt(field.getOffset() + Oop.getHeaderSize()); 93 return addr.getAddressAt(field.getOffset());
94 } 94 }
95 95
96 protected Symbol getSymbol(AddressField field) { 96 protected Symbol getSymbol(AddressField field) {
97 return Symbol.create(getHandle().getAddressAt(field.getOffset() + Oop.getHeaderSize())); 97 return Symbol.create(addr.getAddressAt(field.getOffset()));
98 } 98 }
99 99
100 // Accessors for declared fields 100 // Accessors for declared fields
101 public Instance getJavaMirror() { return (Instance) javaMirror.getValue(this); } 101 public Instance getJavaMirror() { return (Instance) javaMirror.getValue(this); }
102 public Klass getSuper() { return (Klass) superField.getValue(this); } 102 public Klass getSuper() { return (Klass) superField.getValue(this); }
162 162
163 public void printValueOn(PrintStream tty) { 163 public void printValueOn(PrintStream tty) {
164 tty.print("Klass"); 164 tty.print("Klass");
165 } 165 }
166 166
167 public void iterateFields(OopVisitor visitor, boolean doVMFields) { 167 public void iterateFields(MetadataVisitor visitor) {
168 super.iterateFields(visitor, doVMFields);
169 if (doVMFields) {
170 visitor.doOop(javaMirror, true); 168 visitor.doOop(javaMirror, true);
171 visitor.doOop(superField, true); 169 visitor.doMetadata(superField, true);
172 visitor.doInt(layoutHelper, true); 170 visitor.doInt(layoutHelper, true);
173 // visitor.doOop(name, true); 171 // visitor.doOop(name, true);
174 visitor.doCInt(accessFlags, true); 172 visitor.doCInt(accessFlags, true);
175 visitor.doOop(subklass, true); 173 visitor.doMetadata(subklass, true);
176 visitor.doOop(nextSibling, true); 174 visitor.doMetadata(nextSibling, true);
177 visitor.doCInt(allocCount, true); 175 visitor.doCInt(allocCount, true);
178 } 176 }
179 }
180 177
181 public long getObjectSize() { 178 public long getObjectSize() {
182 throw new RuntimeException("should not reach here"); 179 throw new RuntimeException("should not reach here");
183 } 180 }
184 181
189 /** These will return null instead of allocating on the heap */ 186 /** These will return null instead of allocating on the heap */
190 public Klass arrayKlassOrNull(int rank) { return arrayKlassImpl(true, rank); } 187 public Klass arrayKlassOrNull(int rank) { return arrayKlassImpl(true, rank); }
191 public Klass arrayKlassOrNull() { return arrayKlassImpl(true); } 188 public Klass arrayKlassOrNull() { return arrayKlassImpl(true); }
192 189
193 public Klass arrayKlassImpl(boolean orNull, int rank) { 190 public Klass arrayKlassImpl(boolean orNull, int rank) {
194 throw new RuntimeException("array_klass should be dispatched to instanceKlass, objArrayKlass or typeArrayKlass"); 191 throw new RuntimeException("array_klass should be dispatched to InstanceKlass, objArrayKlass or typeArrayKlass");
195 } 192 }
196 193
197 public Klass arrayKlassImpl(boolean orNull) { 194 public Klass arrayKlassImpl(boolean orNull) {
198 throw new RuntimeException("array_klass should be dispatched to instanceKlass, objArrayKlass or typeArrayKlass"); 195 throw new RuntimeException("array_klass should be dispatched to InstanceKlass, objArrayKlass or typeArrayKlass");
199 } 196 }
200 197
201 // This returns the name in the form java/lang/String which isn't really a signature 198 // This returns the name in the form java/lang/String which isn't really a signature
202 // The subclasses override this to produce the correct form, eg 199 // The subclasses override this to produce the correct form, eg
203 // Ljava/lang/String; For ArrayKlasses getName itself is the signature. 200 // Ljava/lang/String; For ArrayKlasses getName itself is the signature.