author | vromero |
Mon, 08 Oct 2018 06:52:41 -0700 | |
changeset 52038 | 957de5be48bc |
parent 47216 | 71c04702a3d5 |
child 53244 | 9807daeb47c4 |
permissions | -rw-r--r-- |
23528 | 1 |
/* |
2 |
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
22 |
* |
|
23 |
*/ |
|
24 |
||
25 |
#ifndef SHARE_VM_OPTO_CASTNODE_HPP |
|
26 |
#define SHARE_VM_OPTO_CASTNODE_HPP |
|
27 |
||
28 |
#include "opto/node.hpp" |
|
29 |
#include "opto/opcodes.hpp" |
|
30 |
||
31 |
||
32 |
//------------------------------ConstraintCastNode----------------------------- |
|
33 |
// cast to a different range |
|
34 |
class ConstraintCastNode: public TypeNode { |
|
35545
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
30300
diff
changeset
|
35 |
protected: |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
30300
diff
changeset
|
36 |
// Can this node be removed post CCP or does it carry a required dependency? |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
30300
diff
changeset
|
37 |
const bool _carry_dependency; |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
30300
diff
changeset
|
38 |
virtual uint cmp( const Node &n ) const; |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
30300
diff
changeset
|
39 |
virtual uint size_of() const; |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
30300
diff
changeset
|
40 |
|
23528 | 41 |
public: |
35545
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
30300
diff
changeset
|
42 |
ConstraintCastNode(Node *n, const Type *t, bool carry_dependency) |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
30300
diff
changeset
|
43 |
: TypeNode(t,2), _carry_dependency(carry_dependency) { |
23528 | 44 |
init_class_id(Class_ConstraintCast); |
45 |
init_req(1, n); |
|
46 |
} |
|
35551
36ef3841fb34
8146629: Make phase->is_IterGVN() accessible from Node::Identity and Node::Value
thartmann
parents:
35549
diff
changeset
|
47 |
virtual Node* Identity(PhaseGVN* phase); |
36ef3841fb34
8146629: Make phase->is_IterGVN() accessible from Node::Identity and Node::Value
thartmann
parents:
35549
diff
changeset
|
48 |
virtual const Type* Value(PhaseGVN* phase) const; |
23528 | 49 |
virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); |
50 |
virtual int Opcode() const; |
|
51 |
virtual uint ideal_reg() const = 0; |
|
35545
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
30300
diff
changeset
|
52 |
virtual bool depends_only_on_test() const { return !_carry_dependency; } |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
30300
diff
changeset
|
53 |
bool carry_dependency() const { return _carry_dependency; } |
46532
7c122c98399d
8181741: C2 compilation fails with "assert(i<_max) failed: oob"
thartmann
parents:
46525
diff
changeset
|
54 |
TypeNode* dominating_cast(PhaseGVN* gvn, PhaseTransform* pt) const; |
35545
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
30300
diff
changeset
|
55 |
static Node* make_cast(int opcode, Node* c, Node *n, const Type *t, bool carry_dependency); |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
30300
diff
changeset
|
56 |
|
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
30300
diff
changeset
|
57 |
#ifndef PRODUCT |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
30300
diff
changeset
|
58 |
virtual void dump_spec(outputStream *st) const; |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
30300
diff
changeset
|
59 |
#endif |
23528 | 60 |
}; |
61 |
||
62 |
//------------------------------CastIINode------------------------------------- |
|
63 |
// cast integer to integer (different range) |
|
64 |
class CastIINode: public ConstraintCastNode { |
|
35574
2b25eb88c8d6
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
35551
diff
changeset
|
65 |
protected: |
2b25eb88c8d6
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
35551
diff
changeset
|
66 |
// Is this node dependent on a range check? |
2b25eb88c8d6
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
35551
diff
changeset
|
67 |
const bool _range_check_dependency; |
2b25eb88c8d6
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
35551
diff
changeset
|
68 |
virtual uint cmp(const Node &n) const; |
2b25eb88c8d6
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
35551
diff
changeset
|
69 |
virtual uint size_of() const; |
2b25eb88c8d6
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
35551
diff
changeset
|
70 |
|
23528 | 71 |
public: |
35574
2b25eb88c8d6
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
35551
diff
changeset
|
72 |
CastIINode(Node* n, const Type* t, bool carry_dependency = false, bool range_check_dependency = false) |
2b25eb88c8d6
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
35551
diff
changeset
|
73 |
: ConstraintCastNode(n, t, carry_dependency), _range_check_dependency(range_check_dependency) { |
2b25eb88c8d6
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
35551
diff
changeset
|
74 |
init_class_id(Class_CastII); |
2b25eb88c8d6
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
35551
diff
changeset
|
75 |
} |
23528 | 76 |
virtual int Opcode() const; |
77 |
virtual uint ideal_reg() const { return Op_RegI; } |
|
35551
36ef3841fb34
8146629: Make phase->is_IterGVN() accessible from Node::Identity and Node::Value
thartmann
parents:
35549
diff
changeset
|
78 |
virtual const Type* Value(PhaseGVN* phase) const; |
35549
3415401a6b6e
8145322: Code generated from unsafe loops can be slightly improved
roland
parents:
35545
diff
changeset
|
79 |
virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); |
35574
2b25eb88c8d6
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
35551
diff
changeset
|
80 |
const bool has_range_check() { |
2b25eb88c8d6
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
35551
diff
changeset
|
81 |
#ifdef _LP64 |
2b25eb88c8d6
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
35551
diff
changeset
|
82 |
return _range_check_dependency; |
2b25eb88c8d6
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
35551
diff
changeset
|
83 |
#else |
2b25eb88c8d6
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
35551
diff
changeset
|
84 |
assert(!_range_check_dependency, "Should not have range check dependency"); |
2b25eb88c8d6
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
35551
diff
changeset
|
85 |
return false; |
2b25eb88c8d6
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
35551
diff
changeset
|
86 |
#endif |
2b25eb88c8d6
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
35551
diff
changeset
|
87 |
} |
2b25eb88c8d6
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
35551
diff
changeset
|
88 |
|
2b25eb88c8d6
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
35551
diff
changeset
|
89 |
#ifndef PRODUCT |
2b25eb88c8d6
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
35551
diff
changeset
|
90 |
virtual void dump_spec(outputStream* st) const; |
2b25eb88c8d6
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
35551
diff
changeset
|
91 |
#endif |
23528 | 92 |
}; |
93 |
||
94 |
//------------------------------CastPPNode------------------------------------- |
|
95 |
// cast pointer to pointer (different type) |
|
96 |
class CastPPNode: public ConstraintCastNode { |
|
97 |
public: |
|
35545
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
30300
diff
changeset
|
98 |
CastPPNode (Node *n, const Type *t, bool carry_dependency = false) |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
30300
diff
changeset
|
99 |
: ConstraintCastNode(n, t, carry_dependency) { |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
30300
diff
changeset
|
100 |
} |
23528 | 101 |
virtual int Opcode() const; |
102 |
virtual uint ideal_reg() const { return Op_RegP; } |
|
103 |
}; |
|
104 |
||
105 |
//------------------------------CheckCastPPNode-------------------------------- |
|
106 |
// for _checkcast, cast pointer to pointer (different type), without JOIN, |
|
35545
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
30300
diff
changeset
|
107 |
class CheckCastPPNode: public ConstraintCastNode { |
23528 | 108 |
public: |
35545
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
30300
diff
changeset
|
109 |
CheckCastPPNode(Node *c, Node *n, const Type *t, bool carry_dependency = false) |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
30300
diff
changeset
|
110 |
: ConstraintCastNode(n, t, carry_dependency) { |
23528 | 111 |
init_class_id(Class_CheckCastPP); |
112 |
init_req(0, c); |
|
113 |
} |
|
114 |
||
35551
36ef3841fb34
8146629: Make phase->is_IterGVN() accessible from Node::Identity and Node::Value
thartmann
parents:
35549
diff
changeset
|
115 |
virtual Node* Identity(PhaseGVN* phase); |
36ef3841fb34
8146629: Make phase->is_IterGVN() accessible from Node::Identity and Node::Value
thartmann
parents:
35549
diff
changeset
|
116 |
virtual const Type* Value(PhaseGVN* phase) const; |
23528 | 117 |
virtual int Opcode() const; |
118 |
virtual uint ideal_reg() const { return Op_RegP; } |
|
46525
3a5c833a43de
8176506: C2: loop unswitching and unsafe accesses cause crash
roland
parents:
35574
diff
changeset
|
119 |
bool depends_only_on_test() const { return !type()->isa_rawptr() && ConstraintCastNode::depends_only_on_test(); } |
3a5c833a43de
8176506: C2: loop unswitching and unsafe accesses cause crash
roland
parents:
35574
diff
changeset
|
120 |
}; |
23528 | 121 |
|
122 |
||
123 |
//------------------------------CastX2PNode------------------------------------- |
|
124 |
// convert a machine-pointer-sized integer to a raw pointer |
|
125 |
class CastX2PNode : public Node { |
|
126 |
public: |
|
127 |
CastX2PNode( Node *n ) : Node(NULL, n) {} |
|
128 |
virtual int Opcode() const; |
|
35551
36ef3841fb34
8146629: Make phase->is_IterGVN() accessible from Node::Identity and Node::Value
thartmann
parents:
35549
diff
changeset
|
129 |
virtual const Type* Value(PhaseGVN* phase) const; |
23528 | 130 |
virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); |
35551
36ef3841fb34
8146629: Make phase->is_IterGVN() accessible from Node::Identity and Node::Value
thartmann
parents:
35549
diff
changeset
|
131 |
virtual Node* Identity(PhaseGVN* phase); |
23528 | 132 |
virtual uint ideal_reg() const { return Op_RegP; } |
133 |
virtual const Type *bottom_type() const { return TypeRawPtr::BOTTOM; } |
|
134 |
}; |
|
135 |
||
136 |
//------------------------------CastP2XNode------------------------------------- |
|
137 |
// Used in both 32-bit and 64-bit land. |
|
138 |
// Used for card-marks and unsafe pointer math. |
|
139 |
class CastP2XNode : public Node { |
|
140 |
public: |
|
141 |
CastP2XNode( Node *ctrl, Node *n ) : Node(ctrl, n) {} |
|
142 |
virtual int Opcode() const; |
|
35551
36ef3841fb34
8146629: Make phase->is_IterGVN() accessible from Node::Identity and Node::Value
thartmann
parents:
35549
diff
changeset
|
143 |
virtual const Type* Value(PhaseGVN* phase) const; |
23528 | 144 |
virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); |
35551
36ef3841fb34
8146629: Make phase->is_IterGVN() accessible from Node::Identity and Node::Value
thartmann
parents:
35549
diff
changeset
|
145 |
virtual Node* Identity(PhaseGVN* phase); |
23528 | 146 |
virtual uint ideal_reg() const { return Op_RegX; } |
147 |
virtual const Type *bottom_type() const { return TypeX_X; } |
|
148 |
// Return false to keep node from moving away from an associated card mark. |
|
149 |
virtual bool depends_only_on_test() const { return false; } |
|
150 |
}; |
|
151 |
||
152 |
||
153 |
||
154 |
#endif // SHARE_VM_OPTO_CASTNODE_HPP |