src/hotspot/share/oops/cpCache.cpp
changeset 53904 9c3fe09f69bc
parent 53746 bdccafc038a2
child 53965 86ee52ca11e3
equal deleted inserted replaced
53903:68bbd727dd5f 53904:9c3fe09f69bc
   589   }
   589   }
   590 }
   590 }
   591 
   591 
   592 // a constant pool cache entry should never contain old or obsolete methods
   592 // a constant pool cache entry should never contain old or obsolete methods
   593 bool ConstantPoolCacheEntry::check_no_old_or_obsolete_entries() {
   593 bool ConstantPoolCacheEntry::check_no_old_or_obsolete_entries() {
   594   Method* m = get_interesting_method_entry(NULL);
   594   Method* m = get_interesting_method_entry();
   595   // return false if m refers to a non-deleted old or obsolete method
   595   // return false if m refers to a non-deleted old or obsolete method
   596   if (m != NULL) {
   596   if (m != NULL) {
   597     assert(m->is_valid() && m->is_method(), "m is a valid method");
   597     assert(m->is_valid() && m->is_method(), "m is a valid method");
   598     return !m->is_old() && !m->is_obsolete(); // old is always set for old and obsolete
   598     return !m->is_old() && !m->is_obsolete(); // old is always set for old and obsolete
   599   } else {
   599   } else {
   600     return true;
   600     return true;
   601   }
   601   }
   602 }
   602 }
   603 
   603 
   604 Method* ConstantPoolCacheEntry::get_interesting_method_entry(Klass* k) {
   604 Method* ConstantPoolCacheEntry::get_interesting_method_entry() {
   605   if (!is_method_entry()) {
   605   if (!is_method_entry()) {
   606     // not a method entry so not interesting by default
   606     // not a method entry so not interesting by default
   607     return NULL;
   607     return NULL;
   608   }
   608   }
   609   Method* m = NULL;
   609   Method* m = NULL;
   620     } else {
   620     } else {
   621       m = f1_as_method();
   621       m = f1_as_method();
   622     }
   622     }
   623   }
   623   }
   624   assert(m != NULL && m->is_method(), "sanity check");
   624   assert(m != NULL && m->is_method(), "sanity check");
   625   if (m == NULL || !m->is_method() || (k != NULL && m->method_holder() != k)) {
   625   if (m == NULL || !m->is_method()) {
   626     // robustness for above sanity checks or method is not in
       
   627     // the interesting class
       
   628     return NULL;
   626     return NULL;
   629   }
   627   }
   630   // the method is in the interesting class so the entry is interesting
       
   631   return m;
   628   return m;
   632 }
   629 }
   633 #endif // INCLUDE_JVMTI
   630 #endif // INCLUDE_JVMTI
   634 
   631 
   635 void ConstantPoolCacheEntry::print(outputStream* st, int index) const {
   632 void ConstantPoolCacheEntry::print(outputStream* st, int index) const {
   775 
   772 
   776 #if INCLUDE_JVMTI
   773 #if INCLUDE_JVMTI
   777 // RedefineClasses() API support:
   774 // RedefineClasses() API support:
   778 // If any entry of this ConstantPoolCache points to any of
   775 // If any entry of this ConstantPoolCache points to any of
   779 // old_methods, replace it with the corresponding new_method.
   776 // old_methods, replace it with the corresponding new_method.
   780 void ConstantPoolCache::adjust_method_entries(InstanceKlass* holder, bool * trace_name_printed) {
   777 void ConstantPoolCache::adjust_method_entries(bool * trace_name_printed) {
   781   for (int i = 0; i < length(); i++) {
   778   for (int i = 0; i < length(); i++) {
   782     ConstantPoolCacheEntry* entry = entry_at(i);
   779     ConstantPoolCacheEntry* entry = entry_at(i);
   783     Method* old_method = entry->get_interesting_method_entry(holder);
   780     Method* old_method = entry->get_interesting_method_entry();
   784     if (old_method == NULL || !old_method->is_old()) {
   781     if (old_method == NULL || !old_method->is_old()) {
   785       continue; // skip uninteresting entries
   782       continue; // skip uninteresting entries
   786     }
   783     }
   787     if (old_method->is_deleted()) {
   784     if (old_method->is_deleted()) {
   788       // clean up entries with deleted methods
   785       // clean up entries with deleted methods
   789       entry->initialize_entry(entry->constant_pool_index());
   786       entry->initialize_entry(entry->constant_pool_index());
   790       continue;
   787       continue;
   791     }
   788     }
   792     Method* new_method = holder->method_with_idnum(old_method->orig_method_idnum());
   789     Method* new_method = old_method->get_new_method();
   793 
       
   794     assert(new_method != NULL, "method_with_idnum() should not be NULL");
       
   795     assert(old_method != new_method, "sanity check");
       
   796 
       
   797     entry_at(i)->adjust_method_entry(old_method, new_method, trace_name_printed);
   790     entry_at(i)->adjust_method_entry(old_method, new_method, trace_name_printed);
   798   }
   791   }
   799 }
   792 }
   800 
   793 
   801 // the constant pool cache should never contain old or obsolete methods
   794 // the constant pool cache should never contain old or obsolete methods
   802 bool ConstantPoolCache::check_no_old_or_obsolete_entries() {
   795 bool ConstantPoolCache::check_no_old_or_obsolete_entries() {
   803   for (int i = 1; i < length(); i++) {
   796   for (int i = 1; i < length(); i++) {
   804     if (entry_at(i)->get_interesting_method_entry(NULL) != NULL &&
   797     if (entry_at(i)->get_interesting_method_entry() != NULL &&
   805         !entry_at(i)->check_no_old_or_obsolete_entries()) {
   798         !entry_at(i)->check_no_old_or_obsolete_entries()) {
   806       return false;
   799       return false;
   807     }
   800     }
   808   }
   801   }
   809   return true;
   802   return true;
   810 }
   803 }
   811 
   804 
   812 void ConstantPoolCache::dump_cache() {
   805 void ConstantPoolCache::dump_cache() {
   813   for (int i = 1; i < length(); i++) {
   806   for (int i = 1; i < length(); i++) {
   814     if (entry_at(i)->get_interesting_method_entry(NULL) != NULL) {
   807     if (entry_at(i)->get_interesting_method_entry() != NULL) {
   815       entry_at(i)->print(tty, i);
   808       entry_at(i)->print(tty, i);
   816     }
   809     }
   817   }
   810   }
   818 }
   811 }
   819 #endif // INCLUDE_JVMTI
   812 #endif // INCLUDE_JVMTI