Mercurial > hg > truffle
annotate src/share/vm/code/debugInfo.cpp @ 11969:c65045599519
8021314: minimal1.make needs to force off components not supported by the minimal VM
Reviewed-by: coleenp, bpittore
author | dholmes |
---|---|
date | Thu, 25 Jul 2013 21:05:29 -0400 |
parents | da91efe96a93 |
children | b6a8f2d23057 78bbf4d43a14 |
rev | line source |
---|---|
0 | 1 /* |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1972
diff
changeset
|
2 * Copyright (c) 1997, 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:
196
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
196
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:
196
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #include "precompiled.hpp" |
26 #include "code/debugInfo.hpp" | |
27 #include "code/debugInfoRec.hpp" | |
28 #include "code/nmethod.hpp" | |
29 #include "runtime/handles.inline.hpp" | |
0 | 30 |
31 // Comstructors | |
32 | |
33 DebugInfoWriteStream::DebugInfoWriteStream(DebugInformationRecorder* recorder, int initial_size) | |
34 : CompressedWriteStream(initial_size) { | |
35 _recorder = recorder; | |
36 } | |
37 | |
38 // Serializing oops | |
39 | |
40 void DebugInfoWriteStream::write_handle(jobject h) { | |
41 write_int(recorder()->oop_recorder()->find_index(h)); | |
42 } | |
43 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1972
diff
changeset
|
44 void DebugInfoWriteStream::write_metadata(Metadata* h) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1972
diff
changeset
|
45 write_int(recorder()->oop_recorder()->find_index(h)); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1972
diff
changeset
|
46 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1972
diff
changeset
|
47 |
0 | 48 ScopeValue* DebugInfoReadStream::read_object_value() { |
49 int id = read_int(); | |
50 #ifdef ASSERT | |
51 assert(_obj_pool != NULL, "object pool does not exist"); | |
52 for (int i = _obj_pool->length() - 1; i >= 0; i--) { | |
53 assert(((ObjectValue*) _obj_pool->at(i))->id() != id, "should not be read twice"); | |
54 } | |
55 #endif | |
56 ObjectValue* result = new ObjectValue(id); | |
44
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
57 // Cache the object since an object field could reference it. |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
58 _obj_pool->push(result); |
0 | 59 result->read_object(this); |
60 return result; | |
61 } | |
62 | |
63 ScopeValue* DebugInfoReadStream::get_cached_object() { | |
64 int id = read_int(); | |
65 assert(_obj_pool != NULL, "object pool does not exist"); | |
66 for (int i = _obj_pool->length() - 1; i >= 0; i--) { | |
44
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
67 ObjectValue* ov = (ObjectValue*) _obj_pool->at(i); |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
68 if (ov->id() == id) { |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
69 return ov; |
0 | 70 } |
71 } | |
72 ShouldNotReachHere(); | |
73 return NULL; | |
74 } | |
75 | |
76 // Serializing scope values | |
77 | |
78 enum { LOCATION_CODE = 0, CONSTANT_INT_CODE = 1, CONSTANT_OOP_CODE = 2, | |
79 CONSTANT_LONG_CODE = 3, CONSTANT_DOUBLE_CODE = 4, | |
80 OBJECT_CODE = 5, OBJECT_ID_CODE = 6 }; | |
81 | |
82 ScopeValue* ScopeValue::read_from(DebugInfoReadStream* stream) { | |
83 ScopeValue* result = NULL; | |
84 switch(stream->read_int()) { | |
85 case LOCATION_CODE: result = new LocationValue(stream); break; | |
86 case CONSTANT_INT_CODE: result = new ConstantIntValue(stream); break; | |
87 case CONSTANT_OOP_CODE: result = new ConstantOopReadValue(stream); break; | |
88 case CONSTANT_LONG_CODE: result = new ConstantLongValue(stream); break; | |
89 case CONSTANT_DOUBLE_CODE: result = new ConstantDoubleValue(stream); break; | |
90 case OBJECT_CODE: result = stream->read_object_value(); break; | |
91 case OBJECT_ID_CODE: result = stream->get_cached_object(); break; | |
92 default: ShouldNotReachHere(); | |
93 } | |
94 return result; | |
95 } | |
96 | |
97 // LocationValue | |
98 | |
99 LocationValue::LocationValue(DebugInfoReadStream* stream) { | |
100 _location = Location(stream); | |
101 } | |
102 | |
103 void LocationValue::write_on(DebugInfoWriteStream* stream) { | |
104 stream->write_int(LOCATION_CODE); | |
105 location().write_on(stream); | |
106 } | |
107 | |
108 void LocationValue::print_on(outputStream* st) const { | |
109 location().print_on(st); | |
110 } | |
111 | |
112 // ObjectValue | |
113 | |
114 void ObjectValue::read_object(DebugInfoReadStream* stream) { | |
115 _klass = read_from(stream); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1972
diff
changeset
|
116 assert(_klass->is_constant_oop(), "should be constant java mirror oop"); |
0 | 117 int length = stream->read_int(); |
118 for (int i = 0; i < length; i++) { | |
119 ScopeValue* val = read_from(stream); | |
120 _field_values.append(val); | |
121 } | |
122 } | |
123 | |
124 void ObjectValue::write_on(DebugInfoWriteStream* stream) { | |
125 if (_visited) { | |
126 stream->write_int(OBJECT_ID_CODE); | |
127 stream->write_int(_id); | |
128 } else { | |
129 _visited = true; | |
130 stream->write_int(OBJECT_CODE); | |
131 stream->write_int(_id); | |
132 _klass->write_on(stream); | |
133 int length = _field_values.length(); | |
134 stream->write_int(length); | |
135 for (int i = 0; i < length; i++) { | |
136 _field_values.at(i)->write_on(stream); | |
137 } | |
138 } | |
139 } | |
140 | |
141 void ObjectValue::print_on(outputStream* st) const { | |
142 st->print("obj[%d]", _id); | |
143 } | |
144 | |
145 void ObjectValue::print_fields_on(outputStream* st) const { | |
146 #ifndef PRODUCT | |
147 if (_field_values.length() > 0) { | |
148 _field_values.at(0)->print_on(st); | |
149 } | |
150 for (int i = 1; i < _field_values.length(); i++) { | |
151 st->print(", "); | |
152 _field_values.at(i)->print_on(st); | |
153 } | |
154 #endif | |
155 } | |
156 | |
157 // ConstantIntValue | |
158 | |
159 ConstantIntValue::ConstantIntValue(DebugInfoReadStream* stream) { | |
160 _value = stream->read_signed_int(); | |
161 } | |
162 | |
163 void ConstantIntValue::write_on(DebugInfoWriteStream* stream) { | |
164 stream->write_int(CONSTANT_INT_CODE); | |
165 stream->write_signed_int(value()); | |
166 } | |
167 | |
168 void ConstantIntValue::print_on(outputStream* st) const { | |
169 st->print("%d", value()); | |
170 } | |
171 | |
172 // ConstantLongValue | |
173 | |
174 ConstantLongValue::ConstantLongValue(DebugInfoReadStream* stream) { | |
175 _value = stream->read_long(); | |
176 } | |
177 | |
178 void ConstantLongValue::write_on(DebugInfoWriteStream* stream) { | |
179 stream->write_int(CONSTANT_LONG_CODE); | |
180 stream->write_long(value()); | |
181 } | |
182 | |
183 void ConstantLongValue::print_on(outputStream* st) const { | |
184 st->print(INT64_FORMAT, value()); | |
185 } | |
186 | |
187 // ConstantDoubleValue | |
188 | |
189 ConstantDoubleValue::ConstantDoubleValue(DebugInfoReadStream* stream) { | |
190 _value = stream->read_double(); | |
191 } | |
192 | |
193 void ConstantDoubleValue::write_on(DebugInfoWriteStream* stream) { | |
194 stream->write_int(CONSTANT_DOUBLE_CODE); | |
195 stream->write_double(value()); | |
196 } | |
197 | |
198 void ConstantDoubleValue::print_on(outputStream* st) const { | |
199 st->print("%f", value()); | |
200 } | |
201 | |
202 // ConstantOopWriteValue | |
203 | |
204 void ConstantOopWriteValue::write_on(DebugInfoWriteStream* stream) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1972
diff
changeset
|
205 assert(JNIHandles::resolve(value()) == NULL || |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1972
diff
changeset
|
206 Universe::heap()->is_in_reserved(JNIHandles::resolve(value())), |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1972
diff
changeset
|
207 "Should be in heap"); |
0 | 208 stream->write_int(CONSTANT_OOP_CODE); |
209 stream->write_handle(value()); | |
210 } | |
211 | |
212 void ConstantOopWriteValue::print_on(outputStream* st) const { | |
213 JNIHandles::resolve(value())->print_value_on(st); | |
214 } | |
215 | |
216 | |
217 // ConstantOopReadValue | |
218 | |
219 ConstantOopReadValue::ConstantOopReadValue(DebugInfoReadStream* stream) { | |
220 _value = Handle(stream->read_oop()); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1972
diff
changeset
|
221 assert(_value() == NULL || |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1972
diff
changeset
|
222 Universe::heap()->is_in_reserved(_value()), "Should be in heap"); |
0 | 223 } |
224 | |
225 void ConstantOopReadValue::write_on(DebugInfoWriteStream* stream) { | |
226 ShouldNotReachHere(); | |
227 } | |
228 | |
229 void ConstantOopReadValue::print_on(outputStream* st) const { | |
230 value()()->print_value_on(st); | |
231 } | |
232 | |
233 | |
234 // MonitorValue | |
235 | |
236 MonitorValue::MonitorValue(ScopeValue* owner, Location basic_lock, bool eliminated) { | |
237 _owner = owner; | |
238 _basic_lock = basic_lock; | |
239 _eliminated = eliminated; | |
240 } | |
241 | |
242 MonitorValue::MonitorValue(DebugInfoReadStream* stream) { | |
243 _basic_lock = Location(stream); | |
244 _owner = ScopeValue::read_from(stream); | |
245 _eliminated = (stream->read_bool() != 0); | |
246 } | |
247 | |
248 void MonitorValue::write_on(DebugInfoWriteStream* stream) { | |
249 _basic_lock.write_on(stream); | |
250 _owner->write_on(stream); | |
251 stream->write_bool(_eliminated); | |
252 } | |
253 | |
254 #ifndef PRODUCT | |
255 void MonitorValue::print_on(outputStream* st) const { | |
256 st->print("monitor{"); | |
257 owner()->print_on(st); | |
258 st->print(","); | |
259 basic_lock().print_on(st); | |
260 st->print("}"); | |
261 if (_eliminated) { | |
262 st->print(" (eliminated)"); | |
263 } | |
264 } | |
265 #endif |