comparison src/share/vm/classfile/systemDictionary.cpp @ 8751:1fc4d4768b90

8007725: NPG: Klass::restore_unshareable_info() triggers assert(k->java_mirror() == NULL) Summary: Check for exception during SystemDictionary::resolve_instance_class_or_null() and clean up. Reviewed-by: coleenp, acorn, hseigel, minqi Contributed-by: ioi.lam@oracle.com
author coleenp
date Fri, 15 Mar 2013 17:24:40 -0400
parents 1f9994892f89
children cd3089a56438 16885e702c88
comparison
equal deleted inserted replaced
8750:39432a1cefdd 8751:1fc4d4768b90
802 } 802 }
803 } 803 }
804 } 804 }
805 } // load_instance_class loop 805 } // load_instance_class loop
806 806
807 if (HAS_PENDING_EXCEPTION) {
808 // An exception, such as OOM could have happened at various places inside
809 // load_instance_class. We might have partially initialized a shared class
810 // and need to clean it up.
811 if (class_loader.is_null()) {
812 // In some cases k may be null. Let's find the shared class again.
813 instanceKlassHandle ik(THREAD, find_shared_class(name));
814 if (ik.not_null()) {
815 if (ik->class_loader_data() == NULL) {
816 // We didn't go as far as Klass::restore_unshareable_info(),
817 // so nothing to clean up.
818 } else {
819 MutexLocker mu(SystemDictionary_lock, THREAD);
820 Klass* kk = find_class(name, ik->class_loader_data());
821 if (kk != NULL) {
822 // No clean up is needed if the shared class has been entered
823 // into system dictionary, as load_shared_class() won't be called
824 // again.
825 } else {
826 clean_up_shared_class(ik, class_loader, THREAD);
827 }
828 }
829 }
830 }
831 }
832
807 if (load_instance_added == true) { 833 if (load_instance_added == true) {
808 // clean up placeholder entries for LOAD_INSTANCE success or error 834 // clean up placeholder entries for LOAD_INSTANCE success or error
809 // This brackets the SystemDictionary updates for both defining 835 // This brackets the SystemDictionary updates for both defining
810 // and initiating loaders 836 // and initiating loaders
811 MutexLocker mu(SystemDictionary_lock, THREAD); 837 MutexLocker mu(SystemDictionary_lock, THREAD);
1138 Symbol* class_name, Handle class_loader, TRAPS) { 1164 Symbol* class_name, Handle class_loader, TRAPS) {
1139 instanceKlassHandle ik (THREAD, find_shared_class(class_name)); 1165 instanceKlassHandle ik (THREAD, find_shared_class(class_name));
1140 return load_shared_class(ik, class_loader, THREAD); 1166 return load_shared_class(ik, class_loader, THREAD);
1141 } 1167 }
1142 1168
1143 // Note well! Changes to this method may affect oop access order
1144 // in the shared archive. Please take care to not make changes that
1145 // adversely affect cold start time by changing the oop access order
1146 // that is specified in dump.cpp MarkAndMoveOrderedReadOnly and
1147 // MarkAndMoveOrderedReadWrite closures.
1148 instanceKlassHandle SystemDictionary::load_shared_class( 1169 instanceKlassHandle SystemDictionary::load_shared_class(
1149 instanceKlassHandle ik, Handle class_loader, TRAPS) { 1170 instanceKlassHandle ik, Handle class_loader, TRAPS) {
1150 assert(class_loader.is_null(), "non-null classloader for shared class?"); 1171 assert(class_loader.is_null(), "non-null classloader for shared class?");
1151 if (ik.not_null()) { 1172 if (ik.not_null()) {
1152 instanceKlassHandle nh = instanceKlassHandle(); // null Handle 1173 instanceKlassHandle nh = instanceKlassHandle(); // null Handle
1203 true /* shared class */); 1224 true /* shared class */);
1204 } 1225 }
1205 return ik; 1226 return ik;
1206 } 1227 }
1207 1228
1229 void SystemDictionary::clean_up_shared_class(instanceKlassHandle ik, Handle class_loader, TRAPS) {
1230 // Updating methods must be done under a lock so multiple
1231 // threads don't update these in parallel
1232 // Shared classes are all currently loaded by the bootstrap
1233 // classloader, so this will never cause a deadlock on
1234 // a custom class loader lock.
1235 {
1236 Handle lockObject = compute_loader_lock_object(class_loader, THREAD);
1237 check_loader_lock_contention(lockObject, THREAD);
1238 ObjectLocker ol(lockObject, THREAD, true);
1239 ik->remove_unshareable_info();
1240 }
1241 }
1208 1242
1209 instanceKlassHandle SystemDictionary::load_instance_class(Symbol* class_name, Handle class_loader, TRAPS) { 1243 instanceKlassHandle SystemDictionary::load_instance_class(Symbol* class_name, Handle class_loader, TRAPS) {
1210 instanceKlassHandle nh = instanceKlassHandle(); // null Handle 1244 instanceKlassHandle nh = instanceKlassHandle(); // null Handle
1211 if (class_loader.is_null()) { 1245 if (class_loader.is_null()) {
1212 1246