src/share/vm/runtime/thread.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File 8148630 Sdiff src/share/vm/runtime

src/share/vm/runtime/thread.cpp

Print this page




3309   // Someday we could have a table or list of all non-JavaThreads.
3310   // For now, just manually iterate through them.
3311   tc->do_thread(VMThread::vm_thread());
3312   Universe::heap()->gc_threads_do(tc);
3313   WatcherThread *wt = WatcherThread::watcher_thread();
3314   // Strictly speaking, the following NULL check isn't sufficient to make sure
3315   // the data for WatcherThread is still valid upon being examined. However,
3316   // considering that WatchThread terminates when the VM is on the way to
3317   // exit at safepoint, the chance of the above is extremely small. The right
3318   // way to prevent termination of WatcherThread would be to acquire
3319   // Terminator_lock, but we can't do that without violating the lock rank
3320   // checking in some cases.
3321   if (wt != NULL) {
3322     tc->do_thread(wt);
3323   }
3324 
3325   // If CompilerThreads ever become non-JavaThreads, add them here
3326 }
3327 
3328 void Threads::initialize_java_lang_classes(JavaThread* main_thread, TRAPS) {
3329   TraceTime timer("Initialize java.lang classes", TraceStartupTime);


3330 
3331   if (EagerXrunInit && Arguments::init_libraries_at_startup()) {
3332     create_vm_init_libraries();
3333   }
3334 
3335   initialize_class(vmSymbols::java_lang_String(), CHECK);
3336 
3337   // Inject CompactStrings value after the static initializers for String ran.
3338   java_lang_String::set_compact_strings(CompactStrings);
3339 
3340   // Initialize java_lang.System (needed before creating the thread)
3341   initialize_class(vmSymbols::java_lang_System(), CHECK);
3342   // The VM creates & returns objects of this class. Make sure it's initialized.
3343   initialize_class(vmSymbols::java_lang_Class(), CHECK);
3344   initialize_class(vmSymbols::java_lang_ThreadGroup(), CHECK);
3345   Handle thread_group = create_initial_thread_group(CHECK);
3346   Universe::set_main_thread_group(thread_group());
3347   initialize_class(vmSymbols::java_lang_Thread(), CHECK);
3348   oop thread_object = create_initial_thread(thread_group, main_thread, CHECK);
3349   main_thread->set_threadObj(thread_object);


3425   if (ergo_result != JNI_OK) return ergo_result;
3426 
3427   // Final check of all ranges after ergonomics which may change values.
3428   if (!CommandLineFlagRangeList::check_ranges()) {
3429     return JNI_EINVAL;
3430   }
3431 
3432   // Final check of all 'AfterErgo' constraints after ergonomics which may change values.
3433   bool constraint_result = CommandLineFlagConstraintList::check_constraints(CommandLineFlagConstraint::AfterErgo);
3434   if (!constraint_result) {
3435     return JNI_EINVAL;
3436   }
3437 
3438   if (PauseAtStartup) {
3439     os::pause();
3440   }
3441 
3442   HOTSPOT_VM_INIT_BEGIN();
3443 
3444   // Timing (must come after argument parsing)
3445   TraceTime timer("Create VM", TraceStartupTime);


3446 
3447   // Initialize the os module after parsing the args
3448   jint os_init_2_result = os::init_2();
3449   if (os_init_2_result != JNI_OK) return os_init_2_result;
3450 
3451   jint adjust_after_os_result = Arguments::adjust_after_os();
3452   if (adjust_after_os_result != JNI_OK) return adjust_after_os_result;
3453 
3454   // Initialize output stream logging
3455   ostream_init_log();
3456 
3457   // Convert -Xrun to -agentlib: if there is no JVM_OnLoad
3458   // Must be before create_vm_init_agents()
3459   if (Arguments::init_libraries_at_startup()) {
3460     convert_vm_init_libraries_to_agents();
3461   }
3462 
3463   // Launch -agentlib/-agentpath and converted -Xrun agents
3464   if (Arguments::init_agents_at_startup()) {
3465     create_vm_init_agents();


3510   if (status != JNI_OK) {
3511     delete main_thread;
3512     *canTryAgain = false; // don't let caller call JNI_CreateJavaVM again
3513     return status;
3514   }
3515 
3516   // Should be done after the heap is fully created
3517   main_thread->cache_global_variables();
3518 
3519   HandleMark hm;
3520 
3521   { MutexLocker mu(Threads_lock);
3522     Threads::add(main_thread);
3523   }
3524 
3525   // Any JVMTI raw monitors entered in onload will transition into
3526   // real raw monitor. VM is setup enough here for raw monitor enter.
3527   JvmtiExport::transition_pending_onload_raw_monitors();
3528 
3529   // Create the VMThread
3530   { TraceTime timer("Start VMThread", TraceStartupTime);



3531     VMThread::create();
3532     Thread* vmthread = VMThread::vm_thread();
3533 
3534     if (!os::create_thread(vmthread, os::vm_thread)) {
3535       vm_exit_during_initialization("Cannot create VM thread. "
3536                                     "Out of system resources.");
3537     }
3538 
3539     // Wait for the VM thread to become ready, and VMThread::run to initialize
3540     // Monitors can have spurious returns, must always check another state flag
3541     {
3542       MutexLocker ml(Notify_lock);
3543       os::start_thread(vmthread);
3544       while (vmthread->active_handles() == NULL) {
3545         Notify_lock->wait();
3546       }
3547     }
3548   }
3549 
3550   assert(Universe::is_fully_initialized(), "not initialized");




3309   // Someday we could have a table or list of all non-JavaThreads.
3310   // For now, just manually iterate through them.
3311   tc->do_thread(VMThread::vm_thread());
3312   Universe::heap()->gc_threads_do(tc);
3313   WatcherThread *wt = WatcherThread::watcher_thread();
3314   // Strictly speaking, the following NULL check isn't sufficient to make sure
3315   // the data for WatcherThread is still valid upon being examined. However,
3316   // considering that WatchThread terminates when the VM is on the way to
3317   // exit at safepoint, the chance of the above is extremely small. The right
3318   // way to prevent termination of WatcherThread would be to acquire
3319   // Terminator_lock, but we can't do that without violating the lock rank
3320   // checking in some cases.
3321   if (wt != NULL) {
3322     tc->do_thread(wt);
3323   }
3324 
3325   // If CompilerThreads ever become non-JavaThreads, add them here
3326 }
3327 
3328 void Threads::initialize_java_lang_classes(JavaThread* main_thread, TRAPS) {
3329   TraceTime timer("Initialize java.lang classes",
3330                   log_is_enabled(Info, startuptime),
3331                   LogTag::_startuptime);
3332 
3333   if (EagerXrunInit && Arguments::init_libraries_at_startup()) {
3334     create_vm_init_libraries();
3335   }
3336 
3337   initialize_class(vmSymbols::java_lang_String(), CHECK);
3338 
3339   // Inject CompactStrings value after the static initializers for String ran.
3340   java_lang_String::set_compact_strings(CompactStrings);
3341 
3342   // Initialize java_lang.System (needed before creating the thread)
3343   initialize_class(vmSymbols::java_lang_System(), CHECK);
3344   // The VM creates & returns objects of this class. Make sure it's initialized.
3345   initialize_class(vmSymbols::java_lang_Class(), CHECK);
3346   initialize_class(vmSymbols::java_lang_ThreadGroup(), CHECK);
3347   Handle thread_group = create_initial_thread_group(CHECK);
3348   Universe::set_main_thread_group(thread_group());
3349   initialize_class(vmSymbols::java_lang_Thread(), CHECK);
3350   oop thread_object = create_initial_thread(thread_group, main_thread, CHECK);
3351   main_thread->set_threadObj(thread_object);


3427   if (ergo_result != JNI_OK) return ergo_result;
3428 
3429   // Final check of all ranges after ergonomics which may change values.
3430   if (!CommandLineFlagRangeList::check_ranges()) {
3431     return JNI_EINVAL;
3432   }
3433 
3434   // Final check of all 'AfterErgo' constraints after ergonomics which may change values.
3435   bool constraint_result = CommandLineFlagConstraintList::check_constraints(CommandLineFlagConstraint::AfterErgo);
3436   if (!constraint_result) {
3437     return JNI_EINVAL;
3438   }
3439 
3440   if (PauseAtStartup) {
3441     os::pause();
3442   }
3443 
3444   HOTSPOT_VM_INIT_BEGIN();
3445 
3446   // Timing (must come after argument parsing)
3447   TraceTime timer("Create VM",
3448                   log_is_enabled(Info, startuptime),
3449                   LogTag::_startuptime);
3450 
3451   // Initialize the os module after parsing the args
3452   jint os_init_2_result = os::init_2();
3453   if (os_init_2_result != JNI_OK) return os_init_2_result;
3454 
3455   jint adjust_after_os_result = Arguments::adjust_after_os();
3456   if (adjust_after_os_result != JNI_OK) return adjust_after_os_result;
3457 
3458   // Initialize output stream logging
3459   ostream_init_log();
3460 
3461   // Convert -Xrun to -agentlib: if there is no JVM_OnLoad
3462   // Must be before create_vm_init_agents()
3463   if (Arguments::init_libraries_at_startup()) {
3464     convert_vm_init_libraries_to_agents();
3465   }
3466 
3467   // Launch -agentlib/-agentpath and converted -Xrun agents
3468   if (Arguments::init_agents_at_startup()) {
3469     create_vm_init_agents();


3514   if (status != JNI_OK) {
3515     delete main_thread;
3516     *canTryAgain = false; // don't let caller call JNI_CreateJavaVM again
3517     return status;
3518   }
3519 
3520   // Should be done after the heap is fully created
3521   main_thread->cache_global_variables();
3522 
3523   HandleMark hm;
3524 
3525   { MutexLocker mu(Threads_lock);
3526     Threads::add(main_thread);
3527   }
3528 
3529   // Any JVMTI raw monitors entered in onload will transition into
3530   // real raw monitor. VM is setup enough here for raw monitor enter.
3531   JvmtiExport::transition_pending_onload_raw_monitors();
3532 
3533   // Create the VMThread
3534   { TraceTime timer("Start VMThread",
3535                     log_is_enabled(Info, startuptime),
3536                     LogTag::_startuptime);
3537 
3538   VMThread::create();
3539     Thread* vmthread = VMThread::vm_thread();
3540 
3541     if (!os::create_thread(vmthread, os::vm_thread)) {
3542       vm_exit_during_initialization("Cannot create VM thread. "
3543                                     "Out of system resources.");
3544     }
3545 
3546     // Wait for the VM thread to become ready, and VMThread::run to initialize
3547     // Monitors can have spurious returns, must always check another state flag
3548     {
3549       MutexLocker ml(Notify_lock);
3550       os::start_thread(vmthread);
3551       while (vmthread->active_handles() == NULL) {
3552         Notify_lock->wait();
3553       }
3554     }
3555   }
3556 
3557   assert(Universe::is_fully_initialized(), "not initialized");


src/share/vm/runtime/thread.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File