17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "compiler/compileBroker.hpp"
27 #include "compiler/compilerOracle.hpp"
28 #include "memory/resourceArea.hpp"
29 #include "runtime/arguments.hpp"
30 #include "runtime/handles.inline.hpp"
31 #include "runtime/safepoint.hpp"
32 #include "runtime/safepointVerifiers.hpp"
33 #include "runtime/tieredThresholdPolicy.hpp"
34 #include "code/scopeDesc.hpp"
35 #include "oops/method.inline.hpp"
36 #if INCLUDE_JVMCI
37 #include "jvmci/jvmciRuntime.hpp"
38 #endif
39
40 #ifdef TIERED
41
42 #include "c1/c1_Compiler.hpp"
43 #include "opto/c2compiler.hpp"
44
45 template<CompLevel level>
46 bool TieredThresholdPolicy::call_predicate_helper(int i, int b, double scale, Method* method) {
47 double threshold_scaling;
48 if (CompilerOracle::has_option_value(method, "CompileThresholdScaling", threshold_scaling)) {
49 scale *= threshold_scaling;
50 }
51 switch(level) {
52 case CompLevel_aot:
53 return (i >= Tier3AOTInvocationThreshold * scale) ||
54 (i >= Tier3AOTMinInvocationThreshold * scale && i + b >= Tier3AOTCompileThreshold * scale);
55 case CompLevel_none:
56 case CompLevel_limited_profile:
57 return (i >= Tier3InvocationThreshold * scale) ||
810 // Determine if a method should be compiled with a normal entry point at a different level.
811 CompLevel TieredThresholdPolicy::call_event(Method* method, CompLevel cur_level, JavaThread * thread) {
812 CompLevel osr_level = MIN2((CompLevel) method->highest_osr_comp_level(),
813 common(&TieredThresholdPolicy::loop_predicate, method, cur_level, true));
814 CompLevel next_level = common(&TieredThresholdPolicy::call_predicate, method, cur_level);
815
816 // If OSR method level is greater than the regular method level, the levels should be
817 // equalized by raising the regular method level in order to avoid OSRs during each
818 // invocation of the method.
819 if (osr_level == CompLevel_full_optimization && cur_level == CompLevel_full_profile) {
820 MethodData* mdo = method->method_data();
821 guarantee(mdo != NULL, "MDO should not be NULL");
822 if (mdo->invocation_count() >= 1) {
823 next_level = CompLevel_full_optimization;
824 }
825 } else {
826 next_level = MAX2(osr_level, next_level);
827 }
828 #if INCLUDE_JVMCI
829 if (UseJVMCICompiler) {
830 next_level = JVMCIRuntime::adjust_comp_level(method, false, next_level, thread);
831 }
832 #endif
833 return next_level;
834 }
835
836 // Determine if we should do an OSR compilation of a given method.
837 CompLevel TieredThresholdPolicy::loop_event(Method* method, CompLevel cur_level, JavaThread* thread) {
838 CompLevel next_level = common(&TieredThresholdPolicy::loop_predicate, method, cur_level, true);
839 if (cur_level == CompLevel_none) {
840 // If there is a live OSR method that means that we deopted to the interpreter
841 // for the transition.
842 CompLevel osr_level = MIN2((CompLevel)method->highest_osr_comp_level(), next_level);
843 if (osr_level > CompLevel_none) {
844 return osr_level;
845 }
846 }
847 #if INCLUDE_JVMCI
848 if (UseJVMCICompiler) {
849 next_level = JVMCIRuntime::adjust_comp_level(method, true, next_level, thread);
850 }
851 #endif
852 return next_level;
853 }
854
855 bool TieredThresholdPolicy::maybe_switch_to_aot(const methodHandle& mh, CompLevel cur_level, CompLevel next_level, JavaThread* thread) {
856 if (UseAOT) {
857 if (cur_level == CompLevel_full_profile || cur_level == CompLevel_none) {
858 // If the current level is full profile or interpreter and we're switching to any other level,
859 // activate the AOT code back first so that we won't waste time overprofiling.
860 compile(mh, InvocationEntryBci, CompLevel_aot, thread);
861 // Fall through for JIT compilation.
862 }
863 if (next_level == CompLevel_limited_profile && cur_level != CompLevel_aot && mh->has_aot_code()) {
864 // If the next level is limited profile, use the aot code (if there is any),
865 // since it's essentially the same thing.
866 compile(mh, InvocationEntryBci, CompLevel_aot, thread);
867 // Not need to JIT, we're done.
868 return true;
869 }
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "compiler/compileBroker.hpp"
27 #include "compiler/compilerOracle.hpp"
28 #include "memory/resourceArea.hpp"
29 #include "runtime/arguments.hpp"
30 #include "runtime/handles.inline.hpp"
31 #include "runtime/safepoint.hpp"
32 #include "runtime/safepointVerifiers.hpp"
33 #include "runtime/tieredThresholdPolicy.hpp"
34 #include "code/scopeDesc.hpp"
35 #include "oops/method.inline.hpp"
36 #if INCLUDE_JVMCI
37 #include "jvmci/jvmci.hpp"
38 #endif
39
40 #ifdef TIERED
41
42 #include "c1/c1_Compiler.hpp"
43 #include "opto/c2compiler.hpp"
44
45 template<CompLevel level>
46 bool TieredThresholdPolicy::call_predicate_helper(int i, int b, double scale, Method* method) {
47 double threshold_scaling;
48 if (CompilerOracle::has_option_value(method, "CompileThresholdScaling", threshold_scaling)) {
49 scale *= threshold_scaling;
50 }
51 switch(level) {
52 case CompLevel_aot:
53 return (i >= Tier3AOTInvocationThreshold * scale) ||
54 (i >= Tier3AOTMinInvocationThreshold * scale && i + b >= Tier3AOTCompileThreshold * scale);
55 case CompLevel_none:
56 case CompLevel_limited_profile:
57 return (i >= Tier3InvocationThreshold * scale) ||
810 // Determine if a method should be compiled with a normal entry point at a different level.
811 CompLevel TieredThresholdPolicy::call_event(Method* method, CompLevel cur_level, JavaThread * thread) {
812 CompLevel osr_level = MIN2((CompLevel) method->highest_osr_comp_level(),
813 common(&TieredThresholdPolicy::loop_predicate, method, cur_level, true));
814 CompLevel next_level = common(&TieredThresholdPolicy::call_predicate, method, cur_level);
815
816 // If OSR method level is greater than the regular method level, the levels should be
817 // equalized by raising the regular method level in order to avoid OSRs during each
818 // invocation of the method.
819 if (osr_level == CompLevel_full_optimization && cur_level == CompLevel_full_profile) {
820 MethodData* mdo = method->method_data();
821 guarantee(mdo != NULL, "MDO should not be NULL");
822 if (mdo->invocation_count() >= 1) {
823 next_level = CompLevel_full_optimization;
824 }
825 } else {
826 next_level = MAX2(osr_level, next_level);
827 }
828 #if INCLUDE_JVMCI
829 if (UseJVMCICompiler) {
830 next_level = JVMCI::adjust_comp_level(method, false, next_level, thread);
831 }
832 #endif
833 return next_level;
834 }
835
836 // Determine if we should do an OSR compilation of a given method.
837 CompLevel TieredThresholdPolicy::loop_event(Method* method, CompLevel cur_level, JavaThread* thread) {
838 CompLevel next_level = common(&TieredThresholdPolicy::loop_predicate, method, cur_level, true);
839 if (cur_level == CompLevel_none) {
840 // If there is a live OSR method that means that we deopted to the interpreter
841 // for the transition.
842 CompLevel osr_level = MIN2((CompLevel)method->highest_osr_comp_level(), next_level);
843 if (osr_level > CompLevel_none) {
844 return osr_level;
845 }
846 }
847 #if INCLUDE_JVMCI
848 if (UseJVMCICompiler) {
849 next_level = JVMCI::adjust_comp_level(method, true, next_level, thread);
850 }
851 #endif
852 return next_level;
853 }
854
855 bool TieredThresholdPolicy::maybe_switch_to_aot(const methodHandle& mh, CompLevel cur_level, CompLevel next_level, JavaThread* thread) {
856 if (UseAOT) {
857 if (cur_level == CompLevel_full_profile || cur_level == CompLevel_none) {
858 // If the current level is full profile or interpreter and we're switching to any other level,
859 // activate the AOT code back first so that we won't waste time overprofiling.
860 compile(mh, InvocationEntryBci, CompLevel_aot, thread);
861 // Fall through for JIT compilation.
862 }
863 if (next_level == CompLevel_limited_profile && cur_level != CompLevel_aot && mh->has_aot_code()) {
864 // If the next level is limited profile, use the aot code (if there is any),
865 // since it's essentially the same thing.
866 compile(mh, InvocationEntryBci, CompLevel_aot, thread);
867 // Not need to JIT, we're done.
868 return true;
869 }
|