src/share/vm/runtime/compilationPolicy.hpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File tiered-osr-logic-fix Sdiff src/share/vm/runtime

src/share/vm/runtime/compilationPolicy.hpp

Print this page




  42   // Accumulated time
  43   static elapsedTimer       _accumulated_time;
  44 
  45   static bool               _in_vm_startup;
  46 public:
  47   static  void set_in_vm_startup(bool in_vm_startup) { _in_vm_startup = in_vm_startup; }
  48   static  void completed_vm_startup();
  49   static  bool delay_compilation_during_startup()    { return _in_vm_startup; }
  50 
  51   // m must be compiled before executing it
  52   static bool must_be_compiled(methodHandle m, int comp_level = CompLevel_all);
  53   // m is allowed to be compiled
  54   static bool can_be_compiled(methodHandle m, int comp_level = CompLevel_all);
  55   static bool is_compilation_enabled();
  56   static void set_policy(CompilationPolicy* policy) { _policy = policy; }
  57   static CompilationPolicy* policy()                { return _policy; }
  58 
  59   // Profiling
  60   elapsedTimer* accumulated_time() { return &_accumulated_time; }
  61   void print_time() PRODUCT_RETURN;


  62   virtual int compiler_count(CompLevel comp_level) = 0;
  63   // main notification entry, return a pointer to an nmethod if the OSR is required,
  64   // returns NULL otherwise.
  65   virtual nmethod* event(methodHandle method, methodHandle inlinee, int branch_bci, int bci, CompLevel comp_level, nmethod* nm, TRAPS) = 0;
  66   // safepoint() is called at the end of the safepoint
  67   virtual void do_safepoint_work() = 0;
  68   // reprofile request
  69   virtual void reprofile(ScopeDesc* trap_scope, bool is_osr) = 0;
  70   // delay_compilation(method) can be called by any component of the runtime to notify the policy
  71   // that it's recommended to delay the complation of this method.
  72   virtual void delay_compilation(methodOop method) = 0;
  73   // disable_compilation() is called whenever the runtime decides to disable compilation of the
  74   // specified method.
  75   virtual void disable_compilation(methodOop method) = 0;
  76   // Select task is called by CompileBroker. The queue is guaranteed to have at least one
  77   // element and is locked. The function should select one and return it.
  78   virtual CompileTask* select_task(CompileQueue* compile_queue) = 0;
  79   // Tell the runtime if we think a given method is adequately profiled.
  80   virtual bool is_mature(methodOop method) = 0;
  81   // Do policy initialization
  82   virtual void initialize() = 0;
  83   virtual bool should_not_inline(ciEnv* env, ciMethod* method) { return false; }
  84 };
  85 
  86 // A base class for baseline policies.
  87 class NonTieredCompPolicy : public CompilationPolicy {
  88   int _compiler_count;
  89 protected:
  90   static void trace_frequency_counter_overflow(methodHandle m, int branch_bci, int bci);
  91   static void trace_osr_request(methodHandle method, nmethod* osr, int bci);
  92   static void trace_osr_completion(nmethod* osr_nm);
  93   void reset_counter_for_invocation_event(methodHandle method);
  94   void reset_counter_for_back_branch_event(methodHandle method);
  95 public:
  96   NonTieredCompPolicy() : _compiler_count(0) { }

  97   virtual int compiler_count(CompLevel comp_level);
  98   virtual void do_safepoint_work();
  99   virtual void reprofile(ScopeDesc* trap_scope, bool is_osr);
 100   virtual void delay_compilation(methodOop method);
 101   virtual void disable_compilation(methodOop method);
 102   virtual bool is_mature(methodOop method);
 103   virtual void initialize();
 104   virtual CompileTask* select_task(CompileQueue* compile_queue);
 105   virtual nmethod* event(methodHandle method, methodHandle inlinee, int branch_bci, int bci, CompLevel comp_level, nmethod* nm, TRAPS);
 106   virtual void method_invocation_event(methodHandle m, TRAPS) = 0;
 107   virtual void method_back_branch_event(methodHandle m, int bci, TRAPS) = 0;
 108 };
 109 
 110 class SimpleCompPolicy : public NonTieredCompPolicy {
 111  public:
 112   virtual void method_invocation_event(methodHandle m, TRAPS);
 113   virtual void method_back_branch_event(methodHandle m, int bci, TRAPS);
 114 };
 115 
 116 // StackWalkCompPolicy - existing C2 policy




  42   // Accumulated time
  43   static elapsedTimer       _accumulated_time;
  44 
  45   static bool               _in_vm_startup;
  46 public:
  47   static  void set_in_vm_startup(bool in_vm_startup) { _in_vm_startup = in_vm_startup; }
  48   static  void completed_vm_startup();
  49   static  bool delay_compilation_during_startup()    { return _in_vm_startup; }
  50 
  51   // m must be compiled before executing it
  52   static bool must_be_compiled(methodHandle m, int comp_level = CompLevel_all);
  53   // m is allowed to be compiled
  54   static bool can_be_compiled(methodHandle m, int comp_level = CompLevel_all);
  55   static bool is_compilation_enabled();
  56   static void set_policy(CompilationPolicy* policy) { _policy = policy; }
  57   static CompilationPolicy* policy()                { return _policy; }
  58 
  59   // Profiling
  60   elapsedTimer* accumulated_time() { return &_accumulated_time; }
  61   void print_time() PRODUCT_RETURN;
  62   // Return initial compile level that is used with Xcomp
  63   virtual CompLevel initial_compile_level() = 0;
  64   virtual int compiler_count(CompLevel comp_level) = 0;
  65   // main notification entry, return a pointer to an nmethod if the OSR is required,
  66   // returns NULL otherwise.
  67   virtual nmethod* event(methodHandle method, methodHandle inlinee, int branch_bci, int bci, CompLevel comp_level, nmethod* nm, TRAPS) = 0;
  68   // safepoint() is called at the end of the safepoint
  69   virtual void do_safepoint_work() = 0;
  70   // reprofile request
  71   virtual void reprofile(ScopeDesc* trap_scope, bool is_osr) = 0;
  72   // delay_compilation(method) can be called by any component of the runtime to notify the policy
  73   // that it's recommended to delay the complation of this method.
  74   virtual void delay_compilation(methodOop method) = 0;
  75   // disable_compilation() is called whenever the runtime decides to disable compilation of the
  76   // specified method.
  77   virtual void disable_compilation(methodOop method) = 0;
  78   // Select task is called by CompileBroker. The queue is guaranteed to have at least one
  79   // element and is locked. The function should select one and return it.
  80   virtual CompileTask* select_task(CompileQueue* compile_queue) = 0;
  81   // Tell the runtime if we think a given method is adequately profiled.
  82   virtual bool is_mature(methodOop method) = 0;
  83   // Do policy initialization
  84   virtual void initialize() = 0;
  85   virtual bool should_not_inline(ciEnv* env, ciMethod* method) { return false; }
  86 };
  87 
  88 // A base class for baseline policies.
  89 class NonTieredCompPolicy : public CompilationPolicy {
  90   int _compiler_count;
  91 protected:
  92   static void trace_frequency_counter_overflow(methodHandle m, int branch_bci, int bci);
  93   static void trace_osr_request(methodHandle method, nmethod* osr, int bci);
  94   static void trace_osr_completion(nmethod* osr_nm);
  95   void reset_counter_for_invocation_event(methodHandle method);
  96   void reset_counter_for_back_branch_event(methodHandle method);
  97 public:
  98   NonTieredCompPolicy() : _compiler_count(0) { }
  99   virtual CompLevel initial_compile_level() { return CompLevel_initial_compile; }
 100   virtual int compiler_count(CompLevel comp_level);
 101   virtual void do_safepoint_work();
 102   virtual void reprofile(ScopeDesc* trap_scope, bool is_osr);
 103   virtual void delay_compilation(methodOop method);
 104   virtual void disable_compilation(methodOop method);
 105   virtual bool is_mature(methodOop method);
 106   virtual void initialize();
 107   virtual CompileTask* select_task(CompileQueue* compile_queue);
 108   virtual nmethod* event(methodHandle method, methodHandle inlinee, int branch_bci, int bci, CompLevel comp_level, nmethod* nm, TRAPS);
 109   virtual void method_invocation_event(methodHandle m, TRAPS) = 0;
 110   virtual void method_back_branch_event(methodHandle m, int bci, TRAPS) = 0;
 111 };
 112 
 113 class SimpleCompPolicy : public NonTieredCompPolicy {
 114  public:
 115   virtual void method_invocation_event(methodHandle m, TRAPS);
 116   virtual void method_back_branch_event(methodHandle m, int bci, TRAPS);
 117 };
 118 
 119 // StackWalkCompPolicy - existing C2 policy


src/share/vm/runtime/compilationPolicy.hpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File