comparison src/share/vm/compiler/compileBroker.hpp @ 20588:41dcdd636080

8040798: compiler/startup/SmallCodeCacheStartup.java timed out in RT_Baseline Summary: Fixes broken memory freeing of compile queue tasks and makes sure that blocking compiles do not hang the VM if compilation gets disabled due to a full code cache. Reviewed-by: kvn, iveresov
author anoll
date Tue, 29 Apr 2014 07:59:22 +0200
parents dd89808e49ba
children 7848fc12602b
comparison
equal deleted inserted replaced
20584:ef9eda2c1abe 20588:41dcdd636080
38 // compilation. 38 // compilation.
39 class CompileTask : public CHeapObj<mtCompiler> { 39 class CompileTask : public CHeapObj<mtCompiler> {
40 friend class VMStructs; 40 friend class VMStructs;
41 41
42 private: 42 private:
43 static CompileTask* _task_free_list;
44 #ifdef ASSERT
45 static int _num_allocated_tasks;
46 #endif
47
43 Monitor* _lock; 48 Monitor* _lock;
44 uint _compile_id; 49 uint _compile_id;
45 Method* _method; 50 Method* _method;
46 jobject _method_holder; 51 jobject _method_holder;
47 int _osr_bci; 52 int _osr_bci;
50 bool _is_blocking; 55 bool _is_blocking;
51 int _comp_level; 56 int _comp_level;
52 int _num_inlined_bytecodes; 57 int _num_inlined_bytecodes;
53 nmethodLocker* _code_handle; // holder of eventual result 58 nmethodLocker* _code_handle; // holder of eventual result
54 CompileTask* _next, *_prev; 59 CompileTask* _next, *_prev;
55 60 bool _is_free;
56 // Fields used for logging why the compilation was initiated: 61 // Fields used for logging why the compilation was initiated:
57 jlong _time_queued; // in units of os::elapsed_counter() 62 jlong _time_queued; // in units of os::elapsed_counter()
58 Method* _hot_method; // which method actually triggered this task 63 Method* _hot_method; // which method actually triggered this task
59 jobject _hot_method_holder; 64 jobject _hot_method_holder;
60 int _hot_count; // information about its invocation counter 65 int _hot_count; // information about its invocation counter
68 73
69 void initialize(int compile_id, methodHandle method, int osr_bci, int comp_level, 74 void initialize(int compile_id, methodHandle method, int osr_bci, int comp_level,
70 methodHandle hot_method, int hot_count, const char* comment, 75 methodHandle hot_method, int hot_count, const char* comment,
71 bool is_blocking); 76 bool is_blocking);
72 77
73 void free(); 78 static CompileTask* allocate();
79 static void free(CompileTask* task);
74 80
75 int compile_id() const { return _compile_id; } 81 int compile_id() const { return _compile_id; }
76 Method* method() const { return _method; } 82 Method* method() const { return _method; }
77 int osr_bci() const { return _osr_bci; } 83 int osr_bci() const { return _osr_bci; }
78 bool is_complete() const { return _is_complete; } 84 bool is_complete() const { return _is_complete; }
97 103
98 CompileTask* next() const { return _next; } 104 CompileTask* next() const { return _next; }
99 void set_next(CompileTask* next) { _next = next; } 105 void set_next(CompileTask* next) { _next = next; }
100 CompileTask* prev() const { return _prev; } 106 CompileTask* prev() const { return _prev; }
101 void set_prev(CompileTask* prev) { _prev = prev; } 107 void set_prev(CompileTask* prev) { _prev = prev; }
108 bool is_free() const { return _is_free; }
109 void set_is_free(bool val) { _is_free = val; }
102 110
103 private: 111 private:
104 static void print_compilation_impl(outputStream* st, Method* method, int compile_id, int comp_level, 112 static void print_compilation_impl(outputStream* st, Method* method, int compile_id, int comp_level,
105 bool is_osr_method = false, int osr_bci = -1, bool is_blocking = false, 113 bool is_osr_method = false, int osr_bci = -1, bool is_blocking = false,
106 const char* msg = NULL, bool short_form = false); 114 const char* msg = NULL, bool short_form = false);
223 int size() const { return _size; } 231 int size() const { return _size; }
224 232
225 233
226 // Redefine Classes support 234 // Redefine Classes support
227 void mark_on_stack(); 235 void mark_on_stack();
228 void delete_all(); 236 void free_all();
229 void print(); 237 NOT_PRODUCT (void print();)
230 238
231 ~CompileQueue() { 239 ~CompileQueue() {
232 assert (is_empty(), " Compile Queue must be empty"); 240 assert (is_empty(), " Compile Queue must be empty");
233 } 241 }
234 }; 242 };
277 285
278 static int _last_compile_type; 286 static int _last_compile_type;
279 static int _last_compile_level; 287 static int _last_compile_level;
280 static char _last_method_compiled[name_buffer_length]; 288 static char _last_method_compiled[name_buffer_length];
281 289
282 static CompileQueue* _c2_method_queue; 290 static CompileQueue* _c2_compile_queue;
283 static CompileQueue* _c1_method_queue; 291 static CompileQueue* _c1_compile_queue;
284 static CompileTask* _task_free_list;
285 292
286 static GrowableArray<CompilerThread*>* _compiler_threads; 293 static GrowableArray<CompilerThread*>* _compiler_threads;
287 294
288 // performance counters 295 // performance counters
289 static PerfCounter* _perf_total_compilation; 296 static PerfCounter* _perf_total_compilation;
332 339
333 static CompilerThread* make_compiler_thread(const char* name, CompileQueue* queue, CompilerCounters* counters, AbstractCompiler* comp, TRAPS); 340 static CompilerThread* make_compiler_thread(const char* name, CompileQueue* queue, CompilerCounters* counters, AbstractCompiler* comp, TRAPS);
334 static void init_compiler_threads(int c1_compiler_count, int c2_compiler_count); 341 static void init_compiler_threads(int c1_compiler_count, int c2_compiler_count);
335 static bool compilation_is_complete (methodHandle method, int osr_bci, int comp_level); 342 static bool compilation_is_complete (methodHandle method, int osr_bci, int comp_level);
336 static bool compilation_is_prohibited(methodHandle method, int osr_bci, int comp_level); 343 static bool compilation_is_prohibited(methodHandle method, int osr_bci, int comp_level);
337 static bool is_compile_blocking (methodHandle method, int osr_bci); 344 static bool is_compile_blocking ();
338 static void preload_classes (methodHandle method, TRAPS); 345 static void preload_classes (methodHandle method, TRAPS);
339 346
340 static CompileTask* create_compile_task(CompileQueue* queue, 347 static CompileTask* create_compile_task(CompileQueue* queue,
341 int compile_id, 348 int compile_id,
342 methodHandle method, 349 methodHandle method,
344 int comp_level, 351 int comp_level,
345 methodHandle hot_method, 352 methodHandle hot_method,
346 int hot_count, 353 int hot_count,
347 const char* comment, 354 const char* comment,
348 bool blocking); 355 bool blocking);
349 static CompileTask* allocate_task();
350 static void free_task(CompileTask* task);
351 static void wait_for_completion(CompileTask* task); 356 static void wait_for_completion(CompileTask* task);
352 357
353 static void invoke_compiler_on_method(CompileTask* task); 358 static void invoke_compiler_on_method(CompileTask* task);
354 static void set_last_compile(CompilerThread *thread, methodHandle method, bool is_osr, int comp_level); 359 static void set_last_compile(CompilerThread *thread, methodHandle method, bool is_osr, int comp_level);
355 static void push_jni_handle_block(); 360 static void push_jni_handle_block();
363 methodHandle hot_method, 368 methodHandle hot_method,
364 int hot_count, 369 int hot_count,
365 const char* comment, 370 const char* comment,
366 Thread* thread); 371 Thread* thread);
367 static CompileQueue* compile_queue(int comp_level) { 372 static CompileQueue* compile_queue(int comp_level) {
368 if (is_c2_compile(comp_level)) return _c2_method_queue; 373 if (is_c2_compile(comp_level)) return _c2_compile_queue;
369 if (is_c1_compile(comp_level)) return _c1_method_queue; 374 if (is_c1_compile(comp_level)) return _c1_compile_queue;
370 return NULL; 375 return NULL;
371 } 376 }
372 static bool init_compiler_runtime(); 377 static bool init_compiler_runtime();
373 static void shutdown_compiler_runtime(AbstractCompiler* comp, CompilerThread* thread); 378 static void shutdown_compiler_runtime(AbstractCompiler* comp, CompilerThread* thread);
374 379
382 if (is_c2_compile(comp_level)) return _compilers[1]; // C2 387 if (is_c2_compile(comp_level)) return _compilers[1]; // C2
383 if (is_c1_compile(comp_level)) return _compilers[0]; // C1 388 if (is_c1_compile(comp_level)) return _compilers[0]; // C1
384 return NULL; 389 return NULL;
385 } 390 }
386 391
387 static bool compilation_is_in_queue(methodHandle method, int osr_bci); 392 static bool compilation_is_in_queue(methodHandle method);
388 static int queue_size(int comp_level) { 393 static int queue_size(int comp_level) {
389 CompileQueue *q = compile_queue(comp_level); 394 CompileQueue *q = compile_queue(comp_level);
390 return q != NULL ? q->size() : 0; 395 return q != NULL ? q->size() : 0;
391 } 396 }
392 static void compilation_init(); 397 static void compilation_init();