< prev index next >

src/hotspot/share/runtime/sharedRuntime.cpp

Print this page

  48 #include "memory/universe.hpp"
  49 #include "metaprogramming/primitiveConversions.hpp"
  50 #include "oops/compiledICHolder.inline.hpp"
  51 #include "oops/klass.hpp"
  52 #include "oops/method.inline.hpp"
  53 #include "oops/objArrayKlass.hpp"
  54 #include "oops/oop.inline.hpp"
  55 #include "prims/forte.hpp"
  56 #include "prims/jvmtiExport.hpp"
  57 #include "prims/jvmtiThreadState.hpp"
  58 #include "prims/methodHandles.hpp"
  59 #include "prims/nativeLookup.hpp"
  60 #include "runtime/atomic.hpp"
  61 #include "runtime/frame.inline.hpp"
  62 #include "runtime/handles.inline.hpp"
  63 #include "runtime/init.hpp"
  64 #include "runtime/interfaceSupport.inline.hpp"
  65 #include "runtime/java.hpp"
  66 #include "runtime/javaCalls.hpp"
  67 #include "runtime/jniHandles.inline.hpp"

  68 #include "runtime/sharedRuntime.hpp"
  69 #include "runtime/stackWatermarkSet.hpp"
  70 #include "runtime/stubRoutines.hpp"
  71 #include "runtime/synchronizer.hpp"
  72 #include "runtime/vframe.inline.hpp"
  73 #include "runtime/vframeArray.hpp"
  74 #include "runtime/vm_version.hpp"
  75 #include "utilities/copy.hpp"
  76 #include "utilities/dtrace.hpp"
  77 #include "utilities/events.hpp"
  78 #include "utilities/resourceHash.hpp"
  79 #include "utilities/macros.hpp"
  80 #include "utilities/xmlstream.hpp"
  81 #ifdef COMPILER1
  82 #include "c1/c1_Runtime1.hpp"
  83 #endif
  84 #if INCLUDE_JFR
  85 #include "jfr/jfr.hpp"
  86 #endif
  87 

2234 }
2235 
2236 JRT_LEAF(void, SharedRuntime::reguard_yellow_pages())
2237   (void) JavaThread::current()->stack_overflow_state()->reguard_stack();
2238 JRT_END
2239 
2240 void SharedRuntime::monitor_enter_helper(oopDesc* obj, BasicLock* lock, JavaThread* current) {
2241   if (!SafepointSynchronize::is_synchronizing()) {
2242     // Only try quick_enter() if we're not trying to reach a safepoint
2243     // so that the calling thread reaches the safepoint more quickly.
2244     if (ObjectSynchronizer::quick_enter(obj, current, lock)) {
2245       return;
2246     }
2247   }
2248   // NO_ASYNC required because an async exception on the state transition destructor
2249   // would leave you with the lock held and it would never be released.
2250   // The normal monitorenter NullPointerException is thrown without acquiring a lock
2251   // and the model is that an exception implies the method failed.
2252   JRT_BLOCK_NO_ASYNC
2253   Handle h_obj(THREAD, obj);

2254   ObjectSynchronizer::enter(h_obj, lock, current);
2255   assert(!HAS_PENDING_EXCEPTION, "Should have no exception here");
2256   JRT_BLOCK_END
2257 }
2258 
2259 // Handles the uncommon case in locking, i.e., contention or an inflated lock.
2260 JRT_BLOCK_ENTRY(void, SharedRuntime::complete_monitor_locking_C(oopDesc* obj, BasicLock* lock, JavaThread* current))
2261   SharedRuntime::monitor_enter_helper(obj, lock, current);
2262 JRT_END
2263 








