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