< prev index next >

src/hotspot/share/runtime/thread.cpp

Print this page




  97 #include "runtime/vframeArray.hpp"
  98 #include "runtime/vframe_hp.hpp"
  99 #include "runtime/vmThread.hpp"
 100 #include "runtime/vm_operations.hpp"
 101 #include "runtime/vm_version.hpp"
 102 #include "services/attachListener.hpp"
 103 #include "services/management.hpp"
 104 #include "services/memTracker.hpp"
 105 #include "services/threadService.hpp"
 106 #include "trace/traceMacros.hpp"
 107 #include "trace/tracing.hpp"
 108 #include "utilities/align.hpp"
 109 #include "utilities/defaultStream.hpp"
 110 #include "utilities/dtrace.hpp"
 111 #include "utilities/events.hpp"
 112 #include "utilities/macros.hpp"
 113 #include "utilities/preserveException.hpp"
 114 #include "utilities/vmError.hpp"
 115 #if INCLUDE_ALL_GCS
 116 #include "gc/cms/concurrentMarkSweepThread.hpp"

 117 #include "gc/g1/g1ConcurrentMarkThread.inline.hpp"
 118 #include "gc/parallel/pcTasks.hpp"
 119 #endif // INCLUDE_ALL_GCS
 120 #if INCLUDE_JVMCI
 121 #include "jvmci/jvmciCompiler.hpp"
 122 #include "jvmci/jvmciRuntime.hpp"
 123 #include "logging/logHandle.hpp"
 124 #endif
 125 #ifdef COMPILER1
 126 #include "c1/c1_Compiler.hpp"
 127 #endif
 128 #ifdef COMPILER2
 129 #include "opto/c2compiler.hpp"
 130 #include "opto/idealGraphPrinter.hpp"
 131 #endif
 132 #if INCLUDE_RTM_OPT
 133 #include "runtime/rtmLocking.hpp"
 134 #endif
 135 
 136 // Initialization after module runtime initialization


