46 #include "memory/resourceArea.hpp"
47 #include "memory/universe.hpp"
48 #include "metaprogramming/primitiveConversions.hpp"
49 #include "oops/klass.hpp"
50 #include "oops/method.inline.hpp"
51 #include "oops/objArrayKlass.hpp"
52 #include "oops/oop.inline.hpp"
53 #include "prims/forte.hpp"
54 #include "prims/jvmtiExport.hpp"
55 #include "prims/jvmtiThreadState.hpp"
56 #include "prims/methodHandles.hpp"
57 #include "prims/nativeLookup.hpp"
58 #include "runtime/atomic.hpp"
59 #include "runtime/frame.inline.hpp"
60 #include "runtime/handles.inline.hpp"
61 #include "runtime/init.hpp"
62 #include "runtime/interfaceSupport.inline.hpp"
63 #include "runtime/java.hpp"
64 #include "runtime/javaCalls.hpp"
65 #include "runtime/jniHandles.inline.hpp"
66 #include "runtime/sharedRuntime.hpp"
67 #include "runtime/stackWatermarkSet.hpp"
68 #include "runtime/stubRoutines.hpp"
69 #include "runtime/synchronizer.hpp"
70 #include "runtime/vframe.inline.hpp"
71 #include "runtime/vframeArray.hpp"
72 #include "runtime/vm_version.hpp"
73 #include "utilities/copy.hpp"
74 #include "utilities/dtrace.hpp"
75 #include "utilities/events.hpp"
76 #include "utilities/resourceHash.hpp"
77 #include "utilities/macros.hpp"
78 #include "utilities/xmlstream.hpp"
79 #ifdef COMPILER1
80 #include "c1/c1_Runtime1.hpp"
81 #endif
82 #if INCLUDE_JFR
83 #include "jfr/jfr.hpp"
84 #endif
85
1902 }
1903
1904 JRT_LEAF(void, SharedRuntime::reguard_yellow_pages())
1905 (void) JavaThread::current()->stack_overflow_state()->reguard_stack();
1906 JRT_END
1907
1908 void SharedRuntime::monitor_enter_helper(oopDesc* obj, BasicLock* lock, JavaThread* current) {
1909 if (!SafepointSynchronize::is_synchronizing()) {
1910 // Only try quick_enter() if we're not trying to reach a safepoint
1911 // so that the calling thread reaches the safepoint more quickly.
1912 if (ObjectSynchronizer::quick_enter(obj, current, lock)) {
1913 return;
1914 }
1915 }
1916 // NO_ASYNC required because an async exception on the state transition destructor
1917 // would leave you with the lock held and it would never be released.
1918 // The normal monitorenter NullPointerException is thrown without acquiring a lock
1919 // and the model is that an exception implies the method failed.
1920 JRT_BLOCK_NO_ASYNC
1921 Handle h_obj(THREAD, obj);
1922 ObjectSynchronizer::enter(h_obj, lock, current);
1923 assert(!HAS_PENDING_EXCEPTION, "Should have no exception here");
1924 JRT_BLOCK_END
1925 }
1926
1927 // Handles the uncommon case in locking, i.e., contention or an inflated lock.
1928 JRT_BLOCK_ENTRY(void, SharedRuntime::complete_monitor_locking_C(oopDesc* obj, BasicLock* lock, JavaThread* current))
1929 SharedRuntime::monitor_enter_helper(obj, lock, current);
1930 JRT_END
1931
1932 void SharedRuntime::monitor_exit_helper(oopDesc* obj, BasicLock* lock, JavaThread* current) {
1933 assert(JavaThread::current() == current, "invariant");
1934 // Exit must be non-blocking, and therefore no exceptions can be thrown.
1935 ExceptionMark em(current);
1936 // The object could become unlocked through a JNI call, which we have no other checks for.
1937 // Give a fatal message if CheckJNICalls. Otherwise we ignore it.
1938 if (obj->is_unlocked()) {
1939 if (CheckJNICalls) {
1940 fatal("Object has been unlocked by JNI");
1941 }
1942 return;
1943 }
1944 ObjectSynchronizer::exit(obj, lock, current);
1945 }
1946
1947 // Handles the uncommon cases of monitor unlocking in compiled code
1948 JRT_LEAF(void, SharedRuntime::complete_monitor_unlocking_C(oopDesc* obj, BasicLock* lock, JavaThread* current))
1949 assert(current == JavaThread::current(), "pre-condition");
1950 SharedRuntime::monitor_exit_helper(obj, lock, current);
1951 JRT_END
|
46 #include "memory/resourceArea.hpp"
47 #include "memory/universe.hpp"
48 #include "metaprogramming/primitiveConversions.hpp"
49 #include "oops/klass.hpp"
50 #include "oops/method.inline.hpp"
51 #include "oops/objArrayKlass.hpp"
52 #include "oops/oop.inline.hpp"
53 #include "prims/forte.hpp"
54 #include "prims/jvmtiExport.hpp"
55 #include "prims/jvmtiThreadState.hpp"
56 #include "prims/methodHandles.hpp"
57 #include "prims/nativeLookup.hpp"
58 #include "runtime/atomic.hpp"
59 #include "runtime/frame.inline.hpp"
60 #include "runtime/handles.inline.hpp"
61 #include "runtime/init.hpp"
62 #include "runtime/interfaceSupport.inline.hpp"
63 #include "runtime/java.hpp"
64 #include "runtime/javaCalls.hpp"
65 #include "runtime/jniHandles.inline.hpp"
66 #include "runtime/objectMonitor.inline.hpp"
67 #include "runtime/sharedRuntime.hpp"
68 #include "runtime/stackWatermarkSet.hpp"
69 #include "runtime/stubRoutines.hpp"
70 #include "runtime/synchronizer.hpp"
71 #include "runtime/vframe.inline.hpp"
72 #include "runtime/vframeArray.hpp"
73 #include "runtime/vm_version.hpp"
74 #include "utilities/copy.hpp"
75 #include "utilities/dtrace.hpp"
76 #include "utilities/events.hpp"
77 #include "utilities/resourceHash.hpp"
78 #include "utilities/macros.hpp"
79 #include "utilities/xmlstream.hpp"
80 #ifdef COMPILER1
81 #include "c1/c1_Runtime1.hpp"
82 #endif
83 #if INCLUDE_JFR
84 #include "jfr/jfr.hpp"
85 #endif
86
1903 }
1904
1905 JRT_LEAF(void, SharedRuntime::reguard_yellow_pages())
1906 (void) JavaThread::current()->stack_overflow_state()->reguard_stack();
1907 JRT_END
1908
1909 void SharedRuntime::monitor_enter_helper(oopDesc* obj, BasicLock* lock, JavaThread* current) {
1910 if (!SafepointSynchronize::is_synchronizing()) {
1911 // Only try quick_enter() if we're not trying to reach a safepoint
1912 // so that the calling thread reaches the safepoint more quickly.
1913 if (ObjectSynchronizer::quick_enter(obj, current, lock)) {
1914 return;
1915 }
1916 }
1917 // NO_ASYNC required because an async exception on the state transition destructor
1918 // would leave you with the lock held and it would never be released.
1919 // The normal monitorenter NullPointerException is thrown without acquiring a lock
1920 // and the model is that an exception implies the method failed.
1921 JRT_BLOCK_NO_ASYNC
1922 Handle h_obj(THREAD, obj);
1923 ThreadOnMonitorEnter tme(current);
1924 ObjectSynchronizer::enter(h_obj, lock, current);
1925 assert(!HAS_PENDING_EXCEPTION, "Should have no exception here");
1926 JRT_BLOCK_END
1927 }
1928
1929 // Handles the uncommon case in locking, i.e., contention or an inflated lock.
1930 JRT_BLOCK_ENTRY(void, SharedRuntime::complete_monitor_locking_C(oopDesc* obj, BasicLock* lock, JavaThread* current))
1931 SharedRuntime::monitor_enter_helper(obj, lock, current);
1932 JRT_END
1933
1934 JRT_LEAF(void, SharedRuntime::redo_monitorenter(JavaThread* current, ObjectMonitor* monitor))
1935 assert(current == JavaThread::current(), "invariant");
1936 assert(!monitor->is_owner(current), "invariant");
1937
1938 monitor->redo_enter(current);
1939 assert(monitor->is_owner(current) || current->preempting(), "invariant");
1940 JRT_END
1941
1942 void SharedRuntime::monitor_exit_helper(oopDesc* obj, BasicLock* lock, JavaThread* current) {
1943 assert(JavaThread::current() == current, "invariant");
1944 // Exit must be non-blocking, and therefore no exceptions can be thrown.
1945 ExceptionMark em(current);
1946 // The object could become unlocked through a JNI call, which we have no other checks for.
1947 // Give a fatal message if CheckJNICalls. Otherwise we ignore it.
1948 if (obj->is_unlocked()) {
1949 if (CheckJNICalls) {
1950 fatal("Object has been unlocked by JNI");
1951 }
1952 return;
1953 }
1954 ObjectSynchronizer::exit(obj, lock, current);
1955 }
1956
1957 // Handles the uncommon cases of monitor unlocking in compiled code
1958 JRT_LEAF(void, SharedRuntime::complete_monitor_unlocking_C(oopDesc* obj, BasicLock* lock, JavaThread* current))
1959 assert(current == JavaThread::current(), "pre-condition");
1960 SharedRuntime::monitor_exit_helper(obj, lock, current);
1961 JRT_END
|