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