Mercurial > hg > graal-jvmci-8
annotate src/share/vm/runtime/compilationPolicy.hpp @ 24234:ea6f94ab283b default tip
Added tag jvmci-0.36 for changeset 8128b98d4736
author | Gilles Duboscq <gilles.m.duboscq@oracle.com> |
---|---|
date | Mon, 18 Sep 2017 18:49:45 +0200 |
parents | 7ae6a635fad0 |
children |
rev | line source |
---|---|
0 | 1 /* |
17524 | 2 * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. |
0 | 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #ifndef SHARE_VM_RUNTIME_COMPILATIONPOLICY_HPP |
26 #define SHARE_VM_RUNTIME_COMPILATIONPOLICY_HPP | |
27 | |
28 #include "code/nmethod.hpp" | |
29 #include "compiler/compileBroker.hpp" | |
30 #include "memory/allocation.hpp" | |
31 #include "runtime/vm_operations.hpp" | |
32 #include "utilities/growableArray.hpp" | |
33 | |
0 | 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). | |
1783 | 37 class CompileTask; |
38 class CompileQueue; | |
0 | 39 |
6197 | 40 class CompilationPolicy : public CHeapObj<mtCompiler> { |
0 | 41 static CompilationPolicy* _policy; |
42 // Accumulated time | |
43 static elapsedTimer _accumulated_time; | |
44 | |
45 static bool _in_vm_startup; | |
23347
7ae6a635fad0
8152903: [JVMCI] CompilerToVM::resolveMethod should correctly handle private methods in interfaces
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22764
diff
changeset
|
46 |
7ae6a635fad0
8152903: [JVMCI] CompilerToVM::resolveMethod should correctly handle private methods in interfaces
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22764
diff
changeset
|
47 // m must be compiled before executing it |
7ae6a635fad0
8152903: [JVMCI] CompilerToVM::resolveMethod should correctly handle private methods in interfaces
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22764
diff
changeset
|
48 static bool must_be_compiled(methodHandle m, int comp_level = CompLevel_all); |
7ae6a635fad0
8152903: [JVMCI] CompilerToVM::resolveMethod should correctly handle private methods in interfaces
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22764
diff
changeset
|
49 |
1783 | 50 public: |
0 | 51 static void set_in_vm_startup(bool in_vm_startup) { _in_vm_startup = in_vm_startup; } |
52 static void completed_vm_startup(); | |
1783 | 53 static bool delay_compilation_during_startup() { return _in_vm_startup; } |
0 | 54 |
23347
7ae6a635fad0
8152903: [JVMCI] CompilerToVM::resolveMethod should correctly handle private methods in interfaces
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22764
diff
changeset
|
55 // If m must_be_compiled then request a compilation from the CompileBroker. |
7ae6a635fad0
8152903: [JVMCI] CompilerToVM::resolveMethod should correctly handle private methods in interfaces
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22764
diff
changeset
|
56 // This supports the -Xcomp option. |
7ae6a635fad0
8152903: [JVMCI] CompilerToVM::resolveMethod should correctly handle private methods in interfaces
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22764
diff
changeset
|
57 static void compile_if_required(methodHandle m, TRAPS); |
7ae6a635fad0
8152903: [JVMCI] CompilerToVM::resolveMethod should correctly handle private methods in interfaces
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22764
diff
changeset
|
58 |
1783 | 59 // m is allowed to be compiled |
60 static bool can_be_compiled(methodHandle m, int comp_level = CompLevel_all); | |
12073 | 61 // m is allowed to be osr compiled |
62 static bool can_be_osr_compiled(methodHandle m, int comp_level = CompLevel_all); | |
1783 | 63 static bool is_compilation_enabled(); |
0 | 64 static void set_policy(CompilationPolicy* policy) { _policy = policy; } |
1783 | 65 static CompilationPolicy* policy() { return _policy; } |
0 | 66 |
22764
9c0966b935a9
converted select_task_blocking_aware into select_task_helper (GRAAL-1387)
Doug Simon <doug.simon@oracle.com>
parents:
22762
diff
changeset
|
67 static CompileTask* select_task_helper(CompileQueue* compile_queue); |
22762
9d78d44d3aac
improved JVMCI support for blocking compilation (GRAAL-1387)
Doug Simon <doug.simon@oracle.com>
parents:
17524
diff
changeset
|
68 |
0 | 69 // Profiling |
70 elapsedTimer* accumulated_time() { return &_accumulated_time; } | |
71 void print_time() PRODUCT_RETURN; | |
3837
43f9d800f276
7066339: Tiered: policy should make consistent decisions about osr levels
iveresov
parents:
3791
diff
changeset
|
72 // Return initial compile level that is used with Xcomp |
43f9d800f276
7066339: Tiered: policy should make consistent decisions about osr levels
iveresov
parents:
3791
diff
changeset
|
73 virtual CompLevel initial_compile_level() = 0; |
1783 | 74 virtual int compiler_count(CompLevel comp_level) = 0; |
75 // main notification entry, return a pointer to an nmethod if the OSR is required, | |
76 // returns NULL otherwise. | |
4825
20334ed5ed3c
7131259: compile_method and CompilationPolicy::event shouldn't be declared TRAPS
iveresov
parents:
3837
diff
changeset
|
77 virtual nmethod* event(methodHandle method, methodHandle inlinee, int branch_bci, int bci, CompLevel comp_level, nmethod* nm, JavaThread* thread) = 0; |
1783 | 78 // safepoint() is called at the end of the safepoint |
79 virtual void do_safepoint_work() = 0; | |
80 // reprofile request | |
81 virtual void reprofile(ScopeDesc* trap_scope, bool is_osr) = 0; | |
82 // delay_compilation(method) can be called by any component of the runtime to notify the policy | |
14909 | 83 // that it's recommended to delay the complation of this method. |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
84 virtual void delay_compilation(Method* method) = 0; |
1783 | 85 // disable_compilation() is called whenever the runtime decides to disable compilation of the |
86 // specified method. | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
87 virtual void disable_compilation(Method* method) = 0; |
1783 | 88 // Select task is called by CompileBroker. The queue is guaranteed to have at least one |
89 // element and is locked. The function should select one and return it. | |
90 virtual CompileTask* select_task(CompileQueue* compile_queue) = 0; | |
91 // Tell the runtime if we think a given method is adequately profiled. | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
92 virtual bool is_mature(Method* method) = 0; |
1783 | 93 // Do policy initialization |
94 virtual void initialize() = 0; | |
3791
2c359f27615c
7057120: Tiered: Allow C1 to inline methods with loops
iveresov
parents:
1972
diff
changeset
|
95 virtual bool should_not_inline(ciEnv* env, ciMethod* method) { return false; } |
0 | 96 }; |
97 | |
1783 | 98 // A base class for baseline policies. |
99 class NonTieredCompPolicy : public CompilationPolicy { | |
100 int _compiler_count; | |
101 protected: | |
102 static void trace_frequency_counter_overflow(methodHandle m, int branch_bci, int bci); | |
103 static void trace_osr_request(methodHandle method, nmethod* osr, int bci); | |
104 static void trace_osr_completion(nmethod* osr_nm); | |
105 void reset_counter_for_invocation_event(methodHandle method); | |
106 void reset_counter_for_back_branch_event(methodHandle method); | |
107 public: | |
108 NonTieredCompPolicy() : _compiler_count(0) { } | |
9080
b84fd7d73702
8007288: Additional WB API for compiler's testing
iignatyev
parents:
6725
diff
changeset
|
109 virtual CompLevel initial_compile_level() { return CompLevel_highest_tier; } |
1783 | 110 virtual int compiler_count(CompLevel comp_level); |
111 virtual void do_safepoint_work(); | |
112 virtual void reprofile(ScopeDesc* trap_scope, bool is_osr); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
113 virtual void delay_compilation(Method* method); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
114 virtual void disable_compilation(Method* method); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
115 virtual bool is_mature(Method* method); |
1783 | 116 virtual void initialize(); |
117 virtual CompileTask* select_task(CompileQueue* compile_queue); | |
4825
20334ed5ed3c
7131259: compile_method and CompilationPolicy::event shouldn't be declared TRAPS
iveresov
parents:
3837
diff
changeset
|
118 virtual nmethod* event(methodHandle method, methodHandle inlinee, int branch_bci, int bci, CompLevel comp_level, nmethod* nm, JavaThread* thread); |
20334ed5ed3c
7131259: compile_method and CompilationPolicy::event shouldn't be declared TRAPS
iveresov
parents:
3837
diff
changeset
|
119 virtual void method_invocation_event(methodHandle m, JavaThread* thread) = 0; |
20334ed5ed3c
7131259: compile_method and CompilationPolicy::event shouldn't be declared TRAPS
iveresov
parents:
3837
diff
changeset
|
120 virtual void method_back_branch_event(methodHandle m, int bci, JavaThread* thread) = 0; |
1783 | 121 }; |
122 | |
123 class SimpleCompPolicy : public NonTieredCompPolicy { | |
0 | 124 public: |
4825
20334ed5ed3c
7131259: compile_method and CompilationPolicy::event shouldn't be declared TRAPS
iveresov
parents:
3837
diff
changeset
|
125 virtual void method_invocation_event(methodHandle m, JavaThread* thread); |
20334ed5ed3c
7131259: compile_method and CompilationPolicy::event shouldn't be declared TRAPS
iveresov
parents:
3837
diff
changeset
|
126 virtual void method_back_branch_event(methodHandle m, int bci, JavaThread* thread); |
0 | 127 }; |
128 | |
129 // StackWalkCompPolicy - existing C2 policy | |
130 | |
131 #ifdef COMPILER2 | |
1783 | 132 class StackWalkCompPolicy : public NonTieredCompPolicy { |
0 | 133 public: |
4825
20334ed5ed3c
7131259: compile_method and CompilationPolicy::event shouldn't be declared TRAPS
iveresov
parents:
3837
diff
changeset
|
134 virtual void method_invocation_event(methodHandle m, JavaThread* thread); |
20334ed5ed3c
7131259: compile_method and CompilationPolicy::event shouldn't be declared TRAPS
iveresov
parents:
3837
diff
changeset
|
135 virtual void method_back_branch_event(methodHandle m, int bci, JavaThread* thread); |
0 | 136 |
137 private: | |
138 RFrame* findTopInlinableFrame(GrowableArray<RFrame*>* stack); | |
139 RFrame* senderOf(RFrame* rf, GrowableArray<RFrame*>* stack); | |
140 | |
141 // the following variables hold values computed by the last inlining decision | |
142 // they are used for performance debugging only (print better messages) | |
143 static const char* _msg; // reason for not inlining | |
144 | |
145 static const char* shouldInline (methodHandle callee, float frequency, int cnt); | |
146 // positive filter: should send be inlined? returns NULL (--> yes) or rejection msg | |
147 static const char* shouldNotInline(methodHandle callee); | |
148 // negative filter: should send NOT be inlined? returns NULL (--> inline) or rejection msg | |
149 | |
150 }; | |
151 #endif | |
1972 | 152 |
153 #endif // SHARE_VM_RUNTIME_COMPILATIONPOLICY_HPP |