48 #include "memory/universe.hpp"
49 #include "metaprogramming/primitiveConversions.hpp"
50 #include "oops/klass.hpp"
51 #include "oops/method.inline.hpp"
52 #include "oops/objArrayKlass.hpp"
53 #include "oops/oop.inline.hpp"
54 #include "prims/forte.hpp"
55 #include "prims/jvmtiExport.hpp"
56 #include "prims/jvmtiThreadState.hpp"
57 #include "prims/methodHandles.hpp"
58 #include "prims/nativeLookup.hpp"
59 #include "runtime/arguments.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/perfData.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
89 // Shared stub locations
90 RuntimeStub* SharedRuntime::_wrong_method_blob;
91 RuntimeStub* SharedRuntime::_wrong_method_abstract_blob;
92 RuntimeStub* SharedRuntime::_ic_miss_blob;
93 RuntimeStub* SharedRuntime::_resolve_opt_virtual_call_blob;
94 RuntimeStub* SharedRuntime::_resolve_virtual_call_blob;
95 RuntimeStub* SharedRuntime::_resolve_static_call_blob;
96 address SharedRuntime::_resolve_static_call_entry;
97
98 DeoptimizationBlob* SharedRuntime::_deopt_blob;
99 SafepointBlob* SharedRuntime::_polling_page_vectors_safepoint_handler_blob;
100 SafepointBlob* SharedRuntime::_polling_page_safepoint_handler_blob;
101 SafepointBlob* SharedRuntime::_polling_page_return_handler_blob;
102
103 #ifdef COMPILER2
104 UncommonTrapBlob* SharedRuntime::_uncommon_trap_blob;
105 #endif // COMPILER2
106
107 nmethod* SharedRuntime::_cont_doYield_stub;
108
109 //----------------------------generate_stubs-----------------------------------
110 void SharedRuntime::generate_stubs() {
111 _wrong_method_blob = generate_resolve_blob(CAST_FROM_FN_PTR(address, SharedRuntime::handle_wrong_method), "wrong_method_stub");
112 _wrong_method_abstract_blob = generate_resolve_blob(CAST_FROM_FN_PTR(address, SharedRuntime::handle_wrong_method_abstract), "wrong_method_abstract_stub");
113 _ic_miss_blob = generate_resolve_blob(CAST_FROM_FN_PTR(address, SharedRuntime::handle_wrong_method_ic_miss), "ic_miss_stub");
114 _resolve_opt_virtual_call_blob = generate_resolve_blob(CAST_FROM_FN_PTR(address, SharedRuntime::resolve_opt_virtual_call_C), "resolve_opt_virtual_call");
115 _resolve_virtual_call_blob = generate_resolve_blob(CAST_FROM_FN_PTR(address, SharedRuntime::resolve_virtual_call_C), "resolve_virtual_call");
116 _resolve_static_call_blob = generate_resolve_blob(CAST_FROM_FN_PTR(address, SharedRuntime::resolve_static_call_C), "resolve_static_call");
1884 }
1885
1886 JRT_LEAF(void, SharedRuntime::reguard_yellow_pages())
1887 (void) JavaThread::current()->stack_overflow_state()->reguard_stack();
1888 JRT_END
1889
1890 void SharedRuntime::monitor_enter_helper(oopDesc* obj, BasicLock* lock, JavaThread* current) {
1891 if (!SafepointSynchronize::is_synchronizing()) {
1892 // Only try quick_enter() if we're not trying to reach a safepoint
1893 // so that the calling thread reaches the safepoint more quickly.
1894 if (ObjectSynchronizer::quick_enter(obj, current, lock)) {
1895 return;
1896 }
1897 }
1898 // NO_ASYNC required because an async exception on the state transition destructor
1899 // would leave you with the lock held and it would never be released.
1900 // The normal monitorenter NullPointerException is thrown without acquiring a lock
1901 // and the model is that an exception implies the method failed.
1902 JRT_BLOCK_NO_ASYNC
1903 Handle h_obj(THREAD, obj);
1904 ObjectSynchronizer::enter(h_obj, lock, current);
1905 assert(!HAS_PENDING_EXCEPTION, "Should have no exception here");
1906 JRT_BLOCK_END
1907 }
1908
1909 // Handles the uncommon case in locking, i.e., contention or an inflated lock.
1910 JRT_BLOCK_ENTRY(void, SharedRuntime::complete_monitor_locking_C(oopDesc* obj, BasicLock* lock, JavaThread* current))
1911 SharedRuntime::monitor_enter_helper(obj, lock, current);
1912 JRT_END
1913
1914 void SharedRuntime::monitor_exit_helper(oopDesc* obj, BasicLock* lock, JavaThread* current) {
1915 assert(JavaThread::current() == current, "invariant");
1916 // Exit must be non-blocking, and therefore no exceptions can be thrown.
1917 ExceptionMark em(current);
1918 // The object could become unlocked through a JNI call, which we have no other checks for.
1919 // Give a fatal message if CheckJNICalls. Otherwise we ignore it.
1920 if (obj->is_unlocked()) {
1921 if (CheckJNICalls) {
1922 fatal("Object has been unlocked by JNI");
1923 }
1924 return;
1925 }
1926 ObjectSynchronizer::exit(obj, lock, current);
1927 }
1928
1929 // Handles the uncommon cases of monitor unlocking in compiled code
1930 JRT_LEAF(void, SharedRuntime::complete_monitor_unlocking_C(oopDesc* obj, BasicLock* lock, JavaThread* current))
1931 assert(current == JavaThread::current(), "pre-condition");
1932 SharedRuntime::monitor_exit_helper(obj, lock, current);
1933 JRT_END
|
48 #include "memory/universe.hpp"
49 #include "metaprogramming/primitiveConversions.hpp"
50 #include "oops/klass.hpp"
51 #include "oops/method.inline.hpp"
52 #include "oops/objArrayKlass.hpp"
53 #include "oops/oop.inline.hpp"
54 #include "prims/forte.hpp"
55 #include "prims/jvmtiExport.hpp"
56 #include "prims/jvmtiThreadState.hpp"
57 #include "prims/methodHandles.hpp"
58 #include "prims/nativeLookup.hpp"
59 #include "runtime/arguments.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/perfData.hpp"
70 #include "runtime/sharedRuntime.hpp"
71 #include "runtime/stackWatermarkSet.hpp"
72 #include "runtime/stubRoutines.hpp"
73 #include "runtime/synchronizer.hpp"
74 #include "runtime/vframe.inline.hpp"
75 #include "runtime/vframeArray.hpp"
76 #include "runtime/vm_version.hpp"
77 #include "utilities/copy.hpp"
78 #include "utilities/dtrace.hpp"
79 #include "utilities/events.hpp"
80 #include "utilities/resourceHash.hpp"
81 #include "utilities/macros.hpp"
82 #include "utilities/xmlstream.hpp"
83 #ifdef COMPILER1
84 #include "c1/c1_Runtime1.hpp"
85 #endif
86 #if INCLUDE_JFR
87 #include "jfr/jfr.hpp"
88 #endif
89
90 // Shared stub locations
91 RuntimeStub* SharedRuntime::_wrong_method_blob;
92 RuntimeStub* SharedRuntime::_wrong_method_abstract_blob;
93 RuntimeStub* SharedRuntime::_ic_miss_blob;
94 RuntimeStub* SharedRuntime::_resolve_opt_virtual_call_blob;
95 RuntimeStub* SharedRuntime::_resolve_virtual_call_blob;
96 RuntimeStub* SharedRuntime::_resolve_static_call_blob;
97 address SharedRuntime::_resolve_static_call_entry;
98 address SharedRuntime::_native_frame_resume_entry = nullptr;
99
100 DeoptimizationBlob* SharedRuntime::_deopt_blob;
101 SafepointBlob* SharedRuntime::_polling_page_vectors_safepoint_handler_blob;
102 SafepointBlob* SharedRuntime::_polling_page_safepoint_handler_blob;
103 SafepointBlob* SharedRuntime::_polling_page_return_handler_blob;
104
105 #ifdef COMPILER2
106 UncommonTrapBlob* SharedRuntime::_uncommon_trap_blob;
107 #endif // COMPILER2
108
109 nmethod* SharedRuntime::_cont_doYield_stub;
110
111 //----------------------------generate_stubs-----------------------------------
112 void SharedRuntime::generate_stubs() {
113 _wrong_method_blob = generate_resolve_blob(CAST_FROM_FN_PTR(address, SharedRuntime::handle_wrong_method), "wrong_method_stub");
114 _wrong_method_abstract_blob = generate_resolve_blob(CAST_FROM_FN_PTR(address, SharedRuntime::handle_wrong_method_abstract), "wrong_method_abstract_stub");
115 _ic_miss_blob = generate_resolve_blob(CAST_FROM_FN_PTR(address, SharedRuntime::handle_wrong_method_ic_miss), "ic_miss_stub");
116 _resolve_opt_virtual_call_blob = generate_resolve_blob(CAST_FROM_FN_PTR(address, SharedRuntime::resolve_opt_virtual_call_C), "resolve_opt_virtual_call");
117 _resolve_virtual_call_blob = generate_resolve_blob(CAST_FROM_FN_PTR(address, SharedRuntime::resolve_virtual_call_C), "resolve_virtual_call");
118 _resolve_static_call_blob = generate_resolve_blob(CAST_FROM_FN_PTR(address, SharedRuntime::resolve_static_call_C), "resolve_static_call");
1886 }
1887
1888 JRT_LEAF(void, SharedRuntime::reguard_yellow_pages())
1889 (void) JavaThread::current()->stack_overflow_state()->reguard_stack();
1890 JRT_END
1891
1892 void SharedRuntime::monitor_enter_helper(oopDesc* obj, BasicLock* lock, JavaThread* current) {
1893 if (!SafepointSynchronize::is_synchronizing()) {
1894 // Only try quick_enter() if we're not trying to reach a safepoint
1895 // so that the calling thread reaches the safepoint more quickly.
1896 if (ObjectSynchronizer::quick_enter(obj, current, lock)) {
1897 return;
1898 }
1899 }
1900 // NO_ASYNC required because an async exception on the state transition destructor
1901 // would leave you with the lock held and it would never be released.
1902 // The normal monitorenter NullPointerException is thrown without acquiring a lock
1903 // and the model is that an exception implies the method failed.
1904 JRT_BLOCK_NO_ASYNC
1905 Handle h_obj(THREAD, obj);
1906 ThreadOnMonitorEnter tme(current);
1907 ObjectSynchronizer::enter(h_obj, lock, current);
1908 assert(!HAS_PENDING_EXCEPTION, "Should have no exception here");
1909 JRT_BLOCK_END
1910 }
1911
1912 // Handles the uncommon case in locking, i.e., contention or an inflated lock.
1913 JRT_BLOCK_ENTRY(void, SharedRuntime::complete_monitor_locking_C(oopDesc* obj, BasicLock* lock, JavaThread* current))
1914 SharedRuntime::monitor_enter_helper(obj, lock, current);
1915 JRT_END
1916
1917 JRT_BLOCK_ENTRY(void, SharedRuntime::resume_monitor_operation(JavaThread* current, ObjectWaiter* node))
1918 assert(current == JavaThread::current(), "invariant");
1919 ObjectMonitor* monitor = node->monitor();
1920 assert(!monitor->is_owner(current), "invariant");
1921
1922 monitor->resume_operation(current, node);
1923 assert(monitor->is_owner(current) || current->preempting(), "invariant");
1924 JRT_END
1925
1926 void SharedRuntime::monitor_exit_helper(oopDesc* obj, BasicLock* lock, JavaThread* current) {
1927 assert(JavaThread::current() == current, "invariant");
1928 // Exit must be non-blocking, and therefore no exceptions can be thrown.
1929 ExceptionMark em(current);
1930 // The object could become unlocked through a JNI call, which we have no other checks for.
1931 // Give a fatal message if CheckJNICalls. Otherwise we ignore it.
1932 if (obj->is_unlocked()) {
1933 if (CheckJNICalls) {
1934 fatal("Object has been unlocked by JNI");
1935 }
1936 return;
1937 }
1938 ObjectSynchronizer::exit(obj, lock, current);
1939 }
1940
1941 // Handles the uncommon cases of monitor unlocking in compiled code
1942 JRT_LEAF(void, SharedRuntime::complete_monitor_unlocking_C(oopDesc* obj, BasicLock* lock, JavaThread* current))
1943 assert(current == JavaThread::current(), "pre-condition");
1944 SharedRuntime::monitor_exit_helper(obj, lock, current);
1945 JRT_END
|