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 : _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 const char* name() { return "RevokeOneBias"; }
524
525 void do_thread(JavaThread* target) {
526 assert(target == _biased_locker, "Wrong thread");
527
528 oop o = _obj();
529 markWord mark = o->mark();
530
531 if (!mark.has_bias_pattern()) {
532 return;
533 }
534
535 markWord prototype = o->klass()->prototype_header();
536 if (!prototype.has_bias_pattern()) {
537 // This object has a stale bias from before the handshake
538 // was requested. If we fail this race, the object's bias
539 // has been revoked by another thread so we simply return.
540 markWord biased_value = mark;
541 mark = o->cas_set_mark(markWord::prototype().set_age(mark.age()), mark);
542 assert(!o->mark().has_bias_pattern(), "even if we raced, should still be revoked");
543 if (biased_value == mark) {
544 _status_code = BiasedLocking::BIAS_REVOKED;
545 }
|