Mercurial > hg > truffle
annotate src/share/vm/ci/ciInstanceKlass.cpp @ 20543:e7d0505c8a30
8059758: Footprint regressions with JDK-8038423
Summary: Changes in JDK-8038423 always initialize (zero out) virtual memory used for auxiliary data structures. This causes a footprint regression for G1 in startup benchmarks. This is because they do not touch that memory at all, so the operating system does not actually commit these pages. The fix is to, if the initialization value of the data structures matches the default value of just committed memory (=0), do not do anything.
Reviewed-by: jwilhelm, brutisso
author | tschatzl |
---|---|
date | Fri, 10 Oct 2014 15:51:58 +0200 |
parents | 78bbf4d43a14 |
children | 52b4284cb496 |
rev | line source |
---|---|
0 | 1 /* |
17937
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
13021
diff
changeset
|
2 * Copyright (c) 1999, 2014, 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(); |
0 | 61 _nonstatic_fields = NULL; // initialized lazily by compute_nonstatic_fields: |
62 | |
5998
49036505ab5f
7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents:
4739
diff
changeset
|
63 _implementor = NULL; // we will fill these lazily |
0 | 64 |
65 Thread *thread = Thread::current(); | |
66 if (ciObjectFactory::is_initialized()) { | |
67 _loader = JNIHandles::make_local(thread, ik->class_loader()); | |
68 _protection_domain = JNIHandles::make_local(thread, | |
69 ik->protection_domain()); | |
70 _is_shared = false; | |
71 } else { | |
72 Handle h_loader(thread, ik->class_loader()); | |
73 Handle h_protection_domain(thread, ik->protection_domain()); | |
74 _loader = JNIHandles::make_global(h_loader); | |
75 _protection_domain = JNIHandles::make_global(h_protection_domain); | |
76 _is_shared = true; | |
77 } | |
78 | |
79 // Lazy fields get filled in only upon request. | |
80 _super = NULL; | |
81 _java_mirror = NULL; | |
82 | |
83 if (is_shared()) { | |
1142 | 84 if (h_k() != SystemDictionary::Object_klass()) { |
0 | 85 super(); |
86 } | |
87 //compute_nonstatic_fields(); // done outside of constructor | |
88 } | |
89 | |
90 _field_cache = NULL; | |
91 } | |
92 | |
93 // Version for unloaded classes: | |
94 ciInstanceKlass::ciInstanceKlass(ciSymbol* name, | |
95 jobject loader, jobject protection_domain) | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
96 : ciKlass(name, T_OBJECT) |
0 | 97 { |
98 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
|
99 _init_state = (InstanceKlass::ClassState)0; |
0 | 100 _nonstatic_field_size = -1; |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
44
diff
changeset
|
101 _has_nonstatic_fields = false; |
0 | 102 _nonstatic_fields = NULL; |
103 _loader = loader; | |
104 _protection_domain = protection_domain; | |
105 _is_shared = false; | |
106 _super = NULL; | |
107 _java_mirror = NULL; | |
108 _field_cache = NULL; | |
109 } | |
110 | |
111 | |
112 | |
113 // ------------------------------------------------------------------ | |
114 // ciInstanceKlass::compute_shared_is_initialized | |
1645
3941674cc7fa
6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents:
1604
diff
changeset
|
115 void ciInstanceKlass::compute_shared_init_state() { |
0 | 116 GUARDED_VM_ENTRY( |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
117 InstanceKlass* ik = get_instanceKlass(); |
4739
52b5d32fbfaf
7117052: instanceKlass::_init_state can be u1 type
coleenp
parents:
3938
diff
changeset
|
118 _init_state = ik->init_state(); |
0 | 119 ) |
120 } | |
121 | |
122 // ------------------------------------------------------------------ | |
123 // ciInstanceKlass::compute_shared_has_subklass | |
124 bool ciInstanceKlass::compute_shared_has_subklass() { | |
125 GUARDED_VM_ENTRY( | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
126 InstanceKlass* ik = get_instanceKlass(); |
0 | 127 _has_subklass = ik->subklass() != NULL; |
128 return _has_subklass; | |
129 ) | |
130 } | |
131 | |
132 // ------------------------------------------------------------------ | |
133 // ciInstanceKlass::loader | |
134 oop ciInstanceKlass::loader() { | |
135 ASSERT_IN_VM; | |
136 return JNIHandles::resolve(_loader); | |
137 } | |
138 | |
139 // ------------------------------------------------------------------ | |
140 // ciInstanceKlass::loader_handle | |
141 jobject ciInstanceKlass::loader_handle() { | |
142 return _loader; | |
143 } | |
144 | |
145 // ------------------------------------------------------------------ | |
146 // ciInstanceKlass::protection_domain | |
147 oop ciInstanceKlass::protection_domain() { | |
148 ASSERT_IN_VM; | |
149 return JNIHandles::resolve(_protection_domain); | |
150 } | |
151 | |
152 // ------------------------------------------------------------------ | |
153 // ciInstanceKlass::protection_domain_handle | |
154 jobject ciInstanceKlass::protection_domain_handle() { | |
155 return _protection_domain; | |
156 } | |
157 | |
158 // ------------------------------------------------------------------ | |
159 // ciInstanceKlass::field_cache | |
160 // | |
161 // Get the field cache associated with this klass. | |
162 ciConstantPoolCache* ciInstanceKlass::field_cache() { | |
163 if (is_shared()) { | |
164 return NULL; | |
165 } | |
166 if (_field_cache == NULL) { | |
167 assert(!is_java_lang_Object(), "Object has no fields"); | |
168 Arena* arena = CURRENT_ENV->arena(); | |
169 _field_cache = new (arena) ciConstantPoolCache(arena, 5); | |
170 } | |
171 return _field_cache; | |
172 } | |
173 | |
174 // ------------------------------------------------------------------ | |
175 // ciInstanceKlass::get_canonical_holder | |
176 // | |
177 ciInstanceKlass* ciInstanceKlass::get_canonical_holder(int offset) { | |
178 #ifdef ASSERT | |
179 if (!(offset >= 0 && offset < layout_helper())) { | |
180 tty->print("*** get_canonical_holder(%d) on ", offset); | |
181 this->print(); | |
182 tty->print_cr(" ***"); | |
183 }; | |
184 assert(offset >= 0 && offset < layout_helper(), "offset must be tame"); | |
185 #endif | |
186 | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
44
diff
changeset
|
187 if (offset < instanceOopDesc::base_offset_in_bytes()) { |
0 | 188 // All header offsets belong properly to java/lang/Object. |
189 return CURRENT_ENV->Object_klass(); | |
190 } | |
191 | |
192 ciInstanceKlass* self = this; | |
193 for (;;) { | |
194 assert(self->is_loaded(), "must be loaded to have size"); | |
195 ciInstanceKlass* super = self->super(); | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
44
diff
changeset
|
196 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
|
197 !super->contains_field_offset(offset)) { |
0 | 198 return self; |
199 } else { | |
200 self = super; // return super->get_canonical_holder(offset) | |
201 } | |
202 } | |
203 } | |
204 | |
205 // ------------------------------------------------------------------ | |
206 // ciInstanceKlass::is_java_lang_Object | |
207 // | |
208 // Is this klass java.lang.Object? | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
209 bool ciInstanceKlass::is_java_lang_Object() const { |
0 | 210 return equals(CURRENT_ENV->Object_klass()); |
211 } | |
212 | |
213 // ------------------------------------------------------------------ | |
214 // ciInstanceKlass::uses_default_loader | |
10278 | 215 bool ciInstanceKlass::uses_default_loader() const { |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
216 // 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
|
217 // in order to test null-ness. |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
218 return _loader == NULL; |
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 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
221 // ------------------------------------------------------------------ |
10278 | 222 |
223 /** | |
224 * Return basic type of boxed value for box klass or T_OBJECT if not. | |
225 */ | |
226 BasicType ciInstanceKlass::box_klass_type() const { | |
227 if (uses_default_loader() && is_loaded()) { | |
228 return SystemDictionary::box_klass_type(get_Klass()); | |
229 } else { | |
230 return T_OBJECT; | |
231 } | |
232 } | |
233 | |
234 /** | |
235 * Is this boxing klass? | |
236 */ | |
237 bool ciInstanceKlass::is_box_klass() const { | |
238 return is_java_primitive(box_klass_type()); | |
239 } | |
240 | |
241 /** | |
242 * Is this boxed value offset? | |
243 */ | |
244 bool ciInstanceKlass::is_boxed_value_offset(int offset) const { | |
245 BasicType bt = box_klass_type(); | |
246 return is_java_primitive(bt) && | |
247 (offset == java_lang_boxing_object::value_offset_in_bytes(bt)); | |
248 } | |
249 | |
250 // ------------------------------------------------------------------ | |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
251 // ciInstanceKlass::is_in_package |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
252 // |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
253 // Is this klass in the given package? |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
254 bool ciInstanceKlass::is_in_package(const char* packagename, int len) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
255 // 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
|
256 if (!uses_default_loader()) |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
257 return false; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
258 GUARDED_VM_ENTRY( |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
259 return is_in_package_impl(packagename, len); |
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 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
263 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
|
264 ASSERT_IN_VM; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
265 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
266 // If packagename contains trailing '/' exclude it from the |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
267 // prefix-test since we test for it explicitly. |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
268 if (packagename[len - 1] == '/') |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
269 len--; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
270 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
271 if (!name()->starts_with(packagename, len)) |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
272 return false; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
273 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
274 // Test if the class name is something like "java/lang". |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
275 if ((len + 1) > name()->utf8_length()) |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
276 return false; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
277 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
278 // Test for trailing '/' |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
279 if ((char) name()->byte_at(len) != '/') |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
280 return false; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
281 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
282 // Make sure it's not actually in a subpackage: |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
283 if (name()->index_of_at(len+1, "/", 1) >= 0) |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
284 return false; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
285 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
286 return true; |
0 | 287 } |
288 | |
289 // ------------------------------------------------------------------ | |
290 // ciInstanceKlass::print_impl | |
291 // | |
292 // Implementation of the print method. | |
293 void ciInstanceKlass::print_impl(outputStream* st) { | |
294 ciKlass::print_impl(st); | |
17937
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
13021
diff
changeset
|
295 GUARDED_VM_ENTRY(st->print(" loader=" INTPTR_FORMAT, p2i((address)loader()));) |
0 | 296 if (is_loaded()) { |
297 st->print(" loaded=true initialized=%s finalized=%s subklass=%s size=%d flags=", | |
298 bool_to_str(is_initialized()), | |
299 bool_to_str(has_finalizer()), | |
300 bool_to_str(has_subklass()), | |
301 layout_helper()); | |
302 | |
303 _flags.print_klass_flags(); | |
304 | |
305 if (_super) { | |
306 st->print(" super="); | |
307 _super->print_name(); | |
308 } | |
309 if (_java_mirror) { | |
310 st->print(" mirror=PRESENT"); | |
311 } | |
312 } else { | |
313 st->print(" loaded=false"); | |
314 } | |
315 } | |
316 | |
317 // ------------------------------------------------------------------ | |
318 // ciInstanceKlass::super | |
319 // | |
320 // Get the superklass of this klass. | |
321 ciInstanceKlass* ciInstanceKlass::super() { | |
322 assert(is_loaded(), "must be loaded"); | |
323 if (_super == NULL && !is_java_lang_Object()) { | |
324 GUARDED_VM_ENTRY( | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
325 Klass* super_klass = get_instanceKlass()->super(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
326 _super = CURRENT_ENV->get_instance_klass(super_klass); |
0 | 327 ) |
328 } | |
329 return _super; | |
330 } | |
331 | |
332 // ------------------------------------------------------------------ | |
333 // ciInstanceKlass::java_mirror | |
334 // | |
335 // 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
|
336 // Cache it on this->_java_mirror. |
0 | 337 ciInstance* ciInstanceKlass::java_mirror() { |
2376
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2244
diff
changeset
|
338 if (is_shared()) { |
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2244
diff
changeset
|
339 return ciKlass::java_mirror(); |
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2244
diff
changeset
|
340 } |
0 | 341 if (_java_mirror == NULL) { |
1604
b918d354830a
6960865: ldc of unloaded class throws an assert in ciTypeFlow
jrose
parents:
1602
diff
changeset
|
342 _java_mirror = ciKlass::java_mirror(); |
0 | 343 } |
344 return _java_mirror; | |
345 } | |
346 | |
347 // ------------------------------------------------------------------ | |
348 // ciInstanceKlass::unique_concrete_subklass | |
349 ciInstanceKlass* ciInstanceKlass::unique_concrete_subklass() { | |
350 if (!is_loaded()) return NULL; // No change if class is not loaded | |
351 if (!is_abstract()) return NULL; // Only applies to abstract classes. | |
352 if (!has_subklass()) return NULL; // Must have at least one subklass. | |
353 VM_ENTRY_MARK; | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
354 InstanceKlass* ik = get_instanceKlass(); |
0 | 355 Klass* up = ik->up_cast_abstract(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
356 assert(up->oop_is_instance(), "must be InstanceKlass"); |
0 | 357 if (ik == up) { |
358 return NULL; | |
359 } | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
360 return CURRENT_THREAD_ENV->get_instance_klass(up); |
0 | 361 } |
362 | |
363 // ------------------------------------------------------------------ | |
364 // ciInstanceKlass::has_finalizable_subclass | |
365 bool ciInstanceKlass::has_finalizable_subclass() { | |
366 if (!is_loaded()) return true; | |
367 VM_ENTRY_MARK; | |
368 return Dependencies::find_finalizable_subclass(get_instanceKlass()) != NULL; | |
369 } | |
370 | |
371 // ------------------------------------------------------------------ | |
372 // ciInstanceKlass::get_field_by_offset | |
373 ciField* ciInstanceKlass::get_field_by_offset(int field_offset, bool is_static) { | |
374 if (!is_static) { | |
375 for (int i = 0, len = nof_nonstatic_fields(); i < len; i++) { | |
376 ciField* field = _nonstatic_fields->at(i); | |
377 int field_off = field->offset_in_bytes(); | |
378 if (field_off == field_offset) | |
379 return field; | |
380 if (field_off > field_offset) | |
381 break; | |
382 // could do binary search or check bins, but probably not worth it | |
383 } | |
384 return NULL; | |
385 } | |
386 VM_ENTRY_MARK; | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
387 InstanceKlass* k = get_instanceKlass(); |
0 | 388 fieldDescriptor fd; |
389 if (!k->find_field_from_offset(field_offset, is_static, &fd)) { | |
390 return NULL; | |
391 } | |
392 ciField* field = new (CURRENT_THREAD_ENV->arena()) ciField(&fd); | |
393 return field; | |
394 } | |
395 | |
44
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
396 // ------------------------------------------------------------------ |
1080
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
196
diff
changeset
|
397 // ciInstanceKlass::get_field_by_name |
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
196
diff
changeset
|
398 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
|
399 VM_ENTRY_MARK; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
400 InstanceKlass* k = get_instanceKlass(); |
1080
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
196
diff
changeset
|
401 fieldDescriptor fd; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
402 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
|
403 if (def == NULL) { |
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
196
diff
changeset
|
404 return NULL; |
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
196
diff
changeset
|
405 } |
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
196
diff
changeset
|
406 ciField* field = new (CURRENT_THREAD_ENV->arena()) ciField(&fd); |
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
196
diff
changeset
|
407 return field; |
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 |
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
196
diff
changeset
|
410 // ------------------------------------------------------------------ |
44
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
411 // ciInstanceKlass::non_static_fields. |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
412 |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
413 class NonStaticFieldFiller: public FieldClosure { |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
414 GrowableArray<ciField*>* _arr; |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
415 ciEnv* _curEnv; |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
416 public: |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
417 NonStaticFieldFiller(ciEnv* curEnv, GrowableArray<ciField*>* arr) : |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
418 _curEnv(curEnv), _arr(arr) |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
419 {} |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
420 void do_field(fieldDescriptor* fd) { |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
421 ciField* field = new (_curEnv->arena()) ciField(fd); |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
422 _arr->append(field); |
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 |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
426 GrowableArray<ciField*>* ciInstanceKlass::non_static_fields() { |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
427 if (_non_static_fields == NULL) { |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
428 VM_ENTRY_MARK; |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
429 ciEnv* curEnv = ciEnv::current(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
430 InstanceKlass* ik = get_instanceKlass(); |
3938 | 431 int max_n_fields = ik->java_fields_count(); |
44
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
432 |
1685 | 433 Arena* arena = curEnv->arena(); |
44
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
434 _non_static_fields = |
1685 | 435 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
|
436 NonStaticFieldFiller filler(curEnv, _non_static_fields); |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
437 ik->do_nonstatic_fields(&filler); |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
438 } |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
439 return _non_static_fields; |
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 |
0 | 442 static int sort_field_by_offset(ciField** a, ciField** b) { |
443 return (*a)->offset_in_bytes() - (*b)->offset_in_bytes(); | |
444 // (no worries about 32-bit overflow...) | |
445 } | |
446 | |
447 // ------------------------------------------------------------------ | |
448 // ciInstanceKlass::compute_nonstatic_fields | |
449 int ciInstanceKlass::compute_nonstatic_fields() { | |
450 assert(is_loaded(), "must be loaded"); | |
451 | |
452 if (_nonstatic_fields != NULL) | |
453 return _nonstatic_fields->length(); | |
454 | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
44
diff
changeset
|
455 if (!has_nonstatic_fields()) { |
0 | 456 Arena* arena = CURRENT_ENV->arena(); |
457 _nonstatic_fields = new (arena) GrowableArray<ciField*>(arena, 0, 0, NULL); | |
458 return 0; | |
459 } | |
460 assert(!is_java_lang_Object(), "bootstrap OK"); | |
461 | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
44
diff
changeset
|
462 // 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
|
463 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
|
464 |
0 | 465 ciInstanceKlass* super = this->super(); |
466 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
|
467 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
|
468 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
|
469 int super_flen = super->nof_nonstatic_fields(); |
0 | 470 super_fields = super->_nonstatic_fields; |
471 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
|
472 // 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
|
473 if (fsize == super_fsize) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
44
diff
changeset
|
474 _nonstatic_fields = super_fields; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
44
diff
changeset
|
475 return super_fields->length(); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
44
diff
changeset
|
476 } |
0 | 477 } |
478 | |
479 GrowableArray<ciField*>* fields = NULL; | |
480 GUARDED_VM_ENTRY({ | |
481 fields = compute_nonstatic_fields_impl(super_fields); | |
482 }); | |
483 | |
484 if (fields == NULL) { | |
485 // This can happen if this class (java.lang.Class) has invisible fields. | |
486 _nonstatic_fields = super_fields; | |
487 return super_fields->length(); | |
488 } | |
489 | |
490 int flen = fields->length(); | |
491 | |
492 // Now sort them by offset, ascending. | |
493 // (In principle, they could mix with superclass fields.) | |
494 fields->sort(sort_field_by_offset); | |
495 _nonstatic_fields = fields; | |
496 return flen; | |
497 } | |
498 | |
499 GrowableArray<ciField*>* | |
500 ciInstanceKlass::compute_nonstatic_fields_impl(GrowableArray<ciField*>* | |
501 super_fields) { | |
502 ASSERT_IN_VM; | |
503 Arena* arena = CURRENT_ENV->arena(); | |
504 int flen = 0; | |
505 GrowableArray<ciField*>* fields = NULL; | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
506 InstanceKlass* k = get_instanceKlass(); |
3938 | 507 for (JavaFieldStream fs(k); !fs.done(); fs.next()) { |
508 if (fs.access_flags().is_static()) continue; | |
509 flen += 1; | |
510 } | |
0 | 511 |
3938 | 512 // allocate the array: |
513 if (flen == 0) { | |
514 return NULL; // return nothing if none are locally declared | |
515 } | |
516 if (super_fields != NULL) { | |
517 flen += super_fields->length(); | |
518 } | |
519 fields = new (arena) GrowableArray<ciField*>(arena, flen, 0, NULL); | |
520 if (super_fields != NULL) { | |
521 fields->appendAll(super_fields); | |
522 } | |
523 | |
524 for (JavaFieldStream fs(k); !fs.done(); fs.next()) { | |
525 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
|
526 fieldDescriptor& fd = fs.field_descriptor(); |
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; |
17937
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
13021
diff
changeset
|
621 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
|
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()); |
17937
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
13021
diff
changeset
|
629 _out->print_cr(INT64_FORMAT, *(int64_t*)&d); |
6972
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(); |
17937
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
13021
diff
changeset
|
659 _out->print_cr("%s", klass_name); |
6972
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) { |
7990
fcc9e7681d63
8006410: allocating without ResourceMark when CompileCommand was specified
vlivanov
parents:
6972
diff
changeset
|
675 ResourceMark rm; |
fcc9e7681d63
8006410: allocating without ResourceMark when CompileCommand was specified
vlivanov
parents:
6972
diff
changeset
|
676 |
6972
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
677 InstanceKlass* ik = get_instanceKlass(); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
678 ConstantPool* cp = ik->constants(); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
679 |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
680 // Try to record related loaded classes |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
681 Klass* sub = ik->subklass(); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
682 while (sub != NULL) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
683 if (sub->oop_is_instance()) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
684 out->print_cr("instanceKlass %s", sub->name()->as_quoted_ascii()); |
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 sub = sub->next_sibling(); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
687 } |
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 // 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
|
690 // 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
|
691 // 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
|
692 // resolved at compile time. |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
693 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
|
694 is_linked(), is_initialized(), cp->length()); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
695 for (int index = 1; index < cp->length(); index++) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
696 out->print(" %d", cp->tags()->at(index)); |
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 out->cr(); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
699 if (is_initialized()) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
700 // 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
|
701 // on their value for correct replay. |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
702 StaticFinalFieldPrinter sffp(out, ik->name()->as_quoted_ascii()); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
703 ik->do_local_static_fields(&sffp); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
704 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
705 } |