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

src/share/vm/runtime/advancedThresholdPolicy.cpp

Print this page
rev 10344 : 8150646: Add support for blocking compiles through whitebox API


   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 #include "precompiled.hpp"
  26 #include "code/codeCache.hpp"


  27 #include "compiler/compileTask.hpp"
  28 #include "runtime/advancedThresholdPolicy.hpp"
  29 #include "runtime/simpleThresholdPolicy.inline.hpp"
  30 
  31 #ifdef TIERED
  32 // Print an event.
  33 void AdvancedThresholdPolicy::print_specific(EventType type, methodHandle mh, methodHandle imh,
  34                                              int bci, CompLevel level) {
  35   tty->print(" rate=");
  36   if (mh->prev_time() == 0) tty->print("n/a");
  37   else tty->print("%f", mh->rate());
  38 
  39   tty->print(" k=%.2lf,%.2lf", threshold_scale(CompLevel_full_profile, Tier3LoadFeedback),
  40                                threshold_scale(CompLevel_full_optimization, Tier4LoadFeedback));
  41 
  42 }
  43 
  44 void AdvancedThresholdPolicy::initialize() {
  45   // Turn on ergonomic compiler count selection
  46   if (FLAG_IS_DEFAULT(CICompilerCountPerCPU) && FLAG_IS_DEFAULT(CICompilerCount)) {


 162   return false;
 163 }
 164 
 165 // Called with the queue locked and with at least one element
 166 CompileTask* AdvancedThresholdPolicy::select_task(CompileQueue* compile_queue) {
 167 #if INCLUDE_JVMCI
 168   CompileTask *max_blocking_task = NULL;
 169 #endif
 170   CompileTask *max_task = NULL;
 171   Method* max_method = NULL;
 172   jlong t = os::javaTimeMillis();
 173   // Iterate through the queue and find a method with a maximum rate.
 174   for (CompileTask* task = compile_queue->first(); task != NULL;) {
 175     CompileTask* next_task = task->next();
 176     Method* method = task->method();
 177     update_rate(t, method);
 178     if (max_task == NULL) {
 179       max_task = task;
 180       max_method = method;
 181     } else {














 182       // If a method has been stale for some time, remove it from the queue.
 183       if (is_stale(t, TieredCompileTaskTimeout, method) && !is_old(method)) {
 184         if (PrintTieredEvents) {
 185           print_event(REMOVE_FROM_QUEUE, method, method, task->osr_bci(), (CompLevel)task->comp_level());
 186         }
 187         task->log_task_dequeued("stale");
 188         compile_queue->remove_and_mark_stale(task);
 189         method->clear_queued_for_compilation();
 190         task = next_task;
 191         continue;
 192       }
 193 
 194       // Select a method with a higher rate
 195       if (compare_methods(method, max_method)) {
 196         max_task = task;
 197         max_method = method;
 198       }
 199     }
 200 #if INCLUDE_JVMCI
 201     if (UseJVMCICompiler && task->is_blocking()) {
 202       if (max_blocking_task == NULL || compare_methods(method, max_blocking_task->method())) {
 203         max_blocking_task = task;
 204       }
 205     }




   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 #include "precompiled.hpp"
  26 #include "code/codeCache.hpp"
  27 #include "compiler/compilerDirectives.hpp"
  28 #include "compiler/compilerOracle.hpp"
  29 #include "compiler/compileTask.hpp"
  30 #include "runtime/advancedThresholdPolicy.hpp"
  31 #include "runtime/simpleThresholdPolicy.inline.hpp"
  32 
  33 #ifdef TIERED
  34 // Print an event.
  35 void AdvancedThresholdPolicy::print_specific(EventType type, methodHandle mh, methodHandle imh,
  36                                              int bci, CompLevel level) {
  37   tty->print(" rate=");
  38   if (mh->prev_time() == 0) tty->print("n/a");
  39   else tty->print("%f", mh->rate());
  40 
  41   tty->print(" k=%.2lf,%.2lf", threshold_scale(CompLevel_full_profile, Tier3LoadFeedback),
  42                                threshold_scale(CompLevel_full_optimization, Tier4LoadFeedback));
  43 
  44 }
  45 
  46 void AdvancedThresholdPolicy::initialize() {
  47   // Turn on ergonomic compiler count selection
  48   if (FLAG_IS_DEFAULT(CICompilerCountPerCPU) && FLAG_IS_DEFAULT(CICompilerCount)) {


 164   return false;
 165 }
 166 
 167 // Called with the queue locked and with at least one element
 168 CompileTask* AdvancedThresholdPolicy::select_task(CompileQueue* compile_queue) {
 169 #if INCLUDE_JVMCI
 170   CompileTask *max_blocking_task = NULL;
 171 #endif
 172   CompileTask *max_task = NULL;
 173   Method* max_method = NULL;
 174   jlong t = os::javaTimeMillis();
 175   // Iterate through the queue and find a method with a maximum rate.
 176   for (CompileTask* task = compile_queue->first(); task != NULL;) {
 177     CompileTask* next_task = task->next();
 178     Method* method = task->method();
 179     update_rate(t, method);
 180     if (max_task == NULL) {
 181       max_task = task;
 182       max_method = method;
 183     } else {
 184       // Prefer 'blocking' compilations to minimize waits on them.
 185       // This also helps to prevent blocking compiles from getting stale.
 186       CompLevel level = (CompLevel)task->comp_level();
 187       bool backgroundCompilation;
 188       DirectiveSet* directive =
 189         DirectivesStack::getMatchingDirective(methodHandle(method),
 190                                               CompileBroker::compiler(level));
 191       backgroundCompilation = directive->BackgroundCompilationOption;
 192       DirectivesStack::release(directive);
 193       if (backgroundCompilation == false) {
 194         max_task = task;
 195         max_method = method;
 196         break;
 197       }
 198       // If a method has been stale for some time, remove it from the queue.
 199       if (is_stale(t, TieredCompileTaskTimeout, method) && !is_old(method)) {
 200         if (PrintTieredEvents) {
 201           print_event(REMOVE_FROM_QUEUE, method, method, task->osr_bci(), level);
 202         }
 203         task->log_task_dequeued("stale");
 204         compile_queue->remove_and_mark_stale(task);
 205         method->clear_queued_for_compilation();
 206         task = next_task;
 207         continue;
 208       }
 209 
 210       // Select a method with a higher rate
 211       if (compare_methods(method, max_method)) {
 212         max_task = task;
 213         max_method = method;
 214       }
 215     }
 216 #if INCLUDE_JVMCI
 217     if (UseJVMCICompiler && task->is_blocking()) {
 218       if (max_blocking_task == NULL || compare_methods(method, max_blocking_task->method())) {
 219         max_blocking_task = task;
 220       }
 221     }


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