Mercurial > hg > graal-compiler
annotate agent/src/share/classes/sun/jvm/hotspot/code/ScopeDesc.java @ 989:148e5441d916
6863023: need non-perm oops in code cache for JSR 292
Summary: Make a special root-list for those few nmethods which might contain non-perm oops.
Reviewed-by: twisti, kvn, never, jmasa, ysr
author | jrose |
---|---|
date | Tue, 15 Sep 2009 21:53:47 -0700 |
parents | 72088be4b386 |
children | 873ec3787992 |
rev | line source |
---|---|
0 | 1 /* |
844 | 2 * Copyright 2000-2009 Sun Microsystems, Inc. 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 * | |
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 |
931
72088be4b386
6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit
cfang
parents:
903
diff
changeset
|
55 public ScopeDesc(NMethod code, int decodeOffset, boolean reexecute) { |
0 | 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); |
931
72088be4b386
6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit
cfang
parents:
903
diff
changeset
|
59 this.reexecute = reexecute; |
818
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
60 |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
61 // Decode header |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
62 DebugInfoReadStream stream = streamAt(decodeOffset); |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
63 |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
64 senderDecodeOffset = stream.readInt(); |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
65 method = (Method) VM.getVM().getObjectHeap().newOop(stream.readOopHandle()); |
931
72088be4b386
6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit
cfang
parents:
903
diff
changeset
|
66 bci = stream.readBCI(); |
818
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
67 // Decode offsets for body and sender |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
68 localsDecodeOffset = stream.readInt(); |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
69 expressionsDecodeOffset = stream.readInt(); |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
70 monitorsDecodeOffset = stream.readInt(); |
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 |
931
72088be4b386
6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit
cfang
parents:
903
diff
changeset
|
73 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
|
74 this.code = code; |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
75 this.decodeOffset = decodeOffset; |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
76 this.objects = decodeObjectValues(objectDecodeOffset); |
931
72088be4b386
6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit
cfang
parents:
903
diff
changeset
|
77 this.reexecute = reexecute; |
0 | 78 |
79 // Decode header | |
80 DebugInfoReadStream stream = streamAt(decodeOffset); | |
81 | |
82 senderDecodeOffset = stream.readInt(); | |
83 method = (Method) VM.getVM().getObjectHeap().newOop(stream.readOopHandle()); | |
931
72088be4b386
6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit
cfang
parents:
903
diff
changeset
|
84 bci = stream.readBCI(); |
0 | 85 // Decode offsets for body and sender |
86 localsDecodeOffset = stream.readInt(); | |
87 expressionsDecodeOffset = stream.readInt(); | |
88 monitorsDecodeOffset = stream.readInt(); | |
89 } | |
90 | |
931
72088be4b386
6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit
cfang
parents:
903
diff
changeset
|
91 public NMethod getNMethod() { return code; } |
72088be4b386
6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit
cfang
parents:
903
diff
changeset
|
92 public Method getMethod() { return method; } |
72088be4b386
6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit
cfang
parents:
903
diff
changeset
|
93 public int getBCI() { return bci; } |
72088be4b386
6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit
cfang
parents:
903
diff
changeset
|
94 public boolean getReexecute() { return reexecute;} |
0 | 95 |
96 /** Returns a List<ScopeValue> */ | |
97 public List getLocals() { | |
98 return decodeScopeValues(localsDecodeOffset); | |
99 } | |
100 | |
101 /** Returns a List<ScopeValue> */ | |
102 public List getExpressions() { | |
103 return decodeScopeValues(expressionsDecodeOffset); | |
104 } | |
105 | |
106 /** Returns a List<MonitorValue> */ | |
107 public List getMonitors() { | |
108 return decodeMonitorValues(monitorsDecodeOffset); | |
109 } | |
110 | |
818
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
111 /** Returns a List<MonitorValue> */ |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
112 public List getObjects() { |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
113 return objects; |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
114 } |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
115 |
0 | 116 /** Stack walking. Returns null if this is the outermost scope. */ |
117 public ScopeDesc sender() { | |
118 if (isTop()) { | |
119 return null; | |
120 } | |
121 | |
931
72088be4b386
6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit
cfang
parents:
903
diff
changeset
|
122 return new ScopeDesc(code, senderDecodeOffset, false); |
0 | 123 } |
124 | |
125 /** Returns where the scope was decoded */ | |
126 public int getDecodeOffset() { | |
127 return decodeOffset; | |
128 } | |
129 | |
130 /** Tells whether sender() returns null */ | |
131 public boolean isTop() { | |
132 return (senderDecodeOffset == DebugInformationRecorder.SERIALIZED_NULL); | |
133 } | |
134 | |
135 public boolean equals(Object arg) { | |
136 if (arg == null) { | |
137 return false; | |
138 } | |
139 | |
140 if (!(arg instanceof ScopeDesc)) { | |
141 return false; | |
142 } | |
143 | |
144 ScopeDesc sd = (ScopeDesc) arg; | |
145 | |
146 return (sd.method.equals(method) && (sd.bci == bci)); | |
147 } | |
148 | |
149 public void printValue() { | |
150 printValueOn(System.out); | |
151 } | |
152 | |
153 public void printValueOn(PrintStream tty) { | |
154 tty.print("ScopeDesc for "); | |
155 method.printValueOn(tty); | |
931
72088be4b386
6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit
cfang
parents:
903
diff
changeset
|
156 tty.print(" @bci " + bci); |
72088be4b386
6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit
cfang
parents:
903
diff
changeset
|
157 tty.println(" reexecute=" + reexecute); |
0 | 158 } |
159 | |
160 // FIXME: add more accessors | |
161 | |
162 //-------------------------------------------------------------------------------- | |
163 // Internals only below this point | |
164 // | |
165 private DebugInfoReadStream streamAt(int decodeOffset) { | |
818
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
166 return new DebugInfoReadStream(code, decodeOffset, objects); |
0 | 167 } |
168 | |
169 /** Returns a List<ScopeValue> or null if no values were present */ | |
170 private List decodeScopeValues(int decodeOffset) { | |
171 if (decodeOffset == DebugInformationRecorder.SERIALIZED_NULL) { | |
172 return null; | |
173 } | |
174 DebugInfoReadStream stream = streamAt(decodeOffset); | |
175 int length = stream.readInt(); | |
176 List res = new ArrayList(length); | |
177 for (int i = 0; i < length; i++) { | |
178 res.add(ScopeValue.readFrom(stream)); | |
179 } | |
180 return res; | |
181 } | |
182 | |
183 /** Returns a List<MonitorValue> or null if no values were present */ | |
184 private List decodeMonitorValues(int decodeOffset) { | |
185 if (decodeOffset == DebugInformationRecorder.SERIALIZED_NULL) { | |
186 return null; | |
187 } | |
188 DebugInfoReadStream stream = streamAt(decodeOffset); | |
189 int length = stream.readInt(); | |
190 List res = new ArrayList(length); | |
191 for (int i = 0; i < length; i++) { | |
192 res.add(new MonitorValue(stream)); | |
193 } | |
194 return res; | |
195 } | |
818
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
196 |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
197 /** 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
|
198 private List decodeObjectValues(int decodeOffset) { |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
199 if (decodeOffset == DebugInformationRecorder.SERIALIZED_NULL) { |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
200 return null; |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
201 } |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
202 List res = new ArrayList(); |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
203 DebugInfoReadStream stream = new DebugInfoReadStream(code, decodeOffset, res); |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
204 int length = stream.readInt(); |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
205 for (int i = 0; i < length; i++) { |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
206 // 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
|
207 // 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
|
208 ScopeValue.readFrom(stream); |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
209 // res.add(ScopeValue.readFrom(stream)); |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
210 } |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
211 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
|
212 return res; |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
0
diff
changeset
|
213 } |
0 | 214 } |