< prev index next >

src/hotspot/share/runtime/javaThread.hpp

Print this page

 476   intptr_t* _cont_fastpath; // the sp of the oldest known interpreted/call_stub/upcall_stub/native_wrapper
 477                             // frame inside the continuation that we know about
 478   int _cont_fastpath_thread_state; // whether global thread state allows continuation fastpath (JVMTI)
 479 
 480   // It's signed for error detection.
 481   intx _held_monitor_count;  // used by continuations for fast lock detection
 482   intx _jni_monitor_count;
 483   ObjectMonitor* _unlocked_inflated_monitor;
 484 
 485   // This is the field we poke in the interpreter and native
 486   // wrapper (Object.wait) to check for preemption.
 487   address _preempt_alternate_return;
 488   // When preempting on monitorenter we could have acquired the
 489   // monitor after freezing all vthread frames. In that case we
 490   // set this field so that in the preempt stub we call thaw again
 491   // instead of unmounting.
 492   bool _preemption_cancelled;
 493   // For Object.wait() we set this field to know if we need to
 494   // throw IE at the end of thawing before returning to Java.
 495   bool _pending_interrupted_exception;



 496 
 497  public:
 498   bool preemption_cancelled()           { return _preemption_cancelled; }
 499   void set_preemption_cancelled(bool b) { _preemption_cancelled = b; }
 500 
 501   bool pending_interrupted_exception()           { return _pending_interrupted_exception; }
 502   void set_pending_interrupted_exception(bool b) { _pending_interrupted_exception = b; }
 503 
 504   bool preempting()           { return _preempt_alternate_return != nullptr; }
 505   void set_preempt_alternate_return(address val) { _preempt_alternate_return = val; }
 506 
 507 private:





 508 





 509   friend class VMThread;
 510   friend class ThreadWaitTransition;
 511   friend class VM_Exit;
 512 
 513   // Stack watermark barriers.
 514   StackWatermarks _stack_watermarks;
 515 
 516  public:
 517   inline StackWatermarks* stack_watermarks() { return &_stack_watermarks; }
 518 
 519  public:
 520   // Constructor
 521   JavaThread(MemTag mem_tag = mtThread);   // delegating constructor
 522   JavaThread(ThreadFunction entry_point, size_t stack_size = 0, MemTag mem_tag = mtThread);
 523   ~JavaThread();
 524 
 525   // Factory method to create a new JavaThread whose attach state is "is attaching"
 526   static JavaThread* create_attaching_thread();
 527 
 528 #ifdef ASSERT

1331   public:
1332     UnlockFlagSaver(JavaThread* t) {
1333       _thread = t;
1334       _do_not_unlock = t->do_not_unlock_if_synchronized();
1335       t->set_do_not_unlock_if_synchronized(false);
1336     }
1337     ~UnlockFlagSaver() {
1338       _thread->set_do_not_unlock_if_synchronized(_do_not_unlock);
1339     }
1340 };
1341 
1342 class JNIHandleMark : public StackObj {
1343   JavaThread* _thread;
1344  public:
1345   JNIHandleMark(JavaThread* thread) : _thread(thread) {
1346     thread->push_jni_handle_block();
1347   }
1348   ~JNIHandleMark() { _thread->pop_jni_handle_block(); }
1349 };
1350 

















