annotate agent/src/share/classes/sun/jvm/hotspot/ci/ciMethodData.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 f6f3bb0ee072
children bd7a7ce2e264
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
1 /*
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
2 * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
4 *
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
7 * published by the Free Software Foundation.
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
8 *
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
13 * accompanied this code).
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
14 *
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
18 *
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
21 * have any questions.
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
22 *
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
23 */
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
24
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
25 package sun.jvm.hotspot.ci;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
26
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
27 import java.io.*;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
28 import java.util.*;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
29 import sun.jvm.hotspot.debugger.*;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
30 import sun.jvm.hotspot.runtime.*;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
31 import sun.jvm.hotspot.oops.*;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
32 import sun.jvm.hotspot.types.*;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
33
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
34 public class ciMethodData extends ciMetadata {
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
35 static {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
36 VM.registerVMInitializedObserver(new Observer() {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
37 public void update(Observable o, Object data) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
38 initialize(VM.getVM().getTypeDataBase());
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
39 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
40 });
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
41 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
42
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
43 private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
44 Type type = db.lookupType("ciMethodData");
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
45 origField = type.getAddressField("_orig");
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
46 currentMileageField = new CIntField(type.getCIntegerField("_current_mileage"), 0);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
47 argReturnedField = new CIntField(type.getCIntegerField("_arg_returned"), 0);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
48 argStackField = new CIntField(type.getCIntegerField("_arg_stack"), 0);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
49 argLocalField = new CIntField(type.getCIntegerField("_arg_local"), 0);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
50 eflagsField = new CIntField(type.getCIntegerField("_eflags"), 0);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
51 hintDiField = new CIntField(type.getCIntegerField("_hint_di"), 0);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
52 currentMileageField = new CIntField(type.getCIntegerField("_current_mileage"), 0);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
53 dataField = type.getAddressField("_data");
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
54 extraDataSizeField = new CIntField(type.getCIntegerField("_extra_data_size"), 0);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
55 dataSizeField = new CIntField(type.getCIntegerField("_data_size"), 0);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
56 stateField = new CIntField(type.getCIntegerField("_state"), 0);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
57 sizeofMethodDataOopDesc = (int)db.lookupType("MethodData").getSize();;
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
58 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
59
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
60 private static AddressField origField;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
61 private static CIntField currentMileageField;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
62 private static CIntField argReturnedField;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
63 private static CIntField argStackField;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
64 private static CIntField argLocalField;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
65 private static CIntField eflagsField;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
66 private static CIntField hintDiField;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
67 private static AddressField dataField;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
68 private static CIntField extraDataSizeField;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
69 private static CIntField dataSizeField;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
70 private static CIntField stateField;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
71 private static int sizeofMethodDataOopDesc;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
72
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
73 public ciMethodData(Address addr) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
74 super(addr);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
75 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
76
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
77 private byte[] fetchDataAt(Address base, long size) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
78 byte[] result = new byte[(int)size];
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
79 for (int i = 0; i < size; i++) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
80 result[i] = base.getJByteAt(i);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
81 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
82 return result;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
83 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
84
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
85 public byte[] orig() {
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
86 // fetch the orig MethodData data between header and dataSize
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
87 Address base = getAddress().addOffsetTo(origField.getOffset());
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
88 byte[] result = new byte[MethodData.sizeofMethodDataOopDesc];
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
89 for (int i = 0; i < MethodData.sizeofMethodDataOopDesc; i++) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
90 result[i] = base.getJByteAt(i);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
91 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
92 return result;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
93 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
94
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
95 public long[] data() {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
96 // Read the data as an array of intptr_t elements
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
97 Address base = dataField.getValue(getAddress());
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
98 int elements = dataSize() / MethodData.cellSize;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
99 long[] result = new long[elements];
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
100 for (int i = 0; i < elements; i++) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
101 Address value = base.getAddressAt(i * MethodData.cellSize);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
102 if (value != null) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
103 result[i] = value.minus(null);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
104 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
105 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
106 return result;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
107 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
108
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
109 int dataSize() {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
110 return (int)dataSizeField.getValue(getAddress());
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
111 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
112
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
113 int state() {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
114 return (int)stateField.getValue(getAddress());
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
115 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
116
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
117 int currentMileage() {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
118 return (int)currentMileageField.getValue(getAddress());
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
119 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
120
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
121 boolean outOfBounds(int dataIndex) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
122 return dataIndex >= dataSize();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
123 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
124
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
125 ProfileData dataAt(int dataIndex) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
126 if (outOfBounds(dataIndex)) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
127 return null;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
128 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
129 DataLayout dataLayout = new DataLayout(dataField.getValue(getAddress()), dataIndex);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
130
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
131 switch (dataLayout.tag()) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
132 case DataLayout.noTag:
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
133 default:
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
134 throw new InternalError();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
135 case DataLayout.bitDataTag:
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
136 return new BitData(dataLayout);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
137 case DataLayout.counterDataTag:
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
138 return new CounterData(dataLayout);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
139 case DataLayout.jumpDataTag:
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
140 return new JumpData(dataLayout);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
141 case DataLayout.receiverTypeDataTag:
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
142 return new ciReceiverTypeData(dataLayout);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
143 case DataLayout.virtualCallDataTag:
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
144 return new ciVirtualCallData(dataLayout);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
145 case DataLayout.retDataTag:
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
146 return new RetData(dataLayout);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
147 case DataLayout.branchDataTag:
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
148 return new BranchData(dataLayout);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
149 case DataLayout.multiBranchDataTag:
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
150 return new MultiBranchData(dataLayout);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
151 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
152 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
153
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
154 int dpToDi(int dp) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
155 return dp;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
156 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
157
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
158 int firstDi() { return 0; }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
159 ProfileData firstData() { return dataAt(firstDi()); }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
160 ProfileData nextData(ProfileData current) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
161 int currentIndex = dpToDi(current.dp());
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
162 int nextIndex = currentIndex + current.sizeInBytes();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
163 return dataAt(nextIndex);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
164 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
165 boolean isValid(ProfileData current) { return current != null; }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
166
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
167 public void printDataOn(PrintStream st) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
168 ProfileData data = firstData();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
169 for ( ; isValid(data); data = nextData(data)) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
170 st.print(dpToDi(data.dp()));
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
171 st.print(" ");
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
172 // st->fillTo(6);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
173 data.printDataOn(st);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
174 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
175 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
176
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
177 }