Print this page
Split |
Close |
Expand all |
Collapse all |
--- old/src/share/vm/runtime/compilationPolicy.hpp
+++ new/src/share/vm/runtime/compilationPolicy.hpp
1 1 /*
2 2 * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 4 *
5 5 * This code is free software; you can redistribute it and/or modify it
6 6 * under the terms of the GNU General Public License version 2 only, as
7 7 * published by the Free Software Foundation.
8 8 *
9 9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 12 * version 2 for more details (a copy is included in the LICENSE file that
13 13 * accompanied this code).
14 14 *
15 15 * You should have received a copy of the GNU General Public License version
16 16 * 2 along with this work; if not, write to the Free Software Foundation,
17 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 18 *
19 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 20 * or visit www.oracle.com if you need additional information or have any
21 21 * questions.
22 22 *
23 23 */
24 24
25 25 #ifndef SHARE_VM_RUNTIME_COMPILATIONPOLICY_HPP
26 26 #define SHARE_VM_RUNTIME_COMPILATIONPOLICY_HPP
27 27
28 28 #include "code/nmethod.hpp"
29 29 #include "compiler/compileBroker.hpp"
30 30 #include "memory/allocation.hpp"
31 31 #include "runtime/vm_operations.hpp"
32 32 #include "utilities/growableArray.hpp"
33 33
34 34 // The CompilationPolicy selects which method (if any) should be compiled.
35 35 // It also decides which methods must always be compiled (i.e., are never
36 36 // interpreted).
37 37 class CompileTask;
38 38 class CompileQueue;
39 39
40 40 class CompilationPolicy : public CHeapObj {
41 41 static CompilationPolicy* _policy;
42 42 // Accumulated time
43 43 static elapsedTimer _accumulated_time;
44 44
45 45 static bool _in_vm_startup;
46 46 public:
47 47 static void set_in_vm_startup(bool in_vm_startup) { _in_vm_startup = in_vm_startup; }
48 48 static void completed_vm_startup();
49 49 static bool delay_compilation_during_startup() { return _in_vm_startup; }
50 50
51 51 // m must be compiled before executing it
↓ open down ↓ |
51 lines elided |
↑ open up ↑ |
52 52 static bool must_be_compiled(methodHandle m, int comp_level = CompLevel_all);
53 53 // m is allowed to be compiled
54 54 static bool can_be_compiled(methodHandle m, int comp_level = CompLevel_all);
55 55 static bool is_compilation_enabled();
56 56 static void set_policy(CompilationPolicy* policy) { _policy = policy; }
57 57 static CompilationPolicy* policy() { return _policy; }
58 58
59 59 // Profiling
60 60 elapsedTimer* accumulated_time() { return &_accumulated_time; }
61 61 void print_time() PRODUCT_RETURN;
62 + // Return initial compile level that is used with Xcomp
63 + virtual CompLevel initial_compile_level() = 0;
62 64 virtual int compiler_count(CompLevel comp_level) = 0;
63 65 // main notification entry, return a pointer to an nmethod if the OSR is required,
64 66 // returns NULL otherwise.
65 67 virtual nmethod* event(methodHandle method, methodHandle inlinee, int branch_bci, int bci, CompLevel comp_level, nmethod* nm, TRAPS) = 0;
66 68 // safepoint() is called at the end of the safepoint
67 69 virtual void do_safepoint_work() = 0;
68 70 // reprofile request
69 71 virtual void reprofile(ScopeDesc* trap_scope, bool is_osr) = 0;
70 72 // delay_compilation(method) can be called by any component of the runtime to notify the policy
71 73 // that it's recommended to delay the complation of this method.
72 74 virtual void delay_compilation(methodOop method) = 0;
73 75 // disable_compilation() is called whenever the runtime decides to disable compilation of the
74 76 // specified method.
75 77 virtual void disable_compilation(methodOop method) = 0;
76 78 // Select task is called by CompileBroker. The queue is guaranteed to have at least one
77 79 // element and is locked. The function should select one and return it.
78 80 virtual CompileTask* select_task(CompileQueue* compile_queue) = 0;
79 81 // Tell the runtime if we think a given method is adequately profiled.
80 82 virtual bool is_mature(methodOop method) = 0;
81 83 // Do policy initialization
82 84 virtual void initialize() = 0;
83 85 virtual bool should_not_inline(ciEnv* env, ciMethod* method) { return false; }
84 86 };
85 87
86 88 // A base class for baseline policies.
↓ open down ↓ |
15 lines elided |
↑ open up ↑ |
87 89 class NonTieredCompPolicy : public CompilationPolicy {
88 90 int _compiler_count;
89 91 protected:
90 92 static void trace_frequency_counter_overflow(methodHandle m, int branch_bci, int bci);
91 93 static void trace_osr_request(methodHandle method, nmethod* osr, int bci);
92 94 static void trace_osr_completion(nmethod* osr_nm);
93 95 void reset_counter_for_invocation_event(methodHandle method);
94 96 void reset_counter_for_back_branch_event(methodHandle method);
95 97 public:
96 98 NonTieredCompPolicy() : _compiler_count(0) { }
99 + virtual CompLevel initial_compile_level() { return CompLevel_initial_compile; }
97 100 virtual int compiler_count(CompLevel comp_level);
98 101 virtual void do_safepoint_work();
99 102 virtual void reprofile(ScopeDesc* trap_scope, bool is_osr);
100 103 virtual void delay_compilation(methodOop method);
101 104 virtual void disable_compilation(methodOop method);
102 105 virtual bool is_mature(methodOop method);
103 106 virtual void initialize();
104 107 virtual CompileTask* select_task(CompileQueue* compile_queue);
105 108 virtual nmethod* event(methodHandle method, methodHandle inlinee, int branch_bci, int bci, CompLevel comp_level, nmethod* nm, TRAPS);
106 109 virtual void method_invocation_event(methodHandle m, TRAPS) = 0;
107 110 virtual void method_back_branch_event(methodHandle m, int bci, TRAPS) = 0;
108 111 };
109 112
110 113 class SimpleCompPolicy : public NonTieredCompPolicy {
111 114 public:
112 115 virtual void method_invocation_event(methodHandle m, TRAPS);
113 116 virtual void method_back_branch_event(methodHandle m, int bci, TRAPS);
114 117 };
115 118
116 119 // StackWalkCompPolicy - existing C2 policy
117 120
118 121 #ifdef COMPILER2
119 122 class StackWalkCompPolicy : public NonTieredCompPolicy {
120 123 public:
121 124 virtual void method_invocation_event(methodHandle m, TRAPS);
122 125 virtual void method_back_branch_event(methodHandle m, int bci, TRAPS);
123 126
124 127 private:
125 128 RFrame* findTopInlinableFrame(GrowableArray<RFrame*>* stack);
126 129 RFrame* senderOf(RFrame* rf, GrowableArray<RFrame*>* stack);
127 130
128 131 // the following variables hold values computed by the last inlining decision
129 132 // they are used for performance debugging only (print better messages)
130 133 static const char* _msg; // reason for not inlining
131 134
132 135 static const char* shouldInline (methodHandle callee, float frequency, int cnt);
133 136 // positive filter: should send be inlined? returns NULL (--> yes) or rejection msg
134 137 static const char* shouldNotInline(methodHandle callee);
135 138 // negative filter: should send NOT be inlined? returns NULL (--> inline) or rejection msg
136 139
137 140 };
138 141 #endif
139 142
140 143 #endif // SHARE_VM_RUNTIME_COMPILATIONPOLICY_HPP
↓ open down ↓ |
34 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX