25 #ifndef SHARE_VM_COMPILER_COMPILEBROKER_HPP |
25 #ifndef SHARE_VM_COMPILER_COMPILEBROKER_HPP |
26 #define SHARE_VM_COMPILER_COMPILEBROKER_HPP |
26 #define SHARE_VM_COMPILER_COMPILEBROKER_HPP |
27 |
27 |
28 #include "ci/compilerInterface.hpp" |
28 #include "ci/compilerInterface.hpp" |
29 #include "compiler/abstractCompiler.hpp" |
29 #include "compiler/abstractCompiler.hpp" |
|
30 #include "compiler/compileTask.hpp" |
30 #include "runtime/perfData.hpp" |
31 #include "runtime/perfData.hpp" |
31 |
32 |
32 class nmethod; |
33 class nmethod; |
33 class nmethodLocker; |
34 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; |
|
51 jobject _method_holder; |
|
52 int _osr_bci; |
|
53 bool _is_complete; |
|
54 bool _is_success; |
|
55 bool _is_blocking; |
|
56 int _comp_level; |
|
57 int _num_inlined_bytecodes; |
|
58 nmethodLocker* _code_handle; // holder of eventual result |
|
59 CompileTask* _next, *_prev; |
|
60 bool _is_free; |
|
61 // Fields used for logging why the compilation was initiated: |
|
62 jlong _time_queued; // in units of os::elapsed_counter() |
|
63 Method* _hot_method; // which method actually triggered this task |
|
64 jobject _hot_method_holder; |
|
65 int _hot_count; // information about its invocation counter |
|
66 const char* _comment; // more info about the task |
|
67 const char* _failure_reason; |
|
68 |
|
69 public: |
|
70 CompileTask() { |
|
71 _lock = new Monitor(Mutex::nonleaf+2, "CompileTaskLock"); |
|
72 } |
|
73 |
|
74 void initialize(int compile_id, methodHandle method, int osr_bci, int comp_level, |
|
75 methodHandle hot_method, int hot_count, const char* comment, |
|
76 bool is_blocking); |
|
77 |
|
78 static CompileTask* allocate(); |
|
79 static void free(CompileTask* task); |
|
80 |
|
81 int compile_id() const { return _compile_id; } |
|
82 Method* method() const { return _method; } |
|
83 Method* hot_method() const { return _hot_method; } |
|
84 int osr_bci() const { return _osr_bci; } |
|
85 bool is_complete() const { return _is_complete; } |
|
86 bool is_blocking() const { return _is_blocking; } |
|
87 bool is_success() const { return _is_success; } |
|
88 |
|
89 nmethodLocker* code_handle() const { return _code_handle; } |
|
90 void set_code_handle(nmethodLocker* l) { _code_handle = l; } |
|
91 nmethod* code() const; // _code_handle->code() |
|
92 void set_code(nmethod* nm); // _code_handle->set_code(nm) |
|
93 |
|
94 Monitor* lock() const { return _lock; } |
|
95 |
|
96 void mark_complete() { _is_complete = true; } |
|
97 void mark_success() { _is_success = true; } |
|
98 |
|
99 int comp_level() { return _comp_level;} |
|
100 void set_comp_level(int comp_level) { _comp_level = comp_level;} |
|
101 |
|
102 int num_inlined_bytecodes() const { return _num_inlined_bytecodes; } |
|
103 void set_num_inlined_bytecodes(int n) { _num_inlined_bytecodes = n; } |
|
104 |
|
105 CompileTask* next() const { return _next; } |
|
106 void set_next(CompileTask* next) { _next = next; } |
|
107 CompileTask* prev() const { return _prev; } |
|
108 void set_prev(CompileTask* prev) { _prev = prev; } |
|
109 bool is_free() const { return _is_free; } |
|
110 void set_is_free(bool val) { _is_free = val; } |
|
111 |
|
112 // RedefineClasses support |
|
113 void metadata_do(void f(Metadata*)); |
|
114 |
|
115 private: |
|
116 static void print_compilation_impl(outputStream* st, Method* method, int compile_id, int comp_level, |
|
117 bool is_osr_method = false, int osr_bci = -1, bool is_blocking = false, |
|
118 const char* msg = NULL, bool short_form = false, bool cr = true); |
|
119 |
|
120 public: |
|
121 void print_compilation(outputStream* st = tty, const char* msg = NULL, bool short_form = false, bool cr = true); |
|
122 static void print_compilation(outputStream* st, const nmethod* nm, const char* msg = NULL, bool short_form = false, bool cr = true) { |
|
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 |
35 |
151 // CompilerCounters |
36 // CompilerCounters |
152 // |
37 // |
153 // Per Compiler Performance Counters. |
38 // Per Compiler Performance Counters. |
154 // |
39 // |