Mercurial > hg > graal-compiler
annotate src/share/vm/ci/ciInstanceKlass.cpp @ 12364:651cc32247d7
Add Graal option for deferring write barriers of eden allocated objects
author | Christos Kotselidis <christos.kotselidis@oracle.com> |
---|---|
date | Fri, 11 Oct 2013 17:06:18 +0200 |
parents | 836a62f43af9 |
children | cefad50507d8 |
rev | line source |
---|---|
0 | 1 /* |
5998
49036505ab5f
7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents:
4739
diff
changeset
|
2 * Copyright (c) 1999, 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:
1142
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1142
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:
1142
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #include "precompiled.hpp" |
26 #include "ci/ciField.hpp" | |
27 #include "ci/ciInstance.hpp" | |
28 #include "ci/ciInstanceKlass.hpp" | |
29 #include "ci/ciUtilities.hpp" | |
30 #include "classfile/systemDictionary.hpp" | |
31 #include "memory/allocation.hpp" | |
32 #include "memory/allocation.inline.hpp" | |
33 #include "oops/oop.inline.hpp" | |
3938 | 34 #include "oops/fieldStreams.hpp" |
1972 | 35 #include "runtime/fieldDescriptor.hpp" |
0 | 36 |
37 // ciInstanceKlass | |
38 // | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
39 // This class represents a Klass* in the HotSpot virtual machine |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
40 // whose Klass part in an InstanceKlass. |
0 | 41 |
42 // ------------------------------------------------------------------ | |
43 // ciInstanceKlass::ciInstanceKlass | |
44 // | |
45 // Loaded instance klass. | |
44
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
46 ciInstanceKlass::ciInstanceKlass(KlassHandle h_k) : |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
47 ciKlass(h_k), _non_static_fields(NULL) |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
48 { |
0 | 49 assert(get_Klass()->oop_is_instance(), "wrong type"); |
2244
4f26f535a225
6354181: nsk.logging.stress.threads.scmhml001 fails assertion in "src/share/vm/oops/instanceKlass.cpp, 111"
never
parents:
2177
diff
changeset
|
50 assert(get_instanceKlass()->is_loaded(), "must be at least loaded"); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
51 InstanceKlass* ik = get_instanceKlass(); |
0 | 52 |
53 AccessFlags access_flags = ik->access_flags(); | |
54 _flags = ciFlags(access_flags); | |
55 _has_finalizer = access_flags.has_finalizer(); | |
56 _has_subklass = ik->subklass() != NULL; | |
4739
52b5d32fbfaf
7117052: instanceKlass::_init_state can be u1 type
coleenp
parents:
3938
diff
changeset
|
57 _init_state = ik->init_state(); |
0 | 58 _nonstatic_field_size = ik->nonstatic_field_size(); |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
44
diff
changeset
|
59 _has_nonstatic_fields = ik->has_nonstatic_fields(); |
0 | 60 _nonstatic_fields = NULL; // initialized lazily by compute_nonstatic_fields: |
61 | |
5998
49036505ab5f
7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents:
4739
diff
changeset
|
62 _implementor = NULL; // we will fill these lazily |
0 | 63 |
64 Thread *thread = Thread::current(); | |
65 if (ciObjectFactory::is_initialized()) { | |
66 _loader = JNIHandles::make_local(thread, ik->class_loader()); | |
67 _protection_domain = JNIHandles::make_local(thread, | |
68 ik->protection_domain()); | |
69 _is_shared = false; | |
70 } else { | |
71 Handle h_loader(thread, ik->class_loader()); | |
72 Handle h_protection_domain(thread, ik->protection_domain()); | |
73 _loader = JNIHandles::make_global(h_loader); | |
74 _protection_domain = JNIHandles::make_global(h_protection_domain); | |
75 _is_shared = true; | |
76 } | |
77 | |
78 // Lazy fields get filled in only upon request. | |
79 _super = NULL; | |
80 _java_mirror = NULL; | |
81 | |
82 if (is_shared()) { | |
1142 | 83 if (h_k() != SystemDictionary::Object_klass()) { |
0 | 84 super(); |
85 } | |
86 //compute_nonstatic_fields(); // done outside of constructor | |
87 } | |
88 | |
89 _field_cache = NULL; | |
90 } | |
91 | |
92 // Version for unloaded classes: | |
93 ciInstanceKlass::ciInstanceKlass(ciSymbol* name, | |
94 jobject loader, jobject protection_domain) | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
95 : ciKlass(name, T_OBJECT) |
0 | 96 { |
97 assert(name->byte_at(0) != '[', "not an instance klass"); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
98 _init_state = (InstanceKlass::ClassState)0; |
0 | 99 _nonstatic_field_size = -1; |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
44
diff
changeset
|
100 _has_nonstatic_fields = false; |
0 | 101 _nonstatic_fields = NULL; |
102 _loader = loader; | |
103 _protection_domain = protection_domain; | |
104 _is_shared = false; | |
105 _super = NULL; | |
106 _java_mirror = NULL; | |
107 _field_cache = NULL; | |
108 } | |
109 | |
110 | |
111 | |
112 // ------------------------------------------------------------------ | |
113 // ciInstanceKlass::compute_shared_is_initialized | |
1645
3941674cc7fa
6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents:
1604
diff
changeset
|
114 void ciInstanceKlass::compute_shared_init_state() { |
0 | 115 GUARDED_VM_ENTRY( |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
116 InstanceKlass* ik = get_instanceKlass(); |
4739
52b5d32fbfaf
7117052: instanceKlass::_init_state can be u1 type
coleenp
parents:
3938
diff
changeset
|
117 _init_state = ik->init_state(); |
0 | 118 ) |
119 } | |
120 | |
121 // ------------------------------------------------------------------ | |
122 // ciInstanceKlass::compute_shared_has_subklass | |
123 bool ciInstanceKlass::compute_shared_has_subklass() { | |
124 GUARDED_VM_ENTRY( | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
125 InstanceKlass* ik = get_instanceKlass(); |
0 | 126 _has_subklass = ik->subklass() != NULL; |
127 return _has_subklass; | |
128 ) | |
129 } | |
130 | |
131 // ------------------------------------------------------------------ | |
132 // ciInstanceKlass::loader | |
133 oop ciInstanceKlass::loader() { | |
134 ASSERT_IN_VM; | |
135 return JNIHandles::resolve(_loader); | |
136 } | |
137 | |
138 // ------------------------------------------------------------------ | |
139 // ciInstanceKlass::loader_handle | |
140 jobject ciInstanceKlass::loader_handle() { | |
141 return _loader; | |
142 } | |
143 | |
144 // ------------------------------------------------------------------ | |
145 // ciInstanceKlass::protection_domain | |
146 oop ciInstanceKlass::protection_domain() { | |
147 ASSERT_IN_VM; | |
148 return JNIHandles::resolve(_protection_domain); | |
149 } | |
150 | |
151 // ------------------------------------------------------------------ | |
152 // ciInstanceKlass::protection_domain_handle | |
153 jobject ciInstanceKlass::protection_domain_handle() { | |
154 return _protection_domain; | |
155 } | |
156 | |
157 // ------------------------------------------------------------------ | |
158 // ciInstanceKlass::field_cache | |
159 // | |
160 // Get the field cache associated with this klass. | |
161 ciConstantPoolCache* ciInstanceKlass::field_cache() { | |
162 if (is_shared()) { | |
163 return NULL; | |
164 } | |
165 if (_field_cache == NULL) { | |
166 assert(!is_java_lang_Object(), "Object has no fields"); | |
167 Arena* arena = CURRENT_ENV->arena(); | |
168 _field_cache = new (arena) ciConstantPoolCache(arena, 5); | |
169 } | |
170 return _field_cache; | |
171 } | |
172 | |
173 // ------------------------------------------------------------------ | |
174 // ciInstanceKlass::get_canonical_holder | |
175 // | |
176 ciInstanceKlass* ciInstanceKlass::get_canonical_holder(int offset) { | |
177 #ifdef ASSERT | |
178 if (!(offset >= 0 && offset < layout_helper())) { | |
179 tty->print("*** get_canonical_holder(%d) on ", offset); | |
180 this->print(); | |
181 tty->print_cr(" ***"); | |
182 }; | |
183 assert(offset >= 0 && offset < layout_helper(), "offset must be tame"); | |
184 #endif | |
185 | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
44
diff
changeset
|
186 if (offset < instanceOopDesc::base_offset_in_bytes()) { |
0 | 187 // All header offsets belong properly to java/lang/Object. |
188 return CURRENT_ENV->Object_klass(); | |
189 } | |
190 | |
191 ciInstanceKlass* self = this; | |
192 for (;;) { | |
193 assert(self->is_loaded(), "must be loaded to have size"); | |
194 ciInstanceKlass* super = self->super(); | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
44
diff
changeset
|
195 if (super == NULL || super->nof_nonstatic_fields() == 0 || |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
44
diff
changeset
|
196 !super->contains_field_offset(offset)) { |
0 | 197 return self; |
198 } else { | |
199 self = super; // return super->get_canonical_holder(offset) | |
200 } | |
201 } | |
202 } | |
203 | |
204 // ------------------------------------------------------------------ | |
205 // ciInstanceKlass::is_java_lang_Object | |
206 // | |
207 // Is this klass java.lang.Object? | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
208 bool ciInstanceKlass::is_java_lang_Object() const { |
0 | 209 return equals(CURRENT_ENV->Object_klass()); |
210 } | |
211 | |
212 // ------------------------------------------------------------------ | |
213 // ciInstanceKlass::uses_default_loader | |
10278 | 214 bool ciInstanceKlass::uses_default_loader() const { |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
215 // Note: We do not need to resolve the handle or enter the VM |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
216 // in order to test null-ness. |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
217 return _loader == NULL; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
218 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
219 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
220 // ------------------------------------------------------------------ |
10278 | 221 |
222 /** | |
223 * Return basic type of boxed value for box klass or T_OBJECT if not. | |
224 */ | |
225 BasicType ciInstanceKlass::box_klass_type() const { | |
226 if (uses_default_loader() && is_loaded()) { | |
227 return SystemDictionary::box_klass_type(get_Klass()); | |
228 } else { | |
229 return T_OBJECT; | |
230 } | |
231 } | |
232 | |
233 /** | |
234 * Is this boxing klass? | |
235 */ | |
236 bool ciInstanceKlass::is_box_klass() const { | |
237 return is_java_primitive(box_klass_type()); | |
238 } | |
239 | |
240 /** | |
241 * Is this boxed value offset? | |
242 */ | |
243 bool ciInstanceKlass::is_boxed_value_offset(int offset) const { | |
244 BasicType bt = box_klass_type(); | |
245 return is_java_primitive(bt) && | |
246 (offset == java_lang_boxing_object::value_offset_in_bytes(bt)); | |
247 } | |
248 | |
249 // ------------------------------------------------------------------ | |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
250 // ciInstanceKlass::is_in_package |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
251 // |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
252 // Is this klass in the given package? |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
253 bool ciInstanceKlass::is_in_package(const char* packagename, int len) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
254 // To avoid class loader mischief, this test always rejects application classes. |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
255 if (!uses_default_loader()) |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
256 return false; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
257 GUARDED_VM_ENTRY( |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
258 return is_in_package_impl(packagename, len); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
259 ) |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
260 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
261 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
262 bool ciInstanceKlass::is_in_package_impl(const char* packagename, int len) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
263 ASSERT_IN_VM; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
264 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
265 // If packagename contains trailing '/' exclude it from the |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
266 // prefix-test since we test for it explicitly. |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
267 if (packagename[len - 1] == '/') |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
268 len--; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
269 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
270 if (!name()->starts_with(packagename, len)) |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
271 return false; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
272 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
273 // Test if the class name is something like "java/lang". |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
274 if ((len + 1) > name()->utf8_length()) |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
275 return false; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
276 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
277 // Test for trailing '/' |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
278 if ((char) name()->byte_at(len) != '/') |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
279 return false; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
280 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
281 // Make sure it's not actually in a subpackage: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
282 if (name()->index_of_at(len+1, "/", 1) >= 0) |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
283 return false; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
284 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
285 return true; |
0 | 286 } |
287 | |
288 // ------------------------------------------------------------------ | |
289 // ciInstanceKlass::print_impl | |
290 // | |
291 // Implementation of the print method. | |
292 void ciInstanceKlass::print_impl(outputStream* st) { | |
293 ciKlass::print_impl(st); | |
294 GUARDED_VM_ENTRY(st->print(" loader=0x%x", (address)loader());) | |
295 if (is_loaded()) { | |
296 st->print(" loaded=true initialized=%s finalized=%s subklass=%s size=%d flags=", | |
297 bool_to_str(is_initialized()), | |
298 bool_to_str(has_finalizer()), | |
299 bool_to_str(has_subklass()), | |
300 layout_helper()); | |
301 | |
302 _flags.print_klass_flags(); | |
303 | |
304 if (_super) { | |
305 st->print(" super="); | |
306 _super->print_name(); | |
307 } | |
308 if (_java_mirror) { | |
309 st->print(" mirror=PRESENT"); | |
310 } | |
311 } else { | |
312 st->print(" loaded=false"); | |
313 } | |
314 } | |
315 | |
316 // ------------------------------------------------------------------ | |
317 // ciInstanceKlass::super | |
318 // | |
319 // Get the superklass of this klass. | |
320 ciInstanceKlass* ciInstanceKlass::super() { | |
321 assert(is_loaded(), "must be loaded"); | |
322 if (_super == NULL && !is_java_lang_Object()) { | |
323 GUARDED_VM_ENTRY( | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
324 Klass* super_klass = get_instanceKlass()->super(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
325 _super = CURRENT_ENV->get_instance_klass(super_klass); |
0 | 326 ) |
327 } | |
328 return _super; | |
329 } | |
330 | |
331 // ------------------------------------------------------------------ | |
332 // ciInstanceKlass::java_mirror | |
333 // | |
334 // Get the instance of java.lang.Class corresponding to this klass. | |
1604
b918d354830a
6960865: ldc of unloaded class throws an assert in ciTypeFlow
jrose
parents:
1602
diff
changeset
|
335 // Cache it on this->_java_mirror. |
0 | 336 ciInstance* ciInstanceKlass::java_mirror() { |
2376
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2244
diff
changeset
|
337 if (is_shared()) { |
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2244
diff
changeset
|
338 return ciKlass::java_mirror(); |
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2244
diff
changeset
|
339 } |
0 | 340 if (_java_mirror == NULL) { |
1604
b918d354830a
6960865: ldc of unloaded class throws an assert in ciTypeFlow
jrose
parents:
1602
diff
changeset
|
341 _java_mirror = ciKlass::java_mirror(); |
0 | 342 } |
343 return _java_mirror; | |
344 } | |
345 | |
346 // ------------------------------------------------------------------ | |
347 // ciInstanceKlass::unique_concrete_subklass | |
348 ciInstanceKlass* ciInstanceKlass::unique_concrete_subklass() { | |
349 if (!is_loaded()) return NULL; // No change if class is not loaded | |
350 if (!is_abstract()) return NULL; // Only applies to abstract classes. | |
351 if (!has_subklass()) return NULL; // Must have at least one subklass. | |
352 VM_ENTRY_MARK; | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
353 InstanceKlass* ik = get_instanceKlass(); |
0 | 354 Klass* up = ik->up_cast_abstract(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
355 assert(up->oop_is_instance(), "must be InstanceKlass"); |
0 | 356 if (ik == up) { |
357 return NULL; | |
358 } | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
359 return CURRENT_THREAD_ENV->get_instance_klass(up); |
0 | 360 } |
361 | |
362 // ------------------------------------------------------------------ | |
363 // ciInstanceKlass::has_finalizable_subclass | |
364 bool ciInstanceKlass::has_finalizable_subclass() { | |
365 if (!is_loaded()) return true; | |
366 VM_ENTRY_MARK; | |
367 return Dependencies::find_finalizable_subclass(get_instanceKlass()) != NULL; | |
368 } | |
369 | |
370 // ------------------------------------------------------------------ | |
371 // ciInstanceKlass::get_field_by_offset | |
372 ciField* ciInstanceKlass::get_field_by_offset(int field_offset, bool is_static) { | |
373 if (!is_static) { | |
374 for (int i = 0, len = nof_nonstatic_fields(); i < len; i++) { | |
375 ciField* field = _nonstatic_fields->at(i); | |
376 int field_off = field->offset_in_bytes(); | |
377 if (field_off == field_offset) | |
378 return field; | |
379 if (field_off > field_offset) | |
380 break; | |
381 // could do binary search or check bins, but probably not worth it | |
382 } | |
383 return NULL; | |
384 } | |
385 VM_ENTRY_MARK; | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
386 InstanceKlass* k = get_instanceKlass(); |
0 | 387 fieldDescriptor fd; |
388 if (!k->find_field_from_offset(field_offset, is_static, &fd)) { | |
389 return NULL; | |
390 } | |
391 ciField* field = new (CURRENT_THREAD_ENV->arena()) ciField(&fd); | |
392 return field; | |
393 } | |
394 | |
44
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
395 // ------------------------------------------------------------------ |
1080
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
196
diff
changeset
|
396 // ciInstanceKlass::get_field_by_name |
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
196
diff
changeset
|
397 ciField* ciInstanceKlass::get_field_by_name(ciSymbol* name, ciSymbol* signature, bool is_static) { |
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
196
diff
changeset
|
398 VM_ENTRY_MARK; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
399 InstanceKlass* k = get_instanceKlass(); |
1080
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
196
diff
changeset
|
400 fieldDescriptor fd; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
401 Klass* def = k->find_field(name->get_symbol(), signature->get_symbol(), is_static, &fd); |
1080
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
196
diff
changeset
|
402 if (def == NULL) { |
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
196
diff
changeset
|
403 return NULL; |
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
196
diff
changeset
|
404 } |
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
196
diff
changeset
|
405 ciField* field = new (CURRENT_THREAD_ENV->arena()) ciField(&fd); |
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
196
diff
changeset
|
406 return field; |
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
196
diff
changeset
|
407 } |
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
196
diff
changeset
|
408 |
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
196
diff
changeset
|
409 // ------------------------------------------------------------------ |
44
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
410 // ciInstanceKlass::non_static_fields. |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
411 |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
412 class NonStaticFieldFiller: public FieldClosure { |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
413 GrowableArray<ciField*>* _arr; |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
414 ciEnv* _curEnv; |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
415 public: |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
416 NonStaticFieldFiller(ciEnv* curEnv, GrowableArray<ciField*>* arr) : |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
417 _curEnv(curEnv), _arr(arr) |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
418 {} |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
419 void do_field(fieldDescriptor* fd) { |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
420 ciField* field = new (_curEnv->arena()) ciField(fd); |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
421 _arr->append(field); |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
422 } |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
423 }; |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
424 |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
425 GrowableArray<ciField*>* ciInstanceKlass::non_static_fields() { |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
426 if (_non_static_fields == NULL) { |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
427 VM_ENTRY_MARK; |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
428 ciEnv* curEnv = ciEnv::current(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
429 InstanceKlass* ik = get_instanceKlass(); |
3938 | 430 int max_n_fields = ik->java_fields_count(); |
44
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
431 |
1685 | 432 Arena* arena = curEnv->arena(); |
44
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
433 _non_static_fields = |
1685 | 434 new (arena) GrowableArray<ciField*>(arena, max_n_fields, 0, NULL); |
44
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
435 NonStaticFieldFiller filler(curEnv, _non_static_fields); |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
436 ik->do_nonstatic_fields(&filler); |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
437 } |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
438 return _non_static_fields; |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
439 } |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
440 |
0 | 441 static int sort_field_by_offset(ciField** a, ciField** b) { |
442 return (*a)->offset_in_bytes() - (*b)->offset_in_bytes(); | |
443 // (no worries about 32-bit overflow...) | |
444 } | |
445 | |
446 // ------------------------------------------------------------------ | |
447 // ciInstanceKlass::compute_nonstatic_fields | |
448 int ciInstanceKlass::compute_nonstatic_fields() { | |
449 assert(is_loaded(), "must be loaded"); | |
450 | |
451 if (_nonstatic_fields != NULL) | |
452 return _nonstatic_fields->length(); | |
453 | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
44
diff
changeset
|
454 if (!has_nonstatic_fields()) { |
0 | 455 Arena* arena = CURRENT_ENV->arena(); |
456 _nonstatic_fields = new (arena) GrowableArray<ciField*>(arena, 0, 0, NULL); | |
457 return 0; | |
458 } | |
459 assert(!is_java_lang_Object(), "bootstrap OK"); | |
460 | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
44
diff
changeset
|
461 // Size in bytes of my fields, including inherited fields. |
165
437d03ea40b1
6703888: Compressed Oops: use the 32-bits gap after klass in a object
kvn
parents:
113
diff
changeset
|
462 int fsize = nonstatic_field_size() * heapOopSize; |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
44
diff
changeset
|
463 |
0 | 464 ciInstanceKlass* super = this->super(); |
465 GrowableArray<ciField*>* super_fields = NULL; | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
44
diff
changeset
|
466 if (super != NULL && super->has_nonstatic_fields()) { |
165
437d03ea40b1
6703888: Compressed Oops: use the 32-bits gap after klass in a object
kvn
parents:
113
diff
changeset
|
467 int super_fsize = super->nonstatic_field_size() * heapOopSize; |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
44
diff
changeset
|
468 int super_flen = super->nof_nonstatic_fields(); |
0 | 469 super_fields = super->_nonstatic_fields; |
470 assert(super_flen == 0 || super_fields != NULL, "first get nof_fields"); | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
44
diff
changeset
|
471 // See if I am no larger than my super; if so, I can use his fields. |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
44
diff
changeset
|
472 if (fsize == super_fsize) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
44
diff
changeset
|
473 _nonstatic_fields = super_fields; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
44
diff
changeset
|
474 return super_fields->length(); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
44
diff
changeset
|
475 } |
0 | 476 } |
477 | |
478 GrowableArray<ciField*>* fields = NULL; | |
479 GUARDED_VM_ENTRY({ | |
480 fields = compute_nonstatic_fields_impl(super_fields); | |
481 }); | |
482 | |
483 if (fields == NULL) { | |
484 // This can happen if this class (java.lang.Class) has invisible fields. | |
485 _nonstatic_fields = super_fields; | |
486 return super_fields->length(); | |
487 } | |
488 | |
489 int flen = fields->length(); | |
490 | |
491 // Now sort them by offset, ascending. | |
492 // (In principle, they could mix with superclass fields.) | |
493 fields->sort(sort_field_by_offset); | |
494 _nonstatic_fields = fields; | |
495 return flen; | |
496 } | |
497 | |
498 GrowableArray<ciField*>* | |
499 ciInstanceKlass::compute_nonstatic_fields_impl(GrowableArray<ciField*>* | |
500 super_fields) { | |
501 ASSERT_IN_VM; | |
502 Arena* arena = CURRENT_ENV->arena(); | |
503 int flen = 0; | |
504 GrowableArray<ciField*>* fields = NULL; | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
505 InstanceKlass* k = get_instanceKlass(); |
3938 | 506 for (JavaFieldStream fs(k); !fs.done(); fs.next()) { |
507 if (fs.access_flags().is_static()) continue; | |
508 flen += 1; | |
509 } | |
0 | 510 |
3938 | 511 // allocate the array: |
512 if (flen == 0) { | |
513 return NULL; // return nothing if none are locally declared | |
514 } | |
515 if (super_fields != NULL) { | |
516 flen += super_fields->length(); | |
517 } | |
518 fields = new (arena) GrowableArray<ciField*>(arena, flen, 0, NULL); | |
519 if (super_fields != NULL) { | |
520 fields->appendAll(super_fields); | |
521 } | |
522 | |
523 for (JavaFieldStream fs(k); !fs.done(); fs.next()) { | |
524 if (fs.access_flags().is_static()) continue; | |
525 fieldDescriptor fd; | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
526 fd.initialize(k, fs.index()); |
3938 | 527 ciField* field = new (arena) ciField(&fd); |
528 fields->append(field); | |
0 | 529 } |
530 assert(fields->length() == flen, "sanity"); | |
531 return fields; | |
532 } | |
533 | |
534 // ------------------------------------------------------------------ | |
535 // ciInstanceKlass::find_method | |
536 // | |
537 // Find a method in this klass. | |
538 ciMethod* ciInstanceKlass::find_method(ciSymbol* name, ciSymbol* signature) { | |
539 VM_ENTRY_MARK; | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
540 InstanceKlass* k = get_instanceKlass(); |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
541 Symbol* name_sym = name->get_symbol(); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
542 Symbol* sig_sym= signature->get_symbol(); |
0 | 543 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
544 Method* m = k->find_method(name_sym, sig_sym); |
0 | 545 if (m == NULL) return NULL; |
546 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
547 return CURRENT_THREAD_ENV->get_method(m); |
0 | 548 } |
549 | |
550 // ------------------------------------------------------------------ | |
551 // ciInstanceKlass::is_leaf_type | |
552 bool ciInstanceKlass::is_leaf_type() { | |
553 assert(is_loaded(), "must be loaded"); | |
554 if (is_shared()) { | |
555 return is_final(); // approximately correct | |
556 } else { | |
5998
49036505ab5f
7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents:
4739
diff
changeset
|
557 return !_has_subklass && (nof_implementors() == 0); |
0 | 558 } |
559 } | |
560 | |
561 // ------------------------------------------------------------------ | |
562 // ciInstanceKlass::implementor | |
563 // | |
564 // Report an implementor of this interface. | |
565 // Note that there are various races here, since my copy | |
566 // of _nof_implementors might be out of date with respect | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
567 // to results returned by InstanceKlass::implementor. |
0 | 568 // This is OK, since any dependencies we decide to assert |
569 // will be checked later under the Compile_lock. | |
5998
49036505ab5f
7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents:
4739
diff
changeset
|
570 ciInstanceKlass* ciInstanceKlass::implementor() { |
49036505ab5f
7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents:
4739
diff
changeset
|
571 ciInstanceKlass* impl = _implementor; |
0 | 572 if (impl == NULL) { |
573 // Go into the VM to fetch the implementor. | |
574 { | |
575 VM_ENTRY_MARK; | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
576 Klass* k = get_instanceKlass()->implementor(); |
0 | 577 if (k != NULL) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
578 if (k == get_instanceKlass()) { |
5998
49036505ab5f
7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents:
4739
diff
changeset
|
579 // More than one implementors. Use 'this' in this case. |
49036505ab5f
7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents:
4739
diff
changeset
|
580 impl = this; |
49036505ab5f
7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents:
4739
diff
changeset
|
581 } else { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
582 impl = CURRENT_THREAD_ENV->get_instance_klass(k); |
5998
49036505ab5f
7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents:
4739
diff
changeset
|
583 } |
0 | 584 } |
585 } | |
586 // Memoize this result. | |
587 if (!is_shared()) { | |
5998
49036505ab5f
7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents:
4739
diff
changeset
|
588 _implementor = impl; |
0 | 589 } |
590 } | |
591 return impl; | |
592 } | |
6972
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
593 |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
594 // Utility class for printing of the contents of the static fields for |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
595 // use by compilation replay. It only prints out the information that |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
596 // could be consumed by the compiler, so for primitive types it prints |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
597 // out the actual value. For Strings it's the actual string value. |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
598 // For array types it it's first level array size since that's the |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
599 // only value which statically unchangeable. For all other reference |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
600 // types it simply prints out the dynamic type. |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
601 |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
602 class StaticFinalFieldPrinter : public FieldClosure { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
603 outputStream* _out; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
604 const char* _holder; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
605 public: |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
606 StaticFinalFieldPrinter(outputStream* out, const char* holder) : |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
607 _out(out), |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
608 _holder(holder) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
609 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
610 void do_field(fieldDescriptor* fd) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
611 if (fd->is_final() && !fd->has_initial_value()) { |
7990
fcc9e7681d63
8006410: allocating without ResourceMark when CompileCommand was specified
vlivanov
parents:
6972
diff
changeset
|
612 ResourceMark rm; |
6972
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
613 oop mirror = fd->field_holder()->java_mirror(); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
614 _out->print("staticfield %s %s %s ", _holder, fd->name()->as_quoted_ascii(), fd->signature()->as_quoted_ascii()); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
615 switch (fd->field_type()) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
616 case T_BYTE: _out->print_cr("%d", mirror->byte_field(fd->offset())); break; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
617 case T_BOOLEAN: _out->print_cr("%d", mirror->bool_field(fd->offset())); break; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
618 case T_SHORT: _out->print_cr("%d", mirror->short_field(fd->offset())); break; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
619 case T_CHAR: _out->print_cr("%d", mirror->char_field(fd->offset())); break; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
620 case T_INT: _out->print_cr("%d", mirror->int_field(fd->offset())); break; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
621 case T_LONG: _out->print_cr(INT64_FORMAT, mirror->long_field(fd->offset())); break; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
622 case T_FLOAT: { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
623 float f = mirror->float_field(fd->offset()); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
624 _out->print_cr("%d", *(int*)&f); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
625 break; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
626 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
627 case T_DOUBLE: { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
628 double d = mirror->double_field(fd->offset()); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
629 _out->print_cr(INT64_FORMAT, *(jlong*)&d); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
630 break; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
631 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
632 case T_ARRAY: { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
633 oop value = mirror->obj_field_acquire(fd->offset()); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
634 if (value == NULL) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
635 _out->print_cr("null"); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
636 } else { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
637 typeArrayOop ta = (typeArrayOop)value; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
638 _out->print("%d", ta->length()); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
639 if (value->is_objArray()) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
640 objArrayOop oa = (objArrayOop)value; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
641 const char* klass_name = value->klass()->name()->as_quoted_ascii(); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
642 _out->print(" %s", klass_name); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
643 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
644 _out->cr(); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
645 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
646 break; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
647 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
648 case T_OBJECT: { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
649 oop value = mirror->obj_field_acquire(fd->offset()); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
650 if (value == NULL) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
651 _out->print_cr("null"); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
652 } else if (value->is_instance()) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
653 if (value->is_a(SystemDictionary::String_klass())) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
654 _out->print("\""); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
655 _out->print_raw(java_lang_String::as_quoted_ascii(value)); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
656 _out->print_cr("\""); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
657 } else { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
658 const char* klass_name = value->klass()->name()->as_quoted_ascii(); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
659 _out->print_cr(klass_name); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
660 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
661 } else { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
662 ShouldNotReachHere(); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
663 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
664 break; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
665 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
666 default: |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
667 ShouldNotReachHere(); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
668 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
669 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
670 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
671 }; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
672 |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
673 |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
674 void ciInstanceKlass::dump_replay_data(outputStream* out) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
675 ASSERT_IN_VM; |
7990
fcc9e7681d63
8006410: allocating without ResourceMark when CompileCommand was specified
vlivanov
parents:
6972
diff
changeset
|
676 ResourceMark rm; |
fcc9e7681d63
8006410: allocating without ResourceMark when CompileCommand was specified
vlivanov
parents:
6972
diff
changeset
|
677 |
6972
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
678 InstanceKlass* ik = get_instanceKlass(); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
679 ConstantPool* cp = ik->constants(); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
680 |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
681 // Try to record related loaded classes |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
682 Klass* sub = ik->subklass(); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
683 while (sub != NULL) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
684 if (sub->oop_is_instance()) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
685 out->print_cr("instanceKlass %s", sub->name()->as_quoted_ascii()); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
686 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
687 sub = sub->next_sibling(); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
688 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
689 |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
690 // Dump out the state of the constant pool tags. During replay the |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
691 // tags will be validated for things which shouldn't change and |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
692 // classes will be resolved if the tags indicate that they were |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
693 // resolved at compile time. |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
694 out->print("ciInstanceKlass %s %d %d %d", ik->name()->as_quoted_ascii(), |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
695 is_linked(), is_initialized(), cp->length()); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
696 for (int index = 1; index < cp->length(); index++) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
697 out->print(" %d", cp->tags()->at(index)); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
698 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
699 out->cr(); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
700 if (is_initialized()) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
701 // Dump out the static final fields in case the compilation relies |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
702 // on their value for correct replay. |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
703 StaticFinalFieldPrinter sffp(out, ik->name()->as_quoted_ascii()); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
704 ik->do_local_static_fields(&sffp); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
705 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
706 } |