487 , _safepoint_id(0) {}
488
489 virtual VMOp_Type type() const { return VMOp_BulkRevokeBias; }
490
491 virtual void doit() {
492 BiasedLocking::bulk_revoke_at_safepoint((*_obj)(), _bulk_rebias, _requesting_thread);
493 _safepoint_id = SafepointSynchronize::safepoint_id();
494 clean_up_cached_monitor_info();
495 }
496
497 bool is_bulk_rebias() const {
498 return _bulk_rebias;
499 }
500
501 uint64_t safepoint_id() const {
502 return _safepoint_id;
503 }
504 };
505
506
507 class RevokeOneBias : public ThreadClosure {
508 protected:
509 Handle _obj;
510 JavaThread* _requesting_thread;
511 JavaThread* _biased_locker;
512 BiasedLocking::Condition _status_code;
513 traceid _biased_locker_id;
514
515 public:
516 RevokeOneBias(Handle obj, JavaThread* requesting_thread, JavaThread* biased_locker)
517 : _obj(obj)
518 , _requesting_thread(requesting_thread)
519 , _biased_locker(biased_locker)
520 , _status_code(BiasedLocking::NOT_BIASED)
521 , _biased_locker_id(0) {}
522
523 void do_thread(Thread* target) {
524 assert(target == _biased_locker, "Wrong thread");
525
526 oop o = _obj();
527 markWord mark = o->mark();
528
529 if (!mark.has_bias_pattern()) {
530 return;
531 }
532
533 markWord prototype = o->klass()->prototype_header();
534 if (!prototype.has_bias_pattern()) {
535 // This object has a stale bias from before the handshake
536 // was requested. If we fail this race, the object's bias
537 // has been revoked by another thread so we simply return.
538 markWord biased_value = mark;
539 mark = o->cas_set_mark(markWord::prototype().set_age(mark.age()), mark);
540 assert(!o->mark().has_bias_pattern(), "even if we raced, should still be revoked");
541 if (biased_value == mark) {
542 _status_code = BiasedLocking::BIAS_REVOKED;
543 }
|
487 , _safepoint_id(0) {}
488
489 virtual VMOp_Type type() const { return VMOp_BulkRevokeBias; }
490
491 virtual void doit() {
492 BiasedLocking::bulk_revoke_at_safepoint((*_obj)(), _bulk_rebias, _requesting_thread);
493 _safepoint_id = SafepointSynchronize::safepoint_id();
494 clean_up_cached_monitor_info();
495 }
496
497 bool is_bulk_rebias() const {
498 return _bulk_rebias;
499 }
500
501 uint64_t safepoint_id() const {
502 return _safepoint_id;
503 }
504 };
505
506
507 class RevokeOneBias : public HandshakeOperation {
508 protected:
509 Handle _obj;
510 JavaThread* _requesting_thread;
511 JavaThread* _biased_locker;
512 BiasedLocking::Condition _status_code;
513 traceid _biased_locker_id;
514
515 public:
516 RevokeOneBias(Handle obj, JavaThread* requesting_thread, JavaThread* biased_locker)
517 : HandshakeOperation("RevokeOneBias")
518 , _obj(obj)
519 , _requesting_thread(requesting_thread)
520 , _biased_locker(biased_locker)
521 , _status_code(BiasedLocking::NOT_BIASED)
522 , _biased_locker_id(0) {}
523
524 void do_thread(JavaThread* target) {
525 assert(target == _biased_locker, "Wrong thread");
526
527 oop o = _obj();
528 markWord mark = o->mark();
529
530 if (!mark.has_bias_pattern()) {
531 return;
532 }
533
534 markWord prototype = o->klass()->prototype_header();
535 if (!prototype.has_bias_pattern()) {
536 // This object has a stale bias from before the handshake
537 // was requested. If we fail this race, the object's bias
538 // has been revoked by another thread so we simply return.
539 markWord biased_value = mark;
540 mark = o->cas_set_mark(markWord::prototype().set_age(mark.age()), mark);
541 assert(!o->mark().has_bias_pattern(), "even if we raced, should still be revoked");
542 if (biased_value == mark) {
543 _status_code = BiasedLocking::BIAS_REVOKED;
544 }
|