1484 JavaThread* deoptee_thread, frame& fr, int exec_mode, bool realloc_failures) {
1485 bool relocked_objects = false;
1486 for (int i = 0; i < monitors->length(); i++) {
1487 MonitorInfo* mon_info = monitors->at(i);
1488 if (mon_info->eliminated()) {
1489 assert(!mon_info->owner_is_scalar_replaced() || realloc_failures, "reallocation was missed");
1490 relocked_objects = true;
1491 if (!mon_info->owner_is_scalar_replaced()) {
1492 Handle obj(thread, mon_info->owner());
1493 markWord mark = obj->mark();
1494 if (UseBiasedLocking && mark.has_bias_pattern()) {
1495 // New allocated objects may have the mark set to anonymously biased.
1496 // Also the deoptimized method may called methods with synchronization
1497 // where the thread-local object is bias locked to the current thread.
1498 assert(mark.is_biased_anonymously() ||
1499 mark.biased_locker() == deoptee_thread, "should be locked to current thread");
1500 // Reset mark word to unbiased prototype.
1501 markWord unbiased_prototype = markWord::prototype().set_age(mark.age());
1502 obj->set_mark(unbiased_prototype);
1503 } else if (exec_mode == Unpack_none) {
1504 if (mark.has_locker() && fr.sp() > (intptr_t*)mark.locker()) {
1505 // With exec_mode == Unpack_none obj may be thread local and locked in
1506 // a callee frame. In this case the bias was revoked before in revoke_for_object_deoptimization().
1507 // Make the lock in the callee a recursive lock and restore the displaced header.
1508 markWord dmw = mark.displaced_mark_helper();
1509 mark.locker()->set_displaced_header(markWord::encode((BasicLock*) NULL));
1510 obj->set_mark(dmw);
1511 }
1512 if (mark.has_monitor()) {
1513 // defer relocking if the deoptee thread is currently waiting for obj
1514 ObjectMonitor* waiting_monitor = deoptee_thread->current_waiting_monitor();
1515 if (waiting_monitor != NULL && waiting_monitor->object() == obj()) {
1516 assert(fr.is_deoptimized_frame(), "frame must be scheduled for deoptimization");
1517 mon_info->lock()->set_displaced_header(markWord::unused_mark());
1518 JvmtiDeferredUpdates::inc_relock_count_after_wait(deoptee_thread);
1519 continue;
1520 }
1521 }
1522 }
1523 BasicLock* lock = mon_info->lock();
1524 ObjectSynchronizer::enter(obj, lock, deoptee_thread);
|
1484 JavaThread* deoptee_thread, frame& fr, int exec_mode, bool realloc_failures) {
1485 bool relocked_objects = false;
1486 for (int i = 0; i < monitors->length(); i++) {
1487 MonitorInfo* mon_info = monitors->at(i);
1488 if (mon_info->eliminated()) {
1489 assert(!mon_info->owner_is_scalar_replaced() || realloc_failures, "reallocation was missed");
1490 relocked_objects = true;
1491 if (!mon_info->owner_is_scalar_replaced()) {
1492 Handle obj(thread, mon_info->owner());
1493 markWord mark = obj->mark();
1494 if (UseBiasedLocking && mark.has_bias_pattern()) {
1495 // New allocated objects may have the mark set to anonymously biased.
1496 // Also the deoptimized method may called methods with synchronization
1497 // where the thread-local object is bias locked to the current thread.
1498 assert(mark.is_biased_anonymously() ||
1499 mark.biased_locker() == deoptee_thread, "should be locked to current thread");
1500 // Reset mark word to unbiased prototype.
1501 markWord unbiased_prototype = markWord::prototype().set_age(mark.age());
1502 obj->set_mark(unbiased_prototype);
1503 } else if (exec_mode == Unpack_none) {
1504 if (LockingMode == LM_LEGACY && mark.has_locker() && fr.sp() > (intptr_t*)mark.locker()) {
1505 // With exec_mode == Unpack_none obj may be thread local and locked in
1506 // a callee frame. In this case the bias was revoked before in revoke_for_object_deoptimization().
1507 // Make the lock in the callee a recursive lock and restore the displaced header.
1508 markWord dmw = mark.displaced_mark_helper();
1509 mark.locker()->set_displaced_header(markWord::encode((BasicLock*) NULL));
1510 obj->set_mark(dmw);
1511 }
1512 if (mark.has_monitor()) {
1513 // defer relocking if the deoptee thread is currently waiting for obj
1514 ObjectMonitor* waiting_monitor = deoptee_thread->current_waiting_monitor();
1515 if (waiting_monitor != NULL && waiting_monitor->object() == obj()) {
1516 assert(fr.is_deoptimized_frame(), "frame must be scheduled for deoptimization");
1517 mon_info->lock()->set_displaced_header(markWord::unused_mark());
1518 JvmtiDeferredUpdates::inc_relock_count_after_wait(deoptee_thread);
1519 continue;
1520 }
1521 }
1522 }
1523 BasicLock* lock = mon_info->lock();
1524 ObjectSynchronizer::enter(obj, lock, deoptee_thread);
|