annotate src/share/vm/ci/bcEscapeAnalyzer.cpp @ 0:a61af66fc99e jdk7-b24

Initial load
author duke
date Sat, 01 Dec 2007 00:00:00 +0000
parents
children 48a3fa21394b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
2 * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
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 *
a61af66fc99e Initial load
duke
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 * have any questions.
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25
a61af66fc99e Initial load
duke
parents:
diff changeset
26 #include "incls/_precompiled.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
27 #include "incls/_bcEscapeAnalyzer.cpp.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
28
a61af66fc99e Initial load
duke
parents:
diff changeset
29
a61af66fc99e Initial load
duke
parents:
diff changeset
30 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
31 #define TRACE_BCEA(level, code) \
a61af66fc99e Initial load
duke
parents:
diff changeset
32 if (EstimateArgEscape && BCEATraceLevel >= level) { \
a61af66fc99e Initial load
duke
parents:
diff changeset
33 code; \
a61af66fc99e Initial load
duke
parents:
diff changeset
34 }
a61af66fc99e Initial load
duke
parents:
diff changeset
35 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
36 #define TRACE_BCEA(level, code)
a61af66fc99e Initial load
duke
parents:
diff changeset
37 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
38
a61af66fc99e Initial load
duke
parents:
diff changeset
39 // Maintain a map of which aguments a local variable or
a61af66fc99e Initial load
duke
parents:
diff changeset
40 // stack slot may contain. In addition to tracking
a61af66fc99e Initial load
duke
parents:
diff changeset
41 // arguments, it tracks two special values, "allocated"
a61af66fc99e Initial load
duke
parents:
diff changeset
42 // which represents any object allocated in the current
a61af66fc99e Initial load
duke
parents:
diff changeset
43 // method, and "unknown" which is any other object.
a61af66fc99e Initial load
duke
parents:
diff changeset
44 // Up to 30 arguments are handled, with the last one
a61af66fc99e Initial load
duke
parents:
diff changeset
45 // representing summary information for any extra arguments
a61af66fc99e Initial load
duke
parents:
diff changeset
46 class BCEscapeAnalyzer::ArgumentMap {
a61af66fc99e Initial load
duke
parents:
diff changeset
47 uint _bits;
a61af66fc99e Initial load
duke
parents:
diff changeset
48 enum {MAXBIT = 29,
a61af66fc99e Initial load
duke
parents:
diff changeset
49 ALLOCATED = 1,
a61af66fc99e Initial load
duke
parents:
diff changeset
50 UNKNOWN = 2};
a61af66fc99e Initial load
duke
parents:
diff changeset
51
a61af66fc99e Initial load
duke
parents:
diff changeset
52 uint int_to_bit(uint e) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
53 if (e > MAXBIT)
a61af66fc99e Initial load
duke
parents:
diff changeset
54 e = MAXBIT;
a61af66fc99e Initial load
duke
parents:
diff changeset
55 return (1 << (e + 2));
a61af66fc99e Initial load
duke
parents:
diff changeset
56 }
a61af66fc99e Initial load
duke
parents:
diff changeset
57
a61af66fc99e Initial load
duke
parents:
diff changeset
58 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
59 ArgumentMap() { _bits = 0;}
a61af66fc99e Initial load
duke
parents:
diff changeset
60 void set_bits(uint bits) { _bits = bits;}
a61af66fc99e Initial load
duke
parents:
diff changeset
61 uint get_bits() const { return _bits;}
a61af66fc99e Initial load
duke
parents:
diff changeset
62 void clear() { _bits = 0;}
a61af66fc99e Initial load
duke
parents:
diff changeset
63 void set_all() { _bits = ~0u; }
a61af66fc99e Initial load
duke
parents:
diff changeset
64 bool is_empty() const { return _bits == 0; }
a61af66fc99e Initial load
duke
parents:
diff changeset
65 bool contains(uint var) const { return (_bits & int_to_bit(var)) != 0; }
a61af66fc99e Initial load
duke
parents:
diff changeset
66 bool is_singleton(uint var) const { return (_bits == int_to_bit(var)); }
a61af66fc99e Initial load
duke
parents:
diff changeset
67 bool contains_unknown() const { return (_bits & UNKNOWN) != 0; }
a61af66fc99e Initial load
duke
parents:
diff changeset
68 bool contains_allocated() const { return (_bits & ALLOCATED) != 0; }
a61af66fc99e Initial load
duke
parents:
diff changeset
69 bool contains_vars() const { return (_bits & (((1 << MAXBIT) -1) << 2)) != 0; }
a61af66fc99e Initial load
duke
parents:
diff changeset
70 void set(uint var) { _bits = int_to_bit(var); }
a61af66fc99e Initial load
duke
parents:
diff changeset
71 void add(uint var) { _bits |= int_to_bit(var); }
a61af66fc99e Initial load
duke
parents:
diff changeset
72 void add_unknown() { _bits = UNKNOWN; }
a61af66fc99e Initial load
duke
parents:
diff changeset
73 void add_allocated() { _bits = ALLOCATED; }
a61af66fc99e Initial load
duke
parents:
diff changeset
74 void set_union(const ArgumentMap &am) { _bits |= am._bits; }
a61af66fc99e Initial load
duke
parents:
diff changeset
75 void set_intersect(const ArgumentMap &am) { _bits |= am._bits; }
a61af66fc99e Initial load
duke
parents:
diff changeset
76 void set_difference(const ArgumentMap &am) { _bits &= ~am._bits; }
a61af66fc99e Initial load
duke
parents:
diff changeset
77 void operator=(const ArgumentMap &am) { _bits = am._bits; }
a61af66fc99e Initial load
duke
parents:
diff changeset
78 bool operator==(const ArgumentMap &am) { return _bits == am._bits; }
a61af66fc99e Initial load
duke
parents:
diff changeset
79 bool operator!=(const ArgumentMap &am) { return _bits != am._bits; }
a61af66fc99e Initial load
duke
parents:
diff changeset
80 };
a61af66fc99e Initial load
duke
parents:
diff changeset
81
a61af66fc99e Initial load
duke
parents:
diff changeset
82 class BCEscapeAnalyzer::StateInfo {
a61af66fc99e Initial load
duke
parents:
diff changeset
83 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
84 ArgumentMap *_vars;
a61af66fc99e Initial load
duke
parents:
diff changeset
85 ArgumentMap *_stack;
a61af66fc99e Initial load
duke
parents:
diff changeset
86 short _stack_height;
a61af66fc99e Initial load
duke
parents:
diff changeset
87 short _max_stack;
a61af66fc99e Initial load
duke
parents:
diff changeset
88 bool _initialized;
a61af66fc99e Initial load
duke
parents:
diff changeset
89 ArgumentMap empty_map;
a61af66fc99e Initial load
duke
parents:
diff changeset
90
a61af66fc99e Initial load
duke
parents:
diff changeset
91 StateInfo() {
a61af66fc99e Initial load
duke
parents:
diff changeset
92 empty_map.clear();
a61af66fc99e Initial load
duke
parents:
diff changeset
93 }
a61af66fc99e Initial load
duke
parents:
diff changeset
94
a61af66fc99e Initial load
duke
parents:
diff changeset
95 ArgumentMap raw_pop() { assert(_stack_height > 0, "stack underflow"); return _stack[--_stack_height]; }
a61af66fc99e Initial load
duke
parents:
diff changeset
96 ArgumentMap apop() { return raw_pop(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
97 void spop() { raw_pop(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
98 void lpop() { spop(); spop(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
99 void raw_push(ArgumentMap i) { assert(_stack_height < _max_stack, "stack overflow"); _stack[_stack_height++] = i; }
a61af66fc99e Initial load
duke
parents:
diff changeset
100 void apush(ArgumentMap i) { raw_push(i); }
a61af66fc99e Initial load
duke
parents:
diff changeset
101 void spush() { raw_push(empty_map); }
a61af66fc99e Initial load
duke
parents:
diff changeset
102 void lpush() { spush(); spush(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
103
a61af66fc99e Initial load
duke
parents:
diff changeset
104 };
a61af66fc99e Initial load
duke
parents:
diff changeset
105
a61af66fc99e Initial load
duke
parents:
diff changeset
106 void BCEscapeAnalyzer::set_returned(ArgumentMap vars) {
a61af66fc99e Initial load
duke
parents:
diff changeset
107 for (int i = 0; i <= _arg_size; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
108 if (vars.contains(i))
a61af66fc99e Initial load
duke
parents:
diff changeset
109 _arg_returned.set_bit(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
110 }
a61af66fc99e Initial load
duke
parents:
diff changeset
111 _return_local = _return_local && !(vars.contains_unknown() || vars.contains_allocated());
a61af66fc99e Initial load
duke
parents:
diff changeset
112 _return_allocated = _return_allocated && vars.contains_allocated() && !(vars.contains_unknown() || vars.contains_vars());
a61af66fc99e Initial load
duke
parents:
diff changeset
113 }
a61af66fc99e Initial load
duke
parents:
diff changeset
114
a61af66fc99e Initial load
duke
parents:
diff changeset
115
a61af66fc99e Initial load
duke
parents:
diff changeset
116 // return true if any element of vars is an argument
a61af66fc99e Initial load
duke
parents:
diff changeset
117 bool BCEscapeAnalyzer::is_argument(ArgumentMap vars) {
a61af66fc99e Initial load
duke
parents:
diff changeset
118 for (int i = 0; i <= _arg_size; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
119 if (vars.contains(i))
a61af66fc99e Initial load
duke
parents:
diff changeset
120 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
121 }
a61af66fc99e Initial load
duke
parents:
diff changeset
122 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
123 }
a61af66fc99e Initial load
duke
parents:
diff changeset
124
a61af66fc99e Initial load
duke
parents:
diff changeset
125 // return true if any element of vars is an arg_stack argument
a61af66fc99e Initial load
duke
parents:
diff changeset
126 bool BCEscapeAnalyzer::is_arg_stack(ArgumentMap vars){
a61af66fc99e Initial load
duke
parents:
diff changeset
127 if (_conservative)
a61af66fc99e Initial load
duke
parents:
diff changeset
128 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
129 for (int i = 0; i <= _arg_size; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
130 if (vars.contains(i) && _arg_stack.at(i))
a61af66fc99e Initial load
duke
parents:
diff changeset
131 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
132 }
a61af66fc99e Initial load
duke
parents:
diff changeset
133 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
134 }
a61af66fc99e Initial load
duke
parents:
diff changeset
135
a61af66fc99e Initial load
duke
parents:
diff changeset
136 void BCEscapeAnalyzer::clear_bits(ArgumentMap vars, BitMap &bm) {
a61af66fc99e Initial load
duke
parents:
diff changeset
137 for (int i = 0; i <= _arg_size; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
138 if (vars.contains(i)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
139 bm.clear_bit(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
140 }
a61af66fc99e Initial load
duke
parents:
diff changeset
141 }
a61af66fc99e Initial load
duke
parents:
diff changeset
142 }
a61af66fc99e Initial load
duke
parents:
diff changeset
143 void BCEscapeAnalyzer::set_method_escape(ArgumentMap vars) {
a61af66fc99e Initial load
duke
parents:
diff changeset
144 clear_bits(vars, _arg_local);
a61af66fc99e Initial load
duke
parents:
diff changeset
145 }
a61af66fc99e Initial load
duke
parents:
diff changeset
146
a61af66fc99e Initial load
duke
parents:
diff changeset
147 void BCEscapeAnalyzer::set_global_escape(ArgumentMap vars) {
a61af66fc99e Initial load
duke
parents:
diff changeset
148 clear_bits(vars, _arg_local);
a61af66fc99e Initial load
duke
parents:
diff changeset
149 clear_bits(vars, _arg_stack);
a61af66fc99e Initial load
duke
parents:
diff changeset
150 if (vars.contains_allocated())
a61af66fc99e Initial load
duke
parents:
diff changeset
151 _allocated_escapes = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
152 }
a61af66fc99e Initial load
duke
parents:
diff changeset
153
a61af66fc99e Initial load
duke
parents:
diff changeset
154 void BCEscapeAnalyzer::set_dirty(ArgumentMap vars) {
a61af66fc99e Initial load
duke
parents:
diff changeset
155 clear_bits(vars, _dirty);
a61af66fc99e Initial load
duke
parents:
diff changeset
156 }
a61af66fc99e Initial load
duke
parents:
diff changeset
157
a61af66fc99e Initial load
duke
parents:
diff changeset
158 bool BCEscapeAnalyzer::is_recursive_call(ciMethod* callee) {
a61af66fc99e Initial load
duke
parents:
diff changeset
159 for (BCEscapeAnalyzer* scope = this; scope != NULL; scope = scope->_parent) {
a61af66fc99e Initial load
duke
parents:
diff changeset
160 if (scope->method() == callee) {
a61af66fc99e Initial load
duke
parents:
diff changeset
161 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
162 }
a61af66fc99e Initial load
duke
parents:
diff changeset
163 }
a61af66fc99e Initial load
duke
parents:
diff changeset
164 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
165 }
a61af66fc99e Initial load
duke
parents:
diff changeset
166
a61af66fc99e Initial load
duke
parents:
diff changeset
167 void BCEscapeAnalyzer::invoke(StateInfo &state, Bytecodes::Code code, ciMethod* target, ciKlass* holder) {
a61af66fc99e Initial load
duke
parents:
diff changeset
168 int i;
a61af66fc99e Initial load
duke
parents:
diff changeset
169
a61af66fc99e Initial load
duke
parents:
diff changeset
170 // retrieve information about the callee
a61af66fc99e Initial load
duke
parents:
diff changeset
171 ciInstanceKlass* klass = target->holder();
a61af66fc99e Initial load
duke
parents:
diff changeset
172 ciInstanceKlass* calling_klass = method()->holder();
a61af66fc99e Initial load
duke
parents:
diff changeset
173 ciInstanceKlass* callee_holder = ciEnv::get_instance_klass_for_declared_method_holder(holder);
a61af66fc99e Initial load
duke
parents:
diff changeset
174 ciInstanceKlass* actual_recv = callee_holder;
a61af66fc99e Initial load
duke
parents:
diff changeset
175
a61af66fc99e Initial load
duke
parents:
diff changeset
176 // compute size of arguments
a61af66fc99e Initial load
duke
parents:
diff changeset
177 int arg_size = target->arg_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
178 if (!target->is_loaded() && code == Bytecodes::_invokestatic) {
a61af66fc99e Initial load
duke
parents:
diff changeset
179 arg_size--;
a61af66fc99e Initial load
duke
parents:
diff changeset
180 }
a61af66fc99e Initial load
duke
parents:
diff changeset
181 int arg_base = MAX2(state._stack_height - arg_size, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
182
a61af66fc99e Initial load
duke
parents:
diff changeset
183 // direct recursive calls are skipped if they can be bound statically without introducing
a61af66fc99e Initial load
duke
parents:
diff changeset
184 // dependencies and if parameters are passed at the same position as in the current method
a61af66fc99e Initial load
duke
parents:
diff changeset
185 // other calls are skipped if there are no unescaped arguments passed to them
a61af66fc99e Initial load
duke
parents:
diff changeset
186 bool directly_recursive = (method() == target) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
187 (code != Bytecodes::_invokevirtual || target->is_final_method() || state._stack[arg_base] .is_empty());
a61af66fc99e Initial load
duke
parents:
diff changeset
188
a61af66fc99e Initial load
duke
parents:
diff changeset
189 // check if analysis of callee can safely be skipped
a61af66fc99e Initial load
duke
parents:
diff changeset
190 bool skip_callee = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
191 for (i = state._stack_height - 1; i >= arg_base && skip_callee; i--) {
a61af66fc99e Initial load
duke
parents:
diff changeset
192 ArgumentMap arg = state._stack[i];
a61af66fc99e Initial load
duke
parents:
diff changeset
193 skip_callee = !is_argument(arg) || !is_arg_stack(arg) || (directly_recursive && arg.is_singleton(i - arg_base));
a61af66fc99e Initial load
duke
parents:
diff changeset
194 }
a61af66fc99e Initial load
duke
parents:
diff changeset
195 if (skip_callee) {
a61af66fc99e Initial load
duke
parents:
diff changeset
196 TRACE_BCEA(3, tty->print_cr("[EA] skipping method %s::%s", holder->name()->as_utf8(), target->name()->as_utf8()));
a61af66fc99e Initial load
duke
parents:
diff changeset
197 for (i = 0; i < arg_size; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
198 set_method_escape(state.raw_pop());
a61af66fc99e Initial load
duke
parents:
diff changeset
199 }
a61af66fc99e Initial load
duke
parents:
diff changeset
200 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
201 }
a61af66fc99e Initial load
duke
parents:
diff changeset
202
a61af66fc99e Initial load
duke
parents:
diff changeset
203 // determine actual method (use CHA if necessary)
a61af66fc99e Initial load
duke
parents:
diff changeset
204 ciMethod* inline_target = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
205 if (target->is_loaded() && klass->is_loaded()
a61af66fc99e Initial load
duke
parents:
diff changeset
206 && (klass->is_initialized() || klass->is_interface() && target->holder()->is_initialized())
a61af66fc99e Initial load
duke
parents:
diff changeset
207 && target->will_link(klass, callee_holder, code)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
208 if (code == Bytecodes::_invokestatic
a61af66fc99e Initial load
duke
parents:
diff changeset
209 || code == Bytecodes::_invokespecial
a61af66fc99e Initial load
duke
parents:
diff changeset
210 || code == Bytecodes::_invokevirtual && target->is_final_method()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
211 inline_target = target;
a61af66fc99e Initial load
duke
parents:
diff changeset
212 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
213 inline_target = target->find_monomorphic_target(calling_klass, callee_holder, actual_recv);
a61af66fc99e Initial load
duke
parents:
diff changeset
214 }
a61af66fc99e Initial load
duke
parents:
diff changeset
215 }
a61af66fc99e Initial load
duke
parents:
diff changeset
216
a61af66fc99e Initial load
duke
parents:
diff changeset
217 if (inline_target != NULL && !is_recursive_call(inline_target)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
218 // analyze callee
a61af66fc99e Initial load
duke
parents:
diff changeset
219 BCEscapeAnalyzer analyzer(inline_target, this);
a61af66fc99e Initial load
duke
parents:
diff changeset
220
a61af66fc99e Initial load
duke
parents:
diff changeset
221 // adjust escape state of actual parameters
a61af66fc99e Initial load
duke
parents:
diff changeset
222 bool must_record_dependencies = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
223 for (i = arg_size - 1; i >= 0; i--) {
a61af66fc99e Initial load
duke
parents:
diff changeset
224 ArgumentMap arg = state.raw_pop();
a61af66fc99e Initial load
duke
parents:
diff changeset
225 if (!is_argument(arg))
a61af66fc99e Initial load
duke
parents:
diff changeset
226 continue;
a61af66fc99e Initial load
duke
parents:
diff changeset
227 if (!is_arg_stack(arg)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
228 // arguments have already been recognized as escaping
a61af66fc99e Initial load
duke
parents:
diff changeset
229 } else if (analyzer.is_arg_stack(i) && !analyzer.is_arg_returned(i)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
230 set_method_escape(arg);
a61af66fc99e Initial load
duke
parents:
diff changeset
231 must_record_dependencies = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
232 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
233 set_global_escape(arg);
a61af66fc99e Initial load
duke
parents:
diff changeset
234 }
a61af66fc99e Initial load
duke
parents:
diff changeset
235 }
a61af66fc99e Initial load
duke
parents:
diff changeset
236
a61af66fc99e Initial load
duke
parents:
diff changeset
237 // record dependencies if at least one parameter retained stack-allocatable
a61af66fc99e Initial load
duke
parents:
diff changeset
238 if (must_record_dependencies) {
a61af66fc99e Initial load
duke
parents:
diff changeset
239 if (code == Bytecodes::_invokeinterface || code == Bytecodes::_invokevirtual && !target->is_final_method()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
240 _dependencies.append(actual_recv);
a61af66fc99e Initial load
duke
parents:
diff changeset
241 _dependencies.append(inline_target);
a61af66fc99e Initial load
duke
parents:
diff changeset
242 }
a61af66fc99e Initial load
duke
parents:
diff changeset
243 _dependencies.appendAll(analyzer.dependencies());
a61af66fc99e Initial load
duke
parents:
diff changeset
244 }
a61af66fc99e Initial load
duke
parents:
diff changeset
245 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
246 TRACE_BCEA(1, tty->print_cr("[EA] virtual method %s is not monomorphic.",
a61af66fc99e Initial load
duke
parents:
diff changeset
247 target->name()->as_utf8()));
a61af66fc99e Initial load
duke
parents:
diff changeset
248 // conservatively mark all actual parameters as escaping globally
a61af66fc99e Initial load
duke
parents:
diff changeset
249 for (i = 0; i < arg_size; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
250 ArgumentMap arg = state.raw_pop();
a61af66fc99e Initial load
duke
parents:
diff changeset
251 if (!is_argument(arg))
a61af66fc99e Initial load
duke
parents:
diff changeset
252 continue;
a61af66fc99e Initial load
duke
parents:
diff changeset
253 set_global_escape(arg);
a61af66fc99e Initial load
duke
parents:
diff changeset
254 }
a61af66fc99e Initial load
duke
parents:
diff changeset
255 }
a61af66fc99e Initial load
duke
parents:
diff changeset
256 }
a61af66fc99e Initial load
duke
parents:
diff changeset
257
a61af66fc99e Initial load
duke
parents:
diff changeset
258 bool BCEscapeAnalyzer::contains(uint arg_set1, uint arg_set2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
259 return ((~arg_set1) | arg_set2) == 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
260 }
a61af66fc99e Initial load
duke
parents:
diff changeset
261
a61af66fc99e Initial load
duke
parents:
diff changeset
262
a61af66fc99e Initial load
duke
parents:
diff changeset
263 void BCEscapeAnalyzer::iterate_one_block(ciBlock *blk, StateInfo &state, GrowableArray<ciBlock *> &successors) {
a61af66fc99e Initial load
duke
parents:
diff changeset
264
a61af66fc99e Initial load
duke
parents:
diff changeset
265 blk->set_processed();
a61af66fc99e Initial load
duke
parents:
diff changeset
266 ciBytecodeStream s(method());
a61af66fc99e Initial load
duke
parents:
diff changeset
267 int limit_bci = blk->limit_bci();
a61af66fc99e Initial load
duke
parents:
diff changeset
268 bool fall_through = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
269 ArgumentMap allocated_obj;
a61af66fc99e Initial load
duke
parents:
diff changeset
270 allocated_obj.add_allocated();
a61af66fc99e Initial load
duke
parents:
diff changeset
271 ArgumentMap unknown_obj;
a61af66fc99e Initial load
duke
parents:
diff changeset
272 unknown_obj.add_unknown();
a61af66fc99e Initial load
duke
parents:
diff changeset
273 ArgumentMap empty_map;
a61af66fc99e Initial load
duke
parents:
diff changeset
274
a61af66fc99e Initial load
duke
parents:
diff changeset
275 s.reset_to_bci(blk->start_bci());
a61af66fc99e Initial load
duke
parents:
diff changeset
276 while (s.next() != ciBytecodeStream::EOBC() && s.cur_bci() < limit_bci) {
a61af66fc99e Initial load
duke
parents:
diff changeset
277 fall_through = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
278 switch (s.cur_bc()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
279 case Bytecodes::_nop:
a61af66fc99e Initial load
duke
parents:
diff changeset
280 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
281 case Bytecodes::_aconst_null:
a61af66fc99e Initial load
duke
parents:
diff changeset
282 state.apush(empty_map);
a61af66fc99e Initial load
duke
parents:
diff changeset
283 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
284 case Bytecodes::_iconst_m1:
a61af66fc99e Initial load
duke
parents:
diff changeset
285 case Bytecodes::_iconst_0:
a61af66fc99e Initial load
duke
parents:
diff changeset
286 case Bytecodes::_iconst_1:
a61af66fc99e Initial load
duke
parents:
diff changeset
287 case Bytecodes::_iconst_2:
a61af66fc99e Initial load
duke
parents:
diff changeset
288 case Bytecodes::_iconst_3:
a61af66fc99e Initial load
duke
parents:
diff changeset
289 case Bytecodes::_iconst_4:
a61af66fc99e Initial load
duke
parents:
diff changeset
290 case Bytecodes::_iconst_5:
a61af66fc99e Initial load
duke
parents:
diff changeset
291 case Bytecodes::_fconst_0:
a61af66fc99e Initial load
duke
parents:
diff changeset
292 case Bytecodes::_fconst_1:
a61af66fc99e Initial load
duke
parents:
diff changeset
293 case Bytecodes::_fconst_2:
a61af66fc99e Initial load
duke
parents:
diff changeset
294 case Bytecodes::_bipush:
a61af66fc99e Initial load
duke
parents:
diff changeset
295 case Bytecodes::_sipush:
a61af66fc99e Initial load
duke
parents:
diff changeset
296 state.spush();
a61af66fc99e Initial load
duke
parents:
diff changeset
297 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
298 case Bytecodes::_lconst_0:
a61af66fc99e Initial load
duke
parents:
diff changeset
299 case Bytecodes::_lconst_1:
a61af66fc99e Initial load
duke
parents:
diff changeset
300 case Bytecodes::_dconst_0:
a61af66fc99e Initial load
duke
parents:
diff changeset
301 case Bytecodes::_dconst_1:
a61af66fc99e Initial load
duke
parents:
diff changeset
302 state.lpush();
a61af66fc99e Initial load
duke
parents:
diff changeset
303 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
304 case Bytecodes::_ldc:
a61af66fc99e Initial load
duke
parents:
diff changeset
305 case Bytecodes::_ldc_w:
a61af66fc99e Initial load
duke
parents:
diff changeset
306 case Bytecodes::_ldc2_w:
a61af66fc99e Initial load
duke
parents:
diff changeset
307 if (type2size[s.get_constant().basic_type()] == 1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
308 state.spush();
a61af66fc99e Initial load
duke
parents:
diff changeset
309 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
310 state.lpush();
a61af66fc99e Initial load
duke
parents:
diff changeset
311 }
a61af66fc99e Initial load
duke
parents:
diff changeset
312 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
313 case Bytecodes::_aload:
a61af66fc99e Initial load
duke
parents:
diff changeset
314 state.apush(state._vars[s.get_index()]);
a61af66fc99e Initial load
duke
parents:
diff changeset
315 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
316 case Bytecodes::_iload:
a61af66fc99e Initial load
duke
parents:
diff changeset
317 case Bytecodes::_fload:
a61af66fc99e Initial load
duke
parents:
diff changeset
318 case Bytecodes::_iload_0:
a61af66fc99e Initial load
duke
parents:
diff changeset
319 case Bytecodes::_iload_1:
a61af66fc99e Initial load
duke
parents:
diff changeset
320 case Bytecodes::_iload_2:
a61af66fc99e Initial load
duke
parents:
diff changeset
321 case Bytecodes::_iload_3:
a61af66fc99e Initial load
duke
parents:
diff changeset
322 case Bytecodes::_fload_0:
a61af66fc99e Initial load
duke
parents:
diff changeset
323 case Bytecodes::_fload_1:
a61af66fc99e Initial load
duke
parents:
diff changeset
324 case Bytecodes::_fload_2:
a61af66fc99e Initial load
duke
parents:
diff changeset
325 case Bytecodes::_fload_3:
a61af66fc99e Initial load
duke
parents:
diff changeset
326 state.spush();
a61af66fc99e Initial load
duke
parents:
diff changeset
327 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
328 case Bytecodes::_lload:
a61af66fc99e Initial load
duke
parents:
diff changeset
329 case Bytecodes::_dload:
a61af66fc99e Initial load
duke
parents:
diff changeset
330 case Bytecodes::_lload_0:
a61af66fc99e Initial load
duke
parents:
diff changeset
331 case Bytecodes::_lload_1:
a61af66fc99e Initial load
duke
parents:
diff changeset
332 case Bytecodes::_lload_2:
a61af66fc99e Initial load
duke
parents:
diff changeset
333 case Bytecodes::_lload_3:
a61af66fc99e Initial load
duke
parents:
diff changeset
334 case Bytecodes::_dload_0:
a61af66fc99e Initial load
duke
parents:
diff changeset
335 case Bytecodes::_dload_1:
a61af66fc99e Initial load
duke
parents:
diff changeset
336 case Bytecodes::_dload_2:
a61af66fc99e Initial load
duke
parents:
diff changeset
337 case Bytecodes::_dload_3:
a61af66fc99e Initial load
duke
parents:
diff changeset
338 state.lpush();
a61af66fc99e Initial load
duke
parents:
diff changeset
339 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
340 case Bytecodes::_aload_0:
a61af66fc99e Initial load
duke
parents:
diff changeset
341 state.apush(state._vars[0]);
a61af66fc99e Initial load
duke
parents:
diff changeset
342 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
343 case Bytecodes::_aload_1:
a61af66fc99e Initial load
duke
parents:
diff changeset
344 state.apush(state._vars[1]);
a61af66fc99e Initial load
duke
parents:
diff changeset
345 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
346 case Bytecodes::_aload_2:
a61af66fc99e Initial load
duke
parents:
diff changeset
347 state.apush(state._vars[2]);
a61af66fc99e Initial load
duke
parents:
diff changeset
348 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
349 case Bytecodes::_aload_3:
a61af66fc99e Initial load
duke
parents:
diff changeset
350 state.apush(state._vars[3]);
a61af66fc99e Initial load
duke
parents:
diff changeset
351 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
352 case Bytecodes::_iaload:
a61af66fc99e Initial load
duke
parents:
diff changeset
353 case Bytecodes::_faload:
a61af66fc99e Initial load
duke
parents:
diff changeset
354 case Bytecodes::_baload:
a61af66fc99e Initial load
duke
parents:
diff changeset
355 case Bytecodes::_caload:
a61af66fc99e Initial load
duke
parents:
diff changeset
356 case Bytecodes::_saload:
a61af66fc99e Initial load
duke
parents:
diff changeset
357 state.spop();
a61af66fc99e Initial load
duke
parents:
diff changeset
358 set_method_escape(state.apop());
a61af66fc99e Initial load
duke
parents:
diff changeset
359 state.spush();
a61af66fc99e Initial load
duke
parents:
diff changeset
360 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
361 case Bytecodes::_laload:
a61af66fc99e Initial load
duke
parents:
diff changeset
362 case Bytecodes::_daload:
a61af66fc99e Initial load
duke
parents:
diff changeset
363 state.spop();
a61af66fc99e Initial load
duke
parents:
diff changeset
364 set_method_escape(state.apop());
a61af66fc99e Initial load
duke
parents:
diff changeset
365 state.lpush();
a61af66fc99e Initial load
duke
parents:
diff changeset
366 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
367 case Bytecodes::_aaload:
a61af66fc99e Initial load
duke
parents:
diff changeset
368 { state.spop();
a61af66fc99e Initial load
duke
parents:
diff changeset
369 ArgumentMap array = state.apop();
a61af66fc99e Initial load
duke
parents:
diff changeset
370 set_method_escape(array);
a61af66fc99e Initial load
duke
parents:
diff changeset
371 state.apush(unknown_obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
372 set_dirty(array);
a61af66fc99e Initial load
duke
parents:
diff changeset
373 }
a61af66fc99e Initial load
duke
parents:
diff changeset
374 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
375 case Bytecodes::_istore:
a61af66fc99e Initial load
duke
parents:
diff changeset
376 case Bytecodes::_fstore:
a61af66fc99e Initial load
duke
parents:
diff changeset
377 case Bytecodes::_istore_0:
a61af66fc99e Initial load
duke
parents:
diff changeset
378 case Bytecodes::_istore_1:
a61af66fc99e Initial load
duke
parents:
diff changeset
379 case Bytecodes::_istore_2:
a61af66fc99e Initial load
duke
parents:
diff changeset
380 case Bytecodes::_istore_3:
a61af66fc99e Initial load
duke
parents:
diff changeset
381 case Bytecodes::_fstore_0:
a61af66fc99e Initial load
duke
parents:
diff changeset
382 case Bytecodes::_fstore_1:
a61af66fc99e Initial load
duke
parents:
diff changeset
383 case Bytecodes::_fstore_2:
a61af66fc99e Initial load
duke
parents:
diff changeset
384 case Bytecodes::_fstore_3:
a61af66fc99e Initial load
duke
parents:
diff changeset
385 state.spop();
a61af66fc99e Initial load
duke
parents:
diff changeset
386 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
387 case Bytecodes::_lstore:
a61af66fc99e Initial load
duke
parents:
diff changeset
388 case Bytecodes::_dstore:
a61af66fc99e Initial load
duke
parents:
diff changeset
389 case Bytecodes::_lstore_0:
a61af66fc99e Initial load
duke
parents:
diff changeset
390 case Bytecodes::_lstore_1:
a61af66fc99e Initial load
duke
parents:
diff changeset
391 case Bytecodes::_lstore_2:
a61af66fc99e Initial load
duke
parents:
diff changeset
392 case Bytecodes::_lstore_3:
a61af66fc99e Initial load
duke
parents:
diff changeset
393 case Bytecodes::_dstore_0:
a61af66fc99e Initial load
duke
parents:
diff changeset
394 case Bytecodes::_dstore_1:
a61af66fc99e Initial load
duke
parents:
diff changeset
395 case Bytecodes::_dstore_2:
a61af66fc99e Initial load
duke
parents:
diff changeset
396 case Bytecodes::_dstore_3:
a61af66fc99e Initial load
duke
parents:
diff changeset
397 state.lpop();
a61af66fc99e Initial load
duke
parents:
diff changeset
398 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
399 case Bytecodes::_astore:
a61af66fc99e Initial load
duke
parents:
diff changeset
400 state._vars[s.get_index()] = state.apop();
a61af66fc99e Initial load
duke
parents:
diff changeset
401 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
402 case Bytecodes::_astore_0:
a61af66fc99e Initial load
duke
parents:
diff changeset
403 state._vars[0] = state.apop();
a61af66fc99e Initial load
duke
parents:
diff changeset
404 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
405 case Bytecodes::_astore_1:
a61af66fc99e Initial load
duke
parents:
diff changeset
406 state._vars[1] = state.apop();
a61af66fc99e Initial load
duke
parents:
diff changeset
407 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
408 case Bytecodes::_astore_2:
a61af66fc99e Initial load
duke
parents:
diff changeset
409 state._vars[2] = state.apop();
a61af66fc99e Initial load
duke
parents:
diff changeset
410 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
411 case Bytecodes::_astore_3:
a61af66fc99e Initial load
duke
parents:
diff changeset
412 state._vars[3] = state.apop();
a61af66fc99e Initial load
duke
parents:
diff changeset
413 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
414 case Bytecodes::_iastore:
a61af66fc99e Initial load
duke
parents:
diff changeset
415 case Bytecodes::_fastore:
a61af66fc99e Initial load
duke
parents:
diff changeset
416 case Bytecodes::_bastore:
a61af66fc99e Initial load
duke
parents:
diff changeset
417 case Bytecodes::_castore:
a61af66fc99e Initial load
duke
parents:
diff changeset
418 case Bytecodes::_sastore:
a61af66fc99e Initial load
duke
parents:
diff changeset
419 {
a61af66fc99e Initial load
duke
parents:
diff changeset
420 state.spop();
a61af66fc99e Initial load
duke
parents:
diff changeset
421 state.spop();
a61af66fc99e Initial load
duke
parents:
diff changeset
422 ArgumentMap arr = state.apop();
a61af66fc99e Initial load
duke
parents:
diff changeset
423 set_method_escape(arr);
a61af66fc99e Initial load
duke
parents:
diff changeset
424 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
425 }
a61af66fc99e Initial load
duke
parents:
diff changeset
426 case Bytecodes::_lastore:
a61af66fc99e Initial load
duke
parents:
diff changeset
427 case Bytecodes::_dastore:
a61af66fc99e Initial load
duke
parents:
diff changeset
428 {
a61af66fc99e Initial load
duke
parents:
diff changeset
429 state.lpop();
a61af66fc99e Initial load
duke
parents:
diff changeset
430 state.spop();
a61af66fc99e Initial load
duke
parents:
diff changeset
431 ArgumentMap arr = state.apop();
a61af66fc99e Initial load
duke
parents:
diff changeset
432 set_method_escape(arr);
a61af66fc99e Initial load
duke
parents:
diff changeset
433 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
434 }
a61af66fc99e Initial load
duke
parents:
diff changeset
435 case Bytecodes::_aastore:
a61af66fc99e Initial load
duke
parents:
diff changeset
436 {
a61af66fc99e Initial load
duke
parents:
diff changeset
437 set_global_escape(state.apop());
a61af66fc99e Initial load
duke
parents:
diff changeset
438 state.spop();
a61af66fc99e Initial load
duke
parents:
diff changeset
439 ArgumentMap arr = state.apop();
a61af66fc99e Initial load
duke
parents:
diff changeset
440 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
441 }
a61af66fc99e Initial load
duke
parents:
diff changeset
442 case Bytecodes::_pop:
a61af66fc99e Initial load
duke
parents:
diff changeset
443 state.raw_pop();
a61af66fc99e Initial load
duke
parents:
diff changeset
444 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
445 case Bytecodes::_pop2:
a61af66fc99e Initial load
duke
parents:
diff changeset
446 state.raw_pop();
a61af66fc99e Initial load
duke
parents:
diff changeset
447 state.raw_pop();
a61af66fc99e Initial load
duke
parents:
diff changeset
448 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
449 case Bytecodes::_dup:
a61af66fc99e Initial load
duke
parents:
diff changeset
450 { ArgumentMap w1 = state.raw_pop();
a61af66fc99e Initial load
duke
parents:
diff changeset
451 state.raw_push(w1);
a61af66fc99e Initial load
duke
parents:
diff changeset
452 state.raw_push(w1);
a61af66fc99e Initial load
duke
parents:
diff changeset
453 }
a61af66fc99e Initial load
duke
parents:
diff changeset
454 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
455 case Bytecodes::_dup_x1:
a61af66fc99e Initial load
duke
parents:
diff changeset
456 { ArgumentMap w1 = state.raw_pop();
a61af66fc99e Initial load
duke
parents:
diff changeset
457 ArgumentMap w2 = state.raw_pop();
a61af66fc99e Initial load
duke
parents:
diff changeset
458 state.raw_push(w1);
a61af66fc99e Initial load
duke
parents:
diff changeset
459 state.raw_push(w2);
a61af66fc99e Initial load
duke
parents:
diff changeset
460 state.raw_push(w1);
a61af66fc99e Initial load
duke
parents:
diff changeset
461 }
a61af66fc99e Initial load
duke
parents:
diff changeset
462 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
463 case Bytecodes::_dup_x2:
a61af66fc99e Initial load
duke
parents:
diff changeset
464 { ArgumentMap w1 = state.raw_pop();
a61af66fc99e Initial load
duke
parents:
diff changeset
465 ArgumentMap w2 = state.raw_pop();
a61af66fc99e Initial load
duke
parents:
diff changeset
466 ArgumentMap w3 = state.raw_pop();
a61af66fc99e Initial load
duke
parents:
diff changeset
467 state.raw_push(w1);
a61af66fc99e Initial load
duke
parents:
diff changeset
468 state.raw_push(w3);
a61af66fc99e Initial load
duke
parents:
diff changeset
469 state.raw_push(w2);
a61af66fc99e Initial load
duke
parents:
diff changeset
470 state.raw_push(w1);
a61af66fc99e Initial load
duke
parents:
diff changeset
471 }
a61af66fc99e Initial load
duke
parents:
diff changeset
472 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
473 case Bytecodes::_dup2:
a61af66fc99e Initial load
duke
parents:
diff changeset
474 { ArgumentMap w1 = state.raw_pop();
a61af66fc99e Initial load
duke
parents:
diff changeset
475 ArgumentMap w2 = state.raw_pop();
a61af66fc99e Initial load
duke
parents:
diff changeset
476 state.raw_push(w2);
a61af66fc99e Initial load
duke
parents:
diff changeset
477 state.raw_push(w1);
a61af66fc99e Initial load
duke
parents:
diff changeset
478 state.raw_push(w2);
a61af66fc99e Initial load
duke
parents:
diff changeset
479 state.raw_push(w1);
a61af66fc99e Initial load
duke
parents:
diff changeset
480 }
a61af66fc99e Initial load
duke
parents:
diff changeset
481 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
482 case Bytecodes::_dup2_x1:
a61af66fc99e Initial load
duke
parents:
diff changeset
483 { ArgumentMap w1 = state.raw_pop();
a61af66fc99e Initial load
duke
parents:
diff changeset
484 ArgumentMap w2 = state.raw_pop();
a61af66fc99e Initial load
duke
parents:
diff changeset
485 ArgumentMap w3 = state.raw_pop();
a61af66fc99e Initial load
duke
parents:
diff changeset
486 state.raw_push(w2);
a61af66fc99e Initial load
duke
parents:
diff changeset
487 state.raw_push(w1);
a61af66fc99e Initial load
duke
parents:
diff changeset
488 state.raw_push(w3);
a61af66fc99e Initial load
duke
parents:
diff changeset
489 state.raw_push(w2);
a61af66fc99e Initial load
duke
parents:
diff changeset
490 state.raw_push(w1);
a61af66fc99e Initial load
duke
parents:
diff changeset
491 }
a61af66fc99e Initial load
duke
parents:
diff changeset
492 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
493 case Bytecodes::_dup2_x2:
a61af66fc99e Initial load
duke
parents:
diff changeset
494 { ArgumentMap w1 = state.raw_pop();
a61af66fc99e Initial load
duke
parents:
diff changeset
495 ArgumentMap w2 = state.raw_pop();
a61af66fc99e Initial load
duke
parents:
diff changeset
496 ArgumentMap w3 = state.raw_pop();
a61af66fc99e Initial load
duke
parents:
diff changeset
497 ArgumentMap w4 = state.raw_pop();
a61af66fc99e Initial load
duke
parents:
diff changeset
498 state.raw_push(w2);
a61af66fc99e Initial load
duke
parents:
diff changeset
499 state.raw_push(w1);
a61af66fc99e Initial load
duke
parents:
diff changeset
500 state.raw_push(w4);
a61af66fc99e Initial load
duke
parents:
diff changeset
501 state.raw_push(w3);
a61af66fc99e Initial load
duke
parents:
diff changeset
502 state.raw_push(w2);
a61af66fc99e Initial load
duke
parents:
diff changeset
503 state.raw_push(w1);
a61af66fc99e Initial load
duke
parents:
diff changeset
504 }
a61af66fc99e Initial load
duke
parents:
diff changeset
505 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
506 case Bytecodes::_swap:
a61af66fc99e Initial load
duke
parents:
diff changeset
507 { ArgumentMap w1 = state.raw_pop();
a61af66fc99e Initial load
duke
parents:
diff changeset
508 ArgumentMap w2 = state.raw_pop();
a61af66fc99e Initial load
duke
parents:
diff changeset
509 state.raw_push(w1);
a61af66fc99e Initial load
duke
parents:
diff changeset
510 state.raw_push(w2);
a61af66fc99e Initial load
duke
parents:
diff changeset
511 }
a61af66fc99e Initial load
duke
parents:
diff changeset
512 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
513 case Bytecodes::_iadd:
a61af66fc99e Initial load
duke
parents:
diff changeset
514 case Bytecodes::_fadd:
a61af66fc99e Initial load
duke
parents:
diff changeset
515 case Bytecodes::_isub:
a61af66fc99e Initial load
duke
parents:
diff changeset
516 case Bytecodes::_fsub:
a61af66fc99e Initial load
duke
parents:
diff changeset
517 case Bytecodes::_imul:
a61af66fc99e Initial load
duke
parents:
diff changeset
518 case Bytecodes::_fmul:
a61af66fc99e Initial load
duke
parents:
diff changeset
519 case Bytecodes::_idiv:
a61af66fc99e Initial load
duke
parents:
diff changeset
520 case Bytecodes::_fdiv:
a61af66fc99e Initial load
duke
parents:
diff changeset
521 case Bytecodes::_irem:
a61af66fc99e Initial load
duke
parents:
diff changeset
522 case Bytecodes::_frem:
a61af66fc99e Initial load
duke
parents:
diff changeset
523 case Bytecodes::_iand:
a61af66fc99e Initial load
duke
parents:
diff changeset
524 case Bytecodes::_ior:
a61af66fc99e Initial load
duke
parents:
diff changeset
525 case Bytecodes::_ixor:
a61af66fc99e Initial load
duke
parents:
diff changeset
526 state.spop();
a61af66fc99e Initial load
duke
parents:
diff changeset
527 state.spop();
a61af66fc99e Initial load
duke
parents:
diff changeset
528 state.spush();
a61af66fc99e Initial load
duke
parents:
diff changeset
529 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
530 case Bytecodes::_ladd:
a61af66fc99e Initial load
duke
parents:
diff changeset
531 case Bytecodes::_dadd:
a61af66fc99e Initial load
duke
parents:
diff changeset
532 case Bytecodes::_lsub:
a61af66fc99e Initial load
duke
parents:
diff changeset
533 case Bytecodes::_dsub:
a61af66fc99e Initial load
duke
parents:
diff changeset
534 case Bytecodes::_lmul:
a61af66fc99e Initial load
duke
parents:
diff changeset
535 case Bytecodes::_dmul:
a61af66fc99e Initial load
duke
parents:
diff changeset
536 case Bytecodes::_ldiv:
a61af66fc99e Initial load
duke
parents:
diff changeset
537 case Bytecodes::_ddiv:
a61af66fc99e Initial load
duke
parents:
diff changeset
538 case Bytecodes::_lrem:
a61af66fc99e Initial load
duke
parents:
diff changeset
539 case Bytecodes::_drem:
a61af66fc99e Initial load
duke
parents:
diff changeset
540 case Bytecodes::_land:
a61af66fc99e Initial load
duke
parents:
diff changeset
541 case Bytecodes::_lor:
a61af66fc99e Initial load
duke
parents:
diff changeset
542 case Bytecodes::_lxor:
a61af66fc99e Initial load
duke
parents:
diff changeset
543 state.lpop();
a61af66fc99e Initial load
duke
parents:
diff changeset
544 state.lpop();
a61af66fc99e Initial load
duke
parents:
diff changeset
545 state.lpush();
a61af66fc99e Initial load
duke
parents:
diff changeset
546 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
547 case Bytecodes::_ishl:
a61af66fc99e Initial load
duke
parents:
diff changeset
548 case Bytecodes::_ishr:
a61af66fc99e Initial load
duke
parents:
diff changeset
549 case Bytecodes::_iushr:
a61af66fc99e Initial load
duke
parents:
diff changeset
550 state.spop();
a61af66fc99e Initial load
duke
parents:
diff changeset
551 state.spop();
a61af66fc99e Initial load
duke
parents:
diff changeset
552 state.spush();
a61af66fc99e Initial load
duke
parents:
diff changeset
553 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
554 case Bytecodes::_lshl:
a61af66fc99e Initial load
duke
parents:
diff changeset
555 case Bytecodes::_lshr:
a61af66fc99e Initial load
duke
parents:
diff changeset
556 case Bytecodes::_lushr:
a61af66fc99e Initial load
duke
parents:
diff changeset
557 state.spop();
a61af66fc99e Initial load
duke
parents:
diff changeset
558 state.lpop();
a61af66fc99e Initial load
duke
parents:
diff changeset
559 state.lpush();
a61af66fc99e Initial load
duke
parents:
diff changeset
560 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
561 case Bytecodes::_ineg:
a61af66fc99e Initial load
duke
parents:
diff changeset
562 case Bytecodes::_fneg:
a61af66fc99e Initial load
duke
parents:
diff changeset
563 state.spop();
a61af66fc99e Initial load
duke
parents:
diff changeset
564 state.spush();
a61af66fc99e Initial load
duke
parents:
diff changeset
565 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
566 case Bytecodes::_lneg:
a61af66fc99e Initial load
duke
parents:
diff changeset
567 case Bytecodes::_dneg:
a61af66fc99e Initial load
duke
parents:
diff changeset
568 state.lpop();
a61af66fc99e Initial load
duke
parents:
diff changeset
569 state.lpush();
a61af66fc99e Initial load
duke
parents:
diff changeset
570 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
571 case Bytecodes::_iinc:
a61af66fc99e Initial load
duke
parents:
diff changeset
572 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
573 case Bytecodes::_i2l:
a61af66fc99e Initial load
duke
parents:
diff changeset
574 case Bytecodes::_i2d:
a61af66fc99e Initial load
duke
parents:
diff changeset
575 case Bytecodes::_f2l:
a61af66fc99e Initial load
duke
parents:
diff changeset
576 case Bytecodes::_f2d:
a61af66fc99e Initial load
duke
parents:
diff changeset
577 state.spop();
a61af66fc99e Initial load
duke
parents:
diff changeset
578 state.lpush();
a61af66fc99e Initial load
duke
parents:
diff changeset
579 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
580 case Bytecodes::_i2f:
a61af66fc99e Initial load
duke
parents:
diff changeset
581 case Bytecodes::_f2i:
a61af66fc99e Initial load
duke
parents:
diff changeset
582 state.spop();
a61af66fc99e Initial load
duke
parents:
diff changeset
583 state.spush();
a61af66fc99e Initial load
duke
parents:
diff changeset
584 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
585 case Bytecodes::_l2i:
a61af66fc99e Initial load
duke
parents:
diff changeset
586 case Bytecodes::_l2f:
a61af66fc99e Initial load
duke
parents:
diff changeset
587 case Bytecodes::_d2i:
a61af66fc99e Initial load
duke
parents:
diff changeset
588 case Bytecodes::_d2f:
a61af66fc99e Initial load
duke
parents:
diff changeset
589 state.lpop();
a61af66fc99e Initial load
duke
parents:
diff changeset
590 state.spush();
a61af66fc99e Initial load
duke
parents:
diff changeset
591 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
592 case Bytecodes::_l2d:
a61af66fc99e Initial load
duke
parents:
diff changeset
593 case Bytecodes::_d2l:
a61af66fc99e Initial load
duke
parents:
diff changeset
594 state.lpop();
a61af66fc99e Initial load
duke
parents:
diff changeset
595 state.lpush();
a61af66fc99e Initial load
duke
parents:
diff changeset
596 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
597 case Bytecodes::_i2b:
a61af66fc99e Initial load
duke
parents:
diff changeset
598 case Bytecodes::_i2c:
a61af66fc99e Initial load
duke
parents:
diff changeset
599 case Bytecodes::_i2s:
a61af66fc99e Initial load
duke
parents:
diff changeset
600 state.spop();
a61af66fc99e Initial load
duke
parents:
diff changeset
601 state.spush();
a61af66fc99e Initial load
duke
parents:
diff changeset
602 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
603 case Bytecodes::_lcmp:
a61af66fc99e Initial load
duke
parents:
diff changeset
604 case Bytecodes::_dcmpl:
a61af66fc99e Initial load
duke
parents:
diff changeset
605 case Bytecodes::_dcmpg:
a61af66fc99e Initial load
duke
parents:
diff changeset
606 state.lpop();
a61af66fc99e Initial load
duke
parents:
diff changeset
607 state.lpop();
a61af66fc99e Initial load
duke
parents:
diff changeset
608 state.spush();
a61af66fc99e Initial load
duke
parents:
diff changeset
609 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
610 case Bytecodes::_fcmpl:
a61af66fc99e Initial load
duke
parents:
diff changeset
611 case Bytecodes::_fcmpg:
a61af66fc99e Initial load
duke
parents:
diff changeset
612 state.spop();
a61af66fc99e Initial load
duke
parents:
diff changeset
613 state.spop();
a61af66fc99e Initial load
duke
parents:
diff changeset
614 state.spush();
a61af66fc99e Initial load
duke
parents:
diff changeset
615 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
616 case Bytecodes::_ifeq:
a61af66fc99e Initial load
duke
parents:
diff changeset
617 case Bytecodes::_ifne:
a61af66fc99e Initial load
duke
parents:
diff changeset
618 case Bytecodes::_iflt:
a61af66fc99e Initial load
duke
parents:
diff changeset
619 case Bytecodes::_ifge:
a61af66fc99e Initial load
duke
parents:
diff changeset
620 case Bytecodes::_ifgt:
a61af66fc99e Initial load
duke
parents:
diff changeset
621 case Bytecodes::_ifle:
a61af66fc99e Initial load
duke
parents:
diff changeset
622 {
a61af66fc99e Initial load
duke
parents:
diff changeset
623 state.spop();
a61af66fc99e Initial load
duke
parents:
diff changeset
624 int dest_bci = s.get_dest();
a61af66fc99e Initial load
duke
parents:
diff changeset
625 assert(_methodBlocks->is_block_start(dest_bci), "branch destination must start a block");
a61af66fc99e Initial load
duke
parents:
diff changeset
626 assert(s.next_bci() == limit_bci, "branch must end block");
a61af66fc99e Initial load
duke
parents:
diff changeset
627 successors.push(_methodBlocks->block_containing(dest_bci));
a61af66fc99e Initial load
duke
parents:
diff changeset
628 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
629 }
a61af66fc99e Initial load
duke
parents:
diff changeset
630 case Bytecodes::_if_icmpeq:
a61af66fc99e Initial load
duke
parents:
diff changeset
631 case Bytecodes::_if_icmpne:
a61af66fc99e Initial load
duke
parents:
diff changeset
632 case Bytecodes::_if_icmplt:
a61af66fc99e Initial load
duke
parents:
diff changeset
633 case Bytecodes::_if_icmpge:
a61af66fc99e Initial load
duke
parents:
diff changeset
634 case Bytecodes::_if_icmpgt:
a61af66fc99e Initial load
duke
parents:
diff changeset
635 case Bytecodes::_if_icmple:
a61af66fc99e Initial load
duke
parents:
diff changeset
636 {
a61af66fc99e Initial load
duke
parents:
diff changeset
637 state.spop();
a61af66fc99e Initial load
duke
parents:
diff changeset
638 state.spop();
a61af66fc99e Initial load
duke
parents:
diff changeset
639 int dest_bci = s.get_dest();
a61af66fc99e Initial load
duke
parents:
diff changeset
640 assert(_methodBlocks->is_block_start(dest_bci), "branch destination must start a block");
a61af66fc99e Initial load
duke
parents:
diff changeset
641 assert(s.next_bci() == limit_bci, "branch must end block");
a61af66fc99e Initial load
duke
parents:
diff changeset
642 successors.push(_methodBlocks->block_containing(dest_bci));
a61af66fc99e Initial load
duke
parents:
diff changeset
643 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
644 }
a61af66fc99e Initial load
duke
parents:
diff changeset
645 case Bytecodes::_if_acmpeq:
a61af66fc99e Initial load
duke
parents:
diff changeset
646 case Bytecodes::_if_acmpne:
a61af66fc99e Initial load
duke
parents:
diff changeset
647 {
a61af66fc99e Initial load
duke
parents:
diff changeset
648 set_method_escape(state.apop());
a61af66fc99e Initial load
duke
parents:
diff changeset
649 set_method_escape(state.apop());
a61af66fc99e Initial load
duke
parents:
diff changeset
650 int dest_bci = s.get_dest();
a61af66fc99e Initial load
duke
parents:
diff changeset
651 assert(_methodBlocks->is_block_start(dest_bci), "branch destination must start a block");
a61af66fc99e Initial load
duke
parents:
diff changeset
652 assert(s.next_bci() == limit_bci, "branch must end block");
a61af66fc99e Initial load
duke
parents:
diff changeset
653 successors.push(_methodBlocks->block_containing(dest_bci));
a61af66fc99e Initial load
duke
parents:
diff changeset
654 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
655 }
a61af66fc99e Initial load
duke
parents:
diff changeset
656 case Bytecodes::_goto:
a61af66fc99e Initial load
duke
parents:
diff changeset
657 {
a61af66fc99e Initial load
duke
parents:
diff changeset
658 int dest_bci = s.get_dest();
a61af66fc99e Initial load
duke
parents:
diff changeset
659 assert(_methodBlocks->is_block_start(dest_bci), "branch destination must start a block");
a61af66fc99e Initial load
duke
parents:
diff changeset
660 assert(s.next_bci() == limit_bci, "branch must end block");
a61af66fc99e Initial load
duke
parents:
diff changeset
661 successors.push(_methodBlocks->block_containing(dest_bci));
a61af66fc99e Initial load
duke
parents:
diff changeset
662 fall_through = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
663 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
664 }
a61af66fc99e Initial load
duke
parents:
diff changeset
665 case Bytecodes::_jsr:
a61af66fc99e Initial load
duke
parents:
diff changeset
666 {
a61af66fc99e Initial load
duke
parents:
diff changeset
667 int dest_bci = s.get_dest();
a61af66fc99e Initial load
duke
parents:
diff changeset
668 assert(_methodBlocks->is_block_start(dest_bci), "branch destination must start a block");
a61af66fc99e Initial load
duke
parents:
diff changeset
669 assert(s.next_bci() == limit_bci, "branch must end block");
a61af66fc99e Initial load
duke
parents:
diff changeset
670 state.apush(empty_map);
a61af66fc99e Initial load
duke
parents:
diff changeset
671 successors.push(_methodBlocks->block_containing(dest_bci));
a61af66fc99e Initial load
duke
parents:
diff changeset
672 fall_through = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
673 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
674 }
a61af66fc99e Initial load
duke
parents:
diff changeset
675 case Bytecodes::_ret:
a61af66fc99e Initial load
duke
parents:
diff changeset
676 // we don't track the destination of a "ret" instruction
a61af66fc99e Initial load
duke
parents:
diff changeset
677 assert(s.next_bci() == limit_bci, "branch must end block");
a61af66fc99e Initial load
duke
parents:
diff changeset
678 fall_through = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
679 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
680 case Bytecodes::_return:
a61af66fc99e Initial load
duke
parents:
diff changeset
681 assert(s.next_bci() == limit_bci, "return must end block");
a61af66fc99e Initial load
duke
parents:
diff changeset
682 fall_through = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
683 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
684 case Bytecodes::_tableswitch:
a61af66fc99e Initial load
duke
parents:
diff changeset
685 {
a61af66fc99e Initial load
duke
parents:
diff changeset
686 state.spop();
a61af66fc99e Initial load
duke
parents:
diff changeset
687 Bytecode_tableswitch* switch_ = Bytecode_tableswitch_at(s.cur_bcp());
a61af66fc99e Initial load
duke
parents:
diff changeset
688 int len = switch_->length();
a61af66fc99e Initial load
duke
parents:
diff changeset
689 int dest_bci;
a61af66fc99e Initial load
duke
parents:
diff changeset
690 for (int i = 0; i < len; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
691 dest_bci = s.cur_bci() + switch_->dest_offset_at(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
692 assert(_methodBlocks->is_block_start(dest_bci), "branch destination must start a block");
a61af66fc99e Initial load
duke
parents:
diff changeset
693 successors.push(_methodBlocks->block_containing(dest_bci));
a61af66fc99e Initial load
duke
parents:
diff changeset
694 }
a61af66fc99e Initial load
duke
parents:
diff changeset
695 dest_bci = s.cur_bci() + switch_->default_offset();
a61af66fc99e Initial load
duke
parents:
diff changeset
696 assert(_methodBlocks->is_block_start(dest_bci), "branch destination must start a block");
a61af66fc99e Initial load
duke
parents:
diff changeset
697 successors.push(_methodBlocks->block_containing(dest_bci));
a61af66fc99e Initial load
duke
parents:
diff changeset
698 assert(s.next_bci() == limit_bci, "branch must end block");
a61af66fc99e Initial load
duke
parents:
diff changeset
699 fall_through = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
700 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
701 }
a61af66fc99e Initial load
duke
parents:
diff changeset
702 case Bytecodes::_lookupswitch:
a61af66fc99e Initial load
duke
parents:
diff changeset
703 {
a61af66fc99e Initial load
duke
parents:
diff changeset
704 state.spop();
a61af66fc99e Initial load
duke
parents:
diff changeset
705 Bytecode_lookupswitch* switch_ = Bytecode_lookupswitch_at(s.cur_bcp());
a61af66fc99e Initial load
duke
parents:
diff changeset
706 int len = switch_->number_of_pairs();
a61af66fc99e Initial load
duke
parents:
diff changeset
707 int dest_bci;
a61af66fc99e Initial load
duke
parents:
diff changeset
708 for (int i = 0; i < len; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
709 dest_bci = s.cur_bci() + switch_->pair_at(i)->offset();
a61af66fc99e Initial load
duke
parents:
diff changeset
710 assert(_methodBlocks->is_block_start(dest_bci), "branch destination must start a block");
a61af66fc99e Initial load
duke
parents:
diff changeset
711 successors.push(_methodBlocks->block_containing(dest_bci));
a61af66fc99e Initial load
duke
parents:
diff changeset
712 }
a61af66fc99e Initial load
duke
parents:
diff changeset
713 dest_bci = s.cur_bci() + switch_->default_offset();
a61af66fc99e Initial load
duke
parents:
diff changeset
714 assert(_methodBlocks->is_block_start(dest_bci), "branch destination must start a block");
a61af66fc99e Initial load
duke
parents:
diff changeset
715 successors.push(_methodBlocks->block_containing(dest_bci));
a61af66fc99e Initial load
duke
parents:
diff changeset
716 fall_through = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
717 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
718 }
a61af66fc99e Initial load
duke
parents:
diff changeset
719 case Bytecodes::_ireturn:
a61af66fc99e Initial load
duke
parents:
diff changeset
720 case Bytecodes::_freturn:
a61af66fc99e Initial load
duke
parents:
diff changeset
721 state.spop();
a61af66fc99e Initial load
duke
parents:
diff changeset
722 fall_through = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
723 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
724 case Bytecodes::_lreturn:
a61af66fc99e Initial load
duke
parents:
diff changeset
725 case Bytecodes::_dreturn:
a61af66fc99e Initial load
duke
parents:
diff changeset
726 state.lpop();
a61af66fc99e Initial load
duke
parents:
diff changeset
727 fall_through = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
728 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
729 case Bytecodes::_areturn:
a61af66fc99e Initial load
duke
parents:
diff changeset
730 set_returned(state.apop());
a61af66fc99e Initial load
duke
parents:
diff changeset
731 fall_through = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
732 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
733 case Bytecodes::_getstatic:
a61af66fc99e Initial load
duke
parents:
diff changeset
734 case Bytecodes::_getfield:
a61af66fc99e Initial load
duke
parents:
diff changeset
735 { bool will_link;
a61af66fc99e Initial load
duke
parents:
diff changeset
736 ciField* field = s.get_field(will_link);
a61af66fc99e Initial load
duke
parents:
diff changeset
737 BasicType field_type = field->type()->basic_type();
a61af66fc99e Initial load
duke
parents:
diff changeset
738 if (s.cur_bc() != Bytecodes::_getstatic) {
a61af66fc99e Initial load
duke
parents:
diff changeset
739 set_method_escape(state.apop());
a61af66fc99e Initial load
duke
parents:
diff changeset
740 }
a61af66fc99e Initial load
duke
parents:
diff changeset
741 if (field_type == T_OBJECT || field_type == T_ARRAY) {
a61af66fc99e Initial load
duke
parents:
diff changeset
742 state.apush(unknown_obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
743 } else if (type2size[field_type] == 1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
744 state.spush();
a61af66fc99e Initial load
duke
parents:
diff changeset
745 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
746 state.lpush();
a61af66fc99e Initial load
duke
parents:
diff changeset
747 }
a61af66fc99e Initial load
duke
parents:
diff changeset
748 }
a61af66fc99e Initial load
duke
parents:
diff changeset
749 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
750 case Bytecodes::_putstatic:
a61af66fc99e Initial load
duke
parents:
diff changeset
751 case Bytecodes::_putfield:
a61af66fc99e Initial load
duke
parents:
diff changeset
752 { bool will_link;
a61af66fc99e Initial load
duke
parents:
diff changeset
753 ciField* field = s.get_field(will_link);
a61af66fc99e Initial load
duke
parents:
diff changeset
754 BasicType field_type = field->type()->basic_type();
a61af66fc99e Initial load
duke
parents:
diff changeset
755 if (field_type == T_OBJECT || field_type == T_ARRAY) {
a61af66fc99e Initial load
duke
parents:
diff changeset
756 set_global_escape(state.apop());
a61af66fc99e Initial load
duke
parents:
diff changeset
757 } else if (type2size[field_type] == 1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
758 state.spop();
a61af66fc99e Initial load
duke
parents:
diff changeset
759 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
760 state.lpop();
a61af66fc99e Initial load
duke
parents:
diff changeset
761 }
a61af66fc99e Initial load
duke
parents:
diff changeset
762 if (s.cur_bc() != Bytecodes::_putstatic) {
a61af66fc99e Initial load
duke
parents:
diff changeset
763 ArgumentMap p = state.apop();
a61af66fc99e Initial load
duke
parents:
diff changeset
764 set_method_escape(p);
a61af66fc99e Initial load
duke
parents:
diff changeset
765 }
a61af66fc99e Initial load
duke
parents:
diff changeset
766 }
a61af66fc99e Initial load
duke
parents:
diff changeset
767 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
768 case Bytecodes::_invokevirtual:
a61af66fc99e Initial load
duke
parents:
diff changeset
769 case Bytecodes::_invokespecial:
a61af66fc99e Initial load
duke
parents:
diff changeset
770 case Bytecodes::_invokestatic:
a61af66fc99e Initial load
duke
parents:
diff changeset
771 case Bytecodes::_invokeinterface:
a61af66fc99e Initial load
duke
parents:
diff changeset
772 { bool will_link;
a61af66fc99e Initial load
duke
parents:
diff changeset
773 ciMethod* target = s.get_method(will_link);
a61af66fc99e Initial load
duke
parents:
diff changeset
774 ciKlass* holder = s.get_declared_method_holder();
a61af66fc99e Initial load
duke
parents:
diff changeset
775 invoke(state, s.cur_bc(), target, holder);
a61af66fc99e Initial load
duke
parents:
diff changeset
776 ciType* return_type = target->return_type();
a61af66fc99e Initial load
duke
parents:
diff changeset
777 if (!return_type->is_primitive_type()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
778 state.apush(unknown_obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
779 } else if (return_type->is_one_word()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
780 state.spush();
a61af66fc99e Initial load
duke
parents:
diff changeset
781 } else if (return_type->is_two_word()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
782 state.lpush();
a61af66fc99e Initial load
duke
parents:
diff changeset
783 }
a61af66fc99e Initial load
duke
parents:
diff changeset
784 }
a61af66fc99e Initial load
duke
parents:
diff changeset
785 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
786 case Bytecodes::_xxxunusedxxx:
a61af66fc99e Initial load
duke
parents:
diff changeset
787 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
788 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
789 case Bytecodes::_new:
a61af66fc99e Initial load
duke
parents:
diff changeset
790 state.apush(allocated_obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
791 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
792 case Bytecodes::_newarray:
a61af66fc99e Initial load
duke
parents:
diff changeset
793 case Bytecodes::_anewarray:
a61af66fc99e Initial load
duke
parents:
diff changeset
794 state.spop();
a61af66fc99e Initial load
duke
parents:
diff changeset
795 state.apush(allocated_obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
796 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
797 case Bytecodes::_multianewarray:
a61af66fc99e Initial load
duke
parents:
diff changeset
798 { int i = s.cur_bcp()[3];
a61af66fc99e Initial load
duke
parents:
diff changeset
799 while (i-- > 0) state.spop();
a61af66fc99e Initial load
duke
parents:
diff changeset
800 state.apush(allocated_obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
801 }
a61af66fc99e Initial load
duke
parents:
diff changeset
802 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
803 case Bytecodes::_arraylength:
a61af66fc99e Initial load
duke
parents:
diff changeset
804 set_method_escape(state.apop());
a61af66fc99e Initial load
duke
parents:
diff changeset
805 state.spush();
a61af66fc99e Initial load
duke
parents:
diff changeset
806 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
807 case Bytecodes::_athrow:
a61af66fc99e Initial load
duke
parents:
diff changeset
808 set_global_escape(state.apop());
a61af66fc99e Initial load
duke
parents:
diff changeset
809 fall_through = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
810 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
811 case Bytecodes::_checkcast:
a61af66fc99e Initial load
duke
parents:
diff changeset
812 { ArgumentMap obj = state.apop();
a61af66fc99e Initial load
duke
parents:
diff changeset
813 set_method_escape(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
814 state.apush(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
815 }
a61af66fc99e Initial load
duke
parents:
diff changeset
816 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
817 case Bytecodes::_instanceof:
a61af66fc99e Initial load
duke
parents:
diff changeset
818 set_method_escape(state.apop());
a61af66fc99e Initial load
duke
parents:
diff changeset
819 state.spush();
a61af66fc99e Initial load
duke
parents:
diff changeset
820 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
821 case Bytecodes::_monitorenter:
a61af66fc99e Initial load
duke
parents:
diff changeset
822 case Bytecodes::_monitorexit:
a61af66fc99e Initial load
duke
parents:
diff changeset
823 state.apop();
a61af66fc99e Initial load
duke
parents:
diff changeset
824 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
825 case Bytecodes::_wide:
a61af66fc99e Initial load
duke
parents:
diff changeset
826 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
827 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
828 case Bytecodes::_ifnull:
a61af66fc99e Initial load
duke
parents:
diff changeset
829 case Bytecodes::_ifnonnull:
a61af66fc99e Initial load
duke
parents:
diff changeset
830 {
a61af66fc99e Initial load
duke
parents:
diff changeset
831 set_method_escape(state.apop());
a61af66fc99e Initial load
duke
parents:
diff changeset
832 int dest_bci = s.get_dest();
a61af66fc99e Initial load
duke
parents:
diff changeset
833 assert(_methodBlocks->is_block_start(dest_bci), "branch destination must start a block");
a61af66fc99e Initial load
duke
parents:
diff changeset
834 assert(s.next_bci() == limit_bci, "branch must end block");
a61af66fc99e Initial load
duke
parents:
diff changeset
835 successors.push(_methodBlocks->block_containing(dest_bci));
a61af66fc99e Initial load
duke
parents:
diff changeset
836 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
837 }
a61af66fc99e Initial load
duke
parents:
diff changeset
838 case Bytecodes::_goto_w:
a61af66fc99e Initial load
duke
parents:
diff changeset
839 {
a61af66fc99e Initial load
duke
parents:
diff changeset
840 int dest_bci = s.get_far_dest();
a61af66fc99e Initial load
duke
parents:
diff changeset
841 assert(_methodBlocks->is_block_start(dest_bci), "branch destination must start a block");
a61af66fc99e Initial load
duke
parents:
diff changeset
842 assert(s.next_bci() == limit_bci, "branch must end block");
a61af66fc99e Initial load
duke
parents:
diff changeset
843 successors.push(_methodBlocks->block_containing(dest_bci));
a61af66fc99e Initial load
duke
parents:
diff changeset
844 fall_through = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
845 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
846 }
a61af66fc99e Initial load
duke
parents:
diff changeset
847 case Bytecodes::_jsr_w:
a61af66fc99e Initial load
duke
parents:
diff changeset
848 {
a61af66fc99e Initial load
duke
parents:
diff changeset
849 int dest_bci = s.get_far_dest();
a61af66fc99e Initial load
duke
parents:
diff changeset
850 assert(_methodBlocks->is_block_start(dest_bci), "branch destination must start a block");
a61af66fc99e Initial load
duke
parents:
diff changeset
851 assert(s.next_bci() == limit_bci, "branch must end block");
a61af66fc99e Initial load
duke
parents:
diff changeset
852 state.apush(empty_map);
a61af66fc99e Initial load
duke
parents:
diff changeset
853 successors.push(_methodBlocks->block_containing(dest_bci));
a61af66fc99e Initial load
duke
parents:
diff changeset
854 fall_through = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
855 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
856 }
a61af66fc99e Initial load
duke
parents:
diff changeset
857 case Bytecodes::_breakpoint:
a61af66fc99e Initial load
duke
parents:
diff changeset
858 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
859 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
860 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
861 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
862 }
a61af66fc99e Initial load
duke
parents:
diff changeset
863
a61af66fc99e Initial load
duke
parents:
diff changeset
864 }
a61af66fc99e Initial load
duke
parents:
diff changeset
865 if (fall_through) {
a61af66fc99e Initial load
duke
parents:
diff changeset
866 int fall_through_bci = s.cur_bci();
a61af66fc99e Initial load
duke
parents:
diff changeset
867 if (fall_through_bci < _method->code_size()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
868 assert(_methodBlocks->is_block_start(fall_through_bci), "must fall through to block start.");
a61af66fc99e Initial load
duke
parents:
diff changeset
869 successors.push(_methodBlocks->block_containing(fall_through_bci));
a61af66fc99e Initial load
duke
parents:
diff changeset
870 }
a61af66fc99e Initial load
duke
parents:
diff changeset
871 }
a61af66fc99e Initial load
duke
parents:
diff changeset
872 }
a61af66fc99e Initial load
duke
parents:
diff changeset
873
a61af66fc99e Initial load
duke
parents:
diff changeset
874 void BCEscapeAnalyzer::merge_block_states(StateInfo *blockstates, ciBlock *dest, StateInfo *s_state) {
a61af66fc99e Initial load
duke
parents:
diff changeset
875 StateInfo *d_state = blockstates+dest->index();
a61af66fc99e Initial load
duke
parents:
diff changeset
876 int nlocals = _method->max_locals();
a61af66fc99e Initial load
duke
parents:
diff changeset
877
a61af66fc99e Initial load
duke
parents:
diff changeset
878 // exceptions may cause transfer of control to handlers in the middle of a
a61af66fc99e Initial load
duke
parents:
diff changeset
879 // block, so we don't merge the incoming state of exception handlers
a61af66fc99e Initial load
duke
parents:
diff changeset
880 if (dest->is_handler())
a61af66fc99e Initial load
duke
parents:
diff changeset
881 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
882 if (!d_state->_initialized ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
883 // destination not initialized, just copy
a61af66fc99e Initial load
duke
parents:
diff changeset
884 for (int i = 0; i < nlocals; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
885 d_state->_vars[i] = s_state->_vars[i];
a61af66fc99e Initial load
duke
parents:
diff changeset
886 }
a61af66fc99e Initial load
duke
parents:
diff changeset
887 for (int i = 0; i < s_state->_stack_height; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
888 d_state->_stack[i] = s_state->_stack[i];
a61af66fc99e Initial load
duke
parents:
diff changeset
889 }
a61af66fc99e Initial load
duke
parents:
diff changeset
890 d_state->_stack_height = s_state->_stack_height;
a61af66fc99e Initial load
duke
parents:
diff changeset
891 d_state->_max_stack = s_state->_max_stack;
a61af66fc99e Initial load
duke
parents:
diff changeset
892 d_state->_initialized = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
893 } else if (!dest->processed()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
894 // we have not yet walked the bytecodes of dest, we can merge
a61af66fc99e Initial load
duke
parents:
diff changeset
895 // the states
a61af66fc99e Initial load
duke
parents:
diff changeset
896 assert(d_state->_stack_height == s_state->_stack_height, "computed stack heights must match");
a61af66fc99e Initial load
duke
parents:
diff changeset
897 for (int i = 0; i < nlocals; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
898 d_state->_vars[i].set_union(s_state->_vars[i]);
a61af66fc99e Initial load
duke
parents:
diff changeset
899 }
a61af66fc99e Initial load
duke
parents:
diff changeset
900 for (int i = 0; i < s_state->_stack_height; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
901 d_state->_stack[i].set_union(s_state->_stack[i]);
a61af66fc99e Initial load
duke
parents:
diff changeset
902 }
a61af66fc99e Initial load
duke
parents:
diff changeset
903 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
904 // the bytecodes of dest have already been processed, mark any
a61af66fc99e Initial load
duke
parents:
diff changeset
905 // arguments in the source state which are not in the dest state
a61af66fc99e Initial load
duke
parents:
diff changeset
906 // as global escape.
a61af66fc99e Initial load
duke
parents:
diff changeset
907 // Future refinement: we only need to mark these variable to the
a61af66fc99e Initial load
duke
parents:
diff changeset
908 // maximum escape of any variables in dest state
a61af66fc99e Initial load
duke
parents:
diff changeset
909 assert(d_state->_stack_height == s_state->_stack_height, "computed stack heights must match");
a61af66fc99e Initial load
duke
parents:
diff changeset
910 ArgumentMap extra_vars;
a61af66fc99e Initial load
duke
parents:
diff changeset
911 for (int i = 0; i < nlocals; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
912 ArgumentMap t;
a61af66fc99e Initial load
duke
parents:
diff changeset
913 t = s_state->_vars[i];
a61af66fc99e Initial load
duke
parents:
diff changeset
914 t.set_difference(d_state->_vars[i]);
a61af66fc99e Initial load
duke
parents:
diff changeset
915 extra_vars.set_union(t);
a61af66fc99e Initial load
duke
parents:
diff changeset
916 }
a61af66fc99e Initial load
duke
parents:
diff changeset
917 for (int i = 0; i < s_state->_stack_height; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
918 ArgumentMap t;
a61af66fc99e Initial load
duke
parents:
diff changeset
919 t.clear();
a61af66fc99e Initial load
duke
parents:
diff changeset
920 t = s_state->_stack[i];
a61af66fc99e Initial load
duke
parents:
diff changeset
921 t.set_difference(d_state->_stack[i]);
a61af66fc99e Initial load
duke
parents:
diff changeset
922 extra_vars.set_union(t);
a61af66fc99e Initial load
duke
parents:
diff changeset
923 }
a61af66fc99e Initial load
duke
parents:
diff changeset
924 set_global_escape(extra_vars);
a61af66fc99e Initial load
duke
parents:
diff changeset
925 }
a61af66fc99e Initial load
duke
parents:
diff changeset
926 }
a61af66fc99e Initial load
duke
parents:
diff changeset
927
a61af66fc99e Initial load
duke
parents:
diff changeset
928 void BCEscapeAnalyzer::iterate_blocks(Arena *arena) {
a61af66fc99e Initial load
duke
parents:
diff changeset
929 int numblocks = _methodBlocks->num_blocks();
a61af66fc99e Initial load
duke
parents:
diff changeset
930 int stkSize = _method->max_stack();
a61af66fc99e Initial load
duke
parents:
diff changeset
931 int numLocals = _method->max_locals();
a61af66fc99e Initial load
duke
parents:
diff changeset
932 StateInfo state;
a61af66fc99e Initial load
duke
parents:
diff changeset
933
a61af66fc99e Initial load
duke
parents:
diff changeset
934 int datacount = (numblocks + 1) * (stkSize + numLocals);
a61af66fc99e Initial load
duke
parents:
diff changeset
935 int datasize = datacount * sizeof(ArgumentMap);
a61af66fc99e Initial load
duke
parents:
diff changeset
936 StateInfo *blockstates = (StateInfo *) arena->Amalloc(_methodBlocks->num_blocks() * sizeof(StateInfo));
a61af66fc99e Initial load
duke
parents:
diff changeset
937 ArgumentMap *statedata = (ArgumentMap *) arena->Amalloc(datasize);
a61af66fc99e Initial load
duke
parents:
diff changeset
938 for (int i = 0; i < datacount; i++) ::new ((void*)&statedata[i]) ArgumentMap();
a61af66fc99e Initial load
duke
parents:
diff changeset
939 ArgumentMap *dp = statedata;
a61af66fc99e Initial load
duke
parents:
diff changeset
940 state._vars = dp;
a61af66fc99e Initial load
duke
parents:
diff changeset
941 dp += numLocals;
a61af66fc99e Initial load
duke
parents:
diff changeset
942 state._stack = dp;
a61af66fc99e Initial load
duke
parents:
diff changeset
943 dp += stkSize;
a61af66fc99e Initial load
duke
parents:
diff changeset
944 state._initialized = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
945 state._max_stack = stkSize;
a61af66fc99e Initial load
duke
parents:
diff changeset
946 for (int i = 0; i < numblocks; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
947 blockstates[i]._vars = dp;
a61af66fc99e Initial load
duke
parents:
diff changeset
948 dp += numLocals;
a61af66fc99e Initial load
duke
parents:
diff changeset
949 blockstates[i]._stack = dp;
a61af66fc99e Initial load
duke
parents:
diff changeset
950 dp += stkSize;
a61af66fc99e Initial load
duke
parents:
diff changeset
951 blockstates[i]._initialized = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
952 blockstates[i]._stack_height = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
953 blockstates[i]._max_stack = stkSize;
a61af66fc99e Initial load
duke
parents:
diff changeset
954 }
a61af66fc99e Initial load
duke
parents:
diff changeset
955 GrowableArray<ciBlock *> worklist(arena, numblocks / 4, 0, NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
956 GrowableArray<ciBlock *> successors(arena, 4, 0, NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
957
a61af66fc99e Initial load
duke
parents:
diff changeset
958 _methodBlocks->clear_processed();
a61af66fc99e Initial load
duke
parents:
diff changeset
959
a61af66fc99e Initial load
duke
parents:
diff changeset
960 // initialize block 0 state from method signature
a61af66fc99e Initial load
duke
parents:
diff changeset
961 ArgumentMap allVars; // all oop arguments to method
a61af66fc99e Initial load
duke
parents:
diff changeset
962 ciSignature* sig = method()->signature();
a61af66fc99e Initial load
duke
parents:
diff changeset
963 int j = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
964 if (!method()->is_static()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
965 // record information for "this"
a61af66fc99e Initial load
duke
parents:
diff changeset
966 blockstates[0]._vars[j].set(j);
a61af66fc99e Initial load
duke
parents:
diff changeset
967 allVars.add(j);
a61af66fc99e Initial load
duke
parents:
diff changeset
968 j++;
a61af66fc99e Initial load
duke
parents:
diff changeset
969 }
a61af66fc99e Initial load
duke
parents:
diff changeset
970 for (int i = 0; i < sig->count(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
971 ciType* t = sig->type_at(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
972 if (!t->is_primitive_type()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
973 blockstates[0]._vars[j].set(j);
a61af66fc99e Initial load
duke
parents:
diff changeset
974 allVars.add(j);
a61af66fc99e Initial load
duke
parents:
diff changeset
975 }
a61af66fc99e Initial load
duke
parents:
diff changeset
976 j += t->size();
a61af66fc99e Initial load
duke
parents:
diff changeset
977 }
a61af66fc99e Initial load
duke
parents:
diff changeset
978 blockstates[0]._initialized = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
979 assert(j == _arg_size, "just checking");
a61af66fc99e Initial load
duke
parents:
diff changeset
980
a61af66fc99e Initial load
duke
parents:
diff changeset
981 ArgumentMap unknown_map;
a61af66fc99e Initial load
duke
parents:
diff changeset
982 unknown_map.add_unknown();
a61af66fc99e Initial load
duke
parents:
diff changeset
983
a61af66fc99e Initial load
duke
parents:
diff changeset
984 worklist.push(_methodBlocks->block_containing(0));
a61af66fc99e Initial load
duke
parents:
diff changeset
985 while(worklist.length() > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
986 ciBlock *blk = worklist.pop();
a61af66fc99e Initial load
duke
parents:
diff changeset
987 StateInfo *blkState = blockstates+blk->index();
a61af66fc99e Initial load
duke
parents:
diff changeset
988 if (blk->is_handler() || blk->is_ret_target()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
989 // for an exception handler or a target of a ret instruction, we assume the worst case,
a61af66fc99e Initial load
duke
parents:
diff changeset
990 // that any variable or stack slot could contain any argument
a61af66fc99e Initial load
duke
parents:
diff changeset
991 for (int i = 0; i < numLocals; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
992 state._vars[i] = allVars;
a61af66fc99e Initial load
duke
parents:
diff changeset
993 }
a61af66fc99e Initial load
duke
parents:
diff changeset
994 if (blk->is_handler()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
995 state._stack_height = 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
996 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
997 state._stack_height = blkState->_stack_height;
a61af66fc99e Initial load
duke
parents:
diff changeset
998 }
a61af66fc99e Initial load
duke
parents:
diff changeset
999 for (int i = 0; i < state._stack_height; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1000 state._stack[i] = allVars;
a61af66fc99e Initial load
duke
parents:
diff changeset
1001 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1002 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1003 for (int i = 0; i < numLocals; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1004 state._vars[i] = blkState->_vars[i];
a61af66fc99e Initial load
duke
parents:
diff changeset
1005 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1006 for (int i = 0; i < blkState->_stack_height; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1007 state._stack[i] = blkState->_stack[i];
a61af66fc99e Initial load
duke
parents:
diff changeset
1008 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1009 state._stack_height = blkState->_stack_height;
a61af66fc99e Initial load
duke
parents:
diff changeset
1010 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1011 iterate_one_block(blk, state, successors);
a61af66fc99e Initial load
duke
parents:
diff changeset
1012 // if this block has any exception handlers, push them
a61af66fc99e Initial load
duke
parents:
diff changeset
1013 // onto successor list
a61af66fc99e Initial load
duke
parents:
diff changeset
1014 if (blk->has_handler()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1015 DEBUG_ONLY(int handler_count = 0;)
a61af66fc99e Initial load
duke
parents:
diff changeset
1016 int blk_start = blk->start_bci();
a61af66fc99e Initial load
duke
parents:
diff changeset
1017 int blk_end = blk->limit_bci();
a61af66fc99e Initial load
duke
parents:
diff changeset
1018 for (int i = 0; i < numblocks; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1019 ciBlock *b = _methodBlocks->block(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
1020 if (b->is_handler()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1021 int ex_start = b->ex_start_bci();
a61af66fc99e Initial load
duke
parents:
diff changeset
1022 int ex_end = b->ex_limit_bci();
a61af66fc99e Initial load
duke
parents:
diff changeset
1023 if ((ex_start >= blk_start && ex_start < blk_end) ||
a61af66fc99e Initial load
duke
parents:
diff changeset
1024 (ex_end > blk_start && ex_end <= blk_end)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1025 successors.push(b);
a61af66fc99e Initial load
duke
parents:
diff changeset
1026 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1027 DEBUG_ONLY(handler_count++;)
a61af66fc99e Initial load
duke
parents:
diff changeset
1028 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1029 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1030 assert(handler_count > 0, "must find at least one handler");
a61af66fc99e Initial load
duke
parents:
diff changeset
1031 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1032 // merge computed variable state with successors
a61af66fc99e Initial load
duke
parents:
diff changeset
1033 while(successors.length() > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1034 ciBlock *succ = successors.pop();
a61af66fc99e Initial load
duke
parents:
diff changeset
1035 merge_block_states(blockstates, succ, &state);
a61af66fc99e Initial load
duke
parents:
diff changeset
1036 if (!succ->processed())
a61af66fc99e Initial load
duke
parents:
diff changeset
1037 worklist.push(succ);
a61af66fc99e Initial load
duke
parents:
diff changeset
1038 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1039 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1040 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1041
a61af66fc99e Initial load
duke
parents:
diff changeset
1042 bool BCEscapeAnalyzer::do_analysis() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1043 Arena* arena = CURRENT_ENV->arena();
a61af66fc99e Initial load
duke
parents:
diff changeset
1044 // identify basic blocks
a61af66fc99e Initial load
duke
parents:
diff changeset
1045 _methodBlocks = _method->get_method_blocks();
a61af66fc99e Initial load
duke
parents:
diff changeset
1046
a61af66fc99e Initial load
duke
parents:
diff changeset
1047 iterate_blocks(arena);
a61af66fc99e Initial load
duke
parents:
diff changeset
1048 // TEMPORARY
a61af66fc99e Initial load
duke
parents:
diff changeset
1049 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
1050 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1051
a61af66fc99e Initial load
duke
parents:
diff changeset
1052 vmIntrinsics::ID BCEscapeAnalyzer::known_intrinsic() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1053 vmIntrinsics::ID iid = method()->intrinsic_id();
a61af66fc99e Initial load
duke
parents:
diff changeset
1054
a61af66fc99e Initial load
duke
parents:
diff changeset
1055 if (iid == vmIntrinsics::_getClass ||
a61af66fc99e Initial load
duke
parents:
diff changeset
1056 iid == vmIntrinsics::_hashCode)
a61af66fc99e Initial load
duke
parents:
diff changeset
1057 return iid;
a61af66fc99e Initial load
duke
parents:
diff changeset
1058 else
a61af66fc99e Initial load
duke
parents:
diff changeset
1059 return vmIntrinsics::_none;
a61af66fc99e Initial load
duke
parents:
diff changeset
1060 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1061
a61af66fc99e Initial load
duke
parents:
diff changeset
1062 bool BCEscapeAnalyzer::compute_escape_for_intrinsic(vmIntrinsics::ID iid) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1063 ArgumentMap empty;
a61af66fc99e Initial load
duke
parents:
diff changeset
1064 empty.clear();
a61af66fc99e Initial load
duke
parents:
diff changeset
1065 switch (iid) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1066 case vmIntrinsics::_getClass:
a61af66fc99e Initial load
duke
parents:
diff changeset
1067 _return_local = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
1068 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1069 case vmIntrinsics::_hashCode:
a61af66fc99e Initial load
duke
parents:
diff changeset
1070 // initialized state is correct
a61af66fc99e Initial load
duke
parents:
diff changeset
1071 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1072 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
1073 assert(false, "unexpected intrinsic");
a61af66fc99e Initial load
duke
parents:
diff changeset
1074 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1075 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
1076 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1077
a61af66fc99e Initial load
duke
parents:
diff changeset
1078 void BCEscapeAnalyzer::initialize() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1079 int i;
a61af66fc99e Initial load
duke
parents:
diff changeset
1080
a61af66fc99e Initial load
duke
parents:
diff changeset
1081 // clear escape information (method may have been deoptimized)
a61af66fc99e Initial load
duke
parents:
diff changeset
1082 methodData()->clear_escape_info();
a61af66fc99e Initial load
duke
parents:
diff changeset
1083
a61af66fc99e Initial load
duke
parents:
diff changeset
1084 // initialize escape state of object parameters
a61af66fc99e Initial load
duke
parents:
diff changeset
1085 ciSignature* sig = method()->signature();
a61af66fc99e Initial load
duke
parents:
diff changeset
1086 int j = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
1087 if (!method()->is_static()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1088 _arg_local.set_bit(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1089 _arg_stack.set_bit(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1090 j++;
a61af66fc99e Initial load
duke
parents:
diff changeset
1091 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1092 for (i = 0; i < sig->count(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1093 ciType* t = sig->type_at(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
1094 if (!t->is_primitive_type()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1095 _arg_local.set_bit(j);
a61af66fc99e Initial load
duke
parents:
diff changeset
1096 _arg_stack.set_bit(j);
a61af66fc99e Initial load
duke
parents:
diff changeset
1097 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1098 j += t->size();
a61af66fc99e Initial load
duke
parents:
diff changeset
1099 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1100 assert(j == _arg_size, "just checking");
a61af66fc99e Initial load
duke
parents:
diff changeset
1101
a61af66fc99e Initial load
duke
parents:
diff changeset
1102 // start with optimistic assumption
a61af66fc99e Initial load
duke
parents:
diff changeset
1103 ciType *rt = _method->return_type();
a61af66fc99e Initial load
duke
parents:
diff changeset
1104 if (rt->is_primitive_type()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1105 _return_local = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
1106 _return_allocated = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
1107 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1108 _return_local = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
1109 _return_allocated = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
1110 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1111 _allocated_escapes = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
1112 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1113
a61af66fc99e Initial load
duke
parents:
diff changeset
1114 void BCEscapeAnalyzer::clear_escape_info() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1115 ciSignature* sig = method()->signature();
a61af66fc99e Initial load
duke
parents:
diff changeset
1116 int arg_count = sig->count();
a61af66fc99e Initial load
duke
parents:
diff changeset
1117 ArgumentMap var;
a61af66fc99e Initial load
duke
parents:
diff changeset
1118 for (int i = 0; i < arg_count; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1119 var.clear();
a61af66fc99e Initial load
duke
parents:
diff changeset
1120 var.set(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
1121 set_global_escape(var);
a61af66fc99e Initial load
duke
parents:
diff changeset
1122 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1123 _arg_local.clear();
a61af66fc99e Initial load
duke
parents:
diff changeset
1124 _arg_stack.clear();
a61af66fc99e Initial load
duke
parents:
diff changeset
1125 _arg_returned.clear();
a61af66fc99e Initial load
duke
parents:
diff changeset
1126 _return_local = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
1127 _return_allocated = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
1128 _allocated_escapes = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
1129 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1130
a61af66fc99e Initial load
duke
parents:
diff changeset
1131
a61af66fc99e Initial load
duke
parents:
diff changeset
1132 void BCEscapeAnalyzer::compute_escape_info() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1133 int i;
a61af66fc99e Initial load
duke
parents:
diff changeset
1134 assert(!methodData()->has_escape_info(), "do not overwrite escape info");
a61af66fc99e Initial load
duke
parents:
diff changeset
1135
a61af66fc99e Initial load
duke
parents:
diff changeset
1136 vmIntrinsics::ID iid = known_intrinsic();
a61af66fc99e Initial load
duke
parents:
diff changeset
1137
a61af66fc99e Initial load
duke
parents:
diff changeset
1138 // check if method can be analyzed
a61af66fc99e Initial load
duke
parents:
diff changeset
1139 if (iid == vmIntrinsics::_none && (method()->is_abstract() || method()->is_native() || !method()->holder()->is_initialized()
a61af66fc99e Initial load
duke
parents:
diff changeset
1140 || _level > MaxBCEAEstimateLevel
a61af66fc99e Initial load
duke
parents:
diff changeset
1141 || method()->code_size() > MaxBCEAEstimateSize)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1142 if (BCEATraceLevel >= 1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1143 tty->print("Skipping method because: ");
a61af66fc99e Initial load
duke
parents:
diff changeset
1144 if (method()->is_abstract())
a61af66fc99e Initial load
duke
parents:
diff changeset
1145 tty->print_cr("method is abstract.");
a61af66fc99e Initial load
duke
parents:
diff changeset
1146 else if (method()->is_native())
a61af66fc99e Initial load
duke
parents:
diff changeset
1147 tty->print_cr("method is native.");
a61af66fc99e Initial load
duke
parents:
diff changeset
1148 else if (!method()->holder()->is_initialized())
a61af66fc99e Initial load
duke
parents:
diff changeset
1149 tty->print_cr("class of method is not initialized.");
a61af66fc99e Initial load
duke
parents:
diff changeset
1150 else if (_level > MaxBCEAEstimateLevel)
a61af66fc99e Initial load
duke
parents:
diff changeset
1151 tty->print_cr("level (%d) exceeds MaxBCEAEstimateLevel (%d).",
a61af66fc99e Initial load
duke
parents:
diff changeset
1152 _level, MaxBCEAEstimateLevel);
a61af66fc99e Initial load
duke
parents:
diff changeset
1153 else if (method()->code_size() > MaxBCEAEstimateSize)
a61af66fc99e Initial load
duke
parents:
diff changeset
1154 tty->print_cr("code size (%d) exceeds MaxBCEAEstimateSize.",
a61af66fc99e Initial load
duke
parents:
diff changeset
1155 method()->code_size(), MaxBCEAEstimateSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
1156 else
a61af66fc99e Initial load
duke
parents:
diff changeset
1157 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1158 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1159 clear_escape_info();
a61af66fc99e Initial load
duke
parents:
diff changeset
1160
a61af66fc99e Initial load
duke
parents:
diff changeset
1161 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
1162 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1163
a61af66fc99e Initial load
duke
parents:
diff changeset
1164 if (BCEATraceLevel >= 1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1165 tty->print("[EA] estimating escape information for");
a61af66fc99e Initial load
duke
parents:
diff changeset
1166 if (iid != vmIntrinsics::_none)
a61af66fc99e Initial load
duke
parents:
diff changeset
1167 tty->print(" intrinsic");
a61af66fc99e Initial load
duke
parents:
diff changeset
1168 method()->print_short_name();
a61af66fc99e Initial load
duke
parents:
diff changeset
1169 tty->print_cr(" (%d bytes)", method()->code_size());
a61af66fc99e Initial load
duke
parents:
diff changeset
1170 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1171
a61af66fc99e Initial load
duke
parents:
diff changeset
1172 bool success;
a61af66fc99e Initial load
duke
parents:
diff changeset
1173
a61af66fc99e Initial load
duke
parents:
diff changeset
1174 initialize();
a61af66fc99e Initial load
duke
parents:
diff changeset
1175
a61af66fc99e Initial load
duke
parents:
diff changeset
1176 // do not scan method if it has no object parameters
a61af66fc99e Initial load
duke
parents:
diff changeset
1177 if (_arg_local.is_empty()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1178 methodData()->set_eflag(methodDataOopDesc::estimated);
a61af66fc99e Initial load
duke
parents:
diff changeset
1179 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
1180 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1181
a61af66fc99e Initial load
duke
parents:
diff changeset
1182 if (iid != vmIntrinsics::_none)
a61af66fc99e Initial load
duke
parents:
diff changeset
1183 success = compute_escape_for_intrinsic(iid);
a61af66fc99e Initial load
duke
parents:
diff changeset
1184 else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1185 success = do_analysis();
a61af66fc99e Initial load
duke
parents:
diff changeset
1186 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1187
a61af66fc99e Initial load
duke
parents:
diff changeset
1188 // dump result of bytecode analysis
a61af66fc99e Initial load
duke
parents:
diff changeset
1189 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
1190 if (BCEATraceLevel >= 3) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1191 tty->print("[EA] estimated escape information for");
a61af66fc99e Initial load
duke
parents:
diff changeset
1192 if (iid != vmIntrinsics::_none)
a61af66fc99e Initial load
duke
parents:
diff changeset
1193 tty->print(" intrinsic");
a61af66fc99e Initial load
duke
parents:
diff changeset
1194 method()->print_short_name();
a61af66fc99e Initial load
duke
parents:
diff changeset
1195 tty->print_cr(has_dependencies() ? " (not stored)" : "");
a61af66fc99e Initial load
duke
parents:
diff changeset
1196 tty->print(" non-escaping args: ");
a61af66fc99e Initial load
duke
parents:
diff changeset
1197 _arg_local.print_on(tty);
a61af66fc99e Initial load
duke
parents:
diff changeset
1198 tty->print(" stack-allocatable args: ");
a61af66fc99e Initial load
duke
parents:
diff changeset
1199 _arg_stack.print_on(tty);
a61af66fc99e Initial load
duke
parents:
diff changeset
1200 if (_return_local) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1201 tty->print(" returned args: ");
a61af66fc99e Initial load
duke
parents:
diff changeset
1202 _arg_returned.print_on(tty);
a61af66fc99e Initial load
duke
parents:
diff changeset
1203 } else if (is_return_allocated()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1204 tty->print_cr(" allocated return values");
a61af66fc99e Initial load
duke
parents:
diff changeset
1205 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1206 tty->print_cr(" non-local return values");
a61af66fc99e Initial load
duke
parents:
diff changeset
1207 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1208 tty->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
1209 tty->print(" flags: ");
a61af66fc99e Initial load
duke
parents:
diff changeset
1210 if (_return_allocated)
a61af66fc99e Initial load
duke
parents:
diff changeset
1211 tty->print(" return_allocated");
a61af66fc99e Initial load
duke
parents:
diff changeset
1212 tty->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
1213 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1214
a61af66fc99e Initial load
duke
parents:
diff changeset
1215 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
1216 // don't store interprocedural escape information if it introduces dependencies
a61af66fc99e Initial load
duke
parents:
diff changeset
1217 // or if method data is empty
a61af66fc99e Initial load
duke
parents:
diff changeset
1218 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1219 if (!has_dependencies() && !methodData()->is_empty()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1220 for (i = 0; i < _arg_size; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1221 if (_arg_local.at(i)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1222 assert(_arg_stack.at(i), "inconsistent escape info");
a61af66fc99e Initial load
duke
parents:
diff changeset
1223 methodData()->set_arg_local(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
1224 methodData()->set_arg_stack(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
1225 } else if (_arg_stack.at(i)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1226 methodData()->set_arg_stack(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
1227 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1228 if (_arg_returned.at(i)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1229 methodData()->set_arg_returned(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
1230 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1231 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1232 if (_return_local) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1233 methodData()->set_eflag(methodDataOopDesc::return_local);
a61af66fc99e Initial load
duke
parents:
diff changeset
1234 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1235 methodData()->set_eflag(methodDataOopDesc::estimated);
a61af66fc99e Initial load
duke
parents:
diff changeset
1236 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1237 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1238
a61af66fc99e Initial load
duke
parents:
diff changeset
1239 void BCEscapeAnalyzer::read_escape_info() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1240 assert(methodData()->has_escape_info(), "no escape info available");
a61af66fc99e Initial load
duke
parents:
diff changeset
1241
a61af66fc99e Initial load
duke
parents:
diff changeset
1242 // read escape information from method descriptor
a61af66fc99e Initial load
duke
parents:
diff changeset
1243 for (int i = 0; i < _arg_size; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1244 _arg_local.at_put(i, methodData()->is_arg_local(i));
a61af66fc99e Initial load
duke
parents:
diff changeset
1245 _arg_stack.at_put(i, methodData()->is_arg_stack(i));
a61af66fc99e Initial load
duke
parents:
diff changeset
1246 _arg_returned.at_put(i, methodData()->is_arg_returned(i));
a61af66fc99e Initial load
duke
parents:
diff changeset
1247 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1248 _return_local = methodData()->eflag_set(methodDataOopDesc::return_local);
a61af66fc99e Initial load
duke
parents:
diff changeset
1249
a61af66fc99e Initial load
duke
parents:
diff changeset
1250 // dump result of loaded escape information
a61af66fc99e Initial load
duke
parents:
diff changeset
1251 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
1252 if (BCEATraceLevel >= 4) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1253 tty->print(" non-escaping args: ");
a61af66fc99e Initial load
duke
parents:
diff changeset
1254 _arg_local.print_on(tty);
a61af66fc99e Initial load
duke
parents:
diff changeset
1255 tty->print(" stack-allocatable args: ");
a61af66fc99e Initial load
duke
parents:
diff changeset
1256 _arg_stack.print_on(tty);
a61af66fc99e Initial load
duke
parents:
diff changeset
1257 if (_return_local) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1258 tty->print(" returned args: ");
a61af66fc99e Initial load
duke
parents:
diff changeset
1259 _arg_returned.print_on(tty);
a61af66fc99e Initial load
duke
parents:
diff changeset
1260 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1261 tty->print_cr(" non-local return values");
a61af66fc99e Initial load
duke
parents:
diff changeset
1262 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1263 tty->print(" modified args: ");
a61af66fc99e Initial load
duke
parents:
diff changeset
1264 tty->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
1265 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1266 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
1267
a61af66fc99e Initial load
duke
parents:
diff changeset
1268 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1269
a61af66fc99e Initial load
duke
parents:
diff changeset
1270
a61af66fc99e Initial load
duke
parents:
diff changeset
1271 BCEscapeAnalyzer::BCEscapeAnalyzer(ciMethod* method, BCEscapeAnalyzer* parent)
a61af66fc99e Initial load
duke
parents:
diff changeset
1272 : _conservative(method == NULL || !EstimateArgEscape)
a61af66fc99e Initial load
duke
parents:
diff changeset
1273 , _method(method)
a61af66fc99e Initial load
duke
parents:
diff changeset
1274 , _methodData(method ? method->method_data() : NULL)
a61af66fc99e Initial load
duke
parents:
diff changeset
1275 , _arg_size(method ? method->arg_size() : 0)
a61af66fc99e Initial load
duke
parents:
diff changeset
1276 , _stack()
a61af66fc99e Initial load
duke
parents:
diff changeset
1277 , _arg_local(_arg_size)
a61af66fc99e Initial load
duke
parents:
diff changeset
1278 , _arg_stack(_arg_size)
a61af66fc99e Initial load
duke
parents:
diff changeset
1279 , _arg_returned(_arg_size)
a61af66fc99e Initial load
duke
parents:
diff changeset
1280 , _dirty(_arg_size)
a61af66fc99e Initial load
duke
parents:
diff changeset
1281 , _return_local(false)
a61af66fc99e Initial load
duke
parents:
diff changeset
1282 , _return_allocated(false)
a61af66fc99e Initial load
duke
parents:
diff changeset
1283 , _allocated_escapes(false)
a61af66fc99e Initial load
duke
parents:
diff changeset
1284 , _dependencies()
a61af66fc99e Initial load
duke
parents:
diff changeset
1285 , _parent(parent)
a61af66fc99e Initial load
duke
parents:
diff changeset
1286 , _level(parent == NULL ? 0 : parent->level() + 1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1287 if (!_conservative) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1288 _arg_local.clear();
a61af66fc99e Initial load
duke
parents:
diff changeset
1289 _arg_stack.clear();
a61af66fc99e Initial load
duke
parents:
diff changeset
1290 _arg_returned.clear();
a61af66fc99e Initial load
duke
parents:
diff changeset
1291 _dirty.clear();
a61af66fc99e Initial load
duke
parents:
diff changeset
1292 Arena* arena = CURRENT_ENV->arena();
a61af66fc99e Initial load
duke
parents:
diff changeset
1293
a61af66fc99e Initial load
duke
parents:
diff changeset
1294 if (methodData() == NULL)
a61af66fc99e Initial load
duke
parents:
diff changeset
1295 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
1296 bool printit = _method->should_print_assembly();
a61af66fc99e Initial load
duke
parents:
diff changeset
1297 if (methodData()->has_escape_info()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1298 TRACE_BCEA(2, tty->print_cr("[EA] Reading previous results for %s.%s",
a61af66fc99e Initial load
duke
parents:
diff changeset
1299 method->holder()->name()->as_utf8(),
a61af66fc99e Initial load
duke
parents:
diff changeset
1300 method->name()->as_utf8()));
a61af66fc99e Initial load
duke
parents:
diff changeset
1301 read_escape_info();
a61af66fc99e Initial load
duke
parents:
diff changeset
1302 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1303 TRACE_BCEA(2, tty->print_cr("[EA] computing results for %s.%s",
a61af66fc99e Initial load
duke
parents:
diff changeset
1304 method->holder()->name()->as_utf8(),
a61af66fc99e Initial load
duke
parents:
diff changeset
1305 method->name()->as_utf8()));
a61af66fc99e Initial load
duke
parents:
diff changeset
1306
a61af66fc99e Initial load
duke
parents:
diff changeset
1307 compute_escape_info();
a61af66fc99e Initial load
duke
parents:
diff changeset
1308 methodData()->update_escape_info();
a61af66fc99e Initial load
duke
parents:
diff changeset
1309 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1310 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1311 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1312
a61af66fc99e Initial load
duke
parents:
diff changeset
1313 void BCEscapeAnalyzer::copy_dependencies(Dependencies *deps) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1314 if(!has_dependencies())
a61af66fc99e Initial load
duke
parents:
diff changeset
1315 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
1316 for (int i = 0; i < _dependencies.length(); i+=2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1317 ciKlass *k = _dependencies[i]->as_klass();
a61af66fc99e Initial load
duke
parents:
diff changeset
1318 ciMethod *m = _dependencies[i+1]->as_method();
a61af66fc99e Initial load
duke
parents:
diff changeset
1319 deps->assert_unique_concrete_method(k, m);
a61af66fc99e Initial load
duke
parents:
diff changeset
1320 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1321 }