src/share/vm/runtime/simpleThresholdPolicy.hpp

Print this page




   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 








  25 class CompileTask;
  26 class CompileQueue;
  27 
  28 class SimpleThresholdPolicy : public CompilationPolicy {
  29   int _c1_count, _c2_count;
  30 
  31   // Check if the counter is big enough and set carry (effectively infinity).
  32   inline void set_carry_if_necessary(InvocationCounter *counter);
  33   // Set carry flags in the counters (in methodOop and MDO).
  34   inline void handle_counter_overflow(methodOop method);
  35   // Call and loop predicates determine whether a transition to a higher compilation
  36   // level should be performed (pointers to predicate functions are passed to common_TF().
  37   // Predicates also take compiler load into account.
  38   typedef bool (SimpleThresholdPolicy::*Predicate)(int i, int b, CompLevel cur_level);
  39   bool call_predicate(int i, int b, CompLevel cur_level);
  40   bool loop_predicate(int i, int b, CompLevel cur_level);
  41   // Common transition function. Given a predicate determines if a method should transition to another level.
  42   CompLevel common(Predicate p, methodOop method, CompLevel cur_level);
  43   // Transition functions.
  44   // call_event determines if a method should be compiled at a different


  88   virtual int compiler_count(CompLevel comp_level) {
  89     if (is_c1_compile(comp_level)) return c1_count();
  90     if (is_c2_compile(comp_level)) return c2_count();
  91     return 0;
  92   }
  93   virtual void do_safepoint_work() { }
  94   virtual void delay_compilation(methodOop method) { }
  95   virtual void disable_compilation(methodOop method) { }
  96   // TODO: we should honour reprofiling requests in the future. Currently reprofiling
  97   // would happen but not to the extent we would ideally like.
  98   virtual void reprofile(ScopeDesc* trap_scope, bool is_osr) { }
  99   virtual nmethod* event(methodHandle method, methodHandle inlinee,
 100                          int branch_bci, int bci, CompLevel comp_level, TRAPS);
 101   // Select task is called by CompileBroker. We should return a task or NULL.
 102   virtual CompileTask* select_task(CompileQueue* compile_queue);
 103   // Tell the runtime if we think a given method is adequately profiled.
 104   virtual bool is_mature(methodOop method);
 105   // Initialize: set compiler thread count
 106   virtual void initialize();
 107 };




   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_RUNTIME_SIMPLETHRESHOLDPOLICY_HPP
  26 #define SHARE_VM_RUNTIME_SIMPLETHRESHOLDPOLICY_HPP
  27 
  28 #include "code/nmethod.hpp"
  29 #include "oops/methodDataOop.hpp"
  30 #include "runtime/compilationPolicy.hpp"
  31 #include "utilities/globalDefinitions.hpp"
  32 
  33 class CompileTask;
  34 class CompileQueue;
  35 
  36 class SimpleThresholdPolicy : public CompilationPolicy {
  37   int _c1_count, _c2_count;
  38 
  39   // Check if the counter is big enough and set carry (effectively infinity).
  40   inline void set_carry_if_necessary(InvocationCounter *counter);
  41   // Set carry flags in the counters (in methodOop and MDO).
  42   inline void handle_counter_overflow(methodOop method);
  43   // Call and loop predicates determine whether a transition to a higher compilation
  44   // level should be performed (pointers to predicate functions are passed to common_TF().
  45   // Predicates also take compiler load into account.
  46   typedef bool (SimpleThresholdPolicy::*Predicate)(int i, int b, CompLevel cur_level);
  47   bool call_predicate(int i, int b, CompLevel cur_level);
  48   bool loop_predicate(int i, int b, CompLevel cur_level);
  49   // Common transition function. Given a predicate determines if a method should transition to another level.
  50   CompLevel common(Predicate p, methodOop method, CompLevel cur_level);
  51   // Transition functions.
  52   // call_event determines if a method should be compiled at a different


  96   virtual int compiler_count(CompLevel comp_level) {
  97     if (is_c1_compile(comp_level)) return c1_count();
  98     if (is_c2_compile(comp_level)) return c2_count();
  99     return 0;
 100   }
 101   virtual void do_safepoint_work() { }
 102   virtual void delay_compilation(methodOop method) { }
 103   virtual void disable_compilation(methodOop method) { }
 104   // TODO: we should honour reprofiling requests in the future. Currently reprofiling
 105   // would happen but not to the extent we would ideally like.
 106   virtual void reprofile(ScopeDesc* trap_scope, bool is_osr) { }
 107   virtual nmethod* event(methodHandle method, methodHandle inlinee,
 108                          int branch_bci, int bci, CompLevel comp_level, TRAPS);
 109   // Select task is called by CompileBroker. We should return a task or NULL.
 110   virtual CompileTask* select_task(CompileQueue* compile_queue);
 111   // Tell the runtime if we think a given method is adequately profiled.
 112   virtual bool is_mature(methodOop method);
 113   // Initialize: set compiler thread count
 114   virtual void initialize();
 115 };
 116 
 117 #endif // SHARE_VM_RUNTIME_SIMPLETHRESHOLDPOLICY_HPP