Mercurial > hg > truffle
comparison src/share/vm/classfile/systemDictionary.cpp @ 10408:836a62f43af9
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Wed, 19 Jun 2013 10:45:56 +0200 |
parents | 89e4d67fdd2a f2110083203d |
children | 096c224171c4 |
comparison
equal
deleted
inserted
replaced
10086:e0fb8a213650 | 10408:836a62f43af9 |
---|---|
53 #include "runtime/javaCalls.hpp" | 53 #include "runtime/javaCalls.hpp" |
54 #include "runtime/mutexLocker.hpp" | 54 #include "runtime/mutexLocker.hpp" |
55 #include "runtime/signature.hpp" | 55 #include "runtime/signature.hpp" |
56 #include "services/classLoadingService.hpp" | 56 #include "services/classLoadingService.hpp" |
57 #include "services/threadService.hpp" | 57 #include "services/threadService.hpp" |
58 | |
59 #if INCLUDE_TRACE | |
60 #include "trace/tracing.hpp" | |
61 #include "trace/traceMacros.hpp" | |
62 #endif | |
58 | 63 |
59 | 64 |
60 Dictionary* SystemDictionary::_dictionary = NULL; | 65 Dictionary* SystemDictionary::_dictionary = NULL; |
61 PlaceholderTable* SystemDictionary::_placeholders = NULL; | 66 PlaceholderTable* SystemDictionary::_placeholders = NULL; |
62 Dictionary* SystemDictionary::_shared_dictionary = NULL; | 67 Dictionary* SystemDictionary::_shared_dictionary = NULL; |
584 } | 589 } |
585 return (nh); | 590 return (nh); |
586 } | 591 } |
587 | 592 |
588 | 593 |
589 Klass* SystemDictionary::resolve_instance_class_or_null(Symbol* name, Handle class_loader, Handle protection_domain, TRAPS) { | 594 Klass* SystemDictionary::resolve_instance_class_or_null(Symbol* name, |
595 Handle class_loader, | |
596 Handle protection_domain, | |
597 TRAPS) { | |
590 assert(name != NULL && !FieldType::is_array(name) && | 598 assert(name != NULL && !FieldType::is_array(name) && |
591 !FieldType::is_obj(name), "invalid class name"); | 599 !FieldType::is_obj(name), "invalid class name"); |
600 | |
601 TracingTime class_load_start_time = Tracing::time(); | |
592 | 602 |
593 // UseNewReflection | 603 // UseNewReflection |
594 // Fix for 4474172; see evaluation for more details | 604 // Fix for 4474172; see evaluation for more details |
595 class_loader = Handle(THREAD, java_lang_ClassLoader::non_reflection_class_loader(class_loader())); | 605 class_loader = Handle(THREAD, java_lang_ClassLoader::non_reflection_class_loader(class_loader())); |
596 ClassLoaderData *loader_data = register_loader(class_loader, CHECK_NULL); | 606 ClassLoaderData *loader_data = register_loader(class_loader, CHECK_NULL); |
802 if (!HAS_PENDING_EXCEPTION) { | 812 if (!HAS_PENDING_EXCEPTION) { |
803 { // Grabbing the Compile_lock prevents systemDictionary updates | 813 { // Grabbing the Compile_lock prevents systemDictionary updates |
804 // during compilations. | 814 // during compilations. |
805 MutexLocker mu(Compile_lock, THREAD); | 815 MutexLocker mu(Compile_lock, THREAD); |
806 update_dictionary(d_index, d_hash, p_index, p_hash, | 816 update_dictionary(d_index, d_hash, p_index, p_hash, |
807 k, class_loader, THREAD); | 817 k, class_loader, THREAD); |
808 } | 818 } |
819 | |
809 if (JvmtiExport::should_post_class_load()) { | 820 if (JvmtiExport::should_post_class_load()) { |
810 Thread *thread = THREAD; | 821 Thread *thread = THREAD; |
811 assert(thread->is_Java_thread(), "thread->is_Java_thread()"); | 822 assert(thread->is_Java_thread(), "thread->is_Java_thread()"); |
812 JvmtiExport::post_class_load((JavaThread *) thread, k()); | 823 JvmtiExport::post_class_load((JavaThread *) thread, k()); |
813 } | 824 } |
828 // so nothing to clean up. | 839 // so nothing to clean up. |
829 } else { | 840 } else { |
830 Klass *kk; | 841 Klass *kk; |
831 { | 842 { |
832 MutexLocker mu(SystemDictionary_lock, THREAD); | 843 MutexLocker mu(SystemDictionary_lock, THREAD); |
833 kk = find_class(name, ik->class_loader_data()); | 844 kk = find_class(d_index, d_hash, name, ik->class_loader_data()); |
834 } | 845 } |
835 if (kk != NULL) { | 846 if (kk != NULL) { |
836 // No clean up is needed if the shared class has been entered | 847 // No clean up is needed if the shared class has been entered |
837 // into system dictionary, as load_shared_class() won't be called | 848 // into system dictionary, as load_shared_class() won't be called |
838 // again. | 849 // again. |
859 if (load_instance_added == true) { | 870 if (load_instance_added == true) { |
860 // clean up placeholder entries for LOAD_INSTANCE success or error | 871 // clean up placeholder entries for LOAD_INSTANCE success or error |
861 // This brackets the SystemDictionary updates for both defining | 872 // This brackets the SystemDictionary updates for both defining |
862 // and initiating loaders | 873 // and initiating loaders |
863 MutexLocker mu(SystemDictionary_lock, THREAD); | 874 MutexLocker mu(SystemDictionary_lock, THREAD); |
864 placeholders()->find_and_remove(p_index, p_hash, name, loader_data, PlaceholderTable::LOAD_INSTANCE, THREAD); | 875 placeholders()->find_and_remove(p_index, p_hash, name, loader_data, PlaceholderTable::LOAD_INSTANCE, THREAD); |
865 SystemDictionary_lock->notify_all(); | 876 SystemDictionary_lock->notify_all(); |
866 } | 877 } |
867 } | 878 } |
868 | 879 |
869 if (HAS_PENDING_EXCEPTION || k.is_null()) { | 880 if (HAS_PENDING_EXCEPTION || k.is_null()) { |
870 return NULL; | 881 return NULL; |
871 } | 882 } |
883 | |
884 post_class_load_event(class_load_start_time, k, class_loader); | |
872 | 885 |
873 #ifdef ASSERT | 886 #ifdef ASSERT |
874 { | 887 { |
875 ClassLoaderData* loader_data = k->class_loader_data(); | 888 ClassLoaderData* loader_data = k->class_loader_data(); |
876 MutexLocker mu(SystemDictionary_lock, THREAD); | 889 MutexLocker mu(SystemDictionary_lock, THREAD); |
991 KlassHandle host_klass, | 1004 KlassHandle host_klass, |
992 GrowableArray<Handle>* cp_patches, | 1005 GrowableArray<Handle>* cp_patches, |
993 TRAPS) { | 1006 TRAPS) { |
994 TempNewSymbol parsed_name = NULL; | 1007 TempNewSymbol parsed_name = NULL; |
995 | 1008 |
1009 TracingTime class_load_start_time = Tracing::time(); | |
1010 | |
996 ClassLoaderData* loader_data; | 1011 ClassLoaderData* loader_data; |
997 if (host_klass.not_null()) { | 1012 if (host_klass.not_null()) { |
998 // Create a new CLD for anonymous class, that uses the same class loader | 1013 // Create a new CLD for anonymous class, that uses the same class loader |
999 // as the host_klass | 1014 // as the host_klass |
1000 assert(EnableInvokeDynamic, ""); | 1015 assert(EnableInvokeDynamic, ""); |
1046 // notify jvmti | 1061 // notify jvmti |
1047 if (JvmtiExport::should_post_class_load()) { | 1062 if (JvmtiExport::should_post_class_load()) { |
1048 assert(THREAD->is_Java_thread(), "thread->is_Java_thread()"); | 1063 assert(THREAD->is_Java_thread(), "thread->is_Java_thread()"); |
1049 JvmtiExport::post_class_load((JavaThread *) THREAD, k()); | 1064 JvmtiExport::post_class_load((JavaThread *) THREAD, k()); |
1050 } | 1065 } |
1066 | |
1067 post_class_load_event(class_load_start_time, k, class_loader); | |
1051 } | 1068 } |
1052 assert(host_klass.not_null() || cp_patches == NULL, | 1069 assert(host_klass.not_null() || cp_patches == NULL, |
1053 "cp_patches only found with host_klass"); | 1070 "cp_patches only found with host_klass"); |
1054 | 1071 |
1055 return k(); | 1072 return k(); |
1433 if (JvmtiExport::should_post_class_load()) { | 1450 if (JvmtiExport::should_post_class_load()) { |
1434 assert(THREAD->is_Java_thread(), "thread->is_Java_thread()"); | 1451 assert(THREAD->is_Java_thread(), "thread->is_Java_thread()"); |
1435 JvmtiExport::post_class_load((JavaThread *) THREAD, k()); | 1452 JvmtiExport::post_class_load((JavaThread *) THREAD, k()); |
1436 | 1453 |
1437 } | 1454 } |
1455 | |
1438 } | 1456 } |
1439 | 1457 |
1440 // Support parallel classloading | 1458 // Support parallel classloading |
1441 // All parallel class loaders, including bootstrap classloader | 1459 // All parallel class loaders, including bootstrap classloader |
1442 // lock a placeholder entry for this class/class_loader pair | 1460 // lock a placeholder entry for this class/class_loader pair |
1676 } | 1694 } |
1677 } | 1695 } |
1678 } | 1696 } |
1679 return newsize; | 1697 return newsize; |
1680 } | 1698 } |
1699 | |
1681 // Assumes classes in the SystemDictionary are only unloaded at a safepoint | 1700 // Assumes classes in the SystemDictionary are only unloaded at a safepoint |
1682 // Note: anonymous classes are not in the SD. | 1701 // Note: anonymous classes are not in the SD. |
1683 bool SystemDictionary::do_unloading(BoolObjectClosure* is_alive) { | 1702 bool SystemDictionary::do_unloading(BoolObjectClosure* is_alive) { |
1684 // First, mark for unload all ClassLoaderData referencing a dead class loader. | 1703 // First, mark for unload all ClassLoaderData referencing a dead class loader. |
1685 bool has_dead_loaders = ClassLoaderDataGraph::do_unloading(is_alive); | 1704 bool has_dead_loaders = ClassLoaderDataGraph::do_unloading(is_alive); |
1743 | 1762 |
1744 // All classes, and their class loaders | 1763 // All classes, and their class loaders |
1745 // Don't iterate over placeholders | 1764 // Don't iterate over placeholders |
1746 void SystemDictionary::classes_do(void f(Klass*, ClassLoaderData*)) { | 1765 void SystemDictionary::classes_do(void f(Klass*, ClassLoaderData*)) { |
1747 dictionary()->classes_do(f); | 1766 dictionary()->classes_do(f); |
1748 } | |
1749 | |
1750 // All classes, and their class loaders | |
1751 // (added for helpers that use HandleMarks and ResourceMarks) | |
1752 // Don't iterate over placeholders | |
1753 void SystemDictionary::classes_do(void f(Klass*, ClassLoaderData*, TRAPS), TRAPS) { | |
1754 dictionary()->classes_do(f, CHECK); | |
1755 } | 1767 } |
1756 | 1768 |
1757 void SystemDictionary::placeholders_do(void f(Symbol*)) { | 1769 void SystemDictionary::placeholders_do(void f(Symbol*)) { |
1758 placeholders()->entries_do(f); | 1770 placeholders()->entries_do(f); |
1759 } | 1771 } |
2028 // defined, not each time it is referenced from a new class loader | 2040 // defined, not each time it is referenced from a new class loader |
2029 if (k->class_loader() == class_loader()) { | 2041 if (k->class_loader() == class_loader()) { |
2030 k->set_prototype_header(markOopDesc::biased_locking_prototype()); | 2042 k->set_prototype_header(markOopDesc::biased_locking_prototype()); |
2031 } | 2043 } |
2032 } | 2044 } |
2033 | |
2034 // Assign a classid if one has not already been assigned. The | |
2035 // counter does not need to be atomically incremented since this | |
2036 // is only done while holding the SystemDictionary_lock. | |
2037 // All loaded classes get a unique ID. | |
2038 TRACE_INIT_ID(k); | |
2039 | 2045 |
2040 // Make a new system dictionary entry. | 2046 // Make a new system dictionary entry. |
2041 Klass* sd_check = find_class(d_index, d_hash, name, loader_data); | 2047 Klass* sd_check = find_class(d_index, d_hash, name, loader_data); |
2042 if (sd_check == NULL) { | 2048 if (sd_check == NULL) { |
2043 dictionary()->add_klass(name, loader_data, k); | 2049 dictionary()->add_klass(name, loader_data, k); |
2617 } | 2623 } |
2618 guarantee(probe != NULL || name != NULL, | 2624 guarantee(probe != NULL || name != NULL, |
2619 "Loaded klasses should be in SystemDictionary"); | 2625 "Loaded klasses should be in SystemDictionary"); |
2620 } | 2626 } |
2621 | 2627 |
2628 // utility function for class load event | |
2629 void SystemDictionary::post_class_load_event(TracingTime start_time, | |
2630 instanceKlassHandle k, | |
2631 Handle initiating_loader) { | |
2632 #if INCLUDE_TRACE | |
2633 EventClassLoad event(UNTIMED); | |
2634 if (event.should_commit()) { | |
2635 event.set_endtime(Tracing::time()); | |
2636 event.set_starttime(start_time); | |
2637 event.set_loadedClass(k()); | |
2638 oop defining_class_loader = k->class_loader(); | |
2639 event.set_definingClassLoader(defining_class_loader != NULL ? | |
2640 defining_class_loader->klass() : (Klass*)NULL); | |
2641 oop class_loader = initiating_loader.is_null() ? (oop)NULL : initiating_loader(); | |
2642 event.set_initiatingClassLoader(class_loader != NULL ? | |
2643 class_loader->klass() : (Klass*)NULL); | |
2644 event.commit(); | |
2645 } | |
2646 #endif /* INCLUDE_TRACE */ | |
2647 } | |
2648 | |
2622 #ifndef PRODUCT | 2649 #ifndef PRODUCT |
2623 | 2650 |
2624 // statistics code | 2651 // statistics code |
2625 class ClassStatistics: AllStatic { | 2652 class ClassStatistics: AllStatic { |
2626 private: | 2653 private: |