< prev index next >

src/hotspot/share/runtime/thread.cpp

Print this page




1110                                                         java_runtime_version,
1111                                                         sizeof(java_runtime_version));
1112     return name;
1113   } else {
1114     return NULL;
1115   }
1116 }
1117 
1118 // General purpose hook into Java code, run once when the VM is initialized.
1119 // The Java library method itself may be changed independently from the VM.
1120 static void call_postVMInitHook(TRAPS) {
1121   Klass* klass = SystemDictionary::resolve_or_null(vmSymbols::jdk_internal_vm_PostVMInitHook(), THREAD);
1122   if (klass != NULL) {
1123     JavaValue result(T_VOID);
1124     JavaCalls::call_static(&result, klass, vmSymbols::run_method_name(),
1125                            vmSymbols::void_method_signature(),
1126                            CHECK);
1127   }
1128 }
1129 
1130 static void reset_vm_info_property(TRAPS) {
1131   // the vm info string
1132   ResourceMark rm(THREAD);
1133   const char *vm_info = VM_Version::vm_info_string();
1134 
1135   // update the native system property first
1136   Arguments::PropertyList_update_value(Arguments::system_properties(), "java.vm.info", vm_info);
1137 
1138   // java.lang.System class
1139   Klass* klass =  SystemDictionary::resolve_or_fail(vmSymbols::java_lang_System(), true, CHECK);
1140 
1141   // setProperty arguments
1142   Handle key_str    = java_lang_String::create_from_str("java.vm.info", CHECK);
1143   Handle value_str  = java_lang_String::create_from_str(vm_info, CHECK);
1144 
1145   // return value
1146   JavaValue r(T_OBJECT);
1147 
1148   // public static String setProperty(String key, String value);
1149   JavaCalls::call_static(&r,
1150                          klass,
1151                          vmSymbols::setProperty_name(),
1152                          vmSymbols::string_string_string_signature(),
1153                          key_str,
1154                          value_str,
1155                          CHECK);
1156 }
1157 
1158 
1159 void JavaThread::allocate_threadObj(Handle thread_group, const char* thread_name,
1160                                     bool daemon, TRAPS) {
1161   assert(thread_group.not_null(), "thread group should be specified");
1162   assert(threadObj() == NULL, "should only create Java thread object once");
1163 
1164   InstanceKlass* ik = SystemDictionary::Thread_klass();
1165   assert(ik->is_initialized(), "must be");
1166   instanceHandle thread_oop = ik->allocate_instance_handle(CHECK);
1167 
1168   // We are called from jni_AttachCurrentThread/jni_AttachCurrentThreadAsDaemon.
1169   // We cannot use JavaCalls::construct_new_instance because the java.lang.Thread
1170   // constructor calls Thread.current(), which must be set here.
1171   java_lang_Thread::set_thread(thread_oop(), this);
1172   java_lang_Thread::set_priority(thread_oop(), NormPriority);
1173   set_threadObj(thread_oop());
1174 
1175   JavaValue result(T_VOID);
1176   if (thread_name != NULL) {
1177     Handle name = java_lang_String::create_from_str(thread_name, CHECK);
1178     // Thread gets assigned specified name and null target


3754     }
3755 
3756     // Wait for the VM thread to become ready, and VMThread::run to initialize
3757     // Monitors can have spurious returns, must always check another state flag
3758     {
3759       MutexLocker ml(Notify_lock);
3760       os::start_thread(vmthread);
3761       while (vmthread->active_handles() == NULL) {
3762         Notify_lock->wait();
3763       }
3764     }
3765   }
3766 
3767   assert(Universe::is_fully_initialized(), "not initialized");
3768   if (VerifyDuringStartup) {
3769     // Make sure we're starting with a clean slate.
3770     VM_Verify verify_op;
3771     VMThread::execute(&verify_op);
3772   }
3773 






3774   Thread* THREAD = Thread::current();
3775 
3776   // Always call even when there are not JVMTI environments yet, since environments
3777   // may be attached late and JVMTI must track phases of VM execution
3778   JvmtiExport::enter_early_start_phase();
3779 
3780   // Notify JVMTI agents that VM has started (JNI is up) - nop if no agents.
3781   JvmtiExport::post_early_vm_start();
3782 
3783   initialize_java_lang_classes(main_thread, CHECK_JNI_ERR);
3784 
3785   // We need this to update the java.vm.info property in case any flags used
3786   // to initially define it have been changed. This is needed for both CDS and
3787   // AOT, since UseSharedSpaces and UseAOT may be changed after java.vm.info
3788   // is initially computed. See Abstract_VM_Version::vm_info_string().
3789   reset_vm_info_property(CHECK_JNI_ERR);
3790 
3791   quicken_jni_functions();
3792 
3793   // No more stub generation allowed after that point.
3794   StubCodeDesc::freeze();
3795 
3796   // Set flag that basic initialization has completed. Used by exceptions and various
3797   // debug stuff, that does not work until all basic classes have been initialized.
3798   set_init_completed();
3799 
3800   LogConfiguration::post_initialize();
3801   Metaspace::post_initialize();
3802 
3803   HOTSPOT_VM_INIT_END();
3804 
3805   // record VM initialization completion time
3806 #if INCLUDE_MANAGEMENT
3807   Management::record_vm_init_completed();
3808 #endif // INCLUDE_MANAGEMENT
3809 




