< 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

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

















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











1380 #endif // SHARE_RUNTIME_JAVATHREAD_HPP

 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

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