aoqi@0: /* aoqi@0: * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. aoqi@0: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. aoqi@0: * aoqi@0: * This code is free software; you can redistribute it and/or modify it aoqi@0: * under the terms of the GNU General Public License version 2 only, as aoqi@0: * published by the Free Software Foundation. aoqi@0: * aoqi@0: * This code is distributed in the hope that it will be useful, but WITHOUT aoqi@0: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or aoqi@0: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License aoqi@0: * version 2 for more details (a copy is included in the LICENSE file that aoqi@0: * accompanied this code). aoqi@0: * aoqi@0: * You should have received a copy of the GNU General Public License version aoqi@0: * 2 along with this work; if not, write to the Free Software Foundation, aoqi@0: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. aoqi@0: * aoqi@0: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA aoqi@0: * or visit www.oracle.com if you need additional information or have any aoqi@0: * questions. aoqi@0: * aoqi@0: */ aoqi@0: aoqi@0: #include "precompiled.hpp" aoqi@0: #include "runtime/advancedThresholdPolicy.hpp" aoqi@0: #include "runtime/simpleThresholdPolicy.inline.hpp" aoqi@0: aoqi@0: #ifdef TIERED aoqi@0: // Print an event. aoqi@0: void AdvancedThresholdPolicy::print_specific(EventType type, methodHandle mh, methodHandle imh, aoqi@0: int bci, CompLevel level) { aoqi@0: tty->print(" rate="); aoqi@0: if (mh->prev_time() == 0) tty->print("n/a"); aoqi@0: else tty->print("%f", mh->rate()); aoqi@0: aoqi@0: tty->print(" k=%.2lf,%.2lf", threshold_scale(CompLevel_full_profile, Tier3LoadFeedback), aoqi@0: threshold_scale(CompLevel_full_optimization, Tier4LoadFeedback)); aoqi@0: aoqi@0: } aoqi@0: aoqi@0: void AdvancedThresholdPolicy::initialize() { aoqi@0: // Turn on ergonomic compiler count selection aoqi@0: if (FLAG_IS_DEFAULT(CICompilerCountPerCPU) && FLAG_IS_DEFAULT(CICompilerCount)) { aoqi@0: FLAG_SET_DEFAULT(CICompilerCountPerCPU, true); aoqi@0: } aoqi@0: int count = CICompilerCount; aoqi@0: if (CICompilerCountPerCPU) { aoqi@0: // Simple log n seems to grow too slowly for tiered, try something faster: log n * log log n aoqi@0: int log_cpu = log2_intptr(os::active_processor_count()); aoqi@0: int loglog_cpu = log2_intptr(MAX2(log_cpu, 1)); aoqi@0: count = MAX2(log_cpu * loglog_cpu, 1) * 3 / 2; aoqi@0: } aoqi@0: aoqi@0: set_c1_count(MAX2(count / 3, 1)); aoqi@0: set_c2_count(MAX2(count - c1_count(), 1)); aoqi@0: FLAG_SET_ERGO(intx, CICompilerCount, c1_count() + c2_count()); aoqi@0: aoqi@0: // Some inlining tuning aoqi@0: #ifdef X86 aoqi@0: if (FLAG_IS_DEFAULT(InlineSmallCode)) { aoqi@0: FLAG_SET_DEFAULT(InlineSmallCode, 2000); aoqi@0: } aoqi@0: #endif aoqi@0: aoqi@0: #ifdef SPARC aoqi@0: if (FLAG_IS_DEFAULT(InlineSmallCode)) { aoqi@0: FLAG_SET_DEFAULT(InlineSmallCode, 2500); aoqi@0: } aoqi@0: #endif aoqi@0: aoqi@0: set_increase_threshold_at_ratio(); aoqi@0: set_start_time(os::javaTimeMillis()); aoqi@0: } aoqi@0: aoqi@0: // update_rate() is called from select_task() while holding a compile queue lock. aoqi@0: void AdvancedThresholdPolicy::update_rate(jlong t, Method* m) { aoqi@0: JavaThread* THREAD = JavaThread::current(); aoqi@0: if (is_old(m)) { aoqi@0: // We don't remove old methods from the queue, aoqi@0: // so we can just zero the rate. aoqi@0: m->set_rate(0, THREAD); aoqi@0: return; aoqi@0: } aoqi@0: aoqi@0: // We don't update the rate if we've just came out of a safepoint. aoqi@0: // delta_s is the time since last safepoint in milliseconds. aoqi@0: jlong delta_s = t - SafepointSynchronize::end_of_last_safepoint(); aoqi@0: jlong delta_t = t - (m->prev_time() != 0 ? m->prev_time() : start_time()); // milliseconds since the last measurement aoqi@0: // How many events were there since the last time? aoqi@0: int event_count = m->invocation_count() + m->backedge_count(); aoqi@0: int delta_e = event_count - m->prev_event_count(); aoqi@0: aoqi@0: // We should be running for at least 1ms. aoqi@0: if (delta_s >= TieredRateUpdateMinTime) { aoqi@0: // And we must've taken the previous point at least 1ms before. aoqi@0: if (delta_t >= TieredRateUpdateMinTime && delta_e > 0) { aoqi@0: m->set_prev_time(t, THREAD); aoqi@0: m->set_prev_event_count(event_count, THREAD); aoqi@0: m->set_rate((float)delta_e / (float)delta_t, THREAD); // Rate is events per millisecond aoqi@0: } else aoqi@0: if (delta_t > TieredRateUpdateMaxTime && delta_e == 0) { aoqi@0: // If nothing happened for 25ms, zero the rate. Don't modify prev values. aoqi@0: m->set_rate(0, THREAD); aoqi@0: } aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: // Check if this method has been stale from a given number of milliseconds. aoqi@0: // See select_task(). aoqi@0: bool AdvancedThresholdPolicy::is_stale(jlong t, jlong timeout, Method* m) { aoqi@0: jlong delta_s = t - SafepointSynchronize::end_of_last_safepoint(); aoqi@0: jlong delta_t = t - m->prev_time(); aoqi@0: if (delta_t > timeout && delta_s > timeout) { aoqi@0: int event_count = m->invocation_count() + m->backedge_count(); aoqi@0: int delta_e = event_count - m->prev_event_count(); aoqi@0: // Return true if there were no events. aoqi@0: return delta_e == 0; aoqi@0: } aoqi@0: return false; aoqi@0: } aoqi@0: aoqi@0: // We don't remove old methods from the compile queue even if they have aoqi@0: // very low activity. See select_task(). aoqi@0: bool AdvancedThresholdPolicy::is_old(Method* method) { aoqi@0: return method->invocation_count() > 50000 || method->backedge_count() > 500000; aoqi@0: } aoqi@0: aoqi@0: double AdvancedThresholdPolicy::weight(Method* method) { aoqi@0: return (method->rate() + 1) * ((method->invocation_count() + 1) * (method->backedge_count() + 1)); aoqi@0: } aoqi@0: aoqi@0: // Apply heuristics and return true if x should be compiled before y aoqi@0: bool AdvancedThresholdPolicy::compare_methods(Method* x, Method* y) { aoqi@0: if (x->highest_comp_level() > y->highest_comp_level()) { aoqi@0: // recompilation after deopt aoqi@0: return true; aoqi@0: } else aoqi@0: if (x->highest_comp_level() == y->highest_comp_level()) { aoqi@0: if (weight(x) > weight(y)) { aoqi@0: return true; aoqi@0: } aoqi@0: } aoqi@0: return false; aoqi@0: } aoqi@0: aoqi@0: // Is method profiled enough? aoqi@0: bool AdvancedThresholdPolicy::is_method_profiled(Method* method) { aoqi@0: MethodData* mdo = method->method_data(); aoqi@0: if (mdo != NULL) { aoqi@0: int i = mdo->invocation_count_delta(); aoqi@0: int b = mdo->backedge_count_delta(); aoqi@0: return call_predicate_helper(i, b, 1); aoqi@0: } aoqi@0: return false; aoqi@0: } aoqi@0: aoqi@0: // Called with the queue locked and with at least one element aoqi@0: CompileTask* AdvancedThresholdPolicy::select_task(CompileQueue* compile_queue) { aoqi@0: CompileTask *max_task = NULL; aoqi@0: Method* max_method = NULL; aoqi@0: jlong t = os::javaTimeMillis(); aoqi@0: // Iterate through the queue and find a method with a maximum rate. aoqi@0: for (CompileTask* task = compile_queue->first(); task != NULL;) { aoqi@0: CompileTask* next_task = task->next(); aoqi@0: Method* method = task->method(); aoqi@0: MethodData* mdo = method->method_data(); aoqi@0: update_rate(t, method); aoqi@0: if (max_task == NULL) { aoqi@0: max_task = task; aoqi@0: max_method = method; aoqi@0: } else { aoqi@0: // If a method has been stale for some time, remove it from the queue. aoqi@0: if (is_stale(t, TieredCompileTaskTimeout, method) && !is_old(method)) { aoqi@0: if (PrintTieredEvents) { aoqi@0: print_event(REMOVE_FROM_QUEUE, method, method, task->osr_bci(), (CompLevel)task->comp_level()); aoqi@0: } aoqi@0: CompileTaskWrapper ctw(task); // Frees the task aoqi@0: compile_queue->remove(task); aoqi@0: method->clear_queued_for_compilation(); aoqi@0: task = next_task; aoqi@0: continue; aoqi@0: } aoqi@0: aoqi@0: // Select a method with a higher rate aoqi@0: if (compare_methods(method, max_method)) { aoqi@0: max_task = task; aoqi@0: max_method = method; aoqi@0: } aoqi@0: } aoqi@0: task = next_task; aoqi@0: } aoqi@0: aoqi@0: if (max_task->comp_level() == CompLevel_full_profile && TieredStopAtLevel > CompLevel_full_profile aoqi@0: && is_method_profiled(max_method)) { aoqi@0: max_task->set_comp_level(CompLevel_limited_profile); aoqi@0: if (PrintTieredEvents) { aoqi@0: print_event(UPDATE_IN_QUEUE, max_method, max_method, max_task->osr_bci(), (CompLevel)max_task->comp_level()); aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: return max_task; aoqi@0: } aoqi@0: aoqi@0: double AdvancedThresholdPolicy::threshold_scale(CompLevel level, int feedback_k) { aoqi@0: double queue_size = CompileBroker::queue_size(level); aoqi@0: int comp_count = compiler_count(level); aoqi@0: double k = queue_size / (feedback_k * comp_count) + 1; aoqi@0: aoqi@0: // Increase C1 compile threshold when the code cache is filled more aoqi@0: // than specified by IncreaseFirstTierCompileThresholdAt percentage. aoqi@0: // The main intention is to keep enough free space for C2 compiled code aoqi@0: // to achieve peak performance if the code cache is under stress. aoqi@0: if ((TieredStopAtLevel == CompLevel_full_optimization) && (level != CompLevel_full_optimization)) { aoqi@0: double current_reverse_free_ratio = CodeCache::reverse_free_ratio(); aoqi@0: if (current_reverse_free_ratio > _increase_threshold_at_ratio) { aoqi@0: k *= exp(current_reverse_free_ratio - _increase_threshold_at_ratio); aoqi@0: } aoqi@0: } aoqi@0: return k; aoqi@0: } aoqi@0: aoqi@0: // Call and loop predicates determine whether a transition to a higher aoqi@0: // compilation level should be performed (pointers to predicate functions aoqi@0: // are passed to common()). aoqi@0: // Tier?LoadFeedback is basically a coefficient that determines of aoqi@0: // how many methods per compiler thread can be in the queue before aoqi@0: // the threshold values double. aoqi@0: bool AdvancedThresholdPolicy::loop_predicate(int i, int b, CompLevel cur_level) { aoqi@0: switch(cur_level) { aoqi@0: case CompLevel_none: aoqi@0: case CompLevel_limited_profile: { aoqi@0: double k = threshold_scale(CompLevel_full_profile, Tier3LoadFeedback); aoqi@0: return loop_predicate_helper(i, b, k); aoqi@0: } aoqi@0: case CompLevel_full_profile: { aoqi@0: double k = threshold_scale(CompLevel_full_optimization, Tier4LoadFeedback); aoqi@0: return loop_predicate_helper(i, b, k); aoqi@0: } aoqi@0: default: aoqi@0: return true; aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: bool AdvancedThresholdPolicy::call_predicate(int i, int b, CompLevel cur_level) { aoqi@0: switch(cur_level) { aoqi@0: case CompLevel_none: aoqi@0: case CompLevel_limited_profile: { aoqi@0: double k = threshold_scale(CompLevel_full_profile, Tier3LoadFeedback); aoqi@0: return call_predicate_helper(i, b, k); aoqi@0: } aoqi@0: case CompLevel_full_profile: { aoqi@0: double k = threshold_scale(CompLevel_full_optimization, Tier4LoadFeedback); aoqi@0: return call_predicate_helper(i, b, k); aoqi@0: } aoqi@0: default: aoqi@0: return true; aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: // If a method is old enough and is still in the interpreter we would want to aoqi@0: // start profiling without waiting for the compiled method to arrive. aoqi@0: // We also take the load on compilers into the account. aoqi@0: bool AdvancedThresholdPolicy::should_create_mdo(Method* method, CompLevel cur_level) { aoqi@0: if (cur_level == CompLevel_none && aoqi@0: CompileBroker::queue_size(CompLevel_full_optimization) <= aoqi@0: Tier3DelayOn * compiler_count(CompLevel_full_optimization)) { aoqi@0: int i = method->invocation_count(); aoqi@0: int b = method->backedge_count(); aoqi@0: double k = Tier0ProfilingStartPercentage / 100.0; aoqi@0: return call_predicate_helper(i, b, k) || loop_predicate_helper(i, b, k); aoqi@0: } aoqi@0: return false; aoqi@0: } aoqi@0: aoqi@0: // Inlining control: if we're compiling a profiled method with C1 and the callee aoqi@0: // is known to have OSRed in a C2 version, don't inline it. aoqi@0: bool AdvancedThresholdPolicy::should_not_inline(ciEnv* env, ciMethod* callee) { aoqi@0: CompLevel comp_level = (CompLevel)env->comp_level(); aoqi@0: if (comp_level == CompLevel_full_profile || aoqi@0: comp_level == CompLevel_limited_profile) { aoqi@0: return callee->highest_osr_comp_level() == CompLevel_full_optimization; aoqi@0: } aoqi@0: return false; aoqi@0: } aoqi@0: aoqi@0: // Create MDO if necessary. aoqi@0: void AdvancedThresholdPolicy::create_mdo(methodHandle mh, JavaThread* THREAD) { aoqi@0: if (mh->is_native() || mh->is_abstract() || mh->is_accessor()) return; aoqi@0: if (mh->method_data() == NULL) { aoqi@0: Method::build_interpreter_method_data(mh, CHECK_AND_CLEAR); aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: aoqi@0: /* aoqi@0: * Method states: aoqi@0: * 0 - interpreter (CompLevel_none) aoqi@0: * 1 - pure C1 (CompLevel_simple) aoqi@0: * 2 - C1 with invocation and backedge counting (CompLevel_limited_profile) aoqi@0: * 3 - C1 with full profiling (CompLevel_full_profile) aoqi@0: * 4 - C2 (CompLevel_full_optimization) aoqi@0: * aoqi@0: * Common state transition patterns: aoqi@0: * a. 0 -> 3 -> 4. aoqi@0: * The most common path. But note that even in this straightforward case aoqi@0: * profiling can start at level 0 and finish at level 3. aoqi@0: * aoqi@0: * b. 0 -> 2 -> 3 -> 4. aoqi@0: * This case occures when the load on C2 is deemed too high. So, instead of transitioning aoqi@0: * into state 3 directly and over-profiling while a method is in the C2 queue we transition to aoqi@0: * level 2 and wait until the load on C2 decreases. This path is disabled for OSRs. aoqi@0: * aoqi@0: * c. 0 -> (3->2) -> 4. aoqi@0: * In this case we enqueue a method for compilation at level 3, but the C1 queue is long enough aoqi@0: * to enable the profiling to fully occur at level 0. In this case we change the compilation level aoqi@0: * of the method to 2, because it'll allow it to run much faster without full profiling while c2 aoqi@0: * is compiling. aoqi@0: * aoqi@0: * d. 0 -> 3 -> 1 or 0 -> 2 -> 1. aoqi@0: * After a method was once compiled with C1 it can be identified as trivial and be compiled to aoqi@0: * level 1. These transition can also occur if a method can't be compiled with C2 but can with C1. aoqi@0: * aoqi@0: * e. 0 -> 4. aoqi@0: * This can happen if a method fails C1 compilation (it will still be profiled in the interpreter) aoqi@0: * or because of a deopt that didn't require reprofiling (compilation won't happen in this case because aoqi@0: * the compiled version already exists). aoqi@0: * aoqi@0: * Note that since state 0 can be reached from any other state via deoptimization different loops aoqi@0: * are possible. aoqi@0: * aoqi@0: */ aoqi@0: aoqi@0: // Common transition function. Given a predicate determines if a method should transition to another level. aoqi@0: CompLevel AdvancedThresholdPolicy::common(Predicate p, Method* method, CompLevel cur_level, bool disable_feedback) { aoqi@0: CompLevel next_level = cur_level; aoqi@0: int i = method->invocation_count(); aoqi@0: int b = method->backedge_count(); aoqi@0: aoqi@0: if (is_trivial(method)) { aoqi@0: next_level = CompLevel_simple; aoqi@0: } else { aoqi@0: switch(cur_level) { aoqi@0: case CompLevel_none: aoqi@0: // If we were at full profile level, would we switch to full opt? aoqi@0: if (common(p, method, CompLevel_full_profile, disable_feedback) == CompLevel_full_optimization) { aoqi@0: next_level = CompLevel_full_optimization; aoqi@0: } else if ((this->*p)(i, b, cur_level)) { aoqi@0: // C1-generated fully profiled code is about 30% slower than the limited profile aoqi@0: // code that has only invocation and backedge counters. The observation is that aoqi@0: // if C2 queue is large enough we can spend too much time in the fully profiled code aoqi@0: // while waiting for C2 to pick the method from the queue. To alleviate this problem aoqi@0: // we introduce a feedback on the C2 queue size. If the C2 queue is sufficiently long aoqi@0: // we choose to compile a limited profiled version and then recompile with full profiling aoqi@0: // when the load on C2 goes down. aoqi@0: if (!disable_feedback && CompileBroker::queue_size(CompLevel_full_optimization) > aoqi@0: Tier3DelayOn * compiler_count(CompLevel_full_optimization)) { aoqi@0: next_level = CompLevel_limited_profile; aoqi@0: } else { aoqi@0: next_level = CompLevel_full_profile; aoqi@0: } aoqi@0: } aoqi@0: break; aoqi@0: case CompLevel_limited_profile: aoqi@0: if (is_method_profiled(method)) { aoqi@0: // Special case: we got here because this method was fully profiled in the interpreter. aoqi@0: next_level = CompLevel_full_optimization; aoqi@0: } else { aoqi@0: MethodData* mdo = method->method_data(); aoqi@0: if (mdo != NULL) { aoqi@0: if (mdo->would_profile()) { aoqi@0: if (disable_feedback || (CompileBroker::queue_size(CompLevel_full_optimization) <= aoqi@0: Tier3DelayOff * compiler_count(CompLevel_full_optimization) && aoqi@0: (this->*p)(i, b, cur_level))) { aoqi@0: next_level = CompLevel_full_profile; aoqi@0: } aoqi@0: } else { aoqi@0: next_level = CompLevel_full_optimization; aoqi@0: } aoqi@0: } aoqi@0: } aoqi@0: break; aoqi@0: case CompLevel_full_profile: aoqi@0: { aoqi@0: MethodData* mdo = method->method_data(); aoqi@0: if (mdo != NULL) { aoqi@0: if (mdo->would_profile()) { aoqi@0: int mdo_i = mdo->invocation_count_delta(); aoqi@0: int mdo_b = mdo->backedge_count_delta(); aoqi@0: if ((this->*p)(mdo_i, mdo_b, cur_level)) { aoqi@0: next_level = CompLevel_full_optimization; aoqi@0: } aoqi@0: } else { aoqi@0: next_level = CompLevel_full_optimization; aoqi@0: } aoqi@0: } aoqi@0: } aoqi@0: break; aoqi@0: } aoqi@0: } aoqi@0: return MIN2(next_level, (CompLevel)TieredStopAtLevel); aoqi@0: } aoqi@0: aoqi@0: // Determine if a method should be compiled with a normal entry point at a different level. aoqi@0: CompLevel AdvancedThresholdPolicy::call_event(Method* method, CompLevel cur_level) { aoqi@0: CompLevel osr_level = MIN2((CompLevel) method->highest_osr_comp_level(), aoqi@0: common(&AdvancedThresholdPolicy::loop_predicate, method, cur_level, true)); aoqi@0: CompLevel next_level = common(&AdvancedThresholdPolicy::call_predicate, method, cur_level); aoqi@0: aoqi@0: // If OSR method level is greater than the regular method level, the levels should be aoqi@0: // equalized by raising the regular method level in order to avoid OSRs during each aoqi@0: // invocation of the method. aoqi@0: if (osr_level == CompLevel_full_optimization && cur_level == CompLevel_full_profile) { aoqi@0: MethodData* mdo = method->method_data(); aoqi@0: guarantee(mdo != NULL, "MDO should not be NULL"); aoqi@0: if (mdo->invocation_count() >= 1) { aoqi@0: next_level = CompLevel_full_optimization; aoqi@0: } aoqi@0: } else { aoqi@0: next_level = MAX2(osr_level, next_level); aoqi@0: } aoqi@0: return next_level; aoqi@0: } aoqi@0: aoqi@0: // Determine if we should do an OSR compilation of a given method. aoqi@0: CompLevel AdvancedThresholdPolicy::loop_event(Method* method, CompLevel cur_level) { aoqi@0: CompLevel next_level = common(&AdvancedThresholdPolicy::loop_predicate, method, cur_level, true); aoqi@0: if (cur_level == CompLevel_none) { aoqi@0: // If there is a live OSR method that means that we deopted to the interpreter aoqi@0: // for the transition. aoqi@0: CompLevel osr_level = MIN2((CompLevel)method->highest_osr_comp_level(), next_level); aoqi@0: if (osr_level > CompLevel_none) { aoqi@0: return osr_level; aoqi@0: } aoqi@0: } aoqi@0: return next_level; aoqi@0: } aoqi@0: aoqi@0: // Update the rate and submit compile aoqi@0: void AdvancedThresholdPolicy::submit_compile(methodHandle mh, int bci, CompLevel level, JavaThread* thread) { aoqi@0: int hot_count = (bci == InvocationEntryBci) ? mh->invocation_count() : mh->backedge_count(); aoqi@0: update_rate(os::javaTimeMillis(), mh()); aoqi@0: CompileBroker::compile_method(mh, bci, level, mh, hot_count, "tiered", thread); aoqi@0: } aoqi@0: aoqi@0: // Handle the invocation event. aoqi@0: void AdvancedThresholdPolicy::method_invocation_event(methodHandle mh, methodHandle imh, aoqi@0: CompLevel level, nmethod* nm, JavaThread* thread) { aoqi@0: if (should_create_mdo(mh(), level)) { aoqi@0: create_mdo(mh, thread); aoqi@0: } aoqi@0: if (is_compilation_enabled() && !CompileBroker::compilation_is_in_queue(mh, InvocationEntryBci)) { aoqi@0: CompLevel next_level = call_event(mh(), level); aoqi@0: if (next_level != level) { aoqi@0: compile(mh, InvocationEntryBci, next_level, thread); aoqi@0: } aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: // Handle the back branch event. Notice that we can compile the method aoqi@0: // with a regular entry from here. aoqi@0: void AdvancedThresholdPolicy::method_back_branch_event(methodHandle mh, methodHandle imh, aoqi@0: int bci, CompLevel level, nmethod* nm, JavaThread* thread) { aoqi@0: if (should_create_mdo(mh(), level)) { aoqi@0: create_mdo(mh, thread); aoqi@0: } aoqi@0: // Check if MDO should be created for the inlined method aoqi@0: if (should_create_mdo(imh(), level)) { aoqi@0: create_mdo(imh, thread); aoqi@0: } aoqi@0: aoqi@0: if (is_compilation_enabled()) { aoqi@0: CompLevel next_osr_level = loop_event(imh(), level); aoqi@0: CompLevel max_osr_level = (CompLevel)imh->highest_osr_comp_level(); aoqi@0: // At the very least compile the OSR version aoqi@0: if (!CompileBroker::compilation_is_in_queue(imh, bci) && next_osr_level != level) { aoqi@0: compile(imh, bci, next_osr_level, thread); aoqi@0: } aoqi@0: aoqi@0: // Use loop event as an opportunity to also check if there's been aoqi@0: // enough calls. aoqi@0: CompLevel cur_level, next_level; aoqi@0: if (mh() != imh()) { // If there is an enclosing method aoqi@0: guarantee(nm != NULL, "Should have nmethod here"); aoqi@0: cur_level = comp_level(mh()); aoqi@0: next_level = call_event(mh(), cur_level); aoqi@0: aoqi@0: if (max_osr_level == CompLevel_full_optimization) { aoqi@0: // The inlinee OSRed to full opt, we need to modify the enclosing method to avoid deopts aoqi@0: bool make_not_entrant = false; aoqi@0: if (nm->is_osr_method()) { aoqi@0: // This is an osr method, just make it not entrant and recompile later if needed aoqi@0: make_not_entrant = true; aoqi@0: } else { aoqi@0: if (next_level != CompLevel_full_optimization) { aoqi@0: // next_level is not full opt, so we need to recompile the aoqi@0: // enclosing method without the inlinee aoqi@0: cur_level = CompLevel_none; aoqi@0: make_not_entrant = true; aoqi@0: } aoqi@0: } aoqi@0: if (make_not_entrant) { aoqi@0: if (PrintTieredEvents) { aoqi@0: int osr_bci = nm->is_osr_method() ? nm->osr_entry_bci() : InvocationEntryBci; aoqi@0: print_event(MAKE_NOT_ENTRANT, mh(), mh(), osr_bci, level); aoqi@0: } aoqi@0: nm->make_not_entrant(); aoqi@0: } aoqi@0: } aoqi@0: if (!CompileBroker::compilation_is_in_queue(mh, InvocationEntryBci)) { aoqi@0: // Fix up next_level if necessary to avoid deopts aoqi@0: if (next_level == CompLevel_limited_profile && max_osr_level == CompLevel_full_profile) { aoqi@0: next_level = CompLevel_full_profile; aoqi@0: } aoqi@0: if (cur_level != next_level) { aoqi@0: compile(mh, InvocationEntryBci, next_level, thread); aoqi@0: } aoqi@0: } aoqi@0: } else { aoqi@0: cur_level = comp_level(imh()); aoqi@0: next_level = call_event(imh(), cur_level); aoqi@0: if (!CompileBroker::compilation_is_in_queue(imh, bci) && next_level != cur_level) { aoqi@0: compile(imh, InvocationEntryBci, next_level, thread); aoqi@0: } aoqi@0: } aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: #endif // TIERED