Mercurial > hg > truffle
annotate src/share/vm/runtime/compilationPolicy.hpp @ 3109:3664989976e2
Merge
author | Gilles Duboscq <gilles.duboscq@oracle.com> |
---|---|
date | Fri, 01 Jul 2011 12:57:10 +0200 |
parents | f95d63e2154a |
children | 409ef3a68dc8 2c359f27615c |
rev | line source |
---|---|
0 | 1 /* |
1783 | 2 * Copyright (c) 2000, 2010, 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 |
40 class CompilationPolicy : public CHeapObj { | |
41 static CompilationPolicy* _policy; | |
42 // Accumulated time | |
43 static elapsedTimer _accumulated_time; | |
44 | |
45 static bool _in_vm_startup; | |
1783 | 46 public: |
0 | 47 static void set_in_vm_startup(bool in_vm_startup) { _in_vm_startup = in_vm_startup; } |
48 static void completed_vm_startup(); | |
1783 | 49 static bool delay_compilation_during_startup() { return _in_vm_startup; } |
0 | 50 |
1783 | 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); | |
55 static bool is_compilation_enabled(); | |
0 | 56 static void set_policy(CompilationPolicy* policy) { _policy = policy; } |
1783 | 57 static CompilationPolicy* policy() { return _policy; } |
0 | 58 |
59 // Profiling | |
60 elapsedTimer* accumulated_time() { return &_accumulated_time; } | |
61 void print_time() PRODUCT_RETURN; | |
1783 | 62 virtual int compiler_count(CompLevel comp_level) = 0; |
63 // main notification entry, return a pointer to an nmethod if the OSR is required, | |
64 // returns NULL otherwise. | |
65 virtual nmethod* event(methodHandle method, methodHandle inlinee, int branch_bci, int bci, CompLevel comp_level, TRAPS) = 0; | |
66 // safepoint() is called at the end of the safepoint | |
67 virtual void do_safepoint_work() = 0; | |
68 // reprofile request | |
69 virtual void reprofile(ScopeDesc* trap_scope, bool is_osr) = 0; | |
70 // delay_compilation(method) can be called by any component of the runtime to notify the policy | |
71 // that it's recommended to delay the complation of this method. | |
72 virtual void delay_compilation(methodOop method) = 0; | |
73 // disable_compilation() is called whenever the runtime decides to disable compilation of the | |
74 // specified method. | |
75 virtual void disable_compilation(methodOop method) = 0; | |
76 // Select task is called by CompileBroker. The queue is guaranteed to have at least one | |
77 // element and is locked. The function should select one and return it. | |
78 virtual CompileTask* select_task(CompileQueue* compile_queue) = 0; | |
79 // Tell the runtime if we think a given method is adequately profiled. | |
80 virtual bool is_mature(methodOop method) = 0; | |
81 // Do policy initialization | |
82 virtual void initialize() = 0; | |
0 | 83 }; |
84 | |
1783 | 85 // A base class for baseline policies. |
86 class NonTieredCompPolicy : public CompilationPolicy { | |
87 int _compiler_count; | |
88 protected: | |
89 static void trace_frequency_counter_overflow(methodHandle m, int branch_bci, int bci); | |
90 static void trace_osr_request(methodHandle method, nmethod* osr, int bci); | |
91 static void trace_osr_completion(nmethod* osr_nm); | |
92 void reset_counter_for_invocation_event(methodHandle method); | |
93 void reset_counter_for_back_branch_event(methodHandle method); | |
94 public: | |
95 NonTieredCompPolicy() : _compiler_count(0) { } | |
96 virtual int compiler_count(CompLevel comp_level); | |
97 virtual void do_safepoint_work(); | |
98 virtual void reprofile(ScopeDesc* trap_scope, bool is_osr); | |
99 virtual void delay_compilation(methodOop method); | |
100 virtual void disable_compilation(methodOop method); | |
101 virtual bool is_mature(methodOop method); | |
102 virtual void initialize(); | |
103 virtual CompileTask* select_task(CompileQueue* compile_queue); | |
104 virtual nmethod* event(methodHandle method, methodHandle inlinee, int branch_bci, int bci, CompLevel comp_level, TRAPS); | |
105 virtual void method_invocation_event(methodHandle m, TRAPS) = 0; | |
106 virtual void method_back_branch_event(methodHandle m, int bci, TRAPS) = 0; | |
107 }; | |
108 | |
109 class SimpleCompPolicy : public NonTieredCompPolicy { | |
0 | 110 public: |
1783 | 111 virtual void method_invocation_event(methodHandle m, TRAPS); |
112 virtual void method_back_branch_event(methodHandle m, int bci, TRAPS); | |
0 | 113 }; |
114 | |
115 // StackWalkCompPolicy - existing C2 policy | |
116 | |
117 #ifdef COMPILER2 | |
1783 | 118 class StackWalkCompPolicy : public NonTieredCompPolicy { |
0 | 119 public: |
1783 | 120 virtual void method_invocation_event(methodHandle m, TRAPS); |
121 virtual void method_back_branch_event(methodHandle m, int bci, TRAPS); | |
0 | 122 |
123 private: | |
124 RFrame* findTopInlinableFrame(GrowableArray<RFrame*>* stack); | |
125 RFrame* senderOf(RFrame* rf, GrowableArray<RFrame*>* stack); | |
126 | |
127 // the following variables hold values computed by the last inlining decision | |
128 // they are used for performance debugging only (print better messages) | |
129 static const char* _msg; // reason for not inlining | |
130 | |
131 static const char* shouldInline (methodHandle callee, float frequency, int cnt); | |
132 // positive filter: should send be inlined? returns NULL (--> yes) or rejection msg | |
133 static const char* shouldNotInline(methodHandle callee); | |
134 // negative filter: should send NOT be inlined? returns NULL (--> inline) or rejection msg | |
135 | |
136 }; | |
137 #endif | |
1972 | 138 |
139 #endif // SHARE_VM_RUNTIME_COMPILATIONPOLICY_HPP |