@@ -624,26 +624,7 @@ void BytecodeInterpreter::run(interpreterState istate) {
624
624
// The initial monitor is ours for the taking.
625
625
BasicObjectLock* mon = &istate->monitor_base ()[-1 ];
626
626
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);
647
628
}
648
629
THREAD->set_do_not_unlock_if_synchronized (false );
649
630
@@ -725,26 +706,7 @@ void BytecodeInterpreter::run(interpreterState istate) {
725
706
BasicObjectLock* entry = (BasicObjectLock*) istate->stack_base ();
726
707
assert (entry->obj () == nullptr , " Frame manager didn't allocate the monitor" );
727
708
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);
748
710
UPDATE_PC_AND_TOS (1 , -1 );
749
711
goto run;
750
712
}
@@ -1657,26 +1619,7 @@ void BytecodeInterpreter::run(interpreterState istate) {
1657
1619
}
1658
1620
if (entry != nullptr ) {
1659
1621
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);
1680
1623
UPDATE_PC_AND_TOS_AND_CONTINUE (1 , -1 );
1681
1624
} else {
1682
1625
istate->set_msg (more_monitors);
@@ -1694,25 +1637,7 @@ void BytecodeInterpreter::run(interpreterState istate) {
1694
1637
while (most_recent != limit ) {
1695
1638
if ((most_recent)->obj () == lockee) {
1696
1639
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);
1716
1641
UPDATE_PC_AND_TOS_AND_CONTINUE (1 , -1 );
1717
1642
}
1718
1643
most_recent++;
@@ -3137,27 +3062,7 @@ void BytecodeInterpreter::run(interpreterState istate) {
3137
3062
while (end < base) {
3138
3063
oop lockee = end->obj ();
3139
3064
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);
3161
3066
3162
3067
// One error is plenty
3163
3068
if (illegal_state_oop () == nullptr && !suppress_error) {
@@ -3204,32 +3109,12 @@ void BytecodeInterpreter::run(interpreterState istate) {
3204
3109
illegal_state_oop = Handle (THREAD, THREAD->pending_exception ());
3205
3110
THREAD->clear_pending_exception ();
3206
3111
}
3207
- } else if (LockingMode != LM_LEGACY) {
3112
+ } else {
3208
3113
InterpreterRuntime::monitorexit (base);
3209
3114
if (THREAD->has_pending_exception ()) {
3210
3115
if (!suppress_error) illegal_state_oop = Handle (THREAD, THREAD->pending_exception ());
3211
3116
THREAD->clear_pending_exception ();
3212
3117
}
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
- }
3233
3118
}
3234
3119
}
3235
3120
}
0 commit comments