annotate src/share/vm/ci/ciTypeFlow.hpp @ 6972:bd7a7ce2e264

6830717: replay of compilations would help with debugging Summary: When java process crashed in compiler thread, repeat the compilation process will help finding root cause. This is done with using SA dump application class data and replay data from core dump, then use debug version of jvm to recompile the problematic java method. Reviewed-by: kvn, twisti, sspitsyn Contributed-by: yumin.qi@oracle.com
author minqi
date Mon, 12 Nov 2012 14:03:53 -0800
parents b9a9ed0f8eeb
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
6842
b9a9ed0f8eeb 7197424: update copyright year to match last edit in jdk8 hotspot repository
mikael
parents: 4777
diff changeset
2 * Copyright (c) 2000, 2012, 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: 380
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 380
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: 380
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: 1552
diff changeset
25 #ifndef SHARE_VM_CI_CITYPEFLOW_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #define SHARE_VM_CI_CITYPEFLOW_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
28 #ifdef COMPILER2
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
29 #include "ci/ciEnv.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
30 #include "ci/ciKlass.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
31 #include "ci/ciMethodBlocks.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
32 #endif
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
33 #ifdef SHARK
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
34 #include "ci/ciEnv.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
35 #include "ci/ciKlass.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
36 #include "ci/ciMethodBlocks.hpp"
2447
e863062e521d 7032458: Zero and Shark fixes
twisti
parents: 1972
diff changeset
37 #include "shark/shark_globals.hpp"
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
38 #endif
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
39
0
a61af66fc99e Initial load
duke
parents:
diff changeset
40
a61af66fc99e Initial load
duke
parents:
diff changeset
41 class ciTypeFlow : public ResourceObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
42 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
43 ciEnv* _env;
a61af66fc99e Initial load
duke
parents:
diff changeset
44 ciMethod* _method;
a61af66fc99e Initial load
duke
parents:
diff changeset
45 ciMethodBlocks* _methodBlocks;
a61af66fc99e Initial load
duke
parents:
diff changeset
46 int _osr_bci;
a61af66fc99e Initial load
duke
parents:
diff changeset
47
a61af66fc99e Initial load
duke
parents:
diff changeset
48 // information cached from the method:
a61af66fc99e Initial load
duke
parents:
diff changeset
49 int _max_locals;
a61af66fc99e Initial load
duke
parents:
diff changeset
50 int _max_stack;
a61af66fc99e Initial load
duke
parents:
diff changeset
51 int _code_size;
367
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
52 bool _has_irreducible_entry;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
53
a61af66fc99e Initial load
duke
parents:
diff changeset
54 const char* _failure_reason;
a61af66fc99e Initial load
duke
parents:
diff changeset
55
a61af66fc99e Initial load
duke
parents:
diff changeset
56 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
57 class StateVector;
367
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
58 class Loop;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
59 class Block;
a61af66fc99e Initial load
duke
parents:
diff changeset
60
a61af66fc99e Initial load
duke
parents:
diff changeset
61 // Build a type flow analyzer
a61af66fc99e Initial load
duke
parents:
diff changeset
62 // Do an OSR analysis if osr_bci >= 0.
a61af66fc99e Initial load
duke
parents:
diff changeset
63 ciTypeFlow(ciEnv* env, ciMethod* method, int osr_bci = InvocationEntryBci);
a61af66fc99e Initial load
duke
parents:
diff changeset
64
a61af66fc99e Initial load
duke
parents:
diff changeset
65 // Accessors
a61af66fc99e Initial load
duke
parents:
diff changeset
66 ciMethod* method() const { return _method; }
a61af66fc99e Initial load
duke
parents:
diff changeset
67 ciEnv* env() { return _env; }
a61af66fc99e Initial load
duke
parents:
diff changeset
68 Arena* arena() { return _env->arena(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
69 bool is_osr_flow() const{ return _osr_bci != InvocationEntryBci; }
a61af66fc99e Initial load
duke
parents:
diff changeset
70 int start_bci() const { return is_osr_flow()? _osr_bci: 0; }
a61af66fc99e Initial load
duke
parents:
diff changeset
71 int max_locals() const { return _max_locals; }
a61af66fc99e Initial load
duke
parents:
diff changeset
72 int max_stack() const { return _max_stack; }
a61af66fc99e Initial load
duke
parents:
diff changeset
73 int max_cells() const { return _max_locals + _max_stack; }
a61af66fc99e Initial load
duke
parents:
diff changeset
74 int code_size() const { return _code_size; }
367
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
75 bool has_irreducible_entry() const { return _has_irreducible_entry; }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
76
a61af66fc99e Initial load
duke
parents:
diff changeset
77 // Represents information about an "active" jsr call. This
a61af66fc99e Initial load
duke
parents:
diff changeset
78 // class represents a call to the routine at some entry address
a61af66fc99e Initial load
duke
parents:
diff changeset
79 // with some distinct return address.
a61af66fc99e Initial load
duke
parents:
diff changeset
80 class JsrRecord : public ResourceObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
81 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
82 int _entry_address;
a61af66fc99e Initial load
duke
parents:
diff changeset
83 int _return_address;
a61af66fc99e Initial load
duke
parents:
diff changeset
84 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
85 JsrRecord(int entry_address, int return_address) {
a61af66fc99e Initial load
duke
parents:
diff changeset
86 _entry_address = entry_address;
a61af66fc99e Initial load
duke
parents:
diff changeset
87 _return_address = return_address;
a61af66fc99e Initial load
duke
parents:
diff changeset
88 }
a61af66fc99e Initial load
duke
parents:
diff changeset
89
a61af66fc99e Initial load
duke
parents:
diff changeset
90 int entry_address() const { return _entry_address; }
a61af66fc99e Initial load
duke
parents:
diff changeset
91 int return_address() const { return _return_address; }
a61af66fc99e Initial load
duke
parents:
diff changeset
92
a61af66fc99e Initial load
duke
parents:
diff changeset
93 void print_on(outputStream* st) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
94 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
95 st->print("%d->%d", entry_address(), return_address());
a61af66fc99e Initial load
duke
parents:
diff changeset
96 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
97 }
a61af66fc99e Initial load
duke
parents:
diff changeset
98 };
a61af66fc99e Initial load
duke
parents:
diff changeset
99
a61af66fc99e Initial load
duke
parents:
diff changeset
100 // A JsrSet represents some set of JsrRecords. This class
a61af66fc99e Initial load
duke
parents:
diff changeset
101 // is used to record a set of all jsr routines which we permit
a61af66fc99e Initial load
duke
parents:
diff changeset
102 // execution to return (ret) from.
a61af66fc99e Initial load
duke
parents:
diff changeset
103 //
a61af66fc99e Initial load
duke
parents:
diff changeset
104 // During abstract interpretation, JsrSets are used to determine
a61af66fc99e Initial load
duke
parents:
diff changeset
105 // whether two paths which reach a given block are unique, and
a61af66fc99e Initial load
duke
parents:
diff changeset
106 // should be cloned apart, or are compatible, and should merge
a61af66fc99e Initial load
duke
parents:
diff changeset
107 // together.
a61af66fc99e Initial load
duke
parents:
diff changeset
108 //
a61af66fc99e Initial load
duke
parents:
diff changeset
109 // Note that different amounts of effort can be expended determining
a61af66fc99e Initial load
duke
parents:
diff changeset
110 // if paths are compatible. <DISCUSSION>
a61af66fc99e Initial load
duke
parents:
diff changeset
111 class JsrSet : public ResourceObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
112 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
113 GrowableArray<JsrRecord*>* _set;
a61af66fc99e Initial load
duke
parents:
diff changeset
114
a61af66fc99e Initial load
duke
parents:
diff changeset
115 JsrRecord* record_at(int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
116 return _set->at(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
117 }
a61af66fc99e Initial load
duke
parents:
diff changeset
118
a61af66fc99e Initial load
duke
parents:
diff changeset
119 // Insert the given JsrRecord into the JsrSet, maintaining the order
a61af66fc99e Initial load
duke
parents:
diff changeset
120 // of the set and replacing any element with the same entry address.
a61af66fc99e Initial load
duke
parents:
diff changeset
121 void insert_jsr_record(JsrRecord* record);
a61af66fc99e Initial load
duke
parents:
diff changeset
122
a61af66fc99e Initial load
duke
parents:
diff changeset
123 // Remove the JsrRecord with the given return address from the JsrSet.
a61af66fc99e Initial load
duke
parents:
diff changeset
124 void remove_jsr_record(int return_address);
a61af66fc99e Initial load
duke
parents:
diff changeset
125
a61af66fc99e Initial load
duke
parents:
diff changeset
126 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
127 JsrSet(Arena* arena, int default_len = 4);
a61af66fc99e Initial load
duke
parents:
diff changeset
128
a61af66fc99e Initial load
duke
parents:
diff changeset
129 // Copy this JsrSet.
a61af66fc99e Initial load
duke
parents:
diff changeset
130 void copy_into(JsrSet* jsrs);
a61af66fc99e Initial load
duke
parents:
diff changeset
131
a61af66fc99e Initial load
duke
parents:
diff changeset
132 // Is this JsrSet compatible with some other JsrSet?
a61af66fc99e Initial load
duke
parents:
diff changeset
133 bool is_compatible_with(JsrSet* other);
a61af66fc99e Initial load
duke
parents:
diff changeset
134
a61af66fc99e Initial load
duke
parents:
diff changeset
135 // Apply the effect of a single bytecode to the JsrSet.
a61af66fc99e Initial load
duke
parents:
diff changeset
136 void apply_control(ciTypeFlow* analyzer,
a61af66fc99e Initial load
duke
parents:
diff changeset
137 ciBytecodeStream* str,
a61af66fc99e Initial load
duke
parents:
diff changeset
138 StateVector* state);
a61af66fc99e Initial load
duke
parents:
diff changeset
139
a61af66fc99e Initial load
duke
parents:
diff changeset
140 // What is the cardinality of this set?
a61af66fc99e Initial load
duke
parents:
diff changeset
141 int size() const { return _set->length(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
142
a61af66fc99e Initial load
duke
parents:
diff changeset
143 void print_on(outputStream* st) const PRODUCT_RETURN;
a61af66fc99e Initial load
duke
parents:
diff changeset
144 };
a61af66fc99e Initial load
duke
parents:
diff changeset
145
367
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
146 class LocalSet VALUE_OBJ_CLASS_SPEC {
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
147 private:
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
148 enum Constants { max = 63 };
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
149 uint64_t _bits;
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
150 public:
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
151 LocalSet() : _bits(0) {}
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
152 void add(uint32_t i) { if (i < (uint32_t)max) _bits |= (1LL << i); }
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
153 void add(LocalSet* ls) { _bits |= ls->_bits; }
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
154 bool test(uint32_t i) const { return i < (uint32_t)max ? (_bits>>i)&1U : true; }
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
155 void clear() { _bits = 0; }
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
156 void print_on(outputStream* st, int limit) const PRODUCT_RETURN;
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
157 };
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
158
0
a61af66fc99e Initial load
duke
parents:
diff changeset
159 // Used as a combined index for locals and temps
a61af66fc99e Initial load
duke
parents:
diff changeset
160 enum Cell {
303
fa4d1d240383 6741642: bad enum definition in ciTypeFlow.hpp
never
parents: 0
diff changeset
161 Cell_0, Cell_max = INT_MAX
0
a61af66fc99e Initial load
duke
parents:
diff changeset
162 };
a61af66fc99e Initial load
duke
parents:
diff changeset
163
a61af66fc99e Initial load
duke
parents:
diff changeset
164 // A StateVector summarizes the type information at some
a61af66fc99e Initial load
duke
parents:
diff changeset
165 // point in the program
a61af66fc99e Initial load
duke
parents:
diff changeset
166 class StateVector : public ResourceObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
167 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
168 ciType** _types;
a61af66fc99e Initial load
duke
parents:
diff changeset
169 int _stack_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
170 int _monitor_count;
a61af66fc99e Initial load
duke
parents:
diff changeset
171 ciTypeFlow* _outer;
a61af66fc99e Initial load
duke
parents:
diff changeset
172
a61af66fc99e Initial load
duke
parents:
diff changeset
173 int _trap_bci;
a61af66fc99e Initial load
duke
parents:
diff changeset
174 int _trap_index;
a61af66fc99e Initial load
duke
parents:
diff changeset
175
367
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
176 LocalSet _def_locals; // For entire block
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
177
0
a61af66fc99e Initial load
duke
parents:
diff changeset
178 static ciType* type_meet_internal(ciType* t1, ciType* t2, ciTypeFlow* analyzer);
a61af66fc99e Initial load
duke
parents:
diff changeset
179
a61af66fc99e Initial load
duke
parents:
diff changeset
180 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
181 // Special elements in our type lattice.
a61af66fc99e Initial load
duke
parents:
diff changeset
182 enum {
a61af66fc99e Initial load
duke
parents:
diff changeset
183 T_TOP = T_VOID, // why not?
a61af66fc99e Initial load
duke
parents:
diff changeset
184 T_BOTTOM = T_CONFLICT,
a61af66fc99e Initial load
duke
parents:
diff changeset
185 T_LONG2 = T_SHORT, // 2nd word of T_LONG
a61af66fc99e Initial load
duke
parents:
diff changeset
186 T_DOUBLE2 = T_CHAR, // 2nd word of T_DOUBLE
a61af66fc99e Initial load
duke
parents:
diff changeset
187 T_NULL = T_BYTE // for now.
a61af66fc99e Initial load
duke
parents:
diff changeset
188 };
a61af66fc99e Initial load
duke
parents:
diff changeset
189 static ciType* top_type() { return ciType::make((BasicType)T_TOP); }
a61af66fc99e Initial load
duke
parents:
diff changeset
190 static ciType* bottom_type() { return ciType::make((BasicType)T_BOTTOM); }
a61af66fc99e Initial load
duke
parents:
diff changeset
191 static ciType* long2_type() { return ciType::make((BasicType)T_LONG2); }
a61af66fc99e Initial load
duke
parents:
diff changeset
192 static ciType* double2_type(){ return ciType::make((BasicType)T_DOUBLE2); }
a61af66fc99e Initial load
duke
parents:
diff changeset
193 static ciType* null_type() { return ciType::make((BasicType)T_NULL); }
a61af66fc99e Initial load
duke
parents:
diff changeset
194
a61af66fc99e Initial load
duke
parents:
diff changeset
195 static ciType* half_type(ciType* t) {
a61af66fc99e Initial load
duke
parents:
diff changeset
196 switch (t->basic_type()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
197 case T_LONG: return long2_type();
a61af66fc99e Initial load
duke
parents:
diff changeset
198 case T_DOUBLE: return double2_type();
a61af66fc99e Initial load
duke
parents:
diff changeset
199 default: ShouldNotReachHere(); return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
200 }
a61af66fc99e Initial load
duke
parents:
diff changeset
201 }
a61af66fc99e Initial load
duke
parents:
diff changeset
202
a61af66fc99e Initial load
duke
parents:
diff changeset
203 // The meet operation for our type lattice.
a61af66fc99e Initial load
duke
parents:
diff changeset
204 ciType* type_meet(ciType* t1, ciType* t2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
205 return type_meet_internal(t1, t2, outer());
a61af66fc99e Initial load
duke
parents:
diff changeset
206 }
a61af66fc99e Initial load
duke
parents:
diff changeset
207
a61af66fc99e Initial load
duke
parents:
diff changeset
208 // Accessors
a61af66fc99e Initial load
duke
parents:
diff changeset
209 ciTypeFlow* outer() const { return _outer; }
a61af66fc99e Initial load
duke
parents:
diff changeset
210
a61af66fc99e Initial load
duke
parents:
diff changeset
211 int stack_size() const { return _stack_size; }
a61af66fc99e Initial load
duke
parents:
diff changeset
212 void set_stack_size(int ss) { _stack_size = ss; }
a61af66fc99e Initial load
duke
parents:
diff changeset
213
a61af66fc99e Initial load
duke
parents:
diff changeset
214 int monitor_count() const { return _monitor_count; }
a61af66fc99e Initial load
duke
parents:
diff changeset
215 void set_monitor_count(int mc) { _monitor_count = mc; }
a61af66fc99e Initial load
duke
parents:
diff changeset
216
367
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
217 LocalSet* def_locals() { return &_def_locals; }
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
218 const LocalSet* def_locals() const { return &_def_locals; }
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
219
0
a61af66fc99e Initial load
duke
parents:
diff changeset
220 static Cell start_cell() { return (Cell)0; }
a61af66fc99e Initial load
duke
parents:
diff changeset
221 static Cell next_cell(Cell c) { return (Cell)(((int)c) + 1); }
a61af66fc99e Initial load
duke
parents:
diff changeset
222 Cell limit_cell() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
223 return (Cell)(outer()->max_locals() + stack_size());
a61af66fc99e Initial load
duke
parents:
diff changeset
224 }
a61af66fc99e Initial load
duke
parents:
diff changeset
225
a61af66fc99e Initial load
duke
parents:
diff changeset
226 // Cell creation
a61af66fc99e Initial load
duke
parents:
diff changeset
227 Cell local(int lnum) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
228 assert(lnum < outer()->max_locals(), "index check");
a61af66fc99e Initial load
duke
parents:
diff changeset
229 return (Cell)(lnum);
a61af66fc99e Initial load
duke
parents:
diff changeset
230 }
a61af66fc99e Initial load
duke
parents:
diff changeset
231
a61af66fc99e Initial load
duke
parents:
diff changeset
232 Cell stack(int snum) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
233 assert(snum < stack_size(), "index check");
a61af66fc99e Initial load
duke
parents:
diff changeset
234 return (Cell)(outer()->max_locals() + snum);
a61af66fc99e Initial load
duke
parents:
diff changeset
235 }
a61af66fc99e Initial load
duke
parents:
diff changeset
236
a61af66fc99e Initial load
duke
parents:
diff changeset
237 Cell tos() const { return stack(stack_size()-1); }
a61af66fc99e Initial load
duke
parents:
diff changeset
238
a61af66fc99e Initial load
duke
parents:
diff changeset
239 // For external use only:
a61af66fc99e Initial load
duke
parents:
diff changeset
240 ciType* local_type_at(int i) const { return type_at(local(i)); }
a61af66fc99e Initial load
duke
parents:
diff changeset
241 ciType* stack_type_at(int i) const { return type_at(stack(i)); }
a61af66fc99e Initial load
duke
parents:
diff changeset
242
a61af66fc99e Initial load
duke
parents:
diff changeset
243 // Accessors for the type of some Cell c
a61af66fc99e Initial load
duke
parents:
diff changeset
244 ciType* type_at(Cell c) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
245 assert(start_cell() <= c && c < limit_cell(), "out of bounds");
a61af66fc99e Initial load
duke
parents:
diff changeset
246 return _types[c];
a61af66fc99e Initial load
duke
parents:
diff changeset
247 }
a61af66fc99e Initial load
duke
parents:
diff changeset
248
a61af66fc99e Initial load
duke
parents:
diff changeset
249 void set_type_at(Cell c, ciType* type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
250 assert(start_cell() <= c && c < limit_cell(), "out of bounds");
a61af66fc99e Initial load
duke
parents:
diff changeset
251 _types[c] = type;
a61af66fc99e Initial load
duke
parents:
diff changeset
252 }
a61af66fc99e Initial load
duke
parents:
diff changeset
253
a61af66fc99e Initial load
duke
parents:
diff changeset
254 // Top-of-stack operations.
a61af66fc99e Initial load
duke
parents:
diff changeset
255 void set_type_at_tos(ciType* type) { set_type_at(tos(), type); }
a61af66fc99e Initial load
duke
parents:
diff changeset
256 ciType* type_at_tos() const { return type_at(tos()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
257
a61af66fc99e Initial load
duke
parents:
diff changeset
258 void push(ciType* type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
259 _stack_size++;
a61af66fc99e Initial load
duke
parents:
diff changeset
260 set_type_at_tos(type);
a61af66fc99e Initial load
duke
parents:
diff changeset
261 }
a61af66fc99e Initial load
duke
parents:
diff changeset
262 void pop() {
a61af66fc99e Initial load
duke
parents:
diff changeset
263 debug_only(set_type_at_tos(bottom_type()));
a61af66fc99e Initial load
duke
parents:
diff changeset
264 _stack_size--;
a61af66fc99e Initial load
duke
parents:
diff changeset
265 }
a61af66fc99e Initial load
duke
parents:
diff changeset
266 ciType* pop_value() {
a61af66fc99e Initial load
duke
parents:
diff changeset
267 ciType* t = type_at_tos();
a61af66fc99e Initial load
duke
parents:
diff changeset
268 pop();
a61af66fc99e Initial load
duke
parents:
diff changeset
269 return t;
a61af66fc99e Initial load
duke
parents:
diff changeset
270 }
a61af66fc99e Initial load
duke
parents:
diff changeset
271
a61af66fc99e Initial load
duke
parents:
diff changeset
272 // Convenience operations.
a61af66fc99e Initial load
duke
parents:
diff changeset
273 bool is_reference(ciType* type) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
274 return type == null_type() || !type->is_primitive_type();
a61af66fc99e Initial load
duke
parents:
diff changeset
275 }
a61af66fc99e Initial load
duke
parents:
diff changeset
276 bool is_int(ciType* type) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
277 return type->basic_type() == T_INT;
a61af66fc99e Initial load
duke
parents:
diff changeset
278 }
a61af66fc99e Initial load
duke
parents:
diff changeset
279 bool is_long(ciType* type) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
280 return type->basic_type() == T_LONG;
a61af66fc99e Initial load
duke
parents:
diff changeset
281 }
a61af66fc99e Initial load
duke
parents:
diff changeset
282 bool is_float(ciType* type) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
283 return type->basic_type() == T_FLOAT;
a61af66fc99e Initial load
duke
parents:
diff changeset
284 }
a61af66fc99e Initial load
duke
parents:
diff changeset
285 bool is_double(ciType* type) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
286 return type->basic_type() == T_DOUBLE;
a61af66fc99e Initial load
duke
parents:
diff changeset
287 }
a61af66fc99e Initial load
duke
parents:
diff changeset
288
367
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
289 void store_to_local(int lnum) {
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
290 _def_locals.add((uint) lnum);
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
291 }
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
292
0
a61af66fc99e Initial load
duke
parents:
diff changeset
293 void push_translate(ciType* type);
a61af66fc99e Initial load
duke
parents:
diff changeset
294
a61af66fc99e Initial load
duke
parents:
diff changeset
295 void push_int() {
a61af66fc99e Initial load
duke
parents:
diff changeset
296 push(ciType::make(T_INT));
a61af66fc99e Initial load
duke
parents:
diff changeset
297 }
a61af66fc99e Initial load
duke
parents:
diff changeset
298 void pop_int() {
a61af66fc99e Initial load
duke
parents:
diff changeset
299 assert(is_int(type_at_tos()), "must be integer");
a61af66fc99e Initial load
duke
parents:
diff changeset
300 pop();
a61af66fc99e Initial load
duke
parents:
diff changeset
301 }
a61af66fc99e Initial load
duke
parents:
diff changeset
302 void check_int(Cell c) {
a61af66fc99e Initial load
duke
parents:
diff changeset
303 assert(is_int(type_at(c)), "must be integer");
a61af66fc99e Initial load
duke
parents:
diff changeset
304 }
a61af66fc99e Initial load
duke
parents:
diff changeset
305 void push_double() {
a61af66fc99e Initial load
duke
parents:
diff changeset
306 push(ciType::make(T_DOUBLE));
a61af66fc99e Initial load
duke
parents:
diff changeset
307 push(double2_type());
a61af66fc99e Initial load
duke
parents:
diff changeset
308 }
a61af66fc99e Initial load
duke
parents:
diff changeset
309 void pop_double() {
a61af66fc99e Initial load
duke
parents:
diff changeset
310 assert(type_at_tos() == double2_type(), "must be 2nd half");
a61af66fc99e Initial load
duke
parents:
diff changeset
311 pop();
a61af66fc99e Initial load
duke
parents:
diff changeset
312 assert(is_double(type_at_tos()), "must be double");
a61af66fc99e Initial load
duke
parents:
diff changeset
313 pop();
a61af66fc99e Initial load
duke
parents:
diff changeset
314 }
a61af66fc99e Initial load
duke
parents:
diff changeset
315 void push_float() {
a61af66fc99e Initial load
duke
parents:
diff changeset
316 push(ciType::make(T_FLOAT));
a61af66fc99e Initial load
duke
parents:
diff changeset
317 }
a61af66fc99e Initial load
duke
parents:
diff changeset
318 void pop_float() {
a61af66fc99e Initial load
duke
parents:
diff changeset
319 assert(is_float(type_at_tos()), "must be float");
a61af66fc99e Initial load
duke
parents:
diff changeset
320 pop();
a61af66fc99e Initial load
duke
parents:
diff changeset
321 }
a61af66fc99e Initial load
duke
parents:
diff changeset
322 void push_long() {
a61af66fc99e Initial load
duke
parents:
diff changeset
323 push(ciType::make(T_LONG));
a61af66fc99e Initial load
duke
parents:
diff changeset
324 push(long2_type());
a61af66fc99e Initial load
duke
parents:
diff changeset
325 }
a61af66fc99e Initial load
duke
parents:
diff changeset
326 void pop_long() {
a61af66fc99e Initial load
duke
parents:
diff changeset
327 assert(type_at_tos() == long2_type(), "must be 2nd half");
a61af66fc99e Initial load
duke
parents:
diff changeset
328 pop();
a61af66fc99e Initial load
duke
parents:
diff changeset
329 assert(is_long(type_at_tos()), "must be long");
a61af66fc99e Initial load
duke
parents:
diff changeset
330 pop();
a61af66fc99e Initial load
duke
parents:
diff changeset
331 }
a61af66fc99e Initial load
duke
parents:
diff changeset
332 void push_object(ciKlass* klass) {
a61af66fc99e Initial load
duke
parents:
diff changeset
333 push(klass);
a61af66fc99e Initial load
duke
parents:
diff changeset
334 }
a61af66fc99e Initial load
duke
parents:
diff changeset
335 void pop_object() {
a61af66fc99e Initial load
duke
parents:
diff changeset
336 assert(is_reference(type_at_tos()), "must be reference type");
a61af66fc99e Initial load
duke
parents:
diff changeset
337 pop();
a61af66fc99e Initial load
duke
parents:
diff changeset
338 }
a61af66fc99e Initial load
duke
parents:
diff changeset
339 void pop_array() {
a61af66fc99e Initial load
duke
parents:
diff changeset
340 assert(type_at_tos() == null_type() ||
a61af66fc99e Initial load
duke
parents:
diff changeset
341 type_at_tos()->is_array_klass(), "must be array type");
a61af66fc99e Initial load
duke
parents:
diff changeset
342 pop();
a61af66fc99e Initial load
duke
parents:
diff changeset
343 }
a61af66fc99e Initial load
duke
parents:
diff changeset
344 // pop_objArray and pop_typeArray narrow the tos to ciObjArrayKlass
a61af66fc99e Initial load
duke
parents:
diff changeset
345 // or ciTypeArrayKlass (resp.). In the rare case that an explicit
a61af66fc99e Initial load
duke
parents:
diff changeset
346 // null is popped from the stack, we return NULL. Caller beware.
a61af66fc99e Initial load
duke
parents:
diff changeset
347 ciObjArrayKlass* pop_objArray() {
a61af66fc99e Initial load
duke
parents:
diff changeset
348 ciType* array = pop_value();
a61af66fc99e Initial load
duke
parents:
diff changeset
349 if (array == null_type()) return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
350 assert(array->is_obj_array_klass(), "must be object array type");
a61af66fc99e Initial load
duke
parents:
diff changeset
351 return array->as_obj_array_klass();
a61af66fc99e Initial load
duke
parents:
diff changeset
352 }
a61af66fc99e Initial load
duke
parents:
diff changeset
353 ciTypeArrayKlass* pop_typeArray() {
a61af66fc99e Initial load
duke
parents:
diff changeset
354 ciType* array = pop_value();
a61af66fc99e Initial load
duke
parents:
diff changeset
355 if (array == null_type()) return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
356 assert(array->is_type_array_klass(), "must be prim array type");
a61af66fc99e Initial load
duke
parents:
diff changeset
357 return array->as_type_array_klass();
a61af66fc99e Initial load
duke
parents:
diff changeset
358 }
a61af66fc99e Initial load
duke
parents:
diff changeset
359 void push_null() {
a61af66fc99e Initial load
duke
parents:
diff changeset
360 push(null_type());
a61af66fc99e Initial load
duke
parents:
diff changeset
361 }
a61af66fc99e Initial load
duke
parents:
diff changeset
362 void do_null_assert(ciKlass* unloaded_klass);
a61af66fc99e Initial load
duke
parents:
diff changeset
363
a61af66fc99e Initial load
duke
parents:
diff changeset
364 // Helper convenience routines.
a61af66fc99e Initial load
duke
parents:
diff changeset
365 void do_aaload(ciBytecodeStream* str);
a61af66fc99e Initial load
duke
parents:
diff changeset
366 void do_checkcast(ciBytecodeStream* str);
a61af66fc99e Initial load
duke
parents:
diff changeset
367 void do_getfield(ciBytecodeStream* str);
a61af66fc99e Initial load
duke
parents:
diff changeset
368 void do_getstatic(ciBytecodeStream* str);
a61af66fc99e Initial load
duke
parents:
diff changeset
369 void do_invoke(ciBytecodeStream* str, bool has_receiver);
a61af66fc99e Initial load
duke
parents:
diff changeset
370 void do_jsr(ciBytecodeStream* str);
a61af66fc99e Initial load
duke
parents:
diff changeset
371 void do_ldc(ciBytecodeStream* str);
a61af66fc99e Initial load
duke
parents:
diff changeset
372 void do_multianewarray(ciBytecodeStream* str);
a61af66fc99e Initial load
duke
parents:
diff changeset
373 void do_new(ciBytecodeStream* str);
a61af66fc99e Initial load
duke
parents:
diff changeset
374 void do_newarray(ciBytecodeStream* str);
a61af66fc99e Initial load
duke
parents:
diff changeset
375 void do_putfield(ciBytecodeStream* str);
a61af66fc99e Initial load
duke
parents:
diff changeset
376 void do_putstatic(ciBytecodeStream* str);
a61af66fc99e Initial load
duke
parents:
diff changeset
377 void do_ret(ciBytecodeStream* str);
a61af66fc99e Initial load
duke
parents:
diff changeset
378
a61af66fc99e Initial load
duke
parents:
diff changeset
379 void overwrite_local_double_long(int index) {
a61af66fc99e Initial load
duke
parents:
diff changeset
380 // Invalidate the previous local if it contains first half of
a61af66fc99e Initial load
duke
parents:
diff changeset
381 // a double or long value since it's seconf half is being overwritten.
a61af66fc99e Initial load
duke
parents:
diff changeset
382 int prev_index = index - 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
383 if (prev_index >= 0 &&
a61af66fc99e Initial load
duke
parents:
diff changeset
384 (is_double(type_at(local(prev_index))) ||
a61af66fc99e Initial load
duke
parents:
diff changeset
385 is_long(type_at(local(prev_index))))) {
a61af66fc99e Initial load
duke
parents:
diff changeset
386 set_type_at(local(prev_index), bottom_type());
a61af66fc99e Initial load
duke
parents:
diff changeset
387 }
a61af66fc99e Initial load
duke
parents:
diff changeset
388 }
a61af66fc99e Initial load
duke
parents:
diff changeset
389
a61af66fc99e Initial load
duke
parents:
diff changeset
390 void load_local_object(int index) {
a61af66fc99e Initial load
duke
parents:
diff changeset
391 ciType* type = type_at(local(index));
a61af66fc99e Initial load
duke
parents:
diff changeset
392 assert(is_reference(type), "must be reference type");
a61af66fc99e Initial load
duke
parents:
diff changeset
393 push(type);
a61af66fc99e Initial load
duke
parents:
diff changeset
394 }
a61af66fc99e Initial load
duke
parents:
diff changeset
395 void store_local_object(int index) {
a61af66fc99e Initial load
duke
parents:
diff changeset
396 ciType* type = pop_value();
a61af66fc99e Initial load
duke
parents:
diff changeset
397 assert(is_reference(type) || type->is_return_address(),
a61af66fc99e Initial load
duke
parents:
diff changeset
398 "must be reference type or return address");
a61af66fc99e Initial load
duke
parents:
diff changeset
399 overwrite_local_double_long(index);
a61af66fc99e Initial load
duke
parents:
diff changeset
400 set_type_at(local(index), type);
367
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
401 store_to_local(index);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
402 }
a61af66fc99e Initial load
duke
parents:
diff changeset
403
a61af66fc99e Initial load
duke
parents:
diff changeset
404 void load_local_double(int index) {
a61af66fc99e Initial load
duke
parents:
diff changeset
405 ciType* type = type_at(local(index));
a61af66fc99e Initial load
duke
parents:
diff changeset
406 ciType* type2 = type_at(local(index+1));
a61af66fc99e Initial load
duke
parents:
diff changeset
407 assert(is_double(type), "must be double type");
a61af66fc99e Initial load
duke
parents:
diff changeset
408 assert(type2 == double2_type(), "must be 2nd half");
a61af66fc99e Initial load
duke
parents:
diff changeset
409 push(type);
a61af66fc99e Initial load
duke
parents:
diff changeset
410 push(double2_type());
a61af66fc99e Initial load
duke
parents:
diff changeset
411 }
a61af66fc99e Initial load
duke
parents:
diff changeset
412 void store_local_double(int index) {
a61af66fc99e Initial load
duke
parents:
diff changeset
413 ciType* type2 = pop_value();
a61af66fc99e Initial load
duke
parents:
diff changeset
414 ciType* type = pop_value();
a61af66fc99e Initial load
duke
parents:
diff changeset
415 assert(is_double(type), "must be double");
a61af66fc99e Initial load
duke
parents:
diff changeset
416 assert(type2 == double2_type(), "must be 2nd half");
a61af66fc99e Initial load
duke
parents:
diff changeset
417 overwrite_local_double_long(index);
a61af66fc99e Initial load
duke
parents:
diff changeset
418 set_type_at(local(index), type);
a61af66fc99e Initial load
duke
parents:
diff changeset
419 set_type_at(local(index+1), type2);
367
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
420 store_to_local(index);
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
421 store_to_local(index+1);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
422 }
a61af66fc99e Initial load
duke
parents:
diff changeset
423
a61af66fc99e Initial load
duke
parents:
diff changeset
424 void load_local_float(int index) {
a61af66fc99e Initial load
duke
parents:
diff changeset
425 ciType* type = type_at(local(index));
a61af66fc99e Initial load
duke
parents:
diff changeset
426 assert(is_float(type), "must be float type");
a61af66fc99e Initial load
duke
parents:
diff changeset
427 push(type);
a61af66fc99e Initial load
duke
parents:
diff changeset
428 }
a61af66fc99e Initial load
duke
parents:
diff changeset
429 void store_local_float(int index) {
a61af66fc99e Initial load
duke
parents:
diff changeset
430 ciType* type = pop_value();
a61af66fc99e Initial load
duke
parents:
diff changeset
431 assert(is_float(type), "must be float type");
a61af66fc99e Initial load
duke
parents:
diff changeset
432 overwrite_local_double_long(index);
a61af66fc99e Initial load
duke
parents:
diff changeset
433 set_type_at(local(index), type);
367
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
434 store_to_local(index);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
435 }
a61af66fc99e Initial load
duke
parents:
diff changeset
436
a61af66fc99e Initial load
duke
parents:
diff changeset
437 void load_local_int(int index) {
a61af66fc99e Initial load
duke
parents:
diff changeset
438 ciType* type = type_at(local(index));
a61af66fc99e Initial load
duke
parents:
diff changeset
439 assert(is_int(type), "must be int type");
a61af66fc99e Initial load
duke
parents:
diff changeset
440 push(type);
a61af66fc99e Initial load
duke
parents:
diff changeset
441 }
a61af66fc99e Initial load
duke
parents:
diff changeset
442 void store_local_int(int index) {
a61af66fc99e Initial load
duke
parents:
diff changeset
443 ciType* type = pop_value();
a61af66fc99e Initial load
duke
parents:
diff changeset
444 assert(is_int(type), "must be int type");
a61af66fc99e Initial load
duke
parents:
diff changeset
445 overwrite_local_double_long(index);
a61af66fc99e Initial load
duke
parents:
diff changeset
446 set_type_at(local(index), type);
367
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
447 store_to_local(index);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
448 }
a61af66fc99e Initial load
duke
parents:
diff changeset
449
a61af66fc99e Initial load
duke
parents:
diff changeset
450 void load_local_long(int index) {
a61af66fc99e Initial load
duke
parents:
diff changeset
451 ciType* type = type_at(local(index));
a61af66fc99e Initial load
duke
parents:
diff changeset
452 ciType* type2 = type_at(local(index+1));
a61af66fc99e Initial load
duke
parents:
diff changeset
453 assert(is_long(type), "must be long type");
a61af66fc99e Initial load
duke
parents:
diff changeset
454 assert(type2 == long2_type(), "must be 2nd half");
a61af66fc99e Initial load
duke
parents:
diff changeset
455 push(type);
a61af66fc99e Initial load
duke
parents:
diff changeset
456 push(long2_type());
a61af66fc99e Initial load
duke
parents:
diff changeset
457 }
a61af66fc99e Initial load
duke
parents:
diff changeset
458 void store_local_long(int index) {
a61af66fc99e Initial load
duke
parents:
diff changeset
459 ciType* type2 = pop_value();
a61af66fc99e Initial load
duke
parents:
diff changeset
460 ciType* type = pop_value();
a61af66fc99e Initial load
duke
parents:
diff changeset
461 assert(is_long(type), "must be long");
a61af66fc99e Initial load
duke
parents:
diff changeset
462 assert(type2 == long2_type(), "must be 2nd half");
a61af66fc99e Initial load
duke
parents:
diff changeset
463 overwrite_local_double_long(index);
a61af66fc99e Initial load
duke
parents:
diff changeset
464 set_type_at(local(index), type);
a61af66fc99e Initial load
duke
parents:
diff changeset
465 set_type_at(local(index+1), type2);
367
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
466 store_to_local(index);
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
467 store_to_local(index+1);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
468 }
a61af66fc99e Initial load
duke
parents:
diff changeset
469
a61af66fc99e Initial load
duke
parents:
diff changeset
470 // Stop interpretation of this path with a trap.
a61af66fc99e Initial load
duke
parents:
diff changeset
471 void trap(ciBytecodeStream* str, ciKlass* klass, int index);
a61af66fc99e Initial load
duke
parents:
diff changeset
472
a61af66fc99e Initial load
duke
parents:
diff changeset
473 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
474 StateVector(ciTypeFlow* outer);
a61af66fc99e Initial load
duke
parents:
diff changeset
475
a61af66fc99e Initial load
duke
parents:
diff changeset
476 // Copy our value into some other StateVector
a61af66fc99e Initial load
duke
parents:
diff changeset
477 void copy_into(StateVector* copy) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
478
a61af66fc99e Initial load
duke
parents:
diff changeset
479 // Meets this StateVector with another, destructively modifying this
a61af66fc99e Initial load
duke
parents:
diff changeset
480 // one. Returns true if any modification takes place.
a61af66fc99e Initial load
duke
parents:
diff changeset
481 bool meet(const StateVector* incoming);
a61af66fc99e Initial load
duke
parents:
diff changeset
482
a61af66fc99e Initial load
duke
parents:
diff changeset
483 // Ditto, except that the incoming state is coming from an exception.
a61af66fc99e Initial load
duke
parents:
diff changeset
484 bool meet_exception(ciInstanceKlass* exc, const StateVector* incoming);
a61af66fc99e Initial load
duke
parents:
diff changeset
485
a61af66fc99e Initial load
duke
parents:
diff changeset
486 // Apply the effect of one bytecode to this StateVector
a61af66fc99e Initial load
duke
parents:
diff changeset
487 bool apply_one_bytecode(ciBytecodeStream* stream);
a61af66fc99e Initial load
duke
parents:
diff changeset
488
a61af66fc99e Initial load
duke
parents:
diff changeset
489 // What is the bci of the trap?
a61af66fc99e Initial load
duke
parents:
diff changeset
490 int trap_bci() { return _trap_bci; }
a61af66fc99e Initial load
duke
parents:
diff changeset
491
a61af66fc99e Initial load
duke
parents:
diff changeset
492 // What is the index associated with the trap?
a61af66fc99e Initial load
duke
parents:
diff changeset
493 int trap_index() { return _trap_index; }
a61af66fc99e Initial load
duke
parents:
diff changeset
494
a61af66fc99e Initial load
duke
parents:
diff changeset
495 void print_cell_on(outputStream* st, Cell c) const PRODUCT_RETURN;
a61af66fc99e Initial load
duke
parents:
diff changeset
496 void print_on(outputStream* st) const PRODUCT_RETURN;
a61af66fc99e Initial load
duke
parents:
diff changeset
497 };
a61af66fc99e Initial load
duke
parents:
diff changeset
498
a61af66fc99e Initial load
duke
parents:
diff changeset
499 // Parameter for "find_block" calls:
367
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
500 // Describes the difference between a public and backedge copy.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
501 enum CreateOption {
a61af66fc99e Initial load
duke
parents:
diff changeset
502 create_public_copy,
367
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
503 create_backedge_copy,
0
a61af66fc99e Initial load
duke
parents:
diff changeset
504 no_create
a61af66fc99e Initial load
duke
parents:
diff changeset
505 };
a61af66fc99e Initial load
duke
parents:
diff changeset
506
367
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
507 // Successor iterator
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
508 class SuccIter : public StackObj {
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
509 private:
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
510 Block* _pred;
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
511 int _index;
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
512 Block* _succ;
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
513 public:
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
514 SuccIter() : _pred(NULL), _index(-1), _succ(NULL) {}
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
515 SuccIter(Block* pred) : _pred(pred), _index(-1), _succ(NULL) { next(); }
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
516 int index() { return _index; }
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
517 Block* pred() { return _pred; } // Return predecessor
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
518 bool done() { return _index < 0; } // Finished?
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
519 Block* succ() { return _succ; } // Return current successor
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
520 void next(); // Advance
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
521 void set_succ(Block* succ); // Update current successor
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
522 bool is_normal_ctrl() { return index() < _pred->successors()->length(); }
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
523 };
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
524
0
a61af66fc99e Initial load
duke
parents:
diff changeset
525 // A basic block
a61af66fc99e Initial load
duke
parents:
diff changeset
526 class Block : public ResourceObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
527 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
528 ciBlock* _ciblock;
a61af66fc99e Initial load
duke
parents:
diff changeset
529 GrowableArray<Block*>* _exceptions;
a61af66fc99e Initial load
duke
parents:
diff changeset
530 GrowableArray<ciInstanceKlass*>* _exc_klasses;
a61af66fc99e Initial load
duke
parents:
diff changeset
531 GrowableArray<Block*>* _successors;
a61af66fc99e Initial load
duke
parents:
diff changeset
532 StateVector* _state;
a61af66fc99e Initial load
duke
parents:
diff changeset
533 JsrSet* _jsrs;
a61af66fc99e Initial load
duke
parents:
diff changeset
534
a61af66fc99e Initial load
duke
parents:
diff changeset
535 int _trap_bci;
a61af66fc99e Initial load
duke
parents:
diff changeset
536 int _trap_index;
a61af66fc99e Initial load
duke
parents:
diff changeset
537
367
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
538 // pre_order, assigned at first visit. Used as block ID and "visited" tag
0
a61af66fc99e Initial load
duke
parents:
diff changeset
539 int _pre_order;
a61af66fc99e Initial load
duke
parents:
diff changeset
540
367
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
541 // A post-order, used to compute the reverse post order (RPO) provided to the client
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
542 int _post_order; // used to compute rpo
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
543
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
544 // Has this block been cloned for a loop backedge?
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
545 bool _backedge_copy;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
546
4777
e9a5e0a812c8 7125896: Eliminate nested locks
kvn
parents: 2447
diff changeset
547 // This block is entry to irreducible loop.
e9a5e0a812c8 7125896: Eliminate nested locks
kvn
parents: 2447
diff changeset
548 bool _irreducible_entry;
e9a5e0a812c8 7125896: Eliminate nested locks
kvn
parents: 2447
diff changeset
549
e9a5e0a812c8 7125896: Eliminate nested locks
kvn
parents: 2447
diff changeset
550 // This block has monitor entry point.
e9a5e0a812c8 7125896: Eliminate nested locks
kvn
parents: 2447
diff changeset
551 bool _has_monitorenter;
e9a5e0a812c8 7125896: Eliminate nested locks
kvn
parents: 2447
diff changeset
552
0
a61af66fc99e Initial load
duke
parents:
diff changeset
553 // A pointer used for our internal work list
4777
e9a5e0a812c8 7125896: Eliminate nested locks
kvn
parents: 2447
diff changeset
554 bool _on_work_list; // on the work list
367
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
555 Block* _next;
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
556 Block* _rpo_next; // Reverse post order list
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
557
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
558 // Loop info
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
559 Loop* _loop; // nearest loop
0
a61af66fc99e Initial load
duke
parents:
diff changeset
560
a61af66fc99e Initial load
duke
parents:
diff changeset
561 ciBlock* ciblock() const { return _ciblock; }
a61af66fc99e Initial load
duke
parents:
diff changeset
562 StateVector* state() const { return _state; }
a61af66fc99e Initial load
duke
parents:
diff changeset
563
a61af66fc99e Initial load
duke
parents:
diff changeset
564 // Compute the exceptional successors and types for this Block.
a61af66fc99e Initial load
duke
parents:
diff changeset
565 void compute_exceptions();
a61af66fc99e Initial load
duke
parents:
diff changeset
566
a61af66fc99e Initial load
duke
parents:
diff changeset
567 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
568 // constructors
a61af66fc99e Initial load
duke
parents:
diff changeset
569 Block(ciTypeFlow* outer, ciBlock* ciblk, JsrSet* jsrs);
a61af66fc99e Initial load
duke
parents:
diff changeset
570
a61af66fc99e Initial load
duke
parents:
diff changeset
571 void set_trap(int trap_bci, int trap_index) {
a61af66fc99e Initial load
duke
parents:
diff changeset
572 _trap_bci = trap_bci;
a61af66fc99e Initial load
duke
parents:
diff changeset
573 _trap_index = trap_index;
a61af66fc99e Initial load
duke
parents:
diff changeset
574 assert(has_trap(), "");
a61af66fc99e Initial load
duke
parents:
diff changeset
575 }
a61af66fc99e Initial load
duke
parents:
diff changeset
576 bool has_trap() const { return _trap_bci != -1; }
a61af66fc99e Initial load
duke
parents:
diff changeset
577 int trap_bci() const { assert(has_trap(), ""); return _trap_bci; }
a61af66fc99e Initial load
duke
parents:
diff changeset
578 int trap_index() const { assert(has_trap(), ""); return _trap_index; }
a61af66fc99e Initial load
duke
parents:
diff changeset
579
a61af66fc99e Initial load
duke
parents:
diff changeset
580 // accessors
a61af66fc99e Initial load
duke
parents:
diff changeset
581 ciTypeFlow* outer() const { return state()->outer(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
582 int start() const { return _ciblock->start_bci(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
583 int limit() const { return _ciblock->limit_bci(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
584 int control() const { return _ciblock->control_bci(); }
367
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
585 JsrSet* jsrs() const { return _jsrs; }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
586
367
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
587 bool is_backedge_copy() const { return _backedge_copy; }
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
588 void set_backedge_copy(bool z);
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
589 int backedge_copy_count() const { return outer()->backedge_copy_count(ciblock()->index(), _jsrs); }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
590
a61af66fc99e Initial load
duke
parents:
diff changeset
591 // access to entry state
a61af66fc99e Initial load
duke
parents:
diff changeset
592 int stack_size() const { return _state->stack_size(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
593 int monitor_count() const { return _state->monitor_count(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
594 ciType* local_type_at(int i) const { return _state->local_type_at(i); }
a61af66fc99e Initial load
duke
parents:
diff changeset
595 ciType* stack_type_at(int i) const { return _state->stack_type_at(i); }
a61af66fc99e Initial load
duke
parents:
diff changeset
596
367
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
597 // Data flow on locals
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
598 bool is_invariant_local(uint v) const {
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
599 assert(is_loop_head(), "only loop heads");
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
600 // Find outermost loop with same loop head
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
601 Loop* lp = loop();
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
602 while (lp->parent() != NULL) {
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
603 if (lp->parent()->head() != lp->head()) break;
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
604 lp = lp->parent();
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
605 }
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
606 return !lp->def_locals()->test(v);
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
607 }
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
608 LocalSet* def_locals() { return _state->def_locals(); }
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
609 const LocalSet* def_locals() const { return _state->def_locals(); }
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
610
0
a61af66fc99e Initial load
duke
parents:
diff changeset
611 // Get the successors for this Block.
a61af66fc99e Initial load
duke
parents:
diff changeset
612 GrowableArray<Block*>* successors(ciBytecodeStream* str,
a61af66fc99e Initial load
duke
parents:
diff changeset
613 StateVector* state,
a61af66fc99e Initial load
duke
parents:
diff changeset
614 JsrSet* jsrs);
a61af66fc99e Initial load
duke
parents:
diff changeset
615 GrowableArray<Block*>* successors() {
a61af66fc99e Initial load
duke
parents:
diff changeset
616 assert(_successors != NULL, "must be filled in");
a61af66fc99e Initial load
duke
parents:
diff changeset
617 return _successors;
a61af66fc99e Initial load
duke
parents:
diff changeset
618 }
a61af66fc99e Initial load
duke
parents:
diff changeset
619
a61af66fc99e Initial load
duke
parents:
diff changeset
620 // Get the exceptional successors for this Block.
a61af66fc99e Initial load
duke
parents:
diff changeset
621 GrowableArray<Block*>* exceptions() {
a61af66fc99e Initial load
duke
parents:
diff changeset
622 if (_exceptions == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
623 compute_exceptions();
a61af66fc99e Initial load
duke
parents:
diff changeset
624 }
a61af66fc99e Initial load
duke
parents:
diff changeset
625 return _exceptions;
a61af66fc99e Initial load
duke
parents:
diff changeset
626 }
a61af66fc99e Initial load
duke
parents:
diff changeset
627
a61af66fc99e Initial load
duke
parents:
diff changeset
628 // Get the exception klasses corresponding to the
a61af66fc99e Initial load
duke
parents:
diff changeset
629 // exceptional successors for this Block.
a61af66fc99e Initial load
duke
parents:
diff changeset
630 GrowableArray<ciInstanceKlass*>* exc_klasses() {
a61af66fc99e Initial load
duke
parents:
diff changeset
631 if (_exc_klasses == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
632 compute_exceptions();
a61af66fc99e Initial load
duke
parents:
diff changeset
633 }
a61af66fc99e Initial load
duke
parents:
diff changeset
634 return _exc_klasses;
a61af66fc99e Initial load
duke
parents:
diff changeset
635 }
a61af66fc99e Initial load
duke
parents:
diff changeset
636
a61af66fc99e Initial load
duke
parents:
diff changeset
637 // Is this Block compatible with a given JsrSet?
a61af66fc99e Initial load
duke
parents:
diff changeset
638 bool is_compatible_with(JsrSet* other) {
a61af66fc99e Initial load
duke
parents:
diff changeset
639 return _jsrs->is_compatible_with(other);
a61af66fc99e Initial load
duke
parents:
diff changeset
640 }
a61af66fc99e Initial load
duke
parents:
diff changeset
641
a61af66fc99e Initial load
duke
parents:
diff changeset
642 // Copy the value of our state vector into another.
a61af66fc99e Initial load
duke
parents:
diff changeset
643 void copy_state_into(StateVector* copy) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
644 _state->copy_into(copy);
a61af66fc99e Initial load
duke
parents:
diff changeset
645 }
a61af66fc99e Initial load
duke
parents:
diff changeset
646
a61af66fc99e Initial load
duke
parents:
diff changeset
647 // Copy the value of our JsrSet into another
a61af66fc99e Initial load
duke
parents:
diff changeset
648 void copy_jsrs_into(JsrSet* copy) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
649 _jsrs->copy_into(copy);
a61af66fc99e Initial load
duke
parents:
diff changeset
650 }
a61af66fc99e Initial load
duke
parents:
diff changeset
651
a61af66fc99e Initial load
duke
parents:
diff changeset
652 // Meets the start state of this block with another state, destructively
a61af66fc99e Initial load
duke
parents:
diff changeset
653 // modifying this one. Returns true if any modification takes place.
a61af66fc99e Initial load
duke
parents:
diff changeset
654 bool meet(const StateVector* incoming) {
a61af66fc99e Initial load
duke
parents:
diff changeset
655 return state()->meet(incoming);
a61af66fc99e Initial load
duke
parents:
diff changeset
656 }
a61af66fc99e Initial load
duke
parents:
diff changeset
657
a61af66fc99e Initial load
duke
parents:
diff changeset
658 // Ditto, except that the incoming state is coming from an
a61af66fc99e Initial load
duke
parents:
diff changeset
659 // exception path. This means the stack is replaced by the
a61af66fc99e Initial load
duke
parents:
diff changeset
660 // appropriate exception type.
a61af66fc99e Initial load
duke
parents:
diff changeset
661 bool meet_exception(ciInstanceKlass* exc, const StateVector* incoming) {
a61af66fc99e Initial load
duke
parents:
diff changeset
662 return state()->meet_exception(exc, incoming);
a61af66fc99e Initial load
duke
parents:
diff changeset
663 }
a61af66fc99e Initial load
duke
parents:
diff changeset
664
a61af66fc99e Initial load
duke
parents:
diff changeset
665 // Work list manipulation
a61af66fc99e Initial load
duke
parents:
diff changeset
666 void set_next(Block* block) { _next = block; }
a61af66fc99e Initial load
duke
parents:
diff changeset
667 Block* next() const { return _next; }
a61af66fc99e Initial load
duke
parents:
diff changeset
668
a61af66fc99e Initial load
duke
parents:
diff changeset
669 void set_on_work_list(bool c) { _on_work_list = c; }
a61af66fc99e Initial load
duke
parents:
diff changeset
670 bool is_on_work_list() const { return _on_work_list; }
a61af66fc99e Initial load
duke
parents:
diff changeset
671
a61af66fc99e Initial load
duke
parents:
diff changeset
672 bool has_pre_order() const { return _pre_order >= 0; }
367
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
673 void set_pre_order(int po) { assert(!has_pre_order(), ""); _pre_order = po; }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
674 int pre_order() const { assert(has_pre_order(), ""); return _pre_order; }
367
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
675 void set_next_pre_order() { set_pre_order(outer()->inc_next_pre_order()); }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
676 bool is_start() const { return _pre_order == outer()->start_block_num(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
677
367
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
678 // Reverse post order
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
679 void df_init();
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
680 bool has_post_order() const { return _post_order >= 0; }
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
681 void set_post_order(int po) { assert(!has_post_order() && po >= 0, ""); _post_order = po; }
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
682 void reset_post_order(int o){ _post_order = o; }
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
683 int post_order() const { assert(has_post_order(), ""); return _post_order; }
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
684
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
685 bool has_rpo() const { return has_post_order() && outer()->have_block_count(); }
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
686 int rpo() const { assert(has_rpo(), ""); return outer()->block_count() - post_order() - 1; }
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
687 void set_rpo_next(Block* b) { _rpo_next = b; }
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
688 Block* rpo_next() { return _rpo_next; }
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
689
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
690 // Loops
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
691 Loop* loop() const { return _loop; }
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
692 void set_loop(Loop* lp) { _loop = lp; }
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
693 bool is_loop_head() const { return _loop && _loop->head() == this; }
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
694 void set_irreducible_entry(bool c) { _irreducible_entry = c; }
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
695 bool is_irreducible_entry() const { return _irreducible_entry; }
4777
e9a5e0a812c8 7125896: Eliminate nested locks
kvn
parents: 2447
diff changeset
696 void set_has_monitorenter() { _has_monitorenter = true; }
e9a5e0a812c8 7125896: Eliminate nested locks
kvn
parents: 2447
diff changeset
697 bool has_monitorenter() const { return _has_monitorenter; }
367
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
698 bool is_visited() const { return has_pre_order(); }
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
699 bool is_post_visited() const { return has_post_order(); }
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
700 bool is_clonable_exit(Loop* lp);
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
701 Block* looping_succ(Loop* lp); // Successor inside of loop
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
702 bool is_single_entry_loop_head() const {
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
703 if (!is_loop_head()) return false;
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
704 for (Loop* lp = loop(); lp != NULL && lp->head() == this; lp = lp->parent())
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
705 if (lp->is_irreducible()) return false;
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
706 return true;
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
707 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
708
a61af66fc99e Initial load
duke
parents:
diff changeset
709 void print_value_on(outputStream* st) const PRODUCT_RETURN;
a61af66fc99e Initial load
duke
parents:
diff changeset
710 void print_on(outputStream* st) const PRODUCT_RETURN;
a61af66fc99e Initial load
duke
parents:
diff changeset
711 };
a61af66fc99e Initial load
duke
parents:
diff changeset
712
367
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
713 // Loop
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
714 class Loop : public ResourceObj {
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
715 private:
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
716 Loop* _parent;
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
717 Loop* _sibling; // List of siblings, null terminated
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
718 Loop* _child; // Head of child list threaded thru sibling pointer
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
719 Block* _head; // Head of loop
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
720 Block* _tail; // Tail of loop
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
721 bool _irreducible;
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
722 LocalSet _def_locals;
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
723
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
724 public:
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
725 Loop(Block* head, Block* tail) :
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
726 _head(head), _tail(tail),
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
727 _parent(NULL), _sibling(NULL), _child(NULL),
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
728 _irreducible(false), _def_locals() {}
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
729
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
730 Loop* parent() const { return _parent; }
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
731 Loop* sibling() const { return _sibling; }
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
732 Loop* child() const { return _child; }
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
733 Block* head() const { return _head; }
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
734 Block* tail() const { return _tail; }
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
735 void set_parent(Loop* p) { _parent = p; }
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
736 void set_sibling(Loop* s) { _sibling = s; }
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
737 void set_child(Loop* c) { _child = c; }
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
738 void set_head(Block* hd) { _head = hd; }
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
739 void set_tail(Block* tl) { _tail = tl; }
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
740
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
741 int depth() const; // nesting depth
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
742
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
743 // Returns true if lp is a nested loop or us.
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
744 bool contains(Loop* lp) const;
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
745 bool contains(Block* blk) const { return contains(blk->loop()); }
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
746
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
747 // Data flow on locals
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
748 LocalSet* def_locals() { return &_def_locals; }
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
749 const LocalSet* def_locals() const { return &_def_locals; }
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
750
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
751 // 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: 303
diff changeset
752 // pre_orders. Returns the new branch.
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
753 Loop* sorted_merge(Loop* lp);
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
754
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
755 // Mark non-single entry to loop
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
756 void set_irreducible(Block* entry) {
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
757 _irreducible = true;
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
758 entry->set_irreducible_entry(true);
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
759 }
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
760 bool is_irreducible() const { return _irreducible; }
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
761
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
762 bool is_root() const { return _tail->pre_order() == max_jint; }
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
763
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
764 void print(outputStream* st = tty, int indent = 0) const PRODUCT_RETURN;
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
765 };
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
766
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
767 // Postorder iteration over the loop tree.
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
768 class PostorderLoops : public StackObj {
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
769 private:
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
770 Loop* _root;
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
771 Loop* _current;
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
772 public:
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
773 PostorderLoops(Loop* root) : _root(root), _current(root) {
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
774 while (_current->child() != NULL) {
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
775 _current = _current->child();
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
776 }
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
777 }
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
778 bool done() { return _current == NULL; } // Finished iterating?
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
779 void next(); // Advance to next loop
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
780 Loop* current() { return _current; } // Return current loop.
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
781 };
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
782
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
783 // Preorder iteration over the loop tree.
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
784 class PreorderLoops : public StackObj {
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
785 private:
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
786 Loop* _root;
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
787 Loop* _current;
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
788 public:
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
789 PreorderLoops(Loop* root) : _root(root), _current(root) {}
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
790 bool done() { return _current == NULL; } // Finished iterating?
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
791 void next(); // Advance to next loop
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
792 Loop* current() { return _current; } // Return current loop.
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
793 };
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
794
0
a61af66fc99e Initial load
duke
parents:
diff changeset
795 // Standard indexes of successors, for various bytecodes.
a61af66fc99e Initial load
duke
parents:
diff changeset
796 enum {
a61af66fc99e Initial load
duke
parents:
diff changeset
797 FALL_THROUGH = 0, // normal control
a61af66fc99e Initial load
duke
parents:
diff changeset
798 IF_NOT_TAKEN = 0, // the not-taken branch of an if (i.e., fall-through)
a61af66fc99e Initial load
duke
parents:
diff changeset
799 IF_TAKEN = 1, // the taken branch of an if
a61af66fc99e Initial load
duke
parents:
diff changeset
800 GOTO_TARGET = 0, // unique successor for goto, jsr, or ret
a61af66fc99e Initial load
duke
parents:
diff changeset
801 SWITCH_DEFAULT = 0, // default branch of a switch
a61af66fc99e Initial load
duke
parents:
diff changeset
802 SWITCH_CASES = 1 // first index for any non-default switch branches
a61af66fc99e Initial load
duke
parents:
diff changeset
803 // Unlike in other blocks, the successors of a switch are listed uniquely.
a61af66fc99e Initial load
duke
parents:
diff changeset
804 };
a61af66fc99e Initial load
duke
parents:
diff changeset
805
a61af66fc99e Initial load
duke
parents:
diff changeset
806 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
807 // A mapping from pre_order to Blocks. This array is created
a61af66fc99e Initial load
duke
parents:
diff changeset
808 // only at the end of the flow.
a61af66fc99e Initial load
duke
parents:
diff changeset
809 Block** _block_map;
a61af66fc99e Initial load
duke
parents:
diff changeset
810
a61af66fc99e Initial load
duke
parents:
diff changeset
811 // For each ciBlock index, a list of Blocks which share this ciBlock.
a61af66fc99e Initial load
duke
parents:
diff changeset
812 GrowableArray<Block*>** _idx_to_blocklist;
a61af66fc99e Initial load
duke
parents:
diff changeset
813 // count of ciBlocks
a61af66fc99e Initial load
duke
parents:
diff changeset
814 int _ciblock_count;
a61af66fc99e Initial load
duke
parents:
diff changeset
815
a61af66fc99e Initial load
duke
parents:
diff changeset
816 // Tells if a given instruction is able to generate an exception edge.
a61af66fc99e Initial load
duke
parents:
diff changeset
817 bool can_trap(ciBytecodeStream& str);
a61af66fc99e Initial load
duke
parents:
diff changeset
818
367
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
819 // Clone the loop heads. Returns true if any cloning occurred.
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
820 bool 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: 303
diff changeset
821
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
822 // 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: 303
diff changeset
823 Block* 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: 303
diff changeset
824
0
a61af66fc99e Initial load
duke
parents:
diff changeset
825 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
826 // Return the block beginning at bci which has a JsrSet compatible
a61af66fc99e Initial load
duke
parents:
diff changeset
827 // with jsrs.
a61af66fc99e Initial load
duke
parents:
diff changeset
828 Block* block_at(int bci, JsrSet* set, CreateOption option = create_public_copy);
a61af66fc99e Initial load
duke
parents:
diff changeset
829
a61af66fc99e Initial load
duke
parents:
diff changeset
830 // block factory
a61af66fc99e Initial load
duke
parents:
diff changeset
831 Block* get_block_for(int ciBlockIndex, JsrSet* jsrs, CreateOption option = create_public_copy);
a61af66fc99e Initial load
duke
parents:
diff changeset
832
367
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
833 // How many of the blocks have the backedge_copy bit set?
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
834 int backedge_copy_count(int ciBlockIndex, JsrSet* jsrs) const;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
835
a61af66fc99e Initial load
duke
parents:
diff changeset
836 // Return an existing block containing bci which has a JsrSet compatible
a61af66fc99e Initial load
duke
parents:
diff changeset
837 // with jsrs, or NULL if there is none.
a61af66fc99e Initial load
duke
parents:
diff changeset
838 Block* existing_block_at(int bci, JsrSet* set) { return block_at(bci, set, no_create); }
a61af66fc99e Initial load
duke
parents:
diff changeset
839
a61af66fc99e Initial load
duke
parents:
diff changeset
840 // Tell whether the flow analysis has encountered an error of some sort.
a61af66fc99e Initial load
duke
parents:
diff changeset
841 bool failing() { return env()->failing() || _failure_reason != NULL; }
a61af66fc99e Initial load
duke
parents:
diff changeset
842
a61af66fc99e Initial load
duke
parents:
diff changeset
843 // Reason this compilation is failing, such as "too many basic blocks".
a61af66fc99e Initial load
duke
parents:
diff changeset
844 const char* failure_reason() { return _failure_reason; }
a61af66fc99e Initial load
duke
parents:
diff changeset
845
a61af66fc99e Initial load
duke
parents:
diff changeset
846 // Note a failure.
a61af66fc99e Initial load
duke
parents:
diff changeset
847 void record_failure(const char* reason);
a61af66fc99e Initial load
duke
parents:
diff changeset
848
a61af66fc99e Initial load
duke
parents:
diff changeset
849 // Return the block of a given pre-order number.
a61af66fc99e Initial load
duke
parents:
diff changeset
850 int have_block_count() const { return _block_map != NULL; }
a61af66fc99e Initial load
duke
parents:
diff changeset
851 int block_count() const { assert(have_block_count(), "");
a61af66fc99e Initial load
duke
parents:
diff changeset
852 return _next_pre_order; }
a61af66fc99e Initial load
duke
parents:
diff changeset
853 Block* pre_order_at(int po) const { assert(0 <= po && po < block_count(), "out of bounds");
a61af66fc99e Initial load
duke
parents:
diff changeset
854 return _block_map[po]; }
a61af66fc99e Initial load
duke
parents:
diff changeset
855 Block* start_block() const { return pre_order_at(start_block_num()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
856 int start_block_num() const { return 0; }
367
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
857 Block* rpo_at(int rpo) const { assert(0 <= rpo && rpo < block_count(), "out of bounds");
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
858 return _block_map[rpo]; }
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
859 int next_pre_order() { return _next_pre_order; }
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
860 int inc_next_pre_order() { return _next_pre_order++; }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
861
a61af66fc99e Initial load
duke
parents:
diff changeset
862 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
863 // A work list used during flow analysis.
a61af66fc99e Initial load
duke
parents:
diff changeset
864 Block* _work_list;
a61af66fc99e Initial load
duke
parents:
diff changeset
865
367
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
866 // List of blocks in reverse post order
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
867 Block* _rpo_list;
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
868
0
a61af66fc99e Initial load
duke
parents:
diff changeset
869 // Next Block::_pre_order. After mapping, doubles as block_count.
a61af66fc99e Initial load
duke
parents:
diff changeset
870 int _next_pre_order;
a61af66fc99e Initial load
duke
parents:
diff changeset
871
a61af66fc99e Initial load
duke
parents:
diff changeset
872 // Are there more blocks on the work list?
a61af66fc99e Initial load
duke
parents:
diff changeset
873 bool work_list_empty() { return _work_list == NULL; }
a61af66fc99e Initial load
duke
parents:
diff changeset
874
a61af66fc99e Initial load
duke
parents:
diff changeset
875 // Get the next basic block from our work list.
a61af66fc99e Initial load
duke
parents:
diff changeset
876 Block* work_list_next();
a61af66fc99e Initial load
duke
parents:
diff changeset
877
a61af66fc99e Initial load
duke
parents:
diff changeset
878 // Add a basic block to our work list.
a61af66fc99e Initial load
duke
parents:
diff changeset
879 void add_to_work_list(Block* block);
a61af66fc99e Initial load
duke
parents:
diff changeset
880
367
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
881 // Prepend a basic block to rpo list.
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
882 void prepend_to_rpo_list(Block* blk) {
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
883 blk->set_rpo_next(_rpo_list);
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
884 _rpo_list = blk;
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
885 }
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
886
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
887 // Root of the loop tree
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
888 Loop* _loop_tree_root;
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
889
0
a61af66fc99e Initial load
duke
parents:
diff changeset
890 // State used for make_jsr_record
a61af66fc99e Initial load
duke
parents:
diff changeset
891 int _jsr_count;
a61af66fc99e Initial load
duke
parents:
diff changeset
892 GrowableArray<JsrRecord*>* _jsr_records;
a61af66fc99e Initial load
duke
parents:
diff changeset
893
a61af66fc99e Initial load
duke
parents:
diff changeset
894 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
895 // Make a JsrRecord for a given (entry, return) pair, if such a record
a61af66fc99e Initial load
duke
parents:
diff changeset
896 // does not already exist.
a61af66fc99e Initial load
duke
parents:
diff changeset
897 JsrRecord* make_jsr_record(int entry_address, int return_address);
a61af66fc99e Initial load
duke
parents:
diff changeset
898
367
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
899 void set_loop_tree_root(Loop* ltr) { _loop_tree_root = ltr; }
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
900 Loop* loop_tree_root() { return _loop_tree_root; }
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
901
0
a61af66fc99e Initial load
duke
parents:
diff changeset
902 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
903 // Get the initial state for start_bci:
a61af66fc99e Initial load
duke
parents:
diff changeset
904 const StateVector* get_start_state();
a61af66fc99e Initial load
duke
parents:
diff changeset
905
a61af66fc99e Initial load
duke
parents:
diff changeset
906 // Merge the current state into all exceptional successors at the
a61af66fc99e Initial load
duke
parents:
diff changeset
907 // current point in the code.
a61af66fc99e Initial load
duke
parents:
diff changeset
908 void flow_exceptions(GrowableArray<Block*>* exceptions,
a61af66fc99e Initial load
duke
parents:
diff changeset
909 GrowableArray<ciInstanceKlass*>* exc_klasses,
a61af66fc99e Initial load
duke
parents:
diff changeset
910 StateVector* state);
a61af66fc99e Initial load
duke
parents:
diff changeset
911
a61af66fc99e Initial load
duke
parents:
diff changeset
912 // Merge the current state into all successors at the current point
a61af66fc99e Initial load
duke
parents:
diff changeset
913 // in the code.
a61af66fc99e Initial load
duke
parents:
diff changeset
914 void flow_successors(GrowableArray<Block*>* successors,
a61af66fc99e Initial load
duke
parents:
diff changeset
915 StateVector* state);
a61af66fc99e Initial load
duke
parents:
diff changeset
916
a61af66fc99e Initial load
duke
parents:
diff changeset
917 // Interpret the effects of the bytecodes on the incoming state
a61af66fc99e Initial load
duke
parents:
diff changeset
918 // vector of a basic block. Push the changed state to succeeding
a61af66fc99e Initial load
duke
parents:
diff changeset
919 // basic blocks.
a61af66fc99e Initial load
duke
parents:
diff changeset
920 void flow_block(Block* block,
a61af66fc99e Initial load
duke
parents:
diff changeset
921 StateVector* scratch_state,
a61af66fc99e Initial load
duke
parents:
diff changeset
922 JsrSet* scratch_jsrs);
a61af66fc99e Initial load
duke
parents:
diff changeset
923
a61af66fc99e Initial load
duke
parents:
diff changeset
924 // Perform the type flow analysis, creating and cloning Blocks as
a61af66fc99e Initial load
duke
parents:
diff changeset
925 // necessary.
a61af66fc99e Initial load
duke
parents:
diff changeset
926 void flow_types();
a61af66fc99e Initial load
duke
parents:
diff changeset
927
367
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
928 // 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: 303
diff changeset
929 void df_flow_types(Block* start,
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
930 bool do_flow,
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
931 StateVector* temp_vector,
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
932 JsrSet* temp_set);
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
933
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
934 // Incrementally build loop tree.
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
935 void build_loop_tree(Block* blk);
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
936
0
a61af66fc99e Initial load
duke
parents:
diff changeset
937 // Create the block map, which indexes blocks in pre_order.
a61af66fc99e Initial load
duke
parents:
diff changeset
938 void map_blocks();
a61af66fc99e Initial load
duke
parents:
diff changeset
939
a61af66fc99e Initial load
duke
parents:
diff changeset
940 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
941 // Perform type inference flow analysis.
a61af66fc99e Initial load
duke
parents:
diff changeset
942 void do_flow();
a61af66fc99e Initial load
duke
parents:
diff changeset
943
a61af66fc99e Initial load
duke
parents:
diff changeset
944 void print_on(outputStream* st) const PRODUCT_RETURN;
367
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
945
194b8e3a2fc4 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 303
diff changeset
946 void rpo_print_on(outputStream* st) const PRODUCT_RETURN;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
947 };
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
948
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
949 #endif // SHARE_VM_CI_CITYPEFLOW_HPP