497 Handle* _obj; |
497 Handle* _obj; |
498 GrowableArray<Handle>* _objs; |
498 GrowableArray<Handle>* _objs; |
499 JavaThread* _requesting_thread; |
499 JavaThread* _requesting_thread; |
500 BiasedLocking::Condition _status_code; |
500 BiasedLocking::Condition _status_code; |
501 traceid _biased_locker_id; |
501 traceid _biased_locker_id; |
|
502 uint64_t _safepoint_id; |
502 |
503 |
503 public: |
504 public: |
504 VM_RevokeBias(Handle* obj, JavaThread* requesting_thread) |
505 VM_RevokeBias(Handle* obj, JavaThread* requesting_thread) |
505 : _obj(obj) |
506 : _obj(obj) |
506 , _objs(NULL) |
507 , _objs(NULL) |
507 , _requesting_thread(requesting_thread) |
508 , _requesting_thread(requesting_thread) |
508 , _status_code(BiasedLocking::NOT_BIASED) |
509 , _status_code(BiasedLocking::NOT_BIASED) |
509 , _biased_locker_id(0) {} |
510 , _biased_locker_id(0) |
|
511 , _safepoint_id(0) {} |
510 |
512 |
511 VM_RevokeBias(GrowableArray<Handle>* objs, JavaThread* requesting_thread) |
513 VM_RevokeBias(GrowableArray<Handle>* objs, JavaThread* requesting_thread) |
512 : _obj(NULL) |
514 : _obj(NULL) |
513 , _objs(objs) |
515 , _objs(objs) |
514 , _requesting_thread(requesting_thread) |
516 , _requesting_thread(requesting_thread) |
515 , _status_code(BiasedLocking::NOT_BIASED) |
517 , _status_code(BiasedLocking::NOT_BIASED) |
516 , _biased_locker_id(0) {} |
518 , _biased_locker_id(0) |
|
519 , _safepoint_id(0) {} |
517 |
520 |
518 virtual VMOp_Type type() const { return VMOp_RevokeBias; } |
521 virtual VMOp_Type type() const { return VMOp_RevokeBias; } |
519 |
522 |
520 virtual bool doit_prologue() { |
523 virtual bool doit_prologue() { |
521 // Verify that there is actual work to do since the callers just |
524 // Verify that there is actual work to do since the callers just |
543 JavaThread* biased_locker = NULL; |
546 JavaThread* biased_locker = NULL; |
544 _status_code = revoke_bias((*_obj)(), false, false, _requesting_thread, &biased_locker); |
547 _status_code = revoke_bias((*_obj)(), false, false, _requesting_thread, &biased_locker); |
545 if (biased_locker != NULL) { |
548 if (biased_locker != NULL) { |
546 _biased_locker_id = JFR_THREAD_ID(biased_locker); |
549 _biased_locker_id = JFR_THREAD_ID(biased_locker); |
547 } |
550 } |
|
551 _safepoint_id = SafepointSynchronize::safepoint_counter(); |
548 clean_up_cached_monitor_info(); |
552 clean_up_cached_monitor_info(); |
549 return; |
553 return; |
550 } else { |
554 } else { |
551 log_info(biasedlocking)("Revoking bias with global safepoint:"); |
555 log_info(biasedlocking)("Revoking bias with global safepoint:"); |
552 BiasedLocking::revoke_at_safepoint(_objs); |
556 BiasedLocking::revoke_at_safepoint(_objs); |
579 virtual VMOp_Type type() const { return VMOp_BulkRevokeBias; } |
587 virtual VMOp_Type type() const { return VMOp_BulkRevokeBias; } |
580 virtual bool doit_prologue() { return true; } |
588 virtual bool doit_prologue() { return true; } |
581 |
589 |
582 virtual void doit() { |
590 virtual void doit() { |
583 _status_code = bulk_revoke_or_rebias_at_safepoint((*_obj)(), _bulk_rebias, _attempt_rebias_of_object, _requesting_thread); |
591 _status_code = bulk_revoke_or_rebias_at_safepoint((*_obj)(), _bulk_rebias, _attempt_rebias_of_object, _requesting_thread); |
|
592 _safepoint_id = SafepointSynchronize::safepoint_counter(); |
584 clean_up_cached_monitor_info(); |
593 clean_up_cached_monitor_info(); |
585 } |
594 } |
|
595 |
|
596 bool is_bulk_rebias() const { |
|
597 return _bulk_rebias; |
|
598 } |
586 }; |
599 }; |
587 |
|
588 template <typename E> |
|
589 static void set_safepoint_id(E* event) { |
|
590 assert(event != NULL, "invariant"); |
|
591 // Subtract 1 to match the id of events committed inside the safepoint |
|
592 event->set_safepointId(SafepointSynchronize::safepoint_counter() - 1); |
|
593 } |
|
594 |
600 |
595 static void post_self_revocation_event(EventBiasedLockSelfRevocation* event, Klass* k) { |
601 static void post_self_revocation_event(EventBiasedLockSelfRevocation* event, Klass* k) { |
596 assert(event != NULL, "invariant"); |
602 assert(event != NULL, "invariant"); |
597 assert(k != NULL, "invariant"); |
603 assert(k != NULL, "invariant"); |
598 assert(event->should_commit(), "invariant"); |
604 assert(event->should_commit(), "invariant"); |
599 event->set_lockClass(k); |
605 event->set_lockClass(k); |
600 event->commit(); |
606 event->commit(); |
601 } |
607 } |
602 |
608 |
603 static void post_revocation_event(EventBiasedLockRevocation* event, Klass* k, VM_RevokeBias* revoke) { |
609 static void post_revocation_event(EventBiasedLockRevocation* event, Klass* k, VM_RevokeBias* op) { |
604 assert(event != NULL, "invariant"); |
610 assert(event != NULL, "invariant"); |
605 assert(k != NULL, "invariant"); |
611 assert(k != NULL, "invariant"); |
606 assert(revoke != NULL, "invariant"); |
612 assert(op != NULL, "invariant"); |
607 assert(event->should_commit(), "invariant"); |
613 assert(event->should_commit(), "invariant"); |
608 event->set_lockClass(k); |
614 event->set_lockClass(k); |
609 set_safepoint_id(event); |
615 event->set_safepointId(op->safepoint_id()); |
610 event->set_previousOwner(revoke->biased_locker()); |
616 event->set_previousOwner(op->biased_locker()); |
611 event->commit(); |
617 event->commit(); |
612 } |
618 } |
613 |
619 |
614 static void post_class_revocation_event(EventBiasedLockClassRevocation* event, Klass* k, bool disabled_bias) { |
620 static void post_class_revocation_event(EventBiasedLockClassRevocation* event, Klass* k, VM_BulkRevokeBias* op) { |
615 assert(event != NULL, "invariant"); |
621 assert(event != NULL, "invariant"); |
616 assert(k != NULL, "invariant"); |
622 assert(k != NULL, "invariant"); |
|
623 assert(op != NULL, "invariant"); |
617 assert(event->should_commit(), "invariant"); |
624 assert(event->should_commit(), "invariant"); |
618 event->set_revokedClass(k); |
625 event->set_revokedClass(k); |
619 event->set_disableBiasing(disabled_bias); |
626 event->set_disableBiasing(!op->is_bulk_rebias()); |
620 set_safepoint_id(event); |
627 event->set_safepointId(op->safepoint_id()); |
621 event->commit(); |
628 event->commit(); |
622 } |
629 } |
623 |
630 |
624 BiasedLocking::Condition BiasedLocking::revoke_and_rebias(Handle obj, bool attempt_rebias, TRAPS) { |
631 BiasedLocking::Condition BiasedLocking::revoke_and_rebias(Handle obj, bool attempt_rebias, TRAPS) { |
625 assert(!SafepointSynchronize::is_at_safepoint(), "must not be called while at safepoint"); |
632 assert(!SafepointSynchronize::is_at_safepoint(), "must not be called while at safepoint"); |