< prev index next >

src/hotspot/share/runtime/javaThread.hpp

Print this page

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



 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 private:





 511 





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

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

















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

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

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