< 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/resourceArea.hpp"
 34 #include "runtime/safepointVerifiers.hpp"
 35 #include "runtime/stubInfo.hpp"
 36 #include "utilities/macros.hpp"
 37 
 38 class AdapterHandlerEntry;
 39 class AdapterFingerPrint;
 40 class MetaspaceClosure;
 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 ||

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















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

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

625 
626 #ifdef COMPILER2
627   // Runtime methods for printf-style debug nodes
628   static void debug_print_value(jboolean x);
629   static void debug_print_value(jbyte x);
630   static void debug_print_value(jshort x);
631   static void debug_print_value(jchar x);
632   static void debug_print_value(jint x);
633   static void debug_print_value(jlong x);
634   static void debug_print_value(jfloat x);
635   static void debug_print_value(jdouble x);
636   static void debug_print_value(oopDesc* x);
637 
638   template <typename T, typename... Rest>
639   static void debug_print_rec(T arg, Rest... args) {
640     debug_print_value(arg);
641     debug_print_rec(args...);
642   }
643 
644   static void debug_print_rec() {}

844  public:
845 
846   static AdapterHandlerEntry* new_entry(AdapterFingerPrint* fingerprint);
847   static void create_native_wrapper(const methodHandle& method);
848   static AdapterHandlerEntry* get_adapter(const methodHandle& method);
849   static AdapterHandlerEntry* lookup(int total_args_passed, BasicType* sig_bt);
850   static bool generate_adapter_code(AdapterHandlerEntry* handler,
851                                     int total_args_passed,
852                                     BasicType* sig_bt,
853                                     bool is_transient);
854 
855 #ifdef ASSERT
856   static void verify_adapter_sharing(int total_args_passed, BasicType* sig_bt, AdapterHandlerEntry* cached);
857 #endif // ASSERT
858 
859   static void print_handler(const CodeBlob* b) { print_handler_on(tty, b); }
860   static void print_handler_on(outputStream* st, const CodeBlob* b);
861   static const char* name(AdapterHandlerEntry* handler);
862   static uint32_t id(AdapterHandlerEntry* handler);
863 #ifndef PRODUCT
864   static void print_statistics();
865 #endif // PRODUCT
866 
867   static void link_aot_adapter_handler(AdapterHandlerEntry* handler) NOT_CDS_RETURN;
868   static void dump_aot_adapter_table() NOT_CDS_RETURN;
869   static void serialize_shared_table_header(SerializeClosure* soc) NOT_CDS_RETURN;
870   static void link_aot_adapters() NOT_CDS_RETURN;
871   static void address_to_offset(address entry_address[AdapterBlob::ENTRY_COUNT], int entry_offset[AdapterBlob::ENTRY_COUNT]);
872 };
873 
874 #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/resourceArea.hpp"
 34 #include "runtime/safepointVerifiers.hpp"
 35 #include "runtime/stubInfo.hpp"
 36 #include "utilities/macros.hpp"
 37 
 38 class AdapterHandlerEntry;
 39 class AdapterFingerPrint;
 40 class MetaspaceClosure;
 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 ||

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





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

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

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