1.1 --- a/src/share/vm/oops/cpCache.cpp Tue Mar 17 01:56:32 2015 -0700 1.2 +++ b/src/share/vm/oops/cpCache.cpp Tue Mar 17 17:11:14 2015 -0700 1.3 @@ -449,7 +449,6 @@ 1.4 new_method->name()->as_C_string(), 1.5 new_method->signature()->as_C_string())); 1.6 } 1.7 - 1.8 return true; 1.9 } 1.10 1.11 @@ -477,7 +476,6 @@ 1.12 new_method->name()->as_C_string(), 1.13 new_method->signature()->as_C_string())); 1.14 } 1.15 - 1.16 return true; 1.17 } 1.18 1.19 @@ -504,36 +502,33 @@ 1.20 (!f1_as_method()->is_old() && !f1_as_method()->is_obsolete()))); 1.21 } 1.22 1.23 -bool ConstantPoolCacheEntry::is_interesting_method_entry(Klass* k) { 1.24 +Method* ConstantPoolCacheEntry::get_interesting_method_entry(Klass* k) { 1.25 if (!is_method_entry()) { 1.26 // not a method entry so not interesting by default 1.27 - return false; 1.28 + return NULL; 1.29 } 1.30 - 1.31 Method* m = NULL; 1.32 if (is_vfinal()) { 1.33 // virtual and final so _f2 contains method ptr instead of vtable index 1.34 m = f2_as_vfinal_method(); 1.35 } else if (is_f1_null()) { 1.36 // NULL _f1 means this is a virtual entry so also not interesting 1.37 - return false; 1.38 + return NULL; 1.39 } else { 1.40 if (!(_f1->is_method())) { 1.41 // _f1 can also contain a Klass* for an interface 1.42 - return false; 1.43 + return NULL; 1.44 } 1.45 m = f1_as_method(); 1.46 } 1.47 - 1.48 assert(m != NULL && m->is_method(), "sanity check"); 1.49 if (m == NULL || !m->is_method() || (k != NULL && m->method_holder() != k)) { 1.50 // robustness for above sanity checks or method is not in 1.51 // the interesting class 1.52 - return false; 1.53 + return NULL; 1.54 } 1.55 - 1.56 // the method is in the interesting class so the entry is interesting 1.57 - return true; 1.58 + return m; 1.59 } 1.60 #endif // INCLUDE_JVMTI 1.61 1.62 @@ -610,7 +605,7 @@ 1.63 // If any entry of this ConstantPoolCache points to any of 1.64 // old_methods, replace it with the corresponding new_method. 1.65 void ConstantPoolCache::adjust_method_entries(Method** old_methods, Method** new_methods, 1.66 - int methods_length, bool * trace_name_printed) { 1.67 + int methods_length, bool * trace_name_printed) { 1.68 1.69 if (methods_length == 0) { 1.70 // nothing to do if there are no methods 1.71 @@ -621,7 +616,7 @@ 1.72 Klass* old_holder = old_methods[0]->method_holder(); 1.73 1.74 for (int i = 0; i < length(); i++) { 1.75 - if (!entry_at(i)->is_interesting_method_entry(old_holder)) { 1.76 + if (entry_at(i)->get_interesting_method_entry(old_holder) == NULL) { 1.77 // skip uninteresting methods 1.78 continue; 1.79 } 1.80 @@ -645,10 +640,33 @@ 1.81 } 1.82 } 1.83 1.84 +// If any entry of this ConstantPoolCache points to any of 1.85 +// old_methods, replace it with the corresponding new_method. 1.86 +void ConstantPoolCache::adjust_method_entries(InstanceKlass* holder, bool * trace_name_printed) { 1.87 + for (int i = 0; i < length(); i++) { 1.88 + ConstantPoolCacheEntry* entry = entry_at(i); 1.89 + Method* old_method = entry->get_interesting_method_entry(holder); 1.90 + if (old_method == NULL || !old_method->is_old()) { 1.91 + continue; // skip uninteresting entries 1.92 + } 1.93 + if (old_method->is_deleted()) { 1.94 + // clean up entries with deleted methods 1.95 + entry->initialize_entry(entry->constant_pool_index()); 1.96 + continue; 1.97 + } 1.98 + Method* new_method = holder->method_with_idnum(old_method->orig_method_idnum()); 1.99 + 1.100 + assert(new_method != NULL, "method_with_idnum() should not be NULL"); 1.101 + assert(old_method != new_method, "sanity check"); 1.102 + 1.103 + entry_at(i)->adjust_method_entry(old_method, new_method, trace_name_printed); 1.104 + } 1.105 +} 1.106 + 1.107 // the constant pool cache should never contain old or obsolete methods 1.108 bool ConstantPoolCache::check_no_old_or_obsolete_entries() { 1.109 for (int i = 1; i < length(); i++) { 1.110 - if (entry_at(i)->is_interesting_method_entry(NULL) && 1.111 + if (entry_at(i)->get_interesting_method_entry(NULL) != NULL && 1.112 !entry_at(i)->check_no_old_or_obsolete_entries()) { 1.113 return false; 1.114 } 1.115 @@ -658,7 +676,7 @@ 1.116 1.117 void ConstantPoolCache::dump_cache() { 1.118 for (int i = 1; i < length(); i++) { 1.119 - if (entry_at(i)->is_interesting_method_entry(NULL)) { 1.120 + if (entry_at(i)->get_interesting_method_entry(NULL) != NULL) { 1.121 entry_at(i)->print(tty, i); 1.122 } 1.123 }