Mercurial > hg > truffle
annotate src/share/vm/ci/ciTypeFlow.cpp @ 1299:9eba43136cb5
6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
Summary: Passing a null pointer to an InvokeDynamic function call should lead to a NullPointerException.
Reviewed-by: kvn, never
author | twisti |
---|---|
date | Tue, 16 Mar 2010 11:52:17 +0100 |
parents | 97125851f396 |
children | c18cbe5936b8 ab102d5d923e |
rev | line source |
---|---|
0 | 1 /* |
844 | 2 * Copyright 2000-2009 Sun Microsystems, Inc. All Rights Reserved. |
0 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | |
20 * CA 95054 USA or visit www.sun.com if you need additional information or | |
21 * have any questions. | |
22 * | |
23 */ | |
24 | |
25 #include "incls/_precompiled.incl" | |
26 #include "incls/_ciTypeFlow.cpp.incl" | |
27 | |
28 // ciTypeFlow::JsrSet | |
29 // | |
30 // A JsrSet represents some set of JsrRecords. This class | |
31 // is used to record a set of all jsr routines which we permit | |
32 // execution to return (ret) from. | |
33 // | |
34 // During abstract interpretation, JsrSets are used to determine | |
35 // whether two paths which reach a given block are unique, and | |
36 // should be cloned apart, or are compatible, and should merge | |
37 // together. | |
38 | |
39 // ------------------------------------------------------------------ | |
40 // ciTypeFlow::JsrSet::JsrSet | |
41 ciTypeFlow::JsrSet::JsrSet(Arena* arena, int default_len) { | |
42 if (arena != NULL) { | |
43 // Allocate growable array in Arena. | |
44 _set = new (arena) GrowableArray<JsrRecord*>(arena, default_len, 0, NULL); | |
45 } else { | |
46 // Allocate growable array in current ResourceArea. | |
47 _set = new GrowableArray<JsrRecord*>(4, 0, NULL, false); | |
48 } | |
49 } | |
50 | |
51 // ------------------------------------------------------------------ | |
52 // ciTypeFlow::JsrSet::copy_into | |
53 void ciTypeFlow::JsrSet::copy_into(JsrSet* jsrs) { | |
54 int len = size(); | |
55 jsrs->_set->clear(); | |
56 for (int i = 0; i < len; i++) { | |
57 jsrs->_set->append(_set->at(i)); | |
58 } | |
59 } | |
60 | |
61 // ------------------------------------------------------------------ | |
62 // ciTypeFlow::JsrSet::is_compatible_with | |
63 // | |
64 // !!!! MISGIVINGS ABOUT THIS... disregard | |
65 // | |
66 // Is this JsrSet compatible with some other JsrSet? | |
67 // | |
68 // In set-theoretic terms, a JsrSet can be viewed as a partial function | |
69 // from entry addresses to return addresses. Two JsrSets A and B are | |
70 // compatible iff | |
71 // | |
72 // For any x, | |
73 // A(x) defined and B(x) defined implies A(x) == B(x) | |
74 // | |
75 // Less formally, two JsrSets are compatible when they have identical | |
76 // return addresses for any entry addresses they share in common. | |
77 bool ciTypeFlow::JsrSet::is_compatible_with(JsrSet* other) { | |
78 // Walk through both sets in parallel. If the same entry address | |
79 // appears in both sets, then the return address must match for | |
80 // the sets to be compatible. | |
81 int size1 = size(); | |
82 int size2 = other->size(); | |
83 | |
84 // Special case. If nothing is on the jsr stack, then there can | |
85 // be no ret. | |
86 if (size2 == 0) { | |
87 return true; | |
88 } else if (size1 != size2) { | |
89 return false; | |
90 } else { | |
91 for (int i = 0; i < size1; i++) { | |
92 JsrRecord* record1 = record_at(i); | |
93 JsrRecord* record2 = other->record_at(i); | |
94 if (record1->entry_address() != record2->entry_address() || | |
95 record1->return_address() != record2->return_address()) { | |
96 return false; | |
97 } | |
98 } | |
99 return true; | |
100 } | |
101 | |
102 #if 0 | |
103 int pos1 = 0; | |
104 int pos2 = 0; | |
105 int size1 = size(); | |
106 int size2 = other->size(); | |
107 while (pos1 < size1 && pos2 < size2) { | |
108 JsrRecord* record1 = record_at(pos1); | |
109 JsrRecord* record2 = other->record_at(pos2); | |
110 int entry1 = record1->entry_address(); | |
111 int entry2 = record2->entry_address(); | |
112 if (entry1 < entry2) { | |
113 pos1++; | |
114 } else if (entry1 > entry2) { | |
115 pos2++; | |
116 } else { | |
117 if (record1->return_address() == record2->return_address()) { | |
118 pos1++; | |
119 pos2++; | |
120 } else { | |
121 // These two JsrSets are incompatible. | |
122 return false; | |
123 } | |
124 } | |
125 } | |
126 // The two JsrSets agree. | |
127 return true; | |
128 #endif | |
129 } | |
130 | |
131 // ------------------------------------------------------------------ | |
132 // ciTypeFlow::JsrSet::insert_jsr_record | |
133 // | |
134 // Insert the given JsrRecord into the JsrSet, maintaining the order | |
135 // of the set and replacing any element with the same entry address. | |
136 void ciTypeFlow::JsrSet::insert_jsr_record(JsrRecord* record) { | |
137 int len = size(); | |
138 int entry = record->entry_address(); | |
139 int pos = 0; | |
140 for ( ; pos < len; pos++) { | |
141 JsrRecord* current = record_at(pos); | |
142 if (entry == current->entry_address()) { | |
143 // Stomp over this entry. | |
144 _set->at_put(pos, record); | |
145 assert(size() == len, "must be same size"); | |
146 return; | |
147 } else if (entry < current->entry_address()) { | |
148 break; | |
149 } | |
150 } | |
151 | |
152 // Insert the record into the list. | |
153 JsrRecord* swap = record; | |
154 JsrRecord* temp = NULL; | |
155 for ( ; pos < len; pos++) { | |
156 temp = _set->at(pos); | |
157 _set->at_put(pos, swap); | |
158 swap = temp; | |
159 } | |
160 _set->append(swap); | |
161 assert(size() == len+1, "must be larger"); | |
162 } | |
163 | |
164 // ------------------------------------------------------------------ | |
165 // ciTypeFlow::JsrSet::remove_jsr_record | |
166 // | |
167 // Remove the JsrRecord with the given return address from the JsrSet. | |
168 void ciTypeFlow::JsrSet::remove_jsr_record(int return_address) { | |
169 int len = size(); | |
170 for (int i = 0; i < len; i++) { | |
171 if (record_at(i)->return_address() == return_address) { | |
172 // We have found the proper entry. Remove it from the | |
173 // JsrSet and exit. | |
174 for (int j = i+1; j < len ; j++) { | |
175 _set->at_put(j-1, _set->at(j)); | |
176 } | |
177 _set->trunc_to(len-1); | |
178 assert(size() == len-1, "must be smaller"); | |
179 return; | |
180 } | |
181 } | |
182 assert(false, "verify: returning from invalid subroutine"); | |
183 } | |
184 | |
185 // ------------------------------------------------------------------ | |
186 // ciTypeFlow::JsrSet::apply_control | |
187 // | |
188 // Apply the effect of a control-flow bytecode on the JsrSet. The | |
189 // only bytecodes that modify the JsrSet are jsr and ret. | |
190 void ciTypeFlow::JsrSet::apply_control(ciTypeFlow* analyzer, | |
191 ciBytecodeStream* str, | |
192 ciTypeFlow::StateVector* state) { | |
193 Bytecodes::Code code = str->cur_bc(); | |
194 if (code == Bytecodes::_jsr) { | |
195 JsrRecord* record = | |
196 analyzer->make_jsr_record(str->get_dest(), str->next_bci()); | |
197 insert_jsr_record(record); | |
198 } else if (code == Bytecodes::_jsr_w) { | |
199 JsrRecord* record = | |
200 analyzer->make_jsr_record(str->get_far_dest(), str->next_bci()); | |
201 insert_jsr_record(record); | |
202 } else if (code == Bytecodes::_ret) { | |
203 Cell local = state->local(str->get_index()); | |
204 ciType* return_address = state->type_at(local); | |
205 assert(return_address->is_return_address(), "verify: wrong type"); | |
206 if (size() == 0) { | |
207 // Ret-state underflow: Hit a ret w/o any previous jsrs. Bail out. | |
208 // This can happen when a loop is inside a finally clause (4614060). | |
209 analyzer->record_failure("OSR in finally clause"); | |
210 return; | |
211 } | |
212 remove_jsr_record(return_address->as_return_address()->bci()); | |
213 } | |
214 } | |
215 | |
216 #ifndef PRODUCT | |
217 // ------------------------------------------------------------------ | |
218 // ciTypeFlow::JsrSet::print_on | |
219 void ciTypeFlow::JsrSet::print_on(outputStream* st) const { | |
220 st->print("{ "); | |
221 int num_elements = size(); | |
222 if (num_elements > 0) { | |
223 int i = 0; | |
224 for( ; i < num_elements - 1; i++) { | |
225 _set->at(i)->print_on(st); | |
226 st->print(", "); | |
227 } | |
228 _set->at(i)->print_on(st); | |
229 st->print(" "); | |
230 } | |
231 st->print("}"); | |
232 } | |
233 #endif | |
234 | |
235 // ciTypeFlow::StateVector | |
236 // | |
237 // A StateVector summarizes the type information at some point in | |
238 // the program. | |
239 | |
240 // ------------------------------------------------------------------ | |
241 // ciTypeFlow::StateVector::type_meet | |
242 // | |
243 // Meet two types. | |
244 // | |
245 // The semi-lattice of types use by this analysis are modeled on those | |
246 // of the verifier. The lattice is as follows: | |
247 // | |
248 // top_type() >= all non-extremal types >= bottom_type | |
249 // and | |
250 // Every primitive type is comparable only with itself. The meet of | |
251 // reference types is determined by their kind: instance class, | |
252 // interface, or array class. The meet of two types of the same | |
253 // kind is their least common ancestor. The meet of two types of | |
254 // different kinds is always java.lang.Object. | |
255 ciType* ciTypeFlow::StateVector::type_meet_internal(ciType* t1, ciType* t2, ciTypeFlow* analyzer) { | |
256 assert(t1 != t2, "checked in caller"); | |
257 if (t1->equals(top_type())) { | |
258 return t2; | |
259 } else if (t2->equals(top_type())) { | |
260 return t1; | |
261 } else if (t1->is_primitive_type() || t2->is_primitive_type()) { | |
262 // Special case null_type. null_type meet any reference type T | |
263 // is T. null_type meet null_type is null_type. | |
264 if (t1->equals(null_type())) { | |
265 if (!t2->is_primitive_type() || t2->equals(null_type())) { | |
266 return t2; | |
267 } | |
268 } else if (t2->equals(null_type())) { | |
269 if (!t1->is_primitive_type()) { | |
270 return t1; | |
271 } | |
272 } | |
273 | |
274 // At least one of the two types is a non-top primitive type. | |
275 // The other type is not equal to it. Fall to bottom. | |
276 return bottom_type(); | |
277 } else { | |
278 // Both types are non-top non-primitive types. That is, | |
279 // both types are either instanceKlasses or arrayKlasses. | |
280 ciKlass* object_klass = analyzer->env()->Object_klass(); | |
281 ciKlass* k1 = t1->as_klass(); | |
282 ciKlass* k2 = t2->as_klass(); | |
283 if (k1->equals(object_klass) || k2->equals(object_klass)) { | |
284 return object_klass; | |
285 } else if (!k1->is_loaded() || !k2->is_loaded()) { | |
286 // Unloaded classes fall to java.lang.Object at a merge. | |
287 return object_klass; | |
288 } else if (k1->is_interface() != k2->is_interface()) { | |
289 // When an interface meets a non-interface, we get Object; | |
290 // This is what the verifier does. | |
291 return object_klass; | |
292 } else if (k1->is_array_klass() || k2->is_array_klass()) { | |
293 // When an array meets a non-array, we get Object. | |
294 // When objArray meets typeArray, we also get Object. | |
295 // And when typeArray meets different typeArray, we again get Object. | |
296 // But when objArray meets objArray, we look carefully at element types. | |
297 if (k1->is_obj_array_klass() && k2->is_obj_array_klass()) { | |
298 // Meet the element types, then construct the corresponding array type. | |
299 ciKlass* elem1 = k1->as_obj_array_klass()->element_klass(); | |
300 ciKlass* elem2 = k2->as_obj_array_klass()->element_klass(); | |
301 ciKlass* elem = type_meet_internal(elem1, elem2, analyzer)->as_klass(); | |
302 // Do an easy shortcut if one type is a super of the other. | |
303 if (elem == elem1) { | |
304 assert(k1 == ciObjArrayKlass::make(elem), "shortcut is OK"); | |
305 return k1; | |
306 } else if (elem == elem2) { | |
307 assert(k2 == ciObjArrayKlass::make(elem), "shortcut is OK"); | |
308 return k2; | |
309 } else { | |
310 return ciObjArrayKlass::make(elem); | |
311 } | |
312 } else { | |
313 return object_klass; | |
314 } | |
315 } else { | |
316 // Must be two plain old instance klasses. | |
317 assert(k1->is_instance_klass(), "previous cases handle non-instances"); | |
318 assert(k2->is_instance_klass(), "previous cases handle non-instances"); | |
319 return k1->least_common_ancestor(k2); | |
320 } | |
321 } | |
322 } | |
323 | |
324 | |
325 // ------------------------------------------------------------------ | |
326 // ciTypeFlow::StateVector::StateVector | |
327 // | |
328 // Build a new state vector | |
329 ciTypeFlow::StateVector::StateVector(ciTypeFlow* analyzer) { | |
330 _outer = analyzer; | |
331 _stack_size = -1; | |
332 _monitor_count = -1; | |
333 // Allocate the _types array | |
334 int max_cells = analyzer->max_cells(); | |
335 _types = (ciType**)analyzer->arena()->Amalloc(sizeof(ciType*) * max_cells); | |
336 for (int i=0; i<max_cells; i++) { | |
337 _types[i] = top_type(); | |
338 } | |
339 _trap_bci = -1; | |
340 _trap_index = 0; | |
367
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
341 _def_locals.clear(); |
0 | 342 } |
343 | |
367
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
344 |
0 | 345 // ------------------------------------------------------------------ |
346 // ciTypeFlow::get_start_state | |
347 // | |
348 // Set this vector to the method entry state. | |
349 const ciTypeFlow::StateVector* ciTypeFlow::get_start_state() { | |
350 StateVector* state = new StateVector(this); | |
351 if (is_osr_flow()) { | |
352 ciTypeFlow* non_osr_flow = method()->get_flow_analysis(); | |
353 if (non_osr_flow->failing()) { | |
354 record_failure(non_osr_flow->failure_reason()); | |
355 return NULL; | |
356 } | |
357 JsrSet* jsrs = new JsrSet(NULL, 16); | |
358 Block* non_osr_block = non_osr_flow->existing_block_at(start_bci(), jsrs); | |
359 if (non_osr_block == NULL) { | |
360 record_failure("cannot reach OSR point"); | |
361 return NULL; | |
362 } | |
363 // load up the non-OSR state at this point | |
364 non_osr_block->copy_state_into(state); | |
365 int non_osr_start = non_osr_block->start(); | |
366 if (non_osr_start != start_bci()) { | |
367 // must flow forward from it | |
368 if (CITraceTypeFlow) { | |
369 tty->print_cr(">> Interpreting pre-OSR block %d:", non_osr_start); | |
370 } | |
371 Block* block = block_at(non_osr_start, jsrs); | |
372 assert(block->limit() == start_bci(), "must flow forward to start"); | |
373 flow_block(block, state, jsrs); | |
374 } | |
375 return state; | |
376 // Note: The code below would be an incorrect for an OSR flow, | |
377 // even if it were possible for an OSR entry point to be at bci zero. | |
378 } | |
379 // "Push" the method signature into the first few locals. | |
380 state->set_stack_size(-max_locals()); | |
381 if (!method()->is_static()) { | |
382 state->push(method()->holder()); | |
383 assert(state->tos() == state->local(0), ""); | |
384 } | |
385 for (ciSignatureStream str(method()->signature()); | |
386 !str.at_return_type(); | |
387 str.next()) { | |
388 state->push_translate(str.type()); | |
389 } | |
390 // Set the rest of the locals to bottom. | |
391 Cell cell = state->next_cell(state->tos()); | |
392 state->set_stack_size(0); | |
393 int limit = state->limit_cell(); | |
394 for (; cell < limit; cell = state->next_cell(cell)) { | |
395 state->set_type_at(cell, state->bottom_type()); | |
396 } | |
397 // Lock an object, if necessary. | |
398 state->set_monitor_count(method()->is_synchronized() ? 1 : 0); | |
399 return state; | |
400 } | |
401 | |
402 // ------------------------------------------------------------------ | |
403 // ciTypeFlow::StateVector::copy_into | |
404 // | |
405 // Copy our value into some other StateVector | |
406 void ciTypeFlow::StateVector::copy_into(ciTypeFlow::StateVector* copy) | |
407 const { | |
408 copy->set_stack_size(stack_size()); | |
409 copy->set_monitor_count(monitor_count()); | |
410 Cell limit = limit_cell(); | |
411 for (Cell c = start_cell(); c < limit; c = next_cell(c)) { | |
412 copy->set_type_at(c, type_at(c)); | |
413 } | |
414 } | |
415 | |
416 // ------------------------------------------------------------------ | |
417 // ciTypeFlow::StateVector::meet | |
418 // | |
419 // Meets this StateVector with another, destructively modifying this | |
420 // one. Returns true if any modification takes place. | |
421 bool ciTypeFlow::StateVector::meet(const ciTypeFlow::StateVector* incoming) { | |
422 if (monitor_count() == -1) { | |
423 set_monitor_count(incoming->monitor_count()); | |
424 } | |
425 assert(monitor_count() == incoming->monitor_count(), "monitors must match"); | |
426 | |
427 if (stack_size() == -1) { | |
428 set_stack_size(incoming->stack_size()); | |
429 Cell limit = limit_cell(); | |
430 #ifdef ASSERT | |
431 { for (Cell c = start_cell(); c < limit; c = next_cell(c)) { | |
432 assert(type_at(c) == top_type(), ""); | |
433 } } | |
434 #endif | |
435 // Make a simple copy of the incoming state. | |
436 for (Cell c = start_cell(); c < limit; c = next_cell(c)) { | |
437 set_type_at(c, incoming->type_at(c)); | |
438 } | |
439 return true; // it is always different the first time | |
440 } | |
441 #ifdef ASSERT | |
442 if (stack_size() != incoming->stack_size()) { | |
443 _outer->method()->print_codes(); | |
444 tty->print_cr("!!!! Stack size conflict"); | |
445 tty->print_cr("Current state:"); | |
446 print_on(tty); | |
447 tty->print_cr("Incoming state:"); | |
448 ((StateVector*)incoming)->print_on(tty); | |
449 } | |
450 #endif | |
451 assert(stack_size() == incoming->stack_size(), "sanity"); | |
452 | |
453 bool different = false; | |
454 Cell limit = limit_cell(); | |
455 for (Cell c = start_cell(); c < limit; c = next_cell(c)) { | |
456 ciType* t1 = type_at(c); | |
457 ciType* t2 = incoming->type_at(c); | |
458 if (!t1->equals(t2)) { | |
459 ciType* new_type = type_meet(t1, t2); | |
460 if (!t1->equals(new_type)) { | |
461 set_type_at(c, new_type); | |
462 different = true; | |
463 } | |
464 } | |
465 } | |
466 return different; | |
467 } | |
468 | |
469 // ------------------------------------------------------------------ | |
470 // ciTypeFlow::StateVector::meet_exception | |
471 // | |
472 // Meets this StateVector with another, destructively modifying this | |
473 // one. The incoming state is coming via an exception. Returns true | |
474 // if any modification takes place. | |
475 bool ciTypeFlow::StateVector::meet_exception(ciInstanceKlass* exc, | |
476 const ciTypeFlow::StateVector* incoming) { | |
477 if (monitor_count() == -1) { | |
478 set_monitor_count(incoming->monitor_count()); | |
479 } | |
480 assert(monitor_count() == incoming->monitor_count(), "monitors must match"); | |
481 | |
482 if (stack_size() == -1) { | |
483 set_stack_size(1); | |
484 } | |
485 | |
486 assert(stack_size() == 1, "must have one-element stack"); | |
487 | |
488 bool different = false; | |
489 | |
490 // Meet locals from incoming array. | |
491 Cell limit = local(_outer->max_locals()-1); | |
492 for (Cell c = start_cell(); c <= limit; c = next_cell(c)) { | |
493 ciType* t1 = type_at(c); | |
494 ciType* t2 = incoming->type_at(c); | |
495 if (!t1->equals(t2)) { | |
496 ciType* new_type = type_meet(t1, t2); | |
497 if (!t1->equals(new_type)) { | |
498 set_type_at(c, new_type); | |
499 different = true; | |
500 } | |
501 } | |
502 } | |
503 | |
504 // Handle stack separately. When an exception occurs, the | |
505 // only stack entry is the exception instance. | |
506 ciType* tos_type = type_at_tos(); | |
507 if (!tos_type->equals(exc)) { | |
508 ciType* new_type = type_meet(tos_type, exc); | |
509 if (!tos_type->equals(new_type)) { | |
510 set_type_at_tos(new_type); | |
511 different = true; | |
512 } | |
513 } | |
514 | |
515 return different; | |
516 } | |
517 | |
518 // ------------------------------------------------------------------ | |
519 // ciTypeFlow::StateVector::push_translate | |
520 void ciTypeFlow::StateVector::push_translate(ciType* type) { | |
521 BasicType basic_type = type->basic_type(); | |
522 if (basic_type == T_BOOLEAN || basic_type == T_CHAR || | |
523 basic_type == T_BYTE || basic_type == T_SHORT) { | |
524 push_int(); | |
525 } else { | |
526 push(type); | |
527 if (type->is_two_word()) { | |
528 push(half_type(type)); | |
529 } | |
530 } | |
531 } | |
532 | |
533 // ------------------------------------------------------------------ | |
534 // ciTypeFlow::StateVector::do_aaload | |
535 void ciTypeFlow::StateVector::do_aaload(ciBytecodeStream* str) { | |
536 pop_int(); | |
537 ciObjArrayKlass* array_klass = pop_objArray(); | |
538 if (array_klass == NULL) { | |
539 // Did aaload on a null reference; push a null and ignore the exception. | |
540 // This instruction will never continue normally. All we have to do | |
541 // is report a value that will meet correctly with any downstream | |
542 // reference types on paths that will truly be executed. This null type | |
543 // meets with any reference type to yield that same reference type. | |
605 | 544 // (The compiler will generate an unconditional exception here.) |
0 | 545 push(null_type()); |
546 return; | |
547 } | |
548 if (!array_klass->is_loaded()) { | |
549 // Only fails for some -Xcomp runs | |
550 trap(str, array_klass, | |
551 Deoptimization::make_trap_request | |
552 (Deoptimization::Reason_unloaded, | |
553 Deoptimization::Action_reinterpret)); | |
554 return; | |
555 } | |
556 ciKlass* element_klass = array_klass->element_klass(); | |
557 if (!element_klass->is_loaded() && element_klass->is_instance_klass()) { | |
558 Untested("unloaded array element class in ciTypeFlow"); | |
559 trap(str, element_klass, | |
560 Deoptimization::make_trap_request | |
561 (Deoptimization::Reason_unloaded, | |
562 Deoptimization::Action_reinterpret)); | |
563 } else { | |
564 push_object(element_klass); | |
565 } | |
566 } | |
567 | |
568 | |
569 // ------------------------------------------------------------------ | |
570 // ciTypeFlow::StateVector::do_checkcast | |
571 void ciTypeFlow::StateVector::do_checkcast(ciBytecodeStream* str) { | |
572 bool will_link; | |
573 ciKlass* klass = str->get_klass(will_link); | |
574 if (!will_link) { | |
575 // VM's interpreter will not load 'klass' if object is NULL. | |
576 // Type flow after this block may still be needed in two situations: | |
577 // 1) C2 uses do_null_assert() and continues compilation for later blocks | |
578 // 2) C2 does an OSR compile in a later block (see bug 4778368). | |
579 pop_object(); | |
580 do_null_assert(klass); | |
581 } else { | |
582 pop_object(); | |
583 push_object(klass); | |
584 } | |
585 } | |
586 | |
587 // ------------------------------------------------------------------ | |
588 // ciTypeFlow::StateVector::do_getfield | |
589 void ciTypeFlow::StateVector::do_getfield(ciBytecodeStream* str) { | |
590 // could add assert here for type of object. | |
591 pop_object(); | |
592 do_getstatic(str); | |
593 } | |
594 | |
595 // ------------------------------------------------------------------ | |
596 // ciTypeFlow::StateVector::do_getstatic | |
597 void ciTypeFlow::StateVector::do_getstatic(ciBytecodeStream* str) { | |
598 bool will_link; | |
599 ciField* field = str->get_field(will_link); | |
600 if (!will_link) { | |
601 trap(str, field->holder(), str->get_field_holder_index()); | |
602 } else { | |
603 ciType* field_type = field->type(); | |
604 if (!field_type->is_loaded()) { | |
605 // Normally, we need the field's type to be loaded if we are to | |
606 // do anything interesting with its value. | |
607 // We used to do this: trap(str, str->get_field_signature_index()); | |
608 // | |
609 // There is one good reason not to trap here. Execution can | |
610 // get past this "getfield" or "getstatic" if the value of | |
611 // the field is null. As long as the value is null, the class | |
612 // does not need to be loaded! The compiler must assume that | |
613 // the value of the unloaded class reference is null; if the code | |
614 // ever sees a non-null value, loading has occurred. | |
615 // | |
616 // This actually happens often enough to be annoying. If the | |
617 // compiler throws an uncommon trap at this bytecode, you can | |
618 // get an endless loop of recompilations, when all the code | |
619 // needs to do is load a series of null values. Also, a trap | |
620 // here can make an OSR entry point unreachable, triggering the | |
621 // assert on non_osr_block in ciTypeFlow::get_start_state. | |
622 // (See bug 4379915.) | |
623 do_null_assert(field_type->as_klass()); | |
624 } else { | |
625 push_translate(field_type); | |
626 } | |
627 } | |
628 } | |
629 | |
630 // ------------------------------------------------------------------ | |
631 // ciTypeFlow::StateVector::do_invoke | |
632 void ciTypeFlow::StateVector::do_invoke(ciBytecodeStream* str, | |
633 bool has_receiver) { | |
634 bool will_link; | |
635 ciMethod* method = str->get_method(will_link); | |
636 if (!will_link) { | |
637 // We weren't able to find the method. | |
1137
97125851f396
6829187: compiler optimizations required for JSR 292
twisti
parents:
991
diff
changeset
|
638 if (str->cur_bc() == Bytecodes::_invokedynamic) { |
97125851f396
6829187: compiler optimizations required for JSR 292
twisti
parents:
991
diff
changeset
|
639 trap(str, NULL, |
97125851f396
6829187: compiler optimizations required for JSR 292
twisti
parents:
991
diff
changeset
|
640 Deoptimization::make_trap_request |
97125851f396
6829187: compiler optimizations required for JSR 292
twisti
parents:
991
diff
changeset
|
641 (Deoptimization::Reason_uninitialized, |
97125851f396
6829187: compiler optimizations required for JSR 292
twisti
parents:
991
diff
changeset
|
642 Deoptimization::Action_reinterpret)); |
97125851f396
6829187: compiler optimizations required for JSR 292
twisti
parents:
991
diff
changeset
|
643 } else { |
97125851f396
6829187: compiler optimizations required for JSR 292
twisti
parents:
991
diff
changeset
|
644 ciKlass* unloaded_holder = method->holder(); |
97125851f396
6829187: compiler optimizations required for JSR 292
twisti
parents:
991
diff
changeset
|
645 trap(str, unloaded_holder, str->get_method_holder_index()); |
97125851f396
6829187: compiler optimizations required for JSR 292
twisti
parents:
991
diff
changeset
|
646 } |
0 | 647 } else { |
648 ciSignature* signature = method->signature(); | |
649 ciSignatureStream sigstr(signature); | |
650 int arg_size = signature->size(); | |
651 int stack_base = stack_size() - arg_size; | |
652 int i = 0; | |
653 for( ; !sigstr.at_return_type(); sigstr.next()) { | |
654 ciType* type = sigstr.type(); | |
655 ciType* stack_type = type_at(stack(stack_base + i++)); | |
656 // Do I want to check this type? | |
657 // assert(stack_type->is_subtype_of(type), "bad type for field value"); | |
658 if (type->is_two_word()) { | |
659 ciType* stack_type2 = type_at(stack(stack_base + i++)); | |
660 assert(stack_type2->equals(half_type(type)), "must be 2nd half"); | |
661 } | |
662 } | |
663 assert(arg_size == i, "must match"); | |
664 for (int j = 0; j < arg_size; j++) { | |
665 pop(); | |
666 } | |
667 if (has_receiver) { | |
668 // Check this? | |
669 pop_object(); | |
670 } | |
671 assert(!sigstr.is_done(), "must have return type"); | |
672 ciType* return_type = sigstr.type(); | |
673 if (!return_type->is_void()) { | |
674 if (!return_type->is_loaded()) { | |
675 // As in do_getstatic(), generally speaking, we need the return type to | |
676 // be loaded if we are to do anything interesting with its value. | |
677 // We used to do this: trap(str, str->get_method_signature_index()); | |
678 // | |
679 // We do not trap here since execution can get past this invoke if | |
680 // the return value is null. As long as the value is null, the class | |
681 // does not need to be loaded! The compiler must assume that | |
682 // the value of the unloaded class reference is null; if the code | |
683 // ever sees a non-null value, loading has occurred. | |
684 // | |
685 // See do_getstatic() for similar explanation, as well as bug 4684993. | |
686 do_null_assert(return_type->as_klass()); | |
687 } else { | |
688 push_translate(return_type); | |
689 } | |
690 } | |
691 } | |
692 } | |
693 | |
694 // ------------------------------------------------------------------ | |
695 // ciTypeFlow::StateVector::do_jsr | |
696 void ciTypeFlow::StateVector::do_jsr(ciBytecodeStream* str) { | |
697 push(ciReturnAddress::make(str->next_bci())); | |
698 } | |
699 | |
700 // ------------------------------------------------------------------ | |
701 // ciTypeFlow::StateVector::do_ldc | |
702 void ciTypeFlow::StateVector::do_ldc(ciBytecodeStream* str) { | |
703 ciConstant con = str->get_constant(); | |
704 BasicType basic_type = con.basic_type(); | |
705 if (basic_type == T_ILLEGAL) { | |
706 // OutOfMemoryError in the CI while loading constant | |
707 push_null(); | |
708 outer()->record_failure("ldc did not link"); | |
709 return; | |
710 } | |
711 if (basic_type == T_OBJECT || basic_type == T_ARRAY) { | |
712 ciObject* obj = con.as_object(); | |
713 if (obj->is_null_object()) { | |
714 push_null(); | |
715 } else if (obj->is_klass()) { | |
716 // The type of ldc <class> is java.lang.Class | |
717 push_object(outer()->env()->Class_klass()); | |
718 } else { | |
719 push_object(obj->klass()); | |
720 } | |
721 } else { | |
722 push_translate(ciType::make(basic_type)); | |
723 } | |
724 } | |
725 | |
726 // ------------------------------------------------------------------ | |
727 // ciTypeFlow::StateVector::do_multianewarray | |
728 void ciTypeFlow::StateVector::do_multianewarray(ciBytecodeStream* str) { | |
729 int dimensions = str->get_dimensions(); | |
730 bool will_link; | |
731 ciArrayKlass* array_klass = str->get_klass(will_link)->as_array_klass(); | |
732 if (!will_link) { | |
733 trap(str, array_klass, str->get_klass_index()); | |
734 } else { | |
735 for (int i = 0; i < dimensions; i++) { | |
736 pop_int(); | |
737 } | |
738 push_object(array_klass); | |
739 } | |
740 } | |
741 | |
742 // ------------------------------------------------------------------ | |
743 // ciTypeFlow::StateVector::do_new | |
744 void ciTypeFlow::StateVector::do_new(ciBytecodeStream* str) { | |
745 bool will_link; | |
746 ciKlass* klass = str->get_klass(will_link); | |
367
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
747 if (!will_link || str->is_unresolved_klass()) { |
0 | 748 trap(str, klass, str->get_klass_index()); |
749 } else { | |
750 push_object(klass); | |
751 } | |
752 } | |
753 | |
754 // ------------------------------------------------------------------ | |
755 // ciTypeFlow::StateVector::do_newarray | |
756 void ciTypeFlow::StateVector::do_newarray(ciBytecodeStream* str) { | |
757 pop_int(); | |
758 ciKlass* klass = ciTypeArrayKlass::make((BasicType)str->get_index()); | |
759 push_object(klass); | |
760 } | |
761 | |
762 // ------------------------------------------------------------------ | |
763 // ciTypeFlow::StateVector::do_putfield | |
764 void ciTypeFlow::StateVector::do_putfield(ciBytecodeStream* str) { | |
765 do_putstatic(str); | |
766 if (_trap_bci != -1) return; // unloaded field holder, etc. | |
767 // could add assert here for type of object. | |
768 pop_object(); | |
769 } | |
770 | |
771 // ------------------------------------------------------------------ | |
772 // ciTypeFlow::StateVector::do_putstatic | |
773 void ciTypeFlow::StateVector::do_putstatic(ciBytecodeStream* str) { | |
774 bool will_link; | |
775 ciField* field = str->get_field(will_link); | |
776 if (!will_link) { | |
777 trap(str, field->holder(), str->get_field_holder_index()); | |
778 } else { | |
779 ciType* field_type = field->type(); | |
780 ciType* type = pop_value(); | |
781 // Do I want to check this type? | |
782 // assert(type->is_subtype_of(field_type), "bad type for field value"); | |
783 if (field_type->is_two_word()) { | |
784 ciType* type2 = pop_value(); | |
785 assert(type2->is_two_word(), "must be 2nd half"); | |
786 assert(type == half_type(type2), "must be 2nd half"); | |
787 } | |
788 } | |
789 } | |
790 | |
791 // ------------------------------------------------------------------ | |
792 // ciTypeFlow::StateVector::do_ret | |
793 void ciTypeFlow::StateVector::do_ret(ciBytecodeStream* str) { | |
794 Cell index = local(str->get_index()); | |
795 | |
796 ciType* address = type_at(index); | |
797 assert(address->is_return_address(), "bad return address"); | |
798 set_type_at(index, bottom_type()); | |
799 } | |
800 | |
801 // ------------------------------------------------------------------ | |
802 // ciTypeFlow::StateVector::trap | |
803 // | |
804 // Stop interpretation of this path with a trap. | |
805 void ciTypeFlow::StateVector::trap(ciBytecodeStream* str, ciKlass* klass, int index) { | |
806 _trap_bci = str->cur_bci(); | |
807 _trap_index = index; | |
808 | |
809 // Log information about this trap: | |
810 CompileLog* log = outer()->env()->log(); | |
811 if (log != NULL) { | |
812 int mid = log->identify(outer()->method()); | |
813 int kid = (klass == NULL)? -1: log->identify(klass); | |
814 log->begin_elem("uncommon_trap method='%d' bci='%d'", mid, str->cur_bci()); | |
815 char buf[100]; | |
816 log->print(" %s", Deoptimization::format_trap_request(buf, sizeof(buf), | |
817 index)); | |
818 if (kid >= 0) | |
819 log->print(" klass='%d'", kid); | |
820 log->end_elem(); | |
821 } | |
822 } | |
823 | |
824 // ------------------------------------------------------------------ | |
825 // ciTypeFlow::StateVector::do_null_assert | |
826 // Corresponds to graphKit::do_null_assert. | |
827 void ciTypeFlow::StateVector::do_null_assert(ciKlass* unloaded_klass) { | |
828 if (unloaded_klass->is_loaded()) { | |
829 // We failed to link, but we can still compute with this class, | |
830 // since it is loaded somewhere. The compiler will uncommon_trap | |
831 // if the object is not null, but the typeflow pass can not assume | |
832 // that the object will be null, otherwise it may incorrectly tell | |
833 // the parser that an object is known to be null. 4761344, 4807707 | |
834 push_object(unloaded_klass); | |
835 } else { | |
836 // The class is not loaded anywhere. It is safe to model the | |
837 // null in the typestates, because we can compile in a null check | |
838 // which will deoptimize us if someone manages to load the | |
839 // class later. | |
840 push_null(); | |
841 } | |
842 } | |
843 | |
844 | |
845 // ------------------------------------------------------------------ | |
846 // ciTypeFlow::StateVector::apply_one_bytecode | |
847 // | |
848 // Apply the effect of one bytecode to this StateVector | |
849 bool ciTypeFlow::StateVector::apply_one_bytecode(ciBytecodeStream* str) { | |
850 _trap_bci = -1; | |
851 _trap_index = 0; | |
852 | |
853 if (CITraceTypeFlow) { | |
854 tty->print_cr(">> Interpreting bytecode %d:%s", str->cur_bci(), | |
855 Bytecodes::name(str->cur_bc())); | |
856 } | |
857 | |
858 switch(str->cur_bc()) { | |
859 case Bytecodes::_aaload: do_aaload(str); break; | |
860 | |
861 case Bytecodes::_aastore: | |
862 { | |
863 pop_object(); | |
864 pop_int(); | |
865 pop_objArray(); | |
866 break; | |
867 } | |
868 case Bytecodes::_aconst_null: | |
869 { | |
870 push_null(); | |
871 break; | |
872 } | |
873 case Bytecodes::_aload: load_local_object(str->get_index()); break; | |
874 case Bytecodes::_aload_0: load_local_object(0); break; | |
875 case Bytecodes::_aload_1: load_local_object(1); break; | |
876 case Bytecodes::_aload_2: load_local_object(2); break; | |
877 case Bytecodes::_aload_3: load_local_object(3); break; | |
878 | |
879 case Bytecodes::_anewarray: | |
880 { | |
881 pop_int(); | |
882 bool will_link; | |
883 ciKlass* element_klass = str->get_klass(will_link); | |
884 if (!will_link) { | |
885 trap(str, element_klass, str->get_klass_index()); | |
886 } else { | |
887 push_object(ciObjArrayKlass::make(element_klass)); | |
888 } | |
889 break; | |
890 } | |
891 case Bytecodes::_areturn: | |
892 case Bytecodes::_ifnonnull: | |
893 case Bytecodes::_ifnull: | |
894 { | |
895 pop_object(); | |
896 break; | |
897 } | |
898 case Bytecodes::_monitorenter: | |
899 { | |
900 pop_object(); | |
901 set_monitor_count(monitor_count() + 1); | |
902 break; | |
903 } | |
904 case Bytecodes::_monitorexit: | |
905 { | |
906 pop_object(); | |
907 assert(monitor_count() > 0, "must be a monitor to exit from"); | |
908 set_monitor_count(monitor_count() - 1); | |
909 break; | |
910 } | |
911 case Bytecodes::_arraylength: | |
912 { | |
913 pop_array(); | |
914 push_int(); | |
915 break; | |
916 } | |
917 case Bytecodes::_astore: store_local_object(str->get_index()); break; | |
918 case Bytecodes::_astore_0: store_local_object(0); break; | |
919 case Bytecodes::_astore_1: store_local_object(1); break; | |
920 case Bytecodes::_astore_2: store_local_object(2); break; | |
921 case Bytecodes::_astore_3: store_local_object(3); break; | |
922 | |
923 case Bytecodes::_athrow: | |
924 { | |
925 NEEDS_CLEANUP; | |
926 pop_object(); | |
927 break; | |
928 } | |
929 case Bytecodes::_baload: | |
930 case Bytecodes::_caload: | |
931 case Bytecodes::_iaload: | |
932 case Bytecodes::_saload: | |
933 { | |
934 pop_int(); | |
935 ciTypeArrayKlass* array_klass = pop_typeArray(); | |
936 // Put assert here for right type? | |
937 push_int(); | |
938 break; | |
939 } | |
940 case Bytecodes::_bastore: | |
941 case Bytecodes::_castore: | |
942 case Bytecodes::_iastore: | |
943 case Bytecodes::_sastore: | |
944 { | |
945 pop_int(); | |
946 pop_int(); | |
947 pop_typeArray(); | |
948 // assert here? | |
949 break; | |
950 } | |
951 case Bytecodes::_bipush: | |
952 case Bytecodes::_iconst_m1: | |
953 case Bytecodes::_iconst_0: | |
954 case Bytecodes::_iconst_1: | |
955 case Bytecodes::_iconst_2: | |
956 case Bytecodes::_iconst_3: | |
957 case Bytecodes::_iconst_4: | |
958 case Bytecodes::_iconst_5: | |
959 case Bytecodes::_sipush: | |
960 { | |
961 push_int(); | |
962 break; | |
963 } | |
964 case Bytecodes::_checkcast: do_checkcast(str); break; | |
965 | |
966 case Bytecodes::_d2f: | |
967 { | |
968 pop_double(); | |
969 push_float(); | |
970 break; | |
971 } | |
972 case Bytecodes::_d2i: | |
973 { | |
974 pop_double(); | |
975 push_int(); | |
976 break; | |
977 } | |
978 case Bytecodes::_d2l: | |
979 { | |
980 pop_double(); | |
981 push_long(); | |
982 break; | |
983 } | |
984 case Bytecodes::_dadd: | |
985 case Bytecodes::_ddiv: | |
986 case Bytecodes::_dmul: | |
987 case Bytecodes::_drem: | |
988 case Bytecodes::_dsub: | |
989 { | |
990 pop_double(); | |
991 pop_double(); | |
992 push_double(); | |
993 break; | |
994 } | |
995 case Bytecodes::_daload: | |
996 { | |
997 pop_int(); | |
998 ciTypeArrayKlass* array_klass = pop_typeArray(); | |
999 // Put assert here for right type? | |
1000 push_double(); | |
1001 break; | |
1002 } | |
1003 case Bytecodes::_dastore: | |
1004 { | |
1005 pop_double(); | |
1006 pop_int(); | |
1007 pop_typeArray(); | |
1008 // assert here? | |
1009 break; | |
1010 } | |
1011 case Bytecodes::_dcmpg: | |
1012 case Bytecodes::_dcmpl: | |
1013 { | |
1014 pop_double(); | |
1015 pop_double(); | |
1016 push_int(); | |
1017 break; | |
1018 } | |
1019 case Bytecodes::_dconst_0: | |
1020 case Bytecodes::_dconst_1: | |
1021 { | |
1022 push_double(); | |
1023 break; | |
1024 } | |
1025 case Bytecodes::_dload: load_local_double(str->get_index()); break; | |
1026 case Bytecodes::_dload_0: load_local_double(0); break; | |
1027 case Bytecodes::_dload_1: load_local_double(1); break; | |
1028 case Bytecodes::_dload_2: load_local_double(2); break; | |
1029 case Bytecodes::_dload_3: load_local_double(3); break; | |
1030 | |
1031 case Bytecodes::_dneg: | |
1032 { | |
1033 pop_double(); | |
1034 push_double(); | |
1035 break; | |
1036 } | |
1037 case Bytecodes::_dreturn: | |
1038 { | |
1039 pop_double(); | |
1040 break; | |
1041 } | |
1042 case Bytecodes::_dstore: store_local_double(str->get_index()); break; | |
1043 case Bytecodes::_dstore_0: store_local_double(0); break; | |
1044 case Bytecodes::_dstore_1: store_local_double(1); break; | |
1045 case Bytecodes::_dstore_2: store_local_double(2); break; | |
1046 case Bytecodes::_dstore_3: store_local_double(3); break; | |
1047 | |
1048 case Bytecodes::_dup: | |
1049 { | |
1050 push(type_at_tos()); | |
1051 break; | |
1052 } | |
1053 case Bytecodes::_dup_x1: | |
1054 { | |
1055 ciType* value1 = pop_value(); | |
1056 ciType* value2 = pop_value(); | |
1057 push(value1); | |
1058 push(value2); | |
1059 push(value1); | |
1060 break; | |
1061 } | |
1062 case Bytecodes::_dup_x2: | |
1063 { | |
1064 ciType* value1 = pop_value(); | |
1065 ciType* value2 = pop_value(); | |
1066 ciType* value3 = pop_value(); | |
1067 push(value1); | |
1068 push(value3); | |
1069 push(value2); | |
1070 push(value1); | |
1071 break; | |
1072 } | |
1073 case Bytecodes::_dup2: | |
1074 { | |
1075 ciType* value1 = pop_value(); | |
1076 ciType* value2 = pop_value(); | |
1077 push(value2); | |
1078 push(value1); | |
1079 push(value2); | |
1080 push(value1); | |
1081 break; | |
1082 } | |
1083 case Bytecodes::_dup2_x1: | |
1084 { | |
1085 ciType* value1 = pop_value(); | |
1086 ciType* value2 = pop_value(); | |
1087 ciType* value3 = pop_value(); | |
1088 push(value2); | |
1089 push(value1); | |
1090 push(value3); | |
1091 push(value2); | |
1092 push(value1); | |
1093 break; | |
1094 } | |
1095 case Bytecodes::_dup2_x2: | |
1096 { | |
1097 ciType* value1 = pop_value(); | |
1098 ciType* value2 = pop_value(); | |
1099 ciType* value3 = pop_value(); | |
1100 ciType* value4 = pop_value(); | |
1101 push(value2); | |
1102 push(value1); | |
1103 push(value4); | |
1104 push(value3); | |
1105 push(value2); | |
1106 push(value1); | |
1107 break; | |
1108 } | |
1109 case Bytecodes::_f2d: | |
1110 { | |
1111 pop_float(); | |
1112 push_double(); | |
1113 break; | |
1114 } | |
1115 case Bytecodes::_f2i: | |
1116 { | |
1117 pop_float(); | |
1118 push_int(); | |
1119 break; | |
1120 } | |
1121 case Bytecodes::_f2l: | |
1122 { | |
1123 pop_float(); | |
1124 push_long(); | |
1125 break; | |
1126 } | |
1127 case Bytecodes::_fadd: | |
1128 case Bytecodes::_fdiv: | |
1129 case Bytecodes::_fmul: | |
1130 case Bytecodes::_frem: | |
1131 case Bytecodes::_fsub: | |
1132 { | |
1133 pop_float(); | |
1134 pop_float(); | |
1135 push_float(); | |
1136 break; | |
1137 } | |
1138 case Bytecodes::_faload: | |
1139 { | |
1140 pop_int(); | |
1141 ciTypeArrayKlass* array_klass = pop_typeArray(); | |
1142 // Put assert here. | |
1143 push_float(); | |
1144 break; | |
1145 } | |
1146 case Bytecodes::_fastore: | |
1147 { | |
1148 pop_float(); | |
1149 pop_int(); | |
1150 ciTypeArrayKlass* array_klass = pop_typeArray(); | |
1151 // Put assert here. | |
1152 break; | |
1153 } | |
1154 case Bytecodes::_fcmpg: | |
1155 case Bytecodes::_fcmpl: | |
1156 { | |
1157 pop_float(); | |
1158 pop_float(); | |
1159 push_int(); | |
1160 break; | |
1161 } | |
1162 case Bytecodes::_fconst_0: | |
1163 case Bytecodes::_fconst_1: | |
1164 case Bytecodes::_fconst_2: | |
1165 { | |
1166 push_float(); | |
1167 break; | |
1168 } | |
1169 case Bytecodes::_fload: load_local_float(str->get_index()); break; | |
1170 case Bytecodes::_fload_0: load_local_float(0); break; | |
1171 case Bytecodes::_fload_1: load_local_float(1); break; | |
1172 case Bytecodes::_fload_2: load_local_float(2); break; | |
1173 case Bytecodes::_fload_3: load_local_float(3); break; | |
1174 | |
1175 case Bytecodes::_fneg: | |
1176 { | |
1177 pop_float(); | |
1178 push_float(); | |
1179 break; | |
1180 } | |
1181 case Bytecodes::_freturn: | |
1182 { | |
1183 pop_float(); | |
1184 break; | |
1185 } | |
1186 case Bytecodes::_fstore: store_local_float(str->get_index()); break; | |
1187 case Bytecodes::_fstore_0: store_local_float(0); break; | |
1188 case Bytecodes::_fstore_1: store_local_float(1); break; | |
1189 case Bytecodes::_fstore_2: store_local_float(2); break; | |
1190 case Bytecodes::_fstore_3: store_local_float(3); break; | |
1191 | |
1192 case Bytecodes::_getfield: do_getfield(str); break; | |
1193 case Bytecodes::_getstatic: do_getstatic(str); break; | |
1194 | |
1195 case Bytecodes::_goto: | |
1196 case Bytecodes::_goto_w: | |
1197 case Bytecodes::_nop: | |
1198 case Bytecodes::_return: | |
1199 { | |
1200 // do nothing. | |
1201 break; | |
1202 } | |
1203 case Bytecodes::_i2b: | |
1204 case Bytecodes::_i2c: | |
1205 case Bytecodes::_i2s: | |
1206 case Bytecodes::_ineg: | |
1207 { | |
1208 pop_int(); | |
1209 push_int(); | |
1210 break; | |
1211 } | |
1212 case Bytecodes::_i2d: | |
1213 { | |
1214 pop_int(); | |
1215 push_double(); | |
1216 break; | |
1217 } | |
1218 case Bytecodes::_i2f: | |
1219 { | |
1220 pop_int(); | |
1221 push_float(); | |
1222 break; | |
1223 } | |
1224 case Bytecodes::_i2l: | |
1225 { | |
1226 pop_int(); | |
1227 push_long(); | |
1228 break; | |
1229 } | |
1230 case Bytecodes::_iadd: | |
1231 case Bytecodes::_iand: | |
1232 case Bytecodes::_idiv: | |
1233 case Bytecodes::_imul: | |
1234 case Bytecodes::_ior: | |
1235 case Bytecodes::_irem: | |
1236 case Bytecodes::_ishl: | |
1237 case Bytecodes::_ishr: | |
1238 case Bytecodes::_isub: | |
1239 case Bytecodes::_iushr: | |
1240 case Bytecodes::_ixor: | |
1241 { | |
1242 pop_int(); | |
1243 pop_int(); | |
1244 push_int(); | |
1245 break; | |
1246 } | |
1247 case Bytecodes::_if_acmpeq: | |
1248 case Bytecodes::_if_acmpne: | |
1249 { | |
1250 pop_object(); | |
1251 pop_object(); | |
1252 break; | |
1253 } | |
1254 case Bytecodes::_if_icmpeq: | |
1255 case Bytecodes::_if_icmpge: | |
1256 case Bytecodes::_if_icmpgt: | |
1257 case Bytecodes::_if_icmple: | |
1258 case Bytecodes::_if_icmplt: | |
1259 case Bytecodes::_if_icmpne: | |
1260 { | |
1261 pop_int(); | |
1262 pop_int(); | |
1263 break; | |
1264 } | |
1265 case Bytecodes::_ifeq: | |
1266 case Bytecodes::_ifle: | |
1267 case Bytecodes::_iflt: | |
1268 case Bytecodes::_ifge: | |
1269 case Bytecodes::_ifgt: | |
1270 case Bytecodes::_ifne: | |
1271 case Bytecodes::_ireturn: | |
1272 case Bytecodes::_lookupswitch: | |
1273 case Bytecodes::_tableswitch: | |
1274 { | |
1275 pop_int(); | |
1276 break; | |
1277 } | |
1278 case Bytecodes::_iinc: | |
1279 { | |
367
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1280 int lnum = str->get_index(); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1281 check_int(local(lnum)); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1282 store_to_local(lnum); |
0 | 1283 break; |
1284 } | |
1285 case Bytecodes::_iload: load_local_int(str->get_index()); break; | |
1286 case Bytecodes::_iload_0: load_local_int(0); break; | |
1287 case Bytecodes::_iload_1: load_local_int(1); break; | |
1288 case Bytecodes::_iload_2: load_local_int(2); break; | |
1289 case Bytecodes::_iload_3: load_local_int(3); break; | |
1290 | |
1291 case Bytecodes::_instanceof: | |
1292 { | |
1293 // Check for uncommon trap: | |
1294 do_checkcast(str); | |
1295 pop_object(); | |
1296 push_int(); | |
1297 break; | |
1298 } | |
1299 case Bytecodes::_invokeinterface: do_invoke(str, true); break; | |
1300 case Bytecodes::_invokespecial: do_invoke(str, true); break; | |
1301 case Bytecodes::_invokestatic: do_invoke(str, false); break; | |
1302 case Bytecodes::_invokevirtual: do_invoke(str, true); break; | |
1137
97125851f396
6829187: compiler optimizations required for JSR 292
twisti
parents:
991
diff
changeset
|
1303 case Bytecodes::_invokedynamic: do_invoke(str, false); break; |
0 | 1304 |
1305 case Bytecodes::_istore: store_local_int(str->get_index()); break; | |
1306 case Bytecodes::_istore_0: store_local_int(0); break; | |
1307 case Bytecodes::_istore_1: store_local_int(1); break; | |
1308 case Bytecodes::_istore_2: store_local_int(2); break; | |
1309 case Bytecodes::_istore_3: store_local_int(3); break; | |
1310 | |
1311 case Bytecodes::_jsr: | |
1312 case Bytecodes::_jsr_w: do_jsr(str); break; | |
1313 | |
1314 case Bytecodes::_l2d: | |
1315 { | |
1316 pop_long(); | |
1317 push_double(); | |
1318 break; | |
1319 } | |
1320 case Bytecodes::_l2f: | |
1321 { | |
1322 pop_long(); | |
1323 push_float(); | |
1324 break; | |
1325 } | |
1326 case Bytecodes::_l2i: | |
1327 { | |
1328 pop_long(); | |
1329 push_int(); | |
1330 break; | |
1331 } | |
1332 case Bytecodes::_ladd: | |
1333 case Bytecodes::_land: | |
1334 case Bytecodes::_ldiv: | |
1335 case Bytecodes::_lmul: | |
1336 case Bytecodes::_lor: | |
1337 case Bytecodes::_lrem: | |
1338 case Bytecodes::_lsub: | |
1339 case Bytecodes::_lxor: | |
1340 { | |
1341 pop_long(); | |
1342 pop_long(); | |
1343 push_long(); | |
1344 break; | |
1345 } | |
1346 case Bytecodes::_laload: | |
1347 { | |
1348 pop_int(); | |
1349 ciTypeArrayKlass* array_klass = pop_typeArray(); | |
1350 // Put assert here for right type? | |
1351 push_long(); | |
1352 break; | |
1353 } | |
1354 case Bytecodes::_lastore: | |
1355 { | |
1356 pop_long(); | |
1357 pop_int(); | |
1358 pop_typeArray(); | |
1359 // assert here? | |
1360 break; | |
1361 } | |
1362 case Bytecodes::_lcmp: | |
1363 { | |
1364 pop_long(); | |
1365 pop_long(); | |
1366 push_int(); | |
1367 break; | |
1368 } | |
1369 case Bytecodes::_lconst_0: | |
1370 case Bytecodes::_lconst_1: | |
1371 { | |
1372 push_long(); | |
1373 break; | |
1374 } | |
1375 case Bytecodes::_ldc: | |
1376 case Bytecodes::_ldc_w: | |
1377 case Bytecodes::_ldc2_w: | |
1378 { | |
1379 do_ldc(str); | |
1380 break; | |
1381 } | |
1382 | |
1383 case Bytecodes::_lload: load_local_long(str->get_index()); break; | |
1384 case Bytecodes::_lload_0: load_local_long(0); break; | |
1385 case Bytecodes::_lload_1: load_local_long(1); break; | |
1386 case Bytecodes::_lload_2: load_local_long(2); break; | |
1387 case Bytecodes::_lload_3: load_local_long(3); break; | |
1388 | |
1389 case Bytecodes::_lneg: | |
1390 { | |
1391 pop_long(); | |
1392 push_long(); | |
1393 break; | |
1394 } | |
1395 case Bytecodes::_lreturn: | |
1396 { | |
1397 pop_long(); | |
1398 break; | |
1399 } | |
1400 case Bytecodes::_lshl: | |
1401 case Bytecodes::_lshr: | |
1402 case Bytecodes::_lushr: | |
1403 { | |
1404 pop_int(); | |
1405 pop_long(); | |
1406 push_long(); | |
1407 break; | |
1408 } | |
1409 case Bytecodes::_lstore: store_local_long(str->get_index()); break; | |
1410 case Bytecodes::_lstore_0: store_local_long(0); break; | |
1411 case Bytecodes::_lstore_1: store_local_long(1); break; | |
1412 case Bytecodes::_lstore_2: store_local_long(2); break; | |
1413 case Bytecodes::_lstore_3: store_local_long(3); break; | |
1414 | |
1415 case Bytecodes::_multianewarray: do_multianewarray(str); break; | |
1416 | |
1417 case Bytecodes::_new: do_new(str); break; | |
1418 | |
1419 case Bytecodes::_newarray: do_newarray(str); break; | |
1420 | |
1421 case Bytecodes::_pop: | |
1422 { | |
1423 pop(); | |
1424 break; | |
1425 } | |
1426 case Bytecodes::_pop2: | |
1427 { | |
1428 pop(); | |
1429 pop(); | |
1430 break; | |
1431 } | |
1432 | |
1433 case Bytecodes::_putfield: do_putfield(str); break; | |
1434 case Bytecodes::_putstatic: do_putstatic(str); break; | |
1435 | |
1436 case Bytecodes::_ret: do_ret(str); break; | |
1437 | |
1438 case Bytecodes::_swap: | |
1439 { | |
1440 ciType* value1 = pop_value(); | |
1441 ciType* value2 = pop_value(); | |
1442 push(value1); | |
1443 push(value2); | |
1444 break; | |
1445 } | |
1446 case Bytecodes::_wide: | |
1447 default: | |
1448 { | |
1449 // The iterator should skip this. | |
1450 ShouldNotReachHere(); | |
1451 break; | |
1452 } | |
1453 } | |
1454 | |
1455 if (CITraceTypeFlow) { | |
1456 print_on(tty); | |
1457 } | |
1458 | |
1459 return (_trap_bci != -1); | |
1460 } | |
1461 | |
1462 #ifndef PRODUCT | |
1463 // ------------------------------------------------------------------ | |
1464 // ciTypeFlow::StateVector::print_cell_on | |
1465 void ciTypeFlow::StateVector::print_cell_on(outputStream* st, Cell c) const { | |
1466 ciType* type = type_at(c); | |
1467 if (type == top_type()) { | |
1468 st->print("top"); | |
1469 } else if (type == bottom_type()) { | |
1470 st->print("bottom"); | |
1471 } else if (type == null_type()) { | |
1472 st->print("null"); | |
1473 } else if (type == long2_type()) { | |
1474 st->print("long2"); | |
1475 } else if (type == double2_type()) { | |
1476 st->print("double2"); | |
1477 } else if (is_int(type)) { | |
1478 st->print("int"); | |
1479 } else if (is_long(type)) { | |
1480 st->print("long"); | |
1481 } else if (is_float(type)) { | |
1482 st->print("float"); | |
1483 } else if (is_double(type)) { | |
1484 st->print("double"); | |
1485 } else if (type->is_return_address()) { | |
1486 st->print("address(%d)", type->as_return_address()->bci()); | |
1487 } else { | |
1488 if (type->is_klass()) { | |
1489 type->as_klass()->name()->print_symbol_on(st); | |
1490 } else { | |
1491 st->print("UNEXPECTED TYPE"); | |
1492 type->print(); | |
1493 } | |
1494 } | |
1495 } | |
1496 | |
1497 // ------------------------------------------------------------------ | |
1498 // ciTypeFlow::StateVector::print_on | |
1499 void ciTypeFlow::StateVector::print_on(outputStream* st) const { | |
1500 int num_locals = _outer->max_locals(); | |
1501 int num_stack = stack_size(); | |
1502 int num_monitors = monitor_count(); | |
1503 st->print_cr(" State : locals %d, stack %d, monitors %d", num_locals, num_stack, num_monitors); | |
1504 if (num_stack >= 0) { | |
1505 int i; | |
1506 for (i = 0; i < num_locals; i++) { | |
1507 st->print(" local %2d : ", i); | |
1508 print_cell_on(st, local(i)); | |
1509 st->cr(); | |
1510 } | |
1511 for (i = 0; i < num_stack; i++) { | |
1512 st->print(" stack %2d : ", i); | |
1513 print_cell_on(st, stack(i)); | |
1514 st->cr(); | |
1515 } | |
1516 } | |
1517 } | |
1518 #endif | |
1519 | |
367
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1520 |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1521 // ------------------------------------------------------------------ |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1522 // ciTypeFlow::SuccIter::next |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1523 // |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1524 void ciTypeFlow::SuccIter::next() { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1525 int succ_ct = _pred->successors()->length(); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1526 int next = _index + 1; |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1527 if (next < succ_ct) { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1528 _index = next; |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1529 _succ = _pred->successors()->at(next); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1530 return; |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1531 } |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1532 for (int i = next - succ_ct; i < _pred->exceptions()->length(); i++) { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1533 // Do not compile any code for unloaded exception types. |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1534 // Following compiler passes are responsible for doing this also. |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1535 ciInstanceKlass* exception_klass = _pred->exc_klasses()->at(i); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1536 if (exception_klass->is_loaded()) { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1537 _index = next; |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1538 _succ = _pred->exceptions()->at(i); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1539 return; |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1540 } |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1541 next++; |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1542 } |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1543 _index = -1; |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1544 _succ = NULL; |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1545 } |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1546 |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1547 // ------------------------------------------------------------------ |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1548 // ciTypeFlow::SuccIter::set_succ |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1549 // |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1550 void ciTypeFlow::SuccIter::set_succ(Block* succ) { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1551 int succ_ct = _pred->successors()->length(); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1552 if (_index < succ_ct) { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1553 _pred->successors()->at_put(_index, succ); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1554 } else { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1555 int idx = _index - succ_ct; |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1556 _pred->exceptions()->at_put(idx, succ); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1557 } |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1558 } |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1559 |
0 | 1560 // ciTypeFlow::Block |
1561 // | |
1562 // A basic block. | |
1563 | |
1564 // ------------------------------------------------------------------ | |
1565 // ciTypeFlow::Block::Block | |
1566 ciTypeFlow::Block::Block(ciTypeFlow* outer, | |
1567 ciBlock *ciblk, | |
1568 ciTypeFlow::JsrSet* jsrs) { | |
1569 _ciblock = ciblk; | |
1570 _exceptions = NULL; | |
1571 _exc_klasses = NULL; | |
1572 _successors = NULL; | |
1573 _state = new (outer->arena()) StateVector(outer); | |
1574 JsrSet* new_jsrs = | |
1575 new (outer->arena()) JsrSet(outer->arena(), jsrs->size()); | |
1576 jsrs->copy_into(new_jsrs); | |
1577 _jsrs = new_jsrs; | |
1578 _next = NULL; | |
1579 _on_work_list = false; | |
367
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1580 _backedge_copy = false; |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1581 _exception_entry = false; |
0 | 1582 _trap_bci = -1; |
1583 _trap_index = 0; | |
367
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1584 df_init(); |
0 | 1585 |
1586 if (CITraceTypeFlow) { | |
1587 tty->print_cr(">> Created new block"); | |
1588 print_on(tty); | |
1589 } | |
1590 | |
1591 assert(this->outer() == outer, "outer link set up"); | |
1592 assert(!outer->have_block_count(), "must not have mapped blocks yet"); | |
1593 } | |
1594 | |
1595 // ------------------------------------------------------------------ | |
367
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1596 // ciTypeFlow::Block::df_init |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1597 void ciTypeFlow::Block::df_init() { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1598 _pre_order = -1; assert(!has_pre_order(), ""); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1599 _post_order = -1; assert(!has_post_order(), ""); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1600 _loop = NULL; |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1601 _irreducible_entry = false; |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1602 _rpo_next = NULL; |
0 | 1603 } |
1604 | |
1605 // ------------------------------------------------------------------ | |
1606 // ciTypeFlow::Block::successors | |
1607 // | |
1608 // Get the successors for this Block. | |
1609 GrowableArray<ciTypeFlow::Block*>* | |
1610 ciTypeFlow::Block::successors(ciBytecodeStream* str, | |
1611 ciTypeFlow::StateVector* state, | |
1612 ciTypeFlow::JsrSet* jsrs) { | |
1613 if (_successors == NULL) { | |
1614 if (CITraceTypeFlow) { | |
1615 tty->print(">> Computing successors for block "); | |
1616 print_value_on(tty); | |
1617 tty->cr(); | |
1618 } | |
1619 | |
1620 ciTypeFlow* analyzer = outer(); | |
1621 Arena* arena = analyzer->arena(); | |
1622 Block* block = NULL; | |
1623 bool has_successor = !has_trap() && | |
1624 (control() != ciBlock::fall_through_bci || limit() < analyzer->code_size()); | |
1625 if (!has_successor) { | |
1626 _successors = | |
1627 new (arena) GrowableArray<Block*>(arena, 1, 0, NULL); | |
1628 // No successors | |
1629 } else if (control() == ciBlock::fall_through_bci) { | |
1630 assert(str->cur_bci() == limit(), "bad block end"); | |
1631 // This block simply falls through to the next. | |
1632 _successors = | |
1633 new (arena) GrowableArray<Block*>(arena, 1, 0, NULL); | |
1634 | |
1635 Block* block = analyzer->block_at(limit(), _jsrs); | |
1636 assert(_successors->length() == FALL_THROUGH, ""); | |
1637 _successors->append(block); | |
1638 } else { | |
1639 int current_bci = str->cur_bci(); | |
1640 int next_bci = str->next_bci(); | |
1641 int branch_bci = -1; | |
1642 Block* target = NULL; | |
1643 assert(str->next_bci() == limit(), "bad block end"); | |
1644 // This block is not a simple fall-though. Interpret | |
1645 // the current bytecode to find our successors. | |
1646 switch (str->cur_bc()) { | |
1647 case Bytecodes::_ifeq: case Bytecodes::_ifne: | |
1648 case Bytecodes::_iflt: case Bytecodes::_ifge: | |
1649 case Bytecodes::_ifgt: case Bytecodes::_ifle: | |
1650 case Bytecodes::_if_icmpeq: case Bytecodes::_if_icmpne: | |
1651 case Bytecodes::_if_icmplt: case Bytecodes::_if_icmpge: | |
1652 case Bytecodes::_if_icmpgt: case Bytecodes::_if_icmple: | |
1653 case Bytecodes::_if_acmpeq: case Bytecodes::_if_acmpne: | |
1654 case Bytecodes::_ifnull: case Bytecodes::_ifnonnull: | |
1655 // Our successors are the branch target and the next bci. | |
1656 branch_bci = str->get_dest(); | |
1657 _successors = | |
1658 new (arena) GrowableArray<Block*>(arena, 2, 0, NULL); | |
1659 assert(_successors->length() == IF_NOT_TAKEN, ""); | |
1660 _successors->append(analyzer->block_at(next_bci, jsrs)); | |
1661 assert(_successors->length() == IF_TAKEN, ""); | |
1662 _successors->append(analyzer->block_at(branch_bci, jsrs)); | |
1663 break; | |
1664 | |
1665 case Bytecodes::_goto: | |
1666 branch_bci = str->get_dest(); | |
1667 _successors = | |
1668 new (arena) GrowableArray<Block*>(arena, 1, 0, NULL); | |
1669 assert(_successors->length() == GOTO_TARGET, ""); | |
367
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1670 _successors->append(analyzer->block_at(branch_bci, jsrs)); |
0 | 1671 break; |
1672 | |
1673 case Bytecodes::_jsr: | |
1674 branch_bci = str->get_dest(); | |
1675 _successors = | |
1676 new (arena) GrowableArray<Block*>(arena, 1, 0, NULL); | |
1677 assert(_successors->length() == GOTO_TARGET, ""); | |
1678 _successors->append(analyzer->block_at(branch_bci, jsrs)); | |
1679 break; | |
1680 | |
1681 case Bytecodes::_goto_w: | |
1682 case Bytecodes::_jsr_w: | |
1683 _successors = | |
1684 new (arena) GrowableArray<Block*>(arena, 1, 0, NULL); | |
1685 assert(_successors->length() == GOTO_TARGET, ""); | |
1686 _successors->append(analyzer->block_at(str->get_far_dest(), jsrs)); | |
1687 break; | |
1688 | |
1689 case Bytecodes::_tableswitch: { | |
1690 Bytecode_tableswitch *tableswitch = | |
1691 Bytecode_tableswitch_at(str->cur_bcp()); | |
1692 | |
1693 int len = tableswitch->length(); | |
1694 _successors = | |
1695 new (arena) GrowableArray<Block*>(arena, len+1, 0, NULL); | |
1696 int bci = current_bci + tableswitch->default_offset(); | |
1697 Block* block = analyzer->block_at(bci, jsrs); | |
1698 assert(_successors->length() == SWITCH_DEFAULT, ""); | |
1699 _successors->append(block); | |
1700 while (--len >= 0) { | |
1701 int bci = current_bci + tableswitch->dest_offset_at(len); | |
1702 block = analyzer->block_at(bci, jsrs); | |
1703 assert(_successors->length() >= SWITCH_CASES, ""); | |
1704 _successors->append_if_missing(block); | |
1705 } | |
1706 break; | |
1707 } | |
1708 | |
1709 case Bytecodes::_lookupswitch: { | |
1710 Bytecode_lookupswitch *lookupswitch = | |
1711 Bytecode_lookupswitch_at(str->cur_bcp()); | |
1712 | |
1713 int npairs = lookupswitch->number_of_pairs(); | |
1714 _successors = | |
1715 new (arena) GrowableArray<Block*>(arena, npairs+1, 0, NULL); | |
1716 int bci = current_bci + lookupswitch->default_offset(); | |
1717 Block* block = analyzer->block_at(bci, jsrs); | |
1718 assert(_successors->length() == SWITCH_DEFAULT, ""); | |
1719 _successors->append(block); | |
1720 while(--npairs >= 0) { | |
1721 LookupswitchPair *pair = lookupswitch->pair_at(npairs); | |
1722 int bci = current_bci + pair->offset(); | |
1723 Block* block = analyzer->block_at(bci, jsrs); | |
1724 assert(_successors->length() >= SWITCH_CASES, ""); | |
1725 _successors->append_if_missing(block); | |
1726 } | |
1727 break; | |
1728 } | |
1729 | |
1730 case Bytecodes::_athrow: case Bytecodes::_ireturn: | |
1731 case Bytecodes::_lreturn: case Bytecodes::_freturn: | |
1732 case Bytecodes::_dreturn: case Bytecodes::_areturn: | |
1733 case Bytecodes::_return: | |
1734 _successors = | |
1735 new (arena) GrowableArray<Block*>(arena, 1, 0, NULL); | |
1736 // No successors | |
1737 break; | |
1738 | |
1739 case Bytecodes::_ret: { | |
1740 _successors = | |
1741 new (arena) GrowableArray<Block*>(arena, 1, 0, NULL); | |
1742 | |
1743 Cell local = state->local(str->get_index()); | |
1744 ciType* return_address = state->type_at(local); | |
1745 assert(return_address->is_return_address(), "verify: wrong type"); | |
1746 int bci = return_address->as_return_address()->bci(); | |
1747 assert(_successors->length() == GOTO_TARGET, ""); | |
1748 _successors->append(analyzer->block_at(bci, jsrs)); | |
1749 break; | |
1750 } | |
1751 | |
1752 case Bytecodes::_wide: | |
1753 default: | |
1754 ShouldNotReachHere(); | |
1755 break; | |
1756 } | |
1757 } | |
1758 } | |
1759 return _successors; | |
1760 } | |
1761 | |
1762 // ------------------------------------------------------------------ | |
1763 // ciTypeFlow::Block:compute_exceptions | |
1764 // | |
1765 // Compute the exceptional successors and types for this Block. | |
1766 void ciTypeFlow::Block::compute_exceptions() { | |
1767 assert(_exceptions == NULL && _exc_klasses == NULL, "repeat"); | |
1768 | |
1769 if (CITraceTypeFlow) { | |
1770 tty->print(">> Computing exceptions for block "); | |
1771 print_value_on(tty); | |
1772 tty->cr(); | |
1773 } | |
1774 | |
1775 ciTypeFlow* analyzer = outer(); | |
1776 Arena* arena = analyzer->arena(); | |
1777 | |
1778 // Any bci in the block will do. | |
1779 ciExceptionHandlerStream str(analyzer->method(), start()); | |
1780 | |
1781 // Allocate our growable arrays. | |
1782 int exc_count = str.count(); | |
1783 _exceptions = new (arena) GrowableArray<Block*>(arena, exc_count, 0, NULL); | |
1784 _exc_klasses = new (arena) GrowableArray<ciInstanceKlass*>(arena, exc_count, | |
1785 0, NULL); | |
1786 | |
1787 for ( ; !str.is_done(); str.next()) { | |
1788 ciExceptionHandler* handler = str.handler(); | |
1789 int bci = handler->handler_bci(); | |
1790 ciInstanceKlass* klass = NULL; | |
1791 if (bci == -1) { | |
1792 // There is no catch all. It is possible to exit the method. | |
1793 break; | |
1794 } | |
1795 if (handler->is_catch_all()) { | |
1796 klass = analyzer->env()->Throwable_klass(); | |
1797 } else { | |
1798 klass = handler->catch_klass(); | |
1799 } | |
1800 _exceptions->append(analyzer->block_at(bci, _jsrs)); | |
1801 _exc_klasses->append(klass); | |
1802 } | |
1803 } | |
1804 | |
1805 // ------------------------------------------------------------------ | |
367
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1806 // ciTypeFlow::Block::set_backedge_copy |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1807 // Use this only to make a pre-existing public block into a backedge copy. |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1808 void ciTypeFlow::Block::set_backedge_copy(bool z) { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1809 assert(z || (z == is_backedge_copy()), "cannot make a backedge copy public"); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1810 _backedge_copy = z; |
0 | 1811 } |
1812 | |
1813 // ------------------------------------------------------------------ | |
367
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1814 // ciTypeFlow::Block::is_clonable_exit |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1815 // |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1816 // At most 2 normal successors, one of which continues looping, |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1817 // and all exceptional successors must exit. |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1818 bool ciTypeFlow::Block::is_clonable_exit(ciTypeFlow::Loop* lp) { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1819 int normal_cnt = 0; |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1820 int in_loop_cnt = 0; |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1821 for (SuccIter iter(this); !iter.done(); iter.next()) { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1822 Block* succ = iter.succ(); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1823 if (iter.is_normal_ctrl()) { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1824 if (++normal_cnt > 2) return false; |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1825 if (lp->contains(succ->loop())) { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1826 if (++in_loop_cnt > 1) return false; |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1827 } |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1828 } else { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1829 if (lp->contains(succ->loop())) return false; |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1830 } |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1831 } |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1832 return in_loop_cnt == 1; |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1833 } |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1834 |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1835 // ------------------------------------------------------------------ |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1836 // ciTypeFlow::Block::looping_succ |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1837 // |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1838 ciTypeFlow::Block* ciTypeFlow::Block::looping_succ(ciTypeFlow::Loop* lp) { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1839 assert(successors()->length() <= 2, "at most 2 normal successors"); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1840 for (SuccIter iter(this); !iter.done(); iter.next()) { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1841 Block* succ = iter.succ(); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1842 if (lp->contains(succ->loop())) { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1843 return succ; |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1844 } |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1845 } |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1846 return NULL; |
0 | 1847 } |
1848 | |
1849 #ifndef PRODUCT | |
1850 // ------------------------------------------------------------------ | |
1851 // ciTypeFlow::Block::print_value_on | |
1852 void ciTypeFlow::Block::print_value_on(outputStream* st) const { | |
367
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1853 if (has_pre_order()) st->print("#%-2d ", pre_order()); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1854 if (has_rpo()) st->print("rpo#%-2d ", rpo()); |
0 | 1855 st->print("[%d - %d)", start(), limit()); |
367
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1856 if (is_loop_head()) st->print(" lphd"); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1857 if (is_irreducible_entry()) st->print(" irred"); |
0 | 1858 if (_jsrs->size() > 0) { st->print("/"); _jsrs->print_on(st); } |
367
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1859 if (is_backedge_copy()) st->print("/backedge_copy"); |
0 | 1860 } |
1861 | |
1862 // ------------------------------------------------------------------ | |
1863 // ciTypeFlow::Block::print_on | |
1864 void ciTypeFlow::Block::print_on(outputStream* st) const { | |
1865 if ((Verbose || WizardMode)) { | |
1866 outer()->method()->print_codes_on(start(), limit(), st); | |
1867 } | |
1868 st->print_cr(" ==================================================== "); | |
1869 st->print (" "); | |
1870 print_value_on(st); | |
367
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1871 st->print(" Stored locals: "); def_locals()->print_on(st, outer()->method()->max_locals()); tty->cr(); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1872 if (loop() && loop()->parent() != NULL) { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1873 st->print(" loops:"); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1874 Loop* lp = loop(); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1875 do { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1876 st->print(" %d<-%d", lp->head()->pre_order(),lp->tail()->pre_order()); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1877 if (lp->is_irreducible()) st->print("(ir)"); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1878 lp = lp->parent(); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1879 } while (lp->parent() != NULL); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1880 } |
0 | 1881 st->cr(); |
1882 _state->print_on(st); | |
1883 if (_successors == NULL) { | |
1884 st->print_cr(" No successor information"); | |
1885 } else { | |
1886 int num_successors = _successors->length(); | |
1887 st->print_cr(" Successors : %d", num_successors); | |
1888 for (int i = 0; i < num_successors; i++) { | |
1889 Block* successor = _successors->at(i); | |
1890 st->print(" "); | |
1891 successor->print_value_on(st); | |
1892 st->cr(); | |
1893 } | |
1894 } | |
1895 if (_exceptions == NULL) { | |
1896 st->print_cr(" No exception information"); | |
1897 } else { | |
1898 int num_exceptions = _exceptions->length(); | |
1899 st->print_cr(" Exceptions : %d", num_exceptions); | |
1900 for (int i = 0; i < num_exceptions; i++) { | |
1901 Block* exc_succ = _exceptions->at(i); | |
1902 ciInstanceKlass* exc_klass = _exc_klasses->at(i); | |
1903 st->print(" "); | |
1904 exc_succ->print_value_on(st); | |
1905 st->print(" -- "); | |
1906 exc_klass->name()->print_symbol_on(st); | |
1907 st->cr(); | |
1908 } | |
1909 } | |
1910 if (has_trap()) { | |
1911 st->print_cr(" Traps on %d with trap index %d", trap_bci(), trap_index()); | |
1912 } | |
1913 st->print_cr(" ==================================================== "); | |
1914 } | |
1915 #endif | |
1916 | |
367
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1917 #ifndef PRODUCT |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1918 // ------------------------------------------------------------------ |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1919 // ciTypeFlow::LocalSet::print_on |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1920 void ciTypeFlow::LocalSet::print_on(outputStream* st, int limit) const { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1921 st->print("{"); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1922 for (int i = 0; i < max; i++) { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1923 if (test(i)) st->print(" %d", i); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1924 } |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1925 if (limit > max) { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1926 st->print(" %d..%d ", max, limit); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1927 } |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1928 st->print(" }"); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1929 } |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1930 #endif |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1931 |
0 | 1932 // ciTypeFlow |
1933 // | |
1934 // This is a pass over the bytecodes which computes the following: | |
1935 // basic block structure | |
1936 // interpreter type-states (a la the verifier) | |
1937 | |
1938 // ------------------------------------------------------------------ | |
1939 // ciTypeFlow::ciTypeFlow | |
1940 ciTypeFlow::ciTypeFlow(ciEnv* env, ciMethod* method, int osr_bci) { | |
1941 _env = env; | |
1942 _method = method; | |
1943 _methodBlocks = method->get_method_blocks(); | |
1944 _max_locals = method->max_locals(); | |
1945 _max_stack = method->max_stack(); | |
1946 _code_size = method->code_size(); | |
367
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1947 _has_irreducible_entry = false; |
0 | 1948 _osr_bci = osr_bci; |
1949 _failure_reason = NULL; | |
1950 assert(start_bci() >= 0 && start_bci() < code_size() , "correct osr_bci argument"); | |
1951 _work_list = NULL; | |
1952 | |
1953 _ciblock_count = _methodBlocks->num_blocks(); | |
1954 _idx_to_blocklist = NEW_ARENA_ARRAY(arena(), GrowableArray<Block*>*, _ciblock_count); | |
1955 for (int i = 0; i < _ciblock_count; i++) { | |
1956 _idx_to_blocklist[i] = NULL; | |
1957 } | |
1958 _block_map = NULL; // until all blocks are seen | |
1959 _jsr_count = 0; | |
1960 _jsr_records = NULL; | |
1961 } | |
1962 | |
1963 // ------------------------------------------------------------------ | |
1964 // ciTypeFlow::work_list_next | |
1965 // | |
1966 // Get the next basic block from our work list. | |
1967 ciTypeFlow::Block* ciTypeFlow::work_list_next() { | |
1968 assert(!work_list_empty(), "work list must not be empty"); | |
1969 Block* next_block = _work_list; | |
1970 _work_list = next_block->next(); | |
1971 next_block->set_next(NULL); | |
1972 next_block->set_on_work_list(false); | |
1973 return next_block; | |
1974 } | |
1975 | |
1976 // ------------------------------------------------------------------ | |
1977 // ciTypeFlow::add_to_work_list | |
1978 // | |
1979 // Add a basic block to our work list. | |
367
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1980 // List is sorted by decreasing postorder sort (same as increasing RPO) |
0 | 1981 void ciTypeFlow::add_to_work_list(ciTypeFlow::Block* block) { |
1982 assert(!block->is_on_work_list(), "must not already be on work list"); | |
1983 | |
1984 if (CITraceTypeFlow) { | |
367
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1985 tty->print(">> Adding block "); |
0 | 1986 block->print_value_on(tty); |
1987 tty->print_cr(" to the work list : "); | |
1988 } | |
1989 | |
1990 block->set_on_work_list(true); | |
367
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1991 |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1992 // decreasing post order sort |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1993 |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1994 Block* prev = NULL; |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1995 Block* current = _work_list; |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1996 int po = block->post_order(); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1997 while (current != NULL) { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1998 if (!current->has_post_order() || po > current->post_order()) |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
1999 break; |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2000 prev = current; |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2001 current = current->next(); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2002 } |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2003 if (prev == NULL) { |
0 | 2004 block->set_next(_work_list); |
2005 _work_list = block; | |
2006 } else { | |
367
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2007 block->set_next(current); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2008 prev->set_next(block); |
0 | 2009 } |
367
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2010 |
0 | 2011 if (CITraceTypeFlow) { |
2012 tty->cr(); | |
2013 } | |
2014 } | |
2015 | |
2016 // ------------------------------------------------------------------ | |
2017 // ciTypeFlow::block_at | |
2018 // | |
2019 // Return the block beginning at bci which has a JsrSet compatible | |
2020 // with jsrs. | |
2021 ciTypeFlow::Block* ciTypeFlow::block_at(int bci, ciTypeFlow::JsrSet* jsrs, CreateOption option) { | |
2022 // First find the right ciBlock. | |
2023 if (CITraceTypeFlow) { | |
2024 tty->print(">> Requesting block for %d/", bci); | |
2025 jsrs->print_on(tty); | |
2026 tty->cr(); | |
2027 } | |
2028 | |
2029 ciBlock* ciblk = _methodBlocks->block_containing(bci); | |
2030 assert(ciblk->start_bci() == bci, "bad ciBlock boundaries"); | |
2031 Block* block = get_block_for(ciblk->index(), jsrs, option); | |
2032 | |
367
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2033 assert(block == NULL? (option == no_create): block->is_backedge_copy() == (option == create_backedge_copy), "create option consistent with result"); |
0 | 2034 |
2035 if (CITraceTypeFlow) { | |
2036 if (block != NULL) { | |
2037 tty->print(">> Found block "); | |
2038 block->print_value_on(tty); | |
2039 tty->cr(); | |
2040 } else { | |
2041 tty->print_cr(">> No such block."); | |
2042 } | |
2043 } | |
2044 | |
2045 return block; | |
2046 } | |
2047 | |
2048 // ------------------------------------------------------------------ | |
2049 // ciTypeFlow::make_jsr_record | |
2050 // | |
2051 // Make a JsrRecord for a given (entry, return) pair, if such a record | |
2052 // does not already exist. | |
2053 ciTypeFlow::JsrRecord* ciTypeFlow::make_jsr_record(int entry_address, | |
2054 int return_address) { | |
2055 if (_jsr_records == NULL) { | |
2056 _jsr_records = new (arena()) GrowableArray<JsrRecord*>(arena(), | |
2057 _jsr_count, | |
2058 0, | |
2059 NULL); | |
2060 } | |
2061 JsrRecord* record = NULL; | |
2062 int len = _jsr_records->length(); | |
2063 for (int i = 0; i < len; i++) { | |
2064 JsrRecord* record = _jsr_records->at(i); | |
2065 if (record->entry_address() == entry_address && | |
2066 record->return_address() == return_address) { | |
2067 return record; | |
2068 } | |
2069 } | |
2070 | |
2071 record = new (arena()) JsrRecord(entry_address, return_address); | |
2072 _jsr_records->append(record); | |
2073 return record; | |
2074 } | |
2075 | |
2076 // ------------------------------------------------------------------ | |
2077 // ciTypeFlow::flow_exceptions | |
2078 // | |
2079 // Merge the current state into all exceptional successors at the | |
2080 // current point in the code. | |
2081 void ciTypeFlow::flow_exceptions(GrowableArray<ciTypeFlow::Block*>* exceptions, | |
2082 GrowableArray<ciInstanceKlass*>* exc_klasses, | |
2083 ciTypeFlow::StateVector* state) { | |
2084 int len = exceptions->length(); | |
2085 assert(exc_klasses->length() == len, "must have same length"); | |
2086 for (int i = 0; i < len; i++) { | |
2087 Block* block = exceptions->at(i); | |
2088 ciInstanceKlass* exception_klass = exc_klasses->at(i); | |
2089 | |
2090 if (!exception_klass->is_loaded()) { | |
2091 // Do not compile any code for unloaded exception types. | |
2092 // Following compiler passes are responsible for doing this also. | |
2093 continue; | |
2094 } | |
2095 | |
2096 if (block->meet_exception(exception_klass, state)) { | |
367
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2097 // Block was modified and has PO. Add it to the work list. |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2098 if (block->has_post_order() && |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2099 !block->is_on_work_list()) { |
0 | 2100 add_to_work_list(block); |
2101 } | |
2102 } | |
2103 } | |
2104 } | |
2105 | |
2106 // ------------------------------------------------------------------ | |
2107 // ciTypeFlow::flow_successors | |
2108 // | |
2109 // Merge the current state into all successors at the current point | |
2110 // in the code. | |
2111 void ciTypeFlow::flow_successors(GrowableArray<ciTypeFlow::Block*>* successors, | |
2112 ciTypeFlow::StateVector* state) { | |
2113 int len = successors->length(); | |
2114 for (int i = 0; i < len; i++) { | |
2115 Block* block = successors->at(i); | |
2116 if (block->meet(state)) { | |
367
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2117 // Block was modified and has PO. Add it to the work list. |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2118 if (block->has_post_order() && |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2119 !block->is_on_work_list()) { |
0 | 2120 add_to_work_list(block); |
2121 } | |
2122 } | |
2123 } | |
2124 } | |
2125 | |
2126 // ------------------------------------------------------------------ | |
2127 // ciTypeFlow::can_trap | |
2128 // | |
2129 // Tells if a given instruction is able to generate an exception edge. | |
2130 bool ciTypeFlow::can_trap(ciBytecodeStream& str) { | |
2131 // Cf. GenerateOopMap::do_exception_edge. | |
2132 if (!Bytecodes::can_trap(str.cur_bc())) return false; | |
2133 | |
2134 switch (str.cur_bc()) { | |
2135 case Bytecodes::_ldc: | |
2136 case Bytecodes::_ldc_w: | |
2137 case Bytecodes::_ldc2_w: | |
2138 case Bytecodes::_aload_0: | |
2139 // These bytecodes can trap for rewriting. We need to assume that | |
2140 // they do not throw exceptions to make the monitor analysis work. | |
2141 return false; | |
2142 | |
2143 case Bytecodes::_ireturn: | |
2144 case Bytecodes::_lreturn: | |
2145 case Bytecodes::_freturn: | |
2146 case Bytecodes::_dreturn: | |
2147 case Bytecodes::_areturn: | |
2148 case Bytecodes::_return: | |
2149 // We can assume the monitor stack is empty in this analysis. | |
2150 return false; | |
2151 | |
2152 case Bytecodes::_monitorexit: | |
2153 // We can assume monitors are matched in this analysis. | |
2154 return false; | |
2155 } | |
2156 | |
2157 return true; | |
2158 } | |
2159 | |
367
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2160 // ------------------------------------------------------------------ |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2161 // ciTypeFlow::clone_loop_heads |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2162 // |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2163 // Clone the loop heads |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2164 bool ciTypeFlow::clone_loop_heads(Loop* lp, StateVector* temp_vector, JsrSet* temp_set) { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2165 bool rslt = false; |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2166 for (PreorderLoops iter(loop_tree_root()); !iter.done(); iter.next()) { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2167 lp = iter.current(); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2168 Block* head = lp->head(); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2169 if (lp == loop_tree_root() || |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2170 lp->is_irreducible() || |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2171 !head->is_clonable_exit(lp)) |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2172 continue; |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2173 |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2174 // check not already cloned |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2175 if (head->backedge_copy_count() != 0) |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2176 continue; |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2177 |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2178 // check _no_ shared head below us |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2179 Loop* ch; |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2180 for (ch = lp->child(); ch != NULL && ch->head() != head; ch = ch->sibling()); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2181 if (ch != NULL) |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2182 continue; |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2183 |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2184 // Clone head |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2185 Block* new_head = head->looping_succ(lp); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2186 Block* clone = clone_loop_head(lp, temp_vector, temp_set); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2187 // Update lp's info |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2188 clone->set_loop(lp); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2189 lp->set_head(new_head); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2190 lp->set_tail(clone); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2191 // And move original head into outer loop |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2192 head->set_loop(lp->parent()); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2193 |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2194 rslt = true; |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2195 } |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2196 return rslt; |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2197 } |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2198 |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2199 // ------------------------------------------------------------------ |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2200 // ciTypeFlow::clone_loop_head |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2201 // |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2202 // Clone lp's head and replace tail's successors with clone. |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2203 // |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2204 // | |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2205 // v |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2206 // head <-> body |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2207 // | |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2208 // v |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2209 // exit |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2210 // |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2211 // new_head |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2212 // |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2213 // | |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2214 // v |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2215 // head ----------\ |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2216 // | | |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2217 // | v |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2218 // | clone <-> body |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2219 // | | |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2220 // | /--/ |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2221 // | | |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2222 // v v |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2223 // exit |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2224 // |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2225 ciTypeFlow::Block* ciTypeFlow::clone_loop_head(Loop* lp, StateVector* temp_vector, JsrSet* temp_set) { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2226 Block* head = lp->head(); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2227 Block* tail = lp->tail(); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2228 if (CITraceTypeFlow) { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2229 tty->print(">> Requesting clone of loop head "); head->print_value_on(tty); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2230 tty->print(" for predecessor "); tail->print_value_on(tty); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2231 tty->cr(); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2232 } |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2233 Block* clone = block_at(head->start(), head->jsrs(), create_backedge_copy); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2234 assert(clone->backedge_copy_count() == 1, "one backedge copy for all back edges"); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2235 |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2236 assert(!clone->has_pre_order(), "just created"); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2237 clone->set_next_pre_order(); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2238 |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2239 // Insert clone after (orig) tail in reverse post order |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2240 clone->set_rpo_next(tail->rpo_next()); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2241 tail->set_rpo_next(clone); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2242 |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2243 // tail->head becomes tail->clone |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2244 for (SuccIter iter(tail); !iter.done(); iter.next()) { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2245 if (iter.succ() == head) { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2246 iter.set_succ(clone); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2247 } |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2248 } |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2249 flow_block(tail, temp_vector, temp_set); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2250 if (head == tail) { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2251 // For self-loops, clone->head becomes clone->clone |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2252 flow_block(clone, temp_vector, temp_set); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2253 for (SuccIter iter(clone); !iter.done(); iter.next()) { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2254 if (iter.succ() == head) { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2255 iter.set_succ(clone); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2256 break; |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2257 } |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2258 } |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2259 } |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2260 flow_block(clone, temp_vector, temp_set); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2261 |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2262 return clone; |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2263 } |
0 | 2264 |
2265 // ------------------------------------------------------------------ | |
2266 // ciTypeFlow::flow_block | |
2267 // | |
2268 // Interpret the effects of the bytecodes on the incoming state | |
2269 // vector of a basic block. Push the changed state to succeeding | |
2270 // basic blocks. | |
2271 void ciTypeFlow::flow_block(ciTypeFlow::Block* block, | |
2272 ciTypeFlow::StateVector* state, | |
2273 ciTypeFlow::JsrSet* jsrs) { | |
2274 if (CITraceTypeFlow) { | |
2275 tty->print("\n>> ANALYZING BLOCK : "); | |
2276 tty->cr(); | |
2277 block->print_on(tty); | |
2278 } | |
2279 assert(block->has_pre_order(), "pre-order is assigned before 1st flow"); | |
2280 | |
2281 int start = block->start(); | |
2282 int limit = block->limit(); | |
2283 int control = block->control(); | |
2284 if (control != ciBlock::fall_through_bci) { | |
2285 limit = control; | |
2286 } | |
2287 | |
2288 // Grab the state from the current block. | |
2289 block->copy_state_into(state); | |
367
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2290 state->def_locals()->clear(); |
0 | 2291 |
2292 GrowableArray<Block*>* exceptions = block->exceptions(); | |
2293 GrowableArray<ciInstanceKlass*>* exc_klasses = block->exc_klasses(); | |
2294 bool has_exceptions = exceptions->length() > 0; | |
2295 | |
367
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2296 bool exceptions_used = false; |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2297 |
0 | 2298 ciBytecodeStream str(method()); |
2299 str.reset_to_bci(start); | |
2300 Bytecodes::Code code; | |
2301 while ((code = str.next()) != ciBytecodeStream::EOBC() && | |
2302 str.cur_bci() < limit) { | |
2303 // Check for exceptional control flow from this point. | |
2304 if (has_exceptions && can_trap(str)) { | |
2305 flow_exceptions(exceptions, exc_klasses, state); | |
367
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2306 exceptions_used = true; |
0 | 2307 } |
2308 // Apply the effects of the current bytecode to our state. | |
2309 bool res = state->apply_one_bytecode(&str); | |
2310 | |
2311 // Watch for bailouts. | |
2312 if (failing()) return; | |
2313 | |
2314 if (res) { | |
2315 | |
2316 // We have encountered a trap. Record it in this block. | |
2317 block->set_trap(state->trap_bci(), state->trap_index()); | |
2318 | |
2319 if (CITraceTypeFlow) { | |
2320 tty->print_cr(">> Found trap"); | |
2321 block->print_on(tty); | |
2322 } | |
2323 | |
367
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2324 // Save set of locals defined in this block |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2325 block->def_locals()->add(state->def_locals()); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2326 |
0 | 2327 // Record (no) successors. |
2328 block->successors(&str, state, jsrs); | |
2329 | |
367
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2330 assert(!has_exceptions || exceptions_used, "Not removing exceptions"); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2331 |
0 | 2332 // Discontinue interpretation of this Block. |
2333 return; | |
2334 } | |
2335 } | |
2336 | |
2337 GrowableArray<Block*>* successors = NULL; | |
2338 if (control != ciBlock::fall_through_bci) { | |
2339 // Check for exceptional control flow from this point. | |
2340 if (has_exceptions && can_trap(str)) { | |
2341 flow_exceptions(exceptions, exc_klasses, state); | |
367
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2342 exceptions_used = true; |
0 | 2343 } |
2344 | |
2345 // Fix the JsrSet to reflect effect of the bytecode. | |
2346 block->copy_jsrs_into(jsrs); | |
2347 jsrs->apply_control(this, &str, state); | |
2348 | |
2349 // Find successor edges based on old state and new JsrSet. | |
2350 successors = block->successors(&str, state, jsrs); | |
2351 | |
2352 // Apply the control changes to the state. | |
2353 state->apply_one_bytecode(&str); | |
2354 } else { | |
2355 // Fall through control | |
2356 successors = block->successors(&str, NULL, NULL); | |
2357 } | |
2358 | |
367
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2359 // Save set of locals defined in this block |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2360 block->def_locals()->add(state->def_locals()); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2361 |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2362 // Remove untaken exception paths |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2363 if (!exceptions_used) |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2364 exceptions->clear(); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2365 |
0 | 2366 // Pass our state to successors. |
2367 flow_successors(successors, state); | |
2368 } | |
2369 | |
2370 // ------------------------------------------------------------------ | |
367
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2371 // ciTypeFlow::PostOrderLoops::next |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2372 // |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2373 // Advance to next loop tree using a postorder, left-to-right traversal. |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2374 void ciTypeFlow::PostorderLoops::next() { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2375 assert(!done(), "must not be done."); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2376 if (_current->sibling() != NULL) { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2377 _current = _current->sibling(); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2378 while (_current->child() != NULL) { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2379 _current = _current->child(); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2380 } |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2381 } else { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2382 _current = _current->parent(); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2383 } |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2384 } |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2385 |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2386 // ------------------------------------------------------------------ |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2387 // ciTypeFlow::PreOrderLoops::next |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2388 // |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2389 // Advance to next loop tree using a preorder, left-to-right traversal. |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2390 void ciTypeFlow::PreorderLoops::next() { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2391 assert(!done(), "must not be done."); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2392 if (_current->child() != NULL) { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2393 _current = _current->child(); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2394 } else if (_current->sibling() != NULL) { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2395 _current = _current->sibling(); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2396 } else { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2397 while (_current != _root && _current->sibling() == NULL) { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2398 _current = _current->parent(); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2399 } |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2400 if (_current == _root) { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2401 _current = NULL; |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2402 assert(done(), "must be done."); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2403 } else { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2404 assert(_current->sibling() != NULL, "must be more to do"); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2405 _current = _current->sibling(); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2406 } |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2407 } |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2408 } |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2409 |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2410 // ------------------------------------------------------------------ |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2411 // ciTypeFlow::Loop::sorted_merge |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2412 // |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2413 // Merge the branch lp into this branch, sorting on the loop head |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2414 // pre_orders. Returns the leaf of the merged branch. |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2415 // Child and sibling pointers will be setup later. |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2416 // Sort is (looking from leaf towards the root) |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2417 // descending on primary key: loop head's pre_order, and |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2418 // ascending on secondary key: loop tail's pre_order. |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2419 ciTypeFlow::Loop* ciTypeFlow::Loop::sorted_merge(Loop* lp) { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2420 Loop* leaf = this; |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2421 Loop* prev = NULL; |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2422 Loop* current = leaf; |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2423 while (lp != NULL) { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2424 int lp_pre_order = lp->head()->pre_order(); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2425 // Find insertion point for "lp" |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2426 while (current != NULL) { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2427 if (current == lp) |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2428 return leaf; // Already in list |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2429 if (current->head()->pre_order() < lp_pre_order) |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2430 break; |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2431 if (current->head()->pre_order() == lp_pre_order && |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2432 current->tail()->pre_order() > lp->tail()->pre_order()) { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2433 break; |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2434 } |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2435 prev = current; |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2436 current = current->parent(); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2437 } |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2438 Loop* next_lp = lp->parent(); // Save future list of items to insert |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2439 // Insert lp before current |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2440 lp->set_parent(current); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2441 if (prev != NULL) { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2442 prev->set_parent(lp); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2443 } else { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2444 leaf = lp; |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2445 } |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2446 prev = lp; // Inserted item is new prev[ious] |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2447 lp = next_lp; // Next item to insert |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2448 } |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2449 return leaf; |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2450 } |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2451 |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2452 // ------------------------------------------------------------------ |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2453 // ciTypeFlow::build_loop_tree |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2454 // |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2455 // Incrementally build loop tree. |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2456 void ciTypeFlow::build_loop_tree(Block* blk) { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2457 assert(!blk->is_post_visited(), "precondition"); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2458 Loop* innermost = NULL; // merge of loop tree branches over all successors |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2459 |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2460 for (SuccIter iter(blk); !iter.done(); iter.next()) { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2461 Loop* lp = NULL; |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2462 Block* succ = iter.succ(); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2463 if (!succ->is_post_visited()) { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2464 // Found backedge since predecessor post visited, but successor is not |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2465 assert(succ->pre_order() <= blk->pre_order(), "should be backedge"); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2466 |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2467 // Create a LoopNode to mark this loop. |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2468 lp = new (arena()) Loop(succ, blk); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2469 if (succ->loop() == NULL) |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2470 succ->set_loop(lp); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2471 // succ->loop will be updated to innermost loop on a later call, when blk==succ |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2472 |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2473 } else { // Nested loop |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2474 lp = succ->loop(); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2475 |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2476 // If succ is loop head, find outer loop. |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2477 while (lp != NULL && lp->head() == succ) { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2478 lp = lp->parent(); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2479 } |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2480 if (lp == NULL) { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2481 // Infinite loop, it's parent is the root |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2482 lp = loop_tree_root(); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2483 } |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2484 } |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2485 |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2486 // Check for irreducible loop. |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2487 // Successor has already been visited. If the successor's loop head |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2488 // has already been post-visited, then this is another entry into the loop. |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2489 while (lp->head()->is_post_visited() && lp != loop_tree_root()) { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2490 _has_irreducible_entry = true; |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2491 lp->set_irreducible(succ); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2492 if (!succ->is_on_work_list()) { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2493 // Assume irreducible entries need more data flow |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2494 add_to_work_list(succ); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2495 } |
991 | 2496 Loop* plp = lp->parent(); |
2497 if (plp == NULL) { | |
2498 // This only happens for some irreducible cases. The parent | |
2499 // will be updated during a later pass. | |
2500 break; | |
2501 } | |
2502 lp = plp; | |
367
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2503 } |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2504 |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2505 // Merge loop tree branch for all successors. |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2506 innermost = innermost == NULL ? lp : innermost->sorted_merge(lp); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2507 |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2508 } // end loop |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2509 |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2510 if (innermost == NULL) { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2511 assert(blk->successors()->length() == 0, "CFG exit"); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2512 blk->set_loop(loop_tree_root()); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2513 } else if (innermost->head() == blk) { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2514 // If loop header, complete the tree pointers |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2515 if (blk->loop() != innermost) { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2516 #if ASSERT |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2517 assert(blk->loop()->head() == innermost->head(), "same head"); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2518 Loop* dl; |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2519 for (dl = innermost; dl != NULL && dl != blk->loop(); dl = dl->parent()); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2520 assert(dl == blk->loop(), "blk->loop() already in innermost list"); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2521 #endif |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2522 blk->set_loop(innermost); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2523 } |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2524 innermost->def_locals()->add(blk->def_locals()); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2525 Loop* l = innermost; |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2526 Loop* p = l->parent(); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2527 while (p && l->head() == blk) { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2528 l->set_sibling(p->child()); // Put self on parents 'next child' |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2529 p->set_child(l); // Make self the first child of parent |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2530 p->def_locals()->add(l->def_locals()); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2531 l = p; // Walk up the parent chain |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2532 p = l->parent(); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2533 } |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2534 } else { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2535 blk->set_loop(innermost); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2536 innermost->def_locals()->add(blk->def_locals()); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2537 } |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2538 } |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2539 |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2540 // ------------------------------------------------------------------ |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2541 // ciTypeFlow::Loop::contains |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2542 // |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2543 // Returns true if lp is nested loop. |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2544 bool ciTypeFlow::Loop::contains(ciTypeFlow::Loop* lp) const { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2545 assert(lp != NULL, ""); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2546 if (this == lp || head() == lp->head()) return true; |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2547 int depth1 = depth(); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2548 int depth2 = lp->depth(); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2549 if (depth1 > depth2) |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2550 return false; |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2551 while (depth1 < depth2) { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2552 depth2--; |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2553 lp = lp->parent(); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2554 } |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2555 return this == lp; |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2556 } |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2557 |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2558 // ------------------------------------------------------------------ |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2559 // ciTypeFlow::Loop::depth |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2560 // |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2561 // Loop depth |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2562 int ciTypeFlow::Loop::depth() const { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2563 int dp = 0; |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2564 for (Loop* lp = this->parent(); lp != NULL; lp = lp->parent()) |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2565 dp++; |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2566 return dp; |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2567 } |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2568 |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2569 #ifndef PRODUCT |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2570 // ------------------------------------------------------------------ |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2571 // ciTypeFlow::Loop::print |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2572 void ciTypeFlow::Loop::print(outputStream* st, int indent) const { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2573 for (int i = 0; i < indent; i++) st->print(" "); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2574 st->print("%d<-%d %s", |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2575 is_root() ? 0 : this->head()->pre_order(), |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2576 is_root() ? 0 : this->tail()->pre_order(), |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2577 is_irreducible()?" irr":""); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2578 st->print(" defs: "); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2579 def_locals()->print_on(st, _head->outer()->method()->max_locals()); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2580 st->cr(); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2581 for (Loop* ch = child(); ch != NULL; ch = ch->sibling()) |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2582 ch->print(st, indent+2); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2583 } |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2584 #endif |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2585 |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2586 // ------------------------------------------------------------------ |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2587 // ciTypeFlow::df_flow_types |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2588 // |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2589 // Perform the depth first type flow analysis. Helper for flow_types. |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2590 void ciTypeFlow::df_flow_types(Block* start, |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2591 bool do_flow, |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2592 StateVector* temp_vector, |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2593 JsrSet* temp_set) { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2594 int dft_len = 100; |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2595 GrowableArray<Block*> stk(arena(), dft_len, 0, NULL); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2596 |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2597 ciBlock* dummy = _methodBlocks->make_dummy_block(); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2598 JsrSet* root_set = new JsrSet(NULL, 0); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2599 Block* root_head = new (arena()) Block(this, dummy, root_set); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2600 Block* root_tail = new (arena()) Block(this, dummy, root_set); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2601 root_head->set_pre_order(0); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2602 root_head->set_post_order(0); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2603 root_tail->set_pre_order(max_jint); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2604 root_tail->set_post_order(max_jint); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2605 set_loop_tree_root(new (arena()) Loop(root_head, root_tail)); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2606 |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2607 stk.push(start); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2608 |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2609 _next_pre_order = 0; // initialize pre_order counter |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2610 _rpo_list = NULL; |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2611 int next_po = 0; // initialize post_order counter |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2612 |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2613 // Compute RPO and the control flow graph |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2614 int size; |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2615 while ((size = stk.length()) > 0) { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2616 Block* blk = stk.top(); // Leave node on stack |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2617 if (!blk->is_visited()) { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2618 // forward arc in graph |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2619 assert (!blk->has_pre_order(), ""); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2620 blk->set_next_pre_order(); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2621 |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2622 if (_next_pre_order >= MaxNodeLimit / 2) { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2623 // Too many basic blocks. Bail out. |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2624 // This can happen when try/finally constructs are nested to depth N, |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2625 // and there is O(2**N) cloning of jsr bodies. See bug 4697245! |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2626 // "MaxNodeLimit / 2" is used because probably the parser will |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2627 // generate at least twice that many nodes and bail out. |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2628 record_failure("too many basic blocks"); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2629 return; |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2630 } |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2631 if (do_flow) { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2632 flow_block(blk, temp_vector, temp_set); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2633 if (failing()) return; // Watch for bailouts. |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2634 } |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2635 } else if (!blk->is_post_visited()) { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2636 // cross or back arc |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2637 for (SuccIter iter(blk); !iter.done(); iter.next()) { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2638 Block* succ = iter.succ(); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2639 if (!succ->is_visited()) { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2640 stk.push(succ); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2641 } |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2642 } |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2643 if (stk.length() == size) { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2644 // There were no additional children, post visit node now |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2645 stk.pop(); // Remove node from stack |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2646 |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2647 build_loop_tree(blk); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2648 blk->set_post_order(next_po++); // Assign post order |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2649 prepend_to_rpo_list(blk); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2650 assert(blk->is_post_visited(), ""); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2651 |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2652 if (blk->is_loop_head() && !blk->is_on_work_list()) { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2653 // Assume loop heads need more data flow |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2654 add_to_work_list(blk); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2655 } |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2656 } |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2657 } else { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2658 stk.pop(); // Remove post-visited node from stack |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2659 } |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2660 } |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2661 } |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2662 |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2663 // ------------------------------------------------------------------ |
0 | 2664 // ciTypeFlow::flow_types |
2665 // | |
2666 // Perform the type flow analysis, creating and cloning Blocks as | |
2667 // necessary. | |
2668 void ciTypeFlow::flow_types() { | |
2669 ResourceMark rm; | |
2670 StateVector* temp_vector = new StateVector(this); | |
2671 JsrSet* temp_set = new JsrSet(NULL, 16); | |
2672 | |
2673 // Create the method entry block. | |
367
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2674 Block* start = block_at(start_bci(), temp_set); |
0 | 2675 |
2676 // Load the initial state into it. | |
2677 const StateVector* start_state = get_start_state(); | |
2678 if (failing()) return; | |
367
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2679 start->meet(start_state); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2680 |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2681 // Depth first visit |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2682 df_flow_types(start, true /*do flow*/, temp_vector, temp_set); |
0 | 2683 |
367
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2684 if (failing()) return; |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2685 assert(_rpo_list == start, "must be start"); |
0 | 2686 |
367
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2687 // Any loops found? |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2688 if (loop_tree_root()->child() != NULL && |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2689 env()->comp_level() >= CompLevel_full_optimization) { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2690 // Loop optimizations are not performed on Tier1 compiles. |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2691 |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2692 bool changed = clone_loop_heads(loop_tree_root(), temp_vector, temp_set); |
0 | 2693 |
367
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2694 // If some loop heads were cloned, recompute postorder and loop tree |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2695 if (changed) { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2696 loop_tree_root()->set_child(NULL); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2697 for (Block* blk = _rpo_list; blk != NULL;) { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2698 Block* next = blk->rpo_next(); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2699 blk->df_init(); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2700 blk = next; |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2701 } |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2702 df_flow_types(start, false /*no flow*/, temp_vector, temp_set); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2703 } |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2704 } |
0 | 2705 |
367
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2706 if (CITraceTypeFlow) { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2707 tty->print_cr("\nLoop tree"); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2708 loop_tree_root()->print(); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2709 } |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2710 |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2711 // Continue flow analysis until fixed point reached |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2712 |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2713 debug_only(int max_block = _next_pre_order;) |
0 | 2714 |
367
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2715 while (!work_list_empty()) { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2716 Block* blk = work_list_next(); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2717 assert (blk->has_post_order(), "post order assigned above"); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2718 |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2719 flow_block(blk, temp_vector, temp_set); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2720 |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2721 assert (max_block == _next_pre_order, "no new blocks"); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2722 assert (!failing(), "no more bailouts"); |
0 | 2723 } |
2724 } | |
2725 | |
2726 // ------------------------------------------------------------------ | |
2727 // ciTypeFlow::map_blocks | |
2728 // | |
367
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2729 // Create the block map, which indexes blocks in reverse post-order. |
0 | 2730 void ciTypeFlow::map_blocks() { |
2731 assert(_block_map == NULL, "single initialization"); | |
367
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2732 int block_ct = _next_pre_order; |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2733 _block_map = NEW_ARENA_ARRAY(arena(), Block*, block_ct); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2734 assert(block_ct == block_count(), ""); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2735 |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2736 Block* blk = _rpo_list; |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2737 for (int m = 0; m < block_ct; m++) { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2738 int rpo = blk->rpo(); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2739 assert(rpo == m, "should be sequential"); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2740 _block_map[rpo] = blk; |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2741 blk = blk->rpo_next(); |
0 | 2742 } |
367
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2743 assert(blk == NULL, "should be done"); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2744 |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2745 for (int j = 0; j < block_ct; j++) { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2746 assert(_block_map[j] != NULL, "must not drop any blocks"); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2747 Block* block = _block_map[j]; |
0 | 2748 // Remove dead blocks from successor lists: |
2749 for (int e = 0; e <= 1; e++) { | |
2750 GrowableArray<Block*>* l = e? block->exceptions(): block->successors(); | |
367
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2751 for (int k = 0; k < l->length(); k++) { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2752 Block* s = l->at(k); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2753 if (!s->has_post_order()) { |
0 | 2754 if (CITraceTypeFlow) { |
2755 tty->print("Removing dead %s successor of #%d: ", (e? "exceptional": "normal"), block->pre_order()); | |
2756 s->print_value_on(tty); | |
2757 tty->cr(); | |
2758 } | |
2759 l->remove(s); | |
367
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2760 --k; |
0 | 2761 } |
2762 } | |
2763 } | |
2764 } | |
2765 } | |
2766 | |
2767 // ------------------------------------------------------------------ | |
2768 // ciTypeFlow::get_block_for | |
2769 // | |
2770 // Find a block with this ciBlock which has a compatible JsrSet. | |
2771 // If no such block exists, create it, unless the option is no_create. | |
367
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2772 // If the option is create_backedge_copy, always create a fresh backedge copy. |
0 | 2773 ciTypeFlow::Block* ciTypeFlow::get_block_for(int ciBlockIndex, ciTypeFlow::JsrSet* jsrs, CreateOption option) { |
2774 Arena* a = arena(); | |
2775 GrowableArray<Block*>* blocks = _idx_to_blocklist[ciBlockIndex]; | |
2776 if (blocks == NULL) { | |
2777 // Query only? | |
2778 if (option == no_create) return NULL; | |
2779 | |
2780 // Allocate the growable array. | |
2781 blocks = new (a) GrowableArray<Block*>(a, 4, 0, NULL); | |
2782 _idx_to_blocklist[ciBlockIndex] = blocks; | |
2783 } | |
2784 | |
367
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2785 if (option != create_backedge_copy) { |
0 | 2786 int len = blocks->length(); |
2787 for (int i = 0; i < len; i++) { | |
2788 Block* block = blocks->at(i); | |
367
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2789 if (!block->is_backedge_copy() && block->is_compatible_with(jsrs)) { |
0 | 2790 return block; |
2791 } | |
2792 } | |
2793 } | |
2794 | |
2795 // Query only? | |
2796 if (option == no_create) return NULL; | |
2797 | |
2798 // We did not find a compatible block. Create one. | |
2799 Block* new_block = new (a) Block(this, _methodBlocks->block(ciBlockIndex), jsrs); | |
367
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2800 if (option == create_backedge_copy) new_block->set_backedge_copy(true); |
0 | 2801 blocks->append(new_block); |
2802 return new_block; | |
2803 } | |
2804 | |
2805 // ------------------------------------------------------------------ | |
367
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2806 // ciTypeFlow::backedge_copy_count |
0 | 2807 // |
367
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2808 int ciTypeFlow::backedge_copy_count(int ciBlockIndex, ciTypeFlow::JsrSet* jsrs) const { |
0 | 2809 GrowableArray<Block*>* blocks = _idx_to_blocklist[ciBlockIndex]; |
2810 | |
2811 if (blocks == NULL) { | |
2812 return 0; | |
2813 } | |
2814 | |
2815 int count = 0; | |
2816 int len = blocks->length(); | |
2817 for (int i = 0; i < len; i++) { | |
2818 Block* block = blocks->at(i); | |
367
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2819 if (block->is_backedge_copy() && block->is_compatible_with(jsrs)) { |
0 | 2820 count++; |
2821 } | |
2822 } | |
2823 | |
2824 return count; | |
2825 } | |
2826 | |
2827 // ------------------------------------------------------------------ | |
2828 // ciTypeFlow::do_flow | |
2829 // | |
2830 // Perform type inference flow analysis. | |
2831 void ciTypeFlow::do_flow() { | |
2832 if (CITraceTypeFlow) { | |
2833 tty->print_cr("\nPerforming flow analysis on method"); | |
2834 method()->print(); | |
2835 if (is_osr_flow()) tty->print(" at OSR bci %d", start_bci()); | |
2836 tty->cr(); | |
2837 method()->print_codes(); | |
2838 } | |
2839 if (CITraceTypeFlow) { | |
2840 tty->print_cr("Initial CI Blocks"); | |
2841 print_on(tty); | |
2842 } | |
2843 flow_types(); | |
2844 // Watch for bailouts. | |
2845 if (failing()) { | |
2846 return; | |
2847 } | |
367
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2848 |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2849 map_blocks(); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2850 |
0 | 2851 if (CIPrintTypeFlow || CITraceTypeFlow) { |
367
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2852 rpo_print_on(tty); |
0 | 2853 } |
2854 } | |
2855 | |
2856 // ------------------------------------------------------------------ | |
2857 // ciTypeFlow::record_failure() | |
2858 // The ciTypeFlow object keeps track of failure reasons separately from the ciEnv. | |
2859 // This is required because there is not a 1-1 relation between the ciEnv and | |
2860 // the TypeFlow passes within a compilation task. For example, if the compiler | |
2861 // is considering inlining a method, it will request a TypeFlow. If that fails, | |
2862 // the compilation as a whole may continue without the inlining. Some TypeFlow | |
2863 // requests are not optional; if they fail the requestor is responsible for | |
2864 // copying the failure reason up to the ciEnv. (See Parse::Parse.) | |
2865 void ciTypeFlow::record_failure(const char* reason) { | |
2866 if (env()->log() != NULL) { | |
2867 env()->log()->elem("failure reason='%s' phase='typeflow'", reason); | |
2868 } | |
2869 if (_failure_reason == NULL) { | |
2870 // Record the first failure reason. | |
2871 _failure_reason = reason; | |
2872 } | |
2873 } | |
2874 | |
2875 #ifndef PRODUCT | |
2876 // ------------------------------------------------------------------ | |
2877 // ciTypeFlow::print_on | |
2878 void ciTypeFlow::print_on(outputStream* st) const { | |
2879 // Walk through CI blocks | |
2880 st->print_cr("********************************************************"); | |
2881 st->print ("TypeFlow for "); | |
2882 method()->name()->print_symbol_on(st); | |
2883 int limit_bci = code_size(); | |
2884 st->print_cr(" %d bytes", limit_bci); | |
2885 ciMethodBlocks *mblks = _methodBlocks; | |
2886 ciBlock* current = NULL; | |
2887 for (int bci = 0; bci < limit_bci; bci++) { | |
2888 ciBlock* blk = mblks->block_containing(bci); | |
2889 if (blk != NULL && blk != current) { | |
2890 current = blk; | |
2891 current->print_on(st); | |
2892 | |
2893 GrowableArray<Block*>* blocks = _idx_to_blocklist[blk->index()]; | |
2894 int num_blocks = (blocks == NULL) ? 0 : blocks->length(); | |
2895 | |
2896 if (num_blocks == 0) { | |
2897 st->print_cr(" No Blocks"); | |
2898 } else { | |
2899 for (int i = 0; i < num_blocks; i++) { | |
2900 Block* block = blocks->at(i); | |
2901 block->print_on(st); | |
2902 } | |
2903 } | |
2904 st->print_cr("--------------------------------------------------------"); | |
2905 st->cr(); | |
2906 } | |
2907 } | |
2908 st->print_cr("********************************************************"); | |
2909 st->cr(); | |
2910 } | |
367
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2911 |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2912 void ciTypeFlow::rpo_print_on(outputStream* st) const { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2913 st->print_cr("********************************************************"); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2914 st->print ("TypeFlow for "); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2915 method()->name()->print_symbol_on(st); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2916 int limit_bci = code_size(); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2917 st->print_cr(" %d bytes", limit_bci); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2918 for (Block* blk = _rpo_list; blk != NULL; blk = blk->rpo_next()) { |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2919 blk->print_on(st); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2920 st->print_cr("--------------------------------------------------------"); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2921 st->cr(); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2922 } |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2923 st->print_cr("********************************************************"); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2924 st->cr(); |
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
0
diff
changeset
|
2925 } |
0 | 2926 #endif |