1351 class NoPreemptMark {
1352   ContinuationEntry* _ce;
1353   bool _unpin;
1354  public:
1355   NoPreemptMark(JavaThread* thread) : _ce(thread->last_continuation()), _unpin(false) {
1356     if (_ce != nullptr) _unpin = _ce->pin();
1357   }
1358   ~NoPreemptMark() { if (_unpin) _ce->unpin(); }
1359 };
1360 
1361 class ThreadOnMonitorWaitedEvent {
1362   JavaThread* _thread;
1363  public:
1364   ThreadOnMonitorWaitedEvent(JavaThread* thread) : _thread(thread) {
1365     JVMTI_ONLY(_thread->set_on_monitor_waited_event(true);)
1366   }
1367   ~ThreadOnMonitorWaitedEvent() { JVMTI_ONLY(_thread->set_on_monitor_waited_event(false);) }
1368 };
1369 
1370 class ThreadInClassInitializer : public StackObj {
1371   JavaThread* _thread;
1372   InstanceKlass* _previous;
1373  public:
1374   ThreadInClassInitializer(JavaThread* thread, InstanceKlass* ik) : _thread(thread) {
1375     _previous = _thread->class_being_initialized();
1376     _thread->set_class_being_initialized(ik);

 476   intptr_t* _cont_fastpath; // the sp of the oldest known interpreted/call_stub/upcall_stub/native_wrapper
 477                             // frame inside the continuation that we know about
 478   int _cont_fastpath_thread_state; // whether global thread state allows continuation fastpath (JVMTI)
 479 
 480   // It's signed for error detection.
 481   intx _held_monitor_count;  // used by continuations for fast lock detection
 482   intx _jni_monitor_count;
 483   ObjectMonitor* _unlocked_inflated_monitor;
 484 
 485   // This is the field we poke in the interpreter and native
 486   // wrapper (Object.wait) to check for preemption.
 487   address _preempt_alternate_return;
 488   // When preempting on monitorenter we could have acquired the
 489   // monitor after freezing all vthread frames. In that case we
 490   // set this field so that in the preempt stub we call thaw again
 491   // instead of unmounting.
 492   bool _preemption_cancelled;
 493   // For Object.wait() we set this field to know if we need to
 494   // throw IE at the end of thawing before returning to Java.
 495   bool _pending_interrupted_exception;
 496   // We allow preemption on some klass initializion calls.
 497   // We use this boolean to mark such calls.
 498   bool _at_preemptable_init;
 499 
 500  public:
 501   bool preemption_cancelled()           { return _preemption_cancelled; }
 502   void set_preemption_cancelled(bool b) { _preemption_cancelled = b; }
 503 
 504   bool pending_interrupted_exception()           { return _pending_interrupted_exception; }
 505   void set_pending_interrupted_exception(bool b) { _pending_interrupted_exception = b; }
 506 
 507   bool preempting()                              { return _preempt_alternate_return != nullptr; }
 508   void set_preempt_alternate_return(address val) { _preempt_alternate_return = val; }
 509 
 510   bool at_preemptable_init() { return _at_preemptable_init; }
 511   void set_at_preemptable_init(bool b) { _at_preemptable_init = b; }
 512 
 513 #ifdef ASSERT
 514   // Used for extra logging with -Xlog:continuation+preempt
 515   InstanceKlass* _preempt_init_klass;
 516 
 517   InstanceKlass* preempt_init_klass() { return _preempt_init_klass; }
 518   void set_preempt_init_klass(InstanceKlass* ik) { _preempt_init_klass = ik; }
 519 #endif
 520 
 521 private:
 522   friend class VMThread;
 523   friend class ThreadWaitTransition;
 524   friend class VM_Exit;
 525 
 526   // Stack watermark barriers.
 527   StackWatermarks _stack_watermarks;
 528 
 529  public:
 530   inline StackWatermarks* stack_watermarks() { return &_stack_watermarks; }
 531 
 532  public:
 533   // Constructor
 534   JavaThread(MemTag mem_tag = mtThread);   // delegating constructor
 535   JavaThread(ThreadFunction entry_point, size_t stack_size = 0, MemTag mem_tag = mtThread);
 536   ~JavaThread();
 537 
 538   // Factory method to create a new JavaThread whose attach state is "is attaching"
 539   static JavaThread* create_attaching_thread();
 540 
 541 #ifdef ASSERT

1344   public:
1345     UnlockFlagSaver(JavaThread* t) {
1346       _thread = t;
1347       _do_not_unlock = t->do_not_unlock_if_synchronized();
1348       t->set_do_not_unlock_if_synchronized(false);
1349     }
1350     ~UnlockFlagSaver() {
1351       _thread->set_do_not_unlock_if_synchronized(_do_not_unlock);
1352     }
1353 };
1354 
1355 class JNIHandleMark : public StackObj {
1356   JavaThread* _thread;
1357  public:
1358   JNIHandleMark(JavaThread* thread) : _thread(thread) {
1359     thread->push_jni_handle_block();
1360   }
1361   ~JNIHandleMark() { _thread->pop_jni_handle_block(); }
1362 };
1363 
1364 class PreemptableInitCall {
1365   JavaThread* _thread;
1366   bool _previous;
1367   DEBUG_ONLY(InstanceKlass* _previous_klass;)
1368  public:
1369   PreemptableInitCall(JavaThread* thread, InstanceKlass* ik) : _thread(thread) {
1370     _previous = thread->at_preemptable_init();
1371     _thread->set_at_preemptable_init(true);
1372     DEBUG_ONLY(_previous_klass = _thread->preempt_init_klass();)
1373     DEBUG_ONLY(_thread->set_preempt_init_klass(ik));
1374   }
1375   ~PreemptableInitCall() {
1376     _thread->set_at_preemptable_init(_previous);
1377     DEBUG_ONLY(_thread->set_preempt_init_klass(_previous_klass));
1378   }
1379 };
1380 
1381 class NoPreemptMark {
1382   ContinuationEntry* _ce;
1383   bool _unpin;
1384  public:
1385   NoPreemptMark(JavaThread* thread, bool ignore_mark = false) : _ce(thread->last_continuation()), _unpin(false) {
1386     if (_ce != nullptr && !ignore_mark) _unpin = _ce->pin();
1387   }
1388   ~NoPreemptMark() { if (_unpin) _ce->unpin(); }
1389 };
1390 
1391 class ThreadOnMonitorWaitedEvent {
1392   JavaThread* _thread;
1393  public:
1394   ThreadOnMonitorWaitedEvent(JavaThread* thread) : _thread(thread) {
1395     JVMTI_ONLY(_thread->set_on_monitor_waited_event(true);)
1396   }
1397   ~ThreadOnMonitorWaitedEvent() { JVMTI_ONLY(_thread->set_on_monitor_waited_event(false);) }
1398 };
1399 
1400 class ThreadInClassInitializer : public StackObj {
1401   JavaThread* _thread;
1402   InstanceKlass* _previous;
1403  public:
1404   ThreadInClassInitializer(JavaThread* thread, InstanceKlass* ik) : _thread(thread) {
1405     _previous = _thread->class_being_initialized();
1406     _thread->set_class_being_initialized(ik);
< prev index next >