author | erikj |
Tue, 12 Sep 2017 19:03:39 +0200 | |
changeset 47216 | 71c04702a3d5 |
parent 35217 | hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/PerfMemory.java@ce4b5303a813 |
child 47775 | ab33aa41d7a4 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
2 |
* Copyright (c) 2004, 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:
1
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
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:
1
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
25 |
package sun.jvm.hotspot.runtime; |
|
26 |
||
27 |
import java.util.*; |
|
28 |
import sun.jvm.hotspot.debugger.*; |
|
29 |
import sun.jvm.hotspot.oops.*; |
|
30 |
import sun.jvm.hotspot.types.*; |
|
31 |
||
32 |
public class PerfMemory { |
|
33 |
private static AddressField startField; |
|
34 |
private static AddressField endField; |
|
35 |
private static AddressField topField; |
|
36 |
private static CIntegerField capacityField; |
|
37 |
private static AddressField prologueField; |
|
38 |
private static JIntField initializedField; |
|
39 |
||
40 |
static { |
|
41 |
VM.registerVMInitializedObserver(new Observer() { |
|
42 |
public void update(Observable o, Object data) { |
|
43 |
initialize(VM.getVM().getTypeDataBase()); |
|
44 |
} |
|
45 |
}); |
|
46 |
} |
|
47 |
||
48 |
private static synchronized void initialize(TypeDataBase db) { |
|
49 |
Type type = db.lookupType("PerfMemory"); |
|
50 |
startField = type.getAddressField("_start"); |
|
51 |
endField = type.getAddressField("_end"); |
|
52 |
topField = type.getAddressField("_top"); |
|
53 |
capacityField = type.getCIntegerField("_capacity"); |
|
54 |
prologueField = type.getAddressField("_prologue"); |
|
55 |
initializedField = type.getJIntField("_initialized"); |
|
56 |
} |
|
57 |
||
58 |
// Accessors |
|
59 |
public static Address start() { |
|
60 |
return startField.getValue(); |
|
61 |
} |
|
62 |
||
63 |
public static Address end() { |
|
64 |
return endField.getValue(); |
|
65 |
} |
|
66 |
||
67 |
public static Address top() { |
|
68 |
return topField.getValue(); |
|
69 |
} |
|
70 |
||
71 |
public static long capacity() { |
|
72 |
return capacityField.getValue(); |
|
73 |
} |
|
74 |
||
75 |
public static boolean initialized() { |
|
76 |
return ((int) initializedField.getValue()) != 0; |
|
77 |
} |
|
78 |
||
79 |
public static PerfDataPrologue prologue() { |
|
80 |
return (PerfDataPrologue) VMObjectFactory.newObject( |
|
81 |
PerfDataPrologue.class, prologueField.getValue()); |
|
82 |
} |
|
83 |
||
84 |
public static boolean contains(Address addr) { |
|
85 |
return start() != null && |
|
86 |
addr.minus(start()) >= 0 && |
|
87 |
end().minus(addr) > 0; |
|
88 |
} |
|
89 |
||
90 |
// an interface supplied to iterate PerfDataEntries |
|
91 |
public static interface PerfDataEntryVisitor { |
|
92 |
// returns false to stop the iteration |
|
93 |
public boolean visit(PerfDataEntry pde); |
|
94 |
} |
|
95 |
||
96 |
public static void iterate(PerfDataEntryVisitor visitor) { |
|
97 |
PerfDataPrologue header = prologue(); |
|
98 |
int off = header.entryOffset(); |
|
99 |
int num = header.numEntries(); |
|
100 |
Address addr = header.getAddress(); |
|
101 |
||
102 |
for (int i = 0; i < num; i++) { |
|
103 |
PerfDataEntry pde = (PerfDataEntry) VMObjectFactory.newObject( |
|
104 |
PerfDataEntry.class, addr.addOffsetTo(off)); |
|
105 |
off += pde.entryLength(); |
|
106 |
if (visitor.visit(pde) == false) return; |
|
107 |
} |
|
108 |
} |
|
109 |
} |