583 p2i(_EntryList));
584
585 if (obj != NULL) {
586 if (log_is_enabled(Trace, monitorinflation)) {
587 ResourceMark rm;
588 log_trace(monitorinflation)("deflate_monitor: object=" INTPTR_FORMAT
589 ", mark=" INTPTR_FORMAT ", type='%s'",
590 p2i(obj), obj->mark().value(),
591 obj->klass()->external_name());
592 }
593
594 // Install the old mark word if nobody else has already done it.
595 install_displaced_markword_in_object(obj);
596 }
597
598 // We leave owner == DEFLATER_MARKER and contentions < 0
599 // to force any racing threads to retry.
600 return true; // Success, ObjectMonitor has been deflated.
601 }
602
603 // Install the displaced mark word (dmw) of a deflating ObjectMonitor
604 // into the header of the object associated with the monitor. This
605 // idempotent method is called by a thread that is deflating a
606 // monitor and by other threads that have detected a race with the
607 // deflation process.
608 void ObjectMonitor::install_displaced_markword_in_object(const oop obj) {
609 // This function must only be called when (owner == DEFLATER_MARKER
610 // && contentions <= 0), but we can't guarantee that here because
611 // those values could change when the ObjectMonitor gets moved from
612 // the global free list to a per-thread free list.
613
614 guarantee(obj != NULL, "must be non-NULL");
615
616 // Separate loads in is_being_async_deflated(), which is almost always
617 // called before this function, from the load of dmw/header below.
618
619 // _contentions and dmw/header may get written by different threads.
620 // Make sure to observe them in the same order when having several observers.
621 OrderAccess::loadload_for_IRIW();
622
|
583 p2i(_EntryList));
584
585 if (obj != NULL) {
586 if (log_is_enabled(Trace, monitorinflation)) {
587 ResourceMark rm;
588 log_trace(monitorinflation)("deflate_monitor: object=" INTPTR_FORMAT
589 ", mark=" INTPTR_FORMAT ", type='%s'",
590 p2i(obj), obj->mark().value(),
591 obj->klass()->external_name());
592 }
593
594 // Install the old mark word if nobody else has already done it.
595 install_displaced_markword_in_object(obj);
596 }
597
598 // We leave owner == DEFLATER_MARKER and contentions < 0
599 // to force any racing threads to retry.
600 return true; // Success, ObjectMonitor has been deflated.
601 }
602
603 // We might access the dead object headers for parsable heap walk, make sure
604 // headers are in correct shape, e.g. monitors deflated.
605 void ObjectMonitor::maybe_deflate_dead(oop* p) {
606 oop obj = *p;
607 assert(obj != NULL, "must not yet been cleared");
608 markWord mark = obj->mark();
609 if (mark.has_monitor()) {
610 ObjectMonitor* monitor = mark.monitor();
611 if (p == monitor->_object.ptr_raw()) {
612 assert(monitor->object_peek() == obj, "lock object must match");
613 markWord dmw = monitor->header();
614 obj->set_mark(dmw);
615 }
616 }
617 }
618
619 // Install the displaced mark word (dmw) of a deflating ObjectMonitor
620 // into the header of the object associated with the monitor. This
621 // idempotent method is called by a thread that is deflating a
622 // monitor and by other threads that have detected a race with the
623 // deflation process.
624 void ObjectMonitor::install_displaced_markword_in_object(const oop obj) {
625 // This function must only be called when (owner == DEFLATER_MARKER
626 // && contentions <= 0), but we can't guarantee that here because
627 // those values could change when the ObjectMonitor gets moved from
628 // the global free list to a per-thread free list.
629
630 guarantee(obj != NULL, "must be non-NULL");
631
632 // Separate loads in is_being_async_deflated(), which is almost always
633 // called before this function, from the load of dmw/header below.
634
635 // _contentions and dmw/header may get written by different threads.
636 // Make sure to observe them in the same order when having several observers.
637 OrderAccess::loadload_for_IRIW();
638
|