1.1 --- a/src/share/vm/oops/instanceKlass.cpp Sun Mar 25 18:08:52 2012 -0400 1.2 +++ b/src/share/vm/oops/instanceKlass.cpp Thu Mar 29 22:18:56 2012 -0400 1.3 @@ -567,8 +567,18 @@ 1.4 ol.notify_all(CHECK); 1.5 } 1.6 1.7 +// The embedded _implementor field can only record one implementor. 1.8 +// When there are more than one implementors, the _implementor field 1.9 +// is set to the interface klassOop itself. Following are the possible 1.10 +// values for the _implementor field: 1.11 +// NULL - no implementor 1.12 +// implementor klassOop - one implementor 1.13 +// self - more than one implementor 1.14 +// 1.15 +// The _implementor field only exists for interfaces. 1.16 void instanceKlass::add_implementor(klassOop k) { 1.17 assert(Compile_lock->owned_by_self(), ""); 1.18 + assert(is_interface(), "not interface"); 1.19 // Filter out my subinterfaces. 1.20 // (Note: Interfaces are never on the subklass list.) 1.21 if (instanceKlass::cast(k)->is_interface()) return; 1.22 @@ -583,17 +593,13 @@ 1.23 // Any supers of the super have the same (or fewer) transitive_interfaces. 1.24 return; 1.25 1.26 - // Update number of implementors 1.27 - int i = _nof_implementors++; 1.28 - 1.29 - // Record this implementor, if there are not too many already 1.30 - if (i < implementors_limit) { 1.31 - assert(_implementors[i] == NULL, "should be exactly one implementor"); 1.32 - oop_store_without_check((oop*)&_implementors[i], k); 1.33 - } else if (i == implementors_limit) { 1.34 - // clear out the list on first overflow 1.35 - for (int i2 = 0; i2 < implementors_limit; i2++) 1.36 - oop_store_without_check((oop*)&_implementors[i2], NULL); 1.37 + klassOop ik = implementor(); 1.38 + if (ik == NULL) { 1.39 + set_implementor(k); 1.40 + } else if (ik != this->as_klassOop()) { 1.41 + // There is already an implementor. Use itself as an indicator of 1.42 + // more than one implementors. 1.43 + set_implementor(this->as_klassOop()); 1.44 } 1.45 1.46 // The implementor also implements the transitive_interfaces 1.47 @@ -603,9 +609,9 @@ 1.48 } 1.49 1.50 void instanceKlass::init_implementor() { 1.51 - for (int i = 0; i < implementors_limit; i++) 1.52 - oop_store_without_check((oop*)&_implementors[i], NULL); 1.53 - _nof_implementors = 0; 1.54 + if (is_interface()) { 1.55 + set_implementor(NULL); 1.56 + } 1.57 } 1.58 1.59 1.60 @@ -1849,24 +1855,22 @@ 1.61 void instanceKlass::follow_weak_klass_links( 1.62 BoolObjectClosure* is_alive, OopClosure* keep_alive) { 1.63 assert(is_alive->do_object_b(as_klassOop()), "this oop should be live"); 1.64 - if (ClassUnloading) { 1.65 - for (int i = 0; i < implementors_limit; i++) { 1.66 - klassOop impl = _implementors[i]; 1.67 - if (impl == NULL) break; // no more in the list 1.68 - if (!is_alive->do_object_b(impl)) { 1.69 - // remove this guy from the list by overwriting him with the tail 1.70 - int lasti = --_nof_implementors; 1.71 - assert(lasti >= i && lasti < implementors_limit, "just checking"); 1.72 - _implementors[i] = _implementors[lasti]; 1.73 - _implementors[lasti] = NULL; 1.74 - --i; // rerun the loop at this index 1.75 + 1.76 + if (is_interface()) { 1.77 + if (ClassUnloading) { 1.78 + klassOop impl = implementor(); 1.79 + if (impl != NULL) { 1.80 + if (!is_alive->do_object_b(impl)) { 1.81 + // remove this guy 1.82 + *start_of_implementor() = NULL; 1.83 + } 1.84 } 1.85 - } 1.86 - } else { 1.87 - for (int i = 0; i < implementors_limit; i++) { 1.88 - keep_alive->do_oop(&adr_implementors()[i]); 1.89 + } else { 1.90 + assert(adr_implementor() != NULL, "just checking"); 1.91 + keep_alive->do_oop(adr_implementor()); 1.92 } 1.93 } 1.94 + 1.95 Klass::follow_weak_klass_links(is_alive, keep_alive); 1.96 } 1.97