33 #include "code/scopeDesc.hpp" |
33 #include "code/scopeDesc.hpp" |
34 #include "compiler/compileBroker.hpp" |
34 #include "compiler/compileBroker.hpp" |
35 #include "compiler/compileTask.hpp" |
35 #include "compiler/compileTask.hpp" |
36 #include "gc/shared/gcId.hpp" |
36 #include "gc/shared/gcId.hpp" |
37 #include "gc/shared/gcLocker.inline.hpp" |
37 #include "gc/shared/gcLocker.inline.hpp" |
|
38 #include "gc/shared/referencePendingListLocker.hpp" |
38 #include "gc/shared/workgroup.hpp" |
39 #include "gc/shared/workgroup.hpp" |
39 #include "interpreter/interpreter.hpp" |
40 #include "interpreter/interpreter.hpp" |
40 #include "interpreter/linkResolver.hpp" |
41 #include "interpreter/linkResolver.hpp" |
41 #include "interpreter/oopMapCache.hpp" |
42 #include "interpreter/oopMapCache.hpp" |
42 #include "jvmtifiles/jvmtiEnv.hpp" |
43 #include "jvmtifiles/jvmtiEnv.hpp" |
43 #include "logging/log.hpp" |
44 #include "logging/log.hpp" |
44 #include "logging/logConfiguration.hpp" |
45 #include "logging/logConfiguration.hpp" |
45 #include "memory/metaspaceShared.hpp" |
46 #include "memory/metaspaceShared.hpp" |
46 #include "memory/oopFactory.hpp" |
47 #include "memory/oopFactory.hpp" |
|
48 #include "memory/resourceArea.hpp" |
47 #include "memory/universe.inline.hpp" |
49 #include "memory/universe.inline.hpp" |
48 #include "oops/instanceKlass.hpp" |
50 #include "oops/instanceKlass.hpp" |
49 #include "oops/objArrayOop.hpp" |
51 #include "oops/objArrayOop.hpp" |
50 #include "oops/oop.inline.hpp" |
52 #include "oops/oop.inline.hpp" |
51 #include "oops/symbol.hpp" |
53 #include "oops/symbol.hpp" |
66 #include "runtime/init.hpp" |
68 #include "runtime/init.hpp" |
67 #include "runtime/interfaceSupport.hpp" |
69 #include "runtime/interfaceSupport.hpp" |
68 #include "runtime/java.hpp" |
70 #include "runtime/java.hpp" |
69 #include "runtime/javaCalls.hpp" |
71 #include "runtime/javaCalls.hpp" |
70 #include "runtime/jniPeriodicChecker.hpp" |
72 #include "runtime/jniPeriodicChecker.hpp" |
71 #include "runtime/logTimer.hpp" |
73 #include "runtime/timerTrace.hpp" |
72 #include "runtime/memprofiler.hpp" |
74 #include "runtime/memprofiler.hpp" |
73 #include "runtime/mutexLocker.hpp" |
75 #include "runtime/mutexLocker.hpp" |
74 #include "runtime/objectMonitor.hpp" |
76 #include "runtime/objectMonitor.hpp" |
75 #include "runtime/orderAccess.inline.hpp" |
77 #include "runtime/orderAccess.inline.hpp" |
76 #include "runtime/osThread.hpp" |
78 #include "runtime/osThread.hpp" |
789 // Do oop for ThreadShadow |
790 // Do oop for ThreadShadow |
790 f->do_oop((oop*)&_pending_exception); |
791 f->do_oop((oop*)&_pending_exception); |
791 handle_area()->oops_do(f); |
792 handle_area()->oops_do(f); |
792 } |
793 } |
793 |
794 |
794 void Thread::nmethods_do(CodeBlobClosure* cf) { |
|
795 // no nmethods in a generic thread... |
|
796 } |
|
797 |
|
798 void Thread::metadata_handles_do(void f(Metadata*)) { |
795 void Thread::metadata_handles_do(void f(Metadata*)) { |
799 // Only walk the Handles in Thread. |
796 // Only walk the Handles in Thread. |
800 if (metadata_handles() != NULL) { |
797 if (metadata_handles() != NULL) { |
801 for (int i = 0; i< metadata_handles()->length(); i++) { |
798 for (int i = 0; i< metadata_handles()->length(); i++) { |
802 f(metadata_handles()->at(i)); |
799 f(metadata_handles()->at(i)); |
2091 // We cannot call Exceptions::_throw(...) here because we cannot block |
2088 // We cannot call Exceptions::_throw(...) here because we cannot block |
2092 set_pending_exception(_pending_async_exception, __FILE__, __LINE__); |
2089 set_pending_exception(_pending_async_exception, __FILE__, __LINE__); |
2093 |
2090 |
2094 if (log_is_enabled(Info, exceptions)) { |
2091 if (log_is_enabled(Info, exceptions)) { |
2095 ResourceMark rm; |
2092 ResourceMark rm; |
2096 outputStream* logstream = LogHandle(exceptions)::info_stream(); |
2093 outputStream* logstream = Log(exceptions)::info_stream(); |
2097 logstream->print("Async. exception installed at runtime exit (" INTPTR_FORMAT ")", p2i(this)); |
2094 logstream->print("Async. exception installed at runtime exit (" INTPTR_FORMAT ")", p2i(this)); |
2098 if (has_last_Java_frame()) { |
2095 if (has_last_Java_frame()) { |
2099 frame f = last_frame(); |
2096 frame f = last_frame(); |
2100 logstream->print(" (pc: " INTPTR_FORMAT " sp: " INTPTR_FORMAT " )", p2i(f.pc()), p2i(f.sp())); |
2097 logstream->print(" (pc: " INTPTR_FORMAT " sp: " INTPTR_FORMAT " )", p2i(f.pc()), p2i(f.sp())); |
2101 } |
2098 } |
2825 jvmti_thread_state()->oops_do(f); |
2822 jvmti_thread_state()->oops_do(f); |
2826 } |
2823 } |
2827 } |
2824 } |
2828 |
2825 |
2829 void JavaThread::nmethods_do(CodeBlobClosure* cf) { |
2826 void JavaThread::nmethods_do(CodeBlobClosure* cf) { |
2830 Thread::nmethods_do(cf); // (super method is a no-op) |
|
2831 |
|
2832 assert((!has_last_Java_frame() && java_call_counter() == 0) || |
2827 assert((!has_last_Java_frame() && java_call_counter() == 0) || |
2833 (has_last_Java_frame() && java_call_counter() > 0), "wrong java_sp info!"); |
2828 (has_last_Java_frame() && java_call_counter() > 0), "wrong java_sp info!"); |
2834 |
2829 |
2835 if (has_last_Java_frame()) { |
2830 if (has_last_Java_frame()) { |
2836 // Traverse the execution stack |
2831 // Traverse the execution stack |
2885 } |
2880 } |
2886 #endif // PRODUCT |
2881 #endif // PRODUCT |
2887 |
2882 |
2888 // Called by Threads::print() for VM_PrintThreads operation |
2883 // Called by Threads::print() for VM_PrintThreads operation |
2889 void JavaThread::print_on(outputStream *st) const { |
2884 void JavaThread::print_on(outputStream *st) const { |
2890 st->print("\"%s\" ", get_thread_name()); |
2885 st->print_raw("\""); |
|
2886 st->print_raw(get_thread_name()); |
|
2887 st->print_raw("\" "); |
2891 oop thread_oop = threadObj(); |
2888 oop thread_oop = threadObj(); |
2892 if (thread_oop != NULL) { |
2889 if (thread_oop != NULL) { |
2893 st->print("#" INT64_FORMAT " ", java_lang_Thread::thread_id(thread_oop)); |
2890 st->print("#" INT64_FORMAT " ", java_lang_Thread::thread_id(thread_oop)); |
2894 if (java_lang_Thread::is_daemon(thread_oop)) st->print("daemon "); |
2891 if (java_lang_Thread::is_daemon(thread_oop)) st->print("daemon "); |
2895 st->print("prio=%d ", java_lang_Thread::priority(thread_oop)); |
2892 st->print("prio=%d ", java_lang_Thread::priority(thread_oop)); |
3299 // Create sweeper thread |
3296 // Create sweeper thread |
3300 CodeCacheSweeperThread::CodeCacheSweeperThread() |
3297 CodeCacheSweeperThread::CodeCacheSweeperThread() |
3301 : JavaThread(&sweeper_thread_entry) { |
3298 : JavaThread(&sweeper_thread_entry) { |
3302 _scanned_nmethod = NULL; |
3299 _scanned_nmethod = NULL; |
3303 } |
3300 } |
|
3301 |
3304 void CodeCacheSweeperThread::oops_do(OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf) { |
3302 void CodeCacheSweeperThread::oops_do(OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf) { |
3305 JavaThread::oops_do(f, cld_f, cf); |
3303 JavaThread::oops_do(f, cld_f, cf); |
|
3304 if (_scanned_nmethod != NULL && cf != NULL) { |
|
3305 // Safepoints can occur when the sweeper is scanning an nmethod so |
|
3306 // process it here to make sure it isn't unloaded in the middle of |
|
3307 // a scan. |
|
3308 cf->do_code_blob(_scanned_nmethod); |
|
3309 } |
|
3310 } |
|
3311 |
|
3312 void CodeCacheSweeperThread::nmethods_do(CodeBlobClosure* cf) { |
|
3313 JavaThread::nmethods_do(cf); |
3306 if (_scanned_nmethod != NULL && cf != NULL) { |
3314 if (_scanned_nmethod != NULL && cf != NULL) { |
3307 // Safepoints can occur when the sweeper is scanning an nmethod so |
3315 // Safepoints can occur when the sweeper is scanning an nmethod so |
3308 // process it here to make sure it isn't unloaded in the middle of |
3316 // process it here to make sure it isn't unloaded in the middle of |
3309 // a scan. |
3317 // a scan. |
3310 cf->do_code_blob(_scanned_nmethod); |
3318 cf->do_code_blob(_scanned_nmethod); |
3414 JavaCalls::call_static(&result, klass, vmSymbols::initPhase3_name(), |
3422 JavaCalls::call_static(&result, klass, vmSymbols::initPhase3_name(), |
3415 vmSymbols::void_method_signature(), CHECK); |
3423 vmSymbols::void_method_signature(), CHECK); |
3416 } |
3424 } |
3417 |
3425 |
3418 void Threads::initialize_java_lang_classes(JavaThread* main_thread, TRAPS) { |
3426 void Threads::initialize_java_lang_classes(JavaThread* main_thread, TRAPS) { |
3419 TraceStartupTime timer("Initialize java.lang classes"); |
3427 TraceTime timer("Initialize java.lang classes", TRACETIME_LOG(Info, startuptime)); |
3420 |
3428 |
3421 if (EagerXrunInit && Arguments::init_libraries_at_startup()) { |
3429 if (EagerXrunInit && Arguments::init_libraries_at_startup()) { |
3422 create_vm_init_libraries(); |
3430 create_vm_init_libraries(); |
3423 } |
3431 } |
3424 |
3432 |
3466 initialize_class(vmSymbols::java_lang_IllegalMonitorStateException(), CHECK); |
3474 initialize_class(vmSymbols::java_lang_IllegalMonitorStateException(), CHECK); |
3467 initialize_class(vmSymbols::java_lang_IllegalArgumentException(), CHECK); |
3475 initialize_class(vmSymbols::java_lang_IllegalArgumentException(), CHECK); |
3468 } |
3476 } |
3469 |
3477 |
3470 void Threads::initialize_jsr292_core_classes(TRAPS) { |
3478 void Threads::initialize_jsr292_core_classes(TRAPS) { |
3471 TraceStartupTime timer("Initialize java.lang.invoke classes"); |
3479 TraceTime timer("Initialize java.lang.invoke classes", TRACETIME_LOG(Info, startuptime)); |
3472 |
3480 |
3473 initialize_class(vmSymbols::java_lang_invoke_MethodHandle(), CHECK); |
3481 initialize_class(vmSymbols::java_lang_invoke_MethodHandle(), CHECK); |
3474 initialize_class(vmSymbols::java_lang_invoke_MemberName(), CHECK); |
3482 initialize_class(vmSymbols::java_lang_invoke_MemberName(), CHECK); |
3475 initialize_class(vmSymbols::java_lang_invoke_MethodHandleNatives(), CHECK); |
3483 initialize_class(vmSymbols::java_lang_invoke_MethodHandleNatives(), CHECK); |
3476 } |
3484 } |
3537 } |
3545 } |
3538 |
3546 |
3539 HOTSPOT_VM_INIT_BEGIN(); |
3547 HOTSPOT_VM_INIT_BEGIN(); |
3540 |
3548 |
3541 // Timing (must come after argument parsing) |
3549 // Timing (must come after argument parsing) |
3542 TraceStartupTime timer("Create VM"); |
3550 TraceTime timer("Create VM", TRACETIME_LOG(Info, startuptime)); |
3543 |
3551 |
3544 // Initialize the os module after parsing the args |
3552 // Initialize the os module after parsing the args |
3545 jint os_init_2_result = os::init_2(); |
3553 jint os_init_2_result = os::init_2(); |
3546 if (os_init_2_result != JNI_OK) return os_init_2_result; |
3554 if (os_init_2_result != JNI_OK) return os_init_2_result; |
3547 |
3555 |
3626 // Any JVMTI raw monitors entered in onload will transition into |
3634 // Any JVMTI raw monitors entered in onload will transition into |
3627 // real raw monitor. VM is setup enough here for raw monitor enter. |
3635 // real raw monitor. VM is setup enough here for raw monitor enter. |
3628 JvmtiExport::transition_pending_onload_raw_monitors(); |
3636 JvmtiExport::transition_pending_onload_raw_monitors(); |
3629 |
3637 |
3630 // Create the VMThread |
3638 // Create the VMThread |
3631 { TraceStartupTime timer("Start VMThread"); |
3639 { TraceTime timer("Start VMThread", TRACETIME_LOG(Info, startuptime)); |
3632 |
3640 |
3633 VMThread::create(); |
3641 VMThread::create(); |
3634 Thread* vmthread = VMThread::vm_thread(); |
3642 Thread* vmthread = VMThread::vm_thread(); |
3635 |
3643 |
3636 if (!os::create_thread(vmthread, os::vm_thread)) { |
3644 if (!os::create_thread(vmthread, os::vm_thread)) { |
3701 |
3709 |
3702 // Note that we do not use CHECK_0 here since we are inside an EXCEPTION_MARK and |
3710 // Note that we do not use CHECK_0 here since we are inside an EXCEPTION_MARK and |
3703 // set_init_completed has just been called, causing exceptions not to be shortcut |
3711 // set_init_completed has just been called, causing exceptions not to be shortcut |
3704 // anymore. We call vm_exit_during_initialization directly instead. |
3712 // anymore. We call vm_exit_during_initialization directly instead. |
3705 |
3713 |
3706 #if INCLUDE_ALL_GCS |
3714 // Initialize reference pending list locker |
3707 // Support for ConcurrentMarkSweep. This should be cleaned up |
3715 bool needs_locker_thread = Universe::heap()->needs_reference_pending_list_locker_thread(); |
3708 // and better encapsulated. The ugly nested if test would go away |
3716 ReferencePendingListLocker::initialize(needs_locker_thread, CHECK_JNI_ERR); |
3709 // once things are properly refactored. XXX YSR |
|
3710 if (UseConcMarkSweepGC || UseG1GC) { |
|
3711 if (UseConcMarkSweepGC) { |
|
3712 ConcurrentMarkSweepThread::makeSurrogateLockerThread(CHECK_JNI_ERR); |
|
3713 } else { |
|
3714 ConcurrentMarkThread::makeSurrogateLockerThread(CHECK_JNI_ERR); |
|
3715 } |
|
3716 } |
|
3717 #endif // INCLUDE_ALL_GCS |
|
3718 |
3717 |
3719 // Signal Dispatcher needs to be started before VMInit event is posted |
3718 // Signal Dispatcher needs to be started before VMInit event is posted |
3720 os::signal_init(); |
3719 os::signal_init(); |
3721 |
3720 |
3722 // Start Attach Listener if +StartAttachListener or it can't be started lazily |
3721 // Start Attach Listener if +StartAttachListener or it can't be started lazily |
4346 } |
4345 } |
4347 #endif // INCLUDE_ALL_GCS |
4346 #endif // INCLUDE_ALL_GCS |
4348 |
4347 |
4349 void Threads::nmethods_do(CodeBlobClosure* cf) { |
4348 void Threads::nmethods_do(CodeBlobClosure* cf) { |
4350 ALL_JAVA_THREADS(p) { |
4349 ALL_JAVA_THREADS(p) { |
4351 p->nmethods_do(cf); |
4350 // This is used by the code cache sweeper to mark nmethods that are active |
4352 } |
4351 // on the stack of a Java thread. Ignore the sweeper thread itself to avoid |
4353 VMThread::vm_thread()->nmethods_do(cf); |
4352 // marking CodeCacheSweeperThread::_scanned_nmethod as active. |
|
4353 if(!p->is_Code_cache_sweeper_thread()) { |
|
4354 p->nmethods_do(cf); |
|
4355 } |
|
4356 } |
4354 } |
4357 } |
4355 |
4358 |
4356 void Threads::metadata_do(void f(Metadata*)) { |
4359 void Threads::metadata_do(void f(Metadata*)) { |
4357 ALL_JAVA_THREADS(p) { |
4360 ALL_JAVA_THREADS(p) { |
4358 p->metadata_do(f); |
4361 p->metadata_do(f); |