comparison src/share/vm/runtime/compilationPolicy.cpp @ 5176:af59b4dfc9e4

compilation queue changes: * new CiCompilationStatistics * added new HotSpot compilation policy (-XX:CompilationPolicyChoice=4) * compile queue prioritizing (-G:+PriorityCompileQueue) * low-priority compilation threads (-G:+SlowCompileThreads) * dynamic compilation thread priority adjustment (-G:+DynamicCompilePriority)
author Lukas Stadler <lukas.stadler@jku.at>
date Thu, 29 Mar 2012 18:43:30 +0200
parents 532be189cf09
children d87155082c4d
comparison
equal deleted inserted replaced
5175:a8c5283a835c 5176:af59b4dfc9e4
78 CompilationPolicy::set_policy(new AdvancedThresholdPolicy()); 78 CompilationPolicy::set_policy(new AdvancedThresholdPolicy());
79 #else 79 #else
80 Unimplemented(); 80 Unimplemented();
81 #endif 81 #endif
82 break; 82 break;
83 case 4:
84 #if defined(GRAAL)
85 CompilationPolicy::set_policy(new GraalCompPolicy());
86 #else
87 Unimplemented();
88 #endif
89 break;
83 default: 90 default:
84 fatal("CompilationPolicyChoice must be in the range: [0-3]"); 91 fatal("CompilationPolicyChoice must be in the range: [0-4]");
85 } 92 }
86 CompilationPolicy::policy()->initialize(); 93 CompilationPolicy::policy()->initialize();
87 } 94 }
88 95
89 void CompilationPolicy::completed_vm_startup() { 96 void CompilationPolicy::completed_vm_startup() {
199 206
200 assert(!m->was_never_executed(), "don't reset to 0 -- could be mistaken for never-executed"); 207 assert(!m->was_never_executed(), "don't reset to 0 -- could be mistaken for never-executed");
201 } 208 }
202 209
203 void NonTieredCompPolicy::reset_counter_for_back_branch_event(methodHandle m) { 210 void NonTieredCompPolicy::reset_counter_for_back_branch_event(methodHandle m) {
211 GRAAL_ONLY(assert(false, "unexpected"));
204 // Delay next back-branch event but pump up invocation counter to triger 212 // Delay next back-branch event but pump up invocation counter to triger
205 // whole method compilation. 213 // whole method compilation.
206 InvocationCounter* i = m->invocation_counter(); 214 InvocationCounter* i = m->invocation_counter();
207 InvocationCounter* b = m->backedge_counter(); 215 InvocationCounter* b = m->backedge_counter();
208 216
416 CompileBroker::compile_method(m, bci, CompLevel_highest_tier, 424 CompileBroker::compile_method(m, bci, CompLevel_highest_tier,
417 m, hot_count, comment, thread); 425 m, hot_count, comment, thread);
418 NOT_PRODUCT(trace_osr_completion(m->lookup_osr_nmethod_for(bci, CompLevel_highest_tier, true));) 426 NOT_PRODUCT(trace_osr_completion(m->lookup_osr_nmethod_for(bci, CompLevel_highest_tier, true));)
419 } 427 }
420 } 428 }
429
430 // GraalCompPolicy - compile current method
431
432 #ifdef GRAAL
433
434 void GraalCompPolicy::method_invocation_event(methodHandle m, JavaThread* thread) {
435 int hot_count = m->invocation_count();
436 jlong hot_time = m->graal_invocation_time();
437 reset_counter_for_invocation_event(m);
438
439 if (is_compilation_enabled() && can_be_compiled(m)) {
440 nmethod* nm = m->code();
441 if (nm == NULL) {
442 if (hot_count > 1) {
443 jlong current_time = os::javaTimeNanos();
444 int time_per_call = (int) ((current_time - hot_time) / hot_count);
445 m->set_graal_invocation_time(current_time);
446 if (m->queued_for_compilation()) {
447 if (time_per_call < (m->graal_priority() / 5)) {
448 m->set_graal_priority(time_per_call);
449 m->clear_queued_for_compilation();
450 }
451 } else {
452 if (time_per_call < m->graal_priority()) {
453 m->set_graal_priority(time_per_call);
454 }
455 }
456 }
457 if (!m->queued_for_compilation()) {
458 CompileBroker::compile_method(m, InvocationEntryBci, CompLevel_highest_tier, m, hot_count, "count", thread);
459 }
460 }
461 } else {
462 }
463 }
464
465 void GraalCompPolicy::method_back_branch_event(methodHandle m, int bci, JavaThread* thread) {
466 int hot_count = m->backedge_count();
467 const char* comment = "backedge_count";
468
469 if (is_compilation_enabled() && !m->is_not_osr_compilable() && can_be_compiled(m)) {
470 CompileBroker::compile_method(m, bci, CompLevel_highest_tier,
471 m, hot_count, comment, thread);
472 NOT_PRODUCT(trace_osr_completion(m->lookup_osr_nmethod_for(bci, CompLevel_highest_tier, true));)
473 }
474 }
475
476 #endif // GRAAL
477
478
421 // StackWalkCompPolicy - walk up stack to find a suitable method to compile 479 // StackWalkCompPolicy - walk up stack to find a suitable method to compile
422 480
423 #if defined(COMPILER2) || defined(GRAAL) 481 #if defined(COMPILER2) || defined(GRAAL)
424 const char* StackWalkCompPolicy::_msg = NULL; 482 const char* StackWalkCompPolicy::_msg = NULL;
425 483