author | sla |
Wed, 18 Dec 2013 08:39:06 +0100 | |
changeset 22190 | d306a75a70d3 |
parent 19332 | ee4c8c2af356 |
child 22234 | da823d78ad65 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
2 |
* Copyright (c) 2000, 2012, 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 |
||
7397 | 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 |
||
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; |
|
1 | 39 |
|
13195 | 40 |
class CompilationPolicy : public CHeapObj<mtCompiler> { |
1 | 41 |
static CompilationPolicy* _policy; |
42 |
// Accumulated time |
|
43 |
static elapsedTimer _accumulated_time; |
|
44 |
||
45 |
static bool _in_vm_startup; |
|
6453 | 46 |
public: |
1 | 47 |
static void set_in_vm_startup(bool in_vm_startup) { _in_vm_startup = in_vm_startup; } |
48 |
static void completed_vm_startup(); |
|
6453 | 49 |
static bool delay_compilation_during_startup() { return _in_vm_startup; } |
1 | 50 |
|
6453 | 51 |
// m must be compiled before executing it |
52 |
static bool must_be_compiled(methodHandle m, int comp_level = CompLevel_all); |
|
53 |
// m is allowed to be compiled |
|
54 |
static bool can_be_compiled(methodHandle m, int comp_level = CompLevel_all); |
|
19332 | 55 |
// m is allowed to be osr compiled |
56 |
static bool can_be_osr_compiled(methodHandle m, int comp_level = CompLevel_all); |
|
6453 | 57 |
static bool is_compilation_enabled(); |
1 | 58 |
static void set_policy(CompilationPolicy* policy) { _policy = policy; } |
6453 | 59 |
static CompilationPolicy* policy() { return _policy; } |
1 | 60 |
|
61 |
// Profiling |
|
62 |
elapsedTimer* accumulated_time() { return &_accumulated_time; } |
|
63 |
void print_time() PRODUCT_RETURN; |
|
10250
0794cd144834
7066339: Tiered: policy should make consistent decisions about osr levels
iveresov
parents:
10014
diff
changeset
|
64 |
// 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
|
65 |
virtual CompLevel initial_compile_level() = 0; |
6453 | 66 |
virtual int compiler_count(CompLevel comp_level) = 0; |
67 |
// main notification entry, return a pointer to an nmethod if the OSR is required, |
|
68 |
// returns NULL otherwise. |
|
11572
84afef481892
7131259: compile_method and CompilationPolicy::event shouldn't be declared TRAPS
iveresov
parents:
10250
diff
changeset
|
69 |
virtual nmethod* event(methodHandle method, methodHandle inlinee, int branch_bci, int bci, CompLevel comp_level, nmethod* nm, JavaThread* thread) = 0; |
6453 | 70 |
// safepoint() is called at the end of the safepoint |
71 |
virtual void do_safepoint_work() = 0; |
|
72 |
// reprofile request |
|
73 |
virtual void reprofile(ScopeDesc* trap_scope, bool is_osr) = 0; |
|
74 |
// delay_compilation(method) can be called by any component of the runtime to notify the policy |
|
75 |
// that it's recommended to delay the complation of this method. |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
76 |
virtual void delay_compilation(Method* method) = 0; |
6453 | 77 |
// disable_compilation() is called whenever the runtime decides to disable compilation of the |
78 |
// specified method. |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
79 |
virtual void disable_compilation(Method* method) = 0; |
6453 | 80 |
// Select task is called by CompileBroker. The queue is guaranteed to have at least one |
81 |
// element and is locked. The function should select one and return it. |
|
82 |
virtual CompileTask* select_task(CompileQueue* compile_queue) = 0; |
|
83 |
// 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
|
84 |
virtual bool is_mature(Method* method) = 0; |
6453 | 85 |
// Do policy initialization |
86 |
virtual void initialize() = 0; |
|
10014
a5c2141ee857
7057120: Tiered: Allow C1 to inline methods with loops
iveresov
parents:
7397
diff
changeset
|
87 |
virtual bool should_not_inline(ciEnv* env, ciMethod* method) { return false; } |
1 | 88 |
}; |
89 |
||
6453 | 90 |
// A base class for baseline policies. |
91 |
class NonTieredCompPolicy : public CompilationPolicy { |
|
92 |
int _compiler_count; |
|
93 |
protected: |
|
94 |
static void trace_frequency_counter_overflow(methodHandle m, int branch_bci, int bci); |
|
95 |
static void trace_osr_request(methodHandle method, nmethod* osr, int bci); |
|
96 |
static void trace_osr_completion(nmethod* osr_nm); |
|
97 |
void reset_counter_for_invocation_event(methodHandle method); |
|
98 |
void reset_counter_for_back_branch_event(methodHandle method); |
|
99 |
public: |
|
100 |
NonTieredCompPolicy() : _compiler_count(0) { } |
|
16689
efce070b8d42
8007288: Additional WB API for compiler's testing
iignatyev
parents:
13728
diff
changeset
|
101 |
virtual CompLevel initial_compile_level() { return CompLevel_highest_tier; } |
6453 | 102 |
virtual int compiler_count(CompLevel comp_level); |
103 |
virtual void do_safepoint_work(); |
|
104 |
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
|
105 |
virtual void delay_compilation(Method* method); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
106 |
virtual void disable_compilation(Method* method); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
107 |
virtual bool is_mature(Method* method); |
6453 | 108 |
virtual void initialize(); |
109 |
virtual CompileTask* select_task(CompileQueue* compile_queue); |
|
11572
84afef481892
7131259: compile_method and CompilationPolicy::event shouldn't be declared TRAPS
iveresov
parents:
10250
diff
changeset
|
110 |
virtual nmethod* event(methodHandle method, methodHandle inlinee, int branch_bci, int bci, CompLevel comp_level, nmethod* nm, JavaThread* thread); |
84afef481892
7131259: compile_method and CompilationPolicy::event shouldn't be declared TRAPS
iveresov
parents:
10250
diff
changeset
|
111 |
virtual void method_invocation_event(methodHandle m, JavaThread* thread) = 0; |
84afef481892
7131259: compile_method and CompilationPolicy::event shouldn't be declared TRAPS
iveresov
parents:
10250
diff
changeset
|
112 |
virtual void method_back_branch_event(methodHandle m, int bci, JavaThread* thread) = 0; |
6453 | 113 |
}; |
114 |
||
115 |
class SimpleCompPolicy : public NonTieredCompPolicy { |
|
1 | 116 |
public: |
11572
84afef481892
7131259: compile_method and CompilationPolicy::event shouldn't be declared TRAPS
iveresov
parents:
10250
diff
changeset
|
117 |
virtual void method_invocation_event(methodHandle m, JavaThread* thread); |
84afef481892
7131259: compile_method and CompilationPolicy::event shouldn't be declared TRAPS
iveresov
parents:
10250
diff
changeset
|
118 |
virtual void method_back_branch_event(methodHandle m, int bci, JavaThread* thread); |
1 | 119 |
}; |
120 |
||
121 |
// StackWalkCompPolicy - existing C2 policy |
|
122 |
||
123 |
#ifdef COMPILER2 |
|
6453 | 124 |
class StackWalkCompPolicy : public NonTieredCompPolicy { |
1 | 125 |
public: |
11572
84afef481892
7131259: compile_method and CompilationPolicy::event shouldn't be declared TRAPS
iveresov
parents:
10250
diff
changeset
|
126 |
virtual void method_invocation_event(methodHandle m, JavaThread* thread); |
84afef481892
7131259: compile_method and CompilationPolicy::event shouldn't be declared TRAPS
iveresov
parents:
10250
diff
changeset
|
127 |
virtual void method_back_branch_event(methodHandle m, int bci, JavaThread* thread); |
1 | 128 |
|
129 |
private: |
|
130 |
RFrame* findTopInlinableFrame(GrowableArray<RFrame*>* stack); |
|
131 |
RFrame* senderOf(RFrame* rf, GrowableArray<RFrame*>* stack); |
|
132 |
||
133 |
// the following variables hold values computed by the last inlining decision |
|
134 |
// they are used for performance debugging only (print better messages) |
|
135 |
static const char* _msg; // reason for not inlining |
|
136 |
||
137 |
static const char* shouldInline (methodHandle callee, float frequency, int cnt); |
|
138 |
// positive filter: should send be inlined? returns NULL (--> yes) or rejection msg |
|
139 |
static const char* shouldNotInline(methodHandle callee); |
|
140 |
// negative filter: should send NOT be inlined? returns NULL (--> inline) or rejection msg |
|
141 |
||
142 |
}; |
|
143 |
#endif |
|
7397 | 144 |
|
145 |
#endif // SHARE_VM_RUNTIME_COMPILATIONPOLICY_HPP |