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