src/hotspot/share/runtime/interfaceSupport.inline.hpp
changeset 57603 f9d9bed12d1a
parent 54898 17926213de55
child 57745 789e967c2731
equal deleted inserted replaced
57602:dbe471d2f8f8 57603:f9d9bed12d1a
   325     if (_thread->has_special_runtime_exit_condition())
   325     if (_thread->has_special_runtime_exit_condition())
   326       _thread->handle_special_runtime_exit_condition(false);
   326       _thread->handle_special_runtime_exit_condition(false);
   327   }
   327   }
   328 };
   328 };
   329 
   329 
   330 // Debug class instantiated in JRT_ENTRY and ITR_ENTRY macro.
   330 // Debug class instantiated in JRT_ENTRY macro.
   331 // Can be used to verify properties on enter/exit of the VM.
   331 // Can be used to verify properties on enter/exit of the VM.
   332 
   332 
   333 #ifdef ASSERT
   333 #ifdef ASSERT
   334 class VMEntryWrapper {
   334 class VMEntryWrapper {
   335  public:
   335  public:
   338 };
   338 };
   339 
   339 
   340 
   340 
   341 class VMNativeEntryWrapper {
   341 class VMNativeEntryWrapper {
   342  public:
   342  public:
   343   VMNativeEntryWrapper() {
   343   VMNativeEntryWrapper();
   344     if (GCALotAtAllSafepoints) InterfaceSupport::check_gc_alot();
   344   ~VMNativeEntryWrapper();
   345   }
   345 };
   346 
       
   347   ~VMNativeEntryWrapper() {
       
   348     if (GCALotAtAllSafepoints) InterfaceSupport::check_gc_alot();
       
   349   }
       
   350 };
       
   351 
       
   352 #endif
       
   353 
       
   354 
       
   355 // VM-internal runtime interface support
       
   356 
       
   357 // Definitions for JRT (Java (Compiler/Shared) Runtime)
       
   358 
       
   359 // JRT_LEAF currently can be called from either _thread_in_Java or
       
   360 // _thread_in_native mode. In _thread_in_native, it is ok
       
   361 // for another thread to trigger GC. The rest of the JRT_LEAF
       
   362 // rules apply.
       
   363 class JRTLeafVerifier : public NoSafepointVerifier {
       
   364   static bool should_verify_GC();
       
   365  public:
       
   366 #ifdef ASSERT
       
   367   JRTLeafVerifier();
       
   368   ~JRTLeafVerifier();
       
   369 #else
       
   370   JRTLeafVerifier() {}
       
   371   ~JRTLeafVerifier() {}
       
   372 #endif
       
   373 };
       
   374 
       
   375 #ifdef ASSERT
       
   376 
   346 
   377 class RuntimeHistogramElement : public HistogramElement {
   347 class RuntimeHistogramElement : public HistogramElement {
   378   public:
   348   public:
   379    RuntimeHistogramElement(const char* name);
   349    RuntimeHistogramElement(const char* name);
   380 };
   350 };
   381 
   351 #endif // ASSERT
       
   352 
       
   353 #ifdef ASSERT
   382 #define TRACE_CALL(result_type, header)                            \
   354 #define TRACE_CALL(result_type, header)                            \
   383   InterfaceSupport::_number_of_calls++;                            \
   355   InterfaceSupport::_number_of_calls++;                            \
   384   if (CountRuntimeCalls) {                                         \
   356   if (CountRuntimeCalls) {                                         \
   385     static RuntimeHistogramElement* e = new RuntimeHistogramElement(#header); \
   357     static RuntimeHistogramElement* e = new RuntimeHistogramElement(#header); \
   386     if (e != NULL) e->increment_count();                           \
   358     if (e != NULL) e->increment_count();                           \
   387   }
   359   }
   388 #else
   360 #else
   389 #define TRACE_CALL(result_type, header)                            \
   361 #define TRACE_CALL(result_type, header)                            \
   390   /* do nothing */
   362   /* do nothing */
   391 #endif
   363 #endif // ASSERT
   392 
   364 
   393 
   365 
   394 // LEAF routines do not lock, GC or throw exceptions
   366 // LEAF routines do not lock, GC or throw exceptions
   395 
   367 
   396 #define VM_LEAF_BASE(result_type, header)                            \
   368 #define VM_LEAF_BASE(result_type, header)                            \
   432   result_type header {                                               \
   404   result_type header {                                               \
   433     ThreadInVMfromJava __tiv(thread);                                \
   405     ThreadInVMfromJava __tiv(thread);                                \
   434     VM_ENTRY_BASE(result_type, header, thread)                       \
   406     VM_ENTRY_BASE(result_type, header, thread)                       \
   435     debug_only(VMEntryWrapper __vew;)
   407     debug_only(VMEntryWrapper __vew;)
   436 
   408 
       
   409 // JRT_LEAF currently can be called from either _thread_in_Java or
       
   410 // _thread_in_native mode.
       
   411 //
       
   412 // JRT_LEAF rules:
       
   413 // A JRT_LEAF method may not interfere with safepointing by
       
   414 //   1) acquiring or blocking on a Mutex or JavaLock - checked
       
   415 //   2) allocating heap memory - checked
       
   416 //   3) executing a VM operation - checked
       
   417 //   4) executing a system call (including malloc) that could block or grab a lock
       
   418 //   5) invoking GC
       
   419 //   6) reaching a safepoint
       
   420 //   7) running too long
       
   421 // Nor may any method it calls.
   437 
   422 
   438 #define JRT_LEAF(result_type, header)                                \
   423 #define JRT_LEAF(result_type, header)                                \
   439   result_type header {                                               \
   424   result_type header {                                               \
   440   VM_LEAF_BASE(result_type, header)                                  \
   425   VM_LEAF_BASE(result_type, header)                                  \
   441   debug_only(JRTLeafVerifier __jlv;)
   426   debug_only(NoSafepointVerifier __nsv;)
   442 
   427 
   443 
   428 
   444 #define JRT_ENTRY_NO_ASYNC(result_type, header)                      \
   429 #define JRT_ENTRY_NO_ASYNC(result_type, header)                      \
   445   result_type header {                                               \
   430   result_type header {                                               \
   446     ThreadInVMfromJavaNoAsyncException __tiv(thread);                \
   431     ThreadInVMfromJavaNoAsyncException __tiv(thread);                \