176
177 // Compilation
178 //
179 // The broker for all compilation requests.
180 class CompileBroker: AllStatic {
181 friend class Threads;
182 friend class CompileTaskWrapper;
183
184 public:
185 enum {
186 name_buffer_length = 100
187 };
188
189 // Compile type Information for print_last_compile() and CompilerCounters
190 enum { no_compile, normal_compile, osr_compile, native_compile };
191
192 private:
193 static bool _initialized;
194 static volatile bool _should_block;
195
196 // The installed compiler(s)
197 static AbstractCompiler* _compilers[2];
198
199 // These counters are used for assigning id's to each compilation
200 static uint _compilation_id;
201 static uint _osr_compilation_id;
202 static uint _native_compilation_id;
203
204 static int _last_compile_type;
205 static int _last_compile_level;
206 static char _last_method_compiled[name_buffer_length];
207
208 static CompileQueue* _method_queue;
209 static CompileTask* _task_free_list;
210
211 static GrowableArray<CompilerThread*>* _method_threads;
212
213 // performance counters
214 static PerfCounter* _perf_total_compilation;
215 static PerfCounter* _perf_native_compilation;
302 public:
303 enum {
304 // The entry bci used for non-OSR compilations.
305 standard_entry_bci = InvocationEntryBci
306 };
307
308 static AbstractCompiler* compiler(int level ) {
309 if (level == CompLevel_fast_compile) return _compilers[0];
310 assert(level == CompLevel_highest_tier, "what level?")
311 return _compilers[1];
312 }
313
314 static void compilation_init();
315 static void init_compiler_thread_log();
316 static nmethod* compile_method(methodHandle method, int osr_bci,
317 methodHandle hot_method, int hot_count,
318 const char* comment, TRAPS);
319
320 static void compiler_thread_loop();
321
322 static bool is_idle();
323
324 // Set _should_block.
325 // Call this from the VM, with Threads_lock held and a safepoint requested.
326 static void set_should_block();
327
328 // Call this from the compiler at convenient points, to poll for _should_block.
329 static void maybe_block();
330
331 // Return total compilation ticks
332 static jlong total_compilation_ticks() {
333 return _perf_total_compilation != NULL ? _perf_total_compilation->get_value() : 0;
334 }
335
336 // Print a detailed accounting of compilation time
337 static void print_times();
338
339 // Debugging output for failure
340 static void print_last_compile();
341
342 static void print_compiler_threads_on(outputStream* st);
343 };
|
176
177 // Compilation
178 //
179 // The broker for all compilation requests.
180 class CompileBroker: AllStatic {
181 friend class Threads;
182 friend class CompileTaskWrapper;
183
184 public:
185 enum {
186 name_buffer_length = 100
187 };
188
189 // Compile type Information for print_last_compile() and CompilerCounters
190 enum { no_compile, normal_compile, osr_compile, native_compile };
191
192 private:
193 static bool _initialized;
194 static volatile bool _should_block;
195
196 // This flag can be used to stop compilation or turn it back on
197 static volatile jint _should_compile_new_jobs;
198
199 // The installed compiler(s)
200 static AbstractCompiler* _compilers[2];
201
202 // These counters are used for assigning id's to each compilation
203 static uint _compilation_id;
204 static uint _osr_compilation_id;
205 static uint _native_compilation_id;
206
207 static int _last_compile_type;
208 static int _last_compile_level;
209 static char _last_method_compiled[name_buffer_length];
210
211 static CompileQueue* _method_queue;
212 static CompileTask* _task_free_list;
213
214 static GrowableArray<CompilerThread*>* _method_threads;
215
216 // performance counters
217 static PerfCounter* _perf_total_compilation;
218 static PerfCounter* _perf_native_compilation;
305 public:
306 enum {
307 // The entry bci used for non-OSR compilations.
308 standard_entry_bci = InvocationEntryBci
309 };
310
311 static AbstractCompiler* compiler(int level ) {
312 if (level == CompLevel_fast_compile) return _compilers[0];
313 assert(level == CompLevel_highest_tier, "what level?")
314 return _compilers[1];
315 }
316
317 static void compilation_init();
318 static void init_compiler_thread_log();
319 static nmethod* compile_method(methodHandle method, int osr_bci,
320 methodHandle hot_method, int hot_count,
321 const char* comment, TRAPS);
322
323 static void compiler_thread_loop();
324
325 static uint get_compilation_id() { return _compilation_id; }
326 static bool is_idle();
327
328 // Set _should_block.
329 // Call this from the VM, with Threads_lock held and a safepoint requested.
330 static void set_should_block();
331
332 // Call this from the compiler at convenient points, to poll for _should_block.
333 static void maybe_block();
334
335 enum {
336 // Flags for toggling compiler activity
337 stop_compilation = 0,
338 run_compilation = 1
339 };
340
341 static bool should_compile_new_jobs() { return UseCompiler && (_should_compile_new_jobs == run_compilation); }
342 static bool set_should_compile_new_jobs(jint new_state) {
343 // Return success if the current caller set it
344 jint old = Atomic::cmpxchg(new_state, &_should_compile_new_jobs, 1-new_state);
345 return (old == (1-new_state));
346 }
347 static void handle_full_code_cache();
348
349 // Return total compilation ticks
350 static jlong total_compilation_ticks() {
351 return _perf_total_compilation != NULL ? _perf_total_compilation->get_value() : 0;
352 }
353
354 // Print a detailed accounting of compilation time
355 static void print_times();
356
357 // Debugging output for failure
358 static void print_last_compile();
359
360 static void print_compiler_threads_on(outputStream* st);
361 };
|