author | rkennke |
Thu, 19 Oct 2017 20:48:31 -0400 | |
changeset 47663 | 3e78d37acdde |
parent 47216 | 71c04702a3d5 |
child 47819 | ee36a8e36561 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
46729 | 2 |
* Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
3261
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
3261
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
3261
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
25 |
package sun.jvm.hotspot.memory; |
|
26 |
||
27 |
import java.io.*; |
|
28 |
import java.util.*; |
|
29 |
import sun.jvm.hotspot.debugger.*; |
|
47663 | 30 |
import sun.jvm.hotspot.gc.cms.CMSHeap; |
30764 | 31 |
import sun.jvm.hotspot.gc.shared.*; |
32 |
import sun.jvm.hotspot.gc.g1.G1CollectedHeap; |
|
33 |
import sun.jvm.hotspot.gc.parallel.*; |
|
1 | 34 |
import sun.jvm.hotspot.oops.*; |
35 |
import sun.jvm.hotspot.types.*; |
|
36 |
import sun.jvm.hotspot.runtime.*; |
|
37 |
||
38 |
||
39 |
public class Universe { |
|
40 |
private static AddressField collectedHeapField; |
|
41 |
private static VirtualConstructor heapConstructor; |
|
42 |
private static sun.jvm.hotspot.types.OopField mainThreadGroupField; |
|
43 |
private static sun.jvm.hotspot.types.OopField systemThreadGroupField; |
|
44 |
||
45 |
// single dimensional primitive array klasses |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10663
diff
changeset
|
46 |
private static sun.jvm.hotspot.types.AddressField boolArrayKlassField; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10663
diff
changeset
|
47 |
private static sun.jvm.hotspot.types.AddressField byteArrayKlassField; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10663
diff
changeset
|
48 |
private static sun.jvm.hotspot.types.AddressField charArrayKlassField; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10663
diff
changeset
|
49 |
private static sun.jvm.hotspot.types.AddressField intArrayKlassField; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10663
diff
changeset
|
50 |
private static sun.jvm.hotspot.types.AddressField shortArrayKlassField; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10663
diff
changeset
|
51 |
private static sun.jvm.hotspot.types.AddressField longArrayKlassField; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10663
diff
changeset
|
52 |
private static sun.jvm.hotspot.types.AddressField singleArrayKlassField; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10663
diff
changeset
|
53 |
private static sun.jvm.hotspot.types.AddressField doubleArrayKlassField; |
1 | 54 |
|
2254
f13dda645a4b
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
670
diff
changeset
|
55 |
private static AddressField narrowOopBaseField; |
f13dda645a4b
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
670
diff
changeset
|
56 |
private static CIntegerField narrowOopShiftField; |
13969
d2a189b83b87
7054512: Compress class pointers after perm gen removal
roland
parents:
13728
diff
changeset
|
57 |
private static AddressField narrowKlassBaseField; |
d2a189b83b87
7054512: Compress class pointers after perm gen removal
roland
parents:
13728
diff
changeset
|
58 |
private static CIntegerField narrowKlassShiftField; |
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
59 |
|
25335 | 60 |
public enum NARROW_OOP_MODE { |
61 |
UnscaledNarrowOop, |
|
62 |
ZeroBasedNarrowOop, |
|
63 |
HeapBasedNarrowOop |
|
64 |
} |
|
65 |
||
1 | 66 |
static { |
67 |
VM.registerVMInitializedObserver(new Observer() { |
|
68 |
public void update(Observable o, Object data) { |
|
69 |
initialize(VM.getVM().getTypeDataBase()); |
|
70 |
} |
|
71 |
}); |
|
72 |
} |
|
73 |
||
74 |
private static synchronized void initialize(TypeDataBase db) { |
|
75 |
Type type = db.lookupType("Universe"); |
|
76 |
||
77 |
collectedHeapField = type.getAddressField("_collectedHeap"); |
|
78 |
||
79 |
heapConstructor = new VirtualConstructor(db); |
|
80 |
heapConstructor.addMapping("GenCollectedHeap", GenCollectedHeap.class); |
|
47663 | 81 |
heapConstructor.addMapping("CMSHeap", CMSHeap.class); |
1 | 82 |
heapConstructor.addMapping("ParallelScavengeHeap", ParallelScavengeHeap.class); |
10663 | 83 |
heapConstructor.addMapping("G1CollectedHeap", G1CollectedHeap.class); |
1 | 84 |
|
85 |
mainThreadGroupField = type.getOopField("_main_thread_group"); |
|
86 |
systemThreadGroupField = type.getOopField("_system_thread_group"); |
|
87 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10663
diff
changeset
|
88 |
boolArrayKlassField = type.getAddressField("_boolArrayKlassObj"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10663
diff
changeset
|
89 |
byteArrayKlassField = type.getAddressField("_byteArrayKlassObj"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10663
diff
changeset
|
90 |
charArrayKlassField = type.getAddressField("_charArrayKlassObj"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10663
diff
changeset
|
91 |
intArrayKlassField = type.getAddressField("_intArrayKlassObj"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10663
diff
changeset
|
92 |
shortArrayKlassField = type.getAddressField("_shortArrayKlassObj"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10663
diff
changeset
|
93 |
longArrayKlassField = type.getAddressField("_longArrayKlassObj"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10663
diff
changeset
|
94 |
singleArrayKlassField = type.getAddressField("_singleArrayKlassObj"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10663
diff
changeset
|
95 |
doubleArrayKlassField = type.getAddressField("_doubleArrayKlassObj"); |
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
96 |
|
2254
f13dda645a4b
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
670
diff
changeset
|
97 |
narrowOopBaseField = type.getAddressField("_narrow_oop._base"); |
f13dda645a4b
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
670
diff
changeset
|
98 |
narrowOopShiftField = type.getCIntegerField("_narrow_oop._shift"); |
13969
d2a189b83b87
7054512: Compress class pointers after perm gen removal
roland
parents:
13728
diff
changeset
|
99 |
narrowKlassBaseField = type.getAddressField("_narrow_klass._base"); |
d2a189b83b87
7054512: Compress class pointers after perm gen removal
roland
parents:
13728
diff
changeset
|
100 |
narrowKlassShiftField = type.getCIntegerField("_narrow_klass._shift"); |
39227
59ace61f7436
8157243: JMap heap test fail when used with external heap
sjohanss
parents:
35217
diff
changeset
|
101 |
|
59ace61f7436
8157243: JMap heap test fail when used with external heap
sjohanss
parents:
35217
diff
changeset
|
102 |
UniverseExt.initialize(heapConstructor); |
1 | 103 |
} |
104 |
||
105 |
public Universe() { |
|
106 |
} |
|
25335 | 107 |
public static String narrowOopModeToString(NARROW_OOP_MODE mode) { |
108 |
switch (mode) { |
|
109 |
case UnscaledNarrowOop: |
|
110 |
return "32-bits Oops"; |
|
111 |
case ZeroBasedNarrowOop: |
|
112 |
return "zero based Compressed Oops"; |
|
113 |
case HeapBasedNarrowOop: |
|
114 |
return "Compressed Oops with base"; |
|
115 |
} |
|
116 |
return ""; |
|
117 |
} |
|
1 | 118 |
public CollectedHeap heap() { |
30159 | 119 |
return (CollectedHeap) heapConstructor.instantiateWrapperFor(collectedHeapField.getValue()); |
1 | 120 |
} |
121 |
||
2254
f13dda645a4b
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
670
diff
changeset
|
122 |
public static long getNarrowOopBase() { |
f13dda645a4b
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
670
diff
changeset
|
123 |
if (narrowOopBaseField.getValue() == null) { |
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
124 |
return 0; |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
125 |
} else { |
2254
f13dda645a4b
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
670
diff
changeset
|
126 |
return narrowOopBaseField.getValue().minus(null); |
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
127 |
} |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
128 |
} |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
129 |
|
2254
f13dda645a4b
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
670
diff
changeset
|
130 |
public static int getNarrowOopShift() { |
f13dda645a4b
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
670
diff
changeset
|
131 |
return (int)narrowOopShiftField.getValue(); |
f13dda645a4b
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
670
diff
changeset
|
132 |
} |
f13dda645a4b
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
670
diff
changeset
|
133 |
|
13969
d2a189b83b87
7054512: Compress class pointers after perm gen removal
roland
parents:
13728
diff
changeset
|
134 |
public static long getNarrowKlassBase() { |
d2a189b83b87
7054512: Compress class pointers after perm gen removal
roland
parents:
13728
diff
changeset
|
135 |
if (narrowKlassBaseField.getValue() == null) { |
d2a189b83b87
7054512: Compress class pointers after perm gen removal
roland
parents:
13728
diff
changeset
|
136 |
return 0; |
d2a189b83b87
7054512: Compress class pointers after perm gen removal
roland
parents:
13728
diff
changeset
|
137 |
} else { |
d2a189b83b87
7054512: Compress class pointers after perm gen removal
roland
parents:
13728
diff
changeset
|
138 |
return narrowKlassBaseField.getValue().minus(null); |
d2a189b83b87
7054512: Compress class pointers after perm gen removal
roland
parents:
13728
diff
changeset
|
139 |
} |
d2a189b83b87
7054512: Compress class pointers after perm gen removal
roland
parents:
13728
diff
changeset
|
140 |
} |
d2a189b83b87
7054512: Compress class pointers after perm gen removal
roland
parents:
13728
diff
changeset
|
141 |
|
d2a189b83b87
7054512: Compress class pointers after perm gen removal
roland
parents:
13728
diff
changeset
|
142 |
public static int getNarrowKlassShift() { |
d2a189b83b87
7054512: Compress class pointers after perm gen removal
roland
parents:
13728
diff
changeset
|
143 |
return (int)narrowKlassShiftField.getValue(); |
d2a189b83b87
7054512: Compress class pointers after perm gen removal
roland
parents:
13728
diff
changeset
|
144 |
} |
d2a189b83b87
7054512: Compress class pointers after perm gen removal
roland
parents:
13728
diff
changeset
|
145 |
|
d2a189b83b87
7054512: Compress class pointers after perm gen removal
roland
parents:
13728
diff
changeset
|
146 |
|
1 | 147 |
/** Returns "TRUE" iff "p" points into the allocated area of the heap. */ |
148 |
public boolean isIn(Address p) { |
|
149 |
return heap().isIn(p); |
|
150 |
} |
|
151 |
||
152 |
/** Returns "TRUE" iff "p" points into the reserved area of the heap. */ |
|
153 |
public boolean isInReserved(Address p) { |
|
154 |
return heap().isInReserved(p); |
|
155 |
} |
|
156 |
||
157 |
private Oop newOop(OopHandle handle) { |
|
158 |
return VM.getVM().getObjectHeap().newOop(handle); |
|
159 |
} |
|
160 |
||
161 |
public Oop mainThreadGroup() { |
|
162 |
return newOop(mainThreadGroupField.getValue()); |
|
163 |
} |
|
164 |
||
165 |
public Oop systemThreadGroup() { |
|
166 |
return newOop(systemThreadGroupField.getValue()); |
|
167 |
} |
|
168 |
||
169 |
||
170 |
public void print() { printOn(System.out); } |
|
171 |
public void printOn(PrintStream tty) { |
|
172 |
heap().printOn(tty); |
|
173 |
} |
|
174 |
||
175 |
// Check whether an element of a typeArrayOop with the given type must be |
|
176 |
// aligned 0 mod 8. The typeArrayOop itself must be aligned at least this |
|
177 |
// strongly. |
|
178 |
public static boolean elementTypeShouldBeAligned(BasicType type) { |
|
179 |
return type == BasicType.T_DOUBLE || type == BasicType.T_LONG; |
|
180 |
} |
|
181 |
||
182 |
// Check whether an object field (static/non-static) of the given type must be |
|
183 |
// aligned 0 mod 8. |
|
184 |
public static boolean fieldTypeShouldBeAligned(BasicType type) { |
|
185 |
return type == BasicType.T_DOUBLE || type == BasicType.T_LONG; |
|
186 |
} |
|
187 |
} |