144 public:
145 enum {
146 name_buffer_length = 100
147 };
148
149 // Compile type Information for print_last_compile() and CompilerCounters
150 enum { no_compile, normal_compile, osr_compile, native_compile };
151 static int assign_compile_id (const methodHandle& method, int osr_bci);
152
153
154 private:
155 static bool _initialized;
156 static volatile bool _should_block;
157
158 // This flag can be used to stop compilation or turn it back on
159 static volatile jint _should_compile_new_jobs;
160
161 // The installed compiler(s)
162 static AbstractCompiler* _compilers[2];
163
164 // These counters are used for assigning id's to each compilation
165 static volatile jint _compilation_id;
166 static volatile jint _osr_compilation_id;
167
168 static int _last_compile_type;
169 static int _last_compile_level;
170 static char _last_method_compiled[name_buffer_length];
171
172 static CompileQueue* _c2_compile_queue;
173 static CompileQueue* _c1_compile_queue;
174
175 // performance counters
176 static PerfCounter* _perf_total_compilation;
177 static PerfCounter* _perf_native_compilation;
178 static PerfCounter* _perf_osr_compilation;
179 static PerfCounter* _perf_standard_compilation;
180
181 static PerfCounter* _perf_total_bailout_count;
182 static PerfCounter* _perf_total_invalidated_count;
183 static PerfCounter* _perf_total_compile_count;
202 static elapsedTimer _t_total_compilation;
203 static elapsedTimer _t_osr_compilation;
204 static elapsedTimer _t_standard_compilation;
205 static elapsedTimer _t_invalidated_compilation;
206 static elapsedTimer _t_bailedout_compilation;
207
208 static int _total_compile_count;
209 static int _total_bailout_count;
210 static int _total_invalidated_count;
211 static int _total_native_compile_count;
212 static int _total_osr_compile_count;
213 static int _total_standard_compile_count;
214 static int _sum_osr_bytes_compiled;
215 static int _sum_standard_bytes_compiled;
216 static int _sum_nmethod_size;
217 static int _sum_nmethod_code_size;
218 static long _peak_compilation_time;
219
220 static volatile int _print_compilation_warning;
221
222 static JavaThread* make_thread(const char* name, CompileQueue* queue, CompilerCounters* counters, AbstractCompiler* comp, bool compiler_thread, TRAPS);
223 static void init_compiler_sweeper_threads(int c1_compiler_count, int c2_compiler_count);
224 static bool compilation_is_complete (const methodHandle& method, int osr_bci, int comp_level);
225 static bool compilation_is_prohibited(const methodHandle& method, int osr_bci, int comp_level, bool excluded);
226 static void preload_classes (const methodHandle& method, TRAPS);
227
228 static CompileTask* create_compile_task(CompileQueue* queue,
229 int compile_id,
230 const methodHandle& method,
231 int osr_bci,
232 int comp_level,
233 const methodHandle& hot_method,
234 int hot_count,
235 CompileTask::CompileReason compile_reason,
236 bool blocking);
237 static void wait_for_completion(CompileTask* task);
238 #if INCLUDE_JVMCI
239 static bool wait_for_jvmci_completion(JVMCICompiler* comp, CompileTask* task, JavaThread* thread);
240 #endif
241
242 static void invoke_compiler_on_method(CompileTask* task);
243 static void post_compile(CompilerThread* thread, CompileTask* task, EventCompilation& event, bool success, ciEnv* ci_env);
349 static jlong total_compilation_ticks() {
350 return _perf_total_compilation != NULL ? _perf_total_compilation->get_value() : 0;
351 }
352
353 // Redefine Classes support
354 static void mark_on_stack();
355
356 #if INCLUDE_JVMCI
357 // Print curent compilation time stats for a given compiler
358 static void print_times(AbstractCompiler* comp);
359 #endif
360
361 // Print a detailed accounting of compilation time
362 static void print_times(bool per_compiler = true, bool aggregate = true);
363
364 // Debugging output for failure
365 static void print_last_compile();
366
367 // compiler name for debugging
368 static const char* compiler_name(int comp_level);
369
370 static int get_total_compile_count() { return _total_compile_count; }
371 static int get_total_bailout_count() { return _total_bailout_count; }
372 static int get_total_invalidated_count() { return _total_invalidated_count; }
373 static int get_total_native_compile_count() { return _total_native_compile_count; }
374 static int get_total_osr_compile_count() { return _total_osr_compile_count; }
375 static int get_total_standard_compile_count() { return _total_standard_compile_count; }
376 static int get_sum_osr_bytes_compiled() { return _sum_osr_bytes_compiled; }
377 static int get_sum_standard_bytes_compiled() { return _sum_standard_bytes_compiled; }
378 static int get_sum_nmethod_size() { return _sum_nmethod_size;}
379 static int get_sum_nmethod_code_size() { return _sum_nmethod_code_size; }
380 static long get_peak_compilation_time() { return _peak_compilation_time; }
381 static long get_total_compilation_time() { return _t_total_compilation.milliseconds(); }
382
383 // Log that compilation profiling is skipped because metaspace is full.
384 static void log_metaspace_failure();
385
386 // CodeHeap State Analytics.
387 static void print_info(outputStream *out);
388 static void print_heapinfo(outputStream *out, const char* function, const char* granularity );
|
144 public:
145 enum {
146 name_buffer_length = 100
147 };
148
149 // Compile type Information for print_last_compile() and CompilerCounters
150 enum { no_compile, normal_compile, osr_compile, native_compile };
151 static int assign_compile_id (const methodHandle& method, int osr_bci);
152
153
154 private:
155 static bool _initialized;
156 static volatile bool _should_block;
157
158 // This flag can be used to stop compilation or turn it back on
159 static volatile jint _should_compile_new_jobs;
160
161 // The installed compiler(s)
162 static AbstractCompiler* _compilers[2];
163
164 // The maximum numbers of compiler threads to be determined during startup.
165 static int _c1_count, _c2_count;
166
167 // An array of compiler thread Java objects
168 static jobject *_compiler1_objects, *_compiler2_objects;
169
170 // An array of compiler logs
171 static CompileLog **_compiler1_logs, **_compiler2_logs;
172
173 // These counters are used for assigning id's to each compilation
174 static volatile jint _compilation_id;
175 static volatile jint _osr_compilation_id;
176
177 static int _last_compile_type;
178 static int _last_compile_level;
179 static char _last_method_compiled[name_buffer_length];
180
181 static CompileQueue* _c2_compile_queue;
182 static CompileQueue* _c1_compile_queue;
183
184 // performance counters
185 static PerfCounter* _perf_total_compilation;
186 static PerfCounter* _perf_native_compilation;
187 static PerfCounter* _perf_osr_compilation;
188 static PerfCounter* _perf_standard_compilation;
189
190 static PerfCounter* _perf_total_bailout_count;
191 static PerfCounter* _perf_total_invalidated_count;
192 static PerfCounter* _perf_total_compile_count;
211 static elapsedTimer _t_total_compilation;
212 static elapsedTimer _t_osr_compilation;
213 static elapsedTimer _t_standard_compilation;
214 static elapsedTimer _t_invalidated_compilation;
215 static elapsedTimer _t_bailedout_compilation;
216
217 static int _total_compile_count;
218 static int _total_bailout_count;
219 static int _total_invalidated_count;
220 static int _total_native_compile_count;
221 static int _total_osr_compile_count;
222 static int _total_standard_compile_count;
223 static int _sum_osr_bytes_compiled;
224 static int _sum_standard_bytes_compiled;
225 static int _sum_nmethod_size;
226 static int _sum_nmethod_code_size;
227 static long _peak_compilation_time;
228
229 static volatile int _print_compilation_warning;
230
231 static Handle create_thread_oop(const char* name, TRAPS);
232 static JavaThread* make_thread(jobject thread_oop, CompileQueue* queue,
233 AbstractCompiler* comp, bool compiler_thread, TRAPS);
234 static void init_compiler_sweeper_threads();
235 static void possibly_add_compiler_threads();
236 static bool compilation_is_complete (const methodHandle& method, int osr_bci, int comp_level);
237 static bool compilation_is_prohibited(const methodHandle& method, int osr_bci, int comp_level, bool excluded);
238 static void preload_classes (const methodHandle& method, TRAPS);
239
240 static CompileTask* create_compile_task(CompileQueue* queue,
241 int compile_id,
242 const methodHandle& method,
243 int osr_bci,
244 int comp_level,
245 const methodHandle& hot_method,
246 int hot_count,
247 CompileTask::CompileReason compile_reason,
248 bool blocking);
249 static void wait_for_completion(CompileTask* task);
250 #if INCLUDE_JVMCI
251 static bool wait_for_jvmci_completion(JVMCICompiler* comp, CompileTask* task, JavaThread* thread);
252 #endif
253
254 static void invoke_compiler_on_method(CompileTask* task);
255 static void post_compile(CompilerThread* thread, CompileTask* task, EventCompilation& event, bool success, ciEnv* ci_env);
361 static jlong total_compilation_ticks() {
362 return _perf_total_compilation != NULL ? _perf_total_compilation->get_value() : 0;
363 }
364
365 // Redefine Classes support
366 static void mark_on_stack();
367
368 #if INCLUDE_JVMCI
369 // Print curent compilation time stats for a given compiler
370 static void print_times(AbstractCompiler* comp);
371 #endif
372
373 // Print a detailed accounting of compilation time
374 static void print_times(bool per_compiler = true, bool aggregate = true);
375
376 // Debugging output for failure
377 static void print_last_compile();
378
379 // compiler name for debugging
380 static const char* compiler_name(int comp_level);
381
382 // Provide access to compiler thread Java objects
383 static jobject compiler1_object(int idx) {
384 assert(_compiler1_objects != NULL, "must be initialized");
385 assert(idx < _c1_count, "oob");
386 return _compiler1_objects[idx];
387 }
388
389 static jobject compiler2_object(int idx) {
390 assert(_compiler2_objects != NULL, "must be initialized");
391 assert(idx < _c2_count, "oob");
392 return _compiler2_objects[idx];
393 }
394
395 static CompileLog* get_log(CompilerThread* ct);
396
397 static int get_total_compile_count() { return _total_compile_count; }
398 static int get_total_bailout_count() { return _total_bailout_count; }
399 static int get_total_invalidated_count() { return _total_invalidated_count; }
400 static int get_total_native_compile_count() { return _total_native_compile_count; }
401 static int get_total_osr_compile_count() { return _total_osr_compile_count; }
402 static int get_total_standard_compile_count() { return _total_standard_compile_count; }
403 static int get_sum_osr_bytes_compiled() { return _sum_osr_bytes_compiled; }
404 static int get_sum_standard_bytes_compiled() { return _sum_standard_bytes_compiled; }
405 static int get_sum_nmethod_size() { return _sum_nmethod_size;}
406 static int get_sum_nmethod_code_size() { return _sum_nmethod_code_size; }
407 static long get_peak_compilation_time() { return _peak_compilation_time; }
408 static long get_total_compilation_time() { return _t_total_compilation.milliseconds(); }
409
410 // Log that compilation profiling is skipped because metaspace is full.
411 static void log_metaspace_failure();
412
413 // CodeHeap State Analytics.
414 static void print_info(outputStream *out);
415 static void print_heapinfo(outputStream *out, const char* function, const char* granularity );
|