< prev index next >

src/hotspot/share/runtime/thread.cpp

Print this page
rev 49264 : [mq]: event-only


 219 // JavaThread
 220 
 221 
 222 Thread::Thread() {
 223   // stack and get_thread
 224   set_stack_base(NULL);
 225   set_stack_size(0);
 226   set_self_raw_id(0);
 227   set_lgrp_id(-1);
 228   DEBUG_ONLY(clear_suspendible_thread();)
 229 
 230   // allocated data structures
 231   set_osthread(NULL);
 232   set_resource_area(new (mtThread)ResourceArea());
 233   DEBUG_ONLY(_current_resource_mark = NULL;)
 234   set_handle_area(new (mtThread) HandleArea(NULL));
 235   set_metadata_handles(new (ResourceObj::C_HEAP, mtClass) GrowableArray<Metadata*>(30, true));
 236   set_active_handles(NULL);
 237   set_free_handle_block(NULL);
 238   set_last_handle_mark(NULL);

 239 
 240   // This initial value ==> never claimed.
 241   _oops_do_parity = 0;
 242   _threads_hazard_ptr = NULL;
 243   _nested_threads_hazard_ptr = NULL;
 244   _nested_threads_hazard_ptr_cnt = 0;
 245 
 246   // the handle mark links itself to last_handle_mark
 247   new HandleMark(this);
 248 
 249   // plain initialization
 250   debug_only(_owned_locks = NULL;)
 251   debug_only(_allow_allocation_count = 0;)
 252   NOT_PRODUCT(_allow_safepoint_count = 0;)
 253   NOT_PRODUCT(_skip_gcalot = false;)
 254   _jvmti_env_iteration_count = 0;
 255   set_allocated_bytes(0);
 256   _vm_operation_started_count = 0;
 257   _vm_operation_completed_count = 0;
 258   _current_pending_monitor = NULL;


2031 void JavaThread::cleanup_failed_attach_current_thread() {
2032   if (active_handles() != NULL) {
2033     JNIHandleBlock* block = active_handles();
2034     set_active_handles(NULL);
2035     JNIHandleBlock::release_block(block);
2036   }
2037 
2038   if (free_handle_block() != NULL) {
2039     JNIHandleBlock* block = free_handle_block();
2040     set_free_handle_block(NULL);
2041     JNIHandleBlock::release_block(block);
2042   }
2043 
2044   // These have to be removed while this is still a valid thread.
2045   remove_stack_guard_pages();
2046 
2047   if (UseTLAB) {
2048     tlab().make_parsable(true);  // retire TLAB, if any
2049   }
2050 

2051   BarrierSet::barrier_set()->on_thread_detach(this);
2052 
2053   Threads::remove(this);
2054   this->smr_delete();
2055 }
2056 
2057 JavaThread* JavaThread::active() {
2058   Thread* thread = Thread::current();
2059   if (thread->is_Java_thread()) {
2060     return (JavaThread*) thread;
2061   } else {
2062     assert(thread->is_VM_thread(), "this must be a vm thread");
2063     VM_Operation* op = ((VMThread*) thread)->vm_operation();
2064     JavaThread *ret=op == NULL ? NULL : (JavaThread *)op->calling_thread();
2065     assert(ret->is_Java_thread(), "must be a Java thread");
2066     return ret;
2067   }
2068 }
2069 
2070 bool JavaThread::is_lock_owned(address adr) const {


4295   return is_supported_jni_version(version);
4296 }
4297 
4298 
4299 jboolean Threads::is_supported_jni_version(jint version) {
4300   if (version == JNI_VERSION_1_2) return JNI_TRUE;
4301   if (version == JNI_VERSION_1_4) return JNI_TRUE;
4302   if (version == JNI_VERSION_1_6) return JNI_TRUE;
4303   if (version == JNI_VERSION_1_8) return JNI_TRUE;
4304   if (version == JNI_VERSION_9) return JNI_TRUE;
4305   if (version == JNI_VERSION_10) return JNI_TRUE;
4306   return JNI_FALSE;
4307 }
4308 
4309 
4310 void Threads::add(JavaThread* p, bool force_daemon) {
4311   // The threads lock must be owned at this point
4312   assert_locked_or_safepoint(Threads_lock);
4313 
4314   BarrierSet::barrier_set()->on_thread_attach(p);
4315 
4316   p->set_next(_thread_list);
4317   _thread_list = p;
4318 
4319   // Once a JavaThread is added to the Threads list, smr_delete() has
4320   // to be used to delete it. Otherwise we can just delete it directly.
4321   p->set_on_thread_list();
4322 
4323   _number_of_threads++;
4324   oop threadObj = p->threadObj();
4325   bool daemon = true;
4326   // Bootstrapping problem: threadObj can be null for initial
4327   // JavaThread (or for threads attached via JNI)
4328   if ((!force_daemon) && (threadObj == NULL || !java_lang_Thread::is_daemon(threadObj))) {
4329     _number_of_non_daemon_threads++;
4330     daemon = false;
4331   }
4332 
4333   ThreadService::add_thread(p, daemon);
4334 
4335   // Maintain fast thread list




 219 // JavaThread
 220 
 221 
 222 Thread::Thread() {
 223   // stack and get_thread
 224   set_stack_base(NULL);
 225   set_stack_size(0);
 226   set_self_raw_id(0);
 227   set_lgrp_id(-1);
 228   DEBUG_ONLY(clear_suspendible_thread();)
 229 
 230   // allocated data structures
 231   set_osthread(NULL);
 232   set_resource_area(new (mtThread)ResourceArea());
 233   DEBUG_ONLY(_current_resource_mark = NULL;)
 234   set_handle_area(new (mtThread) HandleArea(NULL));
 235   set_metadata_handles(new (ResourceObj::C_HEAP, mtClass) GrowableArray<Metadata*>(30, true));
 236   set_active_handles(NULL);
 237   set_free_handle_block(NULL);
 238   set_last_handle_mark(NULL);
 239   _heap_sampler.set_thread(this);
 240 
 241   // This initial value ==> never claimed.
 242   _oops_do_parity = 0;
 243   _threads_hazard_ptr = NULL;
 244   _nested_threads_hazard_ptr = NULL;
 245   _nested_threads_hazard_ptr_cnt = 0;
 246 
 247   // the handle mark links itself to last_handle_mark
 248   new HandleMark(this);
 249 
 250   // plain initialization
 251   debug_only(_owned_locks = NULL;)
 252   debug_only(_allow_allocation_count = 0;)
 253   NOT_PRODUCT(_allow_safepoint_count = 0;)
 254   NOT_PRODUCT(_skip_gcalot = false;)
 255   _jvmti_env_iteration_count = 0;
 256   set_allocated_bytes(0);
 257   _vm_operation_started_count = 0;
 258   _vm_operation_completed_count = 0;
 259   _current_pending_monitor = NULL;


2032 void JavaThread::cleanup_failed_attach_current_thread() {
2033   if (active_handles() != NULL) {
2034     JNIHandleBlock* block = active_handles();
2035     set_active_handles(NULL);
2036     JNIHandleBlock::release_block(block);
2037   }
2038 
2039   if (free_handle_block() != NULL) {
2040     JNIHandleBlock* block = free_handle_block();
2041     set_free_handle_block(NULL);
2042     JNIHandleBlock::release_block(block);
2043   }
2044 
2045   // These have to be removed while this is still a valid thread.
2046   remove_stack_guard_pages();
2047 
2048   if (UseTLAB) {
2049     tlab().make_parsable(true);  // retire TLAB, if any
2050   }
2051 
2052 
2053   BarrierSet::barrier_set()->on_thread_detach(this);
2054 
2055   Threads::remove(this);
2056   this->smr_delete();
2057 }
2058 
2059 JavaThread* JavaThread::active() {
2060   Thread* thread = Thread::current();
2061   if (thread->is_Java_thread()) {
2062     return (JavaThread*) thread;
2063   } else {
2064     assert(thread->is_VM_thread(), "this must be a vm thread");
2065     VM_Operation* op = ((VMThread*) thread)->vm_operation();
2066     JavaThread *ret=op == NULL ? NULL : (JavaThread *)op->calling_thread();
2067     assert(ret->is_Java_thread(), "must be a Java thread");
2068     return ret;
2069   }
2070 }
2071 
2072 bool JavaThread::is_lock_owned(address adr) const {


4297   return is_supported_jni_version(version);
4298 }
4299 
4300 
4301 jboolean Threads::is_supported_jni_version(jint version) {
4302   if (version == JNI_VERSION_1_2) return JNI_TRUE;
4303   if (version == JNI_VERSION_1_4) return JNI_TRUE;
4304   if (version == JNI_VERSION_1_6) return JNI_TRUE;
4305   if (version == JNI_VERSION_1_8) return JNI_TRUE;
4306   if (version == JNI_VERSION_9) return JNI_TRUE;
4307   if (version == JNI_VERSION_10) return JNI_TRUE;
4308   return JNI_FALSE;
4309 }
4310 
4311 
4312 void Threads::add(JavaThread* p, bool force_daemon) {
4313   // The threads lock must be owned at this point
4314   assert_locked_or_safepoint(Threads_lock);
4315 
4316   BarrierSet::barrier_set()->on_thread_attach(p);

4317   p->set_next(_thread_list);
4318   _thread_list = p;
4319 
4320   // Once a JavaThread is added to the Threads list, smr_delete() has
4321   // to be used to delete it. Otherwise we can just delete it directly.
4322   p->set_on_thread_list();
4323 
4324   _number_of_threads++;
4325   oop threadObj = p->threadObj();
4326   bool daemon = true;
4327   // Bootstrapping problem: threadObj can be null for initial
4328   // JavaThread (or for threads attached via JNI)
4329   if ((!force_daemon) && (threadObj == NULL || !java_lang_Thread::is_daemon(threadObj))) {
4330     _number_of_non_daemon_threads++;
4331     daemon = false;
4332   }
4333 
4334   ThreadService::add_thread(p, daemon);
4335 
4336   // Maintain fast thread list


< prev index next >