@@ -624,26 +624,7 @@ void BytecodeInterpreter::run(interpreterState istate) {
624624 // The initial monitor is ours for the taking.
625625 BasicObjectLock* mon = &istate->monitor_base ()[-1 ];
626626 mon->set_obj (rcvr);
627-
628- bool success = false ;
629- if (LockingMode == LM_LEGACY) {
630- // Traditional fast locking.
631- markWord displaced = rcvr->mark ().set_unlocked ();
632- mon->lock ()->set_displaced_header (displaced);
633- success = true ;
634- if (rcvr->cas_set_mark (markWord::from_pointer (mon), displaced) != displaced) {
635- // Is it simple recursive case?
636- if (THREAD->is_lock_owned ((address) displaced.clear_lock_bits ().to_pointer ())) {
637- mon->lock ()->set_displaced_header (markWord::from_pointer (nullptr ));
638- } else {
639- success = false ;
640- }
641- }
642- }
643- if (!success) {
644- CALL_VM (InterpreterRuntime::monitorenter (THREAD, mon), handle_exception);
645- }
646-
627+ CALL_VM (InterpreterRuntime::monitorenter (THREAD, mon), handle_exception);
647628 }
648629 THREAD->set_do_not_unlock_if_synchronized (false );
649630
@@ -725,26 +706,7 @@ void BytecodeInterpreter::run(interpreterState istate) {
725706 BasicObjectLock* entry = (BasicObjectLock*) istate->stack_base ();
726707 assert (entry->obj () == nullptr , " Frame manager didn't allocate the monitor" );
727708 entry->set_obj (lockee);
728-
729- bool success = false ;
730- if (LockingMode == LM_LEGACY) {
731- // Traditional fast locking.
732- markWord displaced = lockee->mark ().set_unlocked ();
733- entry->lock ()->set_displaced_header (displaced);
734- success = true ;
735- if (lockee->cas_set_mark (markWord::from_pointer (entry), displaced) != displaced) {
736- // Is it simple recursive case?
737- if (THREAD->is_lock_owned ((address) displaced.clear_lock_bits ().to_pointer ())) {
738- entry->lock ()->set_displaced_header (markWord::from_pointer (nullptr ));
739- } else {
740- success = false ;
741- }
742- }
743- }
744- if (!success) {
745- CALL_VM (InterpreterRuntime::monitorenter (THREAD, entry), handle_exception);
746- }
747-
709+ CALL_VM (InterpreterRuntime::monitorenter (THREAD, entry), handle_exception);
748710 UPDATE_PC_AND_TOS (1 , -1 );
749711 goto run;
750712 }
@@ -1657,26 +1619,7 @@ void BytecodeInterpreter::run(interpreterState istate) {
16571619 }
16581620 if (entry != nullptr ) {
16591621 entry->set_obj (lockee);
1660-
1661- bool success = false ;
1662- if (LockingMode == LM_LEGACY) {
1663- // Traditional fast locking.
1664- markWord displaced = lockee->mark ().set_unlocked ();
1665- entry->lock ()->set_displaced_header (displaced);
1666- success = true ;
1667- if (lockee->cas_set_mark (markWord::from_pointer (entry), displaced) != displaced) {
1668- // Is it simple recursive case?
1669- if (THREAD->is_lock_owned ((address) displaced.clear_lock_bits ().to_pointer ())) {
1670- entry->lock ()->set_displaced_header (markWord::from_pointer (nullptr ));
1671- } else {
1672- success = false ;
1673- }
1674- }
1675- }
1676- if (!success) {
1677- CALL_VM (InterpreterRuntime::monitorenter (THREAD, entry), handle_exception);
1678- }
1679-
1622+ CALL_VM (InterpreterRuntime::monitorenter (THREAD, entry), handle_exception);
16801623 UPDATE_PC_AND_TOS_AND_CONTINUE (1 , -1 );
16811624 } else {
16821625 istate->set_msg (more_monitors);
@@ -1694,25 +1637,7 @@ void BytecodeInterpreter::run(interpreterState istate) {
16941637 while (most_recent != limit ) {
16951638 if ((most_recent)->obj () == lockee) {
16961639 BasicLock* lock = most_recent->lock ();
1697-
1698- bool success = false ;
1699- if (LockingMode == LM_LEGACY) {
1700- // If it isn't recursive we either must swap old header or call the runtime
1701- most_recent->set_obj (nullptr );
1702- success = true ;
1703- markWord header = lock->displaced_header ();
1704- if (header.to_pointer () != nullptr ) {
1705- markWord old_header = markWord::encode (lock);
1706- if (lockee->cas_set_mark (header, old_header) != old_header) {
1707- // restore object for the slow case
1708- most_recent->set_obj (lockee);
1709- success = false ;
1710- }
1711- }
1712- }
1713- if (!success) {
1714- InterpreterRuntime::monitorexit (most_recent);
1715- }
1640+ InterpreterRuntime::monitorexit (most_recent);
17161641 UPDATE_PC_AND_TOS_AND_CONTINUE (1 , -1 );
17171642 }
17181643 most_recent++;
@@ -3137,27 +3062,7 @@ void BytecodeInterpreter::run(interpreterState istate) {
31373062 while (end < base) {
31383063 oop lockee = end->obj ();
31393064 if (lockee != nullptr ) {
3140- BasicLock* lock = end->lock ();
3141-
3142- bool success = false ;
3143- if (LockingMode == LM_LEGACY) {
3144- markWord header = lock->displaced_header ();
3145- end->set_obj (nullptr );
3146-
3147- // If it isn't recursive we either must swap old header or call the runtime
3148- success = true ;
3149- if (header.to_pointer () != nullptr ) {
3150- markWord old_header = markWord::encode (lock);
3151- if (lockee->cas_set_mark (header, old_header) != old_header) {
3152- // restore object for the slow case
3153- end->set_obj (lockee);
3154- success = false ;
3155- }
3156- }
3157- }
3158- if (!success) {
3159- InterpreterRuntime::monitorexit (end);
3160- }
3065+ InterpreterRuntime::monitorexit (end);
31613066
31623067 // One error is plenty
31633068 if (illegal_state_oop () == nullptr && !suppress_error) {
@@ -3204,32 +3109,12 @@ void BytecodeInterpreter::run(interpreterState istate) {
32043109 illegal_state_oop = Handle (THREAD, THREAD->pending_exception ());
32053110 THREAD->clear_pending_exception ();
32063111 }
3207- } else if (LockingMode != LM_LEGACY) {
3112+ } else {
32083113 InterpreterRuntime::monitorexit (base);
32093114 if (THREAD->has_pending_exception ()) {
32103115 if (!suppress_error) illegal_state_oop = Handle (THREAD, THREAD->pending_exception ());
32113116 THREAD->clear_pending_exception ();
32123117 }
3213- } else {
3214- BasicLock* lock = base->lock ();
3215- markWord header = lock->displaced_header ();
3216- base->set_obj (nullptr );
3217-
3218- // If it isn't recursive we either must swap old header or call the runtime
3219- bool dec_monitor_count = true ;
3220- if (header.to_pointer () != nullptr ) {
3221- markWord old_header = markWord::encode (lock);
3222- if (rcvr->cas_set_mark (header, old_header) != old_header) {
3223- // restore object for the slow case
3224- base->set_obj (rcvr);
3225- dec_monitor_count = false ;
3226- InterpreterRuntime::monitorexit (base);
3227- if (THREAD->has_pending_exception ()) {
3228- if (!suppress_error) illegal_state_oop = Handle (THREAD, THREAD->pending_exception ());
3229- THREAD->clear_pending_exception ();
3230- }
3231- }
3232- }
32333118 }
32343119 }
32353120 }
0 commit comments