author | jgeorge |
Tue, 20 Mar 2018 11:24:32 +0530 | |
changeset 49463 | ccb003941743 |
parent 47619 | 74f5b6c267e3 |
child 53814 | eff915f3d3f2 |
permissions | -rw-r--r-- |
10663 | 1 |
/* |
49463
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
47619
diff
changeset
|
2 |
* Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved. |
10663 | 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 |
* |
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
22 |
* |
|
23 |
*/ |
|
24 |
||
30764 | 25 |
package sun.jvm.hotspot.gc.g1; |
10663 | 26 |
|
49463
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
47619
diff
changeset
|
27 |
import java.io.PrintStream; |
25481
1427aa24638c
8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents:
10663
diff
changeset
|
28 |
import java.util.ArrayList; |
1427aa24638c
8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents:
10663
diff
changeset
|
29 |
import java.util.List; |
10663 | 30 |
import java.util.Observable; |
31 |
import java.util.Observer; |
|
32 |
import sun.jvm.hotspot.debugger.Address; |
|
47602
d4380ee1cbe9
8187403: [Unknown generation] is shown in Stack Memory on HSDB
ysuenaga
parents:
47216
diff
changeset
|
33 |
import sun.jvm.hotspot.debugger.OopHandle; |
30769 | 34 |
import sun.jvm.hotspot.gc.shared.CompactibleSpace; |
25481
1427aa24638c
8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents:
10663
diff
changeset
|
35 |
import sun.jvm.hotspot.memory.MemRegion; |
10663 | 36 |
import sun.jvm.hotspot.runtime.VM; |
47602
d4380ee1cbe9
8187403: [Unknown generation] is shown in Stack Memory on HSDB
ysuenaga
parents:
47216
diff
changeset
|
37 |
import sun.jvm.hotspot.runtime.VMObjectFactory; |
25481
1427aa24638c
8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents:
10663
diff
changeset
|
38 |
import sun.jvm.hotspot.types.AddressField; |
10663 | 39 |
import sun.jvm.hotspot.types.CIntegerField; |
40 |
import sun.jvm.hotspot.types.Type; |
|
41 |
import sun.jvm.hotspot.types.TypeDataBase; |
|
42 |
||
43 |
// Mirror class for HeapRegion. Currently we don't actually include |
|
25481
1427aa24638c
8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents:
10663
diff
changeset
|
44 |
// any of its fields but only iterate over it. |
10663 | 45 |
|
25481
1427aa24638c
8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents:
10663
diff
changeset
|
46 |
public class HeapRegion extends CompactibleSpace { |
10663 | 47 |
// static int GrainBytes; |
48 |
static private CIntegerField grainBytesField; |
|
25481
1427aa24638c
8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents:
10663
diff
changeset
|
49 |
static private AddressField topField; |
47602
d4380ee1cbe9
8187403: [Unknown generation] is shown in Stack Memory on HSDB
ysuenaga
parents:
47216
diff
changeset
|
50 |
private static long typeFieldOffset; |
d4380ee1cbe9
8187403: [Unknown generation] is shown in Stack Memory on HSDB
ysuenaga
parents:
47216
diff
changeset
|
51 |
private static long pointerSize; |
d4380ee1cbe9
8187403: [Unknown generation] is shown in Stack Memory on HSDB
ysuenaga
parents:
47216
diff
changeset
|
52 |
|
d4380ee1cbe9
8187403: [Unknown generation] is shown in Stack Memory on HSDB
ysuenaga
parents:
47216
diff
changeset
|
53 |
private HeapRegionType type; |
10663 | 54 |
|
55 |
static { |
|
56 |
VM.registerVMInitializedObserver(new Observer() { |
|
57 |
public void update(Observable o, Object data) { |
|
58 |
initialize(VM.getVM().getTypeDataBase()); |
|
59 |
} |
|
60 |
}); |
|
61 |
} |
|
62 |
||
63 |
static private synchronized void initialize(TypeDataBase db) { |
|
64 |
Type type = db.lookupType("HeapRegion"); |
|
65 |
||
66 |
grainBytesField = type.getCIntegerField("GrainBytes"); |
|
25481
1427aa24638c
8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents:
10663
diff
changeset
|
67 |
topField = type.getAddressField("_top"); |
47602
d4380ee1cbe9
8187403: [Unknown generation] is shown in Stack Memory on HSDB
ysuenaga
parents:
47216
diff
changeset
|
68 |
typeFieldOffset = type.getField("_type").getOffset(); |
25481
1427aa24638c
8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents:
10663
diff
changeset
|
69 |
|
47602
d4380ee1cbe9
8187403: [Unknown generation] is shown in Stack Memory on HSDB
ysuenaga
parents:
47216
diff
changeset
|
70 |
pointerSize = db.lookupType("HeapRegion*").getSize(); |
10663 | 71 |
} |
72 |
||
73 |
static public long grainBytes() { |
|
74 |
return grainBytesField.getValue(); |
|
75 |
} |
|
76 |
||
77 |
public HeapRegion(Address addr) { |
|
78 |
super(addr); |
|
47619
74f5b6c267e3
8189069: regression after push of 8187403: "AssertionFailure: addr should be OopHandle"
ysuenaga
parents:
47602
diff
changeset
|
79 |
Address typeAddr = (addr instanceof OopHandle) ? addr.addOffsetToAsOopHandle(typeFieldOffset) |
74f5b6c267e3
8189069: regression after push of 8187403: "AssertionFailure: addr should be OopHandle"
ysuenaga
parents:
47602
diff
changeset
|
80 |
: addr.addOffsetTo(typeFieldOffset); |
47602
d4380ee1cbe9
8187403: [Unknown generation] is shown in Stack Memory on HSDB
ysuenaga
parents:
47216
diff
changeset
|
81 |
type = (HeapRegionType)VMObjectFactory.newObject(HeapRegionType.class, typeAddr); |
10663 | 82 |
} |
25481
1427aa24638c
8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents:
10663
diff
changeset
|
83 |
|
1427aa24638c
8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents:
10663
diff
changeset
|
84 |
public Address top() { |
1427aa24638c
8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents:
10663
diff
changeset
|
85 |
return topField.getValue(addr); |
1427aa24638c
8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents:
10663
diff
changeset
|
86 |
} |
1427aa24638c
8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents:
10663
diff
changeset
|
87 |
|
1427aa24638c
8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents:
10663
diff
changeset
|
88 |
@Override |
1427aa24638c
8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents:
10663
diff
changeset
|
89 |
public List getLiveRegions() { |
1427aa24638c
8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents:
10663
diff
changeset
|
90 |
List res = new ArrayList(); |
1427aa24638c
8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents:
10663
diff
changeset
|
91 |
res.add(new MemRegion(bottom(), top())); |
1427aa24638c
8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents:
10663
diff
changeset
|
92 |
return res; |
1427aa24638c
8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents:
10663
diff
changeset
|
93 |
} |
1427aa24638c
8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents:
10663
diff
changeset
|
94 |
|
1427aa24638c
8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents:
10663
diff
changeset
|
95 |
@Override |
1427aa24638c
8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents:
10663
diff
changeset
|
96 |
public long used() { |
1427aa24638c
8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents:
10663
diff
changeset
|
97 |
return top().minus(bottom()); |
1427aa24638c
8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents:
10663
diff
changeset
|
98 |
} |
1427aa24638c
8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents:
10663
diff
changeset
|
99 |
|
1427aa24638c
8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents:
10663
diff
changeset
|
100 |
@Override |
1427aa24638c
8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents:
10663
diff
changeset
|
101 |
public long free() { |
1427aa24638c
8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents:
10663
diff
changeset
|
102 |
return end().minus(top()); |
1427aa24638c
8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents:
10663
diff
changeset
|
103 |
} |
47602
d4380ee1cbe9
8187403: [Unknown generation] is shown in Stack Memory on HSDB
ysuenaga
parents:
47216
diff
changeset
|
104 |
|
d4380ee1cbe9
8187403: [Unknown generation] is shown in Stack Memory on HSDB
ysuenaga
parents:
47216
diff
changeset
|
105 |
public boolean isFree() { |
d4380ee1cbe9
8187403: [Unknown generation] is shown in Stack Memory on HSDB
ysuenaga
parents:
47216
diff
changeset
|
106 |
return type.isFree(); |
d4380ee1cbe9
8187403: [Unknown generation] is shown in Stack Memory on HSDB
ysuenaga
parents:
47216
diff
changeset
|
107 |
} |
d4380ee1cbe9
8187403: [Unknown generation] is shown in Stack Memory on HSDB
ysuenaga
parents:
47216
diff
changeset
|
108 |
|
d4380ee1cbe9
8187403: [Unknown generation] is shown in Stack Memory on HSDB
ysuenaga
parents:
47216
diff
changeset
|
109 |
public boolean isYoung() { |
d4380ee1cbe9
8187403: [Unknown generation] is shown in Stack Memory on HSDB
ysuenaga
parents:
47216
diff
changeset
|
110 |
return type.isYoung(); |
d4380ee1cbe9
8187403: [Unknown generation] is shown in Stack Memory on HSDB
ysuenaga
parents:
47216
diff
changeset
|
111 |
} |
d4380ee1cbe9
8187403: [Unknown generation] is shown in Stack Memory on HSDB
ysuenaga
parents:
47216
diff
changeset
|
112 |
|
d4380ee1cbe9
8187403: [Unknown generation] is shown in Stack Memory on HSDB
ysuenaga
parents:
47216
diff
changeset
|
113 |
public boolean isHumongous() { |
d4380ee1cbe9
8187403: [Unknown generation] is shown in Stack Memory on HSDB
ysuenaga
parents:
47216
diff
changeset
|
114 |
return type.isHumongous(); |
d4380ee1cbe9
8187403: [Unknown generation] is shown in Stack Memory on HSDB
ysuenaga
parents:
47216
diff
changeset
|
115 |
} |
d4380ee1cbe9
8187403: [Unknown generation] is shown in Stack Memory on HSDB
ysuenaga
parents:
47216
diff
changeset
|
116 |
|
d4380ee1cbe9
8187403: [Unknown generation] is shown in Stack Memory on HSDB
ysuenaga
parents:
47216
diff
changeset
|
117 |
public boolean isPinned() { |
d4380ee1cbe9
8187403: [Unknown generation] is shown in Stack Memory on HSDB
ysuenaga
parents:
47216
diff
changeset
|
118 |
return type.isPinned(); |
d4380ee1cbe9
8187403: [Unknown generation] is shown in Stack Memory on HSDB
ysuenaga
parents:
47216
diff
changeset
|
119 |
} |
d4380ee1cbe9
8187403: [Unknown generation] is shown in Stack Memory on HSDB
ysuenaga
parents:
47216
diff
changeset
|
120 |
|
d4380ee1cbe9
8187403: [Unknown generation] is shown in Stack Memory on HSDB
ysuenaga
parents:
47216
diff
changeset
|
121 |
public boolean isOld() { |
d4380ee1cbe9
8187403: [Unknown generation] is shown in Stack Memory on HSDB
ysuenaga
parents:
47216
diff
changeset
|
122 |
return type.isOld(); |
d4380ee1cbe9
8187403: [Unknown generation] is shown in Stack Memory on HSDB
ysuenaga
parents:
47216
diff
changeset
|
123 |
} |
d4380ee1cbe9
8187403: [Unknown generation] is shown in Stack Memory on HSDB
ysuenaga
parents:
47216
diff
changeset
|
124 |
|
d4380ee1cbe9
8187403: [Unknown generation] is shown in Stack Memory on HSDB
ysuenaga
parents:
47216
diff
changeset
|
125 |
public static long getPointerSize() { |
d4380ee1cbe9
8187403: [Unknown generation] is shown in Stack Memory on HSDB
ysuenaga
parents:
47216
diff
changeset
|
126 |
return pointerSize; |
d4380ee1cbe9
8187403: [Unknown generation] is shown in Stack Memory on HSDB
ysuenaga
parents:
47216
diff
changeset
|
127 |
} |
49463
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
47619
diff
changeset
|
128 |
|
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
47619
diff
changeset
|
129 |
public void printOn(PrintStream tty) { |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
47619
diff
changeset
|
130 |
tty.print("Region: " + bottom() + "," + top() + "," + end()); |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
47619
diff
changeset
|
131 |
tty.println(":" + type.typeAnnotation()); |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
47619
diff
changeset
|
132 |
} |
10663 | 133 |
} |