< prev index next >

src/hotspot/share/runtime/sharedRuntime.hpp

Print this page

 21  * questions.
 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/stubInfo.hpp"
 36 #include "utilities/macros.hpp"
 37 
 38 class AdapterHandlerEntry;
 39 class AdapterFingerPrint;
 40 class vframeStream;

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

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















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

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


641 #endif // PRODUCT
642 
643   static void print_statistics() PRODUCT_RETURN;
644 };
645 
646 
647 // ---------------------------------------------------------------------------
648 // Implementation of AdapterHandlerLibrary
649 //
650 // This library manages argument marshaling adapters and native wrappers.
651 // There are 2 flavors of adapters: I2C and C2I.
652 //
653 // The I2C flavor takes a stock interpreted call setup, marshals the
654 // arguments for a Java-compiled call, and jumps to Rmethod-> code()->
655 // code_begin().  It is broken to call it without an nmethod assigned.
656 // The usual behavior is to lift any register arguments up out of the
657 // stack and possibly re-pack the extra arguments to be contiguous.
658 // I2C adapters will save what the interpreter's stack pointer will be
659 // after arguments are popped, then adjust the interpreter's frame
660 // size to force alignment and possibly to repack the arguments.

809   static AdapterHandlerEntry* new_entry(AdapterFingerPrint* fingerprint);
810   static void create_native_wrapper(const methodHandle& method);
811   static AdapterHandlerEntry* get_adapter(const methodHandle& method);
812   static AdapterHandlerEntry* lookup(int total_args_passed, BasicType* sig_bt);
813   static bool generate_adapter_code(AdapterBlob*& adapter_blob,
814                                     AdapterHandlerEntry* handler,
815                                     int total_args_passed,
816                                     BasicType* sig_bt,
817                                     bool is_transient);
818 
819 #ifdef ASSERT
820   static void verify_adapter_sharing(int total_args_passed, BasicType* sig_bt, AdapterHandlerEntry* cached);
821 #endif // ASSERT
822 
823   static void print_handler(const CodeBlob* b) { print_handler_on(tty, b); }
824   static void print_handler_on(outputStream* st, const CodeBlob* b);
825   static bool contains(const CodeBlob* b);
826   static const char* name(AdapterFingerPrint* fingerprint);
827   static uint32_t id(AdapterFingerPrint* fingerprint);
828 #ifndef PRODUCT
829   static void print_statistics();
830 #endif // PRODUCT
831 
832   static AdapterBlob* link_aot_adapter_handler(AdapterHandlerEntry* handler) NOT_CDS_RETURN_(nullptr);
833   static void dump_aot_adapter_table() NOT_CDS_RETURN;
834   static void serialize_shared_table_header(SerializeClosure* soc) NOT_CDS_RETURN;
835   static void link_aot_adapters() NOT_CDS_RETURN;
836 };
837 
838 #endif // SHARE_RUNTIME_SHAREDRUNTIME_HPP

 21  * questions.
 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/stubInfo.hpp"
 36 #include "utilities/macros.hpp"
 37 
 38 class AdapterHandlerEntry;
 39 class AdapterFingerPrint;
 40 class vframeStream;
 41 class MetaspaceClosure;
 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 ||

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





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

629   static uint _mon_exit_ctr;               // monitor exit slow
630   static uint _partial_subtype_ctr;        // SubRoutines::partial_subtype_check
631 
632   // Statistics code
633   // stats for "normal" compiled calls (non-interface)
634   static int64_t _nof_normal_calls;               // total # of calls
635   static int64_t _nof_inlined_calls;              // total # of inlined normal calls
636   static int64_t _nof_static_calls;               // total # of calls to static methods or super methods (invokespecial)
637   static int64_t _nof_inlined_static_calls;       // total # of inlined static calls
638   // stats for compiled interface calls
639   static int64_t _nof_interface_calls;            // total # of compiled calls
640   static int64_t _nof_inlined_interface_calls;    // total # of inlined interface calls
641 
642  public: // for compiler
643   static address nof_normal_calls_addr()                { return (address)&_nof_normal_calls; }
644   static address nof_inlined_calls_addr()               { return (address)&_nof_inlined_calls; }
645   static address nof_static_calls_addr()                { return (address)&_nof_static_calls; }
646   static address nof_inlined_static_calls_addr()        { return (address)&_nof_inlined_static_calls; }
647   static address nof_interface_calls_addr()             { return (address)&_nof_interface_calls; }
648   static address nof_inlined_interface_calls_addr()     { return (address)&_nof_inlined_interface_calls; }


649 
650   static void print_call_statistics_on(outputStream* st);
651   static void print_ic_miss_histogram_on(outputStream* st);
652 #endif // PRODUCT
653 
654   static void print_statistics() PRODUCT_RETURN;
655 };
656 
657 
658 // ---------------------------------------------------------------------------
659 // Implementation of AdapterHandlerLibrary
660 //
661 // This library manages argument marshaling adapters and native wrappers.
662 // There are 2 flavors of adapters: I2C and C2I.
663 //
664 // The I2C flavor takes a stock interpreted call setup, marshals the
665 // arguments for a Java-compiled call, and jumps to Rmethod-> code()->
666 // code_begin().  It is broken to call it without an nmethod assigned.
667 // The usual behavior is to lift any register arguments up out of the
668 // stack and possibly re-pack the extra arguments to be contiguous.
669 // I2C adapters will save what the interpreter's stack pointer will be
670 // after arguments are popped, then adjust the interpreter's frame
671 // size to force alignment and possibly to repack the arguments.

820   static AdapterHandlerEntry* new_entry(AdapterFingerPrint* fingerprint);
821   static void create_native_wrapper(const methodHandle& method);
822   static AdapterHandlerEntry* get_adapter(const methodHandle& method);
823   static AdapterHandlerEntry* lookup(int total_args_passed, BasicType* sig_bt);
824   static bool generate_adapter_code(AdapterBlob*& adapter_blob,
825                                     AdapterHandlerEntry* handler,
826                                     int total_args_passed,
827                                     BasicType* sig_bt,
828                                     bool is_transient);
829 
830 #ifdef ASSERT
831   static void verify_adapter_sharing(int total_args_passed, BasicType* sig_bt, AdapterHandlerEntry* cached);
832 #endif // ASSERT
833 
834   static void print_handler(const CodeBlob* b) { print_handler_on(tty, b); }
835   static void print_handler_on(outputStream* st, const CodeBlob* b);
836   static bool contains(const CodeBlob* b);
837   static const char* name(AdapterFingerPrint* fingerprint);
838   static uint32_t id(AdapterFingerPrint* fingerprint);
839 #ifndef PRODUCT
840   static void print_statistics_on(outputStream* st);
841 #endif // PRODUCT
842 
843   static AdapterBlob* link_aot_adapter_handler(AdapterHandlerEntry* handler) NOT_CDS_RETURN_(nullptr);
844   static void dump_aot_adapter_table() NOT_CDS_RETURN;
845   static void serialize_shared_table_header(SerializeClosure* soc) NOT_CDS_RETURN;
846   static void link_aot_adapters() NOT_CDS_RETURN;
847 };
848 
849 #endif // SHARE_RUNTIME_SHAREDRUNTIME_HPP
< prev index next >