< prev index next >

src/hotspot/share/runtime/javaThread.cpp

Print this page

  53 #include "oops/oop.inline.hpp"
  54 #include "oops/oopHandle.inline.hpp"
  55 #include "oops/verifyOopClosure.hpp"
  56 #include "prims/jvm_misc.hpp"
  57 #include "prims/jvmtiDeferredUpdates.hpp"
  58 #include "prims/jvmtiExport.hpp"
  59 #include "prims/jvmtiThreadState.inline.hpp"
  60 #include "runtime/atomic.hpp"
  61 #include "runtime/continuation.hpp"
  62 #include "runtime/continuationEntry.inline.hpp"
  63 #include "runtime/continuationHelper.inline.hpp"
  64 #include "runtime/deoptimization.hpp"
  65 #include "runtime/frame.inline.hpp"
  66 #include "runtime/handles.inline.hpp"
  67 #include "runtime/handshake.hpp"
  68 #include "runtime/interfaceSupport.inline.hpp"
  69 #include "runtime/java.hpp"
  70 #include "runtime/javaCalls.hpp"
  71 #include "runtime/javaThread.inline.hpp"
  72 #include "runtime/jniHandles.inline.hpp"

  73 #include "runtime/mutexLocker.hpp"
  74 #include "runtime/orderAccess.hpp"
  75 #include "runtime/osThread.hpp"
  76 #include "runtime/safepoint.hpp"
  77 #include "runtime/safepointMechanism.inline.hpp"
  78 #include "runtime/safepointVerifiers.hpp"
  79 #include "runtime/serviceThread.hpp"
  80 #include "runtime/stackFrameStream.inline.hpp"
  81 #include "runtime/stackWatermarkSet.hpp"
  82 #include "runtime/synchronizer.hpp"
  83 #include "runtime/threadCritical.hpp"
  84 #include "runtime/threadSMR.inline.hpp"
  85 #include "runtime/threadStatisticalInfo.hpp"
  86 #include "runtime/threadWXSetters.inline.hpp"
  87 #include "runtime/timer.hpp"
  88 #include "runtime/timerTrace.hpp"
  89 #include "runtime/vframe.inline.hpp"
  90 #include "runtime/vframeArray.hpp"
  91 #include "runtime/vframe_hp.hpp"
  92 #include "runtime/vmThread.hpp"

 470   _cont_entry(nullptr),
 471   _cont_fastpath(0),
 472   _cont_fastpath_thread_state(1),
 473   _held_monitor_count(0),
 474   _jni_monitor_count(0),
 475 
 476   _handshake(this),
 477 
 478   _popframe_preserved_args(nullptr),
 479   _popframe_preserved_args_size(0),
 480 
 481   _jvmti_thread_state(nullptr),
 482   _interp_only_mode(0),
 483   _should_post_on_exceptions_flag(JNI_FALSE),
 484   _thread_stat(new ThreadStatistics()),
 485 
 486   _parker(),
 487 
 488   _class_to_be_initialized(nullptr),
 489 
 490   _SleepEvent(ParkEvent::Allocate(this))
 491 {

 492   set_jni_functions(jni_functions());
 493 
 494 #if INCLUDE_JVMCI
 495   assert(_jvmci._implicit_exception_pc == nullptr, "must be");
 496   if (JVMCICounterSize > 0) {
 497     resize_counters(0, (int) JVMCICounterSize);
 498   }
 499 #endif // INCLUDE_JVMCI
 500 
 501   // Setup safepoint state info for this thread
 502   ThreadSafepointState::create(this);
 503 
 504   SafepointMechanism::initialize_header(this);
 505 
 506   set_requires_cross_modify_fence(false);
 507 
 508   pd_initialize();
 509   assert(deferred_card_mark().is_empty(), "Default MemRegion ctor");
 510 }
 511 

 968     tlab().retire();
 969   }
 970 
 971   Threads::remove(this, is_daemon);
 972   this->smr_delete();
 973 }
 974 
 975 JavaThread* JavaThread::active() {
 976   Thread* thread = Thread::current();
 977   if (thread->is_Java_thread()) {
 978     return JavaThread::cast(thread);
 979   } else {
 980     assert(thread->is_VM_thread(), "this must be a vm thread");
 981     VM_Operation* op = ((VMThread*) thread)->vm_operation();
 982     JavaThread *ret = op == nullptr ? nullptr : JavaThread::cast(op->calling_thread());
 983     return ret;
 984   }
 985 }
 986 
 987 bool JavaThread::is_lock_owned(address adr) const {

 988   if (Thread::is_lock_owned(adr)) return true;
 989 
 990   for (MonitorChunk* chunk = monitor_chunks(); chunk != nullptr; chunk = chunk->next()) {
 991     if (chunk->contains(adr)) return true;
 992   }
 993 
 994   return false;
 995 }
 996 
 997 oop JavaThread::exception_oop() const {
 998   return Atomic::load(&_exception_oop);
 999 }
