src/share/vm/compiler/compileBroker.cpp

Print this page




 120 PerfCounter* CompileBroker::_perf_total_osr_compile_count = NULL;
 121 PerfCounter* CompileBroker::_perf_total_standard_compile_count = NULL;
 122 
 123 PerfCounter* CompileBroker::_perf_sum_osr_bytes_compiled = NULL;
 124 PerfCounter* CompileBroker::_perf_sum_standard_bytes_compiled = NULL;
 125 PerfCounter* CompileBroker::_perf_sum_nmethod_size = NULL;
 126 PerfCounter* CompileBroker::_perf_sum_nmethod_code_size = NULL;
 127 
 128 PerfStringVariable* CompileBroker::_perf_last_method = NULL;
 129 PerfStringVariable* CompileBroker::_perf_last_failed_method = NULL;
 130 PerfStringVariable* CompileBroker::_perf_last_invalidated_method = NULL;
 131 PerfVariable*       CompileBroker::_perf_last_compile_type = NULL;
 132 PerfVariable*       CompileBroker::_perf_last_compile_size = NULL;
 133 PerfVariable*       CompileBroker::_perf_last_failed_type = NULL;
 134 PerfVariable*       CompileBroker::_perf_last_invalidated_type = NULL;
 135 
 136 // Timers and counters for generating statistics
 137 elapsedTimer CompileBroker::_t_total_compilation;
 138 elapsedTimer CompileBroker::_t_osr_compilation;
 139 elapsedTimer CompileBroker::_t_standard_compilation;


 140 
 141 int CompileBroker::_total_bailout_count          = 0;
 142 int CompileBroker::_total_invalidated_count      = 0;
 143 int CompileBroker::_total_compile_count          = 0;
 144 int CompileBroker::_total_osr_compile_count      = 0;
 145 int CompileBroker::_total_standard_compile_count = 0;
 146 
 147 int CompileBroker::_sum_osr_bytes_compiled       = 0;
 148 int CompileBroker::_sum_standard_bytes_compiled  = 0;
 149 int CompileBroker::_sum_nmethod_size             = 0;
 150 int CompileBroker::_sum_nmethod_code_size        = 0;
 151 
 152 long CompileBroker::_peak_compilation_time       = 0;
 153 
 154 CompileQueue* CompileBroker::_c2_compile_queue   = NULL;
 155 CompileQueue* CompileBroker::_c1_compile_queue   = NULL;
 156 
 157 GrowableArray<CompilerThread*>* CompileBroker::_compiler_threads = NULL;
 158 
 159 


