comparison src/share/vm/runtime/thread.cpp @ 2181:d25d4ca69222

Merge.
author Thomas Wuerthinger <wuerthinger@ssw.jku.at>
date Wed, 16 Feb 2011 13:47:20 +0100
parents 91fe28b03d6a 3582bf76420e
children 0cd39a385a72
comparison
equal deleted inserted replaced
2108:50b45e2d9725 2181:d25d4ca69222
29 #include "classfile/vmSymbols.hpp" 29 #include "classfile/vmSymbols.hpp"
30 #include "code/scopeDesc.hpp" 30 #include "code/scopeDesc.hpp"
31 #include "compiler/compileBroker.hpp" 31 #include "compiler/compileBroker.hpp"
32 #include "interpreter/interpreter.hpp" 32 #include "interpreter/interpreter.hpp"
33 #include "interpreter/linkResolver.hpp" 33 #include "interpreter/linkResolver.hpp"
34 #include "jvmtifiles/jvmtiEnv.hpp"
34 #include "memory/oopFactory.hpp" 35 #include "memory/oopFactory.hpp"
35 #include "memory/universe.inline.hpp" 36 #include "memory/universe.inline.hpp"
36 #include "oops/instanceKlass.hpp" 37 #include "oops/instanceKlass.hpp"
37 #include "oops/objArrayOop.hpp" 38 #include "oops/objArrayOop.hpp"
38 #include "oops/oop.inline.hpp" 39 #include "oops/oop.inline.hpp"
39 #include "oops/symbolOop.hpp" 40 #include "oops/symbol.hpp"
40 #include "prims/jvm_misc.hpp" 41 #include "prims/jvm_misc.hpp"
41 #include "prims/jvmtiExport.hpp" 42 #include "prims/jvmtiExport.hpp"
42 #include "prims/jvmtiThreadState.hpp" 43 #include "prims/jvmtiThreadState.hpp"
43 #include "prims/privilegedStack.hpp" 44 #include "prims/privilegedStack.hpp"
44 #include "runtime/aprofiler.hpp" 45 #include "runtime/aprofiler.hpp"
888 bool Thread::set_as_starting_thread() { 889 bool Thread::set_as_starting_thread() {
889 // NOTE: this must be called inside the main thread. 890 // NOTE: this must be called inside the main thread.
890 return os::create_main_thread((JavaThread*)this); 891 return os::create_main_thread((JavaThread*)this);
891 } 892 }
892 893
893 static void initialize_class(symbolHandle class_name, TRAPS) { 894 static void initialize_class(Symbol* class_name, TRAPS) {
894 klassOop klass = SystemDictionary::resolve_or_fail(class_name, true, CHECK); 895 klassOop klass = SystemDictionary::resolve_or_fail(class_name, true, CHECK);
895 instanceKlass::cast(klass)->initialize(CHECK); 896 instanceKlass::cast(klass)->initialize(CHECK);
896 } 897 }
897 898
898 899
899 // Creates the initial ThreadGroup 900 // Creates the initial ThreadGroup
900 static Handle create_initial_thread_group(TRAPS) { 901 static Handle create_initial_thread_group(TRAPS) {
901 klassOop k = SystemDictionary::resolve_or_fail(vmSymbolHandles::java_lang_ThreadGroup(), true, CHECK_NH); 902 klassOop k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_ThreadGroup(), true, CHECK_NH);
902 instanceKlassHandle klass (THREAD, k); 903 instanceKlassHandle klass (THREAD, k);
903 904
904 Handle system_instance = klass->allocate_instance_handle(CHECK_NH); 905 Handle system_instance = klass->allocate_instance_handle(CHECK_NH);
905 { 906 {
906 JavaValue result(T_VOID); 907 JavaValue result(T_VOID);
907 JavaCalls::call_special(&result, 908 JavaCalls::call_special(&result,
908 system_instance, 909 system_instance,
909 klass, 910 klass,
910 vmSymbolHandles::object_initializer_name(), 911 vmSymbols::object_initializer_name(),
911 vmSymbolHandles::void_method_signature(), 912 vmSymbols::void_method_signature(),
912 CHECK_NH); 913 CHECK_NH);
913 } 914 }
914 Universe::set_system_thread_group(system_instance()); 915 Universe::set_system_thread_group(system_instance());
915 916
916 Handle main_instance = klass->allocate_instance_handle(CHECK_NH); 917 Handle main_instance = klass->allocate_instance_handle(CHECK_NH);
918 JavaValue result(T_VOID); 919 JavaValue result(T_VOID);
919 Handle string = java_lang_String::create_from_str("main", CHECK_NH); 920 Handle string = java_lang_String::create_from_str("main", CHECK_NH);
920 JavaCalls::call_special(&result, 921 JavaCalls::call_special(&result,
921 main_instance, 922 main_instance,
922 klass, 923 klass,
923 vmSymbolHandles::object_initializer_name(), 924 vmSymbols::object_initializer_name(),
924 vmSymbolHandles::threadgroup_string_void_signature(), 925 vmSymbols::threadgroup_string_void_signature(),
925 system_instance, 926 system_instance,
926 string, 927 string,
927 CHECK_NH); 928 CHECK_NH);
928 } 929 }
929 return main_instance; 930 return main_instance;
930 } 931 }
931 932
932 // Creates the initial Thread 933 // Creates the initial Thread
933 static oop create_initial_thread(Handle thread_group, JavaThread* thread, TRAPS) { 934 static oop create_initial_thread(Handle thread_group, JavaThread* thread, TRAPS) {
934 klassOop k = SystemDictionary::resolve_or_fail(vmSymbolHandles::java_lang_Thread(), true, CHECK_NULL); 935 klassOop k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), true, CHECK_NULL);
935 instanceKlassHandle klass (THREAD, k); 936 instanceKlassHandle klass (THREAD, k);
936 instanceHandle thread_oop = klass->allocate_instance_handle(CHECK_NULL); 937 instanceHandle thread_oop = klass->allocate_instance_handle(CHECK_NULL);
937 938
938 java_lang_Thread::set_thread(thread_oop(), thread); 939 java_lang_Thread::set_thread(thread_oop(), thread);
939 java_lang_Thread::set_priority(thread_oop(), NormPriority); 940 java_lang_Thread::set_priority(thread_oop(), NormPriority);
942 Handle string = java_lang_String::create_from_str("main", CHECK_NULL); 943 Handle string = java_lang_String::create_from_str("main", CHECK_NULL);
943 944
944 JavaValue result(T_VOID); 945 JavaValue result(T_VOID);
945 JavaCalls::call_special(&result, thread_oop, 946 JavaCalls::call_special(&result, thread_oop,
946 klass, 947 klass,
947 vmSymbolHandles::object_initializer_name(), 948 vmSymbols::object_initializer_name(),
948 vmSymbolHandles::threadgroup_string_void_signature(), 949 vmSymbols::threadgroup_string_void_signature(),
949 thread_group, 950 thread_group,
950 string, 951 string,
951 CHECK_NULL); 952 CHECK_NULL);
952 return thread_oop(); 953 return thread_oop();
953 } 954 }
954 955
955 static void call_initializeSystemClass(TRAPS) { 956 static void call_initializeSystemClass(TRAPS) {
956 klassOop k = SystemDictionary::resolve_or_fail(vmSymbolHandles::java_lang_System(), true, CHECK); 957 klassOop k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_System(), true, CHECK);
957 instanceKlassHandle klass (THREAD, k); 958 instanceKlassHandle klass (THREAD, k);
958 959
959 JavaValue result(T_VOID); 960 JavaValue result(T_VOID);
960 JavaCalls::call_static(&result, klass, vmSymbolHandles::initializeSystemClass_name(), 961 JavaCalls::call_static(&result, klass, vmSymbols::initializeSystemClass_name(),
961 vmSymbolHandles::void_method_signature(), CHECK); 962 vmSymbols::void_method_signature(), CHECK);
962 } 963 }
963 964
964 #ifdef KERNEL 965 #ifdef KERNEL
965 static void set_jkernel_boot_classloader_hook(TRAPS) { 966 static void set_jkernel_boot_classloader_hook(TRAPS) {
966 klassOop k = SystemDictionary::sun_jkernel_DownloadManager_klass(); 967 klassOop k = SystemDictionary::sun_jkernel_DownloadManager_klass();
970 // sun.jkernel.DownloadManager may not present in the JDK; just return 971 // sun.jkernel.DownloadManager may not present in the JDK; just return
971 return; 972 return;
972 } 973 }
973 974
974 JavaValue result(T_VOID); 975 JavaValue result(T_VOID);
975 JavaCalls::call_static(&result, klass, vmSymbolHandles::setBootClassLoaderHook_name(), 976 JavaCalls::call_static(&result, klass, vmSymbols::setBootClassLoaderHook_name(),
976 vmSymbolHandles::void_method_signature(), CHECK); 977 vmSymbols::void_method_signature(), CHECK);
977 } 978 }
978 #endif // KERNEL 979 #endif // KERNEL
980
981 // General purpose hook into Java code, run once when the VM is initialized.
982 // The Java library method itself may be changed independently from the VM.
983 static void call_postVMInitHook(TRAPS) {
984 klassOop k = SystemDictionary::sun_misc_PostVMInitHook_klass();
985 instanceKlassHandle klass (THREAD, k);
986 if (klass.not_null()) {
987 JavaValue result(T_VOID);
988 JavaCalls::call_static(&result, klass, vmSymbols::run_method_name(),
989 vmSymbols::void_method_signature(),
990 CHECK);
991 }
992 }
979 993
980 static void reset_vm_info_property(TRAPS) { 994 static void reset_vm_info_property(TRAPS) {
981 // the vm info string 995 // the vm info string
982 ResourceMark rm(THREAD); 996 ResourceMark rm(THREAD);
983 const char *vm_info = VM_Version::vm_info_string(); 997 const char *vm_info = VM_Version::vm_info_string();
984 998
985 // java.lang.System class 999 // java.lang.System class
986 klassOop k = SystemDictionary::resolve_or_fail(vmSymbolHandles::java_lang_System(), true, CHECK); 1000 klassOop k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_System(), true, CHECK);
987 instanceKlassHandle klass (THREAD, k); 1001 instanceKlassHandle klass (THREAD, k);
988 1002
989 // setProperty arguments 1003 // setProperty arguments
990 Handle key_str = java_lang_String::create_from_str("java.vm.info", CHECK); 1004 Handle key_str = java_lang_String::create_from_str("java.vm.info", CHECK);
991 Handle value_str = java_lang_String::create_from_str(vm_info, CHECK); 1005 Handle value_str = java_lang_String::create_from_str(vm_info, CHECK);
994 JavaValue r(T_OBJECT); 1008 JavaValue r(T_OBJECT);
995 1009
996 // public static String setProperty(String key, String value); 1010 // public static String setProperty(String key, String value);
997 JavaCalls::call_static(&r, 1011 JavaCalls::call_static(&r,
998 klass, 1012 klass,
999 vmSymbolHandles::setProperty_name(), 1013 vmSymbols::setProperty_name(),
1000 vmSymbolHandles::string_string_string_signature(), 1014 vmSymbols::string_string_string_signature(),
1001 key_str, 1015 key_str,
1002 value_str, 1016 value_str,
1003 CHECK); 1017 CHECK);
1004 } 1018 }
1005 1019
1006 1020
1007 void JavaThread::allocate_threadObj(Handle thread_group, char* thread_name, bool daemon, TRAPS) { 1021 void JavaThread::allocate_threadObj(Handle thread_group, char* thread_name, bool daemon, TRAPS) {
1008 assert(thread_group.not_null(), "thread group should be specified"); 1022 assert(thread_group.not_null(), "thread group should be specified");
1009 assert(threadObj() == NULL, "should only create Java thread object once"); 1023 assert(threadObj() == NULL, "should only create Java thread object once");
1010 1024
1011 klassOop k = SystemDictionary::resolve_or_fail(vmSymbolHandles::java_lang_Thread(), true, CHECK); 1025 klassOop k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), true, CHECK);
1012 instanceKlassHandle klass (THREAD, k); 1026 instanceKlassHandle klass (THREAD, k);
1013 instanceHandle thread_oop = klass->allocate_instance_handle(CHECK); 1027 instanceHandle thread_oop = klass->allocate_instance_handle(CHECK);
1014 1028
1015 java_lang_Thread::set_thread(thread_oop(), this); 1029 java_lang_Thread::set_thread(thread_oop(), this);
1016 java_lang_Thread::set_priority(thread_oop(), NormPriority); 1030 java_lang_Thread::set_priority(thread_oop(), NormPriority);
1021 Handle name = java_lang_String::create_from_str(thread_name, CHECK); 1035 Handle name = java_lang_String::create_from_str(thread_name, CHECK);
1022 // Thread gets assigned specified name and null target 1036 // Thread gets assigned specified name and null target
1023 JavaCalls::call_special(&result, 1037 JavaCalls::call_special(&result,
1024 thread_oop, 1038 thread_oop,
1025 klass, 1039 klass,
1026 vmSymbolHandles::object_initializer_name(), 1040 vmSymbols::object_initializer_name(),
1027 vmSymbolHandles::threadgroup_string_void_signature(), 1041 vmSymbols::threadgroup_string_void_signature(),
1028 thread_group, // Argument 1 1042 thread_group, // Argument 1
1029 name, // Argument 2 1043 name, // Argument 2
1030 THREAD); 1044 THREAD);
1031 } else { 1045 } else {
1032 // Thread gets assigned name "Thread-nnn" and null target 1046 // Thread gets assigned name "Thread-nnn" and null target
1033 // (java.lang.Thread doesn't have a constructor taking only a ThreadGroup argument) 1047 // (java.lang.Thread doesn't have a constructor taking only a ThreadGroup argument)
1034 JavaCalls::call_special(&result, 1048 JavaCalls::call_special(&result,
1035 thread_oop, 1049 thread_oop,
1036 klass, 1050 klass,
1037 vmSymbolHandles::object_initializer_name(), 1051 vmSymbols::object_initializer_name(),
1038 vmSymbolHandles::threadgroup_runnable_void_signature(), 1052 vmSymbols::threadgroup_runnable_void_signature(),
1039 thread_group, // Argument 1 1053 thread_group, // Argument 1
1040 Handle(), // Argument 2 1054 Handle(), // Argument 2
1041 THREAD); 1055 THREAD);
1042 } 1056 }
1043 1057
1054 Handle threadObj(this, this->threadObj()); 1068 Handle threadObj(this, this->threadObj());
1055 1069
1056 JavaCalls::call_special(&result, 1070 JavaCalls::call_special(&result,
1057 thread_group, 1071 thread_group,
1058 group, 1072 group,
1059 vmSymbolHandles::add_method_name(), 1073 vmSymbols::add_method_name(),
1060 vmSymbolHandles::thread_void_signature(), 1074 vmSymbols::thread_void_signature(),
1061 threadObj, // Arg 1 1075 threadObj, // Arg 1
1062 THREAD); 1076 THREAD);
1063 1077
1064 1078
1065 } 1079 }
1494 1508
1495 void JavaThread::thread_main_inner() { 1509 void JavaThread::thread_main_inner() {
1496 assert(JavaThread::current() == this, "sanity check"); 1510 assert(JavaThread::current() == this, "sanity check");
1497 assert(this->threadObj() != NULL, "just checking"); 1511 assert(this->threadObj() != NULL, "just checking");
1498 1512
1499 // Execute thread entry point. If this thread is being asked to restart, 1513 // Execute thread entry point unless this thread has a pending exception
1500 // or has been stopped before starting, do not reexecute entry point. 1514 // or has been stopped before starting.
1501 // Note: Due to JVM_StopThread we can have pending exceptions already! 1515 // Note: Due to JVM_StopThread we can have pending exceptions already!
1502 if (!this->has_pending_exception() && !java_lang_Thread::is_stillborn(this->threadObj())) { 1516 if (!this->has_pending_exception() &&
1503 // enter the thread's entry point only if we have no pending exceptions 1517 !java_lang_Thread::is_stillborn(this->threadObj())) {
1504 HandleMark hm(this); 1518 HandleMark hm(this);
1505 this->entry_point()(this, this); 1519 this->entry_point()(this, this);
1506 } 1520 }
1507 1521
1508 DTRACE_THREAD_PROBE(stop, this); 1522 DTRACE_THREAD_PROBE(stop, this);
1517 Handle threadObj(thread, thread->threadObj()); 1531 Handle threadObj(thread, thread->threadObj());
1518 assert(threadObj.not_null(), "java thread object must exist"); 1532 assert(threadObj.not_null(), "java thread object must exist");
1519 ObjectLocker lock(threadObj, thread); 1533 ObjectLocker lock(threadObj, thread);
1520 // Ignore pending exception (ThreadDeath), since we are exiting anyway 1534 // Ignore pending exception (ThreadDeath), since we are exiting anyway
1521 thread->clear_pending_exception(); 1535 thread->clear_pending_exception();
1522 // It is of profound importance that we set the stillborn bit and reset the thread object,
1523 // before we do the notify. Since, changing these two variable will make JVM_IsAlive return
1524 // false. So in case another thread is doing a join on this thread , it will detect that the thread
1525 // is dead when it gets notified.
1526 java_lang_Thread::set_stillborn(threadObj());
1527 // Thread is exiting. So set thread_status field in java.lang.Thread class to TERMINATED. 1536 // Thread is exiting. So set thread_status field in java.lang.Thread class to TERMINATED.
1528 java_lang_Thread::set_thread_status(threadObj(), java_lang_Thread::TERMINATED); 1537 java_lang_Thread::set_thread_status(threadObj(), java_lang_Thread::TERMINATED);
1538 // Clear the native thread instance - this makes isAlive return false and allows the join()
1539 // to complete once we've done the notify_all below
1529 java_lang_Thread::set_thread(threadObj(), NULL); 1540 java_lang_Thread::set_thread(threadObj(), NULL);
1530 lock.notify_all(thread); 1541 lock.notify_all(thread);
1531 // Ignore pending exception (ThreadDeath), since we are exiting anyway 1542 // Ignore pending exception (ThreadDeath), since we are exiting anyway
1532 thread->clear_pending_exception(); 1543 thread->clear_pending_exception();
1533 } 1544 }
1574 // so call ThreadGroup.uncaughtException() 1585 // so call ThreadGroup.uncaughtException()
1575 KlassHandle recvrKlass(THREAD, threadObj->klass()); 1586 KlassHandle recvrKlass(THREAD, threadObj->klass());
1576 CallInfo callinfo; 1587 CallInfo callinfo;
1577 KlassHandle thread_klass(THREAD, SystemDictionary::Thread_klass()); 1588 KlassHandle thread_klass(THREAD, SystemDictionary::Thread_klass());
1578 LinkResolver::resolve_virtual_call(callinfo, threadObj, recvrKlass, thread_klass, 1589 LinkResolver::resolve_virtual_call(callinfo, threadObj, recvrKlass, thread_klass,
1579 vmSymbolHandles::dispatchUncaughtException_name(), 1590 vmSymbols::dispatchUncaughtException_name(),
1580 vmSymbolHandles::throwable_void_signature(), 1591 vmSymbols::throwable_void_signature(),
1581 KlassHandle(), false, false, THREAD); 1592 KlassHandle(), false, false, THREAD);
1582 CLEAR_PENDING_EXCEPTION; 1593 CLEAR_PENDING_EXCEPTION;
1583 methodHandle method = callinfo.selected_method(); 1594 methodHandle method = callinfo.selected_method();
1584 if (method.not_null()) { 1595 if (method.not_null()) {
1585 JavaValue result(T_VOID); 1596 JavaValue result(T_VOID);
1586 JavaCalls::call_virtual(&result, 1597 JavaCalls::call_virtual(&result,
1587 threadObj, thread_klass, 1598 threadObj, thread_klass,
1588 vmSymbolHandles::dispatchUncaughtException_name(), 1599 vmSymbols::dispatchUncaughtException_name(),
1589 vmSymbolHandles::throwable_void_signature(), 1600 vmSymbols::throwable_void_signature(),
1590 uncaught_exception, 1601 uncaught_exception,
1591 THREAD); 1602 THREAD);
1592 } else { 1603 } else {
1593 KlassHandle thread_group(THREAD, SystemDictionary::ThreadGroup_klass()); 1604 KlassHandle thread_group(THREAD, SystemDictionary::ThreadGroup_klass());
1594 JavaValue result(T_VOID); 1605 JavaValue result(T_VOID);
1595 JavaCalls::call_virtual(&result, 1606 JavaCalls::call_virtual(&result,
1596 group, thread_group, 1607 group, thread_group,
1597 vmSymbolHandles::uncaughtException_name(), 1608 vmSymbols::uncaughtException_name(),
1598 vmSymbolHandles::thread_throwable_void_signature(), 1609 vmSymbols::thread_throwable_void_signature(),
1599 threadObj, // Arg 1 1610 threadObj, // Arg 1
1600 uncaught_exception, // Arg 2 1611 uncaught_exception, // Arg 2
1601 THREAD); 1612 THREAD);
1602 } 1613 }
1603 CLEAR_PENDING_EXCEPTION; 1614 CLEAR_PENDING_EXCEPTION;
1612 EXCEPTION_MARK; 1623 EXCEPTION_MARK;
1613 JavaValue result(T_VOID); 1624 JavaValue result(T_VOID);
1614 KlassHandle thread_klass(THREAD, SystemDictionary::Thread_klass()); 1625 KlassHandle thread_klass(THREAD, SystemDictionary::Thread_klass());
1615 JavaCalls::call_virtual(&result, 1626 JavaCalls::call_virtual(&result,
1616 threadObj, thread_klass, 1627 threadObj, thread_klass,
1617 vmSymbolHandles::exit_method_name(), 1628 vmSymbols::exit_method_name(),
1618 vmSymbolHandles::void_method_signature(), 1629 vmSymbols::void_method_signature(),
1619 THREAD); 1630 THREAD);
1620 CLEAR_PENDING_EXCEPTION; 1631 CLEAR_PENDING_EXCEPTION;
1621 } 1632 }
1622 } 1633 }
1623 1634
1697 1708
1698 if (UseTLAB) { 1709 if (UseTLAB) {
1699 tlab().make_parsable(true); // retire TLAB 1710 tlab().make_parsable(true); // retire TLAB
1700 } 1711 }
1701 1712
1702 if (jvmti_thread_state() != NULL) { 1713 if (JvmtiEnv::environments_might_exist()) {
1703 JvmtiExport::cleanup_thread(this); 1714 JvmtiExport::cleanup_thread(this);
1704 } 1715 }
1705 1716
1706 #ifndef SERIALGC 1717 #ifndef SERIALGC
1707 // We must flush G1-related buffers before removing a thread from 1718 // We must flush G1-related buffers before removing a thread from
1982 // (the compiler thread should not be a Java thread -- fix in 1.4.2) 1993 // (the compiler thread should not be a Java thread -- fix in 1.4.2)
1983 1994
1984 // (tw) May we do this? 1995 // (tw) May we do this?
1985 //if (is_Compiler_thread()) return; 1996 //if (is_Compiler_thread()) return;
1986 1997
1987 // This is a change from JDK 1.1, but JDK 1.2 will also do it:
1988 if (java_throwable->is_a(SystemDictionary::ThreadDeath_klass())) {
1989 java_lang_Thread::set_stillborn(threadObj());
1990 }
1991
1992 { 1998 {
1993 // Actually throw the Throwable against the target Thread - however 1999 // Actually throw the Throwable against the target Thread - however
1994 // only if there is no thread death exception installed already. 2000 // only if there is no thread death exception installed already.
1995 if (_pending_async_exception == NULL || !_pending_async_exception->is_a(SystemDictionary::ThreadDeath_klass())) { 2001 if (_pending_async_exception == NULL || !_pending_async_exception->is_a(SystemDictionary::ThreadDeath_klass())) {
1996 // If the topmost frame is a runtime stub, then we are calling into 2002 // If the topmost frame is a runtime stub, then we are calling into
3148 if (EagerXrunInit && Arguments::init_libraries_at_startup()) { 3154 if (EagerXrunInit && Arguments::init_libraries_at_startup()) {
3149 create_vm_init_libraries(); 3155 create_vm_init_libraries();
3150 } 3156 }
3151 3157
3152 if (InitializeJavaLangString) { 3158 if (InitializeJavaLangString) {
3153 initialize_class(vmSymbolHandles::java_lang_String(), CHECK_0); 3159 initialize_class(vmSymbols::java_lang_String(), CHECK_0);
3154 } else { 3160 } else {
3155 warning("java.lang.String not initialized"); 3161 warning("java.lang.String not initialized");
3156 } 3162 }
3157 3163
3158 if (AggressiveOpts) { 3164 if (AggressiveOpts) {
3159 { 3165 {
3160 // Forcibly initialize java/util/HashMap and mutate the private 3166 // Forcibly initialize java/util/HashMap and mutate the private
3161 // static final "frontCacheEnabled" field before we start creating instances 3167 // static final "frontCacheEnabled" field before we start creating instances
3162 #ifdef ASSERT 3168 #ifdef ASSERT
3163 klassOop tmp_k = SystemDictionary::find(vmSymbolHandles::java_util_HashMap(), Handle(), Handle(), CHECK_0); 3169 klassOop tmp_k = SystemDictionary::find(vmSymbols::java_util_HashMap(), Handle(), Handle(), CHECK_0);
3164 assert(tmp_k == NULL, "java/util/HashMap should not be loaded yet"); 3170 assert(tmp_k == NULL, "java/util/HashMap should not be loaded yet");
3165 #endif 3171 #endif
3166 klassOop k_o = SystemDictionary::resolve_or_null(vmSymbolHandles::java_util_HashMap(), Handle(), Handle(), CHECK_0); 3172 klassOop k_o = SystemDictionary::resolve_or_null(vmSymbols::java_util_HashMap(), Handle(), Handle(), CHECK_0);
3167 KlassHandle k = KlassHandle(THREAD, k_o); 3173 KlassHandle k = KlassHandle(THREAD, k_o);
3168 guarantee(k.not_null(), "Must find java/util/HashMap"); 3174 guarantee(k.not_null(), "Must find java/util/HashMap");
3169 instanceKlassHandle ik = instanceKlassHandle(THREAD, k()); 3175 instanceKlassHandle ik = instanceKlassHandle(THREAD, k());
3170 ik->initialize(CHECK_0); 3176 ik->initialize(CHECK_0);
3171 fieldDescriptor fd; 3177 fieldDescriptor fd;
3176 } 3182 }
3177 3183
3178 if (UseStringCache) { 3184 if (UseStringCache) {
3179 // Forcibly initialize java/lang/StringValue and mutate the private 3185 // Forcibly initialize java/lang/StringValue and mutate the private
3180 // static final "stringCacheEnabled" field before we start creating instances 3186 // static final "stringCacheEnabled" field before we start creating instances
3181 klassOop k_o = SystemDictionary::resolve_or_null(vmSymbolHandles::java_lang_StringValue(), Handle(), Handle(), CHECK_0); 3187 klassOop k_o = SystemDictionary::resolve_or_null(vmSymbols::java_lang_StringValue(), Handle(), Handle(), CHECK_0);
3182 // Possible that StringValue isn't present: if so, silently don't break 3188 // Possible that StringValue isn't present: if so, silently don't break
3183 if (k_o != NULL) { 3189 if (k_o != NULL) {
3184 KlassHandle k = KlassHandle(THREAD, k_o); 3190 KlassHandle k = KlassHandle(THREAD, k_o);
3185 instanceKlassHandle ik = instanceKlassHandle(THREAD, k()); 3191 instanceKlassHandle ik = instanceKlassHandle(THREAD, k());
3186 ik->initialize(CHECK_0); 3192 ik->initialize(CHECK_0);
3193 } 3199 }
3194 } 3200 }
3195 3201
3196 // Initialize java_lang.System (needed before creating the thread) 3202 // Initialize java_lang.System (needed before creating the thread)
3197 if (InitializeJavaLangSystem) { 3203 if (InitializeJavaLangSystem) {
3198 initialize_class(vmSymbolHandles::java_lang_System(), CHECK_0); 3204 initialize_class(vmSymbols::java_lang_System(), CHECK_0);
3199 initialize_class(vmSymbolHandles::java_lang_ThreadGroup(), CHECK_0); 3205 initialize_class(vmSymbols::java_lang_ThreadGroup(), CHECK_0);
3200 Handle thread_group = create_initial_thread_group(CHECK_0); 3206 Handle thread_group = create_initial_thread_group(CHECK_0);
3201 Universe::set_main_thread_group(thread_group()); 3207 Universe::set_main_thread_group(thread_group());
3202 initialize_class(vmSymbolHandles::java_lang_Thread(), CHECK_0); 3208 initialize_class(vmSymbols::java_lang_Thread(), CHECK_0);
3203 oop thread_object = create_initial_thread(thread_group, main_thread, CHECK_0); 3209 oop thread_object = create_initial_thread(thread_group, main_thread, CHECK_0);
3204 main_thread->set_threadObj(thread_object); 3210 main_thread->set_threadObj(thread_object);
3205 // Set thread status to running since main thread has 3211 // Set thread status to running since main thread has
3206 // been started and running. 3212 // been started and running.
3207 java_lang_Thread::set_thread_status(thread_object, 3213 java_lang_Thread::set_thread_status(thread_object,
3208 java_lang_Thread::RUNNABLE); 3214 java_lang_Thread::RUNNABLE);
3209 3215
3210 // The VM preresolve methods to these classes. Make sure that get initialized 3216 // The VM preresolve methods to these classes. Make sure that get initialized
3211 initialize_class(vmSymbolHandles::java_lang_reflect_Method(), CHECK_0); 3217 initialize_class(vmSymbols::java_lang_reflect_Method(), CHECK_0);
3212 initialize_class(vmSymbolHandles::java_lang_ref_Finalizer(), CHECK_0); 3218 initialize_class(vmSymbols::java_lang_ref_Finalizer(), CHECK_0);
3213 // The VM creates & returns objects of this class. Make sure it's initialized. 3219 // The VM creates & returns objects of this class. Make sure it's initialized.
3214 initialize_class(vmSymbolHandles::java_lang_Class(), CHECK_0); 3220 initialize_class(vmSymbols::java_lang_Class(), CHECK_0);
3215 call_initializeSystemClass(CHECK_0); 3221 call_initializeSystemClass(CHECK_0);
3216 } else { 3222 } else {
3217 warning("java.lang.System not initialized"); 3223 warning("java.lang.System not initialized");
3218 } 3224 }
3219 3225
3220 // an instance of OutOfMemory exception has been allocated earlier 3226 // an instance of OutOfMemory exception has been allocated earlier
3221 if (InitializeJavaLangExceptionsErrors) { 3227 if (InitializeJavaLangExceptionsErrors) {
3222 initialize_class(vmSymbolHandles::java_lang_OutOfMemoryError(), CHECK_0); 3228 initialize_class(vmSymbols::java_lang_OutOfMemoryError(), CHECK_0);
3223 initialize_class(vmSymbolHandles::java_lang_NullPointerException(), CHECK_0); 3229 initialize_class(vmSymbols::java_lang_NullPointerException(), CHECK_0);
3224 initialize_class(vmSymbolHandles::java_lang_ClassCastException(), CHECK_0); 3230 initialize_class(vmSymbols::java_lang_ClassCastException(), CHECK_0);
3225 initialize_class(vmSymbolHandles::java_lang_ArrayStoreException(), CHECK_0); 3231 initialize_class(vmSymbols::java_lang_ArrayStoreException(), CHECK_0);
3226 initialize_class(vmSymbolHandles::java_lang_ArithmeticException(), CHECK_0); 3232 initialize_class(vmSymbols::java_lang_ArithmeticException(), CHECK_0);
3227 initialize_class(vmSymbolHandles::java_lang_StackOverflowError(), CHECK_0); 3233 initialize_class(vmSymbols::java_lang_StackOverflowError(), CHECK_0);
3228 initialize_class(vmSymbolHandles::java_lang_IllegalMonitorStateException(), CHECK_0); 3234 initialize_class(vmSymbols::java_lang_IllegalMonitorStateException(), CHECK_0);
3229 } else { 3235 } else {
3230 warning("java.lang.OutOfMemoryError has not been initialized"); 3236 warning("java.lang.OutOfMemoryError has not been initialized");
3231 warning("java.lang.NullPointerException has not been initialized"); 3237 warning("java.lang.NullPointerException has not been initialized");
3232 warning("java.lang.ClassCastException has not been initialized"); 3238 warning("java.lang.ClassCastException has not been initialized");
3233 warning("java.lang.ArrayStoreException has not been initialized"); 3239 warning("java.lang.ArrayStoreException has not been initialized");
3249 // Currently even the AWT code has calls to methods in java.lang.Compiler. 3255 // Currently even the AWT code has calls to methods in java.lang.Compiler.
3250 // On the classic VM, java.lang.Compiler is loaded very early to load the JIT. 3256 // On the classic VM, java.lang.Compiler is loaded very early to load the JIT.
3251 // Future Fix : the best fix is to grant everyone permissions to read "java.compiler" and 3257 // Future Fix : the best fix is to grant everyone permissions to read "java.compiler" and
3252 // read and write"java.vm.info" in the default policy file. See bugid 4211383 3258 // read and write"java.vm.info" in the default policy file. See bugid 4211383
3253 // Once that is done, we should remove this hack. 3259 // Once that is done, we should remove this hack.
3254 initialize_class(vmSymbolHandles::java_lang_Compiler(), CHECK_0); 3260 initialize_class(vmSymbols::java_lang_Compiler(), CHECK_0);
3255 3261
3256 // More hackery - the static initializer of java.lang.Compiler adds the string "nojit" to 3262 // More hackery - the static initializer of java.lang.Compiler adds the string "nojit" to
3257 // the java.vm.info property if no jit gets loaded through java.lang.Compiler (the hotspot 3263 // the java.vm.info property if no jit gets loaded through java.lang.Compiler (the hotspot
3258 // compiler does not get loaded through java.lang.Compiler). "java -version" with the 3264 // compiler does not get loaded through java.lang.Compiler). "java -version" with the
3259 // hotspot vm says "nojit" all the time which is confusing. So, we reset it here. 3265 // hotspot vm says "nojit" all the time which is confusing. So, we reset it here.
3346 StatSampler::engage(); 3352 StatSampler::engage();
3347 if (CheckJNICalls) JniPeriodicChecker::engage(); 3353 if (CheckJNICalls) JniPeriodicChecker::engage();
3348 3354
3349 BiasedLocking::init(); 3355 BiasedLocking::init();
3350 3356
3357 if (JDK_Version::current().post_vm_init_hook_enabled()) {
3358 call_postVMInitHook(THREAD);
3359 // The Java side of PostVMInitHook.run must deal with all
3360 // exceptions and provide means of diagnosis.
3361 if (HAS_PENDING_EXCEPTION) {
3362 CLEAR_PENDING_EXCEPTION;
3363 }
3364 }
3351 3365
3352 // Start up the WatcherThread if there are any periodic tasks 3366 // Start up the WatcherThread if there are any periodic tasks
3353 // NOTE: All PeriodicTasks should be registered by now. If they 3367 // NOTE: All PeriodicTasks should be registered by now. If they
3354 // aren't, late joiners might appear to start slowly (we might 3368 // aren't, late joiners might appear to start slowly (we might
3355 // take a while to process their first tick). 3369 // take a while to process their first tick).
3567 this->clear_pending_exception(); 3581 this->clear_pending_exception();
3568 } 3582 }
3569 3583
3570 EXCEPTION_MARK; 3584 EXCEPTION_MARK;
3571 klassOop k = 3585 klassOop k =
3572 SystemDictionary::resolve_or_null(vmSymbolHandles::java_lang_Shutdown(), 3586 SystemDictionary::resolve_or_null(vmSymbols::java_lang_Shutdown(),
3573 THREAD); 3587 THREAD);
3574 if (k != NULL) { 3588 if (k != NULL) {
3575 // SystemDictionary::resolve_or_null will return null if there was 3589 // SystemDictionary::resolve_or_null will return null if there was
3576 // an exception. If we cannot load the Shutdown class, just don't 3590 // an exception. If we cannot load the Shutdown class, just don't
3577 // call Shutdown.shutdown() at all. This will mean the shutdown hooks 3591 // call Shutdown.shutdown() at all. This will mean the shutdown hooks
3581 // (Runtime.addShutdownHook and runFinalizersOnExit will load it). 3595 // (Runtime.addShutdownHook and runFinalizersOnExit will load it).
3582 instanceKlassHandle shutdown_klass (THREAD, k); 3596 instanceKlassHandle shutdown_klass (THREAD, k);
3583 JavaValue result(T_VOID); 3597 JavaValue result(T_VOID);
3584 JavaCalls::call_static(&result, 3598 JavaCalls::call_static(&result,
3585 shutdown_klass, 3599 shutdown_klass,
3586 vmSymbolHandles::shutdown_method_name(), 3600 vmSymbols::shutdown_method_name(),
3587 vmSymbolHandles::void_method_signature(), 3601 vmSymbols::void_method_signature(),
3588 THREAD); 3602 THREAD);
3589 } 3603 }
3590 CLEAR_PENDING_EXCEPTION; 3604 CLEAR_PENDING_EXCEPTION;
3591 } 3605 }
3592 3606