< prev index next >

src/hotspot/share/runtime/sharedRuntime.hpp

Print this page

 22  *
 23  */
 24 
 25 #ifndef SHARE_RUNTIME_SHAREDRUNTIME_HPP
 26 #define SHARE_RUNTIME_SHAREDRUNTIME_HPP
 27 
 28 #include "classfile/compactHashtable.hpp"
 29 #include "code/codeBlob.hpp"
 30 #include "code/vmreg.hpp"
 31 #include "interpreter/linkResolver.hpp"
 32 #include "memory/allStatic.hpp"
 33 #include "memory/metaspaceClosure.hpp"
 34 #include "memory/resourceArea.hpp"
 35 #include "runtime/safepointVerifiers.hpp"
 36 #include "runtime/stubInfo.hpp"
 37 #include "utilities/macros.hpp"
 38 
 39 class AdapterHandlerEntry;
 40 class AdapterFingerPrint;
 41 class vframeStream;

 42 
 43 // Runtime is the base class for various runtime interfaces
 44 // (InterpreterRuntime, CompilerRuntime, etc.). It provides
 45 // shared functionality such as exception forwarding (C++ to
 46 // Java exceptions), locking/unlocking mechanisms, statistical
 47 // information, etc.
 48 
 49 class SharedRuntime: AllStatic {
 50  private:
 51   // Declare shared stub fields
 52 #define SHARED_STUB_FIELD_DECLARE(name, type) \
 53   static type*       BLOB_FIELD_NAME(name);
 54   SHARED_STUBS_DO(SHARED_STUB_FIELD_DECLARE)
 55 #undef SHARED_STUB_FIELD_DECLARE
 56 
 57 #ifdef ASSERT
 58   static bool is_resolve_id(StubId id) {
 59     return (id == StubId::shared_wrong_method_id ||
 60             id == StubId::shared_wrong_method_abstract_id ||
 61             id == StubId::shared_ic_miss_id ||

557 
558   // Resolving of calls
559   static address get_resolved_entry        (JavaThread* current, methodHandle callee_method);
560   static address resolve_static_call_C     (JavaThread* current);
561   static address resolve_virtual_call_C    (JavaThread* current);
562   static address resolve_opt_virtual_call_C(JavaThread* current);
563 
564   // arraycopy, the non-leaf version.  (See StubRoutines for all the leaf calls.)
565   static void slow_arraycopy_C(oopDesc* src,  jint src_pos,
566                                oopDesc* dest, jint dest_pos,
567                                jint length, JavaThread* thread);
568 
569   // handle ic miss with caller being compiled code
570   // wrong method handling (inline cache misses)
571   static address handle_wrong_method(JavaThread* current);
572   static address handle_wrong_method_abstract(JavaThread* current);
573   static address handle_wrong_method_ic_miss(JavaThread* current);
574 
575   static address handle_unsafe_access(JavaThread* thread, address next_pc);
576 















577 #ifndef PRODUCT
578 
579   // Collect and print inline cache miss statistics
580  private:
581   enum { maxICmiss_count = 100 };
582   static int     _ICmiss_index;                  // length of IC miss histogram
583   static int     _ICmiss_count[maxICmiss_count]; // miss counts
584   static address _ICmiss_at[maxICmiss_count];    // miss addresses
585   static void trace_ic_miss(address at);
586 
587  public:
588   static uint _ic_miss_ctr;                      // total # of IC misses
589   static uint _wrong_method_ctr;
590   static uint _resolve_static_ctr;
591   static uint _resolve_virtual_ctr;
592   static uint _resolve_opt_virtual_ctr;
593   static uint _implicit_null_throws;
594   static uint _implicit_div0_throws;
595 
596   static uint _jbyte_array_copy_ctr;       // Slow-path byte array copy
597   static uint _jshort_array_copy_ctr;      // Slow-path short array copy
598   static uint _jint_array_copy_ctr;        // Slow-path int array copy
599   static uint _jlong_array_copy_ctr;       // Slow-path long array copy
600   static uint _oop_array_copy_ctr;         // Slow-path oop array copy
601   static uint _checkcast_array_copy_ctr;   // Slow-path oop array copy, with cast
602   static uint _unsafe_array_copy_ctr;      // Slow-path includes alignment checks
603   static uint _generic_array_copy_ctr;     // Slow-path includes type decoding
604   static uint _slow_array_copy_ctr;        // Slow-path failed out to a method call
605 
606   static uint _unsafe_set_memory_ctr;      // Slow-path includes alignment checks
607 
608   static uint _new_instance_ctr;           // 'new' object requires GC
609   static uint _new_array_ctr;              // 'new' array requires GC
610   static uint _multi2_ctr, _multi3_ctr, _multi4_ctr, _multi5_ctr;
611   static uint _find_handler_ctr;           // find exception handler
612   static uint _rethrow_ctr;                // rethrow exception

616   static uint _mon_exit_ctr;               // monitor exit slow
617   static uint _partial_subtype_ctr;        // SubRoutines::partial_subtype_check
618 
619   // Statistics code
620   // stats for "normal" compiled calls (non-interface)
621   static int64_t _nof_normal_calls;               // total # of calls
622   static int64_t _nof_inlined_calls;              // total # of inlined normal calls
623   static int64_t _nof_static_calls;               // total # of calls to static methods or super methods (invokespecial)
624   static int64_t _nof_inlined_static_calls;       // total # of inlined static calls
625   // stats for compiled interface calls
626   static int64_t _nof_interface_calls;            // total # of compiled calls
627   static int64_t _nof_inlined_interface_calls;    // total # of inlined interface calls
628 
629  public: // for compiler
630   static address nof_normal_calls_addr()                { return (address)&_nof_normal_calls; }
631   static address nof_inlined_calls_addr()               { return (address)&_nof_inlined_calls; }
632   static address nof_static_calls_addr()                { return (address)&_nof_static_calls; }
633   static address nof_inlined_static_calls_addr()        { return (address)&_nof_inlined_static_calls; }
634   static address nof_interface_calls_addr()             { return (address)&_nof_interface_calls; }
635   static address nof_inlined_interface_calls_addr()     { return (address)&_nof_inlined_interface_calls; }
636   static void print_call_statistics(uint64_t comp_total);
637   static void print_ic_miss_histogram();

638 
639 #ifdef COMPILER2
640   // Runtime methods for printf-style debug nodes
641   static void debug_print_value(jboolean x);
642   static void debug_print_value(jbyte x);
643   static void debug_print_value(jshort x);
644   static void debug_print_value(jchar x);
645   static void debug_print_value(jint x);
646   static void debug_print_value(jlong x);
647   static void debug_print_value(jfloat x);
648   static void debug_print_value(jdouble x);
649   static void debug_print_value(oopDesc* x);
650 
651   template <typename T, typename... Rest>
652   static void debug_print_rec(T arg, Rest... args) {
653     debug_print_value(arg);
654     debug_print_rec(args...);
655   }
656 
657   static void debug_print_rec() {}

858 
859   static AdapterHandlerEntry* new_entry(AdapterFingerPrint* fingerprint);
860   static void create_native_wrapper(const methodHandle& method);
861   static AdapterHandlerEntry* get_adapter(const methodHandle& method);
862   static AdapterHandlerEntry* lookup(int total_args_passed, BasicType* sig_bt);
863   static bool generate_adapter_code(AdapterHandlerEntry* handler,
864                                     int total_args_passed,
865                                     BasicType* sig_bt,
866                                     bool is_transient);
867 
868 #ifdef ASSERT
869   static void verify_adapter_sharing(int total_args_passed, BasicType* sig_bt, AdapterHandlerEntry* cached);
870 #endif // ASSERT
871 
872   static void print_handler(const CodeBlob* b) { print_handler_on(tty, b); }
873   static void print_handler_on(outputStream* st, const CodeBlob* b);
874   static bool contains(const CodeBlob* b);
875   static const char* name(AdapterHandlerEntry* handler);
876   static uint32_t id(AdapterHandlerEntry* handler);
877 #ifndef PRODUCT
878   static void print_statistics();
879 #endif // PRODUCT
880 
881   static void link_aot_adapter_handler(AdapterHandlerEntry* handler) NOT_CDS_RETURN;
882   static void dump_aot_adapter_table() NOT_CDS_RETURN;
883   static void serialize_shared_table_header(SerializeClosure* soc) NOT_CDS_RETURN;
884   static void link_aot_adapters() NOT_CDS_RETURN;
885   static void address_to_offset(address entry_address[AdapterBlob::ENTRY_COUNT], int entry_offset[AdapterBlob::ENTRY_COUNT]);
886 };
887 
888 #endif // SHARE_RUNTIME_SHAREDRUNTIME_HPP

 22  *
 23  */
 24 
 25 #ifndef SHARE_RUNTIME_SHAREDRUNTIME_HPP
 26 #define SHARE_RUNTIME_SHAREDRUNTIME_HPP
 27 
 28 #include "classfile/compactHashtable.hpp"
 29 #include "code/codeBlob.hpp"
 30 #include "code/vmreg.hpp"
 31 #include "interpreter/linkResolver.hpp"
 32 #include "memory/allStatic.hpp"
 33 #include "memory/metaspaceClosure.hpp"
 34 #include "memory/resourceArea.hpp"
 35 #include "runtime/safepointVerifiers.hpp"
 36 #include "runtime/stubInfo.hpp"
 37 #include "utilities/macros.hpp"
 38 
 39 class AdapterHandlerEntry;
 40 class AdapterFingerPrint;
 41 class vframeStream;
 42 class MetaspaceClosure;
 43 
 44 // Runtime is the base class for various runtime interfaces
 45 // (InterpreterRuntime, CompilerRuntime, etc.). It provides
 46 // shared functionality such as exception forwarding (C++ to
 47 // Java exceptions), locking/unlocking mechanisms, statistical
 48 // information, etc.
 49 
 50 class SharedRuntime: AllStatic {
 51  private:
 52   // Declare shared stub fields
 53 #define SHARED_STUB_FIELD_DECLARE(name, type) \
 54   static type*       BLOB_FIELD_NAME(name);
 55   SHARED_STUBS_DO(SHARED_STUB_FIELD_DECLARE)
 56 #undef SHARED_STUB_FIELD_DECLARE
 57 
 58 #ifdef ASSERT
 59   static bool is_resolve_id(StubId id) {
 60     return (id == StubId::shared_wrong_method_id ||
 61             id == StubId::shared_wrong_method_abstract_id ||
 62             id == StubId::shared_ic_miss_id ||

558 
559   // Resolving of calls
560   static address get_resolved_entry        (JavaThread* current, methodHandle callee_method);
561   static address resolve_static_call_C     (JavaThread* current);
562   static address resolve_virtual_call_C    (JavaThread* current);
563   static address resolve_opt_virtual_call_C(JavaThread* current);
564 
565   // arraycopy, the non-leaf version.  (See StubRoutines for all the leaf calls.)
566   static void slow_arraycopy_C(oopDesc* src,  jint src_pos,
567                                oopDesc* dest, jint dest_pos,
568                                jint length, JavaThread* thread);
569 
570   // handle ic miss with caller being compiled code
571   // wrong method handling (inline cache misses)
572   static address handle_wrong_method(JavaThread* current);
573   static address handle_wrong_method_abstract(JavaThread* current);
574   static address handle_wrong_method_ic_miss(JavaThread* current);
575 
576   static address handle_unsafe_access(JavaThread* thread, address next_pc);
577 
578  private:
579   static PerfTickCounters* _perf_resolve_opt_virtual_total_time;
580   static PerfTickCounters* _perf_resolve_virtual_total_time;
581   static PerfTickCounters* _perf_resolve_static_total_time;
582   static PerfTickCounters* _perf_handle_wrong_method_total_time;
583   static PerfTickCounters* _perf_ic_miss_total_time;
584  public:
585   static uint _ic_miss_ctr;                      // total # of IC misses
586   static uint _wrong_method_ctr;
587   static uint _resolve_static_ctr;
588   static uint _resolve_virtual_ctr;
589   static uint _resolve_opt_virtual_ctr;
590 
591   static void print_counters_on(outputStream* st);
592 
593 #ifndef PRODUCT
594 
595   // Collect and print inline cache miss statistics
596  private:
597   enum { maxICmiss_count = 100 };
598   static int     _ICmiss_index;                  // length of IC miss histogram
599   static int     _ICmiss_count[maxICmiss_count]; // miss counts
600   static address _ICmiss_at[maxICmiss_count];    // miss addresses
601   static void trace_ic_miss(address at);
602 
603  public:





604   static uint _implicit_null_throws;
605   static uint _implicit_div0_throws;
606 
607   static uint _jbyte_array_copy_ctr;       // Slow-path byte array copy
608   static uint _jshort_array_copy_ctr;      // Slow-path short array copy
609   static uint _jint_array_copy_ctr;        // Slow-path int array copy
610   static uint _jlong_array_copy_ctr;       // Slow-path long array copy
611   static uint _oop_array_copy_ctr;         // Slow-path oop array copy
612   static uint _checkcast_array_copy_ctr;   // Slow-path oop array copy, with cast
613   static uint _unsafe_array_copy_ctr;      // Slow-path includes alignment checks
614   static uint _generic_array_copy_ctr;     // Slow-path includes type decoding
615   static uint _slow_array_copy_ctr;        // Slow-path failed out to a method call
616 
617   static uint _unsafe_set_memory_ctr;      // Slow-path includes alignment checks
618 
619   static uint _new_instance_ctr;           // 'new' object requires GC
620   static uint _new_array_ctr;              // 'new' array requires GC
621   static uint _multi2_ctr, _multi3_ctr, _multi4_ctr, _multi5_ctr;
622   static uint _find_handler_ctr;           // find exception handler
623   static uint _rethrow_ctr;                // rethrow exception

627   static uint _mon_exit_ctr;               // monitor exit slow
628   static uint _partial_subtype_ctr;        // SubRoutines::partial_subtype_check
629 
630   // Statistics code
631   // stats for "normal" compiled calls (non-interface)
632   static int64_t _nof_normal_calls;               // total # of calls
633   static int64_t _nof_inlined_calls;              // total # of inlined normal calls
634   static int64_t _nof_static_calls;               // total # of calls to static methods or super methods (invokespecial)
635   static int64_t _nof_inlined_static_calls;       // total # of inlined static calls
636   // stats for compiled interface calls
637   static int64_t _nof_interface_calls;            // total # of compiled calls
638   static int64_t _nof_inlined_interface_calls;    // total # of inlined interface calls
639 
640  public: // for compiler
641   static address nof_normal_calls_addr()                { return (address)&_nof_normal_calls; }
642   static address nof_inlined_calls_addr()               { return (address)&_nof_inlined_calls; }
643   static address nof_static_calls_addr()                { return (address)&_nof_static_calls; }
644   static address nof_inlined_static_calls_addr()        { return (address)&_nof_inlined_static_calls; }
645   static address nof_interface_calls_addr()             { return (address)&_nof_interface_calls; }
646   static address nof_inlined_interface_calls_addr()     { return (address)&_nof_inlined_interface_calls; }
647 
648   static void print_call_statistics_on(outputStream* st);
649   static void print_ic_miss_histogram_on(outputStream* st);
650 
651 #ifdef COMPILER2
652   // Runtime methods for printf-style debug nodes
653   static void debug_print_value(jboolean x);
654   static void debug_print_value(jbyte x);
655   static void debug_print_value(jshort x);
656   static void debug_print_value(jchar x);
657   static void debug_print_value(jint x);
658   static void debug_print_value(jlong x);
659   static void debug_print_value(jfloat x);
660   static void debug_print_value(jdouble x);
661   static void debug_print_value(oopDesc* x);
662 
663   template <typename T, typename... Rest>
664   static void debug_print_rec(T arg, Rest... args) {
665     debug_print_value(arg);
666     debug_print_rec(args...);
667   }
668 
669   static void debug_print_rec() {}

870 
871   static AdapterHandlerEntry* new_entry(AdapterFingerPrint* fingerprint);
872   static void create_native_wrapper(const methodHandle& method);
873   static AdapterHandlerEntry* get_adapter(const methodHandle& method);
874   static AdapterHandlerEntry* lookup(int total_args_passed, BasicType* sig_bt);
875   static bool generate_adapter_code(AdapterHandlerEntry* handler,
876                                     int total_args_passed,
877                                     BasicType* sig_bt,
878                                     bool is_transient);
879 
880 #ifdef ASSERT
881   static void verify_adapter_sharing(int total_args_passed, BasicType* sig_bt, AdapterHandlerEntry* cached);
882 #endif // ASSERT
883 
884   static void print_handler(const CodeBlob* b) { print_handler_on(tty, b); }
885   static void print_handler_on(outputStream* st, const CodeBlob* b);
886   static bool contains(const CodeBlob* b);
887   static const char* name(AdapterHandlerEntry* handler);
888   static uint32_t id(AdapterHandlerEntry* handler);
889 #ifndef PRODUCT
890   static void print_statistics_on(outputStream* st);
891 #endif // PRODUCT
892 
893   static void link_aot_adapter_handler(AdapterHandlerEntry* handler) NOT_CDS_RETURN;
894   static void dump_aot_adapter_table() NOT_CDS_RETURN;
895   static void serialize_shared_table_header(SerializeClosure* soc) NOT_CDS_RETURN;
896   static void link_aot_adapters() NOT_CDS_RETURN;
897   static void address_to_offset(address entry_address[AdapterBlob::ENTRY_COUNT], int entry_offset[AdapterBlob::ENTRY_COUNT]);
898 };
899 
900 #endif // SHARE_RUNTIME_SHAREDRUNTIME_HPP
< prev index next >