Fri, 28 May 2010 16:23:51 -0700
6957004: MethodComparator uses the wrong CP index accessor
Summary: Change two uses of get_index_u2 to get_index_u2_cpcache; also tweak some debugging print functions
Reviewed-by: kvn
1.1 --- a/src/share/vm/oops/constantPoolKlass.cpp Thu May 27 22:01:55 2010 -0700 1.2 +++ b/src/share/vm/oops/constantPoolKlass.cpp Fri May 28 16:23:51 2010 -0700 1.3 @@ -310,15 +310,12 @@ 1.4 Klass::oop_print_on(obj, st); 1.5 constantPoolOop cp = constantPoolOop(obj); 1.6 if (cp->flags() != 0) { 1.7 - st->print(" - flags : 0x%x", cp->flags()); 1.8 + st->print(" - flags: 0x%x", cp->flags()); 1.9 if (cp->has_pseudo_string()) st->print(" has_pseudo_string"); 1.10 if (cp->has_invokedynamic()) st->print(" has_invokedynamic"); 1.11 st->cr(); 1.12 } 1.13 - 1.14 - // Temp. remove cache so we can do lookups with original indicies. 1.15 - constantPoolCacheHandle cache (THREAD, cp->cache()); 1.16 - cp->set_cache(NULL); 1.17 + st->print_cr(" - cache: " INTPTR_FORMAT, cp->cache()); 1.18 1.19 for (int index = 1; index < cp->length(); index++) { // Index 0 is unused 1.20 st->print(" - %3d : ", index); 1.21 @@ -334,8 +331,8 @@ 1.22 case JVM_CONSTANT_Fieldref : 1.23 case JVM_CONSTANT_Methodref : 1.24 case JVM_CONSTANT_InterfaceMethodref : 1.25 - st->print("klass_index=%d", cp->klass_ref_index_at(index)); 1.26 - st->print(" name_and_type_index=%d", cp->name_and_type_ref_index_at(index)); 1.27 + st->print("klass_index=%d", cp->uncached_klass_ref_index_at(index)); 1.28 + st->print(" name_and_type_index=%d", cp->uncached_name_and_type_ref_index_at(index)); 1.29 break; 1.30 case JVM_CONSTANT_UnresolvedString : 1.31 case JVM_CONSTANT_String : 1.32 @@ -382,9 +379,6 @@ 1.33 st->cr(); 1.34 } 1.35 st->cr(); 1.36 - 1.37 - // Restore cache 1.38 - cp->set_cache(cache()); 1.39 } 1.40 1.41 #endif 1.42 @@ -398,6 +392,9 @@ 1.43 cp->print_address_on(st); 1.44 st->print(" for "); 1.45 cp->pool_holder()->print_value_on(st); 1.46 + if (cp->cache() != NULL) { 1.47 + st->print(" cache=" PTR_FORMAT, cp->cache()); 1.48 + } 1.49 } 1.50 1.51 const char* constantPoolKlass::internal_name() const {
2.1 --- a/src/share/vm/oops/methodKlass.cpp Thu May 27 22:01:55 2010 -0700 2.2 +++ b/src/share/vm/oops/methodKlass.cpp Fri May 28 16:23:51 2010 -0700 2.3 @@ -237,7 +237,7 @@ 2.4 Klass::oop_print_on(obj, st); 2.5 methodOop m = methodOop(obj); 2.6 // get the effect of PrintOopAddress, always, for methods: 2.7 - st->print (" - this oop: "INTPTR_FORMAT, (intptr_t)m); 2.8 + st->print_cr(" - this oop: "INTPTR_FORMAT, (intptr_t)m); 2.9 st->print (" - method holder: "); m->method_holder()->print_value_on(st); st->cr(); 2.10 st->print (" - constants: "INTPTR_FORMAT" ", (address)m->constants()); 2.11 m->constants()->print_value_on(st); st->cr();
3.1 --- a/src/share/vm/prims/methodComparator.cpp Thu May 27 22:01:55 2010 -0700 3.2 +++ b/src/share/vm/prims/methodComparator.cpp Fri May 28 16:23:51 2010 -0700 3.3 @@ -149,8 +149,8 @@ 3.4 case Bytecodes::_invokestatic : // fall through 3.5 case Bytecodes::_invokedynamic : // fall through 3.6 case Bytecodes::_invokeinterface : { 3.7 - u2 cpci_old = _s_old->has_index_u4() ? _s_old->get_index_u4() : _s_old->get_index_u2(); 3.8 - u2 cpci_new = _s_new->has_index_u4() ? _s_new->get_index_u4() : _s_new->get_index_u2(); 3.9 + int cpci_old = _s_old->has_index_u4() ? _s_old->get_index_u4() : _s_old->get_index_u2_cpcache(); 3.10 + int cpci_new = _s_new->has_index_u4() ? _s_new->get_index_u4() : _s_new->get_index_u2_cpcache(); 3.11 // Check if the names of classes, field/method names and signatures at these indexes 3.12 // are the same. Indices which are really into constantpool cache (rather than constant 3.13 // pool itself) are accepted by the constantpool query routines below.