src/share/vm/runtime/advancedThresholdPolicy.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File handle-in-select_task Sdiff src/share/vm/runtime

src/share/vm/runtime/advancedThresholdPolicy.cpp

Print this page




 139         return true;
 140       }
 141     }
 142   return false;
 143 }
 144 
 145 // Is method profiled enough?
 146 bool AdvancedThresholdPolicy::is_method_profiled(methodOop method) {
 147   methodDataOop mdo = method->method_data();
 148   if (mdo != NULL) {
 149     int i = mdo->invocation_count_delta();
 150     int b = mdo->backedge_count_delta();
 151     return call_predicate_helper<CompLevel_full_profile>(i, b, 1);
 152   }
 153   return false;
 154 }
 155 
 156 // Called with the queue locked and with at least one element
 157 CompileTask* AdvancedThresholdPolicy::select_task(CompileQueue* compile_queue) {
 158   CompileTask *max_task = NULL;
 159   methodOop max_method;
 160   jlong t = os::javaTimeMillis();
 161   // Iterate through the queue and find a method with a maximum rate.
 162   for (CompileTask* task = compile_queue->first(); task != NULL;) {
 163     CompileTask* next_task = task->next();
 164     methodOop method = (methodOop)JNIHandles::resolve(task->method_handle());
 165     methodDataOop mdo = method->method_data();
 166     update_rate(t, method);
 167     if (max_task == NULL) {
 168       max_task = task;
 169       max_method = method;
 170     } else {
 171       // If a method has been stale for some time, remove it from the queue.
 172       if (is_stale(t, TieredCompileTaskTimeout, method) && !is_old(method)) {
 173         if (PrintTieredEvents) {
 174           print_event(REMOVE_FROM_QUEUE, method, method, task->osr_bci(), (CompLevel)task->comp_level());
 175         }
 176         CompileTaskWrapper ctw(task); // Frees the task
 177         compile_queue->remove(task);
 178         method->clear_queued_for_compilation();
 179         task = next_task;
 180         continue;
 181       }
 182 
 183       // Select a method with a higher rate
 184       if (compare_methods(method, max_method)) {
 185         max_task = task;
 186         max_method = method;
 187       }
 188     }
 189     task = next_task;
 190   }
 191 
 192   if (max_task->comp_level() == CompLevel_full_profile && TieredStopAtLevel > CompLevel_full_profile
 193       && is_method_profiled(max_method)) {
 194     max_task->set_comp_level(CompLevel_limited_profile);
 195     if (PrintTieredEvents) {
 196       print_event(UPDATE_IN_QUEUE, max_method, max_method, max_task->osr_bci(), (CompLevel)max_task->comp_level());
 197     }
 198   }
 199 
 200   return max_task;
 201 }
 202 
 203 double AdvancedThresholdPolicy::threshold_scale(CompLevel level, int feedback_k) {
 204   double queue_size = CompileBroker::queue_size(level);
 205   int comp_count = compiler_count(level);
 206   double k = queue_size / (feedback_k * comp_count) + 1;
 207   return k;
 208 }
 209 
 210 // Call and loop predicates determine whether a transition to a higher
 211 // compilation level should be performed (pointers to predicate functions
 212 // are passed to common()).
 213 // Tier?LoadFeedback is basically a coefficient that determines of




 139         return true;
 140       }
 141     }
 142   return false;
 143 }
 144 
 145 // Is method profiled enough?
 146 bool AdvancedThresholdPolicy::is_method_profiled(methodOop method) {
 147   methodDataOop mdo = method->method_data();
 148   if (mdo != NULL) {
 149     int i = mdo->invocation_count_delta();
 150     int b = mdo->backedge_count_delta();
 151     return call_predicate_helper<CompLevel_full_profile>(i, b, 1);
 152   }
 153   return false;
 154 }
 155 
 156 // Called with the queue locked and with at least one element
 157 CompileTask* AdvancedThresholdPolicy::select_task(CompileQueue* compile_queue) {
 158   CompileTask *max_task = NULL;
 159   methodHandle max_method;
 160   jlong t = os::javaTimeMillis();
 161   // Iterate through the queue and find a method with a maximum rate.
 162   for (CompileTask* task = compile_queue->first(); task != NULL;) {
 163     CompileTask* next_task = task->next();
 164     methodHandle method = (methodOop)JNIHandles::resolve(task->method_handle());
 165     update_rate(t, method());

 166     if (max_task == NULL) {
 167       max_task = task;
 168       max_method = method;
 169     } else {
 170       // If a method has been stale for some time, remove it from the queue.
 171       if (is_stale(t, TieredCompileTaskTimeout, method()) && !is_old(method())) {
 172         if (PrintTieredEvents) {
 173           print_event(REMOVE_FROM_QUEUE, method, method, task->osr_bci(), (CompLevel)task->comp_level());
 174         }
 175         CompileTaskWrapper ctw(task); // Frees the task
 176         compile_queue->remove(task);
 177         method->clear_queued_for_compilation();
 178         task = next_task;
 179         continue;
 180       }
 181 
 182       // Select a method with a higher rate
 183       if (compare_methods(method(), max_method())) {
 184         max_task = task;
 185         max_method = method;
 186       }
 187     }
 188     task = next_task;
 189   }
 190 
 191   if (max_task->comp_level() == CompLevel_full_profile && TieredStopAtLevel > CompLevel_full_profile
 192       && is_method_profiled(max_method())) {
 193     max_task->set_comp_level(CompLevel_limited_profile);
 194     if (PrintTieredEvents) {
 195       print_event(UPDATE_IN_QUEUE, max_method, max_method, max_task->osr_bci(), (CompLevel)max_task->comp_level());
 196     }
 197   }
 198 
 199   return max_task;
 200 }
 201 
 202 double AdvancedThresholdPolicy::threshold_scale(CompLevel level, int feedback_k) {
 203   double queue_size = CompileBroker::queue_size(level);
 204   int comp_count = compiler_count(level);
 205   double k = queue_size / (feedback_k * comp_count) + 1;
 206   return k;
 207 }
 208 
 209 // Call and loop predicates determine whether a transition to a higher
 210 // compilation level should be performed (pointers to predicate functions
 211 // are passed to common()).
 212 // Tier?LoadFeedback is basically a coefficient that determines of


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