< prev index next >

src/share/vm/runtime/advancedThresholdPolicy.cpp

Print this page
rev 9644 : 8145096: Undefined behaviour in HotSpot
Summary: Fix some integer overflows
Reviewed-by: duke


 116 // See select_task().
 117 bool AdvancedThresholdPolicy::is_stale(jlong t, jlong timeout, Method* m) {
 118   jlong delta_s = t - SafepointSynchronize::end_of_last_safepoint();
 119   jlong delta_t = t - m->prev_time();
 120   if (delta_t > timeout && delta_s > timeout) {
 121     int event_count = m->invocation_count() + m->backedge_count();
 122     int delta_e = event_count - m->prev_event_count();
 123     // Return true if there were no events.
 124     return delta_e == 0;
 125   }
 126   return false;
 127 }
 128 
 129 // We don't remove old methods from the compile queue even if they have
 130 // very low activity. See select_task().
 131 bool AdvancedThresholdPolicy::is_old(Method* method) {
 132   return method->invocation_count() > 50000 || method->backedge_count() > 500000;
 133 }
 134 
 135 double AdvancedThresholdPolicy::weight(Method* method) {
 136   return (method->rate() + 1) * ((method->invocation_count() + 1) *  (method->backedge_count() + 1));

 137 }
 138 
 139 // Apply heuristics and return true if x should be compiled before y
 140 bool AdvancedThresholdPolicy::compare_methods(Method* x, Method* y) {
 141   if (x->highest_comp_level() > y->highest_comp_level()) {
 142     // recompilation after deopt
 143     return true;
 144   } else
 145     if (x->highest_comp_level() == y->highest_comp_level()) {
 146       if (weight(x) > weight(y)) {
 147         return true;
 148       }
 149     }
 150   return false;
 151 }
 152 
 153 // Is method profiled enough?
 154 bool AdvancedThresholdPolicy::is_method_profiled(Method* method) {
 155   MethodData* mdo = method->method_data();
 156   if (mdo != NULL) {




 116 // See select_task().
 117 bool AdvancedThresholdPolicy::is_stale(jlong t, jlong timeout, Method* m) {
 118   jlong delta_s = t - SafepointSynchronize::end_of_last_safepoint();
 119   jlong delta_t = t - m->prev_time();
 120   if (delta_t > timeout && delta_s > timeout) {
 121     int event_count = m->invocation_count() + m->backedge_count();
 122     int delta_e = event_count - m->prev_event_count();
 123     // Return true if there were no events.
 124     return delta_e == 0;
 125   }
 126   return false;
 127 }
 128 
 129 // We don't remove old methods from the compile queue even if they have
 130 // very low activity. See select_task().
 131 bool AdvancedThresholdPolicy::is_old(Method* method) {
 132   return method->invocation_count() > 50000 || method->backedge_count() > 500000;
 133 }
 134 
 135 double AdvancedThresholdPolicy::weight(Method* method) {
 136   return (double)(method->rate() + 1) *
 137     (method->invocation_count() + 1) * (method->backedge_count() + 1);
 138 }
 139 
 140 // Apply heuristics and return true if x should be compiled before y
 141 bool AdvancedThresholdPolicy::compare_methods(Method* x, Method* y) {
 142   if (x->highest_comp_level() > y->highest_comp_level()) {
 143     // recompilation after deopt
 144     return true;
 145   } else
 146     if (x->highest_comp_level() == y->highest_comp_level()) {
 147       if (weight(x) > weight(y)) {
 148         return true;
 149       }
 150     }
 151   return false;
 152 }
 153 
 154 // Is method profiled enough?
 155 bool AdvancedThresholdPolicy::is_method_profiled(Method* method) {
 156   MethodData* mdo = method->method_data();
 157   if (mdo != NULL) {


< prev index next >