981 if (THREAD->is_lock_owned((address)cur)) {
982 assert(_recursions == 0, "invariant");
983 set_owner_from_BasicLock(cur, Self); // Convert from BasicLock* to Thread*.
984 _recursions = 0;
985 } else {
986 // Apparent unbalanced locking ...
987 // Naively we'd like to throw IllegalMonitorStateException.
988 // As a practical matter we can neither allocate nor throw an
989 // exception as ::exit() can be called from leaf routines.
990 // see x86_32.ad Fast_Unlock() and the I1 and I2 properties.
991 // Upon deeper reflection, however, in a properly run JVM the only
992 // way we should encounter this situation is in the presence of
993 // unbalanced JNI locking. TODO: CheckJNICalls.
994 // See also: CR4414101
995 #ifdef ASSERT
996 LogStreamHandle(Error, monitorinflation) lsh;
997 lsh.print_cr("ERROR: ObjectMonitor::exit(): thread=" INTPTR_FORMAT
998 " is exiting an ObjectMonitor it does not own.", p2i(THREAD));
999 lsh.print_cr("The imbalance is possibly caused by JNI locking.");
1000 print_debug_style_on(&lsh);
1001 #endif
1002 assert(false, "Non-balanced monitor enter/exit!");
1003 return;
1004 }
1005 }
1006
1007 if (_recursions != 0) {
1008 _recursions--; // this is simple recursive enter
1009 return;
1010 }
1011
1012 // Invariant: after setting Responsible=null an thread must execute
1013 // a MEMBAR or other serializing instruction before fetching EntryList|cxq.
1014 _Responsible = NULL;
1015
1016 #if INCLUDE_JFR
1017 // get the owner's thread id for the MonitorEnter event
1018 // if it is enabled and the thread isn't suspended
1019 if (not_suspended && EventJavaMonitorEnter::is_enabled()) {
1020 _previous_owner_tid = JFR_THREAD_ID(Self);
1021 }
1022 #endif
|
981 if (THREAD->is_lock_owned((address)cur)) {
982 assert(_recursions == 0, "invariant");
983 set_owner_from_BasicLock(cur, Self); // Convert from BasicLock* to Thread*.
984 _recursions = 0;
985 } else {
986 // Apparent unbalanced locking ...
987 // Naively we'd like to throw IllegalMonitorStateException.
988 // As a practical matter we can neither allocate nor throw an
989 // exception as ::exit() can be called from leaf routines.
990 // see x86_32.ad Fast_Unlock() and the I1 and I2 properties.
991 // Upon deeper reflection, however, in a properly run JVM the only
992 // way we should encounter this situation is in the presence of
993 // unbalanced JNI locking. TODO: CheckJNICalls.
994 // See also: CR4414101
995 #ifdef ASSERT
996 LogStreamHandle(Error, monitorinflation) lsh;
997 lsh.print_cr("ERROR: ObjectMonitor::exit(): thread=" INTPTR_FORMAT
998 " is exiting an ObjectMonitor it does not own.", p2i(THREAD));
999 lsh.print_cr("The imbalance is possibly caused by JNI locking.");
1000 print_debug_style_on(&lsh);
1001 assert(false, "Non-balanced monitor enter/exit!");
1002 #endif
1003 return;
1004 }
1005 }
1006
1007 if (_recursions != 0) {
1008 _recursions--; // this is simple recursive enter
1009 return;
1010 }
1011
1012 // Invariant: after setting Responsible=null an thread must execute
1013 // a MEMBAR or other serializing instruction before fetching EntryList|cxq.
1014 _Responsible = NULL;
1015
1016 #if INCLUDE_JFR
1017 // get the owner's thread id for the MonitorEnter event
1018 // if it is enabled and the thread isn't suspended
1019 if (not_suspended && EventJavaMonitorEnter::is_enabled()) {
1020 _previous_owner_tid = JFR_THREAD_ID(Self);
1021 }
1022 #endif
|