2230 
2231 // ------------------------------------------------------------------
2232 // CompileBroker::collect_statistics
2233 //
2234 // Collect statistics about the compilation.
2235 
2236 void CompileBroker::collect_statistics(CompilerThread* thread, elapsedTimer time, CompileTask* task) {
2237   bool success = task->is_success();
2238   methodHandle method (thread, task->method());
2239   uint compile_id = task->compile_id();
2240   bool is_osr = (task->osr_bci() != standard_entry_bci);
2241   nmethod* code = task->code();
2242   CompilerCounters* counters = thread->counters();
2243 
2244   assert(code == NULL || code->is_locked_by_vm(), "will survive the MutexLocker");
2245   MutexLocker locker(CompileStatistics_lock);
2246 
2247   // _perf variables are production performance counters which are
2248   // updated regardless of the setting of the CITime and CITimeEach flags
2249   //





2250   if (!success) {
2251     _total_bailout_count++;
2252     if (UsePerfData) {
2253       _perf_last_failed_method->set_value(counters->current_method());
2254       _perf_last_failed_type->set_value(counters->compile_type());
2255       _perf_total_bailout_count->inc();
2256     }

2257   } else if (code == NULL) {
2258     if (UsePerfData) {
2259       _perf_last_invalidated_method->set_value(counters->current_method());
2260       _perf_last_invalidated_type->set_value(counters->compile_type());
2261       _perf_total_invalidated_count->inc();
2262     }
2263     _total_invalidated_count++;

2264   } else {
2265     // Compilation succeeded
2266 
2267     // update compilation ticks - used by the implementation of
2268     // java.lang.management.CompilationMBean
2269     _perf_total_compilation->inc(time.ticks());
2270 
2271     _t_total_compilation.add(time);
2272     _peak_compilation_time = time.milliseconds() > _peak_compilation_time ? time.milliseconds() : _peak_compilation_time;
2273 
2274     if (CITime) {
2275       if (is_osr) {
2276         _t_osr_compilation.add(time);
2277         _sum_osr_bytes_compiled += method->code_size() + task->num_inlined_bytecodes();
2278       } else {
2279         _t_standard_compilation.add(time);
2280         _sum_standard_bytes_compiled += method->code_size() + task->num_inlined_bytecodes();
2281       }
2282     }
2283 
2284     if (UsePerfData) {
2285       // save the name of the last method compiled
2286       _perf_last_method->set_value(counters->current_method());
2287       _perf_last_compile_type->set_value(counters->compile_type());
2288       _perf_last_compile_size->set_value(method->code_size() +
2289                                          task->num_inlined_bytecodes());
2290       if (is_osr) {
2291         _perf_osr_compilation->inc(time.ticks());


2319     } else {
2320       if (UsePerfData) _perf_total_standard_compile_count->inc();
2321       _total_standard_compile_count++;
2322     }
2323   }
2324   // set the current method for the thread to null
2325   if (UsePerfData) counters->set_current_method("");
2326 }
2327 
2328 const char* CompileBroker::compiler_name(int comp_level) {
2329   AbstractCompiler *comp = CompileBroker::compiler(comp_level);
2330   if (comp == NULL) {
2331     return "no compiler";
2332   } else {
2333     return (comp->name());
2334   }
2335 }
2336 
2337 void CompileBroker::print_times() {
2338   tty->cr();
2339   tty->print_cr("Accumulated compiler times (for compiled methods only)");
2340   tty->print_cr("------------------------------------------------");
2341                //0000000000111111111122222222223333333333444444444455555555556666666666
2342                //0123456789012345678901234567890123456789012345678901234567890123456789
2343   tty->print_cr("  Total compilation time   : %6.3f s", CompileBroker::_t_total_compilation.seconds());
2344   tty->print_cr("    Standard compilation   : %6.3f s, Average : %2.3f",
2345                 CompileBroker::_t_standard_compilation.seconds(),
2346                 CompileBroker::_t_standard_compilation.seconds() / CompileBroker::_total_standard_compile_count);
2347   tty->print_cr("    On stack replacement   : %6.3f s, Average : %2.3f", CompileBroker::_t_osr_compilation.seconds(), CompileBroker::_t_osr_compilation.seconds() / CompileBroker::_total_osr_compile_count);








2348 
2349   AbstractCompiler *comp = compiler(CompLevel_simple);
2350   if (comp != NULL) {

2351     comp->print_timers();
2352   }
2353   comp = compiler(CompLevel_full_optimization);
2354   if (comp != NULL) {

2355     comp->print_timers();
2356   }
2357   tty->cr();
2358   tty->print_cr("  Total compiled methods   : %6d methods", CompileBroker::_total_compile_count);
2359   tty->print_cr("    Standard compilation   : %6d methods", CompileBroker::_total_standard_compile_count);
2360   tty->print_cr("    On stack replacement   : %6d methods", CompileBroker::_total_osr_compile_count);
2361   int tcb = CompileBroker::_sum_osr_bytes_compiled + CompileBroker::_sum_standard_bytes_compiled;
2362   tty->print_cr("  Total compiled bytecodes : %6d bytes", tcb);
2363   tty->print_cr("    Standard compilation   : %6d bytes", CompileBroker::_sum_standard_bytes_compiled);
2364   tty->print_cr("    On stack replacement   : %6d bytes", CompileBroker::_sum_osr_bytes_compiled);
2365   int bps = (int)(tcb / CompileBroker::_t_total_compilation.seconds());
2366   tty->print_cr("  Average compilation speed: %6d bytes/s", bps);
2367   tty->cr();
2368   tty->print_cr("  nmethod code size        : %6d bytes", CompileBroker::_sum_nmethod_code_size);
2369   tty->print_cr("  nmethod total size       : %6d bytes", CompileBroker::_sum_nmethod_size);
2370 }
2371 
2372 // Debugging output for failure
2373 void CompileBroker::print_last_compile() {
2374   if ( _last_compile_level != CompLevel_none &&


 120 PerfCounter* CompileBroker::_perf_total_osr_compile_count = NULL;
 121 PerfCounter* CompileBroker::_perf_total_standard_compile_count = NULL;
 122 
 123 PerfCounter* CompileBroker::_perf_sum_osr_bytes_compiled = NULL;
 124 PerfCounter* CompileBroker::_perf_sum_standard_bytes_compiled = NULL;
 125 PerfCounter* CompileBroker::_perf_sum_nmethod_size = NULL;
 126 PerfCounter* CompileBroker::_perf_sum_nmethod_code_size = NULL;
 127 
 128 PerfStringVariable* CompileBroker::_perf_last_method = NULL;
 129 PerfStringVariable* CompileBroker::_perf_last_failed_method = NULL;
 130 PerfStringVariable* CompileBroker::_perf_last_invalidated_method = NULL;
 131 PerfVariable*       CompileBroker::_perf_last_compile_type = NULL;
 132 PerfVariable*       CompileBroker::_perf_last_compile_size = NULL;
 133 PerfVariable*       CompileBroker::_perf_last_failed_type = NULL;
 134 PerfVariable*       CompileBroker::_perf_last_invalidated_type = NULL;
 135 
 136 // Timers and counters for generating statistics
 137 elapsedTimer CompileBroker::_t_total_compilation;
 138 elapsedTimer CompileBroker::_t_osr_compilation;
 139 elapsedTimer CompileBroker::_t_standard_compilation;
 140 elapsedTimer CompileBroker::_t_invalidated_compilation;
 141 elapsedTimer CompileBroker::_t_bailedout_compilation;
 142 
 143 int CompileBroker::_total_bailout_count          = 0;
 144 int CompileBroker::_total_invalidated_count      = 0;
 145 int CompileBroker::_total_compile_count          = 0;
 146 int CompileBroker::_total_osr_compile_count      = 0;
 147 int CompileBroker::_total_standard_compile_count = 0;
 148 
 149 int CompileBroker::_sum_osr_bytes_compiled       = 0;
 150 int CompileBroker::_sum_standard_bytes_compiled  = 0;
 151 int CompileBroker::_sum_nmethod_size             = 0;
 152 int CompileBroker::_sum_nmethod_code_size        = 0;
 153 
 154 long CompileBroker::_peak_compilation_time       = 0;
 155 
 156 CompileQueue* CompileBroker::_c2_compile_queue   = NULL;
 157 CompileQueue* CompileBroker::_c1_compile_queue   = NULL;
 158 
 159 GrowableArray<CompilerThread*>* CompileBroker::_compiler_threads = NULL;
 160 
 161 


2232 
2233 // ------------------------------------------------------------------
2234 // CompileBroker::collect_statistics
2235 //
2236 // Collect statistics about the compilation.
2237 
2238 void CompileBroker::collect_statistics(CompilerThread* thread, elapsedTimer time, CompileTask* task) {
2239   bool success = task->is_success();
2240   methodHandle method (thread, task->method());
2241   uint compile_id = task->compile_id();
2242   bool is_osr = (task->osr_bci() != standard_entry_bci);
2243   nmethod* code = task->code();
2244   CompilerCounters* counters = thread->counters();
2245 
2246   assert(code == NULL || code->is_locked_by_vm(), "will survive the MutexLocker");
2247   MutexLocker locker(CompileStatistics_lock);
2248 
2249   // _perf variables are production performance counters which are
2250   // updated regardless of the setting of the CITime and CITimeEach flags
2251   //
2252   
2253   // account all time, including bailouts and failures in this counter;
2254   // C1 and C2 counters are counting both successful and unsuccessful compiles
2255   _t_total_compilation.add(time);
2256   
2257   if (!success) {
2258     _total_bailout_count++;
2259     if (UsePerfData) {
2260       _perf_last_failed_method->set_value(counters->current_method());
2261       _perf_last_failed_type->set_value(counters->compile_type());
2262       _perf_total_bailout_count->inc();
2263     }
2264     _t_bailedout_compilation.add(time);
2265   } else if (code == NULL) {
2266     if (UsePerfData) {
2267       _perf_last_invalidated_method->set_value(counters->current_method());
2268       _perf_last_invalidated_type->set_value(counters->compile_type());
2269       _perf_total_invalidated_count->inc();
2270     }
2271     _total_invalidated_count++;
2272     _t_invalidated_compilation.add(time);
2273   } else {
2274     // Compilation succeeded
2275 
2276     // update compilation ticks - used by the implementation of
2277     // java.lang.management.CompilationMBean
2278     _perf_total_compilation->inc(time.ticks());


2279     _peak_compilation_time = time.milliseconds() > _peak_compilation_time ? time.milliseconds() : _peak_compilation_time;
2280 
2281     if (CITime) {
2282       if (is_osr) {
2283         _t_osr_compilation.add(time);
2284         _sum_osr_bytes_compiled += method->code_size() + task->num_inlined_bytecodes();
2285       } else {
2286         _t_standard_compilation.add(time);
2287         _sum_standard_bytes_compiled += method->code_size() + task->num_inlined_bytecodes();
2288       }
2289     }
2290 
2291     if (UsePerfData) {
2292       // save the name of the last method compiled
2293       _perf_last_method->set_value(counters->current_method());
2294       _perf_last_compile_type->set_value(counters->compile_type());
2295       _perf_last_compile_size->set_value(method->code_size() +
2296                                          task->num_inlined_bytecodes());
2297       if (is_osr) {
2298         _perf_osr_compilation->inc(time.ticks());


2326     } else {
2327       if (UsePerfData) _perf_total_standard_compile_count->inc();
2328       _total_standard_compile_count++;
2329     }
2330   }
2331   // set the current method for the thread to null
2332   if (UsePerfData) counters->set_current_method("");
2333 }
2334 
2335 const char* CompileBroker::compiler_name(int comp_level) {
2336   AbstractCompiler *comp = CompileBroker::compiler(comp_level);
2337   if (comp == NULL) {
2338     return "no compiler";
2339   } else {
2340     return (comp->name());
2341   }
2342 }
2343 
2344 void CompileBroker::print_times() {
2345   tty->cr();
2346   tty->print_cr("Accumulated compiler times");
2347   tty->print_cr("----------------------------------------------------------");
2348                //0000000000111111111122222222223333333333444444444455555555556666666666
2349                //0123456789012345678901234567890123456789012345678901234567890123456789
2350   tty->print_cr("  Total compilation time   : %7.3f s", CompileBroker::_t_total_compilation.seconds());
2351   tty->print_cr("    Standard compilation   : %7.3f s, Average : %2.3f s",
2352                 CompileBroker::_t_standard_compilation.seconds(),
2353                 CompileBroker::_t_standard_compilation.seconds() / CompileBroker::_total_standard_compile_count);
2354   tty->print_cr("    Bailed out compilation : %7.3f s, Average : %2.3f s", 
2355                 CompileBroker::_t_bailedout_compilation.seconds(),
2356                 CompileBroker::_t_bailedout_compilation.seconds() / CompileBroker::_total_bailout_count);
2357   tty->print_cr("    On stack replacement   : %7.3f s, Average : %2.3f s",
2358                 CompileBroker::_t_osr_compilation.seconds(),
2359                 CompileBroker::_t_osr_compilation.seconds() / CompileBroker::_total_osr_compile_count);
2360   tty->print_cr("    Invalidated            : %7.3f s, Average : %2.3f s",
2361                 CompileBroker::_t_invalidated_compilation.seconds(),
2362                 CompileBroker::_t_invalidated_compilation.seconds() / CompileBroker::_total_invalidated_count);
2363   
2364   AbstractCompiler *comp = compiler(CompLevel_simple);
2365   if (comp != NULL) {
2366     tty->cr();
2367     comp->print_timers();
2368   }
2369   comp = compiler(CompLevel_full_optimization);
2370   if (comp != NULL) {
2371     tty->cr();
2372     comp->print_timers();
2373   }
2374   tty->cr();
2375   tty->print_cr("  Total compiled methods   : %6d methods", CompileBroker::_total_compile_count);
2376   tty->print_cr("    Standard compilation   : %6d methods", CompileBroker::_total_standard_compile_count);
2377   tty->print_cr("    On stack replacement   : %6d methods", CompileBroker::_total_osr_compile_count);
2378   int tcb = CompileBroker::_sum_osr_bytes_compiled + CompileBroker::_sum_standard_bytes_compiled;
2379   tty->print_cr("  Total compiled bytecodes : %6d bytes", tcb);
2380   tty->print_cr("    Standard compilation   : %6d bytes", CompileBroker::_sum_standard_bytes_compiled);
2381   tty->print_cr("    On stack replacement   : %6d bytes", CompileBroker::_sum_osr_bytes_compiled);
2382   int bps = (int)(tcb / CompileBroker::_t_total_compilation.seconds());
2383   tty->print_cr("  Average compilation speed: %6d bytes/s", bps);
2384   tty->cr();
2385   tty->print_cr("  nmethod code size        : %6d bytes", CompileBroker::_sum_nmethod_code_size);
2386   tty->print_cr("  nmethod total size       : %6d bytes", CompileBroker::_sum_nmethod_size);
2387 }
2388 
2389 // Debugging output for failure
2390 void CompileBroker::print_last_compile() {
2391   if ( _last_compile_level != CompLevel_none &&