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

src/share/vm/compiler/compileBroker.hpp

Print this page
rev 6793 : 8054889: Compiler team's implementation task
Summary: Adding three new diagnostic commands for compiler
Reviewed-by:


  94 
  95   void         mark_complete()                   { _is_complete = true; }
  96   void         mark_success()                    { _is_success = true; }
  97 
  98   int          comp_level()                      { return _comp_level;}
  99   void         set_comp_level(int comp_level)    { _comp_level = comp_level;}
 100 
 101   int          num_inlined_bytecodes() const     { return _num_inlined_bytecodes; }
 102   void         set_num_inlined_bytecodes(int n)  { _num_inlined_bytecodes = n; }
 103 
 104   CompileTask* next() const                      { return _next; }
 105   void         set_next(CompileTask* next)       { _next = next; }
 106   CompileTask* prev() const                      { return _prev; }
 107   void         set_prev(CompileTask* prev)       { _prev = prev; }
 108   bool         is_free() const                   { return _is_free; }
 109   void         set_is_free(bool val)             { _is_free = val; }
 110 
 111 private:
 112   static void  print_compilation_impl(outputStream* st, Method* method, int compile_id, int comp_level,
 113                                       bool is_osr_method = false, int osr_bci = -1, bool is_blocking = false,
 114                                       const char* msg = NULL, bool short_form = false);
 115 
 116 public:
 117   void         print_compilation(outputStream* st = tty, const char* msg = NULL, bool short_form = false);
 118   static void  print_compilation(outputStream* st, const nmethod* nm, const char* msg = NULL, bool short_form = false) {
 119     print_compilation_impl(st, nm->method(), nm->compile_id(), nm->comp_level(),
 120                            nm->is_osr_method(), nm->is_osr_method() ? nm->osr_entry_bci() : -1, /*is_blocking*/ false,
 121                            msg, short_form);
 122   }
 123 
 124   static void  print_inlining(outputStream* st, ciMethod* method, int inline_level, int bci, const char* msg = NULL);
 125   static void  print_inlining(ciMethod* method, int inline_level, int bci, const char* msg = NULL) {
 126     print_inlining(tty, method, inline_level, bci, msg);
 127   }
 128 
 129   // Redefine Classes support
 130   void mark_on_stack();
 131 
 132   static void  print_inline_indent(int inline_level, outputStream* st = tty);
 133 
 134   void         print();
 135   void         print_line();
 136   void         print_line_on_error(outputStream* st, char* buf, int buflen);
 137 
 138   void         log_task(xmlStream* log);
 139   void         log_task_queued();
 140   void         log_task_start(CompileLog* log);
 141   void         log_task_done(CompileLog* log);
 142 
 143   void         set_failure_reason(const char* reason) {
 144     _failure_reason = reason;
 145   }
 146 };
 147 
 148 // CompilerCounters
 149 //
 150 // Per Compiler Performance Counters.
 151 //
 152 class CompilerCounters : public CHeapObj<mtCompiler> {
 153 
 154   public:
 155     enum {


 217   }
 218 
 219   const char*  name() const                      { return _name; }
 220   Monitor*     lock() const                      { return _lock; }
 221 
 222   void         add(CompileTask* task);
 223   void         remove(CompileTask* task);
 224   void         remove_and_mark_stale(CompileTask* task);
 225   CompileTask* first()                           { return _first; }
 226   CompileTask* last()                            { return _last;  }
 227 
 228   CompileTask* get();
 229 
 230   bool         is_empty() const                  { return _first == NULL; }
 231   int          size()     const                  { return _size;          }
 232 
 233 
 234   // Redefine Classes support
 235   void mark_on_stack();
 236   void free_all();
 237   NOT_PRODUCT (void print();)

 238 
 239   ~CompileQueue() {
 240     assert (is_empty(), " Compile Queue must be empty");
 241   }
 242 };
 243 
 244 // CompileTaskWrapper
 245 //
 246 // Assign this task to the current thread.  Deallocate the task
 247 // when the compilation is complete.
 248 class CompileTaskWrapper : StackObj {
 249 public:
 250   CompileTaskWrapper(CompileTask* task);
 251   ~CompileTaskWrapper();
 252 };
 253 
 254 
 255 // Compilation
 256 //
 257 // The broker for all compilation requests.


 324   static elapsedTimer _t_standard_compilation;
 325 
 326   static int _total_compile_count;
 327   static int _total_bailout_count;
 328   static int _total_invalidated_count;
 329   static int _total_native_compile_count;
 330   static int _total_osr_compile_count;
 331   static int _total_standard_compile_count;
 332   static int _sum_osr_bytes_compiled;
 333   static int _sum_standard_bytes_compiled;
 334   static int _sum_nmethod_size;
 335   static int _sum_nmethod_code_size;
 336   static long _peak_compilation_time;
 337 
 338   static volatile jint _print_compilation_warning;
 339 
 340   static CompilerThread* make_compiler_thread(const char* name, CompileQueue* queue, CompilerCounters* counters, AbstractCompiler* comp, TRAPS);
 341   static void init_compiler_threads(int c1_compiler_count, int c2_compiler_count);
 342   static bool compilation_is_complete  (methodHandle method, int osr_bci, int comp_level);
 343   static bool compilation_is_prohibited(methodHandle method, int osr_bci, int comp_level);
 344   static bool is_compile_blocking      ();
 345   static void preload_classes          (methodHandle method, TRAPS);
 346 
 347   static CompileTask* create_compile_task(CompileQueue* queue,
 348                                           int           compile_id,
 349                                           methodHandle  method,
 350                                           int           osr_bci,
 351                                           int           comp_level,
 352                                           methodHandle  hot_method,
 353                                           int           hot_count,
 354                                           const char*   comment,
 355                                           bool          blocking);
 356   static void wait_for_completion(CompileTask* task);
 357 
 358   static void invoke_compiler_on_method(CompileTask* task);
 359   static void set_last_compile(CompilerThread *thread, methodHandle method, bool is_osr, int comp_level);
 360   static void push_jni_handle_block();
 361   static void pop_jni_handle_block();
 362   static bool check_break_at(methodHandle method, int compile_id, bool is_osr);
 363   static void collect_statistics(CompilerThread* thread, elapsedTimer time, CompileTask* task);
 364 
 365   static void compile_method_base(methodHandle method,
 366                                   int osr_bci,
 367                                   int comp_level,
 368                                   methodHandle hot_method,
 369                                   int hot_count,
 370                                   const char* comment,
 371                                   Thread* thread);
 372   static CompileQueue* compile_queue(int comp_level) {
 373     if (is_c2_compile(comp_level)) return _c2_compile_queue;
 374     if (is_c1_compile(comp_level)) return _c1_compile_queue;
 375     return NULL;
 376   }
 377   static bool init_compiler_runtime();
 378   static void shutdown_compiler_runtime(AbstractCompiler* comp, CompilerThread* thread);
 379 
 380  public:
 381   enum {
 382     // The entry bci used for non-OSR compilations.
 383     standard_entry_bci = InvocationEntryBci
 384   };
 385 
 386   static AbstractCompiler* compiler(int comp_level) {
 387     if (is_c2_compile(comp_level)) return _compilers[1]; // C2
 388     if (is_c1_compile(comp_level)) return _compilers[0]; // C1
 389     return NULL;
 390   }
 391 
 392   static bool compilation_is_in_queue(methodHandle method);

 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 




  94 
  95   void         mark_complete()                   { _is_complete = true; }
  96   void         mark_success()                    { _is_success = true; }
  97 
  98   int          comp_level()                      { return _comp_level;}
  99   void         set_comp_level(int comp_level)    { _comp_level = comp_level;}
 100 
 101   int          num_inlined_bytecodes() const     { return _num_inlined_bytecodes; }
 102   void         set_num_inlined_bytecodes(int n)  { _num_inlined_bytecodes = n; }
 103 
 104   CompileTask* next() const                      { return _next; }
 105   void         set_next(CompileTask* next)       { _next = next; }
 106   CompileTask* prev() const                      { return _prev; }
 107   void         set_prev(CompileTask* prev)       { _prev = prev; }
 108   bool         is_free() const                   { return _is_free; }
 109   void         set_is_free(bool val)             { _is_free = val; }
 110 
 111 private:
 112   static void  print_compilation_impl(outputStream* st, Method* method, int compile_id, int comp_level,
 113                                       bool is_osr_method = false, int osr_bci = -1, bool is_blocking = false,
 114                                       const char* msg = NULL, bool short_form = false, bool cr = true);
 115 
 116 public:
 117   void         print_compilation(outputStream* st = tty, const char* msg = NULL, bool short_form = false, bool cr = true);
 118   static void  print_compilation(outputStream* st, const nmethod* nm, const char* msg = NULL, bool short_form = false, bool cr = true) {
 119     print_compilation_impl(st, nm->method(), nm->compile_id(), nm->comp_level(),
 120                            nm->is_osr_method(), nm->is_osr_method() ? nm->osr_entry_bci() : -1, /*is_blocking*/ false,
 121                            msg, short_form, cr);
 122   }
 123 
 124   static void  print_inlining(outputStream* st, ciMethod* method, int inline_level, int bci, const char* msg = NULL);
 125   static void  print_inlining(ciMethod* method, int inline_level, int bci, const char* msg = NULL) {
 126     print_inlining(tty, method, inline_level, bci, msg);
 127   }
 128 
 129   // Redefine Classes support
 130   void mark_on_stack();
 131 
 132   static void  print_inline_indent(int inline_level, outputStream* st = tty);
 133 
 134   void         print_tty();

 135   void         print_line_on_error(outputStream* st, char* buf, int buflen);
 136 
 137   void         log_task(xmlStream* log);
 138   void         log_task_queued();
 139   void         log_task_start(CompileLog* log);
 140   void         log_task_done(CompileLog* log);
 141 
 142   void         set_failure_reason(const char* reason) {
 143     _failure_reason = reason;
 144   }
 145 };
 146 
 147 // CompilerCounters
 148 //
 149 // Per Compiler Performance Counters.
 150 //
 151 class CompilerCounters : public CHeapObj<mtCompiler> {
 152 
 153   public:
 154     enum {


 216   }
 217 
 218   const char*  name() const                      { return _name; }
 219   Monitor*     lock() const                      { return _lock; }
 220 
 221   void         add(CompileTask* task);
 222   void         remove(CompileTask* task);
 223   void         remove_and_mark_stale(CompileTask* task);
 224   CompileTask* first()                           { return _first; }
 225   CompileTask* last()                            { return _last;  }
 226 
 227   CompileTask* get();
 228 
 229   bool         is_empty() const                  { return _first == NULL; }
 230   int          size()     const                  { return _size;          }
 231 
 232 
 233   // Redefine Classes support
 234   void mark_on_stack();
 235   void free_all();
 236   void print_tty();
 237   void print(outputStream* st = tty);
 238 
 239   ~CompileQueue() {
 240     assert (is_empty(), " Compile Queue must be empty");
 241   }
 242 };
 243 
 244 // CompileTaskWrapper
 245 //
 246 // Assign this task to the current thread.  Deallocate the task
 247 // when the compilation is complete.
 248 class CompileTaskWrapper : StackObj {
 249 public:
 250   CompileTaskWrapper(CompileTask* task);
 251   ~CompileTaskWrapper();
 252 };
 253 
 254 
 255 // Compilation
 256 //
 257 // The broker for all compilation requests.


 324   static elapsedTimer _t_standard_compilation;
 325 
 326   static int _total_compile_count;
 327   static int _total_bailout_count;
 328   static int _total_invalidated_count;
 329   static int _total_native_compile_count;
 330   static int _total_osr_compile_count;
 331   static int _total_standard_compile_count;
 332   static int _sum_osr_bytes_compiled;
 333   static int _sum_standard_bytes_compiled;
 334   static int _sum_nmethod_size;
 335   static int _sum_nmethod_code_size;
 336   static long _peak_compilation_time;
 337 
 338   static volatile jint _print_compilation_warning;
 339 
 340   static CompilerThread* make_compiler_thread(const char* name, CompileQueue* queue, CompilerCounters* counters, AbstractCompiler* comp, TRAPS);
 341   static void init_compiler_threads(int c1_compiler_count, int c2_compiler_count);
 342   static bool compilation_is_complete  (methodHandle method, int osr_bci, int comp_level);
 343   static bool compilation_is_prohibited(methodHandle method, int osr_bci, int comp_level);
 344   static bool is_compile_blocking();
 345   static void preload_classes          (methodHandle method, TRAPS);
 346 
 347   static CompileTask* create_compile_task(CompileQueue* queue,
 348                                           int           compile_id,
 349                                           methodHandle  method,
 350                                           int           osr_bci,
 351                                           int           comp_level,
 352                                           methodHandle  hot_method,
 353                                           int           hot_count,
 354                                           const char*   comment,
 355                                           bool          blocking);
 356   static void wait_for_completion(CompileTask* task);
 357 
 358   static void invoke_compiler_on_method(CompileTask* task);
 359   static void set_last_compile(CompilerThread *thread, methodHandle method, bool is_osr, int comp_level);
 360   static void push_jni_handle_block();
 361   static void pop_jni_handle_block();
 362   static bool check_break_at(methodHandle method, int compile_id, bool is_osr);
 363   static void collect_statistics(CompilerThread* thread, elapsedTimer time, CompileTask* task);
 364 
 365   static void compile_method_base(methodHandle method,
 366                                   int osr_bci,
 367                                   int comp_level,
 368                                   methodHandle hot_method,
 369                                   int hot_count,
 370                                   const char* comment,
 371                                   Thread* thread);
 372 
 373   static CompileQueue* compile_queue(int comp_level);



 374   static bool init_compiler_runtime();
 375   static void shutdown_compiler_runtime(AbstractCompiler* comp, CompilerThread* thread);
 376 
 377  public:
 378   enum {
 379     // The entry bci used for non-OSR compilations.
 380     standard_entry_bci = InvocationEntryBci
 381   };
 382 
 383   static AbstractCompiler* compiler(int comp_level) {
 384     if (is_c2_compile(comp_level)) return _compilers[1]; // C2
 385     if (is_c1_compile(comp_level)) return _compilers[0]; // C1
 386     return NULL;
 387   }
 388 
 389   static bool compilation_is_in_queue(methodHandle method);
 390   static void print_compile_queues(outputStream* st);
 391   static int queue_size(int comp_level) {
 392     CompileQueue *q = compile_queue(comp_level);
 393     return q != NULL ? q->size() : 0;
 394   }
 395   static void compilation_init();
 396   static void init_compiler_thread_log();
 397   static nmethod* compile_method(methodHandle method,
 398                                  int osr_bci,
 399                                  int comp_level,
 400                                  methodHandle hot_method,
 401                                  int hot_count,
 402                                  const char* comment, Thread* thread);
 403 
 404   static void compiler_thread_loop();
 405   static uint get_compilation_id() { return _compilation_id; }
 406 
 407   // Set _should_block.
 408   // Call this from the VM, with Threads_lock held and a safepoint requested.
 409   static void set_should_block();
 410 


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