Mercurial > hg > truffle
annotate src/share/vm/opto/connode.cpp @ 21231:0bb06deee33b
Check for null in LabelOp#setIncomingValues and JumpOp#setOutgoingValues.
author | Josef Eisl <josef.eisl@jku.at> |
---|---|
date | Tue, 05 May 2015 12:12:33 +0200 |
parents | 7848fc12602b |
children |
rev | line source |
---|---|
0 | 1 /* |
14223
de6a9e811145
8029233: Update copyright year to match last edit in jdk8 hotspot repository for 2013
mikael
parents:
12226
diff
changeset
|
2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. |
0 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
995
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
995
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
995
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #include "precompiled.hpp" |
26 #include "memory/allocation.inline.hpp" | |
27 #include "opto/addnode.hpp" | |
28 #include "opto/compile.hpp" | |
29 #include "opto/connode.hpp" | |
30 #include "opto/machnode.hpp" | |
31 #include "opto/matcher.hpp" | |
32 #include "opto/memnode.hpp" | |
33 #include "opto/phaseX.hpp" | |
34 #include "opto/subnode.hpp" | |
35 #include "runtime/sharedRuntime.hpp" | |
0 | 36 |
1972 | 37 // Optimization - Graph Style |
0 | 38 |
39 //============================================================================= | |
40 //------------------------------hash------------------------------------------- | |
41 uint ConNode::hash() const { | |
42 return (uintptr_t)in(TypeFunc::Control) + _type->hash(); | |
43 } | |
44 | |
45 //------------------------------make------------------------------------------- | |
46 ConNode *ConNode::make( Compile* C, const Type *t ) { | |
47 switch( t->basic_type() ) { | |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6804
diff
changeset
|
48 case T_INT: return new (C) ConINode( t->is_int() ); |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6804
diff
changeset
|
49 case T_LONG: return new (C) ConLNode( t->is_long() ); |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6804
diff
changeset
|
50 case T_FLOAT: return new (C) ConFNode( t->is_float_constant() ); |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6804
diff
changeset
|
51 case T_DOUBLE: return new (C) ConDNode( t->is_double_constant() ); |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6804
diff
changeset
|
52 case T_VOID: return new (C) ConNode ( Type::TOP ); |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6804
diff
changeset
|
53 case T_OBJECT: return new (C) ConPNode( t->is_ptr() ); |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6804
diff
changeset
|
54 case T_ARRAY: return new (C) ConPNode( t->is_aryptr() ); |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6804
diff
changeset
|
55 case T_ADDRESS: return new (C) ConPNode( t->is_ptr() ); |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6804
diff
changeset
|
56 case T_NARROWOOP: return new (C) ConNNode( t->is_narrowoop() ); |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6804
diff
changeset
|
57 case T_NARROWKLASS: return new (C) ConNKlassNode( t->is_narrowklass() ); |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6804
diff
changeset
|
58 case T_METADATA: return new (C) ConPNode( t->is_ptr() ); |
0 | 59 // Expected cases: TypePtr::NULL_PTR, any is_rawptr() |
60 // Also seen: AnyPtr(TopPTR *+top); from command line: | |
61 // r -XX:+PrintOpto -XX:CIStart=285 -XX:+CompileTheWorld -XX:CompileTheWorldStartAt=660 | |
62 // %%%% Stop using TypePtr::NULL_PTR to represent nulls: use either TypeRawPtr::NULL_PTR | |
63 // or else TypeOopPtr::NULL_PTR. Then set Type::_basic_type[AnyPtr] = T_ILLEGAL | |
64 } | |
65 ShouldNotReachHere(); | |
66 return NULL; | |
67 } | |
68 | |
69 //============================================================================= | |
70 /* | |
71 The major change is for CMoveP and StrComp. They have related but slightly | |
72 different problems. They both take in TWO oops which are both null-checked | |
73 independently before the using Node. After CCP removes the CastPP's they need | |
74 to pick up the guarding test edge - in this case TWO control edges. I tried | |
75 various solutions, all have problems: | |
76 | |
77 (1) Do nothing. This leads to a bug where we hoist a Load from a CMoveP or a | |
78 StrComp above a guarding null check. I've seen both cases in normal -Xcomp | |
79 testing. | |
80 | |
81 (2) Plug the control edge from 1 of the 2 oops in. Apparent problem here is | |
82 to figure out which test post-dominates. The real problem is that it doesn't | |
83 matter which one you pick. After you pick up, the dominating-test elider in | |
84 IGVN can remove the test and allow you to hoist up to the dominating test on | |
605 | 85 the chosen oop bypassing the test on the not-chosen oop. Seen in testing. |
0 | 86 Oops. |
87 | |
88 (3) Leave the CastPP's in. This makes the graph more accurate in some sense; | |
89 we get to keep around the knowledge that an oop is not-null after some test. | |
90 Alas, the CastPP's interfere with GVN (some values are the regular oop, some | |
91 are the CastPP of the oop, all merge at Phi's which cannot collapse, etc). | |
92 This cost us 10% on SpecJVM, even when I removed some of the more trivial | |
93 cases in the optimizer. Removing more useless Phi's started allowing Loads to | |
94 illegally float above null checks. I gave up on this approach. | |
95 | |
96 (4) Add BOTH control edges to both tests. Alas, too much code knows that | |
97 control edges are in slot-zero ONLY. Many quick asserts fail; no way to do | |
98 this one. Note that I really want to allow the CMoveP to float and add both | |
99 control edges to the dependent Load op - meaning I can select early but I | |
100 cannot Load until I pass both tests. | |
101 | |
102 (5) Do not hoist CMoveP and StrComp. To this end I added the v-call | |
103 depends_only_on_test(). No obvious performance loss on Spec, but we are | |
104 clearly conservative on CMoveP (also so on StrComp but that's unlikely to | |
105 matter ever). | |
106 | |
107 */ | |
108 | |
109 | |
110 //------------------------------Ideal------------------------------------------ | |
111 // Return a node which is more "ideal" than the current node. | |
112 // Move constants to the right. | |
113 Node *CMoveNode::Ideal(PhaseGVN *phase, bool can_reshape) { | |
114 if( in(0) && remove_dead_region(phase, can_reshape) ) return this; | |
305 | 115 // Don't bother trying to transform a dead node |
116 if( in(0) && in(0)->is_top() ) return NULL; | |
0 | 117 assert( !phase->eqv(in(Condition), this) && |
118 !phase->eqv(in(IfFalse), this) && | |
119 !phase->eqv(in(IfTrue), this), "dead loop in CMoveNode::Ideal" ); | |
120 if( phase->type(in(Condition)) == Type::TOP ) | |
121 return NULL; // return NULL when Condition is dead | |
122 | |
123 if( in(IfFalse)->is_Con() && !in(IfTrue)->is_Con() ) { | |
124 if( in(Condition)->is_Bool() ) { | |
125 BoolNode* b = in(Condition)->as_Bool(); | |
126 BoolNode* b2 = b->negate(phase); | |
127 return make( phase->C, in(Control), phase->transform(b2), in(IfTrue), in(IfFalse), _type ); | |
128 } | |
129 } | |
130 return NULL; | |
131 } | |
132 | |
133 //------------------------------is_cmove_id------------------------------------ | |
134 // Helper function to check for CMOVE identity. Shared with PhiNode::Identity | |
135 Node *CMoveNode::is_cmove_id( PhaseTransform *phase, Node *cmp, Node *t, Node *f, BoolNode *b ) { | |
136 // Check for Cmp'ing and CMove'ing same values | |
137 if( (phase->eqv(cmp->in(1),f) && | |
138 phase->eqv(cmp->in(2),t)) || | |
139 // Swapped Cmp is OK | |
140 (phase->eqv(cmp->in(2),f) && | |
141 phase->eqv(cmp->in(1),t)) ) { | |
755
36ee9b69616e
6833879: Assigning positive zero is ignored when old value is negative zero
cfang
parents:
642
diff
changeset
|
142 // Give up this identity check for floating points because it may choose incorrect |
36ee9b69616e
6833879: Assigning positive zero is ignored when old value is negative zero
cfang
parents:
642
diff
changeset
|
143 // value around 0.0 and -0.0 |
36ee9b69616e
6833879: Assigning positive zero is ignored when old value is negative zero
cfang
parents:
642
diff
changeset
|
144 if ( cmp->Opcode()==Op_CmpF || cmp->Opcode()==Op_CmpD ) |
36ee9b69616e
6833879: Assigning positive zero is ignored when old value is negative zero
cfang
parents:
642
diff
changeset
|
145 return NULL; |
0 | 146 // Check for "(t==f)?t:f;" and replace with "f" |
147 if( b->_test._test == BoolTest::eq ) | |
148 return f; | |
149 // Allow the inverted case as well | |
150 // Check for "(t!=f)?t:f;" and replace with "t" | |
151 if( b->_test._test == BoolTest::ne ) | |
152 return t; | |
153 } | |
154 return NULL; | |
155 } | |
156 | |
157 //------------------------------Identity--------------------------------------- | |
158 // Conditional-move is an identity if both inputs are the same, or the test | |
159 // true or false. | |
160 Node *CMoveNode::Identity( PhaseTransform *phase ) { | |
161 if( phase->eqv(in(IfFalse),in(IfTrue)) ) // C-moving identical inputs? | |
162 return in(IfFalse); // Then it doesn't matter | |
163 if( phase->type(in(Condition)) == TypeInt::ZERO ) | |
164 return in(IfFalse); // Always pick left(false) input | |
165 if( phase->type(in(Condition)) == TypeInt::ONE ) | |
166 return in(IfTrue); // Always pick right(true) input | |
167 | |
168 // Check for CMove'ing a constant after comparing against the constant. | |
169 // Happens all the time now, since if we compare equality vs a constant in | |
170 // the parser, we "know" the variable is constant on one path and we force | |
171 // it. Thus code like "if( x==0 ) {/*EMPTY*/}" ends up inserting a | |
172 // conditional move: "x = (x==0)?0:x;". Yucko. This fix is slightly more | |
173 // general in that we don't need constants. | |
174 if( in(Condition)->is_Bool() ) { | |
175 BoolNode *b = in(Condition)->as_Bool(); | |
176 Node *cmp = b->in(1); | |
177 if( cmp->is_Cmp() ) { | |
178 Node *id = is_cmove_id( phase, cmp, in(IfTrue), in(IfFalse), b ); | |
179 if( id ) return id; | |
180 } | |
181 } | |
182 | |
183 return this; | |
184 } | |
185 | |
186 //------------------------------Value------------------------------------------ | |
187 // Result is the meet of inputs | |
188 const Type *CMoveNode::Value( PhaseTransform *phase ) const { | |
189 if( phase->type(in(Condition)) == Type::TOP ) | |
190 return Type::TOP; | |
14383
5ec7dace41a6
8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
14223
diff
changeset
|
191 return phase->type(in(IfFalse))->meet_speculative(phase->type(in(IfTrue))); |
0 | 192 } |
193 | |
194 //------------------------------make------------------------------------------- | |
195 // Make a correctly-flavored CMove. Since _type is directly determined | |
196 // from the inputs we do not need to specify it here. | |
197 CMoveNode *CMoveNode::make( Compile *C, Node *c, Node *bol, Node *left, Node *right, const Type *t ) { | |
198 switch( t->basic_type() ) { | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6795
diff
changeset
|
199 case T_INT: return new (C) CMoveINode( bol, left, right, t->is_int() ); |
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6795
diff
changeset
|
200 case T_FLOAT: return new (C) CMoveFNode( bol, left, right, t ); |
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6795
diff
changeset
|
201 case T_DOUBLE: return new (C) CMoveDNode( bol, left, right, t ); |
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6795
diff
changeset
|
202 case T_LONG: return new (C) CMoveLNode( bol, left, right, t->is_long() ); |
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6795
diff
changeset
|
203 case T_OBJECT: return new (C) CMovePNode( c, bol, left, right, t->is_oopptr() ); |
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6795
diff
changeset
|
204 case T_ADDRESS: return new (C) CMovePNode( c, bol, left, right, t->is_ptr() ); |
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6795
diff
changeset
|
205 case T_NARROWOOP: return new (C) CMoveNNode( c, bol, left, right, t ); |
0 | 206 default: |
207 ShouldNotReachHere(); | |
208 return NULL; | |
209 } | |
210 } | |
211 | |
212 //============================================================================= | |
213 //------------------------------Ideal------------------------------------------ | |
214 // Return a node which is more "ideal" than the current node. | |
215 // Check for conversions to boolean | |
216 Node *CMoveINode::Ideal(PhaseGVN *phase, bool can_reshape) { | |
217 // Try generic ideal's first | |
218 Node *x = CMoveNode::Ideal(phase, can_reshape); | |
219 if( x ) return x; | |
220 | |
221 // If zero is on the left (false-case, no-move-case) it must mean another | |
222 // constant is on the right (otherwise the shared CMove::Ideal code would | |
223 // have moved the constant to the right). This situation is bad for Intel | |
224 // and a don't-care for Sparc. It's bad for Intel because the zero has to | |
225 // be manifested in a register with a XOR which kills flags, which are live | |
226 // on input to the CMoveI, leading to a situation which causes excessive | |
227 // spilling on Intel. For Sparc, if the zero in on the left the Sparc will | |
228 // zero a register via G0 and conditionally-move the other constant. If the | |
229 // zero is on the right, the Sparc will load the first constant with a | |
230 // 13-bit set-lo and conditionally move G0. See bug 4677505. | |
231 if( phase->type(in(IfFalse)) == TypeInt::ZERO && !(phase->type(in(IfTrue)) == TypeInt::ZERO) ) { | |
232 if( in(Condition)->is_Bool() ) { | |
233 BoolNode* b = in(Condition)->as_Bool(); | |
234 BoolNode* b2 = b->negate(phase); | |
235 return make( phase->C, in(Control), phase->transform(b2), in(IfTrue), in(IfFalse), _type ); | |
236 } | |
237 } | |
238 | |
239 // Now check for booleans | |
240 int flip = 0; | |
241 | |
242 // Check for picking from zero/one | |
243 if( phase->type(in(IfFalse)) == TypeInt::ZERO && phase->type(in(IfTrue)) == TypeInt::ONE ) { | |
244 flip = 1 - flip; | |
245 } else if( phase->type(in(IfFalse)) == TypeInt::ONE && phase->type(in(IfTrue)) == TypeInt::ZERO ) { | |
246 } else return NULL; | |
247 | |
248 // Check for eq/ne test | |
249 if( !in(1)->is_Bool() ) return NULL; | |
250 BoolNode *bol = in(1)->as_Bool(); | |
251 if( bol->_test._test == BoolTest::eq ) { | |
252 } else if( bol->_test._test == BoolTest::ne ) { | |
253 flip = 1-flip; | |
254 } else return NULL; | |
255 | |
256 // Check for vs 0 or 1 | |
257 if( !bol->in(1)->is_Cmp() ) return NULL; | |
258 const CmpNode *cmp = bol->in(1)->as_Cmp(); | |
259 if( phase->type(cmp->in(2)) == TypeInt::ZERO ) { | |
260 } else if( phase->type(cmp->in(2)) == TypeInt::ONE ) { | |
261 // Allow cmp-vs-1 if the other input is bounded by 0-1 | |
262 if( phase->type(cmp->in(1)) != TypeInt::BOOL ) | |
263 return NULL; | |
264 flip = 1 - flip; | |
265 } else return NULL; | |
266 | |
267 // Convert to a bool (flipped) | |
268 // Build int->bool conversion | |
269 #ifndef PRODUCT | |
270 if( PrintOpto ) tty->print_cr("CMOV to I2B"); | |
271 #endif | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6795
diff
changeset
|
272 Node *n = new (phase->C) Conv2BNode( cmp->in(1) ); |
0 | 273 if( flip ) |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6795
diff
changeset
|
274 n = new (phase->C) XorINode( phase->transform(n), phase->intcon(1) ); |
0 | 275 |
276 return n; | |
277 } | |
278 | |
279 //============================================================================= | |
280 //------------------------------Ideal------------------------------------------ | |
281 // Return a node which is more "ideal" than the current node. | |
282 // Check for absolute value | |
283 Node *CMoveFNode::Ideal(PhaseGVN *phase, bool can_reshape) { | |
284 // Try generic ideal's first | |
285 Node *x = CMoveNode::Ideal(phase, can_reshape); | |
286 if( x ) return x; | |
287 | |
288 int cmp_zero_idx = 0; // Index of compare input where to look for zero | |
289 int phi_x_idx = 0; // Index of phi input where to find naked x | |
290 | |
291 // Find the Bool | |
292 if( !in(1)->is_Bool() ) return NULL; | |
293 BoolNode *bol = in(1)->as_Bool(); | |
294 // Check bool sense | |
295 switch( bol->_test._test ) { | |
296 case BoolTest::lt: cmp_zero_idx = 1; phi_x_idx = IfTrue; break; | |
297 case BoolTest::le: cmp_zero_idx = 2; phi_x_idx = IfFalse; break; | |
298 case BoolTest::gt: cmp_zero_idx = 2; phi_x_idx = IfTrue; break; | |
299 case BoolTest::ge: cmp_zero_idx = 1; phi_x_idx = IfFalse; break; | |
300 default: return NULL; break; | |
301 } | |
302 | |
303 // Find zero input of CmpF; the other input is being abs'd | |
304 Node *cmpf = bol->in(1); | |
305 if( cmpf->Opcode() != Op_CmpF ) return NULL; | |
306 Node *X = NULL; | |
307 bool flip = false; | |
308 if( phase->type(cmpf->in(cmp_zero_idx)) == TypeF::ZERO ) { | |
309 X = cmpf->in(3 - cmp_zero_idx); | |
310 } else if (phase->type(cmpf->in(3 - cmp_zero_idx)) == TypeF::ZERO) { | |
311 // The test is inverted, we should invert the result... | |
312 X = cmpf->in(cmp_zero_idx); | |
313 flip = true; | |
314 } else { | |
315 return NULL; | |
316 } | |
317 | |
318 // If X is found on the appropriate phi input, find the subtract on the other | |
319 if( X != in(phi_x_idx) ) return NULL; | |
320 int phi_sub_idx = phi_x_idx == IfTrue ? IfFalse : IfTrue; | |
321 Node *sub = in(phi_sub_idx); | |
322 | |
323 // Allow only SubF(0,X) and fail out for all others; NegF is not OK | |
324 if( sub->Opcode() != Op_SubF || | |
325 sub->in(2) != X || | |
326 phase->type(sub->in(1)) != TypeF::ZERO ) return NULL; | |
327 | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6795
diff
changeset
|
328 Node *abs = new (phase->C) AbsFNode( X ); |
0 | 329 if( flip ) |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6795
diff
changeset
|
330 abs = new (phase->C) SubFNode(sub->in(1), phase->transform(abs)); |
0 | 331 |
332 return abs; | |
333 } | |
334 | |
335 //============================================================================= | |
336 //------------------------------Ideal------------------------------------------ | |
337 // Return a node which is more "ideal" than the current node. | |
338 // Check for absolute value | |
339 Node *CMoveDNode::Ideal(PhaseGVN *phase, bool can_reshape) { | |
340 // Try generic ideal's first | |
341 Node *x = CMoveNode::Ideal(phase, can_reshape); | |
342 if( x ) return x; | |
343 | |
344 int cmp_zero_idx = 0; // Index of compare input where to look for zero | |
345 int phi_x_idx = 0; // Index of phi input where to find naked x | |
346 | |
347 // Find the Bool | |
348 if( !in(1)->is_Bool() ) return NULL; | |
349 BoolNode *bol = in(1)->as_Bool(); | |
350 // Check bool sense | |
351 switch( bol->_test._test ) { | |
352 case BoolTest::lt: cmp_zero_idx = 1; phi_x_idx = IfTrue; break; | |
353 case BoolTest::le: cmp_zero_idx = 2; phi_x_idx = IfFalse; break; | |
354 case BoolTest::gt: cmp_zero_idx = 2; phi_x_idx = IfTrue; break; | |
355 case BoolTest::ge: cmp_zero_idx = 1; phi_x_idx = IfFalse; break; | |
356 default: return NULL; break; | |
357 } | |
358 | |
359 // Find zero input of CmpD; the other input is being abs'd | |
360 Node *cmpd = bol->in(1); | |
361 if( cmpd->Opcode() != Op_CmpD ) return NULL; | |
362 Node *X = NULL; | |
363 bool flip = false; | |
364 if( phase->type(cmpd->in(cmp_zero_idx)) == TypeD::ZERO ) { | |
365 X = cmpd->in(3 - cmp_zero_idx); | |
366 } else if (phase->type(cmpd->in(3 - cmp_zero_idx)) == TypeD::ZERO) { | |
367 // The test is inverted, we should invert the result... | |
368 X = cmpd->in(cmp_zero_idx); | |
369 flip = true; | |
370 } else { | |
371 return NULL; | |
372 } | |
373 | |
374 // If X is found on the appropriate phi input, find the subtract on the other | |
375 if( X != in(phi_x_idx) ) return NULL; | |
376 int phi_sub_idx = phi_x_idx == IfTrue ? IfFalse : IfTrue; | |
377 Node *sub = in(phi_sub_idx); | |
378 | |
379 // Allow only SubD(0,X) and fail out for all others; NegD is not OK | |
380 if( sub->Opcode() != Op_SubD || | |
381 sub->in(2) != X || | |
382 phase->type(sub->in(1)) != TypeD::ZERO ) return NULL; | |
383 | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6795
diff
changeset
|
384 Node *abs = new (phase->C) AbsDNode( X ); |
0 | 385 if( flip ) |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6795
diff
changeset
|
386 abs = new (phase->C) SubDNode(sub->in(1), phase->transform(abs)); |
0 | 387 |
388 return abs; | |
389 } | |
390 | |
391 | |
392 //============================================================================= | |
393 // If input is already higher or equal to cast type, then this is an identity. | |
394 Node *ConstraintCastNode::Identity( PhaseTransform *phase ) { | |
14383
5ec7dace41a6
8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
14223
diff
changeset
|
395 return phase->type(in(1))->higher_equal_speculative(_type) ? in(1) : this; |
0 | 396 } |
397 | |
398 //------------------------------Value------------------------------------------ | |
399 // Take 'join' of input and cast-up type | |
400 const Type *ConstraintCastNode::Value( PhaseTransform *phase ) const { | |
401 if( in(0) && phase->type(in(0)) == Type::TOP ) return Type::TOP; | |
14383
5ec7dace41a6
8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
14223
diff
changeset
|
402 const Type* ft = phase->type(in(1))->filter_speculative(_type); |
0 | 403 |
404 #ifdef ASSERT | |
405 // Previous versions of this function had some special case logic, | |
406 // which is no longer necessary. Make sure of the required effects. | |
407 switch (Opcode()) { | |
408 case Op_CastII: | |
409 { | |
410 const Type* t1 = phase->type(in(1)); | |
411 if( t1 == Type::TOP ) assert(ft == Type::TOP, "special case #1"); | |
14383
5ec7dace41a6
8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
14223
diff
changeset
|
412 const Type* rt = t1->join_speculative(_type); |
0 | 413 if (rt->empty()) assert(ft == Type::TOP, "special case #2"); |
414 break; | |
415 } | |
416 case Op_CastPP: | |
417 if (phase->type(in(1)) == TypePtr::NULL_PTR && | |
418 _type->isa_ptr() && _type->is_ptr()->_ptr == TypePtr::NotNull) | |
419 assert(ft == Type::TOP, "special case #3"); | |
420 break; | |
421 } | |
422 #endif //ASSERT | |
423 | |
424 return ft; | |
425 } | |
426 | |
427 //------------------------------Ideal------------------------------------------ | |
428 // Return a node which is more "ideal" than the current node. Strip out | |
429 // control copies | |
430 Node *ConstraintCastNode::Ideal(PhaseGVN *phase, bool can_reshape){ | |
431 return (in(0) && remove_dead_region(phase, can_reshape)) ? this : NULL; | |
432 } | |
433 | |
434 //------------------------------Ideal_DU_postCCP------------------------------- | |
435 // Throw away cast after constant propagation | |
436 Node *ConstraintCastNode::Ideal_DU_postCCP( PhaseCCP *ccp ) { | |
437 const Type *t = ccp->type(in(1)); | |
438 ccp->hash_delete(this); | |
439 set_type(t); // Turn into ID function | |
440 ccp->hash_insert(this); | |
441 return this; | |
442 } | |
443 | |
20680
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
444 uint CastIINode::size_of() const { |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
445 return sizeof(*this); |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
446 } |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
447 |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
448 uint CastIINode::cmp(const Node &n) const { |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
449 return TypeNode::cmp(n) && ((CastIINode&)n)._carry_dependency == _carry_dependency; |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
450 } |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
451 |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
452 Node *CastIINode::Identity(PhaseTransform *phase) { |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
453 if (_carry_dependency) { |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
454 return this; |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
455 } |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
456 return ConstraintCastNode::Identity(phase); |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
457 } |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
458 |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
459 const Type *CastIINode::Value(PhaseTransform *phase) const { |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
460 const Type *res = ConstraintCastNode::Value(phase); |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
461 |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
462 // Try to improve the type of the CastII if we recognize a CmpI/If |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
463 // pattern. |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
464 if (_carry_dependency) { |
20708
d9e22e15d3f6
8066775: opto/node.hpp:355, assert(i < _max) failed: oob: i=1, _max=1
roland
parents:
20680
diff
changeset
|
465 if (in(0) != NULL && in(0)->in(0) != NULL && in(0)->in(0)->is_If()) { |
d9e22e15d3f6
8066775: opto/node.hpp:355, assert(i < _max) failed: oob: i=1, _max=1
roland
parents:
20680
diff
changeset
|
466 assert(in(0)->is_IfFalse() || in(0)->is_IfTrue(), "should be If proj"); |
20680
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
467 Node* proj = in(0); |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
468 if (proj->in(0)->in(1)->is_Bool()) { |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
469 Node* b = proj->in(0)->in(1); |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
470 if (b->in(1)->Opcode() == Op_CmpI) { |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
471 Node* cmp = b->in(1); |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
472 if (cmp->in(1) == in(1) && phase->type(cmp->in(2))->isa_int()) { |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
473 const TypeInt* in2_t = phase->type(cmp->in(2))->is_int(); |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
474 const Type* t = TypeInt::INT; |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
475 BoolTest test = b->as_Bool()->_test; |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
476 if (proj->is_IfFalse()) { |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
477 test = test.negate(); |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
478 } |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
479 BoolTest::mask m = test._test; |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
480 jlong lo_long = min_jint; |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
481 jlong hi_long = max_jint; |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
482 if (m == BoolTest::le || m == BoolTest::lt) { |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
483 hi_long = in2_t->_hi; |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
484 if (m == BoolTest::lt) { |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
485 hi_long -= 1; |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
486 } |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
487 } else if (m == BoolTest::ge || m == BoolTest::gt) { |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
488 lo_long = in2_t->_lo; |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
489 if (m == BoolTest::gt) { |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
490 lo_long += 1; |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
491 } |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
492 } else if (m == BoolTest::eq) { |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
493 lo_long = in2_t->_lo; |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
494 hi_long = in2_t->_hi; |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
495 } else if (m == BoolTest::ne) { |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
496 // can't do any better |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
497 } else { |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
498 stringStream ss; |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
499 test.dump_on(&ss); |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
500 fatal(err_msg_res("unexpected comparison %s", ss.as_string())); |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
501 } |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
502 int lo_int = (int)lo_long; |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
503 int hi_int = (int)hi_long; |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
504 |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
505 if (lo_long != (jlong)lo_int) { |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
506 lo_int = min_jint; |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
507 } |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
508 if (hi_long != (jlong)hi_int) { |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
509 hi_int = max_jint; |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
510 } |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
511 |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
512 t = TypeInt::make(lo_int, hi_int, Type::WidenMax); |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
513 |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
514 res = res->filter_speculative(t); |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
515 |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
516 return res; |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
517 } |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
518 } |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
519 } |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
520 } |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
521 } |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
522 return res; |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
523 } |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
524 |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
525 Node *CastIINode::Ideal_DU_postCCP(PhaseCCP *ccp) { |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
526 if (_carry_dependency) { |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
527 return NULL; |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
528 } |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
529 return ConstraintCastNode::Ideal_DU_postCCP(ccp); |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
530 } |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
531 |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
532 #ifndef PRODUCT |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
533 void CastIINode::dump_spec(outputStream *st) const { |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
534 TypeNode::dump_spec(st); |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
535 if (_carry_dependency) { |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
536 st->print(" carry dependency"); |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
537 } |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
538 } |
5b8e0f84f00f
8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents:
14383
diff
changeset
|
539 #endif |
0 | 540 |
541 //============================================================================= | |
542 | |
543 //------------------------------Ideal_DU_postCCP------------------------------- | |
544 // If not converting int->oop, throw away cast after constant propagation | |
545 Node *CastPPNode::Ideal_DU_postCCP( PhaseCCP *ccp ) { | |
546 const Type *t = ccp->type(in(1)); | |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6804
diff
changeset
|
547 if (!t->isa_oop_ptr() || ((in(1)->is_DecodeN()) && Matcher::gen_narrow_oop_implicit_null_checks())) { |
368
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
305
diff
changeset
|
548 return NULL; // do not transform raw pointers or narrow oops |
0 | 549 } |
550 return ConstraintCastNode::Ideal_DU_postCCP(ccp); | |
551 } | |
552 | |
553 | |
554 | |
555 //============================================================================= | |
556 //------------------------------Identity--------------------------------------- | |
557 // If input is already higher or equal to cast type, then this is an identity. | |
558 Node *CheckCastPPNode::Identity( PhaseTransform *phase ) { | |
559 // Toned down to rescue meeting at a Phi 3 different oops all implementing | |
560 // the same interface. CompileTheWorld starting at 502, kd12rc1.zip. | |
561 return (phase->type(in(1)) == phase->type(this)) ? in(1) : this; | |
562 } | |
563 | |
564 //------------------------------Value------------------------------------------ | |
565 // Take 'join' of input and cast-up type, unless working with an Interface | |
566 const Type *CheckCastPPNode::Value( PhaseTransform *phase ) const { | |
567 if( in(0) && phase->type(in(0)) == Type::TOP ) return Type::TOP; | |
568 | |
569 const Type *inn = phase->type(in(1)); | |
570 if( inn == Type::TOP ) return Type::TOP; // No information yet | |
571 | |
572 const TypePtr *in_type = inn->isa_ptr(); | |
573 const TypePtr *my_type = _type->isa_ptr(); | |
574 const Type *result = _type; | |
575 if( in_type != NULL && my_type != NULL ) { | |
576 TypePtr::PTR in_ptr = in_type->ptr(); | |
577 if( in_ptr == TypePtr::Null ) { | |
578 result = in_type; | |
579 } else if( in_ptr == TypePtr::Constant ) { | |
580 // Casting a constant oop to an interface? | |
581 // (i.e., a String to a Comparable?) | |
582 // Then return the interface. | |
583 const TypeOopPtr *jptr = my_type->isa_oopptr(); | |
584 assert( jptr, "" ); | |
585 result = (jptr->klass()->is_interface() || !in_type->higher_equal(_type)) | |
586 ? my_type->cast_to_ptr_type( TypePtr::NotNull ) | |
587 : in_type; | |
588 } else { | |
589 result = my_type->cast_to_ptr_type( my_type->join_ptr(in_ptr) ); | |
590 } | |
591 } | |
592 return result; | |
593 | |
594 // JOIN NOT DONE HERE BECAUSE OF INTERFACE ISSUES. | |
595 // FIX THIS (DO THE JOIN) WHEN UNION TYPES APPEAR! | |
596 | |
597 // | |
598 // Remove this code after overnight run indicates no performance | |
599 // loss from not performing JOIN at CheckCastPPNode | |
600 // | |
601 // const TypeInstPtr *in_oop = in->isa_instptr(); | |
602 // const TypeInstPtr *my_oop = _type->isa_instptr(); | |
603 // // If either input is an 'interface', return destination type | |
604 // assert (in_oop == NULL || in_oop->klass() != NULL, ""); | |
605 // assert (my_oop == NULL || my_oop->klass() != NULL, ""); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5901
diff
changeset
|
606 // if( (in_oop && in_oop->klass()->is_interface()) |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5901
diff
changeset
|
607 // ||(my_oop && my_oop->klass()->is_interface()) ) { |
0 | 608 // TypePtr::PTR in_ptr = in->isa_ptr() ? in->is_ptr()->_ptr : TypePtr::BotPTR; |
609 // // Preserve cast away nullness for interfaces | |
610 // if( in_ptr == TypePtr::NotNull && my_oop && my_oop->_ptr == TypePtr::BotPTR ) { | |
611 // return my_oop->cast_to_ptr_type(TypePtr::NotNull); | |
612 // } | |
613 // return _type; | |
614 // } | |
615 // | |
616 // // Neither the input nor the destination type is an interface, | |
617 // | |
618 // // history: JOIN used to cause weird corner case bugs | |
619 // // return (in == TypeOopPtr::NULL_PTR) ? in : _type; | |
620 // // JOIN picks up NotNull in common instance-of/check-cast idioms, both oops. | |
621 // // JOIN does not preserve NotNull in other cases, e.g. RawPtr vs InstPtr | |
622 // const Type *join = in->join(_type); | |
623 // // Check if join preserved NotNull'ness for pointers | |
624 // if( join->isa_ptr() && _type->isa_ptr() ) { | |
625 // TypePtr::PTR join_ptr = join->is_ptr()->_ptr; | |
626 // TypePtr::PTR type_ptr = _type->is_ptr()->_ptr; | |
627 // // If there isn't any NotNull'ness to preserve | |
628 // // OR if join preserved NotNull'ness then return it | |
629 // if( type_ptr == TypePtr::BotPTR || type_ptr == TypePtr::Null || | |
630 // join_ptr == TypePtr::NotNull || join_ptr == TypePtr::Constant ) { | |
631 // return join; | |
632 // } | |
633 // // ELSE return same old type as before | |
634 // return _type; | |
635 // } | |
636 // // Not joining two pointers | |
637 // return join; | |
638 } | |
639 | |
640 //------------------------------Ideal------------------------------------------ | |
641 // Return a node which is more "ideal" than the current node. Strip out | |
642 // control copies | |
643 Node *CheckCastPPNode::Ideal(PhaseGVN *phase, bool can_reshape){ | |
644 return (in(0) && remove_dead_region(phase, can_reshape)) ? this : NULL; | |
645 } | |
646 | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
36
diff
changeset
|
647 |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
36
diff
changeset
|
648 Node* DecodeNNode::Identity(PhaseTransform* phase) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
36
diff
changeset
|
649 const Type *t = phase->type( in(1) ); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
36
diff
changeset
|
650 if( t == Type::TOP ) return in(1); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
36
diff
changeset
|
651 |
168
7793bd37a336
6705887: Compressed Oops: generate x64 addressing and implicit null checks with narrow oops
kvn
parents:
164
diff
changeset
|
652 if (in(1)->is_EncodeP()) { |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
36
diff
changeset
|
653 // (DecodeN (EncodeP p)) -> p |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
36
diff
changeset
|
654 return in(1)->in(1); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
36
diff
changeset
|
655 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
36
diff
changeset
|
656 return this; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
36
diff
changeset
|
657 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
36
diff
changeset
|
658 |
124
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
659 const Type *DecodeNNode::Value( PhaseTransform *phase ) const { |
216
8d191a7697e2
6715633: when matching a memory node the adr_type should not change
kvn
parents:
168
diff
changeset
|
660 const Type *t = phase->type( in(1) ); |
8d191a7697e2
6715633: when matching a memory node the adr_type should not change
kvn
parents:
168
diff
changeset
|
661 if (t == Type::TOP) return Type::TOP; |
8d191a7697e2
6715633: when matching a memory node the adr_type should not change
kvn
parents:
168
diff
changeset
|
662 if (t == TypeNarrowOop::NULL_PTR) return TypePtr::NULL_PTR; |
8d191a7697e2
6715633: when matching a memory node the adr_type should not change
kvn
parents:
168
diff
changeset
|
663 |
8d191a7697e2
6715633: when matching a memory node the adr_type should not change
kvn
parents:
168
diff
changeset
|
664 assert(t->isa_narrowoop(), "only narrowoop here"); |
221
1e026f8da827
6710487: More than half of JDI Regression tests hang with COOPs in -Xcomp mode
kvn
parents:
216
diff
changeset
|
665 return t->make_ptr(); |
124
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
666 } |
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
667 |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
36
diff
changeset
|
668 Node* EncodePNode::Identity(PhaseTransform* phase) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
36
diff
changeset
|
669 const Type *t = phase->type( in(1) ); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
36
diff
changeset
|
670 if( t == Type::TOP ) return in(1); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
36
diff
changeset
|
671 |
168
7793bd37a336
6705887: Compressed Oops: generate x64 addressing and implicit null checks with narrow oops
kvn
parents:
164
diff
changeset
|
672 if (in(1)->is_DecodeN()) { |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
36
diff
changeset
|
673 // (EncodeP (DecodeN p)) -> p |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
36
diff
changeset
|
674 return in(1)->in(1); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
36
diff
changeset
|
675 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
36
diff
changeset
|
676 return this; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
36
diff
changeset
|
677 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
36
diff
changeset
|
678 |
124
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
679 const Type *EncodePNode::Value( PhaseTransform *phase ) const { |
216
8d191a7697e2
6715633: when matching a memory node the adr_type should not change
kvn
parents:
168
diff
changeset
|
680 const Type *t = phase->type( in(1) ); |
8d191a7697e2
6715633: when matching a memory node the adr_type should not change
kvn
parents:
168
diff
changeset
|
681 if (t == Type::TOP) return Type::TOP; |
8d191a7697e2
6715633: when matching a memory node the adr_type should not change
kvn
parents:
168
diff
changeset
|
682 if (t == TypePtr::NULL_PTR) return TypeNarrowOop::NULL_PTR; |
8d191a7697e2
6715633: when matching a memory node the adr_type should not change
kvn
parents:
168
diff
changeset
|
683 |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6804
diff
changeset
|
684 assert(t->isa_oop_ptr(), "only oopptr here"); |
221
1e026f8da827
6710487: More than half of JDI Regression tests hang with COOPs in -Xcomp mode
kvn
parents:
216
diff
changeset
|
685 return t->make_narrowoop(); |
124
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
686 } |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
36
diff
changeset
|
687 |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
36
diff
changeset
|
688 |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6804
diff
changeset
|
689 Node *EncodeNarrowPtrNode::Ideal_DU_postCCP( PhaseCCP *ccp ) { |
163 | 690 return MemNode::Ideal_common_DU_postCCP(ccp, this, in(1)); |
691 } | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
36
diff
changeset
|
692 |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6804
diff
changeset
|
693 Node* DecodeNKlassNode::Identity(PhaseTransform* phase) { |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6804
diff
changeset
|
694 const Type *t = phase->type( in(1) ); |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6804
diff
changeset
|
695 if( t == Type::TOP ) return in(1); |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6804
diff
changeset
|
696 |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6804
diff
changeset
|
697 if (in(1)->is_EncodePKlass()) { |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6804
diff
changeset
|
698 // (DecodeNKlass (EncodePKlass p)) -> p |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6804
diff
changeset
|
699 return in(1)->in(1); |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6804
diff
changeset
|
700 } |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6804
diff
changeset
|
701 return this; |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6804
diff
changeset
|
702 } |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6804
diff
changeset
|
703 |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6804
diff
changeset
|
704 const Type *DecodeNKlassNode::Value( PhaseTransform *phase ) const { |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6804
diff
changeset
|
705 const Type *t = phase->type( in(1) ); |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6804
diff
changeset
|
706 if (t == Type::TOP) return Type::TOP; |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6804
diff
changeset
|
707 assert(t != TypeNarrowKlass::NULL_PTR, "null klass?"); |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6804
diff
changeset
|
708 |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6804
diff
changeset
|
709 assert(t->isa_narrowklass(), "only narrow klass ptr here"); |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6804
diff
changeset
|
710 return t->make_ptr(); |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6804
diff
changeset
|
711 } |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6804
diff
changeset
|
712 |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6804
diff
changeset
|
713 Node* EncodePKlassNode::Identity(PhaseTransform* phase) { |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6804
diff
changeset
|
714 const Type *t = phase->type( in(1) ); |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6804
diff
changeset
|
715 if( t == Type::TOP ) return in(1); |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6804
diff
changeset
|
716 |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6804
diff
changeset
|
717 if (in(1)->is_DecodeNKlass()) { |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6804
diff
changeset
|
718 // (EncodePKlass (DecodeNKlass p)) -> p |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6804
diff
changeset
|
719 return in(1)->in(1); |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6804
diff
changeset
|
720 } |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6804
diff
changeset
|
721 return this; |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6804
diff
changeset
|
722 } |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6804
diff
changeset
|
723 |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6804
diff
changeset
|
724 const Type *EncodePKlassNode::Value( PhaseTransform *phase ) const { |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6804
diff
changeset
|
725 const Type *t = phase->type( in(1) ); |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6804
diff
changeset
|
726 if (t == Type::TOP) return Type::TOP; |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6804
diff
changeset
|
727 assert (t != TypePtr::NULL_PTR, "null klass?"); |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6804
diff
changeset
|
728 |
12226
7944aba7ba41
8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents:
9060
diff
changeset
|
729 assert(UseCompressedClassPointers && t->isa_klassptr(), "only klass ptr here"); |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6804
diff
changeset
|
730 return t->make_narrowklass(); |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6804
diff
changeset
|
731 } |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6804
diff
changeset
|
732 |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6804
diff
changeset
|
733 |
0 | 734 //============================================================================= |
735 //------------------------------Identity--------------------------------------- | |
736 Node *Conv2BNode::Identity( PhaseTransform *phase ) { | |
737 const Type *t = phase->type( in(1) ); | |
738 if( t == Type::TOP ) return in(1); | |
739 if( t == TypeInt::ZERO ) return in(1); | |
740 if( t == TypeInt::ONE ) return in(1); | |
741 if( t == TypeInt::BOOL ) return in(1); | |
742 return this; | |
743 } | |
744 | |
745 //------------------------------Value------------------------------------------ | |
746 const Type *Conv2BNode::Value( PhaseTransform *phase ) const { | |
747 const Type *t = phase->type( in(1) ); | |
748 if( t == Type::TOP ) return Type::TOP; | |
749 if( t == TypeInt::ZERO ) return TypeInt::ZERO; | |
750 if( t == TypePtr::NULL_PTR ) return TypeInt::ZERO; | |
751 const TypePtr *tp = t->isa_ptr(); | |
752 if( tp != NULL ) { | |
753 if( tp->ptr() == TypePtr::AnyNull ) return Type::TOP; | |
754 if( tp->ptr() == TypePtr::Constant) return TypeInt::ONE; | |
755 if (tp->ptr() == TypePtr::NotNull) return TypeInt::ONE; | |
756 return TypeInt::BOOL; | |
757 } | |
758 if (t->base() != Type::Int) return TypeInt::BOOL; | |
759 const TypeInt *ti = t->is_int(); | |
760 if( ti->_hi < 0 || ti->_lo > 0 ) return TypeInt::ONE; | |
761 return TypeInt::BOOL; | |
762 } | |
763 | |
764 | |
765 // The conversions operations are all Alpha sorted. Please keep it that way! | |
766 //============================================================================= | |
767 //------------------------------Value------------------------------------------ | |
768 const Type *ConvD2FNode::Value( PhaseTransform *phase ) const { | |
769 const Type *t = phase->type( in(1) ); | |
770 if( t == Type::TOP ) return Type::TOP; | |
771 if( t == Type::DOUBLE ) return Type::FLOAT; | |
772 const TypeD *td = t->is_double_constant(); | |
773 return TypeF::make( (float)td->getd() ); | |
774 } | |
775 | |
776 //------------------------------Identity--------------------------------------- | |
777 // Float's can be converted to doubles with no loss of bits. Hence | |
778 // converting a float to a double and back to a float is a NOP. | |
779 Node *ConvD2FNode::Identity(PhaseTransform *phase) { | |
780 return (in(1)->Opcode() == Op_ConvF2D) ? in(1)->in(1) : this; | |
781 } | |
782 | |
783 //============================================================================= | |
784 //------------------------------Value------------------------------------------ | |
785 const Type *ConvD2INode::Value( PhaseTransform *phase ) const { | |
786 const Type *t = phase->type( in(1) ); | |
787 if( t == Type::TOP ) return Type::TOP; | |
788 if( t == Type::DOUBLE ) return TypeInt::INT; | |
789 const TypeD *td = t->is_double_constant(); | |
790 return TypeInt::make( SharedRuntime::d2i( td->getd() ) ); | |
791 } | |
792 | |
793 //------------------------------Ideal------------------------------------------ | |
794 // If converting to an int type, skip any rounding nodes | |
795 Node *ConvD2INode::Ideal(PhaseGVN *phase, bool can_reshape) { | |
796 if( in(1)->Opcode() == Op_RoundDouble ) | |
797 set_req(1,in(1)->in(1)); | |
798 return NULL; | |
799 } | |
800 | |
801 //------------------------------Identity--------------------------------------- | |
802 // Int's can be converted to doubles with no loss of bits. Hence | |
803 // converting an integer to a double and back to an integer is a NOP. | |
804 Node *ConvD2INode::Identity(PhaseTransform *phase) { | |
805 return (in(1)->Opcode() == Op_ConvI2D) ? in(1)->in(1) : this; | |
806 } | |
807 | |
808 //============================================================================= | |
809 //------------------------------Value------------------------------------------ | |
810 const Type *ConvD2LNode::Value( PhaseTransform *phase ) const { | |
811 const Type *t = phase->type( in(1) ); | |
812 if( t == Type::TOP ) return Type::TOP; | |
813 if( t == Type::DOUBLE ) return TypeLong::LONG; | |
814 const TypeD *td = t->is_double_constant(); | |
815 return TypeLong::make( SharedRuntime::d2l( td->getd() ) ); | |
816 } | |
817 | |
818 //------------------------------Identity--------------------------------------- | |
819 Node *ConvD2LNode::Identity(PhaseTransform *phase) { | |
820 // Remove ConvD2L->ConvL2D->ConvD2L sequences. | |
821 if( in(1) ->Opcode() == Op_ConvL2D && | |
822 in(1)->in(1)->Opcode() == Op_ConvD2L ) | |
823 return in(1)->in(1); | |
824 return this; | |
825 } | |
826 | |
827 //------------------------------Ideal------------------------------------------ | |
828 // If converting to an int type, skip any rounding nodes | |
829 Node *ConvD2LNode::Ideal(PhaseGVN *phase, bool can_reshape) { | |
830 if( in(1)->Opcode() == Op_RoundDouble ) | |
831 set_req(1,in(1)->in(1)); | |
832 return NULL; | |
833 } | |
834 | |
835 //============================================================================= | |
836 //------------------------------Value------------------------------------------ | |
837 const Type *ConvF2DNode::Value( PhaseTransform *phase ) const { | |
838 const Type *t = phase->type( in(1) ); | |
839 if( t == Type::TOP ) return Type::TOP; | |
840 if( t == Type::FLOAT ) return Type::DOUBLE; | |
841 const TypeF *tf = t->is_float_constant(); | |
842 return TypeD::make( (double)tf->getf() ); | |
843 } | |
844 | |
845 //============================================================================= | |
846 //------------------------------Value------------------------------------------ | |
847 const Type *ConvF2INode::Value( PhaseTransform *phase ) const { | |
848 const Type *t = phase->type( in(1) ); | |
849 if( t == Type::TOP ) return Type::TOP; | |
850 if( t == Type::FLOAT ) return TypeInt::INT; | |
851 const TypeF *tf = t->is_float_constant(); | |
852 return TypeInt::make( SharedRuntime::f2i( tf->getf() ) ); | |
853 } | |
854 | |
855 //------------------------------Identity--------------------------------------- | |
856 Node *ConvF2INode::Identity(PhaseTransform *phase) { | |
857 // Remove ConvF2I->ConvI2F->ConvF2I sequences. | |
858 if( in(1) ->Opcode() == Op_ConvI2F && | |
859 in(1)->in(1)->Opcode() == Op_ConvF2I ) | |
860 return in(1)->in(1); | |
861 return this; | |
862 } | |
863 | |
864 //------------------------------Ideal------------------------------------------ | |
865 // If converting to an int type, skip any rounding nodes | |
866 Node *ConvF2INode::Ideal(PhaseGVN *phase, bool can_reshape) { | |
867 if( in(1)->Opcode() == Op_RoundFloat ) | |
868 set_req(1,in(1)->in(1)); | |
869 return NULL; | |
870 } | |
871 | |
872 //============================================================================= | |
873 //------------------------------Value------------------------------------------ | |
874 const Type *ConvF2LNode::Value( PhaseTransform *phase ) const { | |
875 const Type *t = phase->type( in(1) ); | |
876 if( t == Type::TOP ) return Type::TOP; | |
877 if( t == Type::FLOAT ) return TypeLong::LONG; | |
878 const TypeF *tf = t->is_float_constant(); | |
879 return TypeLong::make( SharedRuntime::f2l( tf->getf() ) ); | |
880 } | |
881 | |
882 //------------------------------Identity--------------------------------------- | |
883 Node *ConvF2LNode::Identity(PhaseTransform *phase) { | |
884 // Remove ConvF2L->ConvL2F->ConvF2L sequences. | |
885 if( in(1) ->Opcode() == Op_ConvL2F && | |
886 in(1)->in(1)->Opcode() == Op_ConvF2L ) | |
887 return in(1)->in(1); | |
888 return this; | |
889 } | |
890 | |
891 //------------------------------Ideal------------------------------------------ | |
892 // If converting to an int type, skip any rounding nodes | |
893 Node *ConvF2LNode::Ideal(PhaseGVN *phase, bool can_reshape) { | |
894 if( in(1)->Opcode() == Op_RoundFloat ) | |
895 set_req(1,in(1)->in(1)); | |
896 return NULL; | |
897 } | |
898 | |
899 //============================================================================= | |
900 //------------------------------Value------------------------------------------ | |
901 const Type *ConvI2DNode::Value( PhaseTransform *phase ) const { | |
902 const Type *t = phase->type( in(1) ); | |
903 if( t == Type::TOP ) return Type::TOP; | |
904 const TypeInt *ti = t->is_int(); | |
905 if( ti->is_con() ) return TypeD::make( (double)ti->get_con() ); | |
906 return bottom_type(); | |
907 } | |
908 | |
909 //============================================================================= | |
910 //------------------------------Value------------------------------------------ | |
911 const Type *ConvI2FNode::Value( PhaseTransform *phase ) const { | |
912 const Type *t = phase->type( in(1) ); | |
913 if( t == Type::TOP ) return Type::TOP; | |
914 const TypeInt *ti = t->is_int(); | |
915 if( ti->is_con() ) return TypeF::make( (float)ti->get_con() ); | |
916 return bottom_type(); | |
917 } | |
918 | |
919 //------------------------------Identity--------------------------------------- | |
920 Node *ConvI2FNode::Identity(PhaseTransform *phase) { | |
921 // Remove ConvI2F->ConvF2I->ConvI2F sequences. | |
922 if( in(1) ->Opcode() == Op_ConvF2I && | |
923 in(1)->in(1)->Opcode() == Op_ConvI2F ) | |
924 return in(1)->in(1); | |
925 return this; | |
926 } | |
927 | |
928 //============================================================================= | |
929 //------------------------------Value------------------------------------------ | |
930 const Type *ConvI2LNode::Value( PhaseTransform *phase ) const { | |
931 const Type *t = phase->type( in(1) ); | |
932 if( t == Type::TOP ) return Type::TOP; | |
933 const TypeInt *ti = t->is_int(); | |
934 const Type* tl = TypeLong::make(ti->_lo, ti->_hi, ti->_widen); | |
935 // Join my declared type against my incoming type. | |
936 tl = tl->filter(_type); | |
937 return tl; | |
938 } | |
939 | |
940 #ifdef _LP64 | |
941 static inline bool long_ranges_overlap(jlong lo1, jlong hi1, | |
942 jlong lo2, jlong hi2) { | |
943 // Two ranges overlap iff one range's low point falls in the other range. | |
944 return (lo2 <= lo1 && lo1 <= hi2) || (lo1 <= lo2 && lo2 <= hi1); | |
945 } | |
946 #endif | |
947 | |
948 //------------------------------Ideal------------------------------------------ | |
949 Node *ConvI2LNode::Ideal(PhaseGVN *phase, bool can_reshape) { | |
950 const TypeLong* this_type = this->type()->is_long(); | |
951 Node* this_changed = NULL; | |
952 | |
953 // If _major_progress, then more loop optimizations follow. Do NOT | |
954 // remove this node's type assertion until no more loop ops can happen. | |
955 // The progress bit is set in the major loop optimizations THEN comes the | |
956 // call to IterGVN and any chance of hitting this code. Cf. Opaque1Node. | |
957 if (can_reshape && !phase->C->major_progress()) { | |
958 const TypeInt* in_type = phase->type(in(1))->isa_int(); | |
959 if (in_type != NULL && this_type != NULL && | |
960 (in_type->_lo != this_type->_lo || | |
961 in_type->_hi != this_type->_hi)) { | |
962 // Although this WORSENS the type, it increases GVN opportunities, | |
963 // because I2L nodes with the same input will common up, regardless | |
964 // of slightly differing type assertions. Such slight differences | |
965 // arise routinely as a result of loop unrolling, so this is a | |
966 // post-unrolling graph cleanup. Choose a type which depends only | |
967 // on my input. (Exception: Keep a range assertion of >=0 or <0.) | |
968 jlong lo1 = this_type->_lo; | |
969 jlong hi1 = this_type->_hi; | |
970 int w1 = this_type->_widen; | |
971 if (lo1 != (jint)lo1 || | |
972 hi1 != (jint)hi1 || | |
973 lo1 > hi1) { | |
974 // Overflow leads to wraparound, wraparound leads to range saturation. | |
975 lo1 = min_jint; hi1 = max_jint; | |
976 } else if (lo1 >= 0) { | |
977 // Keep a range assertion of >=0. | |
978 lo1 = 0; hi1 = max_jint; | |
979 } else if (hi1 < 0) { | |
980 // Keep a range assertion of <0. | |
981 lo1 = min_jint; hi1 = -1; | |
982 } else { | |
983 lo1 = min_jint; hi1 = max_jint; | |
984 } | |
985 const TypeLong* wtype = TypeLong::make(MAX2((jlong)in_type->_lo, lo1), | |
986 MIN2((jlong)in_type->_hi, hi1), | |
987 MAX2((int)in_type->_widen, w1)); | |
988 if (wtype != type()) { | |
989 set_type(wtype); | |
990 // Note: this_type still has old type value, for the logic below. | |
991 this_changed = this; | |
992 } | |
993 } | |
994 } | |
995 | |
996 #ifdef _LP64 | |
997 // Convert ConvI2L(AddI(x, y)) to AddL(ConvI2L(x), ConvI2L(y)) , | |
998 // but only if x and y have subranges that cannot cause 32-bit overflow, | |
999 // under the assumption that x+y is in my own subrange this->type(). | |
1000 | |
1001 // This assumption is based on a constraint (i.e., type assertion) | |
1002 // established in Parse::array_addressing or perhaps elsewhere. | |
1003 // This constraint has been adjoined to the "natural" type of | |
1004 // the incoming argument in(0). We know (because of runtime | |
1005 // checks) - that the result value I2L(x+y) is in the joined range. | |
1006 // Hence we can restrict the incoming terms (x, y) to values such | |
1007 // that their sum also lands in that range. | |
1008 | |
1009 // This optimization is useful only on 64-bit systems, where we hope | |
1010 // the addition will end up subsumed in an addressing mode. | |
1011 // It is necessary to do this when optimizing an unrolled array | |
1012 // copy loop such as x[i++] = y[i++]. | |
1013 | |
1014 // On 32-bit systems, it's better to perform as much 32-bit math as | |
1015 // possible before the I2L conversion, because 32-bit math is cheaper. | |
1016 // There's no common reason to "leak" a constant offset through the I2L. | |
1017 // Addressing arithmetic will not absorb it as part of a 64-bit AddL. | |
1018 | |
1019 Node* z = in(1); | |
1020 int op = z->Opcode(); | |
1021 if (op == Op_AddI || op == Op_SubI) { | |
1022 Node* x = z->in(1); | |
1023 Node* y = z->in(2); | |
1024 assert (x != z && y != z, "dead loop in ConvI2LNode::Ideal"); | |
1025 if (phase->type(x) == Type::TOP) return this_changed; | |
1026 if (phase->type(y) == Type::TOP) return this_changed; | |
1027 const TypeInt* tx = phase->type(x)->is_int(); | |
1028 const TypeInt* ty = phase->type(y)->is_int(); | |
1029 const TypeLong* tz = this_type; | |
1030 jlong xlo = tx->_lo; | |
1031 jlong xhi = tx->_hi; | |
1032 jlong ylo = ty->_lo; | |
1033 jlong yhi = ty->_hi; | |
1034 jlong zlo = tz->_lo; | |
1035 jlong zhi = tz->_hi; | |
1036 jlong vbit = CONST64(1) << BitsPerInt; | |
1037 int widen = MAX2(tx->_widen, ty->_widen); | |
1038 if (op == Op_SubI) { | |
1039 jlong ylo0 = ylo; | |
1040 ylo = -yhi; | |
1041 yhi = -ylo0; | |
1042 } | |
1043 // See if x+y can cause positive overflow into z+2**32 | |
1044 if (long_ranges_overlap(xlo+ylo, xhi+yhi, zlo+vbit, zhi+vbit)) { | |
1045 return this_changed; | |
1046 } | |
1047 // See if x+y can cause negative overflow into z-2**32 | |
1048 if (long_ranges_overlap(xlo+ylo, xhi+yhi, zlo-vbit, zhi-vbit)) { | |
1049 return this_changed; | |
1050 } | |
1051 // Now it's always safe to assume x+y does not overflow. | |
1052 // This is true even if some pairs x,y might cause overflow, as long | |
1053 // as that overflow value cannot fall into [zlo,zhi]. | |
1054 | |
1055 // Confident that the arithmetic is "as if infinite precision", | |
1056 // we can now use z's range to put constraints on those of x and y. | |
1057 // The "natural" range of x [xlo,xhi] can perhaps be narrowed to a | |
1058 // more "restricted" range by intersecting [xlo,xhi] with the | |
1059 // range obtained by subtracting y's range from the asserted range | |
1060 // of the I2L conversion. Here's the interval arithmetic algebra: | |
1061 // x == z-y == [zlo,zhi]-[ylo,yhi] == [zlo,zhi]+[-yhi,-ylo] | |
1062 // => x in [zlo-yhi, zhi-ylo] | |
1063 // => x in [zlo-yhi, zhi-ylo] INTERSECT [xlo,xhi] | |
1064 // => x in [xlo MAX zlo-yhi, xhi MIN zhi-ylo] | |
1065 jlong rxlo = MAX2(xlo, zlo - yhi); | |
1066 jlong rxhi = MIN2(xhi, zhi - ylo); | |
1067 // And similarly, x changing place with y: | |
1068 jlong rylo = MAX2(ylo, zlo - xhi); | |
1069 jlong ryhi = MIN2(yhi, zhi - xlo); | |
1070 if (rxlo > rxhi || rylo > ryhi) { | |
1071 return this_changed; // x or y is dying; don't mess w/ it | |
1072 } | |
1073 if (op == Op_SubI) { | |
1074 jlong rylo0 = rylo; | |
1075 rylo = -ryhi; | |
1076 ryhi = -rylo0; | |
1077 } | |
1078 | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6795
diff
changeset
|
1079 Node* cx = phase->transform( new (phase->C) ConvI2LNode(x, TypeLong::make(rxlo, rxhi, widen)) ); |
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6795
diff
changeset
|
1080 Node* cy = phase->transform( new (phase->C) ConvI2LNode(y, TypeLong::make(rylo, ryhi, widen)) ); |
0 | 1081 switch (op) { |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6795
diff
changeset
|
1082 case Op_AddI: return new (phase->C) AddLNode(cx, cy); |
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6795
diff
changeset
|
1083 case Op_SubI: return new (phase->C) SubLNode(cx, cy); |
0 | 1084 default: ShouldNotReachHere(); |
1085 } | |
1086 } | |
1087 #endif //_LP64 | |
1088 | |
1089 return this_changed; | |
1090 } | |
1091 | |
1092 //============================================================================= | |
1093 //------------------------------Value------------------------------------------ | |
1094 const Type *ConvL2DNode::Value( PhaseTransform *phase ) const { | |
1095 const Type *t = phase->type( in(1) ); | |
1096 if( t == Type::TOP ) return Type::TOP; | |
1097 const TypeLong *tl = t->is_long(); | |
1098 if( tl->is_con() ) return TypeD::make( (double)tl->get_con() ); | |
1099 return bottom_type(); | |
1100 } | |
1101 | |
1102 //============================================================================= | |
1103 //------------------------------Value------------------------------------------ | |
1104 const Type *ConvL2FNode::Value( PhaseTransform *phase ) const { | |
1105 const Type *t = phase->type( in(1) ); | |
1106 if( t == Type::TOP ) return Type::TOP; | |
1107 const TypeLong *tl = t->is_long(); | |
1108 if( tl->is_con() ) return TypeF::make( (float)tl->get_con() ); | |
1109 return bottom_type(); | |
1110 } | |
1111 | |
1112 //============================================================================= | |
1113 //----------------------------Identity----------------------------------------- | |
1114 Node *ConvL2INode::Identity( PhaseTransform *phase ) { | |
1115 // Convert L2I(I2L(x)) => x | |
1116 if (in(1)->Opcode() == Op_ConvI2L) return in(1)->in(1); | |
1117 return this; | |
1118 } | |
1119 | |
1120 //------------------------------Value------------------------------------------ | |
1121 const Type *ConvL2INode::Value( PhaseTransform *phase ) const { | |
1122 const Type *t = phase->type( in(1) ); | |
1123 if( t == Type::TOP ) return Type::TOP; | |
1124 const TypeLong *tl = t->is_long(); | |
1125 if (tl->is_con()) | |
1126 // Easy case. | |
1127 return TypeInt::make((jint)tl->get_con()); | |
1128 return bottom_type(); | |
1129 } | |
1130 | |
1131 //------------------------------Ideal------------------------------------------ | |
1132 // Return a node which is more "ideal" than the current node. | |
1133 // Blow off prior masking to int | |
1134 Node *ConvL2INode::Ideal(PhaseGVN *phase, bool can_reshape) { | |
1135 Node *andl = in(1); | |
1136 uint andl_op = andl->Opcode(); | |
1137 if( andl_op == Op_AndL ) { | |
1138 // Blow off prior masking to int | |
1139 if( phase->type(andl->in(2)) == TypeLong::make( 0xFFFFFFFF ) ) { | |
1140 set_req(1,andl->in(1)); | |
1141 return this; | |
1142 } | |
1143 } | |
1144 | |
1145 // Swap with a prior add: convL2I(addL(x,y)) ==> addI(convL2I(x),convL2I(y)) | |
1146 // This replaces an 'AddL' with an 'AddI'. | |
1147 if( andl_op == Op_AddL ) { | |
1148 // Don't do this for nodes which have more than one user since | |
1149 // we'll end up computing the long add anyway. | |
1150 if (andl->outcnt() > 1) return NULL; | |
1151 | |
1152 Node* x = andl->in(1); | |
1153 Node* y = andl->in(2); | |
1154 assert( x != andl && y != andl, "dead loop in ConvL2INode::Ideal" ); | |
1155 if (phase->type(x) == Type::TOP) return NULL; | |
1156 if (phase->type(y) == Type::TOP) return NULL; | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6795
diff
changeset
|
1157 Node *add1 = phase->transform(new (phase->C) ConvL2INode(x)); |
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6795
diff
changeset
|
1158 Node *add2 = phase->transform(new (phase->C) ConvL2INode(y)); |
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6795
diff
changeset
|
1159 return new (phase->C) AddINode(add1,add2); |
0 | 1160 } |
1161 | |
36 | 1162 // Disable optimization: LoadL->ConvL2I ==> LoadI. |
1163 // It causes problems (sizes of Load and Store nodes do not match) | |
1164 // in objects initialization code and Escape Analysis. | |
0 | 1165 return NULL; |
1166 } | |
1167 | |
1168 //============================================================================= | |
1169 //------------------------------Value------------------------------------------ | |
1170 const Type *CastX2PNode::Value( PhaseTransform *phase ) const { | |
1171 const Type* t = phase->type(in(1)); | |
5901 | 1172 if (t == Type::TOP) return Type::TOP; |
0 | 1173 if (t->base() == Type_X && t->singleton()) { |
1174 uintptr_t bits = (uintptr_t) t->is_intptr_t()->get_con(); | |
1175 if (bits == 0) return TypePtr::NULL_PTR; | |
1176 return TypeRawPtr::make((address) bits); | |
1177 } | |
1178 return CastX2PNode::bottom_type(); | |
1179 } | |
1180 | |
1181 //------------------------------Idealize--------------------------------------- | |
1182 static inline bool fits_in_int(const Type* t, bool but_not_min_int = false) { | |
1183 if (t == Type::TOP) return false; | |
1184 const TypeX* tl = t->is_intptr_t(); | |
1185 jint lo = min_jint; | |
1186 jint hi = max_jint; | |
1187 if (but_not_min_int) ++lo; // caller wants to negate the value w/o overflow | |
1188 return (tl->_lo >= lo) && (tl->_hi <= hi); | |
1189 } | |
1190 | |
1191 static inline Node* addP_of_X2P(PhaseGVN *phase, | |
1192 Node* base, | |
1193 Node* dispX, | |
1194 bool negate = false) { | |
1195 if (negate) { | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6795
diff
changeset
|
1196 dispX = new (phase->C) SubXNode(phase->MakeConX(0), phase->transform(dispX)); |
0 | 1197 } |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6795
diff
changeset
|
1198 return new (phase->C) AddPNode(phase->C->top(), |
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6795
diff
changeset
|
1199 phase->transform(new (phase->C) CastX2PNode(base)), |
0 | 1200 phase->transform(dispX)); |
1201 } | |
1202 | |
1203 Node *CastX2PNode::Ideal(PhaseGVN *phase, bool can_reshape) { | |
1204 // convert CastX2P(AddX(x, y)) to AddP(CastX2P(x), y) if y fits in an int | |
1205 int op = in(1)->Opcode(); | |
1206 Node* x; | |
1207 Node* y; | |
1208 switch (op) { | |
1209 case Op_SubX: | |
1210 x = in(1)->in(1); | |
995
ddd6f1182ae3
6883468: C2 compiler enters infinite loop in PhaseIterGVN::transform
kvn
parents:
844
diff
changeset
|
1211 // Avoid ideal transformations ping-pong between this and AddP for raw pointers. |
ddd6f1182ae3
6883468: C2 compiler enters infinite loop in PhaseIterGVN::transform
kvn
parents:
844
diff
changeset
|
1212 if (phase->find_intptr_t_con(x, -1) == 0) |
ddd6f1182ae3
6883468: C2 compiler enters infinite loop in PhaseIterGVN::transform
kvn
parents:
844
diff
changeset
|
1213 break; |
0 | 1214 y = in(1)->in(2); |
1215 if (fits_in_int(phase->type(y), true)) { | |
1216 return addP_of_X2P(phase, x, y, true); | |
1217 } | |
1218 break; | |
1219 case Op_AddX: | |
1220 x = in(1)->in(1); | |
1221 y = in(1)->in(2); | |
1222 if (fits_in_int(phase->type(y))) { | |
1223 return addP_of_X2P(phase, x, y); | |
1224 } | |
1225 if (fits_in_int(phase->type(x))) { | |
1226 return addP_of_X2P(phase, y, x); | |
1227 } | |
1228 break; | |
1229 } | |
1230 return NULL; | |
1231 } | |
1232 | |
1233 //------------------------------Identity--------------------------------------- | |
1234 Node *CastX2PNode::Identity( PhaseTransform *phase ) { | |
1235 if (in(1)->Opcode() == Op_CastP2X) return in(1)->in(1); | |
1236 return this; | |
1237 } | |
1238 | |
1239 //============================================================================= | |
1240 //------------------------------Value------------------------------------------ | |
1241 const Type *CastP2XNode::Value( PhaseTransform *phase ) const { | |
1242 const Type* t = phase->type(in(1)); | |
5901 | 1243 if (t == Type::TOP) return Type::TOP; |
0 | 1244 if (t->base() == Type::RawPtr && t->singleton()) { |
1245 uintptr_t bits = (uintptr_t) t->is_rawptr()->get_con(); | |
1246 return TypeX::make(bits); | |
1247 } | |
1248 return CastP2XNode::bottom_type(); | |
1249 } | |
1250 | |
1251 Node *CastP2XNode::Ideal(PhaseGVN *phase, bool can_reshape) { | |
1252 return (in(0) && remove_dead_region(phase, can_reshape)) ? this : NULL; | |
1253 } | |
1254 | |
1255 //------------------------------Identity--------------------------------------- | |
1256 Node *CastP2XNode::Identity( PhaseTransform *phase ) { | |
1257 if (in(1)->Opcode() == Op_CastX2P) return in(1)->in(1); | |
1258 return this; | |
1259 } | |
1260 | |
1261 | |
1262 //============================================================================= | |
1263 //------------------------------Identity--------------------------------------- | |
1264 // Remove redundant roundings | |
1265 Node *RoundFloatNode::Identity( PhaseTransform *phase ) { | |
1266 assert(Matcher::strict_fp_requires_explicit_rounding, "should only generate for Intel"); | |
1267 // Do not round constants | |
1268 if (phase->type(in(1))->base() == Type::FloatCon) return in(1); | |
1269 int op = in(1)->Opcode(); | |
1270 // Redundant rounding | |
1271 if( op == Op_RoundFloat ) return in(1); | |
1272 // Already rounded | |
1273 if( op == Op_Parm ) return in(1); | |
1274 if( op == Op_LoadF ) return in(1); | |
1275 return this; | |
1276 } | |
1277 | |
1278 //------------------------------Value------------------------------------------ | |
1279 const Type *RoundFloatNode::Value( PhaseTransform *phase ) const { | |
1280 return phase->type( in(1) ); | |
1281 } | |
1282 | |
1283 //============================================================================= | |
1284 //------------------------------Identity--------------------------------------- | |
1285 // Remove redundant roundings. Incoming arguments are already rounded. | |
1286 Node *RoundDoubleNode::Identity( PhaseTransform *phase ) { | |
1287 assert(Matcher::strict_fp_requires_explicit_rounding, "should only generate for Intel"); | |
1288 // Do not round constants | |
1289 if (phase->type(in(1))->base() == Type::DoubleCon) return in(1); | |
1290 int op = in(1)->Opcode(); | |
1291 // Redundant rounding | |
1292 if( op == Op_RoundDouble ) return in(1); | |
1293 // Already rounded | |
1294 if( op == Op_Parm ) return in(1); | |
1295 if( op == Op_LoadD ) return in(1); | |
1296 if( op == Op_ConvF2D ) return in(1); | |
1297 if( op == Op_ConvI2D ) return in(1); | |
1298 return this; | |
1299 } | |
1300 | |
1301 //------------------------------Value------------------------------------------ | |
1302 const Type *RoundDoubleNode::Value( PhaseTransform *phase ) const { | |
1303 return phase->type( in(1) ); | |
1304 } | |
1305 | |
1306 | |
1307 //============================================================================= | |
1308 // Do not allow value-numbering | |
1309 uint Opaque1Node::hash() const { return NO_HASH; } | |
1310 uint Opaque1Node::cmp( const Node &n ) const { | |
1311 return (&n == this); // Always fail except on self | |
1312 } | |
1313 | |
1314 //------------------------------Identity--------------------------------------- | |
1315 // If _major_progress, then more loop optimizations follow. Do NOT remove | |
1316 // the opaque Node until no more loop ops can happen. Note the timing of | |
1317 // _major_progress; it's set in the major loop optimizations THEN comes the | |
1318 // call to IterGVN and any chance of hitting this code. Hence there's no | |
1319 // phase-ordering problem with stripping Opaque1 in IGVN followed by some | |
1320 // more loop optimizations that require it. | |
1321 Node *Opaque1Node::Identity( PhaseTransform *phase ) { | |
1322 return phase->C->major_progress() ? this : in(1); | |
1323 } | |
1324 | |
1325 //============================================================================= | |
1326 // A node to prevent unwanted optimizations. Allows constant folding. Stops | |
1327 // value-numbering, most Ideal calls or Identity functions. This Node is | |
1328 // specifically designed to prevent the pre-increment value of a loop trip | |
1329 // counter from being live out of the bottom of the loop (hence causing the | |
1330 // pre- and post-increment values both being live and thus requiring an extra | |
1331 // temp register and an extra move). If we "accidentally" optimize through | |
1332 // this kind of a Node, we'll get slightly pessimal, but correct, code. Thus | |
1333 // it's OK to be slightly sloppy on optimizations here. | |
1334 | |
1335 // Do not allow value-numbering | |
1336 uint Opaque2Node::hash() const { return NO_HASH; } | |
1337 uint Opaque2Node::cmp( const Node &n ) const { | |
1338 return (&n == this); // Always fail except on self | |
1339 } | |
1340 | |
1341 | |
1342 //------------------------------Value------------------------------------------ | |
1343 const Type *MoveL2DNode::Value( PhaseTransform *phase ) const { | |
1344 const Type *t = phase->type( in(1) ); | |
1345 if( t == Type::TOP ) return Type::TOP; | |
1346 const TypeLong *tl = t->is_long(); | |
1347 if( !tl->is_con() ) return bottom_type(); | |
1348 JavaValue v; | |
1349 v.set_jlong(tl->get_con()); | |
1350 return TypeD::make( v.get_jdouble() ); | |
1351 } | |
1352 | |
1353 //------------------------------Value------------------------------------------ | |
1354 const Type *MoveI2FNode::Value( PhaseTransform *phase ) const { | |
1355 const Type *t = phase->type( in(1) ); | |
1356 if( t == Type::TOP ) return Type::TOP; | |
1357 const TypeInt *ti = t->is_int(); | |
1358 if( !ti->is_con() ) return bottom_type(); | |
1359 JavaValue v; | |
1360 v.set_jint(ti->get_con()); | |
1361 return TypeF::make( v.get_jfloat() ); | |
1362 } | |
1363 | |
1364 //------------------------------Value------------------------------------------ | |
1365 const Type *MoveF2INode::Value( PhaseTransform *phase ) const { | |
1366 const Type *t = phase->type( in(1) ); | |
1367 if( t == Type::TOP ) return Type::TOP; | |
1368 if( t == Type::FLOAT ) return TypeInt::INT; | |
1369 const TypeF *tf = t->is_float_constant(); | |
1370 JavaValue v; | |
1371 v.set_jfloat(tf->getf()); | |
1372 return TypeInt::make( v.get_jint() ); | |
1373 } | |
1374 | |
1375 //------------------------------Value------------------------------------------ | |
1376 const Type *MoveD2LNode::Value( PhaseTransform *phase ) const { | |
1377 const Type *t = phase->type( in(1) ); | |
1378 if( t == Type::TOP ) return Type::TOP; | |
1379 if( t == Type::DOUBLE ) return TypeLong::LONG; | |
1380 const TypeD *td = t->is_double_constant(); | |
1381 JavaValue v; | |
1382 v.set_jdouble(td->getd()); | |
1383 return TypeLong::make( v.get_jlong() ); | |
1384 } | |
775
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1385 |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1386 //------------------------------Value------------------------------------------ |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1387 const Type* CountLeadingZerosINode::Value(PhaseTransform* phase) const { |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1388 const Type* t = phase->type(in(1)); |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1389 if (t == Type::TOP) return Type::TOP; |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1390 const TypeInt* ti = t->isa_int(); |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1391 if (ti && ti->is_con()) { |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1392 jint i = ti->get_con(); |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1393 // HD, Figure 5-6 |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1394 if (i == 0) |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1395 return TypeInt::make(BitsPerInt); |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1396 int n = 1; |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1397 unsigned int x = i; |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1398 if (x >> 16 == 0) { n += 16; x <<= 16; } |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1399 if (x >> 24 == 0) { n += 8; x <<= 8; } |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1400 if (x >> 28 == 0) { n += 4; x <<= 4; } |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1401 if (x >> 30 == 0) { n += 2; x <<= 2; } |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1402 n -= x >> 31; |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1403 return TypeInt::make(n); |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1404 } |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1405 return TypeInt::INT; |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1406 } |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1407 |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1408 //------------------------------Value------------------------------------------ |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1409 const Type* CountLeadingZerosLNode::Value(PhaseTransform* phase) const { |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1410 const Type* t = phase->type(in(1)); |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1411 if (t == Type::TOP) return Type::TOP; |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1412 const TypeLong* tl = t->isa_long(); |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1413 if (tl && tl->is_con()) { |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1414 jlong l = tl->get_con(); |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1415 // HD, Figure 5-6 |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1416 if (l == 0) |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1417 return TypeInt::make(BitsPerLong); |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1418 int n = 1; |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1419 unsigned int x = (((julong) l) >> 32); |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1420 if (x == 0) { n += 32; x = (int) l; } |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1421 if (x >> 16 == 0) { n += 16; x <<= 16; } |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1422 if (x >> 24 == 0) { n += 8; x <<= 8; } |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1423 if (x >> 28 == 0) { n += 4; x <<= 4; } |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1424 if (x >> 30 == 0) { n += 2; x <<= 2; } |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1425 n -= x >> 31; |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1426 return TypeInt::make(n); |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1427 } |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1428 return TypeInt::INT; |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1429 } |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1430 |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1431 //------------------------------Value------------------------------------------ |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1432 const Type* CountTrailingZerosINode::Value(PhaseTransform* phase) const { |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1433 const Type* t = phase->type(in(1)); |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1434 if (t == Type::TOP) return Type::TOP; |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1435 const TypeInt* ti = t->isa_int(); |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1436 if (ti && ti->is_con()) { |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1437 jint i = ti->get_con(); |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1438 // HD, Figure 5-14 |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1439 int y; |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1440 if (i == 0) |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1441 return TypeInt::make(BitsPerInt); |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1442 int n = 31; |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1443 y = i << 16; if (y != 0) { n = n - 16; i = y; } |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1444 y = i << 8; if (y != 0) { n = n - 8; i = y; } |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1445 y = i << 4; if (y != 0) { n = n - 4; i = y; } |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1446 y = i << 2; if (y != 0) { n = n - 2; i = y; } |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1447 y = i << 1; if (y != 0) { n = n - 1; } |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1448 return TypeInt::make(n); |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1449 } |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1450 return TypeInt::INT; |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1451 } |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1452 |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1453 //------------------------------Value------------------------------------------ |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1454 const Type* CountTrailingZerosLNode::Value(PhaseTransform* phase) const { |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1455 const Type* t = phase->type(in(1)); |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1456 if (t == Type::TOP) return Type::TOP; |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1457 const TypeLong* tl = t->isa_long(); |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1458 if (tl && tl->is_con()) { |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1459 jlong l = tl->get_con(); |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1460 // HD, Figure 5-14 |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1461 int x, y; |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1462 if (l == 0) |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1463 return TypeInt::make(BitsPerLong); |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1464 int n = 63; |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1465 y = (int) l; if (y != 0) { n = n - 32; x = y; } else x = (((julong) l) >> 32); |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1466 y = x << 16; if (y != 0) { n = n - 16; x = y; } |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1467 y = x << 8; if (y != 0) { n = n - 8; x = y; } |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1468 y = x << 4; if (y != 0) { n = n - 4; x = y; } |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1469 y = x << 2; if (y != 0) { n = n - 2; x = y; } |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1470 y = x << 1; if (y != 0) { n = n - 1; } |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1471 return TypeInt::make(n); |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1472 } |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1473 return TypeInt::INT; |
93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
755
diff
changeset
|
1474 } |