Mercurial > hg > truffle
annotate agent/src/share/classes/sun/jvm/hotspot/ci/ciMethodData.java @ 11997:cd25d3be91c5
8012144: multiple SIGSEGVs fails on staxf
Summary: Forward port of 7u change to add additional fence() on RMO platforms, with a load_acquire on all platforms
Reviewed-by: dholmes, kvn
author | vladidan |
---|---|
date | Tue, 06 Aug 2013 20:01:40 -0400 |
parents | bd7a7ce2e264 |
children |
rev | line source |
---|---|
3939 | 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 | 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 * | |
6972
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
21 * questions. |
3939 | 22 * |
23 */ | |
24 | |
25 package sun.jvm.hotspot.ci; | |
26 | |
27 import java.io.*; | |
28 import java.util.*; | |
29 import sun.jvm.hotspot.debugger.*; | |
30 import sun.jvm.hotspot.runtime.*; | |
31 import sun.jvm.hotspot.oops.*; | |
32 import sun.jvm.hotspot.types.*; | |
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 | 35 static { |
36 VM.registerVMInitializedObserver(new Observer() { | |
37 public void update(Observable o, Object data) { | |
38 initialize(VM.getVM().getTypeDataBase()); | |
39 } | |
40 }); | |
41 } | |
42 | |
43 private static synchronized void initialize(TypeDataBase db) throws WrongTypeException { | |
44 Type type = db.lookupType("ciMethodData"); | |
45 origField = type.getAddressField("_orig"); | |
46 currentMileageField = new CIntField(type.getCIntegerField("_current_mileage"), 0); | |
47 argReturnedField = new CIntField(type.getCIntegerField("_arg_returned"), 0); | |
48 argStackField = new CIntField(type.getCIntegerField("_arg_stack"), 0); | |
49 argLocalField = new CIntField(type.getCIntegerField("_arg_local"), 0); | |
50 eflagsField = new CIntField(type.getCIntegerField("_eflags"), 0); | |
51 hintDiField = new CIntField(type.getCIntegerField("_hint_di"), 0); | |
52 currentMileageField = new CIntField(type.getCIntegerField("_current_mileage"), 0); | |
53 dataField = type.getAddressField("_data"); | |
54 extraDataSizeField = new CIntField(type.getCIntegerField("_extra_data_size"), 0); | |
55 dataSizeField = new CIntField(type.getCIntegerField("_data_size"), 0); | |
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 | 58 } |
59 | |
60 private static AddressField origField; | |
61 private static CIntField currentMileageField; | |
62 private static CIntField argReturnedField; | |
63 private static CIntField argStackField; | |
64 private static CIntField argLocalField; | |
65 private static CIntField eflagsField; | |
66 private static CIntField hintDiField; | |
67 private static AddressField dataField; | |
68 private static CIntField extraDataSizeField; | |
69 private static CIntField dataSizeField; | |
70 private static CIntField stateField; | |
71 private static int sizeofMethodDataOopDesc; | |
72 | |
73 public ciMethodData(Address addr) { | |
74 super(addr); | |
75 } | |
76 | |
77 private byte[] fetchDataAt(Address base, long size) { | |
78 byte[] result = new byte[(int)size]; | |
79 for (int i = 0; i < size; i++) { | |
80 result[i] = base.getJByteAt(i); | |
81 } | |
82 return result; | |
83 } | |
84 | |
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 | 87 Address base = getAddress().addOffsetTo(origField.getOffset()); |
88 byte[] result = new byte[MethodData.sizeofMethodDataOopDesc]; | |
89 for (int i = 0; i < MethodData.sizeofMethodDataOopDesc; i++) { | |
90 result[i] = base.getJByteAt(i); | |
91 } | |
92 return result; | |
93 } | |
94 | |
95 public long[] data() { | |
96 // Read the data as an array of intptr_t elements | |
97 Address base = dataField.getValue(getAddress()); | |
98 int elements = dataSize() / MethodData.cellSize; | |
99 long[] result = new long[elements]; | |
100 for (int i = 0; i < elements; i++) { | |
101 Address value = base.getAddressAt(i * MethodData.cellSize); | |
102 if (value != null) { | |
103 result[i] = value.minus(null); | |
104 } | |
105 } | |
106 return result; | |
107 } | |
108 | |
109 int dataSize() { | |
110 return (int)dataSizeField.getValue(getAddress()); | |
111 } | |
112 | |
113 int state() { | |
114 return (int)stateField.getValue(getAddress()); | |
115 } | |
116 | |
117 int currentMileage() { | |
118 return (int)currentMileageField.getValue(getAddress()); | |
119 } | |
120 | |
121 boolean outOfBounds(int dataIndex) { | |
122 return dataIndex >= dataSize(); | |
123 } | |
124 | |
125 ProfileData dataAt(int dataIndex) { | |
126 if (outOfBounds(dataIndex)) { | |
127 return null; | |
128 } | |
129 DataLayout dataLayout = new DataLayout(dataField.getValue(getAddress()), dataIndex); | |
130 | |
131 switch (dataLayout.tag()) { | |
132 case DataLayout.noTag: | |
133 default: | |
134 throw new InternalError(); | |
135 case DataLayout.bitDataTag: | |
136 return new BitData(dataLayout); | |
137 case DataLayout.counterDataTag: | |
138 return new CounterData(dataLayout); | |
139 case DataLayout.jumpDataTag: | |
140 return new JumpData(dataLayout); | |
141 case DataLayout.receiverTypeDataTag: | |
142 return new ciReceiverTypeData(dataLayout); | |
143 case DataLayout.virtualCallDataTag: | |
144 return new ciVirtualCallData(dataLayout); | |
145 case DataLayout.retDataTag: | |
146 return new RetData(dataLayout); | |
147 case DataLayout.branchDataTag: | |
148 return new BranchData(dataLayout); | |
149 case DataLayout.multiBranchDataTag: | |
150 return new MultiBranchData(dataLayout); | |
151 } | |
152 } | |
153 | |
154 int dpToDi(int dp) { | |
155 return dp; | |
156 } | |
157 | |
158 int firstDi() { return 0; } | |
159 ProfileData firstData() { return dataAt(firstDi()); } | |
160 ProfileData nextData(ProfileData current) { | |
161 int currentIndex = dpToDi(current.dp()); | |
162 int nextIndex = currentIndex + current.sizeInBytes(); | |
163 return dataAt(nextIndex); | |
164 } | |
165 boolean isValid(ProfileData current) { return current != null; } | |
166 | |
167 public void printDataOn(PrintStream st) { | |
168 ProfileData data = firstData(); | |
169 for ( ; isValid(data); data = nextData(data)) { | |
170 st.print(dpToDi(data.dp())); | |
171 st.print(" "); | |
172 // st->fillTo(6); | |
173 data.printDataOn(st); | |
174 } | |
175 } | |
176 | |
6972
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
177 public void dumpReplayData(PrintStream out) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
178 MethodData mdo = (MethodData)getMetadata(); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
179 Method method = mdo.getMethod(); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
180 Klass holder = method.getMethodHolder(); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
181 out.print("ciMethodData " + |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
182 holder.getName().asString() + " " + |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
183 OopUtilities.escapeString(method.getName().asString()) + " " + |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
184 method.getSignature().asString() + " " + |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
185 state() + " " + currentMileage()); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
186 byte[] orig = orig(); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
187 out.print(" orig " + orig.length); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
188 for (int i = 0; i < orig.length; i++) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
189 out.print(" " + (orig[i] & 0xff)); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
190 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
191 |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
192 long[] data = data(); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
193 out.print(" data " + data.length); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
194 for (int i = 0; i < data.length; i++) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
195 out.print(" 0x" + Long.toHexString(data[i])); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
196 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
197 int count = 0; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
198 for (int round = 0; round < 2; round++) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
199 if (round == 1) out.print(" oops " + count); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
200 ProfileData pdata = firstData(); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
201 for ( ; isValid(pdata); pdata = nextData(pdata)) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
202 if (pdata instanceof ciReceiverTypeData) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
203 ciReceiverTypeData vdata = (ciReceiverTypeData)pdata; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
204 for (int i = 0; i < vdata.rowLimit(); i++) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
205 ciKlass k = vdata.receiverAt(i); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
206 if (k != null) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
207 if (round == 0) count++; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
208 else out.print(" " + ((vdata.dp() + vdata.cellOffset(vdata.receiverCellIndex(i))) / MethodData.cellSize) + " " + k.name()); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
209 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
210 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
211 } else if (pdata instanceof ciVirtualCallData) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
212 ciVirtualCallData vdata = (ciVirtualCallData)pdata; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
213 for (int i = 0; i < vdata.rowLimit(); i++) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
214 ciKlass k = vdata.receiverAt(i); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
215 if (k != null) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
216 if (round == 0) count++; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
217 else out.print(" " + ((vdata.dp() + vdata.cellOffset(vdata.receiverCellIndex(i))) / MethodData.cellSize + " " + k.name())); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
218 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
219 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
220 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
221 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
222 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
223 out.println(); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
224 } |
3939 | 225 } |