src/share/vm/runtime/sharedRuntime.hpp

Print this page
rev 2893 : 7121756: Improve C1 inlining policy by using profiling at call sites
Summary: profile based recompilation of methods with C1 with more inlining.
Reviewed-by:


  35 
  36 class AdapterHandlerEntry;
  37 class AdapterHandlerTable;
  38 class AdapterFingerPrint;
  39 class vframeStream;
  40 
  41 // Runtime is the base class for various runtime interfaces
  42 // (InterpreterRuntime, CompilerRuntime, etc.). It provides
  43 // shared functionality such as exception forwarding (C++ to
  44 // Java exceptions), locking/unlocking mechanisms, statistical
  45 // information, etc.
  46 
  47 class SharedRuntime: AllStatic {
  48   friend class VMStructs;
  49 
  50  private:
  51   static methodHandle resolve_sub_helper(JavaThread *thread,
  52                                      bool is_virtual,
  53                                      bool is_optimized, TRAPS);
  54 


  55   // Shared stub locations
  56 
  57   static RuntimeStub*        _wrong_method_blob;
  58   static RuntimeStub*        _ic_miss_blob;
  59   static RuntimeStub*        _resolve_opt_virtual_call_blob;
  60   static RuntimeStub*        _resolve_virtual_call_blob;
  61   static RuntimeStub*        _resolve_static_call_blob;




  62 
  63   static DeoptimizationBlob* _deopt_blob;
  64   static RicochetBlob*       _ricochet_blob;
  65 
  66   static SafepointBlob*      _polling_page_safepoint_handler_blob;
  67   static SafepointBlob*      _polling_page_return_handler_blob;
  68 
  69 #ifdef COMPILER2
  70   static UncommonTrapBlob*   _uncommon_trap_blob;
  71 #endif // COMPILER2
  72 
  73 #ifndef PRODUCT
  74   // Counters
  75   static int     _nof_megamorphic_calls;         // total # of megamorphic calls (through vtable)
  76 #endif // !PRODUCT
  77 
  78  private:
  79   static SafepointBlob* generate_handler_blob(address call_ptr, bool cause_return);
  80   static RuntimeStub*   generate_resolve_blob(address destination, const char* name);
  81 


 182     STACK_OVERFLOW
 183   };
 184   static void    throw_AbstractMethodError(JavaThread* thread);
 185   static void    throw_IncompatibleClassChangeError(JavaThread* thread);
 186   static void    throw_ArithmeticException(JavaThread* thread);
 187   static void    throw_NullPointerException(JavaThread* thread);
 188   static void    throw_NullPointerException_at_call(JavaThread* thread);
 189   static void    throw_StackOverflowError(JavaThread* thread);
 190   static void    throw_WrongMethodTypeException(JavaThread* thread, oopDesc* required, oopDesc* actual);
 191   static address continuation_for_implicit_exception(JavaThread* thread,
 192                                                      address faulting_pc,
 193                                                      ImplicitExceptionKind exception_kind);
 194 
 195   // Shared stub locations
 196   static address get_poll_stub(address pc);
 197 
 198   static address get_ic_miss_stub() {
 199     assert(_ic_miss_blob!= NULL, "oops");
 200     return _ic_miss_blob->entry_point();
 201   }










 202 
 203   static address get_handle_wrong_method_stub() {
 204     assert(_wrong_method_blob!= NULL, "oops");
 205     return _wrong_method_blob->entry_point();
 206   }
 207 
 208 #ifdef COMPILER2
 209   static void generate_uncommon_trap_blob(void);
 210   static UncommonTrapBlob* uncommon_trap_blob()                  { return _uncommon_trap_blob; }
 211 #endif // COMPILER2
 212 
 213   static address get_resolve_opt_virtual_call_stub(){
 214     assert(_resolve_opt_virtual_call_blob != NULL, "oops");
 215     return _resolve_opt_virtual_call_blob->entry_point();
 216   }
 217   static address get_resolve_virtual_call_stub() {
 218     assert(_resolve_virtual_call_blob != NULL, "oops");
 219     return _resolve_virtual_call_blob->entry_point();
 220   }
 221   static address get_resolve_static_call_stub() {


 470   // returns.
 471   static nmethod *generate_dtrace_nmethod(MacroAssembler* masm,
 472                                           methodHandle method);
 473 
 474   // dtrace support to convert a Java string to utf8
 475   static void get_utf(oopDesc* src, address dst);
 476 #endif // def HAVE_DTRACE_H
 477 
 478   // A compiled caller has just called the interpreter, but compiled code
 479   // exists.  Patch the caller so he no longer calls into the interpreter.
 480   static void fixup_callers_callsite(methodOopDesc* moop, address ret_pc);
 481 
 482   // Slow-path Locking and Unlocking
 483   static void complete_monitor_locking_C(oopDesc* obj, BasicLock* lock, JavaThread* thread);
 484   static void complete_monitor_unlocking_C(oopDesc* obj, BasicLock* lock);
 485 
 486   // Resolving of calls
 487   static address resolve_static_call_C     (JavaThread *thread);
 488   static address resolve_virtual_call_C    (JavaThread *thread);
 489   static address resolve_opt_virtual_call_C(JavaThread *thread);




 490 
 491   // arraycopy, the non-leaf version.  (See StubRoutines for all the leaf calls.)
 492   static void slow_arraycopy_C(oopDesc* src,  jint src_pos,
 493                                oopDesc* dest, jint dest_pos,
 494                                jint length, JavaThread* thread);
 495 
 496   // handle ic miss with caller being compiled code
 497   // wrong method handling (inline cache misses, zombie methods)
 498   static address handle_wrong_method(JavaThread* thread);
 499   static address handle_wrong_method_ic_miss(JavaThread* thread);
 500 
 501 #ifndef PRODUCT
 502 
 503   // Collect and print inline cache miss statistics
 504  private:
 505   enum { maxICmiss_count = 100 };
 506   static int     _ICmiss_index;                  // length of IC miss histogram
 507   static int     _ICmiss_count[maxICmiss_count]; // miss counts
 508   static address _ICmiss_at[maxICmiss_count];    // miss addresses
 509   static void trace_ic_miss(address at);




  35 
  36 class AdapterHandlerEntry;
  37 class AdapterHandlerTable;
  38 class AdapterFingerPrint;
  39 class vframeStream;
  40 
  41 // Runtime is the base class for various runtime interfaces
  42 // (InterpreterRuntime, CompilerRuntime, etc.). It provides
  43 // shared functionality such as exception forwarding (C++ to
  44 // Java exceptions), locking/unlocking mechanisms, statistical
  45 // information, etc.
  46 
  47 class SharedRuntime: AllStatic {
  48   friend class VMStructs;
  49 
  50  private:
  51   static methodHandle resolve_sub_helper(JavaThread *thread,
  52                                      bool is_virtual,
  53                                      bool is_optimized, TRAPS);
  54 
  55   static methodHandle resolve_profile_helper(JavaThread *thread, TRAPS);
  56 
  57   // Shared stub locations
  58 
  59   static RuntimeStub*        _wrong_method_blob;
  60   static RuntimeStub*        _ic_miss_blob;
  61   static RuntimeStub*        _resolve_opt_virtual_call_blob;
  62   static RuntimeStub*        _resolve_virtual_call_blob;
  63   static RuntimeStub*        _resolve_static_call_blob;
  64 #ifdef COMPILER1
  65   static RuntimeStub* _resolve_profile_call_blob;
  66   static RuntimeStub* _resolve_static_profile_call_blob;
  67 #endif
  68 
  69   static DeoptimizationBlob* _deopt_blob;
  70   static RicochetBlob*       _ricochet_blob;
  71 
  72   static SafepointBlob*      _polling_page_safepoint_handler_blob;
  73   static SafepointBlob*      _polling_page_return_handler_blob;
  74 
  75 #ifdef COMPILER2
  76   static UncommonTrapBlob*   _uncommon_trap_blob;
  77 #endif // COMPILER2
  78 
  79 #ifndef PRODUCT
  80   // Counters
  81   static int     _nof_megamorphic_calls;         // total # of megamorphic calls (through vtable)
  82 #endif // !PRODUCT
  83 
  84  private:
  85   static SafepointBlob* generate_handler_blob(address call_ptr, bool cause_return);
  86   static RuntimeStub*   generate_resolve_blob(address destination, const char* name);
  87 


 188     STACK_OVERFLOW
 189   };
 190   static void    throw_AbstractMethodError(JavaThread* thread);
 191   static void    throw_IncompatibleClassChangeError(JavaThread* thread);
 192   static void    throw_ArithmeticException(JavaThread* thread);
 193   static void    throw_NullPointerException(JavaThread* thread);
 194   static void    throw_NullPointerException_at_call(JavaThread* thread);
 195   static void    throw_StackOverflowError(JavaThread* thread);
 196   static void    throw_WrongMethodTypeException(JavaThread* thread, oopDesc* required, oopDesc* actual);
 197   static address continuation_for_implicit_exception(JavaThread* thread,
 198                                                      address faulting_pc,
 199                                                      ImplicitExceptionKind exception_kind);
 200 
 201   // Shared stub locations
 202   static address get_poll_stub(address pc);
 203 
 204   static address get_ic_miss_stub() {
 205     assert(_ic_miss_blob!= NULL, "oops");
 206     return _ic_miss_blob->entry_point();
 207   }
 208 #ifdef COMPILER1
 209   static address get_resolve_profile_call_stub() {
 210     assert(_resolve_profile_call_blob != NULL, "oops");
 211     return _resolve_profile_call_blob->entry_point();
 212   }
 213   static address get_resolve_static_profile_call_stub() {
 214     assert(_resolve_static_profile_call_blob != NULL, "oops");
 215     return _resolve_static_profile_call_blob->entry_point();
 216   }
 217 #endif
 218 
 219   static address get_handle_wrong_method_stub() {
 220     assert(_wrong_method_blob!= NULL, "oops");
 221     return _wrong_method_blob->entry_point();
 222   }
 223 
 224 #ifdef COMPILER2
 225   static void generate_uncommon_trap_blob(void);
 226   static UncommonTrapBlob* uncommon_trap_blob()                  { return _uncommon_trap_blob; }
 227 #endif // COMPILER2
 228 
 229   static address get_resolve_opt_virtual_call_stub(){
 230     assert(_resolve_opt_virtual_call_blob != NULL, "oops");
 231     return _resolve_opt_virtual_call_blob->entry_point();
 232   }
 233   static address get_resolve_virtual_call_stub() {
 234     assert(_resolve_virtual_call_blob != NULL, "oops");
 235     return _resolve_virtual_call_blob->entry_point();
 236   }
 237   static address get_resolve_static_call_stub() {


 486   // returns.
 487   static nmethod *generate_dtrace_nmethod(MacroAssembler* masm,
 488                                           methodHandle method);
 489 
 490   // dtrace support to convert a Java string to utf8
 491   static void get_utf(oopDesc* src, address dst);
 492 #endif // def HAVE_DTRACE_H
 493 
 494   // A compiled caller has just called the interpreter, but compiled code
 495   // exists.  Patch the caller so he no longer calls into the interpreter.
 496   static void fixup_callers_callsite(methodOopDesc* moop, address ret_pc);
 497 
 498   // Slow-path Locking and Unlocking
 499   static void complete_monitor_locking_C(oopDesc* obj, BasicLock* lock, JavaThread* thread);
 500   static void complete_monitor_unlocking_C(oopDesc* obj, BasicLock* lock);
 501 
 502   // Resolving of calls
 503   static address resolve_static_call_C     (JavaThread *thread);
 504   static address resolve_virtual_call_C    (JavaThread *thread);
 505   static address resolve_opt_virtual_call_C(JavaThread *thread);
 506 #ifdef COMPILER1
 507   static address resolve_profile_call_C    (JavaThread *thread);
 508   static address resolve_static_profile_call_C(JavaThread *thread);
 509 #endif
 510 
 511   // arraycopy, the non-leaf version.  (See StubRoutines for all the leaf calls.)
 512   static void slow_arraycopy_C(oopDesc* src,  jint src_pos,
 513                                oopDesc* dest, jint dest_pos,
 514                                jint length, JavaThread* thread);
 515 
 516   // handle ic miss with caller being compiled code
 517   // wrong method handling (inline cache misses, zombie methods)
 518   static address handle_wrong_method(JavaThread* thread);
 519   static address handle_wrong_method_ic_miss(JavaThread* thread);
 520 
 521 #ifndef PRODUCT
 522 
 523   // Collect and print inline cache miss statistics
 524  private:
 525   enum { maxICmiss_count = 100 };
 526   static int     _ICmiss_index;                  // length of IC miss histogram
 527   static int     _ICmiss_count[maxICmiss_count]; // miss counts
 528   static address _ICmiss_at[maxICmiss_count];    // miss addresses
 529   static void trace_ic_miss(address at);