annotate src/share/vm/ci/ciTypeFlow.cpp @ 20807:8d4496e10a51

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