Thu, 07 Oct 2010 21:40:55 -0700
6980792: Crash "exception happened outside interpreter, nmethods and vtable stubs (1)"
Reviewed-by: kvn
1 /*
2 * Copyright (c) 1997, 2006, 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 */
25 // Portions of code courtesy of Clifford Click
27 class PhaseTransform;
29 //------------------------------AddNode----------------------------------------
30 // Classic Add functionality. This covers all the usual 'add' behaviors for
31 // an algebraic ring. Add-integer, add-float, add-double, and binary-or are
32 // all inherited from this class. The various identity values are supplied
33 // by virtual functions.
34 class AddNode : public Node {
35 virtual uint hash() const;
36 public:
37 AddNode( Node *in1, Node *in2 ) : Node(0,in1,in2) {
38 init_class_id(Class_Add);
39 }
41 // Handle algebraic identities here. If we have an identity, return the Node
42 // we are equivalent to. We look for "add of zero" as an identity.
43 virtual Node *Identity( PhaseTransform *phase );
45 // We also canonicalize the Node, moving constants to the right input,
46 // and flatten expressions (so that 1+x+2 becomes x+3).
47 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
49 // Compute a new Type for this node. Basically we just do the pre-check,
50 // then call the virtual add() to set the type.
51 virtual const Type *Value( PhaseTransform *phase ) const;
53 // Check if this addition involves the additive identity
54 virtual const Type *add_of_identity( const Type *t1, const Type *t2 ) const;
56 // Supplied function returns the sum of the inputs.
57 // This also type-checks the inputs for sanity. Guaranteed never to
58 // be passed a TOP or BOTTOM type, these are filtered out by a pre-check.
59 virtual const Type *add_ring( const Type *, const Type * ) const = 0;
61 // Supplied function to return the additive identity type
62 virtual const Type *add_id() const = 0;
64 };
66 //------------------------------AddINode---------------------------------------
67 // Add 2 integers
68 class AddINode : public AddNode {
69 public:
70 AddINode( Node *in1, Node *in2 ) : AddNode(in1,in2) {}
71 virtual int Opcode() const;
72 virtual const Type *add_ring( const Type *, const Type * ) const;
73 virtual const Type *add_id() const { return TypeInt::ZERO; }
74 virtual const Type *bottom_type() const { return TypeInt::INT; }
75 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
76 virtual Node *Identity( PhaseTransform *phase );
77 virtual uint ideal_reg() const { return Op_RegI; }
78 };
80 //------------------------------AddLNode---------------------------------------
81 // Add 2 longs
82 class AddLNode : public AddNode {
83 public:
84 AddLNode( Node *in1, Node *in2 ) : AddNode(in1,in2) {}
85 virtual int Opcode() const;
86 virtual const Type *add_ring( const Type *, const Type * ) const;
87 virtual const Type *add_id() const { return TypeLong::ZERO; }
88 virtual const Type *bottom_type() const { return TypeLong::LONG; }
89 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
90 virtual Node *Identity( PhaseTransform *phase );
91 virtual uint ideal_reg() const { return Op_RegL; }
92 };
94 //------------------------------AddFNode---------------------------------------
95 // Add 2 floats
96 class AddFNode : public AddNode {
97 public:
98 AddFNode( Node *in1, Node *in2 ) : AddNode(in1,in2) {}
99 virtual int Opcode() const;
100 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
101 virtual const Type *add_of_identity( const Type *t1, const Type *t2 ) const;
102 virtual const Type *add_ring( const Type *, const Type * ) const;
103 virtual const Type *add_id() const { return TypeF::ZERO; }
104 virtual const Type *bottom_type() const { return Type::FLOAT; }
105 virtual Node *Identity( PhaseTransform *phase ) { return this; }
106 virtual uint ideal_reg() const { return Op_RegF; }
107 };
109 //------------------------------AddDNode---------------------------------------
110 // Add 2 doubles
111 class AddDNode : public AddNode {
112 public:
113 AddDNode( Node *in1, Node *in2 ) : AddNode(in1,in2) {}
114 virtual int Opcode() const;
115 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
116 virtual const Type *add_of_identity( const Type *t1, const Type *t2 ) const;
117 virtual const Type *add_ring( const Type *, const Type * ) const;
118 virtual const Type *add_id() const { return TypeD::ZERO; }
119 virtual const Type *bottom_type() const { return Type::DOUBLE; }
120 virtual Node *Identity( PhaseTransform *phase ) { return this; }
121 virtual uint ideal_reg() const { return Op_RegD; }
122 };
124 //------------------------------AddPNode---------------------------------------
125 // Add pointer plus integer to get pointer. NOT commutative, really.
126 // So not really an AddNode. Lives here, because people associate it with
127 // an add.
128 class AddPNode : public Node {
129 public:
130 enum { Control, // When is it safe to do this add?
131 Base, // Base oop, for GC purposes
132 Address, // Actually address, derived from base
133 Offset } ; // Offset added to address
134 AddPNode( Node *base, Node *ptr, Node *off ) : Node(0,base,ptr,off) {
135 init_class_id(Class_AddP);
136 }
137 virtual int Opcode() const;
138 virtual Node *Identity( PhaseTransform *phase );
139 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
140 virtual const Type *Value( PhaseTransform *phase ) const;
141 virtual const Type *bottom_type() const;
142 virtual uint ideal_reg() const { return Op_RegP; }
143 Node *base_node() { assert( req() > Base, "Missing base"); return in(Base); }
144 static Node* Ideal_base_and_offset(Node* ptr, PhaseTransform* phase,
145 // second return value:
146 intptr_t& offset);
148 // Collect the AddP offset values into the elements array, giving up
149 // if there are more than length.
150 int unpack_offsets(Node* elements[], int length);
152 // Do not match base-ptr edge
153 virtual uint match_edge(uint idx) const;
154 };
156 //------------------------------OrINode----------------------------------------
157 // Logically OR 2 integers. Included with the ADD nodes because it inherits
158 // all the behavior of addition on a ring.
159 class OrINode : public AddNode {
160 public:
161 OrINode( Node *in1, Node *in2 ) : AddNode(in1,in2) {}
162 virtual int Opcode() const;
163 virtual const Type *add_ring( const Type *, const Type * ) const;
164 virtual const Type *add_id() const { return TypeInt::ZERO; }
165 virtual const Type *bottom_type() const { return TypeInt::INT; }
166 virtual Node *Identity( PhaseTransform *phase );
167 virtual uint ideal_reg() const { return Op_RegI; }
168 };
170 //------------------------------OrLNode----------------------------------------
171 // Logically OR 2 longs. Included with the ADD nodes because it inherits
172 // all the behavior of addition on a ring.
173 class OrLNode : public AddNode {
174 public:
175 OrLNode( Node *in1, Node *in2 ) : AddNode(in1,in2) {}
176 virtual int Opcode() const;
177 virtual const Type *add_ring( const Type *, const Type * ) const;
178 virtual const Type *add_id() const { return TypeLong::ZERO; }
179 virtual const Type *bottom_type() const { return TypeLong::LONG; }
180 virtual Node *Identity( PhaseTransform *phase );
181 virtual uint ideal_reg() const { return Op_RegL; }
182 };
184 //------------------------------XorINode---------------------------------------
185 // XOR'ing 2 integers
186 class XorINode : public AddNode {
187 public:
188 XorINode( Node *in1, Node *in2 ) : AddNode(in1,in2) {}
189 virtual int Opcode() const;
190 virtual const Type *add_ring( const Type *, const Type * ) const;
191 virtual const Type *add_id() const { return TypeInt::ZERO; }
192 virtual const Type *bottom_type() const { return TypeInt::INT; }
193 virtual uint ideal_reg() const { return Op_RegI; }
194 };
196 //------------------------------XorINode---------------------------------------
197 // XOR'ing 2 longs
198 class XorLNode : public AddNode {
199 public:
200 XorLNode( Node *in1, Node *in2 ) : AddNode(in1,in2) {}
201 virtual int Opcode() const;
202 virtual const Type *add_ring( const Type *, const Type * ) const;
203 virtual const Type *add_id() const { return TypeLong::ZERO; }
204 virtual const Type *bottom_type() const { return TypeLong::LONG; }
205 virtual uint ideal_reg() const { return Op_RegL; }
206 };
208 //------------------------------MaxNode----------------------------------------
209 // Max (or min) of 2 values. Included with the ADD nodes because it inherits
210 // all the behavior of addition on a ring. Only new thing is that we allow
211 // 2 equal inputs to be equal.
212 class MaxNode : public AddNode {
213 public:
214 MaxNode( Node *in1, Node *in2 ) : AddNode(in1,in2) {}
215 virtual int Opcode() const = 0;
216 };
218 //------------------------------MaxINode---------------------------------------
219 // Maximum of 2 integers. Included with the ADD nodes because it inherits
220 // all the behavior of addition on a ring.
221 class MaxINode : public MaxNode {
222 public:
223 MaxINode( Node *in1, Node *in2 ) : MaxNode(in1,in2) {}
224 virtual int Opcode() const;
225 virtual const Type *add_ring( const Type *, const Type * ) const;
226 virtual const Type *add_id() const { return TypeInt::make(min_jint); }
227 virtual const Type *bottom_type() const { return TypeInt::INT; }
228 virtual uint ideal_reg() const { return Op_RegI; }
229 };
231 //------------------------------MinINode---------------------------------------
232 // MINimum of 2 integers. Included with the ADD nodes because it inherits
233 // all the behavior of addition on a ring.
234 class MinINode : public MaxNode {
235 public:
236 MinINode( Node *in1, Node *in2 ) : MaxNode(in1,in2) {}
237 virtual int Opcode() const;
238 virtual const Type *add_ring( const Type *, const Type * ) const;
239 virtual const Type *add_id() const { return TypeInt::make(max_jint); }
240 virtual const Type *bottom_type() const { return TypeInt::INT; }
241 virtual uint ideal_reg() const { return Op_RegI; }
242 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
243 };