Mercurial > hg > truffle
comparison src/share/vm/runtime/thread.cpp @ 11173:6b0fd0964b87
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Wed, 31 Jul 2013 11:00:54 +0200 |
parents | d55f24eac4b1 02d7aa1456c9 |
children | d7964e96b0b0 |
comparison
equal
deleted
inserted
replaced
10912:4ea54634f03e | 11173:6b0fd0964b87 |
---|---|
46 #include "oops/symbol.hpp" | 46 #include "oops/symbol.hpp" |
47 #include "prims/jvm_misc.hpp" | 47 #include "prims/jvm_misc.hpp" |
48 #include "prims/jvmtiExport.hpp" | 48 #include "prims/jvmtiExport.hpp" |
49 #include "prims/jvmtiThreadState.hpp" | 49 #include "prims/jvmtiThreadState.hpp" |
50 #include "prims/privilegedStack.hpp" | 50 #include "prims/privilegedStack.hpp" |
51 #include "runtime/aprofiler.hpp" | |
52 #include "runtime/arguments.hpp" | 51 #include "runtime/arguments.hpp" |
53 #include "runtime/biasedLocking.hpp" | 52 #include "runtime/biasedLocking.hpp" |
54 #include "runtime/deoptimization.hpp" | 53 #include "runtime/deoptimization.hpp" |
55 #include "runtime/fprofiler.hpp" | 54 #include "runtime/fprofiler.hpp" |
56 #include "runtime/frame.inline.hpp" | 55 #include "runtime/frame.inline.hpp" |
221 set_lgrp_id(-1); | 220 set_lgrp_id(-1); |
222 | 221 |
223 // allocated data structures | 222 // allocated data structures |
224 set_osthread(NULL); | 223 set_osthread(NULL); |
225 set_resource_area(new (mtThread)ResourceArea()); | 224 set_resource_area(new (mtThread)ResourceArea()); |
225 DEBUG_ONLY(_current_resource_mark = NULL;) | |
226 set_handle_area(new (mtThread) HandleArea(NULL)); | 226 set_handle_area(new (mtThread) HandleArea(NULL)); |
227 set_metadata_handles(new (ResourceObj::C_HEAP, mtClass) GrowableArray<Metadata*>(300, true)); | 227 set_metadata_handles(new (ResourceObj::C_HEAP, mtClass) GrowableArray<Metadata*>(30, true)); |
228 set_active_handles(NULL); | 228 set_active_handles(NULL); |
229 set_free_handle_block(NULL); | 229 set_free_handle_block(NULL); |
230 set_last_handle_mark(NULL); | 230 set_last_handle_mark(NULL); |
231 | 231 |
232 // This initial value ==> never claimed. | 232 // This initial value ==> never claimed. |
956 | 956 |
957 return false; | 957 return false; |
958 } | 958 } |
959 | 959 |
960 | 960 |
961 bool Thread::is_in_usable_stack(address adr) const { | |
962 size_t stack_guard_size = os::uses_stack_guard_pages() ? (StackYellowPages + StackRedPages) * os::vm_page_size() : 0; | |
963 size_t usable_stack_size = _stack_size - stack_guard_size; | |
964 | |
965 return ((adr < stack_base()) && (adr >= stack_base() - usable_stack_size)); | |
966 } | |
967 | |
968 | |
961 // We had to move these methods here, because vm threads get into ObjectSynchronizer::enter | 969 // We had to move these methods here, because vm threads get into ObjectSynchronizer::enter |
962 // However, there is a note in JavaThread::is_lock_owned() about the VM threads not being | 970 // However, there is a note in JavaThread::is_lock_owned() about the VM threads not being |
963 // used for compilation in the future. If that change is made, the need for these methods | 971 // used for compilation in the future. If that change is made, the need for these methods |
964 // should be revisited, and they should be removed if possible. | 972 // should be revisited, and they should be removed if possible. |
965 | 973 |
1220 | 1228 |
1221 WatcherThread* WatcherThread::_watcher_thread = NULL; | 1229 WatcherThread* WatcherThread::_watcher_thread = NULL; |
1222 bool WatcherThread::_startable = false; | 1230 bool WatcherThread::_startable = false; |
1223 volatile bool WatcherThread::_should_terminate = false; | 1231 volatile bool WatcherThread::_should_terminate = false; |
1224 | 1232 |
1225 WatcherThread::WatcherThread() : Thread() { | 1233 WatcherThread::WatcherThread() : Thread(), _crash_protection(NULL) { |
1226 assert(watcher_thread() == NULL, "we can only allocate one WatcherThread"); | 1234 assert(watcher_thread() == NULL, "we can only allocate one WatcherThread"); |
1227 if (os::create_thread(this, os::watcher_thread)) { | 1235 if (os::create_thread(this, os::watcher_thread)) { |
1228 _watcher_thread = this; | 1236 _watcher_thread = this; |
1229 | 1237 |
1230 // Set the watcher thread to the highest OS priority which should not be | 1238 // Set the watcher thread to the highest OS priority which should not be |
3488 create_vm_init_libraries(); | 3496 create_vm_init_libraries(); |
3489 } | 3497 } |
3490 | 3498 |
3491 initialize_class(vmSymbols::java_lang_String(), CHECK_0); | 3499 initialize_class(vmSymbols::java_lang_String(), CHECK_0); |
3492 | 3500 |
3493 if (AggressiveOpts) { | |
3494 { | |
3495 // Forcibly initialize java/util/HashMap and mutate the private | |
3496 // static final "frontCacheEnabled" field before we start creating instances | |
3497 #ifdef ASSERT | |
3498 Klass* tmp_k = SystemDictionary::find(vmSymbols::java_util_HashMap(), Handle(), Handle(), CHECK_0); | |
3499 assert(tmp_k == NULL, "java/util/HashMap should not be loaded yet"); | |
3500 #endif | |
3501 Klass* k_o = SystemDictionary::resolve_or_null(vmSymbols::java_util_HashMap(), Handle(), Handle(), CHECK_0); | |
3502 KlassHandle k = KlassHandle(THREAD, k_o); | |
3503 guarantee(k.not_null(), "Must find java/util/HashMap"); | |
3504 instanceKlassHandle ik = instanceKlassHandle(THREAD, k()); | |
3505 ik->initialize(CHECK_0); | |
3506 fieldDescriptor fd; | |
3507 // Possible we might not find this field; if so, don't break | |
3508 if (ik->find_local_field(vmSymbols::frontCacheEnabled_name(), vmSymbols::bool_signature(), &fd)) { | |
3509 k()->java_mirror()->bool_field_put(fd.offset(), true); | |
3510 } | |
3511 } | |
3512 | |
3513 if (UseStringCache) { | |
3514 // Forcibly initialize java/lang/StringValue and mutate the private | |
3515 // static final "stringCacheEnabled" field before we start creating instances | |
3516 Klass* k_o = SystemDictionary::resolve_or_null(vmSymbols::java_lang_StringValue(), Handle(), Handle(), CHECK_0); | |
3517 // Possible that StringValue isn't present: if so, silently don't break | |
3518 if (k_o != NULL) { | |
3519 KlassHandle k = KlassHandle(THREAD, k_o); | |
3520 instanceKlassHandle ik = instanceKlassHandle(THREAD, k()); | |
3521 ik->initialize(CHECK_0); | |
3522 fieldDescriptor fd; | |
3523 // Possible we might not find this field: if so, silently don't break | |
3524 if (ik->find_local_field(vmSymbols::stringCacheEnabled_name(), vmSymbols::bool_signature(), &fd)) { | |
3525 k()->java_mirror()->bool_field_put(fd.offset(), true); | |
3526 } | |
3527 } | |
3528 } | |
3529 } | |
3530 | |
3531 // Initialize java_lang.System (needed before creating the thread) | 3501 // Initialize java_lang.System (needed before creating the thread) |
3532 initialize_class(vmSymbols::java_lang_System(), CHECK_0); | 3502 initialize_class(vmSymbols::java_lang_System(), CHECK_0); |
3533 initialize_class(vmSymbols::java_lang_ThreadGroup(), CHECK_0); | 3503 initialize_class(vmSymbols::java_lang_ThreadGroup(), CHECK_0); |
3534 Handle thread_group = create_initial_thread_group(CHECK_0); | 3504 Handle thread_group = create_initial_thread_group(CHECK_0); |
3535 Universe::set_main_thread_group(thread_group()); | 3505 Universe::set_main_thread_group(thread_group()); |
3643 // Signal Dispatcher needs to be started before VMInit event is posted | 3613 // Signal Dispatcher needs to be started before VMInit event is posted |
3644 os::signal_init(); | 3614 os::signal_init(); |
3645 | 3615 |
3646 // Start Attach Listener if +StartAttachListener or it can't be started lazily | 3616 // Start Attach Listener if +StartAttachListener or it can't be started lazily |
3647 if (!DisableAttachMechanism) { | 3617 if (!DisableAttachMechanism) { |
3618 AttachListener::vm_start(); | |
3648 if (StartAttachListener || AttachListener::init_at_startup()) { | 3619 if (StartAttachListener || AttachListener::init_at_startup()) { |
3649 AttachListener::init(); | 3620 AttachListener::init(); |
3650 } | 3621 } |
3651 } | 3622 } |
3652 | 3623 |
3683 // stack trace if appropriate. Simply exit VM. | 3654 // stack trace if appropriate. Simply exit VM. |
3684 vm_exit(1); | 3655 vm_exit(1); |
3685 } | 3656 } |
3686 | 3657 |
3687 if (Arguments::has_profile()) FlatProfiler::engage(main_thread, true); | 3658 if (Arguments::has_profile()) FlatProfiler::engage(main_thread, true); |
3688 if (Arguments::has_alloc_profile()) AllocationProfiler::engage(); | |
3689 if (MemProfiling) MemProfiler::engage(); | 3659 if (MemProfiling) MemProfiler::engage(); |
3690 StatSampler::engage(); | 3660 StatSampler::engage(); |
3691 if (CheckJNICalls) JniPeriodicChecker::engage(); | 3661 if (CheckJNICalls) JniPeriodicChecker::engage(); |
3692 | 3662 |
3693 BiasedLocking::init(); | 3663 BiasedLocking::init(); |