< prev index next >

src/share/vm/oops/constantPool.cpp

Print this page




 267       if (p != NULL && i < ref_map_len) {
 268         int index = object_to_cp_index(i);
 269         // Skip the entry if the string hash code is 0 since the string
 270         // is not included in the shared string_table, see StringTable::copy_shared_string.
 271         if (tag_at(index).is_string() && java_lang_String::hash_code(p) != 0) {
 272           oop op = StringTable::create_archived_string(p, THREAD);
 273           // If the String object is not archived (possibly too large),
 274           // NULL is returned. Also set it in the array, so we won't
 275           // have a 'bad' reference in the archived resolved_reference
 276           // array.
 277           rr->obj_at_put(i, op);
 278         }
 279       }
 280     }
 281 
 282     oop archived = MetaspaceShared::archive_heap_object(rr, THREAD);
 283     _cache->set_archived_references(archived);
 284     set_resolved_references(NULL);
 285   }
 286 }























 287 #endif
 288 
 289 // CDS support. Create a new resolved_references array.
 290 void ConstantPool::restore_unshareable_info(TRAPS) {
 291   assert(is_constantPool(), "ensure C++ vtable is restored");
 292   assert(on_stack(), "should always be set for shared constant pools");
 293   assert(is_shared(), "should always be set for shared constant pools");
 294   assert(_cache != NULL, "constant pool _cache should not be NULL");
 295 
 296   // Only create the new resolved references array if it hasn't been attempted before
 297   if (resolved_references() != NULL) return;
 298 
 299   // restore the C++ vtable from the shared archive
 300   restore_vtable();
 301 
 302   if (SystemDictionary::Object_klass_loaded()) {
 303     ClassLoaderData* loader_data = pool_holder()->class_loader_data();
 304 #if INCLUDE_CDS_JAVA_HEAP
 305     if (MetaspaceShared::open_archive_heap_region_mapped() &&
 306         _cache->archived_references() != NULL) {


 693 Symbol* ConstantPool::uncached_klass_ref_at_noresolve(int which) {
 694   jint ref_index = uncached_klass_ref_index_at(which);
 695   return klass_at_noresolve(ref_index);
 696 }
 697 
 698 char* ConstantPool::string_at_noresolve(int which) {
 699   return unresolved_string_at(which)->as_C_string();
 700 }
 701 
 702 BasicType ConstantPool::basic_type_for_signature_at(int which) const {
 703   return FieldType::basic_type(symbol_at(which));
 704 }
 705 
 706 
 707 void ConstantPool::resolve_string_constants_impl(const constantPoolHandle& this_cp, TRAPS) {
 708   for (int index = 1; index < this_cp->length(); index++) { // Index 0 is unused
 709     if (this_cp->tag_at(index).is_string()) {
 710       this_cp->string_at(index, CHECK);
 711     }
 712   }
 713 }
 714 
 715 bool ConstantPool::resolve_class_constants(TRAPS) {
 716   constantPoolHandle cp(THREAD, this);
 717   for (int index = 1; index < length(); index++) { // Index 0 is unused
 718     if (tag_at(index).is_string()) {
 719       Symbol* sym = cp->unresolved_string_at(index);
 720       // Look up only. Only resolve references to already interned strings.
 721       oop str = StringTable::lookup(sym);
 722       if (str != NULL) {
 723         int cache_index = cp->cp_to_object_index(index);
 724         cp->string_at_put(index, cache_index, str);
 725       }
 726     }
 727   }
 728   return true;
 729 }
 730 
 731 Symbol* ConstantPool::exception_message(const constantPoolHandle& this_cp, int which, constantTag tag, oop pending_exception) {
 732   // Dig out the detailed message to reuse if possible
 733   Symbol* message = java_lang_Throwable::detail_message(pending_exception);
 734   if (message != NULL) {
 735     return message;
 736   }
 737 
 738   // Return specific message for the tag
 739   switch (tag.value()) {
 740   case JVM_CONSTANT_UnresolvedClass:
 741     // return the class name in the error message
 742     message = this_cp->klass_name_at(which);
 743     break;
 744   case JVM_CONSTANT_MethodHandle:
 745     // return the method handle name in the error message
 746     message = this_cp->method_handle_name_ref_at(which);
 747     break;
 748   case JVM_CONSTANT_MethodType:




 267       if (p != NULL && i < ref_map_len) {
 268         int index = object_to_cp_index(i);
 269         // Skip the entry if the string hash code is 0 since the string
 270         // is not included in the shared string_table, see StringTable::copy_shared_string.
 271         if (tag_at(index).is_string() && java_lang_String::hash_code(p) != 0) {
 272           oop op = StringTable::create_archived_string(p, THREAD);
 273           // If the String object is not archived (possibly too large),
 274           // NULL is returned. Also set it in the array, so we won't
 275           // have a 'bad' reference in the archived resolved_reference
 276           // array.
 277           rr->obj_at_put(i, op);
 278         }
 279       }
 280     }
 281 
 282     oop archived = MetaspaceShared::archive_heap_object(rr, THREAD);
 283     _cache->set_archived_references(archived);
 284     set_resolved_references(NULL);
 285   }
 286 }
 287 
 288 bool ConstantPool::resolve_class_constants(TRAPS) {
 289   assert(DumpSharedSpaces, "used during dump time only");
 290   // The _cache may be NULL if the _pool_holder klass fails verification
 291   // at dump time due to missing dependencies.
 292   if (cache() == NULL || reference_map() == NULL) {
 293     return true; // nothing to do
 294   }
 295 
 296   constantPoolHandle cp(THREAD, this);
 297   for (int index = 1; index < length(); index++) { // Index 0 is unused
 298     if (tag_at(index).is_string()) {
 299       Symbol* sym = cp->unresolved_string_at(index);
 300       // Look up only. Only resolve references to already interned strings.
 301       oop str = StringTable::lookup(sym);
 302       if (str != NULL) {
 303         int cache_index = cp->cp_to_object_index(index);
 304         cp->string_at_put(index, cache_index, str);
 305       }
 306     }
 307   }
 308   return true;
 309 }
 310 #endif
 311 
 312 // CDS support. Create a new resolved_references array.
 313 void ConstantPool::restore_unshareable_info(TRAPS) {
 314   assert(is_constantPool(), "ensure C++ vtable is restored");
 315   assert(on_stack(), "should always be set for shared constant pools");
 316   assert(is_shared(), "should always be set for shared constant pools");
 317   assert(_cache != NULL, "constant pool _cache should not be NULL");
 318 
 319   // Only create the new resolved references array if it hasn't been attempted before
 320   if (resolved_references() != NULL) return;
 321 
 322   // restore the C++ vtable from the shared archive
 323   restore_vtable();
 324 
 325   if (SystemDictionary::Object_klass_loaded()) {
 326     ClassLoaderData* loader_data = pool_holder()->class_loader_data();
 327 #if INCLUDE_CDS_JAVA_HEAP
 328     if (MetaspaceShared::open_archive_heap_region_mapped() &&
 329         _cache->archived_references() != NULL) {


 716 Symbol* ConstantPool::uncached_klass_ref_at_noresolve(int which) {
 717   jint ref_index = uncached_klass_ref_index_at(which);
 718   return klass_at_noresolve(ref_index);
 719 }
 720 
 721 char* ConstantPool::string_at_noresolve(int which) {
 722   return unresolved_string_at(which)->as_C_string();
 723 }
 724 
 725 BasicType ConstantPool::basic_type_for_signature_at(int which) const {
 726   return FieldType::basic_type(symbol_at(which));
 727 }
 728 
 729 
 730 void ConstantPool::resolve_string_constants_impl(const constantPoolHandle& this_cp, TRAPS) {
 731   for (int index = 1; index < this_cp->length(); index++) { // Index 0 is unused
 732     if (this_cp->tag_at(index).is_string()) {
 733       this_cp->string_at(index, CHECK);
 734     }
 735   }
















 736 }
 737 
 738 Symbol* ConstantPool::exception_message(const constantPoolHandle& this_cp, int which, constantTag tag, oop pending_exception) {
 739   // Dig out the detailed message to reuse if possible
 740   Symbol* message = java_lang_Throwable::detail_message(pending_exception);
 741   if (message != NULL) {
 742     return message;
 743   }
 744 
 745   // Return specific message for the tag
 746   switch (tag.value()) {
 747   case JVM_CONSTANT_UnresolvedClass:
 748     // return the class name in the error message
 749     message = this_cp->klass_name_at(which);
 750     break;
 751   case JVM_CONSTANT_MethodHandle:
 752     // return the method handle name in the error message
 753     message = this_cp->method_handle_name_ref_at(which);
 754     break;
 755   case JVM_CONSTANT_MethodType:


< prev index next >