Wed, 03 Jul 2019 20:42:37 +0800
Merge
1 /*
2 * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
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 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
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"
34 #include "oops/fieldStreams.hpp"
35 #include "runtime/fieldDescriptor.hpp"
37 // ciInstanceKlass
38 //
39 // This class represents a Klass* in the HotSpot virtual machine
40 // whose Klass part in an InstanceKlass.
42 // ------------------------------------------------------------------
43 // ciInstanceKlass::ciInstanceKlass
44 //
45 // Loaded instance klass.
46 ciInstanceKlass::ciInstanceKlass(KlassHandle h_k) :
47 ciKlass(h_k), _non_static_fields(NULL)
48 {
49 assert(get_Klass()->oop_is_instance(), "wrong type");
50 assert(get_instanceKlass()->is_loaded(), "must be at least loaded");
51 InstanceKlass* ik = get_instanceKlass();
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;
57 _init_state = ik->init_state();
58 _nonstatic_field_size = ik->nonstatic_field_size();
59 _has_nonstatic_fields = ik->has_nonstatic_fields();
60 _has_default_methods = ik->has_default_methods();
61 _is_anonymous = ik->is_anonymous();
62 _nonstatic_fields = NULL; // initialized lazily by compute_nonstatic_fields:
64 _implementor = NULL; // we will fill these lazily
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 }
80 // Lazy fields get filled in only upon request.
81 _super = NULL;
82 _java_mirror = NULL;
84 if (is_shared()) {
85 if (h_k() != SystemDictionary::Object_klass()) {
86 super();
87 }
88 //compute_nonstatic_fields(); // done outside of constructor
89 }
91 _field_cache = NULL;
92 }
94 // Version for unloaded classes:
95 ciInstanceKlass::ciInstanceKlass(ciSymbol* name,
96 jobject loader, jobject protection_domain)
97 : ciKlass(name, T_OBJECT)
98 {
99 assert(name->byte_at(0) != '[', "not an instance klass");
100 _init_state = (InstanceKlass::ClassState)0;
101 _nonstatic_field_size = -1;
102 _has_nonstatic_fields = false;
103 _nonstatic_fields = NULL;
104 _is_anonymous = false;
105 _loader = loader;
106 _protection_domain = protection_domain;
107 _is_shared = false;
108 _super = NULL;
109 _java_mirror = NULL;
110 _field_cache = NULL;
111 }
115 // ------------------------------------------------------------------
116 // ciInstanceKlass::compute_shared_is_initialized
117 void ciInstanceKlass::compute_shared_init_state() {
118 GUARDED_VM_ENTRY(
119 InstanceKlass* ik = get_instanceKlass();
120 _init_state = ik->init_state();
121 )
122 }
124 // ------------------------------------------------------------------
125 // ciInstanceKlass::compute_shared_has_subklass
126 bool ciInstanceKlass::compute_shared_has_subklass() {
127 GUARDED_VM_ENTRY(
128 InstanceKlass* ik = get_instanceKlass();
129 _has_subklass = ik->subklass() != NULL;
130 return _has_subklass;
131 )
132 }
134 // ------------------------------------------------------------------
135 // ciInstanceKlass::loader
136 oop ciInstanceKlass::loader() {
137 ASSERT_IN_VM;
138 return JNIHandles::resolve(_loader);
139 }
141 // ------------------------------------------------------------------
142 // ciInstanceKlass::loader_handle
143 jobject ciInstanceKlass::loader_handle() {
144 return _loader;
145 }
147 // ------------------------------------------------------------------
148 // ciInstanceKlass::protection_domain
149 oop ciInstanceKlass::protection_domain() {
150 ASSERT_IN_VM;
151 return JNIHandles::resolve(_protection_domain);
152 }
154 // ------------------------------------------------------------------
155 // ciInstanceKlass::protection_domain_handle
156 jobject ciInstanceKlass::protection_domain_handle() {
157 return _protection_domain;
158 }
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 }
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
189 if (offset < instanceOopDesc::base_offset_in_bytes()) {
190 // All header offsets belong properly to java/lang/Object.
191 return CURRENT_ENV->Object_klass();
192 }
194 ciInstanceKlass* self = this;
195 for (;;) {
196 assert(self->is_loaded(), "must be loaded to have size");
197 ciInstanceKlass* super = self->super();
198 if (super == NULL || super->nof_nonstatic_fields() == 0 ||
199 !super->contains_field_offset(offset)) {
200 return self;
201 } else {
202 self = super; // return super->get_canonical_holder(offset)
203 }
204 }
205 }
207 // ------------------------------------------------------------------
208 // ciInstanceKlass::is_java_lang_Object
209 //
210 // Is this klass java.lang.Object?
211 bool ciInstanceKlass::is_java_lang_Object() const {
212 return equals(CURRENT_ENV->Object_klass());
213 }
215 // ------------------------------------------------------------------
216 // ciInstanceKlass::uses_default_loader
217 bool ciInstanceKlass::uses_default_loader() const {
218 // Note: We do not need to resolve the handle or enter the VM
219 // in order to test null-ness.
220 return _loader == NULL;
221 }
223 // ------------------------------------------------------------------
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 }
236 /**
237 * Is this boxing klass?
238 */
239 bool ciInstanceKlass::is_box_klass() const {
240 return is_java_primitive(box_klass_type());
241 }
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 }
252 // ------------------------------------------------------------------
253 // ciInstanceKlass::is_in_package
254 //
255 // Is this klass in the given package?
256 bool ciInstanceKlass::is_in_package(const char* packagename, int len) {
257 // To avoid class loader mischief, this test always rejects application classes.
258 if (!uses_default_loader())
259 return false;
260 GUARDED_VM_ENTRY(
261 return is_in_package_impl(packagename, len);
262 )
263 }
265 bool ciInstanceKlass::is_in_package_impl(const char* packagename, int len) {
266 ASSERT_IN_VM;
268 // If packagename contains trailing '/' exclude it from the
269 // prefix-test since we test for it explicitly.
270 if (packagename[len - 1] == '/')
271 len--;
273 if (!name()->starts_with(packagename, len))
274 return false;
276 // Test if the class name is something like "java/lang".
277 if ((len + 1) > name()->utf8_length())
278 return false;
280 // Test for trailing '/'
281 if ((char) name()->byte_at(len) != '/')
282 return false;
284 // Make sure it's not actually in a subpackage:
285 if (name()->index_of_at(len+1, "/", 1) >= 0)
286 return false;
288 return true;
289 }
291 // ------------------------------------------------------------------
292 // ciInstanceKlass::print_impl
293 //
294 // Implementation of the print method.
295 void ciInstanceKlass::print_impl(outputStream* st) {
296 ciKlass::print_impl(st);
297 GUARDED_VM_ENTRY(st->print(" loader=" INTPTR_FORMAT, p2i((address)loader()));)
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());
305 _flags.print_klass_flags();
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 }
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(
327 Klass* super_klass = get_instanceKlass()->super();
328 _super = CURRENT_ENV->get_instance_klass(super_klass);
329 )
330 }
331 return _super;
332 }
334 // ------------------------------------------------------------------
335 // ciInstanceKlass::java_mirror
336 //
337 // Get the instance of java.lang.Class corresponding to this klass.
338 // Cache it on this->_java_mirror.
339 ciInstance* ciInstanceKlass::java_mirror() {
340 if (is_shared()) {
341 return ciKlass::java_mirror();
342 }
343 if (_java_mirror == NULL) {
344 _java_mirror = ciKlass::java_mirror();
345 }
346 return _java_mirror;
347 }
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;
356 InstanceKlass* ik = get_instanceKlass();
357 Klass* up = ik->up_cast_abstract();
358 assert(up->oop_is_instance(), "must be InstanceKlass");
359 if (ik == up) {
360 return NULL;
361 }
362 return CURRENT_THREAD_ENV->get_instance_klass(up);
363 }
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 }
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;
389 InstanceKlass* k = get_instanceKlass();
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 }
398 // ------------------------------------------------------------------
399 // ciInstanceKlass::get_field_by_name
400 ciField* ciInstanceKlass::get_field_by_name(ciSymbol* name, ciSymbol* signature, bool is_static) {
401 VM_ENTRY_MARK;
402 InstanceKlass* k = get_instanceKlass();
403 fieldDescriptor fd;
404 Klass* def = k->find_field(name->get_symbol(), signature->get_symbol(), is_static, &fd);
405 if (def == NULL) {
406 return NULL;
407 }
408 ciField* field = new (CURRENT_THREAD_ENV->arena()) ciField(&fd);
409 return field;
410 }
412 // ------------------------------------------------------------------
413 // ciInstanceKlass::non_static_fields.
415 class NonStaticFieldFiller: public FieldClosure {
416 GrowableArray<ciField*>* _arr;
417 ciEnv* _curEnv;
418 public:
419 NonStaticFieldFiller(ciEnv* curEnv, GrowableArray<ciField*>* arr) :
420 _curEnv(curEnv), _arr(arr)
421 {}
422 void do_field(fieldDescriptor* fd) {
423 ciField* field = new (_curEnv->arena()) ciField(fd);
424 _arr->append(field);
425 }
426 };
428 GrowableArray<ciField*>* ciInstanceKlass::non_static_fields() {
429 if (_non_static_fields == NULL) {
430 VM_ENTRY_MARK;
431 ciEnv* curEnv = ciEnv::current();
432 InstanceKlass* ik = get_instanceKlass();
433 int max_n_fields = ik->java_fields_count();
435 Arena* arena = curEnv->arena();
436 _non_static_fields =
437 new (arena) GrowableArray<ciField*>(arena, max_n_fields, 0, NULL);
438 NonStaticFieldFiller filler(curEnv, _non_static_fields);
439 ik->do_nonstatic_fields(&filler);
440 }
441 return _non_static_fields;
442 }
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 }
449 // ------------------------------------------------------------------
450 // ciInstanceKlass::compute_nonstatic_fields
451 int ciInstanceKlass::compute_nonstatic_fields() {
452 assert(is_loaded(), "must be loaded");
454 if (_nonstatic_fields != NULL)
455 return _nonstatic_fields->length();
457 if (!has_nonstatic_fields()) {
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");
464 // Size in bytes of my fields, including inherited fields.
465 int fsize = nonstatic_field_size() * heapOopSize;
467 ciInstanceKlass* super = this->super();
468 GrowableArray<ciField*>* super_fields = NULL;
469 if (super != NULL && super->has_nonstatic_fields()) {
470 int super_fsize = super->nonstatic_field_size() * heapOopSize;
471 int super_flen = super->nof_nonstatic_fields();
472 super_fields = super->_nonstatic_fields;
473 assert(super_flen == 0 || super_fields != NULL, "first get nof_fields");
474 // See if I am no larger than my super; if so, I can use his fields.
475 if (fsize == super_fsize) {
476 _nonstatic_fields = super_fields;
477 return super_fields->length();
478 }
479 }
481 GrowableArray<ciField*>* fields = NULL;
482 GUARDED_VM_ENTRY({
483 fields = compute_nonstatic_fields_impl(super_fields);
484 });
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 }
492 int flen = fields->length();
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 }
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;
508 InstanceKlass* k = get_instanceKlass();
509 for (JavaFieldStream fs(k); !fs.done(); fs.next()) {
510 if (fs.access_flags().is_static()) continue;
511 flen += 1;
512 }
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 }
526 for (JavaFieldStream fs(k); !fs.done(); fs.next()) {
527 if (fs.access_flags().is_static()) continue;
528 fieldDescriptor& fd = fs.field_descriptor();
529 ciField* field = new (arena) ciField(&fd);
530 fields->append(field);
531 }
532 assert(fields->length() == flen, "sanity");
533 return fields;
534 }
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;
542 InstanceKlass* k = get_instanceKlass();
543 Symbol* name_sym = name->get_symbol();
544 Symbol* sig_sym= signature->get_symbol();
546 Method* m = k->find_method(name_sym, sig_sym);
547 if (m == NULL) return NULL;
549 return CURRENT_THREAD_ENV->get_method(m);
550 }
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 {
559 return !_has_subklass && (nof_implementors() == 0);
560 }
561 }
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
569 // to results returned by InstanceKlass::implementor.
570 // This is OK, since any dependencies we decide to assert
571 // will be checked later under the Compile_lock.
572 ciInstanceKlass* ciInstanceKlass::implementor() {
573 ciInstanceKlass* impl = _implementor;
574 if (impl == NULL) {
575 // Go into the VM to fetch the implementor.
576 {
577 VM_ENTRY_MARK;
578 Klass* k = get_instanceKlass()->implementor();
579 if (k != NULL) {
580 if (k == get_instanceKlass()) {
581 // More than one implementors. Use 'this' in this case.
582 impl = this;
583 } else {
584 impl = CURRENT_THREAD_ENV->get_instance_klass(k);
585 }
586 }
587 }
588 // Memoize this result.
589 if (!is_shared()) {
590 _implementor = impl;
591 }
592 }
593 return impl;
594 }
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 }
606 // Utility class for printing of the contents of the static fields for
607 // use by compilation replay. It only prints out the information that
608 // could be consumed by the compiler, so for primitive types it prints
609 // out the actual value. For Strings it's the actual string value.
610 // For array types it it's first level array size since that's the
611 // only value which statically unchangeable. For all other reference
612 // types it simply prints out the dynamic type.
614 class StaticFinalFieldPrinter : public FieldClosure {
615 outputStream* _out;
616 const char* _holder;
617 public:
618 StaticFinalFieldPrinter(outputStream* out, const char* holder) :
619 _out(out),
620 _holder(holder) {
621 }
622 void do_field(fieldDescriptor* fd) {
623 if (fd->is_final() && !fd->has_initial_value()) {
624 ResourceMark rm;
625 oop mirror = fd->field_holder()->java_mirror();
626 _out->print("staticfield %s %s %s ", _holder, fd->name()->as_quoted_ascii(), fd->signature()->as_quoted_ascii());
627 switch (fd->field_type()) {
628 case T_BYTE: _out->print_cr("%d", mirror->byte_field(fd->offset())); break;
629 case T_BOOLEAN: _out->print_cr("%d", mirror->bool_field(fd->offset())); break;
630 case T_SHORT: _out->print_cr("%d", mirror->short_field(fd->offset())); break;
631 case T_CHAR: _out->print_cr("%d", mirror->char_field(fd->offset())); break;
632 case T_INT: _out->print_cr("%d", mirror->int_field(fd->offset())); break;
633 case T_LONG: _out->print_cr(INT64_FORMAT, (int64_t)(mirror->long_field(fd->offset()))); break;
634 case T_FLOAT: {
635 float f = mirror->float_field(fd->offset());
636 _out->print_cr("%d", *(int*)&f);
637 break;
638 }
639 case T_DOUBLE: {
640 double d = mirror->double_field(fd->offset());
641 _out->print_cr(INT64_FORMAT, *(int64_t*)&d);
642 break;
643 }
644 case T_ARRAY: {
645 oop value = mirror->obj_field_acquire(fd->offset());
646 if (value == NULL) {
647 _out->print_cr("null");
648 } else {
649 typeArrayOop ta = (typeArrayOop)value;
650 _out->print("%d", ta->length());
651 if (value->is_objArray()) {
652 objArrayOop oa = (objArrayOop)value;
653 const char* klass_name = value->klass()->name()->as_quoted_ascii();
654 _out->print(" %s", klass_name);
655 }
656 _out->cr();
657 }
658 break;
659 }
660 case T_OBJECT: {
661 oop value = mirror->obj_field_acquire(fd->offset());
662 if (value == NULL) {
663 _out->print_cr("null");
664 } else if (value->is_instance()) {
665 if (value->is_a(SystemDictionary::String_klass())) {
666 _out->print("\"");
667 _out->print_raw(java_lang_String::as_quoted_ascii(value));
668 _out->print_cr("\"");
669 } else {
670 const char* klass_name = value->klass()->name()->as_quoted_ascii();
671 _out->print_cr("%s", klass_name);
672 }
673 } else {
674 ShouldNotReachHere();
675 }
676 break;
677 }
678 default:
679 ShouldNotReachHere();
680 }
681 }
682 }
683 };
686 void ciInstanceKlass::dump_replay_data(outputStream* out) {
687 ResourceMark rm;
689 InstanceKlass* ik = get_instanceKlass();
690 ConstantPool* cp = ik->constants();
692 // Try to record related loaded classes
693 Klass* sub = ik->subklass();
694 while (sub != NULL) {
695 if (sub->oop_is_instance()) {
696 out->print_cr("instanceKlass %s", sub->name()->as_quoted_ascii());
697 }
698 sub = sub->next_sibling();
699 }
701 // Dump out the state of the constant pool tags. During replay the
702 // tags will be validated for things which shouldn't change and
703 // classes will be resolved if the tags indicate that they were
704 // resolved at compile time.
705 out->print("ciInstanceKlass %s %d %d %d", ik->name()->as_quoted_ascii(),
706 is_linked(), is_initialized(), cp->length());
707 for (int index = 1; index < cp->length(); index++) {
708 out->print(" %d", cp->tags()->at(index));
709 }
710 out->cr();
711 if (is_initialized()) {
712 // Dump out the static final fields in case the compilation relies
713 // on their value for correct replay.
714 StaticFinalFieldPrinter sffp(out, ik->name()->as_quoted_ascii());
715 ik->do_local_static_fields(&sffp);
716 }
717 }