comparison src/share/vm/runtime/compilationPolicy.cpp @ 10672:e7d07c9bb779

Removed priority compilation queue. Fixed another race condition in the compilation queue. Removed Graal-specific compilation policy.
author Christian Haeubl <haeubl@ssw.jku.at>
date Tue, 09 Jul 2013 17:53:58 +0200
parents a9b76e1e5ab3
children cefad50507d8
comparison
equal deleted inserted replaced
10665:dcee58529a1c 10672:e7d07c9bb779
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 #ifdef GRAALVM
85 CompilationPolicy::set_policy(new GraalCompPolicy());
86 #else
87 Unimplemented();
88 #endif
89 break;
90 default: 83 default:
91 fatal("CompilationPolicyChoice must be in the range: [0-4]"); 84 fatal("CompilationPolicyChoice must be in the range: [0-3]");
92 } 85 }
93 CompilationPolicy::policy()->initialize(); 86 CompilationPolicy::policy()->initialize();
94 } 87 }
95 88
96 void CompilationPolicy::completed_vm_startup() { 89 void CompilationPolicy::completed_vm_startup() {
469 CompileBroker::compile_method(m, bci, comp_level, m, hot_count, comment, thread); 462 CompileBroker::compile_method(m, bci, comp_level, m, hot_count, comment, thread);
470 NOT_PRODUCT(trace_osr_completion(m->lookup_osr_nmethod_for(bci, comp_level, true));) 463 NOT_PRODUCT(trace_osr_completion(m->lookup_osr_nmethod_for(bci, comp_level, true));)
471 } 464 }
472 } 465 }
473 466
474 // GraalCompPolicy - compile current method
475
476 #ifdef GRAALVM
477
478 void GraalCompPolicy::method_invocation_event(methodHandle m, JavaThread* thread) {
479 MethodCounters* mcs = m->method_counters();
480 assert(mcs != NULL, "method counters should be initialized");
481 int hot_count = m->invocation_count();
482 jlong hot_time = mcs->graal_invocation_time();
483 reset_counter_for_invocation_event(m);
484
485 if (is_compilation_enabled() && can_be_compiled(m)) {
486 nmethod* nm = m->code();
487 if (nm == NULL) {
488 if (hot_count > 1) {
489 jlong current_time = os::javaTimeNanos();
490 int time_per_call = (int) ((current_time - hot_time) / hot_count);
491 if (mcs != NULL) {
492 mcs->set_graal_invocation_time(current_time);
493 }
494 if (UseNewCode) {
495 if (m->queued_for_compilation()) {
496 if (time_per_call < (mcs->graal_priority() / 5)) {
497 mcs->set_graal_priority(time_per_call);
498 m->clear_queued_for_compilation();
499 }
500 } else {
501 if (time_per_call < mcs->graal_priority()) {
502 mcs->set_graal_priority(time_per_call);
503 }
504 }
505 } else {
506 if (time_per_call < mcs->graal_priority()) {
507 mcs->set_graal_priority(time_per_call);
508 }
509 }
510 }
511
512 if (!m->queued_for_compilation()) {
513 if (TraceCompilationPolicy) {
514 tty->print("method invocation trigger: ");
515 m->print_short_name(tty);
516 tty->print_cr(" ( interpreted " INTPTR_FORMAT ", size=%d, hotCount=%d, hotTime=" UINT64_FORMAT " ) ", (address)m(), m->code_size(), hot_count, hot_time);
517 }
518
519 assert(m->is_native() || m->method_data() != NULL, "do not compile code methods");
520 CompileBroker::compile_method(m, InvocationEntryBci, CompLevel_highest_tier, m, hot_count, "count", thread);
521 }
522 }
523 }
524 }
525
526 void GraalCompPolicy::method_back_branch_event(methodHandle m, int bci, JavaThread* thread) {
527 int hot_count = m->backedge_count();
528 const char* comment = "backedge_count";
529 reset_counter_for_back_branch_event(m);
530
531 if (is_compilation_enabled() && !m->is_not_osr_compilable() && can_be_compiled(m) && !m->queued_for_compilation() && m->code() == NULL) {
532 if (TraceCompilationPolicy) {
533 tty->print("backedge invocation trigger: ");
534 m->print_short_name(tty);
535 tty->print_cr(" ( interpreted " INTPTR_FORMAT ", size=%d, hotCount=%d ) ", (address)m(), m->code_size(), hot_count);
536 }
537
538 CompileBroker::compile_method(m, bci, CompLevel_highest_tier,
539 m, hot_count, comment, thread);
540 NOT_PRODUCT(trace_osr_completion(m->lookup_osr_nmethod_for(bci, CompLevel_highest_tier, true));)
541 }
542 }
543
544 #endif // GRAALVM
545
546
547 // StackWalkCompPolicy - walk up stack to find a suitable method to compile 467 // StackWalkCompPolicy - walk up stack to find a suitable method to compile
548 468
549 #ifdef COMPILER2 469 #ifdef COMPILER2
550 const char* StackWalkCompPolicy::_msg = NULL; 470 const char* StackWalkCompPolicy::_msg = NULL;
551 471