< prev index next >

src/share/vm/runtime/simpleThresholdPolicy.hpp

Print this page




  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
  55   // level with a regular invocation entry.
  56   CompLevel call_event(Method* method, CompLevel cur_level, JavaThread* thread);
  57   // loop_event checks if a method should be OSR compiled at a different
  58   // level.
  59   CompLevel loop_event(Method* method, CompLevel cur_level, JavaThread* thread);
  60   void print_counters(const char* prefix, methodHandle mh);
  61 protected:
  62   int c1_count() const     { return _c1_count; }
  63   int c2_count() const     { return _c2_count; }
  64   void set_c1_count(int x) { _c1_count = x;    }
  65   void set_c2_count(int x) { _c2_count = x;    }
  66 
  67   enum EventType { CALL, LOOP, COMPILE, REMOVE_FROM_QUEUE, UPDATE_IN_QUEUE, REPROFILE, MAKE_NOT_ENTRANT };
  68   void print_event(EventType type, methodHandle mh, methodHandle imh, int bci, CompLevel level);
  69   // Print policy-specific information if necessary
  70   virtual void print_specific(EventType type, methodHandle mh, methodHandle imh, int bci, CompLevel level) { }
  71   // Check if the method can be compiled, change level if necessary
  72   void compile(const methodHandle& mh, int bci, CompLevel level, JavaThread* thread);
  73   // Submit a given method for compilation
  74   virtual void submit_compile(const methodHandle& mh, int bci, CompLevel level, JavaThread* thread);
  75   // Simple methods are as good being compiled with C1 as C2.
  76   // This function tells if it's such a function.
  77   inline bool is_trivial(Method* method);
  78 
  79   // Predicate helpers are used by .*_predicate() methods as well as others.
  80   // They check the given counter values, multiplied by the scale against the thresholds.
  81   template<CompLevel level> static inline bool call_predicate_helper(int i, int b, double scale, Method* method);
  82   template<CompLevel level> static inline bool loop_predicate_helper(int i, int b, double scale, Method* method);
  83 
  84   // Get a compilation level for a given method.
  85   static CompLevel comp_level(Method* method) {
  86     CompiledMethod *nm = method->code();
  87     if (nm != NULL && nm->is_in_use()) {
  88       return (CompLevel)nm->comp_level();
  89     }
  90     return CompLevel_none;




  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
  55   // level with a regular invocation entry.
  56   CompLevel call_event(Method* method, CompLevel cur_level, JavaThread* thread);
  57   // loop_event checks if a method should be OSR compiled at a different
  58   // level.
  59   CompLevel loop_event(Method* method, CompLevel cur_level, JavaThread* thread);
  60   void print_counters(const char* prefix, const methodHandle& mh);
  61 protected:
  62   int c1_count() const     { return _c1_count; }
  63   int c2_count() const     { return _c2_count; }
  64   void set_c1_count(int x) { _c1_count = x;    }
  65   void set_c2_count(int x) { _c2_count = x;    }
  66 
  67   enum EventType { CALL, LOOP, COMPILE, REMOVE_FROM_QUEUE, UPDATE_IN_QUEUE, REPROFILE, MAKE_NOT_ENTRANT };
  68   void print_event(EventType type, const methodHandle& mh, const methodHandle& imh, int bci, CompLevel level);
  69   // Print policy-specific information if necessary
  70   virtual void print_specific(EventType type, const methodHandle& mh, const methodHandle& imh, int bci, CompLevel level) { }
  71   // Check if the method can be compiled, change level if necessary
  72   void compile(const methodHandle& mh, int bci, CompLevel level, JavaThread* thread);
  73   // Submit a given method for compilation
  74   virtual void submit_compile(const methodHandle& mh, int bci, CompLevel level, JavaThread* thread);
  75   // Simple methods are as good being compiled with C1 as C2.
  76   // This function tells if it's such a function.
  77   inline bool is_trivial(Method* method);
  78 
  79   // Predicate helpers are used by .*_predicate() methods as well as others.
  80   // They check the given counter values, multiplied by the scale against the thresholds.
  81   template<CompLevel level> static inline bool call_predicate_helper(int i, int b, double scale, Method* method);
  82   template<CompLevel level> static inline bool loop_predicate_helper(int i, int b, double scale, Method* method);
  83 
  84   // Get a compilation level for a given method.
  85   static CompLevel comp_level(Method* method) {
  86     CompiledMethod *nm = method->code();
  87     if (nm != NULL && nm->is_in_use()) {
  88       return (CompLevel)nm->comp_level();
  89     }
  90     return CompLevel_none;


< prev index next >