src/share/vm/runtime/compilationPolicy.cpp
Print this page
rev 2893 : 7121756: Improve C1 inlining policy by using profiling at call sites
Summary: profile based recompilation of methods with C1 with more inlining.
Reviewed-by:
*** 54,64 ****
--- 54,72 ----
void compilationPolicy_init() {
CompilationPolicy::set_in_vm_startup(DelayCompilationDuringStartup);
switch(CompilationPolicyChoice) {
case 0:
+ #ifdef COMPILER1
+ if (C1ProfileInlining) {
+ CompilationPolicy::set_policy(new SimpleProfiledCompPolicy());
+ } else {
+ #endif
CompilationPolicy::set_policy(new SimpleCompPolicy());
+ #ifdef COMPILER1
+ }
+ #endif
break;
case 1:
#ifdef COMPILER2
CompilationPolicy::set_policy(new StackWalkCompPolicy());
*** 418,427 ****
--- 426,494 ----
CompileBroker::compile_method(m, bci, CompLevel_highest_tier,
m, hot_count, comment, CHECK);
NOT_PRODUCT(trace_osr_completion(m->lookup_osr_nmethod_for(bci, CompLevel_highest_tier, true));)
}
}
+
+ #ifdef COMPILER1
+ bool SimpleProfiledCompPolicy::profile_overflow_event(JavaThread *thread, TRAPS) {
+ RegisterMap map(thread, false);
+ frame fr = thread->last_frame().sender(&map);
+ nmethod* nm = (nmethod*) fr.cb();
+ assert(nm!= NULL && nm->is_nmethod(), "what?");
+ ResourceMark rm;
+
+ vframeStream vfst(thread);
+ methodHandle mh = methodHandle(vfst.method());
+ int bci = vfst.bci();
+
+ bool fix_call = false;
+ {
+ nmethodLocker nml(nm);
+ if (!nm->needs_recomp()) {
+ CounterData* profile = mh->method_data()->bci_to_data(bci)->as_CounterData();
+ bool warm;
+
+ if (is_hot(C1ProfileCompileThreshold, profile->timestamp(), &warm)) {
+
+ assert(mh->method_data() != NULL, "should have a mdo if we get here");
+ nm->set_needs_recomp(true);
+ methodHandle mh_recomp(nm->method());
+
+ if (TraceC1ProfileInlining) {
+ ttyLocker ttyl;
+ tty->print("C1ProfileInlining: recompiling: ");
+ mh_recomp->print_short_name(tty);
+ tty->print(" because of ");
+ mh->print_short_name(tty);
+ tty->print_cr(" at bci = %d", bci);
+ }
+
+ const char* comment = "tier1 overflow";
+ profile->set_hot();
+ CompileBroker::compile_method(mh_recomp, InvocationEntryBci, CompLevel_highest_tier,
+ mh_recomp, C1ProfileCompileThreshold, comment, CHECK_(true));
+ fix_call = true;
+ } else if (warm) {
+ fix_call = true;
+ profile->set_warm();
+ } else {
+ profile->set_cold();
+ }
+ if (!fix_call) {
+ profile->set_count(0);
+ profile->set_timestamp(os::javaTimeNanos());
+ }
+ } else {
+ fix_call = true;
+ }
+ }
+ return fix_call;
+ }
+ #endif
+
+
// StackWalkCompPolicy - walk up stack to find a suitable method to compile
#ifdef COMPILER2
const char* StackWalkCompPolicy::_msg = NULL;