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;
321 #define JRT_BLOCK_ENTRY(result_type, header) \
322 result_type header { \
323 assert(current == JavaThread::current(), "Must be"); \
324 MACOS_AARCH64_ONLY(ThreadWXEnable __wx(WXWrite, current)); \
325 HandleMarkCleaner __hm(current);
326
327 #define JRT_BLOCK \
328 { \
329 assert(current == JavaThread::current(), "Must be"); \
330 ThreadInVMfromJava __tiv(current); \
331 JavaThread* THREAD = current; /* For exception macros. */ \
332 debug_only(VMEntryWrapper __vew;)
333
334 #define JRT_BLOCK_NO_ASYNC \
335 { \
336 assert(current == JavaThread::current(), "Must be"); \
337 ThreadInVMfromJava __tiv(current, false /* check asyncs */); \
338 JavaThread* THREAD = current; /* For exception macros. */ \
339 debug_only(VMEntryWrapper __vew;)
340
341 #define JRT_BLOCK_END }
342
343 #define JRT_END }
344
345 // Definitions for JNI
346 //
347 // As the JNIEnv can be passed from external native code we validate
348 // it in debug builds, primarily for our own testing. In general JNI
349 // does not attempt to detect programming errors and a bad JNIEnv may
350 // not even be readable.
351
352 #define JNI_ENTRY(result_type, header) \
353 JNI_ENTRY_NO_PRESERVE(result_type, header) \
354 WeakPreserveExceptionMark __wem(thread);
355
356 #define JNI_ENTRY_NO_PRESERVE(result_type, header) \
357 extern "C" { \
358 result_type JNICALL header { \
359 JavaThread* thread=JavaThread::thread_from_jni_environment(env); \
360 assert(thread == Thread::current(), "JNIEnv is only valid in same thread"); \
361 MACOS_AARCH64_ONLY(ThreadWXEnable __wx(WXWrite, thread)); \
362 ThreadInVMfromNative __tiv(thread); \
363 debug_only(VMNativeEntryWrapper __vew;) \
389 VM_ENTRY_BASE(result_type, header, thread)
390
391
392 #define JVM_ENTRY_NO_ENV(result_type, header) \
393 extern "C" { \
394 result_type JNICALL header { \
395 JavaThread* thread = JavaThread::current(); \
396 MACOS_AARCH64_ONLY(ThreadWXEnable __wx(WXWrite, thread)); \
397 ThreadInVMfromNative __tiv(thread); \
398 debug_only(VMNativeEntryWrapper __vew;) \
399 VM_ENTRY_BASE(result_type, header, thread)
400
401
402 #define JVM_LEAF(result_type, header) \
403 extern "C" { \
404 result_type JNICALL header { \
405 VM_Exit::block_if_vm_exited(); \
406 VM_LEAF_BASE(result_type, header)
407
408
409 #define JVM_END } }
410
411 #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;
322 #define JRT_BLOCK_ENTRY(result_type, header) \
323 result_type header { \
324 assert(current == JavaThread::current(), "Must be"); \
325 MACOS_AARCH64_ONLY(ThreadWXEnable __wx(WXWrite, current)); \
326 HandleMarkCleaner __hm(current);
327
328 #define JRT_BLOCK \
329 { \
330 assert(current == JavaThread::current(), "Must be"); \
331 ThreadInVMfromJava __tiv(current); \
332 JavaThread* THREAD = current; /* For exception macros. */ \
333 debug_only(VMEntryWrapper __vew;)
334
335 #define JRT_BLOCK_NO_ASYNC \
336 { \
337 assert(current == JavaThread::current(), "Must be"); \
338 ThreadInVMfromJava __tiv(current, false /* check asyncs */); \
339 JavaThread* THREAD = current; /* For exception macros. */ \
340 debug_only(VMEntryWrapper __vew;)
341
342 #define JRT_ENTRY_PROF(result_type, sub, name, header) \
343 PerfTickCounters* _perf_##sub##_##name##_timer = nullptr; \
344 PerfCounter* _perf_##sub##_##name##_count = nullptr; \
345 result_type header { \
346 assert(current == JavaThread::current(), "Must be"); \
347 PerfTraceTimedEvent perf_##sub##_##name(_perf_##sub##_##name##_timer, _perf_##sub##_##name##_count, current->do_profile_rt_call()); \
348 ProfileVMCallContext pctx(current, &(perf_##sub##_##name), current->do_profile_rt_call()); \
349 MACOS_AARCH64_ONLY(ThreadWXEnable __wx(WXWrite, current)); \
350 ThreadInVMfromJava __tiv(current); \
351 VM_ENTRY_BASE(result_type, header, current) \
352 debug_only(VMEntryWrapper __vew;)
353
354 #define JRT_LEAF_PROF(result_type, sub, name, header) \
355 PerfTickCounters* _perf_##sub##_##name##_timer = nullptr; \
356 PerfCounter* _perf_##sub##_##name##_count = nullptr; \
357 result_type header { \
358 PerfTraceTimedEvent perf_##sub##_##name(_perf_##sub##_##name##_timer, _perf_##sub##_##name##_count, \
359 current->do_profile_rt_call()); \
360 ProfileVMCallContext pctx(current, &(perf_##sub##_##name), current->do_profile_rt_call()); \
361 VM_LEAF_BASE(result_type, header) \
362 debug_only(NoSafepointVerifier __nsv;)
363
364 #define JRT_LEAF_PROF_NO_THREAD(result_type, sub, name, header) \
365 PerfTickCounters* _perf_##sub##_##name##_timer = nullptr; \
366 PerfCounter* _perf_##sub##_##name##_count = nullptr; \
367 result_type header { \
368 Thread* current = Thread::current(); \
369 PerfTraceTimedEvent perf_##sub##_##name(_perf_##sub##_##name##_timer, _perf_##sub##_##name##_count, \
370 current->do_profile_rt_call()); \
371 ProfileVMCallContext pctx(current, &(perf_##sub##_##name), current->do_profile_rt_call()); \
372 VM_LEAF_BASE(result_type, header) \
373 debug_only(NoSafepointVerifier __nsv;)
374
375 #define JRT_ENTRY_NO_ASYNC_PROF(result_type, sub, name, header) \
376 PerfTickCounters* _perf_##sub##_##name##_timer = nullptr; \
377 PerfCounter* _perf_##sub##_##name##_count = nullptr; \
378 result_type header { \
379 assert(current == JavaThread::current(), "Must be"); \
380 PerfTraceTimedEvent perf_##sub##_##name(_perf_##sub##_##name##_timer, _perf_##sub##_##name##_count, current->do_profile_rt_call()); \
381 ProfileVMCallContext pctx(current, &(perf_##sub##_##name), current->do_profile_rt_call()); \
382 MACOS_AARCH64_ONLY(ThreadWXEnable __wx(WXWrite, current)); \
383 ThreadInVMfromJava __tiv(current, false /* check asyncs */); \
384 VM_ENTRY_BASE(result_type, header, current) \
385 debug_only(VMEntryWrapper __vew;)
386
387 #define JRT_BLOCK_ENTRY_PROF(result_type, sub, name, header) \
388 PerfTickCounters* _perf_##sub##_##name##_timer = nullptr; \
389 PerfCounter* _perf_##sub##_##name##_count = nullptr; \
390 result_type header { \
391 assert(current == JavaThread::current(), "Must be"); \
392 PerfTraceTimedEvent perf_##sub##_##name(_perf_##sub##_##name##_timer, _perf_##sub##_##name##_count, current->do_profile_rt_call()); \
393 ProfileVMCallContext pctx(current, &(perf_##sub##_##name), current->do_profile_rt_call()); \
394 MACOS_AARCH64_ONLY(ThreadWXEnable __wx(WXWrite, current)); \
395 HandleMarkCleaner __hm(current);
396
397 #define PROF_ENTRY(result_type, sub, name, header) \
398 PerfTickCounters* _perf_##sub##_##name##_timer = nullptr; \
399 PerfCounter* _perf_##sub##_##name##_count = nullptr; \
400 result_type header { \
401 assert(current == JavaThread::current(), "must be"); \
402 PerfTraceTimedEvent perf_##sub##_##name(_perf_##sub##_##name##_timer, _perf_##sub##_##name##_count, current->do_profile_rt_call()); \
403 ProfileVMCallContext pctx(current, &(perf_##sub##_##name), current->do_profile_rt_call());
404
405 #define JRT_BLOCK_END }
406 #define JRT_END }
407 #define PROF_END }
408
409 // Definitions for JNI
410 //
411 // As the JNIEnv can be passed from external native code we validate
412 // it in debug builds, primarily for our own testing. In general JNI
413 // does not attempt to detect programming errors and a bad JNIEnv may
414 // not even be readable.
415
416 #define JNI_ENTRY(result_type, header) \
417 JNI_ENTRY_NO_PRESERVE(result_type, header) \
418 WeakPreserveExceptionMark __wem(thread);
419
420 #define JNI_ENTRY_NO_PRESERVE(result_type, header) \
421 extern "C" { \
422 result_type JNICALL header { \
423 JavaThread* thread=JavaThread::thread_from_jni_environment(env); \
424 assert(thread == Thread::current(), "JNIEnv is only valid in same thread"); \
425 MACOS_AARCH64_ONLY(ThreadWXEnable __wx(WXWrite, thread)); \
426 ThreadInVMfromNative __tiv(thread); \
427 debug_only(VMNativeEntryWrapper __vew;) \
453 VM_ENTRY_BASE(result_type, header, thread)
454
455
456 #define JVM_ENTRY_NO_ENV(result_type, header) \
457 extern "C" { \
458 result_type JNICALL header { \
459 JavaThread* thread = JavaThread::current(); \
460 MACOS_AARCH64_ONLY(ThreadWXEnable __wx(WXWrite, thread)); \
461 ThreadInVMfromNative __tiv(thread); \
462 debug_only(VMNativeEntryWrapper __vew;) \
463 VM_ENTRY_BASE(result_type, header, thread)
464
465
466 #define JVM_LEAF(result_type, header) \
467 extern "C" { \
468 result_type JNICALL header { \
469 VM_Exit::block_if_vm_exited(); \
470 VM_LEAF_BASE(result_type, header)
471
472
473 #define JVM_ENTRY_PROF(result_type, name, header) \
474 PerfTickCounters* _perf_##name##_timer = nullptr; \
475 PerfCounter* _perf_##name##_count = nullptr; \
476 extern "C" { \
477 result_type JNICALL header { \
478 JavaThread* thread=JavaThread::thread_from_jni_environment(env); \
479 PerfTraceTimedEvent perf_##name(_perf_##name##_timer, _perf_##name##_count, thread->profile_vm_calls()); \
480 MACOS_AARCH64_ONLY(ThreadWXEnable __wx(WXWrite, thread)); \
481 ThreadInVMfromNative __tiv(thread); \
482 debug_only(VMNativeEntryWrapper __vew;) \
483 VM_ENTRY_BASE(result_type, header, thread)
484
485
486 #define JVM_ENTRY_NO_ENV_PROF(result_type, name, header) \
487 PerfTickCounters* _perf_##name##_timer = nullptr; \
488 PerfCounter* _perf_##name##_count = nullptr; \
489 extern "C" { \
490 result_type JNICALL header { \
491 JavaThread* thread = JavaThread::current(); \
492 PerfTraceTimedEvent perf_##name(_perf_##name##_timer, _perf_##name##_count, thread->profile_vm_calls()); \
493 MACOS_AARCH64_ONLY(ThreadWXEnable __wx(WXWrite, thread)); \
494 ThreadInVMfromNative __tiv(thread); \
495 debug_only(VMNativeEntryWrapper __vew;) \
496 VM_ENTRY_BASE(result_type, header, thread)
497
498
499 #define JVM_LEAF_PROF(result_type, name, header) \
500 PerfTickCounters* _perf_##name##_timer = nullptr; \
501 PerfCounter* _perf_##name##_count = nullptr; \
502 extern "C" { \
503 result_type JNICALL header { \
504 PerfTraceTimedEvent perf_##name(_perf_##name##_timer, _perf_##name##_count, \
505 ProfileVMCalls && Thread::current()->profile_vm_calls()); \
506 VM_Exit::block_if_vm_exited(); \
507 VM_LEAF_BASE(result_type, header)
508
509 #define JVM_END } }
510
511 #endif // SHARE_RUNTIME_INTERFACESUPPORT_INLINE_HPP
|