< prev index next >

src/hotspot/share/runtime/sharedRuntime.cpp

Print this page




2074 JRT_END
2075 
2076 
2077 // Handles the uncommon case in locking, i.e., contention or an inflated lock.
2078 JRT_BLOCK_ENTRY(void, SharedRuntime::complete_monitor_locking_C(oopDesc* _obj, BasicLock* lock, JavaThread* thread))
2079   if (!SafepointSynchronize::is_synchronizing()) {
2080     // Only try quick_enter() if we're not trying to reach a safepoint
2081     // so that the calling thread reaches the safepoint more quickly.
2082     if (ObjectSynchronizer::quick_enter(_obj, thread, lock)) return;
2083   }
2084   // NO_ASYNC required because an async exception on the state transition destructor
2085   // would leave you with the lock held and it would never be released.
2086   // The normal monitorenter NullPointerException is thrown without acquiring a lock
2087   // and the model is that an exception implies the method failed.
2088   JRT_BLOCK_NO_ASYNC
2089   oop obj(_obj);
2090   if (PrintBiasedLockingStatistics) {
2091     Atomic::inc(BiasedLocking::slow_path_entry_count_addr());
2092   }
2093   Handle h_obj(THREAD, obj);
2094   if (UseBiasedLocking) {
2095     // Retry fast entry if bias is revoked to avoid unnecessary inflation
2096     ObjectSynchronizer::fast_enter(h_obj, lock, true, CHECK);
2097   } else {
2098     ObjectSynchronizer::slow_enter(h_obj, lock, CHECK);
2099   }
2100   assert(!HAS_PENDING_EXCEPTION, "Should have no exception here");
2101   JRT_BLOCK_END
2102 JRT_END
2103 
2104 // Handles the uncommon cases of monitor unlocking in compiled code
2105 JRT_LEAF(void, SharedRuntime::complete_monitor_unlocking_C(oopDesc* _obj, BasicLock* lock, JavaThread * THREAD))
2106    oop obj(_obj);
2107   assert(JavaThread::current() == THREAD, "invariant");
2108   // I'm not convinced we need the code contained by MIGHT_HAVE_PENDING anymore
2109   // testing was unable to ever fire the assert that guarded it so I have removed it.
2110   assert(!HAS_PENDING_EXCEPTION, "Do we need code below anymore?");
2111 #undef MIGHT_HAVE_PENDING
2112 #ifdef MIGHT_HAVE_PENDING
2113   // Save and restore any pending_exception around the exception mark.
2114   // While the slow_exit must not throw an exception, we could come into
2115   // this routine with one set.
2116   oop pending_excep = NULL;
2117   const char* pending_file;
2118   int pending_line;
2119   if (HAS_PENDING_EXCEPTION) {
2120     pending_excep = PENDING_EXCEPTION;
2121     pending_file  = THREAD->exception_file();
2122     pending_line  = THREAD->exception_line();
2123     CLEAR_PENDING_EXCEPTION;
2124   }
2125 #endif /* MIGHT_HAVE_PENDING */
2126 
2127   {
2128     // Exit must be non-blocking, and therefore no exceptions can be thrown.
2129     EXCEPTION_MARK;
2130     ObjectSynchronizer::slow_exit(obj, lock, THREAD);
2131   }
2132 
2133 #ifdef MIGHT_HAVE_PENDING
2134   if (pending_excep != NULL) {
2135     THREAD->set_pending_exception(pending_excep, pending_file, pending_line);
2136   }
2137 #endif /* MIGHT_HAVE_PENDING */
2138 JRT_END
2139 
2140 #ifndef PRODUCT
2141 
2142 void SharedRuntime::print_statistics() {
2143   ttyLocker ttyl;
2144   if (xtty != NULL)  xtty->head("statistics type='SharedRuntime'");
2145 
2146   if (_throw_null_ctr) tty->print_cr("%5d implicit null throw", _throw_null_ctr);
2147 
2148   SharedRuntime::print_ic_miss_histogram();
2149 
2150   if (CountRemovableExceptions) {




2074 JRT_END
2075 
2076 
2077 // Handles the uncommon case in locking, i.e., contention or an inflated lock.
2078 JRT_BLOCK_ENTRY(void, SharedRuntime::complete_monitor_locking_C(oopDesc* _obj, BasicLock* lock, JavaThread* thread))
2079   if (!SafepointSynchronize::is_synchronizing()) {
2080     // Only try quick_enter() if we're not trying to reach a safepoint
2081     // so that the calling thread reaches the safepoint more quickly.
2082     if (ObjectSynchronizer::quick_enter(_obj, thread, lock)) return;
2083   }
2084   // NO_ASYNC required because an async exception on the state transition destructor
2085   // would leave you with the lock held and it would never be released.
2086   // The normal monitorenter NullPointerException is thrown without acquiring a lock
2087   // and the model is that an exception implies the method failed.
2088   JRT_BLOCK_NO_ASYNC
2089   oop obj(_obj);
2090   if (PrintBiasedLockingStatistics) {
2091     Atomic::inc(BiasedLocking::slow_path_entry_count_addr());
2092   }
2093   Handle h_obj(THREAD, obj);
2094   ObjectSynchronizer::enter(h_obj, lock, CHECK);





2095   assert(!HAS_PENDING_EXCEPTION, "Should have no exception here");
2096   JRT_BLOCK_END
2097 JRT_END
2098 
2099 // Handles the uncommon cases of monitor unlocking in compiled code
2100 JRT_LEAF(void, SharedRuntime::complete_monitor_unlocking_C(oopDesc* _obj, BasicLock* lock, JavaThread * THREAD))
2101    oop obj(_obj);
2102   assert(JavaThread::current() == THREAD, "invariant");
2103   // I'm not convinced we need the code contained by MIGHT_HAVE_PENDING anymore
2104   // testing was unable to ever fire the assert that guarded it so I have removed it.
2105   assert(!HAS_PENDING_EXCEPTION, "Do we need code below anymore?");
2106 #undef MIGHT_HAVE_PENDING
2107 #ifdef MIGHT_HAVE_PENDING
2108   // Save and restore any pending_exception around the exception mark.
2109   // While the slow_exit must not throw an exception, we could come into
2110   // this routine with one set.
2111   oop pending_excep = NULL;
2112   const char* pending_file;
2113   int pending_line;
2114   if (HAS_PENDING_EXCEPTION) {
2115     pending_excep = PENDING_EXCEPTION;
2116     pending_file  = THREAD->exception_file();
2117     pending_line  = THREAD->exception_line();
2118     CLEAR_PENDING_EXCEPTION;
2119   }
2120 #endif /* MIGHT_HAVE_PENDING */
2121 
2122   {
2123     // Exit must be non-blocking, and therefore no exceptions can be thrown.
2124     EXCEPTION_MARK;
2125     ObjectSynchronizer::exit(obj, lock, THREAD);
2126   }
2127 
2128 #ifdef MIGHT_HAVE_PENDING
2129   if (pending_excep != NULL) {
2130     THREAD->set_pending_exception(pending_excep, pending_file, pending_line);
2131   }
2132 #endif /* MIGHT_HAVE_PENDING */
2133 JRT_END
2134 
2135 #ifndef PRODUCT
2136 
2137 void SharedRuntime::print_statistics() {
2138   ttyLocker ttyl;
2139   if (xtty != NULL)  xtty->head("statistics type='SharedRuntime'");
2140 
2141   if (_throw_null_ctr) tty->print_cr("%5d implicit null throw", _throw_null_ctr);
2142 
2143   SharedRuntime::print_ic_miss_histogram();
2144 
2145   if (CountRemovableExceptions) {


< prev index next >