src/hotspot/share/runtime/compilationPolicy.hpp
branchstuefe-new-metaspace-branch
changeset 58494 54c1ba464b78
parent 58398 ff559f979c4b
equal deleted inserted replaced
58475:e3aa9f95b85e 58494:54c1ba464b78
    34 // The CompilationPolicy selects which method (if any) should be compiled.
    34 // The CompilationPolicy selects which method (if any) should be compiled.
    35 // It also decides which methods must always be compiled (i.e., are never
    35 // It also decides which methods must always be compiled (i.e., are never
    36 // interpreted).
    36 // interpreted).
    37 class CompileTask;
    37 class CompileTask;
    38 class CompileQueue;
    38 class CompileQueue;
    39 class RFrame;
       
    40 
    39 
    41 class CompilationPolicy : public CHeapObj<mtCompiler> {
    40 class CompilationPolicy : public CHeapObj<mtCompiler> {
    42   static CompilationPolicy* _policy;
    41   static CompilationPolicy* _policy;
    43 
    42 
    44   // m must be compiled before executing it
    43   // m must be compiled before executing it
    83   // Do policy initialization
    82   // Do policy initialization
    84   virtual void initialize() = 0;
    83   virtual void initialize() = 0;
    85   virtual bool should_not_inline(ciEnv* env, ciMethod* method) { return false; }
    84   virtual bool should_not_inline(ciEnv* env, ciMethod* method) { return false; }
    86 };
    85 };
    87 
    86 
    88 // A base class for baseline policies.
    87 // A simple compilation policy.
    89 class NonTieredCompPolicy : public CompilationPolicy {
    88 class SimpleCompPolicy : public CompilationPolicy {
    90   int _compiler_count;
    89   int _compiler_count;
    91 protected:
    90  private:
    92   static void trace_frequency_counter_overflow(const methodHandle& m, int branch_bci, int bci);
    91   static void trace_frequency_counter_overflow(const methodHandle& m, int branch_bci, int bci);
    93   static void trace_osr_request(const methodHandle& method, nmethod* osr, int bci);
    92   static void trace_osr_request(const methodHandle& method, nmethod* osr, int bci);
    94   static void trace_osr_completion(nmethod* osr_nm);
    93   static void trace_osr_completion(nmethod* osr_nm);
    95   void reset_counter_for_invocation_event(const methodHandle& method);
    94   void reset_counter_for_invocation_event(const methodHandle& method);
    96   void reset_counter_for_back_branch_event(const methodHandle& method);
    95   void reset_counter_for_back_branch_event(const methodHandle& method);
    97 public:
    96   void method_invocation_event(const methodHandle& m, JavaThread* thread);
    98   NonTieredCompPolicy() : _compiler_count(0) { }
    97   void method_back_branch_event(const methodHandle& m, int bci, JavaThread* thread);
       
    98  public:
       
    99   SimpleCompPolicy() : _compiler_count(0) { }
    99   virtual CompLevel initial_compile_level() { return CompLevel_highest_tier; }
   100   virtual CompLevel initial_compile_level() { return CompLevel_highest_tier; }
   100   virtual int compiler_count(CompLevel comp_level);
   101   virtual int compiler_count(CompLevel comp_level);
   101   virtual void do_safepoint_work();
   102   virtual void do_safepoint_work();
   102   virtual void reprofile(ScopeDesc* trap_scope, bool is_osr);
   103   virtual void reprofile(ScopeDesc* trap_scope, bool is_osr);
   103   virtual void delay_compilation(Method* method);
   104   virtual void delay_compilation(Method* method);
   104   virtual void disable_compilation(Method* method);
   105   virtual void disable_compilation(Method* method);
   105   virtual bool is_mature(Method* method);
   106   virtual bool is_mature(Method* method);
   106   virtual void initialize();
   107   virtual void initialize();
   107   virtual CompileTask* select_task(CompileQueue* compile_queue);
   108   virtual CompileTask* select_task(CompileQueue* compile_queue);
   108   virtual nmethod* event(const methodHandle& method, const methodHandle& inlinee, int branch_bci, int bci, CompLevel comp_level, CompiledMethod* nm, JavaThread* thread);
   109   virtual nmethod* event(const methodHandle& method, const methodHandle& inlinee, int branch_bci, int bci, CompLevel comp_level, CompiledMethod* nm, JavaThread* thread);
   109   virtual void method_invocation_event(const methodHandle& m, JavaThread* thread) = 0;
       
   110   virtual void method_back_branch_event(const methodHandle& m, int bci, JavaThread* thread) = 0;
       
   111 };
   110 };
   112 
   111 
   113 class SimpleCompPolicy : public NonTieredCompPolicy {
       
   114  public:
       
   115   virtual void method_invocation_event(const methodHandle& m, JavaThread* thread);
       
   116   virtual void method_back_branch_event(const methodHandle& m, int bci, JavaThread* thread);
       
   117 };
       
   118 
       
   119 // StackWalkCompPolicy - existing C2 policy
       
   120 
       
   121 #ifdef COMPILER2
       
   122 class StackWalkCompPolicy : public NonTieredCompPolicy {
       
   123  public:
       
   124   virtual void method_invocation_event(const methodHandle& m, JavaThread* thread);
       
   125   virtual void method_back_branch_event(const methodHandle& m, int bci, JavaThread* thread);
       
   126 
       
   127  private:
       
   128   RFrame* findTopInlinableFrame(GrowableArray<RFrame*>* stack);
       
   129   RFrame* senderOf(RFrame* rf, GrowableArray<RFrame*>* stack);
       
   130 
       
   131   // the following variables hold values computed by the last inlining decision
       
   132   // they are used for performance debugging only (print better messages)
       
   133   static const char* _msg;            // reason for not inlining
       
   134 
       
   135   static const char* shouldInline   (const methodHandle& callee, float frequency, int cnt);
       
   136   // positive filter: should send be inlined?  returns NULL (--> yes) or rejection msg
       
   137   static const char* shouldNotInline(const methodHandle& callee);
       
   138   // negative filter: should send NOT be inlined?  returns NULL (--> inline) or rejection msg
       
   139 
       
   140 };
       
   141 #endif
       
   142 
   112 
   143 #endif // SHARE_RUNTIME_COMPILATIONPOLICY_HPP
   113 #endif // SHARE_RUNTIME_COMPILATIONPOLICY_HPP