Print this page
rev 1081 : imported patch indy-cleanup-6893081.patch
Split |
Close |
Expand all |
Collapse all |
--- old/src/share/vm/c1/c1_IR.hpp
+++ new/src/share/vm/c1/c1_IR.hpp
1 1 /*
2 2 * Copyright 1999-2009 Sun Microsystems, Inc. All Rights Reserved.
3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 4 *
5 5 * This code is free software; you can redistribute it and/or modify it
6 6 * under the terms of the GNU General Public License version 2 only, as
7 7 * published by the Free Software Foundation.
8 8 *
9 9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 12 * version 2 for more details (a copy is included in the LICENSE file that
13 13 * accompanied this code).
14 14 *
15 15 * You should have received a copy of the GNU General Public License version
16 16 * 2 along with this work; if not, write to the Free Software Foundation,
17 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 18 *
19 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 21 * have any questions.
22 22 *
23 23 */
24 24
25 25 // An XHandler is a C1 internal description for an exception handler
26 26
27 27 class XHandler: public CompilationResourceObj {
28 28 private:
29 29 ciExceptionHandler* _desc;
30 30
31 31 BlockBegin* _entry_block; // Entry block of xhandler
32 32 LIR_List* _entry_code; // LIR-operations that must be executed before jumping to entry_block
33 33 int _entry_pco; // pco where entry_code (or entry_block if no entry_code) starts
34 34 int _phi_operand; // For resolving of phi functions at begin of entry_block
35 35 int _scope_count; // for filling ExceptionRangeEntry::scope_count
36 36
37 37 #ifdef ASSERT
38 38 int _lir_op_id; // op_id of the LIR-operation throwing to this handler
39 39 #endif
40 40
41 41 public:
42 42 // creation
43 43 XHandler(ciExceptionHandler* desc)
44 44 : _desc(desc)
45 45 , _entry_block(NULL)
46 46 , _entry_code(NULL)
47 47 , _entry_pco(-1)
48 48 , _phi_operand(-1)
49 49 , _scope_count(-1)
50 50 #ifdef ASSERT
51 51 , _lir_op_id(-1)
52 52 #endif
53 53 { }
54 54
55 55 XHandler(XHandler* other)
56 56 : _desc(other->_desc)
57 57 , _entry_block(other->_entry_block)
58 58 , _entry_code(other->_entry_code)
59 59 , _entry_pco(other->_entry_pco)
60 60 , _phi_operand(other->_phi_operand)
61 61 , _scope_count(other->_scope_count)
62 62 #ifdef ASSERT
63 63 , _lir_op_id(other->_lir_op_id)
64 64 #endif
65 65 { }
66 66
67 67 // accessors for data of ciExceptionHandler
68 68 int beg_bci() const { return _desc->start(); }
69 69 int end_bci() const { return _desc->limit(); }
70 70 int handler_bci() const { return _desc->handler_bci(); }
71 71 bool is_catch_all() const { return _desc->is_catch_all(); }
72 72 int catch_type() const { return _desc->catch_klass_index(); }
73 73 ciInstanceKlass* catch_klass() const { return _desc->catch_klass(); }
74 74 bool covers(int bci) const { return beg_bci() <= bci && bci < end_bci(); }
75 75
76 76 // accessors for additional fields
77 77 BlockBegin* entry_block() const { return _entry_block; }
78 78 LIR_List* entry_code() const { return _entry_code; }
79 79 int entry_pco() const { return _entry_pco; }
80 80 int phi_operand() const { assert(_phi_operand != -1, "not set"); return _phi_operand; }
81 81 int scope_count() const { assert(_scope_count != -1, "not set"); return _scope_count; }
82 82 DEBUG_ONLY(int lir_op_id() const { return _lir_op_id; });
83 83
84 84 void set_entry_block(BlockBegin* entry_block) {
85 85 assert(entry_block->is_set(BlockBegin::exception_entry_flag), "must be an exception handler entry");
86 86 assert(entry_block->bci() == handler_bci(), "bci's must correspond");
87 87 _entry_block = entry_block;
88 88 }
89 89 void set_entry_code(LIR_List* entry_code) { _entry_code = entry_code; }
90 90 void set_entry_pco(int entry_pco) { _entry_pco = entry_pco; }
91 91 void set_phi_operand(int phi_operand) { _phi_operand = phi_operand; }
92 92 void set_scope_count(int scope_count) { _scope_count = scope_count; }
93 93 DEBUG_ONLY(void set_lir_op_id(int lir_op_id) { _lir_op_id = lir_op_id; });
94 94
95 95 bool equals(XHandler* other) const;
96 96 };
97 97
98 98 define_array(_XHandlerArray, XHandler*)
99 99 define_stack(_XHandlerList, _XHandlerArray)
100 100
101 101
102 102 // XHandlers is the C1 internal list of exception handlers for a method
103 103 class XHandlers: public CompilationResourceObj {
104 104 private:
105 105 _XHandlerList _list;
106 106
107 107 public:
108 108 // creation
109 109 XHandlers() : _list() { }
110 110 XHandlers(ciMethod* method);
111 111 XHandlers(XHandlers* other);
112 112
113 113 // accessors
114 114 int length() const { return _list.length(); }
115 115 XHandler* handler_at(int i) const { return _list.at(i); }
116 116 bool has_handlers() const { return _list.length() > 0; }
117 117 void append(XHandler* h) { _list.append(h); }
118 118 XHandler* remove_last() { return _list.pop(); }
119 119
120 120 bool could_catch(ciInstanceKlass* klass, bool type_is_exact) const;
121 121 bool equals(XHandlers* others) const;
122 122 };
123 123
124 124
125 125 class IRScope;
126 126 define_array(IRScopeArray, IRScope*)
127 127 define_stack(IRScopeList, IRScopeArray)
128 128
129 129 class Compilation;
130 130 class IRScope: public CompilationResourceObj {
131 131 private:
132 132 // hierarchy
133 133 Compilation* _compilation; // the current compilation
134 134 IRScope* _caller; // the caller scope, or NULL
135 135 int _caller_bci; // the caller bci of the corresponding (inlined) invoke, or < 0
136 136 ValueStack* _caller_state; // the caller state, or NULL
137 137 int _level; // the inlining level
138 138 ciMethod* _method; // the corresponding method
139 139 IRScopeList _callees; // the inlined method scopes
140 140
141 141 // graph
142 142 XHandlers* _xhandlers; // the exception handlers
143 143 int _number_of_locks; // the number of monitor lock slots needed
144 144 bool _monitor_pairing_ok; // the monitor pairing info
145 145 BlockBegin* _start; // the start block, successsors are method entries
146 146
147 147 // lock stack management
148 148 int _lock_stack_size; // number of expression stack elements which, if present,
149 149 // must be spilled to the stack because of exception
150 150 // handling inside inlined methods
151 151
152 152 BitMap _requires_phi_function; // bit is set if phi functions at loop headers are necessary for a local variable
153 153
154 154 // helper functions
155 155 BlockBegin* header_block(BlockBegin* entry, BlockBegin::Flag f, ValueStack* state);
156 156 BlockBegin* build_graph(Compilation* compilation, int osr_bci);
157 157
158 158 public:
159 159 // creation
160 160 IRScope(Compilation* compilation, IRScope* caller, int caller_bci, ciMethod* method, int osr_bci, bool create_graph = false);
161 161
162 162 // accessors
163 163 Compilation* compilation() const { return _compilation; }
164 164 IRScope* caller() const { return _caller; }
165 165 int caller_bci() const { return _caller_bci; }
166 166 ValueStack* caller_state() const { return _caller_state; }
167 167 int level() const { return _level; }
168 168 ciMethod* method() const { return _method; }
169 169 int max_stack() const; // NOTE: expensive
170 170 int lock_stack_size() const {
171 171 assert(_lock_stack_size != -1, "uninitialized");
172 172 return _lock_stack_size;
173 173 }
174 174 BitMap& requires_phi_function() { return _requires_phi_function; }
175 175
176 176 // mutators
177 177 // Needed because caller state is not ready at time of IRScope construction
178 178 void set_caller_state(ValueStack* state) { _caller_state = state; }
179 179 // Needed because caller state changes after IRScope construction.
180 180 // Computes number of expression stack elements whose state must be
181 181 // preserved in the case of an exception; these may be seen by
182 182 // caller scopes. Zero when inlining of methods containing exception
183 183 // handlers is disabled, otherwise a conservative approximation.
184 184 void compute_lock_stack_size();
185 185
186 186 // hierarchy
187 187 bool is_top_scope() const { return _caller == NULL; }
188 188 void add_callee(IRScope* callee) { _callees.append(callee); }
189 189 int number_of_callees() const { return _callees.length(); }
190 190 IRScope* callee_no(int i) const { return _callees.at(i); }
191 191 int top_scope_bci() const;
192 192
193 193 // accessors, graph
194 194 bool is_valid() const { return start() != NULL; }
195 195 XHandlers* xhandlers() const { return _xhandlers; }
196 196 int number_of_locks() const { return _number_of_locks; }
197 197 void set_min_number_of_locks(int n) { if (n > _number_of_locks) _number_of_locks = n; }
198 198 bool monitor_pairing_ok() const { return _monitor_pairing_ok; }
199 199 BlockBegin* start() const { return _start; }
200 200 };
201 201
202 202
203 203 //
204 204 // IRScopeDebugInfo records the debug information for a particular IRScope
205 205 // in a particular CodeEmitInfo. This allows the information to be computed
206 206 // once early enough for the OopMap to be available to the LIR and also to be
207 207 // reemited for different pcs using the same CodeEmitInfo without recomputing
208 208 // everything.
209 209 //
210 210
211 211 class IRScopeDebugInfo: public CompilationResourceObj {
212 212 private:
213 213 IRScope* _scope;
214 214 int _bci;
215 215 GrowableArray<ScopeValue*>* _locals;
216 216 GrowableArray<ScopeValue*>* _expressions;
217 217 GrowableArray<MonitorValue*>* _monitors;
218 218 IRScopeDebugInfo* _caller;
219 219
220 220 public:
221 221 IRScopeDebugInfo(IRScope* scope,
222 222 int bci,
223 223 GrowableArray<ScopeValue*>* locals,
224 224 GrowableArray<ScopeValue*>* expressions,
225 225 GrowableArray<MonitorValue*>* monitors,
226 226 IRScopeDebugInfo* caller):
227 227 _scope(scope)
228 228 , _locals(locals)
229 229 , _bci(bci)
230 230 , _expressions(expressions)
231 231 , _monitors(monitors)
232 232 , _caller(caller) {}
233 233
234 234
235 235 IRScope* scope() { return _scope; }
236 236 int bci() { return _bci; }
237 237 GrowableArray<ScopeValue*>* locals() { return _locals; }
238 238 GrowableArray<ScopeValue*>* expressions() { return _expressions; }
239 239 GrowableArray<MonitorValue*>* monitors() { return _monitors; }
240 240 IRScopeDebugInfo* caller() { return _caller; }
241 241
242 242 //Whether we should reexecute this bytecode for deopt
243 243 bool should_reexecute();
↓ open down ↓ |
243 lines elided |
↑ open up ↑ |
244 244
245 245 void record_debug_info(DebugInformationRecorder* recorder, int pc_offset, bool topmost) {
246 246 if (caller() != NULL) {
247 247 // Order is significant: Must record caller first.
248 248 caller()->record_debug_info(recorder, pc_offset, false/*topmost*/);
249 249 }
250 250 DebugToken* locvals = recorder->create_scope_values(locals());
251 251 DebugToken* expvals = recorder->create_scope_values(expressions());
252 252 DebugToken* monvals = recorder->create_monitor_values(monitors());
253 253 // reexecute allowed only for the topmost frame
254 - bool reexecute = topmost ? should_reexecute() : false;
255 - recorder->describe_scope(pc_offset, scope()->method(), bci(), reexecute, locvals, expvals, monvals);
254 + bool reexecute = topmost ? should_reexecute() : false;
255 + bool is_method_handle_invoke = false;
256 + recorder->describe_scope(pc_offset, scope()->method(), bci(), reexecute, is_method_handle_invoke, locvals, expvals, monvals);
256 257 }
257 258 };
258 259
259 260
260 261 class CodeEmitInfo: public CompilationResourceObj {
261 262 friend class LinearScan;
262 263 private:
263 264 IRScopeDebugInfo* _scope_debug_info;
264 265 IRScope* _scope;
265 266 XHandlers* _exception_handlers;
266 267 OopMap* _oop_map;
267 268 ValueStack* _stack; // used by deoptimization (contains also monitors
268 269 int _bci;
269 270 CodeEmitInfo* _next;
270 271 int _id;
271 272
272 273 FrameMap* frame_map() const { return scope()->compilation()->frame_map(); }
273 274 Compilation* compilation() const { return scope()->compilation(); }
274 275
275 276 public:
276 277
277 278 // use scope from ValueStack
278 279 CodeEmitInfo(int bci, ValueStack* stack, XHandlers* exception_handlers);
279 280
280 281 // used by natives
281 282 CodeEmitInfo(IRScope* scope, int bci)
282 283 : _scope(scope)
283 284 , _bci(bci)
284 285 , _oop_map(NULL)
285 286 , _scope_debug_info(NULL)
286 287 , _stack(NULL)
287 288 , _exception_handlers(NULL)
288 289 , _next(NULL)
289 290 , _id(-1) {
290 291 }
291 292
292 293 // make a copy
293 294 CodeEmitInfo(CodeEmitInfo* info, bool lock_stack_only = false);
294 295
295 296 // accessors
296 297 OopMap* oop_map() { return _oop_map; }
297 298 ciMethod* method() const { return _scope->method(); }
298 299 IRScope* scope() const { return _scope; }
299 300 XHandlers* exception_handlers() const { return _exception_handlers; }
300 301 ValueStack* stack() const { return _stack; }
301 302 int bci() const { return _bci; }
302 303
303 304 void add_register_oop(LIR_Opr opr);
304 305 void record_debug_info(DebugInformationRecorder* recorder, int pc_offset);
305 306
306 307 CodeEmitInfo* next() const { return _next; }
307 308 void set_next(CodeEmitInfo* next) { _next = next; }
308 309
309 310 int id() const { return _id; }
310 311 void set_id(int id) { _id = id; }
311 312 };
312 313
313 314
314 315 class IR: public CompilationResourceObj {
315 316 private:
316 317 Compilation* _compilation; // the current compilation
317 318 IRScope* _top_scope; // the root of the scope hierarchy
318 319 WordSize _locals_size; // the space required for all locals
319 320 int _num_loops; // Total number of loops
320 321 BlockList* _code; // the blocks in code generation order w/ use counts
321 322
322 323 public:
323 324 // creation
324 325 IR(Compilation* compilation, ciMethod* method, int osr_bci);
325 326
326 327 // accessors
327 328 bool is_valid() const { return top_scope()->is_valid(); }
328 329 Compilation* compilation() const { return _compilation; }
329 330 IRScope* top_scope() const { return _top_scope; }
330 331 int number_of_locks() const { return top_scope()->number_of_locks(); }
331 332 ciMethod* method() const { return top_scope()->method(); }
332 333 BlockBegin* start() const { return top_scope()->start(); }
333 334 BlockBegin* std_entry() const { return start()->end()->as_Base()->std_entry(); }
334 335 BlockBegin* osr_entry() const { return start()->end()->as_Base()->osr_entry(); }
335 336 WordSize locals_size() const { return _locals_size; }
336 337 int locals_size_in_words() const { return in_words(_locals_size); }
337 338 BlockList* code() const { return _code; }
338 339 int num_loops() const { return _num_loops; }
339 340 int max_stack() const { return top_scope()->max_stack(); } // expensive
340 341
341 342 // ir manipulation
342 343 void optimize();
343 344 void compute_predecessors();
344 345 void split_critical_edges();
345 346 void compute_code();
346 347 void compute_use_counts();
347 348
348 349 // The linear-scan order and the code emission order are equal, but
349 350 // this may change in future
350 351 BlockList* linear_scan_order() { assert(_code != NULL, "not computed"); return _code; }
351 352
352 353 // iteration
353 354 void iterate_preorder (BlockClosure* closure);
354 355 void iterate_postorder (BlockClosure* closure);
355 356 void iterate_linear_scan_order(BlockClosure* closure);
356 357
357 358 // debugging
358 359 static void print(BlockBegin* start, bool cfg_only, bool live_only = false) PRODUCT_RETURN;
359 360 void print(bool cfg_only, bool live_only = false) PRODUCT_RETURN;
360 361 void verify() PRODUCT_RETURN;
361 362 };
362 363
363 364
364 365 // Globally do instruction substitution and remove substituted
365 366 // instructions from the instruction list.
366 367 //
367 368
368 369 class SubstitutionResolver: public BlockClosure {
369 370 static void substitute(Value* v);
370 371
371 372 public:
372 373 SubstitutionResolver(IR* hir) {
373 374 hir->iterate_preorder(this);
374 375 }
375 376
376 377 SubstitutionResolver(BlockBegin* block) {
377 378 block->iterate_preorder(this);
378 379 }
379 380
380 381 virtual void block_do(BlockBegin* block);
381 382 };
↓ open down ↓ |
116 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX