author | dlong |
Wed, 24 Apr 2019 09:10:45 -0700 | |
changeset 54647 | c0d9bc9b4e1f |
parent 54015 | cd701366fcf8 |
child 54669 | ad45b3802d4e |
permissions | -rw-r--r-- |
6453 | 1 |
/* |
53193
184c51e48260
8216262: Remove develop flag DelayCompilationDuringStartup
redestad
parents:
52934
diff
changeset
|
2 |
* Copyright (c) 2010, 2019, Oracle and/or its affiliates. All rights reserved. |
6453 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
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 |
||
7397 | 25 |
#include "precompiled.hpp" |
26 |
#include "compiler/compileBroker.hpp" |
|
51369
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
27 |
#include "compiler/compilerOracle.hpp" |
7397 | 28 |
#include "memory/resourceArea.hpp" |
29 |
#include "runtime/arguments.hpp" |
|
49480
d7df2dd501ce
8199809: Don't include frame.inline.hpp and other.inline.hpp from .hpp files
coleenp
parents:
49449
diff
changeset
|
30 |
#include "runtime/handles.inline.hpp" |
53628
213a2377b792
8218276: AIX build fails in tieredThresholdPolicy.cpp
mbaesken
parents:
53195
diff
changeset
|
31 |
#include "runtime/safepoint.hpp" |
49594
898ef81cbc0e
8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
49480
diff
changeset
|
32 |
#include "runtime/safepointVerifiers.hpp" |
51369
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
33 |
#include "runtime/tieredThresholdPolicy.hpp" |
8322 | 34 |
#include "code/scopeDesc.hpp" |
51369
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
35 |
#include "oops/method.inline.hpp" |
38666
5ff19807abd5
8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents:
38218
diff
changeset
|
36 |
#if INCLUDE_JVMCI |
5ff19807abd5
8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents:
38218
diff
changeset
|
37 |
#include "jvmci/jvmciRuntime.hpp" |
5ff19807abd5
8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents:
38218
diff
changeset
|
38 |
#endif |
6453 | 39 |
|
42650 | 40 |
#ifdef TIERED |
11192
ff37c2093a0d
7112085: assert(fr.interpreter_frame_expression_stack_size()==0) failed: only handle empty stacks
iveresov
parents:
10250
diff
changeset
|
41 |
|
52325
0451e0a2f1f5
8177899: Tests fail due to code cache exhaustion on machines with many cores
thartmann
parents:
51369
diff
changeset
|
42 |
#include "c1/c1_Compiler.hpp" |
0451e0a2f1f5
8177899: Tests fail due to code cache exhaustion on machines with many cores
thartmann
parents:
51369
diff
changeset
|
43 |
#include "opto/c2compiler.hpp" |
0451e0a2f1f5
8177899: Tests fail due to code cache exhaustion on machines with many cores
thartmann
parents:
51369
diff
changeset
|
44 |
|
51369
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
45 |
template<CompLevel level> |
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
46 |
bool TieredThresholdPolicy::call_predicate_helper(int i, int b, double scale, Method* method) { |
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
47 |
double threshold_scaling; |
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
48 |
if (CompilerOracle::has_option_value(method, "CompileThresholdScaling", threshold_scaling)) { |
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
49 |
scale *= threshold_scaling; |
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
50 |
} |
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
51 |
switch(level) { |
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
52 |
case CompLevel_aot: |
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
53 |
return (i >= Tier3AOTInvocationThreshold * scale) || |
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
54 |
(i >= Tier3AOTMinInvocationThreshold * scale && i + b >= Tier3AOTCompileThreshold * scale); |
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
55 |
case CompLevel_none: |
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
56 |
case CompLevel_limited_profile: |
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
57 |
return (i >= Tier3InvocationThreshold * scale) || |
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
58 |
(i >= Tier3MinInvocationThreshold * scale && i + b >= Tier3CompileThreshold * scale); |
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
59 |
case CompLevel_full_profile: |
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
60 |
return (i >= Tier4InvocationThreshold * scale) || |
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
61 |
(i >= Tier4MinInvocationThreshold * scale && i + b >= Tier4CompileThreshold * scale); |
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
62 |
} |
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
63 |
return true; |
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
64 |
} |
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
65 |
|
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
66 |
template<CompLevel level> |
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
67 |
bool TieredThresholdPolicy::loop_predicate_helper(int i, int b, double scale, Method* method) { |
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
68 |
double threshold_scaling; |
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
69 |
if (CompilerOracle::has_option_value(method, "CompileThresholdScaling", threshold_scaling)) { |
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
70 |
scale *= threshold_scaling; |
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
71 |
} |
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
72 |
switch(level) { |
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
73 |
case CompLevel_aot: |
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
74 |
return b >= Tier3AOTBackEdgeThreshold * scale; |
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
75 |
case CompLevel_none: |
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
76 |
case CompLevel_limited_profile: |
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
77 |
return b >= Tier3BackEdgeThreshold * scale; |
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
78 |
case CompLevel_full_profile: |
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
79 |
return b >= Tier4BackEdgeThreshold * scale; |
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
80 |
} |
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
81 |
return true; |
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
82 |
} |
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
83 |
|
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
84 |
// Simple methods are as good being compiled with C1 as C2. |
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
85 |
// Determine if a given method is such a case. |
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
86 |
bool TieredThresholdPolicy::is_trivial(Method* method) { |
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
87 |
if (method->is_accessor() || |
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
88 |
method->is_constant_getter()) { |
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
89 |
return true; |
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
90 |
} |
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
91 |
return false; |
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
92 |
} |
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
93 |
|
54647
c0d9bc9b4e1f
8219403: JVMCIRuntime::adjust_comp_level should be replaced
dlong
parents:
54015
diff
changeset
|
94 |
bool TieredThresholdPolicy::should_compile_at_level_simple(Method* method) { |
c0d9bc9b4e1f
8219403: JVMCIRuntime::adjust_comp_level should be replaced
dlong
parents:
54015
diff
changeset
|
95 |
if (TieredThresholdPolicy::is_trivial(method)) { |
c0d9bc9b4e1f
8219403: JVMCIRuntime::adjust_comp_level should be replaced
dlong
parents:
54015
diff
changeset
|
96 |
return true; |
c0d9bc9b4e1f
8219403: JVMCIRuntime::adjust_comp_level should be replaced
dlong
parents:
54015
diff
changeset
|
97 |
} |
c0d9bc9b4e1f
8219403: JVMCIRuntime::adjust_comp_level should be replaced
dlong
parents:
54015
diff
changeset
|
98 |
#if INCLUDE_JVMCI |
c0d9bc9b4e1f
8219403: JVMCIRuntime::adjust_comp_level should be replaced
dlong
parents:
54015
diff
changeset
|
99 |
if (UseJVMCICompiler) { |
c0d9bc9b4e1f
8219403: JVMCIRuntime::adjust_comp_level should be replaced
dlong
parents:
54015
diff
changeset
|
100 |
AbstractCompiler* comp = CompileBroker::compiler(CompLevel_full_optimization); |
c0d9bc9b4e1f
8219403: JVMCIRuntime::adjust_comp_level should be replaced
dlong
parents:
54015
diff
changeset
|
101 |
if (comp != NULL && comp->is_jvmci() && ((JVMCICompiler*) comp)->force_comp_at_level_simple(method)) { |
c0d9bc9b4e1f
8219403: JVMCIRuntime::adjust_comp_level should be replaced
dlong
parents:
54015
diff
changeset
|
102 |
return true; |
c0d9bc9b4e1f
8219403: JVMCIRuntime::adjust_comp_level should be replaced
dlong
parents:
54015
diff
changeset
|
103 |
} |
c0d9bc9b4e1f
8219403: JVMCIRuntime::adjust_comp_level should be replaced
dlong
parents:
54015
diff
changeset
|
104 |
} |
c0d9bc9b4e1f
8219403: JVMCIRuntime::adjust_comp_level should be replaced
dlong
parents:
54015
diff
changeset
|
105 |
#endif |
c0d9bc9b4e1f
8219403: JVMCIRuntime::adjust_comp_level should be replaced
dlong
parents:
54015
diff
changeset
|
106 |
return false; |
c0d9bc9b4e1f
8219403: JVMCIRuntime::adjust_comp_level should be replaced
dlong
parents:
54015
diff
changeset
|
107 |
} |
c0d9bc9b4e1f
8219403: JVMCIRuntime::adjust_comp_level should be replaced
dlong
parents:
54015
diff
changeset
|
108 |
|
51369
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
109 |
CompLevel TieredThresholdPolicy::comp_level(Method* method) { |
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
110 |
CompiledMethod *nm = method->code(); |
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
111 |
if (nm != NULL && nm->is_in_use()) { |
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
112 |
return (CompLevel)nm->comp_level(); |
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
113 |
} |
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
114 |
return CompLevel_none; |
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
115 |
} |
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
116 |
|
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
117 |
void TieredThresholdPolicy::print_counters(const char* prefix, const methodHandle& mh) { |
11192
ff37c2093a0d
7112085: assert(fr.interpreter_frame_expression_stack_size()==0) failed: only handle empty stacks
iveresov
parents:
10250
diff
changeset
|
118 |
int invocation_count = mh->invocation_count(); |
ff37c2093a0d
7112085: assert(fr.interpreter_frame_expression_stack_size()==0) failed: only handle empty stacks
iveresov
parents:
10250
diff
changeset
|
119 |
int backedge_count = mh->backedge_count(); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11572
diff
changeset
|
120 |
MethodData* mdh = mh->method_data(); |
11192
ff37c2093a0d
7112085: assert(fr.interpreter_frame_expression_stack_size()==0) failed: only handle empty stacks
iveresov
parents:
10250
diff
changeset
|
121 |
int mdo_invocations = 0, mdo_backedges = 0; |
ff37c2093a0d
7112085: assert(fr.interpreter_frame_expression_stack_size()==0) failed: only handle empty stacks
iveresov
parents:
10250
diff
changeset
|
122 |
int mdo_invocations_start = 0, mdo_backedges_start = 0; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11572
diff
changeset
|
123 |
if (mdh != NULL) { |
11192
ff37c2093a0d
7112085: assert(fr.interpreter_frame_expression_stack_size()==0) failed: only handle empty stacks
iveresov
parents:
10250
diff
changeset
|
124 |
mdo_invocations = mdh->invocation_count(); |
ff37c2093a0d
7112085: assert(fr.interpreter_frame_expression_stack_size()==0) failed: only handle empty stacks
iveresov
parents:
10250
diff
changeset
|
125 |
mdo_backedges = mdh->backedge_count(); |
ff37c2093a0d
7112085: assert(fr.interpreter_frame_expression_stack_size()==0) failed: only handle empty stacks
iveresov
parents:
10250
diff
changeset
|
126 |
mdo_invocations_start = mdh->invocation_count_start(); |
ff37c2093a0d
7112085: assert(fr.interpreter_frame_expression_stack_size()==0) failed: only handle empty stacks
iveresov
parents:
10250
diff
changeset
|
127 |
mdo_backedges_start = mdh->backedge_count_start(); |
ff37c2093a0d
7112085: assert(fr.interpreter_frame_expression_stack_size()==0) failed: only handle empty stacks
iveresov
parents:
10250
diff
changeset
|
128 |
} |
13891
35dabd293e56
7200001: failed C1 OSR compile doesn't get recompiled with C2
twisti
parents:
13728
diff
changeset
|
129 |
tty->print(" %stotal=%d,%d %smdo=%d(%d),%d(%d)", prefix, |
11192
ff37c2093a0d
7112085: assert(fr.interpreter_frame_expression_stack_size()==0) failed: only handle empty stacks
iveresov
parents:
10250
diff
changeset
|
130 |
invocation_count, backedge_count, prefix, |
ff37c2093a0d
7112085: assert(fr.interpreter_frame_expression_stack_size()==0) failed: only handle empty stacks
iveresov
parents:
10250
diff
changeset
|
131 |
mdo_invocations, mdo_invocations_start, |
ff37c2093a0d
7112085: assert(fr.interpreter_frame_expression_stack_size()==0) failed: only handle empty stacks
iveresov
parents:
10250
diff
changeset
|
132 |
mdo_backedges, mdo_backedges_start); |
13891
35dabd293e56
7200001: failed C1 OSR compile doesn't get recompiled with C2
twisti
parents:
13728
diff
changeset
|
133 |
tty->print(" %smax levels=%d,%d", prefix, |
11192
ff37c2093a0d
7112085: assert(fr.interpreter_frame_expression_stack_size()==0) failed: only handle empty stacks
iveresov
parents:
10250
diff
changeset
|
134 |
mh->highest_comp_level(), mh->highest_osr_comp_level()); |
ff37c2093a0d
7112085: assert(fr.interpreter_frame_expression_stack_size()==0) failed: only handle empty stacks
iveresov
parents:
10250
diff
changeset
|
135 |
} |
ff37c2093a0d
7112085: assert(fr.interpreter_frame_expression_stack_size()==0) failed: only handle empty stacks
iveresov
parents:
10250
diff
changeset
|
136 |
|
6453 | 137 |
// Print an event. |
51369
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
138 |
void TieredThresholdPolicy::print_event(EventType type, const methodHandle& mh, const methodHandle& imh, |
6453 | 139 |
int bci, CompLevel level) { |
140 |
bool inlinee_event = mh() != imh(); |
|
141 |
||
142 |
ttyLocker tty_lock; |
|
143 |
tty->print("%lf: [", os::elapsedTime()); |
|
144 |
||
145 |
switch(type) { |
|
146 |
case CALL: |
|
147 |
tty->print("call"); |
|
148 |
break; |
|
149 |
case LOOP: |
|
150 |
tty->print("loop"); |
|
151 |
break; |
|
152 |
case COMPILE: |
|
153 |
tty->print("compile"); |
|
8322 | 154 |
break; |
10014
a5c2141ee857
7057120: Tiered: Allow C1 to inline methods with loops
iveresov
parents:
10013
diff
changeset
|
155 |
case REMOVE_FROM_QUEUE: |
a5c2141ee857
7057120: Tiered: Allow C1 to inline methods with loops
iveresov
parents:
10013
diff
changeset
|
156 |
tty->print("remove-from-queue"); |
8322 | 157 |
break; |
10014
a5c2141ee857
7057120: Tiered: Allow C1 to inline methods with loops
iveresov
parents:
10013
diff
changeset
|
158 |
case UPDATE_IN_QUEUE: |
a5c2141ee857
7057120: Tiered: Allow C1 to inline methods with loops
iveresov
parents:
10013
diff
changeset
|
159 |
tty->print("update-in-queue"); |
8322 | 160 |
break; |
161 |
case REPROFILE: |
|
162 |
tty->print("reprofile"); |
|
163 |
break; |
|
10014
a5c2141ee857
7057120: Tiered: Allow C1 to inline methods with loops
iveresov
parents:
10013
diff
changeset
|
164 |
case MAKE_NOT_ENTRANT: |
a5c2141ee857
7057120: Tiered: Allow C1 to inline methods with loops
iveresov
parents:
10013
diff
changeset
|
165 |
tty->print("make-not-entrant"); |
a5c2141ee857
7057120: Tiered: Allow C1 to inline methods with loops
iveresov
parents:
10013
diff
changeset
|
166 |
break; |
8322 | 167 |
default: |
168 |
tty->print("unknown"); |
|
6453 | 169 |
} |
170 |
||
13891
35dabd293e56
7200001: failed C1 OSR compile doesn't get recompiled with C2
twisti
parents:
13728
diff
changeset
|
171 |
tty->print(" level=%d ", level); |
6453 | 172 |
|
173 |
ResourceMark rm; |
|
174 |
char *method_name = mh->name_and_sig_as_C_string(); |
|
175 |
tty->print("[%s", method_name); |
|
176 |
if (inlinee_event) { |
|
177 |
char *inlinee_name = imh->name_and_sig_as_C_string(); |
|
178 |
tty->print(" [%s]] ", inlinee_name); |
|
179 |
} |
|
180 |
else tty->print("] "); |
|
13891
35dabd293e56
7200001: failed C1 OSR compile doesn't get recompiled with C2
twisti
parents:
13728
diff
changeset
|
181 |
tty->print("@%d queues=%d,%d", bci, CompileBroker::queue_size(CompLevel_full_profile), |
35dabd293e56
7200001: failed C1 OSR compile doesn't get recompiled with C2
twisti
parents:
13728
diff
changeset
|
182 |
CompileBroker::queue_size(CompLevel_full_optimization)); |
6453 | 183 |
|
184 |
print_specific(type, mh, imh, bci, level); |
|
185 |
||
186 |
if (type != COMPILE) { |
|
11192
ff37c2093a0d
7112085: assert(fr.interpreter_frame_expression_stack_size()==0) failed: only handle empty stacks
iveresov
parents:
10250
diff
changeset
|
187 |
print_counters("", mh); |
6453 | 188 |
if (inlinee_event) { |
11192
ff37c2093a0d
7112085: assert(fr.interpreter_frame_expression_stack_size()==0) failed: only handle empty stacks
iveresov
parents:
10250
diff
changeset
|
189 |
print_counters("inlinee ", imh); |
6453 | 190 |
} |
13891
35dabd293e56
7200001: failed C1 OSR compile doesn't get recompiled with C2
twisti
parents:
13728
diff
changeset
|
191 |
tty->print(" compilable="); |
6453 | 192 |
bool need_comma = false; |
193 |
if (!mh->is_not_compilable(CompLevel_full_profile)) { |
|
194 |
tty->print("c1"); |
|
195 |
need_comma = true; |
|
196 |
} |
|
13891
35dabd293e56
7200001: failed C1 OSR compile doesn't get recompiled with C2
twisti
parents:
13728
diff
changeset
|
197 |
if (!mh->is_not_osr_compilable(CompLevel_full_profile)) { |
35dabd293e56
7200001: failed C1 OSR compile doesn't get recompiled with C2
twisti
parents:
13728
diff
changeset
|
198 |
if (need_comma) tty->print(","); |
35dabd293e56
7200001: failed C1 OSR compile doesn't get recompiled with C2
twisti
parents:
13728
diff
changeset
|
199 |
tty->print("c1-osr"); |
35dabd293e56
7200001: failed C1 OSR compile doesn't get recompiled with C2
twisti
parents:
13728
diff
changeset
|
200 |
need_comma = true; |
35dabd293e56
7200001: failed C1 OSR compile doesn't get recompiled with C2
twisti
parents:
13728
diff
changeset
|
201 |
} |
6453 | 202 |
if (!mh->is_not_compilable(CompLevel_full_optimization)) { |
13891
35dabd293e56
7200001: failed C1 OSR compile doesn't get recompiled with C2
twisti
parents:
13728
diff
changeset
|
203 |
if (need_comma) tty->print(","); |
6453 | 204 |
tty->print("c2"); |
205 |
need_comma = true; |
|
206 |
} |
|
13891
35dabd293e56
7200001: failed C1 OSR compile doesn't get recompiled with C2
twisti
parents:
13728
diff
changeset
|
207 |
if (!mh->is_not_osr_compilable(CompLevel_full_optimization)) { |
35dabd293e56
7200001: failed C1 OSR compile doesn't get recompiled with C2
twisti
parents:
13728
diff
changeset
|
208 |
if (need_comma) tty->print(","); |
35dabd293e56
7200001: failed C1 OSR compile doesn't get recompiled with C2
twisti
parents:
13728
diff
changeset
|
209 |
tty->print("c2-osr"); |
6453 | 210 |
} |
13891
35dabd293e56
7200001: failed C1 OSR compile doesn't get recompiled with C2
twisti
parents:
13728
diff
changeset
|
211 |
tty->print(" status="); |
6453 | 212 |
if (mh->queued_for_compilation()) { |
13891
35dabd293e56
7200001: failed C1 OSR compile doesn't get recompiled with C2
twisti
parents:
13728
diff
changeset
|
213 |
tty->print("in-queue"); |
35dabd293e56
7200001: failed C1 OSR compile doesn't get recompiled with C2
twisti
parents:
13728
diff
changeset
|
214 |
} else tty->print("idle"); |
6453 | 215 |
} |
216 |
tty->print_cr("]"); |
|
217 |
} |
|
218 |
||
51369
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
219 |
void TieredThresholdPolicy::initialize() { |
6453 | 220 |
int count = CICompilerCount; |
52325
0451e0a2f1f5
8177899: Tests fail due to code cache exhaustion on machines with many cores
thartmann
parents:
51369
diff
changeset
|
221 |
bool c1_only = TieredStopAtLevel < CompLevel_full_optimization; |
36556
7f092a7ce938
8150839: Adjust the number of compiler threads for 32-bit platforms
zmajo
parents:
35547
diff
changeset
|
222 |
#ifdef _LP64 |
50068 | 223 |
// Turn on ergonomic compiler count selection |
224 |
if (FLAG_IS_DEFAULT(CICompilerCountPerCPU) && FLAG_IS_DEFAULT(CICompilerCount)) { |
|
225 |
FLAG_SET_DEFAULT(CICompilerCountPerCPU, true); |
|
226 |
} |
|
6453 | 227 |
if (CICompilerCountPerCPU) { |
50068 | 228 |
// Simple log n seems to grow too slowly for tiered, try something faster: log n * log log n |
52675 | 229 |
int log_cpu = log2_int(os::active_processor_count()); |
230 |
int loglog_cpu = log2_int(MAX2(log_cpu, 1)); |
|
50068 | 231 |
count = MAX2(log_cpu * loglog_cpu * 3 / 2, 2); |
52325
0451e0a2f1f5
8177899: Tests fail due to code cache exhaustion on machines with many cores
thartmann
parents:
51369
diff
changeset
|
232 |
// Make sure there is enough space in the code cache to hold all the compiler buffers |
0451e0a2f1f5
8177899: Tests fail due to code cache exhaustion on machines with many cores
thartmann
parents:
51369
diff
changeset
|
233 |
size_t c1_size = Compiler::code_buffer_size(); |
0451e0a2f1f5
8177899: Tests fail due to code cache exhaustion on machines with many cores
thartmann
parents:
51369
diff
changeset
|
234 |
size_t c2_size = C2Compiler::initial_code_buffer_size(); |
0451e0a2f1f5
8177899: Tests fail due to code cache exhaustion on machines with many cores
thartmann
parents:
51369
diff
changeset
|
235 |
size_t buffer_size = c1_only ? c1_size : (c1_size/3 + 2*c2_size/3); |
0451e0a2f1f5
8177899: Tests fail due to code cache exhaustion on machines with many cores
thartmann
parents:
51369
diff
changeset
|
236 |
int max_count = (ReservedCodeCacheSize - (CodeCacheMinimumUseSpace DEBUG_ONLY(* 3))) / (int)buffer_size; |
0451e0a2f1f5
8177899: Tests fail due to code cache exhaustion on machines with many cores
thartmann
parents:
51369
diff
changeset
|
237 |
if (count > max_count) { |
0451e0a2f1f5
8177899: Tests fail due to code cache exhaustion on machines with many cores
thartmann
parents:
51369
diff
changeset
|
238 |
// Lower the compiler count such that all buffers fit into the code cache |
0451e0a2f1f5
8177899: Tests fail due to code cache exhaustion on machines with many cores
thartmann
parents:
51369
diff
changeset
|
239 |
count = MAX2(max_count, c1_only ? 1 : 2); |
0451e0a2f1f5
8177899: Tests fail due to code cache exhaustion on machines with many cores
thartmann
parents:
51369
diff
changeset
|
240 |
} |
50068 | 241 |
FLAG_SET_ERGO(intx, CICompilerCount, count); |
242 |
} |
|
243 |
#else |
|
244 |
// On 32-bit systems, the number of compiler threads is limited to 3. |
|
245 |
// On these systems, the virtual address space available to the JVM |
|
246 |
// is usually limited to 2-4 GB (the exact value depends on the platform). |
|
247 |
// As the compilers (especially C2) can consume a large amount of |
|
248 |
// memory, scaling the number of compiler threads with the number of |
|
249 |
// available cores can result in the exhaustion of the address space |
|
250 |
/// available to the VM and thus cause the VM to crash. |
|
251 |
if (FLAG_IS_DEFAULT(CICompilerCount)) { |
|
252 |
count = 3; |
|
40364
5bf8fa4fddfd
8162881: Effect of -XX:CICompilerCount depends on ordering of other flags
thartmann
parents:
40074
diff
changeset
|
253 |
FLAG_SET_ERGO(intx, CICompilerCount, count); |
6453 | 254 |
} |
36556
7f092a7ce938
8150839: Adjust the number of compiler threads for 32-bit platforms
zmajo
parents:
35547
diff
changeset
|
255 |
#endif |
50068 | 256 |
|
52325
0451e0a2f1f5
8177899: Tests fail due to code cache exhaustion on machines with many cores
thartmann
parents:
51369
diff
changeset
|
257 |
if (c1_only) { |
40364
5bf8fa4fddfd
8162881: Effect of -XX:CICompilerCount depends on ordering of other flags
thartmann
parents:
40074
diff
changeset
|
258 |
// No C2 compiler thread required |
5bf8fa4fddfd
8162881: Effect of -XX:CICompilerCount depends on ordering of other flags
thartmann
parents:
40074
diff
changeset
|
259 |
set_c1_count(count); |
5bf8fa4fddfd
8162881: Effect of -XX:CICompilerCount depends on ordering of other flags
thartmann
parents:
40074
diff
changeset
|
260 |
} else { |
5bf8fa4fddfd
8162881: Effect of -XX:CICompilerCount depends on ordering of other flags
thartmann
parents:
40074
diff
changeset
|
261 |
set_c1_count(MAX2(count / 3, 1)); |
5bf8fa4fddfd
8162881: Effect of -XX:CICompilerCount depends on ordering of other flags
thartmann
parents:
40074
diff
changeset
|
262 |
set_c2_count(MAX2(count - c1_count(), 1)); |
5bf8fa4fddfd
8162881: Effect of -XX:CICompilerCount depends on ordering of other flags
thartmann
parents:
40074
diff
changeset
|
263 |
} |
5bf8fa4fddfd
8162881: Effect of -XX:CICompilerCount depends on ordering of other flags
thartmann
parents:
40074
diff
changeset
|
264 |
assert(count == c1_count() + c2_count(), "inconsistent compiler thread count"); |
50068 | 265 |
|
266 |
// Some inlining tuning |
|
267 |
#ifdef X86 |
|
268 |
if (FLAG_IS_DEFAULT(InlineSmallCode)) { |
|
269 |
FLAG_SET_DEFAULT(InlineSmallCode, 2000); |
|
270 |
} |
|
271 |
#endif |
|
272 |
||
273 |
#if defined SPARC || defined AARCH64 |
|
274 |
if (FLAG_IS_DEFAULT(InlineSmallCode)) { |
|
275 |
FLAG_SET_DEFAULT(InlineSmallCode, 2500); |
|
276 |
} |
|
277 |
#endif |
|
278 |
||
279 |
set_increase_threshold_at_ratio(); |
|
280 |
set_start_time(os::javaTimeMillis()); |
|
6453 | 281 |
} |
282 |
||
51369
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
283 |
void TieredThresholdPolicy::set_carry_if_necessary(InvocationCounter *counter) { |
6453 | 284 |
if (!counter->carry() && counter->count() > InvocationCounter::count_limit / 2) { |
285 |
counter->set_carry_flag(); |
|
286 |
} |
|
287 |
} |
|
288 |
||
289 |
// Set carry flags on the counters if necessary |
|
51369
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
290 |
void TieredThresholdPolicy::handle_counter_overflow(Method* method) { |
17000
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
13891
diff
changeset
|
291 |
MethodCounters *mcs = method->method_counters(); |
17130
6853aae617cb
8013036: vm/runtime/simpleThresholdPolicy.cpp: assert(mcs != NULL).
jiangli
parents:
17000
diff
changeset
|
292 |
if (mcs != NULL) { |
6853aae617cb
8013036: vm/runtime/simpleThresholdPolicy.cpp: assert(mcs != NULL).
jiangli
parents:
17000
diff
changeset
|
293 |
set_carry_if_necessary(mcs->invocation_counter()); |
6853aae617cb
8013036: vm/runtime/simpleThresholdPolicy.cpp: assert(mcs != NULL).
jiangli
parents:
17000
diff
changeset
|
294 |
set_carry_if_necessary(mcs->backedge_counter()); |
6853aae617cb
8013036: vm/runtime/simpleThresholdPolicy.cpp: assert(mcs != NULL).
jiangli
parents:
17000
diff
changeset
|
295 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11572
diff
changeset
|
296 |
MethodData* mdo = method->method_data(); |
6453 | 297 |
if (mdo != NULL) { |
298 |
set_carry_if_necessary(mdo->invocation_counter()); |
|
299 |
set_carry_if_necessary(mdo->backedge_counter()); |
|
300 |
} |
|
301 |
} |
|
302 |
||
303 |
// Called with the queue locked and with at least one element |
|
51369
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
304 |
CompileTask* TieredThresholdPolicy::select_task(CompileQueue* compile_queue) { |
50068 | 305 |
CompileTask *max_blocking_task = NULL; |
306 |
CompileTask *max_task = NULL; |
|
307 |
Method* max_method = NULL; |
|
308 |
jlong t = os::javaTimeMillis(); |
|
309 |
// Iterate through the queue and find a method with a maximum rate. |
|
310 |
for (CompileTask* task = compile_queue->first(); task != NULL;) { |
|
311 |
CompileTask* next_task = task->next(); |
|
312 |
Method* method = task->method(); |
|
54015
cd701366fcf8
8163511: Allocation of compile task fails with assert: "Leaking compilation tasks?"
thartmann
parents:
54009
diff
changeset
|
313 |
// If a method was unloaded or has been stale for some time, remove it from the queue. |
cd701366fcf8
8163511: Allocation of compile task fails with assert: "Leaking compilation tasks?"
thartmann
parents:
54009
diff
changeset
|
314 |
// Blocking tasks and tasks submitted from whitebox API don't become stale |
cd701366fcf8
8163511: Allocation of compile task fails with assert: "Leaking compilation tasks?"
thartmann
parents:
54009
diff
changeset
|
315 |
if (task->is_unloaded() || (task->can_become_stale() && is_stale(t, TieredCompileTaskTimeout, method) && !is_old(method))) { |
cd701366fcf8
8163511: Allocation of compile task fails with assert: "Leaking compilation tasks?"
thartmann
parents:
54009
diff
changeset
|
316 |
if (!task->is_unloaded()) { |
cd701366fcf8
8163511: Allocation of compile task fails with assert: "Leaking compilation tasks?"
thartmann
parents:
54009
diff
changeset
|
317 |
if (PrintTieredEvents) { |
cd701366fcf8
8163511: Allocation of compile task fails with assert: "Leaking compilation tasks?"
thartmann
parents:
54009
diff
changeset
|
318 |
print_event(REMOVE_FROM_QUEUE, method, method, task->osr_bci(), (CompLevel) task->comp_level()); |
cd701366fcf8
8163511: Allocation of compile task fails with assert: "Leaking compilation tasks?"
thartmann
parents:
54009
diff
changeset
|
319 |
} |
cd701366fcf8
8163511: Allocation of compile task fails with assert: "Leaking compilation tasks?"
thartmann
parents:
54009
diff
changeset
|
320 |
method->clear_queued_for_compilation(); |
cd701366fcf8
8163511: Allocation of compile task fails with assert: "Leaking compilation tasks?"
thartmann
parents:
54009
diff
changeset
|
321 |
} |
cd701366fcf8
8163511: Allocation of compile task fails with assert: "Leaking compilation tasks?"
thartmann
parents:
54009
diff
changeset
|
322 |
compile_queue->remove_and_mark_stale(task); |
cd701366fcf8
8163511: Allocation of compile task fails with assert: "Leaking compilation tasks?"
thartmann
parents:
54009
diff
changeset
|
323 |
task = next_task; |
cd701366fcf8
8163511: Allocation of compile task fails with assert: "Leaking compilation tasks?"
thartmann
parents:
54009
diff
changeset
|
324 |
continue; |
cd701366fcf8
8163511: Allocation of compile task fails with assert: "Leaking compilation tasks?"
thartmann
parents:
54009
diff
changeset
|
325 |
} |
50068 | 326 |
update_rate(t, method); |
54015
cd701366fcf8
8163511: Allocation of compile task fails with assert: "Leaking compilation tasks?"
thartmann
parents:
54009
diff
changeset
|
327 |
if (max_task == NULL || compare_methods(method, max_method)) { |
cd701366fcf8
8163511: Allocation of compile task fails with assert: "Leaking compilation tasks?"
thartmann
parents:
54009
diff
changeset
|
328 |
// Select a method with the highest rate |
50068 | 329 |
max_task = task; |
330 |
max_method = method; |
|
331 |
} |
|
332 |
||
333 |
if (task->is_blocking()) { |
|
334 |
if (max_blocking_task == NULL || compare_methods(method, max_blocking_task->method())) { |
|
335 |
max_blocking_task = task; |
|
336 |
} |
|
337 |
} |
|
338 |
||
339 |
task = next_task; |
|
340 |
} |
|
341 |
||
342 |
if (max_blocking_task != NULL) { |
|
343 |
// In blocking compilation mode, the CompileBroker will make |
|
344 |
// compilations submitted by a JVMCI compiler thread non-blocking. These |
|
345 |
// compilations should be scheduled after all blocking compilations |
|
346 |
// to service non-compiler related compilations sooner and reduce the |
|
347 |
// chance of such compilations timing out. |
|
348 |
max_task = max_blocking_task; |
|
349 |
max_method = max_task->method(); |
|
350 |
} |
|
351 |
||
51078 | 352 |
if (max_task != NULL && max_task->comp_level() == CompLevel_full_profile && |
353 |
TieredStopAtLevel > CompLevel_full_profile && |
|
354 |
max_method != NULL && is_method_profiled(max_method)) { |
|
50068 | 355 |
max_task->set_comp_level(CompLevel_limited_profile); |
356 |
if (PrintTieredEvents) { |
|
357 |
print_event(UPDATE_IN_QUEUE, max_method, max_method, max_task->osr_bci(), (CompLevel)max_task->comp_level()); |
|
358 |
} |
|
359 |
} |
|
360 |
||
361 |
return max_task; |
|
6453 | 362 |
} |
363 |
||
51369
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
364 |
void TieredThresholdPolicy::reprofile(ScopeDesc* trap_scope, bool is_osr) { |
8322 | 365 |
for (ScopeDesc* sd = trap_scope;; sd = sd->sender()) { |
366 |
if (PrintTieredEvents) { |
|
367 |
methodHandle mh(sd->method()); |
|
368 |
print_event(REPROFILE, mh, mh, InvocationEntryBci, CompLevel_none); |
|
369 |
} |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11572
diff
changeset
|
370 |
MethodData* mdo = sd->method()->method_data(); |
8322 | 371 |
if (mdo != NULL) { |
372 |
mdo->reset_start_counters(); |
|
373 |
} |
|
374 |
if (sd->is_top()) break; |
|
375 |
} |
|
376 |
} |
|
377 |
||
51369
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
378 |
nmethod* TieredThresholdPolicy::event(const methodHandle& method, const methodHandle& inlinee, |
38133
78b95467b9f1
8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
37281
diff
changeset
|
379 |
int branch_bci, int bci, CompLevel comp_level, CompiledMethod* nm, JavaThread* thread) { |
6453 | 380 |
if (comp_level == CompLevel_none && |
11572
84afef481892
7131259: compile_method and CompilationPolicy::event shouldn't be declared TRAPS
iveresov
parents:
11192
diff
changeset
|
381 |
JvmtiExport::can_post_interpreter_events() && |
84afef481892
7131259: compile_method and CompilationPolicy::event shouldn't be declared TRAPS
iveresov
parents:
11192
diff
changeset
|
382 |
thread->is_interp_only_mode()) { |
84afef481892
7131259: compile_method and CompilationPolicy::event shouldn't be declared TRAPS
iveresov
parents:
11192
diff
changeset
|
383 |
return NULL; |
6453 | 384 |
} |
52934
8deeb7bba516
8214917: CTW testlibrary shouldn't ignore errors raised by the library itself
iignatyev
parents:
52675
diff
changeset
|
385 |
if (ReplayCompiles) { |
24324
e18584aa83e2
8041959: Skip replay parsing errors with ReplayIgnoreInitErrors
kvn
parents:
24321
diff
changeset
|
386 |
// Don't trigger other compiles in testing mode |
e18584aa83e2
8041959: Skip replay parsing errors with ReplayIgnoreInitErrors
kvn
parents:
24321
diff
changeset
|
387 |
return NULL; |
e18584aa83e2
8041959: Skip replay parsing errors with ReplayIgnoreInitErrors
kvn
parents:
24321
diff
changeset
|
388 |
} |
6453 | 389 |
|
390 |
handle_counter_overflow(method()); |
|
391 |
if (method() != inlinee()) { |
|
392 |
handle_counter_overflow(inlinee()); |
|
393 |
} |
|
394 |
||
395 |
if (PrintTieredEvents) { |
|
396 |
print_event(bci == InvocationEntryBci ? CALL : LOOP, method, inlinee, bci, comp_level); |
|
397 |
} |
|
398 |
||
399 |
if (bci == InvocationEntryBci) { |
|
11572
84afef481892
7131259: compile_method and CompilationPolicy::event shouldn't be declared TRAPS
iveresov
parents:
11192
diff
changeset
|
400 |
method_invocation_event(method, inlinee, comp_level, nm, thread); |
6453 | 401 |
} else { |
27447
5cd7caca045d
8062169: Multiple OSR compilations issued for same bci
thartmann
parents:
24324
diff
changeset
|
402 |
// method == inlinee if the event originated in the main method |
11572
84afef481892
7131259: compile_method and CompilationPolicy::event shouldn't be declared TRAPS
iveresov
parents:
11192
diff
changeset
|
403 |
method_back_branch_event(method, inlinee, bci, comp_level, nm, thread); |
27447
5cd7caca045d
8062169: Multiple OSR compilations issued for same bci
thartmann
parents:
24324
diff
changeset
|
404 |
// Check if event led to a higher level OSR compilation |
5cd7caca045d
8062169: Multiple OSR compilations issued for same bci
thartmann
parents:
24324
diff
changeset
|
405 |
nmethod* osr_nm = inlinee->lookup_osr_nmethod_for(bci, comp_level, false); |
5cd7caca045d
8062169: Multiple OSR compilations issued for same bci
thartmann
parents:
24324
diff
changeset
|
406 |
if (osr_nm != NULL && osr_nm->comp_level() > comp_level) { |
5cd7caca045d
8062169: Multiple OSR compilations issued for same bci
thartmann
parents:
24324
diff
changeset
|
407 |
// Perform OSR with new nmethod |
5cd7caca045d
8062169: Multiple OSR compilations issued for same bci
thartmann
parents:
24324
diff
changeset
|
408 |
return osr_nm; |
6453 | 409 |
} |
410 |
} |
|
27447
5cd7caca045d
8062169: Multiple OSR compilations issued for same bci
thartmann
parents:
24324
diff
changeset
|
411 |
return NULL; |
6453 | 412 |
} |
413 |
||
414 |
// Check if the method can be compiled, change level if necessary |
|
51369
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
415 |
void TieredThresholdPolicy::compile(const methodHandle& mh, int bci, CompLevel level, JavaThread* thread) { |
10250
0794cd144834
7066339: Tiered: policy should make consistent decisions about osr levels
iveresov
parents:
10014
diff
changeset
|
416 |
assert(level <= TieredStopAtLevel, "Invalid compilation level"); |
6453 | 417 |
if (level == CompLevel_none) { |
418 |
return; |
|
419 |
} |
|
42650 | 420 |
if (level == CompLevel_aot) { |
421 |
if (mh->has_aot_code()) { |
|
422 |
if (PrintTieredEvents) { |
|
423 |
print_event(COMPILE, mh, mh, bci, level); |
|
424 |
} |
|
425 |
MutexLocker ml(Compile_lock); |
|
426 |
NoSafepointVerifier nsv; |
|
427 |
if (mh->has_aot_code() && mh->code() != mh->aot_code()) { |
|
428 |
mh->aot_code()->make_entrant(); |
|
429 |
if (mh->has_compiled_code()) { |
|
430 |
mh->code()->make_not_entrant(); |
|
431 |
} |
|
432 |
Method::set_code(mh, mh->aot_code()); |
|
433 |
} |
|
434 |
} |
|
435 |
return; |
|
436 |
} |
|
37281
c4e7456d6ae1
8144964: JVMCI compilations need to be disabled until the module system is initialized
twisti
parents:
36556
diff
changeset
|
437 |
|
7389
93110864f81e
7000349: Tiered reacts incorrectly to C1 compilation failures
iveresov
parents:
6453
diff
changeset
|
438 |
// Check if the method can be compiled. If it cannot be compiled with C1, continue profiling |
93110864f81e
7000349: Tiered reacts incorrectly to C1 compilation failures
iveresov
parents:
6453
diff
changeset
|
439 |
// in the interpreter and then compile with C2 (the transition function will request that, |
93110864f81e
7000349: Tiered reacts incorrectly to C1 compilation failures
iveresov
parents:
6453
diff
changeset
|
440 |
// see common() ). If the method cannot be compiled with C2 but still can with C1, compile it with |
93110864f81e
7000349: Tiered reacts incorrectly to C1 compilation failures
iveresov
parents:
6453
diff
changeset
|
441 |
// pure C1. |
6453 | 442 |
if (!can_be_compiled(mh, level)) { |
443 |
if (level == CompLevel_full_optimization && can_be_compiled(mh, CompLevel_simple)) { |
|
11572
84afef481892
7131259: compile_method and CompilationPolicy::event shouldn't be declared TRAPS
iveresov
parents:
11192
diff
changeset
|
444 |
compile(mh, bci, CompLevel_simple, thread); |
6453 | 445 |
} |
446 |
return; |
|
447 |
} |
|
13891
35dabd293e56
7200001: failed C1 OSR compile doesn't get recompiled with C2
twisti
parents:
13728
diff
changeset
|
448 |
if (bci != InvocationEntryBci && mh->is_not_osr_compilable(level)) { |
6453 | 449 |
return; |
450 |
} |
|
24321
621f7e09fc0a
8040798: compiler/startup/SmallCodeCacheStartup.java timed out in RT_Baseline
anoll
parents:
24013
diff
changeset
|
451 |
if (!CompileBroker::compilation_is_in_queue(mh)) { |
10250
0794cd144834
7066339: Tiered: policy should make consistent decisions about osr levels
iveresov
parents:
10014
diff
changeset
|
452 |
if (PrintTieredEvents) { |
0794cd144834
7066339: Tiered: policy should make consistent decisions about osr levels
iveresov
parents:
10014
diff
changeset
|
453 |
print_event(COMPILE, mh, mh, bci, level); |
0794cd144834
7066339: Tiered: policy should make consistent decisions about osr levels
iveresov
parents:
10014
diff
changeset
|
454 |
} |
11572
84afef481892
7131259: compile_method and CompilationPolicy::event shouldn't be declared TRAPS
iveresov
parents:
11192
diff
changeset
|
455 |
submit_compile(mh, bci, level, thread); |
6453 | 456 |
} |
457 |
} |
|
458 |
||
50068 | 459 |
// Update the rate and submit compile |
51369
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
460 |
void TieredThresholdPolicy::submit_compile(const methodHandle& mh, int bci, CompLevel level, JavaThread* thread) { |
6453 | 461 |
int hot_count = (bci == InvocationEntryBci) ? mh->invocation_count() : mh->backedge_count(); |
50068 | 462 |
update_rate(os::javaTimeMillis(), mh()); |
38218 | 463 |
CompileBroker::compile_method(mh, bci, level, mh, hot_count, CompileTask::Reason_Tiered, thread); |
6453 | 464 |
} |
465 |
||
50068 | 466 |
// Print an event. |
51369
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
467 |
void TieredThresholdPolicy::print_specific(EventType type, const methodHandle& mh, const methodHandle& imh, |
50068 | 468 |
int bci, CompLevel level) { |
469 |
tty->print(" rate="); |
|
470 |
if (mh->prev_time() == 0) tty->print("n/a"); |
|
471 |
else tty->print("%f", mh->rate()); |
|
472 |
||
473 |
tty->print(" k=%.2lf,%.2lf", threshold_scale(CompLevel_full_profile, Tier3LoadFeedback), |
|
474 |
threshold_scale(CompLevel_full_optimization, Tier4LoadFeedback)); |
|
475 |
||
476 |
} |
|
477 |
||
478 |
// update_rate() is called from select_task() while holding a compile queue lock. |
|
51369
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
479 |
void TieredThresholdPolicy::update_rate(jlong t, Method* m) { |
50068 | 480 |
// Skip update if counters are absent. |
481 |
// Can't allocate them since we are holding compile queue lock. |
|
482 |
if (m->method_counters() == NULL) return; |
|
483 |
||
484 |
if (is_old(m)) { |
|
485 |
// We don't remove old methods from the queue, |
|
486 |
// so we can just zero the rate. |
|
487 |
m->set_rate(0); |
|
488 |
return; |
|
489 |
} |
|
490 |
||
491 |
// We don't update the rate if we've just came out of a safepoint. |
|
492 |
// delta_s is the time since last safepoint in milliseconds. |
|
54009
13acb4339895
8220151: SafepointTracing::end_of_last_safepoint_ms should return ms since epoch.
rehn
parents:
53895
diff
changeset
|
493 |
jlong delta_s = t - SafepointTracing::end_of_last_safepoint_epoch_ms(); |
50068 | 494 |
jlong delta_t = t - (m->prev_time() != 0 ? m->prev_time() : start_time()); // milliseconds since the last measurement |
495 |
// How many events were there since the last time? |
|
496 |
int event_count = m->invocation_count() + m->backedge_count(); |
|
497 |
int delta_e = event_count - m->prev_event_count(); |
|
498 |
||
499 |
// We should be running for at least 1ms. |
|
500 |
if (delta_s >= TieredRateUpdateMinTime) { |
|
501 |
// And we must've taken the previous point at least 1ms before. |
|
502 |
if (delta_t >= TieredRateUpdateMinTime && delta_e > 0) { |
|
503 |
m->set_prev_time(t); |
|
504 |
m->set_prev_event_count(event_count); |
|
505 |
m->set_rate((float)delta_e / (float)delta_t); // Rate is events per millisecond |
|
506 |
} else { |
|
507 |
if (delta_t > TieredRateUpdateMaxTime && delta_e == 0) { |
|
508 |
// If nothing happened for 25ms, zero the rate. Don't modify prev values. |
|
509 |
m->set_rate(0); |
|
510 |
} |
|
511 |
} |
|
512 |
} |
|
513 |
} |
|
514 |
||
54015
cd701366fcf8
8163511: Allocation of compile task fails with assert: "Leaking compilation tasks?"
thartmann
parents:
54009
diff
changeset
|
515 |
// Check if this method has been stale for a given number of milliseconds. |
50068 | 516 |
// See select_task(). |
51369
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
517 |
bool TieredThresholdPolicy::is_stale(jlong t, jlong timeout, Method* m) { |
54009
13acb4339895
8220151: SafepointTracing::end_of_last_safepoint_ms should return ms since epoch.
rehn
parents:
53895
diff
changeset
|
518 |
jlong delta_s = t - SafepointTracing::end_of_last_safepoint_epoch_ms(); |
50068 | 519 |
jlong delta_t = t - m->prev_time(); |
520 |
if (delta_t > timeout && delta_s > timeout) { |
|
521 |
int event_count = m->invocation_count() + m->backedge_count(); |
|
522 |
int delta_e = event_count - m->prev_event_count(); |
|
523 |
// Return true if there were no events. |
|
524 |
return delta_e == 0; |
|
525 |
} |
|
526 |
return false; |
|
527 |
} |
|
528 |
||
529 |
// We don't remove old methods from the compile queue even if they have |
|
530 |
// very low activity. See select_task(). |
|
51369
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
531 |
bool TieredThresholdPolicy::is_old(Method* method) { |
50068 | 532 |
return method->invocation_count() > 50000 || method->backedge_count() > 500000; |
533 |
} |
|
534 |
||
51369
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
535 |
double TieredThresholdPolicy::weight(Method* method) { |
50068 | 536 |
return (double)(method->rate() + 1) * |
537 |
(method->invocation_count() + 1) * (method->backedge_count() + 1); |
|
538 |
} |
|
539 |
||
540 |
// Apply heuristics and return true if x should be compiled before y |
|
51369
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
541 |
bool TieredThresholdPolicy::compare_methods(Method* x, Method* y) { |
50068 | 542 |
if (x->highest_comp_level() > y->highest_comp_level()) { |
543 |
// recompilation after deopt |
|
544 |
return true; |
|
545 |
} else |
|
546 |
if (x->highest_comp_level() == y->highest_comp_level()) { |
|
547 |
if (weight(x) > weight(y)) { |
|
548 |
return true; |
|
549 |
} |
|
550 |
} |
|
551 |
return false; |
|
552 |
} |
|
553 |
||
554 |
// Is method profiled enough? |
|
51369
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
555 |
bool TieredThresholdPolicy::is_method_profiled(Method* method) { |
50068 | 556 |
MethodData* mdo = method->method_data(); |
557 |
if (mdo != NULL) { |
|
558 |
int i = mdo->invocation_count_delta(); |
|
559 |
int b = mdo->backedge_count_delta(); |
|
560 |
return call_predicate_helper<CompLevel_full_profile>(i, b, 1, method); |
|
561 |
} |
|
562 |
return false; |
|
563 |
} |
|
564 |
||
51369
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
565 |
double TieredThresholdPolicy::threshold_scale(CompLevel level, int feedback_k) { |
50068 | 566 |
double queue_size = CompileBroker::queue_size(level); |
567 |
int comp_count = compiler_count(level); |
|
568 |
double k = queue_size / (feedback_k * comp_count) + 1; |
|
569 |
||
570 |
// Increase C1 compile threshold when the code cache is filled more |
|
571 |
// than specified by IncreaseFirstTierCompileThresholdAt percentage. |
|
572 |
// The main intention is to keep enough free space for C2 compiled code |
|
573 |
// to achieve peak performance if the code cache is under stress. |
|
574 |
if ((TieredStopAtLevel == CompLevel_full_optimization) && (level != CompLevel_full_optimization)) { |
|
575 |
double current_reverse_free_ratio = CodeCache::reverse_free_ratio(CodeCache::get_code_blob_type(level)); |
|
576 |
if (current_reverse_free_ratio > _increase_threshold_at_ratio) { |
|
577 |
k *= exp(current_reverse_free_ratio - _increase_threshold_at_ratio); |
|
578 |
} |
|
579 |
} |
|
580 |
return k; |
|
581 |
} |
|
582 |
||
6453 | 583 |
// Call and loop predicates determine whether a transition to a higher |
584 |
// compilation level should be performed (pointers to predicate functions |
|
50068 | 585 |
// are passed to common()). |
586 |
// Tier?LoadFeedback is basically a coefficient that determines of |
|
587 |
// how many methods per compiler thread can be in the queue before |
|
588 |
// the threshold values double. |
|
51369
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
589 |
bool TieredThresholdPolicy::loop_predicate(int i, int b, CompLevel cur_level, Method* method) { |
6453 | 590 |
switch(cur_level) { |
42650 | 591 |
case CompLevel_aot: { |
50068 | 592 |
double k = threshold_scale(CompLevel_full_profile, Tier3LoadFeedback); |
593 |
return loop_predicate_helper<CompLevel_aot>(i, b, k, method); |
|
42650 | 594 |
} |
6453 | 595 |
case CompLevel_none: |
596 |
case CompLevel_limited_profile: { |
|
50068 | 597 |
double k = threshold_scale(CompLevel_full_profile, Tier3LoadFeedback); |
598 |
return loop_predicate_helper<CompLevel_none>(i, b, k, method); |
|
6453 | 599 |
} |
600 |
case CompLevel_full_profile: { |
|
50068 | 601 |
double k = threshold_scale(CompLevel_full_optimization, Tier4LoadFeedback); |
602 |
return loop_predicate_helper<CompLevel_full_profile>(i, b, k, method); |
|
6453 | 603 |
} |
604 |
default: |
|
605 |
return true; |
|
606 |
} |
|
607 |
} |
|
608 |
||
51369
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
609 |
bool TieredThresholdPolicy::call_predicate(int i, int b, CompLevel cur_level, Method* method) { |
6453 | 610 |
switch(cur_level) { |
42650 | 611 |
case CompLevel_aot: { |
50068 | 612 |
double k = threshold_scale(CompLevel_full_profile, Tier3LoadFeedback); |
613 |
return call_predicate_helper<CompLevel_aot>(i, b, k, method); |
|
42650 | 614 |
} |
6453 | 615 |
case CompLevel_none: |
616 |
case CompLevel_limited_profile: { |
|
50068 | 617 |
double k = threshold_scale(CompLevel_full_profile, Tier3LoadFeedback); |
618 |
return call_predicate_helper<CompLevel_none>(i, b, k, method); |
|
6453 | 619 |
} |
620 |
case CompLevel_full_profile: { |
|
50068 | 621 |
double k = threshold_scale(CompLevel_full_optimization, Tier4LoadFeedback); |
622 |
return call_predicate_helper<CompLevel_full_profile>(i, b, k, method); |
|
6453 | 623 |
} |
624 |
default: |
|
625 |
return true; |
|
626 |
} |
|
627 |
} |
|
628 |
||
629 |
// Determine is a method is mature. |
|
51369
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
630 |
bool TieredThresholdPolicy::is_mature(Method* method) { |
54647
c0d9bc9b4e1f
8219403: JVMCIRuntime::adjust_comp_level should be replaced
dlong
parents:
54015
diff
changeset
|
631 |
if (should_compile_at_level_simple(method)) return true; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11572
diff
changeset
|
632 |
MethodData* mdo = method->method_data(); |
6453 | 633 |
if (mdo != NULL) { |
634 |
int i = mdo->invocation_count(); |
|
635 |
int b = mdo->backedge_count(); |
|
636 |
double k = ProfileMaturityPercentage / 100.0; |
|
28650
772aaab2582f
8059606: Enable per-method usage of CompileThresholdScaling (per-method compilation thresholds)
zmajo
parents:
27447
diff
changeset
|
637 |
return call_predicate_helper<CompLevel_full_profile>(i, b, k, method) || |
772aaab2582f
8059606: Enable per-method usage of CompileThresholdScaling (per-method compilation thresholds)
zmajo
parents:
27447
diff
changeset
|
638 |
loop_predicate_helper<CompLevel_full_profile>(i, b, k, method); |
6453 | 639 |
} |
640 |
return false; |
|
641 |
} |
|
642 |
||
50068 | 643 |
// If a method is old enough and is still in the interpreter we would want to |
644 |
// start profiling without waiting for the compiled method to arrive. |
|
645 |
// We also take the load on compilers into the account. |
|
51369
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
646 |
bool TieredThresholdPolicy::should_create_mdo(Method* method, CompLevel cur_level) { |
50068 | 647 |
if (cur_level == CompLevel_none && |
648 |
CompileBroker::queue_size(CompLevel_full_optimization) <= |
|
649 |
Tier3DelayOn * compiler_count(CompLevel_full_optimization)) { |
|
650 |
int i = method->invocation_count(); |
|
651 |
int b = method->backedge_count(); |
|
652 |
double k = Tier0ProfilingStartPercentage / 100.0; |
|
653 |
return call_predicate_helper<CompLevel_none>(i, b, k, method) || loop_predicate_helper<CompLevel_none>(i, b, k, method); |
|
654 |
} |
|
655 |
return false; |
|
656 |
} |
|
657 |
||
658 |
// Inlining control: if we're compiling a profiled method with C1 and the callee |
|
659 |
// is known to have OSRed in a C2 version, don't inline it. |
|
51369
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
660 |
bool TieredThresholdPolicy::should_not_inline(ciEnv* env, ciMethod* callee) { |
50068 | 661 |
CompLevel comp_level = (CompLevel)env->comp_level(); |
662 |
if (comp_level == CompLevel_full_profile || |
|
663 |
comp_level == CompLevel_limited_profile) { |
|
664 |
return callee->highest_osr_comp_level() == CompLevel_full_optimization; |
|
665 |
} |
|
666 |
return false; |
|
667 |
} |
|
668 |
||
669 |
// Create MDO if necessary. |
|
51369
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
670 |
void TieredThresholdPolicy::create_mdo(const methodHandle& mh, JavaThread* THREAD) { |
50068 | 671 |
if (mh->is_native() || |
672 |
mh->is_abstract() || |
|
673 |
mh->is_accessor() || |
|
674 |
mh->is_constant_getter()) { |
|
675 |
return; |
|
676 |
} |
|
677 |
if (mh->method_data() == NULL) { |
|
678 |
Method::build_interpreter_method_data(mh, CHECK_AND_CLEAR); |
|
679 |
} |
|
680 |
} |
|
681 |
||
682 |
||
683 |
/* |
|
684 |
* Method states: |
|
685 |
* 0 - interpreter (CompLevel_none) |
|
686 |
* 1 - pure C1 (CompLevel_simple) |
|
687 |
* 2 - C1 with invocation and backedge counting (CompLevel_limited_profile) |
|
688 |
* 3 - C1 with full profiling (CompLevel_full_profile) |
|
689 |
* 4 - C2 (CompLevel_full_optimization) |
|
690 |
* |
|
691 |
* Common state transition patterns: |
|
692 |
* a. 0 -> 3 -> 4. |
|
693 |
* The most common path. But note that even in this straightforward case |
|
694 |
* profiling can start at level 0 and finish at level 3. |
|
695 |
* |
|
696 |
* b. 0 -> 2 -> 3 -> 4. |
|
697 |
* This case occurs when the load on C2 is deemed too high. So, instead of transitioning |
|
698 |
* into state 3 directly and over-profiling while a method is in the C2 queue we transition to |
|
699 |
* level 2 and wait until the load on C2 decreases. This path is disabled for OSRs. |
|
700 |
* |
|
701 |
* c. 0 -> (3->2) -> 4. |
|
702 |
* In this case we enqueue a method for compilation at level 3, but the C1 queue is long enough |
|
703 |
* to enable the profiling to fully occur at level 0. In this case we change the compilation level |
|
704 |
* of the method to 2 while the request is still in-queue, because it'll allow it to run much faster |
|
705 |
* without full profiling while c2 is compiling. |
|
706 |
* |
|
707 |
* d. 0 -> 3 -> 1 or 0 -> 2 -> 1. |
|
708 |
* After a method was once compiled with C1 it can be identified as trivial and be compiled to |
|
709 |
* level 1. These transition can also occur if a method can't be compiled with C2 but can with C1. |
|
710 |
* |
|
711 |
* e. 0 -> 4. |
|
712 |
* This can happen if a method fails C1 compilation (it will still be profiled in the interpreter) |
|
713 |
* or because of a deopt that didn't require reprofiling (compilation won't happen in this case because |
|
714 |
* the compiled version already exists). |
|
715 |
* |
|
716 |
* Note that since state 0 can be reached from any other state via deoptimization different loops |
|
717 |
* are possible. |
|
718 |
* |
|
719 |
*/ |
|
720 |
||
6453 | 721 |
// Common transition function. Given a predicate determines if a method should transition to another level. |
51369
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
722 |
CompLevel TieredThresholdPolicy::common(Predicate p, Method* method, CompLevel cur_level, bool disable_feedback) { |
6453 | 723 |
CompLevel next_level = cur_level; |
724 |
int i = method->invocation_count(); |
|
725 |
int b = method->backedge_count(); |
|
726 |
||
54647
c0d9bc9b4e1f
8219403: JVMCIRuntime::adjust_comp_level should be replaced
dlong
parents:
54015
diff
changeset
|
727 |
if (should_compile_at_level_simple(method)) { |
10250
0794cd144834
7066339: Tiered: policy should make consistent decisions about osr levels
iveresov
parents:
10014
diff
changeset
|
728 |
next_level = CompLevel_simple; |
0794cd144834
7066339: Tiered: policy should make consistent decisions about osr levels
iveresov
parents:
10014
diff
changeset
|
729 |
} else { |
0794cd144834
7066339: Tiered: policy should make consistent decisions about osr levels
iveresov
parents:
10014
diff
changeset
|
730 |
switch(cur_level) { |
50068 | 731 |
default: break; |
732 |
case CompLevel_aot: { |
|
733 |
// If we were at full profile level, would we switch to full opt? |
|
734 |
if (common(p, method, CompLevel_full_profile, disable_feedback) == CompLevel_full_optimization) { |
|
735 |
next_level = CompLevel_full_optimization; |
|
736 |
} else if (disable_feedback || (CompileBroker::queue_size(CompLevel_full_optimization) <= |
|
737 |
Tier3DelayOff * compiler_count(CompLevel_full_optimization) && |
|
738 |
(this->*p)(i, b, cur_level, method))) { |
|
42650 | 739 |
next_level = CompLevel_full_profile; |
740 |
} |
|
741 |
} |
|
742 |
break; |
|
10250
0794cd144834
7066339: Tiered: policy should make consistent decisions about osr levels
iveresov
parents:
10014
diff
changeset
|
743 |
case CompLevel_none: |
0794cd144834
7066339: Tiered: policy should make consistent decisions about osr levels
iveresov
parents:
10014
diff
changeset
|
744 |
// If we were at full profile level, would we switch to full opt? |
50068 | 745 |
if (common(p, method, CompLevel_full_profile, disable_feedback) == CompLevel_full_optimization) { |
10250
0794cd144834
7066339: Tiered: policy should make consistent decisions about osr levels
iveresov
parents:
10014
diff
changeset
|
746 |
next_level = CompLevel_full_optimization; |
28650
772aaab2582f
8059606: Enable per-method usage of CompileThresholdScaling (per-method compilation thresholds)
zmajo
parents:
27447
diff
changeset
|
747 |
} else if ((this->*p)(i, b, cur_level, method)) { |
50068 | 748 |
#if INCLUDE_JVMCI |
749 |
if (EnableJVMCI && UseJVMCICompiler) { |
|
750 |
// Since JVMCI takes a while to warm up, its queue inevitably backs up during |
|
751 |
// early VM execution. As of 2014-06-13, JVMCI's inliner assumes that the root |
|
752 |
// compilation method and all potential inlinees have mature profiles (which |
|
753 |
// includes type profiling). If it sees immature profiles, JVMCI's inliner |
|
754 |
// can perform pathologically bad (e.g., causing OutOfMemoryErrors due to |
|
755 |
// exploring/inlining too many graphs). Since a rewrite of the inliner is |
|
756 |
// in progress, we simply disable the dialing back heuristic for now and will |
|
757 |
// revisit this decision once the new inliner is completed. |
|
758 |
next_level = CompLevel_full_profile; |
|
759 |
} else |
|
760 |
#endif |
|
761 |
{ |
|
762 |
// C1-generated fully profiled code is about 30% slower than the limited profile |
|
763 |
// code that has only invocation and backedge counters. The observation is that |
|
764 |
// if C2 queue is large enough we can spend too much time in the fully profiled code |
|
765 |
// while waiting for C2 to pick the method from the queue. To alleviate this problem |
|
766 |
// we introduce a feedback on the C2 queue size. If the C2 queue is sufficiently long |
|
767 |
// we choose to compile a limited profiled version and then recompile with full profiling |
|
768 |
// when the load on C2 goes down. |
|
769 |
if (!disable_feedback && CompileBroker::queue_size(CompLevel_full_optimization) > |
|
770 |
Tier3DelayOn * compiler_count(CompLevel_full_optimization)) { |
|
771 |
next_level = CompLevel_limited_profile; |
|
772 |
} else { |
|
773 |
next_level = CompLevel_full_profile; |
|
774 |
} |
|
775 |
} |
|
10250
0794cd144834
7066339: Tiered: policy should make consistent decisions about osr levels
iveresov
parents:
10014
diff
changeset
|
776 |
} |
0794cd144834
7066339: Tiered: policy should make consistent decisions about osr levels
iveresov
parents:
10014
diff
changeset
|
777 |
break; |
0794cd144834
7066339: Tiered: policy should make consistent decisions about osr levels
iveresov
parents:
10014
diff
changeset
|
778 |
case CompLevel_limited_profile: |
50068 | 779 |
if (is_method_profiled(method)) { |
780 |
// Special case: we got here because this method was fully profiled in the interpreter. |
|
781 |
next_level = CompLevel_full_optimization; |
|
782 |
} else { |
|
783 |
MethodData* mdo = method->method_data(); |
|
784 |
if (mdo != NULL) { |
|
785 |
if (mdo->would_profile()) { |
|
786 |
if (disable_feedback || (CompileBroker::queue_size(CompLevel_full_optimization) <= |
|
787 |
Tier3DelayOff * compiler_count(CompLevel_full_optimization) && |
|
788 |
(this->*p)(i, b, cur_level, method))) { |
|
789 |
next_level = CompLevel_full_profile; |
|
790 |
} |
|
791 |
} else { |
|
792 |
next_level = CompLevel_full_optimization; |
|
793 |
} |
|
794 |
} else { |
|
795 |
// If there is no MDO we need to profile |
|
796 |
if (disable_feedback || (CompileBroker::queue_size(CompLevel_full_optimization) <= |
|
797 |
Tier3DelayOff * compiler_count(CompLevel_full_optimization) && |
|
798 |
(this->*p)(i, b, cur_level, method))) { |
|
799 |
next_level = CompLevel_full_profile; |
|
800 |
} |
|
801 |
} |
|
802 |
} |
|
803 |
break; |
|
10250
0794cd144834
7066339: Tiered: policy should make consistent decisions about osr levels
iveresov
parents:
10014
diff
changeset
|
804 |
case CompLevel_full_profile: |
0794cd144834
7066339: Tiered: policy should make consistent decisions about osr levels
iveresov
parents:
10014
diff
changeset
|
805 |
{ |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11572
diff
changeset
|
806 |
MethodData* mdo = method->method_data(); |
10250
0794cd144834
7066339: Tiered: policy should make consistent decisions about osr levels
iveresov
parents:
10014
diff
changeset
|
807 |
if (mdo != NULL) { |
0794cd144834
7066339: Tiered: policy should make consistent decisions about osr levels
iveresov
parents:
10014
diff
changeset
|
808 |
if (mdo->would_profile()) { |
0794cd144834
7066339: Tiered: policy should make consistent decisions about osr levels
iveresov
parents:
10014
diff
changeset
|
809 |
int mdo_i = mdo->invocation_count_delta(); |
0794cd144834
7066339: Tiered: policy should make consistent decisions about osr levels
iveresov
parents:
10014
diff
changeset
|
810 |
int mdo_b = mdo->backedge_count_delta(); |
28650
772aaab2582f
8059606: Enable per-method usage of CompileThresholdScaling (per-method compilation thresholds)
zmajo
parents:
27447
diff
changeset
|
811 |
if ((this->*p)(mdo_i, mdo_b, cur_level, method)) { |
10250
0794cd144834
7066339: Tiered: policy should make consistent decisions about osr levels
iveresov
parents:
10014
diff
changeset
|
812 |
next_level = CompLevel_full_optimization; |
0794cd144834
7066339: Tiered: policy should make consistent decisions about osr levels
iveresov
parents:
10014
diff
changeset
|
813 |
} |
0794cd144834
7066339: Tiered: policy should make consistent decisions about osr levels
iveresov
parents:
10014
diff
changeset
|
814 |
} else { |
8322 | 815 |
next_level = CompLevel_full_optimization; |
816 |
} |
|
6453 | 817 |
} |
818 |
} |
|
10250
0794cd144834
7066339: Tiered: policy should make consistent decisions about osr levels
iveresov
parents:
10014
diff
changeset
|
819 |
break; |
6453 | 820 |
} |
821 |
} |
|
10250
0794cd144834
7066339: Tiered: policy should make consistent decisions about osr levels
iveresov
parents:
10014
diff
changeset
|
822 |
return MIN2(next_level, (CompLevel)TieredStopAtLevel); |
6453 | 823 |
} |
824 |
||
825 |
// Determine if a method should be compiled with a normal entry point at a different level. |
|
51369
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
826 |
CompLevel TieredThresholdPolicy::call_event(Method* method, CompLevel cur_level, JavaThread * thread) { |
10013
714ad59b56cb
7058689: Tiered: Reprofiling doesn't happen in presence of level 4 OSR methods
iveresov
parents:
9625
diff
changeset
|
827 |
CompLevel osr_level = MIN2((CompLevel) method->highest_osr_comp_level(), |
51369
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
828 |
common(&TieredThresholdPolicy::loop_predicate, method, cur_level, true)); |
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
829 |
CompLevel next_level = common(&TieredThresholdPolicy::call_predicate, method, cur_level); |
6453 | 830 |
|
831 |
// If OSR method level is greater than the regular method level, the levels should be |
|
832 |
// equalized by raising the regular method level in order to avoid OSRs during each |
|
833 |
// invocation of the method. |
|
834 |
if (osr_level == CompLevel_full_optimization && cur_level == CompLevel_full_profile) { |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11572
diff
changeset
|
835 |
MethodData* mdo = method->method_data(); |
6453 | 836 |
guarantee(mdo != NULL, "MDO should not be NULL"); |
837 |
if (mdo->invocation_count() >= 1) { |
|
838 |
next_level = CompLevel_full_optimization; |
|
839 |
} |
|
840 |
} else { |
|
841 |
next_level = MAX2(osr_level, next_level); |
|
842 |
} |
|
843 |
return next_level; |
|
844 |
} |
|
845 |
||
846 |
// Determine if we should do an OSR compilation of a given method. |
|
51369
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
847 |
CompLevel TieredThresholdPolicy::loop_event(Method* method, CompLevel cur_level, JavaThread* thread) { |
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
848 |
CompLevel next_level = common(&TieredThresholdPolicy::loop_predicate, method, cur_level, true); |
6453 | 849 |
if (cur_level == CompLevel_none) { |
850 |
// If there is a live OSR method that means that we deopted to the interpreter |
|
851 |
// for the transition. |
|
10013
714ad59b56cb
7058689: Tiered: Reprofiling doesn't happen in presence of level 4 OSR methods
iveresov
parents:
9625
diff
changeset
|
852 |
CompLevel osr_level = MIN2((CompLevel)method->highest_osr_comp_level(), next_level); |
6453 | 853 |
if (osr_level > CompLevel_none) { |
854 |
return osr_level; |
|
855 |
} |
|
856 |
} |
|
10013
714ad59b56cb
7058689: Tiered: Reprofiling doesn't happen in presence of level 4 OSR methods
iveresov
parents:
9625
diff
changeset
|
857 |
return next_level; |
6453 | 858 |
} |
859 |
||
51369
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
860 |
bool TieredThresholdPolicy::maybe_switch_to_aot(const methodHandle& mh, CompLevel cur_level, CompLevel next_level, JavaThread* thread) { |
53193
184c51e48260
8216262: Remove develop flag DelayCompilationDuringStartup
redestad
parents:
52934
diff
changeset
|
861 |
if (UseAOT) { |
50068 | 862 |
if (cur_level == CompLevel_full_profile || cur_level == CompLevel_none) { |
863 |
// If the current level is full profile or interpreter and we're switching to any other level, |
|
864 |
// activate the AOT code back first so that we won't waste time overprofiling. |
|
865 |
compile(mh, InvocationEntryBci, CompLevel_aot, thread); |
|
866 |
// Fall through for JIT compilation. |
|
867 |
} |
|
868 |
if (next_level == CompLevel_limited_profile && cur_level != CompLevel_aot && mh->has_aot_code()) { |
|
869 |
// If the next level is limited profile, use the aot code (if there is any), |
|
870 |
// since it's essentially the same thing. |
|
871 |
compile(mh, InvocationEntryBci, CompLevel_aot, thread); |
|
872 |
// Not need to JIT, we're done. |
|
873 |
return true; |
|
874 |
} |
|
875 |
} |
|
876 |
return false; |
|
877 |
} |
|
878 |
||
6453 | 879 |
|
880 |
// Handle the invocation event. |
|
51369
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
881 |
void TieredThresholdPolicy::method_invocation_event(const methodHandle& mh, const methodHandle& imh, |
50068 | 882 |
CompLevel level, CompiledMethod* nm, JavaThread* thread) { |
883 |
if (should_create_mdo(mh(), level)) { |
|
884 |
create_mdo(mh, thread); |
|
885 |
} |
|
886 |
CompLevel next_level = call_event(mh(), level, thread); |
|
887 |
if (next_level != level) { |
|
888 |
if (maybe_switch_to_aot(mh, level, next_level, thread)) { |
|
889 |
// No JITting necessary |
|
890 |
return; |
|
891 |
} |
|
892 |
if (is_compilation_enabled() && !CompileBroker::compilation_is_in_queue(mh)) { |
|
11572
84afef481892
7131259: compile_method and CompilationPolicy::event shouldn't be declared TRAPS
iveresov
parents:
11192
diff
changeset
|
893 |
compile(mh, InvocationEntryBci, next_level, thread); |
6453 | 894 |
} |
895 |
} |
|
896 |
} |
|
897 |
||
898 |
// Handle the back branch event. Notice that we can compile the method |
|
899 |
// with a regular entry from here. |
|
51369
f32e61253792
8209186: Rename SimpleThresholdPolicy to TieredThresholdPolicy
redestad
parents:
51078
diff
changeset
|
900 |
void TieredThresholdPolicy::method_back_branch_event(const methodHandle& mh, const methodHandle& imh, |
38133
78b95467b9f1
8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
37281
diff
changeset
|
901 |
int bci, CompLevel level, CompiledMethod* nm, JavaThread* thread) { |
50068 | 902 |
if (should_create_mdo(mh(), level)) { |
903 |
create_mdo(mh, thread); |
|
904 |
} |
|
905 |
// Check if MDO should be created for the inlined method |
|
906 |
if (should_create_mdo(imh(), level)) { |
|
907 |
create_mdo(imh, thread); |
|
908 |
} |
|
6453 | 909 |
|
50068 | 910 |
if (is_compilation_enabled()) { |
911 |
CompLevel next_osr_level = loop_event(imh(), level, thread); |
|
912 |
CompLevel max_osr_level = (CompLevel)imh->highest_osr_comp_level(); |
|
913 |
// At the very least compile the OSR version |
|
914 |
if (!CompileBroker::compilation_is_in_queue(imh) && (next_osr_level != level)) { |
|
915 |
compile(imh, bci, next_osr_level, thread); |
|
6453 | 916 |
} |
917 |
||
50068 | 918 |
// Use loop event as an opportunity to also check if there's been |
919 |
// enough calls. |
|
920 |
CompLevel cur_level, next_level; |
|
921 |
if (mh() != imh()) { // If there is an enclosing method |
|
922 |
if (level == CompLevel_aot) { |
|
923 |
// Recompile the enclosing method to prevent infinite OSRs. Stay at AOT level while it's compiling. |
|
924 |
if (max_osr_level != CompLevel_none && !CompileBroker::compilation_is_in_queue(mh)) { |
|
925 |
compile(mh, InvocationEntryBci, MIN2((CompLevel)TieredStopAtLevel, CompLevel_full_profile), thread); |
|
926 |
} |
|
927 |
} else { |
|
928 |
// Current loop event level is not AOT |
|
929 |
guarantee(nm != NULL, "Should have nmethod here"); |
|
930 |
cur_level = comp_level(mh()); |
|
931 |
next_level = call_event(mh(), cur_level, thread); |
|
932 |
||
933 |
if (max_osr_level == CompLevel_full_optimization) { |
|
934 |
// The inlinee OSRed to full opt, we need to modify the enclosing method to avoid deopts |
|
935 |
bool make_not_entrant = false; |
|
936 |
if (nm->is_osr_method()) { |
|
937 |
// This is an osr method, just make it not entrant and recompile later if needed |
|
938 |
make_not_entrant = true; |
|
939 |
} else { |
|
940 |
if (next_level != CompLevel_full_optimization) { |
|
941 |
// next_level is not full opt, so we need to recompile the |
|
942 |
// enclosing method without the inlinee |
|
943 |
cur_level = CompLevel_none; |
|
944 |
make_not_entrant = true; |
|
945 |
} |
|
946 |
} |
|
947 |
if (make_not_entrant) { |
|
948 |
if (PrintTieredEvents) { |
|
949 |
int osr_bci = nm->is_osr_method() ? nm->osr_entry_bci() : InvocationEntryBci; |
|
950 |
print_event(MAKE_NOT_ENTRANT, mh(), mh(), osr_bci, level); |
|
951 |
} |
|
952 |
nm->make_not_entrant(); |
|
953 |
} |
|
954 |
} |
|
955 |
// Fix up next_level if necessary to avoid deopts |
|
956 |
if (next_level == CompLevel_limited_profile && max_osr_level == CompLevel_full_profile) { |
|
957 |
next_level = CompLevel_full_profile; |
|
958 |
} |
|
959 |
if (cur_level != next_level) { |
|
960 |
if (!maybe_switch_to_aot(mh, cur_level, next_level, thread) && !CompileBroker::compilation_is_in_queue(mh)) { |
|
961 |
compile(mh, InvocationEntryBci, next_level, thread); |
|
962 |
} |
|
963 |
} |
|
964 |
} |
|
965 |
} else { |
|
966 |
cur_level = comp_level(mh()); |
|
967 |
next_level = call_event(mh(), cur_level, thread); |
|
968 |
if (next_level != cur_level) { |
|
969 |
if (!maybe_switch_to_aot(mh, cur_level, next_level, thread) && !CompileBroker::compilation_is_in_queue(mh)) { |
|
970 |
compile(mh, InvocationEntryBci, next_level, thread); |
|
971 |
} |
|
972 |
} |
|
6453 | 973 |
} |
974 |
} |
|
975 |
} |
|
42650 | 976 |
|
977 |
#endif |