comparison src/share/vm/runtime/thread.cpp @ 14422:2b8e28fdf503

Merge
author kvn
date Tue, 05 Nov 2013 17:38:04 -0800
parents e2722a66aba7 292050e5d5ea
children abec000618bf 62c54fcc0a35
comparison
equal deleted inserted replaced
14421:3068270ba476 14422:2b8e28fdf503
334 334
335 Thread::~Thread() { 335 Thread::~Thread() {
336 // Reclaim the objectmonitors from the omFreeList of the moribund thread. 336 // Reclaim the objectmonitors from the omFreeList of the moribund thread.
337 ObjectSynchronizer::omFlush (this) ; 337 ObjectSynchronizer::omFlush (this) ;
338 338
339 EVENT_THREAD_DESTRUCT(this);
340
339 // stack_base can be NULL if the thread is never started or exited before 341 // stack_base can be NULL if the thread is never started or exited before
340 // record_stack_base_and_size called. Although, we would like to ensure 342 // record_stack_base_and_size called. Although, we would like to ensure
341 // that all started threads do call record_stack_base_and_size(), there is 343 // that all started threads do call record_stack_base_and_size(), there is
342 // not proper way to enforce that. 344 // not proper way to enforce that.
343 #if INCLUDE_NMT 345 #if INCLUDE_NMT
1096 } 1098 }
1097 1099
1098 // General purpose hook into Java code, run once when the VM is initialized. 1100 // General purpose hook into Java code, run once when the VM is initialized.
1099 // The Java library method itself may be changed independently from the VM. 1101 // The Java library method itself may be changed independently from the VM.
1100 static void call_postVMInitHook(TRAPS) { 1102 static void call_postVMInitHook(TRAPS) {
1101 Klass* k = SystemDictionary::PostVMInitHook_klass(); 1103 Klass* k = SystemDictionary::resolve_or_null(vmSymbols::sun_misc_PostVMInitHook(), THREAD);
1102 instanceKlassHandle klass (THREAD, k); 1104 instanceKlassHandle klass (THREAD, k);
1103 if (klass.not_null()) { 1105 if (klass.not_null()) {
1104 JavaValue result(T_VOID); 1106 JavaValue result(T_VOID);
1105 JavaCalls::call_static(&result, klass, vmSymbols::run_method_name(), 1107 JavaCalls::call_static(&result, klass, vmSymbols::run_method_name(),
1106 vmSymbols::void_method_signature(), 1108 vmSymbols::void_method_signature(),
1443 _array_for_gc = NULL; 1445 _array_for_gc = NULL;
1444 _suspend_equivalent = false; 1446 _suspend_equivalent = false;
1445 _in_deopt_handler = 0; 1447 _in_deopt_handler = 0;
1446 _doing_unsafe_access = false; 1448 _doing_unsafe_access = false;
1447 _stack_guard_state = stack_guard_unused; 1449 _stack_guard_state = stack_guard_unused;
1448 _exception_oop = NULL; 1450 (void)const_cast<oop&>(_exception_oop = NULL);
1449 _exception_pc = 0; 1451 _exception_pc = 0;
1450 _exception_handler_pc = 0; 1452 _exception_handler_pc = 0;
1451 _is_method_handle_return = 0; 1453 _is_method_handle_return = 0;
1452 _jvmti_thread_state= NULL; 1454 _jvmti_thread_state= NULL;
1453 _should_post_on_exceptions_flag = JNI_FALSE; 1455 _should_post_on_exceptions_flag = JNI_FALSE;
1454 _jvmti_get_loaded_classes_closure = NULL; 1456 _jvmti_get_loaded_classes_closure = NULL;
1455 _interp_only_mode = 0; 1457 _interp_only_mode = 0;
1456 _special_runtime_exit_condition = _no_async_condition; 1458 _special_runtime_exit_condition = _no_async_condition;
1457 _pending_async_exception = NULL; 1459 _pending_async_exception = NULL;
1458 _is_compiling = false;
1459 _thread_stat = NULL; 1460 _thread_stat = NULL;
1460 _thread_stat = new ThreadStatistics(); 1461 _thread_stat = new ThreadStatistics();
1461 _blocked_on_compilation = false; 1462 _blocked_on_compilation = false;
1462 _jni_active_critical = 0; 1463 _jni_active_critical = 0;
1463 _do_not_unlock_if_synchronized = false; 1464 _do_not_unlock_if_synchronized = false;
1814 EVENT_THREAD_EXIT(this); 1815 EVENT_THREAD_EXIT(this);
1815 1816
1816 // Call Thread.exit(). We try 3 times in case we got another Thread.stop during 1817 // Call Thread.exit(). We try 3 times in case we got another Thread.stop during
1817 // the execution of the method. If that is not enough, then we don't really care. Thread.stop 1818 // the execution of the method. If that is not enough, then we don't really care. Thread.stop
1818 // is deprecated anyhow. 1819 // is deprecated anyhow.
1819 { int count = 3; 1820 if (!is_Compiler_thread()) {
1821 int count = 3;
1820 while (java_lang_Thread::threadGroup(threadObj()) != NULL && (count-- > 0)) { 1822 while (java_lang_Thread::threadGroup(threadObj()) != NULL && (count-- > 0)) {
1821 EXCEPTION_MARK; 1823 EXCEPTION_MARK;
1822 JavaValue result(T_VOID); 1824 JavaValue result(T_VOID);
1823 KlassHandle thread_klass(THREAD, SystemDictionary::Thread_klass()); 1825 KlassHandle thread_klass(THREAD, SystemDictionary::Thread_klass());
1824 JavaCalls::call_virtual(&result, 1826 JavaCalls::call_virtual(&result,
1827 vmSymbols::void_method_signature(), 1829 vmSymbols::void_method_signature(),
1828 THREAD); 1830 THREAD);
1829 CLEAR_PENDING_EXCEPTION; 1831 CLEAR_PENDING_EXCEPTION;
1830 } 1832 }
1831 } 1833 }
1832
1833 // notify JVMTI 1834 // notify JVMTI
1834 if (JvmtiExport::should_post_thread_life()) { 1835 if (JvmtiExport::should_post_thread_life()) {
1835 JvmtiExport::post_thread_end(this); 1836 JvmtiExport::post_thread_end(this);
1836 } 1837 }
1837 1838
3238 _task = NULL; 3239 _task = NULL;
3239 _queue = queue; 3240 _queue = queue;
3240 _counters = counters; 3241 _counters = counters;
3241 _buffer_blob = NULL; 3242 _buffer_blob = NULL;
3242 _scanned_nmethod = NULL; 3243 _scanned_nmethod = NULL;
3244 _compiler = NULL;
3243 3245
3244 #ifndef PRODUCT 3246 #ifndef PRODUCT
3245 _ideal_graph_printer = NULL; 3247 _ideal_graph_printer = NULL;
3246 #endif 3248 #endif
3247 } 3249 }
3253 // process it here to make sure it isn't unloaded in the middle of 3255 // process it here to make sure it isn't unloaded in the middle of
3254 // a scan. 3256 // a scan.
3255 cf->do_code_blob(_scanned_nmethod); 3257 cf->do_code_blob(_scanned_nmethod);
3256 } 3258 }
3257 } 3259 }
3260
3258 3261
3259 // ======= Threads ======== 3262 // ======= Threads ========
3260 3263
3261 // The Threads class links together all active threads, and provides 3264 // The Threads class links together all active threads, and provides
3262 // operations over all threads. It is protected by its own Mutex 3265 // operations over all threads. It is protected by its own Mutex
3273 bool Threads::_vm_complete = false; 3276 bool Threads::_vm_complete = false;
3274 #endif 3277 #endif
3275 3278
3276 // All JavaThreads 3279 // All JavaThreads
3277 #define ALL_JAVA_THREADS(X) for (JavaThread* X = _thread_list; X; X = X->next()) 3280 #define ALL_JAVA_THREADS(X) for (JavaThread* X = _thread_list; X; X = X->next())
3278
3279 void os_stream();
3280 3281
3281 // All JavaThreads + all non-JavaThreads (i.e., every thread in the system) 3282 // All JavaThreads + all non-JavaThreads (i.e., every thread in the system)
3282 void Threads::threads_do(ThreadClosure* tc) { 3283 void Threads::threads_do(ThreadClosure* tc) {
3283 assert_locked_or_safepoint(Threads_lock); 3284 assert_locked_or_safepoint(Threads_lock);
3284 // ALL_JAVA_THREADS iterates through all JavaThreads 3285 // ALL_JAVA_THREADS iterates through all JavaThreads
3329 Arguments::init_version_specific_system_properties(); 3330 Arguments::init_version_specific_system_properties();
3330 3331
3331 // Parse arguments 3332 // Parse arguments
3332 jint parse_result = Arguments::parse(args); 3333 jint parse_result = Arguments::parse(args);
3333 if (parse_result != JNI_OK) return parse_result; 3334 if (parse_result != JNI_OK) return parse_result;
3335
3336 os::init_before_ergo();
3337
3338 jint ergo_result = Arguments::apply_ergo();
3339 if (ergo_result != JNI_OK) return ergo_result;
3334 3340
3335 if (PauseAtStartup) { 3341 if (PauseAtStartup) {
3336 os::pause(); 3342 os::pause();
3337 } 3343 }
3338 3344
3637 // initialize compiler(s) 3643 // initialize compiler(s)
3638 #if defined(COMPILER1) || defined(COMPILER2) || defined(SHARK) 3644 #if defined(COMPILER1) || defined(COMPILER2) || defined(SHARK)
3639 CompileBroker::compilation_init(); 3645 CompileBroker::compilation_init();
3640 #endif 3646 #endif
3641 3647
3648 if (EnableInvokeDynamic) {
3649 // Pre-initialize some JSR292 core classes to avoid deadlock during class loading.
3650 // It is done after compilers are initialized, because otherwise compilations of
3651 // signature polymorphic MH intrinsics can be missed
3652 // (see SystemDictionary::find_method_handle_intrinsic).
3653 initialize_class(vmSymbols::java_lang_invoke_MethodHandle(), CHECK_0);
3654 initialize_class(vmSymbols::java_lang_invoke_MemberName(), CHECK_0);
3655 initialize_class(vmSymbols::java_lang_invoke_MethodHandleNatives(), CHECK_0);
3656 }
3657
3642 #if INCLUDE_MANAGEMENT 3658 #if INCLUDE_MANAGEMENT
3643 Management::initialize(THREAD); 3659 Management::initialize(THREAD);
3644 #endif // INCLUDE_MANAGEMENT 3660 #endif // INCLUDE_MANAGEMENT
3645 3661
3646 if (HAS_PENDING_EXCEPTION) { 3662 if (HAS_PENDING_EXCEPTION) {
3705 char buffer[JVM_MAXPATHLEN]; 3721 char buffer[JVM_MAXPATHLEN];
3706 char ebuf[1024]; 3722 char ebuf[1024];
3707 const char *name = agent->name(); 3723 const char *name = agent->name();
3708 const char *msg = "Could not find agent library "; 3724 const char *msg = "Could not find agent library ";
3709 3725
3710 // First check to see if agent is statcally linked into executable 3726 // First check to see if agent is statically linked into executable
3711 if (os::find_builtin_agent(agent, on_load_symbols, num_symbol_entries)) { 3727 if (os::find_builtin_agent(agent, on_load_symbols, num_symbol_entries)) {
3712 library = agent->os_lib(); 3728 library = agent->os_lib();
3713 } else if (agent->is_absolute_path()) { 3729 } else if (agent->is_absolute_path()) {
3714 library = os::dll_load(name, ebuf, sizeof ebuf); 3730 library = os::dll_load(name, ebuf, sizeof ebuf);
3715 if (library == NULL) { 3731 if (library == NULL) {