annotate src/share/vm/opto/parse.hpp @ 6972:bd7a7ce2e264

6830717: replay of compilations would help with debugging Summary: When java process crashed in compiler thread, repeat the compilation process will help finding root cause. This is done with using SA dump application class data and replay data from core dump, then use debug version of jvm to recompile the problematic java method. Reviewed-by: kvn, twisti, sspitsyn Contributed-by: yumin.qi@oracle.com
author minqi
date Mon, 12 Nov 2012 14:03:53 -0800
parents b9a9ed0f8eeb
children d092d1b31229
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
6842
b9a9ed0f8eeb 7197424: update copyright year to match last edit in jdk8 hotspot repository
mikael
parents: 6266
diff changeset
2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1344
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1344
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: 1344
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1746
diff changeset
25 #ifndef SHARE_VM_OPTO_PARSE_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1746
diff changeset
26 #define SHARE_VM_OPTO_PARSE_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1746
diff changeset
27
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1746
diff changeset
28 #include "ci/ciMethodData.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1746
diff changeset
29 #include "ci/ciTypeFlow.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1746
diff changeset
30 #include "compiler/methodLiveness.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1746
diff changeset
31 #include "libadt/vectset.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1746
diff changeset
32 #include "oops/generateOopMap.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1746
diff changeset
33 #include "opto/graphKit.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1746
diff changeset
34 #include "opto/subnode.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1746
diff changeset
35
0
a61af66fc99e Initial load
duke
parents:
diff changeset
36 class BytecodeParseHistogram;
a61af66fc99e Initial load
duke
parents:
diff changeset
37 class InlineTree;
a61af66fc99e Initial load
duke
parents:
diff changeset
38 class Parse;
a61af66fc99e Initial load
duke
parents:
diff changeset
39 class SwitchRange;
a61af66fc99e Initial load
duke
parents:
diff changeset
40
a61af66fc99e Initial load
duke
parents:
diff changeset
41
a61af66fc99e Initial load
duke
parents:
diff changeset
42 //------------------------------InlineTree-------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
43 class InlineTree : public ResourceObj {
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3900
diff changeset
44 friend class VMStructs;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3900
diff changeset
45
0
a61af66fc99e Initial load
duke
parents:
diff changeset
46 Compile* C; // cache
a61af66fc99e Initial load
duke
parents:
diff changeset
47 JVMState* _caller_jvms; // state of caller
a61af66fc99e Initial load
duke
parents:
diff changeset
48 ciMethod* _method; // method being called by the caller_jvms
a61af66fc99e Initial load
duke
parents:
diff changeset
49 InlineTree* _caller_tree;
a61af66fc99e Initial load
duke
parents:
diff changeset
50 uint _count_inline_bcs; // Accumulated count of inlined bytecodes
a61af66fc99e Initial load
duke
parents:
diff changeset
51 // Call-site count / interpreter invocation count, scaled recursively.
a61af66fc99e Initial load
duke
parents:
diff changeset
52 // Always between 0.0 and 1.0. Represents the percentage of the method's
a61af66fc99e Initial load
duke
parents:
diff changeset
53 // total execution time used at this call site.
a61af66fc99e Initial load
duke
parents:
diff changeset
54 const float _site_invoke_ratio;
3784
aabf25fa3f05 7057587: JSR 292 - crash with jruby in test/test_respond_to.rb
never
parents: 3366
diff changeset
55 const int _max_inline_level; // the maximum inline level for this sub-tree (may be adjusted)
0
a61af66fc99e Initial load
duke
parents:
diff changeset
56 float compute_callee_frequency( int caller_bci ) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
57
a61af66fc99e Initial load
duke
parents:
diff changeset
58 GrowableArray<InlineTree*> _subtrees;
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3900
diff changeset
59
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3900
diff changeset
60 void print_impl(outputStream* stj, int indent) const PRODUCT_RETURN;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
61
a61af66fc99e Initial load
duke
parents:
diff changeset
62 protected:
a61af66fc99e Initial load
duke
parents:
diff changeset
63 InlineTree(Compile* C,
a61af66fc99e Initial load
duke
parents:
diff changeset
64 const InlineTree* caller_tree,
a61af66fc99e Initial load
duke
parents:
diff changeset
65 ciMethod* callee_method,
a61af66fc99e Initial load
duke
parents:
diff changeset
66 JVMState* caller_jvms,
a61af66fc99e Initial load
duke
parents:
diff changeset
67 int caller_bci,
1157
c3b315a0d58a 6912063: inlining parameters need to be adjusted for some uses of the JVM
jrose
parents: 989
diff changeset
68 float site_invoke_ratio,
3784
aabf25fa3f05 7057587: JSR 292 - crash with jruby in test/test_respond_to.rb
never
parents: 3366
diff changeset
69 int max_inline_level);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
70 InlineTree *build_inline_tree_for_callee(ciMethod* callee_method,
a61af66fc99e Initial load
duke
parents:
diff changeset
71 JVMState* caller_jvms,
a61af66fc99e Initial load
duke
parents:
diff changeset
72 int caller_bci);
41
874b2c4f43d1 6667605: (Escape Analysis) inline java constructors when EA is on
kvn
parents: 0
diff changeset
73 const char* try_to_inline(ciMethod* callee_method, ciMethod* caller_method, int caller_bci, ciCallProfile& profile, WarmCallInfo* wci_result);
3366
e2a92dd0d3d2 7042122: JSR 292: adjust various inline thresholds for JSR 292 API methods and method handle adapters
twisti
parents: 3345
diff changeset
74 const char* should_inline(ciMethod* callee_method, ciMethod* caller_method, int caller_bci, ciCallProfile& profile, WarmCallInfo* wci_result) const;
e2a92dd0d3d2 7042122: JSR 292: adjust various inline thresholds for JSR 292 API methods and method handle adapters
twisti
parents: 3345
diff changeset
75 const char* should_not_inline(ciMethod* callee_method, ciMethod* caller_method, WarmCallInfo* wci_result) const;
3345
bad7ecd0b6ed 5091921: Sign flip issues in loop optimizer
kvn
parents: 2385
diff changeset
76 void print_inlining(ciMethod *callee_method, int caller_bci, const char *failure_msg) const;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
77
a61af66fc99e Initial load
duke
parents:
diff changeset
78 InlineTree *caller_tree() const { return _caller_tree; }
a61af66fc99e Initial load
duke
parents:
diff changeset
79 InlineTree* callee_at(int bci, ciMethod* m) const;
3784
aabf25fa3f05 7057587: JSR 292 - crash with jruby in test/test_respond_to.rb
never
parents: 3366
diff changeset
80 int inline_level() const { return stack_depth(); }
1157
c3b315a0d58a 6912063: inlining parameters need to be adjusted for some uses of the JVM
jrose
parents: 989
diff changeset
81 int stack_depth() const { return _caller_jvms ? _caller_jvms->depth() : 0; }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
82
a61af66fc99e Initial load
duke
parents:
diff changeset
83 public:
3900
a32de5085326 7079673: JSR 292: C1 should inline bytecoded method handle adapters
twisti
parents: 3784
diff changeset
84 static const char* check_can_parse(ciMethod* callee);
a32de5085326 7079673: JSR 292: C1 should inline bytecoded method handle adapters
twisti
parents: 3784
diff changeset
85
0
a61af66fc99e Initial load
duke
parents:
diff changeset
86 static InlineTree* build_inline_tree_root();
6266
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 6131
diff changeset
87 static InlineTree* find_subtree_from_root(InlineTree* root, JVMState* jvms, ciMethod* callee);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
88
a61af66fc99e Initial load
duke
parents:
diff changeset
89 // For temporary (stack-allocated, stateless) ilts:
3784
aabf25fa3f05 7057587: JSR 292 - crash with jruby in test/test_respond_to.rb
never
parents: 3366
diff changeset
90 InlineTree(Compile* c, ciMethod* callee_method, JVMState* caller_jvms, float site_invoke_ratio, int max_inline_level);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
91
a61af66fc99e Initial load
duke
parents:
diff changeset
92 // InlineTree enum
a61af66fc99e Initial load
duke
parents:
diff changeset
93 enum InlineStyle {
a61af66fc99e Initial load
duke
parents:
diff changeset
94 Inline_do_not_inline = 0, //
a61af66fc99e Initial load
duke
parents:
diff changeset
95 Inline_cha_is_monomorphic = 1, //
a61af66fc99e Initial load
duke
parents:
diff changeset
96 Inline_type_profile_monomorphic = 2 //
a61af66fc99e Initial load
duke
parents:
diff changeset
97 };
a61af66fc99e Initial load
duke
parents:
diff changeset
98
a61af66fc99e Initial load
duke
parents:
diff changeset
99 // See if it is OK to inline.
605
98cb887364d3 6810672: Comment typos
twisti
parents: 435
diff changeset
100 // The receiver is the inline tree for the caller.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
101 //
a61af66fc99e Initial load
duke
parents:
diff changeset
102 // The result is a temperature indication. If it is hot or cold,
a61af66fc99e Initial load
duke
parents:
diff changeset
103 // inlining is immediate or undesirable. Otherwise, the info block
a61af66fc99e Initial load
duke
parents:
diff changeset
104 // returned is newly allocated and may be enqueued.
a61af66fc99e Initial load
duke
parents:
diff changeset
105 //
a61af66fc99e Initial load
duke
parents:
diff changeset
106 // If the method is inlinable, a new inline subtree is created on the fly,
a61af66fc99e Initial load
duke
parents:
diff changeset
107 // and may be accessed by find_subtree_from_root.
a61af66fc99e Initial load
duke
parents:
diff changeset
108 // The call_method is the dest_method for a special or static invocation.
a61af66fc99e Initial load
duke
parents:
diff changeset
109 // The call_method is an optimized virtual method candidate otherwise.
a61af66fc99e Initial load
duke
parents:
diff changeset
110 WarmCallInfo* ok_to_inline(ciMethod *call_method, JVMState* caller_jvms, ciCallProfile& profile, WarmCallInfo* wci);
a61af66fc99e Initial load
duke
parents:
diff changeset
111
a61af66fc99e Initial load
duke
parents:
diff changeset
112 // Information about inlined method
a61af66fc99e Initial load
duke
parents:
diff changeset
113 JVMState* caller_jvms() const { return _caller_jvms; }
a61af66fc99e Initial load
duke
parents:
diff changeset
114 ciMethod *method() const { return _method; }
a61af66fc99e Initial load
duke
parents:
diff changeset
115 int caller_bci() const { return _caller_jvms ? _caller_jvms->bci() : InvocationEntryBci; }
a61af66fc99e Initial load
duke
parents:
diff changeset
116 uint count_inline_bcs() const { return _count_inline_bcs; }
a61af66fc99e Initial load
duke
parents:
diff changeset
117 float site_invoke_ratio() const { return _site_invoke_ratio; };
a61af66fc99e Initial load
duke
parents:
diff changeset
118
a61af66fc99e Initial load
duke
parents:
diff changeset
119 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
120 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
121 uint _count_inlines; // Count of inlined methods
a61af66fc99e Initial load
duke
parents:
diff changeset
122 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
123 // Debug information collected during parse
a61af66fc99e Initial load
duke
parents:
diff changeset
124 uint count_inlines() const { return _count_inlines; };
a61af66fc99e Initial load
duke
parents:
diff changeset
125 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
126 GrowableArray<InlineTree*> subtrees() { return _subtrees; }
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3900
diff changeset
127
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3900
diff changeset
128 void print_value_on(outputStream* st) const PRODUCT_RETURN;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
129 };
a61af66fc99e Initial load
duke
parents:
diff changeset
130
a61af66fc99e Initial load
duke
parents:
diff changeset
131
a61af66fc99e Initial load
duke
parents:
diff changeset
132 //-----------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
133 //------------------------------Parse------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
134 // Parse bytecodes, build a Graph
a61af66fc99e Initial load
duke
parents:
diff changeset
135 class Parse : public GraphKit {
a61af66fc99e Initial load
duke
parents:
diff changeset
136 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
137 // Per-block information needed by the parser:
a61af66fc99e Initial load
duke
parents:
diff changeset
138 class Block {
a61af66fc99e Initial load
duke
parents:
diff changeset
139 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
140 ciTypeFlow::Block* _flow;
a61af66fc99e Initial load
duke
parents:
diff changeset
141 int _pred_count; // how many predecessors in CFG?
a61af66fc99e Initial load
duke
parents:
diff changeset
142 int _preds_parsed; // how many of these have been parsed?
a61af66fc99e Initial load
duke
parents:
diff changeset
143 uint _count; // how many times executed? Currently only set by _goto's
a61af66fc99e Initial load
duke
parents:
diff changeset
144 bool _is_parsed; // has this block been parsed yet?
a61af66fc99e Initial load
duke
parents:
diff changeset
145 bool _is_handler; // is this block an exception handler?
2383
9dc311b8473e 7008866: Missing loop predicate for loop with multiple entries
kvn
parents: 1972
diff changeset
146 bool _has_merged_backedge; // does this block have merged backedge?
0
a61af66fc99e Initial load
duke
parents:
diff changeset
147 SafePointNode* _start_map; // all values flowing into this block
a61af66fc99e Initial load
duke
parents:
diff changeset
148 MethodLivenessResult _live_locals; // lazily initialized liveness bitmap
a61af66fc99e Initial load
duke
parents:
diff changeset
149
a61af66fc99e Initial load
duke
parents:
diff changeset
150 int _num_successors; // Includes only normal control flow.
a61af66fc99e Initial load
duke
parents:
diff changeset
151 int _all_successors; // Include exception paths also.
a61af66fc99e Initial load
duke
parents:
diff changeset
152 Block** _successors;
a61af66fc99e Initial load
duke
parents:
diff changeset
153
a61af66fc99e Initial load
duke
parents:
diff changeset
154 // Use init_node/init_graph to initialize Blocks.
a61af66fc99e Initial load
duke
parents:
diff changeset
155 // Block() : _live_locals((uintptr_t*)NULL,0) { ShouldNotReachHere(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
156 Block() : _live_locals(NULL,0) { ShouldNotReachHere(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
157
a61af66fc99e Initial load
duke
parents:
diff changeset
158 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
159
a61af66fc99e Initial load
duke
parents:
diff changeset
160 // Set up the block data structure itself.
a61af66fc99e Initial load
duke
parents:
diff changeset
161 void init_node(Parse* outer, int po);
a61af66fc99e Initial load
duke
parents:
diff changeset
162 // Set up the block's relations to other blocks.
a61af66fc99e Initial load
duke
parents:
diff changeset
163 void init_graph(Parse* outer);
a61af66fc99e Initial load
duke
parents:
diff changeset
164
a61af66fc99e Initial load
duke
parents:
diff changeset
165 ciTypeFlow::Block* flow() const { return _flow; }
a61af66fc99e Initial load
duke
parents:
diff changeset
166 int pred_count() const { return _pred_count; }
a61af66fc99e Initial load
duke
parents:
diff changeset
167 int preds_parsed() const { return _preds_parsed; }
a61af66fc99e Initial load
duke
parents:
diff changeset
168 bool is_parsed() const { return _is_parsed; }
a61af66fc99e Initial load
duke
parents:
diff changeset
169 bool is_handler() const { return _is_handler; }
a61af66fc99e Initial load
duke
parents:
diff changeset
170 void set_count( uint x ) { _count = x; }
a61af66fc99e Initial load
duke
parents:
diff changeset
171 uint count() const { return _count; }
a61af66fc99e Initial load
duke
parents:
diff changeset
172
a61af66fc99e Initial load
duke
parents:
diff changeset
173 SafePointNode* start_map() const { assert(is_merged(),""); return _start_map; }
a61af66fc99e Initial load
duke
parents:
diff changeset
174 void set_start_map(SafePointNode* m) { assert(!is_merged(), ""); _start_map = m; }
a61af66fc99e Initial load
duke
parents:
diff changeset
175
a61af66fc99e Initial load
duke
parents:
diff changeset
176 // True after any predecessor flows control into this block
a61af66fc99e Initial load
duke
parents:
diff changeset
177 bool is_merged() const { return _start_map != NULL; }
a61af66fc99e Initial load
duke
parents:
diff changeset
178
2383
9dc311b8473e 7008866: Missing loop predicate for loop with multiple entries
kvn
parents: 1972
diff changeset
179 #ifdef ASSERT
9dc311b8473e 7008866: Missing loop predicate for loop with multiple entries
kvn
parents: 1972
diff changeset
180 // True after backedge predecessor flows control into this block
9dc311b8473e 7008866: Missing loop predicate for loop with multiple entries
kvn
parents: 1972
diff changeset
181 bool has_merged_backedge() const { return _has_merged_backedge; }
9dc311b8473e 7008866: Missing loop predicate for loop with multiple entries
kvn
parents: 1972
diff changeset
182 void mark_merged_backedge(Block* pred) {
9dc311b8473e 7008866: Missing loop predicate for loop with multiple entries
kvn
parents: 1972
diff changeset
183 assert(is_SEL_head(), "should be loop head");
9dc311b8473e 7008866: Missing loop predicate for loop with multiple entries
kvn
parents: 1972
diff changeset
184 if (pred != NULL && is_SEL_backedge(pred)) {
9dc311b8473e 7008866: Missing loop predicate for loop with multiple entries
kvn
parents: 1972
diff changeset
185 assert(is_parsed(), "block should be parsed before merging backedges");
9dc311b8473e 7008866: Missing loop predicate for loop with multiple entries
kvn
parents: 1972
diff changeset
186 _has_merged_backedge = true;
9dc311b8473e 7008866: Missing loop predicate for loop with multiple entries
kvn
parents: 1972
diff changeset
187 }
9dc311b8473e 7008866: Missing loop predicate for loop with multiple entries
kvn
parents: 1972
diff changeset
188 }
9dc311b8473e 7008866: Missing loop predicate for loop with multiple entries
kvn
parents: 1972
diff changeset
189 #endif
9dc311b8473e 7008866: Missing loop predicate for loop with multiple entries
kvn
parents: 1972
diff changeset
190
0
a61af66fc99e Initial load
duke
parents:
diff changeset
191 // True when all non-exception predecessors have been parsed.
a61af66fc99e Initial load
duke
parents:
diff changeset
192 bool is_ready() const { return preds_parsed() == pred_count(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
193
a61af66fc99e Initial load
duke
parents:
diff changeset
194 int num_successors() const { return _num_successors; }
a61af66fc99e Initial load
duke
parents:
diff changeset
195 int all_successors() const { return _all_successors; }
a61af66fc99e Initial load
duke
parents:
diff changeset
196 Block* successor_at(int i) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
197 assert((uint)i < (uint)all_successors(), "");
a61af66fc99e Initial load
duke
parents:
diff changeset
198 return _successors[i];
a61af66fc99e Initial load
duke
parents:
diff changeset
199 }
a61af66fc99e Initial load
duke
parents:
diff changeset
200 Block* successor_for_bci(int bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
201
a61af66fc99e Initial load
duke
parents:
diff changeset
202 int start() const { return flow()->start(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
203 int limit() const { return flow()->limit(); }
367
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 248
diff changeset
204 int rpo() const { return flow()->rpo(); }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
205 int start_sp() const { return flow()->stack_size(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
206
367
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 248
diff changeset
207 bool is_loop_head() const { return flow()->is_loop_head(); }
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 248
diff changeset
208 bool is_SEL_head() const { return flow()->is_single_entry_loop_head(); }
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 248
diff changeset
209 bool is_SEL_backedge(Block* pred) const{ return is_SEL_head() && pred->rpo() >= rpo(); }
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 248
diff changeset
210 bool is_invariant_local(uint i) const {
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 248
diff changeset
211 const JVMState* jvms = start_map()->jvms();
435
b1d6a3e95810 6766316: assert(!nocreate,"Cannot build a phi for a block already parsed.")
kvn
parents: 367
diff changeset
212 if (!jvms->is_loc(i) || flow()->outer()->has_irreducible_entry()) return false;
367
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 248
diff changeset
213 return flow()->is_invariant_local(i - jvms->locoff());
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 248
diff changeset
214 }
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 248
diff changeset
215 bool can_elide_SEL_phi(uint i) const { assert(is_SEL_head(),""); return is_invariant_local(i); }
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 248
diff changeset
216
0
a61af66fc99e Initial load
duke
parents:
diff changeset
217 const Type* peek(int off=0) const { return stack_type_at(start_sp() - (off+1)); }
a61af66fc99e Initial load
duke
parents:
diff changeset
218
a61af66fc99e Initial load
duke
parents:
diff changeset
219 const Type* stack_type_at(int i) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
220 const Type* local_type_at(int i) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
221 static const Type* get_type(ciType* t) { return Type::get_typeflow_type(t); }
a61af66fc99e Initial load
duke
parents:
diff changeset
222
a61af66fc99e Initial load
duke
parents:
diff changeset
223 bool has_trap_at(int bci) const { return flow()->has_trap() && flow()->trap_bci() == bci; }
a61af66fc99e Initial load
duke
parents:
diff changeset
224
a61af66fc99e Initial load
duke
parents:
diff changeset
225 // Call this just before parsing a block.
a61af66fc99e Initial load
duke
parents:
diff changeset
226 void mark_parsed() {
a61af66fc99e Initial load
duke
parents:
diff changeset
227 assert(!_is_parsed, "must parse each block exactly once");
a61af66fc99e Initial load
duke
parents:
diff changeset
228 _is_parsed = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
229 }
a61af66fc99e Initial load
duke
parents:
diff changeset
230
a61af66fc99e Initial load
duke
parents:
diff changeset
231 // Return the phi/region input index for the "current" pred,
a61af66fc99e Initial load
duke
parents:
diff changeset
232 // and bump the pred number. For historical reasons these index
a61af66fc99e Initial load
duke
parents:
diff changeset
233 // numbers are handed out in descending order. The last index is
a61af66fc99e Initial load
duke
parents:
diff changeset
234 // always PhiNode::Input (i.e., 1). The value returned is known
a61af66fc99e Initial load
duke
parents:
diff changeset
235 // as a "path number" because it distinguishes by which path we are
a61af66fc99e Initial load
duke
parents:
diff changeset
236 // entering the block.
a61af66fc99e Initial load
duke
parents:
diff changeset
237 int next_path_num() {
a61af66fc99e Initial load
duke
parents:
diff changeset
238 assert(preds_parsed() < pred_count(), "too many preds?");
a61af66fc99e Initial load
duke
parents:
diff changeset
239 return pred_count() - _preds_parsed++;
a61af66fc99e Initial load
duke
parents:
diff changeset
240 }
a61af66fc99e Initial load
duke
parents:
diff changeset
241
a61af66fc99e Initial load
duke
parents:
diff changeset
242 // Add a previously unaccounted predecessor to this block.
a61af66fc99e Initial load
duke
parents:
diff changeset
243 // This operates by increasing the size of the block's region
a61af66fc99e Initial load
duke
parents:
diff changeset
244 // and all its phi nodes (if any). The value returned is a
a61af66fc99e Initial load
duke
parents:
diff changeset
245 // path number ("pnum").
a61af66fc99e Initial load
duke
parents:
diff changeset
246 int add_new_path();
a61af66fc99e Initial load
duke
parents:
diff changeset
247
a61af66fc99e Initial load
duke
parents:
diff changeset
248 // Initialize me by recording the parser's map. My own map must be NULL.
a61af66fc99e Initial load
duke
parents:
diff changeset
249 void record_state(Parse* outer);
a61af66fc99e Initial load
duke
parents:
diff changeset
250 };
a61af66fc99e Initial load
duke
parents:
diff changeset
251
a61af66fc99e Initial load
duke
parents:
diff changeset
252 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
253 // BytecodeParseHistogram collects number of bytecodes parsed, nodes constructed, and transformations.
a61af66fc99e Initial load
duke
parents:
diff changeset
254 class BytecodeParseHistogram : public ResourceObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
255 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
256 enum BPHType {
a61af66fc99e Initial load
duke
parents:
diff changeset
257 BPH_transforms,
a61af66fc99e Initial load
duke
parents:
diff changeset
258 BPH_values
a61af66fc99e Initial load
duke
parents:
diff changeset
259 };
a61af66fc99e Initial load
duke
parents:
diff changeset
260 static bool _initialized;
a61af66fc99e Initial load
duke
parents:
diff changeset
261 static uint _bytecodes_parsed [Bytecodes::number_of_codes];
a61af66fc99e Initial load
duke
parents:
diff changeset
262 static uint _nodes_constructed[Bytecodes::number_of_codes];
a61af66fc99e Initial load
duke
parents:
diff changeset
263 static uint _nodes_transformed[Bytecodes::number_of_codes];
a61af66fc99e Initial load
duke
parents:
diff changeset
264 static uint _new_values [Bytecodes::number_of_codes];
a61af66fc99e Initial load
duke
parents:
diff changeset
265
a61af66fc99e Initial load
duke
parents:
diff changeset
266 Bytecodes::Code _initial_bytecode;
a61af66fc99e Initial load
duke
parents:
diff changeset
267 int _initial_node_count;
a61af66fc99e Initial load
duke
parents:
diff changeset
268 int _initial_transforms;
a61af66fc99e Initial load
duke
parents:
diff changeset
269 int _initial_values;
a61af66fc99e Initial load
duke
parents:
diff changeset
270
a61af66fc99e Initial load
duke
parents:
diff changeset
271 Parse *_parser;
a61af66fc99e Initial load
duke
parents:
diff changeset
272 Compile *_compiler;
a61af66fc99e Initial load
duke
parents:
diff changeset
273
a61af66fc99e Initial load
duke
parents:
diff changeset
274 // Initialization
a61af66fc99e Initial load
duke
parents:
diff changeset
275 static void reset();
a61af66fc99e Initial load
duke
parents:
diff changeset
276
a61af66fc99e Initial load
duke
parents:
diff changeset
277 // Return info being collected, select with global flag 'BytecodeParseInfo'
a61af66fc99e Initial load
duke
parents:
diff changeset
278 int current_count(BPHType info_selector);
a61af66fc99e Initial load
duke
parents:
diff changeset
279
a61af66fc99e Initial load
duke
parents:
diff changeset
280 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
281 BytecodeParseHistogram(Parse *p, Compile *c);
a61af66fc99e Initial load
duke
parents:
diff changeset
282 static bool initialized();
a61af66fc99e Initial load
duke
parents:
diff changeset
283
a61af66fc99e Initial load
duke
parents:
diff changeset
284 // Record info when starting to parse one bytecode
a61af66fc99e Initial load
duke
parents:
diff changeset
285 void set_initial_state( Bytecodes::Code bc );
a61af66fc99e Initial load
duke
parents:
diff changeset
286 // Record results of parsing one bytecode
a61af66fc99e Initial load
duke
parents:
diff changeset
287 void record_change();
a61af66fc99e Initial load
duke
parents:
diff changeset
288
a61af66fc99e Initial load
duke
parents:
diff changeset
289 // Profile printing
a61af66fc99e Initial load
duke
parents:
diff changeset
290 static void print(float cutoff = 0.01F); // cutoff in percent
a61af66fc99e Initial load
duke
parents:
diff changeset
291 };
a61af66fc99e Initial load
duke
parents:
diff changeset
292
a61af66fc99e Initial load
duke
parents:
diff changeset
293 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
294 // Record work done during parsing
a61af66fc99e Initial load
duke
parents:
diff changeset
295 BytecodeParseHistogram* _parse_histogram;
a61af66fc99e Initial load
duke
parents:
diff changeset
296 void set_parse_histogram(BytecodeParseHistogram *bph) { _parse_histogram = bph; }
a61af66fc99e Initial load
duke
parents:
diff changeset
297 BytecodeParseHistogram* parse_histogram() { return _parse_histogram; }
a61af66fc99e Initial load
duke
parents:
diff changeset
298 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
299
a61af66fc99e Initial load
duke
parents:
diff changeset
300 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
301 friend class Block;
a61af66fc99e Initial load
duke
parents:
diff changeset
302
a61af66fc99e Initial load
duke
parents:
diff changeset
303 // Variables which characterize this compilation as a whole:
a61af66fc99e Initial load
duke
parents:
diff changeset
304
a61af66fc99e Initial load
duke
parents:
diff changeset
305 JVMState* _caller; // JVMS which carries incoming args & state.
a61af66fc99e Initial load
duke
parents:
diff changeset
306 float _expected_uses; // expected number of calls to this code
a61af66fc99e Initial load
duke
parents:
diff changeset
307 float _prof_factor; // discount applied to my profile counts
a61af66fc99e Initial load
duke
parents:
diff changeset
308 int _depth; // Inline tree depth, for debug printouts
a61af66fc99e Initial load
duke
parents:
diff changeset
309 const TypeFunc*_tf; // My kind of function type
a61af66fc99e Initial load
duke
parents:
diff changeset
310 int _entry_bci; // the osr bci or InvocationEntryBci
a61af66fc99e Initial load
duke
parents:
diff changeset
311
a61af66fc99e Initial load
duke
parents:
diff changeset
312 ciTypeFlow* _flow; // Results of previous flow pass.
a61af66fc99e Initial load
duke
parents:
diff changeset
313 Block* _blocks; // Array of basic-block structs.
a61af66fc99e Initial load
duke
parents:
diff changeset
314 int _block_count; // Number of elements in _blocks.
a61af66fc99e Initial load
duke
parents:
diff changeset
315
a61af66fc99e Initial load
duke
parents:
diff changeset
316 GraphKit _exits; // Record all normal returns and throws here.
a61af66fc99e Initial load
duke
parents:
diff changeset
317 bool _wrote_final; // Did we write a final field?
a61af66fc99e Initial load
duke
parents:
diff changeset
318 bool _count_invocations; // update and test invocation counter
a61af66fc99e Initial load
duke
parents:
diff changeset
319 bool _method_data_update; // update method data oop
a61af66fc99e Initial load
duke
parents:
diff changeset
320
a61af66fc99e Initial load
duke
parents:
diff changeset
321 // Variables which track Java semantics during bytecode parsing:
a61af66fc99e Initial load
duke
parents:
diff changeset
322
a61af66fc99e Initial load
duke
parents:
diff changeset
323 Block* _block; // block currently getting parsed
a61af66fc99e Initial load
duke
parents:
diff changeset
324 ciBytecodeStream _iter; // stream of this method's bytecodes
a61af66fc99e Initial load
duke
parents:
diff changeset
325
a61af66fc99e Initial load
duke
parents:
diff changeset
326 int _blocks_merged; // Progress meter: state merges from BB preds
a61af66fc99e Initial load
duke
parents:
diff changeset
327 int _blocks_parsed; // Progress meter: BBs actually parsed
a61af66fc99e Initial load
duke
parents:
diff changeset
328
a61af66fc99e Initial load
duke
parents:
diff changeset
329 const FastLockNode* _synch_lock; // FastLockNode for synchronized method
a61af66fc99e Initial load
duke
parents:
diff changeset
330
a61af66fc99e Initial load
duke
parents:
diff changeset
331 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
332 int _max_switch_depth; // Debugging SwitchRanges.
a61af66fc99e Initial load
duke
parents:
diff changeset
333 int _est_switch_depth; // Debugging SwitchRanges.
a61af66fc99e Initial load
duke
parents:
diff changeset
334 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
335
a61af66fc99e Initial load
duke
parents:
diff changeset
336 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
337 // Constructor
a61af66fc99e Initial load
duke
parents:
diff changeset
338 Parse(JVMState* caller, ciMethod* parse_method, float expected_uses);
a61af66fc99e Initial load
duke
parents:
diff changeset
339
a61af66fc99e Initial load
duke
parents:
diff changeset
340 virtual Parse* is_Parse() const { return (Parse*)this; }
a61af66fc99e Initial load
duke
parents:
diff changeset
341
a61af66fc99e Initial load
duke
parents:
diff changeset
342 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
343 // Accessors.
a61af66fc99e Initial load
duke
parents:
diff changeset
344 JVMState* caller() const { return _caller; }
a61af66fc99e Initial load
duke
parents:
diff changeset
345 float expected_uses() const { return _expected_uses; }
a61af66fc99e Initial load
duke
parents:
diff changeset
346 float prof_factor() const { return _prof_factor; }
a61af66fc99e Initial load
duke
parents:
diff changeset
347 int depth() const { return _depth; }
a61af66fc99e Initial load
duke
parents:
diff changeset
348 const TypeFunc* tf() const { return _tf; }
a61af66fc99e Initial load
duke
parents:
diff changeset
349 // entry_bci() -- see osr_bci, etc.
a61af66fc99e Initial load
duke
parents:
diff changeset
350
a61af66fc99e Initial load
duke
parents:
diff changeset
351 ciTypeFlow* flow() const { return _flow; }
367
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 248
diff changeset
352 // blocks() -- see rpo_at, start_block, etc.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
353 int block_count() const { return _block_count; }
a61af66fc99e Initial load
duke
parents:
diff changeset
354
a61af66fc99e Initial load
duke
parents:
diff changeset
355 GraphKit& exits() { return _exits; }
a61af66fc99e Initial load
duke
parents:
diff changeset
356 bool wrote_final() const { return _wrote_final; }
a61af66fc99e Initial load
duke
parents:
diff changeset
357 void set_wrote_final(bool z) { _wrote_final = z; }
a61af66fc99e Initial load
duke
parents:
diff changeset
358 bool count_invocations() const { return _count_invocations; }
a61af66fc99e Initial load
duke
parents:
diff changeset
359 bool method_data_update() const { return _method_data_update; }
a61af66fc99e Initial load
duke
parents:
diff changeset
360
a61af66fc99e Initial load
duke
parents:
diff changeset
361 Block* block() const { return _block; }
a61af66fc99e Initial load
duke
parents:
diff changeset
362 ciBytecodeStream& iter() { return _iter; }
a61af66fc99e Initial load
duke
parents:
diff changeset
363 Bytecodes::Code bc() const { return _iter.cur_bc(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
364
a61af66fc99e Initial load
duke
parents:
diff changeset
365 void set_block(Block* b) { _block = b; }
a61af66fc99e Initial load
duke
parents:
diff changeset
366
a61af66fc99e Initial load
duke
parents:
diff changeset
367 // Derived accessors:
a61af66fc99e Initial load
duke
parents:
diff changeset
368 bool is_normal_parse() const { return _entry_bci == InvocationEntryBci; }
a61af66fc99e Initial load
duke
parents:
diff changeset
369 bool is_osr_parse() const { return _entry_bci != InvocationEntryBci; }
a61af66fc99e Initial load
duke
parents:
diff changeset
370 int osr_bci() const { assert(is_osr_parse(),""); return _entry_bci; }
a61af66fc99e Initial load
duke
parents:
diff changeset
371
a61af66fc99e Initial load
duke
parents:
diff changeset
372 void set_parse_bci(int bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
373
a61af66fc99e Initial load
duke
parents:
diff changeset
374 // Must this parse be aborted?
a61af66fc99e Initial load
duke
parents:
diff changeset
375 bool failing() { return C->failing(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
376
367
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 248
diff changeset
377 Block* rpo_at(int rpo) {
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 248
diff changeset
378 assert(0 <= rpo && rpo < _block_count, "oob");
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 248
diff changeset
379 return &_blocks[rpo];
0
a61af66fc99e Initial load
duke
parents:
diff changeset
380 }
a61af66fc99e Initial load
duke
parents:
diff changeset
381 Block* start_block() {
367
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 248
diff changeset
382 return rpo_at(flow()->start_block()->rpo());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
383 }
a61af66fc99e Initial load
duke
parents:
diff changeset
384 // Can return NULL if the flow pass did not complete a block.
a61af66fc99e Initial load
duke
parents:
diff changeset
385 Block* successor_for_bci(int bci) {
a61af66fc99e Initial load
duke
parents:
diff changeset
386 return block()->successor_for_bci(bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
387 }
a61af66fc99e Initial load
duke
parents:
diff changeset
388
a61af66fc99e Initial load
duke
parents:
diff changeset
389 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
390 // Create a JVMS & map for the initial state of this method.
a61af66fc99e Initial load
duke
parents:
diff changeset
391 SafePointNode* create_entry_map();
a61af66fc99e Initial load
duke
parents:
diff changeset
392
a61af66fc99e Initial load
duke
parents:
diff changeset
393 // OSR helpers
a61af66fc99e Initial load
duke
parents:
diff changeset
394 Node *fetch_interpreter_state(int index, BasicType bt, Node *local_addrs, Node *local_addrs_base);
a61af66fc99e Initial load
duke
parents:
diff changeset
395 Node* check_interpreter_type(Node* l, const Type* type, SafePointNode* &bad_type_exit);
a61af66fc99e Initial load
duke
parents:
diff changeset
396 void load_interpreter_state(Node* osr_buf);
a61af66fc99e Initial load
duke
parents:
diff changeset
397
a61af66fc99e Initial load
duke
parents:
diff changeset
398 // Functions for managing basic blocks:
a61af66fc99e Initial load
duke
parents:
diff changeset
399 void init_blocks();
a61af66fc99e Initial load
duke
parents:
diff changeset
400 void load_state_from(Block* b);
a61af66fc99e Initial load
duke
parents:
diff changeset
401 void store_state_to(Block* b) { b->record_state(this); }
a61af66fc99e Initial load
duke
parents:
diff changeset
402
a61af66fc99e Initial load
duke
parents:
diff changeset
403 // Parse all the basic blocks.
a61af66fc99e Initial load
duke
parents:
diff changeset
404 void do_all_blocks();
a61af66fc99e Initial load
duke
parents:
diff changeset
405
a61af66fc99e Initial load
duke
parents:
diff changeset
406 // Parse the current basic block
a61af66fc99e Initial load
duke
parents:
diff changeset
407 void do_one_block();
a61af66fc99e Initial load
duke
parents:
diff changeset
408
a61af66fc99e Initial load
duke
parents:
diff changeset
409 // Raise an error if we get a bad ciTypeFlow CFG.
a61af66fc99e Initial load
duke
parents:
diff changeset
410 void handle_missing_successor(int bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
411
a61af66fc99e Initial load
duke
parents:
diff changeset
412 // first actions (before BCI 0)
a61af66fc99e Initial load
duke
parents:
diff changeset
413 void do_method_entry();
a61af66fc99e Initial load
duke
parents:
diff changeset
414
a61af66fc99e Initial load
duke
parents:
diff changeset
415 // implementation of monitorenter/monitorexit
a61af66fc99e Initial load
duke
parents:
diff changeset
416 void do_monitor_enter();
a61af66fc99e Initial load
duke
parents:
diff changeset
417 void do_monitor_exit();
a61af66fc99e Initial load
duke
parents:
diff changeset
418
a61af66fc99e Initial load
duke
parents:
diff changeset
419 // Eagerly create phie throughout the state, to cope with back edges.
a61af66fc99e Initial load
duke
parents:
diff changeset
420 void ensure_phis_everywhere();
a61af66fc99e Initial load
duke
parents:
diff changeset
421
a61af66fc99e Initial load
duke
parents:
diff changeset
422 // Merge the current mapping into the basic block starting at bci
a61af66fc99e Initial load
duke
parents:
diff changeset
423 void merge( int target_bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
424 // Same as plain merge, except that it allocates a new path number.
a61af66fc99e Initial load
duke
parents:
diff changeset
425 void merge_new_path( int target_bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
426 // Merge the current mapping into an exception handler.
a61af66fc99e Initial load
duke
parents:
diff changeset
427 void merge_exception(int target_bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
428 // Helper: Merge the current mapping into the given basic block
a61af66fc99e Initial load
duke
parents:
diff changeset
429 void merge_common(Block* target, int pnum);
a61af66fc99e Initial load
duke
parents:
diff changeset
430 // Helper functions for merging individual cells.
a61af66fc99e Initial load
duke
parents:
diff changeset
431 PhiNode *ensure_phi( int idx, bool nocreate = false);
a61af66fc99e Initial load
duke
parents:
diff changeset
432 PhiNode *ensure_memory_phi(int idx, bool nocreate = false);
a61af66fc99e Initial load
duke
parents:
diff changeset
433 // Helper to merge the current memory state into the given basic block
a61af66fc99e Initial load
duke
parents:
diff changeset
434 void merge_memory_edges(MergeMemNode* n, int pnum, bool nophi);
a61af66fc99e Initial load
duke
parents:
diff changeset
435
a61af66fc99e Initial load
duke
parents:
diff changeset
436 // Parse this bytecode, and alter the Parsers JVM->Node mapping
a61af66fc99e Initial load
duke
parents:
diff changeset
437 void do_one_bytecode();
a61af66fc99e Initial load
duke
parents:
diff changeset
438
a61af66fc99e Initial load
duke
parents:
diff changeset
439 // helper function to generate array store check
a61af66fc99e Initial load
duke
parents:
diff changeset
440 void array_store_check();
a61af66fc99e Initial load
duke
parents:
diff changeset
441 // Helper function to generate array load
a61af66fc99e Initial load
duke
parents:
diff changeset
442 void array_load(BasicType etype);
a61af66fc99e Initial load
duke
parents:
diff changeset
443 // Helper function to generate array store
a61af66fc99e Initial load
duke
parents:
diff changeset
444 void array_store(BasicType etype);
a61af66fc99e Initial load
duke
parents:
diff changeset
445 // Helper function to compute array addressing
a61af66fc99e Initial load
duke
parents:
diff changeset
446 Node* array_addressing(BasicType type, int vals, const Type* *result2=NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
447
a61af66fc99e Initial load
duke
parents:
diff changeset
448 // Pass current map to exits
a61af66fc99e Initial load
duke
parents:
diff changeset
449 void return_current(Node* value);
a61af66fc99e Initial load
duke
parents:
diff changeset
450
a61af66fc99e Initial load
duke
parents:
diff changeset
451 // Register finalizers on return from Object.<init>
a61af66fc99e Initial load
duke
parents:
diff changeset
452 void call_register_finalizer();
a61af66fc99e Initial load
duke
parents:
diff changeset
453
a61af66fc99e Initial load
duke
parents:
diff changeset
454 // Insert a compiler safepoint into the graph
a61af66fc99e Initial load
duke
parents:
diff changeset
455 void add_safepoint();
a61af66fc99e Initial load
duke
parents:
diff changeset
456
a61af66fc99e Initial load
duke
parents:
diff changeset
457 // Insert a compiler safepoint into the graph, if there is a back-branch.
a61af66fc99e Initial load
duke
parents:
diff changeset
458 void maybe_add_safepoint(int target_bci) {
a61af66fc99e Initial load
duke
parents:
diff changeset
459 if (UseLoopSafepoints && target_bci <= bci()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
460 add_safepoint();
a61af66fc99e Initial load
duke
parents:
diff changeset
461 }
a61af66fc99e Initial load
duke
parents:
diff changeset
462 }
a61af66fc99e Initial load
duke
parents:
diff changeset
463
a61af66fc99e Initial load
duke
parents:
diff changeset
464 // Note: Intrinsic generation routines may be found in library_call.cpp.
a61af66fc99e Initial load
duke
parents:
diff changeset
465
a61af66fc99e Initial load
duke
parents:
diff changeset
466 // Helper function to setup Ideal Call nodes
a61af66fc99e Initial load
duke
parents:
diff changeset
467 void do_call();
a61af66fc99e Initial load
duke
parents:
diff changeset
468
a61af66fc99e Initial load
duke
parents:
diff changeset
469 // Helper function to uncommon-trap or bailout for non-compilable call-sites
a61af66fc99e Initial load
duke
parents:
diff changeset
470 bool can_not_compile_call_site(ciMethod *dest_method, ciInstanceKlass *klass);
a61af66fc99e Initial load
duke
parents:
diff changeset
471
a61af66fc99e Initial load
duke
parents:
diff changeset
472 // Helper function to identify inlining potential at call-site
a61af66fc99e Initial load
duke
parents:
diff changeset
473 ciMethod* optimize_inlining(ciMethod* caller, int bci, ciInstanceKlass* klass,
a61af66fc99e Initial load
duke
parents:
diff changeset
474 ciMethod *dest_method, const TypeOopPtr* receiver_type);
a61af66fc99e Initial load
duke
parents:
diff changeset
475
a61af66fc99e Initial load
duke
parents:
diff changeset
476 // Helper function to setup for type-profile based inlining
a61af66fc99e Initial load
duke
parents:
diff changeset
477 bool prepare_type_profile_inline(ciInstanceKlass* prof_klass, ciMethod* prof_method);
a61af66fc99e Initial load
duke
parents:
diff changeset
478
a61af66fc99e Initial load
duke
parents:
diff changeset
479 // Helper functions for type checking bytecodes:
a61af66fc99e Initial load
duke
parents:
diff changeset
480 void do_checkcast();
a61af66fc99e Initial load
duke
parents:
diff changeset
481 void do_instanceof();
a61af66fc99e Initial load
duke
parents:
diff changeset
482
a61af66fc99e Initial load
duke
parents:
diff changeset
483 // Helper functions for shifting & arithmetic
a61af66fc99e Initial load
duke
parents:
diff changeset
484 void modf();
a61af66fc99e Initial load
duke
parents:
diff changeset
485 void modd();
a61af66fc99e Initial load
duke
parents:
diff changeset
486 void l2f();
a61af66fc99e Initial load
duke
parents:
diff changeset
487
a61af66fc99e Initial load
duke
parents:
diff changeset
488 void do_irem();
a61af66fc99e Initial load
duke
parents:
diff changeset
489
a61af66fc99e Initial load
duke
parents:
diff changeset
490 // implementation of _get* and _put* bytecodes
a61af66fc99e Initial load
duke
parents:
diff changeset
491 void do_getstatic() { do_field_access(true, false); }
a61af66fc99e Initial load
duke
parents:
diff changeset
492 void do_getfield () { do_field_access(true, true); }
a61af66fc99e Initial load
duke
parents:
diff changeset
493 void do_putstatic() { do_field_access(false, false); }
a61af66fc99e Initial load
duke
parents:
diff changeset
494 void do_putfield () { do_field_access(false, true); }
a61af66fc99e Initial load
duke
parents:
diff changeset
495
a61af66fc99e Initial load
duke
parents:
diff changeset
496 // common code for making initial checks and forming addresses
a61af66fc99e Initial load
duke
parents:
diff changeset
497 void do_field_access(bool is_get, bool is_field);
a61af66fc99e Initial load
duke
parents:
diff changeset
498 bool static_field_ok_in_clinit(ciField *field, ciMethod *method);
a61af66fc99e Initial load
duke
parents:
diff changeset
499
a61af66fc99e Initial load
duke
parents:
diff changeset
500 // common code for actually performing the load or store
2376
c7f3d0b4570f 7017732: move static fields into Class to prepare for perm gen removal
never
parents: 1972
diff changeset
501 void do_get_xxx(Node* obj, ciField* field, bool is_field);
c7f3d0b4570f 7017732: move static fields into Class to prepare for perm gen removal
never
parents: 1972
diff changeset
502 void do_put_xxx(Node* obj, ciField* field, bool is_field);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
503
a61af66fc99e Initial load
duke
parents:
diff changeset
504 // loading from a constant field or the constant pool
a61af66fc99e Initial load
duke
parents:
diff changeset
505 // returns false if push failed (non-perm field constants only, not ldcs)
989
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 844
diff changeset
506 bool push_constant(ciConstant con, bool require_constant = false);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
507
a61af66fc99e Initial load
duke
parents:
diff changeset
508 // implementation of object creation bytecodes
1645
3941674cc7fa 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 1552
diff changeset
509 void emit_guard_for_new(ciInstanceKlass* klass);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
510 void do_new();
a61af66fc99e Initial load
duke
parents:
diff changeset
511 void do_newarray(BasicType elemtype);
a61af66fc99e Initial load
duke
parents:
diff changeset
512 void do_anewarray();
a61af66fc99e Initial load
duke
parents:
diff changeset
513 void do_multianewarray();
730
9c6be3edf0dc 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents: 605
diff changeset
514 Node* expand_multianewarray(ciArrayKlass* array_klass, Node* *lengths, int ndimensions, int nargs);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
515
a61af66fc99e Initial load
duke
parents:
diff changeset
516 // implementation of jsr/ret
a61af66fc99e Initial load
duke
parents:
diff changeset
517 void do_jsr();
a61af66fc99e Initial load
duke
parents:
diff changeset
518 void do_ret();
a61af66fc99e Initial load
duke
parents:
diff changeset
519
a61af66fc99e Initial load
duke
parents:
diff changeset
520 float dynamic_branch_prediction(float &cnt);
a61af66fc99e Initial load
duke
parents:
diff changeset
521 float branch_prediction(float &cnt, BoolTest::mask btest, int target_bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
522 bool seems_never_taken(float prob);
1746
4b29a725c43c 6912064: type profiles need to be exploited more for dynamic language support
jrose
parents: 1645
diff changeset
523 bool seems_stable_comparison(BoolTest::mask btest, Node* c);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
524
248
18aab3cdd513 6726504: handle do_ifxxx calls in parser more uniformly
rasbold
parents: 196
diff changeset
525 void do_ifnull(BoolTest::mask btest, Node* c);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
526 void do_if(BoolTest::mask btest, Node* c);
1172
b2b6a9bf6238 6894779: Loop Predication for Loop Optimizer in C2
cfang
parents: 1157
diff changeset
527 int repush_if_args();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
528 void adjust_map_after_if(BoolTest::mask btest, Node* c, float prob,
a61af66fc99e Initial load
duke
parents:
diff changeset
529 Block* path, Block* other_path);
6131
8f6ce6f1049b 7170463: C2 should recognize "obj.getClass() == A.class" code pattern
kvn
parents: 3939
diff changeset
530 void sharpen_type_after_if(BoolTest::mask btest,
8f6ce6f1049b 7170463: C2 should recognize "obj.getClass() == A.class" code pattern
kvn
parents: 3939
diff changeset
531 Node* con, const Type* tcon,
8f6ce6f1049b 7170463: C2 should recognize "obj.getClass() == A.class" code pattern
kvn
parents: 3939
diff changeset
532 Node* val, const Type* tval);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
533 IfNode* jump_if_fork_int(Node* a, Node* b, BoolTest::mask mask);
a61af66fc99e Initial load
duke
parents:
diff changeset
534 Node* jump_if_join(Node* iffalse, Node* iftrue);
a61af66fc99e Initial load
duke
parents:
diff changeset
535 void jump_if_true_fork(IfNode *ifNode, int dest_bci_if_true, int prof_table_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
536 void jump_if_false_fork(IfNode *ifNode, int dest_bci_if_false, int prof_table_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
537 void jump_if_always_fork(int dest_bci_if_true, int prof_table_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
538
a61af66fc99e Initial load
duke
parents:
diff changeset
539 friend class SwitchRange;
a61af66fc99e Initial load
duke
parents:
diff changeset
540 void do_tableswitch();
a61af66fc99e Initial load
duke
parents:
diff changeset
541 void do_lookupswitch();
a61af66fc99e Initial load
duke
parents:
diff changeset
542 void jump_switch_ranges(Node* a, SwitchRange* lo, SwitchRange* hi, int depth = 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
543 bool create_jump_tables(Node* a, SwitchRange* lo, SwitchRange* hi);
a61af66fc99e Initial load
duke
parents:
diff changeset
544
a61af66fc99e Initial load
duke
parents:
diff changeset
545 // helper functions for methodData style profiling
a61af66fc99e Initial load
duke
parents:
diff changeset
546 void test_counter_against_threshold(Node* cnt, int limit);
a61af66fc99e Initial load
duke
parents:
diff changeset
547 void increment_and_test_invocation_counter(int limit);
a61af66fc99e Initial load
duke
parents:
diff changeset
548 void test_for_osr_md_counter_at(ciMethodData* md, ciProfileData* data, ByteSize offset, int limit);
a61af66fc99e Initial load
duke
parents:
diff changeset
549 Node* method_data_addressing(ciMethodData* md, ciProfileData* data, ByteSize offset, Node* idx = NULL, uint stride = 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
550 void increment_md_counter_at(ciMethodData* md, ciProfileData* data, ByteSize offset, Node* idx = NULL, uint stride = 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
551 void set_md_flag_at(ciMethodData* md, ciProfileData* data, int flag_constant);
a61af66fc99e Initial load
duke
parents:
diff changeset
552
a61af66fc99e Initial load
duke
parents:
diff changeset
553 void profile_method_entry();
a61af66fc99e Initial load
duke
parents:
diff changeset
554 void profile_taken_branch(int target_bci, bool force_update = false);
a61af66fc99e Initial load
duke
parents:
diff changeset
555 void profile_not_taken_branch(bool force_update = false);
a61af66fc99e Initial load
duke
parents:
diff changeset
556 void profile_call(Node* receiver);
a61af66fc99e Initial load
duke
parents:
diff changeset
557 void profile_generic_call();
a61af66fc99e Initial load
duke
parents:
diff changeset
558 void profile_receiver_type(Node* receiver);
a61af66fc99e Initial load
duke
parents:
diff changeset
559 void profile_ret(int target_bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
560 void profile_null_checkcast();
a61af66fc99e Initial load
duke
parents:
diff changeset
561 void profile_switch_case(int table_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
562
a61af66fc99e Initial load
duke
parents:
diff changeset
563 // helper function for call statistics
a61af66fc99e Initial load
duke
parents:
diff changeset
564 void count_compiled_calls(bool at_method_entry, bool is_inline) PRODUCT_RETURN;
a61af66fc99e Initial load
duke
parents:
diff changeset
565
a61af66fc99e Initial load
duke
parents:
diff changeset
566 Node_Notes* make_node_notes(Node_Notes* caller_nn);
a61af66fc99e Initial load
duke
parents:
diff changeset
567
a61af66fc99e Initial load
duke
parents:
diff changeset
568 // Helper functions for handling normal and abnormal exits.
a61af66fc99e Initial load
duke
parents:
diff changeset
569 void build_exits();
a61af66fc99e Initial load
duke
parents:
diff changeset
570
a61af66fc99e Initial load
duke
parents:
diff changeset
571 // Fix up all exceptional control flow exiting a single bytecode.
a61af66fc99e Initial load
duke
parents:
diff changeset
572 void do_exceptions();
a61af66fc99e Initial load
duke
parents:
diff changeset
573
a61af66fc99e Initial load
duke
parents:
diff changeset
574 // Fix up all exiting control flow at the end of the parse.
a61af66fc99e Initial load
duke
parents:
diff changeset
575 void do_exits();
a61af66fc99e Initial load
duke
parents:
diff changeset
576
a61af66fc99e Initial load
duke
parents:
diff changeset
577 // Add Catch/CatchProjs
a61af66fc99e Initial load
duke
parents:
diff changeset
578 // The call is either a Java call or the VM's rethrow stub
a61af66fc99e Initial load
duke
parents:
diff changeset
579 void catch_call_exceptions(ciExceptionHandlerStream&);
a61af66fc99e Initial load
duke
parents:
diff changeset
580
a61af66fc99e Initial load
duke
parents:
diff changeset
581 // Handle all exceptions thrown by the inlined method.
a61af66fc99e Initial load
duke
parents:
diff changeset
582 // Also handles exceptions for individual bytecodes.
a61af66fc99e Initial load
duke
parents:
diff changeset
583 void catch_inline_exceptions(SafePointNode* ex_map);
a61af66fc99e Initial load
duke
parents:
diff changeset
584
a61af66fc99e Initial load
duke
parents:
diff changeset
585 // Merge the given map into correct exceptional exit state.
a61af66fc99e Initial load
duke
parents:
diff changeset
586 // Assumes that there is no applicable local handler.
a61af66fc99e Initial load
duke
parents:
diff changeset
587 void throw_to_exit(SafePointNode* ex_map);
a61af66fc99e Initial load
duke
parents:
diff changeset
588
a61af66fc99e Initial load
duke
parents:
diff changeset
589 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
590 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
591 // Handle PrintOpto, etc.
a61af66fc99e Initial load
duke
parents:
diff changeset
592 void show_parse_info();
a61af66fc99e Initial load
duke
parents:
diff changeset
593 void dump_map_adr_mem() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
594 static void print_statistics(); // Print some performance counters
a61af66fc99e Initial load
duke
parents:
diff changeset
595 void dump();
a61af66fc99e Initial load
duke
parents:
diff changeset
596 void dump_bci(int bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
597 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
598 };
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1746
diff changeset
599
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1746
diff changeset
600 #endif // SHARE_VM_OPTO_PARSE_HPP