Mercurial > hg > truffle
annotate agent/src/share/classes/sun/jvm/hotspot/code/ScopeDesc.java @ 900:9987d9d5eb0e
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
Summary: developed a reexecute logic for the interpreter to reexecute the bytecode when deopt happens
Reviewed-by: kvn, never, jrose, twisti
author | cfang |
---|---|
date | Fri, 31 Jul 2009 17:12:33 -0700 |
parents | b109e761e927 |
children | 15bbd3f505c0 |
rev | line source |
---|---|
0 | 1 /* |
2 * Copyright 2000-2005 Sun Microsystems, Inc. All Rights Reserved. | |
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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | |
20 * CA 95054 USA or visit www.sun.com if you need additional information or | |
21 * have any questions. | |
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 |
0 | 54 |
55 public ScopeDesc(NMethod code, int decodeOffset) { | |
56 this.code = code; | |
57 this.decodeOffset = decodeOffset; | |
818
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
58 this.objects = decodeObjectValues(DebugInformationRecorder.SERIALIZED_NULL); |
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(); |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
64 method = (Method) VM.getVM().getObjectHeap().newOop(stream.readOopHandle()); |
900
9987d9d5eb0e
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
818
diff
changeset
|
65 setBCIAndReexecute(stream.readInt()); |
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 |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
72 public ScopeDesc(NMethod code, int decodeOffset, int objectDecodeOffset) { |
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); |
0 | 76 |
77 // Decode header | |
78 DebugInfoReadStream stream = streamAt(decodeOffset); | |
79 | |
80 senderDecodeOffset = stream.readInt(); | |
81 method = (Method) VM.getVM().getObjectHeap().newOop(stream.readOopHandle()); | |
900
9987d9d5eb0e
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
818
diff
changeset
|
82 setBCIAndReexecute(stream.readInt()); |
0 | 83 // Decode offsets for body and sender |
84 localsDecodeOffset = stream.readInt(); | |
85 expressionsDecodeOffset = stream.readInt(); | |
86 monitorsDecodeOffset = stream.readInt(); | |
87 } | |
88 | |
89 public NMethod getNMethod() { return code; } | |
90 public Method getMethod() { return method; } | |
91 public int getBCI() { return bci; } | |
900
9987d9d5eb0e
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
818
diff
changeset
|
92 public boolean getReexecute() {return reexecute;} |
0 | 93 |
94 /** Returns a List<ScopeValue> */ | |
95 public List getLocals() { | |
96 return decodeScopeValues(localsDecodeOffset); | |
97 } | |
98 | |
99 /** Returns a List<ScopeValue> */ | |
100 public List getExpressions() { | |
101 return decodeScopeValues(expressionsDecodeOffset); | |
102 } | |
103 | |
104 /** Returns a List<MonitorValue> */ | |
105 public List getMonitors() { | |
106 return decodeMonitorValues(monitorsDecodeOffset); | |
107 } | |
108 | |
818
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
109 /** Returns a List<MonitorValue> */ |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
110 public List getObjects() { |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
111 return objects; |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
112 } |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
113 |
0 | 114 /** Stack walking. Returns null if this is the outermost scope. */ |
115 public ScopeDesc sender() { | |
116 if (isTop()) { | |
117 return null; | |
118 } | |
119 | |
120 return new ScopeDesc(code, senderDecodeOffset); | |
121 } | |
122 | |
123 /** Returns where the scope was decoded */ | |
124 public int getDecodeOffset() { | |
125 return decodeOffset; | |
126 } | |
127 | |
128 /** Tells whether sender() returns null */ | |
129 public boolean isTop() { | |
130 return (senderDecodeOffset == DebugInformationRecorder.SERIALIZED_NULL); | |
131 } | |
132 | |
133 public boolean equals(Object arg) { | |
134 if (arg == null) { | |
135 return false; | |
136 } | |
137 | |
138 if (!(arg instanceof ScopeDesc)) { | |
139 return false; | |
140 } | |
141 | |
142 ScopeDesc sd = (ScopeDesc) arg; | |
143 | |
144 return (sd.method.equals(method) && (sd.bci == bci)); | |
145 } | |
146 | |
147 public void printValue() { | |
148 printValueOn(System.out); | |
149 } | |
150 | |
151 public void printValueOn(PrintStream tty) { | |
152 tty.print("ScopeDesc for "); | |
153 method.printValueOn(tty); | |
154 tty.println(" @bci " + bci); | |
900
9987d9d5eb0e
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
818
diff
changeset
|
155 tty.println(" reexecute: " + reexecute); |
0 | 156 } |
157 | |
158 // FIXME: add more accessors | |
159 | |
160 //-------------------------------------------------------------------------------- | |
161 // Internals only below this point | |
162 // | |
900
9987d9d5eb0e
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
818
diff
changeset
|
163 private void setBCIAndReexecute(int combination) { |
9987d9d5eb0e
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
818
diff
changeset
|
164 int InvocationEntryBci = VM.getVM().getInvocationEntryBCI(); |
9987d9d5eb0e
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
818
diff
changeset
|
165 bci = (combination >> 1) + InvocationEntryBci; |
9987d9d5eb0e
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
818
diff
changeset
|
166 reexecute = (combination & 1)==1 ? true : false; |
9987d9d5eb0e
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
818
diff
changeset
|
167 } |
0 | 168 |
169 private DebugInfoReadStream streamAt(int decodeOffset) { | |
818
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
170 return new DebugInfoReadStream(code, decodeOffset, objects); |
0 | 171 } |
172 | |
173 /** Returns a List<ScopeValue> or null if no values were present */ | |
174 private List decodeScopeValues(int decodeOffset) { | |
175 if (decodeOffset == DebugInformationRecorder.SERIALIZED_NULL) { | |
176 return null; | |
177 } | |
178 DebugInfoReadStream stream = streamAt(decodeOffset); | |
179 int length = stream.readInt(); | |
180 List res = new ArrayList(length); | |
181 for (int i = 0; i < length; i++) { | |
182 res.add(ScopeValue.readFrom(stream)); | |
183 } | |
184 return res; | |
185 } | |
186 | |
187 /** Returns a List<MonitorValue> or null if no values were present */ | |
188 private List decodeMonitorValues(int decodeOffset) { | |
189 if (decodeOffset == DebugInformationRecorder.SERIALIZED_NULL) { | |
190 return null; | |
191 } | |
192 DebugInfoReadStream stream = streamAt(decodeOffset); | |
193 int length = stream.readInt(); | |
194 List res = new ArrayList(length); | |
195 for (int i = 0; i < length; i++) { | |
196 res.add(new MonitorValue(stream)); | |
197 } | |
198 return res; | |
199 } | |
818
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 /** 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
|
202 private List decodeObjectValues(int decodeOffset) { |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
203 if (decodeOffset == DebugInformationRecorder.SERIALIZED_NULL) { |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
204 return null; |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
205 } |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
206 List res = new ArrayList(); |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
207 DebugInfoReadStream stream = new DebugInfoReadStream(code, decodeOffset, res); |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
208 int length = stream.readInt(); |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
209 for (int i = 0; i < length; i++) { |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
210 // 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
|
211 // 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
|
212 ScopeValue.readFrom(stream); |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
213 // res.add(ScopeValue.readFrom(stream)); |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
214 } |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
215 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
|
216 return res; |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
217 } |
0 | 218 } |