comparison src/share/vm/runtime/thread.cpp @ 14407:94c202aa2646

Merge
author kvn
date Thu, 01 Aug 2013 17:25:10 -0700
parents 438e13354adf 02d7aa1456c9
children e2722a66aba7
comparison
equal deleted inserted replaced
14406:c9f0adfb4a8b 14407:94c202aa2646
216 set_lgrp_id(-1); 216 set_lgrp_id(-1);
217 217
218 // allocated data structures 218 // allocated data structures
219 set_osthread(NULL); 219 set_osthread(NULL);
220 set_resource_area(new (mtThread)ResourceArea()); 220 set_resource_area(new (mtThread)ResourceArea());
221 DEBUG_ONLY(_current_resource_mark = NULL;)
221 set_handle_area(new (mtThread) HandleArea(NULL)); 222 set_handle_area(new (mtThread) HandleArea(NULL));
222 set_metadata_handles(new (ResourceObj::C_HEAP, mtClass) GrowableArray<Metadata*>(30, true)); 223 set_metadata_handles(new (ResourceObj::C_HEAP, mtClass) GrowableArray<Metadata*>(30, true));
223 set_active_handles(NULL); 224 set_active_handles(NULL);
224 set_free_handle_block(NULL); 225 set_free_handle_block(NULL);
225 set_last_handle_mark(NULL); 226 set_last_handle_mark(NULL);
954 955
955 return false; 956 return false;
956 } 957 }
957 958
958 959
960 bool Thread::is_in_usable_stack(address adr) const {
961 size_t stack_guard_size = os::uses_stack_guard_pages() ? (StackYellowPages + StackRedPages) * os::vm_page_size() : 0;
962 size_t usable_stack_size = _stack_size - stack_guard_size;
963
964 return ((adr < stack_base()) && (adr >= stack_base() - usable_stack_size));
965 }
966
967
959 // We had to move these methods here, because vm threads get into ObjectSynchronizer::enter 968 // We had to move these methods here, because vm threads get into ObjectSynchronizer::enter
960 // However, there is a note in JavaThread::is_lock_owned() about the VM threads not being 969 // However, there is a note in JavaThread::is_lock_owned() about the VM threads not being
961 // used for compilation in the future. If that change is made, the need for these methods 970 // used for compilation in the future. If that change is made, the need for these methods
962 // should be revisited, and they should be removed if possible. 971 // should be revisited, and they should be removed if possible.
963 972
1218 1227
1219 WatcherThread* WatcherThread::_watcher_thread = NULL; 1228 WatcherThread* WatcherThread::_watcher_thread = NULL;
1220 bool WatcherThread::_startable = false; 1229 bool WatcherThread::_startable = false;
1221 volatile bool WatcherThread::_should_terminate = false; 1230 volatile bool WatcherThread::_should_terminate = false;
1222 1231
1223 WatcherThread::WatcherThread() : Thread() { 1232 WatcherThread::WatcherThread() : Thread(), _crash_protection(NULL) {
1224 assert(watcher_thread() == NULL, "we can only allocate one WatcherThread"); 1233 assert(watcher_thread() == NULL, "we can only allocate one WatcherThread");
1225 if (os::create_thread(this, os::watcher_thread)) { 1234 if (os::create_thread(this, os::watcher_thread)) {
1226 _watcher_thread = this; 1235 _watcher_thread = this;
1227 1236
1228 // Set the watcher thread to the highest OS priority which should not be 1237 // Set the watcher thread to the highest OS priority which should not be
3482 create_vm_init_libraries(); 3491 create_vm_init_libraries();
3483 } 3492 }
3484 3493
3485 initialize_class(vmSymbols::java_lang_String(), CHECK_0); 3494 initialize_class(vmSymbols::java_lang_String(), CHECK_0);
3486 3495
3487 if (AggressiveOpts) {
3488 {
3489 // Forcibly initialize java/util/HashMap and mutate the private
3490 // static final "frontCacheEnabled" field before we start creating instances
3491 #ifdef ASSERT
3492 Klass* tmp_k = SystemDictionary::find(vmSymbols::java_util_HashMap(), Handle(), Handle(), CHECK_0);
3493 assert(tmp_k == NULL, "java/util/HashMap should not be loaded yet");
3494 #endif
3495 Klass* k_o = SystemDictionary::resolve_or_null(vmSymbols::java_util_HashMap(), Handle(), Handle(), CHECK_0);
3496 KlassHandle k = KlassHandle(THREAD, k_o);
3497 guarantee(k.not_null(), "Must find java/util/HashMap");
3498 instanceKlassHandle ik = instanceKlassHandle(THREAD, k());
3499 ik->initialize(CHECK_0);
3500 fieldDescriptor fd;
3501 // Possible we might not find this field; if so, don't break
3502 if (ik->find_local_field(vmSymbols::frontCacheEnabled_name(), vmSymbols::bool_signature(), &fd)) {
3503 k()->java_mirror()->bool_field_put(fd.offset(), true);
3504 }
3505 }
3506
3507 if (UseStringCache) {
3508 // Forcibly initialize java/lang/StringValue and mutate the private
3509 // static final "stringCacheEnabled" field before we start creating instances
3510 Klass* k_o = SystemDictionary::resolve_or_null(vmSymbols::java_lang_StringValue(), Handle(), Handle(), CHECK_0);
3511 // Possible that StringValue isn't present: if so, silently don't break
3512 if (k_o != NULL) {
3513 KlassHandle k = KlassHandle(THREAD, k_o);
3514 instanceKlassHandle ik = instanceKlassHandle(THREAD, k());
3515 ik->initialize(CHECK_0);
3516 fieldDescriptor fd;
3517 // Possible we might not find this field: if so, silently don't break
3518 if (ik->find_local_field(vmSymbols::stringCacheEnabled_name(), vmSymbols::bool_signature(), &fd)) {
3519 k()->java_mirror()->bool_field_put(fd.offset(), true);
3520 }
3521 }
3522 }
3523 }
3524
3525 // Initialize java_lang.System (needed before creating the thread) 3496 // Initialize java_lang.System (needed before creating the thread)
3526 initialize_class(vmSymbols::java_lang_System(), CHECK_0); 3497 initialize_class(vmSymbols::java_lang_System(), CHECK_0);
3527 initialize_class(vmSymbols::java_lang_ThreadGroup(), CHECK_0); 3498 initialize_class(vmSymbols::java_lang_ThreadGroup(), CHECK_0);
3528 Handle thread_group = create_initial_thread_group(CHECK_0); 3499 Handle thread_group = create_initial_thread_group(CHECK_0);
3529 Universe::set_main_thread_group(thread_group()); 3500 Universe::set_main_thread_group(thread_group());
3637 // Signal Dispatcher needs to be started before VMInit event is posted 3608 // Signal Dispatcher needs to be started before VMInit event is posted
3638 os::signal_init(); 3609 os::signal_init();
3639 3610
3640 // Start Attach Listener if +StartAttachListener or it can't be started lazily 3611 // Start Attach Listener if +StartAttachListener or it can't be started lazily
3641 if (!DisableAttachMechanism) { 3612 if (!DisableAttachMechanism) {
3613 AttachListener::vm_start();
3642 if (StartAttachListener || AttachListener::init_at_startup()) { 3614 if (StartAttachListener || AttachListener::init_at_startup()) {
3643 AttachListener::init(); 3615 AttachListener::init();
3644 } 3616 }
3645 } 3617 }
3646 3618