< prev index next >

src/hotspot/share/runtime/interfaceSupport.inline.hpp

Print this page

 18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 19  *
 20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 21  * or visit www.oracle.com if you need additional information or have any
 22  * questions.
 23  *
 24  */
 25 
 26 #ifndef SHARE_RUNTIME_INTERFACESUPPORT_INLINE_HPP
 27 #define SHARE_RUNTIME_INTERFACESUPPORT_INLINE_HPP
 28 
 29 // No interfaceSupport.hpp
 30 
 31 #include "gc/shared/gc_globals.hpp"
 32 #include "runtime/globals.hpp"
 33 #include "runtime/handles.inline.hpp"
 34 #include "runtime/javaThread.inline.hpp"
 35 #include "runtime/mutexLocker.hpp"
 36 #include "runtime/orderAccess.hpp"
 37 #include "runtime/os.hpp"

 38 #include "runtime/safepointMechanism.inline.hpp"
 39 #include "runtime/safepointVerifiers.hpp"
 40 #include "runtime/threadWXSetters.inline.hpp"
 41 #include "runtime/vmOperations.hpp"
 42 #include "utilities/globalDefinitions.hpp"
 43 #include "utilities/macros.hpp"
 44 #include "utilities/preserveException.hpp"
 45 
 46 // Wrapper for all entry points to the virtual machine.
 47 
 48 // InterfaceSupport provides functionality used by the VM_LEAF_BASE and
 49 // VM_ENTRY_BASE macros. These macros are used to guard entry points into
 50 // the VM and perform checks upon leave of the VM.
 51 
 52 
 53 class InterfaceSupport: AllStatic {
 54 # ifdef ASSERT
 55  public:
 56   static unsigned int _scavenge_alot_counter;
 57   static unsigned int _fullgc_alot_counter;

329     MACOS_AARCH64_ONLY(                                              \
330       static WXMode wx_mode = DefaultWXWriteMode;                    \
331       ThreadWXEnable __wx(&wx_mode, current);                        \
332     )                                                                \
333     HandleMarkCleaner __hm(current);
334 
335 #define JRT_BLOCK                                                    \
336     {                                                                \
337     assert(current == JavaThread::current(), "Must be");             \
338     ThreadInVMfromJava __tiv(current);                               \
339     JavaThread* THREAD = current; /* For exception macros. */        \
340     DEBUG_ONLY(VMEntryWrapper __vew;)
341 
342 #define JRT_BLOCK_NO_ASYNC                                           \
343     {                                                                \
344     assert(current == JavaThread::current(), "Must be");             \
345     ThreadInVMfromJava __tiv(current, false /* check asyncs */);     \
346     JavaThread* THREAD = current; /* For exception macros. */        \
347     DEBUG_ONLY(VMEntryWrapper __vew;)
348 
349 #define JRT_BLOCK_END }










350 




















































351 #define JRT_END }

352 
353 // Definitions for JNI
354 //
355 // As the JNIEnv can be passed from external native code we validate
356 // it in debug builds, primarily for our own testing. In general JNI
357 // does not attempt to detect programming errors and a bad JNIEnv may
358 // not even be readable.
359 
360 #define JNI_ENTRY(result_type, header)                               \
361     JNI_ENTRY_NO_PRESERVE(result_type, header)                       \
362     WeakPreserveExceptionMark __wem(thread);
363 
364 #define JNI_ENTRY_NO_PRESERVE(result_type, header)                   \
365 extern "C" {                                                         \
366   result_type JNICALL header {                                       \
367     JavaThread* thread=JavaThread::thread_from_jni_environment(env); \
368     assert(thread == Thread::current(), "JNIEnv is only valid in same thread"); \
369     ThreadInVMfromNative __tiv(thread);                              \
370     MACOS_AARCH64_ONLY(                                              \
371       static WXMode wx_mode = DefaultWXWriteMode;                    \

406 #define JVM_ENTRY_NO_ENV(result_type, header)                        \
407 extern "C" {                                                         \
408   result_type JNICALL header {                                       \
409     JavaThread* thread = JavaThread::current();                      \
410     ThreadInVMfromNative __tiv(thread);                              \
411     MACOS_AARCH64_ONLY(                                              \
412       static WXMode wx_mode = DefaultWXWriteMode;                    \
413       ThreadWXEnable __wx(&wx_mode, thread);                         \
414     )                                                                \
415     DEBUG_ONLY(VMNativeEntryWrapper __vew;)                          \
416     VM_ENTRY_BASE(result_type, header, thread)
417 
418 
419 #define JVM_LEAF(result_type, header)                                \
420 extern "C" {                                                         \
421   result_type JNICALL header {                                       \
422     VM_Exit::block_if_vm_exited();                                   \
423     VM_LEAF_BASE(result_type, header)
424 
425 




































426 #define JVM_END } }
427 
428 #endif // SHARE_RUNTIME_INTERFACESUPPORT_INLINE_HPP

 18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 19  *
 20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 21  * or visit www.oracle.com if you need additional information or have any
 22  * questions.
 23  *
 24  */
 25 
 26 #ifndef SHARE_RUNTIME_INTERFACESUPPORT_INLINE_HPP
 27 #define SHARE_RUNTIME_INTERFACESUPPORT_INLINE_HPP
 28 
 29 // No interfaceSupport.hpp
 30 
 31 #include "gc/shared/gc_globals.hpp"
 32 #include "runtime/globals.hpp"
 33 #include "runtime/handles.inline.hpp"
 34 #include "runtime/javaThread.inline.hpp"
 35 #include "runtime/mutexLocker.hpp"
 36 #include "runtime/orderAccess.hpp"
 37 #include "runtime/os.hpp"
 38 #include "runtime/perfData.hpp"
 39 #include "runtime/safepointMechanism.inline.hpp"
 40 #include "runtime/safepointVerifiers.hpp"
 41 #include "runtime/threadWXSetters.inline.hpp"
 42 #include "runtime/vmOperations.hpp"
 43 #include "utilities/globalDefinitions.hpp"
 44 #include "utilities/macros.hpp"
 45 #include "utilities/preserveException.hpp"
 46 
 47 // Wrapper for all entry points to the virtual machine.
 48 
 49 // InterfaceSupport provides functionality used by the VM_LEAF_BASE and
 50 // VM_ENTRY_BASE macros. These macros are used to guard entry points into
 51 // the VM and perform checks upon leave of the VM.
 52 
 53 
 54 class InterfaceSupport: AllStatic {
 55 # ifdef ASSERT
 56  public:
 57   static unsigned int _scavenge_alot_counter;
 58   static unsigned int _fullgc_alot_counter;

330     MACOS_AARCH64_ONLY(                                              \
331       static WXMode wx_mode = DefaultWXWriteMode;                    \
332       ThreadWXEnable __wx(&wx_mode, current);                        \
333     )                                                                \
334     HandleMarkCleaner __hm(current);
335 
336 #define JRT_BLOCK                                                    \
337     {                                                                \
338     assert(current == JavaThread::current(), "Must be");             \
339     ThreadInVMfromJava __tiv(current);                               \
340     JavaThread* THREAD = current; /* For exception macros. */        \
341     DEBUG_ONLY(VMEntryWrapper __vew;)
342 
343 #define JRT_BLOCK_NO_ASYNC                                           \
344     {                                                                \
345     assert(current == JavaThread::current(), "Must be");             \
346     ThreadInVMfromJava __tiv(current, false /* check asyncs */);     \
347     JavaThread* THREAD = current; /* For exception macros. */        \
348     DEBUG_ONLY(VMEntryWrapper __vew;)
349 
350 #define JRT_ENTRY_PROF(result_type, sub, name, header)               \
351   PerfTickCounters* _perf_##sub##_##name##_timer = nullptr;          \
352   PerfCounter* _perf_##sub##_##name##_count = nullptr;               \
353   result_type header {                                               \
354     assert(current == JavaThread::current(), "Must be");             \
355     PerfTraceTimedEvent perf_##sub##_##name(_perf_##sub##_##name##_timer, _perf_##sub##_##name##_count, current->do_profile_rt_call()); \
356     ProfileVMCallContext pctx(current, &(perf_##sub##_##name), current->do_profile_rt_call()); \
357     MACOS_AARCH64_ONLY(ThreadWXEnable __wx(WXWrite, current));       \
358     ThreadInVMfromJava __tiv(current);                               \
359     VM_ENTRY_BASE(result_type, header, current)                      \
360     DEBUG_ONLY(VMEntryWrapper __vew;)
361 
362 #define JRT_LEAF_PROF(result_type, sub, name, header)                \
363   PerfTickCounters* _perf_##sub##_##name##_timer = nullptr;          \
364   PerfCounter* _perf_##sub##_##name##_count = nullptr;               \
365   result_type header {                                               \
366     PerfTraceTimedEvent perf_##sub##_##name(_perf_##sub##_##name##_timer, _perf_##sub##_##name##_count, \
367                                             current->do_profile_rt_call()); \
368     ProfileVMCallContext pctx(current, &(perf_##sub##_##name), current->do_profile_rt_call()); \
369     VM_LEAF_BASE(result_type, header)                                \
370     DEBUG_ONLY(NoSafepointVerifier __nsv;)
371 
372 #define JRT_LEAF_PROF_NO_THREAD(result_type, sub, name, header)      \
373   PerfTickCounters* _perf_##sub##_##name##_timer = nullptr;          \
374   PerfCounter* _perf_##sub##_##name##_count = nullptr;               \
375   result_type header {                                               \
376     Thread* current = Thread::current();                             \
377     PerfTraceTimedEvent perf_##sub##_##name(_perf_##sub##_##name##_timer, _perf_##sub##_##name##_count, \
378                                             current->do_profile_rt_call()); \
379     ProfileVMCallContext pctx(current, &(perf_##sub##_##name), current->do_profile_rt_call()); \
380     VM_LEAF_BASE(result_type, header)                                \
381     DEBUG_ONLY(NoSafepointVerifier __nsv;)
382 
383 #define JRT_ENTRY_NO_ASYNC_PROF(result_type, sub, name, header)      \
384   PerfTickCounters* _perf_##sub##_##name##_timer = nullptr;          \
385   PerfCounter* _perf_##sub##_##name##_count = nullptr;               \
386   result_type header {                                               \
387     assert(current == JavaThread::current(), "Must be");             \
388     PerfTraceTimedEvent perf_##sub##_##name(_perf_##sub##_##name##_timer, _perf_##sub##_##name##_count, current->do_profile_rt_call()); \
389     ProfileVMCallContext pctx(current, &(perf_##sub##_##name), current->do_profile_rt_call()); \
390     MACOS_AARCH64_ONLY(ThreadWXEnable __wx(WXWrite, current));       \
391     ThreadInVMfromJava __tiv(current, false /* check asyncs */);     \
392     VM_ENTRY_BASE(result_type, header, current)                      \
393     DEBUG_ONLY(VMEntryWrapper __vew;)
394 
395 #define JRT_BLOCK_ENTRY_PROF(result_type, sub, name, header)         \
396   PerfTickCounters* _perf_##sub##_##name##_timer = nullptr;          \
397   PerfCounter* _perf_##sub##_##name##_count = nullptr;               \
398   result_type header {                                               \
399     assert(current == JavaThread::current(), "Must be");             \
400     PerfTraceTimedEvent perf_##sub##_##name(_perf_##sub##_##name##_timer, _perf_##sub##_##name##_count, current->do_profile_rt_call()); \
401     ProfileVMCallContext pctx(current, &(perf_##sub##_##name), current->do_profile_rt_call()); \
402     MACOS_AARCH64_ONLY(ThreadWXEnable __wx(WXWrite, current));       \
403     HandleMarkCleaner __hm(current);
404 
405 #define PROF_ENTRY(result_type, sub, name, header)                   \
406   PerfTickCounters* _perf_##sub##_##name##_timer = nullptr;          \
407   PerfCounter* _perf_##sub##_##name##_count = nullptr;               \
408   result_type header {                                               \
409     assert(current == JavaThread::current(), "must be");             \
410     PerfTraceTimedEvent perf_##sub##_##name(_perf_##sub##_##name##_timer, _perf_##sub##_##name##_count, current->do_profile_rt_call()); \
411     ProfileVMCallContext pctx(current, &(perf_##sub##_##name), current->do_profile_rt_call());
412 
413 #define JRT_BLOCK_END }
414 #define JRT_END }
415 #define PROF_END }
416 
417 // Definitions for JNI
418 //
419 // As the JNIEnv can be passed from external native code we validate
420 // it in debug builds, primarily for our own testing. In general JNI
421 // does not attempt to detect programming errors and a bad JNIEnv may
422 // not even be readable.
423 
424 #define JNI_ENTRY(result_type, header)                               \
425     JNI_ENTRY_NO_PRESERVE(result_type, header)                       \
426     WeakPreserveExceptionMark __wem(thread);
427 
428 #define JNI_ENTRY_NO_PRESERVE(result_type, header)                   \
429 extern "C" {                                                         \
430   result_type JNICALL header {                                       \
431     JavaThread* thread=JavaThread::thread_from_jni_environment(env); \
432     assert(thread == Thread::current(), "JNIEnv is only valid in same thread"); \
433     ThreadInVMfromNative __tiv(thread);                              \
434     MACOS_AARCH64_ONLY(                                              \
435       static WXMode wx_mode = DefaultWXWriteMode;                    \

470 #define JVM_ENTRY_NO_ENV(result_type, header)                        \
471 extern "C" {                                                         \
472   result_type JNICALL header {                                       \
473     JavaThread* thread = JavaThread::current();                      \
474     ThreadInVMfromNative __tiv(thread);                              \
475     MACOS_AARCH64_ONLY(                                              \
476       static WXMode wx_mode = DefaultWXWriteMode;                    \
477       ThreadWXEnable __wx(&wx_mode, thread);                         \
478     )                                                                \
479     DEBUG_ONLY(VMNativeEntryWrapper __vew;)                          \
480     VM_ENTRY_BASE(result_type, header, thread)
481 
482 
483 #define JVM_LEAF(result_type, header)                                \
484 extern "C" {                                                         \
485   result_type JNICALL header {                                       \
486     VM_Exit::block_if_vm_exited();                                   \
487     VM_LEAF_BASE(result_type, header)
488 
489 
490 #define JVM_ENTRY_PROF(result_type, name, header)                    \
491   PerfTickCounters* _perf_##name##_timer = nullptr;                  \
492   PerfCounter* _perf_##name##_count = nullptr;                       \
493 extern "C" {                                                         \
494   result_type JNICALL header {                                       \
495     JavaThread* thread=JavaThread::thread_from_jni_environment(env); \
496     PerfTraceTimedEvent perf_##name(_perf_##name##_timer, _perf_##name##_count, thread->profile_vm_calls()); \
497     MACOS_AARCH64_ONLY(ThreadWXEnable __wx(WXWrite, thread));        \
498     ThreadInVMfromNative __tiv(thread);                              \
499     DEBUG_ONLY(VMNativeEntryWrapper __vew;)                          \
500     VM_ENTRY_BASE(result_type, header, thread)
501 
502 
503 #define JVM_ENTRY_NO_ENV_PROF(result_type, name, header)             \
504   PerfTickCounters* _perf_##name##_timer = nullptr;                  \
505   PerfCounter* _perf_##name##_count = nullptr;                       \
506 extern "C" {                                                         \
507   result_type JNICALL header {                                       \
508     JavaThread* thread = JavaThread::current();                      \
509     PerfTraceTimedEvent perf_##name(_perf_##name##_timer, _perf_##name##_count, thread->profile_vm_calls()); \
510     MACOS_AARCH64_ONLY(ThreadWXEnable __wx(WXWrite, thread));        \
511     ThreadInVMfromNative __tiv(thread);                              \
512     DEBUG_ONLY(VMNativeEntryWrapper __vew;)                          \
513     VM_ENTRY_BASE(result_type, header, thread)
514 
515 
516 #define JVM_LEAF_PROF(result_type, name, header)                     \
517   PerfTickCounters* _perf_##name##_timer = nullptr;                  \
518   PerfCounter* _perf_##name##_count = nullptr;                       \
519 extern "C" {                                                         \
520   result_type JNICALL header {                                       \
521     PerfTraceTimedEvent perf_##name(_perf_##name##_timer, _perf_##name##_count, \
522                                     ProfileVMCalls && Thread::current()->profile_vm_calls()); \
523     VM_Exit::block_if_vm_exited();                                   \
524     VM_LEAF_BASE(result_type, header)
525 
526 #define JVM_END } }
527 
528 #endif // SHARE_RUNTIME_INTERFACESUPPORT_INLINE_HPP
< prev index next >