2264 void SharedRuntime::monitor_exit_helper(oopDesc* obj, BasicLock* lock, JavaThread* current) {
2265   assert(JavaThread::current() == current, "invariant");
2266   // Exit must be non-blocking, and therefore no exceptions can be thrown.
2267   ExceptionMark em(current);
2268   // The object could become unlocked through a JNI call, which we have no other checks for.
2269   // Give a fatal message if CheckJNICalls. Otherwise we ignore it.
2270   if (obj->is_unlocked()) {
2271     if (CheckJNICalls) {
2272       fatal("Object has been unlocked by JNI");
2273     }
2274     return;
2275   }
2276   ObjectSynchronizer::exit(obj, lock, current);
2277 }
2278 
2279 // Handles the uncommon cases of monitor unlocking in compiled code
2280 JRT_LEAF(void, SharedRuntime::complete_monitor_unlocking_C(oopDesc* obj, BasicLock* lock, JavaThread* current))
2281   assert(current == JavaThread::current(), "pre-condition");
2282   SharedRuntime::monitor_exit_helper(obj, lock, current);
2283 JRT_END

  48 #include "memory/universe.hpp"
  49 #include "metaprogramming/primitiveConversions.hpp"
  50 #include "oops/compiledICHolder.inline.hpp"
  51 #include "oops/klass.hpp"
  52 #include "oops/method.inline.hpp"
  53 #include "oops/objArrayKlass.hpp"
  54 #include "oops/oop.inline.hpp"
  55 #include "prims/forte.hpp"
  56 #include "prims/jvmtiExport.hpp"
  57 #include "prims/jvmtiThreadState.hpp"
  58 #include "prims/methodHandles.hpp"
  59 #include "prims/nativeLookup.hpp"
  60 #include "runtime/atomic.hpp"
  61 #include "runtime/frame.inline.hpp"
  62 #include "runtime/handles.inline.hpp"
  63 #include "runtime/init.hpp"
  64 #include "runtime/interfaceSupport.inline.hpp"
  65 #include "runtime/java.hpp"
  66 #include "runtime/javaCalls.hpp"
  67 #include "runtime/jniHandles.inline.hpp"
  68 #include "runtime/objectMonitor.inline.hpp"
  69 #include "runtime/sharedRuntime.hpp"
  70 #include "runtime/stackWatermarkSet.hpp"
  71 #include "runtime/stubRoutines.hpp"
  72 #include "runtime/synchronizer.hpp"
  73 #include "runtime/vframe.inline.hpp"
  74 #include "runtime/vframeArray.hpp"
  75 #include "runtime/vm_version.hpp"
  76 #include "utilities/copy.hpp"
  77 #include "utilities/dtrace.hpp"
  78 #include "utilities/events.hpp"
  79 #include "utilities/resourceHash.hpp"
  80 #include "utilities/macros.hpp"
  81 #include "utilities/xmlstream.hpp"
  82 #ifdef COMPILER1
  83 #include "c1/c1_Runtime1.hpp"
  84 #endif
  85 #if INCLUDE_JFR
  86 #include "jfr/jfr.hpp"
  87 #endif
  88 

2235 }
2236 
2237 JRT_LEAF(void, SharedRuntime::reguard_yellow_pages())
2238   (void) JavaThread::current()->stack_overflow_state()->reguard_stack();
2239 JRT_END
2240 
2241 void SharedRuntime::monitor_enter_helper(oopDesc* obj, BasicLock* lock, JavaThread* current) {
2242   if (!SafepointSynchronize::is_synchronizing()) {
2243     // Only try quick_enter() if we're not trying to reach a safepoint
2244     // so that the calling thread reaches the safepoint more quickly.
2245     if (ObjectSynchronizer::quick_enter(obj, current, lock)) {
2246       return;
2247     }
2248   }
2249   // NO_ASYNC required because an async exception on the state transition destructor
2250   // would leave you with the lock held and it would never be released.
2251   // The normal monitorenter NullPointerException is thrown without acquiring a lock
2252   // and the model is that an exception implies the method failed.
2253   JRT_BLOCK_NO_ASYNC
2254   Handle h_obj(THREAD, obj);
2255   ThreadOnMonitorEnter tme(current);
2256   ObjectSynchronizer::enter(h_obj, lock, current);
2257   assert(!HAS_PENDING_EXCEPTION, "Should have no exception here");
2258   JRT_BLOCK_END
2259 }
2260 
2261 // Handles the uncommon case in locking, i.e., contention or an inflated lock.
2262 JRT_BLOCK_ENTRY(void, SharedRuntime::complete_monitor_locking_C(oopDesc* obj, BasicLock* lock, JavaThread* current))
2263   SharedRuntime::monitor_enter_helper(obj, lock, current);
2264 JRT_END
2265 
2266 JRT_LEAF(void, SharedRuntime::redo_monitorenter(JavaThread* current, ObjectMonitor* monitor))
2267   assert(current == JavaThread::current(), "invariant");
2268   assert(!monitor->is_owner(current), "invariant");
2269 
2270   monitor->redo_enter(current);
2271   assert(monitor->is_owner(current) || current->preempting(), "invariant");
2272 JRT_END
2273 
2274 void SharedRuntime::monitor_exit_helper(oopDesc* obj, BasicLock* lock, JavaThread* current) {
2275   assert(JavaThread::current() == current, "invariant");
2276   // Exit must be non-blocking, and therefore no exceptions can be thrown.
2277   ExceptionMark em(current);
2278   // The object could become unlocked through a JNI call, which we have no other checks for.
2279   // Give a fatal message if CheckJNICalls. Otherwise we ignore it.
2280   if (obj->is_unlocked()) {
2281     if (CheckJNICalls) {
2282       fatal("Object has been unlocked by JNI");
2283     }
2284     return;
2285   }
2286   ObjectSynchronizer::exit(obj, lock, current);
2287 }
2288 
2289 // Handles the uncommon cases of monitor unlocking in compiled code
2290 JRT_LEAF(void, SharedRuntime::complete_monitor_unlocking_C(oopDesc* obj, BasicLock* lock, JavaThread* current))
2291   assert(current == JavaThread::current(), "pre-condition");
2292   SharedRuntime::monitor_exit_helper(obj, lock, current);
2293 JRT_END
< prev index next >