< prev index next >

src/hotspot/share/runtime/thread.cpp

Print this page
rev 49643 : [mq]: heap8


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

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


4318   return is_supported_jni_version(version);
4319 }
4320 
4321 
4322 jboolean Threads::is_supported_jni_version(jint version) {
4323   if (version == JNI_VERSION_1_2) return JNI_TRUE;
4324   if (version == JNI_VERSION_1_4) return JNI_TRUE;
4325   if (version == JNI_VERSION_1_6) return JNI_TRUE;
4326   if (version == JNI_VERSION_1_8) return JNI_TRUE;
4327   if (version == JNI_VERSION_9) return JNI_TRUE;
4328   if (version == JNI_VERSION_10) return JNI_TRUE;
4329   return JNI_FALSE;
4330 }
4331 
4332 
4333 void Threads::add(JavaThread* p, bool force_daemon) {
4334   // The threads lock must be owned at this point
4335   assert_locked_or_safepoint(Threads_lock);
4336 
4337   BarrierSet::barrier_set()->on_thread_attach(p);
4338 
4339   p->set_next(_thread_list);
4340   _thread_list = p;
4341 
4342   // Once a JavaThread is added to the Threads list, smr_delete() has
4343   // to be used to delete it. Otherwise we can just delete it directly.
4344   p->set_on_thread_list();
4345 
4346   _number_of_threads++;
4347   oop threadObj = p->threadObj();
4348   bool daemon = true;
4349   // Bootstrapping problem: threadObj can be null for initial
4350   // JavaThread (or for threads attached via JNI)
4351   if ((!force_daemon) && (threadObj == NULL || !java_lang_Thread::is_daemon(threadObj))) {
4352     _number_of_non_daemon_threads++;
4353     daemon = false;
4354   }
4355 
4356   ThreadService::add_thread(p, daemon);
4357 
4358   // Maintain fast thread list




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


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


4320   return is_supported_jni_version(version);
4321 }
4322 
4323 
4324 jboolean Threads::is_supported_jni_version(jint version) {
4325   if (version == JNI_VERSION_1_2) return JNI_TRUE;
4326   if (version == JNI_VERSION_1_4) return JNI_TRUE;
4327   if (version == JNI_VERSION_1_6) return JNI_TRUE;
4328   if (version == JNI_VERSION_1_8) return JNI_TRUE;
4329   if (version == JNI_VERSION_9) return JNI_TRUE;
4330   if (version == JNI_VERSION_10) return JNI_TRUE;
4331   return JNI_FALSE;
4332 }
4333 
4334 
4335 void Threads::add(JavaThread* p, bool force_daemon) {
4336   // The threads lock must be owned at this point
4337   assert_locked_or_safepoint(Threads_lock);
4338 
4339   BarrierSet::barrier_set()->on_thread_attach(p);

4340   p->set_next(_thread_list);
4341   _thread_list = p;
4342 
4343   // Once a JavaThread is added to the Threads list, smr_delete() has
4344   // to be used to delete it. Otherwise we can just delete it directly.
4345   p->set_on_thread_list();
4346 
4347   _number_of_threads++;
4348   oop threadObj = p->threadObj();
4349   bool daemon = true;
4350   // Bootstrapping problem: threadObj can be null for initial
4351   // JavaThread (or for threads attached via JNI)
4352   if ((!force_daemon) && (threadObj == NULL || !java_lang_Thread::is_daemon(threadObj))) {
4353     _number_of_non_daemon_threads++;
4354     daemon = false;
4355   }
4356 
4357   ThreadService::add_thread(p, daemon);
4358 
4359   // Maintain fast thread list


< prev index next >