src/share/vm/compiler/compileBroker.hpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/compiler

src/share/vm/compiler/compileBroker.hpp

Print this page




  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 #ifndef SHARE_VM_COMPILER_COMPILEBROKER_HPP
  26 #define SHARE_VM_COMPILER_COMPILEBROKER_HPP
  27 
  28 #include "ci/compilerInterface.hpp"
  29 #include "compiler/abstractCompiler.hpp"
  30 #include "runtime/perfData.hpp"

  31 
  32 class nmethod;
  33 class nmethodLocker;
  34 
  35 // CompileTask
  36 //
  37 // An entry in the compile queue.  It represents a pending or current
  38 // compilation.
  39 class CompileTask : public CHeapObj<mtCompiler> {
  40   friend class VMStructs;
  41 
  42  private:
  43   static CompileTask* _task_free_list;
  44 #ifdef ASSERT
  45   static int          _num_allocated_tasks;
  46 #endif
  47 
  48   Monitor*     _lock;
  49   uint         _compile_id;
  50   Method*      _method;


 123     print_compilation_impl(st, nm->method(), nm->compile_id(), nm->comp_level(),
 124                            nm->is_osr_method(), nm->is_osr_method() ? nm->osr_entry_bci() : -1, /*is_blocking*/ false,
 125                            msg, short_form, cr);
 126   }
 127 
 128   static void  print_inlining(outputStream* st, ciMethod* method, int inline_level, int bci, const char* msg = NULL);
 129   static void  print_inlining(ciMethod* method, int inline_level, int bci, const char* msg = NULL) {
 130     print_inlining(tty, method, inline_level, bci, msg);
 131   }
 132 
 133   // Redefine Classes support
 134   void mark_on_stack();
 135 
 136   static void  print_inline_indent(int inline_level, outputStream* st = tty);
 137 
 138   void         print_tty();
 139   void         print_line_on_error(outputStream* st, char* buf, int buflen);
 140 
 141   void         log_task(xmlStream* log);
 142   void         log_task_queued();

 143   void         log_task_start(CompileLog* log);
 144   void         log_task_done(CompileLog* log);
 145 
 146   void         set_failure_reason(const char* reason) {
 147     _failure_reason = reason;
 148   }
 149 };
 150 
 151 // CompilerCounters
 152 //
 153 // Per Compiler Performance Counters.
 154 //
 155 class CompilerCounters : public CHeapObj<mtCompiler> {
 156 
 157   public:
 158     enum {
 159       cmname_buffer_length = 160
 160     };
 161 
 162   private:


 341 
 342   static JavaThread* make_thread(const char* name, CompileQueue* queue, CompilerCounters* counters, AbstractCompiler* comp, bool compiler_thread, TRAPS);
 343   static void init_compiler_sweeper_threads(int c1_compiler_count, int c2_compiler_count);
 344   static bool compilation_is_complete  (methodHandle method, int osr_bci, int comp_level);
 345   static bool compilation_is_prohibited(methodHandle method, int osr_bci, int comp_level);
 346   static bool is_compile_blocking();
 347   static void preload_classes          (methodHandle method, TRAPS);
 348 
 349   static CompileTask* create_compile_task(CompileQueue* queue,
 350                                           int           compile_id,
 351                                           methodHandle  method,
 352                                           int           osr_bci,
 353                                           int           comp_level,
 354                                           methodHandle  hot_method,
 355                                           int           hot_count,
 356                                           const char*   comment,
 357                                           bool          blocking);
 358   static void wait_for_completion(CompileTask* task);
 359 
 360   static void invoke_compiler_on_method(CompileTask* task);

 361   static void set_last_compile(CompilerThread *thread, methodHandle method, bool is_osr, int comp_level);
 362   static void push_jni_handle_block();
 363   static void pop_jni_handle_block();
 364   static bool check_break_at(methodHandle method, int compile_id, bool is_osr);
 365   static void collect_statistics(CompilerThread* thread, elapsedTimer time, CompileTask* task);
 366 
 367   static void compile_method_base(methodHandle method,
 368                                   int osr_bci,
 369                                   int comp_level,
 370                                   methodHandle hot_method,
 371                                   int hot_count,
 372                                   const char* comment,
 373                                   Thread* thread);
 374 
 375   static CompileQueue* compile_queue(int comp_level);
 376   static bool init_compiler_runtime();
 377   static void shutdown_compiler_runtime(AbstractCompiler* comp, CompilerThread* thread);
 378 
 379  public:
 380   enum {


 386     if (is_c2_compile(comp_level)) return _compilers[1]; // C2
 387     if (is_c1_compile(comp_level)) return _compilers[0]; // C1
 388     return NULL;
 389   }
 390 
 391   static bool compilation_is_in_queue(methodHandle method);
 392   static void print_compile_queues(outputStream* st);
 393   static int queue_size(int comp_level) {
 394     CompileQueue *q = compile_queue(comp_level);
 395     return q != NULL ? q->size() : 0;
 396   }
 397   static void compilation_init();
 398   static void init_compiler_thread_log();
 399   static nmethod* compile_method(methodHandle method,
 400                                  int osr_bci,
 401                                  int comp_level,
 402                                  methodHandle hot_method,
 403                                  int hot_count,
 404                                  const char* comment, Thread* thread);
 405 



 406   static void compiler_thread_loop();
 407   static uint get_compilation_id() { return _compilation_id; }
 408 
 409   // Set _should_block.
 410   // Call this from the VM, with Threads_lock held and a safepoint requested.
 411   static void set_should_block();
 412 
 413   // Call this from the compiler at convenient points, to poll for _should_block.
 414   static void maybe_block();
 415 
 416   enum {
 417     // Flags for toggling compiler activity
 418     stop_compilation    = 0,
 419     run_compilation     = 1,
 420     shutdown_compilaton = 2
 421   };
 422 
 423   static jint get_compilation_activity_mode() { return _should_compile_new_jobs; }
 424   static bool should_compile_new_jobs() { return UseCompiler && (_should_compile_new_jobs == run_compilation); }
 425   static bool set_should_compile_new_jobs(jint new_state) {


 434     Atomic::xchg(shutdown_compilaton, &_should_compile_new_jobs);
 435   }
 436 
 437   static bool is_compilation_disabled_forever() {
 438     return _should_compile_new_jobs == shutdown_compilaton;
 439   }
 440   static void handle_full_code_cache(int code_blob_type);
 441   // Ensures that warning is only printed once.
 442   static bool should_print_compiler_warning() {
 443     jint old = Atomic::cmpxchg(1, &_print_compilation_warning, 0);
 444     return old == 0;
 445   }
 446   // Return total compilation ticks
 447   static jlong total_compilation_ticks() {
 448     return _perf_total_compilation != NULL ? _perf_total_compilation->get_value() : 0;
 449   }
 450 
 451   // Redefine Classes support
 452   static void mark_on_stack();
 453 





 454   // Print a detailed accounting of compilation time
 455   static void print_times();
 456 
 457   // Debugging output for failure
 458   static void print_last_compile();
 459 
 460   static void print_compiler_threads_on(outputStream* st);
 461 
 462   // compiler name for debugging
 463   static const char* compiler_name(int comp_level);
 464 
 465   static int get_total_compile_count() {          return _total_compile_count; }
 466   static int get_total_bailout_count() {          return _total_bailout_count; }
 467   static int get_total_invalidated_count() {      return _total_invalidated_count; }
 468   static int get_total_native_compile_count() {   return _total_native_compile_count; }
 469   static int get_total_osr_compile_count() {      return _total_osr_compile_count; }
 470   static int get_total_standard_compile_count() { return _total_standard_compile_count; }
 471   static int get_sum_osr_bytes_compiled() {       return _sum_osr_bytes_compiled; }
 472   static int get_sum_standard_bytes_compiled() {  return _sum_standard_bytes_compiled; }
 473   static int get_sum_nmethod_size() {             return _sum_nmethod_size;}
 474   static int get_sum_nmethod_code_size() {        return _sum_nmethod_code_size; }
 475   static long get_peak_compilation_time() {       return _peak_compilation_time; }


  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 #ifndef SHARE_VM_COMPILER_COMPILEBROKER_HPP
  26 #define SHARE_VM_COMPILER_COMPILEBROKER_HPP
  27 
  28 #include "ci/compilerInterface.hpp"
  29 #include "compiler/abstractCompiler.hpp"
  30 #include "runtime/perfData.hpp"
  31 #include "trace/tracing.hpp"
  32 
  33 class nmethod;
  34 class nmethodLocker;
  35 
  36 // CompileTask
  37 //
  38 // An entry in the compile queue.  It represents a pending or current
  39 // compilation.
  40 class CompileTask : public CHeapObj<mtCompiler> {
  41   friend class VMStructs;
  42 
  43  private:
  44   static CompileTask* _task_free_list;
  45 #ifdef ASSERT
  46   static int          _num_allocated_tasks;
  47 #endif
  48 
  49   Monitor*     _lock;
  50   uint         _compile_id;
  51   Method*      _method;


 124     print_compilation_impl(st, nm->method(), nm->compile_id(), nm->comp_level(),
 125                            nm->is_osr_method(), nm->is_osr_method() ? nm->osr_entry_bci() : -1, /*is_blocking*/ false,
 126                            msg, short_form, cr);
 127   }
 128 
 129   static void  print_inlining(outputStream* st, ciMethod* method, int inline_level, int bci, const char* msg = NULL);
 130   static void  print_inlining(ciMethod* method, int inline_level, int bci, const char* msg = NULL) {
 131     print_inlining(tty, method, inline_level, bci, msg);
 132   }
 133 
 134   // Redefine Classes support
 135   void mark_on_stack();
 136 
 137   static void  print_inline_indent(int inline_level, outputStream* st = tty);
 138 
 139   void         print_tty();
 140   void         print_line_on_error(outputStream* st, char* buf, int buflen);
 141 
 142   void         log_task(xmlStream* log);
 143   void         log_task_queued();
 144   void         log_task_dequeued(const char* comment);
 145   void         log_task_start(CompileLog* log);
 146   void         log_task_done(CompileLog* log);
 147 
 148   void         set_failure_reason(const char* reason) {
 149     _failure_reason = reason;
 150   }
 151 };
 152 
 153 // CompilerCounters
 154 //
 155 // Per Compiler Performance Counters.
 156 //
 157 class CompilerCounters : public CHeapObj<mtCompiler> {
 158 
 159   public:
 160     enum {
 161       cmname_buffer_length = 160
 162     };
 163 
 164   private:


 343 
 344   static JavaThread* make_thread(const char* name, CompileQueue* queue, CompilerCounters* counters, AbstractCompiler* comp, bool compiler_thread, TRAPS);
 345   static void init_compiler_sweeper_threads(int c1_compiler_count, int c2_compiler_count);
 346   static bool compilation_is_complete  (methodHandle method, int osr_bci, int comp_level);
 347   static bool compilation_is_prohibited(methodHandle method, int osr_bci, int comp_level);
 348   static bool is_compile_blocking();
 349   static void preload_classes          (methodHandle method, TRAPS);
 350 
 351   static CompileTask* create_compile_task(CompileQueue* queue,
 352                                           int           compile_id,
 353                                           methodHandle  method,
 354                                           int           osr_bci,
 355                                           int           comp_level,
 356                                           methodHandle  hot_method,
 357                                           int           hot_count,
 358                                           const char*   comment,
 359                                           bool          blocking);
 360   static void wait_for_completion(CompileTask* task);
 361 
 362   static void invoke_compiler_on_method(CompileTask* task);
 363   static void post_compile(CompilerThread* thread, CompileTask* task, EventCompilation& event, bool success, ciEnv* ci_env);
 364   static void set_last_compile(CompilerThread *thread, methodHandle method, bool is_osr, int comp_level);
 365   static void push_jni_handle_block();
 366   static void pop_jni_handle_block();
 367   static bool check_break_at(methodHandle method, int compile_id, bool is_osr);
 368   static void collect_statistics(CompilerThread* thread, elapsedTimer time, CompileTask* task);
 369 
 370   static void compile_method_base(methodHandle method,
 371                                   int osr_bci,
 372                                   int comp_level,
 373                                   methodHandle hot_method,
 374                                   int hot_count,
 375                                   const char* comment,
 376                                   Thread* thread);
 377 
 378   static CompileQueue* compile_queue(int comp_level);
 379   static bool init_compiler_runtime();
 380   static void shutdown_compiler_runtime(AbstractCompiler* comp, CompilerThread* thread);
 381 
 382  public:
 383   enum {


 389     if (is_c2_compile(comp_level)) return _compilers[1]; // C2
 390     if (is_c1_compile(comp_level)) return _compilers[0]; // C1
 391     return NULL;
 392   }
 393 
 394   static bool compilation_is_in_queue(methodHandle method);
 395   static void print_compile_queues(outputStream* st);
 396   static int queue_size(int comp_level) {
 397     CompileQueue *q = compile_queue(comp_level);
 398     return q != NULL ? q->size() : 0;
 399   }
 400   static void compilation_init();
 401   static void init_compiler_thread_log();
 402   static nmethod* compile_method(methodHandle method,
 403                                  int osr_bci,
 404                                  int comp_level,
 405                                  methodHandle hot_method,
 406                                  int hot_count,
 407                                  const char* comment, Thread* thread);
 408 
 409   // Acquire any needed locks and assign a compile id
 410   static uint assign_compile_id_unlocked(Thread* thread, methodHandle method, int osr_bci);
 411 
 412   static void compiler_thread_loop();
 413   static uint get_compilation_id() { return _compilation_id; }
 414 
 415   // Set _should_block.
 416   // Call this from the VM, with Threads_lock held and a safepoint requested.
 417   static void set_should_block();
 418 
 419   // Call this from the compiler at convenient points, to poll for _should_block.
 420   static void maybe_block();
 421 
 422   enum {
 423     // Flags for toggling compiler activity
 424     stop_compilation    = 0,
 425     run_compilation     = 1,
 426     shutdown_compilaton = 2
 427   };
 428 
 429   static jint get_compilation_activity_mode() { return _should_compile_new_jobs; }
 430   static bool should_compile_new_jobs() { return UseCompiler && (_should_compile_new_jobs == run_compilation); }
 431   static bool set_should_compile_new_jobs(jint new_state) {


 440     Atomic::xchg(shutdown_compilaton, &_should_compile_new_jobs);
 441   }
 442 
 443   static bool is_compilation_disabled_forever() {
 444     return _should_compile_new_jobs == shutdown_compilaton;
 445   }
 446   static void handle_full_code_cache(int code_blob_type);
 447   // Ensures that warning is only printed once.
 448   static bool should_print_compiler_warning() {
 449     jint old = Atomic::cmpxchg(1, &_print_compilation_warning, 0);
 450     return old == 0;
 451   }
 452   // Return total compilation ticks
 453   static jlong total_compilation_ticks() {
 454     return _perf_total_compilation != NULL ? _perf_total_compilation->get_value() : 0;
 455   }
 456 
 457   // Redefine Classes support
 458   static void mark_on_stack();
 459 
 460 #if INCLUDE_JVMCI
 461   // Print curent compilation time stats for a given compiler
 462   static void print_times(AbstractCompiler* comp);
 463 #endif
 464 
 465   // Print a detailed accounting of compilation time
 466   static void print_times(bool per_compiler = true, bool aggregate = true);
 467 
 468   // Debugging output for failure
 469   static void print_last_compile();
 470 
 471   static void print_compiler_threads_on(outputStream* st);
 472 
 473   // compiler name for debugging
 474   static const char* compiler_name(int comp_level);
 475 
 476   static int get_total_compile_count() {          return _total_compile_count; }
 477   static int get_total_bailout_count() {          return _total_bailout_count; }
 478   static int get_total_invalidated_count() {      return _total_invalidated_count; }
 479   static int get_total_native_compile_count() {   return _total_native_compile_count; }
 480   static int get_total_osr_compile_count() {      return _total_osr_compile_count; }
 481   static int get_total_standard_compile_count() { return _total_standard_compile_count; }
 482   static int get_sum_osr_bytes_compiled() {       return _sum_osr_bytes_compiled; }
 483   static int get_sum_standard_bytes_compiled() {  return _sum_standard_bytes_compiled; }
 484   static int get_sum_nmethod_size() {             return _sum_nmethod_size;}
 485   static int get_sum_nmethod_code_size() {        return _sum_nmethod_code_size; }
 486   static long get_peak_compilation_time() {       return _peak_compilation_time; }
src/share/vm/compiler/compileBroker.hpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File