1 /* 2 * Copyright (c) 1999, 2015, 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 */ 24 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" 36 37 // ciInstanceKlass 38 // 39 // This class represents a Klass* in the HotSpot virtual machine 40 // whose Klass part in an InstanceKlass. 41 42 // ------------------------------------------------------------------ 43 // ciInstanceKlass::ciInstanceKlass 44 // 45 // Loaded instance klass. 46 ciInstanceKlass::ciInstanceKlass(KlassHandle h_k) : 47 ciKlass(h_k) 48 { 49 assert(get_Klass()->is_instance_klass(), "wrong type"); 50 assert(get_instanceKlass()->is_loaded(), "must be at least loaded"); 51 InstanceKlass* ik = get_instanceKlass(); 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; 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: 63 _has_injected_fields = -1; 64 _implementor = NULL; // we will fill these lazily 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()) { 85 if (h_k() != SystemDictionary::Object_klass()) { 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) 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 _has_injected_fields = -1; 105 _is_anonymous = false; 106 _loader = loader; 107 _protection_domain = protection_domain; 108 _is_shared = false; 109 _super = NULL; 110 _java_mirror = NULL; 111 _field_cache = NULL; 112 } 113 114 115 116 // ------------------------------------------------------------------ 117 // ciInstanceKlass::compute_shared_is_initialized 118 void ciInstanceKlass::compute_shared_init_state() { 119 GUARDED_VM_ENTRY( 120 InstanceKlass* ik = get_instanceKlass(); 121 _init_state = ik->init_state(); 122 ) 123 } 124 125 // ------------------------------------------------------------------ 126 // ciInstanceKlass::compute_shared_has_subklass 127 bool ciInstanceKlass::compute_shared_has_subklass() { 128 GUARDED_VM_ENTRY( 129 InstanceKlass* ik = get_instanceKlass(); 130 _has_subklass = ik->subklass() != NULL; 131 return _has_subklass; 132 ) 133 } 134 135 // ------------------------------------------------------------------ 136 // ciInstanceKlass::loader 137 oop ciInstanceKlass::loader() { 138 ASSERT_IN_VM; 139 return JNIHandles::resolve(_loader); 140 } 141 142 // ------------------------------------------------------------------ 143 // ciInstanceKlass::loader_handle 144 jobject ciInstanceKlass::loader_handle() { 145 return _loader; 146 } 147 148 // ------------------------------------------------------------------ 149 // ciInstanceKlass::protection_domain 150 oop ciInstanceKlass::protection_domain() { 151 ASSERT_IN_VM; 152 return JNIHandles::resolve(_protection_domain); 153 } 154 155 // ------------------------------------------------------------------ 156 // ciInstanceKlass::protection_domain_handle 157 jobject ciInstanceKlass::protection_domain_handle() { 158 return _protection_domain; 159 } 160 161 // ------------------------------------------------------------------ 162 // ciInstanceKlass::field_cache 163 // 164 // Get the field cache associated with this klass. 165 ciConstantPoolCache* ciInstanceKlass::field_cache() { 166 if (is_shared()) { 167 return NULL; 168 } 169 if (_field_cache == NULL) { 170 assert(!is_java_lang_Object(), "Object has no fields"); 171 Arena* arena = CURRENT_ENV->arena(); 172 _field_cache = new (arena) ciConstantPoolCache(arena, 5); 173 } 174 return _field_cache; 175 } 176 177 // ------------------------------------------------------------------ 178 // ciInstanceKlass::get_canonical_holder 179 // 180 ciInstanceKlass* ciInstanceKlass::get_canonical_holder(int offset) { 181 #ifdef ASSERT 182 if (!(offset >= 0 && offset < layout_helper())) { 183 tty->print("*** get_canonical_holder(%d) on ", offset); 184 this->print(); 185 tty->print_cr(" ***"); 186 }; 187 assert(offset >= 0 && offset < layout_helper(), "offset must be tame"); 188 #endif 189 190 if (offset < instanceOopDesc::base_offset_in_bytes()) { 191 // All header offsets belong properly to java/lang/Object. 192 return CURRENT_ENV->Object_klass(); 193 } 194 195 ciInstanceKlass* self = this; 196 for (;;) { 197 assert(self->is_loaded(), "must be loaded to have size"); 198 ciInstanceKlass* super = self->super(); 199 if (super == NULL || super->nof_nonstatic_fields() == 0 || 200 !super->contains_field_offset(offset)) { 201 return self; 202 } else { 203 self = super; // return super->get_canonical_holder(offset) 204 } 205 } 206 } 207 208 // ------------------------------------------------------------------ 209 // ciInstanceKlass::is_java_lang_Object 210 // 211 // Is this klass java.lang.Object? 212 bool ciInstanceKlass::is_java_lang_Object() const { 213 return equals(CURRENT_ENV->Object_klass()); 214 } 215 216 // ------------------------------------------------------------------ 217 // ciInstanceKlass::uses_default_loader 218 bool ciInstanceKlass::uses_default_loader() const { 219 // Note: We do not need to resolve the handle or enter the VM 220 // in order to test null-ness. 221 return _loader == NULL; 222 } 223 224 // ------------------------------------------------------------------ 225 226 /** 227 * Return basic type of boxed value for box klass or T_OBJECT if not. 228 */ 229 BasicType ciInstanceKlass::box_klass_type() const { 230 if (uses_default_loader() && is_loaded()) { 231 return SystemDictionary::box_klass_type(get_Klass()); 232 } else { 233 return T_OBJECT; 234 } 235 } 236 237 /** 238 * Is this boxing klass? 239 */ 240 bool ciInstanceKlass::is_box_klass() const { 241 return is_java_primitive(box_klass_type()); 242 } 243 244 /** 245 * Is this boxed value offset? 246 */ 247 bool ciInstanceKlass::is_boxed_value_offset(int offset) const { 248 BasicType bt = box_klass_type(); 249 return is_java_primitive(bt) && 250 (offset == java_lang_boxing_object::value_offset_in_bytes(bt)); 251 } 252 253 // ------------------------------------------------------------------ 254 // ciInstanceKlass::is_in_package 255 // 256 // Is this klass in the given package? 257 bool ciInstanceKlass::is_in_package(const char* packagename, int len) { 258 // To avoid class loader mischief, this test always rejects application classes. 259 if (!uses_default_loader()) 260 return false; 261 GUARDED_VM_ENTRY( 262 return is_in_package_impl(packagename, len); 263 ) 264 } 265 266 bool ciInstanceKlass::is_in_package_impl(const char* packagename, int len) { 267 ASSERT_IN_VM; 268 269 // If packagename contains trailing '/' exclude it from the 270 // prefix-test since we test for it explicitly. 271 if (packagename[len - 1] == '/') 272 len--; 273 274 if (!name()->starts_with(packagename, len)) 275 return false; 276 277 // Test if the class name is something like "java/lang". 278 if ((len + 1) > name()->utf8_length()) 279 return false; 280 281 // Test for trailing '/' 282 if ((char) name()->byte_at(len) != '/') 283 return false; 284 285 // Make sure it's not actually in a subpackage: 286 if (name()->index_of_at(len+1, "/", 1) >= 0) 287 return false; 288 289 return true; 290 } 291 292 // ------------------------------------------------------------------ 293 // ciInstanceKlass::print_impl 294 // 295 // Implementation of the print method. 296 void ciInstanceKlass::print_impl(outputStream* st) { 297 ciKlass::print_impl(st); 298 GUARDED_VM_ENTRY(st->print(" loader=" INTPTR_FORMAT, p2i((address)loader()));) 299 if (is_loaded()) { 300 st->print(" loaded=true initialized=%s finalized=%s subklass=%s size=%d flags=", 301 bool_to_str(is_initialized()), 302 bool_to_str(has_finalizer()), 303 bool_to_str(has_subklass()), 304 layout_helper()); 305 306 _flags.print_klass_flags(); 307 308 if (_super) { 309 st->print(" super="); 310 _super->print_name(); 311 } 312 if (_java_mirror) { 313 st->print(" mirror=PRESENT"); 314 } 315 } else { 316 st->print(" loaded=false"); 317 } 318 } 319 320 // ------------------------------------------------------------------ 321 // ciInstanceKlass::super 322 // 323 // Get the superklass of this klass. 324 ciInstanceKlass* ciInstanceKlass::super() { 325 assert(is_loaded(), "must be loaded"); 326 if (_super == NULL && !is_java_lang_Object()) { 327 GUARDED_VM_ENTRY( 328 Klass* super_klass = get_instanceKlass()->super(); 329 _super = CURRENT_ENV->get_instance_klass(super_klass); 330 ) 331 } 332 return _super; 333 } 334 335 // ------------------------------------------------------------------ 336 // ciInstanceKlass::java_mirror 337 // 338 // Get the instance of java.lang.Class corresponding to this klass. 339 // Cache it on this->_java_mirror. 340 ciInstance* ciInstanceKlass::java_mirror() { 341 if (is_shared()) { 342 return ciKlass::java_mirror(); 343 } 344 if (_java_mirror == NULL) { 345 _java_mirror = ciKlass::java_mirror(); 346 } 347 return _java_mirror; 348 } 349 350 // ------------------------------------------------------------------ 351 // ciInstanceKlass::unique_concrete_subklass 352 ciInstanceKlass* ciInstanceKlass::unique_concrete_subklass() { 353 if (!is_loaded()) return NULL; // No change if class is not loaded 354 if (!is_abstract()) return NULL; // Only applies to abstract classes. 355 if (!has_subklass()) return NULL; // Must have at least one subklass. 356 VM_ENTRY_MARK; 357 InstanceKlass* ik = get_instanceKlass(); 358 Klass* up = ik->up_cast_abstract(); 359 assert(up->is_instance_klass(), "must be InstanceKlass"); 360 if (ik == up) { 361 return NULL; 362 } 363 return CURRENT_THREAD_ENV->get_instance_klass(up); 364 } 365 366 // ------------------------------------------------------------------ 367 // ciInstanceKlass::has_finalizable_subclass 368 bool ciInstanceKlass::has_finalizable_subclass() { 369 if (!is_loaded()) return true; 370 VM_ENTRY_MARK; 371 return Dependencies::find_finalizable_subclass(get_instanceKlass()) != NULL; 372 } 373 374 // ------------------------------------------------------------------ 375 // ciInstanceKlass::get_field_by_offset 376 ciField* ciInstanceKlass::get_field_by_offset(int field_offset, bool is_static) { 377 if (!is_static) { 378 for (int i = 0, len = nof_nonstatic_fields(); i < len; i++) { 379 ciField* field = _nonstatic_fields->at(i); 380 int field_off = field->offset_in_bytes(); 381 if (field_off == field_offset) 382 return field; 383 if (field_off > field_offset) 384 break; 385 // could do binary search or check bins, but probably not worth it 386 } 387 return NULL; 388 } 389 VM_ENTRY_MARK; 390 InstanceKlass* k = get_instanceKlass(); 391 fieldDescriptor fd; 392 if (!k->find_field_from_offset(field_offset, is_static, &fd)) { 393 return NULL; 394 } 395 ciField* field = new (CURRENT_THREAD_ENV->arena()) ciField(&fd); 396 return field; 397 } 398 399 // ------------------------------------------------------------------ 400 // ciInstanceKlass::get_field_by_name 401 ciField* ciInstanceKlass::get_field_by_name(ciSymbol* name, ciSymbol* signature, bool is_static) { 402 VM_ENTRY_MARK; 403 InstanceKlass* k = get_instanceKlass(); 404 fieldDescriptor fd; 405 Klass* def = k->find_field(name->get_symbol(), signature->get_symbol(), is_static, &fd); 406 if (def == NULL) { 407 return NULL; 408 } 409 ciField* field = new (CURRENT_THREAD_ENV->arena()) ciField(&fd); 410 return field; 411 } 412 413 414 static int sort_field_by_offset(ciField** a, ciField** b) { 415 return (*a)->offset_in_bytes() - (*b)->offset_in_bytes(); 416 // (no worries about 32-bit overflow...) 417 } 418 419 // ------------------------------------------------------------------ 420 // ciInstanceKlass::compute_nonstatic_fields 421 int ciInstanceKlass::compute_nonstatic_fields() { 422 assert(is_loaded(), "must be loaded"); 423 424 if (_nonstatic_fields != NULL) 425 return _nonstatic_fields->length(); 426 427 if (!has_nonstatic_fields()) { 428 Arena* arena = CURRENT_ENV->arena(); 429 _nonstatic_fields = new (arena) GrowableArray<ciField*>(arena, 0, 0, NULL); 430 return 0; 431 } 432 assert(!is_java_lang_Object(), "bootstrap OK"); 433 434 // Size in bytes of my fields, including inherited fields. 435 int fsize = nonstatic_field_size() * heapOopSize; 436 437 ciInstanceKlass* super = this->super(); 438 GrowableArray<ciField*>* super_fields = NULL; 439 if (super != NULL && super->has_nonstatic_fields()) { 440 int super_fsize = super->nonstatic_field_size() * heapOopSize; 441 int super_flen = super->nof_nonstatic_fields(); 442 super_fields = super->_nonstatic_fields; 443 assert(super_flen == 0 || super_fields != NULL, "first get nof_fields"); 444 // See if I am no larger than my super; if so, I can use his fields. 445 if (fsize == super_fsize) { 446 _nonstatic_fields = super_fields; 447 return super_fields->length(); 448 } 449 } 450 451 GrowableArray<ciField*>* fields = NULL; 452 GUARDED_VM_ENTRY({ 453 fields = compute_nonstatic_fields_impl(super_fields); 454 }); 455 456 if (fields == NULL) { 457 // This can happen if this class (java.lang.Class) has invisible fields. 458 if (super_fields != NULL) { 459 _nonstatic_fields = super_fields; 460 return super_fields->length(); 461 } else { 462 return 0; 463 } 464 } 465 466 int flen = fields->length(); 467 468 // Now sort them by offset, ascending. 469 // (In principle, they could mix with superclass fields.) 470 fields->sort(sort_field_by_offset); 471 _nonstatic_fields = fields; 472 return flen; 473 } 474 475 GrowableArray<ciField*>* 476 ciInstanceKlass::compute_nonstatic_fields_impl(GrowableArray<ciField*>* 477 super_fields) { 478 ASSERT_IN_VM; 479 Arena* arena = CURRENT_ENV->arena(); 480 int flen = 0; 481 GrowableArray<ciField*>* fields = NULL; 482 InstanceKlass* k = get_instanceKlass(); 483 for (JavaFieldStream fs(k); !fs.done(); fs.next()) { 484 if (fs.access_flags().is_static()) continue; 485 flen += 1; 486 } 487 488 // allocate the array: 489 if (flen == 0) { 490 return NULL; // return nothing if none are locally declared 491 } 492 if (super_fields != NULL) { 493 flen += super_fields->length(); 494 } 495 fields = new (arena) GrowableArray<ciField*>(arena, flen, 0, NULL); 496 if (super_fields != NULL) { 497 fields->appendAll(super_fields); 498 } 499 500 for (JavaFieldStream fs(k); !fs.done(); fs.next()) { 501 if (fs.access_flags().is_static()) continue; 502 fieldDescriptor& fd = fs.field_descriptor(); 503 ciField* field = new (arena) ciField(&fd); 504 fields->append(field); 505 } 506 assert(fields->length() == flen, "sanity"); 507 return fields; 508 } 509 510 bool ciInstanceKlass::compute_injected_fields_helper() { 511 ASSERT_IN_VM; 512 InstanceKlass* k = get_instanceKlass(); 513 514 for (InternalFieldStream fs(k); !fs.done(); fs.next()) { 515 if (fs.access_flags().is_static()) continue; 516 return true; 517 } 518 return false; 519 } 520 521 void ciInstanceKlass::compute_injected_fields() { 522 assert(is_loaded(), "must be loaded"); 523 524 int has_injected_fields = 0; 525 if (super() != NULL && super()->has_injected_fields()) { 526 has_injected_fields = 1; 527 } else { 528 GUARDED_VM_ENTRY({ 529 has_injected_fields = compute_injected_fields_helper() ? 1 : 0; 530 }); 531 } 532 // may be concurrently initialized for shared ciInstanceKlass objects 533 assert(_has_injected_fields == -1 || _has_injected_fields == has_injected_fields, "broken concurrent initialization"); 534 _has_injected_fields = has_injected_fields; 535 } 536 537 // ------------------------------------------------------------------ 538 // ciInstanceKlass::find_method 539 // 540 // Find a method in this klass. 541 ciMethod* ciInstanceKlass::find_method(ciSymbol* name, ciSymbol* signature) { 542 VM_ENTRY_MARK; 543 InstanceKlass* k = get_instanceKlass(); 544 Symbol* name_sym = name->get_symbol(); 545 Symbol* sig_sym= signature->get_symbol(); 546 547 Method* m = k->find_method(name_sym, sig_sym); 548 if (m == NULL) return NULL; 549 550 return CURRENT_THREAD_ENV->get_method(m); 551 } 552 553 // ------------------------------------------------------------------ 554 // ciInstanceKlass::is_leaf_type 555 bool ciInstanceKlass::is_leaf_type() { 556 assert(is_loaded(), "must be loaded"); 557 if (is_shared()) { 558 return is_final(); // approximately correct 559 } else { 560 return !_has_subklass && (nof_implementors() == 0); 561 } 562 } 563 564 // ------------------------------------------------------------------ 565 // ciInstanceKlass::implementor 566 // 567 // Report an implementor of this interface. 568 // Note that there are various races here, since my copy 569 // of _nof_implementors might be out of date with respect 570 // to results returned by InstanceKlass::implementor. 571 // This is OK, since any dependencies we decide to assert 572 // will be checked later under the Compile_lock. 573 ciInstanceKlass* ciInstanceKlass::implementor() { 574 ciInstanceKlass* impl = _implementor; 575 if (impl == NULL) { 576 // Go into the VM to fetch the implementor. 577 { 578 VM_ENTRY_MARK; 579 Klass* k = get_instanceKlass()->implementor(); 580 if (k != NULL) { 581 if (k == get_instanceKlass()) { 582 // More than one implementors. Use 'this' in this case. 583 impl = this; 584 } else { 585 impl = CURRENT_THREAD_ENV->get_instance_klass(k); 586 } 587 } 588 } 589 // Memoize this result. 590 if (!is_shared()) { 591 _implementor = impl; 592 } 593 } 594 return impl; 595 } 596 597 // Utility class for printing of the contents of the static fields for 598 // use by compilation replay. It only prints out the information that 599 // could be consumed by the compiler, so for primitive types it prints 600 // out the actual value. For Strings it's the actual string value. 601 // For array types it it's first level array size since that's the 602 // only value which statically unchangeable. For all other reference 603 // types it simply prints out the dynamic type. 604 605 class StaticFinalFieldPrinter : public FieldClosure { 606 outputStream* _out; 607 const char* _holder; 608 public: 609 StaticFinalFieldPrinter(outputStream* out, const char* holder) : 610 _out(out), 611 _holder(holder) { 612 } 613 void do_field(fieldDescriptor* fd) { 614 if (fd->is_final() && !fd->has_initial_value()) { 615 ResourceMark rm; 616 oop mirror = fd->field_holder()->java_mirror(); 617 _out->print("staticfield %s %s %s ", _holder, fd->name()->as_quoted_ascii(), fd->signature()->as_quoted_ascii()); 618 switch (fd->field_type()) { 619 case T_BYTE: _out->print_cr("%d", mirror->byte_field(fd->offset())); break; 620 case T_BOOLEAN: _out->print_cr("%d", mirror->bool_field(fd->offset())); break; 621 case T_SHORT: _out->print_cr("%d", mirror->short_field(fd->offset())); break; 622 case T_CHAR: _out->print_cr("%d", mirror->char_field(fd->offset())); break; 623 case T_INT: _out->print_cr("%d", mirror->int_field(fd->offset())); break; 624 case T_LONG: _out->print_cr(INT64_FORMAT, (int64_t)(mirror->long_field(fd->offset()))); break; 625 case T_FLOAT: { 626 float f = mirror->float_field(fd->offset()); 627 _out->print_cr("%d", *(int*)&f); 628 break; 629 } 630 case T_DOUBLE: { 631 double d = mirror->double_field(fd->offset()); 632 _out->print_cr(INT64_FORMAT, *(int64_t*)&d); 633 break; 634 } 635 case T_ARRAY: { 636 oop value = mirror->obj_field_acquire(fd->offset()); 637 if (value == NULL) { 638 _out->print_cr("null"); 639 } else { 640 typeArrayOop ta = (typeArrayOop)value; 641 _out->print("%d", ta->length()); 642 if (value->is_objArray()) { 643 objArrayOop oa = (objArrayOop)value; 644 const char* klass_name = value->klass()->name()->as_quoted_ascii(); 645 _out->print(" %s", klass_name); 646 } 647 _out->cr(); 648 } 649 break; 650 } 651 case T_OBJECT: { 652 oop value = mirror->obj_field_acquire(fd->offset()); 653 if (value == NULL) { 654 _out->print_cr("null"); 655 } else if (value->is_instance()) { 656 if (value->is_a(SystemDictionary::String_klass())) { 657 _out->print("\""); 658 _out->print_raw(java_lang_String::as_quoted_ascii(value)); 659 _out->print_cr("\""); 660 } else { 661 const char* klass_name = value->klass()->name()->as_quoted_ascii(); 662 _out->print_cr("%s", klass_name); 663 } 664 } else { 665 ShouldNotReachHere(); 666 } 667 break; 668 } 669 default: 670 ShouldNotReachHere(); 671 } 672 } 673 } 674 }; 675 676 677 void ciInstanceKlass::dump_replay_data(outputStream* out) { 678 ResourceMark rm; 679 680 InstanceKlass* ik = get_instanceKlass(); 681 ConstantPool* cp = ik->constants(); 682 683 // Try to record related loaded classes 684 Klass* sub = ik->subklass(); 685 while (sub != NULL) { 686 if (sub->is_instance_klass()) { 687 out->print_cr("instanceKlass %s", sub->name()->as_quoted_ascii()); 688 } 689 sub = sub->next_sibling(); 690 } 691 692 // Dump out the state of the constant pool tags. During replay the 693 // tags will be validated for things which shouldn't change and 694 // classes will be resolved if the tags indicate that they were 695 // resolved at compile time. 696 out->print("ciInstanceKlass %s %d %d %d", ik->name()->as_quoted_ascii(), 697 is_linked(), is_initialized(), cp->length()); 698 for (int index = 1; index < cp->length(); index++) { 699 out->print(" %d", cp->tags()->at(index)); 700 } 701 out->cr(); 702 if (is_initialized()) { 703 // Dump out the static final fields in case the compilation relies 704 // on their value for correct replay. 705 StaticFinalFieldPrinter sffp(out, ik->name()->as_quoted_ascii()); 706 ik->do_local_static_fields(&sffp); 707 } 708 }