1455 JavaThread* deoptee_thread, frame& fr, int exec_mode, bool realloc_failures) {
1456 bool relocked_objects = false;
1457 for (int i = 0; i < monitors->length(); i++) {
1458 MonitorInfo* mon_info = monitors->at(i);
1459 if (mon_info->eliminated()) {
1460 assert(!mon_info->owner_is_scalar_replaced() || realloc_failures, "reallocation was missed");
1461 relocked_objects = true;
1462 if (!mon_info->owner_is_scalar_replaced()) {
1463 Handle obj(thread, mon_info->owner());
1464 markWord mark = obj->mark();
1465 if (UseBiasedLocking && mark.has_bias_pattern()) {
1466 // New allocated objects may have the mark set to anonymously biased.
1467 // Also the deoptimized method may called methods with synchronization
1468 // where the thread-local object is bias locked to the current thread.
1469 assert(mark.is_biased_anonymously() ||
1470 mark.biased_locker() == deoptee_thread, "should be locked to current thread");
1471 // Reset mark word to unbiased prototype.
1472 markWord unbiased_prototype = markWord::prototype().set_age(mark.age());
1473 obj->set_mark(unbiased_prototype);
1474 } else if (exec_mode == Unpack_none) {
1475 if (mark.has_locker() && fr.sp() > (intptr_t*)mark.locker()) {
1476 // With exec_mode == Unpack_none obj may be thread local and locked in
1477 // a callee frame. In this case the bias was revoked before in revoke_for_object_deoptimization().
1478 // Make the lock in the callee a recursive lock and restore the displaced header.
1479 markWord dmw = mark.displaced_mark_helper();
1480 mark.locker()->set_displaced_header(markWord::encode((BasicLock*) NULL));
1481 obj->set_mark(dmw);
1482 }
1483 if (mark.has_monitor()) {
1484 // defer relocking if the deoptee thread is currently waiting for obj
1485 ObjectMonitor* waiting_monitor = deoptee_thread->current_waiting_monitor();
1486 if (waiting_monitor != NULL && waiting_monitor->object() == obj()) {
1487 assert(fr.is_deoptimized_frame(), "frame must be scheduled for deoptimization");
1488 mon_info->lock()->set_displaced_header(markWord::unused_mark());
1489 JvmtiDeferredUpdates::inc_relock_count_after_wait(deoptee_thread);
1490 continue;
1491 }
1492 }
1493 }
1494 BasicLock* lock = mon_info->lock();
1495 ObjectSynchronizer::enter(obj, lock, deoptee_thread);
|
1455 JavaThread* deoptee_thread, frame& fr, int exec_mode, bool realloc_failures) {
1456 bool relocked_objects = false;
1457 for (int i = 0; i < monitors->length(); i++) {
1458 MonitorInfo* mon_info = monitors->at(i);
1459 if (mon_info->eliminated()) {
1460 assert(!mon_info->owner_is_scalar_replaced() || realloc_failures, "reallocation was missed");
1461 relocked_objects = true;
1462 if (!mon_info->owner_is_scalar_replaced()) {
1463 Handle obj(thread, mon_info->owner());
1464 markWord mark = obj->mark();
1465 if (UseBiasedLocking && mark.has_bias_pattern()) {
1466 // New allocated objects may have the mark set to anonymously biased.
1467 // Also the deoptimized method may called methods with synchronization
1468 // where the thread-local object is bias locked to the current thread.
1469 assert(mark.is_biased_anonymously() ||
1470 mark.biased_locker() == deoptee_thread, "should be locked to current thread");
1471 // Reset mark word to unbiased prototype.
1472 markWord unbiased_prototype = markWord::prototype().set_age(mark.age());
1473 obj->set_mark(unbiased_prototype);
1474 } else if (exec_mode == Unpack_none) {
1475 if (LockingMode == LM_LEGACY && mark.has_locker() && fr.sp() > (intptr_t*)mark.locker()) {
1476 // With exec_mode == Unpack_none obj may be thread local and locked in
1477 // a callee frame. In this case the bias was revoked before in revoke_for_object_deoptimization().
1478 // Make the lock in the callee a recursive lock and restore the displaced header.
1479 markWord dmw = mark.displaced_mark_helper();
1480 mark.locker()->set_displaced_header(markWord::encode((BasicLock*) NULL));
1481 obj->set_mark(dmw);
1482 }
1483 if (mark.has_monitor()) {
1484 // defer relocking if the deoptee thread is currently waiting for obj
1485 ObjectMonitor* waiting_monitor = deoptee_thread->current_waiting_monitor();
1486 if (waiting_monitor != NULL && waiting_monitor->object() == obj()) {
1487 assert(fr.is_deoptimized_frame(), "frame must be scheduled for deoptimization");
1488 mon_info->lock()->set_displaced_header(markWord::unused_mark());
1489 JvmtiDeferredUpdates::inc_relock_count_after_wait(deoptee_thread);
1490 continue;
1491 }
1492 }
1493 }
1494 BasicLock* lock = mon_info->lock();
1495 ObjectSynchronizer::enter(obj, lock, deoptee_thread);
|