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

src/share/vm/compiler/compileTask.hpp

Print this page
rev 10833 : 8153013: BlockingCompilation test times out
Summary: Task has no invocation count and get stale at once
Reviewed-by: kvn, iveresov


  23  */
  24 
  25 #ifndef SHARE_VM_COMPILER_COMPILETASK_HPP
  26 #define SHARE_VM_COMPILER_COMPILETASK_HPP
  27 
  28 #include "code/nmethod.hpp"
  29 #include "ci/ciMethod.hpp"
  30 #include "compiler/compileLog.hpp"
  31 #include "memory/allocation.inline.hpp"
  32 #include "utilities/xmlstream.hpp"
  33 
  34 // CompileTask
  35 //
  36 // An entry in the compile queue.  It represents a pending or current
  37 // compilation.
  38 
  39 class CompileTask : public CHeapObj<mtCompiler> {
  40   friend class VMStructs;
  41   friend class JVMCIVMStructs;
  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;
  52   jobject      _method_holder;
  53   int          _osr_bci;
  54   bool         _is_complete;
  55   bool         _is_success;
  56   bool         _is_blocking;
  57 #if INCLUDE_JVMCI
  58   bool         _has_waiter;
  59   // Compiler thread for a blocking JVMCI compilation
  60   CompilerThread* _jvmci_compiler_thread;
  61 #endif
  62   int          _comp_level;
  63   int          _num_inlined_bytecodes;
  64   nmethodLocker* _code_handle;  // holder of eventual result
  65   CompileTask* _next, *_prev;
  66   bool         _is_free;
  67   // Fields used for logging why the compilation was initiated:
  68   jlong        _time_queued;  // in units of os::elapsed_counter()
  69   Method*      _hot_method;   // which method actually triggered this task
  70   jobject      _hot_method_holder;
  71   int          _hot_count;    // information about its invocation counter
  72   const char*  _comment;      // more info about the task
  73   const char*  _failure_reason;
  74 
  75  public:
  76   CompileTask() {
  77     _lock = new Monitor(Mutex::nonleaf+2, "CompileTaskLock");
  78   }
  79 
  80   void initialize(int compile_id, const methodHandle& method, int osr_bci, int comp_level,
  81                   const methodHandle& hot_method, int hot_count, const char* comment,
  82                   bool is_blocking);
  83 
  84   static CompileTask* allocate();
  85   static void         free(CompileTask* task);
  86 
  87   int          compile_id() const                { return _compile_id; }
  88   Method*      method() const                    { return _method; }
  89   Method*      hot_method() const                { return _hot_method; }
  90   int          osr_bci() const                   { return _osr_bci; }
  91   bool         is_complete() const               { return _is_complete; }
  92   bool         is_blocking() const               { return _is_blocking; }
  93   bool         is_success() const                { return _is_success; }









  94 #if INCLUDE_JVMCI
  95   bool         has_waiter() const                { return _has_waiter; }
  96   void         clear_waiter()                    { _has_waiter = false; }
  97   CompilerThread* jvmci_compiler_thread() const  { return _jvmci_compiler_thread; }
  98   void         set_jvmci_compiler_thread(CompilerThread* t) {
  99     assert(is_blocking(), "must be");
 100     assert((t == NULL) != (_jvmci_compiler_thread == NULL), "must be");
 101     _jvmci_compiler_thread = t;
 102   }
 103 #endif
 104 
 105   nmethodLocker* code_handle() const             { return _code_handle; }
 106   void         set_code_handle(nmethodLocker* l) { _code_handle = l; }
 107   nmethod*     code() const;                     // _code_handle->code()
 108   void         set_code(nmethod* nm);            // _code_handle->set_code(nm)
 109 
 110   Monitor*     lock() const                      { return _lock; }
 111 
 112   void         mark_complete()                   { _is_complete = true; }
 113   void         mark_success()                    { _is_success = true; }




  23  */
  24 
  25 #ifndef SHARE_VM_COMPILER_COMPILETASK_HPP
  26 #define SHARE_VM_COMPILER_COMPILETASK_HPP
  27 
  28 #include "code/nmethod.hpp"
  29 #include "ci/ciMethod.hpp"
  30 #include "compiler/compileLog.hpp"
  31 #include "memory/allocation.inline.hpp"
  32 #include "utilities/xmlstream.hpp"
  33 
  34 // CompileTask
  35 //
  36 // An entry in the compile queue.  It represents a pending or current
  37 // compilation.
  38 
  39 class CompileTask : public CHeapObj<mtCompiler> {
  40   friend class VMStructs;
  41   friend class JVMCIVMStructs;
  42 
  43  public:
  44   // Different reasons for a compilation
  45   // The order is important - Reason_Whitebox and higher can not become
  46   // stale, see CompileTask::can_become_stale()
  47   // Also mapped to reason_names[]
  48   enum CompileReason {
  49       Reason_None,
  50       Reason_InvocationCount,  // Simple/StackWalk-policy
  51       Reason_BackedgeCount,    // Simple/StackWalk-policy
  52       Reason_Tiered,           // Tiered-policy
  53       Reason_CTW,              // Compile the world
  54       Reason_Replay,           // ciReplay
  55       Reason_Whitebox,         // Whitebox API
  56       Reason_MustBeCompiled,   // Java callHelper, LinkResolver
  57       Reason_Bootstrap,        // JVMCI bootstrap
  58       Reason_Count
  59   };
  60 
  61   static const char* reason_name(CompileTask::CompileReason compile_reason) {
  62     static const char* reason_names[] = {
  63       "no_reason",
  64       "count",
  65       "backedge_count",
  66       "tiered",
  67       "CTW",
  68       "replay",
  69       "whitebox",
  70       "must_be_compiled",
  71       "bootstrap"
  72     };
  73     return reason_names[compile_reason];
  74   }
  75 
  76  private:
  77   static CompileTask* _task_free_list;
  78 #ifdef ASSERT
  79   static int          _num_allocated_tasks;
  80 #endif
  81 
  82   Monitor*     _lock;
  83   uint         _compile_id;
  84   Method*      _method;
  85   jobject      _method_holder;
  86   int          _osr_bci;
  87   bool         _is_complete;
  88   bool         _is_success;
  89   bool         _is_blocking;
  90 #if INCLUDE_JVMCI
  91   bool         _has_waiter;
  92   // Compiler thread for a blocking JVMCI compilation
  93   CompilerThread* _jvmci_compiler_thread;
  94 #endif
  95   int          _comp_level;
  96   int          _num_inlined_bytecodes;
  97   nmethodLocker* _code_handle;  // holder of eventual result
  98   CompileTask* _next, *_prev;
  99   bool         _is_free;
 100   // Fields used for logging why the compilation was initiated:
 101   jlong        _time_queued;  // in units of os::elapsed_counter()
 102   Method*      _hot_method;   // which method actually triggered this task
 103   jobject      _hot_method_holder;
 104   int          _hot_count;    // information about its invocation counter
 105   CompileReason _compile_reason;      // more info about the task
 106   const char*  _failure_reason;
 107 
 108  public:
 109   CompileTask() {
 110     _lock = new Monitor(Mutex::nonleaf+2, "CompileTaskLock");
 111   }
 112 
 113   void initialize(int compile_id, const methodHandle& method, int osr_bci, int comp_level,
 114                   const methodHandle& hot_method, int hot_count,
 115                   CompileTask::CompileReason compile_reason, bool is_blocking);
 116 
 117   static CompileTask* allocate();
 118   static void         free(CompileTask* task);
 119 
 120   int          compile_id() const                { return _compile_id; }
 121   Method*      method() const                    { return _method; }
 122   Method*      hot_method() const                { return _hot_method; }
 123   int          osr_bci() const                   { return _osr_bci; }
 124   bool         is_complete() const               { return _is_complete; }
 125   bool         is_blocking() const               { return _is_blocking; }
 126   bool         is_success() const                { return _is_success; }
 127   bool         can_become_stale() const          {
 128     switch(_compile_reason) {
 129       case Reason_BackedgeCount:
 130       case Reason_InvocationCount:
 131       case Reason_Tiered:
 132         return !_is_blocking;
 133       }
 134     return false;
 135   }
 136 #if INCLUDE_JVMCI
 137   bool         has_waiter() const                { return _has_waiter; }
 138   void         clear_waiter()                    { _has_waiter = false; }
 139   CompilerThread* jvmci_compiler_thread() const  { return _jvmci_compiler_thread; }
 140   void         set_jvmci_compiler_thread(CompilerThread* t) {
 141     assert(is_blocking(), "must be");
 142     assert((t == NULL) != (_jvmci_compiler_thread == NULL), "must be");
 143     _jvmci_compiler_thread = t;
 144   }
 145 #endif
 146 
 147   nmethodLocker* code_handle() const             { return _code_handle; }
 148   void         set_code_handle(nmethodLocker* l) { _code_handle = l; }
 149   nmethod*     code() const;                     // _code_handle->code()
 150   void         set_code(nmethod* nm);            // _code_handle->set_code(nm)
 151 
 152   Monitor*     lock() const                      { return _lock; }
 153 
 154   void         mark_complete()                   { _is_complete = true; }
 155   void         mark_success()                    { _is_success = true; }


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