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/methodData.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 Method* and MDO). 42 inline void handle_counter_overflow(Method* 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, Method* method); 47 bool call_predicate(int i, int b, CompLevel cur_level, Method* method); 48 bool loop_predicate(int i, int b, CompLevel cur_level, Method* method); 49 // Common transition function. Given a predicate determines if a method should transition to another level. 50 CompLevel common(Predicate p, Method* method, CompLevel cur_level); 51 // Transition functions. 52 // call_event determines if a method should be compiled at a different 101 virtual CompLevel initial_compile_level() { return MIN2((CompLevel)TieredStopAtLevel, CompLevel_initial_compile); } 102 virtual void do_safepoint_work() { } 103 virtual void delay_compilation(Method* method) { } 104 virtual void disable_compilation(Method* method) { } 105 virtual void reprofile(ScopeDesc* trap_scope, bool is_osr); 106 virtual nmethod* event(const methodHandle& method, const methodHandle& inlinee, 107 int branch_bci, int bci, CompLevel comp_level, CompiledMethod* nm, JavaThread* thread); 108 // Select task is called by CompileBroker. We should return a task or NULL. 109 virtual CompileTask* select_task(CompileQueue* compile_queue); 110 // Tell the runtime if we think a given method is adequately profiled. 111 virtual bool is_mature(Method* method); 112 // Initialize: set compiler thread count 113 virtual void initialize(); 114 virtual bool should_not_inline(ciEnv* env, ciMethod* callee) { 115 return (env->comp_level() == CompLevel_limited_profile || 116 env->comp_level() == CompLevel_full_profile) && 117 callee->has_loops(); 118 } 119 }; 120 121 #endif // SHARE_VM_RUNTIME_SIMPLETHRESHOLDPOLICY_HPP | 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/methodData.hpp" 30 #include "runtime/compilationPolicy.hpp" 31 #include "utilities/globalDefinitions.hpp" 32 33 #ifdef TIERED 34 35 class CompileTask; 36 class CompileQueue; 37 38 class SimpleThresholdPolicy : public CompilationPolicy { 39 int _c1_count, _c2_count; 40 41 // Check if the counter is big enough and set carry (effectively infinity). 42 inline void set_carry_if_necessary(InvocationCounter *counter); 43 // Set carry flags in the counters (in Method* and MDO). 44 inline void handle_counter_overflow(Method* method); 45 // Call and loop predicates determine whether a transition to a higher compilation 46 // level should be performed (pointers to predicate functions are passed to common_TF(). 47 // Predicates also take compiler load into account. 48 typedef bool (SimpleThresholdPolicy::*Predicate)(int i, int b, CompLevel cur_level, Method* method); 49 bool call_predicate(int i, int b, CompLevel cur_level, Method* method); 50 bool loop_predicate(int i, int b, CompLevel cur_level, Method* method); 51 // Common transition function. Given a predicate determines if a method should transition to another level. 52 CompLevel common(Predicate p, Method* method, CompLevel cur_level); 53 // Transition functions. 54 // call_event determines if a method should be compiled at a different 103 virtual CompLevel initial_compile_level() { return MIN2((CompLevel)TieredStopAtLevel, CompLevel_initial_compile); } 104 virtual void do_safepoint_work() { } 105 virtual void delay_compilation(Method* method) { } 106 virtual void disable_compilation(Method* method) { } 107 virtual void reprofile(ScopeDesc* trap_scope, bool is_osr); 108 virtual nmethod* event(const methodHandle& method, const methodHandle& inlinee, 109 int branch_bci, int bci, CompLevel comp_level, CompiledMethod* nm, JavaThread* thread); 110 // Select task is called by CompileBroker. We should return a task or NULL. 111 virtual CompileTask* select_task(CompileQueue* compile_queue); 112 // Tell the runtime if we think a given method is adequately profiled. 113 virtual bool is_mature(Method* method); 114 // Initialize: set compiler thread count 115 virtual void initialize(); 116 virtual bool should_not_inline(ciEnv* env, ciMethod* callee) { 117 return (env->comp_level() == CompLevel_limited_profile || 118 env->comp_level() == CompLevel_full_profile) && 119 callee->has_loops(); 120 } 121 }; 122 123 #endif // TIERED 124 125 #endif // SHARE_VM_RUNTIME_SIMPLETHRESHOLDPOLICY_HPP |