< prev index next >

src/hotspot/share/runtime/objectMonitor.cpp

Print this page

 596             p2i(_EntryList));
 597 
 598   if (obj != NULL) {
 599     if (log_is_enabled(Trace, monitorinflation)) {
 600       ResourceMark rm;
 601       log_trace(monitorinflation)("deflate_monitor: object=" INTPTR_FORMAT
 602                                   ", mark=" INTPTR_FORMAT ", type='%s'",
 603                                   p2i(obj), obj->mark().value(),
 604                                   obj->klass()->external_name());
 605     }
 606 
 607     // Install the old mark word if nobody else has already done it.
 608     install_displaced_markword_in_object(obj);
 609   }
 610 
 611   // We leave owner == DEFLATER_MARKER and contentions < 0
 612   // to force any racing threads to retry.
 613   return true;  // Success, ObjectMonitor has been deflated.
 614 }
 615 
















 616 // Install the displaced mark word (dmw) of a deflating ObjectMonitor
 617 // into the header of the object associated with the monitor. This
 618 // idempotent method is called by a thread that is deflating a
 619 // monitor and by other threads that have detected a race with the
 620 // deflation process.
 621 void ObjectMonitor::install_displaced_markword_in_object(const oop obj) {
 622   // This function must only be called when (owner == DEFLATER_MARKER
 623   // && contentions <= 0), but we can't guarantee that here because
 624   // those values could change when the ObjectMonitor gets moved from
 625   // the global free list to a per-thread free list.
 626 
 627   guarantee(obj != NULL, "must be non-NULL");
 628 
 629   // Separate loads in is_being_async_deflated(), which is almost always
 630   // called before this function, from the load of dmw/header below.
 631 
 632   // _contentions and dmw/header may get written by different threads.
 633   // Make sure to observe them in the same order when having several observers.
 634   OrderAccess::loadload_for_IRIW();
 635 

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