hotspot/src/share/vm/compiler/compileTask.hpp
changeset 38218 f5ba1dea04eb
parent 37281 c4e7456d6ae1
child 42650 1f304d0c888b
equal deleted inserted replaced
38217:7ecc47b7df3d 38218:f5ba1dea04eb
    37 // compilation.
    37 // compilation.
    38 
    38 
    39 class CompileTask : public CHeapObj<mtCompiler> {
    39 class CompileTask : public CHeapObj<mtCompiler> {
    40   friend class VMStructs;
    40   friend class VMStructs;
    41   friend class JVMCIVMStructs;
    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   }
    42 
    75 
    43  private:
    76  private:
    44   static CompileTask* _task_free_list;
    77   static CompileTask* _task_free_list;
    45 #ifdef ASSERT
    78 #ifdef ASSERT
    46   static int          _num_allocated_tasks;
    79   static int          _num_allocated_tasks;
    67   // Fields used for logging why the compilation was initiated:
   100   // Fields used for logging why the compilation was initiated:
    68   jlong        _time_queued;  // in units of os::elapsed_counter()
   101   jlong        _time_queued;  // in units of os::elapsed_counter()
    69   Method*      _hot_method;   // which method actually triggered this task
   102   Method*      _hot_method;   // which method actually triggered this task
    70   jobject      _hot_method_holder;
   103   jobject      _hot_method_holder;
    71   int          _hot_count;    // information about its invocation counter
   104   int          _hot_count;    // information about its invocation counter
    72   const char*  _comment;      // more info about the task
   105   CompileReason _compile_reason;      // more info about the task
    73   const char*  _failure_reason;
   106   const char*  _failure_reason;
    74 
   107 
    75  public:
   108  public:
    76   CompileTask() {
   109   CompileTask() {
    77     _lock = new Monitor(Mutex::nonleaf+2, "CompileTaskLock");
   110     _lock = new Monitor(Mutex::nonleaf+2, "CompileTaskLock");
    78   }
   111   }
    79 
   112 
    80   void initialize(int compile_id, const methodHandle& method, int osr_bci, int comp_level,
   113   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,
   114                   const methodHandle& hot_method, int hot_count,
    82                   bool is_blocking);
   115                   CompileTask::CompileReason compile_reason, bool is_blocking);
    83 
   116 
    84   static CompileTask* allocate();
   117   static CompileTask* allocate();
    85   static void         free(CompileTask* task);
   118   static void         free(CompileTask* task);
    86 
   119 
    87   int          compile_id() const                { return _compile_id; }
   120   int          compile_id() const                { return _compile_id; }
    89   Method*      hot_method() const                { return _hot_method; }
   122   Method*      hot_method() const                { return _hot_method; }
    90   int          osr_bci() const                   { return _osr_bci; }
   123   int          osr_bci() const                   { return _osr_bci; }
    91   bool         is_complete() const               { return _is_complete; }
   124   bool         is_complete() const               { return _is_complete; }
    92   bool         is_blocking() const               { return _is_blocking; }
   125   bool         is_blocking() const               { return _is_blocking; }
    93   bool         is_success() const                { return _is_success; }
   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   }
    94 #if INCLUDE_JVMCI
   136 #if INCLUDE_JVMCI
    95   bool         has_waiter() const                { return _has_waiter; }
   137   bool         has_waiter() const                { return _has_waiter; }
    96   void         clear_waiter()                    { _has_waiter = false; }
   138   void         clear_waiter()                    { _has_waiter = false; }
    97   CompilerThread* jvmci_compiler_thread() const  { return _jvmci_compiler_thread; }
   139   CompilerThread* jvmci_compiler_thread() const  { return _jvmci_compiler_thread; }
    98   void         set_jvmci_compiler_thread(CompilerThread* t) {
   140   void         set_jvmci_compiler_thread(CompilerThread* t) {