< 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 ||

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















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

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

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

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

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





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

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

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