Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/hotspot/share/code/debugInfo.hpp
40931 views
1
/*
2
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*
23
*/
24
25
#ifndef SHARE_CODE_DEBUGINFO_HPP
26
#define SHARE_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 "runtime/thread.hpp"
34
#include "utilities/growableArray.hpp"
35
36
// Classes used for serializing debugging information.
37
// These abstractions are introducted to provide symmetric
38
// read and write operations.
39
40
// ScopeValue describes the value of a variable/expression in a scope
41
// - LocationValue describes a value in a given location (in frame or register)
42
// - ConstantValue describes a constant
43
44
class ConstantOopReadValue;
45
class LocationValue;
46
class ObjectValue;
47
48
class ScopeValue: public ResourceObj {
49
public:
50
// Testers
51
virtual bool is_location() const { return false; }
52
virtual bool is_object() const { return false; }
53
virtual bool is_auto_box() const { return false; }
54
virtual bool is_marker() const { return false; }
55
virtual bool is_constant_int() const { return false; }
56
virtual bool is_constant_double() const { return false; }
57
virtual bool is_constant_long() const { return false; }
58
virtual bool is_constant_oop() const { return false; }
59
virtual bool equals(ScopeValue* other) const { return false; }
60
61
ConstantOopReadValue* as_ConstantOopReadValue() {
62
assert(is_constant_oop(), "must be");
63
return (ConstantOopReadValue*) this;
64
}
65
66
ObjectValue* as_ObjectValue() {
67
assert(is_object(), "must be");
68
return (ObjectValue*)this;
69
}
70
71
LocationValue* as_LocationValue() {
72
assert(is_location(), "must be");
73
return (LocationValue*)this;
74
}
75
76
// Serialization of debugging information
77
virtual void write_on(DebugInfoWriteStream* stream) = 0;
78
static ScopeValue* read_from(DebugInfoReadStream* stream);
79
};
80
81
82
// A Location value describes a value in a given location; i.e. the corresponding
83
// logical entity (e.g., a method temporary) lives in this location.
84
85
class LocationValue: public ScopeValue {
86
private:
87
Location _location;
88
public:
89
LocationValue(Location location) { _location = location; }
90
bool is_location() const { return true; }
91
Location location() const { return _location; }
92
93
// Serialization of debugging information
94
LocationValue(DebugInfoReadStream* stream);
95
void write_on(DebugInfoWriteStream* stream);
96
97
// Printing
98
void print_on(outputStream* st) const;
99
};
100
101
// A placeholder value that has no concrete meaning other than helping constructing
102
// other values.
103
104
class MarkerValue: public ScopeValue {
105
public:
106
bool is_marker() const { return true; }
107
108
// Serialization of debugging information
109
void write_on(DebugInfoWriteStream* stream);
110
111
// Printing
112
void print_on(outputStream* st) const;
113
};
114
115
// An ObjectValue describes an object eliminated by escape analysis.
116
117
class ObjectValue: public ScopeValue {
118
protected:
119
int _id;
120
ScopeValue* _klass;
121
GrowableArray<ScopeValue*> _field_values;
122
Handle _value;
123
bool _visited;
124
public:
125
ObjectValue(int id, ScopeValue* klass)
126
: _id(id)
127
, _klass(klass)
128
, _field_values()
129
, _value()
130
, _visited(false) {
131
assert(klass->is_constant_oop(), "should be constant java mirror oop");
132
}
133
134
ObjectValue(int id)
135
: _id(id)
136
, _klass(NULL)
137
, _field_values()
138
, _value()
139
, _visited(false) {}
140
141
// Accessors
142
bool is_object() const { return true; }
143
int id() const { return _id; }
144
ScopeValue* klass() const { return _klass; }
145
GrowableArray<ScopeValue*>* field_values() { return &_field_values; }
146
ScopeValue* field_at(int i) const { return _field_values.at(i); }
147
int field_size() { return _field_values.length(); }
148
Handle value() const { return _value; }
149
bool is_visited() const { return _visited; }
150
151
void set_value(oop value);
152
void set_visited(bool visited) { _visited = visited; }
153
154
// Serialization of debugging information
155
void read_object(DebugInfoReadStream* stream);
156
void write_on(DebugInfoWriteStream* stream);
157
158
// Printing
159
void print_on(outputStream* st) const;
160
void print_fields_on(outputStream* st) const;
161
};
162
163
class AutoBoxObjectValue : public ObjectValue {
164
bool _cached;
165
public:
166
bool is_auto_box() const { return true; }
167
bool is_cached() const { return _cached; }
168
void set_cached(bool cached) { _cached = cached; }
169
AutoBoxObjectValue(int id, ScopeValue* klass) : ObjectValue(id, klass), _cached(false) { }
170
AutoBoxObjectValue(int id) : ObjectValue(id), _cached(false) { }
171
};
172
173
174
// A ConstantIntValue describes a constant int; i.e., the corresponding logical entity
175
// is either a source constant or its computation has been constant-folded.
176
177
class ConstantIntValue: public ScopeValue {
178
private:
179
jint _value;
180
public:
181
ConstantIntValue(jint value) { _value = value; }
182
jint value() const { return _value; }
183
bool is_constant_int() const { return true; }
184
bool equals(ScopeValue* other) const { return false; }
185
186
// Serialization of debugging information
187
ConstantIntValue(DebugInfoReadStream* stream);
188
void write_on(DebugInfoWriteStream* stream);
189
190
// Printing
191
void print_on(outputStream* st) const;
192
};
193
194
class ConstantLongValue: public ScopeValue {
195
private:
196
jlong _value;
197
public:
198
ConstantLongValue(jlong value) { _value = value; }
199
jlong value() const { return _value; }
200
bool is_constant_long() const { return true; }
201
bool equals(ScopeValue* other) const { return false; }
202
203
// Serialization of debugging information
204
ConstantLongValue(DebugInfoReadStream* stream);
205
void write_on(DebugInfoWriteStream* stream);
206
207
// Printing
208
void print_on(outputStream* st) const;
209
};
210
211
class ConstantDoubleValue: public ScopeValue {
212
private:
213
jdouble _value;
214
public:
215
ConstantDoubleValue(jdouble value) { _value = value; }
216
jdouble value() const { return _value; }
217
bool is_constant_double() const { return true; }
218
bool equals(ScopeValue* other) const { return false; }
219
220
// Serialization of debugging information
221
ConstantDoubleValue(DebugInfoReadStream* stream);
222
void write_on(DebugInfoWriteStream* stream);
223
224
// Printing
225
void print_on(outputStream* st) const;
226
};
227
228
// A ConstantOopWriteValue is created by the compiler to
229
// be written as debugging information.
230
231
class ConstantOopWriteValue: public ScopeValue {
232
private:
233
jobject _value;
234
public:
235
ConstantOopWriteValue(jobject value) { _value = value; }
236
jobject value() const { return _value; }
237
bool is_constant_oop() const { return true; }
238
bool equals(ScopeValue* other) const { return false; }
239
240
// Serialization of debugging information
241
void write_on(DebugInfoWriteStream* stream);
242
243
// Printing
244
void print_on(outputStream* st) const;
245
};
246
247
// A ConstantOopReadValue is created by the VM when reading
248
// debug information
249
250
class ConstantOopReadValue: public ScopeValue {
251
private:
252
Handle _value;
253
public:
254
Handle value() const { return _value; }
255
bool is_constant_oop() const { return true; }
256
bool equals(ScopeValue* other) const { return false; }
257
258
// Serialization of debugging information
259
ConstantOopReadValue(DebugInfoReadStream* stream);
260
void write_on(DebugInfoWriteStream* stream);
261
262
// Printing
263
void print_on(outputStream* st) const;
264
};
265
266
// MonitorValue describes the pair used for monitor_enter and monitor_exit.
267
268
class MonitorValue: public ResourceObj {
269
private:
270
ScopeValue* _owner;
271
Location _basic_lock;
272
bool _eliminated;
273
public:
274
// Constructor
275
MonitorValue(ScopeValue* owner, Location basic_lock, bool eliminated = false);
276
277
// Accessors
278
ScopeValue* owner() const { return _owner; }
279
Location basic_lock() const { return _basic_lock; }
280
bool eliminated() const { return _eliminated; }
281
282
// Serialization of debugging information
283
MonitorValue(DebugInfoReadStream* stream);
284
void write_on(DebugInfoWriteStream* stream);
285
286
// Printing
287
void print_on(outputStream* st) const;
288
};
289
290
// DebugInfoReadStream specializes CompressedReadStream for reading
291
// debugging information. Used by ScopeDesc.
292
293
class DebugInfoReadStream : public CompressedReadStream {
294
private:
295
const CompiledMethod* _code;
296
const CompiledMethod* code() const { return _code; }
297
GrowableArray<ScopeValue*>* _obj_pool;
298
public:
299
DebugInfoReadStream(const CompiledMethod* code, int offset, GrowableArray<ScopeValue*>* obj_pool = NULL) :
300
CompressedReadStream(code->scopes_data_begin(), offset) {
301
_code = code;
302
_obj_pool = obj_pool;
303
304
} ;
305
306
oop read_oop();
307
Method* read_method() {
308
Method* o = (Method*)(code()->metadata_at(read_int()));
309
// is_metadata() is a faster check than is_metaspace_object()
310
assert(o == NULL || o->is_metadata(), "meta data only");
311
return o;
312
}
313
ScopeValue* read_object_value(bool is_auto_box);
314
ScopeValue* get_cached_object();
315
// BCI encoding is mostly unsigned, but -1 is a distinguished value
316
int read_bci() { return read_int() + InvocationEntryBci; }
317
};
318
319
// DebugInfoWriteStream specializes CompressedWriteStream for
320
// writing debugging information. Used by ScopeDescRecorder.
321
322
class DebugInfoWriteStream : public CompressedWriteStream {
323
private:
324
DebugInformationRecorder* _recorder;
325
DebugInformationRecorder* recorder() const { return _recorder; }
326
public:
327
DebugInfoWriteStream(DebugInformationRecorder* recorder, int initial_size);
328
void write_handle(jobject h);
329
void write_bci(int bci) { write_int(bci - InvocationEntryBci); }
330
331
void write_metadata(Metadata* m);
332
};
333
334
#endif // SHARE_CODE_DEBUGINFO_HPP
335
336