Mercurial > hg > truffle
annotate src/share/vm/code/debugInfo.cpp @ 2428:5134fa1cfe63
7029036: Card-table verification hangs with all framework collectors, except G1, even before the first GC
Summary: When verifying clean card ranges, use memory-range-bounded iteration over oops of objects overlapping that range, thus avoiding the otherwise quadratic worst-case cost of scanning large object arrays.
Reviewed-by: jmasa, jwilhelm, tonyp
author | ysr |
---|---|
date | Thu, 24 Mar 2011 15:47:01 -0700 |
parents | f95d63e2154a |
children | da91efe96a93 |
rev | line source |
---|---|
0 | 1 /* |
1972 | 2 * Copyright (c) 1997, 2010, 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 | |
44 ScopeValue* DebugInfoReadStream::read_object_value() { | |
45 int id = read_int(); | |
46 #ifdef ASSERT | |
47 assert(_obj_pool != NULL, "object pool does not exist"); | |
48 for (int i = _obj_pool->length() - 1; i >= 0; i--) { | |
49 assert(((ObjectValue*) _obj_pool->at(i))->id() != id, "should not be read twice"); | |
50 } | |
51 #endif | |
52 ObjectValue* result = new ObjectValue(id); | |
44
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
53 // 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
|
54 _obj_pool->push(result); |
0 | 55 result->read_object(this); |
56 return result; | |
57 } | |
58 | |
59 ScopeValue* DebugInfoReadStream::get_cached_object() { | |
60 int id = read_int(); | |
61 assert(_obj_pool != NULL, "object pool does not exist"); | |
62 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
|
63 ObjectValue* ov = (ObjectValue*) _obj_pool->at(i); |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
64 if (ov->id() == id) { |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
65 return ov; |
0 | 66 } |
67 } | |
68 ShouldNotReachHere(); | |
69 return NULL; | |
70 } | |
71 | |
72 // Serializing scope values | |
73 | |
74 enum { LOCATION_CODE = 0, CONSTANT_INT_CODE = 1, CONSTANT_OOP_CODE = 2, | |
75 CONSTANT_LONG_CODE = 3, CONSTANT_DOUBLE_CODE = 4, | |
76 OBJECT_CODE = 5, OBJECT_ID_CODE = 6 }; | |
77 | |
78 ScopeValue* ScopeValue::read_from(DebugInfoReadStream* stream) { | |
79 ScopeValue* result = NULL; | |
80 switch(stream->read_int()) { | |
81 case LOCATION_CODE: result = new LocationValue(stream); break; | |
82 case CONSTANT_INT_CODE: result = new ConstantIntValue(stream); break; | |
83 case CONSTANT_OOP_CODE: result = new ConstantOopReadValue(stream); break; | |
84 case CONSTANT_LONG_CODE: result = new ConstantLongValue(stream); break; | |
85 case CONSTANT_DOUBLE_CODE: result = new ConstantDoubleValue(stream); break; | |
86 case OBJECT_CODE: result = stream->read_object_value(); break; | |
87 case OBJECT_ID_CODE: result = stream->get_cached_object(); break; | |
88 default: ShouldNotReachHere(); | |
89 } | |
90 return result; | |
91 } | |
92 | |
93 // LocationValue | |
94 | |
95 LocationValue::LocationValue(DebugInfoReadStream* stream) { | |
96 _location = Location(stream); | |
97 } | |
98 | |
99 void LocationValue::write_on(DebugInfoWriteStream* stream) { | |
100 stream->write_int(LOCATION_CODE); | |
101 location().write_on(stream); | |
102 } | |
103 | |
104 void LocationValue::print_on(outputStream* st) const { | |
105 location().print_on(st); | |
106 } | |
107 | |
108 // ObjectValue | |
109 | |
110 void ObjectValue::read_object(DebugInfoReadStream* stream) { | |
111 _klass = read_from(stream); | |
112 assert(_klass->is_constant_oop(), "should be constant klass oop"); | |
113 int length = stream->read_int(); | |
114 for (int i = 0; i < length; i++) { | |
115 ScopeValue* val = read_from(stream); | |
116 _field_values.append(val); | |
117 } | |
118 } | |
119 | |
120 void ObjectValue::write_on(DebugInfoWriteStream* stream) { | |
121 if (_visited) { | |
122 stream->write_int(OBJECT_ID_CODE); | |
123 stream->write_int(_id); | |
124 } else { | |
125 _visited = true; | |
126 stream->write_int(OBJECT_CODE); | |
127 stream->write_int(_id); | |
128 _klass->write_on(stream); | |
129 int length = _field_values.length(); | |
130 stream->write_int(length); | |
131 for (int i = 0; i < length; i++) { | |
132 _field_values.at(i)->write_on(stream); | |
133 } | |
134 } | |
135 } | |
136 | |
137 void ObjectValue::print_on(outputStream* st) const { | |
138 st->print("obj[%d]", _id); | |
139 } | |
140 | |
141 void ObjectValue::print_fields_on(outputStream* st) const { | |
142 #ifndef PRODUCT | |
143 if (_field_values.length() > 0) { | |
144 _field_values.at(0)->print_on(st); | |
145 } | |
146 for (int i = 1; i < _field_values.length(); i++) { | |
147 st->print(", "); | |
148 _field_values.at(i)->print_on(st); | |
149 } | |
150 #endif | |
151 } | |
152 | |
153 // ConstantIntValue | |
154 | |
155 ConstantIntValue::ConstantIntValue(DebugInfoReadStream* stream) { | |
156 _value = stream->read_signed_int(); | |
157 } | |
158 | |
159 void ConstantIntValue::write_on(DebugInfoWriteStream* stream) { | |
160 stream->write_int(CONSTANT_INT_CODE); | |
161 stream->write_signed_int(value()); | |
162 } | |
163 | |
164 void ConstantIntValue::print_on(outputStream* st) const { | |
165 st->print("%d", value()); | |
166 } | |
167 | |
168 // ConstantLongValue | |
169 | |
170 ConstantLongValue::ConstantLongValue(DebugInfoReadStream* stream) { | |
171 _value = stream->read_long(); | |
172 } | |
173 | |
174 void ConstantLongValue::write_on(DebugInfoWriteStream* stream) { | |
175 stream->write_int(CONSTANT_LONG_CODE); | |
176 stream->write_long(value()); | |
177 } | |
178 | |
179 void ConstantLongValue::print_on(outputStream* st) const { | |
180 st->print(INT64_FORMAT, value()); | |
181 } | |
182 | |
183 // ConstantDoubleValue | |
184 | |
185 ConstantDoubleValue::ConstantDoubleValue(DebugInfoReadStream* stream) { | |
186 _value = stream->read_double(); | |
187 } | |
188 | |
189 void ConstantDoubleValue::write_on(DebugInfoWriteStream* stream) { | |
190 stream->write_int(CONSTANT_DOUBLE_CODE); | |
191 stream->write_double(value()); | |
192 } | |
193 | |
194 void ConstantDoubleValue::print_on(outputStream* st) const { | |
195 st->print("%f", value()); | |
196 } | |
197 | |
198 // ConstantOopWriteValue | |
199 | |
200 void ConstantOopWriteValue::write_on(DebugInfoWriteStream* stream) { | |
201 stream->write_int(CONSTANT_OOP_CODE); | |
202 stream->write_handle(value()); | |
203 } | |
204 | |
205 void ConstantOopWriteValue::print_on(outputStream* st) const { | |
206 JNIHandles::resolve(value())->print_value_on(st); | |
207 } | |
208 | |
209 | |
210 // ConstantOopReadValue | |
211 | |
212 ConstantOopReadValue::ConstantOopReadValue(DebugInfoReadStream* stream) { | |
213 _value = Handle(stream->read_oop()); | |
214 } | |
215 | |
216 void ConstantOopReadValue::write_on(DebugInfoWriteStream* stream) { | |
217 ShouldNotReachHere(); | |
218 } | |
219 | |
220 void ConstantOopReadValue::print_on(outputStream* st) const { | |
221 value()()->print_value_on(st); | |
222 } | |
223 | |
224 | |
225 // MonitorValue | |
226 | |
227 MonitorValue::MonitorValue(ScopeValue* owner, Location basic_lock, bool eliminated) { | |
228 _owner = owner; | |
229 _basic_lock = basic_lock; | |
230 _eliminated = eliminated; | |
231 } | |
232 | |
233 MonitorValue::MonitorValue(DebugInfoReadStream* stream) { | |
234 _basic_lock = Location(stream); | |
235 _owner = ScopeValue::read_from(stream); | |
236 _eliminated = (stream->read_bool() != 0); | |
237 } | |
238 | |
239 void MonitorValue::write_on(DebugInfoWriteStream* stream) { | |
240 _basic_lock.write_on(stream); | |
241 _owner->write_on(stream); | |
242 stream->write_bool(_eliminated); | |
243 } | |
244 | |
245 #ifndef PRODUCT | |
246 void MonitorValue::print_on(outputStream* st) const { | |
247 st->print("monitor{"); | |
248 owner()->print_on(st); | |
249 st->print(","); | |
250 basic_lock().print_on(st); | |
251 st->print("}"); | |
252 if (_eliminated) { | |
253 st->print(" (eliminated)"); | |
254 } | |
255 } | |
256 #endif |