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