1000 
1001 void JavaThread::set_exception_oop(oop o) {
1002   Atomic::store(&_exception_oop, o);
1003 }
1004 
1005 void JavaThread::add_monitor_chunk(MonitorChunk* chunk) {
1006   chunk->set_next(monitor_chunks());
1007   set_monitor_chunks(chunk);

1361   f->do_oop((oop*) &_vm_result);
1362   f->do_oop((oop*) &_exception_oop);
1363 #if INCLUDE_JVMCI
1364   f->do_oop((oop*) &_jvmci_reserved_oop0);
1365 #endif
1366 
1367   if (jvmti_thread_state() != nullptr) {
1368     jvmti_thread_state()->oops_do(f, cf);
1369   }
1370 
1371   // The continuation oops are really on the stack. But there is typically at most
1372   // one of those per thread, so we handle them here in the oops_do_no_frames part
1373   // so that we don't have to sprinkle as many stack watermark checks where these
1374   // oops are used. We just need to make sure the thread has started processing.
1375   ContinuationEntry* entry = _cont_entry;
1376   while (entry != nullptr) {
1377     f->do_oop((oop*)entry->cont_addr());
1378     f->do_oop((oop*)entry->chunk_addr());
1379     entry = entry->parent();
1380   }




1381 }
1382 
1383 void JavaThread::oops_do_frames(OopClosure* f, CodeBlobClosure* cf) {
1384   if (!has_last_Java_frame()) {
1385     return;
1386   }
1387   // Finish any pending lazy GC activity for the frames
1388   StackWatermarkSet::finish_processing(this, nullptr /* context */, StackWatermarkKind::gc);
1389   // Traverse the execution stack
1390   for (StackFrameStream fst(this, true /* update */, false /* process_frames */); !fst.is_done(); fst.next()) {
1391     fst.current()->oops_do(f, cf, fst.register_map());
1392   }
1393 }
1394 
1395 #ifdef ASSERT
1396 void JavaThread::verify_states_for_handshake() {
1397   // This checks that the thread has a correct frame state during a handshake.
1398   verify_frame_info();
1399 }
1400 #endif

  53 #include "oops/oop.inline.hpp"
  54 #include "oops/oopHandle.inline.hpp"
  55 #include "oops/verifyOopClosure.hpp"
  56 #include "prims/jvm_misc.hpp"
  57 #include "prims/jvmtiDeferredUpdates.hpp"
  58 #include "prims/jvmtiExport.hpp"
  59 #include "prims/jvmtiThreadState.inline.hpp"
  60 #include "runtime/atomic.hpp"
  61 #include "runtime/continuation.hpp"
  62 #include "runtime/continuationEntry.inline.hpp"
  63 #include "runtime/continuationHelper.inline.hpp"
  64 #include "runtime/deoptimization.hpp"
  65 #include "runtime/frame.inline.hpp"
  66 #include "runtime/handles.inline.hpp"
  67 #include "runtime/handshake.hpp"
  68 #include "runtime/interfaceSupport.inline.hpp"
  69 #include "runtime/java.hpp"
  70 #include "runtime/javaCalls.hpp"
  71 #include "runtime/javaThread.inline.hpp"
  72 #include "runtime/jniHandles.inline.hpp"
  73 #include "runtime/lockStack.inline.hpp"
  74 #include "runtime/mutexLocker.hpp"
  75 #include "runtime/orderAccess.hpp"
  76 #include "runtime/osThread.hpp"
  77 #include "runtime/safepoint.hpp"
  78 #include "runtime/safepointMechanism.inline.hpp"
  79 #include "runtime/safepointVerifiers.hpp"
  80 #include "runtime/serviceThread.hpp"
  81 #include "runtime/stackFrameStream.inline.hpp"
  82 #include "runtime/stackWatermarkSet.hpp"
  83 #include "runtime/synchronizer.hpp"
  84 #include "runtime/threadCritical.hpp"
  85 #include "runtime/threadSMR.inline.hpp"
  86 #include "runtime/threadStatisticalInfo.hpp"
  87 #include "runtime/threadWXSetters.inline.hpp"
  88 #include "runtime/timer.hpp"
  89 #include "runtime/timerTrace.hpp"
  90 #include "runtime/vframe.inline.hpp"
  91 #include "runtime/vframeArray.hpp"
  92 #include "runtime/vframe_hp.hpp"
  93 #include "runtime/vmThread.hpp"

 471   _cont_entry(nullptr),
 472   _cont_fastpath(0),
 473   _cont_fastpath_thread_state(1),
 474   _held_monitor_count(0),
 475   _jni_monitor_count(0),
 476 
 477   _handshake(this),
 478 
 479   _popframe_preserved_args(nullptr),
 480   _popframe_preserved_args_size(0),
 481 
 482   _jvmti_thread_state(nullptr),
 483   _interp_only_mode(0),
 484   _should_post_on_exceptions_flag(JNI_FALSE),
 485   _thread_stat(new ThreadStatistics()),
 486 
 487   _parker(),
 488 
 489   _class_to_be_initialized(nullptr),
 490 
 491   _SleepEvent(ParkEvent::Allocate(this)),
 492 
 493   _lock_stack() {
 494   set_jni_functions(jni_functions());
 495 
 496 #if INCLUDE_JVMCI
 497   assert(_jvmci._implicit_exception_pc == nullptr, "must be");
 498   if (JVMCICounterSize > 0) {
 499     resize_counters(0, (int) JVMCICounterSize);
 500   }
 501 #endif // INCLUDE_JVMCI
 502 
 503   // Setup safepoint state info for this thread
 504   ThreadSafepointState::create(this);
 505 
 506   SafepointMechanism::initialize_header(this);
 507 
 508   set_requires_cross_modify_fence(false);
 509 
 510   pd_initialize();
 511   assert(deferred_card_mark().is_empty(), "Default MemRegion ctor");
 512 }
 513 

 970     tlab().retire();
 971   }
 972 
 973   Threads::remove(this, is_daemon);
 974   this->smr_delete();
 975 }
 976 
 977 JavaThread* JavaThread::active() {
 978   Thread* thread = Thread::current();
 979   if (thread->is_Java_thread()) {
 980     return JavaThread::cast(thread);
 981   } else {
 982     assert(thread->is_VM_thread(), "this must be a vm thread");
 983     VM_Operation* op = ((VMThread*) thread)->vm_operation();
 984     JavaThread *ret = op == nullptr ? nullptr : JavaThread::cast(op->calling_thread());
 985     return ret;
 986   }
 987 }
 988 
 989 bool JavaThread::is_lock_owned(address adr) const {
 990   assert(!UseFastLocking, "should not be called with fast-locking");
 991   if (Thread::is_lock_owned(adr)) return true;
 992 
 993   for (MonitorChunk* chunk = monitor_chunks(); chunk != nullptr; chunk = chunk->next()) {
 994     if (chunk->contains(adr)) return true;
 995   }
 996 
 997   return false;
 998 }
 999 
