< prev index next >

src/hotspot/share/runtime/synchronizer.cpp

Print this page

        

*** 240,249 **** --- 240,250 ---- // and last are the inflated Java Monitor (ObjectMonitor) checks. lock->set_displaced_header(markOopDesc::unused_mark()); if (owner == NULL && Atomic::replace_if_null(Self, &(m->_owner))) { assert(m->_recursions == 0, "invariant"); + assert(m->_owner == Self, "invariant"); return true; } } // Note that we could inflate in quick_enter.
*** 1027,1037 **** // and list coherency traffic, but also tends to increase the // number of objectMonitors in circulation as well as the STW // scavenge costs. As usual, we lean toward time in space-time // tradeoffs. const int MAXPRIVATE = 1024; - stringStream ss; for (;;) { ObjectMonitor * m; // 1: try to allocate from the thread's local omFreeList. // Threads will attempt to allocate first from their local list, then --- 1028,1037 ----
*** 1063,1072 **** --- 1063,1073 ---- for (int i = Self->omFreeProvision; --i >= 0 && gFreeList != NULL;) { gMonitorFreeCount--; ObjectMonitor * take = gFreeList; gFreeList = take->FreeNext; guarantee(take->object() == NULL, "invariant"); + guarantee(!take->is_busy(), "invariant"); take->Recycle(); omRelease(Self, take, false); } Thread::muxRelease(&gListLock); Self->omFreeProvision += 1 + (Self->omFreeProvision/2);
*** 1164,1177 **** void ObjectSynchronizer::omRelease(Thread * Self, ObjectMonitor * m, bool fromPerThreadAlloc) { guarantee(m->header() == NULL, "invariant"); guarantee(m->object() == NULL, "invariant"); ! stringStream ss; ! guarantee((m->is_busy() | m->_recursions) == 0, "freeing in-use monitor: " ! "%s, recursions=" INTPTR_FORMAT, m->is_busy_to_string(&ss), ! m->_recursions); // Remove from omInUseList if (fromPerThreadAlloc) { ObjectMonitor* cur_mid_in_use = NULL; bool extracted = false; for (ObjectMonitor* mid = Self->omInUseList; mid != NULL; cur_mid_in_use = mid, mid = mid->FreeNext) { --- 1165,1175 ---- void ObjectSynchronizer::omRelease(Thread * Self, ObjectMonitor * m, bool fromPerThreadAlloc) { guarantee(m->header() == NULL, "invariant"); guarantee(m->object() == NULL, "invariant"); ! guarantee(((m->is_busy()|m->_recursions) == 0), "freeing in-use monitor"); // Remove from omInUseList if (fromPerThreadAlloc) { ObjectMonitor* cur_mid_in_use = NULL; bool extracted = false; for (ObjectMonitor* mid = Self->omInUseList; mid != NULL; cur_mid_in_use = mid, mid = mid->FreeNext) {
*** 1220,1237 **** ObjectMonitor * list = Self->omFreeList; // Null-terminated SLL ObjectMonitor * tail = NULL; int tally = 0; if (list != NULL) { ObjectMonitor * s; ! // The thread is going away. Set 'tail' to the last per-thread free ! // monitor which will be linked to gFreeList below under the gListLock. ! stringStream ss; for (s = list; s != NULL; s = s->FreeNext) { tally++; tail = s; guarantee(s->object() == NULL, "invariant"); ! guarantee(!s->is_busy(), "must be !is_busy: %s", s->is_busy_to_string(&ss)); } guarantee(tail != NULL, "invariant"); assert(Self->omFreeCount == tally, "free-count off"); Self->omFreeList = NULL; Self->omFreeCount = 0; --- 1218,1237 ---- ObjectMonitor * list = Self->omFreeList; // Null-terminated SLL ObjectMonitor * tail = NULL; int tally = 0; if (list != NULL) { ObjectMonitor * s; ! // The thread is going away, the per-thread free monitors ! // are freed via set_owner(NULL) ! // Link them to tail, which will be linked into the global free list ! // gFreeList below, under the gListLock for (s = list; s != NULL; s = s->FreeNext) { tally++; tail = s; guarantee(s->object() == NULL, "invariant"); ! guarantee(!s->is_busy(), "invariant"); ! s->set_owner(NULL); // redundant but good hygiene } guarantee(tail != NULL, "invariant"); assert(Self->omFreeCount == tally, "free-count off"); Self->omFreeList = NULL; Self->omFreeCount = 0;
*** 1377,1386 **** --- 1377,1387 ---- // Optimistically prepare the objectmonitor - anticipate successful CAS // We do this before the CAS in order to minimize the length of time // in which INFLATING appears in the mark. m->Recycle(); m->_Responsible = NULL; + m->_recursions = 0; m->_SpinDuration = ObjectMonitor::Knob_SpinLimit; // Consider: maintain by type/class markOop cmp = object->cas_set_mark(markOopDesc::INFLATING(), mark); if (cmp != mark) { omRelease(Self, m, true);
*** 1469,1479 **** --- 1470,1482 ---- assert(mark->is_neutral(), "invariant: header=" INTPTR_FORMAT, p2i(mark)); ObjectMonitor * m = omAlloc(Self); // prepare m for installation - set monitor to initial state m->Recycle(); m->set_header(mark); + m->set_owner(NULL); m->set_object(object); + m->_recursions = 0; m->_Responsible = NULL; m->_SpinDuration = ObjectMonitor::Knob_SpinLimit; // consider: keep metastats by type/class if (object->cas_set_mark(markOopDesc::encode(m), mark) != mark) { m->set_header(NULL);
*** 1920,1938 **** } // Check a free monitor entry; log any errors. void ObjectSynchronizer::chk_free_entry(JavaThread * jt, ObjectMonitor * n, outputStream * out, int *error_cnt_p) { - stringStream ss; if (n->is_busy()) { if (jt != NULL) { out->print_cr("ERROR: jt=" INTPTR_FORMAT ", monitor=" INTPTR_FORMAT ! ": free per-thread monitor must not be busy: %s", p2i(jt), ! p2i(n), n->is_busy_to_string(&ss)); } else { out->print_cr("ERROR: monitor=" INTPTR_FORMAT ": free global monitor " ! "must not be busy: %s", p2i(n), n->is_busy_to_string(&ss)); } *error_cnt_p = *error_cnt_p + 1; } if (n->header() != NULL) { if (jt != NULL) { --- 1923,1940 ---- } // Check a free monitor entry; log any errors. void ObjectSynchronizer::chk_free_entry(JavaThread * jt, ObjectMonitor * n, outputStream * out, int *error_cnt_p) { if (n->is_busy()) { if (jt != NULL) { out->print_cr("ERROR: jt=" INTPTR_FORMAT ", monitor=" INTPTR_FORMAT ! ": free per-thread monitor must not be busy.", p2i(jt), ! p2i(n)); } else { out->print_cr("ERROR: monitor=" INTPTR_FORMAT ": free global monitor " ! "must not be busy.", p2i(n)); } *error_cnt_p = *error_cnt_p + 1; } if (n->header() != NULL) { if (jt != NULL) {
*** 2107,2135 **** if (!on_exit) { // Not at VM exit so grab the global list lock. Thread::muxAcquire(&gListLock, "log_in_use_monitor_details"); } - stringStream ss; if (gOmInUseCount > 0) { out->print_cr("In-use global monitor info:"); out->print_cr("(B -> is_busy, H -> has hash code, L -> lock status)"); out->print_cr("%18s %s %18s %18s", "monitor", "BHL", "object", "object type"); out->print_cr("================== === ================== =================="); for (ObjectMonitor * n = gOmInUseList; n != NULL; n = n->FreeNext) { const oop obj = (oop) n->object(); const markOop mark = n->header(); ResourceMark rm; ! out->print(INTPTR_FORMAT " %d%d%d " INTPTR_FORMAT " %s", p2i(n), ! n->is_busy() != 0, mark->hash() != 0, n->owner() != NULL, ! p2i(obj), obj->klass()->external_name()); ! if (n->is_busy() != 0) { ! out->print(" (%s)", n->is_busy_to_string(&ss)); ! ss.reset(); ! } ! out->cr(); } } if (!on_exit) { Thread::muxRelease(&gListLock); --- 2109,2131 ---- if (!on_exit) { // Not at VM exit so grab the global list lock. Thread::muxAcquire(&gListLock, "log_in_use_monitor_details"); } if (gOmInUseCount > 0) { out->print_cr("In-use global monitor info:"); out->print_cr("(B -> is_busy, H -> has hash code, L -> lock status)"); out->print_cr("%18s %s %18s %18s", "monitor", "BHL", "object", "object type"); out->print_cr("================== === ================== =================="); for (ObjectMonitor * n = gOmInUseList; n != NULL; n = n->FreeNext) { const oop obj = (oop) n->object(); const markOop mark = n->header(); ResourceMark rm; ! out->print_cr(INTPTR_FORMAT " %d%d%d " INTPTR_FORMAT " %s", p2i(n), ! n->is_busy() != 0, mark->hash() != 0, n->owner() != NULL, ! p2i(obj), obj->klass()->external_name()); } } if (!on_exit) { Thread::muxRelease(&gListLock);
*** 2143,2161 **** for (JavaThreadIteratorWithHandle jtiwh; JavaThread *jt = jtiwh.next(); ) { for (ObjectMonitor * n = jt->omInUseList; n != NULL; n = n->FreeNext) { const oop obj = (oop) n->object(); const markOop mark = n->header(); ResourceMark rm; ! out->print(INTPTR_FORMAT " " INTPTR_FORMAT " %d%d%d " INTPTR_FORMAT ! " %s", p2i(jt), p2i(n), n->is_busy() != 0, ! mark->hash() != 0, n->owner() != NULL, p2i(obj), ! obj->klass()->external_name()); ! if (n->is_busy() != 0) { ! out->print(" (%s)", n->is_busy_to_string(&ss)); ! ss.reset(); ! } ! out->cr(); } } out->flush(); } --- 2139,2152 ---- for (JavaThreadIteratorWithHandle jtiwh; JavaThread *jt = jtiwh.next(); ) { for (ObjectMonitor * n = jt->omInUseList; n != NULL; n = n->FreeNext) { const oop obj = (oop) n->object(); const markOop mark = n->header(); ResourceMark rm; ! out->print_cr(INTPTR_FORMAT " " INTPTR_FORMAT " %d%d%d " INTPTR_FORMAT ! " %s", p2i(jt), p2i(n), n->is_busy() != 0, ! mark->hash() != 0, n->owner() != NULL, p2i(obj), ! obj->klass()->external_name()); } } out->flush(); }
< prev index next >