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