author | stefank |
Mon, 10 Jun 2019 13:04:12 +0200 | |
changeset 55603 | 3868dde58ebb |
parent 53244 | 9807daeb47c4 |
child 58367 | b3ca57ddfc92 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
53149
259c36ef27df
8215731: Move forward class definitions out of globalDefinitions.hpp
coleenp
parents:
52877
diff
changeset
|
2 |
* Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
53194
diff
changeset
|
25 |
#ifndef SHARE_RUNTIME_COMPILATIONPOLICY_HPP |
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
53194
diff
changeset
|
26 |
#define SHARE_RUNTIME_COMPILATIONPOLICY_HPP |
7397 | 27 |
|
28 |
#include "code/nmethod.hpp" |
|
29 |
#include "compiler/compileBroker.hpp" |
|
30 |
#include "memory/allocation.hpp" |
|
52877
9e041366c764
8214850: Rename vm_operations.?pp files to vmOperations.?pp files
tschatzl
parents:
47216
diff
changeset
|
31 |
#include "runtime/vmOperations.hpp" |
7397 | 32 |
#include "utilities/growableArray.hpp" |
33 |
||
1 | 34 |
// The CompilationPolicy selects which method (if any) should be compiled. |
35 |
// It also decides which methods must always be compiled (i.e., are never |
|
36 |
// interpreted). |
|
6453 | 37 |
class CompileTask; |
38 |
class CompileQueue; |
|
53149
259c36ef27df
8215731: Move forward class definitions out of globalDefinitions.hpp
coleenp
parents:
52877
diff
changeset
|
39 |
class RFrame; |
1 | 40 |
|
13195 | 41 |
class CompilationPolicy : public CHeapObj<mtCompiler> { |
1 | 42 |
static CompilationPolicy* _policy; |
38139
cf6f5c1b7205
8152903: [JVMCI] CompilerToVM::resolveMethod should correctly handle private methods in interfaces
never
parents:
38133
diff
changeset
|
43 |
|
cf6f5c1b7205
8152903: [JVMCI] CompilerToVM::resolveMethod should correctly handle private methods in interfaces
never
parents:
38133
diff
changeset
|
44 |
// m must be compiled before executing it |
46727
6e4a84748e2c
8183039: Re-examine methodHandle methods uninlined by 8144256
coleenp
parents:
38139
diff
changeset
|
45 |
static bool must_be_compiled(const methodHandle& m, int comp_level = CompLevel_all); |
38139
cf6f5c1b7205
8152903: [JVMCI] CompilerToVM::resolveMethod should correctly handle private methods in interfaces
never
parents:
38133
diff
changeset
|
46 |
|
6453 | 47 |
public: |
38139
cf6f5c1b7205
8152903: [JVMCI] CompilerToVM::resolveMethod should correctly handle private methods in interfaces
never
parents:
38133
diff
changeset
|
48 |
// If m must_be_compiled then request a compilation from the CompileBroker. |
cf6f5c1b7205
8152903: [JVMCI] CompilerToVM::resolveMethod should correctly handle private methods in interfaces
never
parents:
38133
diff
changeset
|
49 |
// This supports the -Xcomp option. |
46727
6e4a84748e2c
8183039: Re-examine methodHandle methods uninlined by 8144256
coleenp
parents:
38139
diff
changeset
|
50 |
static void compile_if_required(const methodHandle& m, TRAPS); |
38139
cf6f5c1b7205
8152903: [JVMCI] CompilerToVM::resolveMethod should correctly handle private methods in interfaces
never
parents:
38133
diff
changeset
|
51 |
|
6453 | 52 |
// m is allowed to be compiled |
46727
6e4a84748e2c
8183039: Re-examine methodHandle methods uninlined by 8144256
coleenp
parents:
38139
diff
changeset
|
53 |
static bool can_be_compiled(const methodHandle& m, int comp_level = CompLevel_all); |
19332 | 54 |
// m is allowed to be osr compiled |
46727
6e4a84748e2c
8183039: Re-examine methodHandle methods uninlined by 8144256
coleenp
parents:
38139
diff
changeset
|
55 |
static bool can_be_osr_compiled(const methodHandle& m, int comp_level = CompLevel_all); |
6453 | 56 |
static bool is_compilation_enabled(); |
1 | 57 |
static void set_policy(CompilationPolicy* policy) { _policy = policy; } |
6453 | 58 |
static CompilationPolicy* policy() { return _policy; } |
1 | 59 |
|
35547
0ee84aa8e705
8146705: Improve JVMCI support for blocking compilation
dnsimon
parents:
33593
diff
changeset
|
60 |
static CompileTask* select_task_helper(CompileQueue* compile_queue); |
0ee84aa8e705
8146705: Improve JVMCI support for blocking compilation
dnsimon
parents:
33593
diff
changeset
|
61 |
|
10250
0794cd144834
7066339: Tiered: policy should make consistent decisions about osr levels
iveresov
parents:
10014
diff
changeset
|
62 |
// Return initial compile level that is used with Xcomp |
0794cd144834
7066339: Tiered: policy should make consistent decisions about osr levels
iveresov
parents:
10014
diff
changeset
|
63 |
virtual CompLevel initial_compile_level() = 0; |
6453 | 64 |
virtual int compiler_count(CompLevel comp_level) = 0; |
65 |
// main notification entry, return a pointer to an nmethod if the OSR is required, |
|
66 |
// returns NULL otherwise. |
|
38133
78b95467b9f1
8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
35547
diff
changeset
|
67 |
virtual nmethod* event(const methodHandle& method, const methodHandle& inlinee, int branch_bci, int bci, CompLevel comp_level, CompiledMethod* nm, JavaThread* thread) = 0; |
6453 | 68 |
// safepoint() is called at the end of the safepoint |
69 |
virtual void do_safepoint_work() = 0; |
|
70 |
// reprofile request |
|
71 |
virtual void reprofile(ScopeDesc* trap_scope, bool is_osr) = 0; |
|
72 |
// delay_compilation(method) can be called by any component of the runtime to notify the policy |
|
22551 | 73 |
// that it's recommended to delay the compilation of this method. |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
74 |
virtual void delay_compilation(Method* method) = 0; |
6453 | 75 |
// disable_compilation() is called whenever the runtime decides to disable compilation of the |
76 |
// specified method. |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
77 |
virtual void disable_compilation(Method* method) = 0; |
6453 | 78 |
// Select task is called by CompileBroker. The queue is guaranteed to have at least one |
79 |
// element and is locked. The function should select one and return it. |
|
80 |
virtual CompileTask* select_task(CompileQueue* compile_queue) = 0; |
|
81 |
// Tell the runtime if we think a given method is adequately profiled. |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
82 |
virtual bool is_mature(Method* method) = 0; |
6453 | 83 |
// Do policy initialization |
84 |
virtual void initialize() = 0; |
|
10014
a5c2141ee857
7057120: Tiered: Allow C1 to inline methods with loops
iveresov
parents:
7397
diff
changeset
|
85 |
virtual bool should_not_inline(ciEnv* env, ciMethod* method) { return false; } |
1 | 86 |
}; |
87 |
||
6453 | 88 |
// A base class for baseline policies. |
89 |
class NonTieredCompPolicy : public CompilationPolicy { |
|
90 |
int _compiler_count; |
|
91 |
protected: |
|
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
22551
diff
changeset
|
92 |
static void trace_frequency_counter_overflow(const methodHandle& m, int branch_bci, int bci); |
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
22551
diff
changeset
|
93 |
static void trace_osr_request(const methodHandle& method, nmethod* osr, int bci); |
6453 | 94 |
static void trace_osr_completion(nmethod* osr_nm); |
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
22551
diff
changeset
|
95 |
void reset_counter_for_invocation_event(const methodHandle& method); |
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
22551
diff
changeset
|
96 |
void reset_counter_for_back_branch_event(const methodHandle& method); |
6453 | 97 |
public: |
98 |
NonTieredCompPolicy() : _compiler_count(0) { } |
|
16689
efce070b8d42
8007288: Additional WB API for compiler's testing
iignatyev
parents:
13728
diff
changeset
|
99 |
virtual CompLevel initial_compile_level() { return CompLevel_highest_tier; } |
6453 | 100 |
virtual int compiler_count(CompLevel comp_level); |
101 |
virtual void do_safepoint_work(); |
|
102 |
virtual void reprofile(ScopeDesc* trap_scope, bool is_osr); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
103 |
virtual void delay_compilation(Method* method); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
104 |
virtual void disable_compilation(Method* method); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
105 |
virtual bool is_mature(Method* method); |
6453 | 106 |
virtual void initialize(); |
107 |
virtual CompileTask* select_task(CompileQueue* compile_queue); |
|
38133
78b95467b9f1
8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
35547
diff
changeset
|
108 |
virtual nmethod* event(const methodHandle& method, const methodHandle& inlinee, int branch_bci, int bci, CompLevel comp_level, CompiledMethod* nm, JavaThread* thread); |
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
22551
diff
changeset
|
109 |
virtual void method_invocation_event(const methodHandle& m, JavaThread* thread) = 0; |
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
22551
diff
changeset
|
110 |
virtual void method_back_branch_event(const methodHandle& m, int bci, JavaThread* thread) = 0; |
6453 | 111 |
}; |
112 |
||
113 |
class SimpleCompPolicy : public NonTieredCompPolicy { |
|
1 | 114 |
public: |
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
22551
diff
changeset
|
115 |
virtual void method_invocation_event(const methodHandle& m, JavaThread* thread); |
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
22551
diff
changeset
|
116 |
virtual void method_back_branch_event(const methodHandle& m, int bci, JavaThread* thread); |
1 | 117 |
}; |
118 |
||
119 |
// StackWalkCompPolicy - existing C2 policy |
|
120 |
||
121 |
#ifdef COMPILER2 |
|
6453 | 122 |
class StackWalkCompPolicy : public NonTieredCompPolicy { |
1 | 123 |
public: |
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
22551
diff
changeset
|
124 |
virtual void method_invocation_event(const methodHandle& m, JavaThread* thread); |
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
22551
diff
changeset
|
125 |
virtual void method_back_branch_event(const methodHandle& m, int bci, JavaThread* thread); |
1 | 126 |
|
127 |
private: |
|
128 |
RFrame* findTopInlinableFrame(GrowableArray<RFrame*>* stack); |
|
129 |
RFrame* senderOf(RFrame* rf, GrowableArray<RFrame*>* stack); |
|
130 |
||
131 |
// the following variables hold values computed by the last inlining decision |
|
132 |
// they are used for performance debugging only (print better messages) |
|
133 |
static const char* _msg; // reason for not inlining |
|
134 |
||
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
22551
diff
changeset
|
135 |
static const char* shouldInline (const methodHandle& callee, float frequency, int cnt); |
1 | 136 |
// positive filter: should send be inlined? returns NULL (--> yes) or rejection msg |
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
22551
diff
changeset
|
137 |
static const char* shouldNotInline(const methodHandle& callee); |
1 | 138 |
// negative filter: should send NOT be inlined? returns NULL (--> inline) or rejection msg |
139 |
||
140 |
}; |
|
141 |
#endif |
|
7397 | 142 |
|
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
53194
diff
changeset
|
143 |
#endif // SHARE_RUNTIME_COMPILATIONPOLICY_HPP |