1110                                                         java_runtime_version,
1111                                                         sizeof(java_runtime_version));
1112     return name;
1113   } else {
1114     return NULL;
1115   }
1116 }
1117 
1118 // General purpose hook into Java code, run once when the VM is initialized.
1119 // The Java library method itself may be changed independently from the VM.
1120 static void call_postVMInitHook(TRAPS) {
1121   Klass* klass = SystemDictionary::resolve_or_null(vmSymbols::jdk_internal_vm_PostVMInitHook(), THREAD);
1122   if (klass != NULL) {
1123     JavaValue result(T_VOID);
1124     JavaCalls::call_static(&result, klass, vmSymbols::run_method_name(),
1125                            vmSymbols::void_method_signature(),
1126                            CHECK);
1127   }
1128 }
1129 





























1130 void JavaThread::allocate_threadObj(Handle thread_group, const char* thread_name,
1131                                     bool daemon, TRAPS) {
1132   assert(thread_group.not_null(), "thread group should be specified");
1133   assert(threadObj() == NULL, "should only create Java thread object once");
1134 
1135   InstanceKlass* ik = SystemDictionary::Thread_klass();
1136   assert(ik->is_initialized(), "must be");
1137   instanceHandle thread_oop = ik->allocate_instance_handle(CHECK);
1138 
1139   // We are called from jni_AttachCurrentThread/jni_AttachCurrentThreadAsDaemon.
1140   // We cannot use JavaCalls::construct_new_instance because the java.lang.Thread
1141   // constructor calls Thread.current(), which must be set here.
1142   java_lang_Thread::set_thread(thread_oop(), this);
1143   java_lang_Thread::set_priority(thread_oop(), NormPriority);
1144   set_threadObj(thread_oop());
1145 
1146   JavaValue result(T_VOID);
1147   if (thread_name != NULL) {
1148     Handle name = java_lang_String::create_from_str(thread_name, CHECK);
1149     // Thread gets assigned specified name and null target


3725     }
3726 
3727     // Wait for the VM thread to become ready, and VMThread::run to initialize
3728     // Monitors can have spurious returns, must always check another state flag
3729     {
3730       MutexLocker ml(Notify_lock);
3731       os::start_thread(vmthread);
3732       while (vmthread->active_handles() == NULL) {
3733         Notify_lock->wait();
3734       }
3735     }
3736   }
3737 
3738   assert(Universe::is_fully_initialized(), "not initialized");
3739   if (VerifyDuringStartup) {
3740     // Make sure we're starting with a clean slate.
3741     VM_Verify verify_op;
3742     VMThread::execute(&verify_op);
3743   }
3744 
3745   // We need this to update the java.vm.info property in case any flags used
3746   // to initially define it have been changed. This is needed for both CDS and
3747   // AOT, since UseSharedSpaces and UseAOT may be changed after java.vm.info
3748   // is initially computed. See Abstract_VM_Version::vm_info_string().
3749   Arguments::update_vm_info_property(VM_Version::vm_info_string());
3750 
3751   Thread* THREAD = Thread::current();
3752 
3753   // Always call even when there are not JVMTI environments yet, since environments
3754   // may be attached late and JVMTI must track phases of VM execution
3755   JvmtiExport::enter_early_start_phase();
3756 
3757   // Notify JVMTI agents that VM has started (JNI is up) - nop if no agents.
3758   JvmtiExport::post_early_vm_start();
3759 
3760   initialize_java_lang_classes(main_thread, CHECK_JNI_ERR);






3761 
3762   quicken_jni_functions();
3763 
3764   // No more stub generation allowed after that point.
3765   StubCodeDesc::freeze();
3766 
3767   // Set flag that basic initialization has completed. Used by exceptions and various
3768   // debug stuff, that does not work until all basic classes have been initialized.
3769   set_init_completed();
3770 
3771   LogConfiguration::post_initialize();
3772   Metaspace::post_initialize();
3773 
3774   HOTSPOT_VM_INIT_END();
3775 
3776   // record VM initialization completion time
3777 #if INCLUDE_MANAGEMENT
3778   Management::record_vm_init_completed();
3779 #endif // INCLUDE_MANAGEMENT
3780 


< prev index next >