1000 oop JavaThread::exception_oop() const {
1001   return Atomic::load(&_exception_oop);
1002 }
1003 
1004 void JavaThread::set_exception_oop(oop o) {
1005   Atomic::store(&_exception_oop, o);
1006 }
1007 
1008 void JavaThread::add_monitor_chunk(MonitorChunk* chunk) {
1009   chunk->set_next(monitor_chunks());
1010   set_monitor_chunks(chunk);

1364   f->do_oop((oop*) &_vm_result);
1365   f->do_oop((oop*) &_exception_oop);
1366 #if INCLUDE_JVMCI
1367   f->do_oop((oop*) &_jvmci_reserved_oop0);
1368 #endif
1369 
1370   if (jvmti_thread_state() != nullptr) {
1371     jvmti_thread_state()->oops_do(f, cf);
1372   }
1373 
1374   // The continuation oops are really on the stack. But there is typically at most
1375   // one of those per thread, so we handle them here in the oops_do_no_frames part
1376   // so that we don't have to sprinkle as many stack watermark checks where these
1377   // oops are used. We just need to make sure the thread has started processing.
1378   ContinuationEntry* entry = _cont_entry;
1379   while (entry != nullptr) {
1380     f->do_oop((oop*)entry->cont_addr());
1381     f->do_oop((oop*)entry->chunk_addr());
1382     entry = entry->parent();
1383   }
1384 
1385   if (!UseHeavyMonitors && UseFastLocking) {
1386     lock_stack().oops_do(f);
1387   }
1388 }
1389 
1390 void JavaThread::oops_do_frames(OopClosure* f, CodeBlobClosure* cf) {
1391   if (!has_last_Java_frame()) {
1392     return;
1393   }
1394   // Finish any pending lazy GC activity for the frames
1395   StackWatermarkSet::finish_processing(this, nullptr /* context */, StackWatermarkKind::gc);
1396   // Traverse the execution stack
1397   for (StackFrameStream fst(this, true /* update */, false /* process_frames */); !fst.is_done(); fst.next()) {
1398     fst.current()->oops_do(f, cf, fst.register_map());
1399   }
1400 }
1401 
1402 #ifdef ASSERT
1403 void JavaThread::verify_states_for_handshake() {
1404   // This checks that the thread has a correct frame state during a handshake.
1405   verify_frame_info();
1406 }
1407 #endif
< prev index next >