1571 #endif // PRODUCT
1572 
1573   // Setup safepoint state info for this thread
1574   ThreadSafepointState::create(this);
1575 
1576   debug_only(_java_call_counter = 0);
1577 
1578   // JVMTI PopFrame support
1579   _popframe_condition = popframe_inactive;
1580   _popframe_preserved_args = NULL;
1581   _popframe_preserved_args_size = 0;
1582   _frames_to_pop_failed_realloc = 0;
1583 
1584   if (SafepointMechanism::uses_thread_local_poll()) {
1585     SafepointMechanism::initialize_header(this);
1586   }
1587 
1588   pd_initialize();
1589 }
1590 
1591 #if INCLUDE_ALL_GCS
1592 SATBMarkQueueSet JavaThread::_satb_mark_queue_set;
1593 DirtyCardQueueSet JavaThread::_dirty_card_queue_set;
1594 #endif // INCLUDE_ALL_GCS
1595 
1596 JavaThread::JavaThread(bool is_attaching_via_jni) :
1597                        Thread()
1598 #if INCLUDE_ALL_GCS
1599                        , _satb_mark_queue(&_satb_mark_queue_set),
1600                        _dirty_card_queue(&_dirty_card_queue_set)
1601 #endif // INCLUDE_ALL_GCS
1602 {
1603   initialize();
1604   if (is_attaching_via_jni) {
1605     _jni_attach_state = _attaching_via_jni;
1606   } else {
1607     _jni_attach_state = _not_attaching_via_jni;
1608   }
1609   assert(deferred_card_mark().is_empty(), "Default MemRegion ctor");
1610 }
1611 
1612 bool JavaThread::reguard_stack(address cur_sp) {
1613   if (_stack_guard_state != stack_guard_yellow_reserved_disabled
1614       && _stack_guard_state != stack_guard_reserved_disabled) {
1615     return true; // Stack already guarded or guard pages not needed.
1616   }
1617 
1618   if (register_stack_overflow()) {
1619     // For those architectures which have separate register and
1620     // memory stacks, we must check the register stack to see if


1646 }
1647 
1648 
1649 void JavaThread::block_if_vm_exited() {
1650   if (_terminated == _vm_exited) {
1651     // _vm_exited is set at safepoint, and Threads_lock is never released
1652     // we will block here forever
1653     Threads_lock->lock_without_safepoint_check();
1654     ShouldNotReachHere();
1655   }
1656 }
1657 
1658 
1659 // Remove this ifdef when C1 is ported to the compiler interface.
1660 static void compiler_thread_entry(JavaThread* thread, TRAPS);
1661 static void sweeper_thread_entry(JavaThread* thread, TRAPS);
1662 
1663 JavaThread::JavaThread(ThreadFunction entry_point, size_t stack_sz) :
1664                        Thread()
1665 #if INCLUDE_ALL_GCS
1666                        , _satb_mark_queue(&_satb_mark_queue_set),
1667                        _dirty_card_queue(&_dirty_card_queue_set)
1668 #endif // INCLUDE_ALL_GCS
1669 {
1670   initialize();
1671   _jni_attach_state = _not_attaching_via_jni;
1672   set_entry_point(entry_point);
1673   // Create the native thread itself.
1674   // %note runtime_23
1675   os::ThreadType thr_type = os::java_thread;
1676   thr_type = entry_point == &compiler_thread_entry ? os::compiler_thread :
1677                                                      os::java_thread;
1678   os::create_thread(this, thr_type, stack_sz);
1679   // The _osthread may be NULL here because we ran out of memory (too many threads active).
1680   // We need to throw and OutOfMemoryError - however we cannot do this here because the caller
1681   // may hold a lock and all locks must be unlocked before throwing the exception (throwing
1682   // the exception consists of creating the exception object & initializing it, initialization
1683   // will leave the VM via a JavaCall and then all locks must be unlocked).
1684   //
1685   // The thread is still suspended when we reach here. Thread must be explicit started
1686   // by creator! Furthermore, the thread must also explicitly be added to the Threads list
1687   // by calling Threads:add. The reason why this is not done here, is because the thread




  97 #include "runtime/vframeArray.hpp"
  98 #include "runtime/vframe_hp.hpp"
  99 #include "runtime/vmThread.hpp"
 100 #include "runtime/vm_operations.hpp"
 101 #include "runtime/vm_version.hpp"
 102 #include "services/attachListener.hpp"
 103 #include "services/management.hpp"
 104 #include "services/memTracker.hpp"
 105 #include "services/threadService.hpp"
 106 #include "trace/traceMacros.hpp"
 107 #include "trace/tracing.hpp"
 108 #include "utilities/align.hpp"
 109 #include "utilities/defaultStream.hpp"
 110 #include "utilities/dtrace.hpp"
 111 #include "utilities/events.hpp"
 112 #include "utilities/macros.hpp"
 113 #include "utilities/preserveException.hpp"
 114 #include "utilities/vmError.hpp"
 115 #if INCLUDE_ALL_GCS
 116 #include "gc/cms/concurrentMarkSweepThread.hpp"
 117 #include "gc/g1/g1BarrierSet.hpp"
 118 #include "gc/g1/g1ConcurrentMarkThread.inline.hpp"
 119 #include "gc/parallel/pcTasks.hpp"
 120 #endif // INCLUDE_ALL_GCS
 121 #if INCLUDE_JVMCI
 122 #include "jvmci/jvmciCompiler.hpp"
 123 #include "jvmci/jvmciRuntime.hpp"
 124 #include "logging/logHandle.hpp"
 125 #endif
 126 #ifdef COMPILER1
 127 #include "c1/c1_Compiler.hpp"
 128 #endif
 129 #ifdef COMPILER2
 130 #include "opto/c2compiler.hpp"
 131 #include "opto/idealGraphPrinter.hpp"
 132 #endif
 133 #if INCLUDE_RTM_OPT
 134 #include "runtime/rtmLocking.hpp"
 135 #endif
 136 
 137 // Initialization after module runtime initialization


1572 #endif // PRODUCT
1573 
1574   // Setup safepoint state info for this thread
1575   ThreadSafepointState::create(this);
1576 
1577   debug_only(_java_call_counter = 0);
1578 
1579   // JVMTI PopFrame support
1580   _popframe_condition = popframe_inactive;
1581   _popframe_preserved_args = NULL;
1582   _popframe_preserved_args_size = 0;
1583   _frames_to_pop_failed_realloc = 0;
1584 
1585   if (SafepointMechanism::uses_thread_local_poll()) {
1586     SafepointMechanism::initialize_header(this);
1587   }
1588 
1589   pd_initialize();
1590 }
1591 





1592 JavaThread::JavaThread(bool is_attaching_via_jni) :
1593                        Thread()
1594 #if INCLUDE_ALL_GCS
1595                        , _satb_mark_queue(&G1BarrierSet::satb_mark_queue_set()),
1596                        _dirty_card_queue(&G1BarrierSet::dirty_card_queue_set())
1597 #endif // INCLUDE_ALL_GCS
1598 {
1599   initialize();
1600   if (is_attaching_via_jni) {
1601     _jni_attach_state = _attaching_via_jni;
1602   } else {
1603     _jni_attach_state = _not_attaching_via_jni;
1604   }
1605   assert(deferred_card_mark().is_empty(), "Default MemRegion ctor");
1606 }
1607 
1608 bool JavaThread::reguard_stack(address cur_sp) {
1609   if (_stack_guard_state != stack_guard_yellow_reserved_disabled
1610       && _stack_guard_state != stack_guard_reserved_disabled) {
1611     return true; // Stack already guarded or guard pages not needed.
1612   }
1613 
1614   if (register_stack_overflow()) {
1615     // For those architectures which have separate register and
1616     // memory stacks, we must check the register stack to see if


1642 }
1643 
1644 
1645 void JavaThread::block_if_vm_exited() {
1646   if (_terminated == _vm_exited) {
1647     // _vm_exited is set at safepoint, and Threads_lock is never released
1648     // we will block here forever
1649     Threads_lock->lock_without_safepoint_check();
1650     ShouldNotReachHere();
1651   }
1652 }
1653 
1654 
1655 // Remove this ifdef when C1 is ported to the compiler interface.
1656 static void compiler_thread_entry(JavaThread* thread, TRAPS);
1657 static void sweeper_thread_entry(JavaThread* thread, TRAPS);
1658 
1659 JavaThread::JavaThread(ThreadFunction entry_point, size_t stack_sz) :
1660                        Thread()
1661 #if INCLUDE_ALL_GCS
1662                        , _satb_mark_queue(&G1BarrierSet::satb_mark_queue_set()),
1663                        _dirty_card_queue(&G1BarrierSet::dirty_card_queue_set())
1664 #endif // INCLUDE_ALL_GCS
1665 {
1666   initialize();
1667   _jni_attach_state = _not_attaching_via_jni;
1668   set_entry_point(entry_point);
1669   // Create the native thread itself.
1670   // %note runtime_23
1671   os::ThreadType thr_type = os::java_thread;
1672   thr_type = entry_point == &compiler_thread_entry ? os::compiler_thread :
1673                                                      os::java_thread;
1674   os::create_thread(this, thr_type, stack_sz);
1675   // The _osthread may be NULL here because we ran out of memory (too many threads active).
1676   // We need to throw and OutOfMemoryError - however we cannot do this here because the caller
1677   // may hold a lock and all locks must be unlocked before throwing the exception (throwing
1678   // the exception consists of creating the exception object & initializing it, initialization
1679   // will leave the VM via a JavaCall and then all locks must be unlocked).
1680   //
1681   // The thread is still suspended when we reach here. Thread must be explicit started
1682   // by creator! Furthermore, the thread must also explicitly be added to the Threads list
1683   // by calling Threads:add. The reason why this is not done here, is because the thread


< prev index next >