Mercurial > hg > graal-compiler
comparison src/share/vm/runtime/thread.cpp @ 6725:da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
Summary: Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
Contributed-by: jmasa <jon.masamitsu@oracle.com>, stefank <stefan.karlsson@oracle.com>, mgerdin <mikael.gerdin@oracle.com>, never <tom.rodriguez@oracle.com>
author | coleenp |
---|---|
date | Sat, 01 Sep 2012 13:25:18 -0400 |
parents | 24b9c7f4cae6 |
children | 33143ee07800 |
comparison
equal
deleted
inserted
replaced
6724:36d1d483d5d6 | 6725:da91efe96a93 |
---|---|
32 #include "interpreter/interpreter.hpp" | 32 #include "interpreter/interpreter.hpp" |
33 #include "interpreter/linkResolver.hpp" | 33 #include "interpreter/linkResolver.hpp" |
34 #include "interpreter/oopMapCache.hpp" | 34 #include "interpreter/oopMapCache.hpp" |
35 #include "jvmtifiles/jvmtiEnv.hpp" | 35 #include "jvmtifiles/jvmtiEnv.hpp" |
36 #include "memory/gcLocker.inline.hpp" | 36 #include "memory/gcLocker.inline.hpp" |
37 #include "memory/metaspaceShared.hpp" | |
37 #include "memory/oopFactory.hpp" | 38 #include "memory/oopFactory.hpp" |
38 #include "memory/universe.inline.hpp" | 39 #include "memory/universe.inline.hpp" |
39 #include "oops/instanceKlass.hpp" | 40 #include "oops/instanceKlass.hpp" |
40 #include "oops/objArrayOop.hpp" | 41 #include "oops/objArrayOop.hpp" |
41 #include "oops/oop.inline.hpp" | 42 #include "oops/oop.inline.hpp" |
217 | 218 |
218 // allocated data structures | 219 // allocated data structures |
219 set_osthread(NULL); | 220 set_osthread(NULL); |
220 set_resource_area(new (mtThread)ResourceArea()); | 221 set_resource_area(new (mtThread)ResourceArea()); |
221 set_handle_area(new (mtThread) HandleArea(NULL)); | 222 set_handle_area(new (mtThread) HandleArea(NULL)); |
223 set_metadata_handles(new (ResourceObj::C_HEAP, mtClass) GrowableArray<Metadata*>(300, true)); | |
222 set_active_handles(NULL); | 224 set_active_handles(NULL); |
223 set_free_handle_block(NULL); | 225 set_free_handle_block(NULL); |
224 set_last_handle_mark(NULL); | 226 set_last_handle_mark(NULL); |
225 | 227 |
226 // This initial value ==> never claimed. | 228 // This initial value ==> never claimed. |
344 ParkEvent::Release (_SleepEvent) ; _SleepEvent = NULL ; | 346 ParkEvent::Release (_SleepEvent) ; _SleepEvent = NULL ; |
345 ParkEvent::Release (_MutexEvent) ; _MutexEvent = NULL ; | 347 ParkEvent::Release (_MutexEvent) ; _MutexEvent = NULL ; |
346 ParkEvent::Release (_MuxEvent) ; _MuxEvent = NULL ; | 348 ParkEvent::Release (_MuxEvent) ; _MuxEvent = NULL ; |
347 | 349 |
348 delete handle_area(); | 350 delete handle_area(); |
351 delete metadata_handles(); | |
349 | 352 |
350 // osthread() can be NULL, if creation of thread failed. | 353 // osthread() can be NULL, if creation of thread failed. |
351 if (osthread() != NULL) os::free_thread(osthread()); | 354 if (osthread() != NULL) os::free_thread(osthread()); |
352 | 355 |
353 delete _SR_lock; | 356 delete _SR_lock; |
815 | 818 |
816 void Thread::nmethods_do(CodeBlobClosure* cf) { | 819 void Thread::nmethods_do(CodeBlobClosure* cf) { |
817 // no nmethods in a generic thread... | 820 // no nmethods in a generic thread... |
818 } | 821 } |
819 | 822 |
823 void Thread::metadata_do(void f(Metadata*)) { | |
824 if (metadata_handles() != NULL) { | |
825 for (int i = 0; i< metadata_handles()->length(); i++) { | |
826 f(metadata_handles()->at(i)); | |
827 } | |
828 } | |
829 } | |
830 | |
820 void Thread::print_on(outputStream* st) const { | 831 void Thread::print_on(outputStream* st) const { |
821 // get_priority assumes osthread initialized | 832 // get_priority assumes osthread initialized |
822 if (osthread() != NULL) { | 833 if (osthread() != NULL) { |
823 st->print("prio=%d tid=" INTPTR_FORMAT " ", get_priority(this), this); | 834 st->print("prio=%d tid=" INTPTR_FORMAT " ", get_priority(this), this); |
824 osthread()->print_on(st); | 835 osthread()->print_on(st); |
914 #endif | 925 #endif |
915 | 926 |
916 bool Thread::is_in_stack(address adr) const { | 927 bool Thread::is_in_stack(address adr) const { |
917 assert(Thread::current() == this, "is_in_stack can only be called from current thread"); | 928 assert(Thread::current() == this, "is_in_stack can only be called from current thread"); |
918 address end = os::current_stack_pointer(); | 929 address end = os::current_stack_pointer(); |
930 // Allow non Java threads to call this without stack_base | |
931 if (_stack_base == NULL) return true; | |
919 if (stack_base() >= adr && adr >= end) return true; | 932 if (stack_base() >= adr && adr >= end) return true; |
920 | 933 |
921 return false; | 934 return false; |
922 } | 935 } |
923 | 936 |
935 // NOTE: this must be called inside the main thread. | 948 // NOTE: this must be called inside the main thread. |
936 return os::create_main_thread((JavaThread*)this); | 949 return os::create_main_thread((JavaThread*)this); |
937 } | 950 } |
938 | 951 |
939 static void initialize_class(Symbol* class_name, TRAPS) { | 952 static void initialize_class(Symbol* class_name, TRAPS) { |
940 klassOop klass = SystemDictionary::resolve_or_fail(class_name, true, CHECK); | 953 Klass* klass = SystemDictionary::resolve_or_fail(class_name, true, CHECK); |
941 instanceKlass::cast(klass)->initialize(CHECK); | 954 InstanceKlass::cast(klass)->initialize(CHECK); |
942 } | 955 } |
943 | 956 |
944 | 957 |
945 // Creates the initial ThreadGroup | 958 // Creates the initial ThreadGroup |
946 static Handle create_initial_thread_group(TRAPS) { | 959 static Handle create_initial_thread_group(TRAPS) { |
947 klassOop k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_ThreadGroup(), true, CHECK_NH); | 960 Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_ThreadGroup(), true, CHECK_NH); |
948 instanceKlassHandle klass (THREAD, k); | 961 instanceKlassHandle klass (THREAD, k); |
949 | 962 |
950 Handle system_instance = klass->allocate_instance_handle(CHECK_NH); | 963 Handle system_instance = klass->allocate_instance_handle(CHECK_NH); |
951 { | 964 { |
952 JavaValue result(T_VOID); | 965 JavaValue result(T_VOID); |
975 return main_instance; | 988 return main_instance; |
976 } | 989 } |
977 | 990 |
978 // Creates the initial Thread | 991 // Creates the initial Thread |
979 static oop create_initial_thread(Handle thread_group, JavaThread* thread, TRAPS) { | 992 static oop create_initial_thread(Handle thread_group, JavaThread* thread, TRAPS) { |
980 klassOop k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), true, CHECK_NULL); | 993 Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), true, CHECK_NULL); |
981 instanceKlassHandle klass (THREAD, k); | 994 instanceKlassHandle klass (THREAD, k); |
982 instanceHandle thread_oop = klass->allocate_instance_handle(CHECK_NULL); | 995 instanceHandle thread_oop = klass->allocate_instance_handle(CHECK_NULL); |
983 | 996 |
984 java_lang_Thread::set_thread(thread_oop(), thread); | 997 java_lang_Thread::set_thread(thread_oop(), thread); |
985 java_lang_Thread::set_priority(thread_oop(), NormPriority); | 998 java_lang_Thread::set_priority(thread_oop(), NormPriority); |
997 CHECK_NULL); | 1010 CHECK_NULL); |
998 return thread_oop(); | 1011 return thread_oop(); |
999 } | 1012 } |
1000 | 1013 |
1001 static void call_initializeSystemClass(TRAPS) { | 1014 static void call_initializeSystemClass(TRAPS) { |
1002 klassOop k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_System(), true, CHECK); | 1015 Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_System(), true, CHECK); |
1003 instanceKlassHandle klass (THREAD, k); | 1016 instanceKlassHandle klass (THREAD, k); |
1004 | 1017 |
1005 JavaValue result(T_VOID); | 1018 JavaValue result(T_VOID); |
1006 JavaCalls::call_static(&result, klass, vmSymbols::initializeSystemClass_name(), | 1019 JavaCalls::call_static(&result, klass, vmSymbols::initializeSystemClass_name(), |
1007 vmSymbols::void_method_signature(), CHECK); | 1020 vmSymbols::void_method_signature(), CHECK); |
1009 | 1022 |
1010 char java_runtime_name[128] = ""; | 1023 char java_runtime_name[128] = ""; |
1011 | 1024 |
1012 // extract the JRE name from sun.misc.Version.java_runtime_name | 1025 // extract the JRE name from sun.misc.Version.java_runtime_name |
1013 static const char* get_java_runtime_name(TRAPS) { | 1026 static const char* get_java_runtime_name(TRAPS) { |
1014 klassOop k = SystemDictionary::find(vmSymbols::sun_misc_Version(), | 1027 Klass* k = SystemDictionary::find(vmSymbols::sun_misc_Version(), |
1015 Handle(), Handle(), CHECK_AND_CLEAR_NULL); | 1028 Handle(), Handle(), CHECK_AND_CLEAR_NULL); |
1016 fieldDescriptor fd; | 1029 fieldDescriptor fd; |
1017 bool found = k != NULL && | 1030 bool found = k != NULL && |
1018 instanceKlass::cast(k)->find_local_field(vmSymbols::java_runtime_name_name(), | 1031 InstanceKlass::cast(k)->find_local_field(vmSymbols::java_runtime_name_name(), |
1019 vmSymbols::string_signature(), &fd); | 1032 vmSymbols::string_signature(), &fd); |
1020 if (found) { | 1033 if (found) { |
1021 oop name_oop = k->java_mirror()->obj_field(fd.offset()); | 1034 oop name_oop = k->java_mirror()->obj_field(fd.offset()); |
1022 if (name_oop == NULL) | 1035 if (name_oop == NULL) |
1023 return NULL; | 1036 return NULL; |
1031 } | 1044 } |
1032 | 1045 |
1033 // General purpose hook into Java code, run once when the VM is initialized. | 1046 // General purpose hook into Java code, run once when the VM is initialized. |
1034 // The Java library method itself may be changed independently from the VM. | 1047 // The Java library method itself may be changed independently from the VM. |
1035 static void call_postVMInitHook(TRAPS) { | 1048 static void call_postVMInitHook(TRAPS) { |
1036 klassOop k = SystemDictionary::PostVMInitHook_klass(); | 1049 Klass* k = SystemDictionary::PostVMInitHook_klass(); |
1037 instanceKlassHandle klass (THREAD, k); | 1050 instanceKlassHandle klass (THREAD, k); |
1038 if (klass.not_null()) { | 1051 if (klass.not_null()) { |
1039 JavaValue result(T_VOID); | 1052 JavaValue result(T_VOID); |
1040 JavaCalls::call_static(&result, klass, vmSymbols::run_method_name(), | 1053 JavaCalls::call_static(&result, klass, vmSymbols::run_method_name(), |
1041 vmSymbols::void_method_signature(), | 1054 vmSymbols::void_method_signature(), |
1047 // the vm info string | 1060 // the vm info string |
1048 ResourceMark rm(THREAD); | 1061 ResourceMark rm(THREAD); |
1049 const char *vm_info = VM_Version::vm_info_string(); | 1062 const char *vm_info = VM_Version::vm_info_string(); |
1050 | 1063 |
1051 // java.lang.System class | 1064 // java.lang.System class |
1052 klassOop k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_System(), true, CHECK); | 1065 Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_System(), true, CHECK); |
1053 instanceKlassHandle klass (THREAD, k); | 1066 instanceKlassHandle klass (THREAD, k); |
1054 | 1067 |
1055 // setProperty arguments | 1068 // setProperty arguments |
1056 Handle key_str = java_lang_String::create_from_str("java.vm.info", CHECK); | 1069 Handle key_str = java_lang_String::create_from_str("java.vm.info", CHECK); |
1057 Handle value_str = java_lang_String::create_from_str(vm_info, CHECK); | 1070 Handle value_str = java_lang_String::create_from_str(vm_info, CHECK); |
1072 | 1085 |
1073 void JavaThread::allocate_threadObj(Handle thread_group, char* thread_name, bool daemon, TRAPS) { | 1086 void JavaThread::allocate_threadObj(Handle thread_group, char* thread_name, bool daemon, TRAPS) { |
1074 assert(thread_group.not_null(), "thread group should be specified"); | 1087 assert(thread_group.not_null(), "thread group should be specified"); |
1075 assert(threadObj() == NULL, "should only create Java thread object once"); | 1088 assert(threadObj() == NULL, "should only create Java thread object once"); |
1076 | 1089 |
1077 klassOop k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), true, CHECK); | 1090 Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), true, CHECK); |
1078 instanceKlassHandle klass (THREAD, k); | 1091 instanceKlassHandle klass (THREAD, k); |
1079 instanceHandle thread_oop = klass->allocate_instance_handle(CHECK); | 1092 instanceHandle thread_oop = klass->allocate_instance_handle(CHECK); |
1080 | 1093 |
1081 java_lang_Thread::set_thread(thread_oop(), this); | 1094 java_lang_Thread::set_thread(thread_oop(), this); |
1082 java_lang_Thread::set_priority(thread_oop(), NormPriority); | 1095 java_lang_Thread::set_priority(thread_oop(), NormPriority); |
1980 tty->print("Async. exception installed at runtime exit (" INTPTR_FORMAT ")", this); | 1993 tty->print("Async. exception installed at runtime exit (" INTPTR_FORMAT ")", this); |
1981 if (has_last_Java_frame() ) { | 1994 if (has_last_Java_frame() ) { |
1982 frame f = last_frame(); | 1995 frame f = last_frame(); |
1983 tty->print(" (pc: " INTPTR_FORMAT " sp: " INTPTR_FORMAT " )", f.pc(), f.sp()); | 1996 tty->print(" (pc: " INTPTR_FORMAT " sp: " INTPTR_FORMAT " )", f.pc(), f.sp()); |
1984 } | 1997 } |
1985 tty->print_cr(" of type: %s", instanceKlass::cast(_pending_async_exception->klass())->external_name()); | 1998 tty->print_cr(" of type: %s", InstanceKlass::cast(_pending_async_exception->klass())->external_name()); |
1986 } | 1999 } |
1987 _pending_async_exception = NULL; | 2000 _pending_async_exception = NULL; |
1988 clear_has_async_exception(); | 2001 clear_has_async_exception(); |
1989 } | 2002 } |
1990 } | 2003 } |
2101 // Set async. pending exception in thread. | 2114 // Set async. pending exception in thread. |
2102 set_pending_async_exception(java_throwable); | 2115 set_pending_async_exception(java_throwable); |
2103 | 2116 |
2104 if (TraceExceptions) { | 2117 if (TraceExceptions) { |
2105 ResourceMark rm; | 2118 ResourceMark rm; |
2106 tty->print_cr("Pending Async. exception installed of type: %s", instanceKlass::cast(_pending_async_exception->klass())->external_name()); | 2119 tty->print_cr("Pending Async. exception installed of type: %s", InstanceKlass::cast(_pending_async_exception->klass())->external_name()); |
2107 } | 2120 } |
2108 // for AbortVMOnException flag | 2121 // for AbortVMOnException flag |
2109 NOT_PRODUCT(Exceptions::debug_check_abort(instanceKlass::cast(_pending_async_exception->klass())->external_name())); | 2122 NOT_PRODUCT(Exceptions::debug_check_abort(InstanceKlass::cast(_pending_async_exception->klass())->external_name())); |
2110 } | 2123 } |
2111 } | 2124 } |
2112 | 2125 |
2113 | 2126 |
2114 // Interrupt thread so it will wake up from a potential wait() | 2127 // Interrupt thread so it will wake up from a potential wait() |
2654 | 2667 |
2655 // Traverse instance variables at the end since the GC may be moving things | 2668 // Traverse instance variables at the end since the GC may be moving things |
2656 // around using this function | 2669 // around using this function |
2657 f->do_oop((oop*) &_threadObj); | 2670 f->do_oop((oop*) &_threadObj); |
2658 f->do_oop((oop*) &_vm_result); | 2671 f->do_oop((oop*) &_vm_result); |
2659 f->do_oop((oop*) &_vm_result_2); | |
2660 f->do_oop((oop*) &_exception_oop); | 2672 f->do_oop((oop*) &_exception_oop); |
2661 f->do_oop((oop*) &_pending_async_exception); | 2673 f->do_oop((oop*) &_pending_async_exception); |
2662 | 2674 |
2663 if (jvmti_thread_state() != NULL) { | 2675 if (jvmti_thread_state() != NULL) { |
2664 jvmti_thread_state()->oops_do(f); | 2676 jvmti_thread_state()->oops_do(f); |
2673 | 2685 |
2674 if (has_last_Java_frame()) { | 2686 if (has_last_Java_frame()) { |
2675 // Traverse the execution stack | 2687 // Traverse the execution stack |
2676 for(StackFrameStream fst(this); !fst.is_done(); fst.next()) { | 2688 for(StackFrameStream fst(this); !fst.is_done(); fst.next()) { |
2677 fst.current()->nmethods_do(cf); | 2689 fst.current()->nmethods_do(cf); |
2690 } | |
2691 } | |
2692 } | |
2693 | |
2694 void JavaThread::metadata_do(void f(Metadata*)) { | |
2695 Thread::metadata_do(f); | |
2696 if (has_last_Java_frame()) { | |
2697 // Traverse the execution stack to call f() on the methods in the stack | |
2698 for(StackFrameStream fst(this); !fst.is_done(); fst.next()) { | |
2699 fst.current()->metadata_do(f); | |
2700 } | |
2701 } else if (is_Compiler_thread()) { | |
2702 // need to walk ciMetadata in current compile tasks to keep alive. | |
2703 CompilerThread* ct = (CompilerThread*)this; | |
2704 if (ct->env() != NULL) { | |
2705 ct->env()->metadata_do(f); | |
2678 } | 2706 } |
2679 } | 2707 } |
2680 } | 2708 } |
2681 | 2709 |
2682 // Printing | 2710 // Printing |
2867 // Set the thread field (a JavaThread *) of the | 2895 // Set the thread field (a JavaThread *) of the |
2868 // oop representing the java_lang_Thread to the new thread (a JavaThread *). | 2896 // oop representing the java_lang_Thread to the new thread (a JavaThread *). |
2869 | 2897 |
2870 Handle thread_oop(Thread::current(), | 2898 Handle thread_oop(Thread::current(), |
2871 JNIHandles::resolve_non_null(jni_thread)); | 2899 JNIHandles::resolve_non_null(jni_thread)); |
2872 assert(instanceKlass::cast(thread_oop->klass())->is_linked(), | 2900 assert(InstanceKlass::cast(thread_oop->klass())->is_linked(), |
2873 "must be initialized"); | 2901 "must be initialized"); |
2874 set_threadObj(thread_oop()); | 2902 set_threadObj(thread_oop()); |
2875 java_lang_Thread::set_thread(thread_oop(), this); | 2903 java_lang_Thread::set_thread(thread_oop(), this); |
2876 | 2904 |
2877 if (prio == NoPriority) { | 2905 if (prio == NoPriority) { |
3068 } | 3096 } |
3069 return NULL; | 3097 return NULL; |
3070 } | 3098 } |
3071 | 3099 |
3072 | 3100 |
3073 klassOop JavaThread::security_get_caller_class(int depth) { | 3101 Klass* JavaThread::security_get_caller_class(int depth) { |
3074 vframeStream vfst(this); | 3102 vframeStream vfst(this); |
3075 vfst.security_get_caller_frame(depth); | 3103 vfst.security_get_caller_frame(depth); |
3076 if (!vfst.at_end()) { | 3104 if (!vfst.at_end()) { |
3077 return vfst.method()->method_holder(); | 3105 return vfst.method()->method_holder(); |
3078 } | 3106 } |
3121 JavaThread* Threads::_thread_list = NULL; | 3149 JavaThread* Threads::_thread_list = NULL; |
3122 int Threads::_number_of_threads = 0; | 3150 int Threads::_number_of_threads = 0; |
3123 int Threads::_number_of_non_daemon_threads = 0; | 3151 int Threads::_number_of_non_daemon_threads = 0; |
3124 int Threads::_return_code = 0; | 3152 int Threads::_return_code = 0; |
3125 size_t JavaThread::_stack_size_at_create = 0; | 3153 size_t JavaThread::_stack_size_at_create = 0; |
3154 #ifdef ASSERT | |
3155 bool Threads::_vm_complete = false; | |
3156 #endif | |
3126 | 3157 |
3127 // All JavaThreads | 3158 // All JavaThreads |
3128 #define ALL_JAVA_THREADS(X) for (JavaThread* X = _thread_list; X; X = X->next()) | 3159 #define ALL_JAVA_THREADS(X) for (JavaThread* X = _thread_list; X; X = X->next()) |
3129 | 3160 |
3130 void os_stream(); | 3161 void os_stream(); |
3318 EXCEPTION_MARK; | 3349 EXCEPTION_MARK; |
3319 | 3350 |
3320 // At this point, the Universe is initialized, but we have not executed | 3351 // At this point, the Universe is initialized, but we have not executed |
3321 // any byte code. Now is a good time (the only time) to dump out the | 3352 // any byte code. Now is a good time (the only time) to dump out the |
3322 // internal state of the JVM for sharing. | 3353 // internal state of the JVM for sharing. |
3323 | |
3324 if (DumpSharedSpaces) { | 3354 if (DumpSharedSpaces) { |
3325 Universe::heap()->preload_and_dump(CHECK_0); | 3355 MetaspaceShared::preload_and_dump(CHECK_0); |
3326 ShouldNotReachHere(); | 3356 ShouldNotReachHere(); |
3327 } | 3357 } |
3328 | 3358 |
3329 // Always call even when there are not JVMTI environments yet, since environments | 3359 // Always call even when there are not JVMTI environments yet, since environments |
3330 // may be attached late and JVMTI must track phases of VM execution | 3360 // may be attached late and JVMTI must track phases of VM execution |
3349 if (AggressiveOpts) { | 3379 if (AggressiveOpts) { |
3350 { | 3380 { |
3351 // Forcibly initialize java/util/HashMap and mutate the private | 3381 // Forcibly initialize java/util/HashMap and mutate the private |
3352 // static final "frontCacheEnabled" field before we start creating instances | 3382 // static final "frontCacheEnabled" field before we start creating instances |
3353 #ifdef ASSERT | 3383 #ifdef ASSERT |
3354 klassOop tmp_k = SystemDictionary::find(vmSymbols::java_util_HashMap(), Handle(), Handle(), CHECK_0); | 3384 Klass* tmp_k = SystemDictionary::find(vmSymbols::java_util_HashMap(), Handle(), Handle(), CHECK_0); |
3355 assert(tmp_k == NULL, "java/util/HashMap should not be loaded yet"); | 3385 assert(tmp_k == NULL, "java/util/HashMap should not be loaded yet"); |
3356 #endif | 3386 #endif |
3357 klassOop k_o = SystemDictionary::resolve_or_null(vmSymbols::java_util_HashMap(), Handle(), Handle(), CHECK_0); | 3387 Klass* k_o = SystemDictionary::resolve_or_null(vmSymbols::java_util_HashMap(), Handle(), Handle(), CHECK_0); |
3358 KlassHandle k = KlassHandle(THREAD, k_o); | 3388 KlassHandle k = KlassHandle(THREAD, k_o); |
3359 guarantee(k.not_null(), "Must find java/util/HashMap"); | 3389 guarantee(k.not_null(), "Must find java/util/HashMap"); |
3360 instanceKlassHandle ik = instanceKlassHandle(THREAD, k()); | 3390 instanceKlassHandle ik = instanceKlassHandle(THREAD, k()); |
3361 ik->initialize(CHECK_0); | 3391 ik->initialize(CHECK_0); |
3362 fieldDescriptor fd; | 3392 fieldDescriptor fd; |
3367 } | 3397 } |
3368 | 3398 |
3369 if (UseStringCache) { | 3399 if (UseStringCache) { |
3370 // Forcibly initialize java/lang/StringValue and mutate the private | 3400 // Forcibly initialize java/lang/StringValue and mutate the private |
3371 // static final "stringCacheEnabled" field before we start creating instances | 3401 // static final "stringCacheEnabled" field before we start creating instances |
3372 klassOop k_o = SystemDictionary::resolve_or_null(vmSymbols::java_lang_StringValue(), Handle(), Handle(), CHECK_0); | 3402 Klass* k_o = SystemDictionary::resolve_or_null(vmSymbols::java_lang_StringValue(), Handle(), Handle(), CHECK_0); |
3373 // Possible that StringValue isn't present: if so, silently don't break | 3403 // Possible that StringValue isn't present: if so, silently don't break |
3374 if (k_o != NULL) { | 3404 if (k_o != NULL) { |
3375 KlassHandle k = KlassHandle(THREAD, k_o); | 3405 KlassHandle k = KlassHandle(THREAD, k_o); |
3376 instanceKlassHandle ik = instanceKlassHandle(THREAD, k()); | 3406 instanceKlassHandle ik = instanceKlassHandle(THREAD, k()); |
3377 ik->initialize(CHECK_0); | 3407 ik->initialize(CHECK_0); |
3572 | 3602 |
3573 // Give os specific code one last chance to start | 3603 // Give os specific code one last chance to start |
3574 os::init_3(); | 3604 os::init_3(); |
3575 | 3605 |
3576 create_vm_timer.end(); | 3606 create_vm_timer.end(); |
3607 #ifdef ASSERT | |
3608 _vm_complete = true; | |
3609 #endif | |
3577 return JNI_OK; | 3610 return JNI_OK; |
3578 } | 3611 } |
3579 | 3612 |
3580 // type for the Agent_OnLoad and JVM_OnLoad entry points | 3613 // type for the Agent_OnLoad and JVM_OnLoad entry points |
3581 extern "C" { | 3614 extern "C" { |
3779 if (this->has_pending_exception()) { | 3812 if (this->has_pending_exception()) { |
3780 this->clear_pending_exception(); | 3813 this->clear_pending_exception(); |
3781 } | 3814 } |
3782 | 3815 |
3783 EXCEPTION_MARK; | 3816 EXCEPTION_MARK; |
3784 klassOop k = | 3817 Klass* k = |
3785 SystemDictionary::resolve_or_null(vmSymbols::java_lang_Shutdown(), | 3818 SystemDictionary::resolve_or_null(vmSymbols::java_lang_Shutdown(), |
3786 THREAD); | 3819 THREAD); |
3787 if (k != NULL) { | 3820 if (k != NULL) { |
3788 // SystemDictionary::resolve_or_null will return null if there was | 3821 // SystemDictionary::resolve_or_null will return null if there was |
3789 // an exception. If we cannot load the Shutdown class, just don't | 3822 // an exception. If we cannot load the Shutdown class, just don't |
3838 // + Return to caller | 3871 // + Return to caller |
3839 | 3872 |
3840 bool Threads::destroy_vm() { | 3873 bool Threads::destroy_vm() { |
3841 JavaThread* thread = JavaThread::current(); | 3874 JavaThread* thread = JavaThread::current(); |
3842 | 3875 |
3876 #ifdef ASSERT | |
3877 _vm_complete = false; | |
3878 #endif | |
3843 // Wait until we are the last non-daemon thread to execute | 3879 // Wait until we are the last non-daemon thread to execute |
3844 { MutexLocker nu(Threads_lock); | 3880 { MutexLocker nu(Threads_lock); |
3845 while (Threads::number_of_non_daemon_threads() > 1 ) | 3881 while (Threads::number_of_non_daemon_threads() > 1 ) |
3846 // This wait should make safepoint checks, wait without a timeout, | 3882 // This wait should make safepoint checks, wait without a timeout, |
3847 // and wait as a suspend-equivalent condition. | 3883 // and wait as a suspend-equivalent condition. |
4096 void Threads::nmethods_do(CodeBlobClosure* cf) { | 4132 void Threads::nmethods_do(CodeBlobClosure* cf) { |
4097 ALL_JAVA_THREADS(p) { | 4133 ALL_JAVA_THREADS(p) { |
4098 p->nmethods_do(cf); | 4134 p->nmethods_do(cf); |
4099 } | 4135 } |
4100 VMThread::vm_thread()->nmethods_do(cf); | 4136 VMThread::vm_thread()->nmethods_do(cf); |
4137 } | |
4138 | |
4139 void Threads::metadata_do(void f(Metadata*)) { | |
4140 ALL_JAVA_THREADS(p) { | |
4141 p->metadata_do(f); | |
4142 } | |
4101 } | 4143 } |
4102 | 4144 |
4103 void Threads::gc_epilogue() { | 4145 void Threads::gc_epilogue() { |
4104 ALL_JAVA_THREADS(p) { | 4146 ALL_JAVA_THREADS(p) { |
4105 p->gc_epilogue(); | 4147 p->gc_epilogue(); |