< prev index next >

src/hotspot/share/runtime/thread.cpp

Print this page

119     _unhandled_oops = new UnhandledOops(this);
120   }
121 #endif // CHECK_UNHANDLED_OOPS
122 
123   // Notify the barrier set that a thread is being created. The initial
124   // thread is created before the barrier set is available.  The call to
125   // BarrierSet::on_thread_create() for this thread is therefore deferred
126   // to BarrierSet::set_barrier_set().
127   BarrierSet* const barrier_set = BarrierSet::barrier_set();
128   if (barrier_set != nullptr) {
129     barrier_set->on_thread_create(this);
130   } else {
131     // Only the main thread should be created before the barrier set
132     // and that happens just before Thread::current is set. No other thread
133     // can attach as the VM is not created yet, so they can't execute this code.
134     // If the main thread creates other threads before the barrier set that is an error.
135     assert(Thread::current_or_null() == nullptr, "creating thread before barrier set");
136   }
137 
138   MACOS_AARCH64_ONLY(DEBUG_ONLY(_wx_init = false));











139 }
140 
141 #ifdef ASSERT
142 address Thread::stack_base() const {
143   // Note: can't report Thread::name() here as that can require a ResourceMark which we
144   // can't use because this gets called too early in the thread initialization.
145   assert(_stack_base != nullptr, "Stack base not yet set for thread id:%d (0 if not set)",
146          osthread() != nullptr ? osthread()->thread_id() : 0);
147   return _stack_base;
148 }
149 #endif
150 
151 void Thread::initialize_tlab() {
152   if (UseTLAB) {
153     tlab().initialize();
154   }
155 }
156 
157 void Thread::retire_tlab(ThreadLocalAllocStats* stats) {
158   // Sampling and serviceability support

550     }
551   }
552 }
553 
554 Thread* Thread::_starting_thread = nullptr;
555 
556 bool Thread::is_starting_thread(const Thread* t) {
557   assert(_starting_thread != nullptr, "invariant");
558   return t == _starting_thread;
559 }
560 #endif // ASSERT
561 
562 bool Thread::set_as_starting_thread(JavaThread* jt) {
563   assert(jt != nullptr, "invariant");
564   assert(_starting_thread == nullptr, "already initialized: "
565          "_starting_thread=" INTPTR_FORMAT, p2i(_starting_thread));
566   // NOTE: this must be called from Threads::create_vm().
567   DEBUG_ONLY(_starting_thread = jt;)
568   return os::create_main_thread(jt);
569 }












119     _unhandled_oops = new UnhandledOops(this);
120   }
121 #endif // CHECK_UNHANDLED_OOPS
122 
123   // Notify the barrier set that a thread is being created. The initial
124   // thread is created before the barrier set is available.  The call to
125   // BarrierSet::on_thread_create() for this thread is therefore deferred
126   // to BarrierSet::set_barrier_set().
127   BarrierSet* const barrier_set = BarrierSet::barrier_set();
128   if (barrier_set != nullptr) {
129     barrier_set->on_thread_create(this);
130   } else {
131     // Only the main thread should be created before the barrier set
132     // and that happens just before Thread::current is set. No other thread
133     // can attach as the VM is not created yet, so they can't execute this code.
134     // If the main thread creates other threads before the barrier set that is an error.
135     assert(Thread::current_or_null() == nullptr, "creating thread before barrier set");
136   }
137 
138   MACOS_AARCH64_ONLY(DEBUG_ONLY(_wx_init = false));
139 
140   _profile_vm_locks = false;
141   _profile_vm_calls = false;
142   _profile_vm_ops   = false;
143   _profile_rt_calls = false;
144   _profile_upcalls  = false;
145 
146   _all_bc_counter_value = 0;
147   _clinit_bc_counter_value = 0;
148 
149   _current_rt_call_timer = nullptr;
150 }
151 
152 #ifdef ASSERT
153 address Thread::stack_base() const {
154   // Note: can't report Thread::name() here as that can require a ResourceMark which we
155   // can't use because this gets called too early in the thread initialization.
156   assert(_stack_base != nullptr, "Stack base not yet set for thread id:%d (0 if not set)",
157          osthread() != nullptr ? osthread()->thread_id() : 0);
158   return _stack_base;
159 }
160 #endif
161 
162 void Thread::initialize_tlab() {
163   if (UseTLAB) {
164     tlab().initialize();
165   }
166 }
167 
168 void Thread::retire_tlab(ThreadLocalAllocStats* stats) {
169   // Sampling and serviceability support

561     }
562   }
563 }
564 
565 Thread* Thread::_starting_thread = nullptr;
566 
567 bool Thread::is_starting_thread(const Thread* t) {
568   assert(_starting_thread != nullptr, "invariant");
569   return t == _starting_thread;
570 }
571 #endif // ASSERT
572 
573 bool Thread::set_as_starting_thread(JavaThread* jt) {
574   assert(jt != nullptr, "invariant");
575   assert(_starting_thread == nullptr, "already initialized: "
576          "_starting_thread=" INTPTR_FORMAT, p2i(_starting_thread));
577   // NOTE: this must be called from Threads::create_vm().
578   DEBUG_ONLY(_starting_thread = jt;)
579   return os::create_main_thread(jt);
580 }
581 
582 const char* ProfileVMCallContext::name(PerfTraceTime* t) {
583   return t->name();
584 }
585 
586 int ProfileVMCallContext::_perf_nested_runtime_calls_count = 0;
587 
588 void ProfileVMCallContext::notify_nested_rt_call(PerfTraceTime* outer_timer, PerfTraceTime* inner_timer) {
589   log_debug(init)("Nested runtime call: inner=%s outer=%s", inner_timer->name(), outer_timer->name());
590   AtomicAccess::inc(&ProfileVMCallContext::_perf_nested_runtime_calls_count);
591 }
< prev index next >