Mercurial > hg > truffle
annotate agent/src/share/classes/sun/jvm/hotspot/memory/Universe.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 | 4f93f0d00802 |
children | 8e47bac5643a |
rev | line source |
---|---|
0 | 1 /* |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3972
diff
changeset
|
2 * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. |
0 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
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 | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
844
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
844
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
844
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
25 package sun.jvm.hotspot.memory; | |
26 | |
27 import java.io.*; | |
28 import java.util.*; | |
29 import sun.jvm.hotspot.debugger.*; | |
30 import sun.jvm.hotspot.gc_interface.*; | |
3972 | 31 import sun.jvm.hotspot.gc_implementation.g1.G1CollectedHeap; |
0 | 32 import sun.jvm.hotspot.gc_implementation.parallelScavenge.*; |
33 import sun.jvm.hotspot.oops.*; | |
34 import sun.jvm.hotspot.types.*; | |
35 import sun.jvm.hotspot.runtime.*; | |
36 | |
37 | |
38 public class Universe { | |
39 private static AddressField collectedHeapField; | |
40 private static VirtualConstructor heapConstructor; | |
41 private static sun.jvm.hotspot.types.OopField mainThreadGroupField; | |
42 private static sun.jvm.hotspot.types.OopField systemThreadGroupField; | |
43 | |
44 // single dimensional primitive array klasses | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3972
diff
changeset
|
45 private static sun.jvm.hotspot.types.AddressField boolArrayKlassField; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3972
diff
changeset
|
46 private static sun.jvm.hotspot.types.AddressField byteArrayKlassField; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3972
diff
changeset
|
47 private static sun.jvm.hotspot.types.AddressField charArrayKlassField; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3972
diff
changeset
|
48 private static sun.jvm.hotspot.types.AddressField intArrayKlassField; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3972
diff
changeset
|
49 private static sun.jvm.hotspot.types.AddressField shortArrayKlassField; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3972
diff
changeset
|
50 private static sun.jvm.hotspot.types.AddressField longArrayKlassField; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3972
diff
changeset
|
51 private static sun.jvm.hotspot.types.AddressField singleArrayKlassField; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3972
diff
changeset
|
52 private static sun.jvm.hotspot.types.AddressField doubleArrayKlassField; |
0 | 53 |
642
660978a2a31a
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
196
diff
changeset
|
54 private static AddressField narrowOopBaseField; |
660978a2a31a
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
196
diff
changeset
|
55 private static CIntegerField narrowOopShiftField; |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
56 |
0 | 57 static { |
58 VM.registerVMInitializedObserver(new Observer() { | |
59 public void update(Observable o, Object data) { | |
60 initialize(VM.getVM().getTypeDataBase()); | |
61 } | |
62 }); | |
63 } | |
64 | |
65 private static synchronized void initialize(TypeDataBase db) { | |
66 Type type = db.lookupType("Universe"); | |
67 | |
68 collectedHeapField = type.getAddressField("_collectedHeap"); | |
69 | |
70 heapConstructor = new VirtualConstructor(db); | |
71 heapConstructor.addMapping("GenCollectedHeap", GenCollectedHeap.class); | |
72 heapConstructor.addMapping("ParallelScavengeHeap", ParallelScavengeHeap.class); | |
3972 | 73 heapConstructor.addMapping("G1CollectedHeap", G1CollectedHeap.class); |
0 | 74 |
75 mainThreadGroupField = type.getOopField("_main_thread_group"); | |
76 systemThreadGroupField = type.getOopField("_system_thread_group"); | |
77 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3972
diff
changeset
|
78 boolArrayKlassField = type.getAddressField("_boolArrayKlassObj"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3972
diff
changeset
|
79 byteArrayKlassField = type.getAddressField("_byteArrayKlassObj"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3972
diff
changeset
|
80 charArrayKlassField = type.getAddressField("_charArrayKlassObj"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3972
diff
changeset
|
81 intArrayKlassField = type.getAddressField("_intArrayKlassObj"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3972
diff
changeset
|
82 shortArrayKlassField = type.getAddressField("_shortArrayKlassObj"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3972
diff
changeset
|
83 longArrayKlassField = type.getAddressField("_longArrayKlassObj"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3972
diff
changeset
|
84 singleArrayKlassField = type.getAddressField("_singleArrayKlassObj"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3972
diff
changeset
|
85 doubleArrayKlassField = type.getAddressField("_doubleArrayKlassObj"); |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
86 |
642
660978a2a31a
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
196
diff
changeset
|
87 narrowOopBaseField = type.getAddressField("_narrow_oop._base"); |
660978a2a31a
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
196
diff
changeset
|
88 narrowOopShiftField = type.getCIntegerField("_narrow_oop._shift"); |
0 | 89 } |
90 | |
91 public Universe() { | |
92 } | |
93 | |
94 public CollectedHeap heap() { | |
95 try { | |
96 return (CollectedHeap) heapConstructor.instantiateWrapperFor(collectedHeapField.getValue()); | |
97 } catch (WrongTypeException e) { | |
98 return new CollectedHeap(collectedHeapField.getValue()); | |
99 } | |
100 } | |
101 | |
642
660978a2a31a
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
196
diff
changeset
|
102 public static long getNarrowOopBase() { |
660978a2a31a
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
196
diff
changeset
|
103 if (narrowOopBaseField.getValue() == null) { |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
104 return 0; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
105 } else { |
642
660978a2a31a
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
196
diff
changeset
|
106 return narrowOopBaseField.getValue().minus(null); |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
107 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
108 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
109 |
642
660978a2a31a
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
196
diff
changeset
|
110 public static int getNarrowOopShift() { |
660978a2a31a
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
196
diff
changeset
|
111 return (int)narrowOopShiftField.getValue(); |
660978a2a31a
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
196
diff
changeset
|
112 } |
660978a2a31a
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
196
diff
changeset
|
113 |
0 | 114 /** Returns "TRUE" iff "p" points into the allocated area of the heap. */ |
115 public boolean isIn(Address p) { | |
116 return heap().isIn(p); | |
117 } | |
118 | |
119 /** Returns "TRUE" iff "p" points into the reserved area of the heap. */ | |
120 public boolean isInReserved(Address p) { | |
121 return heap().isInReserved(p); | |
122 } | |
123 | |
124 private Oop newOop(OopHandle handle) { | |
125 return VM.getVM().getObjectHeap().newOop(handle); | |
126 } | |
127 | |
128 public Oop mainThreadGroup() { | |
129 return newOop(mainThreadGroupField.getValue()); | |
130 } | |
131 | |
132 public Oop systemThreadGroup() { | |
133 return newOop(systemThreadGroupField.getValue()); | |
134 } | |
135 | |
136 // iterate through the single dimensional primitive array klasses | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3972
diff
changeset
|
137 // refer to basic_type_classes_do(void f(Klass*)) in universe.cpp |
0 | 138 public void basicTypeClassesDo(SystemDictionary.ClassVisitor visitor) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3972
diff
changeset
|
139 visitor.visit(new TypeArrayKlass(boolArrayKlassField.getValue())); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3972
diff
changeset
|
140 visitor.visit(new TypeArrayKlass(byteArrayKlassField.getValue())); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3972
diff
changeset
|
141 visitor.visit(new TypeArrayKlass(charArrayKlassField.getValue())); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3972
diff
changeset
|
142 visitor.visit(new TypeArrayKlass(intArrayKlassField.getValue())); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3972
diff
changeset
|
143 visitor.visit(new TypeArrayKlass(shortArrayKlassField.getValue())); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3972
diff
changeset
|
144 visitor.visit(new TypeArrayKlass(longArrayKlassField.getValue())); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3972
diff
changeset
|
145 visitor.visit(new TypeArrayKlass(singleArrayKlassField.getValue())); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3972
diff
changeset
|
146 visitor.visit(new TypeArrayKlass(doubleArrayKlassField.getValue())); |
0 | 147 } |
148 | |
149 public void print() { printOn(System.out); } | |
150 public void printOn(PrintStream tty) { | |
151 heap().printOn(tty); | |
152 } | |
153 | |
154 // Check whether an element of a typeArrayOop with the given type must be | |
155 // aligned 0 mod 8. The typeArrayOop itself must be aligned at least this | |
156 // strongly. | |
157 public static boolean elementTypeShouldBeAligned(BasicType type) { | |
158 return type == BasicType.T_DOUBLE || type == BasicType.T_LONG; | |
159 } | |
160 | |
161 // Check whether an object field (static/non-static) of the given type must be | |
162 // aligned 0 mod 8. | |
163 public static boolean fieldTypeShouldBeAligned(BasicType type) { | |
164 return type == BasicType.T_DOUBLE || type == BasicType.T_LONG; | |
165 } | |
166 } |