Mercurial > hg > truffle
comparison src/share/vm/classfile/systemDictionary.cpp @ 18041:52b4284cb496
Merge with jdk8u20-b26
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Wed, 15 Oct 2014 16:02:50 +0200 |
parents | 89152779163c ae92351815b6 |
children | 43e2cc9a4fde |
comparison
equal
deleted
inserted
replaced
17606:45d7b2c7029d | 18041:52b4284cb496 |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
835 } | 835 } |
836 } | 836 } |
837 } | 837 } |
838 } // load_instance_class loop | 838 } // load_instance_class loop |
839 | 839 |
840 if (HAS_PENDING_EXCEPTION) { | |
841 // An exception, such as OOM could have happened at various places inside | |
842 // load_instance_class. We might have partially initialized a shared class | |
843 // and need to clean it up. | |
844 if (class_loader.is_null()) { | |
845 // In some cases k may be null. Let's find the shared class again. | |
846 instanceKlassHandle ik(THREAD, find_shared_class(name)); | |
847 if (ik.not_null()) { | |
848 if (ik->class_loader_data() == NULL) { | |
849 // We didn't go as far as Klass::restore_unshareable_info(), | |
850 // so nothing to clean up. | |
851 } else { | |
852 Klass *kk; | |
853 { | |
854 MutexLocker mu(SystemDictionary_lock, THREAD); | |
855 kk = find_class(d_index, d_hash, name, ik->class_loader_data()); | |
856 } | |
857 if (kk != NULL) { | |
858 // No clean up is needed if the shared class has been entered | |
859 // into system dictionary, as load_shared_class() won't be called | |
860 // again. | |
861 } else { | |
862 // This must be done outside of the SystemDictionary_lock to | |
863 // avoid deadlock. | |
864 // | |
865 // Note that Klass::restore_unshareable_info (called via | |
866 // load_instance_class above) is also called outside | |
867 // of SystemDictionary_lock. Other threads are blocked from | |
868 // loading this class because they are waiting on the | |
869 // SystemDictionary_lock until this thread removes | |
870 // the placeholder below. | |
871 // | |
872 // This need to be re-thought when parallel-capable non-boot | |
873 // classloaders are supported by CDS (today they're not). | |
874 clean_up_shared_class(ik, class_loader, THREAD); | |
875 } | |
876 } | |
877 } | |
878 } | |
879 } | |
880 | |
881 if (load_instance_added == true) { | 840 if (load_instance_added == true) { |
882 // clean up placeholder entries for LOAD_INSTANCE success or error | 841 // clean up placeholder entries for LOAD_INSTANCE success or error |
883 // This brackets the SystemDictionary updates for both defining | 842 // This brackets the SystemDictionary updates for both defining |
884 // and initiating loaders | 843 // and initiating loaders |
885 MutexLocker mu(SystemDictionary_lock, THREAD); | 844 MutexLocker mu(SystemDictionary_lock, THREAD); |
1047 THREAD); | 1006 THREAD); |
1048 | 1007 |
1049 | 1008 |
1050 if (host_klass.not_null() && k.not_null()) { | 1009 if (host_klass.not_null() && k.not_null()) { |
1051 assert(EnableInvokeDynamic, ""); | 1010 assert(EnableInvokeDynamic, ""); |
1052 k->set_host_klass(host_klass()); | |
1053 // If it's anonymous, initialize it now, since nobody else will. | 1011 // If it's anonymous, initialize it now, since nobody else will. |
1054 | 1012 |
1055 { | 1013 { |
1056 MutexLocker mu_r(Compile_lock, THREAD); | 1014 MutexLocker mu_r(Compile_lock, THREAD); |
1057 | 1015 |
1281 true /* shared class */); | 1239 true /* shared class */); |
1282 } | 1240 } |
1283 return ik; | 1241 return ik; |
1284 } | 1242 } |
1285 | 1243 |
1286 void SystemDictionary::clean_up_shared_class(instanceKlassHandle ik, Handle class_loader, TRAPS) { | |
1287 // Updating methods must be done under a lock so multiple | |
1288 // threads don't update these in parallel | |
1289 // Shared classes are all currently loaded by the bootstrap | |
1290 // classloader, so this will never cause a deadlock on | |
1291 // a custom class loader lock. | |
1292 { | |
1293 Handle lockObject = compute_loader_lock_object(class_loader, THREAD); | |
1294 check_loader_lock_contention(lockObject, THREAD); | |
1295 ObjectLocker ol(lockObject, THREAD, true); | |
1296 ik->remove_unshareable_info(); | |
1297 } | |
1298 } | |
1299 | 1244 |
1300 instanceKlassHandle SystemDictionary::load_instance_class(Symbol* class_name, Handle class_loader, TRAPS) { | 1245 instanceKlassHandle SystemDictionary::load_instance_class(Symbol* class_name, Handle class_loader, TRAPS) { |
1301 instanceKlassHandle nh = instanceKlassHandle(); // null Handle | 1246 instanceKlassHandle nh = instanceKlassHandle(); // null Handle |
1302 if (class_loader.is_null()) { | 1247 if (class_loader.is_null()) { |
1303 | 1248 |
2360 if (vmtarget != NULL && vmtarget->is_method()) { | 2305 if (vmtarget != NULL && vmtarget->is_method()) { |
2361 Method* m = (Method*)vmtarget; | 2306 Method* m = (Method*)vmtarget; |
2362 oop appendix = appendix_box->obj_at(0); | 2307 oop appendix = appendix_box->obj_at(0); |
2363 if (TraceMethodHandles) { | 2308 if (TraceMethodHandles) { |
2364 #ifndef PRODUCT | 2309 #ifndef PRODUCT |
2365 tty->print("Linked method="INTPTR_FORMAT": ", m); | 2310 tty->print("Linked method=" INTPTR_FORMAT ": ", p2i(m)); |
2366 m->print(); | 2311 m->print(); |
2367 if (appendix != NULL) { tty->print("appendix = "); appendix->print(); } | 2312 if (appendix != NULL) { tty->print("appendix = "); appendix->print(); } |
2368 tty->cr(); | 2313 tty->cr(); |
2369 #endif //PRODUCT | 2314 #endif //PRODUCT |
2370 } | 2315 } |
2686 placeholders()->verify(); | 2631 placeholders()->verify(); |
2687 | 2632 |
2688 // Verify constraint table | 2633 // Verify constraint table |
2689 guarantee(constraints() != NULL, "Verify of loader constraints failed"); | 2634 guarantee(constraints() != NULL, "Verify of loader constraints failed"); |
2690 constraints()->verify(dictionary(), placeholders()); | 2635 constraints()->verify(dictionary(), placeholders()); |
2691 } | |
2692 | |
2693 | |
2694 void SystemDictionary::verify_obj_klass_present(Symbol* class_name, | |
2695 ClassLoaderData* loader_data) { | |
2696 GCMutexLocker mu(SystemDictionary_lock); | |
2697 Symbol* name; | |
2698 | |
2699 Klass* probe = find_class(class_name, loader_data); | |
2700 if (probe == NULL) { | |
2701 probe = SystemDictionary::find_shared_class(class_name); | |
2702 if (probe == NULL) { | |
2703 name = find_placeholder(class_name, loader_data); | |
2704 } | |
2705 } | |
2706 guarantee(probe != NULL || name != NULL, | |
2707 "Loaded klasses should be in SystemDictionary"); | |
2708 } | 2636 } |
2709 | 2637 |
2710 // utility function for class load event | 2638 // utility function for class load event |
2711 void SystemDictionary::post_class_load_event(const Ticks& start_time, | 2639 void SystemDictionary::post_class_load_event(const Ticks& start_time, |
2712 instanceKlassHandle k, | 2640 instanceKlassHandle k, |