Mercurial > hg > graal-jvmci-8
annotate agent/src/share/classes/sun/jvm/hotspot/code/ScopeDesc.java @ 6782:5a98bf7d847b
6879063: SA should use hsdis for disassembly
Summary: We should in SA to use hsdis for it like the JVM does to replace the current java based disassembler.
Reviewed-by: twisti, jrose, sla
Contributed-by: yumin.qi@oracle.com
author | minqi |
---|---|
date | Mon, 24 Sep 2012 12:44:00 -0700 |
parents | da91efe96a93 |
children |
rev | line source |
---|---|
0 | 1 /* |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
2 * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. |
0 | 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1040
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1040
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1040
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
25 package sun.jvm.hotspot.code; | |
26 | |
27 import java.io.*; | |
28 import java.util.*; | |
29 | |
818
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
30 import sun.jvm.hotspot.debugger.*; |
0 | 31 import sun.jvm.hotspot.oops.*; |
32 import sun.jvm.hotspot.runtime.*; | |
818
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
33 import sun.jvm.hotspot.utilities.*; |
0 | 34 |
35 /** ScopeDescs contain the information that makes source-level | |
36 debugging of nmethods possible; each scopeDesc describes a method | |
37 activation */ | |
38 | |
39 public class ScopeDesc { | |
40 /** NMethod information */ | |
41 private NMethod code; | |
42 private Method method; | |
43 private int bci; | |
900
9987d9d5eb0e
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
818
diff
changeset
|
44 private boolean reexecute; |
0 | 45 /** Decoding offsets */ |
46 private int decodeOffset; | |
47 private int senderDecodeOffset; | |
48 private int localsDecodeOffset; | |
49 private int expressionsDecodeOffset; | |
50 private int monitorsDecodeOffset; | |
818
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
51 /** Scalar replaced bjects pool */ |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
52 private List objects; // ArrayList<ScopeValue> |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
53 |
1040
873ec3787992
6892186: SA does not dump debug info for scalar replaced objects
kvn
parents:
931
diff
changeset
|
54 private ScopeDesc(NMethod code, int decodeOffset, List objects, boolean reexecute) { |
0 | 55 this.code = code; |
56 this.decodeOffset = decodeOffset; | |
1040
873ec3787992
6892186: SA does not dump debug info for scalar replaced objects
kvn
parents:
931
diff
changeset
|
57 this.objects = objects; |
931
72088be4b386
6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit
cfang
parents:
903
diff
changeset
|
58 this.reexecute = reexecute; |
818
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
59 |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
60 // Decode header |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
61 DebugInfoReadStream stream = streamAt(decodeOffset); |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
62 |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
63 senderDecodeOffset = stream.readInt(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
64 method = stream.readMethod(); |
931
72088be4b386
6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit
cfang
parents:
903
diff
changeset
|
65 bci = stream.readBCI(); |
818
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
66 // Decode offsets for body and sender |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
67 localsDecodeOffset = stream.readInt(); |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
68 expressionsDecodeOffset = stream.readInt(); |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
69 monitorsDecodeOffset = stream.readInt(); |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
70 } |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
71 |
931
72088be4b386
6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit
cfang
parents:
903
diff
changeset
|
72 public ScopeDesc(NMethod code, int decodeOffset, int objectDecodeOffset, boolean reexecute) { |
818
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
73 this.code = code; |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
74 this.decodeOffset = decodeOffset; |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
75 this.objects = decodeObjectValues(objectDecodeOffset); |
931
72088be4b386
6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit
cfang
parents:
903
diff
changeset
|
76 this.reexecute = reexecute; |
0 | 77 |
78 // Decode header | |
79 DebugInfoReadStream stream = streamAt(decodeOffset); | |
80 | |
81 senderDecodeOffset = stream.readInt(); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
82 method = stream.readMethod(); |
931
72088be4b386
6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit
cfang
parents:
903
diff
changeset
|
83 bci = stream.readBCI(); |
0 | 84 // Decode offsets for body and sender |
85 localsDecodeOffset = stream.readInt(); | |
86 expressionsDecodeOffset = stream.readInt(); | |
87 monitorsDecodeOffset = stream.readInt(); | |
88 } | |
89 | |
931
72088be4b386
6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit
cfang
parents:
903
diff
changeset
|
90 public NMethod getNMethod() { return code; } |
72088be4b386
6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit
cfang
parents:
903
diff
changeset
|
91 public Method getMethod() { return method; } |
72088be4b386
6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit
cfang
parents:
903
diff
changeset
|
92 public int getBCI() { return bci; } |
72088be4b386
6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit
cfang
parents:
903
diff
changeset
|
93 public boolean getReexecute() { return reexecute;} |
0 | 94 |
95 /** Returns a List<ScopeValue> */ | |
96 public List getLocals() { | |
97 return decodeScopeValues(localsDecodeOffset); | |
98 } | |
99 | |
100 /** Returns a List<ScopeValue> */ | |
101 public List getExpressions() { | |
102 return decodeScopeValues(expressionsDecodeOffset); | |
103 } | |
104 | |
105 /** Returns a List<MonitorValue> */ | |
106 public List getMonitors() { | |
107 return decodeMonitorValues(monitorsDecodeOffset); | |
108 } | |
109 | |
1040
873ec3787992
6892186: SA does not dump debug info for scalar replaced objects
kvn
parents:
931
diff
changeset
|
110 /** Returns a List<ObjectValue> */ |
818
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
111 public List getObjects() { |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
112 return objects; |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
113 } |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
114 |
0 | 115 /** Stack walking. Returns null if this is the outermost scope. */ |
116 public ScopeDesc sender() { | |
117 if (isTop()) { | |
118 return null; | |
119 } | |
120 | |
1040
873ec3787992
6892186: SA does not dump debug info for scalar replaced objects
kvn
parents:
931
diff
changeset
|
121 return new ScopeDesc(code, senderDecodeOffset, objects, false); |
0 | 122 } |
123 | |
124 /** Returns where the scope was decoded */ | |
125 public int getDecodeOffset() { | |
126 return decodeOffset; | |
127 } | |
128 | |
129 /** Tells whether sender() returns null */ | |
130 public boolean isTop() { | |
131 return (senderDecodeOffset == DebugInformationRecorder.SERIALIZED_NULL); | |
132 } | |
133 | |
134 public boolean equals(Object arg) { | |
135 if (arg == null) { | |
136 return false; | |
137 } | |
138 | |
139 if (!(arg instanceof ScopeDesc)) { | |
140 return false; | |
141 } | |
142 | |
143 ScopeDesc sd = (ScopeDesc) arg; | |
144 | |
145 return (sd.method.equals(method) && (sd.bci == bci)); | |
146 } | |
147 | |
148 public void printValue() { | |
149 printValueOn(System.out); | |
150 } | |
151 | |
152 public void printValueOn(PrintStream tty) { | |
153 tty.print("ScopeDesc for "); | |
154 method.printValueOn(tty); | |
931
72088be4b386
6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit
cfang
parents:
903
diff
changeset
|
155 tty.print(" @bci " + bci); |
72088be4b386
6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit
cfang
parents:
903
diff
changeset
|
156 tty.println(" reexecute=" + reexecute); |
0 | 157 } |
158 | |
159 // FIXME: add more accessors | |
160 | |
161 //-------------------------------------------------------------------------------- | |
162 // Internals only below this point | |
163 // | |
164 private DebugInfoReadStream streamAt(int decodeOffset) { | |
818
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
165 return new DebugInfoReadStream(code, decodeOffset, objects); |
0 | 166 } |
167 | |
168 /** Returns a List<ScopeValue> or null if no values were present */ | |
169 private List decodeScopeValues(int decodeOffset) { | |
170 if (decodeOffset == DebugInformationRecorder.SERIALIZED_NULL) { | |
171 return null; | |
172 } | |
173 DebugInfoReadStream stream = streamAt(decodeOffset); | |
174 int length = stream.readInt(); | |
175 List res = new ArrayList(length); | |
176 for (int i = 0; i < length; i++) { | |
177 res.add(ScopeValue.readFrom(stream)); | |
178 } | |
179 return res; | |
180 } | |
181 | |
182 /** Returns a List<MonitorValue> or null if no values were present */ | |
183 private List decodeMonitorValues(int decodeOffset) { | |
184 if (decodeOffset == DebugInformationRecorder.SERIALIZED_NULL) { | |
185 return null; | |
186 } | |
187 DebugInfoReadStream stream = streamAt(decodeOffset); | |
188 int length = stream.readInt(); | |
189 List res = new ArrayList(length); | |
190 for (int i = 0; i < length; i++) { | |
191 res.add(new MonitorValue(stream)); | |
192 } | |
193 return res; | |
194 } | |
818
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
195 |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
196 /** Returns a List<ObjectValue> or null if no values were present */ |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
197 private List decodeObjectValues(int decodeOffset) { |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
198 if (decodeOffset == DebugInformationRecorder.SERIALIZED_NULL) { |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
199 return null; |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
200 } |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
201 List res = new ArrayList(); |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
202 DebugInfoReadStream stream = new DebugInfoReadStream(code, decodeOffset, res); |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
203 int length = stream.readInt(); |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
204 for (int i = 0; i < length; i++) { |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
205 // Objects values are pushed to 'res' array during read so that |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
206 // object's fields could reference it (OBJECT_ID_CODE). |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
207 ScopeValue.readFrom(stream); |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
208 // res.add(ScopeValue.readFrom(stream)); |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
209 } |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
210 Assert.that(res.size() == length, "inconsistent debug information"); |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
211 return res; |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
212 } |
0 | 213 } |