< prev index next >

src/share/vm/compiler/compileBroker.cpp

Print this page
rev 9032 : 8134607: Remove per-compiler performance counters
Reviewed-by: duke


 436   assert(MethodCompileQueue_lock->owned_by_self(), "must own lock");
 437   st->print_cr("Contents of %s", name());
 438   st->print_cr("----------------------------");
 439   CompileTask* task = _first;
 440   if (task == NULL) {
 441     st->print_cr("Empty");
 442   } else {
 443     while (task != NULL) {
 444       task->print(st, NULL, true, true);
 445       task = task->next();
 446     }
 447   }
 448   st->print_cr("----------------------------");
 449 }
 450 
 451 void CompileQueue::print_tty() {
 452   ttyLocker ttyl;
 453   print(tty);
 454 }
 455 
 456 CompilerCounters::CompilerCounters(const char* thread_name, int instance, TRAPS) {
 457 
 458   _current_method[0] = '\0';
 459   _compile_type = CompileBroker::no_compile;
 460 
 461   if (UsePerfData) {
 462     ResourceMark rm;
 463 
 464     // create the thread instance name space string - don't create an
 465     // instance subspace if instance is -1 - keeps the adapterThread
 466     // counters  from having a ".0" namespace.
 467     const char* thread_i = (instance == -1) ? thread_name :
 468                       PerfDataManager::name_space(thread_name, instance);
 469 
 470 
 471     char* name = PerfDataManager::counter_name(thread_i, "method");
 472     _perf_current_method =
 473                PerfDataManager::create_string_variable(SUN_CI, name,
 474                                                        cmname_buffer_length,
 475                                                        _current_method, CHECK);
 476 
 477     name = PerfDataManager::counter_name(thread_i, "type");
 478     _perf_compile_type = PerfDataManager::create_variable(SUN_CI, name,
 479                                                           PerfData::U_None,
 480                                                          (jlong)_compile_type,
 481                                                           CHECK);
 482 
 483     name = PerfDataManager::counter_name(thread_i, "time");
 484     _perf_time = PerfDataManager::create_counter(SUN_CI, name,
 485                                                  PerfData::U_Ticks, CHECK);
 486 
 487     name = PerfDataManager::counter_name(thread_i, "compiles");
 488     _perf_compiles = PerfDataManager::create_counter(SUN_CI, name,
 489                                                      PerfData::U_Events, CHECK);
 490   }
 491 }
 492 
 493 // ------------------------------------------------------------------
 494 // CompileBroker::compilation_init
 495 //
 496 // Initialize the Compilation object
 497 void CompileBroker::compilation_init() {
 498   _last_method_compiled[0] = '\0';
 499 
 500   // No need to initialize compilation system if we do not use it.
 501   if (!UseCompiler) {
 502     return;
 503   }
 504 #ifndef SHARK
 505   // Set the interface to the current compiler(s).
 506   int c1_count = CompilationPolicy::policy()->compiler_count(CompLevel_simple);
 507   int c2_count = CompilationPolicy::policy()->compiler_count(CompLevel_full_optimization);
 508 #ifdef COMPILER1
 509   if (c1_count > 0) {
 510     _compilers[0] = new Compiler();


 717 #if !defined(ZERO) && !defined(SHARK)
 718   assert(c2_compiler_count > 0 || c1_compiler_count > 0, "No compilers?");
 719 #endif // !ZERO && !SHARK
 720   // Initialize the compilation queue
 721   if (c2_compiler_count > 0) {
 722     _c2_compile_queue  = new CompileQueue("C2 compile queue");
 723     _compilers[1]->set_num_compiler_threads(c2_compiler_count);
 724   }
 725   if (c1_compiler_count > 0) {
 726     _c1_compile_queue  = new CompileQueue("C1 compile queue");
 727     _compilers[0]->set_num_compiler_threads(c1_compiler_count);
 728   }
 729 
 730   int compiler_count = c1_compiler_count + c2_compiler_count;
 731 
 732   char name_buffer[256];
 733   const bool compiler_thread = true;
 734   for (int i = 0; i < c2_compiler_count; i++) {
 735     // Create a name for our thread.
 736     sprintf(name_buffer, "C2 CompilerThread%d", i);
 737     CompilerCounters* counters = new CompilerCounters("compilerThread", i, CHECK);
 738     // Shark and C2
 739     make_thread(name_buffer, _c2_compile_queue, counters, _compilers[1], compiler_thread, CHECK);
 740   }
 741 
 742   for (int i = c2_compiler_count; i < compiler_count; i++) {
 743     // Create a name for our thread.
 744     sprintf(name_buffer, "C1 CompilerThread%d", i);
 745     CompilerCounters* counters = new CompilerCounters("compilerThread", i, CHECK);
 746     // C1
 747     make_thread(name_buffer, _c1_compile_queue, counters, _compilers[0], compiler_thread, CHECK);
 748   }
 749 
 750   if (UsePerfData) {
 751     PerfDataManager::create_constant(SUN_CI, "threads", PerfData::U_Bytes, compiler_count, CHECK);
 752   }
 753 
 754   if (MethodFlushing) {
 755     // Initialize the sweeper thread
 756     make_thread("Sweeper thread", NULL, NULL, NULL, false, CHECK);
 757   }
 758 }
 759 
 760 
 761 /**
 762  * Set the methods on the stack as on_stack so that redefine classes doesn't
 763  * reclaim them. This method is executed at a safepoint.
 764  */
 765 void CompileBroker::mark_on_stack() {


1418 
1419   // Poll for new compilation tasks as long as the JVM runs. Compilation
1420   // should only be disabled if something went wrong while initializing the
1421   // compiler runtimes. This, in turn, should not happen. The only known case
1422   // when compiler runtime initialization fails is if there is not enough free
1423   // space in the code cache to generate the necessary stubs, etc.
1424   while (!is_compilation_disabled_forever()) {
1425     // We need this HandleMark to avoid leaking VM handles.
1426     HandleMark hm(thread);
1427 
1428     CompileTask* task = queue->get();
1429     if (task == NULL) {
1430       continue;
1431     }
1432 
1433     // Give compiler threads an extra quanta.  They tend to be bursty and
1434     // this helps the compiler to finish up the job.
1435     if (CompilerThreadHintNoPreempt) {
1436       os::hint_no_preempt();
1437     }
1438 
1439     // trace per thread time and compile statistics
1440     CompilerCounters* counters = ((CompilerThread*)thread)->counters();
1441     PerfTraceTimedEvent(counters->time_counter(), counters->compile_counter());
1442 
1443     // Assign the task to the current thread.  Mark this compilation
1444     // thread as active for the profiler.
1445     CompileTaskWrapper ctw(task);
1446     nmethodLocker result_handle;  // (handle for the nmethod produced by this task)
1447     task->set_code_handle(&result_handle);
1448     methodHandle method(thread, task->method());
1449 
1450     // Never compile a method if breakpoints are present in it
1451     if (method()->number_of_breakpoints() == 0) {
1452       // Compile the method.
1453       if ((UseCompiler || AlwaysCompileLoopMethods) && CompileBroker::should_compile_new_jobs()) {
1454         invoke_compiler_on_method(task);
1455       } else {
1456         // After compilation is disabled, remove remaining methods from queue
1457         method->clear_queued_for_compilation();
1458         task->set_failure_reason("compilation is disabled");
1459       }
1460     }
1461   }




 436   assert(MethodCompileQueue_lock->owned_by_self(), "must own lock");
 437   st->print_cr("Contents of %s", name());
 438   st->print_cr("----------------------------");
 439   CompileTask* task = _first;
 440   if (task == NULL) {
 441     st->print_cr("Empty");
 442   } else {
 443     while (task != NULL) {
 444       task->print(st, NULL, true, true);
 445       task = task->next();
 446     }
 447   }
 448   st->print_cr("----------------------------");
 449 }
 450 
 451 void CompileQueue::print_tty() {
 452   ttyLocker ttyl;
 453   print(tty);
 454 }
 455 
 456 CompilerCounters::CompilerCounters() {

 457   _current_method[0] = '\0';
 458   _compile_type = CompileBroker::no_compile;































 459 }
 460 
 461 // ------------------------------------------------------------------
 462 // CompileBroker::compilation_init
 463 //
 464 // Initialize the Compilation object
 465 void CompileBroker::compilation_init() {
 466   _last_method_compiled[0] = '\0';
 467 
 468   // No need to initialize compilation system if we do not use it.
 469   if (!UseCompiler) {
 470     return;
 471   }
 472 #ifndef SHARK
 473   // Set the interface to the current compiler(s).
 474   int c1_count = CompilationPolicy::policy()->compiler_count(CompLevel_simple);
 475   int c2_count = CompilationPolicy::policy()->compiler_count(CompLevel_full_optimization);
 476 #ifdef COMPILER1
 477   if (c1_count > 0) {
 478     _compilers[0] = new Compiler();


 685 #if !defined(ZERO) && !defined(SHARK)
 686   assert(c2_compiler_count > 0 || c1_compiler_count > 0, "No compilers?");
 687 #endif // !ZERO && !SHARK
 688   // Initialize the compilation queue
 689   if (c2_compiler_count > 0) {
 690     _c2_compile_queue  = new CompileQueue("C2 compile queue");
 691     _compilers[1]->set_num_compiler_threads(c2_compiler_count);
 692   }
 693   if (c1_compiler_count > 0) {
 694     _c1_compile_queue  = new CompileQueue("C1 compile queue");
 695     _compilers[0]->set_num_compiler_threads(c1_compiler_count);
 696   }
 697 
 698   int compiler_count = c1_compiler_count + c2_compiler_count;
 699 
 700   char name_buffer[256];
 701   const bool compiler_thread = true;
 702   for (int i = 0; i < c2_compiler_count; i++) {
 703     // Create a name for our thread.
 704     sprintf(name_buffer, "C2 CompilerThread%d", i);
 705     CompilerCounters* counters = new CompilerCounters();
 706     // Shark and C2
 707     make_thread(name_buffer, _c2_compile_queue, counters, _compilers[1], compiler_thread, CHECK);
 708   }
 709 
 710   for (int i = c2_compiler_count; i < compiler_count; i++) {
 711     // Create a name for our thread.
 712     sprintf(name_buffer, "C1 CompilerThread%d", i);
 713     CompilerCounters* counters = new CompilerCounters();
 714     // C1
 715     make_thread(name_buffer, _c1_compile_queue, counters, _compilers[0], compiler_thread, CHECK);
 716   }
 717 
 718   if (UsePerfData) {
 719     PerfDataManager::create_constant(SUN_CI, "threads", PerfData::U_Bytes, compiler_count, CHECK);
 720   }
 721 
 722   if (MethodFlushing) {
 723     // Initialize the sweeper thread
 724     make_thread("Sweeper thread", NULL, NULL, NULL, false, CHECK);
 725   }
 726 }
 727 
 728 
 729 /**
 730  * Set the methods on the stack as on_stack so that redefine classes doesn't
 731  * reclaim them. This method is executed at a safepoint.
 732  */
 733 void CompileBroker::mark_on_stack() {


1386 
1387   // Poll for new compilation tasks as long as the JVM runs. Compilation
1388   // should only be disabled if something went wrong while initializing the
1389   // compiler runtimes. This, in turn, should not happen. The only known case
1390   // when compiler runtime initialization fails is if there is not enough free
1391   // space in the code cache to generate the necessary stubs, etc.
1392   while (!is_compilation_disabled_forever()) {
1393     // We need this HandleMark to avoid leaking VM handles.
1394     HandleMark hm(thread);
1395 
1396     CompileTask* task = queue->get();
1397     if (task == NULL) {
1398       continue;
1399     }
1400 
1401     // Give compiler threads an extra quanta.  They tend to be bursty and
1402     // this helps the compiler to finish up the job.
1403     if (CompilerThreadHintNoPreempt) {
1404       os::hint_no_preempt();
1405     }




1406 
1407     // Assign the task to the current thread.  Mark this compilation
1408     // thread as active for the profiler.
1409     CompileTaskWrapper ctw(task);
1410     nmethodLocker result_handle;  // (handle for the nmethod produced by this task)
1411     task->set_code_handle(&result_handle);
1412     methodHandle method(thread, task->method());
1413 
1414     // Never compile a method if breakpoints are present in it
1415     if (method()->number_of_breakpoints() == 0) {
1416       // Compile the method.
1417       if ((UseCompiler || AlwaysCompileLoopMethods) && CompileBroker::should_compile_new_jobs()) {
1418         invoke_compiler_on_method(task);
1419       } else {
1420         // After compilation is disabled, remove remaining methods from queue
1421         method->clear_queued_for_compilation();
1422         task->set_failure_reason("compilation is disabled");
1423       }
1424     }
1425   }


< prev index next >