annotate src/share/vm/c1/c1_GraphBuilder.hpp @ 1819:f02a8bbe6ed4

6986046: C1 valuestack cleanup Summary: fixes an historical oddity in C1 with inlining where all of the expression stacks are kept in the topmost ValueStack instead of being in their respective ValueStacks. Reviewed-by: never Contributed-by: Christian Wimmer <cwimmer@uci.edu>
author roland
date Tue, 29 Dec 2009 19:08:54 +0100
parents d5d065957597
children 80c9354976b0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1584
diff changeset
2 * Copyright (c) 1999, 2010, 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: 470
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 470
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: 470
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
a61af66fc99e Initial load
duke
parents:
diff changeset
25 class MemoryBuffer;
a61af66fc99e Initial load
duke
parents:
diff changeset
26
a61af66fc99e Initial load
duke
parents:
diff changeset
27 class GraphBuilder VALUE_OBJ_CLASS_SPEC {
a61af66fc99e Initial load
duke
parents:
diff changeset
28 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
29 // Per-scope data. These are pushed and popped as we descend into
a61af66fc99e Initial load
duke
parents:
diff changeset
30 // inlined methods. Currently in order to generate good code in the
a61af66fc99e Initial load
duke
parents:
diff changeset
31 // inliner we have to attempt to inline methods directly into the
a61af66fc99e Initial load
duke
parents:
diff changeset
32 // basic block we are parsing; this adds complexity.
a61af66fc99e Initial load
duke
parents:
diff changeset
33 class ScopeData: public CompilationResourceObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
34 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
35 ScopeData* _parent;
a61af66fc99e Initial load
duke
parents:
diff changeset
36 // bci-to-block mapping
a61af66fc99e Initial load
duke
parents:
diff changeset
37 BlockList* _bci2block;
a61af66fc99e Initial load
duke
parents:
diff changeset
38 // Scope
a61af66fc99e Initial load
duke
parents:
diff changeset
39 IRScope* _scope;
a61af66fc99e Initial load
duke
parents:
diff changeset
40 // Whether this scope or any parent scope has exception handlers
a61af66fc99e Initial load
duke
parents:
diff changeset
41 bool _has_handler;
a61af66fc99e Initial load
duke
parents:
diff changeset
42 // The bytecodes
a61af66fc99e Initial load
duke
parents:
diff changeset
43 ciBytecodeStream* _stream;
a61af66fc99e Initial load
duke
parents:
diff changeset
44
a61af66fc99e Initial load
duke
parents:
diff changeset
45 // Work list
a61af66fc99e Initial load
duke
parents:
diff changeset
46 BlockList* _work_list;
a61af66fc99e Initial load
duke
parents:
diff changeset
47
a61af66fc99e Initial load
duke
parents:
diff changeset
48 // Maximum inline size for this scope
a61af66fc99e Initial load
duke
parents:
diff changeset
49 intx _max_inline_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
50 // Expression stack depth at point where inline occurred
a61af66fc99e Initial load
duke
parents:
diff changeset
51 int _caller_stack_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
52
a61af66fc99e Initial load
duke
parents:
diff changeset
53 // The continuation point for the inline. Currently only used in
a61af66fc99e Initial load
duke
parents:
diff changeset
54 // multi-block inlines, but eventually would like to use this for
a61af66fc99e Initial load
duke
parents:
diff changeset
55 // all inlines for uniformity and simplicity; in this case would
a61af66fc99e Initial load
duke
parents:
diff changeset
56 // get the continuation point from the BlockList instead of
a61af66fc99e Initial load
duke
parents:
diff changeset
57 // fabricating it anew because Invokes would be considered to be
a61af66fc99e Initial load
duke
parents:
diff changeset
58 // BlockEnds.
a61af66fc99e Initial load
duke
parents:
diff changeset
59 BlockBegin* _continuation;
a61af66fc99e Initial load
duke
parents:
diff changeset
60
a61af66fc99e Initial load
duke
parents:
diff changeset
61 // Was this ScopeData created only for the parsing and inlining of
a61af66fc99e Initial load
duke
parents:
diff changeset
62 // a jsr?
a61af66fc99e Initial load
duke
parents:
diff changeset
63 bool _parsing_jsr;
a61af66fc99e Initial load
duke
parents:
diff changeset
64 // We track the destination bci of the jsr only to determine
a61af66fc99e Initial load
duke
parents:
diff changeset
65 // bailout conditions, since we only handle a subset of all of the
a61af66fc99e Initial load
duke
parents:
diff changeset
66 // possible jsr-ret control structures. Recursive invocations of a
a61af66fc99e Initial load
duke
parents:
diff changeset
67 // jsr are disallowed by the verifier.
a61af66fc99e Initial load
duke
parents:
diff changeset
68 int _jsr_entry_bci;
a61af66fc99e Initial load
duke
parents:
diff changeset
69 // We need to track the local variable in which the return address
a61af66fc99e Initial load
duke
parents:
diff changeset
70 // was stored to ensure we can handle inlining the jsr, because we
a61af66fc99e Initial load
duke
parents:
diff changeset
71 // don't handle arbitrary jsr/ret constructs.
a61af66fc99e Initial load
duke
parents:
diff changeset
72 int _jsr_ret_addr_local;
a61af66fc99e Initial load
duke
parents:
diff changeset
73 // If we are parsing a jsr, the continuation point for rets
a61af66fc99e Initial load
duke
parents:
diff changeset
74 BlockBegin* _jsr_continuation;
a61af66fc99e Initial load
duke
parents:
diff changeset
75 // Cloned XHandlers for jsr-related ScopeDatas
a61af66fc99e Initial load
duke
parents:
diff changeset
76 XHandlers* _jsr_xhandlers;
a61af66fc99e Initial load
duke
parents:
diff changeset
77
a61af66fc99e Initial load
duke
parents:
diff changeset
78 // Number of returns seen in this scope
a61af66fc99e Initial load
duke
parents:
diff changeset
79 int _num_returns;
a61af66fc99e Initial load
duke
parents:
diff changeset
80
a61af66fc99e Initial load
duke
parents:
diff changeset
81 // In order to generate profitable code for inlining, we currently
a61af66fc99e Initial load
duke
parents:
diff changeset
82 // have to perform an optimization for single-block inlined
a61af66fc99e Initial load
duke
parents:
diff changeset
83 // methods where we continue parsing into the same block. This
a61af66fc99e Initial load
duke
parents:
diff changeset
84 // allows us to perform CSE across inlined scopes and to avoid
a61af66fc99e Initial load
duke
parents:
diff changeset
85 // storing parameters to the stack. Having a global register
a61af66fc99e Initial load
duke
parents:
diff changeset
86 // allocator and being able to perform global CSE would allow this
a61af66fc99e Initial load
duke
parents:
diff changeset
87 // code to be removed and thereby simplify the inliner.
a61af66fc99e Initial load
duke
parents:
diff changeset
88 BlockBegin* _cleanup_block; // The block to which the return was added
a61af66fc99e Initial load
duke
parents:
diff changeset
89 Instruction* _cleanup_return_prev; // Instruction before return instruction
a61af66fc99e Initial load
duke
parents:
diff changeset
90 ValueStack* _cleanup_state; // State of that block (not yet pinned)
a61af66fc99e Initial load
duke
parents:
diff changeset
91
a61af66fc99e Initial load
duke
parents:
diff changeset
92 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
93 ScopeData(ScopeData* parent);
a61af66fc99e Initial load
duke
parents:
diff changeset
94
a61af66fc99e Initial load
duke
parents:
diff changeset
95 ScopeData* parent() const { return _parent; }
a61af66fc99e Initial load
duke
parents:
diff changeset
96
a61af66fc99e Initial load
duke
parents:
diff changeset
97 BlockList* bci2block() const { return _bci2block; }
a61af66fc99e Initial load
duke
parents:
diff changeset
98 void set_bci2block(BlockList* bci2block) { _bci2block = bci2block; }
a61af66fc99e Initial load
duke
parents:
diff changeset
99
a61af66fc99e Initial load
duke
parents:
diff changeset
100 // NOTE: this has a different effect when parsing jsrs
a61af66fc99e Initial load
duke
parents:
diff changeset
101 BlockBegin* block_at(int bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
102
a61af66fc99e Initial load
duke
parents:
diff changeset
103 IRScope* scope() const { return _scope; }
a61af66fc99e Initial load
duke
parents:
diff changeset
104 // Has side-effect of setting has_handler flag
a61af66fc99e Initial load
duke
parents:
diff changeset
105 void set_scope(IRScope* scope);
a61af66fc99e Initial load
duke
parents:
diff changeset
106
a61af66fc99e Initial load
duke
parents:
diff changeset
107 // Whether this or any parent scope has exception handlers
a61af66fc99e Initial load
duke
parents:
diff changeset
108 bool has_handler() const { return _has_handler; }
a61af66fc99e Initial load
duke
parents:
diff changeset
109 void set_has_handler() { _has_handler = true; }
a61af66fc99e Initial load
duke
parents:
diff changeset
110
a61af66fc99e Initial load
duke
parents:
diff changeset
111 // Exception handlers list to be used for this scope
a61af66fc99e Initial load
duke
parents:
diff changeset
112 XHandlers* xhandlers() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
113
a61af66fc99e Initial load
duke
parents:
diff changeset
114 // How to get a block to be parsed
a61af66fc99e Initial load
duke
parents:
diff changeset
115 void add_to_work_list(BlockBegin* block);
a61af66fc99e Initial load
duke
parents:
diff changeset
116 // How to remove the next block to be parsed; returns NULL if none left
a61af66fc99e Initial load
duke
parents:
diff changeset
117 BlockBegin* remove_from_work_list();
a61af66fc99e Initial load
duke
parents:
diff changeset
118 // Indicates parse is over
a61af66fc99e Initial load
duke
parents:
diff changeset
119 bool is_work_list_empty() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
120
a61af66fc99e Initial load
duke
parents:
diff changeset
121 ciBytecodeStream* stream() { return _stream; }
a61af66fc99e Initial load
duke
parents:
diff changeset
122 void set_stream(ciBytecodeStream* stream) { _stream = stream; }
a61af66fc99e Initial load
duke
parents:
diff changeset
123
a61af66fc99e Initial load
duke
parents:
diff changeset
124 intx max_inline_size() const { return _max_inline_size; }
a61af66fc99e Initial load
duke
parents:
diff changeset
125
a61af66fc99e Initial load
duke
parents:
diff changeset
126 BlockBegin* continuation() const { return _continuation; }
a61af66fc99e Initial load
duke
parents:
diff changeset
127 void set_continuation(BlockBegin* cont) { _continuation = cont; }
a61af66fc99e Initial load
duke
parents:
diff changeset
128
a61af66fc99e Initial load
duke
parents:
diff changeset
129 // Indicates whether this ScopeData was pushed only for the
a61af66fc99e Initial load
duke
parents:
diff changeset
130 // parsing and inlining of a jsr
a61af66fc99e Initial load
duke
parents:
diff changeset
131 bool parsing_jsr() const { return _parsing_jsr; }
a61af66fc99e Initial load
duke
parents:
diff changeset
132 void set_parsing_jsr() { _parsing_jsr = true; }
a61af66fc99e Initial load
duke
parents:
diff changeset
133 int jsr_entry_bci() const { return _jsr_entry_bci; }
a61af66fc99e Initial load
duke
parents:
diff changeset
134 void set_jsr_entry_bci(int bci) { _jsr_entry_bci = bci; }
a61af66fc99e Initial load
duke
parents:
diff changeset
135 void set_jsr_return_address_local(int local_no){ _jsr_ret_addr_local = local_no; }
a61af66fc99e Initial load
duke
parents:
diff changeset
136 int jsr_return_address_local() const { return _jsr_ret_addr_local; }
a61af66fc99e Initial load
duke
parents:
diff changeset
137 // Must be called after scope is set up for jsr ScopeData
a61af66fc99e Initial load
duke
parents:
diff changeset
138 void setup_jsr_xhandlers();
a61af66fc99e Initial load
duke
parents:
diff changeset
139
a61af66fc99e Initial load
duke
parents:
diff changeset
140 // The jsr continuation is only used when parsing_jsr is true, and
a61af66fc99e Initial load
duke
parents:
diff changeset
141 // is different from the "normal" continuation since we can end up
a61af66fc99e Initial load
duke
parents:
diff changeset
142 // doing a return (rather than a ret) from within a subroutine
a61af66fc99e Initial load
duke
parents:
diff changeset
143 BlockBegin* jsr_continuation() const { return _jsr_continuation; }
a61af66fc99e Initial load
duke
parents:
diff changeset
144 void set_jsr_continuation(BlockBegin* cont) { _jsr_continuation = cont; }
a61af66fc99e Initial load
duke
parents:
diff changeset
145
a61af66fc99e Initial load
duke
parents:
diff changeset
146 int num_returns();
a61af66fc99e Initial load
duke
parents:
diff changeset
147 void incr_num_returns();
a61af66fc99e Initial load
duke
parents:
diff changeset
148
a61af66fc99e Initial load
duke
parents:
diff changeset
149 void set_inline_cleanup_info(BlockBegin* block,
a61af66fc99e Initial load
duke
parents:
diff changeset
150 Instruction* return_prev,
a61af66fc99e Initial load
duke
parents:
diff changeset
151 ValueStack* return_state);
a61af66fc99e Initial load
duke
parents:
diff changeset
152 BlockBegin* inline_cleanup_block() const { return _cleanup_block; }
a61af66fc99e Initial load
duke
parents:
diff changeset
153 Instruction* inline_cleanup_return_prev() const{ return _cleanup_return_prev; }
a61af66fc99e Initial load
duke
parents:
diff changeset
154 ValueStack* inline_cleanup_state() const { return _cleanup_state; }
a61af66fc99e Initial load
duke
parents:
diff changeset
155 };
a61af66fc99e Initial load
duke
parents:
diff changeset
156
a61af66fc99e Initial load
duke
parents:
diff changeset
157 // for all GraphBuilders
a61af66fc99e Initial load
duke
parents:
diff changeset
158 static bool _can_trap[Bytecodes::number_of_java_codes];
a61af66fc99e Initial load
duke
parents:
diff changeset
159
a61af66fc99e Initial load
duke
parents:
diff changeset
160 // for each instance of GraphBuilder
a61af66fc99e Initial load
duke
parents:
diff changeset
161 ScopeData* _scope_data; // Per-scope data; used for inlining
a61af66fc99e Initial load
duke
parents:
diff changeset
162 Compilation* _compilation; // the current compilation
a61af66fc99e Initial load
duke
parents:
diff changeset
163 ValueMap* _vmap; // the map of values encountered (for CSE)
a61af66fc99e Initial load
duke
parents:
diff changeset
164 MemoryBuffer* _memory;
a61af66fc99e Initial load
duke
parents:
diff changeset
165 const char* _inline_bailout_msg; // non-null if most recent inline attempt failed
a61af66fc99e Initial load
duke
parents:
diff changeset
166 int _instruction_count; // for bailing out in pathological jsr/ret cases
a61af66fc99e Initial load
duke
parents:
diff changeset
167 BlockBegin* _start; // the start block
a61af66fc99e Initial load
duke
parents:
diff changeset
168 BlockBegin* _osr_entry; // the osr entry block block
a61af66fc99e Initial load
duke
parents:
diff changeset
169 ValueStack* _initial_state; // The state for the start block
a61af66fc99e Initial load
duke
parents:
diff changeset
170
a61af66fc99e Initial load
duke
parents:
diff changeset
171 // for each call to connect_to_end; can also be set by inliner
a61af66fc99e Initial load
duke
parents:
diff changeset
172 BlockBegin* _block; // the current block
a61af66fc99e Initial load
duke
parents:
diff changeset
173 ValueStack* _state; // the current execution state
a61af66fc99e Initial load
duke
parents:
diff changeset
174 Instruction* _last; // the last instruction added
a61af66fc99e Initial load
duke
parents:
diff changeset
175 bool _skip_block; // skip processing of the rest of this block
a61af66fc99e Initial load
duke
parents:
diff changeset
176
a61af66fc99e Initial load
duke
parents:
diff changeset
177 // accessors
a61af66fc99e Initial load
duke
parents:
diff changeset
178 ScopeData* scope_data() const { return _scope_data; }
a61af66fc99e Initial load
duke
parents:
diff changeset
179 Compilation* compilation() const { return _compilation; }
a61af66fc99e Initial load
duke
parents:
diff changeset
180 BlockList* bci2block() const { return scope_data()->bci2block(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
181 ValueMap* vmap() const { assert(UseLocalValueNumbering, "should not access otherwise"); return _vmap; }
a61af66fc99e Initial load
duke
parents:
diff changeset
182 bool has_handler() const { return scope_data()->has_handler(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
183
a61af66fc99e Initial load
duke
parents:
diff changeset
184 BlockBegin* block() const { return _block; }
a61af66fc99e Initial load
duke
parents:
diff changeset
185 ValueStack* state() const { return _state; }
a61af66fc99e Initial load
duke
parents:
diff changeset
186 void set_state(ValueStack* state) { _state = state; }
a61af66fc99e Initial load
duke
parents:
diff changeset
187 IRScope* scope() const { return scope_data()->scope(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
188 ciMethod* method() const { return scope()->method(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
189 ciBytecodeStream* stream() const { return scope_data()->stream(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
190 Instruction* last() const { return _last; }
a61af66fc99e Initial load
duke
parents:
diff changeset
191 Bytecodes::Code code() const { return stream()->cur_bc(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
192 int bci() const { return stream()->cur_bci(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
193 int next_bci() const { return stream()->next_bci(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
194
a61af66fc99e Initial load
duke
parents:
diff changeset
195 // unified bailout support
a61af66fc99e Initial load
duke
parents:
diff changeset
196 void bailout(const char* msg) const { compilation()->bailout(msg); }
a61af66fc99e Initial load
duke
parents:
diff changeset
197 bool bailed_out() const { return compilation()->bailed_out(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
198
a61af66fc99e Initial load
duke
parents:
diff changeset
199 // stack manipulation helpers
a61af66fc99e Initial load
duke
parents:
diff changeset
200 void ipush(Value t) const { state()->ipush(t); }
a61af66fc99e Initial load
duke
parents:
diff changeset
201 void lpush(Value t) const { state()->lpush(t); }
a61af66fc99e Initial load
duke
parents:
diff changeset
202 void fpush(Value t) const { state()->fpush(t); }
a61af66fc99e Initial load
duke
parents:
diff changeset
203 void dpush(Value t) const { state()->dpush(t); }
a61af66fc99e Initial load
duke
parents:
diff changeset
204 void apush(Value t) const { state()->apush(t); }
a61af66fc99e Initial load
duke
parents:
diff changeset
205 void push(ValueType* type, Value t) const { state()-> push(type, t); }
a61af66fc99e Initial load
duke
parents:
diff changeset
206
a61af66fc99e Initial load
duke
parents:
diff changeset
207 Value ipop() { return state()->ipop(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
208 Value lpop() { return state()->lpop(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
209 Value fpop() { return state()->fpop(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
210 Value dpop() { return state()->dpop(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
211 Value apop() { return state()->apop(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
212 Value pop(ValueType* type) { return state()-> pop(type); }
a61af66fc99e Initial load
duke
parents:
diff changeset
213
a61af66fc99e Initial load
duke
parents:
diff changeset
214 // instruction helpers
a61af66fc99e Initial load
duke
parents:
diff changeset
215 void load_constant();
a61af66fc99e Initial load
duke
parents:
diff changeset
216 void load_local(ValueType* type, int index);
a61af66fc99e Initial load
duke
parents:
diff changeset
217 void store_local(ValueType* type, int index);
a61af66fc99e Initial load
duke
parents:
diff changeset
218 void store_local(ValueStack* state, Value value, ValueType* type, int index);
a61af66fc99e Initial load
duke
parents:
diff changeset
219 void load_indexed (BasicType type);
a61af66fc99e Initial load
duke
parents:
diff changeset
220 void store_indexed(BasicType type);
a61af66fc99e Initial load
duke
parents:
diff changeset
221 void stack_op(Bytecodes::Code code);
1819
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1783
diff changeset
222 void arithmetic_op(ValueType* type, Bytecodes::Code code, ValueStack* state_before = NULL);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
223 void negate_op(ValueType* type);
a61af66fc99e Initial load
duke
parents:
diff changeset
224 void shift_op(ValueType* type, Bytecodes::Code code);
a61af66fc99e Initial load
duke
parents:
diff changeset
225 void logic_op(ValueType* type, Bytecodes::Code code);
a61af66fc99e Initial load
duke
parents:
diff changeset
226 void compare_op(ValueType* type, Bytecodes::Code code);
a61af66fc99e Initial load
duke
parents:
diff changeset
227 void convert(Bytecodes::Code op, BasicType from, BasicType to);
a61af66fc99e Initial load
duke
parents:
diff changeset
228 void increment();
a61af66fc99e Initial load
duke
parents:
diff changeset
229 void _goto(int from_bci, int to_bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
230 void if_node(Value x, If::Condition cond, Value y, ValueStack* stack_before);
a61af66fc99e Initial load
duke
parents:
diff changeset
231 void if_zero(ValueType* type, If::Condition cond);
a61af66fc99e Initial load
duke
parents:
diff changeset
232 void if_null(ValueType* type, If::Condition cond);
a61af66fc99e Initial load
duke
parents:
diff changeset
233 void if_same(ValueType* type, If::Condition cond);
a61af66fc99e Initial load
duke
parents:
diff changeset
234 void jsr(int dest);
a61af66fc99e Initial load
duke
parents:
diff changeset
235 void ret(int local_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
236 void table_switch();
a61af66fc99e Initial load
duke
parents:
diff changeset
237 void lookup_switch();
a61af66fc99e Initial load
duke
parents:
diff changeset
238 void method_return(Value x);
a61af66fc99e Initial load
duke
parents:
diff changeset
239 void call_register_finalizer();
a61af66fc99e Initial load
duke
parents:
diff changeset
240 void access_field(Bytecodes::Code code);
a61af66fc99e Initial load
duke
parents:
diff changeset
241 void invoke(Bytecodes::Code code);
a61af66fc99e Initial load
duke
parents:
diff changeset
242 void new_instance(int klass_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
243 void new_type_array();
a61af66fc99e Initial load
duke
parents:
diff changeset
244 void new_object_array();
a61af66fc99e Initial load
duke
parents:
diff changeset
245 void check_cast(int klass_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
246 void instance_of(int klass_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
247 void monitorenter(Value x, int bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
248 void monitorexit(Value x, int bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
249 void new_multi_array(int dimensions);
a61af66fc99e Initial load
duke
parents:
diff changeset
250 void throw_op(int bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
251 Value round_fp(Value fp_value);
a61af66fc99e Initial load
duke
parents:
diff changeset
252
a61af66fc99e Initial load
duke
parents:
diff changeset
253 // stack/code manipulation helpers
a61af66fc99e Initial load
duke
parents:
diff changeset
254 Instruction* append_with_bci(Instruction* instr, int bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
255 Instruction* append(Instruction* instr);
a61af66fc99e Initial load
duke
parents:
diff changeset
256 Instruction* append_split(StateSplit* instr);
a61af66fc99e Initial load
duke
parents:
diff changeset
257
a61af66fc99e Initial load
duke
parents:
diff changeset
258 // other helpers
a61af66fc99e Initial load
duke
parents:
diff changeset
259 BlockBegin* block_at(int bci) { return scope_data()->block_at(bci); }
1819
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1783
diff changeset
260 XHandlers* handle_exception(Instruction* instruction);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
261 void connect_to_end(BlockBegin* beg);
a61af66fc99e Initial load
duke
parents:
diff changeset
262 void null_check(Value value);
a61af66fc99e Initial load
duke
parents:
diff changeset
263 void eliminate_redundant_phis(BlockBegin* start);
a61af66fc99e Initial load
duke
parents:
diff changeset
264 BlockEnd* iterate_bytecodes_for_block(int bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
265 void iterate_all_blocks(bool start_in_current_block_for_inlining = false);
a61af66fc99e Initial load
duke
parents:
diff changeset
266 Dependencies* dependency_recorder() const; // = compilation()->dependencies()
a61af66fc99e Initial load
duke
parents:
diff changeset
267 bool direct_compare(ciKlass* k);
a61af66fc99e Initial load
duke
parents:
diff changeset
268
a61af66fc99e Initial load
duke
parents:
diff changeset
269 void kill_all();
a61af66fc99e Initial load
duke
parents:
diff changeset
270
1819
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1783
diff changeset
271 // use of state copy routines (try to minimize unnecessary state
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1783
diff changeset
272 // object allocations):
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1783
diff changeset
273
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1783
diff changeset
274 // - if the instruction unconditionally needs a full copy of the
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1783
diff changeset
275 // state (for patching for example), then use copy_state_before*
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1783
diff changeset
276
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1783
diff changeset
277 // - if the instruction needs a full copy of the state only for
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1783
diff changeset
278 // handler generation (Instruction::needs_exception_state() returns
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1783
diff changeset
279 // false) then use copy_state_exhandling*
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1783
diff changeset
280
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1783
diff changeset
281 // - if the instruction needs either a full copy of the state for
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1783
diff changeset
282 // handler generation and a least a minimal copy of the state (as
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1783
diff changeset
283 // returned by Instruction::exception_state()) for debug info
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1783
diff changeset
284 // generation (that is when Instruction::needs_exception_state()
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1783
diff changeset
285 // returns true) then use copy_state_for_exception*
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1783
diff changeset
286
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1783
diff changeset
287 ValueStack* copy_state_before_with_bci(int bci);
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1783
diff changeset
288 ValueStack* copy_state_before();
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1783
diff changeset
289 ValueStack* copy_state_exhandling_with_bci(int bci);
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1783
diff changeset
290 ValueStack* copy_state_exhandling();
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1783
diff changeset
291 ValueStack* copy_state_for_exception_with_bci(int bci);
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1783
diff changeset
292 ValueStack* copy_state_for_exception();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
293
a61af66fc99e Initial load
duke
parents:
diff changeset
294 //
a61af66fc99e Initial load
duke
parents:
diff changeset
295 // Inlining support
a61af66fc99e Initial load
duke
parents:
diff changeset
296 //
a61af66fc99e Initial load
duke
parents:
diff changeset
297
a61af66fc99e Initial load
duke
parents:
diff changeset
298 // accessors
a61af66fc99e Initial load
duke
parents:
diff changeset
299 bool parsing_jsr() const { return scope_data()->parsing_jsr(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
300 BlockBegin* continuation() const { return scope_data()->continuation(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
301 BlockBegin* jsr_continuation() const { return scope_data()->jsr_continuation(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
302 void set_continuation(BlockBegin* continuation) { scope_data()->set_continuation(continuation); }
a61af66fc99e Initial load
duke
parents:
diff changeset
303 void set_inline_cleanup_info(BlockBegin* block,
a61af66fc99e Initial load
duke
parents:
diff changeset
304 Instruction* return_prev,
a61af66fc99e Initial load
duke
parents:
diff changeset
305 ValueStack* return_state) { scope_data()->set_inline_cleanup_info(block,
a61af66fc99e Initial load
duke
parents:
diff changeset
306 return_prev,
a61af66fc99e Initial load
duke
parents:
diff changeset
307 return_state); }
a61af66fc99e Initial load
duke
parents:
diff changeset
308 BlockBegin* inline_cleanup_block() const { return scope_data()->inline_cleanup_block(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
309 Instruction* inline_cleanup_return_prev() const { return scope_data()->inline_cleanup_return_prev(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
310 ValueStack* inline_cleanup_state() const { return scope_data()->inline_cleanup_state(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
311 void incr_num_returns() { scope_data()->incr_num_returns(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
312 int num_returns() const { return scope_data()->num_returns(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
313 intx max_inline_size() const { return scope_data()->max_inline_size(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
314 int inline_level() const { return scope()->level(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
315 int recursive_inline_level(ciMethod* callee) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
316
a61af66fc99e Initial load
duke
parents:
diff changeset
317 // inlining of synchronized methods
a61af66fc99e Initial load
duke
parents:
diff changeset
318 void inline_sync_entry(Value lock, BlockBegin* sync_handler);
a61af66fc99e Initial load
duke
parents:
diff changeset
319 void fill_sync_handler(Value lock, BlockBegin* sync_handler, bool default_handler = false);
a61af66fc99e Initial load
duke
parents:
diff changeset
320
a61af66fc99e Initial load
duke
parents:
diff changeset
321 // inliners
a61af66fc99e Initial load
duke
parents:
diff changeset
322 bool try_inline(ciMethod* callee, bool holder_known);
a61af66fc99e Initial load
duke
parents:
diff changeset
323 bool try_inline_intrinsics(ciMethod* callee);
a61af66fc99e Initial load
duke
parents:
diff changeset
324 bool try_inline_full (ciMethod* callee, bool holder_known);
a61af66fc99e Initial load
duke
parents:
diff changeset
325 bool try_inline_jsr(int jsr_dest_bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
326
a61af66fc99e Initial load
duke
parents:
diff changeset
327 // helpers
a61af66fc99e Initial load
duke
parents:
diff changeset
328 void inline_bailout(const char* msg);
a61af66fc99e Initial load
duke
parents:
diff changeset
329 BlockBegin* header_block(BlockBegin* entry, BlockBegin::Flag f, ValueStack* state);
a61af66fc99e Initial load
duke
parents:
diff changeset
330 BlockBegin* setup_start_block(int osr_bci, BlockBegin* std_entry, BlockBegin* osr_entry, ValueStack* init_state);
a61af66fc99e Initial load
duke
parents:
diff changeset
331 void setup_osr_entry_block();
a61af66fc99e Initial load
duke
parents:
diff changeset
332 void clear_inline_bailout();
a61af66fc99e Initial load
duke
parents:
diff changeset
333 ValueStack* state_at_entry();
a61af66fc99e Initial load
duke
parents:
diff changeset
334 void push_root_scope(IRScope* scope, BlockList* bci2block, BlockBegin* start);
a61af66fc99e Initial load
duke
parents:
diff changeset
335 void push_scope(ciMethod* callee, BlockBegin* continuation);
a61af66fc99e Initial load
duke
parents:
diff changeset
336 void push_scope_for_jsr(BlockBegin* jsr_continuation, int jsr_dest_bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
337 void pop_scope();
a61af66fc99e Initial load
duke
parents:
diff changeset
338 void pop_scope_for_jsr();
a61af66fc99e Initial load
duke
parents:
diff changeset
339
a61af66fc99e Initial load
duke
parents:
diff changeset
340 bool append_unsafe_get_obj(ciMethod* callee, BasicType t, bool is_volatile);
a61af66fc99e Initial load
duke
parents:
diff changeset
341 bool append_unsafe_put_obj(ciMethod* callee, BasicType t, bool is_volatile);
a61af66fc99e Initial load
duke
parents:
diff changeset
342 bool append_unsafe_get_raw(ciMethod* callee, BasicType t);
a61af66fc99e Initial load
duke
parents:
diff changeset
343 bool append_unsafe_put_raw(ciMethod* callee, BasicType t);
a61af66fc99e Initial load
duke
parents:
diff changeset
344 bool append_unsafe_prefetch(ciMethod* callee, bool is_store, bool is_static);
a61af66fc99e Initial load
duke
parents:
diff changeset
345 void append_unsafe_CAS(ciMethod* callee);
a61af66fc99e Initial load
duke
parents:
diff changeset
346
a61af66fc99e Initial load
duke
parents:
diff changeset
347 NOT_PRODUCT(void print_inline_result(ciMethod* callee, bool res);)
a61af66fc99e Initial load
duke
parents:
diff changeset
348
a61af66fc99e Initial load
duke
parents:
diff changeset
349 void profile_call(Value recv, ciKlass* predicted_holder);
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1584
diff changeset
350 void profile_invocation(ciMethod* inlinee, ValueStack* state, int bci);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
351
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1584
diff changeset
352 // Shortcuts to profiling control.
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1584
diff changeset
353 bool is_profiling() { return _compilation->is_profiling(); }
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1584
diff changeset
354 bool count_invocations() { return _compilation->count_invocations(); }
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1584
diff changeset
355 bool count_backedges() { return _compilation->count_backedges(); }
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1584
diff changeset
356 bool profile_branches() { return _compilation->profile_branches(); }
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1584
diff changeset
357 bool profile_calls() { return _compilation->profile_calls(); }
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1584
diff changeset
358 bool profile_inlined_calls() { return _compilation->profile_inlined_calls(); }
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1584
diff changeset
359 bool profile_checkcasts() { return _compilation->profile_checkcasts(); }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
360
a61af66fc99e Initial load
duke
parents:
diff changeset
361 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
362 NOT_PRODUCT(void print_stats();)
a61af66fc99e Initial load
duke
parents:
diff changeset
363
a61af66fc99e Initial load
duke
parents:
diff changeset
364 // initialization
a61af66fc99e Initial load
duke
parents:
diff changeset
365 static void initialize();
a61af66fc99e Initial load
duke
parents:
diff changeset
366
a61af66fc99e Initial load
duke
parents:
diff changeset
367 // public
a61af66fc99e Initial load
duke
parents:
diff changeset
368 static bool can_trap(ciMethod* method, Bytecodes::Code code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
369 assert(0 <= code && code < Bytecodes::number_of_java_codes, "illegal bytecode");
a61af66fc99e Initial load
duke
parents:
diff changeset
370 if (_can_trap[code]) return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
371 // special handling for finalizer registration
a61af66fc99e Initial load
duke
parents:
diff changeset
372 return code == Bytecodes::_return && method->intrinsic_id() == vmIntrinsics::_Object_init;
a61af66fc99e Initial load
duke
parents:
diff changeset
373 }
a61af66fc99e Initial load
duke
parents:
diff changeset
374
a61af66fc99e Initial load
duke
parents:
diff changeset
375 // creation
a61af66fc99e Initial load
duke
parents:
diff changeset
376 GraphBuilder(Compilation* compilation, IRScope* scope);
a61af66fc99e Initial load
duke
parents:
diff changeset
377 static void sort_top_into_worklist(BlockList* worklist, BlockBegin* top);
a61af66fc99e Initial load
duke
parents:
diff changeset
378
a61af66fc99e Initial load
duke
parents:
diff changeset
379 BlockBegin* start() const { return _start; }
a61af66fc99e Initial load
duke
parents:
diff changeset
380 };