1
|
1 |
/*
|
|
2 |
* Copyright 1998-2007 Sun Microsystems, Inc. All Rights Reserved.
|
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
|
7 |
* published by the Free Software Foundation.
|
|
8 |
*
|
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
13 |
* accompanied this code).
|
|
14 |
*
|
|
15 |
* You should have received a copy of the GNU General Public License version
|
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
18 |
*
|
|
19 |
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
|
20 |
* CA 95054 USA or visit www.sun.com if you need additional information or
|
|
21 |
* have any questions.
|
|
22 |
*
|
|
23 |
*/
|
|
24 |
|
|
25 |
#include "incls/_precompiled.incl"
|
|
26 |
#include "incls/_parse2.cpp.incl"
|
|
27 |
|
|
28 |
extern int explicit_null_checks_inserted,
|
|
29 |
explicit_null_checks_elided;
|
|
30 |
|
|
31 |
//---------------------------------array_load----------------------------------
|
|
32 |
void Parse::array_load(BasicType elem_type) {
|
|
33 |
const Type* elem = Type::TOP;
|
|
34 |
Node* adr = array_addressing(elem_type, 0, &elem);
|
|
35 |
if (stopped()) return; // guarenteed null or range check
|
|
36 |
_sp -= 2; // Pop array and index
|
|
37 |
const TypeAryPtr* adr_type = TypeAryPtr::get_array_body_type(elem_type);
|
|
38 |
Node* ld = make_load(control(), adr, elem, elem_type, adr_type);
|
|
39 |
push(ld);
|
|
40 |
}
|
|
41 |
|
|
42 |
|
|
43 |
//--------------------------------array_store----------------------------------
|
|
44 |
void Parse::array_store(BasicType elem_type) {
|
|
45 |
Node* adr = array_addressing(elem_type, 1);
|
|
46 |
if (stopped()) return; // guarenteed null or range check
|
|
47 |
Node* val = pop();
|
|
48 |
_sp -= 2; // Pop array and index
|
|
49 |
const TypeAryPtr* adr_type = TypeAryPtr::get_array_body_type(elem_type);
|
|
50 |
store_to_memory(control(), adr, val, elem_type, adr_type);
|
|
51 |
}
|
|
52 |
|
|
53 |
|
|
54 |
//------------------------------array_addressing-------------------------------
|
|
55 |
// Pull array and index from the stack. Compute pointer-to-element.
|
|
56 |
Node* Parse::array_addressing(BasicType type, int vals, const Type* *result2) {
|
|
57 |
Node *idx = peek(0+vals); // Get from stack without popping
|
|
58 |
Node *ary = peek(1+vals); // in case of exception
|
|
59 |
|
|
60 |
// Null check the array base, with correct stack contents
|
|
61 |
ary = do_null_check(ary, T_ARRAY);
|
|
62 |
// Compile-time detect of null-exception?
|
|
63 |
if (stopped()) return top();
|
|
64 |
|
|
65 |
const TypeAryPtr* arytype = _gvn.type(ary)->is_aryptr();
|
|
66 |
const TypeInt* sizetype = arytype->size();
|
|
67 |
const Type* elemtype = arytype->elem();
|
|
68 |
|
|
69 |
if (UseUniqueSubclasses && result2 != NULL) {
|
|
70 |
const TypeInstPtr* toop = elemtype->isa_instptr();
|
|
71 |
if (toop) {
|
|
72 |
if (toop->klass()->as_instance_klass()->unique_concrete_subklass()) {
|
|
73 |
// If we load from "AbstractClass[]" we must see "ConcreteSubClass".
|
|
74 |
const Type* subklass = Type::get_const_type(toop->klass());
|
|
75 |
elemtype = subklass->join(elemtype);
|
|
76 |
}
|
|
77 |
}
|
|
78 |
}
|
|
79 |
|
|
80 |
// Check for big class initializers with all constant offsets
|
|
81 |
// feeding into a known-size array.
|
|
82 |
const TypeInt* idxtype = _gvn.type(idx)->is_int();
|
|
83 |
// See if the highest idx value is less than the lowest array bound,
|
|
84 |
// and if the idx value cannot be negative:
|
|
85 |
bool need_range_check = true;
|
|
86 |
if (idxtype->_hi < sizetype->_lo && idxtype->_lo >= 0) {
|
|
87 |
need_range_check = false;
|
|
88 |
if (C->log() != NULL) C->log()->elem("observe that='!need_range_check'");
|
|
89 |
}
|
|
90 |
|
|
91 |
if (!arytype->klass()->is_loaded()) {
|
|
92 |
// Only fails for some -Xcomp runs
|
|
93 |
// The class is unloaded. We have to run this bytecode in the interpreter.
|
|
94 |
uncommon_trap(Deoptimization::Reason_unloaded,
|
|
95 |
Deoptimization::Action_reinterpret,
|
|
96 |
arytype->klass(), "!loaded array");
|
|
97 |
return top();
|
|
98 |
}
|
|
99 |
|
|
100 |
// Do the range check
|
|
101 |
if (GenerateRangeChecks && need_range_check) {
|
|
102 |
// Range is constant in array-oop, so we can use the original state of mem
|
|
103 |
Node* len = load_array_length(ary);
|
|
104 |
// Test length vs index (standard trick using unsigned compare)
|
|
105 |
Node* chk = _gvn.transform( new (C, 3) CmpUNode(idx, len) );
|
|
106 |
BoolTest::mask btest = BoolTest::lt;
|
|
107 |
Node* tst = _gvn.transform( new (C, 2) BoolNode(chk, btest) );
|
|
108 |
// Branch to failure if out of bounds
|
|
109 |
{ BuildCutout unless(this, tst, PROB_MAX);
|
|
110 |
if (C->allow_range_check_smearing()) {
|
|
111 |
// Do not use builtin_throw, since range checks are sometimes
|
|
112 |
// made more stringent by an optimistic transformation.
|
|
113 |
// This creates "tentative" range checks at this point,
|
|
114 |
// which are not guaranteed to throw exceptions.
|
|
115 |
// See IfNode::Ideal, is_range_check, adjust_check.
|
|
116 |
uncommon_trap(Deoptimization::Reason_range_check,
|
|
117 |
Deoptimization::Action_make_not_entrant,
|
|
118 |
NULL, "range_check");
|
|
119 |
} else {
|
|
120 |
// If we have already recompiled with the range-check-widening
|
|
121 |
// heroic optimization turned off, then we must really be throwing
|
|
122 |
// range check exceptions.
|
|
123 |
builtin_throw(Deoptimization::Reason_range_check, idx);
|
|
124 |
}
|
|
125 |
}
|
|
126 |
}
|
|
127 |
// Check for always knowing you are throwing a range-check exception
|
|
128 |
if (stopped()) return top();
|
|
129 |
|
|
130 |
Node* ptr = array_element_address( ary, idx, type, sizetype);
|
|
131 |
|
|
132 |
if (result2 != NULL) *result2 = elemtype;
|
|
133 |
return ptr;
|
|
134 |
}
|
|
135 |
|
|
136 |
|
|
137 |
// returns IfNode
|
|
138 |
IfNode* Parse::jump_if_fork_int(Node* a, Node* b, BoolTest::mask mask) {
|
|
139 |
Node *cmp = _gvn.transform( new (C, 3) CmpINode( a, b)); // two cases: shiftcount > 32 and shiftcount <= 32
|
|
140 |
Node *tst = _gvn.transform( new (C, 2) BoolNode( cmp, mask));
|
|
141 |
IfNode *iff = create_and_map_if( control(), tst, ((mask == BoolTest::eq) ? PROB_STATIC_INFREQUENT : PROB_FAIR), COUNT_UNKNOWN );
|
|
142 |
return iff;
|
|
143 |
}
|
|
144 |
|
|
145 |
// return Region node
|
|
146 |
Node* Parse::jump_if_join(Node* iffalse, Node* iftrue) {
|
|
147 |
Node *region = new (C, 3) RegionNode(3); // 2 results
|
|
148 |
record_for_igvn(region);
|
|
149 |
region->init_req(1, iffalse);
|
|
150 |
region->init_req(2, iftrue );
|
|
151 |
_gvn.set_type(region, Type::CONTROL);
|
|
152 |
region = _gvn.transform(region);
|
|
153 |
set_control (region);
|
|
154 |
return region;
|
|
155 |
}
|
|
156 |
|
|
157 |
|
|
158 |
//------------------------------helper for tableswitch-------------------------
|
|
159 |
void Parse::jump_if_true_fork(IfNode *iff, int dest_bci_if_true, int prof_table_index) {
|
|
160 |
// True branch, use existing map info
|
|
161 |
{ PreserveJVMState pjvms(this);
|
|
162 |
Node *iftrue = _gvn.transform( new (C, 1) IfTrueNode (iff) );
|
|
163 |
set_control( iftrue );
|
|
164 |
profile_switch_case(prof_table_index);
|
|
165 |
merge_new_path(dest_bci_if_true);
|
|
166 |
}
|
|
167 |
|
|
168 |
// False branch
|
|
169 |
Node *iffalse = _gvn.transform( new (C, 1) IfFalseNode(iff) );
|
|
170 |
set_control( iffalse );
|
|
171 |
}
|
|
172 |
|
|
173 |
void Parse::jump_if_false_fork(IfNode *iff, int dest_bci_if_true, int prof_table_index) {
|
|
174 |
// True branch, use existing map info
|
|
175 |
{ PreserveJVMState pjvms(this);
|
|
176 |
Node *iffalse = _gvn.transform( new (C, 1) IfFalseNode (iff) );
|
|
177 |
set_control( iffalse );
|
|
178 |
profile_switch_case(prof_table_index);
|
|
179 |
merge_new_path(dest_bci_if_true);
|
|
180 |
}
|
|
181 |
|
|
182 |
// False branch
|
|
183 |
Node *iftrue = _gvn.transform( new (C, 1) IfTrueNode(iff) );
|
|
184 |
set_control( iftrue );
|
|
185 |
}
|
|
186 |
|
|
187 |
void Parse::jump_if_always_fork(int dest_bci, int prof_table_index) {
|
|
188 |
// False branch, use existing map and control()
|
|
189 |
profile_switch_case(prof_table_index);
|
|
190 |
merge_new_path(dest_bci);
|
|
191 |
}
|
|
192 |
|
|
193 |
|
|
194 |
extern "C" {
|
|
195 |
static int jint_cmp(const void *i, const void *j) {
|
|
196 |
int a = *(jint *)i;
|
|
197 |
int b = *(jint *)j;
|
|
198 |
return a > b ? 1 : a < b ? -1 : 0;
|
|
199 |
}
|
|
200 |
}
|
|
201 |
|
|
202 |
|
|
203 |
// Default value for methodData switch indexing. Must be a negative value to avoid
|
|
204 |
// conflict with any legal switch index.
|
|
205 |
#define NullTableIndex -1
|
|
206 |
|
|
207 |
class SwitchRange : public StackObj {
|
|
208 |
// a range of integers coupled with a bci destination
|
|
209 |
jint _lo; // inclusive lower limit
|
|
210 |
jint _hi; // inclusive upper limit
|
|
211 |
int _dest;
|
|
212 |
int _table_index; // index into method data table
|
|
213 |
|
|
214 |
public:
|
|
215 |
jint lo() const { return _lo; }
|
|
216 |
jint hi() const { return _hi; }
|
|
217 |
int dest() const { return _dest; }
|
|
218 |
int table_index() const { return _table_index; }
|
|
219 |
bool is_singleton() const { return _lo == _hi; }
|
|
220 |
|
|
221 |
void setRange(jint lo, jint hi, int dest, int table_index) {
|
|
222 |
assert(lo <= hi, "must be a non-empty range");
|
|
223 |
_lo = lo, _hi = hi; _dest = dest; _table_index = table_index;
|
|
224 |
}
|
|
225 |
bool adjoinRange(jint lo, jint hi, int dest, int table_index) {
|
|
226 |
assert(lo <= hi, "must be a non-empty range");
|
|
227 |
if (lo == _hi+1 && dest == _dest && table_index == _table_index) {
|
|
228 |
_hi = hi;
|
|
229 |
return true;
|
|
230 |
}
|
|
231 |
return false;
|
|
232 |
}
|
|
233 |
|
|
234 |
void set (jint value, int dest, int table_index) {
|
|
235 |
setRange(value, value, dest, table_index);
|
|
236 |
}
|
|
237 |
bool adjoin(jint value, int dest, int table_index) {
|
|
238 |
return adjoinRange(value, value, dest, table_index);
|
|
239 |
}
|
|
240 |
|
|
241 |
void print(ciEnv* env) {
|
|
242 |
if (is_singleton())
|
|
243 |
tty->print(" {%d}=>%d", lo(), dest());
|
|
244 |
else if (lo() == min_jint)
|
|
245 |
tty->print(" {..%d}=>%d", hi(), dest());
|
|
246 |
else if (hi() == max_jint)
|
|
247 |
tty->print(" {%d..}=>%d", lo(), dest());
|
|
248 |
else
|
|
249 |
tty->print(" {%d..%d}=>%d", lo(), hi(), dest());
|
|
250 |
}
|
|
251 |
};
|
|
252 |
|
|
253 |
|
|
254 |
//-------------------------------do_tableswitch--------------------------------
|
|
255 |
void Parse::do_tableswitch() {
|
|
256 |
Node* lookup = pop();
|
|
257 |
|
|
258 |
// Get information about tableswitch
|
|
259 |
int default_dest = iter().get_dest_table(0);
|
|
260 |
int lo_index = iter().get_int_table(1);
|
|
261 |
int hi_index = iter().get_int_table(2);
|
|
262 |
int len = hi_index - lo_index + 1;
|
|
263 |
|
|
264 |
if (len < 1) {
|
|
265 |
// If this is a backward branch, add safepoint
|
|
266 |
maybe_add_safepoint(default_dest);
|
|
267 |
merge(default_dest);
|
|
268 |
return;
|
|
269 |
}
|
|
270 |
|
|
271 |
// generate decision tree, using trichotomy when possible
|
|
272 |
int rnum = len+2;
|
|
273 |
bool makes_backward_branch = false;
|
|
274 |
SwitchRange* ranges = NEW_RESOURCE_ARRAY(SwitchRange, rnum);
|
|
275 |
int rp = -1;
|
|
276 |
if (lo_index != min_jint) {
|
|
277 |
ranges[++rp].setRange(min_jint, lo_index-1, default_dest, NullTableIndex);
|
|
278 |
}
|
|
279 |
for (int j = 0; j < len; j++) {
|
|
280 |
jint match_int = lo_index+j;
|
|
281 |
int dest = iter().get_dest_table(j+3);
|
|
282 |
makes_backward_branch |= (dest <= bci());
|
|
283 |
int table_index = method_data_update() ? j : NullTableIndex;
|
|
284 |
if (rp < 0 || !ranges[rp].adjoin(match_int, dest, table_index)) {
|
|
285 |
ranges[++rp].set(match_int, dest, table_index);
|
|
286 |
}
|
|
287 |
}
|
|
288 |
jint highest = lo_index+(len-1);
|
|
289 |
assert(ranges[rp].hi() == highest, "");
|
|
290 |
if (highest != max_jint
|
|
291 |
&& !ranges[rp].adjoinRange(highest+1, max_jint, default_dest, NullTableIndex)) {
|
|
292 |
ranges[++rp].setRange(highest+1, max_jint, default_dest, NullTableIndex);
|
|
293 |
}
|
|
294 |
assert(rp < len+2, "not too many ranges");
|
|
295 |
|
|
296 |
// Safepoint in case if backward branch observed
|
|
297 |
if( makes_backward_branch && UseLoopSafepoints )
|
|
298 |
add_safepoint();
|
|
299 |
|
|
300 |
jump_switch_ranges(lookup, &ranges[0], &ranges[rp]);
|
|
301 |
}
|
|
302 |
|
|
303 |
|
|
304 |
//------------------------------do_lookupswitch--------------------------------
|
|
305 |
void Parse::do_lookupswitch() {
|
|
306 |
Node *lookup = pop(); // lookup value
|
|
307 |
// Get information about lookupswitch
|
|
308 |
int default_dest = iter().get_dest_table(0);
|
|
309 |
int len = iter().get_int_table(1);
|
|
310 |
|
|
311 |
if (len < 1) { // If this is a backward branch, add safepoint
|
|
312 |
maybe_add_safepoint(default_dest);
|
|
313 |
merge(default_dest);
|
|
314 |
return;
|
|
315 |
}
|
|
316 |
|
|
317 |
// generate decision tree, using trichotomy when possible
|
|
318 |
jint* table = NEW_RESOURCE_ARRAY(jint, len*2);
|
|
319 |
{
|
|
320 |
for( int j = 0; j < len; j++ ) {
|
|
321 |
table[j+j+0] = iter().get_int_table(2+j+j);
|
|
322 |
table[j+j+1] = iter().get_dest_table(2+j+j+1);
|
|
323 |
}
|
|
324 |
qsort( table, len, 2*sizeof(table[0]), jint_cmp );
|
|
325 |
}
|
|
326 |
|
|
327 |
int rnum = len*2+1;
|
|
328 |
bool makes_backward_branch = false;
|
|
329 |
SwitchRange* ranges = NEW_RESOURCE_ARRAY(SwitchRange, rnum);
|
|
330 |
int rp = -1;
|
|
331 |
for( int j = 0; j < len; j++ ) {
|
|
332 |
jint match_int = table[j+j+0];
|
|
333 |
int dest = table[j+j+1];
|
|
334 |
int next_lo = rp < 0 ? min_jint : ranges[rp].hi()+1;
|
|
335 |
int table_index = method_data_update() ? j : NullTableIndex;
|
|
336 |
makes_backward_branch |= (dest <= bci());
|
|
337 |
if( match_int != next_lo ) {
|
|
338 |
ranges[++rp].setRange(next_lo, match_int-1, default_dest, NullTableIndex);
|
|
339 |
}
|
|
340 |
if( rp < 0 || !ranges[rp].adjoin(match_int, dest, table_index) ) {
|
|
341 |
ranges[++rp].set(match_int, dest, table_index);
|
|
342 |
}
|
|
343 |
}
|
|
344 |
jint highest = table[2*(len-1)];
|
|
345 |
assert(ranges[rp].hi() == highest, "");
|
|
346 |
if( highest != max_jint
|
|
347 |
&& !ranges[rp].adjoinRange(highest+1, max_jint, default_dest, NullTableIndex) ) {
|
|
348 |
ranges[++rp].setRange(highest+1, max_jint, default_dest, NullTableIndex);
|
|
349 |
}
|
|
350 |
assert(rp < rnum, "not too many ranges");
|
|
351 |
|
|
352 |
// Safepoint in case backward branch observed
|
|
353 |
if( makes_backward_branch && UseLoopSafepoints )
|
|
354 |
add_safepoint();
|
|
355 |
|
|
356 |
jump_switch_ranges(lookup, &ranges[0], &ranges[rp]);
|
|
357 |
}
|
|
358 |
|
|
359 |
//----------------------------create_jump_tables-------------------------------
|
|
360 |
bool Parse::create_jump_tables(Node* key_val, SwitchRange* lo, SwitchRange* hi) {
|
|
361 |
// Are jumptables enabled
|
|
362 |
if (!UseJumpTables) return false;
|
|
363 |
|
|
364 |
// Are jumptables supported
|
|
365 |
if (!Matcher::has_match_rule(Op_Jump)) return false;
|
|
366 |
|
|
367 |
// Don't make jump table if profiling
|
|
368 |
if (method_data_update()) return false;
|
|
369 |
|
|
370 |
// Decide if a guard is needed to lop off big ranges at either (or
|
|
371 |
// both) end(s) of the input set. We'll call this the default target
|
|
372 |
// even though we can't be sure that it is the true "default".
|
|
373 |
|
|
374 |
bool needs_guard = false;
|
|
375 |
int default_dest;
|
|
376 |
int64 total_outlier_size = 0;
|
|
377 |
int64 hi_size = ((int64)hi->hi()) - ((int64)hi->lo()) + 1;
|
|
378 |
int64 lo_size = ((int64)lo->hi()) - ((int64)lo->lo()) + 1;
|
|
379 |
|
|
380 |
if (lo->dest() == hi->dest()) {
|
|
381 |
total_outlier_size = hi_size + lo_size;
|
|
382 |
default_dest = lo->dest();
|
|
383 |
} else if (lo_size > hi_size) {
|
|
384 |
total_outlier_size = lo_size;
|
|
385 |
default_dest = lo->dest();
|
|
386 |
} else {
|
|
387 |
total_outlier_size = hi_size;
|
|
388 |
default_dest = hi->dest();
|
|
389 |
}
|
|
390 |
|
|
391 |
// If a guard test will eliminate very sparse end ranges, then
|
|
392 |
// it is worth the cost of an extra jump.
|
|
393 |
if (total_outlier_size > (MaxJumpTableSparseness * 4)) {
|
|
394 |
needs_guard = true;
|
|
395 |
if (default_dest == lo->dest()) lo++;
|
|
396 |
if (default_dest == hi->dest()) hi--;
|
|
397 |
}
|
|
398 |
|
|
399 |
// Find the total number of cases and ranges
|
|
400 |
int64 num_cases = ((int64)hi->hi()) - ((int64)lo->lo()) + 1;
|
|
401 |
int num_range = hi - lo + 1;
|
|
402 |
|
|
403 |
// Don't create table if: too large, too small, or too sparse.
|
|
404 |
if (num_cases < MinJumpTableSize || num_cases > MaxJumpTableSize)
|
|
405 |
return false;
|
|
406 |
if (num_cases > (MaxJumpTableSparseness * num_range))
|
|
407 |
return false;
|
|
408 |
|
|
409 |
// Normalize table lookups to zero
|
|
410 |
int lowval = lo->lo();
|
|
411 |
key_val = _gvn.transform( new (C, 3) SubINode(key_val, _gvn.intcon(lowval)) );
|
|
412 |
|
|
413 |
// Generate a guard to protect against input keyvals that aren't
|
|
414 |
// in the switch domain.
|
|
415 |
if (needs_guard) {
|
|
416 |
Node* size = _gvn.intcon(num_cases);
|
|
417 |
Node* cmp = _gvn.transform( new (C, 3) CmpUNode(key_val, size) );
|
|
418 |
Node* tst = _gvn.transform( new (C, 2) BoolNode(cmp, BoolTest::ge) );
|
|
419 |
IfNode* iff = create_and_map_if( control(), tst, PROB_FAIR, COUNT_UNKNOWN);
|
|
420 |
jump_if_true_fork(iff, default_dest, NullTableIndex);
|
|
421 |
}
|
|
422 |
|
|
423 |
// Create an ideal node JumpTable that has projections
|
|
424 |
// of all possible ranges for a switch statement
|
|
425 |
// The key_val input must be converted to a pointer offset and scaled.
|
|
426 |
// Compare Parse::array_addressing above.
|
|
427 |
#ifdef _LP64
|
|
428 |
// Clean the 32-bit int into a real 64-bit offset.
|
|
429 |
// Otherwise, the jint value 0 might turn into an offset of 0x0800000000.
|
|
430 |
const TypeLong* lkeytype = TypeLong::make(CONST64(0), num_cases-1, Type::WidenMin);
|
|
431 |
key_val = _gvn.transform( new (C, 2) ConvI2LNode(key_val, lkeytype) );
|
|
432 |
#endif
|
|
433 |
// Shift the value by wordsize so we have an index into the table, rather
|
|
434 |
// than a switch value
|
|
435 |
Node *shiftWord = _gvn.MakeConX(wordSize);
|
|
436 |
key_val = _gvn.transform( new (C, 3) MulXNode( key_val, shiftWord));
|
|
437 |
|
|
438 |
// Create the JumpNode
|
|
439 |
Node* jtn = _gvn.transform( new (C, 2) JumpNode(control(), key_val, num_cases) );
|
|
440 |
|
|
441 |
// These are the switch destinations hanging off the jumpnode
|
|
442 |
int i = 0;
|
|
443 |
for (SwitchRange* r = lo; r <= hi; r++) {
|
|
444 |
for (int j = r->lo(); j <= r->hi(); j++, i++) {
|
|
445 |
Node* input = _gvn.transform(new (C, 1) JumpProjNode(jtn, i, r->dest(), j - lowval));
|
|
446 |
{
|
|
447 |
PreserveJVMState pjvms(this);
|
|
448 |
set_control(input);
|
|
449 |
jump_if_always_fork(r->dest(), r->table_index());
|
|
450 |
}
|
|
451 |
}
|
|
452 |
}
|
|
453 |
assert(i == num_cases, "miscount of cases");
|
|
454 |
stop_and_kill_map(); // no more uses for this JVMS
|
|
455 |
return true;
|
|
456 |
}
|
|
457 |
|
|
458 |
//----------------------------jump_switch_ranges-------------------------------
|
|
459 |
void Parse::jump_switch_ranges(Node* key_val, SwitchRange *lo, SwitchRange *hi, int switch_depth) {
|
|
460 |
Block* switch_block = block();
|
|
461 |
|
|
462 |
if (switch_depth == 0) {
|
|
463 |
// Do special processing for the top-level call.
|
|
464 |
assert(lo->lo() == min_jint, "initial range must exhaust Type::INT");
|
|
465 |
assert(hi->hi() == max_jint, "initial range must exhaust Type::INT");
|
|
466 |
|
|
467 |
// Decrement pred-numbers for the unique set of nodes.
|
|
468 |
#ifdef ASSERT
|
|
469 |
// Ensure that the block's successors are a (duplicate-free) set.
|
|
470 |
int successors_counted = 0; // block occurrences in [hi..lo]
|
|
471 |
int unique_successors = switch_block->num_successors();
|
|
472 |
for (int i = 0; i < unique_successors; i++) {
|
|
473 |
Block* target = switch_block->successor_at(i);
|
|
474 |
|
|
475 |
// Check that the set of successors is the same in both places.
|
|
476 |
int successors_found = 0;
|
|
477 |
for (SwitchRange* p = lo; p <= hi; p++) {
|
|
478 |
if (p->dest() == target->start()) successors_found++;
|
|
479 |
}
|
|
480 |
assert(successors_found > 0, "successor must be known");
|
|
481 |
successors_counted += successors_found;
|
|
482 |
}
|
|
483 |
assert(successors_counted == (hi-lo)+1, "no unexpected successors");
|
|
484 |
#endif
|
|
485 |
|
|
486 |
// Maybe prune the inputs, based on the type of key_val.
|
|
487 |
jint min_val = min_jint;
|
|
488 |
jint max_val = max_jint;
|
|
489 |
const TypeInt* ti = key_val->bottom_type()->isa_int();
|
|
490 |
if (ti != NULL) {
|
|
491 |
min_val = ti->_lo;
|
|
492 |
max_val = ti->_hi;
|
|
493 |
assert(min_val <= max_val, "invalid int type");
|
|
494 |
}
|
|
495 |
while (lo->hi() < min_val) lo++;
|
|
496 |
if (lo->lo() < min_val) lo->setRange(min_val, lo->hi(), lo->dest(), lo->table_index());
|
|
497 |
while (hi->lo() > max_val) hi--;
|
|
498 |
if (hi->hi() > max_val) hi->setRange(hi->lo(), max_val, hi->dest(), hi->table_index());
|
|
499 |
}
|
|
500 |
|
|
501 |
#ifndef PRODUCT
|
|
502 |
if (switch_depth == 0) {
|
|
503 |
_max_switch_depth = 0;
|
|
504 |
_est_switch_depth = log2_intptr((hi-lo+1)-1)+1;
|
|
505 |
}
|
|
506 |
#endif
|
|
507 |
|
|
508 |
assert(lo <= hi, "must be a non-empty set of ranges");
|
|
509 |
if (lo == hi) {
|
|
510 |
jump_if_always_fork(lo->dest(), lo->table_index());
|
|
511 |
} else {
|
|
512 |
assert(lo->hi() == (lo+1)->lo()-1, "contiguous ranges");
|
|
513 |
assert(hi->lo() == (hi-1)->hi()+1, "contiguous ranges");
|
|
514 |
|
|
515 |
if (create_jump_tables(key_val, lo, hi)) return;
|
|
516 |
|
|
517 |
int nr = hi - lo + 1;
|
|
518 |
|
|
519 |
SwitchRange* mid = lo + nr/2;
|
|
520 |
// if there is an easy choice, pivot at a singleton:
|
|
521 |
if (nr > 3 && !mid->is_singleton() && (mid-1)->is_singleton()) mid--;
|
|
522 |
|
|
523 |
assert(lo < mid && mid <= hi, "good pivot choice");
|
|
524 |
assert(nr != 2 || mid == hi, "should pick higher of 2");
|
|
525 |
assert(nr != 3 || mid == hi-1, "should pick middle of 3");
|
|
526 |
|
|
527 |
Node *test_val = _gvn.intcon(mid->lo());
|
|
528 |
|
|
529 |
if (mid->is_singleton()) {
|
|
530 |
IfNode *iff_ne = jump_if_fork_int(key_val, test_val, BoolTest::ne);
|
|
531 |
jump_if_false_fork(iff_ne, mid->dest(), mid->table_index());
|
|
532 |
|
|
533 |
// Special Case: If there are exactly three ranges, and the high
|
|
534 |
// and low range each go to the same place, omit the "gt" test,
|
|
535 |
// since it will not discriminate anything.
|
|
536 |
bool eq_test_only = (hi == lo+2 && hi->dest() == lo->dest());
|
|
537 |
if (eq_test_only) {
|
|
538 |
assert(mid == hi-1, "");
|
|
539 |
}
|
|
540 |
|
|
541 |
// if there is a higher range, test for it and process it:
|
|
542 |
if (mid < hi && !eq_test_only) {
|
|
543 |
// two comparisons of same values--should enable 1 test for 2 branches
|
|
544 |
// Use BoolTest::le instead of BoolTest::gt
|
|
545 |
IfNode *iff_le = jump_if_fork_int(key_val, test_val, BoolTest::le);
|
|
546 |
Node *iftrue = _gvn.transform( new (C, 1) IfTrueNode(iff_le) );
|
|
547 |
Node *iffalse = _gvn.transform( new (C, 1) IfFalseNode(iff_le) );
|
|
548 |
{ PreserveJVMState pjvms(this);
|
|
549 |
set_control(iffalse);
|
|
550 |
jump_switch_ranges(key_val, mid+1, hi, switch_depth+1);
|
|
551 |
}
|
|
552 |
set_control(iftrue);
|
|
553 |
}
|
|
554 |
|
|
555 |
} else {
|
|
556 |
// mid is a range, not a singleton, so treat mid..hi as a unit
|
|
557 |
IfNode *iff_ge = jump_if_fork_int(key_val, test_val, BoolTest::ge);
|
|
558 |
|
|
559 |
// if there is a higher range, test for it and process it:
|
|
560 |
if (mid == hi) {
|
|
561 |
jump_if_true_fork(iff_ge, mid->dest(), mid->table_index());
|
|
562 |
} else {
|
|
563 |
Node *iftrue = _gvn.transform( new (C, 1) IfTrueNode(iff_ge) );
|
|
564 |
Node *iffalse = _gvn.transform( new (C, 1) IfFalseNode(iff_ge) );
|
|
565 |
{ PreserveJVMState pjvms(this);
|
|
566 |
set_control(iftrue);
|
|
567 |
jump_switch_ranges(key_val, mid, hi, switch_depth+1);
|
|
568 |
}
|
|
569 |
set_control(iffalse);
|
|
570 |
}
|
|
571 |
}
|
|
572 |
|
|
573 |
// in any case, process the lower range
|
|
574 |
jump_switch_ranges(key_val, lo, mid-1, switch_depth+1);
|
|
575 |
}
|
|
576 |
|
|
577 |
// Decrease pred_count for each successor after all is done.
|
|
578 |
if (switch_depth == 0) {
|
|
579 |
int unique_successors = switch_block->num_successors();
|
|
580 |
for (int i = 0; i < unique_successors; i++) {
|
|
581 |
Block* target = switch_block->successor_at(i);
|
|
582 |
// Throw away the pre-allocated path for each unique successor.
|
|
583 |
target->next_path_num();
|
|
584 |
}
|
|
585 |
}
|
|
586 |
|
|
587 |
#ifndef PRODUCT
|
|
588 |
_max_switch_depth = MAX2(switch_depth, _max_switch_depth);
|
|
589 |
if (TraceOptoParse && Verbose && WizardMode && switch_depth == 0) {
|
|
590 |
SwitchRange* r;
|
|
591 |
int nsing = 0;
|
|
592 |
for( r = lo; r <= hi; r++ ) {
|
|
593 |
if( r->is_singleton() ) nsing++;
|
|
594 |
}
|
|
595 |
tty->print(">>> ");
|
|
596 |
_method->print_short_name();
|
|
597 |
tty->print_cr(" switch decision tree");
|
|
598 |
tty->print_cr(" %d ranges (%d singletons), max_depth=%d, est_depth=%d",
|
|
599 |
hi-lo+1, nsing, _max_switch_depth, _est_switch_depth);
|
|
600 |
if (_max_switch_depth > _est_switch_depth) {
|
|
601 |
tty->print_cr("******** BAD SWITCH DEPTH ********");
|
|
602 |
}
|
|
603 |
tty->print(" ");
|
|
604 |
for( r = lo; r <= hi; r++ ) {
|
|
605 |
r->print(env());
|
|
606 |
}
|
|
607 |
tty->print_cr("");
|
|
608 |
}
|
|
609 |
#endif
|
|
610 |
}
|
|
611 |
|
|
612 |
void Parse::modf() {
|
|
613 |
Node *f2 = pop();
|
|
614 |
Node *f1 = pop();
|
|
615 |
Node* c = make_runtime_call(RC_LEAF, OptoRuntime::modf_Type(),
|
|
616 |
CAST_FROM_FN_PTR(address, SharedRuntime::frem),
|
|
617 |
"frem", NULL, //no memory effects
|
|
618 |
f1, f2);
|
|
619 |
Node* res = _gvn.transform(new (C, 1) ProjNode(c, TypeFunc::Parms + 0));
|
|
620 |
|
|
621 |
push(res);
|
|
622 |
}
|
|
623 |
|
|
624 |
void Parse::modd() {
|
|
625 |
Node *d2 = pop_pair();
|
|
626 |
Node *d1 = pop_pair();
|
|
627 |
Node* c = make_runtime_call(RC_LEAF, OptoRuntime::Math_DD_D_Type(),
|
|
628 |
CAST_FROM_FN_PTR(address, SharedRuntime::drem),
|
|
629 |
"drem", NULL, //no memory effects
|
|
630 |
d1, top(), d2, top());
|
|
631 |
Node* res_d = _gvn.transform(new (C, 1) ProjNode(c, TypeFunc::Parms + 0));
|
|
632 |
|
|
633 |
#ifdef ASSERT
|
|
634 |
Node* res_top = _gvn.transform(new (C, 1) ProjNode(c, TypeFunc::Parms + 1));
|
|
635 |
assert(res_top == top(), "second value must be top");
|
|
636 |
#endif
|
|
637 |
|
|
638 |
push_pair(res_d);
|
|
639 |
}
|
|
640 |
|
|
641 |
void Parse::l2f() {
|
|
642 |
Node* f2 = pop();
|
|
643 |
Node* f1 = pop();
|
|
644 |
Node* c = make_runtime_call(RC_LEAF, OptoRuntime::l2f_Type(),
|
|
645 |
CAST_FROM_FN_PTR(address, SharedRuntime::l2f),
|
|
646 |
"l2f", NULL, //no memory effects
|
|
647 |
f1, f2);
|
|
648 |
Node* res = _gvn.transform(new (C, 1) ProjNode(c, TypeFunc::Parms + 0));
|
|
649 |
|
|
650 |
push(res);
|
|
651 |
}
|
|
652 |
|
|
653 |
void Parse::do_irem() {
|
|
654 |
// Must keep both values on the expression-stack during null-check
|
|
655 |
do_null_check(peek(), T_INT);
|
|
656 |
// Compile-time detect of null-exception?
|
|
657 |
if (stopped()) return;
|
|
658 |
|
|
659 |
Node* b = pop();
|
|
660 |
Node* a = pop();
|
|
661 |
|
|
662 |
const Type *t = _gvn.type(b);
|
|
663 |
if (t != Type::TOP) {
|
|
664 |
const TypeInt *ti = t->is_int();
|
|
665 |
if (ti->is_con()) {
|
|
666 |
int divisor = ti->get_con();
|
|
667 |
// check for positive power of 2
|
|
668 |
if (divisor > 0 &&
|
|
669 |
(divisor & ~(divisor-1)) == divisor) {
|
|
670 |
// yes !
|
|
671 |
Node *mask = _gvn.intcon((divisor - 1));
|
|
672 |
// Sigh, must handle negative dividends
|
|
673 |
Node *zero = _gvn.intcon(0);
|
|
674 |
IfNode *ifff = jump_if_fork_int(a, zero, BoolTest::lt);
|
|
675 |
Node *iff = _gvn.transform( new (C, 1) IfFalseNode(ifff) );
|
|
676 |
Node *ift = _gvn.transform( new (C, 1) IfTrueNode (ifff) );
|
|
677 |
Node *reg = jump_if_join(ift, iff);
|
|
678 |
Node *phi = PhiNode::make(reg, NULL, TypeInt::INT);
|
|
679 |
// Negative path; negate/and/negate
|
|
680 |
Node *neg = _gvn.transform( new (C, 3) SubINode(zero, a) );
|
|
681 |
Node *andn= _gvn.transform( new (C, 3) AndINode(neg, mask) );
|
|
682 |
Node *negn= _gvn.transform( new (C, 3) SubINode(zero, andn) );
|
|
683 |
phi->init_req(1, negn);
|
|
684 |
// Fast positive case
|
|
685 |
Node *andx = _gvn.transform( new (C, 3) AndINode(a, mask) );
|
|
686 |
phi->init_req(2, andx);
|
|
687 |
// Push the merge
|
|
688 |
push( _gvn.transform(phi) );
|
|
689 |
return;
|
|
690 |
}
|
|
691 |
}
|
|
692 |
}
|
|
693 |
// Default case
|
|
694 |
push( _gvn.transform( new (C, 3) ModINode(control(),a,b) ) );
|
|
695 |
}
|
|
696 |
|
|
697 |
// Handle jsr and jsr_w bytecode
|
|
698 |
void Parse::do_jsr() {
|
|
699 |
assert(bc() == Bytecodes::_jsr || bc() == Bytecodes::_jsr_w, "wrong bytecode");
|
|
700 |
|
|
701 |
// Store information about current state, tagged with new _jsr_bci
|
|
702 |
int return_bci = iter().next_bci();
|
|
703 |
int jsr_bci = (bc() == Bytecodes::_jsr) ? iter().get_dest() : iter().get_far_dest();
|
|
704 |
|
|
705 |
// Update method data
|
|
706 |
profile_taken_branch(jsr_bci);
|
|
707 |
|
|
708 |
// The way we do things now, there is only one successor block
|
|
709 |
// for the jsr, because the target code is cloned by ciTypeFlow.
|
|
710 |
Block* target = successor_for_bci(jsr_bci);
|
|
711 |
|
|
712 |
// What got pushed?
|
|
713 |
const Type* ret_addr = target->peek();
|
|
714 |
assert(ret_addr->singleton(), "must be a constant (cloned jsr body)");
|
|
715 |
|
|
716 |
// Effect on jsr on stack
|
|
717 |
push(_gvn.makecon(ret_addr));
|
|
718 |
|
|
719 |
// Flow to the jsr.
|
|
720 |
merge(jsr_bci);
|
|
721 |
}
|
|
722 |
|
|
723 |
// Handle ret bytecode
|
|
724 |
void Parse::do_ret() {
|
|
725 |
// Find to whom we return.
|
|
726 |
#if 0 // %%%% MAKE THIS WORK
|
|
727 |
Node* con = local();
|
|
728 |
const TypePtr* tp = con->bottom_type()->isa_ptr();
|
|
729 |
assert(tp && tp->singleton(), "");
|
|
730 |
int return_bci = (int) tp->get_con();
|
|
731 |
merge(return_bci);
|
|
732 |
#else
|
|
733 |
assert(block()->num_successors() == 1, "a ret can only go one place now");
|
|
734 |
Block* target = block()->successor_at(0);
|
|
735 |
assert(!target->is_ready(), "our arrival must be expected");
|
|
736 |
profile_ret(target->flow()->start());
|
|
737 |
int pnum = target->next_path_num();
|
|
738 |
merge_common(target, pnum);
|
|
739 |
#endif
|
|
740 |
}
|
|
741 |
|
|
742 |
//--------------------------dynamic_branch_prediction--------------------------
|
|
743 |
// Try to gather dynamic branch prediction behavior. Return a probability
|
|
744 |
// of the branch being taken and set the "cnt" field. Returns a -1.0
|
|
745 |
// if we need to use static prediction for some reason.
|
|
746 |
float Parse::dynamic_branch_prediction(float &cnt) {
|
|
747 |
ResourceMark rm;
|
|
748 |
|
|
749 |
cnt = COUNT_UNKNOWN;
|
|
750 |
|
|
751 |
// Use MethodData information if it is available
|
|
752 |
// FIXME: free the ProfileData structure
|
|
753 |
ciMethodData* methodData = method()->method_data();
|
|
754 |
if (!methodData->is_mature()) return PROB_UNKNOWN;
|
|
755 |
ciProfileData* data = methodData->bci_to_data(bci());
|
|
756 |
if (!data->is_JumpData()) return PROB_UNKNOWN;
|
|
757 |
|
|
758 |
// get taken and not taken values
|
|
759 |
int taken = data->as_JumpData()->taken();
|
|
760 |
int not_taken = 0;
|
|
761 |
if (data->is_BranchData()) {
|
|
762 |
not_taken = data->as_BranchData()->not_taken();
|
|
763 |
}
|
|
764 |
|
|
765 |
// scale the counts to be commensurate with invocation counts:
|
|
766 |
taken = method()->scale_count(taken);
|
|
767 |
not_taken = method()->scale_count(not_taken);
|
|
768 |
|
|
769 |
// Give up if too few counts to be meaningful
|
|
770 |
if (taken + not_taken < 40) {
|
|
771 |
if (C->log() != NULL) {
|
|
772 |
C->log()->elem("branch target_bci='%d' taken='%d' not_taken='%d'", iter().get_dest(), taken, not_taken);
|
|
773 |
}
|
|
774 |
return PROB_UNKNOWN;
|
|
775 |
}
|
|
776 |
|
|
777 |
// Compute frequency that we arrive here
|
|
778 |
int sum = taken + not_taken;
|
|
779 |
// Adjust, if this block is a cloned private block but the
|
|
780 |
// Jump counts are shared. Taken the private counts for
|
|
781 |
// just this path instead of the shared counts.
|
|
782 |
if( block()->count() > 0 )
|
|
783 |
sum = block()->count();
|
|
784 |
cnt = (float)sum / (float)FreqCountInvocations;
|
|
785 |
|
|
786 |
// Pin probability to sane limits
|
|
787 |
float prob;
|
|
788 |
if( !taken )
|
|
789 |
prob = (0+PROB_MIN) / 2;
|
|
790 |
else if( !not_taken )
|
|
791 |
prob = (1+PROB_MAX) / 2;
|
|
792 |
else { // Compute probability of true path
|
|
793 |
prob = (float)taken / (float)(taken + not_taken);
|
|
794 |
if (prob > PROB_MAX) prob = PROB_MAX;
|
|
795 |
if (prob < PROB_MIN) prob = PROB_MIN;
|
|
796 |
}
|
|
797 |
|
|
798 |
assert((cnt > 0.0f) && (prob > 0.0f),
|
|
799 |
"Bad frequency assignment in if");
|
|
800 |
|
|
801 |
if (C->log() != NULL) {
|
|
802 |
const char* prob_str = NULL;
|
|
803 |
if (prob >= PROB_MAX) prob_str = (prob == PROB_MAX) ? "max" : "always";
|
|
804 |
if (prob <= PROB_MIN) prob_str = (prob == PROB_MIN) ? "min" : "never";
|
|
805 |
char prob_str_buf[30];
|
|
806 |
if (prob_str == NULL) {
|
|
807 |
sprintf(prob_str_buf, "%g", prob);
|
|
808 |
prob_str = prob_str_buf;
|
|
809 |
}
|
|
810 |
C->log()->elem("branch target_bci='%d' taken='%d' not_taken='%d' cnt='%g' prob='%s'",
|
|
811 |
iter().get_dest(), taken, not_taken, cnt, prob_str);
|
|
812 |
}
|
|
813 |
return prob;
|
|
814 |
}
|
|
815 |
|
|
816 |
//-----------------------------branch_prediction-------------------------------
|
|
817 |
float Parse::branch_prediction(float& cnt,
|
|
818 |
BoolTest::mask btest,
|
|
819 |
int target_bci) {
|
|
820 |
float prob = dynamic_branch_prediction(cnt);
|
|
821 |
// If prob is unknown, switch to static prediction
|
|
822 |
if (prob != PROB_UNKNOWN) return prob;
|
|
823 |
|
|
824 |
prob = PROB_FAIR; // Set default value
|
|
825 |
if (btest == BoolTest::eq) // Exactly equal test?
|
|
826 |
prob = PROB_STATIC_INFREQUENT; // Assume its relatively infrequent
|
|
827 |
else if (btest == BoolTest::ne)
|
|
828 |
prob = PROB_STATIC_FREQUENT; // Assume its relatively frequent
|
|
829 |
|
|
830 |
// If this is a conditional test guarding a backwards branch,
|
|
831 |
// assume its a loop-back edge. Make it a likely taken branch.
|
|
832 |
if (target_bci < bci()) {
|
|
833 |
if (is_osr_parse()) { // Could be a hot OSR'd loop; force deopt
|
|
834 |
// Since it's an OSR, we probably have profile data, but since
|
|
835 |
// branch_prediction returned PROB_UNKNOWN, the counts are too small.
|
|
836 |
// Let's make a special check here for completely zero counts.
|
|
837 |
ciMethodData* methodData = method()->method_data();
|
|
838 |
if (!methodData->is_empty()) {
|
|
839 |
ciProfileData* data = methodData->bci_to_data(bci());
|
|
840 |
// Only stop for truly zero counts, which mean an unknown part
|
|
841 |
// of the OSR-ed method, and we want to deopt to gather more stats.
|
|
842 |
// If you have ANY counts, then this loop is simply 'cold' relative
|
|
843 |
// to the OSR loop.
|
|
844 |
if (data->as_BranchData()->taken() +
|
|
845 |
data->as_BranchData()->not_taken() == 0 ) {
|
|
846 |
// This is the only way to return PROB_UNKNOWN:
|
|
847 |
return PROB_UNKNOWN;
|
|
848 |
}
|
|
849 |
}
|
|
850 |
}
|
|
851 |
prob = PROB_STATIC_FREQUENT; // Likely to take backwards branch
|
|
852 |
}
|
|
853 |
|
|
854 |
assert(prob != PROB_UNKNOWN, "must have some guess at this point");
|
|
855 |
return prob;
|
|
856 |
}
|
|
857 |
|
|
858 |
// The magic constants are chosen so as to match the output of
|
|
859 |
// branch_prediction() when the profile reports a zero taken count.
|
|
860 |
// It is important to distinguish zero counts unambiguously, because
|
|
861 |
// some branches (e.g., _213_javac.Assembler.eliminate) validly produce
|
|
862 |
// very small but nonzero probabilities, which if confused with zero
|
|
863 |
// counts would keep the program recompiling indefinitely.
|
|
864 |
bool Parse::seems_never_taken(float prob) {
|
|
865 |
return prob < PROB_MIN;
|
|
866 |
}
|
|
867 |
|
|
868 |
inline void Parse::repush_if_args() {
|
|
869 |
#ifndef PRODUCT
|
|
870 |
if (PrintOpto && WizardMode) {
|
|
871 |
tty->print("defending against excessive implicit null exceptions on %s @%d in ",
|
|
872 |
Bytecodes::name(iter().cur_bc()), iter().cur_bci());
|
|
873 |
method()->print_name(); tty->cr();
|
|
874 |
}
|
|
875 |
#endif
|
|
876 |
int bc_depth = - Bytecodes::depth(iter().cur_bc());
|
|
877 |
assert(bc_depth == 1 || bc_depth == 2, "only two kinds of branches");
|
|
878 |
DEBUG_ONLY(sync_jvms()); // argument(n) requires a synced jvms
|
|
879 |
assert(argument(0) != NULL, "must exist");
|
|
880 |
assert(bc_depth == 1 || argument(1) != NULL, "two must exist");
|
|
881 |
_sp += bc_depth;
|
|
882 |
}
|
|
883 |
|
|
884 |
//----------------------------------do_ifnull----------------------------------
|
|
885 |
void Parse::do_ifnull(BoolTest::mask btest) {
|
|
886 |
int target_bci = iter().get_dest();
|
|
887 |
|
|
888 |
float cnt;
|
|
889 |
float prob = branch_prediction(cnt, btest, target_bci);
|
|
890 |
if (prob == PROB_UNKNOWN) {
|
|
891 |
// (An earlier version of do_ifnull omitted this trap for OSR methods.)
|
|
892 |
#ifndef PRODUCT
|
|
893 |
if (PrintOpto && Verbose)
|
|
894 |
tty->print_cr("Never-taken backedge stops compilation at bci %d",bci());
|
|
895 |
#endif
|
|
896 |
repush_if_args(); // to gather stats on loop
|
|
897 |
// We need to mark this branch as taken so that if we recompile we will
|
|
898 |
// see that it is possible. In the tiered system the interpreter doesn't
|
|
899 |
// do profiling and by the time we get to the lower tier from the interpreter
|
|
900 |
// the path may be cold again. Make sure it doesn't look untaken
|
|
901 |
profile_taken_branch(target_bci, !ProfileInterpreter);
|
|
902 |
uncommon_trap(Deoptimization::Reason_unreached,
|
|
903 |
Deoptimization::Action_reinterpret,
|
|
904 |
NULL, "cold");
|
|
905 |
return;
|
|
906 |
}
|
|
907 |
|
|
908 |
// If this is a backwards branch in the bytecodes, add Safepoint
|
|
909 |
maybe_add_safepoint(target_bci);
|
|
910 |
Block* branch_block = successor_for_bci(target_bci);
|
|
911 |
Block* next_block = successor_for_bci(iter().next_bci());
|
|
912 |
|
|
913 |
explicit_null_checks_inserted++;
|
|
914 |
Node* a = null();
|
|
915 |
Node* b = pop();
|
|
916 |
Node* c = _gvn.transform( new (C, 3) CmpPNode(b, a) );
|
|
917 |
|
|
918 |
// Make a cast-away-nullness that is control dependent on the test
|
|
919 |
const Type *t = _gvn.type(b);
|
|
920 |
const Type *t_not_null = t->join(TypePtr::NOTNULL);
|
|
921 |
Node *cast = new (C, 2) CastPPNode(b,t_not_null);
|
|
922 |
|
|
923 |
// Generate real control flow
|
|
924 |
Node *tst = _gvn.transform( new (C, 2) BoolNode( c, btest ) );
|
|
925 |
|
|
926 |
// Sanity check the probability value
|
|
927 |
assert(prob > 0.0f,"Bad probability in Parser");
|
|
928 |
// Need xform to put node in hash table
|
|
929 |
IfNode *iff = create_and_xform_if( control(), tst, prob, cnt );
|
|
930 |
assert(iff->_prob > 0.0f,"Optimizer made bad probability in parser");
|
|
931 |
// True branch
|
|
932 |
{ PreserveJVMState pjvms(this);
|
|
933 |
Node* iftrue = _gvn.transform( new (C, 1) IfTrueNode (iff) );
|
|
934 |
set_control(iftrue);
|
|
935 |
|
|
936 |
if (stopped()) { // Path is dead?
|
|
937 |
explicit_null_checks_elided++;
|
|
938 |
} else { // Path is live.
|
|
939 |
// Update method data
|
|
940 |
profile_taken_branch(target_bci);
|
|
941 |
adjust_map_after_if(btest, c, prob, branch_block, next_block);
|
|
942 |
if (!stopped())
|
|
943 |
merge(target_bci);
|
|
944 |
}
|
|
945 |
}
|
|
946 |
|
|
947 |
// False branch
|
|
948 |
Node* iffalse = _gvn.transform( new (C, 1) IfFalseNode(iff) );
|
|
949 |
set_control(iffalse);
|
|
950 |
|
|
951 |
if (stopped()) { // Path is dead?
|
|
952 |
explicit_null_checks_elided++;
|
|
953 |
} else { // Path is live.
|
|
954 |
// Update method data
|
|
955 |
profile_not_taken_branch();
|
|
956 |
adjust_map_after_if(BoolTest(btest).negate(), c, 1.0-prob,
|
|
957 |
next_block, branch_block);
|
|
958 |
}
|
|
959 |
}
|
|
960 |
|
|
961 |
//------------------------------------do_if------------------------------------
|
|
962 |
void Parse::do_if(BoolTest::mask btest, Node* c) {
|
|
963 |
int target_bci = iter().get_dest();
|
|
964 |
|
|
965 |
float cnt;
|
|
966 |
float prob = branch_prediction(cnt, btest, target_bci);
|
|
967 |
float untaken_prob = 1.0 - prob;
|
|
968 |
|
|
969 |
if (prob == PROB_UNKNOWN) {
|
|
970 |
#ifndef PRODUCT
|
|
971 |
if (PrintOpto && Verbose)
|
|
972 |
tty->print_cr("Never-taken backedge stops compilation at bci %d",bci());
|
|
973 |
#endif
|
|
974 |
repush_if_args(); // to gather stats on loop
|
|
975 |
// We need to mark this branch as taken so that if we recompile we will
|
|
976 |
// see that it is possible. In the tiered system the interpreter doesn't
|
|
977 |
// do profiling and by the time we get to the lower tier from the interpreter
|
|
978 |
// the path may be cold again. Make sure it doesn't look untaken
|
|
979 |
profile_taken_branch(target_bci, !ProfileInterpreter);
|
|
980 |
uncommon_trap(Deoptimization::Reason_unreached,
|
|
981 |
Deoptimization::Action_reinterpret,
|
|
982 |
NULL, "cold");
|
|
983 |
return;
|
|
984 |
}
|
|
985 |
|
|
986 |
// Sanity check the probability value
|
|
987 |
assert(0.0f < prob && prob < 1.0f,"Bad probability in Parser");
|
|
988 |
|
|
989 |
bool taken_if_true = true;
|
|
990 |
// Convert BoolTest to canonical form:
|
|
991 |
if (!BoolTest(btest).is_canonical()) {
|
|
992 |
btest = BoolTest(btest).negate();
|
|
993 |
taken_if_true = false;
|
|
994 |
// prob is NOT updated here; it remains the probability of the taken
|
|
995 |
// path (as opposed to the prob of the path guarded by an 'IfTrueNode').
|
|
996 |
}
|
|
997 |
assert(btest != BoolTest::eq, "!= is the only canonical exact test");
|
|
998 |
|
|
999 |
Node* tst0 = new (C, 2) BoolNode(c, btest);
|
|
1000 |
Node* tst = _gvn.transform(tst0);
|
|
1001 |
BoolTest::mask taken_btest = BoolTest::illegal;
|
|
1002 |
BoolTest::mask untaken_btest = BoolTest::illegal;
|
|
1003 |
if (btest == BoolTest::ne) {
|
|
1004 |
// For now, these are the only cases of btest that matter. (More later.)
|
|
1005 |
taken_btest = taken_if_true ? btest : BoolTest::eq;
|
|
1006 |
untaken_btest = taken_if_true ? BoolTest::eq : btest;
|
|
1007 |
}
|
|
1008 |
|
|
1009 |
// Generate real control flow
|
|
1010 |
float true_prob = (taken_if_true ? prob : untaken_prob);
|
|
1011 |
IfNode* iff = create_and_map_if(control(), tst, true_prob, cnt);
|
|
1012 |
assert(iff->_prob > 0.0f,"Optimizer made bad probability in parser");
|
|
1013 |
Node* taken_branch = new (C, 1) IfTrueNode(iff);
|
|
1014 |
Node* untaken_branch = new (C, 1) IfFalseNode(iff);
|
|
1015 |
if (!taken_if_true) { // Finish conversion to canonical form
|
|
1016 |
Node* tmp = taken_branch;
|
|
1017 |
taken_branch = untaken_branch;
|
|
1018 |
untaken_branch = tmp;
|
|
1019 |
}
|
|
1020 |
|
|
1021 |
Block* branch_block = successor_for_bci(target_bci);
|
|
1022 |
Block* next_block = successor_for_bci(iter().next_bci());
|
|
1023 |
|
|
1024 |
// Branch is taken:
|
|
1025 |
{ PreserveJVMState pjvms(this);
|
|
1026 |
taken_branch = _gvn.transform(taken_branch);
|
|
1027 |
set_control(taken_branch);
|
|
1028 |
|
|
1029 |
if (!stopped()) {
|
|
1030 |
// Update method data
|
|
1031 |
profile_taken_branch(target_bci);
|
|
1032 |
adjust_map_after_if(taken_btest, c, prob, branch_block, next_block);
|
|
1033 |
if (!stopped())
|
|
1034 |
merge(target_bci);
|
|
1035 |
}
|
|
1036 |
}
|
|
1037 |
|
|
1038 |
untaken_branch = _gvn.transform(untaken_branch);
|
|
1039 |
set_control(untaken_branch);
|
|
1040 |
|
|
1041 |
// Branch not taken.
|
|
1042 |
if (!stopped()) {
|
|
1043 |
// Update method data
|
|
1044 |
profile_not_taken_branch();
|
|
1045 |
adjust_map_after_if(untaken_btest, c, untaken_prob,
|
|
1046 |
next_block, branch_block);
|
|
1047 |
}
|
|
1048 |
}
|
|
1049 |
|
|
1050 |
//----------------------------adjust_map_after_if------------------------------
|
|
1051 |
// Adjust the JVM state to reflect the result of taking this path.
|
|
1052 |
// Basically, it means inspecting the CmpNode controlling this
|
|
1053 |
// branch, seeing how it constrains a tested value, and then
|
|
1054 |
// deciding if it's worth our while to encode this constraint
|
|
1055 |
// as graph nodes in the current abstract interpretation map.
|
|
1056 |
void Parse::adjust_map_after_if(BoolTest::mask btest, Node* c, float prob,
|
|
1057 |
Block* path, Block* other_path) {
|
|
1058 |
if (stopped() || !c->is_Cmp() || btest == BoolTest::illegal)
|
|
1059 |
return; // nothing to do
|
|
1060 |
|
|
1061 |
bool is_fallthrough = (path == successor_for_bci(iter().next_bci()));
|
|
1062 |
|
|
1063 |
int cop = c->Opcode();
|
|
1064 |
if (seems_never_taken(prob) && cop == Op_CmpP && btest == BoolTest::eq) {
|
|
1065 |
// (An earlier version of do_if omitted '&& btest == BoolTest::eq'.)
|
|
1066 |
//
|
|
1067 |
// If this might possibly turn into an implicit null check,
|
|
1068 |
// and the null has never yet been seen, we need to generate
|
|
1069 |
// an uncommon trap, so as to recompile instead of suffering
|
|
1070 |
// with very slow branches. (We'll get the slow branches if
|
|
1071 |
// the program ever changes phase and starts seeing nulls here.)
|
|
1072 |
//
|
|
1073 |
// The tests we worry about are of the form (p == null).
|
|
1074 |
// We do not simply inspect for a null constant, since a node may
|
|
1075 |
// optimize to 'null' later on.
|
|
1076 |
repush_if_args();
|
|
1077 |
// We need to mark this branch as taken so that if we recompile we will
|
|
1078 |
// see that it is possible. In the tiered system the interpreter doesn't
|
|
1079 |
// do profiling and by the time we get to the lower tier from the interpreter
|
|
1080 |
// the path may be cold again. Make sure it doesn't look untaken
|
|
1081 |
if (is_fallthrough) {
|
|
1082 |
profile_not_taken_branch(!ProfileInterpreter);
|
|
1083 |
} else {
|
|
1084 |
profile_taken_branch(iter().get_dest(), !ProfileInterpreter);
|
|
1085 |
}
|
|
1086 |
uncommon_trap(Deoptimization::Reason_unreached,
|
|
1087 |
Deoptimization::Action_reinterpret,
|
|
1088 |
NULL,
|
|
1089 |
(is_fallthrough ? "taken always" : "taken never"));
|
|
1090 |
return;
|
|
1091 |
}
|
|
1092 |
|
|
1093 |
Node* val = c->in(1);
|
|
1094 |
Node* con = c->in(2);
|
|
1095 |
const Type* tcon = _gvn.type(con);
|
|
1096 |
const Type* tval = _gvn.type(val);
|
|
1097 |
bool have_con = tcon->singleton();
|
|
1098 |
if (tval->singleton()) {
|
|
1099 |
if (!have_con) {
|
|
1100 |
// Swap, so constant is in con.
|
|
1101 |
con = val;
|
|
1102 |
tcon = tval;
|
|
1103 |
val = c->in(2);
|
|
1104 |
tval = _gvn.type(val);
|
|
1105 |
btest = BoolTest(btest).commute();
|
|
1106 |
have_con = true;
|
|
1107 |
} else {
|
|
1108 |
// Do we have two constants? Then leave well enough alone.
|
|
1109 |
have_con = false;
|
|
1110 |
}
|
|
1111 |
}
|
|
1112 |
if (!have_con) // remaining adjustments need a con
|
|
1113 |
return;
|
|
1114 |
|
|
1115 |
|
|
1116 |
int val_in_map = map()->find_edge(val);
|
|
1117 |
if (val_in_map < 0) return; // replace_in_map would be useless
|
|
1118 |
{
|
|
1119 |
JVMState* jvms = this->jvms();
|
|
1120 |
if (!(jvms->is_loc(val_in_map) ||
|
|
1121 |
jvms->is_stk(val_in_map)))
|
|
1122 |
return; // again, it would be useless
|
|
1123 |
}
|
|
1124 |
|
|
1125 |
// Check for a comparison to a constant, and "know" that the compared
|
|
1126 |
// value is constrained on this path.
|
|
1127 |
assert(tcon->singleton(), "");
|
|
1128 |
ConstraintCastNode* ccast = NULL;
|
|
1129 |
Node* cast = NULL;
|
|
1130 |
|
|
1131 |
switch (btest) {
|
|
1132 |
case BoolTest::eq: // Constant test?
|
|
1133 |
{
|
|
1134 |
const Type* tboth = tcon->join(tval);
|
|
1135 |
if (tboth == tval) break; // Nothing to gain.
|
|
1136 |
if (tcon->isa_int()) {
|
|
1137 |
ccast = new (C, 2) CastIINode(val, tboth);
|
|
1138 |
} else if (tcon == TypePtr::NULL_PTR) {
|
|
1139 |
// Cast to null, but keep the pointer identity temporarily live.
|
|
1140 |
ccast = new (C, 2) CastPPNode(val, tboth);
|
|
1141 |
} else {
|
|
1142 |
const TypeF* tf = tcon->isa_float_constant();
|
|
1143 |
const TypeD* td = tcon->isa_double_constant();
|
|
1144 |
// Exclude tests vs float/double 0 as these could be
|
|
1145 |
// either +0 or -0. Just because you are equal to +0
|
|
1146 |
// doesn't mean you ARE +0!
|
|
1147 |
if ((!tf || tf->_f != 0.0) &&
|
|
1148 |
(!td || td->_d != 0.0))
|
|
1149 |
cast = con; // Replace non-constant val by con.
|
|
1150 |
}
|
|
1151 |
}
|
|
1152 |
break;
|
|
1153 |
|
|
1154 |
case BoolTest::ne:
|
|
1155 |
if (tcon == TypePtr::NULL_PTR) {
|
|
1156 |
cast = cast_not_null(val, false);
|
|
1157 |
}
|
|
1158 |
break;
|
|
1159 |
|
|
1160 |
default:
|
|
1161 |
// (At this point we could record int range types with CastII.)
|
|
1162 |
break;
|
|
1163 |
}
|
|
1164 |
|
|
1165 |
if (ccast != NULL) {
|
|
1166 |
const Type* tcc = ccast->as_Type()->type();
|
|
1167 |
assert(tcc != tval && tcc->higher_equal(tval), "must improve");
|
|
1168 |
// Delay transform() call to allow recovery of pre-cast value
|
|
1169 |
// at the control merge.
|
|
1170 |
ccast->set_req(0, control());
|
|
1171 |
_gvn.set_type_bottom(ccast);
|
|
1172 |
record_for_igvn(ccast);
|
|
1173 |
cast = ccast;
|
|
1174 |
}
|
|
1175 |
|
|
1176 |
if (cast != NULL) { // Here's the payoff.
|
|
1177 |
replace_in_map(val, cast);
|
|
1178 |
}
|
|
1179 |
}
|
|
1180 |
|
|
1181 |
|
|
1182 |
//------------------------------do_one_bytecode--------------------------------
|
|
1183 |
// Parse this bytecode, and alter the Parsers JVM->Node mapping
|
|
1184 |
void Parse::do_one_bytecode() {
|
|
1185 |
Node *a, *b, *c, *d; // Handy temps
|
|
1186 |
BoolTest::mask btest;
|
|
1187 |
int i;
|
|
1188 |
|
|
1189 |
assert(!has_exceptions(), "bytecode entry state must be clear of throws");
|
|
1190 |
|
|
1191 |
if (C->check_node_count(NodeLimitFudgeFactor * 5,
|
|
1192 |
"out of nodes parsing method")) {
|
|
1193 |
return;
|
|
1194 |
}
|
|
1195 |
|
|
1196 |
#ifdef ASSERT
|
|
1197 |
// for setting breakpoints
|
|
1198 |
if (TraceOptoParse) {
|
|
1199 |
tty->print(" @");
|
|
1200 |
dump_bci(bci());
|
|
1201 |
}
|
|
1202 |
#endif
|
|
1203 |
|
|
1204 |
switch (bc()) {
|
|
1205 |
case Bytecodes::_nop:
|
|
1206 |
// do nothing
|
|
1207 |
break;
|
|
1208 |
case Bytecodes::_lconst_0:
|
|
1209 |
push_pair(longcon(0));
|
|
1210 |
break;
|
|
1211 |
|
|
1212 |
case Bytecodes::_lconst_1:
|
|
1213 |
push_pair(longcon(1));
|
|
1214 |
break;
|
|
1215 |
|
|
1216 |
case Bytecodes::_fconst_0:
|
|
1217 |
push(zerocon(T_FLOAT));
|
|
1218 |
break;
|
|
1219 |
|
|
1220 |
case Bytecodes::_fconst_1:
|
|
1221 |
push(makecon(TypeF::ONE));
|
|
1222 |
break;
|
|
1223 |
|
|
1224 |
case Bytecodes::_fconst_2:
|
|
1225 |
push(makecon(TypeF::make(2.0f)));
|
|
1226 |
break;
|
|
1227 |
|
|
1228 |
case Bytecodes::_dconst_0:
|
|
1229 |
push_pair(zerocon(T_DOUBLE));
|
|
1230 |
break;
|
|
1231 |
|
|
1232 |
case Bytecodes::_dconst_1:
|
|
1233 |
push_pair(makecon(TypeD::ONE));
|
|
1234 |
break;
|
|
1235 |
|
|
1236 |
case Bytecodes::_iconst_m1:push(intcon(-1)); break;
|
|
1237 |
case Bytecodes::_iconst_0: push(intcon( 0)); break;
|
|
1238 |
case Bytecodes::_iconst_1: push(intcon( 1)); break;
|
|
1239 |
case Bytecodes::_iconst_2: push(intcon( 2)); break;
|
|
1240 |
case Bytecodes::_iconst_3: push(intcon( 3)); break;
|
|
1241 |
case Bytecodes::_iconst_4: push(intcon( 4)); break;
|
|
1242 |
case Bytecodes::_iconst_5: push(intcon( 5)); break;
|
|
1243 |
case Bytecodes::_bipush: push(intcon( iter().get_byte())); break;
|
|
1244 |
case Bytecodes::_sipush: push(intcon( iter().get_short())); break;
|
|
1245 |
case Bytecodes::_aconst_null: push(null()); break;
|
|
1246 |
case Bytecodes::_ldc:
|
|
1247 |
case Bytecodes::_ldc_w:
|
|
1248 |
case Bytecodes::_ldc2_w:
|
|
1249 |
// If the constant is unresolved, run this BC once in the interpreter.
|
|
1250 |
if (iter().is_unresolved_string()) {
|
|
1251 |
uncommon_trap(Deoptimization::make_trap_request
|
|
1252 |
(Deoptimization::Reason_unloaded,
|
|
1253 |
Deoptimization::Action_reinterpret,
|
|
1254 |
iter().get_constant_index()),
|
|
1255 |
NULL, "unresolved_string");
|
|
1256 |
break;
|
|
1257 |
} else {
|
|
1258 |
ciConstant constant = iter().get_constant();
|
|
1259 |
if (constant.basic_type() == T_OBJECT) {
|
|
1260 |
ciObject* c = constant.as_object();
|
|
1261 |
if (c->is_klass()) {
|
|
1262 |
// The constant returned for a klass is the ciKlass for the
|
|
1263 |
// entry. We want the java_mirror so get it.
|
|
1264 |
ciKlass* klass = c->as_klass();
|
|
1265 |
if (klass->is_loaded()) {
|
|
1266 |
constant = ciConstant(T_OBJECT, klass->java_mirror());
|
|
1267 |
} else {
|
|
1268 |
uncommon_trap(Deoptimization::make_trap_request
|
|
1269 |
(Deoptimization::Reason_unloaded,
|
|
1270 |
Deoptimization::Action_reinterpret,
|
|
1271 |
iter().get_constant_index()),
|
|
1272 |
NULL, "unresolved_klass");
|
|
1273 |
break;
|
|
1274 |
}
|
|
1275 |
}
|
|
1276 |
}
|
|
1277 |
push_constant(constant);
|
|
1278 |
}
|
|
1279 |
|
|
1280 |
break;
|
|
1281 |
|
|
1282 |
case Bytecodes::_aload_0:
|
|
1283 |
push( local(0) );
|
|
1284 |
break;
|
|
1285 |
case Bytecodes::_aload_1:
|
|
1286 |
push( local(1) );
|
|
1287 |
break;
|
|
1288 |
case Bytecodes::_aload_2:
|
|
1289 |
push( local(2) );
|
|
1290 |
break;
|
|
1291 |
case Bytecodes::_aload_3:
|
|
1292 |
push( local(3) );
|
|
1293 |
break;
|
|
1294 |
case Bytecodes::_aload:
|
|
1295 |
push( local(iter().get_index()) );
|
|
1296 |
break;
|
|
1297 |
|
|
1298 |
case Bytecodes::_fload_0:
|
|
1299 |
case Bytecodes::_iload_0:
|
|
1300 |
push( local(0) );
|
|
1301 |
break;
|
|
1302 |
case Bytecodes::_fload_1:
|
|
1303 |
case Bytecodes::_iload_1:
|
|
1304 |
push( local(1) );
|
|
1305 |
break;
|
|
1306 |
case Bytecodes::_fload_2:
|
|
1307 |
case Bytecodes::_iload_2:
|
|
1308 |
push( local(2) );
|
|
1309 |
break;
|
|
1310 |
case Bytecodes::_fload_3:
|
|
1311 |
case Bytecodes::_iload_3:
|
|
1312 |
push( local(3) );
|
|
1313 |
break;
|
|
1314 |
case Bytecodes::_fload:
|
|
1315 |
case Bytecodes::_iload:
|
|
1316 |
push( local(iter().get_index()) );
|
|
1317 |
break;
|
|
1318 |
case Bytecodes::_lload_0:
|
|
1319 |
push_pair_local( 0 );
|
|
1320 |
break;
|
|
1321 |
case Bytecodes::_lload_1:
|
|
1322 |
push_pair_local( 1 );
|
|
1323 |
break;
|
|
1324 |
case Bytecodes::_lload_2:
|
|
1325 |
push_pair_local( 2 );
|
|
1326 |
break;
|
|
1327 |
case Bytecodes::_lload_3:
|
|
1328 |
push_pair_local( 3 );
|
|
1329 |
break;
|
|
1330 |
case Bytecodes::_lload:
|
|
1331 |
push_pair_local( iter().get_index() );
|
|
1332 |
break;
|
|
1333 |
|
|
1334 |
case Bytecodes::_dload_0:
|
|
1335 |
push_pair_local(0);
|
|
1336 |
break;
|
|
1337 |
case Bytecodes::_dload_1:
|
|
1338 |
push_pair_local(1);
|
|
1339 |
break;
|
|
1340 |
case Bytecodes::_dload_2:
|
|
1341 |
push_pair_local(2);
|
|
1342 |
break;
|
|
1343 |
case Bytecodes::_dload_3:
|
|
1344 |
push_pair_local(3);
|
|
1345 |
break;
|
|
1346 |
case Bytecodes::_dload:
|
|
1347 |
push_pair_local(iter().get_index());
|
|
1348 |
break;
|
|
1349 |
case Bytecodes::_fstore_0:
|
|
1350 |
case Bytecodes::_istore_0:
|
|
1351 |
case Bytecodes::_astore_0:
|
|
1352 |
set_local( 0, pop() );
|
|
1353 |
break;
|
|
1354 |
case Bytecodes::_fstore_1:
|
|
1355 |
case Bytecodes::_istore_1:
|
|
1356 |
case Bytecodes::_astore_1:
|
|
1357 |
set_local( 1, pop() );
|
|
1358 |
break;
|
|
1359 |
case Bytecodes::_fstore_2:
|
|
1360 |
case Bytecodes::_istore_2:
|
|
1361 |
case Bytecodes::_astore_2:
|
|
1362 |
set_local( 2, pop() );
|
|
1363 |
break;
|
|
1364 |
case Bytecodes::_fstore_3:
|
|
1365 |
case Bytecodes::_istore_3:
|
|
1366 |
case Bytecodes::_astore_3:
|
|
1367 |
set_local( 3, pop() );
|
|
1368 |
break;
|
|
1369 |
case Bytecodes::_fstore:
|
|
1370 |
case Bytecodes::_istore:
|
|
1371 |
case Bytecodes::_astore:
|
|
1372 |
set_local( iter().get_index(), pop() );
|
|
1373 |
break;
|
|
1374 |
// long stores
|
|
1375 |
case Bytecodes::_lstore_0:
|
|
1376 |
set_pair_local( 0, pop_pair() );
|
|
1377 |
break;
|
|
1378 |
case Bytecodes::_lstore_1:
|
|
1379 |
set_pair_local( 1, pop_pair() );
|
|
1380 |
break;
|
|
1381 |
case Bytecodes::_lstore_2:
|
|
1382 |
set_pair_local( 2, pop_pair() );
|
|
1383 |
break;
|
|
1384 |
case Bytecodes::_lstore_3:
|
|
1385 |
set_pair_local( 3, pop_pair() );
|
|
1386 |
break;
|
|
1387 |
case Bytecodes::_lstore:
|
|
1388 |
set_pair_local( iter().get_index(), pop_pair() );
|
|
1389 |
break;
|
|
1390 |
|
|
1391 |
// double stores
|
|
1392 |
case Bytecodes::_dstore_0:
|
|
1393 |
set_pair_local( 0, dstore_rounding(pop_pair()) );
|
|
1394 |
break;
|
|
1395 |
case Bytecodes::_dstore_1:
|
|
1396 |
set_pair_local( 1, dstore_rounding(pop_pair()) );
|
|
1397 |
break;
|
|
1398 |
case Bytecodes::_dstore_2:
|
|
1399 |
set_pair_local( 2, dstore_rounding(pop_pair()) );
|
|
1400 |
break;
|
|
1401 |
case Bytecodes::_dstore_3:
|
|
1402 |
set_pair_local( 3, dstore_rounding(pop_pair()) );
|
|
1403 |
break;
|
|
1404 |
case Bytecodes::_dstore:
|
|
1405 |
set_pair_local( iter().get_index(), dstore_rounding(pop_pair()) );
|
|
1406 |
break;
|
|
1407 |
|
|
1408 |
case Bytecodes::_pop: _sp -= 1; break;
|
|
1409 |
case Bytecodes::_pop2: _sp -= 2; break;
|
|
1410 |
case Bytecodes::_swap:
|
|
1411 |
a = pop();
|
|
1412 |
b = pop();
|
|
1413 |
push(a);
|
|
1414 |
push(b);
|
|
1415 |
break;
|
|
1416 |
case Bytecodes::_dup:
|
|
1417 |
a = pop();
|
|
1418 |
push(a);
|
|
1419 |
push(a);
|
|
1420 |
break;
|
|
1421 |
case Bytecodes::_dup_x1:
|
|
1422 |
a = pop();
|
|
1423 |
b = pop();
|
|
1424 |
push( a );
|
|
1425 |
push( b );
|
|
1426 |
push( a );
|
|
1427 |
break;
|
|
1428 |
case Bytecodes::_dup_x2:
|
|
1429 |
a = pop();
|
|
1430 |
b = pop();
|
|
1431 |
c = pop();
|
|
1432 |
push( a );
|
|
1433 |
push( c );
|
|
1434 |
push( b );
|
|
1435 |
push( a );
|
|
1436 |
break;
|
|
1437 |
case Bytecodes::_dup2:
|
|
1438 |
a = pop();
|
|
1439 |
b = pop();
|
|
1440 |
push( b );
|
|
1441 |
push( a );
|
|
1442 |
push( b );
|
|
1443 |
push( a );
|
|
1444 |
break;
|
|
1445 |
|
|
1446 |
case Bytecodes::_dup2_x1:
|
|
1447 |
// before: .. c, b, a
|
|
1448 |
// after: .. b, a, c, b, a
|
|
1449 |
// not tested
|
|
1450 |
a = pop();
|
|
1451 |
b = pop();
|
|
1452 |
c = pop();
|
|
1453 |
push( b );
|
|
1454 |
push( a );
|
|
1455 |
push( c );
|
|
1456 |
push( b );
|
|
1457 |
push( a );
|
|
1458 |
break;
|
|
1459 |
case Bytecodes::_dup2_x2:
|
|
1460 |
// before: .. d, c, b, a
|
|
1461 |
// after: .. b, a, d, c, b, a
|
|
1462 |
// not tested
|
|
1463 |
a = pop();
|
|
1464 |
b = pop();
|
|
1465 |
c = pop();
|
|
1466 |
d = pop();
|
|
1467 |
push( b );
|
|
1468 |
push( a );
|
|
1469 |
push( d );
|
|
1470 |
push( c );
|
|
1471 |
push( b );
|
|
1472 |
push( a );
|
|
1473 |
break;
|
|
1474 |
|
|
1475 |
case Bytecodes::_arraylength: {
|
|
1476 |
// Must do null-check with value on expression stack
|
|
1477 |
Node *ary = do_null_check(peek(), T_ARRAY);
|
|
1478 |
// Compile-time detect of null-exception?
|
|
1479 |
if (stopped()) return;
|
|
1480 |
a = pop();
|
|
1481 |
push(load_array_length(a));
|
|
1482 |
break;
|
|
1483 |
}
|
|
1484 |
|
|
1485 |
case Bytecodes::_baload: array_load(T_BYTE); break;
|
|
1486 |
case Bytecodes::_caload: array_load(T_CHAR); break;
|
|
1487 |
case Bytecodes::_iaload: array_load(T_INT); break;
|
|
1488 |
case Bytecodes::_saload: array_load(T_SHORT); break;
|
|
1489 |
case Bytecodes::_faload: array_load(T_FLOAT); break;
|
|
1490 |
case Bytecodes::_aaload: array_load(T_OBJECT); break;
|
|
1491 |
case Bytecodes::_laload: {
|
|
1492 |
a = array_addressing(T_LONG, 0);
|
|
1493 |
if (stopped()) return; // guarenteed null or range check
|
|
1494 |
_sp -= 2; // Pop array and index
|
|
1495 |
push_pair( make_load(control(), a, TypeLong::LONG, T_LONG, TypeAryPtr::LONGS));
|
|
1496 |
break;
|
|
1497 |
}
|
|
1498 |
case Bytecodes::_daload: {
|
|
1499 |
a = array_addressing(T_DOUBLE, 0);
|
|
1500 |
if (stopped()) return; // guarenteed null or range check
|
|
1501 |
_sp -= 2; // Pop array and index
|
|
1502 |
push_pair( make_load(control(), a, Type::DOUBLE, T_DOUBLE, TypeAryPtr::DOUBLES));
|
|
1503 |
break;
|
|
1504 |
}
|
|
1505 |
case Bytecodes::_bastore: array_store(T_BYTE); break;
|
|
1506 |
case Bytecodes::_castore: array_store(T_CHAR); break;
|
|
1507 |
case Bytecodes::_iastore: array_store(T_INT); break;
|
|
1508 |
case Bytecodes::_sastore: array_store(T_SHORT); break;
|
|
1509 |
case Bytecodes::_fastore: array_store(T_FLOAT); break;
|
|
1510 |
case Bytecodes::_aastore: {
|
|
1511 |
d = array_addressing(T_OBJECT, 1);
|
|
1512 |
if (stopped()) return; // guarenteed null or range check
|
|
1513 |
array_store_check();
|
|
1514 |
c = pop(); // Oop to store
|
|
1515 |
b = pop(); // index (already used)
|
|
1516 |
a = pop(); // the array itself
|
|
1517 |
const Type* elemtype = _gvn.type(a)->is_aryptr()->elem();
|
|
1518 |
const TypeAryPtr* adr_type = TypeAryPtr::OOPS;
|
|
1519 |
Node* store = store_oop_to_array(control(), a, d, adr_type, c, elemtype, T_OBJECT);
|
|
1520 |
break;
|
|
1521 |
}
|
|
1522 |
case Bytecodes::_lastore: {
|
|
1523 |
a = array_addressing(T_LONG, 2);
|
|
1524 |
if (stopped()) return; // guarenteed null or range check
|
|
1525 |
c = pop_pair();
|
|
1526 |
_sp -= 2; // Pop array and index
|
|
1527 |
store_to_memory(control(), a, c, T_LONG, TypeAryPtr::LONGS);
|
|
1528 |
break;
|
|
1529 |
}
|
|
1530 |
case Bytecodes::_dastore: {
|
|
1531 |
a = array_addressing(T_DOUBLE, 2);
|
|
1532 |
if (stopped()) return; // guarenteed null or range check
|
|
1533 |
c = pop_pair();
|
|
1534 |
_sp -= 2; // Pop array and index
|
|
1535 |
c = dstore_rounding(c);
|
|
1536 |
store_to_memory(control(), a, c, T_DOUBLE, TypeAryPtr::DOUBLES);
|
|
1537 |
break;
|
|
1538 |
}
|
|
1539 |
case Bytecodes::_getfield:
|
|
1540 |
do_getfield();
|
|
1541 |
break;
|
|
1542 |
|
|
1543 |
case Bytecodes::_getstatic:
|
|
1544 |
do_getstatic();
|
|
1545 |
break;
|
|
1546 |
|
|
1547 |
case Bytecodes::_putfield:
|
|
1548 |
do_putfield();
|
|
1549 |
break;
|
|
1550 |
|
|
1551 |
case Bytecodes::_putstatic:
|
|
1552 |
do_putstatic();
|
|
1553 |
break;
|
|
1554 |
|
|
1555 |
case Bytecodes::_irem:
|
|
1556 |
do_irem();
|
|
1557 |
break;
|
|
1558 |
case Bytecodes::_idiv:
|
|
1559 |
// Must keep both values on the expression-stack during null-check
|
|
1560 |
do_null_check(peek(), T_INT);
|
|
1561 |
// Compile-time detect of null-exception?
|
|
1562 |
if (stopped()) return;
|
|
1563 |
b = pop();
|
|
1564 |
a = pop();
|
|
1565 |
push( _gvn.transform( new (C, 3) DivINode(control(),a,b) ) );
|
|
1566 |
break;
|
|
1567 |
case Bytecodes::_imul:
|
|
1568 |
b = pop(); a = pop();
|
|
1569 |
push( _gvn.transform( new (C, 3) MulINode(a,b) ) );
|
|
1570 |
break;
|
|
1571 |
case Bytecodes::_iadd:
|
|
1572 |
b = pop(); a = pop();
|
|
1573 |
push( _gvn.transform( new (C, 3) AddINode(a,b) ) );
|
|
1574 |
break;
|
|
1575 |
case Bytecodes::_ineg:
|
|
1576 |
a = pop();
|
|
1577 |
push( _gvn.transform( new (C, 3) SubINode(_gvn.intcon(0),a)) );
|
|
1578 |
break;
|
|
1579 |
case Bytecodes::_isub:
|
|
1580 |
b = pop(); a = pop();
|
|
1581 |
push( _gvn.transform( new (C, 3) SubINode(a,b) ) );
|
|
1582 |
break;
|
|
1583 |
case Bytecodes::_iand:
|
|
1584 |
b = pop(); a = pop();
|
|
1585 |
push( _gvn.transform( new (C, 3) AndINode(a,b) ) );
|
|
1586 |
break;
|
|
1587 |
case Bytecodes::_ior:
|
|
1588 |
b = pop(); a = pop();
|
|
1589 |
push( _gvn.transform( new (C, 3) OrINode(a,b) ) );
|
|
1590 |
break;
|
|
1591 |
case Bytecodes::_ixor:
|
|
1592 |
b = pop(); a = pop();
|
|
1593 |
push( _gvn.transform( new (C, 3) XorINode(a,b) ) );
|
|
1594 |
break;
|
|
1595 |
case Bytecodes::_ishl:
|
|
1596 |
b = pop(); a = pop();
|
|
1597 |
push( _gvn.transform( new (C, 3) LShiftINode(a,b) ) );
|
|
1598 |
break;
|
|
1599 |
case Bytecodes::_ishr:
|
|
1600 |
b = pop(); a = pop();
|
|
1601 |
push( _gvn.transform( new (C, 3) RShiftINode(a,b) ) );
|
|
1602 |
break;
|
|
1603 |
case Bytecodes::_iushr:
|
|
1604 |
b = pop(); a = pop();
|
|
1605 |
push( _gvn.transform( new (C, 3) URShiftINode(a,b) ) );
|
|
1606 |
break;
|
|
1607 |
|
|
1608 |
case Bytecodes::_fneg:
|
|
1609 |
a = pop();
|
|
1610 |
b = _gvn.transform(new (C, 2) NegFNode (a));
|
|
1611 |
push(b);
|
|
1612 |
break;
|
|
1613 |
|
|
1614 |
case Bytecodes::_fsub:
|
|
1615 |
b = pop();
|
|
1616 |
a = pop();
|
|
1617 |
c = _gvn.transform( new (C, 3) SubFNode(a,b) );
|
|
1618 |
d = precision_rounding(c);
|
|
1619 |
push( d );
|
|
1620 |
break;
|
|
1621 |
|
|
1622 |
case Bytecodes::_fadd:
|
|
1623 |
b = pop();
|
|
1624 |
a = pop();
|
|
1625 |
c = _gvn.transform( new (C, 3) AddFNode(a,b) );
|
|
1626 |
d = precision_rounding(c);
|
|
1627 |
push( d );
|
|
1628 |
break;
|
|
1629 |
|
|
1630 |
case Bytecodes::_fmul:
|
|
1631 |
b = pop();
|
|
1632 |
a = pop();
|
|
1633 |
c = _gvn.transform( new (C, 3) MulFNode(a,b) );
|
|
1634 |
d = precision_rounding(c);
|
|
1635 |
push( d );
|
|
1636 |
break;
|
|
1637 |
|
|
1638 |
case Bytecodes::_fdiv:
|
|
1639 |
b = pop();
|
|
1640 |
a = pop();
|
|
1641 |
c = _gvn.transform( new (C, 3) DivFNode(0,a,b) );
|
|
1642 |
d = precision_rounding(c);
|
|
1643 |
push( d );
|
|
1644 |
break;
|
|
1645 |
|
|
1646 |
case Bytecodes::_frem:
|
|
1647 |
if (Matcher::has_match_rule(Op_ModF)) {
|
|
1648 |
// Generate a ModF node.
|
|
1649 |
b = pop();
|
|
1650 |
a = pop();
|
|
1651 |
c = _gvn.transform( new (C, 3) ModFNode(0,a,b) );
|
|
1652 |
d = precision_rounding(c);
|
|
1653 |
push( d );
|
|
1654 |
}
|
|
1655 |
else {
|
|
1656 |
// Generate a call.
|
|
1657 |
modf();
|
|
1658 |
}
|
|
1659 |
break;
|
|
1660 |
|
|
1661 |
case Bytecodes::_fcmpl:
|
|
1662 |
b = pop();
|
|
1663 |
a = pop();
|
|
1664 |
c = _gvn.transform( new (C, 3) CmpF3Node( a, b));
|
|
1665 |
push(c);
|
|
1666 |
break;
|
|
1667 |
case Bytecodes::_fcmpg:
|
|
1668 |
b = pop();
|
|
1669 |
a = pop();
|
|
1670 |
|
|
1671 |
// Same as fcmpl but need to flip the unordered case. Swap the inputs,
|
|
1672 |
// which negates the result sign except for unordered. Flip the unordered
|
|
1673 |
// as well by using CmpF3 which implements unordered-lesser instead of
|
|
1674 |
// unordered-greater semantics. Finally, commute the result bits. Result
|
|
1675 |
// is same as using a CmpF3Greater except we did it with CmpF3 alone.
|
|
1676 |
c = _gvn.transform( new (C, 3) CmpF3Node( b, a));
|
|
1677 |
c = _gvn.transform( new (C, 3) SubINode(_gvn.intcon(0),c) );
|
|
1678 |
push(c);
|
|
1679 |
break;
|
|
1680 |
|
|
1681 |
case Bytecodes::_f2i:
|
|
1682 |
a = pop();
|
|
1683 |
push(_gvn.transform(new (C, 2) ConvF2INode(a)));
|
|
1684 |
break;
|
|
1685 |
|
|
1686 |
case Bytecodes::_d2i:
|
|
1687 |
a = pop_pair();
|
|
1688 |
b = _gvn.transform(new (C, 2) ConvD2INode(a));
|
|
1689 |
push( b );
|
|
1690 |
break;
|
|
1691 |
|
|
1692 |
case Bytecodes::_f2d:
|
|
1693 |
a = pop();
|
|
1694 |
b = _gvn.transform( new (C, 2) ConvF2DNode(a));
|
|
1695 |
push_pair( b );
|
|
1696 |
break;
|
|
1697 |
|
|
1698 |
case Bytecodes::_d2f:
|
|
1699 |
a = pop_pair();
|
|
1700 |
b = _gvn.transform( new (C, 2) ConvD2FNode(a));
|
|
1701 |
// This breaks _227_mtrt (speed & correctness) and _222_mpegaudio (speed)
|
|
1702 |
//b = _gvn.transform(new (C, 2) RoundFloatNode(0, b) );
|
|
1703 |
push( b );
|
|
1704 |
break;
|
|
1705 |
|
|
1706 |
case Bytecodes::_l2f:
|
|
1707 |
if (Matcher::convL2FSupported()) {
|
|
1708 |
a = pop_pair();
|
|
1709 |
b = _gvn.transform( new (C, 2) ConvL2FNode(a));
|
|
1710 |
// For i486.ad, FILD doesn't restrict precision to 24 or 53 bits.
|
|
1711 |
// Rather than storing the result into an FP register then pushing
|
|
1712 |
// out to memory to round, the machine instruction that implements
|
|
1713 |
// ConvL2D is responsible for rounding.
|
|
1714 |
// c = precision_rounding(b);
|
|
1715 |
c = _gvn.transform(b);
|
|
1716 |
push(c);
|
|
1717 |
} else {
|
|
1718 |
l2f();
|
|
1719 |
}
|
|
1720 |
break;
|
|
1721 |
|
|
1722 |
case Bytecodes::_l2d:
|
|
1723 |
a = pop_pair();
|
|
1724 |
b = _gvn.transform( new (C, 2) ConvL2DNode(a));
|
|
1725 |
// For i486.ad, rounding is always necessary (see _l2f above).
|
|
1726 |
// c = dprecision_rounding(b);
|
|
1727 |
c = _gvn.transform(b);
|
|
1728 |
push_pair(c);
|
|
1729 |
break;
|
|
1730 |
|
|
1731 |
case Bytecodes::_f2l:
|
|
1732 |
a = pop();
|
|
1733 |
b = _gvn.transform( new (C, 2) ConvF2LNode(a));
|
|
1734 |
push_pair(b);
|
|
1735 |
break;
|
|
1736 |
|
|
1737 |
case Bytecodes::_d2l:
|
|
1738 |
a = pop_pair();
|
|
1739 |
b = _gvn.transform( new (C, 2) ConvD2LNode(a));
|
|
1740 |
push_pair(b);
|
|
1741 |
break;
|
|
1742 |
|
|
1743 |
case Bytecodes::_dsub:
|
|
1744 |
b = pop_pair();
|
|
1745 |
a = pop_pair();
|
|
1746 |
c = _gvn.transform( new (C, 3) SubDNode(a,b) );
|
|
1747 |
d = dprecision_rounding(c);
|
|
1748 |
push_pair( d );
|
|
1749 |
break;
|
|
1750 |
|
|
1751 |
case Bytecodes::_dadd:
|
|
1752 |
b = pop_pair();
|
|
1753 |
a = pop_pair();
|
|
1754 |
c = _gvn.transform( new (C, 3) AddDNode(a,b) );
|
|
1755 |
d = dprecision_rounding(c);
|
|
1756 |
push_pair( d );
|
|
1757 |
break;
|
|
1758 |
|
|
1759 |
case Bytecodes::_dmul:
|
|
1760 |
b = pop_pair();
|
|
1761 |
a = pop_pair();
|
|
1762 |
c = _gvn.transform( new (C, 3) MulDNode(a,b) );
|
|
1763 |
d = dprecision_rounding(c);
|
|
1764 |
push_pair( d );
|
|
1765 |
break;
|
|
1766 |
|
|
1767 |
case Bytecodes::_ddiv:
|
|
1768 |
b = pop_pair();
|
|
1769 |
a = pop_pair();
|
|
1770 |
c = _gvn.transform( new (C, 3) DivDNode(0,a,b) );
|
|
1771 |
d = dprecision_rounding(c);
|
|
1772 |
push_pair( d );
|
|
1773 |
break;
|
|
1774 |
|
|
1775 |
case Bytecodes::_dneg:
|
|
1776 |
a = pop_pair();
|
|
1777 |
b = _gvn.transform(new (C, 2) NegDNode (a));
|
|
1778 |
push_pair(b);
|
|
1779 |
break;
|
|
1780 |
|
|
1781 |
case Bytecodes::_drem:
|
|
1782 |
if (Matcher::has_match_rule(Op_ModD)) {
|
|
1783 |
// Generate a ModD node.
|
|
1784 |
b = pop_pair();
|
|
1785 |
a = pop_pair();
|
|
1786 |
// a % b
|
|
1787 |
|
|
1788 |
c = _gvn.transform( new (C, 3) ModDNode(0,a,b) );
|
|
1789 |
d = dprecision_rounding(c);
|
|
1790 |
push_pair( d );
|
|
1791 |
}
|
|
1792 |
else {
|
|
1793 |
// Generate a call.
|
|
1794 |
modd();
|
|
1795 |
}
|
|
1796 |
break;
|
|
1797 |
|
|
1798 |
case Bytecodes::_dcmpl:
|
|
1799 |
b = pop_pair();
|
|
1800 |
a = pop_pair();
|
|
1801 |
c = _gvn.transform( new (C, 3) CmpD3Node( a, b));
|
|
1802 |
push(c);
|
|
1803 |
break;
|
|
1804 |
|
|
1805 |
case Bytecodes::_dcmpg:
|
|
1806 |
b = pop_pair();
|
|
1807 |
a = pop_pair();
|
|
1808 |
// Same as dcmpl but need to flip the unordered case.
|
|
1809 |
// Commute the inputs, which negates the result sign except for unordered.
|
|
1810 |
// Flip the unordered as well by using CmpD3 which implements
|
|
1811 |
// unordered-lesser instead of unordered-greater semantics.
|
|
1812 |
// Finally, negate the result bits. Result is same as using a
|
|
1813 |
// CmpD3Greater except we did it with CmpD3 alone.
|
|
1814 |
c = _gvn.transform( new (C, 3) CmpD3Node( b, a));
|
|
1815 |
c = _gvn.transform( new (C, 3) SubINode(_gvn.intcon(0),c) );
|
|
1816 |
push(c);
|
|
1817 |
break;
|
|
1818 |
|
|
1819 |
|
|
1820 |
// Note for longs -> lo word is on TOS, hi word is on TOS - 1
|
|
1821 |
case Bytecodes::_land:
|
|
1822 |
b = pop_pair();
|
|
1823 |
a = pop_pair();
|
|
1824 |
c = _gvn.transform( new (C, 3) AndLNode(a,b) );
|
|
1825 |
push_pair(c);
|
|
1826 |
break;
|
|
1827 |
case Bytecodes::_lor:
|
|
1828 |
b = pop_pair();
|
|
1829 |
a = pop_pair();
|
|
1830 |
c = _gvn.transform( new (C, 3) OrLNode(a,b) );
|
|
1831 |
push_pair(c);
|
|
1832 |
break;
|
|
1833 |
case Bytecodes::_lxor:
|
|
1834 |
b = pop_pair();
|
|
1835 |
a = pop_pair();
|
|
1836 |
c = _gvn.transform( new (C, 3) XorLNode(a,b) );
|
|
1837 |
push_pair(c);
|
|
1838 |
break;
|
|
1839 |
|
|
1840 |
case Bytecodes::_lshl:
|
|
1841 |
b = pop(); // the shift count
|
|
1842 |
a = pop_pair(); // value to be shifted
|
|
1843 |
c = _gvn.transform( new (C, 3) LShiftLNode(a,b) );
|
|
1844 |
push_pair(c);
|
|
1845 |
break;
|
|
1846 |
case Bytecodes::_lshr:
|
|
1847 |
b = pop(); // the shift count
|
|
1848 |
a = pop_pair(); // value to be shifted
|
|
1849 |
c = _gvn.transform( new (C, 3) RShiftLNode(a,b) );
|
|
1850 |
push_pair(c);
|
|
1851 |
break;
|
|
1852 |
case Bytecodes::_lushr:
|
|
1853 |
b = pop(); // the shift count
|
|
1854 |
a = pop_pair(); // value to be shifted
|
|
1855 |
c = _gvn.transform( new (C, 3) URShiftLNode(a,b) );
|
|
1856 |
push_pair(c);
|
|
1857 |
break;
|
|
1858 |
case Bytecodes::_lmul:
|
|
1859 |
b = pop_pair();
|
|
1860 |
a = pop_pair();
|
|
1861 |
c = _gvn.transform( new (C, 3) MulLNode(a,b) );
|
|
1862 |
push_pair(c);
|
|
1863 |
break;
|
|
1864 |
|
|
1865 |
case Bytecodes::_lrem:
|
|
1866 |
// Must keep both values on the expression-stack during null-check
|
|
1867 |
assert(peek(0) == top(), "long word order");
|
|
1868 |
do_null_check(peek(1), T_LONG);
|
|
1869 |
// Compile-time detect of null-exception?
|
|
1870 |
if (stopped()) return;
|
|
1871 |
b = pop_pair();
|
|
1872 |
a = pop_pair();
|
|
1873 |
c = _gvn.transform( new (C, 3) ModLNode(control(),a,b) );
|
|
1874 |
push_pair(c);
|
|
1875 |
break;
|
|
1876 |
|
|
1877 |
case Bytecodes::_ldiv:
|
|
1878 |
// Must keep both values on the expression-stack during null-check
|
|
1879 |
assert(peek(0) == top(), "long word order");
|
|
1880 |
do_null_check(peek(1), T_LONG);
|
|
1881 |
// Compile-time detect of null-exception?
|
|
1882 |
if (stopped()) return;
|
|
1883 |
b = pop_pair();
|
|
1884 |
a = pop_pair();
|
|
1885 |
c = _gvn.transform( new (C, 3) DivLNode(control(),a,b) );
|
|
1886 |
push_pair(c);
|
|
1887 |
break;
|
|
1888 |
|
|
1889 |
case Bytecodes::_ladd:
|
|
1890 |
b = pop_pair();
|
|
1891 |
a = pop_pair();
|
|
1892 |
c = _gvn.transform( new (C, 3) AddLNode(a,b) );
|
|
1893 |
push_pair(c);
|
|
1894 |
break;
|
|
1895 |
case Bytecodes::_lsub:
|
|
1896 |
b = pop_pair();
|
|
1897 |
a = pop_pair();
|
|
1898 |
c = _gvn.transform( new (C, 3) SubLNode(a,b) );
|
|
1899 |
push_pair(c);
|
|
1900 |
break;
|
|
1901 |
case Bytecodes::_lcmp:
|
|
1902 |
// Safepoints are now inserted _before_ branches. The long-compare
|
|
1903 |
// bytecode painfully produces a 3-way value (-1,0,+1) which requires a
|
|
1904 |
// slew of control flow. These are usually followed by a CmpI vs zero and
|
|
1905 |
// a branch; this pattern then optimizes to the obvious long-compare and
|
|
1906 |
// branch. However, if the branch is backwards there's a Safepoint
|
|
1907 |
// inserted. The inserted Safepoint captures the JVM state at the
|
|
1908 |
// pre-branch point, i.e. it captures the 3-way value. Thus if a
|
|
1909 |
// long-compare is used to control a loop the debug info will force
|
|
1910 |
// computation of the 3-way value, even though the generated code uses a
|
|
1911 |
// long-compare and branch. We try to rectify the situation by inserting
|
|
1912 |
// a SafePoint here and have it dominate and kill the safepoint added at a
|
|
1913 |
// following backwards branch. At this point the JVM state merely holds 2
|
|
1914 |
// longs but not the 3-way value.
|
|
1915 |
if( UseLoopSafepoints ) {
|
|
1916 |
switch( iter().next_bc() ) {
|
|
1917 |
case Bytecodes::_ifgt:
|
|
1918 |
case Bytecodes::_iflt:
|
|
1919 |
case Bytecodes::_ifge:
|
|
1920 |
case Bytecodes::_ifle:
|
|
1921 |
case Bytecodes::_ifne:
|
|
1922 |
case Bytecodes::_ifeq:
|
|
1923 |
// If this is a backwards branch in the bytecodes, add Safepoint
|
|
1924 |
maybe_add_safepoint(iter().next_get_dest());
|
|
1925 |
}
|
|
1926 |
}
|
|
1927 |
b = pop_pair();
|
|
1928 |
a = pop_pair();
|
|
1929 |
c = _gvn.transform( new (C, 3) CmpL3Node( a, b ));
|
|
1930 |
push(c);
|
|
1931 |
break;
|
|
1932 |
|
|
1933 |
case Bytecodes::_lneg:
|
|
1934 |
a = pop_pair();
|
|
1935 |
b = _gvn.transform( new (C, 3) SubLNode(longcon(0),a));
|
|
1936 |
push_pair(b);
|
|
1937 |
break;
|
|
1938 |
case Bytecodes::_l2i:
|
|
1939 |
a = pop_pair();
|
|
1940 |
push( _gvn.transform( new (C, 2) ConvL2INode(a)));
|
|
1941 |
break;
|
|
1942 |
case Bytecodes::_i2l:
|
|
1943 |
a = pop();
|
|
1944 |
b = _gvn.transform( new (C, 2) ConvI2LNode(a));
|
|
1945 |
push_pair(b);
|
|
1946 |
break;
|
|
1947 |
case Bytecodes::_i2b:
|
|
1948 |
// Sign extend
|
|
1949 |
a = pop();
|
|
1950 |
a = _gvn.transform( new (C, 3) LShiftINode(a,_gvn.intcon(24)) );
|
|
1951 |
a = _gvn.transform( new (C, 3) RShiftINode(a,_gvn.intcon(24)) );
|
|
1952 |
push( a );
|
|
1953 |
break;
|
|
1954 |
case Bytecodes::_i2s:
|
|
1955 |
a = pop();
|
|
1956 |
a = _gvn.transform( new (C, 3) LShiftINode(a,_gvn.intcon(16)) );
|
|
1957 |
a = _gvn.transform( new (C, 3) RShiftINode(a,_gvn.intcon(16)) );
|
|
1958 |
push( a );
|
|
1959 |
break;
|
|
1960 |
case Bytecodes::_i2c:
|
|
1961 |
a = pop();
|
|
1962 |
push( _gvn.transform( new (C, 3) AndINode(a,_gvn.intcon(0xFFFF)) ) );
|
|
1963 |
break;
|
|
1964 |
|
|
1965 |
case Bytecodes::_i2f:
|
|
1966 |
a = pop();
|
|
1967 |
b = _gvn.transform( new (C, 2) ConvI2FNode(a) ) ;
|
|
1968 |
c = precision_rounding(b);
|
|
1969 |
push (b);
|
|
1970 |
break;
|
|
1971 |
|
|
1972 |
case Bytecodes::_i2d:
|
|
1973 |
a = pop();
|
|
1974 |
b = _gvn.transform( new (C, 2) ConvI2DNode(a));
|
|
1975 |
push_pair(b);
|
|
1976 |
break;
|
|
1977 |
|
|
1978 |
case Bytecodes::_iinc: // Increment local
|
|
1979 |
i = iter().get_index(); // Get local index
|
|
1980 |
set_local( i, _gvn.transform( new (C, 3) AddINode( _gvn.intcon(iter().get_iinc_con()), local(i) ) ) );
|
|
1981 |
break;
|
|
1982 |
|
|
1983 |
// Exit points of synchronized methods must have an unlock node
|
|
1984 |
case Bytecodes::_return:
|
|
1985 |
return_current(NULL);
|
|
1986 |
break;
|
|
1987 |
|
|
1988 |
case Bytecodes::_ireturn:
|
|
1989 |
case Bytecodes::_areturn:
|
|
1990 |
case Bytecodes::_freturn:
|
|
1991 |
return_current(pop());
|
|
1992 |
break;
|
|
1993 |
case Bytecodes::_lreturn:
|
|
1994 |
return_current(pop_pair());
|
|
1995 |
break;
|
|
1996 |
case Bytecodes::_dreturn:
|
|
1997 |
return_current(pop_pair());
|
|
1998 |
break;
|
|
1999 |
|
|
2000 |
case Bytecodes::_athrow:
|
|
2001 |
// null exception oop throws NULL pointer exception
|
|
2002 |
do_null_check(peek(), T_OBJECT);
|
|
2003 |
if (stopped()) return;
|
|
2004 |
if (JvmtiExport::can_post_exceptions()) {
|
|
2005 |
// "Full-speed throwing" is not necessary here,
|
|
2006 |
// since we're notifying the VM on every throw.
|
|
2007 |
uncommon_trap(Deoptimization::Reason_unhandled,
|
|
2008 |
Deoptimization::Action_none);
|
|
2009 |
return;
|
|
2010 |
}
|
|
2011 |
// Hook the thrown exception directly to subsequent handlers.
|
|
2012 |
if (BailoutToInterpreterForThrows) {
|
|
2013 |
// Keep method interpreted from now on.
|
|
2014 |
uncommon_trap(Deoptimization::Reason_unhandled,
|
|
2015 |
Deoptimization::Action_make_not_compilable);
|
|
2016 |
return;
|
|
2017 |
}
|
|
2018 |
add_exception_state(make_exception_state(peek()));
|
|
2019 |
break;
|
|
2020 |
|
|
2021 |
case Bytecodes::_goto: // fall through
|
|
2022 |
case Bytecodes::_goto_w: {
|
|
2023 |
int target_bci = (bc() == Bytecodes::_goto) ? iter().get_dest() : iter().get_far_dest();
|
|
2024 |
|
|
2025 |
// If this is a backwards branch in the bytecodes, add Safepoint
|
|
2026 |
maybe_add_safepoint(target_bci);
|
|
2027 |
|
|
2028 |
// Update method data
|
|
2029 |
profile_taken_branch(target_bci);
|
|
2030 |
|
|
2031 |
// Merge the current control into the target basic block
|
|
2032 |
merge(target_bci);
|
|
2033 |
|
|
2034 |
// See if we can get some profile data and hand it off to the next block
|
|
2035 |
Block *target_block = block()->successor_for_bci(target_bci);
|
|
2036 |
if (target_block->pred_count() != 1) break;
|
|
2037 |
ciMethodData* methodData = method()->method_data();
|
|
2038 |
if (!methodData->is_mature()) break;
|
|
2039 |
ciProfileData* data = methodData->bci_to_data(bci());
|
|
2040 |
assert( data->is_JumpData(), "" );
|
|
2041 |
int taken = ((ciJumpData*)data)->taken();
|
|
2042 |
taken = method()->scale_count(taken);
|
|
2043 |
target_block->set_count(taken);
|
|
2044 |
break;
|
|
2045 |
}
|
|
2046 |
|
|
2047 |
case Bytecodes::_ifnull:
|
|
2048 |
do_ifnull(BoolTest::eq);
|
|
2049 |
break;
|
|
2050 |
case Bytecodes::_ifnonnull:
|
|
2051 |
do_ifnull(BoolTest::ne);
|
|
2052 |
break;
|
|
2053 |
|
|
2054 |
case Bytecodes::_if_acmpeq: btest = BoolTest::eq; goto handle_if_acmp;
|
|
2055 |
case Bytecodes::_if_acmpne: btest = BoolTest::ne; goto handle_if_acmp;
|
|
2056 |
handle_if_acmp:
|
|
2057 |
// If this is a backwards branch in the bytecodes, add Safepoint
|
|
2058 |
maybe_add_safepoint(iter().get_dest());
|
|
2059 |
a = pop();
|
|
2060 |
b = pop();
|
|
2061 |
c = _gvn.transform( new (C, 3) CmpPNode(b, a) );
|
|
2062 |
do_if(btest, c);
|
|
2063 |
break;
|
|
2064 |
|
|
2065 |
case Bytecodes::_ifeq: btest = BoolTest::eq; goto handle_ifxx;
|
|
2066 |
case Bytecodes::_ifne: btest = BoolTest::ne; goto handle_ifxx;
|
|
2067 |
case Bytecodes::_iflt: btest = BoolTest::lt; goto handle_ifxx;
|
|
2068 |
case Bytecodes::_ifle: btest = BoolTest::le; goto handle_ifxx;
|
|
2069 |
case Bytecodes::_ifgt: btest = BoolTest::gt; goto handle_ifxx;
|
|
2070 |
case Bytecodes::_ifge: btest = BoolTest::ge; goto handle_ifxx;
|
|
2071 |
handle_ifxx:
|
|
2072 |
// If this is a backwards branch in the bytecodes, add Safepoint
|
|
2073 |
maybe_add_safepoint(iter().get_dest());
|
|
2074 |
a = _gvn.intcon(0);
|
|
2075 |
b = pop();
|
|
2076 |
c = _gvn.transform( new (C, 3) CmpINode(b, a) );
|
|
2077 |
do_if(btest, c);
|
|
2078 |
break;
|
|
2079 |
|
|
2080 |
case Bytecodes::_if_icmpeq: btest = BoolTest::eq; goto handle_if_icmp;
|
|
2081 |
case Bytecodes::_if_icmpne: btest = BoolTest::ne; goto handle_if_icmp;
|
|
2082 |
case Bytecodes::_if_icmplt: btest = BoolTest::lt; goto handle_if_icmp;
|
|
2083 |
case Bytecodes::_if_icmple: btest = BoolTest::le; goto handle_if_icmp;
|
|
2084 |
case Bytecodes::_if_icmpgt: btest = BoolTest::gt; goto handle_if_icmp;
|
|
2085 |
case Bytecodes::_if_icmpge: btest = BoolTest::ge; goto handle_if_icmp;
|
|
2086 |
handle_if_icmp:
|
|
2087 |
// If this is a backwards branch in the bytecodes, add Safepoint
|
|
2088 |
maybe_add_safepoint(iter().get_dest());
|
|
2089 |
a = pop();
|
|
2090 |
b = pop();
|
|
2091 |
c = _gvn.transform( new (C, 3) CmpINode( b, a ) );
|
|
2092 |
do_if(btest, c);
|
|
2093 |
break;
|
|
2094 |
|
|
2095 |
case Bytecodes::_tableswitch:
|
|
2096 |
do_tableswitch();
|
|
2097 |
break;
|
|
2098 |
|
|
2099 |
case Bytecodes::_lookupswitch:
|
|
2100 |
do_lookupswitch();
|
|
2101 |
break;
|
|
2102 |
|
|
2103 |
case Bytecodes::_invokestatic:
|
|
2104 |
case Bytecodes::_invokespecial:
|
|
2105 |
case Bytecodes::_invokevirtual:
|
|
2106 |
case Bytecodes::_invokeinterface:
|
|
2107 |
do_call();
|
|
2108 |
break;
|
|
2109 |
case Bytecodes::_checkcast:
|
|
2110 |
do_checkcast();
|
|
2111 |
break;
|
|
2112 |
case Bytecodes::_instanceof:
|
|
2113 |
do_instanceof();
|
|
2114 |
break;
|
|
2115 |
case Bytecodes::_anewarray:
|
|
2116 |
do_anewarray();
|
|
2117 |
break;
|
|
2118 |
case Bytecodes::_newarray:
|
|
2119 |
do_newarray((BasicType)iter().get_index());
|
|
2120 |
break;
|
|
2121 |
case Bytecodes::_multianewarray:
|
|
2122 |
do_multianewarray();
|
|
2123 |
break;
|
|
2124 |
case Bytecodes::_new:
|
|
2125 |
do_new();
|
|
2126 |
break;
|
|
2127 |
|
|
2128 |
case Bytecodes::_jsr:
|
|
2129 |
case Bytecodes::_jsr_w:
|
|
2130 |
do_jsr();
|
|
2131 |
break;
|
|
2132 |
|
|
2133 |
case Bytecodes::_ret:
|
|
2134 |
do_ret();
|
|
2135 |
break;
|
|
2136 |
|
|
2137 |
|
|
2138 |
case Bytecodes::_monitorenter:
|
|
2139 |
do_monitor_enter();
|
|
2140 |
break;
|
|
2141 |
|
|
2142 |
case Bytecodes::_monitorexit:
|
|
2143 |
do_monitor_exit();
|
|
2144 |
break;
|
|
2145 |
|
|
2146 |
case Bytecodes::_breakpoint:
|
|
2147 |
// Breakpoint set concurrently to compile
|
|
2148 |
// %%% use an uncommon trap?
|
|
2149 |
C->record_failure("breakpoint in method");
|
|
2150 |
return;
|
|
2151 |
|
|
2152 |
default:
|
|
2153 |
#ifndef PRODUCT
|
|
2154 |
map()->dump(99);
|
|
2155 |
#endif
|
|
2156 |
tty->print("\nUnhandled bytecode %s\n", Bytecodes::name(bc()) );
|
|
2157 |
ShouldNotReachHere();
|
|
2158 |
}
|
|
2159 |
|
|
2160 |
#ifndef PRODUCT
|
|
2161 |
IdealGraphPrinter *printer = IdealGraphPrinter::printer();
|
|
2162 |
if(printer) {
|
|
2163 |
char buffer[256];
|
|
2164 |
sprintf(buffer, "Bytecode %d: %s", bci(), Bytecodes::name(bc()));
|
|
2165 |
bool old = printer->traverse_outs();
|
|
2166 |
printer->set_traverse_outs(true);
|
|
2167 |
printer->print_method(C, buffer, 3);
|
|
2168 |
printer->set_traverse_outs(old);
|
|
2169 |
}
|
|
2170 |
#endif
|
|
2171 |
}
|