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