author | stefank |
Tue, 23 Nov 2010 13:22:55 -0800 | |
changeset 7397 | 5b173b4ca846 |
parent 5547 | f4b087cbb361 |
child 13728 | 882756847a04 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
7397 | 2 |
* Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
3686
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
3686
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
3686
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#ifndef SHARE_VM_CODE_DEBUGINFO_HPP |
26 |
#define SHARE_VM_CODE_DEBUGINFO_HPP |
|
27 |
||
28 |
#include "code/compressedStream.hpp" |
|
29 |
#include "code/location.hpp" |
|
30 |
#include "code/nmethod.hpp" |
|
31 |
#include "code/oopRecorder.hpp" |
|
32 |
#include "runtime/stackValue.hpp" |
|
33 |
#include "utilities/growableArray.hpp" |
|
34 |
||
1 | 35 |
// Classes used for serializing debugging information. |
36 |
// These abstractions are introducted to provide symmetric |
|
37 |
// read and write operations. |
|
38 |
||
39 |
// ScopeValue describes the value of a variable/expression in a scope |
|
40 |
// - LocationValue describes a value in a given location (in frame or register) |
|
41 |
// - ConstantValue describes a constant |
|
42 |
||
43 |
class ScopeValue: public ResourceObj { |
|
44 |
public: |
|
45 |
// Testers |
|
46 |
virtual bool is_location() const { return false; } |
|
47 |
virtual bool is_object() const { return false; } |
|
48 |
virtual bool is_constant_int() const { return false; } |
|
49 |
virtual bool is_constant_double() const { return false; } |
|
50 |
virtual bool is_constant_long() const { return false; } |
|
51 |
virtual bool is_constant_oop() const { return false; } |
|
52 |
virtual bool equals(ScopeValue* other) const { return false; } |
|
53 |
||
54 |
// Serialization of debugging information |
|
55 |
virtual void write_on(DebugInfoWriteStream* stream) = 0; |
|
56 |
static ScopeValue* read_from(DebugInfoReadStream* stream); |
|
57 |
}; |
|
58 |
||
59 |
||
60 |
// A Location value describes a value in a given location; i.e. the corresponding |
|
61 |
// logical entity (e.g., a method temporary) lives in this location. |
|
62 |
||
63 |
class LocationValue: public ScopeValue { |
|
64 |
private: |
|
65 |
Location _location; |
|
66 |
public: |
|
67 |
LocationValue(Location location) { _location = location; } |
|
68 |
bool is_location() const { return true; } |
|
69 |
Location location() const { return _location; } |
|
70 |
||
71 |
// Serialization of debugging information |
|
72 |
LocationValue(DebugInfoReadStream* stream); |
|
73 |
void write_on(DebugInfoWriteStream* stream); |
|
74 |
||
75 |
// Printing |
|
76 |
void print_on(outputStream* st) const; |
|
77 |
}; |
|
78 |
||
79 |
||
80 |
// An ObjectValue describes an object eliminated by escape analysis. |
|
81 |
||
82 |
class ObjectValue: public ScopeValue { |
|
83 |
private: |
|
84 |
int _id; |
|
85 |
ScopeValue* _klass; |
|
86 |
GrowableArray<ScopeValue*> _field_values; |
|
87 |
Handle _value; |
|
88 |
bool _visited; |
|
89 |
||
90 |
public: |
|
91 |
ObjectValue(int id, ScopeValue* klass) |
|
92 |
: _id(id) |
|
93 |
, _klass(klass) |
|
94 |
, _field_values() |
|
95 |
, _value() |
|
96 |
, _visited(false) { |
|
97 |
assert(klass->is_constant_oop(), "should be constant klass oop"); |
|
98 |
} |
|
99 |
||
100 |
ObjectValue(int id) |
|
101 |
: _id(id) |
|
102 |
, _klass(NULL) |
|
103 |
, _field_values() |
|
104 |
, _value() |
|
105 |
, _visited(false) {} |
|
106 |
||
107 |
// Accessors |
|
108 |
bool is_object() const { return true; } |
|
109 |
int id() const { return _id; } |
|
110 |
ScopeValue* klass() const { return _klass; } |
|
111 |
GrowableArray<ScopeValue*>* field_values() { return &_field_values; } |
|
112 |
ScopeValue* field_at(int i) const { return _field_values.at(i); } |
|
113 |
int field_size() { return _field_values.length(); } |
|
114 |
Handle value() const { return _value; } |
|
115 |
bool is_visited() const { return _visited; } |
|
116 |
||
117 |
void set_value(oop value) { _value = Handle(value); } |
|
118 |
void set_visited(bool visited) { _visited = false; } |
|
119 |
||
120 |
// Serialization of debugging information |
|
121 |
void read_object(DebugInfoReadStream* stream); |
|
122 |
void write_on(DebugInfoWriteStream* stream); |
|
123 |
||
124 |
// Printing |
|
125 |
void print_on(outputStream* st) const; |
|
126 |
void print_fields_on(outputStream* st) const; |
|
127 |
}; |
|
128 |
||
129 |
||
130 |
// A ConstantIntValue describes a constant int; i.e., the corresponding logical entity |
|
131 |
// is either a source constant or its computation has been constant-folded. |
|
132 |
||
133 |
class ConstantIntValue: public ScopeValue { |
|
134 |
private: |
|
135 |
jint _value; |
|
136 |
public: |
|
137 |
ConstantIntValue(jint value) { _value = value; } |
|
138 |
jint value() const { return _value; } |
|
139 |
bool is_constant_int() const { return true; } |
|
140 |
bool equals(ScopeValue* other) const { return false; } |
|
141 |
||
142 |
// Serialization of debugging information |
|
143 |
ConstantIntValue(DebugInfoReadStream* stream); |
|
144 |
void write_on(DebugInfoWriteStream* stream); |
|
145 |
||
146 |
// Printing |
|
147 |
void print_on(outputStream* st) const; |
|
148 |
}; |
|
149 |
||
150 |
class ConstantLongValue: public ScopeValue { |
|
151 |
private: |
|
152 |
jlong _value; |
|
153 |
public: |
|
154 |
ConstantLongValue(jlong value) { _value = value; } |
|
155 |
jlong value() const { return _value; } |
|
156 |
bool is_constant_long() const { return true; } |
|
157 |
bool equals(ScopeValue* other) const { return false; } |
|
158 |
||
159 |
// Serialization of debugging information |
|
160 |
ConstantLongValue(DebugInfoReadStream* stream); |
|
161 |
void write_on(DebugInfoWriteStream* stream); |
|
162 |
||
163 |
// Printing |
|
164 |
void print_on(outputStream* st) const; |
|
165 |
}; |
|
166 |
||
167 |
class ConstantDoubleValue: public ScopeValue { |
|
168 |
private: |
|
169 |
jdouble _value; |
|
170 |
public: |
|
171 |
ConstantDoubleValue(jdouble value) { _value = value; } |
|
172 |
jdouble value() const { return _value; } |
|
173 |
bool is_constant_double() const { return true; } |
|
174 |
bool equals(ScopeValue* other) const { return false; } |
|
175 |
||
176 |
// Serialization of debugging information |
|
177 |
ConstantDoubleValue(DebugInfoReadStream* stream); |
|
178 |
void write_on(DebugInfoWriteStream* stream); |
|
179 |
||
180 |
// Printing |
|
181 |
void print_on(outputStream* st) const; |
|
182 |
}; |
|
183 |
||
184 |
// A ConstantOopWriteValue is created by the compiler to |
|
185 |
// be written as debugging information. |
|
186 |
||
187 |
class ConstantOopWriteValue: public ScopeValue { |
|
188 |
private: |
|
189 |
jobject _value; |
|
190 |
public: |
|
191 |
ConstantOopWriteValue(jobject value) { _value = value; } |
|
192 |
jobject value() const { return _value; } |
|
193 |
bool is_constant_oop() const { return true; } |
|
194 |
bool equals(ScopeValue* other) const { return false; } |
|
195 |
||
196 |
// Serialization of debugging information |
|
197 |
void write_on(DebugInfoWriteStream* stream); |
|
198 |
||
199 |
// Printing |
|
200 |
void print_on(outputStream* st) const; |
|
201 |
}; |
|
202 |
||
203 |
// A ConstantOopReadValue is created by the VM when reading |
|
204 |
// debug information |
|
205 |
||
206 |
class ConstantOopReadValue: public ScopeValue { |
|
207 |
private: |
|
208 |
Handle _value; |
|
209 |
public: |
|
210 |
Handle value() const { return _value; } |
|
211 |
bool is_constant_oop() const { return true; } |
|
212 |
bool equals(ScopeValue* other) const { return false; } |
|
213 |
||
214 |
// Serialization of debugging information |
|
215 |
ConstantOopReadValue(DebugInfoReadStream* stream); |
|
216 |
void write_on(DebugInfoWriteStream* stream); |
|
217 |
||
218 |
// Printing |
|
219 |
void print_on(outputStream* st) const; |
|
220 |
}; |
|
221 |
||
222 |
// MonitorValue describes the pair used for monitor_enter and monitor_exit. |
|
223 |
||
224 |
class MonitorValue: public ResourceObj { |
|
225 |
private: |
|
226 |
ScopeValue* _owner; |
|
227 |
Location _basic_lock; |
|
228 |
bool _eliminated; |
|
229 |
public: |
|
230 |
// Constructor |
|
231 |
MonitorValue(ScopeValue* owner, Location basic_lock, bool eliminated = false); |
|
232 |
||
233 |
// Accessors |
|
234 |
ScopeValue* owner() const { return _owner; } |
|
235 |
Location basic_lock() const { return _basic_lock; } |
|
236 |
bool eliminated() const { return _eliminated; } |
|
237 |
||
238 |
// Serialization of debugging information |
|
239 |
MonitorValue(DebugInfoReadStream* stream); |
|
240 |
void write_on(DebugInfoWriteStream* stream); |
|
241 |
||
242 |
// Printing |
|
243 |
void print_on(outputStream* st) const; |
|
244 |
}; |
|
245 |
||
246 |
// DebugInfoReadStream specializes CompressedReadStream for reading |
|
247 |
// debugging information. Used by ScopeDesc. |
|
248 |
||
249 |
class DebugInfoReadStream : public CompressedReadStream { |
|
250 |
private: |
|
251 |
const nmethod* _code; |
|
252 |
const nmethod* code() const { return _code; } |
|
253 |
GrowableArray<ScopeValue*>* _obj_pool; |
|
254 |
public: |
|
255 |
DebugInfoReadStream(const nmethod* code, int offset, GrowableArray<ScopeValue*>* obj_pool = NULL) : |
|
256 |
CompressedReadStream(code->scopes_data_begin(), offset) { |
|
257 |
_code = code; |
|
258 |
_obj_pool = obj_pool; |
|
259 |
||
260 |
} ; |
|
261 |
||
262 |
oop read_oop() { |
|
263 |
return code()->oop_at(read_int()); |
|
264 |
} |
|
265 |
ScopeValue* read_object_value(); |
|
266 |
ScopeValue* get_cached_object(); |
|
267 |
// BCI encoding is mostly unsigned, but -1 is a distinguished value |
|
3686
69c1b5228547
6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit
cfang
parents:
3600
diff
changeset
|
268 |
int read_bci() { return read_int() + InvocationEntryBci; } |
1 | 269 |
}; |
270 |
||
271 |
// DebugInfoWriteStream specializes CompressedWriteStream for |
|
272 |
// writing debugging information. Used by ScopeDescRecorder. |
|
273 |
||
274 |
class DebugInfoWriteStream : public CompressedWriteStream { |
|
275 |
private: |
|
276 |
DebugInformationRecorder* _recorder; |
|
277 |
DebugInformationRecorder* recorder() const { return _recorder; } |
|
278 |
public: |
|
279 |
DebugInfoWriteStream(DebugInformationRecorder* recorder, int initial_size); |
|
280 |
void write_handle(jobject h); |
|
3686
69c1b5228547
6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit
cfang
parents:
3600
diff
changeset
|
281 |
void write_bci(int bci) { write_int(bci - InvocationEntryBci); } |
1 | 282 |
}; |
7397 | 283 |
|
284 |
#endif // SHARE_VM_CODE_DEBUGINFO_HPP |