author | thartmann |
Wed, 01 Jun 2016 14:22:18 +0200 | |
changeset 39252 | a3644fa2b8b4 |
parent 38177 | b0c9cb06506b |
permissions | -rw-r--r-- |
1 | 1 |
/* |
22234
da823d78ad65
8029233: Update copyright year to match last edit in jdk8 hotspot repository for 2013
mikael
parents:
21099
diff
changeset
|
2 |
* Copyright (c) 1997, 2013, 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:
5228
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5228
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:
5228
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#ifndef SHARE_VM_OPTO_PARSE_HPP |
26 |
#define SHARE_VM_OPTO_PARSE_HPP |
|
27 |
||
28 |
#include "ci/ciMethodData.hpp" |
|
29 |
#include "ci/ciTypeFlow.hpp" |
|
30 |
#include "compiler/methodLiveness.hpp" |
|
31 |
#include "libadt/vectset.hpp" |
|
32 |
#include "oops/generateOopMap.hpp" |
|
33 |
#include "opto/graphKit.hpp" |
|
34 |
#include "opto/subnode.hpp" |
|
35 |
||
1 | 36 |
class BytecodeParseHistogram; |
37 |
class InlineTree; |
|
38 |
class Parse; |
|
39 |
class SwitchRange; |
|
40 |
||
41 |
||
42 |
//------------------------------InlineTree------------------------------------- |
|
43 |
class InlineTree : public ResourceObj { |
|
10547 | 44 |
friend class VMStructs; |
45 |
||
1 | 46 |
Compile* C; // cache |
47 |
JVMState* _caller_jvms; // state of caller |
|
48 |
ciMethod* _method; // method being called by the caller_jvms |
|
49 |
InlineTree* _caller_tree; |
|
50 |
uint _count_inline_bcs; // Accumulated count of inlined bytecodes |
|
51 |
// Call-site count / interpreter invocation count, scaled recursively. |
|
52 |
// Always between 0.0 and 1.0. Represents the percentage of the method's |
|
53 |
// total execution time used at this call site. |
|
54 |
const float _site_invoke_ratio; |
|
10007
43d4a6542551
7057587: JSR 292 - crash with jruby in test/test_respond_to.rb
never
parents:
9633
diff
changeset
|
55 |
const int _max_inline_level; // the maximum inline level for this sub-tree (may be adjusted) |
1 | 56 |
float compute_callee_frequency( int caller_bci ) const; |
57 |
||
58 |
GrowableArray<InlineTree*> _subtrees; |
|
10547 | 59 |
|
60 |
void print_impl(outputStream* stj, int indent) const PRODUCT_RETURN; |
|
15816
33b9a6b4f9df
8007439: C2: adding successful message of inlining
iignatyev
parents:
15472
diff
changeset
|
61 |
const char* _msg; |
1 | 62 |
protected: |
63 |
InlineTree(Compile* C, |
|
64 |
const InlineTree* caller_tree, |
|
65 |
ciMethod* callee_method, |
|
66 |
JVMState* caller_jvms, |
|
67 |
int caller_bci, |
|
4586
f1c484fca023
6912063: inlining parameters need to be adjusted for some uses of the JVM
jrose
parents:
3908
diff
changeset
|
68 |
float site_invoke_ratio, |
10007
43d4a6542551
7057587: JSR 292 - crash with jruby in test/test_respond_to.rb
never
parents:
9633
diff
changeset
|
69 |
int max_inline_level); |
1 | 70 |
InlineTree *build_inline_tree_for_callee(ciMethod* callee_method, |
71 |
JVMState* caller_jvms, |
|
72 |
int caller_bci); |
|
15816
33b9a6b4f9df
8007439: C2: adding successful message of inlining
iignatyev
parents:
15472
diff
changeset
|
73 |
bool try_to_inline(ciMethod* callee_method, |
33b9a6b4f9df
8007439: C2: adding successful message of inlining
iignatyev
parents:
15472
diff
changeset
|
74 |
ciMethod* caller_method, |
33b9a6b4f9df
8007439: C2: adding successful message of inlining
iignatyev
parents:
15472
diff
changeset
|
75 |
int caller_bci, |
20689
bc5805c29150
8011138: C2: stack overflow in compiler thread because of recursive inlining of lambda form methods
twisti
parents:
19770
diff
changeset
|
76 |
JVMState* jvms, |
15816
33b9a6b4f9df
8007439: C2: adding successful message of inlining
iignatyev
parents:
15472
diff
changeset
|
77 |
ciCallProfile& profile, |
33b9a6b4f9df
8007439: C2: adding successful message of inlining
iignatyev
parents:
15472
diff
changeset
|
78 |
WarmCallInfo* wci_result, |
33b9a6b4f9df
8007439: C2: adding successful message of inlining
iignatyev
parents:
15472
diff
changeset
|
79 |
bool& should_delay); |
33b9a6b4f9df
8007439: C2: adding successful message of inlining
iignatyev
parents:
15472
diff
changeset
|
80 |
bool should_inline(ciMethod* callee_method, |
33b9a6b4f9df
8007439: C2: adding successful message of inlining
iignatyev
parents:
15472
diff
changeset
|
81 |
ciMethod* caller_method, |
33b9a6b4f9df
8007439: C2: adding successful message of inlining
iignatyev
parents:
15472
diff
changeset
|
82 |
int caller_bci, |
33b9a6b4f9df
8007439: C2: adding successful message of inlining
iignatyev
parents:
15472
diff
changeset
|
83 |
ciCallProfile& profile, |
33b9a6b4f9df
8007439: C2: adding successful message of inlining
iignatyev
parents:
15472
diff
changeset
|
84 |
WarmCallInfo* wci_result); |
33b9a6b4f9df
8007439: C2: adding successful message of inlining
iignatyev
parents:
15472
diff
changeset
|
85 |
bool should_not_inline(ciMethod* callee_method, |
33b9a6b4f9df
8007439: C2: adding successful message of inlining
iignatyev
parents:
15472
diff
changeset
|
86 |
ciMethod* caller_method, |
20689
bc5805c29150
8011138: C2: stack overflow in compiler thread because of recursive inlining of lambda form methods
twisti
parents:
19770
diff
changeset
|
87 |
JVMState* jvms, |
15816
33b9a6b4f9df
8007439: C2: adding successful message of inlining
iignatyev
parents:
15472
diff
changeset
|
88 |
WarmCallInfo* wci_result); |
15472
ae13b6ad6c25
8005439: no message about inline method if it specifed by CompileCommand
vlivanov
parents:
15118
diff
changeset
|
89 |
void print_inlining(ciMethod* callee_method, int caller_bci, |
29582 | 90 |
ciMethod* caller_method, bool success) const; |
1 | 91 |
|
15816
33b9a6b4f9df
8007439: C2: adding successful message of inlining
iignatyev
parents:
15472
diff
changeset
|
92 |
InlineTree* caller_tree() const { return _caller_tree; } |
1 | 93 |
InlineTree* callee_at(int bci, ciMethod* m) const; |
10007
43d4a6542551
7057587: JSR 292 - crash with jruby in test/test_respond_to.rb
never
parents:
9633
diff
changeset
|
94 |
int inline_level() const { return stack_depth(); } |
4586
f1c484fca023
6912063: inlining parameters need to be adjusted for some uses of the JVM
jrose
parents:
3908
diff
changeset
|
95 |
int stack_depth() const { return _caller_jvms ? _caller_jvms->depth() : 0; } |
15816
33b9a6b4f9df
8007439: C2: adding successful message of inlining
iignatyev
parents:
15472
diff
changeset
|
96 |
const char* msg() const { return _msg; } |
33b9a6b4f9df
8007439: C2: adding successful message of inlining
iignatyev
parents:
15472
diff
changeset
|
97 |
void set_msg(const char* msg) { _msg = msg; } |
1 | 98 |
public: |
10509
43d670e5701e
7079673: JSR 292: C1 should inline bytecoded method handle adapters
twisti
parents:
10007
diff
changeset
|
99 |
static const char* check_can_parse(ciMethod* callee); |
43d670e5701e
7079673: JSR 292: C1 should inline bytecoded method handle adapters
twisti
parents:
10007
diff
changeset
|
100 |
|
1 | 101 |
static InlineTree* build_inline_tree_root(); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
12945
diff
changeset
|
102 |
static InlineTree* find_subtree_from_root(InlineTree* root, JVMState* jvms, ciMethod* callee); |
1 | 103 |
|
104 |
// For temporary (stack-allocated, stateless) ilts: |
|
10007
43d4a6542551
7057587: JSR 292 - crash with jruby in test/test_respond_to.rb
never
parents:
9633
diff
changeset
|
105 |
InlineTree(Compile* c, ciMethod* callee_method, JVMState* caller_jvms, float site_invoke_ratio, int max_inline_level); |
1 | 106 |
|
107 |
// See if it is OK to inline. |
|
2131 | 108 |
// The receiver is the inline tree for the caller. |
1 | 109 |
// |
110 |
// The result is a temperature indication. If it is hot or cold, |
|
111 |
// inlining is immediate or undesirable. Otherwise, the info block |
|
112 |
// returned is newly allocated and may be enqueued. |
|
113 |
// |
|
114 |
// If the method is inlinable, a new inline subtree is created on the fly, |
|
115 |
// and may be accessed by find_subtree_from_root. |
|
116 |
// The call_method is the dest_method for a special or static invocation. |
|
117 |
// The call_method is an optimized virtual method candidate otherwise. |
|
15113 | 118 |
WarmCallInfo* ok_to_inline(ciMethod *call_method, JVMState* caller_jvms, ciCallProfile& profile, WarmCallInfo* wci, bool& should_delay); |
1 | 119 |
|
120 |
// Information about inlined method |
|
121 |
JVMState* caller_jvms() const { return _caller_jvms; } |
|
122 |
ciMethod *method() const { return _method; } |
|
123 |
int caller_bci() const { return _caller_jvms ? _caller_jvms->bci() : InvocationEntryBci; } |
|
124 |
uint count_inline_bcs() const { return _count_inline_bcs; } |
|
125 |
float site_invoke_ratio() const { return _site_invoke_ratio; }; |
|
126 |
||
127 |
#ifndef PRODUCT |
|
128 |
private: |
|
129 |
uint _count_inlines; // Count of inlined methods |
|
130 |
public: |
|
131 |
// Debug information collected during parse |
|
132 |
uint count_inlines() const { return _count_inlines; }; |
|
133 |
#endif |
|
134 |
GrowableArray<InlineTree*> subtrees() { return _subtrees; } |
|
10547 | 135 |
|
136 |
void print_value_on(outputStream* st) const PRODUCT_RETURN; |
|
22243 | 137 |
|
25640
eb0d8ef2f700
8049528: Method marked w/ @ForceInline isn't inlined with "executed < MinInliningThreshold times" message
vlivanov
parents:
25496
diff
changeset
|
138 |
bool _forced_inline; // Inlining was forced by CompilerOracle, ciReplay or annotation |
22243 | 139 |
bool forced_inline() const { return _forced_inline; } |
140 |
// Count number of nodes in this subtree |
|
141 |
int count() const; |
|
142 |
// Dump inlining replay data to the stream. |
|
143 |
void dump_replay_data(outputStream* out); |
|
1 | 144 |
}; |
145 |
||
146 |
||
147 |
//----------------------------------------------------------------------------- |
|
148 |
//------------------------------Parse------------------------------------------ |
|
149 |
// Parse bytecodes, build a Graph |
|
150 |
class Parse : public GraphKit { |
|
151 |
public: |
|
152 |
// Per-block information needed by the parser: |
|
153 |
class Block { |
|
154 |
private: |
|
155 |
ciTypeFlow::Block* _flow; |
|
156 |
int _pred_count; // how many predecessors in CFG? |
|
157 |
int _preds_parsed; // how many of these have been parsed? |
|
158 |
uint _count; // how many times executed? Currently only set by _goto's |
|
159 |
bool _is_parsed; // has this block been parsed yet? |
|
160 |
bool _is_handler; // is this block an exception handler? |
|
8732
16fc1c68714b
7008866: Missing loop predicate for loop with multiple entries
kvn
parents:
7397
diff
changeset
|
161 |
bool _has_merged_backedge; // does this block have merged backedge? |
1 | 162 |
SafePointNode* _start_map; // all values flowing into this block |
163 |
MethodLivenessResult _live_locals; // lazily initialized liveness bitmap |
|
164 |
||
165 |
int _num_successors; // Includes only normal control flow. |
|
166 |
int _all_successors; // Include exception paths also. |
|
167 |
Block** _successors; |
|
168 |
||
169 |
public: |
|
170 |
||
171 |
// Set up the block data structure itself. |
|
39252
a3644fa2b8b4
8155046: Parse::Block construction using undefined behavior
thartmann
parents:
38177
diff
changeset
|
172 |
Block(Parse* outer, int rpo); |
a3644fa2b8b4
8155046: Parse::Block construction using undefined behavior
thartmann
parents:
38177
diff
changeset
|
173 |
|
1 | 174 |
// Set up the block's relations to other blocks. |
175 |
void init_graph(Parse* outer); |
|
176 |
||
177 |
ciTypeFlow::Block* flow() const { return _flow; } |
|
178 |
int pred_count() const { return _pred_count; } |
|
179 |
int preds_parsed() const { return _preds_parsed; } |
|
180 |
bool is_parsed() const { return _is_parsed; } |
|
181 |
bool is_handler() const { return _is_handler; } |
|
182 |
void set_count( uint x ) { _count = x; } |
|
183 |
uint count() const { return _count; } |
|
184 |
||
185 |
SafePointNode* start_map() const { assert(is_merged(),""); return _start_map; } |
|
186 |
void set_start_map(SafePointNode* m) { assert(!is_merged(), ""); _start_map = m; } |
|
187 |
||
188 |
// True after any predecessor flows control into this block |
|
189 |
bool is_merged() const { return _start_map != NULL; } |
|
190 |
||
8732
16fc1c68714b
7008866: Missing loop predicate for loop with multiple entries
kvn
parents:
7397
diff
changeset
|
191 |
#ifdef ASSERT |
16fc1c68714b
7008866: Missing loop predicate for loop with multiple entries
kvn
parents:
7397
diff
changeset
|
192 |
// True after backedge predecessor flows control into this block |
16fc1c68714b
7008866: Missing loop predicate for loop with multiple entries
kvn
parents:
7397
diff
changeset
|
193 |
bool has_merged_backedge() const { return _has_merged_backedge; } |
16fc1c68714b
7008866: Missing loop predicate for loop with multiple entries
kvn
parents:
7397
diff
changeset
|
194 |
void mark_merged_backedge(Block* pred) { |
16fc1c68714b
7008866: Missing loop predicate for loop with multiple entries
kvn
parents:
7397
diff
changeset
|
195 |
assert(is_SEL_head(), "should be loop head"); |
16fc1c68714b
7008866: Missing loop predicate for loop with multiple entries
kvn
parents:
7397
diff
changeset
|
196 |
if (pred != NULL && is_SEL_backedge(pred)) { |
16fc1c68714b
7008866: Missing loop predicate for loop with multiple entries
kvn
parents:
7397
diff
changeset
|
197 |
assert(is_parsed(), "block should be parsed before merging backedges"); |
16fc1c68714b
7008866: Missing loop predicate for loop with multiple entries
kvn
parents:
7397
diff
changeset
|
198 |
_has_merged_backedge = true; |
16fc1c68714b
7008866: Missing loop predicate for loop with multiple entries
kvn
parents:
7397
diff
changeset
|
199 |
} |
16fc1c68714b
7008866: Missing loop predicate for loop with multiple entries
kvn
parents:
7397
diff
changeset
|
200 |
} |
16fc1c68714b
7008866: Missing loop predicate for loop with multiple entries
kvn
parents:
7397
diff
changeset
|
201 |
#endif |
16fc1c68714b
7008866: Missing loop predicate for loop with multiple entries
kvn
parents:
7397
diff
changeset
|
202 |
|
1 | 203 |
// True when all non-exception predecessors have been parsed. |
204 |
bool is_ready() const { return preds_parsed() == pred_count(); } |
|
205 |
||
206 |
int num_successors() const { return _num_successors; } |
|
207 |
int all_successors() const { return _all_successors; } |
|
208 |
Block* successor_at(int i) const { |
|
209 |
assert((uint)i < (uint)all_successors(), ""); |
|
210 |
return _successors[i]; |
|
211 |
} |
|
212 |
Block* successor_for_bci(int bci); |
|
213 |
||
214 |
int start() const { return flow()->start(); } |
|
215 |
int limit() const { return flow()->limit(); } |
|
1399
9648dfd4ce09
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
956
diff
changeset
|
216 |
int rpo() const { return flow()->rpo(); } |
1 | 217 |
int start_sp() const { return flow()->stack_size(); } |
218 |
||
1399
9648dfd4ce09
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
956
diff
changeset
|
219 |
bool is_loop_head() const { return flow()->is_loop_head(); } |
9648dfd4ce09
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
956
diff
changeset
|
220 |
bool is_SEL_head() const { return flow()->is_single_entry_loop_head(); } |
9648dfd4ce09
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
956
diff
changeset
|
221 |
bool is_SEL_backedge(Block* pred) const{ return is_SEL_head() && pred->rpo() >= rpo(); } |
9648dfd4ce09
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
956
diff
changeset
|
222 |
bool is_invariant_local(uint i) const { |
9648dfd4ce09
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
956
diff
changeset
|
223 |
const JVMState* jvms = start_map()->jvms(); |
1554
59019800a87c
6766316: assert(!nocreate,"Cannot build a phi for a block already parsed.")
kvn
parents:
1399
diff
changeset
|
224 |
if (!jvms->is_loc(i) || flow()->outer()->has_irreducible_entry()) return false; |
1399
9648dfd4ce09
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
956
diff
changeset
|
225 |
return flow()->is_invariant_local(i - jvms->locoff()); |
9648dfd4ce09
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
956
diff
changeset
|
226 |
} |
9648dfd4ce09
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
956
diff
changeset
|
227 |
bool can_elide_SEL_phi(uint i) const { assert(is_SEL_head(),""); return is_invariant_local(i); } |
9648dfd4ce09
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
956
diff
changeset
|
228 |
|
1 | 229 |
const Type* peek(int off=0) const { return stack_type_at(start_sp() - (off+1)); } |
230 |
||
231 |
const Type* stack_type_at(int i) const; |
|
232 |
const Type* local_type_at(int i) const; |
|
233 |
static const Type* get_type(ciType* t) { return Type::get_typeflow_type(t); } |
|
234 |
||
235 |
bool has_trap_at(int bci) const { return flow()->has_trap() && flow()->trap_bci() == bci; } |
|
236 |
||
237 |
// Call this just before parsing a block. |
|
238 |
void mark_parsed() { |
|
239 |
assert(!_is_parsed, "must parse each block exactly once"); |
|
240 |
_is_parsed = true; |
|
241 |
} |
|
242 |
||
243 |
// Return the phi/region input index for the "current" pred, |
|
244 |
// and bump the pred number. For historical reasons these index |
|
245 |
// numbers are handed out in descending order. The last index is |
|
246 |
// always PhiNode::Input (i.e., 1). The value returned is known |
|
247 |
// as a "path number" because it distinguishes by which path we are |
|
248 |
// entering the block. |
|
249 |
int next_path_num() { |
|
250 |
assert(preds_parsed() < pred_count(), "too many preds?"); |
|
251 |
return pred_count() - _preds_parsed++; |
|
252 |
} |
|
253 |
||
254 |
// Add a previously unaccounted predecessor to this block. |
|
255 |
// This operates by increasing the size of the block's region |
|
256 |
// and all its phi nodes (if any). The value returned is a |
|
257 |
// path number ("pnum"). |
|
258 |
int add_new_path(); |
|
259 |
||
260 |
// Initialize me by recording the parser's map. My own map must be NULL. |
|
261 |
void record_state(Parse* outer); |
|
262 |
}; |
|
263 |
||
264 |
#ifndef PRODUCT |
|
265 |
// BytecodeParseHistogram collects number of bytecodes parsed, nodes constructed, and transformations. |
|
266 |
class BytecodeParseHistogram : public ResourceObj { |
|
267 |
private: |
|
268 |
enum BPHType { |
|
269 |
BPH_transforms, |
|
270 |
BPH_values |
|
271 |
}; |
|
272 |
static bool _initialized; |
|
273 |
static uint _bytecodes_parsed [Bytecodes::number_of_codes]; |
|
274 |
static uint _nodes_constructed[Bytecodes::number_of_codes]; |
|
275 |
static uint _nodes_transformed[Bytecodes::number_of_codes]; |
|
276 |
static uint _new_values [Bytecodes::number_of_codes]; |
|
277 |
||
278 |
Bytecodes::Code _initial_bytecode; |
|
279 |
int _initial_node_count; |
|
280 |
int _initial_transforms; |
|
281 |
int _initial_values; |
|
282 |
||
283 |
Parse *_parser; |
|
284 |
Compile *_compiler; |
|
285 |
||
286 |
// Initialization |
|
287 |
static void reset(); |
|
288 |
||
289 |
// Return info being collected, select with global flag 'BytecodeParseInfo' |
|
290 |
int current_count(BPHType info_selector); |
|
291 |
||
292 |
public: |
|
293 |
BytecodeParseHistogram(Parse *p, Compile *c); |
|
294 |
static bool initialized(); |
|
295 |
||
296 |
// Record info when starting to parse one bytecode |
|
297 |
void set_initial_state( Bytecodes::Code bc ); |
|
298 |
// Record results of parsing one bytecode |
|
299 |
void record_change(); |
|
300 |
||
301 |
// Profile printing |
|
302 |
static void print(float cutoff = 0.01F); // cutoff in percent |
|
303 |
}; |
|
304 |
||
305 |
public: |
|
306 |
// Record work done during parsing |
|
307 |
BytecodeParseHistogram* _parse_histogram; |
|
308 |
void set_parse_histogram(BytecodeParseHistogram *bph) { _parse_histogram = bph; } |
|
309 |
BytecodeParseHistogram* parse_histogram() { return _parse_histogram; } |
|
310 |
#endif |
|
311 |
||
312 |
private: |
|
313 |
friend class Block; |
|
314 |
||
315 |
// Variables which characterize this compilation as a whole: |
|
316 |
||
317 |
JVMState* _caller; // JVMS which carries incoming args & state. |
|
318 |
float _expected_uses; // expected number of calls to this code |
|
319 |
float _prof_factor; // discount applied to my profile counts |
|
320 |
int _depth; // Inline tree depth, for debug printouts |
|
321 |
const TypeFunc*_tf; // My kind of function type |
|
322 |
int _entry_bci; // the osr bci or InvocationEntryBci |
|
323 |
||
324 |
ciTypeFlow* _flow; // Results of previous flow pass. |
|
325 |
Block* _blocks; // Array of basic-block structs. |
|
326 |
int _block_count; // Number of elements in _blocks. |
|
327 |
||
328 |
GraphKit _exits; // Record all normal returns and throws here. |
|
329 |
bool _wrote_final; // Did we write a final field? |
|
22868
7f6eb436873b
8029101: PPC64 (part 211): ordering of Independent Reads of Independent Writes
goetz
parents:
21099
diff
changeset
|
330 |
bool _wrote_volatile; // Did we write a volatile field? |
23190
e8bbf9cd711e
8031818: Experimental VM flag for enforcing safe object construction
shade
parents:
22872
diff
changeset
|
331 |
bool _wrote_stable; // Did we write a @Stable field? |
e8bbf9cd711e
8031818: Experimental VM flag for enforcing safe object construction
shade
parents:
22872
diff
changeset
|
332 |
bool _wrote_fields; // Did we write any field? |
22868
7f6eb436873b
8029101: PPC64 (part 211): ordering of Independent Reads of Independent Writes
goetz
parents:
21099
diff
changeset
|
333 |
bool _count_invocations; // update and test invocation counter |
1 | 334 |
bool _method_data_update; // update method data oop |
17383 | 335 |
Node* _alloc_with_final; // An allocation node with final field |
1 | 336 |
|
337 |
// Variables which track Java semantics during bytecode parsing: |
|
338 |
||
339 |
Block* _block; // block currently getting parsed |
|
340 |
ciBytecodeStream _iter; // stream of this method's bytecodes |
|
341 |
||
342 |
const FastLockNode* _synch_lock; // FastLockNode for synchronized method |
|
343 |
||
344 |
#ifndef PRODUCT |
|
345 |
int _max_switch_depth; // Debugging SwitchRanges. |
|
346 |
int _est_switch_depth; // Debugging SwitchRanges. |
|
347 |
#endif |
|
348 |
||
24946
24b68ccf3fc4
8026796: Make replace_in_map() on parent maps generic
roland
parents:
24442
diff
changeset
|
349 |
bool _first_return; // true if return is the first to be parsed |
24b68ccf3fc4
8026796: Make replace_in_map() on parent maps generic
roland
parents:
24442
diff
changeset
|
350 |
bool _replaced_nodes_for_exceptions; // needs processing of replaced nodes in exception paths? |
24b68ccf3fc4
8026796: Make replace_in_map() on parent maps generic
roland
parents:
24442
diff
changeset
|
351 |
uint _new_idx; // any node with _idx above were new during this parsing. Used to trim the replaced nodes list. |
21089
e1986ff6fe2e
8024069: replace_in_map() should operate on parent maps
roland
parents:
20689
diff
changeset
|
352 |
|
1 | 353 |
public: |
354 |
// Constructor |
|
24946
24b68ccf3fc4
8026796: Make replace_in_map() on parent maps generic
roland
parents:
24442
diff
changeset
|
355 |
Parse(JVMState* caller, ciMethod* parse_method, float expected_uses); |
1 | 356 |
|
357 |
virtual Parse* is_Parse() const { return (Parse*)this; } |
|
358 |
||
359 |
// Accessors. |
|
360 |
JVMState* caller() const { return _caller; } |
|
361 |
float expected_uses() const { return _expected_uses; } |
|
362 |
float prof_factor() const { return _prof_factor; } |
|
363 |
int depth() const { return _depth; } |
|
364 |
const TypeFunc* tf() const { return _tf; } |
|
365 |
// entry_bci() -- see osr_bci, etc. |
|
366 |
||
367 |
ciTypeFlow* flow() const { return _flow; } |
|
1399
9648dfd4ce09
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
956
diff
changeset
|
368 |
// blocks() -- see rpo_at, start_block, etc. |
1 | 369 |
int block_count() const { return _block_count; } |
370 |
||
371 |
GraphKit& exits() { return _exits; } |
|
372 |
bool wrote_final() const { return _wrote_final; } |
|
373 |
void set_wrote_final(bool z) { _wrote_final = z; } |
|
22868
7f6eb436873b
8029101: PPC64 (part 211): ordering of Independent Reads of Independent Writes
goetz
parents:
21099
diff
changeset
|
374 |
bool wrote_volatile() const { return _wrote_volatile; } |
7f6eb436873b
8029101: PPC64 (part 211): ordering of Independent Reads of Independent Writes
goetz
parents:
21099
diff
changeset
|
375 |
void set_wrote_volatile(bool z) { _wrote_volatile = z; } |
23190
e8bbf9cd711e
8031818: Experimental VM flag for enforcing safe object construction
shade
parents:
22872
diff
changeset
|
376 |
bool wrote_stable() const { return _wrote_stable; } |
e8bbf9cd711e
8031818: Experimental VM flag for enforcing safe object construction
shade
parents:
22872
diff
changeset
|
377 |
void set_wrote_stable(bool z) { _wrote_stable = z; } |
e8bbf9cd711e
8031818: Experimental VM flag for enforcing safe object construction
shade
parents:
22872
diff
changeset
|
378 |
bool wrote_fields() const { return _wrote_fields; } |
e8bbf9cd711e
8031818: Experimental VM flag for enforcing safe object construction
shade
parents:
22872
diff
changeset
|
379 |
void set_wrote_fields(bool z) { _wrote_fields = z; } |
1 | 380 |
bool count_invocations() const { return _count_invocations; } |
381 |
bool method_data_update() const { return _method_data_update; } |
|
17383 | 382 |
Node* alloc_with_final() const { return _alloc_with_final; } |
383 |
void set_alloc_with_final(Node* n) { |
|
384 |
assert((_alloc_with_final == NULL) || (_alloc_with_final == n), "different init objects?"); |
|
385 |
_alloc_with_final = n; |
|
386 |
} |
|
1 | 387 |
|
388 |
Block* block() const { return _block; } |
|
389 |
ciBytecodeStream& iter() { return _iter; } |
|
390 |
Bytecodes::Code bc() const { return _iter.cur_bc(); } |
|
391 |
||
392 |
void set_block(Block* b) { _block = b; } |
|
393 |
||
394 |
// Derived accessors: |
|
395 |
bool is_normal_parse() const { return _entry_bci == InvocationEntryBci; } |
|
396 |
bool is_osr_parse() const { return _entry_bci != InvocationEntryBci; } |
|
397 |
int osr_bci() const { assert(is_osr_parse(),""); return _entry_bci; } |
|
398 |
||
399 |
void set_parse_bci(int bci); |
|
400 |
||
401 |
// Must this parse be aborted? |
|
402 |
bool failing() { return C->failing(); } |
|
403 |
||
1399
9648dfd4ce09
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
956
diff
changeset
|
404 |
Block* rpo_at(int rpo) { |
9648dfd4ce09
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
956
diff
changeset
|
405 |
assert(0 <= rpo && rpo < _block_count, "oob"); |
9648dfd4ce09
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
956
diff
changeset
|
406 |
return &_blocks[rpo]; |
1 | 407 |
} |
408 |
Block* start_block() { |
|
1399
9648dfd4ce09
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
956
diff
changeset
|
409 |
return rpo_at(flow()->start_block()->rpo()); |
1 | 410 |
} |
411 |
// Can return NULL if the flow pass did not complete a block. |
|
412 |
Block* successor_for_bci(int bci) { |
|
413 |
return block()->successor_for_bci(bci); |
|
414 |
} |
|
415 |
||
416 |
private: |
|
417 |
// Create a JVMS & map for the initial state of this method. |
|
418 |
SafePointNode* create_entry_map(); |
|
419 |
||
420 |
// OSR helpers |
|
421 |
Node *fetch_interpreter_state(int index, BasicType bt, Node *local_addrs, Node *local_addrs_base); |
|
422 |
Node* check_interpreter_type(Node* l, const Type* type, SafePointNode* &bad_type_exit); |
|
423 |
void load_interpreter_state(Node* osr_buf); |
|
424 |
||
425 |
// Functions for managing basic blocks: |
|
426 |
void init_blocks(); |
|
427 |
void load_state_from(Block* b); |
|
428 |
void store_state_to(Block* b) { b->record_state(this); } |
|
429 |
||
430 |
// Parse all the basic blocks. |
|
431 |
void do_all_blocks(); |
|
432 |
||
433 |
// Parse the current basic block |
|
434 |
void do_one_block(); |
|
435 |
||
436 |
// Raise an error if we get a bad ciTypeFlow CFG. |
|
437 |
void handle_missing_successor(int bci); |
|
438 |
||
439 |
// first actions (before BCI 0) |
|
440 |
void do_method_entry(); |
|
441 |
||
442 |
// implementation of monitorenter/monitorexit |
|
443 |
void do_monitor_enter(); |
|
444 |
void do_monitor_exit(); |
|
445 |
||
446 |
// Eagerly create phie throughout the state, to cope with back edges. |
|
447 |
void ensure_phis_everywhere(); |
|
448 |
||
449 |
// Merge the current mapping into the basic block starting at bci |
|
450 |
void merge( int target_bci); |
|
451 |
// Same as plain merge, except that it allocates a new path number. |
|
452 |
void merge_new_path( int target_bci); |
|
453 |
// Merge the current mapping into an exception handler. |
|
454 |
void merge_exception(int target_bci); |
|
455 |
// Helper: Merge the current mapping into the given basic block |
|
456 |
void merge_common(Block* target, int pnum); |
|
457 |
// Helper functions for merging individual cells. |
|
458 |
PhiNode *ensure_phi( int idx, bool nocreate = false); |
|
459 |
PhiNode *ensure_memory_phi(int idx, bool nocreate = false); |
|
460 |
// Helper to merge the current memory state into the given basic block |
|
461 |
void merge_memory_edges(MergeMemNode* n, int pnum, bool nophi); |
|
462 |
||
463 |
// Parse this bytecode, and alter the Parsers JVM->Node mapping |
|
464 |
void do_one_bytecode(); |
|
465 |
||
466 |
// helper function to generate array store check |
|
467 |
void array_store_check(); |
|
468 |
// Helper function to generate array load |
|
469 |
void array_load(BasicType etype); |
|
470 |
// Helper function to generate array store |
|
471 |
void array_store(BasicType etype); |
|
472 |
// Helper function to compute array addressing |
|
473 |
Node* array_addressing(BasicType type, int vals, const Type* *result2=NULL); |
|
474 |
||
23491 | 475 |
void rtm_deopt(); |
476 |
||
1 | 477 |
// Pass current map to exits |
478 |
void return_current(Node* value); |
|
479 |
||
480 |
// Register finalizers on return from Object.<init> |
|
481 |
void call_register_finalizer(); |
|
482 |
||
483 |
// Insert a compiler safepoint into the graph |
|
484 |
void add_safepoint(); |
|
485 |
||
486 |
// Insert a compiler safepoint into the graph, if there is a back-branch. |
|
487 |
void maybe_add_safepoint(int target_bci) { |
|
488 |
if (UseLoopSafepoints && target_bci <= bci()) { |
|
489 |
add_safepoint(); |
|
490 |
} |
|
491 |
} |
|
492 |
||
493 |
// Note: Intrinsic generation routines may be found in library_call.cpp. |
|
494 |
||
495 |
// Helper function to setup Ideal Call nodes |
|
496 |
void do_call(); |
|
497 |
||
498 |
// Helper function to uncommon-trap or bailout for non-compilable call-sites |
|
499 |
bool can_not_compile_call_site(ciMethod *dest_method, ciInstanceKlass *klass); |
|
500 |
||
501 |
// Helper function to setup for type-profile based inlining |
|
502 |
bool prepare_type_profile_inline(ciInstanceKlass* prof_klass, ciMethod* prof_method); |
|
503 |
||
504 |
// Helper functions for type checking bytecodes: |
|
505 |
void do_checkcast(); |
|
506 |
void do_instanceof(); |
|
507 |
||
508 |
// Helper functions for shifting & arithmetic |
|
509 |
void modf(); |
|
510 |
void modd(); |
|
511 |
void l2f(); |
|
512 |
||
513 |
void do_irem(); |
|
514 |
||
515 |
// implementation of _get* and _put* bytecodes |
|
516 |
void do_getstatic() { do_field_access(true, false); } |
|
517 |
void do_getfield () { do_field_access(true, true); } |
|
518 |
void do_putstatic() { do_field_access(false, false); } |
|
519 |
void do_putfield () { do_field_access(false, true); } |
|
520 |
||
521 |
// common code for making initial checks and forming addresses |
|
522 |
void do_field_access(bool is_get, bool is_field); |
|
523 |
bool static_field_ok_in_clinit(ciField *field, ciMethod *method); |
|
524 |
||
525 |
// common code for actually performing the load or store |
|
8725
8c1e3dd5fe1b
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
7397
diff
changeset
|
526 |
void do_get_xxx(Node* obj, ciField* field, bool is_field); |
8c1e3dd5fe1b
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
7397
diff
changeset
|
527 |
void do_put_xxx(Node* obj, ciField* field, bool is_field); |
1 | 528 |
|
529 |
// implementation of object creation bytecodes |
|
5925
a30fef61d0b7
6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents:
5547
diff
changeset
|
530 |
void emit_guard_for_new(ciInstanceKlass* klass); |
1 | 531 |
void do_new(); |
532 |
void do_newarray(BasicType elemtype); |
|
533 |
void do_anewarray(); |
|
534 |
void do_multianewarray(); |
|
2574
1d5f85c2d755
6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
2131
diff
changeset
|
535 |
Node* expand_multianewarray(ciArrayKlass* array_klass, Node* *lengths, int ndimensions, int nargs); |
1 | 536 |
|
537 |
// implementation of jsr/ret |
|
538 |
void do_jsr(); |
|
539 |
void do_ret(); |
|
540 |
||
28912
27fac2f8fdbe
8063137: Never-taken branches should be pruned when GWT LambdaForms are shared
vlivanov
parents:
25640
diff
changeset
|
541 |
float dynamic_branch_prediction(float &cnt, BoolTest::mask btest, Node* test); |
27fac2f8fdbe
8063137: Never-taken branches should be pruned when GWT LambdaForms are shared
vlivanov
parents:
25640
diff
changeset
|
542 |
float branch_prediction(float &cnt, BoolTest::mask btest, int target_bci, Node* test); |
25496
a829ea1310b5
8046289: compiler/6340864/TestLongVect.java timeout with
rbackman
parents:
24946
diff
changeset
|
543 |
bool seems_never_taken(float prob) const; |
a829ea1310b5
8046289: compiler/6340864/TestLongVect.java timeout with
rbackman
parents:
24946
diff
changeset
|
544 |
bool path_is_suitable_for_uncommon_trap(float prob) const; |
a829ea1310b5
8046289: compiler/6340864/TestLongVect.java timeout with
rbackman
parents:
24946
diff
changeset
|
545 |
bool seems_stable_comparison() const; |
1 | 546 |
|
956
f1aadc829f59
6726504: handle do_ifxxx calls in parser more uniformly
rasbold
parents:
670
diff
changeset
|
547 |
void do_ifnull(BoolTest::mask btest, Node* c); |
1 | 548 |
void do_if(BoolTest::mask btest, Node* c); |
4643 | 549 |
int repush_if_args(); |
1 | 550 |
void adjust_map_after_if(BoolTest::mask btest, Node* c, float prob, |
551 |
Block* path, Block* other_path); |
|
12945
e63d6176cbd1
7170463: C2 should recognize "obj.getClass() == A.class" code pattern
kvn
parents:
10547
diff
changeset
|
552 |
void sharpen_type_after_if(BoolTest::mask btest, |
e63d6176cbd1
7170463: C2 should recognize "obj.getClass() == A.class" code pattern
kvn
parents:
10547
diff
changeset
|
553 |
Node* con, const Type* tcon, |
e63d6176cbd1
7170463: C2 should recognize "obj.getClass() == A.class" code pattern
kvn
parents:
10547
diff
changeset
|
554 |
Node* val, const Type* tval); |
1 | 555 |
IfNode* jump_if_fork_int(Node* a, Node* b, BoolTest::mask mask); |
556 |
Node* jump_if_join(Node* iffalse, Node* iftrue); |
|
557 |
void jump_if_true_fork(IfNode *ifNode, int dest_bci_if_true, int prof_table_index); |
|
558 |
void jump_if_false_fork(IfNode *ifNode, int dest_bci_if_false, int prof_table_index); |
|
559 |
void jump_if_always_fork(int dest_bci_if_true, int prof_table_index); |
|
560 |
||
561 |
friend class SwitchRange; |
|
562 |
void do_tableswitch(); |
|
563 |
void do_lookupswitch(); |
|
564 |
void jump_switch_ranges(Node* a, SwitchRange* lo, SwitchRange* hi, int depth = 0); |
|
565 |
bool create_jump_tables(Node* a, SwitchRange* lo, SwitchRange* hi); |
|
566 |
||
24442
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
23491
diff
changeset
|
567 |
void decrement_age(); |
1 | 568 |
// helper functions for methodData style profiling |
569 |
void test_counter_against_threshold(Node* cnt, int limit); |
|
570 |
void increment_and_test_invocation_counter(int limit); |
|
571 |
void test_for_osr_md_counter_at(ciMethodData* md, ciProfileData* data, ByteSize offset, int limit); |
|
572 |
Node* method_data_addressing(ciMethodData* md, ciProfileData* data, ByteSize offset, Node* idx = NULL, uint stride = 0); |
|
573 |
void increment_md_counter_at(ciMethodData* md, ciProfileData* data, ByteSize offset, Node* idx = NULL, uint stride = 0); |
|
574 |
void set_md_flag_at(ciMethodData* md, ciProfileData* data, int flag_constant); |
|
575 |
||
576 |
void profile_method_entry(); |
|
577 |
void profile_taken_branch(int target_bci, bool force_update = false); |
|
578 |
void profile_not_taken_branch(bool force_update = false); |
|
579 |
void profile_call(Node* receiver); |
|
580 |
void profile_generic_call(); |
|
581 |
void profile_receiver_type(Node* receiver); |
|
582 |
void profile_ret(int target_bci); |
|
583 |
void profile_null_checkcast(); |
|
584 |
void profile_switch_case(int table_index); |
|
585 |
||
586 |
// helper function for call statistics |
|
587 |
void count_compiled_calls(bool at_method_entry, bool is_inline) PRODUCT_RETURN; |
|
588 |
||
589 |
Node_Notes* make_node_notes(Node_Notes* caller_nn); |
|
590 |
||
591 |
// Helper functions for handling normal and abnormal exits. |
|
592 |
void build_exits(); |
|
593 |
||
594 |
// Fix up all exceptional control flow exiting a single bytecode. |
|
595 |
void do_exceptions(); |
|
596 |
||
597 |
// Fix up all exiting control flow at the end of the parse. |
|
598 |
void do_exits(); |
|
599 |
||
600 |
// Add Catch/CatchProjs |
|
601 |
// The call is either a Java call or the VM's rethrow stub |
|
602 |
void catch_call_exceptions(ciExceptionHandlerStream&); |
|
603 |
||
604 |
// Handle all exceptions thrown by the inlined method. |
|
605 |
// Also handles exceptions for individual bytecodes. |
|
606 |
void catch_inline_exceptions(SafePointNode* ex_map); |
|
607 |
||
608 |
// Merge the given map into correct exceptional exit state. |
|
609 |
// Assumes that there is no applicable local handler. |
|
610 |
void throw_to_exit(SafePointNode* ex_map); |
|
611 |
||
21099 | 612 |
// Use speculative type to optimize CmpP node |
613 |
Node* optimize_cmp_with_klass(Node* c); |
|
614 |
||
1 | 615 |
public: |
616 |
#ifndef PRODUCT |
|
617 |
// Handle PrintOpto, etc. |
|
618 |
void show_parse_info(); |
|
619 |
void dump_map_adr_mem() const; |
|
620 |
static void print_statistics(); // Print some performance counters |
|
621 |
void dump(); |
|
622 |
void dump_bci(int bci); |
|
623 |
#endif |
|
624 |
}; |
|
7397 | 625 |
|
626 |
#endif // SHARE_VM_OPTO_PARSE_HPP |