Mercurial > hg > graal-compiler
comparison src/share/vm/classfile/systemDictionary.cpp @ 11020:3a0774193f71
Merge
author | chegar |
---|---|
date | Wed, 19 Jun 2013 11:02:10 +0100 |
parents | f2110083203d |
children | 836a62f43af9 82af7d7a0128 |
comparison
equal
deleted
inserted
replaced
11019:eaf3742822ec | 11020:3a0774193f71 |
---|---|
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 } |
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); |
2021 // 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 |
2022 if (k->class_loader() == class_loader()) { | 2041 if (k->class_loader() == class_loader()) { |
2023 k->set_prototype_header(markOopDesc::biased_locking_prototype()); | 2042 k->set_prototype_header(markOopDesc::biased_locking_prototype()); |
2024 } | 2043 } |
2025 } | 2044 } |
2026 | |
2027 // Assign a classid if one has not already been assigned. The | |
2028 // counter does not need to be atomically incremented since this | |
2029 // is only done while holding the SystemDictionary_lock. | |
2030 // All loaded classes get a unique ID. | |
2031 TRACE_INIT_ID(k); | |
2032 | 2045 |
2033 // Make a new system dictionary entry. | 2046 // Make a new system dictionary entry. |
2034 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); |
2035 if (sd_check == NULL) { | 2048 if (sd_check == NULL) { |
2036 dictionary()->add_klass(name, loader_data, k); | 2049 dictionary()->add_klass(name, loader_data, k); |
2610 } | 2623 } |
2611 guarantee(probe != NULL || name != NULL, | 2624 guarantee(probe != NULL || name != NULL, |
2612 "Loaded klasses should be in SystemDictionary"); | 2625 "Loaded klasses should be in SystemDictionary"); |
2613 } | 2626 } |
2614 | 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 | |
2615 #ifndef PRODUCT | 2649 #ifndef PRODUCT |
2616 | 2650 |
2617 // statistics code | 2651 // statistics code |
2618 class ClassStatistics: AllStatic { | 2652 class ClassStatistics: AllStatic { |
2619 private: | 2653 private: |